@blokjs/helper 0.4.0 → 0.6.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/components/AddElse.d.ts +0 -5
- package/dist/components/AddIf.d.ts +0 -5
- package/dist/components/StepNode.js +0 -1
- package/dist/components/StepNode.js.map +1 -1
- package/dist/components/forEach.d.ts +53 -0
- package/dist/components/forEach.js +64 -0
- package/dist/components/forEach.js.map +1 -0
- package/dist/components/loop.d.ts +52 -0
- package/dist/components/loop.js +54 -0
- package/dist/components/loop.js.map +1 -0
- package/dist/components/switchOn.d.ts +68 -0
- package/dist/components/switchOn.js +76 -0
- package/dist/components/switchOn.js.map +1 -0
- package/dist/components/tryCatch.d.ts +63 -0
- package/dist/components/tryCatch.js +68 -0
- package/dist/components/tryCatch.js.map +1 -0
- package/dist/components/workflowV2.d.ts +1 -1
- package/dist/components/workflowV2.js +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/proxy/$.d.ts +7 -0
- package/dist/proxy/$.js.map +1 -1
- package/dist/types/StepOpts.d.ts +301 -34
- package/dist/types/StepOpts.js +262 -16
- package/dist/types/StepOpts.js.map +1 -1
- package/dist/types/TriggerOpts.d.ts +419 -31
- package/dist/types/TriggerOpts.js +206 -10
- package/dist/types/TriggerOpts.js.map +1 -1
- package/dist/types/WorkflowOpts.d.ts +186 -20
- package/dist/types/WorkflowOpts.js +12 -1
- package/dist/types/WorkflowOpts.js.map +1 -1
- package/dist/workflow.schema.json +243 -7
- package/package.json +1 -1
|
@@ -35,7 +35,12 @@
|
|
|
35
35
|
"websocket"
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
-
"description": "Trigger configuration. Most workflows use { http: { method: 'GET' } }. See TRIGGER_SCHEMAS for per-kind shapes."
|
|
38
|
+
"description": "Trigger configuration. Most workflows use { http: { method: 'GET' } }. Optional ONLY when `middleware: true` is set — middleware-only workflows are invoked from another workflow's `trigger.http.middleware: [...]` array and don't have a public route of their own. See TRIGGER_SCHEMAS for per-kind shapes."
|
|
39
|
+
},
|
|
40
|
+
"middleware": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"const": true,
|
|
43
|
+
"description": "v0.5 — when true, this workflow is registered as middleware and is NOT exposed as a public HTTP route. It's invoked by another workflow that lists this one's `name` in its `trigger.http.middleware: [...]` array. Middleware runs on the parent ctx (state mutations carry forward) and can short-circuit by setting `ctx.response` and using a step with `stop: true`. Middleware-only workflows MAY omit `trigger`."
|
|
39
44
|
},
|
|
40
45
|
"steps": {
|
|
41
46
|
"type": "array",
|
|
@@ -99,7 +104,7 @@
|
|
|
99
104
|
"subworkflow": {
|
|
100
105
|
"type": "string",
|
|
101
106
|
"minLength": 1,
|
|
102
|
-
"description": "Name of the workflow to invoke. Looked up in the WorkflowRegistry at run time
|
|
107
|
+
"description": "Name of the workflow to invoke. Looked up in the WorkflowRegistry at run time. **Literal names** (`\"send-receipt-email\"`) are matched directly. **Polymorphic expressions** (`\"$.req.body.kind\"`, `\"js/ctx.req.body.kind\"`) resolve against the live ctx at dispatch time — pair with `allowList` to constrain which workflows the expression may resolve to."
|
|
103
108
|
},
|
|
104
109
|
"inputs": {
|
|
105
110
|
"type": "object",
|
|
@@ -185,6 +190,22 @@
|
|
|
185
190
|
}
|
|
186
191
|
],
|
|
187
192
|
"description": "OPTIONAL. Per-attempt execution timeout. Caps the synchronous wait for `wait: true` sub-workflows. No-op for `wait: false` (parent returns immediately; the child's max-duration is the child's concern). Number (ms) or duration string. On final-attempt timeout, the run auto-flips to `\"timedOut\"`."
|
|
193
|
+
},
|
|
194
|
+
"allowList": {
|
|
195
|
+
"type": "array",
|
|
196
|
+
"items": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"minLength": 1
|
|
199
|
+
},
|
|
200
|
+
"description": "Exact-match allow-list for polymorphic dispatch. When the resolved workflow name (after any `namespace` prefix is applied) is not in this array, the dispatch is rejected at run time with a structured error. Strongly recommended when `subworkflow` is an expression (`$.<path>` or `js/...`) so a malicious or buggy ctx value can't dispatch arbitrary workflows. Ignored for literal names (they don't need the guard)."
|
|
201
|
+
},
|
|
202
|
+
"dispatch": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"enum": [
|
|
205
|
+
"in-process",
|
|
206
|
+
"http-self"
|
|
207
|
+
],
|
|
208
|
+
"description": "G2 (v0.6) — dispatch strategy. `in-process` (default) invokes the child workflow in the same Node process — synchronous when `wait: true`, `setImmediate`-based when `wait: false`. `http-self` makes an HTTP request to the deployment's own base URL (`BLOK_SELF_BASE_URL` env var, defaults to `http://localhost:${PORT || 4000}`). Use `http-self` when you want each child run to land on a different process in a horizontally-scaled deployment, or to fully isolate child execution from the parent's call stack. The child must have an HTTP trigger; a runtime error is thrown otherwise. Lineage (parentRunId / parentNodeRunId) is preserved across the HTTP hop via `X-Blok-Parent-Run-Id` / `X-Blok-Parent-Node-Run-Id` headers."
|
|
188
209
|
}
|
|
189
210
|
},
|
|
190
211
|
"required": [
|
|
@@ -265,6 +286,226 @@
|
|
|
265
286
|
],
|
|
266
287
|
"additionalProperties": false
|
|
267
288
|
},
|
|
289
|
+
{
|
|
290
|
+
"type": "object",
|
|
291
|
+
"properties": {
|
|
292
|
+
"id": {
|
|
293
|
+
"type": "string",
|
|
294
|
+
"minLength": 1,
|
|
295
|
+
"description": "Stable identifier for the forEach step. Visible in traces."
|
|
296
|
+
},
|
|
297
|
+
"forEach": {
|
|
298
|
+
"type": "object",
|
|
299
|
+
"properties": {
|
|
300
|
+
"in": {
|
|
301
|
+
"description": "Array source. Literal expression string (`'$.state.items'`) or `$` proxy expression."
|
|
302
|
+
},
|
|
303
|
+
"as": {
|
|
304
|
+
"type": "string",
|
|
305
|
+
"minLength": 1,
|
|
306
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
|
|
307
|
+
"description": "Per-iteration variable name. Each iteration sets ctx.state[as] = item and ctx.state[as+'Index'] = i."
|
|
308
|
+
},
|
|
309
|
+
"mode": {
|
|
310
|
+
"type": "string",
|
|
311
|
+
"enum": [
|
|
312
|
+
"sequential",
|
|
313
|
+
"parallel"
|
|
314
|
+
],
|
|
315
|
+
"description": "Execution mode. `sequential` (default) awaits each iteration; `parallel` runs with bounded concurrency."
|
|
316
|
+
},
|
|
317
|
+
"concurrency": {
|
|
318
|
+
"type": "integer",
|
|
319
|
+
"minimum": 1,
|
|
320
|
+
"maximum": 1000,
|
|
321
|
+
"description": "Max concurrent inner pipelines when `mode: 'parallel'`. Default 10."
|
|
322
|
+
},
|
|
323
|
+
"do": {
|
|
324
|
+
"type": "array",
|
|
325
|
+
"items": {},
|
|
326
|
+
"minItems": 1,
|
|
327
|
+
"description": "Sub-pipeline run for each item."
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
"required": [
|
|
331
|
+
"as",
|
|
332
|
+
"do"
|
|
333
|
+
],
|
|
334
|
+
"additionalProperties": false,
|
|
335
|
+
"description": "forEach configuration."
|
|
336
|
+
},
|
|
337
|
+
"active": {
|
|
338
|
+
"type": "boolean"
|
|
339
|
+
},
|
|
340
|
+
"stop": {
|
|
341
|
+
"type": "boolean"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
"required": [
|
|
345
|
+
"id",
|
|
346
|
+
"forEach"
|
|
347
|
+
],
|
|
348
|
+
"additionalProperties": false
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"type": "object",
|
|
352
|
+
"properties": {
|
|
353
|
+
"id": {
|
|
354
|
+
"type": "string",
|
|
355
|
+
"minLength": 1,
|
|
356
|
+
"description": "Stable identifier for the loop step. Visible in traces."
|
|
357
|
+
},
|
|
358
|
+
"loop": {
|
|
359
|
+
"type": "object",
|
|
360
|
+
"properties": {
|
|
361
|
+
"while": {
|
|
362
|
+
"type": "string",
|
|
363
|
+
"minLength": 1,
|
|
364
|
+
"description": "JS expression evaluated against ctx before each iteration. Loop continues while truthy."
|
|
365
|
+
},
|
|
366
|
+
"maxIterations": {
|
|
367
|
+
"type": "integer",
|
|
368
|
+
"minimum": 1,
|
|
369
|
+
"description": "Hard safety cap on iterations. Default 1000 (override via env BLOK_LOOP_MAX_ITERATIONS). Hitting the cap throws LoopMaxIterationsError."
|
|
370
|
+
},
|
|
371
|
+
"do": {
|
|
372
|
+
"type": "array",
|
|
373
|
+
"items": {},
|
|
374
|
+
"minItems": 1,
|
|
375
|
+
"description": "Sub-pipeline run each iteration."
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"required": [
|
|
379
|
+
"while",
|
|
380
|
+
"do"
|
|
381
|
+
],
|
|
382
|
+
"additionalProperties": false,
|
|
383
|
+
"description": "loop configuration."
|
|
384
|
+
},
|
|
385
|
+
"active": {
|
|
386
|
+
"type": "boolean"
|
|
387
|
+
},
|
|
388
|
+
"stop": {
|
|
389
|
+
"type": "boolean"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"required": [
|
|
393
|
+
"id",
|
|
394
|
+
"loop"
|
|
395
|
+
],
|
|
396
|
+
"additionalProperties": false
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"type": "object",
|
|
400
|
+
"properties": {
|
|
401
|
+
"id": {
|
|
402
|
+
"type": "string",
|
|
403
|
+
"minLength": 1,
|
|
404
|
+
"description": "Stable identifier for the switch step. Visible in traces."
|
|
405
|
+
},
|
|
406
|
+
"switch": {
|
|
407
|
+
"type": "object",
|
|
408
|
+
"properties": {
|
|
409
|
+
"on": {
|
|
410
|
+
"description": "Value to match against. Literal, `$` proxy expression, or `js/...` string. Resolved by the blueprint mapper before matching."
|
|
411
|
+
},
|
|
412
|
+
"cases": {
|
|
413
|
+
"type": "array",
|
|
414
|
+
"items": {
|
|
415
|
+
"type": "object",
|
|
416
|
+
"properties": {
|
|
417
|
+
"when": {
|
|
418
|
+
"description": "Match value. Literal scalar (number/string/boolean) for `on === when` matching, or an array for `array.includes(on)` matching."
|
|
419
|
+
},
|
|
420
|
+
"do": {
|
|
421
|
+
"type": "array",
|
|
422
|
+
"items": {},
|
|
423
|
+
"minItems": 1,
|
|
424
|
+
"description": "Sub-pipeline run when this case matches."
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
"required": [
|
|
428
|
+
"do"
|
|
429
|
+
],
|
|
430
|
+
"additionalProperties": false
|
|
431
|
+
},
|
|
432
|
+
"minItems": 1,
|
|
433
|
+
"description": "Ordered list of cases. First match wins."
|
|
434
|
+
},
|
|
435
|
+
"default": {
|
|
436
|
+
"type": "array",
|
|
437
|
+
"items": {},
|
|
438
|
+
"description": "Fallback sub-pipeline when no case matches. Optional."
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
"required": [
|
|
442
|
+
"cases"
|
|
443
|
+
],
|
|
444
|
+
"additionalProperties": false,
|
|
445
|
+
"description": "switch configuration."
|
|
446
|
+
},
|
|
447
|
+
"active": {
|
|
448
|
+
"type": "boolean"
|
|
449
|
+
},
|
|
450
|
+
"stop": {
|
|
451
|
+
"type": "boolean"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
"required": [
|
|
455
|
+
"id",
|
|
456
|
+
"switch"
|
|
457
|
+
],
|
|
458
|
+
"additionalProperties": false
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"type": "object",
|
|
462
|
+
"properties": {
|
|
463
|
+
"id": {
|
|
464
|
+
"type": "string",
|
|
465
|
+
"minLength": 1,
|
|
466
|
+
"description": "Stable identifier for the tryCatch step. Visible in traces."
|
|
467
|
+
},
|
|
468
|
+
"tryCatch": {
|
|
469
|
+
"type": "object",
|
|
470
|
+
"properties": {
|
|
471
|
+
"try": {
|
|
472
|
+
"type": "array",
|
|
473
|
+
"items": {},
|
|
474
|
+
"minItems": 1,
|
|
475
|
+
"description": "Sub-pipeline run first. If any step throws, control jumps to `catch`."
|
|
476
|
+
},
|
|
477
|
+
"catch": {
|
|
478
|
+
"type": "array",
|
|
479
|
+
"items": {},
|
|
480
|
+
"minItems": 1,
|
|
481
|
+
"description": "Sub-pipeline run when `try` throws. Has access to `$.error` (message, name, stack). Errors here propagate — they do NOT re-trigger catch."
|
|
482
|
+
},
|
|
483
|
+
"finally": {
|
|
484
|
+
"type": "array",
|
|
485
|
+
"items": {},
|
|
486
|
+
"description": "Sub-pipeline run unconditionally after try/catch. Runs even if `catch` itself throws. Errors here propagate."
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"required": [
|
|
490
|
+
"try",
|
|
491
|
+
"catch"
|
|
492
|
+
],
|
|
493
|
+
"additionalProperties": false,
|
|
494
|
+
"description": "tryCatch configuration."
|
|
495
|
+
},
|
|
496
|
+
"active": {
|
|
497
|
+
"type": "boolean"
|
|
498
|
+
},
|
|
499
|
+
"stop": {
|
|
500
|
+
"type": "boolean"
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
"required": [
|
|
504
|
+
"id",
|
|
505
|
+
"tryCatch"
|
|
506
|
+
],
|
|
507
|
+
"additionalProperties": false
|
|
508
|
+
},
|
|
268
509
|
{
|
|
269
510
|
"type": "object",
|
|
270
511
|
"properties": {
|
|
@@ -398,10 +639,6 @@
|
|
|
398
639
|
}
|
|
399
640
|
],
|
|
400
641
|
"description": "OPTIONAL. Per-attempt execution timeout. Number (ms) or duration string ('30s', '5m', '500ms'). When the step's `step.process()` exceeds this duration, the attempt fails with a StepTimeoutError. Pairs with `retry` — each attempt gets its own timeout (total budget = maxDuration × maxAttempts). On final-attempt timeout, the run auto-flips to `\"timedOut\"` status (distinct from `\"failed\"` so SLA dashboards can separate timeouts from logic failures)."
|
|
401
|
-
},
|
|
402
|
-
"set_var": {
|
|
403
|
-
"type": "boolean",
|
|
404
|
-
"description": "@deprecated v2 default-stores every step's output. `set_var: true` is a no-op; `set_var: false` is normalized to `ephemeral: true`."
|
|
405
642
|
}
|
|
406
643
|
},
|
|
407
644
|
"required": [
|
|
@@ -419,7 +656,6 @@
|
|
|
419
656
|
"required": [
|
|
420
657
|
"name",
|
|
421
658
|
"version",
|
|
422
|
-
"trigger",
|
|
423
659
|
"steps"
|
|
424
660
|
],
|
|
425
661
|
"additionalProperties": false
|