jsfe 1.57.0 → 1.58.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.
@@ -1 +1 @@
1
- {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AA4GA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAiGD;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEC;AACD;;;GAGG;AACH;;;;;;EAGC;AAmlBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AAp4BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8H9G,4CAEqI;AA29BrI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
1
+ {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../../src/forms/flows.js"],"names":[],"mappings":"AA4GA;;;;;;;GAOG;AACH;;;;GAIG;AACH,8HAA8H;AAC9H,uFAIC;AAsGD;;2EAE2E;AAC3E,qEAEC;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEC;AACD;;;GAGG;AACH;;;;;;EAGC;AAmlBD,wHAAwH;AACxH,wEAaC;AACD,4FAA4F;AAC5F;;;EAYC;AACD,sGAAsG;AACtG;;;EAOC;AAz4BM,6CAAuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkI9G,4CAEqI;AA49BrI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOG"}
@@ -157,13 +157,17 @@ function validateAcceptanceDeclarations(id, inputs) {
157
157
  * names, and fills {input: part} fills inputs of this form with its locality (and, for a combobox, the code's other
158
158
  * localities as its options) or admin_area.
159
159
  * - control 'combobox': a choice that also takes other text (accept_other), drawn as a text box offering its choices.
160
+ * - control 'options' {options_from}: a text box with ready replies the card offers beside it (buttons, or a list when there
161
+ * are many). options_from names the form data holding them, [{key, label, label_es?}]; a pick submits its key as the
162
+ * typed reply would be, so the profile reads it unchanged and no channel without a card is affected.
160
163
  * - autofill: the HTML autocomplete token the browser may fill the box from (a saved address, name, email or phone).
161
164
  * Checked at definition time; malformed fails.
162
165
  */
163
166
  const FORM_CLIENT_KEYS = { date: ['control', 'range_from', 'min', 'max', 'timezone', 'autofill'], number: ['control', 'min', 'max', 'autofill'],
164
- place: ['control', 'types', 'regions', 'fills', 'autofill'], postal: ['control', 'regions', 'fills', 'autofill'], combobox: ['control', 'autofill'], none: ['autofill'] };
167
+ place: ['control', 'types', 'regions', 'fills', 'autofill'], postal: ['control', 'regions', 'fills', 'autofill'], combobox: ['control', 'autofill'],
168
+ options: ['control', 'options_from', 'autofill'], none: ['autofill'] };
165
169
  const FORM_CLIENT_KINDS = ['pattern', 'text', 'digits', 'amount', 'identifier'];
166
- const FORM_CONTROL_KINDS = { place: ['pattern', 'text'], postal: ['digits', 'pattern', 'text', 'identifier'], combobox: ['choice'],
170
+ const FORM_CONTROL_KINDS = { place: ['pattern', 'text'], postal: ['digits', 'pattern', 'text', 'identifier'], combobox: ['choice'], options: ['pattern', 'text'],
167
171
  none: ['pattern', 'text', 'digits', 'amount', 'identifier', 'email', 'phone', 'choice'] };
168
172
  const FORM_PLACE_TYPES = ['cities', 'address'];
169
173
  const FORM_FILL_PARTS = { place: ['postal_code', 'locality', 'admin_area', 'country'], postal: ['locality', 'admin_area'] };
@@ -182,7 +186,7 @@ function validateFormClientControls(id, inputs) {
182
186
  else if (!declared || typeof declared !== 'object' || Array.isArray(declared))
183
187
  fail(input, 'must be false or {control?, autofill?, ...}');
184
188
  else if (declared.control !== undefined && (declared.control === 'none' || !Object.hasOwn(FORM_CLIENT_KEYS, declared.control)))
185
- fail(input, 'control must be "date", "number", "place", "postal" or "combobox"');
189
+ fail(input, 'control must be "date", "number", "place", "postal", "combobox" or "options"');
186
190
  else { /* a control object, or autofill alone; checked below */ }
187
191
  const control = declared.control ?? 'none';
188
192
  const extra = Object.keys(declared).filter((key) => !FORM_CLIENT_KEYS[control].includes(key));
@@ -198,6 +202,8 @@ function validateFormClientControls(id, inputs) {
198
202
  fail(input, `autofill ${JSON.stringify(declared.autofill)} is not one of ${FORM_AUTOFILL_TOKENS.join(', ')}`);
199
203
  if (control === 'combobox' && (input.profile || {}).accept_other !== true)
200
204
  fail(input, 'combobox needs a choice that accepts other text (accept_other)');
205
+ if (control === 'options' && (typeof declared.options_from !== 'string' || !/^[A-Za-z_]\w{0,63}$/.test(declared.options_from)))
206
+ fail(input, 'options needs options_from: the name of the form data holding the replies');
201
207
  for (const key of ['min', 'max'])
202
208
  if (declared[key] !== undefined && !Number.isInteger(declared[key]))
203
209
  fail(input, `${key} must be a whole number`);
@@ -1 +1 @@
1
- {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SAwGC;AAMD;;;;;;;;GAQG;AACH;;;;;;;;SAoBC;AAED;;;;yGAIyG;AACzG,oDAyBC;AACD,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SA4CC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BC;AAzSD,qCAAsC,eAAe,CAAC"}
1
+ {"version":3,"file":"form-client.d.ts","sourceRoot":"","sources":["../../src/forms/form-client.js"],"names":[],"mappings":"AAiCA,iGAAiG;AACjG;;;;;SAoHC;AAMD;;;;;;;;GAQG;AACH;;;;;;;;SAoBC;AAED;;;;yGAIyG;AACzG,oDAyBC;AACD,+GAA+G;AAC/G;wHACwH;AACxH,qEAWC;AAED;;;;SA4CC;AAED;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BC;AArTD,qCAAsC,eAAe,CAAC"}
@@ -132,6 +132,20 @@ export function projectForm(session, flows) {
132
132
  else if (control === 'combobox') {
133
133
  field.control = control;
134
134
  }
135
+ else if (control === 'options') {
136
+ // Ready replies beside the box: a pick is submitted as its key, read by the profile like typed text.
137
+ field.control = control;
138
+ const offered = state.data?.[input.form_client.options_from];
139
+ const options = new Map();
140
+ for (const option of Array.isArray(offered) ? offered : []) {
141
+ const key = option && (typeof option.key === 'string' || typeof option.key === 'number') ? String(option.key) : '';
142
+ const optionLabel = option ? (language === 'es' ? option.label_es || option.label : option.label) : '';
143
+ if (key && !options.has(key))
144
+ options.set(key, { key, label: typeof optionLabel === 'string' && optionLabel ? optionLabel : key });
145
+ else { /* no key, or a key already offered */ }
146
+ }
147
+ field.options = [...options.values()];
148
+ }
135
149
  else { /* the profile's own box */ }
136
150
  // The browser may fill the box from its saved data (an address, a name).
137
151
  if (input.form_client?.autofill && !field.sensitive)
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:c29fa529bb5527d049229ecc264171f035aa5a275f1ac7900cf2fed042362f54";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:e9c8f01a25b15ca5aa5b82f2c97e9c7e033af282e567a4361413603b69df9f04";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.57.0",
3
+ "version": "1.58.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",