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
Show all changes
59 commits
Select commit Hold shift + click to select a range
8ca4d55
set up the interface
boydc2014 Sep 4, 2019
1655f13
set up the interface
boydc2014 Sep 4, 2019
e9e2066
Revert "set up the interface"
boydc2014 Sep 4, 2019
78dd309
update some naming
boydc2014 Sep 4, 2019
3ba62ad
fill in Diagnostic
boydc2014 Sep 6, 2019
b0ce4f7
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 9, 2019
2512cf8
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 16, 2019
d061414
define Resources
boydc2014 Sep 16, 2019
d1297db
Split interfaces
boydc2014 Sep 16, 2019
d0316ec
Move responsibility from lgIndexer to lgResource
boydc2014 Sep 16, 2019
42028d8
in case i revert
boydc2014 Sep 17, 2019
5c96a53
add luResource
boydc2014 Sep 17, 2019
3b8d024
validator
boydc2014 Sep 17, 2019
79019d8
expand diagnostics
boydc2014 Sep 18, 2019
b37118f
create index.ts
boydc2014 Sep 18, 2019
2d94d30
Fix the interface export
boydc2014 Sep 18, 2019
9320104
add comments
boydc2014 Sep 18, 2019
7f1a65d
fix the import
boydc2014 Sep 19, 2019
72202e6
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 21, 2019
5213512
migrate dialogChecker
boydc2014 Sep 22, 2019
51bd392
migrate lg validator
boydc2014 Sep 22, 2019
9ebcaa5
migrate lu validator
boydc2014 Sep 22, 2019
1011408
fix build error
boydc2014 Sep 22, 2019
af5b680
Fix load resource path
boydc2014 Sep 22, 2019
30f1d6f
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 22, 2019
dcfc602
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 23, 2019
071fa60
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 24, 2019
81c066e
make resource id unique per type
boydc2014 Sep 25, 2019
fdf0127
add comments
boydc2014 Sep 25, 2019
a1c29a4
backward compatible with previous interface
boydc2014 Sep 25, 2019
e54fc45
get resource
boydc2014 Sep 25, 2019
876e86e
make load resources pure function
boydc2014 Sep 26, 2019
f58f2fb
use resource to power dialog
boydc2014 Sep 26, 2019
47f498c
migrate lu
boydc2014 Sep 26, 2019
397a655
migrate lg
boydc2014 Sep 26, 2019
e287674
fix isRoot
boydc2014 Sep 26, 2019
ae3b2b3
dont load .lu.dialog
boydc2014 Sep 26, 2019
4623eae
fix filter
boydc2014 Sep 26, 2019
d2147ac
fix luResource indexing
boydc2014 Sep 26, 2019
b1319d8
fix botname
boydc2014 Sep 26, 2019
a29277b
add schemaResource
boydc2014 Sep 26, 2019
a0f5326
fix interface
boydc2014 Sep 26, 2019
65a8fc9
fix luDiagnostic
boydc2014 Sep 26, 2019
4eb24f0
fix lg all up view
boydc2014 Sep 26, 2019
c04784c
fix lu lg id
boydc2014 Sep 26, 2019
bfcb054
fix import path
boydc2014 Sep 26, 2019
c6ceb1f
fix fitler issue
boydc2014 Sep 26, 2019
3c45f2a
add validation and remove indexer
boydc2014 Sep 26, 2019
7bc74c0
fix lgValidator
boydc2014 Sep 26, 2019
7d92af0
fix tests
boydc2014 Sep 26, 2019
078c331
fix lint
boydc2014 Sep 27, 2019
aa60ac9
fix lint
boydc2014 Sep 27, 2019
2a32bdf
Merge branch 'master' into donglei/validation-interface
boydc2014 Sep 27, 2019
97d042a
revert unexpected lu file change
boydc2014 Sep 27, 2019
23f043d
Merge branch 'donglei/validation-interface' of https://github.com/mic…
boydc2014 Sep 27, 2019
ea146c1
Merge branch 'master' into donglei/validation-interface
boydc2014 Oct 4, 2019
c80a1c5
Merge branch 'master' into donglei/validation-interface
boydc2014 Oct 4, 2019
970a08e
merge the lastest
boydc2014 Oct 4, 2019
9222edb
Merge branch 'master' into donglei/validation-interface
boydc2014 Oct 9, 2019
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 @@ -47,7 +47,7 @@ export default function TableView(props) {
setTemplates(allTemplates);
} else {
const dialogsTemplates = [];
activeDialog.lgTemplates.forEach(item => {
activeDialog.referredLGTemplates.forEach(item => {
const template = allTemplates.find(t => t.Name === item);
if (template) {
dialogsTemplates.push(template);
Expand Down Expand Up @@ -167,7 +167,7 @@ export default function TableView(props) {
// build usedIn map
templates.forEach(template => {
templateUsedInDialogMap[template.Name] = dialogs.reduce((result, dialog) => {
if (dialog.lgTemplates.indexOf(template.Name) !== -1) {
if (dialog.referredLGTemplates.indexOf(template.Name) !== -1) {
result.push(dialog.id);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function TableView(props) {
name,
phrases: [utterance.text],
fileId: luFile.id,
used: luDialog.luIntents.indexOf(name) !== -1, // used by it's dialog or not
used: luDialog.referredLUIntents.indexOf(name) !== -1, // used by it's dialog or not
state,
});
}
Expand Down
37 changes: 31 additions & 6 deletions Composer/packages/client/src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export interface DialogInfo {
isRoot: boolean;
content: any;
diagnostics: string[];
luFile: string;
referredLUFile: string;
referredLUIntents: string[];
triggers: ITrigger[];
}

Expand All @@ -105,10 +106,6 @@ export interface Utterance {
text: string;
}

export interface LuDiagnostic {
text: string;
}

export interface LuFile {
id: string;
relativePath: string;
Expand All @@ -119,7 +116,7 @@ export interface LuFile {
utterances: Utterance[];
};
};
diagnostics: LuDiagnostic[];
diagnostics: Diagnostic[];
}

export interface LgFile {
Expand Down Expand Up @@ -154,3 +151,31 @@ export interface DesignPageLocation {
focused: string;
promptTab?: PromptTab;
}

export interface Diagnostic {
severity: DiagnosticSeverity;
message: string;

source: string;

range?: Range;
path?: string;
code?: string;
}

export interface Range {
start: Position;
end: Position;
}

export interface Position {
line: number;
character: number;
}

export enum DiagnosticSeverity {
Error = 0,
Warning = 1,
Information = 2,
Hint = 3,
}
10 changes: 5 additions & 5 deletions Composer/packages/client/src/utils/luUtil.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { LuFile, DialogInfo, LuDiagnostic } from '../store/types';
import { LuFile, DialogInfo, Diagnostic } from '../store/types';

export function getReferredFiles(luFiles: LuFile[], dialogs: DialogInfo[]) {
return luFiles.filter(file => {
if (dialogs.findIndex(dialog => dialog.luFile === file.id) !== -1) {
if (dialogs.findIndex(dialog => dialog.referredLUFile === file.id) !== -1) {
return true;
}
return false;
});
}

export function isValid(diagnostics: LuDiagnostic[]) {
export function isValid(diagnostics: Diagnostic[]) {
return diagnostics.length === 0;
}

export function combineMessage(diagnostics: LuDiagnostic[]) {
export function combineMessage(diagnostics: Diagnostic[]) {
return diagnostics.reduce((msg, d) => {
msg += `${d.text}\n`;
msg += `${d.message}\n`;
return msg;
}, '');
}
43 changes: 15 additions & 28 deletions Composer/packages/server/__tests__/models/bot/botProject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs';
import { Path } from '../../../src/utility/path';
import { BotProject } from '../../../src/models/bot/botProject';
import { LocationRef, FileInfo } from '../../../src/models/bot/interface';
import { LGResource, LUResource } from '../../../src/models/resource';

import DIALOG_TEMPLATE from './../../../src/store/dialogTemplate.json';

Expand Down Expand Up @@ -31,8 +32,8 @@ describe('index', () => {
expect(project.luFiles.length).toBe(3);

// find out lg templates used in
expect(project.dialogs.find((d: { isRoot: boolean }) => d.isRoot).lgTemplates.length).toBe(3);
expect(project.dialogs.find((d: { isRoot: boolean }) => d.isRoot).lgTemplates.join(',')).toBe(
expect(project.dialogs.find((d: { isRoot: boolean }) => d.isRoot).referredLGTemplates.length).toBe(3);
expect(project.dialogs.find((d: { isRoot: boolean }) => d.isRoot).referredLGTemplates.join(',')).toBe(
['hello', 'bye', 'ShowImage'].join(',')
);

Expand Down Expand Up @@ -143,9 +144,9 @@ describe('lg operation', () => {
const dir = 'root';
const content = '# hello \n - hello';
const lgFiles = await proj.createLgFile(id, content, dir);
const result = lgFiles.find(f => f.id === id);
const result = lgFiles.find(f => f.id === id) as LGResource;

expect(proj.files.length).toEqual(8);
expect(proj.resources.length).toEqual(8);
expect(lgFiles.length).toEqual(2);

expect(result).not.toBeUndefined();
Expand All @@ -159,9 +160,9 @@ describe('lg operation', () => {
const id = 'root';
const content = '# hello \n - hello2';
const lgFiles = await proj.updateLgFile(id, content);
const result = lgFiles.find(f => f.id === id);
const result = lgFiles.find(f => f.id === id) as LGResource;

expect(proj.files.length).toEqual(8);
expect(proj.resources.length).toEqual(8);
expect(lgFiles.length).toEqual(2);

expect(result).not.toBeUndefined();
Expand All @@ -171,19 +172,12 @@ describe('lg operation', () => {
}
});

it('should throw error when lg content is invalid', async () => {
const id = 'root';
const content = '# hello \n hello3';

await expect(proj.updateLgFile(id, content)).rejects.toThrow();
});

it('should delete lg file and update index', async () => {
const id = 'root';
const lgFiles = await proj.removeLgFile(id);
const result = lgFiles.find(f => f.id === id);
const result = lgFiles.find(f => f.id === id) as LGResource;

expect(proj.files.length).toEqual(7);
expect(proj.resources.length).toEqual(7);
expect(lgFiles.length).toEqual(1);

expect(result).toBeUndefined();
Expand All @@ -206,9 +200,9 @@ describe('lu operation', () => {
const dir = 'root';
const content = '## hello \n - hello';
const luFiles = await proj.createLuFile(id, content, dir);
const result = luFiles.find(f => f.id === id);
const result = luFiles.find(f => f.id === id) as LUResource;

expect(proj.files.length).toEqual(8);
expect(proj.resources.length).toEqual(8);
expect(luFiles.length).toEqual(4);

expect(result).not.toBeUndefined();
Expand All @@ -222,9 +216,9 @@ describe('lu operation', () => {
const id = 'root';
const content = '## hello \n - hello2';
const luFiles = await proj.updateLuFile(id, content);
const result = luFiles.find(f => f.id === id);
const result = luFiles.find(f => f.id === id) as LUResource;

expect(proj.files.length).toEqual(8);
expect(proj.resources.length).toEqual(8);
expect(luFiles.length).toEqual(4);

expect(result).not.toBeUndefined();
Expand All @@ -234,19 +228,12 @@ describe('lu operation', () => {
}
});

it('should throw error when lu content is invalid', async () => {
const id = 'root';
const content = 'hello \n hello3';

await expect(proj.updateLuFile(id, content)).rejects.toThrow();
});

it('should delete lu file and update index', async () => {
const id = 'root';
const luFiles = await proj.removeLuFile(id);
const result = luFiles.find(f => f.id === id);
const result = luFiles.find(f => f.id === id) as LUResource;

expect(proj.files.length).toEqual(7);
expect(proj.resources.length).toEqual(7);
expect(luFiles.length).toEqual(3);

expect(result).toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ describe('get unpublishedFiles', () => {
const luPublisher = new LuPublisher(botDir, storage);
await luPublisher.loadStatus(['bot1/a.lu', 'bot1/b.lu']); // relative path is key

let files = await luPublisher.getUnpublisedFiles(lufiles);
let files = lufiles.filter(x => luPublisher.isUnPublished(x.relativePath));
expect(files.length).toBe(2);
const curTime = Date.now();
luPublisher.status['bot1/a.lu'].lastPublishTime = curTime; // assumming we publish a.lu
luPublisher.status['bot1/b.lu'].lastPublishTime = curTime; // and b.lu
files = await luPublisher.getUnpublisedFiles(lufiles);
files = lufiles.filter(x => luPublisher.isUnPublished(x.relativePath));
expect(files.length).toBe(0);

await luPublisher.onFileChange('bot1/a.lu', FileUpdateType.UPDATE);
files = await luPublisher.getUnpublisedFiles(lufiles);
files = lufiles.filter(x => luPublisher.isUnPublished(x.relativePath));
expect(files.length).toBe(1);
});
});
Loading