@protobase/workflows 0.100.4 → 0.100.6

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.
@@ -13,7 +13,7 @@ import { taskResource } from "./task-resource.js";
13
13
  import { connectionProblems } from "./used-connections.js";
14
14
  import { visibleVariables } from "./visible.js";
15
15
  import { blockProblems } from "./check-block.js";
16
- import { nestingDepth } from "../nesting.js";
16
+ import { depthProblems } from "./depth-problems.js";
17
17
  import { pinProblems } from "./pins/check-pins.js";
18
18
  import { dataflowProblems, dataflowVisible } from "./dataflow/check-dataflow.js";
19
19
  import { orderOf } from "./types.js";
@@ -168,7 +168,8 @@ const wholeProblems = (definition) => {
168
168
  const checkDefinition = (definition, options) => {
169
169
  const bytes = new TextEncoder().encode(JSON.stringify(definition) ?? "").length;
170
170
  if (bytes > limits.definitionBytes) return [{ message: `The definition is ${bytes} bytes as JSON, more than the ${limits.definitionBytes} a workflow may have` }];
171
- if (nestingDepth(definition, limits.definitionDepth) > limits.definitionDepth) return [{ message: `The definition nests more than ${limits.definitionDepth} levels of arrays and objects` }];
171
+ const deep = depthProblems(definition);
172
+ if (deep.length > 0) return deep;
172
173
  const aws = awsProblems(definition);
173
174
  if (aws.length > 0) return aws;
174
175
  const shape = schemaProblems(definition);
@@ -0,0 +1,10 @@
1
+ import { limits } from "../limits.js";
2
+ import { nestingDepth } from "../nesting.js";
3
+ //#region src/definition/depth-problems.ts
4
+ /** The problem of a definition, or a state machine, nesting past `limits.definitionDepth`, found without recursion; empty within it. */
5
+ const depthProblems = (value) => {
6
+ if (nestingDepth(value, limits.definitionDepth) <= limits.definitionDepth) return [];
7
+ return [{ message: `The definition nests more than ${limits.definitionDepth} levels of arrays and objects` }];
8
+ };
9
+ //#endregion
10
+ export { depthProblems };
@@ -4,7 +4,8 @@ import { ConnectionHeaders } from "./http-connection.js";
4
4
  /**
5
5
  * A state machine exported from Step Functions with each of its HTTP tasks, in Maps and Blocks too, as an app:http step
6
6
  * (see `importHttpTask`), each connection sending the header `connections` gives for it; every other state as it is.
7
- * With problems, nothing should be saved: each names the state and field that does not import exactly.
7
+ * With problems, nothing should be saved: each names the state and field that does not import exactly. A machine nesting
8
+ * past the definition's depth limit is given back as it is with that problem, before the import's walk could overflow the stack.
8
9
  */
9
10
  export declare const importStateMachine: (machine: Record<string, unknown>, connections?: ConnectionHeaders) => {
10
11
  stateMachine: Record<string, unknown>;
@@ -1,3 +1,4 @@
1
+ import { depthProblems } from "../depth-problems.js";
1
2
  import { importHttpTask } from "./http-task.js";
2
3
  //#region src/definition/import/import-machine.ts
3
4
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -42,9 +43,15 @@ const importStates = (states, path, connections) => {
42
43
  /**
43
44
  * A state machine exported from Step Functions with each of its HTTP tasks, in Maps and Blocks too, as an app:http step
44
45
  * (see `importHttpTask`), each connection sending the header `connections` gives for it; every other state as it is.
45
- * With problems, nothing should be saved: each names the state and field that does not import exactly.
46
+ * With problems, nothing should be saved: each names the state and field that does not import exactly. A machine nesting
47
+ * past the definition's depth limit is given back as it is with that problem, before the import's walk could overflow the stack.
46
48
  */
47
49
  const importStateMachine = (machine, connections = {}) => {
50
+ const deep = depthProblems(machine);
51
+ if (deep.length > 0) return {
52
+ stateMachine: machine,
53
+ problems: deep
54
+ };
48
55
  const { states, problems } = importStates(machine.States, [], connections);
49
56
  return {
50
57
  stateMachine: machine.States === void 0 ? machine : {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/workflows",
3
- "version": "0.100.4",
3
+ "version": "0.100.6",
4
4
  "description": "Workflows as state machines with JSONata expressions: their check, a runner that saves only what a run needs to go on and traces every step, and the plugin interface for trigger and step types.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {