Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 455e79e

Browse files
author
Chris McConnell
authored
Chrimc/form (#384)
* Intermediate check-in before inverting template/prop loops. * Working generator with incomplete templates. * Basic .lu files working. * Update to generate single .lu file. * Fix cli issues. * Fix CLI issues with template resources. * Clean up lint warnings. * Fix lint errors. * Generate composite .lu * Add dialog and multi-language support. * shortcut to debug * Add per-locale .lg file. * Update debug config to use temp directory. Generate multilingual .lg file. * Update to include schema prefix on names. * Fix bugs in .lg genertion. * try help * help and cancel * Copy schema to output directory. * help and cancel version 1 * separate help.lu * several fixes * remove help enum * reset launch.json * remove empty line * Add the ability to copy library dialog files. * Add ability to specify schema and multiple templates. * Rename resources. Support multiple templates. Add *PROPN** pattern. * Fix bug in striingify call. * Generate schema.main.dialog and update config. * Update templates to newest format. * Update templates to match names. * add .dialogs for several basic rules * Update templates to use $ and add begindialog as a hack to work around ada ptive issue. * add .dialogs for several basic rules * fix comments * merge from origin * small changes * Add formCopy cmd file. * Adjust for bug in templates. * fix path * Version 1 of contact.form.dialog * Same info is modeled for both Home and Work. * List of state abbreviations and their spelled-out names are specified in the separate state.en-us.lu, and used in the $mappings specifications. * Latitude and Longitude should be auto-filled if the corresponding address are filled. * Validation patterns are specified for zip codes and phone numbers. * Fixed contact.form.dialog and added activity.form.dialog * contact.form.dialog - Fixed spelling - Use phonenumber prebuilt entity type * activity.form.dialog: the second scenario from Darren "An employee working for a customer wants to add a quick update to a customer record after a call. This update will then be available for other people working with that customer to see". * Added opportunity.form.dialog For Darren's scenario "An employee working with a customer has had a meeting and needs to create a new opportunity." * change names * Revert "change names" This reverts commit 64ffaff. * change names * basic work done for ask, set and help * cancel confirmation * cancel confirmation done, unexpected property set confirmation in progress * improve unexpected property test * Version 1 of contact.form.dialog * Same info is modeled for both Home and Work. * List of state abbreviations and their spelled-out names are specified in the separate state.en-us.lu, and used in the $mappings specifications. * Latitude and Longitude should be auto-filled if the corresponding address are filled. * Validation patterns are specified for zip codes and phone numbers. * Fixed contact.form.dialog and added activity.form.dialog * contact.form.dialog - Fixed spelling - Use phonenumber prebuilt entity type * activity.form.dialog: the second scenario from Darren "An employee working for a customer wants to add a quick update to a customer record after a call. This update will then be available for other people working with that customer to see". * Added opportunity.form.dialog For Darren's scenario "An employee working with a customer has had a meeting and needs to create a new opportunity." * rename state.lu * prebuilt lu templates * remove choose entity we only have chooseProperty and clarifyEntity * Switch to event expected. * Update templates for latest runtime and add ask for multiple properties. * Add **NAMES/**NAME** and generate property names. * fix unexpected property confirmation usage * change unexpected property action from ask to sendactivity * all done confirmation * Update names to support chooseProperty. * Check-in bread value hack. * Fix template bug around clarify. * Update templates to use names and start numbers. * complete the new forms * contextual help * activity schema working fine * add meta info to opportunity schema * opportunity semi-working cannot use phonenumber; properties not in required also got asked; in stringset, default value is not expression, cannot get the value for @email * three schemas working sandwich, activity, opportunity * contact schema working Adding welcome message in beginDialog, Add help message for non-enum properties, All three CDS schemas working * Sync changes for demo. * Before adding mapping templates * Getting close to E2e. * Largely working with some template debugging. * Update the readme. * Update to latest expression and lg packages. Support app schema. * Update standard schema. * Finish merge. * Show metaschema. * Fix readme typo. * several changes (#299) * several changes (1) remove unused old files; (2) change incorrect file names; (3) add string ask templates; (4) remove meta properties from schemas; (5) fix an error in calculating optional properties * fix help property bug * Add string templates. * a few changes (#318) (1) fix the cancel.lu bug (2) add datetime.lu (2) stringSetdatetime.dialog.lg * Add template for not understood. * Connect to bf cli. * Add basic role support. * Nigao/newtemplate (#321) * a few changes (1) fix the cancel.lu bug (2) add datetime.lu (2) stringSetdatetime.dialog.lg * autohelp for new templates * Update to use @{} everywhere and remove auto-help since it required post-ask action. * Nigao/newtemplate (#323) * a few changes (1) fix the cancel.lu bug (2) add datetime.lu (2) stringSetdatetime.dialog.lg * autohelp for new templates * add $requires, and datetime entity sets * add all stringSet for prebuilt entities explicitly * change prebuilt-entity.lu.lg files * Switch to using a triggerIntent instead of none for entities. Cleanup filename expressions. * Fix bug in status. * Switch from dialog:form to dialog:generate * Add top-level documentation. * Update tests to use dialog:generate. * Rename tests to generator. * Fixing linting errors * Generate confirmation card. * Fix reference regex ot not match structured lg. * Minor bug fixes. * Update to allow multi-lingual fallback.
1 parent 4c685ed commit 455e79e

File tree

8 files changed

+36
-33
lines changed

8 files changed

+36
-33
lines changed

packages/dialog/.vscode/launch.json

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"type": "antlr-debug",
9-
"request": "launch",
10-
"name": "Debug Current Grammar",
11-
"input": "test/commands/dialog/forms/input.txt",
12-
"startRule": "doc",
13-
"visualParseTree": true
14-
},
157
{
168
"type": "node",
179
"request": "launch",
@@ -64,17 +56,22 @@
6456
{
6557
"type": "node",
6658
"request": "launch",
67-
"name": "Launch Program",
68-
"program": "${workspaceFolder}\\bin\\run",
59+
"name": "BotBuilder schema",
60+
"program": "${workspaceFolder}/bin/run",
6961
"preLaunchTask": "tsc: build - tsconfig.json",
7062
"outFiles": [
7163
"${workspaceFolder}/lib/**/*.js"
7264
],
7365
"args": [
7466
"dialog:merge",
75-
"-f",
76-
"c:/source/github/botbuilder-dotnet/**/*.schema"
77-
]
67+
"libraries/**/*.schema",
68+
"-u",
69+
"-b", "master",
70+
"-o", "schemas/sdk.schema",
71+
"--verbose"
72+
],
73+
"internalConsoleOptions": "openOnSessionStart",
74+
"cwd": "c:/users/chrimc/source/repos/botbuilder-dotnet"
7875
},
7976
{
8077
"type": "node",
@@ -92,8 +89,6 @@
9289
"${env:TEMP}/sandwich.out",
9390
"--force",
9491
"--verbose",
95-
"--schema",
96-
"https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/chrimc/map/schemas/sdk.schema"
9792
],
9893
"internalConsoleOptions": "openOnSessionStart"
9994
},
@@ -107,7 +102,7 @@
107102
"${workspaceFolder}/lib/**/*.js"
108103
],
109104
"args": [
110-
"dialog:form",
105+
"dialog:generate",
111106
"${workspaceFolder}/test/commands/dialog/forms/activity.form.dialog",
112107
"-o",
113108
"${env:TEMP}/activity.out",
@@ -128,7 +123,7 @@
128123
"${workspaceFolder}/lib/**/*.js"
129124
],
130125
"args": [
131-
"dialog:form",
126+
"dialog:generate",
132127
"${workspaceFolder}/test/commands/dialog/forms/contact.form.dialog",
133128
"-o",
134129
"${env:TEMP}/contact.out",
@@ -149,7 +144,7 @@
149144
"${workspaceFolder}/lib/**/*.js"
150145
],
151146
"args": [
152-
"dialog:form",
147+
"dialog:generate",
153148
"${workspaceFolder}/test/commands/dialog/forms/opportunity.form.dialog",
154149
"-o",
155150
"${env:TEMP}/opportunity.out",

packages/dialog/src/commands/dialog/merge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class DialogMerge extends Command {
3535
static flags: flags.Input<any> = {
3636
help: flags.help({ char: 'h' }),
3737
output: flags.string({ char: 'o', description: 'Output path and filename for merged schema. [default: app.schema]', default: 'app.schema', required: false }),
38-
branch: flags.string({ char: 'b', description: 'The branch to use for the meta-schema component.schema.', default: '4.Future', required: false }),
38+
branch: flags.string({ char: 'b', description: 'The branch to use for the meta-schema component.schema.', default: 'master', required: false }),
3939
update: flags.boolean({ char: 'u', description: 'Update .schema files to point the <branch> component.schema and regenerate component.schema if baseComponent.schema is present.', default: false, required: false }),
4040
verbose: flags.boolean({ description: 'output verbose logging of files as they are processed', default: false }),
4141
}

packages/dialog/src/library/dialogGenerator.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,21 @@ async function replaceAsync(str: string, re: RegExp, callback: (match: string) =
108108
}
109109
110110
const RefPattern = /^\s*\[[^\]\n\r]*\]\s*$/gm
111+
const LocalePattern = /\.[^.]+\.lg$/
111112
async function processLibraryTemplates(template: string, outPath: string, templateDirs: string[], outDir: string, form: any, scope: any, force: boolean, feedback: Feedback): Promise<string> {
112113
if (!template.startsWith('>>> Library')) {
113114
return replaceAsync(template, RefPattern, async (match: string): Promise<string> => {
114115
let replacement = await processTemplate(match.substring(match.indexOf('[') + 1, match.indexOf(']')), templateDirs, outDir, form, scope, force, feedback, false)
116+
replacement = replacement.replace(LocalePattern, '.lg')
115117
let local = ppath.relative(ppath.dirname(outPath), replacement)
116-
return Promise.resolve(`[${ppath.basename(replacement)}](${local})`)
118+
return Promise.resolve(`\n[${ppath.basename(replacement)}](${local})`)
117119
});
118120
} else {
119121
return Promise.resolve(template)
120122
}
121123
}
122124
123-
type FileRef = { name: string, fullName: string, relative: string }
125+
type FileRef = { name: string, fallbackName: string, fullName: string, relative: string }
124126
function addEntry(fullPath: string, outDir: string, tracker: any): FileRef | undefined {
125127
let ref: FileRef | undefined
126128
let basename = ppath.basename(fullPath, '.dialog')
@@ -129,6 +131,7 @@ function addEntry(fullPath: string, outDir: string, tracker: any): FileRef | und
129131
if (!arr.find(ref => ref.name === basename)) {
130132
ref = {
131133
name: basename,
134+
fallbackName: basename.replace(/\.[^.]+\.lg/, '.lg'),
132135
fullName: ppath.basename(fullPath),
133136
relative: ppath.relative(outDir, fullPath)
134137
}
@@ -275,7 +278,7 @@ export async function generate(
275278
}
276279

277280
if (!metaSchema) {
278-
metaSchema = 'https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/chrimc/map/schemas/sdk.schema'
281+
metaSchema = 'https://raw.githubusercontent.com/microsoft/botbuilder-dotnet/chrimc/form/schemas/sdk.schema'
279282
} else if (!metaSchema.startsWith('http')) {
280283
// Adjust relative to outDir
281284
metaSchema = ppath.relative(outDir, metaSchema)

packages/dialog/templates/ChooseProperty.dialog.lg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"actions": [
77
{
88
"$type": "Microsoft.Ask",
9-
"activity": "@{callChooseProperties()}"
9+
"activity": "@{callChooseProperties()}",
10+
"expectedProperties": ["PROPERTYName"]
1011
}
1112
]
1213
}

packages/dialog/templates/Main.dialog.lg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- ```
66
{
77
"$schema": "@{appSchema}",
8-
"$type": "Microsoft.FormDialog",
8+
"$type": "Microsoft.AdaptiveDialog",
99
"recognizer": "@{formName}.lu",
1010
"generator": "@{formName}.lg",
1111
"schema": "@{formName}.schema",

packages/dialog/templates/en-us/common.lg

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ Which value do you want for @{name(property)}?
6060
- ELSE:
6161
-
6262

63+
> TODO: We should enable this when where/foreach works over objects.
6364
# optionalProperties
64-
- IF: @{add(count(turn.schema.required),count(turn.schema.$expectedOnly)) < count(turn.schema.properties)}
65-
- Optional properties include: @{join(foreach(where(turn.form.properties, property, !contains(turn.schema.required && !contains(turn.schema.$expectedOnly, property), property)), property, name(property)), ', ')}\n
66-
- ELSE:
67-
-
65+
-
66+
> - IF: @{add(count(turn.schema.required),count(turn.schema.$expectedOnly)) < count(turn.schema.properties)}
67+
> - Optional properties include: @{join(foreach(where(turn.schema.properties, property, !contains(turn.schema.required, property) && !contains(turn.schema.$expectedOnly, property)), property, name(property)), ', ')}\n
68+
> - ELSE:
69+
> -
6870

6971
# possibleValues(property)
7072
- @{foreach(turn.schema.properties[property].enum, enum, value(property, enum))}
@@ -134,8 +136,8 @@ Please choose a value for @{name(property)} from \[@{join(foreach(turn.dialogEve
134136
}
135137
```
136138

137-
>>> TODO: It would be nice to able to include bound optional properties as well.
138-
>>> Once we have support in foreach for objects we can expand this.
139+
> TODO: It would be nice to able to include bound optional properties as well.
140+
> Once we have support in foreach for objects we can expand this.
139141
# requiredFacts
140142
- @{join(foreach(dialog.requiredProperties, property, fact(property)), ', ')}
141143

@@ -163,4 +165,6 @@ Please choose a value for @{name(property)} from \[@{join(foreach(turn.dialogEve
163165
# PropertyToChange(value)
164166
- @{PROPERTYName(value)}
165167

166-
[PropertyNAME.lg]
168+
> TODO: Would be good to split out all the component pieces, i.e. help, cancel, confirmation into their own files
169+
[PROPERTYName.lg]
170+
[Confirmation.lg]

packages/dialog/templates/en-us/locale.lg.lg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
- @{formName}.@{locale}.lg
33

44
# template
5-
- >>> Library\n@{join(foreach(templates.lg, lg, concat('[', lg.fullName, '](./', lg.fullName, ')')), '\n')}
5+
- >>> Library\n@{join(foreach(templates.lg, lg, concat('[', lg.fallbackName, '](', lg.fallbackName, ')')), '\n')}

packages/dialog/templates/enumAsk.dialog.lg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
```
2626

2727
# callAsk
28-
- @\{Ask{property}()}
28+
- @\{Ask@{property}()}

0 commit comments

Comments
 (0)