jsfe 1.46.0 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@ npm i jsfe
14
14
  - **[README.md](README.md)** - Technical API reference (this document)
15
15
  - **[Flows architecture guide](docs/architecture-guide.md)** - start here: the concepts, the building blocks, what the caller experiences, and how conversational AI and exact transactional flows work together (the reply ranker and DISPATCH)
16
16
  - **[Flow author reference](docs/copilot-reference.md)** - the authoritative engine and JSON authoring specification for flow authors and AI flow generators (shipped in the package; the Flow Designer's CoPilot reads it from the published version, so change it with the engine)
17
- - **[Form client adapter](docs/form-client.md)** - optional: a host renders the pending FORM question as a form for a capable client and reads its strict named submission through the same FORM workers; an input may name its control (`form_client`: date, date range, number since jsfe 1.44.0; place (city or address suggestions from the host) since 1.46.0)
17
+ - **[Form client adapter](docs/form-client.md)** - optional: a host renders the pending FORM question as a form for a capable client and reads its strict named submission through the same FORM workers; an input may name its control (`form_client`: date, date range, number since jsfe 1.44.0; place (city or address suggestions from the host) since 1.46.0, narrowed by other fields (`context`) since 1.47.0)
18
18
  - **[Development candidate acceptance](docs/development-release.md)** - reproducible package and cross-repository verification
19
19
  - **[System Flows](docs/flows/system/README.md)** and **[Shopify Flows](docs/flows/shopify/README.md)** - the bundled flow and tool libraries in `flows/`: a page and a chart per flow, generated from the JSON (`node scripts/flow-docs.mjs`), plus the conventions the system flows share
20
20
 
@@ -17,7 +17,7 @@ const address = defineForm({ id: 'collect-geocoded-address', name: 'CollectGeoco
17
17
  inputs: [{ name: 'zip', field: 'zip', argument_description: '5-digit ZIP code', names: ['zip', 'zip code', 'postal code', 'código postal', 'codigo postal'], validator: 'address-zip-validate', prepare: 'address-zip-prompt', question_from: 'zip_question', question: 'What is the 5-digit zip code of your new address?', question_es: '¿Cuál es el código postal de 5 dígitos de su nueva dirección?' },
18
18
  { name: 'city', argument_description: 'city name alone', label: 'city', label_es: 'ciudad', names: ['city', 'ciudad'], profile: { kind: 'choice', choices: [], accept_other: true, other_needs_letter: true }, choices_from: 'city_choices', when: { 'form.data.city_known': true }, depends_on: ['zip'], reset_on: ['zip'], prepare: 'address-city-prompt', question_from: 'city_question', question: 'Which city is it?', question_es: '¿Qué ciudad es?' },
19
19
  { name: 'city_state', argument_description: 'city and state', label: 'city and state', label_es: 'ciudad y estado', names: ['city', 'ciudad'], profile: { kind: 'text' }, when: { 'form.data.need_city': true }, depends_on: ['zip'], question_from: 'city_state_question', question: 'What city and state is that in?', question_es: '¿En qué ciudad y estado está?' },
20
- { name: 'street', argument_description: 'street number and street name, without the apartment', label: 'street address', label_es: 'dirección', names: ['street', 'calle'], profile: { kind: 'pattern', regex: streetPattern, spoken_digits: 'house_number', accept_other: true }, depends_on: ['zip'], validator: 'address-street-validate', prepare: 'address-street-prompt', question_from: 'street_question', question: 'What is the street address?', question_es: '¿Cuál es la dirección?' },
20
+ { name: 'street', argument_description: 'street number and street name, without the apartment', label: 'street address', label_es: 'dirección', names: ['street', 'calle'], profile: { kind: 'pattern', regex: streetPattern, spoken_digits: 'house_number', accept_other: true }, depends_on: ['zip'], validator: 'address-street-validate', prepare: 'address-street-prompt', question_from: 'street_question', question: 'What is the street address?', question_es: '¿Cuál es la dirección?', form_client: { control: 'place', types: 'address', regions: ['us'], context: ['zip'] } },
21
21
  { name: 'unit', argument_description: 'apartment or unit number alone, such as 4 or 12B', reset_on: ['street'], label: 'apartment or unit', label_es: 'apartamento o unidad', names: ['apartment', 'apt', 'unit', 'apartamento', 'unidad', 'departamento'], profile: { kind: 'pattern', regex: '(?:\\bapartment|\\bapartamento|\\bdepartamento|\\bapt\\.?|\\bunit|\\bunidad|#)\\s*([\\w-]+)', group: 1, spoken_digits: true, accept_other: true }, question_from: 'unit_question', question: 'Is there an apartment or unit number? Type the number, or NONE.', question_es: '¿Hay un número de apartamento o unidad? Escriba el número, o NINGUNO.' }],
22
22
  before_confirm: [S('address_resolved', 'address_result', E(resolvedAddress, 'cargo.forms[form_instance].values', 'cargo.forms[form_instance].data'))],
23
23
  confirm: { named_fields: true, reply_context: 'This is a mailing address read back for confirmation. A reply may correct one part or several at once: the street number, street name or street type, the apartment or unit, the city, or the ZIP code.', no_keys: ['2', 'not right', 'not correct', 'incorrect', 'wrong', 'no es correcto', 'no es correcta', 'incorrecta'], question: 'Your {{address_label}} is {{address_result.line}}. Is that correct?', question_es: 'Su {{address_label_es}} es {{address_result.line}}. ¿Es correcta?' },
@@ -1 +1 @@
1
- {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AAgHA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAiED;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEC;AACD;;;GAGG;AACH;;;;;;EAGC;AA+lBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AAp3BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8kC9G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
1
+ {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AAgHA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AA2ED;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEC;AACD;;;GAGG;AACH;;;;;;EAGC;AA+lBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AA93BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwlC9G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
@@ -154,9 +154,10 @@ function validateAcceptanceDeclarations(id, inputs) {
154
154
  * regions?}. A date's min and max are whole days from today in `timezone` (required with either); range_from names the
155
155
  * start of a range, a date input of this form that is not itself an end. A number's min and max bound its value. A
156
156
  * place suggests what the caller types from the host's place service: types 'cities' or 'address', regions up to 15
157
- * ISO 3166-1 alpha-2 country codes. Checked at definition time; malformed fails.
157
+ * ISO 3166-1 alpha-2 country codes, context up to 5 other inputs of this form whose values narrow the lookup (a ZIP code
158
+ * for a street). Checked at definition time; malformed fails.
158
159
  */
159
- const FORM_CLIENT_KEYS = { date: ['control', 'range_from', 'min', 'max', 'timezone'], number: ['control', 'min', 'max'], place: ['control', 'types', 'regions'] };
160
+ const FORM_CLIENT_KEYS = { date: ['control', 'range_from', 'min', 'max', 'timezone'], number: ['control', 'min', 'max'], place: ['control', 'types', 'regions', 'context'] };
160
161
  const FORM_CLIENT_KINDS = ['pattern', 'text', 'digits', 'amount', 'identifier'];
161
162
  const FORM_PLACE_KINDS = ['pattern', 'text'];
162
163
  const FORM_PLACE_TYPES = ['cities', 'address'];
@@ -214,6 +215,19 @@ function validateFormClientControls(id, inputs) {
214
215
  !declared.regions.every((region) => typeof region === 'string' && /^[a-z]{2}$/i.test(region))))
215
216
  fail(input, 'regions must be 1 to 15 two-letter country codes');
216
217
  else { /* any region, or a valid list */ }
218
+ if (declared.context !== undefined) {
219
+ if (!Array.isArray(declared.context) || !declared.context.length || declared.context.length > 5)
220
+ fail(input, 'context must list 1 to 5 inputs of this form');
221
+ for (const name of declared.context) {
222
+ const other = all.find((candidate) => candidate.name === name);
223
+ if (!other || other === input)
224
+ fail(input, `context ${JSON.stringify(name)} must name another input of this form`);
225
+ else if (other.pii === true)
226
+ fail(input, `context ${name} is a sensitive input`);
227
+ else { /* a field whose value narrows the lookup */ }
228
+ }
229
+ }
230
+ else { /* no context */ }
217
231
  }
218
232
  else { /* a number */ }
219
233
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SA0FC;AAED,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SAgCC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BC;AA1MD,qCAAsC,eAAe,CAAC"}
1
+ {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SA2FC;AAED,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SAgCC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BC;AA3MD,qCAAsC,eAAe,CAAC"}
@@ -122,7 +122,8 @@ export function projectForm(session, flows) {
122
122
  else if (control === 'place') {
123
123
  // Suggestions come from the host's place service; the profile's bounds still apply to the typed text.
124
124
  field.control = control;
125
- field.place = { types: input.form_client.types, ...(input.form_client.regions ? { regions: input.form_client.regions.map(region => region.toLowerCase()) } : {}) };
125
+ field.place = { types: input.form_client.types, ...(input.form_client.regions ? { regions: input.form_client.regions.map(region => region.toLowerCase()) } : {}),
126
+ ...(input.form_client.context ? { context: input.form_client.context.map(name => prefix + name) } : {}) };
126
127
  }
127
128
  else { /* the profile's own box */ }
128
129
  if (!field.sensitive && ['string', 'number', 'boolean'].includes(typeof state.values?.[input.name]))
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:6aff62af247bd0e4356b9ee8177b42c88aa95c152f133610d6d2c0e5182267ad";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:05a683dbf62c7941e56bbe7efc025943a8f6d28d614c2ed1e5029eafaedb6a64";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.46.0",
3
+ "version": "1.47.0",
4
4
  "description": "TypeScript workflow engine for conversational/automation apps: multi-flow orchestration, interrupt/resume, stack-based control, robust errors, and flexible tool/REST integration.",
5
5
  "license": "MIT",
6
6
  "author": "Ron Pinkas",