From 2aa6fa0d694d7db5f54c9dd33912fed7e4009088 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:17:07 -0700 Subject: [PATCH 1/9] remove tildes --- .../client/src/Onboarding/WelcomeModal/Expanded/index.tsx | 4 ++-- Composer/packages/client/src/Onboarding/index.tsx | 2 +- .../client/src/pages/design/exportSkillModal/index.tsx | 2 +- Composer/packages/client/src/utils/luUtil.ts | 2 +- .../packages/lib/indexers/src/dialogUtils/dialogChecker.ts | 2 +- Composer/packages/lib/indexers/src/dialogUtils/validation.ts | 4 ++-- Composer/packages/server/src/models/bot/botProject.ts | 2 +- Composer/packages/server/src/models/bot/luPublisher.ts | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx b/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx index f71d4f492b..394aae21f3 100644 --- a/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx +++ b/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx @@ -57,14 +57,14 @@ const WelcomeModal = () => { {stepSets.map(({ steps: { length }, title }, index) => ( ))}
- {!~currentStep && ( + {currentStep === -1 && (
{currentSet + 1 < stepSets.length && ( diff --git a/Composer/packages/client/src/Onboarding/index.tsx b/Composer/packages/client/src/Onboarding/index.tsx index a583b733c6..6ac26e25d7 100644 --- a/Composer/packages/client/src/Onboarding/index.tsx +++ b/Composer/packages/client/src/Onboarding/index.tsx @@ -72,7 +72,7 @@ const Onboarding: React.FC = () => { !complete && projectId && navigateTo && navigate(navigateTo); setTeachingBubble({ currentStep, id, location, setLength: steps.length, targetId }); - setMinimized(!!~currentStep); + setMinimized(currentStep >= 0); if (currentSet > -1 && currentSet < stepSets.length) { onboardingState.setCurrentSet(stepSets[currentSet].id); diff --git a/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx b/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx index 275588cb9e..f1f36651ba 100644 --- a/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx +++ b/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx @@ -42,7 +42,7 @@ const ExportSkillModal: React.FC = ({ onSubmit, onDismiss const handleEditJson = () => { const step = order.findIndex((step) => step === ManifestEditorSteps.MANIFEST_REVIEW); - if (~step) { + if (step >= 0) { setCurrentStep(step); setErrors({}); } diff --git a/Composer/packages/client/src/utils/luUtil.ts b/Composer/packages/client/src/utils/luUtil.ts index 94c8500f64..f829815a58 100644 --- a/Composer/packages/client/src/utils/luUtil.ts +++ b/Composer/packages/client/src/utils/luUtil.ts @@ -17,7 +17,7 @@ export * from '@bfc/indexers/lib/utils/luUtil'; export function getReferredFiles(luFiles: LuFile[], dialogs: DialogInfo[]) { return luFiles.filter((file) => { const idWithOutLocale = getBaseName(file.id); - return !!~dialogs.findIndex((dialog) => dialog.luFile === idWithOutLocale); + return dialogs.some((dialog) => dialog.luFile === idWithOutLocale); }); } diff --git a/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts b/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts index 05623cf66d..d3295618fb 100644 --- a/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts +++ b/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts @@ -16,7 +16,7 @@ export const createPath = (path: string, type: string): string => { if (/\[|\]/.test(x)) { const reg = /\[.*\]/; x = x.replace(reg, ''); - return ~values(FieldNames).indexOf(x); + return values(FieldNames).includes(x); } }); diff --git a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts index 618c74abd3..3c2aec6b02 100644 --- a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts +++ b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts @@ -29,8 +29,8 @@ const isExpression = (value: string | boolean | number, types: string[]): boolea //TODO: returnType is number, schem type is string, need map or unify const checkReturnType = (returnType: ReturnType, types: string[]): string => { return returnType === ReturnType.Object || - ~types.indexOf(ExpressionTypeMapString[returnType]) || - (returnType === ReturnType.Number && ~types.indexOf(ExpressionType.integer)) + types.includes(ExpressionTypeMapString[returnType]) || + (returnType === ReturnType.Number && types.includes(ExpressionType.integer)) ? '' : formatMessage('the expression type is not match'); }; diff --git a/Composer/packages/server/src/models/bot/botProject.ts b/Composer/packages/server/src/models/bot/botProject.ts index 95d33ba96f..f988e5e6f7 100644 --- a/Composer/packages/server/src/models/bot/botProject.ts +++ b/Composer/packages/server/src/models/bot/botProject.ts @@ -381,7 +381,7 @@ export class BotProject { private getLocale(id: string): string { const index = id.lastIndexOf('.'); - if (~index) return ''; + if (index >= 0) return ''; return id.substring(index + 1); } diff --git a/Composer/packages/server/src/models/bot/luPublisher.ts b/Composer/packages/server/src/models/bot/luPublisher.ts index e1dcb51641..24f07c82cc 100644 --- a/Composer/packages/server/src/models/bot/luPublisher.ts +++ b/Composer/packages/server/src/models/bot/luPublisher.ts @@ -208,7 +208,7 @@ export class LuPublisher { //add the lu file that are not in interuption folder. files.forEach((file) => { - if (!~paths.indexOf(file.name)) { + if (!paths.includes(file.name)) { luConfig.models.push(Path.resolve(this.botDir, file.relativePath)); } }); From c541a498e4f73dd1f258f824621aebac6e4cc5d3 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 2 Jun 2020 08:39:45 -0700 Subject: [PATCH 2/9] add no-bitwise rule --- Composer/.eslintrc.js | 1 + Composer/packages/lib/code-editor/src/LuEditor.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Composer/.eslintrc.js b/Composer/.eslintrc.js index a835b17601..5730676e9d 100644 --- a/Composer/.eslintrc.js +++ b/Composer/.eslintrc.js @@ -40,6 +40,7 @@ module.exports = { 'no-console': 'warn', 'dot-notation': 'error', yoda: 'error', + 'no-bitwise': 'error', // eqeqeq: 'error', // plugin: import diff --git a/Composer/packages/lib/code-editor/src/LuEditor.tsx b/Composer/packages/lib/code-editor/src/LuEditor.tsx index c0b46e3945..8a54959560 100644 --- a/Composer/packages/lib/code-editor/src/LuEditor.tsx +++ b/Composer/packages/lib/code-editor/src/LuEditor.tsx @@ -119,6 +119,8 @@ const LuEditor: React.FC = (props) => { const m = monacoRef.current; if (m) { + // this is the correct way to combine keycodes in Monaco + // eslint-disable-next-line no-bitwise editor.addCommand(m.KeyMod.Shift | m.KeyCode.Enter, function () { const position = editor.getPosition(); languageClient.sendRequest('labelingExperienceRequest', { uri, position }); From f03a9a259a2c298537dc6aa19de572ae00510bd4 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:44:40 -0700 Subject: [PATCH 3/9] update luPublisher with typo fixes and some cleanup --- .../server/src/models/bot/luPublisher.ts | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Composer/packages/server/src/models/bot/luPublisher.ts b/Composer/packages/server/src/models/bot/luPublisher.ts index 7628d388e4..8263d65bec 100644 --- a/Composer/packages/server/src/models/bot/luPublisher.ts +++ b/Composer/packages/server/src/models/bot/luPublisher.ts @@ -39,7 +39,7 @@ export class LuPublisher { public botDir: string; public dialogsDir: string; public generatedFolderPath: string; - public interuptionFolderPath: string; + public interruptionFolderPath: string; public storage: IFileStorage; public config: ILuisConfig | null = null; public downSamplingConfig: IDownSamplingConfig = { maxImbalanceRatio: 0, maxUtteranceAllowed: 0 }; @@ -59,7 +59,7 @@ export class LuPublisher { this.botDir = path; this.dialogsDir = this.botDir; this.generatedFolderPath = Path.join(this.dialogsDir, GENERATEDFOLDER); - this.interuptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION); + this.interruptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION); this.storage = storage; } @@ -125,7 +125,7 @@ export class LuPublisher { return luObject; } - private async _downSizeUtterances(luContents: any) { + private async _downsizeUtterances(luContents: any) { return await Promise.all( luContents.map(async (luContent) => { const result = await LuisBuilder.fromLUAsync(luContent.content); @@ -137,12 +137,12 @@ export class LuPublisher { } private async _writeFiles(crossTrainResult) { - if (!(await this.storage.exists(this.interuptionFolderPath))) { - await this.storage.mkDir(this.interuptionFolderPath); + if (!(await this.storage.exists(this.interruptionFolderPath))) { + await this.storage.mkDir(this.interruptionFolderPath); } for (const key of crossTrainResult.keys()) { const fileName = Path.basename(key); - const newFileId = Path.join(this.interuptionFolderPath, fileName); + const newFileId = Path.join(this.interruptionFolderPath, fileName); await this.storage.writeFile(newFileId, crossTrainResult.get(key).Content); } } @@ -150,14 +150,12 @@ export class LuPublisher { private async _runBuild(files: FileInfo[]) { const config = await this._getConfig(files); if (config.models.length === 0) { - throw new Error('No luis file exist'); - } - const loadResult = await this._loadLuConatents(config.models); - loadResult.luContents = await this._downSizeUtterances(loadResult.luContents); - let endpoint = config.endpoint; - if (!endpoint) { - endpoint = `https://${config.region}.api.cognitive.microsoft.com`; + throw new Error('No LUIS files exist'); } + const loadResult = await this._loadLuContents(config.models); + loadResult.luContents = await this._downsizeUtterances(loadResult.luContents); + const endpoint = config?.endpoint ?? `https://${config.region}.api.cognitive.microsoft.com`; + const buildResult = await this.builder.build( loadResult.luContents, loadResult.recognizers, @@ -191,35 +189,38 @@ export class LuPublisher { private _getConfig = async (files: FileInfo[]) => { if (!this.config) { - throw new Error('Please complete your Luis settings'); + throw new Error('Please complete your LUIS settings'); } - const luConfig: any = { + const luConfig = { authoringKey: this.config.authoringKey || '', region: this.config.authoringRegion || '', botName: this.config.name || '', suffix: this.config.environment || '', fallbackLocal: this.config.defaultLanguage || 'en-us', + endpoint: this.config.endpoint || null, + models: [] as string[], }; - luConfig.models = []; //add all lu file after cross train let paths: string[] = []; if (this._needCrossTrain()) { - paths = await this.storage.glob('**/*.lu', this.interuptionFolderPath); - luConfig.models = paths.map((filePath) => Path.join(this.interuptionFolderPath, filePath)); + paths = await this.storage.glob('**/*.lu', this.interruptionFolderPath); + luConfig.models = paths.map((filePath) => Path.join(this.interruptionFolderPath, filePath)); } - //add the lu file that are not in interuption folder. + const pathSet = new Set(paths); + + //add the lu file that are not in interruption folder. files.forEach((file) => { - if (!paths.includes(file.name)) { + if (!pathSet.has(file.name)) { luConfig.models.push(Path.resolve(this.botDir, file.relativePath)); } }); return luConfig; }; - private _loadLuConatents = async (paths: string[]) => { + private _loadLuContents = async (paths: string[]) => { return await this.builder.loadContents( paths, 'en-us', @@ -230,6 +231,6 @@ export class LuPublisher { private async _cleanCrossTrain() { if (!this._needCrossTrain()) return; - await this._deleteDir(this.interuptionFolderPath); + await this._deleteDir(this.interruptionFolderPath); } } From 63bbd09113c45f798be5ab9aa5a3008531b4124f Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:16:37 -0700 Subject: [PATCH 4/9] fix typo --- Composer/packages/lib/indexers/src/dialogUtils/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts index 3c2aec6b02..be66900cae 100644 --- a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts +++ b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts @@ -32,7 +32,7 @@ const checkReturnType = (returnType: ReturnType, types: string[]): string => { types.includes(ExpressionTypeMapString[returnType]) || (returnType === ReturnType.Number && types.includes(ExpressionType.integer)) ? '' - : formatMessage('the expression type is not match'); + : formatMessage('the return type does not match'); }; export const checkExpression = (exp: string | boolean | number, required: boolean, types: string[]): string => { From 75d35aeebc5f7caaa4eca9ff3b509a6e9a09cc8b Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Mon, 1 Jun 2020 14:17:07 -0700 Subject: [PATCH 5/9] remove tildes --- .../client/src/Onboarding/WelcomeModal/Expanded/index.tsx | 4 ++-- Composer/packages/client/src/Onboarding/index.tsx | 2 +- .../client/src/pages/design/exportSkillModal/index.tsx | 2 +- Composer/packages/client/src/utils/luUtil.ts | 2 +- .../packages/lib/indexers/src/dialogUtils/dialogChecker.ts | 2 +- Composer/packages/lib/indexers/src/dialogUtils/validation.ts | 4 ++-- Composer/packages/server/src/models/bot/botProject.ts | 2 +- Composer/packages/server/src/models/bot/luPublisher.ts | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx b/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx index f71d4f492b..394aae21f3 100644 --- a/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx +++ b/Composer/packages/client/src/Onboarding/WelcomeModal/Expanded/index.tsx @@ -57,14 +57,14 @@ const WelcomeModal = () => { {stepSets.map(({ steps: { length }, title }, index) => ( ))}
- {!~currentStep && ( + {currentStep === -1 && (
{currentSet + 1 < stepSets.length && ( diff --git a/Composer/packages/client/src/Onboarding/index.tsx b/Composer/packages/client/src/Onboarding/index.tsx index a583b733c6..6ac26e25d7 100644 --- a/Composer/packages/client/src/Onboarding/index.tsx +++ b/Composer/packages/client/src/Onboarding/index.tsx @@ -72,7 +72,7 @@ const Onboarding: React.FC = () => { !complete && projectId && navigateTo && navigate(navigateTo); setTeachingBubble({ currentStep, id, location, setLength: steps.length, targetId }); - setMinimized(!!~currentStep); + setMinimized(currentStep >= 0); if (currentSet > -1 && currentSet < stepSets.length) { onboardingState.setCurrentSet(stepSets[currentSet].id); diff --git a/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx b/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx index 275588cb9e..f1f36651ba 100644 --- a/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx +++ b/Composer/packages/client/src/pages/design/exportSkillModal/index.tsx @@ -42,7 +42,7 @@ const ExportSkillModal: React.FC = ({ onSubmit, onDismiss const handleEditJson = () => { const step = order.findIndex((step) => step === ManifestEditorSteps.MANIFEST_REVIEW); - if (~step) { + if (step >= 0) { setCurrentStep(step); setErrors({}); } diff --git a/Composer/packages/client/src/utils/luUtil.ts b/Composer/packages/client/src/utils/luUtil.ts index ba8be1f60e..6a4c4b1fc4 100644 --- a/Composer/packages/client/src/utils/luUtil.ts +++ b/Composer/packages/client/src/utils/luUtil.ts @@ -17,7 +17,7 @@ export * from '@bfc/indexers/lib/utils/luUtil'; export function getReferredFiles(luFiles: LuFile[], dialogs: DialogInfo[]) { return luFiles.filter((file) => { const idWithOutLocale = getBaseName(file.id); - return !!~dialogs.findIndex((dialog) => dialog.luFile === idWithOutLocale); + return dialogs.some((dialog) => dialog.luFile === idWithOutLocale); }); } diff --git a/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts b/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts index 05623cf66d..d3295618fb 100644 --- a/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts +++ b/Composer/packages/lib/indexers/src/dialogUtils/dialogChecker.ts @@ -16,7 +16,7 @@ export const createPath = (path: string, type: string): string => { if (/\[|\]/.test(x)) { const reg = /\[.*\]/; x = x.replace(reg, ''); - return ~values(FieldNames).indexOf(x); + return values(FieldNames).includes(x); } }); diff --git a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts index 618c74abd3..3c2aec6b02 100644 --- a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts +++ b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts @@ -29,8 +29,8 @@ const isExpression = (value: string | boolean | number, types: string[]): boolea //TODO: returnType is number, schem type is string, need map or unify const checkReturnType = (returnType: ReturnType, types: string[]): string => { return returnType === ReturnType.Object || - ~types.indexOf(ExpressionTypeMapString[returnType]) || - (returnType === ReturnType.Number && ~types.indexOf(ExpressionType.integer)) + types.includes(ExpressionTypeMapString[returnType]) || + (returnType === ReturnType.Number && types.includes(ExpressionType.integer)) ? '' : formatMessage('the expression type is not match'); }; diff --git a/Composer/packages/server/src/models/bot/botProject.ts b/Composer/packages/server/src/models/bot/botProject.ts index e9de13c0ab..26791691f6 100644 --- a/Composer/packages/server/src/models/bot/botProject.ts +++ b/Composer/packages/server/src/models/bot/botProject.ts @@ -397,7 +397,7 @@ export class BotProject { private getLocale(id: string): string { const index = id.lastIndexOf('.'); - if (~index) return ''; + if (index >= 0) return ''; return id.substring(index + 1); } diff --git a/Composer/packages/server/src/models/bot/luPublisher.ts b/Composer/packages/server/src/models/bot/luPublisher.ts index d3325236c8..b14f63ef4a 100644 --- a/Composer/packages/server/src/models/bot/luPublisher.ts +++ b/Composer/packages/server/src/models/bot/luPublisher.ts @@ -222,7 +222,7 @@ export class LuPublisher { //add the lu file that are not in interuption folder. files.forEach((file) => { - if (!~paths.indexOf(file.name)) { + if (!paths.includes(file.name)) { luConfig.models.push(Path.resolve(this.botDir, file.relativePath)); } }); From e896efcb05289974b004e308e732a497385db81e Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 2 Jun 2020 08:39:45 -0700 Subject: [PATCH 6/9] add no-bitwise rule --- Composer/.eslintrc.js | 1 + Composer/packages/lib/code-editor/src/LuEditor.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Composer/.eslintrc.js b/Composer/.eslintrc.js index a835b17601..5730676e9d 100644 --- a/Composer/.eslintrc.js +++ b/Composer/.eslintrc.js @@ -40,6 +40,7 @@ module.exports = { 'no-console': 'warn', 'dot-notation': 'error', yoda: 'error', + 'no-bitwise': 'error', // eqeqeq: 'error', // plugin: import diff --git a/Composer/packages/lib/code-editor/src/LuEditor.tsx b/Composer/packages/lib/code-editor/src/LuEditor.tsx index 32d8235340..d0b39ca9b1 100644 --- a/Composer/packages/lib/code-editor/src/LuEditor.tsx +++ b/Composer/packages/lib/code-editor/src/LuEditor.tsx @@ -100,6 +100,8 @@ const LuEditor: React.FC = (props) => { const m = monacoRef.current; if (m) { + // this is the correct way to combine keycodes in Monaco + // eslint-disable-next-line no-bitwise editor.addCommand(m.KeyMod.Shift | m.KeyCode.Enter, function () { const position = editor.getPosition(); SendRequestWithRetry(languageClient, 'labelingExperienceRequest', { uri, position }); From f49e848f7b3d84592ccb287ef7554d463bb3067e Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:44:40 -0700 Subject: [PATCH 7/9] update luPublisher with typo fixes and some cleanup --- .../server/src/models/bot/luPublisher.ts | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Composer/packages/server/src/models/bot/luPublisher.ts b/Composer/packages/server/src/models/bot/luPublisher.ts index b14f63ef4a..d175d3680f 100644 --- a/Composer/packages/server/src/models/bot/luPublisher.ts +++ b/Composer/packages/server/src/models/bot/luPublisher.ts @@ -39,7 +39,7 @@ export class LuPublisher { public botDir: string; public dialogsDir: string; public generatedFolderPath: string; - public interuptionFolderPath: string; + public interruptionFolderPath: string; public storage: IFileStorage; public config: ILuisConfig | null = null; public downSamplingConfig: IDownSamplingConfig = { maxImbalanceRatio: 0, maxUtteranceAllowed: 0 }; @@ -60,7 +60,7 @@ export class LuPublisher { this.botDir = path; this.dialogsDir = this.botDir; this.generatedFolderPath = Path.join(this.dialogsDir, GENERATEDFOLDER); - this.interuptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION); + this.interruptionFolderPath = Path.join(this.generatedFolderPath, INTERUPTION); this.storage = storage; this._locale = locale; } @@ -135,7 +135,7 @@ export class LuPublisher { return luObject; } - private async _downSizeUtterances(luContents: any) { + private async _downsizeUtterances(luContents: any) { return await Promise.all( luContents.map(async (luContent) => { const result = await LuisBuilder.fromLUAsync(luContent.content); @@ -147,12 +147,12 @@ export class LuPublisher { } private async _writeFiles(crossTrainResult) { - if (!(await this.storage.exists(this.interuptionFolderPath))) { - await this.storage.mkDir(this.interuptionFolderPath); + if (!(await this.storage.exists(this.interruptionFolderPath))) { + await this.storage.mkDir(this.interruptionFolderPath); } for (const key of crossTrainResult.keys()) { const fileName = Path.basename(key); - const newFileId = Path.join(this.interuptionFolderPath, fileName); + const newFileId = Path.join(this.interruptionFolderPath, fileName); await this.storage.writeFile(newFileId, crossTrainResult.get(key).Content); } } @@ -160,14 +160,12 @@ export class LuPublisher { private async _runBuild(files: FileInfo[]) { const config = await this._getConfig(files); if (config.models.length === 0) { - throw new Error('No luis file exist'); - } - const loadResult = await this._loadLuConatents(config.models); - loadResult.luContents = await this._downSizeUtterances(loadResult.luContents); - let endpoint = config.endpoint; - if (!endpoint) { - endpoint = `https://${config.region}.api.cognitive.microsoft.com`; + throw new Error('No LUIS files exist'); } + const loadResult = await this._loadLuContents(config.models); + loadResult.luContents = await this._downsizeUtterances(loadResult.luContents); + const endpoint = config?.endpoint ?? `https://${config.region}.api.cognitive.microsoft.com`; + const buildResult = await this.builder.build( loadResult.luContents, loadResult.recognizers, @@ -201,35 +199,38 @@ export class LuPublisher { private _getConfig = async (files: FileInfo[]) => { if (!this.config) { - throw new Error('Please complete your Luis settings'); + throw new Error('Please complete your LUIS settings'); } - const luConfig: any = { + const luConfig = { authoringKey: this.config.authoringKey || '', region: this.config.authoringRegion || '', botName: this.config.name || '', suffix: this.config.environment || '', fallbackLocal: this.config.defaultLanguage || 'en-us', + endpoint: this.config.endpoint || null, + models: [] as string[], }; - luConfig.models = []; //add all lu file after cross train let paths: string[] = []; if (this._needCrossTrain()) { - paths = await this.storage.glob('**/*.lu', this.interuptionFolderPath); - luConfig.models = paths.map((filePath) => Path.join(this.interuptionFolderPath, filePath)); + paths = await this.storage.glob('**/*.lu', this.interruptionFolderPath); + luConfig.models = paths.map((filePath) => Path.join(this.interruptionFolderPath, filePath)); } - //add the lu file that are not in interuption folder. + const pathSet = new Set(paths); + + //add the lu file that are not in interruption folder. files.forEach((file) => { - if (!paths.includes(file.name)) { + if (!pathSet.has(file.name)) { luConfig.models.push(Path.resolve(this.botDir, file.relativePath)); } }); return luConfig; }; - private _loadLuConatents = async (paths: string[]) => { + private _loadLuContents = async (paths: string[]) => { return await this.builder.loadContents( paths, this._locale, @@ -240,6 +241,6 @@ export class LuPublisher { private async _cleanCrossTrain() { if (!this._needCrossTrain()) return; - await this._deleteDir(this.interuptionFolderPath); + await this._deleteDir(this.interruptionFolderPath); } } From 84b2cf51bf61dd634158ff4e5fd42da1763d9827 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:16:37 -0700 Subject: [PATCH 8/9] fix typo --- Composer/packages/lib/indexers/src/dialogUtils/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts index 3c2aec6b02..be66900cae 100644 --- a/Composer/packages/lib/indexers/src/dialogUtils/validation.ts +++ b/Composer/packages/lib/indexers/src/dialogUtils/validation.ts @@ -32,7 +32,7 @@ const checkReturnType = (returnType: ReturnType, types: string[]): string => { types.includes(ExpressionTypeMapString[returnType]) || (returnType === ReturnType.Number && types.includes(ExpressionType.integer)) ? '' - : formatMessage('the expression type is not match'); + : formatMessage('the return type does not match'); }; export const checkExpression = (exp: string | boolean | number, required: boolean, types: string[]): string => { From b3d4c38cacefc7b545cb2a7d7a3ffe9494e8aa58 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Mon, 15 Jun 2020 17:02:46 -0700 Subject: [PATCH 9/9] fix endpoint issue --- Composer/packages/server/src/models/bot/luPublisher.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Composer/packages/server/src/models/bot/luPublisher.ts b/Composer/packages/server/src/models/bot/luPublisher.ts index b602b303b9..1536d27f2b 100644 --- a/Composer/packages/server/src/models/bot/luPublisher.ts +++ b/Composer/packages/server/src/models/bot/luPublisher.ts @@ -162,15 +162,10 @@ export class LuPublisher { if (config.models.length === 0) { throw new Error('No LUIS files exist'); } - const loadResult = await this._loadLuConatents(config.models); - loadResult.luContents = await this._downSizeUtterances(loadResult.luContents); - let authoringEndpoint = config.authoringEndpoint; - if (!authoringEndpoint) { - authoringEndpoint = `https://${config.region}.api.cognitive.microsoft.com`; - } + const loadResult = await this._loadLuContents(config.models); loadResult.luContents = await this._downsizeUtterances(loadResult.luContents); - const endpoint = config?.endpoint ?? `https://${config.region}.api.cognitive.microsoft.com`; + const authoringEndpoint = config.endpoint ?? `https://${config.region}.api.cognitive.microsoft.com`; const buildResult = await this.builder.build( loadResult.luContents,