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

Commit 70a1d50

Browse files
author
Chris McConnell
authored
Chrimc/form (#394)
* 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. * Change from $type to $kind. Change unionType to union. Add documentation. * Move from $type to $kind. * Enable schema tests. * Switch to $kind and add dynamic .schema. * Update string to new help pattern. * Merge with master and support $kind. * Address review comments.
1 parent 6c63b41 commit 70a1d50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+194
-172
lines changed

.vscode/launch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@
8383
{
8484
"type": "node",
8585
"request": "launch",
86-
"name": "Generate Sandwich Form",
86+
"name": "Generate Sandwich",
8787
"preLaunchTask": "${defaultBuildTask}",
8888
"program": "${workspaceFolder}/packages/dialog/bin/run",
8989
"outFiles": [
9090
"./packages/dialog/lib/**"
9191
],
9292
"args": [
9393
"dialog:generate",
94-
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/sandwich.form.dialog",
94+
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/sandwich.schema",
9595
"-o",
9696
"${env:TEMP}/sandwich.out",
9797
"--force",
@@ -110,7 +110,7 @@
110110
],
111111
"args": [
112112
"dialog:generate",
113-
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/activity.form.dialog",
113+
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/activity.schema",
114114
"-o",
115115
"${env:TEMP}/activity.out",
116116
"--force",
@@ -131,7 +131,7 @@
131131
],
132132
"args": [
133133
"dialog:generate",
134-
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/contact.form.dialog",
134+
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/contact.schema",
135135
"-o",
136136
"${env:TEMP}/contact.out",
137137
"--force",
@@ -152,7 +152,7 @@
152152
],
153153
"args": [
154154
"dialog:generate",
155-
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/opportunity.form.dialog",
155+
"${workspaceFolder}/packages/dialog/test/commands/dialog/forms/opportunity.schema",
156156
"-o",
157157
"${env:TEMP}/opportunity.out",
158158
"--force",

packages/dialog/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@
2727
"scripts": {
2828
"postpack": "rimraf oclif.manifest.json",
2929
"posttest": "tslint -p test -t stylish",
30-
"build":"tsc -b",
31-
"clean":"rimraf ./.nyc_output ./lib ./package-lock.json ./tsconfig.tsbuildinfo",
30+
"build": "tsc -b",
31+
"clean": "rimraf ./.nyc_output ./lib ./package-lock.json ./tsconfig.tsbuildinfo",
3232
"test": "mocha",
3333
"coverage": "nyc npm run test",
34-
"report:coverage":"npm run coverage && nyc report --reporter=text-lcov | coveralls",
34+
"report:coverage": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
3535
"doc": "npm run build && npm run doc:readme && rimraf oclif.manifest.json",
36-
"doc:readme":"oclif-dev manifest && oclif-dev readme",
36+
"doc:readme": "oclif-dev manifest && oclif-dev readme",
3737
"version": "npm run doc:readme && git add README.md"
3838
},
3939
"dependencies": {
40+
"@christopheranderson/botbuilder-lg": "4.7.0-a0-b6513caa",
41+
"@christopheranderson/botframework-expressions": "4.7.0-a0-b6513caa",
42+
"@microsoft/bf-cli-command": "~1.0.0",
4043
"@oclif/command": "~1.5.13",
4144
"@oclif/errors": "~1.2.2",
42-
"@microsoft/bf-cli-command": "~1.0.0",
4345
"@types/lru-cache": "^5.1.0",
4446
"@types/semver": "^6.0.1",
4547
"@types/xml2js": "^0.4.4",
4648
"ajv": "^6.9.1",
47-
"@christopheranderson/botframework-expressions": "4.7.0-a0-b6513caa",
48-
"@christopheranderson/botbuilder-lg": "4.7.0-a0-b6513caa",
4949
"chalk": "^2.4.2",
5050
"clone": "^2.1.2",
5151
"fs-extra": "^8.1.0",

packages/dialog/src/commands/dialog/generate.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default class GenerateDialog extends Command {
1212
async run() {
1313
const { args, flags } = this.parse(GenerateDialog)
1414
try {
15-
let formName = ppath.basename(args.schema, '.schema.dialog')
15+
let schemaName = ppath.basename(args.schema, '.schema')
1616
let outDir = flags.output
1717
if (!outDir) {
18-
outDir = ppath.join(formName + '-resources')
18+
outDir = ppath.join(schemaName + '-resources')
1919
}
2020
await gen.generate(args.schema, outDir, flags.schema, flags.locale, flags.templates, flags.force,
2121
(type, msg) => {
@@ -46,16 +46,16 @@ export default class GenerateDialog extends Command {
4646
`]
4747

4848
static args = [
49-
{ name: 'schema', required: true, description: 'JSON Schema file used to drive generation.' }
49+
{ name: 'schema', required: true, description: 'JSON Schema .schema file used to drive generation.' }
5050
]
5151

5252
static flags: flags.Input<any> = {
5353
force: flags.boolean({ char: 'f', description: 'Force overwriting generated files.' }),
5454
help: flags.help({ char: 'h' }),
5555
locale: flags.string({ char: 'l', description: 'Locales to generate. [default: en-us]', multiple: true }),
56-
output: flags.string({ char: 'o', description: 'Output path for where to put generated .lu, .lg, .qna and .dialog files. [default: ./<form>-resources]', default: '.', required: false }),
56+
output: flags.string({ char: 'o', description: 'Output path for where to put generated .lu, .lg, .qna and .dialog files. [default: .]', default: '.', required: false }),
5757
schema: flags.string({ char: 's', description: 'Path to your app.schema file.', required: false }),
58-
templates: flags.string({ char: 't', description: 'Directory with templates to use for generating form assets.', multiple: true }),
58+
templates: flags.string({ char: 't', description: 'Directory with templates to use for generating assets.', multiple: true }),
5959
verbose: flags.boolean({ description: 'Output verbose logging of files as they are processed', default: false }),
6060
}
6161
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export default class DialogMerge extends Command {
333333
const prefix = 'union('
334334
if (role === 'expression' || role === 'lg' || role === 'memoryPath') {
335335
if (elt.kind) {
336-
this.error(`${this.currentFile}:error: $role ${role} must not have a type.`)
336+
this.error(`${this.currentFile}:error: $role ${role} must not have a kind.`)
337337
}
338338
for (let prop in metaSchema.definitions[role]) {
339339
if (!elt[prop]) {

packages/dialog/src/commands/dialog/readme.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@ For example look at these files:
2121

2222
# Verify
2323

24-
# Form
24+
# Generate
2525

26-
The form command generates .lu, .lg, .qna and .dialog assets from a schema defined using JSON Schema. The parameters to the command are:
26+
The generate command generates .lu, .lg, .qna and .dialog assets from a schema defined using JSON Schema. The parameters to the command are:
2727

2828
- **--force, -f** Force overwriting generated files.
2929
- **--help, -h** Generate help.
3030
- **--locale, -l** Locales to generate. By default en-us.
3131
- **--output, -o** Output directory.
3232
- **--schema, -s** Path to your app.schema file. By default is the standard SDK app.schema.
33-
- **--templates, -t** Directories with templates to use for generating form assets.
33+
- **--templates, -t** Directories with templates to use for generating assets.
3434
- **--verbose, -v** Verbose logging of generated files.
3535

3636
## Schema
3737

38-
Schemas are specified using JSON Schema. You can use the normal JSON Schema mechanisms including \$ref and allOf which will be resolved into a single schema. In addition there are a few extra keywords including:
38+
Schemas are specified using JSON Schema. You can use the normal JSON Schema mechanisms including \$ref and allOf which will be resolved into a single schema.
39+
You can also use expression syntax, i.e. `@{<expr>}` to compute schema.
40+
In addition there are a few extra keywords including:
3941

4042
- **\$mappings** List of entity names that can map to a property. The order of the entities also defines the precedence to use when resolving entities. By default the mappings are based on the type:
4143
- **enum**
@@ -44,29 +46,30 @@ Schemas are specified using JSON Schema. You can use the normal JSON Schema mech
4446
- **enum**
4547
- **number**, **string**
4648
- **\$expectedOnly** A list of properties that are only possible if they are expected.
47-
- **\$requires** A list of JSON Schema to use for internal mechanisms. You can use either actual paths or just the name of the schema to use if found in one of the template directories. The standard schema is `standard.schema.dialog`. The form schema and all of the required schemas will have the top-level `properties`, `definitions`, `required`, `$expectedOnly` and `$templates` merged.
48-
- **\$triggerIntent** Name of the trigger intent or by default the name of the form.
49+
- **\$public** List of the public properties in the schema. By default these are the top-level properties in the root schema.
50+
- **\$requires** A list of JSON Schema to use for internal mechanisms. You can use either actual paths or just the name of the schema to use if found in one of the template directories. The standard schema is `standard.schema`. The forrootm schema and all of the required schemas will have the top-level `properties`, `definitions`, `required`, `$expectedOnly`, `$public` and `$templates` merged.
51+
- **\$triggerIntent** Name of the trigger intent or by default the name of the schema.
4952

50-
`<form>.form.dialog` will be generated with the form schema in it. `<form>.schema.dialog` will have the whole schema defined.
53+
`<schemaName>.schema.dialog` will have the resulting schema with all references resolved.
5154

5255
## Templates
5356

5457
Each entity or property can have associated .lu, .lg, .qna and .dialog files that are generated by
5558
copying or instantiating templates found in the template directories. If a template name matches exactly it is
56-
just copied. If the template ends with .lg then it is analyzed to see if it has a template named 'template' and optionally one named 'filename'. If 'filename' is specified, then the filename will be the result of generating generated file is the result of evaluating that template, otherwise it defaults to `<formName>-<templateName>[.<locale>].<extension>`. When evaluating templates there are a number of variables defined in the scope including:
59+
just copied. If the template ends with .lg then it is analyzed to see if it has a template named 'template' and optionally one named 'filename'. If 'filename' is specified, then the filename will be the result of generating generated file is the result of evaluating that template, otherwise it defaults to `<root>-<templateName>[.<locale>].<extension>`. When evaluating templates there are a number of variables defined in the scope including:
5760

58-
- **formName** The name of the form being generated.
61+
- **schemaName** The name of the root schema used as a prefix to make files unique.
5962
- **appSchema** The path to the app.schema to use.
60-
- **form** The JSON Schema defining the form.
61-
- **schema** The JSON Schema of the form + internal properties.
63+
- **schema** The full JSON Schema including the root schema + internal properties.
6264
- **locales** The list of all locales being generated.
63-
- **properties** All of the form property names.
65+
- **properties** All of the $public property names.
6466
- **entities** All of the types of schema entities being used.
65-
- **triggerIntent** \$triggerIntent or the form name by default.
67+
- **triggerIntent** \$triggerIntent or the schema name by default.
6668
- **locale** The locale being generated or empty if no locale.
6769
- **property** For per-property templates this the property name being generated.
6870
- **templates** Object with generated templates per lu, lg, qna, json and dialog. The object contains:
6971
- **name** Base name of the template without final extension.
72+
- **fallbackName** For .lg files the base filename without locale.
7073
- **fullName** The name of the template including the extension.
7174
- **relative** Path relative to the output directory of where template is.
7275

@@ -81,3 +84,4 @@ Templates are generated in the following order:
8184
- Per-property
8285
- Per-template in `<property>.$templates` generate .dialog and .json files.
8386
- Per-template in `$templates` generate .dialog and .json files.
87+
- Evaluate schema expressions

0 commit comments

Comments
 (0)