@protobase/workflows 0.99.16 → 0.100.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/dist/definition/check-aws.js +80 -0
- package/dist/definition/check-definition.d.ts +4 -0
- package/dist/definition/check-definition.js +27 -10
- package/dist/definition/check-reads.js +9 -4
- package/dist/definition/check-schema.js +19 -7
- package/dist/definition/dataflow/check-dataflow.js +36 -0
- package/dist/definition/dataflow/dependencies.d.ts +17 -0
- package/dist/definition/dataflow/dependencies.js +88 -0
- package/dist/definition/expression-fields.d.ts +5 -0
- package/dist/definition/expression-fields.js +1 -0
- package/dist/definition/expressions.d.ts +5 -0
- package/dist/definition/graph.js +1 -1
- package/dist/definition/parts.d.ts +21 -0
- package/dist/definition/parts.js +21 -0
- package/dist/definition/pins/check-pins.js +40 -0
- package/dist/definition/pins/pin-sources.d.ts +33 -0
- package/dist/definition/pins/pin-sources.js +78 -0
- package/dist/definition/pins/pin-type.d.ts +19 -0
- package/dist/definition/pins/pin-type.js +61 -0
- package/dist/definition/pins/references.d.ts +32 -0
- package/dist/definition/pins/references.js +118 -0
- package/dist/definition/pins/resolve-schema.d.ts +21 -0
- package/dist/definition/pins/resolve-schema.js +62 -0
- package/dist/definition/reads.js +17 -10
- package/dist/definition/schema.d.ts +285 -191
- package/dist/definition/schema.js +275 -245
- package/dist/definition/types.d.ts +16 -4
- package/dist/definition/types.js +5 -0
- package/dist/definition/visible.js +6 -4
- package/dist/index.d.ts +11 -3
- package/dist/index.js +12 -3
- package/dist/plugin/index.d.ts +2 -1
- package/dist/plugin/index.js +2 -1
- package/dist/plugin/value-check.d.ts +9 -0
- package/dist/plugin/value-check.js +24 -0
- package/dist/run/block-state.js +1 -1
- package/dist/run/context.d.ts +2 -1
- package/dist/run/dataflow.js +183 -0
- package/dist/run/position.js +16 -11
- package/dist/run/recovery.js +22 -3
- package/dist/run/rerun-from.d.ts +8 -5
- package/dist/run/rerun-from.js +61 -5
- package/dist/run/rerun.d.ts +4 -3
- package/dist/run/rerun.js +16 -7
- package/dist/run/result-states.js +3 -3
- package/dist/run/scope.js +5 -4
- package/dist/run/segment.js +5 -2
- package/package.json +1 -1
|
@@ -21,272 +21,302 @@ const assign = {
|
|
|
21
21
|
type: "object",
|
|
22
22
|
propertyNames: { pattern: "^[A-Za-z][A-Za-z0-9_]*$" }
|
|
23
23
|
};
|
|
24
|
-
const
|
|
25
|
-
Type: {},
|
|
26
|
-
Comment: { type: "string" },
|
|
27
|
-
Output: {},
|
|
28
|
-
Assign: assign,
|
|
29
|
-
QueryLanguage: { const: "JSONata" }
|
|
30
|
-
};
|
|
31
|
-
const flow = {
|
|
32
|
-
Next: name,
|
|
33
|
-
End: { const: true }
|
|
34
|
-
};
|
|
35
|
-
const nextOrEnd = { oneOf: [{
|
|
36
|
-
required: ["Next"],
|
|
37
|
-
not: { required: ["End"] }
|
|
38
|
-
}, {
|
|
39
|
-
required: ["End"],
|
|
40
|
-
not: { required: ["Next"] }
|
|
41
|
-
}] };
|
|
42
|
-
const recovery = {
|
|
43
|
-
Retry: {
|
|
44
|
-
type: "array",
|
|
45
|
-
items: {
|
|
46
|
-
type: "object",
|
|
47
|
-
additionalProperties: false,
|
|
48
|
-
required: ["ErrorEquals"],
|
|
49
|
-
properties: {
|
|
50
|
-
ErrorEquals: errorNames,
|
|
51
|
-
IntervalSeconds: {
|
|
52
|
-
type: "integer",
|
|
53
|
-
minimum: 1,
|
|
54
|
-
maximum: limits.retryDelaySeconds
|
|
55
|
-
},
|
|
56
|
-
MaxAttempts: {
|
|
57
|
-
type: "integer",
|
|
58
|
-
minimum: 0,
|
|
59
|
-
maximum: limits.retryAttempts
|
|
60
|
-
},
|
|
61
|
-
BackoffRate: {
|
|
62
|
-
type: "number",
|
|
63
|
-
minimum: 1,
|
|
64
|
-
maximum: 10
|
|
65
|
-
},
|
|
66
|
-
MaxDelaySeconds: {
|
|
67
|
-
type: "integer",
|
|
68
|
-
minimum: 1,
|
|
69
|
-
maximum: limits.retryDelaySeconds
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
Catch: {
|
|
75
|
-
type: "array",
|
|
76
|
-
items: {
|
|
77
|
-
type: "object",
|
|
78
|
-
additionalProperties: false,
|
|
79
|
-
required: ["ErrorEquals", "Next"],
|
|
80
|
-
properties: {
|
|
81
|
-
ErrorEquals: errorNames,
|
|
82
|
-
Next: name,
|
|
83
|
-
Output: {},
|
|
84
|
-
Assign: assign
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const state = (type, properties, { required = [], ...extra } = {}) => ({
|
|
24
|
+
const retrier = {
|
|
90
25
|
type: "object",
|
|
91
26
|
additionalProperties: false,
|
|
92
|
-
required: ["
|
|
93
|
-
...extra,
|
|
27
|
+
required: ["ErrorEquals"],
|
|
94
28
|
properties: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
29
|
+
ErrorEquals: errorNames,
|
|
30
|
+
IntervalSeconds: {
|
|
31
|
+
type: "integer",
|
|
32
|
+
minimum: 1,
|
|
33
|
+
maximum: limits.retryDelaySeconds
|
|
34
|
+
},
|
|
35
|
+
MaxAttempts: {
|
|
36
|
+
type: "integer",
|
|
37
|
+
minimum: 0,
|
|
38
|
+
maximum: limits.retryAttempts
|
|
39
|
+
},
|
|
40
|
+
BackoffRate: {
|
|
41
|
+
type: "number",
|
|
42
|
+
minimum: 1,
|
|
43
|
+
maximum: 10
|
|
44
|
+
},
|
|
45
|
+
MaxDelaySeconds: {
|
|
46
|
+
type: "integer",
|
|
47
|
+
minimum: 1,
|
|
48
|
+
maximum: limits.retryDelaySeconds
|
|
49
|
+
}
|
|
98
50
|
}
|
|
99
|
-
}
|
|
51
|
+
};
|
|
100
52
|
/**
|
|
101
|
-
* The JSON Schema of a workflow definition: its trigger, and a state machine in the States Language with
|
|
102
|
-
* expressions, in the named-reads profile.
|
|
53
|
+
* The JSON Schema of a workflow definition in one order: its trigger, and a state machine in the States Language with
|
|
54
|
+
* JSONata expressions, in the named-reads profile. In sequence order every state names its `Next` or `End` and the
|
|
55
|
+
* machine its `StartAt`, as the States Language has them; in data order none does, a state may have a `Condition`,
|
|
56
|
+
* a catcher has no `Next`, and there is no Choice or Succeed. It checks the shape; `checkDefinition` also checks the
|
|
57
|
+
* edges and what each expression reads.
|
|
103
58
|
*/
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
59
|
+
const schemaFor = (order) => {
|
|
60
|
+
const sequence = order === "sequence";
|
|
61
|
+
const common = {
|
|
62
|
+
Type: {},
|
|
63
|
+
Comment: { type: "string" },
|
|
64
|
+
Output: {},
|
|
65
|
+
Assign: assign,
|
|
66
|
+
QueryLanguage: { const: "JSONata" },
|
|
67
|
+
...!sequence && { Condition: expression }
|
|
68
|
+
};
|
|
69
|
+
const flow = sequence ? {
|
|
70
|
+
Next: name,
|
|
71
|
+
End: { const: true }
|
|
72
|
+
} : {};
|
|
73
|
+
const nextOrEnd = sequence ? { oneOf: [{
|
|
74
|
+
required: ["Next"],
|
|
75
|
+
not: { required: ["End"] }
|
|
76
|
+
}, {
|
|
77
|
+
required: ["End"],
|
|
78
|
+
not: { required: ["Next"] }
|
|
79
|
+
}] } : {};
|
|
80
|
+
const catcher = {
|
|
81
|
+
type: "object",
|
|
82
|
+
additionalProperties: false,
|
|
83
|
+
required: ["ErrorEquals", ...sequence ? ["Next"] : []],
|
|
84
|
+
properties: {
|
|
85
|
+
ErrorEquals: errorNames,
|
|
86
|
+
...sequence && { Next: name },
|
|
87
|
+
Output: {},
|
|
88
|
+
Assign: assign
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const recovery = {
|
|
92
|
+
Retry: {
|
|
93
|
+
type: "array",
|
|
94
|
+
items: retrier
|
|
122
95
|
},
|
|
123
|
-
|
|
96
|
+
Catch: {
|
|
97
|
+
type: "array",
|
|
98
|
+
items: catcher
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const state = (type, properties, { required = [], ...extra } = {}) => ({
|
|
102
|
+
type: "object",
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
required: ["Type", ...required],
|
|
105
|
+
...extra,
|
|
106
|
+
properties: {
|
|
107
|
+
...common,
|
|
108
|
+
Type: { const: type },
|
|
109
|
+
...properties
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const machine = sequence ? {
|
|
113
|
+
type: "object",
|
|
114
|
+
required: ["StartAt", "States"],
|
|
115
|
+
properties: {
|
|
116
|
+
StartAt: name,
|
|
117
|
+
Comment: { type: "string" },
|
|
118
|
+
States: {
|
|
119
|
+
type: "object",
|
|
120
|
+
minProperties: 1,
|
|
121
|
+
propertyNames: name,
|
|
122
|
+
additionalProperties: { $ref: "#/definitions/state" }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} : {
|
|
126
|
+
type: "object",
|
|
127
|
+
required: ["States"],
|
|
128
|
+
properties: {
|
|
129
|
+
Comment: { type: "string" },
|
|
130
|
+
States: {
|
|
131
|
+
type: "object",
|
|
132
|
+
minProperties: 1,
|
|
133
|
+
propertyNames: name,
|
|
134
|
+
additionalProperties: { $ref: "#/definitions/state" }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const machineFields = {
|
|
139
|
+
...sequence && { StartAt: {} },
|
|
140
|
+
States: {},
|
|
141
|
+
Comment: {},
|
|
142
|
+
Version: { type: "string" }
|
|
143
|
+
};
|
|
144
|
+
const flowStates = [
|
|
145
|
+
state("Pass", flow, nextOrEnd),
|
|
146
|
+
state("Task", {
|
|
147
|
+
...flow,
|
|
148
|
+
...recovery,
|
|
149
|
+
Resource: name,
|
|
150
|
+
Arguments: {},
|
|
151
|
+
TimeoutSeconds: {
|
|
152
|
+
type: "integer",
|
|
153
|
+
minimum: 1,
|
|
154
|
+
maximum: limits.taskTimeoutSeconds
|
|
155
|
+
},
|
|
156
|
+
Cache: { type: "boolean" }
|
|
157
|
+
}, {
|
|
158
|
+
required: ["Resource"],
|
|
159
|
+
...nextOrEnd
|
|
160
|
+
}),
|
|
161
|
+
state("Wait", {
|
|
162
|
+
...flow,
|
|
163
|
+
Seconds: { anyOf: [{
|
|
164
|
+
type: "integer",
|
|
165
|
+
minimum: 0,
|
|
166
|
+
maximum: limits.waitSeconds
|
|
167
|
+
}, expression] },
|
|
168
|
+
Timestamp: { type: "string" }
|
|
169
|
+
}, { allOf: [nextOrEnd, { oneOf: [{ required: ["Seconds"] }, { required: ["Timestamp"] }] }] }),
|
|
170
|
+
{
|
|
124
171
|
type: "object",
|
|
125
172
|
additionalProperties: false,
|
|
126
|
-
required: ["
|
|
173
|
+
required: ["Type"],
|
|
127
174
|
properties: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"none"
|
|
135
|
-
] }
|
|
175
|
+
Type: { const: "Fail" },
|
|
176
|
+
Comment: { type: "string" },
|
|
177
|
+
QueryLanguage: { const: "JSONata" },
|
|
178
|
+
...!sequence && { Condition: expression },
|
|
179
|
+
Error: { type: "string" },
|
|
180
|
+
Cause: { type: "string" }
|
|
136
181
|
}
|
|
137
182
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
183
|
+
state("Map", {
|
|
184
|
+
...flow,
|
|
185
|
+
...recovery,
|
|
186
|
+
Items: {},
|
|
187
|
+
ItemProcessor: { $ref: "#/definitions/processor" },
|
|
188
|
+
MaxConcurrency: {
|
|
189
|
+
type: "integer",
|
|
190
|
+
minimum: 0,
|
|
191
|
+
maximum: limits.mapConcurrency
|
|
145
192
|
}
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
193
|
+
}, {
|
|
194
|
+
required: ["ItemProcessor", "Items"],
|
|
195
|
+
...nextOrEnd
|
|
196
|
+
}),
|
|
197
|
+
state("Block", {
|
|
198
|
+
...flow,
|
|
199
|
+
...recovery,
|
|
200
|
+
Arguments: {},
|
|
201
|
+
Processor: { $ref: "#/definitions/machine" },
|
|
202
|
+
Cache: {
|
|
153
203
|
type: "object",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
204
|
+
additionalProperties: false,
|
|
205
|
+
required: ["Ttl"],
|
|
206
|
+
properties: {
|
|
207
|
+
Ttl: { type: ["integer", "string"] },
|
|
208
|
+
Key: {}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}, {
|
|
212
|
+
required: ["Processor", "Cache"],
|
|
213
|
+
...nextOrEnd
|
|
214
|
+
})
|
|
215
|
+
];
|
|
216
|
+
const sequenceStates = sequence ? [state("Choice", {
|
|
217
|
+
Choices: {
|
|
218
|
+
type: "array",
|
|
219
|
+
minItems: 1,
|
|
220
|
+
items: {
|
|
221
|
+
type: "object",
|
|
222
|
+
additionalProperties: false,
|
|
223
|
+
required: ["Condition", "Next"],
|
|
224
|
+
properties: {
|
|
225
|
+
Condition: expression,
|
|
226
|
+
Next: name,
|
|
227
|
+
Comment: { type: "string" },
|
|
228
|
+
Output: {},
|
|
229
|
+
Assign: assign
|
|
230
|
+
}
|
|
231
|
+
}
|
|
157
232
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
233
|
+
Default: name
|
|
234
|
+
}, { required: ["Choices"] }), {
|
|
235
|
+
type: "object",
|
|
236
|
+
additionalProperties: false,
|
|
237
|
+
required: ["Type"],
|
|
238
|
+
properties: {
|
|
239
|
+
Type: { const: "Succeed" },
|
|
240
|
+
Comment: { type: "string" },
|
|
241
|
+
Output: {},
|
|
242
|
+
QueryLanguage: { const: "JSONata" }
|
|
243
|
+
}
|
|
244
|
+
}] : [];
|
|
245
|
+
return {
|
|
246
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
247
|
+
$id: `https://docs.protobase.net/schemas/workflow-definition${sequence ? "" : "-data"}.json`,
|
|
248
|
+
$ref: "#/definitions/definition",
|
|
249
|
+
definitions: {
|
|
250
|
+
machine,
|
|
251
|
+
definition: {
|
|
252
|
+
type: "object",
|
|
253
|
+
additionalProperties: false,
|
|
254
|
+
required: ["trigger", "stateMachine"],
|
|
255
|
+
properties: {
|
|
256
|
+
trigger: { $ref: "#/definitions/trigger" },
|
|
257
|
+
order: { enum: ["sequence", "data"] },
|
|
258
|
+
stateMachine: { $ref: "#/definitions/stateMachine" },
|
|
259
|
+
connections: { $ref: "#/definitions/connections" },
|
|
260
|
+
trace: { enum: [
|
|
261
|
+
"all",
|
|
262
|
+
"failed",
|
|
263
|
+
"none"
|
|
264
|
+
] }
|
|
265
|
+
}
|
|
166
266
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
properties: { Mode: { const: "INLINE" } }
|
|
176
|
-
},
|
|
177
|
-
StartAt: {},
|
|
178
|
-
States: {},
|
|
179
|
-
Comment: {}
|
|
267
|
+
connections: {
|
|
268
|
+
type: "object",
|
|
269
|
+
propertyNames: { pattern: "^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$" },
|
|
270
|
+
additionalProperties: {
|
|
271
|
+
type: "string",
|
|
272
|
+
minLength: 1,
|
|
273
|
+
maxLength: 255
|
|
274
|
+
}
|
|
180
275
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
oneOf: [
|
|
188
|
-
state("Pass", flow, nextOrEnd),
|
|
189
|
-
state("Task", {
|
|
190
|
-
...flow,
|
|
191
|
-
...recovery,
|
|
192
|
-
Resource: name,
|
|
193
|
-
Arguments: {},
|
|
194
|
-
TimeoutSeconds: {
|
|
195
|
-
type: "integer",
|
|
196
|
-
minimum: 1,
|
|
197
|
-
maximum: limits.taskTimeoutSeconds
|
|
198
|
-
},
|
|
199
|
-
Cache: { type: "boolean" }
|
|
200
|
-
}, {
|
|
201
|
-
required: ["Resource"],
|
|
202
|
-
...nextOrEnd
|
|
203
|
-
}),
|
|
204
|
-
state("Choice", {
|
|
205
|
-
Choices: {
|
|
206
|
-
type: "array",
|
|
207
|
-
minItems: 1,
|
|
208
|
-
items: {
|
|
209
|
-
type: "object",
|
|
210
|
-
additionalProperties: false,
|
|
211
|
-
required: ["Condition", "Next"],
|
|
212
|
-
properties: {
|
|
213
|
-
Condition: expression,
|
|
214
|
-
Next: name,
|
|
215
|
-
Comment: { type: "string" },
|
|
216
|
-
Output: {},
|
|
217
|
-
Assign: assign
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
Default: name
|
|
222
|
-
}, { required: ["Choices"] }),
|
|
223
|
-
state("Wait", {
|
|
224
|
-
...flow,
|
|
225
|
-
Seconds: { anyOf: [{
|
|
226
|
-
type: "integer",
|
|
227
|
-
minimum: 0,
|
|
228
|
-
maximum: limits.waitSeconds
|
|
229
|
-
}, expression] },
|
|
230
|
-
Timestamp: { type: "string" }
|
|
231
|
-
}, { allOf: [nextOrEnd, { oneOf: [{ required: ["Seconds"] }, { required: ["Timestamp"] }] }] }),
|
|
232
|
-
{
|
|
233
|
-
type: "object",
|
|
234
|
-
additionalProperties: false,
|
|
235
|
-
required: ["Type"],
|
|
236
|
-
properties: {
|
|
237
|
-
Type: { const: "Succeed" },
|
|
238
|
-
Comment: { type: "string" },
|
|
239
|
-
Output: {},
|
|
240
|
-
QueryLanguage: { const: "JSONata" }
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
{
|
|
276
|
+
trigger: {
|
|
277
|
+
type: "object",
|
|
278
|
+
minProperties: 1,
|
|
279
|
+
maxProperties: 1,
|
|
280
|
+
propertyNames: { pattern: "^(manual|[a-z][a-z0-9_]*:[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*)$" },
|
|
281
|
+
properties: { manual: {
|
|
244
282
|
type: "object",
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
283
|
+
maxProperties: 0
|
|
284
|
+
} },
|
|
285
|
+
additionalProperties: { type: "object" }
|
|
286
|
+
},
|
|
287
|
+
stateMachine: {
|
|
288
|
+
allOf: [{ $ref: "#/definitions/machine" }],
|
|
289
|
+
required: ["QueryLanguage"],
|
|
290
|
+
properties: {
|
|
291
|
+
QueryLanguage: { const: "JSONata" },
|
|
292
|
+
...machineFields
|
|
254
293
|
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
type: "integer",
|
|
262
|
-
minimum: 0,
|
|
263
|
-
maximum: limits.mapConcurrency
|
|
264
|
-
}
|
|
265
|
-
}, {
|
|
266
|
-
required: ["ItemProcessor", "Items"],
|
|
267
|
-
...nextOrEnd
|
|
268
|
-
}),
|
|
269
|
-
state("Block", {
|
|
270
|
-
...flow,
|
|
271
|
-
...recovery,
|
|
272
|
-
Arguments: {},
|
|
273
|
-
Processor: { $ref: "#/definitions/machine" },
|
|
274
|
-
Cache: {
|
|
294
|
+
additionalProperties: false
|
|
295
|
+
},
|
|
296
|
+
processor: {
|
|
297
|
+
allOf: [{ $ref: "#/definitions/machine" }],
|
|
298
|
+
properties: {
|
|
299
|
+
ProcessorConfig: {
|
|
275
300
|
type: "object",
|
|
276
301
|
additionalProperties: false,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
302
|
+
properties: { Mode: { const: "INLINE" } }
|
|
303
|
+
},
|
|
304
|
+
...machineFields
|
|
305
|
+
},
|
|
306
|
+
additionalProperties: false
|
|
307
|
+
},
|
|
308
|
+
state: {
|
|
309
|
+
type: "object",
|
|
310
|
+
required: ["Type"],
|
|
311
|
+
discriminator: { propertyName: "Type" },
|
|
312
|
+
oneOf: [...flowStates, ...sequenceStates]
|
|
313
|
+
}
|
|
288
314
|
}
|
|
289
|
-
}
|
|
315
|
+
};
|
|
290
316
|
};
|
|
317
|
+
/** The JSON Schema of a workflow definition whose states run in sequence, the States Language's own order. */
|
|
318
|
+
const definitionSchema = schemaFor("sequence");
|
|
319
|
+
/** The JSON Schema of a workflow definition whose states run in the order their reads give: `"order": "data"`. */
|
|
320
|
+
const dataflowDefinitionSchema = schemaFor("data");
|
|
291
321
|
//#endregion
|
|
292
|
-
export { definitionSchema };
|
|
322
|
+
export { dataflowDefinitionSchema, definitionSchema };
|
|
@@ -8,17 +8,20 @@ export type Retrier = {
|
|
|
8
8
|
BackoffRate?: number;
|
|
9
9
|
MaxDelaySeconds?: number;
|
|
10
10
|
};
|
|
11
|
+
/** In dataflow mode a catcher has no `Next`: the state counts as ended, its Status `FAILED`, with the catcher's `Output` and `Assign`. */
|
|
11
12
|
export type Catcher = {
|
|
12
13
|
ErrorEquals: string[];
|
|
13
|
-
Next
|
|
14
|
+
Next?: string;
|
|
14
15
|
Output?: Template;
|
|
15
16
|
Assign?: Record<string, Template>;
|
|
16
17
|
};
|
|
18
|
+
/** `Condition`, in dataflow mode only: the state runs once its dependencies have ended and only when it is true, else it is skipped. */
|
|
17
19
|
type Common = {
|
|
18
20
|
Comment?: string;
|
|
19
21
|
Output?: Template;
|
|
20
22
|
Assign?: Record<string, Template>;
|
|
21
23
|
QueryLanguage?: 'JSONata';
|
|
24
|
+
Condition?: string;
|
|
22
25
|
};
|
|
23
26
|
type Flow = {
|
|
24
27
|
Next?: string;
|
|
@@ -94,9 +97,9 @@ export type BlockState = Common & Flow & {
|
|
|
94
97
|
Catch?: Catcher[];
|
|
95
98
|
};
|
|
96
99
|
export type State = PassState | TaskState | ChoiceState | WaitState | SucceedState | FailState | MapState | BlockState;
|
|
97
|
-
/** States and where they start: a whole state machine, or a Map's item processor. */
|
|
100
|
+
/** States and where they start: a whole state machine, or a Map's item processor. A dataflow machine has no `StartAt`. */
|
|
98
101
|
export type Machine = {
|
|
99
|
-
StartAt
|
|
102
|
+
StartAt?: string;
|
|
100
103
|
States: Record<string, State>;
|
|
101
104
|
Comment?: string;
|
|
102
105
|
};
|
|
@@ -110,14 +113,23 @@ export type Trigger = {
|
|
|
110
113
|
[type: `${string}:${string}`]: Record<string, unknown>;
|
|
111
114
|
};
|
|
112
115
|
/**
|
|
113
|
-
*
|
|
116
|
+
* How a workflow's states are ordered: `sequence`, by each state's `Next` as the States Language orders them, or `data`,
|
|
117
|
+
* where a state runs once every state it reads from has ended and states that read nothing of each other run at once.
|
|
118
|
+
*/
|
|
119
|
+
export type Order = 'sequence' | 'data';
|
|
120
|
+
/**
|
|
121
|
+
* A workflow definition: its trigger, how its states are ordered (`order`, sequence when absent), the state machine a
|
|
122
|
+
* run runs from `StartAt`, or by its reads in dataflow mode, the connected account each
|
|
114
123
|
* connection `<plugin>:<connection>` of its types signs in with, by the account's id, and which of its runs keep a
|
|
115
124
|
* trace (`all`, `failed` or `none`), when it says, over the app's default.
|
|
116
125
|
*/
|
|
117
126
|
export type Definition = {
|
|
118
127
|
trigger: Trigger;
|
|
128
|
+
order?: Order;
|
|
119
129
|
stateMachine: StateMachine;
|
|
120
130
|
connections?: Record<string, string>;
|
|
121
131
|
trace?: 'all' | 'failed' | 'none';
|
|
122
132
|
};
|
|
133
|
+
/** How a definition's states are ordered: as it says, else in sequence. */
|
|
134
|
+
export declare const orderOf: (definition: Pick<Definition, "order">) => Order;
|
|
123
135
|
//#endregion
|
|
@@ -17,10 +17,12 @@ const passedOn = (state) => {
|
|
|
17
17
|
names: own
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
if ("Catch" in state)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if ("Catch" in state) {
|
|
21
|
+
for (const catcher of state.Catch ?? []) if (catcher.Next !== void 0) along.push({
|
|
22
|
+
target: catcher.Next,
|
|
23
|
+
names: Object.keys(catcher.Assign ?? {})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
24
26
|
return along;
|
|
25
27
|
};
|
|
26
28
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { Problem, problemText } from "./definition/problem.js";
|
|
2
|
-
import { BlockCache, BlockState, Catcher, ChoiceRule, ChoiceState, Definition, Machine, MapState, Retrier, State, StateMachine, TaskState, Trigger } from "./definition/types.js";
|
|
2
|
+
import { BlockCache, BlockState, Catcher, ChoiceRule, ChoiceState, Definition, Machine, MapState, Order, Retrier, State, StateMachine, TaskState, Trigger, orderOf } from "./definition/types.js";
|
|
3
3
|
import { TriggerCheck } from "./definition/check-trigger.js";
|
|
4
|
+
import { ReadBase, Reference, expressionReferences, parseReference, readText, referenceValue } from "./definition/pins/references.js";
|
|
5
|
+
import { RecordSchemas, RecordUse, resolveSchema, schemaAt } from "./definition/pins/resolve-schema.js";
|
|
6
|
+
import { PinSchemas, inputSchema, referenceSchema, resultSchema, resultState, stepStatusSchema, triggerSchema } from "./definition/pins/pin-sources.js";
|
|
4
7
|
import { CheckOptions, checkDefinition } from "./definition/check-definition.js";
|
|
5
|
-
import { definitionSchema } from "./definition/schema.js";
|
|
8
|
+
import { dataflowDefinitionSchema, definitionSchema } from "./definition/schema.js";
|
|
9
|
+
import { DefinitionParts, definitionFromParts, partOfProblem, partsOfDefinition } from "./definition/parts.js";
|
|
10
|
+
import { expressionSource } from "./definition/expressions.js";
|
|
11
|
+
import { PinKind, PinType, fits, pinType, pinTypeText } from "./definition/pins/pin-type.js";
|
|
6
12
|
import { definitionWarnings } from "./definition/check-warnings.js";
|
|
7
13
|
import { allStates, blockDefinition, findBlock, innerMachine } from "./definition/inner.js";
|
|
8
14
|
import { usedConnections } from "./definition/used-connections.js";
|
|
15
|
+
import { assignedNames } from "./definition/expression-fields.js";
|
|
16
|
+
import { Dependencies, dependsOn, machineDependencies } from "./definition/dataflow/dependencies.js";
|
|
9
17
|
import { limits } from "./limits.js";
|
|
10
18
|
import { nestingDepth } from "./nesting.js";
|
|
11
19
|
import { ErrorOutput, StepError } from "./run/errors.js";
|
|
@@ -24,4 +32,4 @@ import { triggerChecks } from "./plugin/trigger-checks.js";
|
|
|
24
32
|
import { TypeEntry, Unavailable, typeList } from "./plugin/type-list.js";
|
|
25
33
|
import { ConnectionSupport, connectionUnavailable } from "./plugin/connection-availability.js";
|
|
26
34
|
import { CatalogEntry, TypeCatalog, typeCatalog } from "./plugin/type-catalog.js";
|
|
27
|
-
export { type BlockCache, type BlockRun, type BlockRunStore, type BlockShare, type BlockState, type CacheCall, type CacheEntry, type CacheIdentity, type CatalogEntry, type Catcher, type CheckOptions, type Checkpoint, type ChoiceRule, type ChoiceState, type ConnectionSupport, type Definition, type EarlierCheckpoint, type ErrorOutput, type KeyShape, type LoadedPlugin, type LoadedRun, type Machine, type MapState, type Problem, type Redactor, type ReplayedStep, type RerunFrom, type Retrier, type RunChange, type RunStatus, type RunStore, type Runner, type RunnerPort, type SegmentInput, type SegmentQueue, type State, type StateMachine, type StepCacheStore, StepError, type StepLog, type StepRecord, type StepStatus, type StepWiring, type TaskContext, type TaskHandler, type TaskHandlers, type TaskState, type TraceMode, type TraceSink, type Trigger, type TriggerCheck, type TypeCatalog, type TypeEntry, type Unavailable, allStates, blockDefinition, checkDefinition, connectionUnavailable, createRunner, definitionSchema, definitionWarnings, findBlock, heldBackLog, innerMachine, keptAssigned, limits, loadPlugins, nestingDepth, problemText, redacted, rerunCheckpoint, rerunFrom, rerunProblem, resultRead, runSegment, secretRedactor, shortestSecret, stepHandlers, triggerChecks, typeCatalog, typeList, usedConnections };
|
|
35
|
+
export { type BlockCache, type BlockRun, type BlockRunStore, type BlockShare, type BlockState, type CacheCall, type CacheEntry, type CacheIdentity, type CatalogEntry, type Catcher, type CheckOptions, type Checkpoint, type ChoiceRule, type ChoiceState, type ConnectionSupport, type Definition, type DefinitionParts, type Dependencies, type EarlierCheckpoint, type ErrorOutput, type KeyShape, type LoadedPlugin, type LoadedRun, type Machine, type MapState, type Order, type PinKind, type PinSchemas, type PinType, type Problem, type ReadBase, type RecordSchemas, type RecordUse, type Redactor, type Reference, type ReplayedStep, type RerunFrom, type Retrier, type RunChange, type RunStatus, type RunStore, type Runner, type RunnerPort, type SegmentInput, type SegmentQueue, type State, type StateMachine, type StepCacheStore, StepError, type StepLog, type StepRecord, type StepStatus, type StepWiring, type TaskContext, type TaskHandler, type TaskHandlers, type TaskState, type TraceMode, type TraceSink, type Trigger, type TriggerCheck, type TypeCatalog, type TypeEntry, type Unavailable, allStates, assignedNames, blockDefinition, checkDefinition, connectionUnavailable, createRunner, dataflowDefinitionSchema, definitionFromParts, definitionSchema, definitionWarnings, dependsOn, expressionReferences, expressionSource, findBlock, fits, heldBackLog, innerMachine, inputSchema, keptAssigned, limits, loadPlugins, machineDependencies, nestingDepth, orderOf, parseReference, partOfProblem, partsOfDefinition, pinType, pinTypeText, problemText, readText, redacted, referenceSchema, referenceValue, rerunCheckpoint, rerunFrom, rerunProblem, resolveSchema, resultRead, resultSchema, resultState, runSegment, schemaAt, secretRedactor, shortestSecret, stepHandlers, stepStatusSchema, triggerChecks, triggerSchema, typeCatalog, typeList, usedConnections };
|