jsfe 1.8.0 → 1.8.1

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":"declarations.d.ts","sourceRoot":"","sources":["../../src/forms/declarations.js"],"names":[],"mappings":"AA2FA;;;;GAIG;AACH,+CAJW,GAAG,EAAE,uCACL;IAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAC,GACxD,GAAG,EAAE,CA2DjB;AAED,sGAAsG;AACtG;;;SAAqK;AAuBrK,6FAA6F;AAC7F;;QAuCC"}
1
+ {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/forms/declarations.js"],"names":[],"mappings":"AAmGA;;;;GAIG;AACH,+CAJW,GAAG,EAAE,uCACL;IAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAC,GACxD,GAAG,EAAE,CA+DjB;AAED,sGAAsG;AACtG;;;SAAqK;AAuBrK,6FAA6F;AAC7F;;QAuCC"}
@@ -86,7 +86,15 @@ function describeChoiceValues(flow) {
86
86
  return { ...describeLeaf(input, parameter, { top: true }), jsonSchema: describeSchema(parameter.jsonSchema, input.schema.inputs) };
87
87
  return describeLeaf(input, parameter, { top: true });
88
88
  });
89
- return { ...flow, parameters };
89
+ // Every generated parameter is a variable of the flow, as an authored one is (Form's parametersFor): the flow's
90
+ // expressions read it by name whether or not it was supplied.
91
+ const variables = { ...(flow.variables || {}) };
92
+ for (const parameter of parameters)
93
+ if (!Object.hasOwn(variables, parameter.name)) {
94
+ const type = parameter.type || 'string';
95
+ variables[parameter.name] = { type: type === 'integer' ? 'number' : type, value: type === 'object' ? null : type === 'array' ? [] : type === 'boolean' ? false : type === 'number' || type === 'integer' ? 0 : '' };
96
+ }
97
+ return { ...flow, parameters, variables };
90
98
  }
91
99
  const callSteps = steps => (steps || []).flatMap(step => [step, ...callSteps(Object.values(step.branches || {})), ...(step.onFail ? callSteps([step.onFail]) : [])]);
92
100
  /** Version 2's single parameter contract: a parameter is generated from an input or authored, never both; a call
@@ -107,7 +115,8 @@ function enforceParameterContract(flows, authored, builder, protocol = new Map()
107
115
  const target = byId.get(step.value) || byName.get(step.value);
108
116
  if (!target || target.metadata?.declaration?.version !== 2)
109
117
  continue;
110
- const declared = new Set([...(target.parameters || []).map(parameter => parameter.name), ...(protocol.get(target.id) || [])]);
118
+ // A target compiled earlier (not authored in this call) keeps its protocol variables only as variables.
119
+ const declared = new Set([...(target.parameters || []).map(parameter => parameter.name), ...(protocol.get(target.id) || (target.variables?.form_instance !== undefined ? Object.keys(target.variables) : []))]);
111
120
  for (const name of Object.keys(step.parameters || {}))
112
121
  if (!declared.has(name))
113
122
  fail(flow.id + ' step ' + step.id + ' passes ' + name + ', which ' + target.id + ' does not declare');
@@ -130,7 +139,8 @@ export function compileFlowDeclarations(flows, { tools, externalFlows = [], vali
130
139
  if (libraries.length)
131
140
  flows = flows.filter(flow => !isLibrary(flow));
132
141
  if (!flows.some(flow => flow?.declarationVersion !== undefined)) {
133
- if (Object.keys(shared).length)
142
+ // Already compiled version 2 flows carry the shared functions merged in; the entry adds nothing to them.
143
+ if (Object.keys(shared).length && !flows.some(flow => flow?.metadata?.declaration?.version === 2))
134
144
  fail('shared functions need declarationVersion 2 flows');
135
145
  return flows;
136
146
  }
@@ -1 +1 @@
1
- export const JSFE_RUNTIME_FINGERPRINT = "sha256:1d83b7dde5c1292fc912653a3bb5dc616eca4a6a6dd9323fe3e1f259a8a203ef";
1
+ export const JSFE_RUNTIME_FINGERPRINT = "sha256:e402e6a7004b2f9289aedcb86eb974cf8c7fbf759ec432fb21a815b84356eb61";
@@ -1,3 +1,7 @@
1
+ ## 1.8.1: version 2 fixes found in the first tenant migration
2
+
3
+ A generated parameter is also a variable of its flow, as an authored one always was, so a flow's expressions can read it by name (without it, removing an authored copy left `service is not defined`). Compiling already compiled version 2 flows again keeps working: a FLOW call may pass a compiled form target's protocol variables, and a shared-functions entry beside compiled flows is accepted.
4
+
1
5
  ## 1.8.0: declaration version 2, shared functions, option clarification
2
6
 
3
7
  `declarationVersion: 2` makes parameters one contract: a primary form's input parameters (sub-forms as object parameters with every nested field) are generated, and writing one of those names in `parameters` is a compile error at any depth. `parameters` holds only entry arguments. An enum value's meaning is read from its choice's `description`, after the input's own `description` as the rule (`enumDescriptions`, and the parameter description `rule: key: meaning; …`); `extract:false` keeps a choice out of the enum and `internal:true` marks an input extraction never fills. A FLOW step may pass only arguments a version 2 target declares. Version 1 is unchanged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfe",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
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",