Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const hostControlLabels = {

export const DialogSettings: React.FC<RouteComponentProps> = () => {
const { state, actions } = useContext(StoreContext);
const { botName, settings: origSettings, botEnvironment, projectId } = state;
const { botName, settings: origSettings, botEnvironment, projectId, settingsSchemas } = state;
const absHosted = isAbsHosted();
const { luis, MicrosoftAppPassword, MicrosoftAppId, ...settings } = origSettings;
const managedSettings = { luis, MicrosoftAppPassword, MicrosoftAppId };
Expand Down Expand Up @@ -83,7 +83,7 @@ export const DialogSettings: React.FC<RouteComponentProps> = () => {
<div css={hostedSettings}>
{hostedControl()}
<div css={settingsEditor}>
<JsonEditor value={visibleSettings} onChange={handleChange} />
<JsonEditor schema={settingsSchemas} value={visibleSettings} onChange={handleChange} />
</div>
</div>
) : (
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/client/src/store/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const initialState: State = {
showAddSkillDialogModal: false,
isEnvSettingUpdated: false,
settings: {},
settingsSchemas: {},
currentUser: {
token: null,
sessionExpired: false,
Expand Down
14 changes: 13 additions & 1 deletion Composer/packages/client/src/store/reducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@ const initLuFilesStatus = (botName: string, luFiles: LuFile[], dialogs: DialogIn
};

const getProjectSuccess: ReducerFunc = (state, { response }) => {
const { files, botName, botEnvironment, location, schemas, settings, id, locale, diagnostics } = response.data;
const {
files,
botName,
botEnvironment,
location,
schemas,
settings,
settingsSchemas,
id,
locale,
diagnostics,
} = response.data;
schemas.sdk.content = processSchema(id, schemas.sdk.content);
const { dialogs, luFiles, lgFiles, skillManifestFiles } = indexer.index(files, botName, schemas.sdk.content, locale);
state.projectId = id;
Expand All @@ -97,6 +108,7 @@ const getProjectSuccess: ReducerFunc = (state, { response }) => {
state.schemas = schemas;
state.luFiles = initLuFilesStatus(botName, luFiles, dialogs);
state.settings = settings;
state.settingsSchemas = settingsSchemas;
state.locale = locale;
state.diagnostics = diagnostics;
state.skillManifests = skillManifestFiles;
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/client/src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface State {
showAddSkillDialogModal: boolean;
isEnvSettingUpdated: boolean;
settings: DialogSetting;
settingsSchemas: JSONSchema7;
actionsSeed: any;
onCreateDialogComplete?: (dialogId: string | null) => void;
onAddSkillDialogComplete?: (dialogId: string | null) => void;
Expand Down
6 changes: 3 additions & 3 deletions Composer/packages/lib/bot-deploy/src/botProjectDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class BotProjectDeploy {
private logger: (string) => any;

// Will be assigned by create or deploy
private tenantId: string = '';
private tenantId = '';

constructor(config: BotProjectDeployConfig) {
this.subId = config.subId;
Expand Down Expand Up @@ -91,7 +91,7 @@ export class BotProjectDeploy {
if (err.body.error.details) {
const details = err.body.error.details;
let errMsg = '';
for (let detail of details) {
for (const detail of details) {
errMsg += detail.message;
}
return errMsg;
Expand Down Expand Up @@ -445,7 +445,7 @@ export class BotProjectDeploy {
endpoint: luisEndpoint,
endpointKey: luisEndpointKey,
authoringRegion: luisAuthoringRegion,
authoringKey: luisAuthoringRegion,
authoringKey: luisAuthoringKey,
};

Object.assign(luisConfig, luisAppIds);
Expand Down
5 changes: 4 additions & 1 deletion Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fs from 'fs';
import axios from 'axios';
import { autofixReferInDialog } from '@bfc/indexers';
import { getNewDesigner, FileInfo, Skill, Diagnostic } from '@bfc/shared';
import { UserIdentity, pluginLoader } from '@bfc/plugin-loader';
import { UserIdentity, pluginLoader, JSONSchema7 } from '@bfc/plugin-loader';

import { Path } from '../../utility/path';
import { copyDir } from '../../utility/storage';
Expand Down Expand Up @@ -70,6 +70,7 @@ export class BotProject {
public skills: Skill[] = [];
public diagnostics: Diagnostic[] = [];
public settingManager: ISettingManager;
public settingsSchemas: JSONSchema7;
public settings: DialogSetting | null = null;
constructor(ref: LocationRef, user?: UserIdentity) {
this.ref = ref;
Expand All @@ -81,6 +82,7 @@ export class BotProject {
this.defaultSDKSchema = JSON.parse(fs.readFileSync(Path.join(__dirname, '../../../schemas/sdk.schema'), 'utf-8'));

this.settingManager = new DefaultSettingManager(this.dir);
this.settingsSchemas = (this.settingManager as DefaultSettingManager).schema;
this.fileStorage = StorageService.getStorageClient(this.ref.storageId, user);
this.luPublisher = new LuPublisher(this.dir, this.fileStorage);
}
Expand Down Expand Up @@ -108,6 +110,7 @@ export class BotProject {
files: this.files,
location: this.dir,
schemas: this.getSchemas(),
settingsSchemas: this.settingsSchemas,
skills: this.skills,
diagnostics: this.diagnostics,
settings: this.settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@

import omit from 'lodash/omit';
import { SensitiveProperties } from '@bfc/shared';
import { UserIdentity } from '@bfc/plugin-loader';
import { UserIdentity, JSONSchema7 } from '@bfc/plugin-loader';

import { Path } from '../../utility/path';
import log from '../../logger';

import { getDefaultSchema } from './interface';
import { FileSettingManager } from './fileSettingManager';

const debug = log.extend('default-settings-manager');

export class DefaultSettingManager extends FileSettingManager {
public schema: JSONSchema7;
constructor(basePath: string, user?: UserIdentity) {
super(basePath, user);
this.schema = getDefaultSchema(this.createDefaultSettings());
}

protected createDefaultSettings = (): any => {
Expand Down
104 changes: 103 additions & 1 deletion Composer/packages/server/src/models/settings/interface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,112 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { JSONSchema7 } from '@bfc/plugin-loader';
export const OBFUSCATED_VALUE = '*****';

export interface ISettingManager {
get(slot?: string, obfuscate?: boolean): Promise<any | null>;
set(slot: string, settings: any): Promise<void>;
getFileName: () => string;
}

export const getDefaultSchema = (defaultValue): JSONSchema7 => {
return {
type: 'object',
properties: {
MicrosoftAppId: {
type: 'string',
},
MicrosoftAppPassword: {
type: 'string',
},
luis: {
type: 'object',
properties: {
name: {
type: 'string',
},
authoringKey: {
type: 'string',
},
endpointKey: {
type: 'string',
},
authoringRegion: {
type: 'string',
},
defaultLanguage: {
type: 'string',
},
environment: {
type: 'string',
},
},
},
feature: {
type: 'object',
properties: {
UseShowTypingMiddleware: {
type: 'boolean',
},
UseInspectionMiddleware: {
type: 'boolean',
},
},
},
publishTargets: {
type: 'array',
},
qna: {
type: 'object',
properties: {
knowledgebaseid: {
type: 'string',
},
endpointkey: {
type: 'string',
},
hostname: {
type: 'string',
},
},
},
telemetry: {
type: 'object',
properties: {
logPersonalInformation: {
type: 'boolean',
},
logActivities: {
type: 'boolean',
},
},
},
runtime: {
type: 'object',
properties: {
customRuntime: {
type: 'boolean',
},
path: {
type: 'string',
},
command: {
type: 'string',
},
},
},
downsampling: {
type: 'object',
properties: {
maxImbalanceRatio: {
type: 'number',
},
maxUtteranceAllowed: {
type: 'number',
},
},
},
},
default: defaultValue,
};
};
2 changes: 1 addition & 1 deletion Composer/plugins/azureFunctionsPublish/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const schema: JSONSchema7 = {
required: ['MicrosoftAppId', 'MicrosoftAppPassword'],
},
},
required: ['subscriptionID', 'publishName', 'provision', 'accessToken'],
required: ['subscriptionID', 'name', 'settings', 'accessToken'],
default: {
accessToken: '<Access token from az account get-access-token>',
name: '<unique name in your subscription>',
Expand Down
2 changes: 1 addition & 1 deletion Composer/plugins/azurePublish/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const schema: JSONSchema7 = {
required: ['MicrosoftAppId', 'MicrosoftAppPassword'],
},
},
required: ['subscriptionID', 'publishName', 'provision', 'accessToken'],
required: ['subscriptionID', 'name', 'settings', 'accessToken'],
default: {
accessToken: '<Access token from az account get-access-token>',
name: '<unique name in your subscription>',
Expand Down