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

Commit bf4aefe

Browse files
authored
Nigao/splitlibrary (#583)
* move missing functions to library-Missing.lg * move assign functions to library-Assign.lg * separate choose and help from library.lg * separate read fact/form from library.lg * remove unused functions from library.lg
1 parent 504c004 commit bf4aefe

File tree

12 files changed

+167
-168
lines changed

12 files changed

+167
-168
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
>>> This is because of issues around ' and } in strings--see enumEntityDesired.lg for a test case
55
# template
6-
- @{propertyEntity()}\n@{chooseEntity()}\n\[library.lg]
6+
- @{propertyEntity()}\n@{chooseEntity()}\n\[library.lg]\n\[library-Choose.lg]
77

88
# chooseEntity
99
- # choose@{property}Entity\n- @\{chooseEnumEntity(@{concat("'", property, "'")})\}\n

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- @{propertyFilename()}
33

44
# template
5-
- @{AskTemplate()}\n@{NameTemplate()}\n@{ValueTemplate()}\n\[@{schemaName}-@{property}Entity.@{locale}.lg]\n\[library.lg]
5+
- @{AskTemplate()}\n@{NameTemplate()}\n@{ValueTemplate()}\n\[@{schemaName}-@{property}Entity.@{locale}.lg]\n\[library.lg]\n\[library-Missing.lg]
66

77
# AskTemplate
88
- # Ask@{property}\n- @\{askEnum('@{property}')\}\n
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# numberValidation(property, number)
2+
- IF: @{less(number, dialogClass.schema.properties[property].minimum)}
3+
- @{number} is less than the minimum value @{dialogClass.schema.properties[property].minimum}.
4+
- ELSEIF: @{greater(number, dialogClass.schema.properties[property].maximum)}
5+
- @{number} is greater than the maximum value @{dialogClass.schema.properties[property].maximum}.
6+
7+
# unitsAlert(property)
8+
- IF: @{dialogClass.schema.properties[property].$units}
9+
- Required response for @{property} should be in @{dialogClass.schema.properties[property].$units}.
10+
- ELSE:
11+
- Unit for @{property} is not defined in the schema.
12+
13+
# setObjectPropertyMessage(property, val)
14+
- IF: @{contains($expectedProperties, property)}
15+
-
16+
- ELSEIF: @{dialog[property]}
17+
- @{name(property)} is changed from @{join(foreach(dialogClass.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')} to @{val}.
18+
- ELSE:
19+
- @{name(property)} is set as @{val}.
20+
21+
# setPropertyMessage(property, val)
22+
- IF: @{contains($expectedProperties, property)}
23+
-
24+
- ELSE:
25+
- @{setUnexpectedPropertyMessage(property, val)}
26+
27+
# setUnexpectedPropertyMessage(property, val)
28+
- IF:@{dialog[property]}
29+
- @{unexpectedPropertyChange(property, val, dialog[property])}
30+
- ELSE:
31+
- @{unexpectedPropertySet(property, val)}
32+
33+
# unexpectedPropertySet(property, val)
34+
- @{name(property)} is set as @{value(property, val)}.
35+
36+
# unexpectedPropertyChange(property, val, oldVal)
37+
- @{name(property)} is changed from @{value(property, oldVal)} to @{value(property, val)}.
38+
39+
[library.lg]
40+
[library-ReadForm.lg]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# chooseEnumEntity(property)
2+
- ```
3+
@{askHelp()}
4+
Please choose a value for @{name(property)} from \[@{join(foreach(turn.dialogEvent.value.entity.value, val, enumEntityValue(property, val)), ', ')}\]
5+
```
6+
7+
# chooseProperties
8+
- Did you mean @{join(foreach(turn.dialogevent.value, choice, choosePropertyEntity(choice)), " or ")}
9+
10+
# choosePropertyEntity(property)
11+
- "@{property.entity.text}" as @{name(property.property)}
12+
13+
[library.lg]
14+
[library-Help.lg]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# askHelp
2+
- IF: @{$retries > 0 && $lastIntent != 'Help'}
3+
- @{join(foreach($expectedProperties, expected, help1(expected)), '\n')}
4+
- ELSE:
5+
-
6+
7+
# help(property)
8+
- IF: @{property}
9+
- @{help1(property)}
10+
- ELSEIF: @{$expectedProperties}
11+
- @{join(foreach($expectedProperties, expected, help1(expected)), '\n')}
12+
- ELSE:
13+
- @{requiredProperties()}\n@{optionalProperties()}\nYou can find out about a specific property by doing 'help <property>'.
14+
15+
# help1(property)
16+
- IF: @{dialogClass.schema.properties[property].enum}
17+
- Possible values for @{name(property)} include: \[@{join(possibleValues(property), ', ')}\]
18+
- ELSEIF: @{dialogClass.schema.properties[property].type == 'number'}
19+
- Expect a number for @{name(property)}
20+
- ELSEIF: @{dialogClass.schema.properties[property].type == 'string'}
21+
- Enter any string for @{name(property)}
22+
- ELSE:
23+
- No help available.
24+
25+
[library.lg]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# askEnum(property)
2+
- ```
3+
@{askHelp()}
4+
Which value do you want for @{name(property)}?
5+
```
6+
7+
# askNumber(property)
8+
- IF: @{dialogClass.schema.properties[property].minimum && dialogClass.schema.properties[property].maximum}
9+
- Enter a number for @{name(property)} between @{dialogClass.schema.properties[property].minimum} and @{dialogClass.schema.properties[property].maximum}
10+
- ELSEIF: @{dialogClass.schema.properties[property].minimum}
11+
- Enter a number for @{name(property)} that is greater than @{dialogClass.schema.properties[property].minimum}
12+
- ELSEIF: @{dialogClass.schema.properties[property].maximum}
13+
- Enter a number for @{name(property)} that is less than @{dialogClass.schema.properties[property].maximum}
14+
- ELSE:
15+
- Enter a number for @{name(property)}
16+
17+
# askString(property)
18+
- ```
19+
@{askHelp()}
20+
Enter a value for @{name(property)}
21+
```
22+
23+
[library.lg]
24+
[library-Help.lg]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# readForm
2+
[Activity
3+
Attachments=@{json(formCard())}
4+
]
5+
6+
>>> To generate text instead of card, use this
7+
# formText
8+
- @{join(foreach(dialog.requiredProperties, property, textProperty(property)), ', ')}
9+
10+
# textProperty(property)
11+
- IF: @{dialog[property] == null}
12+
- The value of @{toLower(property)} is empty.
13+
- ELSEIF: @{dialogClass.schema.properties[property].required}
14+
- The value of @{toLower(property)} is @{join(foreach(dialogClass.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')}.
15+
- ELSE:
16+
- The value of @{toLower(property)} is @{dialog[property]}.
17+
18+
# formCard
19+
-```
20+
{
21+
"type": "AdaptiveCard",
22+
"version": "1.0",
23+
"body": [
24+
{
25+
"type": "TextBlock",
26+
"text": "sandwich",
27+
"size": "large"
28+
},
29+
{
30+
"type": "FactSet",
31+
"facts": [@{requiredFacts()}]
32+
}
33+
],
34+
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
35+
}
36+
```
37+
38+
39+
> TODO: It would be nice to able to include bound optional properties as well.
40+
> Once we have support in foreach for objects we can expand this.
41+
# requiredFacts
42+
- @{join(foreach(dialog.requiredProperties, property, fact(property)), ', ')}
43+
44+
# fact(property)
45+
- IF: @{dialogClass.schema.properties[property].required}
46+
- {"title": "@{name(property)}", "value": "@{join(foreach(dialogClass.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')}"}
47+
- ELSE:
48+
- {"title": "@{name(property)}", "value": "@{value(property, dialog[property])}"}
49+
50+
# subFact(property, subproperty)
51+
- @{dialog[property][subproperty]}
52+
53+
[library.lg]

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

Lines changed: 1 addition & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,6 @@
1212
# enumEntityValue(property, val)
1313
- @{template(concat(property, 'Entity'), val)}
1414

15-
>>> Ask prompts <<<
16-
17-
> TODO: We should look at the schema and if a few items list them or do cards or..
18-
# askEnum(property)
19-
- ```
20-
@{askHelp()}
21-
Which value do you want for @{name(property)}?
22-
```
23-
24-
# askNumber(property)
25-
- IF: @{dialogClass.schema.properties[property].minimum && dialogClass.schema.properties[property].maximum}
26-
- Enter a number for @{name(property)} between @{dialogClass.schema.properties[property].minimum} and @{dialogClass.schema.properties[property].maximum}
27-
- ELSEIF: @{dialogClass.schema.properties[property].minimum}
28-
- Enter a number for @{name(property)} that is greater than @{dialogClass.schema.properties[property].minimum}
29-
- ELSEIF: @{dialogClass.schema.properties[property].maximum}
30-
- Enter a number for @{name(property)} that is less than @{dialogClass.schema.properties[property].maximum}
31-
- ELSE:
32-
- Enter a number for @{name(property)}
33-
34-
# numberValidation(property, number)
35-
- IF: @{less(number, dialogClass.schema.properties[property].minimum)}
36-
- @{number} is less than the minimum value @{dialogClass.schema.properties[property].minimum}.
37-
- ELSEIF: @{greater(number, dialogClass.schema.properties[property].maximum)}
38-
- @{number} is greater than the maximum value @{dialogClass.schema.properties[property].maximum}.
39-
40-
# unitsAlert(property)
41-
- IF: @{dialogClass.schema.properties[property].$units}
42-
- Required response for @{property} should be in @{dialogClass.schema.properties[property].$units}.
43-
- ELSE:
44-
- Unit for @{property} is not defined in the schema.
45-
46-
# askString(property)
47-
- ```
48-
@{askHelp()}
49-
Enter a value for @{name(property)}
50-
```
51-
52-
# askHelp
53-
- IF: @{$retries > 0 && $lastIntent != 'Help'}
54-
- @{join(foreach($expectedProperties, expected, help1(expected)), '\n')}
55-
- ELSE:
56-
-
57-
58-
# help(property)
59-
- IF: @{property}
60-
- @{help1(property)}
61-
- ELSEIF: @{$expectedProperties}
62-
- @{join(foreach($expectedProperties, expected, help1(expected)), '\n')}
63-
- ELSE:
64-
- @{requiredProperties()}\n@{optionalProperties()}\nYou can find out about a specific property by doing 'help <property>'.
65-
66-
# help1(property)
67-
- IF: @{dialogClass.schema.properties[property].enum}
68-
- Possible values for @{name(property)} include: \[@{join(possibleValues(property), ', ')}\]
69-
- ELSEIF: @{dialogClass.schema.properties[property].type == 'number'}
70-
- Expect a number for @{name(property)}
71-
- ELSEIF: @{dialogClass.schema.properties[property].type == 'string'}
72-
- Enter any string for @{name(property)}
73-
- ELSE:
74-
- No help available.
75-
7615
# requiredProperties
7716
- IF: @{count(dialogClass.schema.required) > 0}
7817
- Required properties include: @{join(foreach(dialogClass.schema.required, property, name(property)), ',')}\n
@@ -90,104 +29,15 @@ Enter a value for @{name(property)}
9029
# possibleValues(property)
9130
- @{foreach(dialogClass.schema.properties[property].enum, enum, value(property, enum))}
9231

93-
# chooseEnumEntity(property)
94-
- ```
95-
@{askHelp()}
96-
Please choose a value for @{name(property)} from \[@{join(foreach(turn.dialogEvent.value.entity.value, val, enumEntityValue(property, val)), ', ')}\]
97-
```
98-
9932
# cancel
10033
- Do you want to end the conversation? (yes/no)
10134

102-
# setObjectPropertyMessage(property, val)
103-
- IF: @{contains($expectedProperties, property)}
104-
-
105-
- ELSEIF: @{dialog[property]}
106-
- @{name(property)} is changed from @{join(foreach(dialogClass.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')} to @{val}.
107-
- ELSE:
108-
- @{name(property)} is set as @{val}.
109-
110-
# setPropertyMessage(property, val)
111-
- IF: @{contains($expectedProperties, property)}
112-
-
113-
- ELSE:
114-
- @{setUnexpectedPropertyMessage(property, val)}
115-
116-
# setUnexpectedPropertyMessage(property, val)
117-
- IF:@{dialog[property]}
118-
- @{unexpectedPropertyChange(property, val, dialog[property])}
119-
- ELSE:
120-
- @{unexpectedPropertySet(property, val)}
121-
122-
# unexpectedPropertySet(property, val)
123-
- @{name(property)} is set as @{value(property, val)}.
124-
125-
# unexpectedPropertyChange(property, val, oldVal)
126-
- @{name(property)} is changed from @{value(property, oldVal)} to @{value(property, val)}.
127-
128-
# chooseProperties
129-
- Did you mean @{join(foreach(turn.dialogevent.value, choice, choosePropertyEntity(choice)), " or ")}
130-
131-
# choosePropertyEntity(property)
132-
- "@{property.entity.text}" as @{name(property.property)}
133-
134-
# readForm
135-
[Activity
136-
Attachments=@{json(formCard())}
137-
]
138-
139-
>>> To generate text instead of card, use this
140-
# formText
141-
- @{join(foreach(dialog.requiredProperties, property, textProperty(property)), ', ')}
142-
143-
# textProperty(property)
144-
- IF: @{dialog[property] == null}
145-
- The value of @{toLower(property)} is empty.
146-
- ELSEIF: @{dialogClass.schema.properties[property].required}
147-
- The value of @{toLower(property)} is @{join(foreach(dialogClass.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')}.
148-
- ELSE:
149-
- The value of @{toLower(property)} is @{dialog[property]}.
150-
15135
# confirmChangeProperty(property)
15236
- IF: @{dialog[property]}
15337
- Do you want to change the value of @{toLower(property)}? (yes or no)
15438
- ELSE:
15539
- Do you want to add a value for @{toLower(property)}? (yes or no)
15640

157-
# formCard
158-
-```
159-
{
160-
"type": "AdaptiveCard",
161-
"version": "1.0",
162-
"body": [
163-
{
164-
"type": "TextBlock",
165-
"text": "sandwich",
166-
"size": "large"
167-
},
168-
{
169-
"type": "FactSet",
170-
"facts": [@{requiredFacts()}]
171-
}
172-
],
173-
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
174-
}
175-
```
176-
177-
> TODO: It would be nice to able to include bound optional properties as well.
178-
> Once we have support in foreach for objects we can expand this.
179-
# requiredFacts
180-
- @{join(foreach(dialog.requiredProperties, property, fact(property)), ', ')}
181-
182-
# fact(property)
183-
- IF: @{dialogClass.schema.properties[property].required}
184-
- {"title": "@{name(property)}", "value": "@{join(foreach(dialogClass.schema.properties[property].required, subproperty, subFact(property, subproperty)), ' ')}"}
185-
- ELSE:
186-
- {"title": "@{name(property)}", "value": "@{value(property, dialog[property])}"}
187-
188-
# subFact(property, subproperty)
189-
- @{dialog[property][subproperty]}
190-
19141
# confirmChange
19242
- Is there any property you want to change? (no or the property name)
19343

@@ -197,18 +47,6 @@ Please choose a value for @{name(property)} from \[@{join(foreach(turn.dialogEve
19747
# notUnderstood
19848
- Sorry, I do not understand @{join(foreach(turn.unrecognizedtext, chunk, concat("'", chunk, "'")), ' or ')}\n
19949

200-
# CompleteConfirmationName
201-
- confirmation
202-
203-
# CompleteConfirmation(value)
204-
- @{Confirmation(value)}
205-
206-
# PropertyToChangeName
207-
- property
208-
209-
# PropertyToChange(value)
210-
- @{PROPERTYName(value)}
211-
21250
> TODO: Would be good to split out all the component pieces, i.e. help, cancel, confirmation into their own files
21351
[library-PROPERTYName.lg]
214-
[library-ConfirmationEntity.lg]
52+
[library-ConfirmationEntity.lg]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- @{propertyFilename()}
33

44
# template
5-
- @{AskTemplate()}\n@{NameTemplate()}\n@{ValueTemplate()}\n\[@{schemaName}-@{property}Entity.@{locale}.lg]\n\[library.lg]
5+
- @{AskTemplate()}\n@{NameTemplate()}\n@{ValueTemplate()}\n\[@{schemaName}-@{property}Entity.@{locale}.lg]\n\[library.lg]\n\[library-Missing.lg]
66

77
# AskTemplate
88
- # Ask@{property}\n- @\{askNumber('@{property}')\}\n

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- @{propertyFilename()}
33

44
# template
5-
- @{AskTemplate()}\n@{NameTemplate()}\n\[library.lg]
5+
- @{AskTemplate()}\n@{NameTemplate()}\n\[library.lg]\n\[library-Missing.lg]
66

77
# AskTemplate
88
- # Ask@{property}\n- @\{askString('@{property}')\}\n

0 commit comments

Comments
 (0)