diff --git a/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx b/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx index b7d5a7e490..9d78cbd062 100644 --- a/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx @@ -28,7 +28,7 @@ const hostControlLabels = { export const DialogSettings: React.FC = () => { 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 }; @@ -83,7 +83,7 @@ export const DialogSettings: React.FC = () => {
{hostedControl()}
- +
) : ( diff --git a/Composer/packages/client/src/store/index.tsx b/Composer/packages/client/src/store/index.tsx index 5127138269..b7f064b37b 100644 --- a/Composer/packages/client/src/store/index.tsx +++ b/Composer/packages/client/src/store/index.tsx @@ -93,6 +93,7 @@ export const initialState: State = { showAddSkillDialogModal: false, isEnvSettingUpdated: false, settings: {}, + settingsSchemas: {}, currentUser: { token: null, sessionExpired: false, diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index ae90331bd7..a965a2dd8f 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -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; @@ -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; diff --git a/Composer/packages/client/src/store/types.ts b/Composer/packages/client/src/store/types.ts index 5265fa52c5..6ffe1c232c 100644 --- a/Composer/packages/client/src/store/types.ts +++ b/Composer/packages/client/src/store/types.ts @@ -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; diff --git a/Composer/packages/lib/bot-deploy/src/botProjectDeploy.ts b/Composer/packages/lib/bot-deploy/src/botProjectDeploy.ts index 080184aaf5..61d3f6314b 100644 --- a/Composer/packages/lib/bot-deploy/src/botProjectDeploy.ts +++ b/Composer/packages/lib/bot-deploy/src/botProjectDeploy.ts @@ -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; @@ -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; @@ -445,7 +445,7 @@ export class BotProjectDeploy { endpoint: luisEndpoint, endpointKey: luisEndpointKey, authoringRegion: luisAuthoringRegion, - authoringKey: luisAuthoringRegion, + authoringKey: luisAuthoringKey, }; Object.assign(luisConfig, luisAppIds); diff --git a/Composer/packages/server/src/models/bot/botProject.ts b/Composer/packages/server/src/models/bot/botProject.ts index 63529da519..2f7eb603aa 100644 --- a/Composer/packages/server/src/models/bot/botProject.ts +++ b/Composer/packages/server/src/models/bot/botProject.ts @@ -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'; @@ -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; @@ -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); } @@ -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, diff --git a/Composer/packages/server/src/models/settings/defaultSettingManager.ts b/Composer/packages/server/src/models/settings/defaultSettingManager.ts index 1d8f13d652..9a600ce516 100644 --- a/Composer/packages/server/src/models/settings/defaultSettingManager.ts +++ b/Composer/packages/server/src/models/settings/defaultSettingManager.ts @@ -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 => { diff --git a/Composer/packages/server/src/models/settings/interface.ts b/Composer/packages/server/src/models/settings/interface.ts index 869b1b0f9d..75e1ee5d07 100644 --- a/Composer/packages/server/src/models/settings/interface.ts +++ b/Composer/packages/server/src/models/settings/interface.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - +import { JSONSchema7 } from '@bfc/plugin-loader'; export const OBFUSCATED_VALUE = '*****'; export interface ISettingManager { @@ -8,3 +8,105 @@ export interface ISettingManager { set(slot: string, settings: any): Promise; 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, + }; +}; diff --git a/Composer/plugins/azureFunctionsPublish/src/schema.ts b/Composer/plugins/azureFunctionsPublish/src/schema.ts index 0e0cab19b3..6d478279bf 100644 --- a/Composer/plugins/azureFunctionsPublish/src/schema.ts +++ b/Composer/plugins/azureFunctionsPublish/src/schema.ts @@ -97,7 +97,7 @@ const schema: JSONSchema7 = { required: ['MicrosoftAppId', 'MicrosoftAppPassword'], }, }, - required: ['subscriptionID', 'publishName', 'provision', 'accessToken'], + required: ['subscriptionID', 'name', 'settings', 'accessToken'], default: { accessToken: '', name: '', diff --git a/Composer/plugins/azurePublish/src/schema.ts b/Composer/plugins/azurePublish/src/schema.ts index 0f5fec91b0..a89e55a7de 100644 --- a/Composer/plugins/azurePublish/src/schema.ts +++ b/Composer/plugins/azurePublish/src/schema.ts @@ -97,7 +97,7 @@ const schema: JSONSchema7 = { required: ['MicrosoftAppId', 'MicrosoftAppPassword'], }, }, - required: ['subscriptionID', 'publishName', 'provision', 'accessToken'], + required: ['subscriptionID', 'name', 'settings', 'accessToken'], default: { accessToken: '', name: '',