This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 374
feat: Added jsonSchema and trigger content #4353
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
163d031
Added jsonSchema and trigger content
GeoffCoxMSFT 1c7f4e7
Fix for filtering skill manifests
GeoffCoxMSFT 448429e
PR fixes
GeoffCoxMSFT 8637247
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT c532129
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT 9e4f823
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT e7f490b
Fixing baseName and test issue
GeoffCoxMSFT 5ae2386
Merge branch 'gcox/support-json-schema-files' of https://github.com/m…
GeoffCoxMSFT b9d8f7b
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT 812d7b5
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT 9155eed
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT c2343b2
Merge branch 'main' into gcox/support-json-schema-files
GeoffCoxMSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
Composer/packages/lib/indexers/__tests__/jsonSchemafileIndexer.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { jsonSchemaFileIndexer } from '../src/jsonSchemaFileIndexer'; | ||
| import { FileInfo } from '../src/type'; | ||
| import { getBaseName } from '../src/utils/help'; | ||
|
|
||
| const { index } = jsonSchemaFileIndexer; | ||
|
|
||
| describe('jsonSchemaFileIndexer', () => { | ||
| describe('index', () => { | ||
| it('should return json schema files', () => { | ||
| const input: FileInfo[] = [ | ||
| { | ||
| name: 'test1.json', | ||
| relativePath: './test1.json', | ||
| content: '{ "$schema":"http://json-schema.org/draft/schema" }', | ||
| path: '/', | ||
| }, | ||
| { | ||
| name: 'test2.json', | ||
| relativePath: './test2.json', | ||
| content: '{ "$schema":"http://json-schema.org/draft-07/schema" }', | ||
| path: '/', | ||
| }, | ||
| { | ||
| name: 'test3.json', | ||
| relativePath: './test3.json', | ||
| content: '{ "$schema":"http://json-schema.org/draft-07/schemav2" }', | ||
| path: '/', | ||
| }, | ||
| ]; | ||
|
|
||
| const expected = input.map((item) => { | ||
| return { | ||
| name: getBaseName(item.name), | ||
| content: JSON.parse(item.content), | ||
| }; | ||
| }); | ||
|
|
||
| const actual = index(input); | ||
|
|
||
| expect(actual).toHaveLength(expected.length); | ||
|
|
||
| for (let i = 0; i < actual.length; i++) { | ||
| expect(actual[i].id).toEqual(expected[i].name); | ||
| expect(actual[i].content.$schema).toEqual(expected[i].content.$schema); | ||
| } | ||
| }); | ||
|
|
||
| it('should not return other json files', () => { | ||
| const input: FileInfo[] = [ | ||
| { | ||
| name: 'test1', | ||
| relativePath: './test1.json', | ||
| content: '{ "$schema":"http://microsoft.org/wsp" }', | ||
| path: '/', | ||
| }, | ||
| { | ||
| name: 'test2', | ||
| relativePath: './test2.json', | ||
| content: '{ "$schema":"http://json-schema.org/draft-07/schema" }', | ||
| path: '/', | ||
| }, | ||
| { | ||
| name: 'test3', | ||
| relativePath: './test3.json', | ||
| content: '{ "$schema":"http://microsoft.org/wsp" }', | ||
| path: '/', | ||
| }, | ||
| ]; | ||
|
|
||
| const expected = [ | ||
| { | ||
| name: 'test2', | ||
| content: JSON.parse(input[1].content), | ||
| }, | ||
| ]; | ||
|
|
||
| const actual = index(input); | ||
|
|
||
| expect(actual).toHaveLength(expected.length); | ||
|
|
||
| for (let i = 0; i < actual.length; i++) { | ||
| expect(actual[i].id).toEqual(expected[i].name); | ||
| expect(actual[i].content.$schema).toEqual(expected[i].content.$schema); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Composer/packages/lib/indexers/src/jsonSchemaFileIndexer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { FileInfo, JsonSchemaFile } from '@bfc/shared'; | ||
| import has from 'lodash/has'; | ||
|
|
||
| import { getBaseName } from './utils/help'; | ||
|
|
||
| const index = (jsonFiles: FileInfo[]) => { | ||
| return jsonFiles.reduce((jsonSchemaFiles: JsonSchemaFile[], { content, name }) => { | ||
GeoffCoxMSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try { | ||
| const jsonContent = JSON.parse(content); | ||
|
|
||
| if (has(jsonContent, '$schema')) { | ||
| const schema = jsonContent.$schema.toLowerCase().trim(); | ||
| if (schema.startsWith('http://json-schema.org')) { | ||
| return [...jsonSchemaFiles, { content: jsonContent, id: getBaseName(name) }]; | ||
| } | ||
| } | ||
|
|
||
| return jsonSchemaFiles; | ||
| } catch (error) { | ||
| return jsonSchemaFiles; | ||
| } | ||
| }, [] as JsonSchemaFile[]); | ||
| }; | ||
|
|
||
| export const jsonSchemaFileIndexer = { | ||
| index, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,5 @@ export enum FileExtensions { | |
| lg = '.lg', | ||
| Manifest = '.json', | ||
| BotProjectSpace = '.botproj', | ||
| Json = '.json', | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.