Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 11 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
4 changes: 2 additions & 2 deletions Composer/packages/adaptive-flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@bfc/ui-shared": "*",
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"adaptive-expressions": "4.10.0-preview-147186",
"botbuilder-lg": "^4.10.0-preview-150886",
"adaptive-expressions": "^4.11.0-dev.20201013.d5458bf",
"botbuilder-lg": "4.11.0-dev.20201010.6e4a99e",
"create-react-class": "^15.6.3",
"d3": "^5.9.1",
"dagre": "^0.8.4",
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/hooks/useResolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { useRef } from 'react';
import { importResolverGenerator } from '@bfc/shared';
import { lgImportResolverGenerator } from '@bfc/shared';
import { useRecoilValue } from 'recoil';

import { dialogsState, luFilesState, lgFilesState, localeState, qnaFilesState } from '../recoilModel';
Expand All @@ -28,7 +28,7 @@ export const useResolvers = (projectId: string) => {
const dialogsRef = useRef(dialogs);
dialogsRef.current = dialogs;

const lgImportresolver = () => importResolverGenerator(lgFilesRef.current, '.lg');
const lgImportresolver = () => lgImportResolverGenerator(lgFilesRef.current, '.lg');

const lgFileResolver = (id: string) => {
const fileId = id.includes('.') ? id : `${id}.${localeRef.current}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { lgUtil } from '@bfc/indexers';
import { importResolverGenerator, LgFile } from '@bfc/shared';
import { lgImportResolverGenerator, LgFile } from '@bfc/shared';

import {
LgActionType,
Expand Down Expand Up @@ -92,7 +92,7 @@ type LgMessageEvent =
type LgResources = Map<string, LgFile>;

const lgFileResolver = (lgFiles) => {
return importResolverGenerator(lgFiles, '.lg');
return lgImportResolverGenerator(lgFiles, '.lg');
};

export class LgCache {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/lib/indexers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
},
"dependencies": {
"@microsoft/bf-lu": "^4.11.0-dev.20201013.7ccb128",
"adaptive-expressions": "4.10.0-preview-147186",
"botbuilder-lg": "^4.10.0-preview-150886",
"adaptive-expressions": "^4.11.0-dev.20201013.d5458bf",
"botbuilder-lg": "4.11.0-dev.20201010.6e4a99e",
"lodash": "^4.17.19"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/lib/indexers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { DialogSetting, FileInfo, importResolverGenerator } from '@bfc/shared';
import { DialogSetting, FileInfo, lgImportResolverGenerator } from '@bfc/shared';

import { dialogIndexer } from './dialogIndexer';
import { dialogSchemaIndexer } from './dialogSchemaIndexer';
Expand Down Expand Up @@ -46,7 +46,7 @@ class Indexer {
};
});

return importResolverGenerator(lgFiles, '.lg', locale);
return lgImportResolverGenerator(lgFiles, '.lg', locale);
};

public index(files: FileInfo[], botName: string, locale: string, skillContent: any, settings: DialogSetting) {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/lib/indexers/src/utils/lgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { Templates, Template, Diagnostic as LGDiagnostic, ImportResolverDelegate } from 'botbuilder-lg';
import { LgTemplate, importResolverGenerator, TextFile, Diagnostic, Position, Range, LgFile } from '@bfc/shared';
import { LgTemplate, lgImportResolverGenerator, TextFile, Diagnostic, Position, Range, LgFile } from '@bfc/shared';
import formatMessage from 'format-message';
import isEmpty from 'lodash/isEmpty';
import { SourceRange } from 'botbuilder-lg/lib/sourceRange';
Expand Down Expand Up @@ -260,7 +260,7 @@ export function extractOptionByKey(nameOfKey: string, options: string[]): string
}

export function parse(id: string, content: string, lgFiles: TextFile[]): LgFile {
const lgImportResolver = importResolverGenerator(lgFiles, '.lg');
const lgImportResolver = lgImportResolverGenerator(lgFiles, '.lg');

return lgIndexer.parse(content, id, lgImportResolver);
}
46 changes: 43 additions & 3 deletions Composer/packages/lib/shared/src/resolverFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// Licensed under the MIT License.

import formatMessage from 'format-message';
import { LGResource, ImportResolverDelegate } from 'botbuilder-lg';

export declare type ResolverResource = { content: string; id: string };
export declare type ImportResolverDelegate = (source: string, resourceId: string) => ResolverResource;
export declare type LUImportResolverDelegate = (source: string, resourceId: string) => ResolverResource;

function getFileName(path: string): string {
return path.split('/').pop() || path;
Expand All @@ -16,11 +17,11 @@ function getFileName(path: string): string {
* @param ext resource extension, e.g. .lg, .lu
* @param defaultLocale complete resource id = [id].[locale][ext]
*/
export function importResolverGenerator(
export function luImportResolverGenerator(
resources: ResolverResource[],
ext = '',
defaultLocale = 'en-us'
): ImportResolverDelegate {
): LUImportResolverDelegate {
/**
* @param source current file id
* @param resourceId imported file id
Expand Down Expand Up @@ -51,3 +52,42 @@ export function importResolverGenerator(
};
};
}

/**
*
* @param resources resources feed to resolver
* @param ext resource extension, e.g. .lg, .lu
* @param defaultLocale complete resource id = [id].[locale][ext]
*/
export function lgImportResolverGenerator(
resources: ResolverResource[],
ext = '',
defaultLocale = 'en-us'
): ImportResolverDelegate {
/**
* @param source current file id
* @param resourceId imported file id
* for example:
* in todosample.en-us.lg:
* [import](../common/common.lg)
*
* would resolve to common.en-us.lg || common.lg
*
* lgResource = todosample || todosample.en-us || todosample.en-us.lg || todosample.lg || .
* resourceId = common || common.lg || ../common/common.lg
*
*/
return (lgResource: LGResource, resourceId: string) => {
// eslint-disable-next-line security/detect-non-literal-regexp
const extReg = new RegExp(ext + '$');
const sourceId = getFileName(lgResource.id).replace(extReg, '');
const locale = /\w\.\w/.test(sourceId) ? sourceId.split('.').pop() : defaultLocale;
const targetId = getFileName(resourceId).replace(extReg, '');

const targetFile =
resources.find(({ id }) => id === `${targetId}.${locale}`) || resources.find(({ id }) => id === targetId);

if (!targetFile) throw new Error(formatMessage(`File not found`));
return new LGResource(resourceId, resourceId, targetFile.content);
};
}
94 changes: 45 additions & 49 deletions Composer/packages/server/schemas/sdk.en-US.uischema
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,6 @@
}
}
},
"Microsoft.AttachmentInput": {
"form": {
"label": "Prompt for a file or an attachment",
"subtitle": "Attachment Input"
}
},
"Microsoft.ChoiceInput": {
"form": {
"label": "Prompt with multi-choice",
"subtitle": "Choice Input"
}
},
"Microsoft.ConfirmInput": {
"form": {
"label": "Prompt for confirmation",
"subtitle": "Confirm Input"
}
},
"Microsoft.DateTimeInput": {
"form": {
"label": "Prompt for a date or a time",
"subtitle": "Date Time Input"
}
},
"Microsoft.NumberInput": {
"form": {
"label": "Prompt for a number",
"subtitle": "Number Input"
}
},
"Microsoft.OAuthInput": {
"form": {
"label": "OAuth login",
"subtitle": "OAuth Input"
}
},
"Microsoft.TextInput": {
"form": {
"label": "Prompt for text",
"subtitle": "Text Input"
}
},
"Microsoft.BeginDialog": {
"form": {
"label": "Begin a new dialog",
Expand Down Expand Up @@ -100,11 +58,6 @@
"subtitle": "Delete Property"
}
},
"Microsoft.DeleteActivity": {
"form": {
"label": "Delete activity"
}
},
"Microsoft.EditActions": {
"form": {
"label": "Modify active dialog",
Expand Down Expand Up @@ -213,9 +166,46 @@
"subtitle": "Trace Activity"
}
},
"Microsoft.UpdateActivity": {
"Microsoft.AttachmentInput": {
"form": {
"label": "Prompt for a file or an attachment",
"subtitle": "Attachment Input"
}
},
"Microsoft.ChoiceInput": {
"form": {
"label": "Prompt with multi-choice",
"subtitle": "Choice Input"
}
},
"Microsoft.ConfirmInput": {
"form": {
"label": "Update an activity"
"label": "Prompt for confirmation",
"subtitle": "Confirm Input"
}
},
"Microsoft.DateTimeInput": {
"form": {
"label": "Prompt for a date or a time",
"subtitle": "Date Time Input"
}
},
"Microsoft.NumberInput": {
"form": {
"label": "Prompt for a number",
"subtitle": "Number Input"
}
},
"Microsoft.OAuthInput": {
"form": {
"label": "OAuth login",
"subtitle": "OAuth Input"
}
},
"Microsoft.TextInput": {
"form": {
"label": "Prompt for text",
"subtitle": "Text Input"
}
},
"Microsoft.OnActivity": {
Expand Down Expand Up @@ -279,6 +269,12 @@
"subtitle": "Handoff activity"
}
},
"Microsoft.OnInstallationUpdateActivity": {
"form": {
"label": "Installation updated",
"subtitle": "Installation updated activity"
}
},
"Microsoft.OnIntent": {
"form": {
"label": "Intent recognized",
Expand Down
18 changes: 6 additions & 12 deletions Composer/packages/server/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,6 @@
"export_de71cd8e": {
"message": "Export"
},
"export_json_2e2981f5": {
"message": "Export JSON"
},
"expression_7f906a13": {
"message": "Expression"
},
Expand Down Expand Up @@ -1811,6 +1808,9 @@
"open_inline_editor_a5aabcfa": {
"message": "Open inline editor"
},
"open_skills_page_for_configuration_details_a2a484ea": {
"message": "Open Skills page for configuration details"
},
"optional_221bcc9d": {
"message": "Optional"
},
Expand Down Expand Up @@ -1955,9 +1955,6 @@
"property_actions_9c1a20d9": {
"message": "Property actions"
},
"property_array_help_text_126845dc": {
"message": "Property array help text"
},
"property_description_8d21ea2e": {
"message": "Property description."
},
Expand All @@ -1970,12 +1967,6 @@
"property_name_914371f5": {
"message": "Property name"
},
"property_name_help_text_421a5f7f": {
"message": "Property name help text"
},
"property_required_help_text_57f027ad": {
"message": "Property required help text"
},
"property_title_f2b443b7": {
"message": "Property title"
},
Expand Down Expand Up @@ -2088,6 +2079,9 @@
"message": "RegEx { intent } is already defined"
},
"regular_expression_855557bf": {
"message": "Regular Expression"
},
"regular_expression_recognizer_44664557": {
"message": "Regular expression recognizer"
},
"release_1af20f26": {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/server/src/services/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import merge from 'lodash/merge';
import find from 'lodash/find';
import flatten from 'lodash/flatten';
import { importResolverGenerator, ResolverResource } from '@bfc/shared';
import { luImportResolverGenerator, ResolverResource } from '@bfc/shared';
import extractMemoryPaths from '@bfc/indexers/lib/dialogUtils/extractMemoryPaths';
import { UserIdentity } from '@bfc/extension';

Expand Down Expand Up @@ -54,7 +54,7 @@ export class BotProjectService {
const { name, content } = file;
return { id: Path.basename(name, '.lu'), content };
});
const resolver = importResolverGenerator(resource, '.lu');
const resolver = luImportResolverGenerator(resource, '.lu');
return resolver(source, id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"lint:typecheck": "tsc --noEmit"
},
"dependencies": {
"@bfc/built-in-functions": "*",
"@bfc/indexers": "*",
"botbuilder-lg": "^4.10.0-preview-150886",
"vscode-languageserver": "^5.3.0-next",
"@bfc/built-in-functions": "*"
"botbuilder-lg": "4.11.0-dev.20201010.6e4a99e",
"vscode-languageserver": "^5.3.0-next"
},
"devDependencies": {
"@botframework-composer/test-utils": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { TextDocumentPositionParams, DocumentOnTypeFormattingParams } from 'vscode-languageserver-protocol';
import get from 'lodash/get';
import { filterTemplateDiagnostics, isValid, lgUtil } from '@bfc/indexers';
import { MemoryResolver, ResolverResource, LgFile, importResolverGenerator } from '@bfc/shared';
import { MemoryResolver, ResolverResource, LgFile, lgImportResolverGenerator } from '@bfc/shared';
import { buildInFunctionsMap } from '@bfc/built-in-functions';

import { LgParser } from './lgParser';
Expand Down Expand Up @@ -166,7 +166,7 @@ export class LGServer {
const lgTextFile = lgTextFiles.find((item) => item.id === fileId);
if (lgTextFile) {
const lgFile = lgUtil.parse(lgTextFile.id, lgTextFile.content, lgTextFiles);
const lgResolver = importResolverGenerator(lgTextFiles, '.lg');
const lgResolver = lgImportResolverGenerator(lgTextFiles, '.lg');
return lgUtil.updateTemplate(lgFile, templateId, { body: content }, lgResolver);
}
}
Expand Down
Loading