@oomol-lab/open-flow 0.1.0-beta.50 → 0.1.0-beta.51

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.
Files changed (33) hide show
  1. package/dist/browser/{createResourceDialog-CSltk-qY.js → createResourceDialog-BDtXpRSt.js} +1 -1
  2. package/dist/browser/flow-authoring-node.d.ts +3 -1
  3. package/dist/browser/flow-authoring.js +39 -3
  4. package/dist/browser/flow-change-schema.d.ts +1 -1
  5. package/dist/browser/flow-change.d.ts +9 -1
  6. package/dist/browser/flow-change.js +38 -3
  7. package/dist/browser/{flowChanges-DbYrpHnS.js → flowChanges-BWSXSnMX.js} +431 -27
  8. package/dist/browser/{flowWorkspace-CjwpbVBR.js → flowWorkspace-DBaq2Eks.js} +459 -190
  9. package/dist/browser/preview.css +20 -0
  10. package/dist/browser/preview.js +556 -21
  11. package/dist/browser/ui.css +20 -0
  12. package/dist/browser/ui.js +4 -3
  13. package/dist/browser/workbench-contract.d.ts +1 -0
  14. package/dist/browser/workbench.css +20 -0
  15. package/dist/browser/workbench.js +133 -22
  16. package/dist/browser/{workbenchSelect-oVujN2z6.js → workbenchSelect-C9kwcUmN.js} +47 -6
  17. package/dist/common/authoringExamples.d.ts +3 -2
  18. package/dist/common/control-api-conformance.js +82 -10
  19. package/dist/common/control-api.d.ts +34 -5
  20. package/dist/common/control-api.js +147 -10
  21. package/dist/common/control-requests.js +23 -1
  22. package/dist/common/flow-encoding.js +30 -5
  23. package/dist/common/flow-semantics.js +87 -2
  24. package/dist/common/integration-trigger.js +16 -1
  25. package/dist/common/mcp.js +82 -10
  26. package/dist/common/poll-trigger.js +16 -1
  27. package/dist/common/provider-triggers.js +16 -1
  28. package/dist/common/run-events.js +25 -1
  29. package/dist/common/scheduler.d.ts +3 -0
  30. package/dist/common/scheduler.js +91 -5
  31. package/dist/common/trigger-contract.d.ts +2 -0
  32. package/dist/common/webhook-trigger.js +16 -1
  33. package/package.json +1 -1
@@ -6045,6 +6045,7 @@ var endpoint = object({
6045
6045
  ])),
6046
6046
  successStatus: number()
6047
6047
  });
6048
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
6048
6049
  var trigger = {
6049
6050
  name: text,
6050
6051
  description: text.optional(),
@@ -6102,6 +6103,11 @@ var node = union([
6102
6103
  ...trigger,
6103
6104
  kind: literal("manual")
6104
6105
  }),
6106
+ strictObject({
6107
+ ...trigger,
6108
+ kind: literal("error"),
6109
+ sourceFlowIds: sourceFlowIds.optional()
6110
+ }),
6105
6111
  object({
6106
6112
  ...trigger,
6107
6113
  kind: literal("webhook"),
@@ -6173,7 +6179,11 @@ var document = object({
6173
6179
  tasks: record$1(text, managed)
6174
6180
  });
6175
6181
  var revision = object({
6176
- modelVersion: union([literal(2), literal(4)]),
6182
+ modelVersion: union([
6183
+ literal(2),
6184
+ literal(4),
6185
+ literal(5)
6186
+ ]),
6177
6187
  document,
6178
6188
  modules: record$1(text, module)
6179
6189
  });
@@ -6183,9 +6193,16 @@ revision.extend({
6183
6193
  });
6184
6194
  function decodeRevisionContent(value) {
6185
6195
  checkJsonDepth(value);
6186
- return revision.parse(value);
6196
+ const content = revision.parse(value);
6197
+ checkErrorModelVersion(content);
6198
+ return content;
6187
6199
  }
6188
6200
  var shapes = {
6201
+ "graph.trigger.sources.set": {
6202
+ nodeId: text,
6203
+ before: sourceFlowIds.optional(),
6204
+ value: sourceFlowIds.optional()
6205
+ },
6189
6206
  "binding.create": {
6190
6207
  bindingId: text,
6191
6208
  binding
@@ -6359,6 +6376,9 @@ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, sha
6359
6376
  kind: literal(kind),
6360
6377
  ...shape
6361
6378
  })])).values()])).min(1);
6379
+ function checkErrorModelVersion(content) {
6380
+ if (content.modelVersion < 5 && [content.document.graph, ...Object.values(content.document.subflows).map((item) => item.graph)].some((item) => Object.values(item.nodes).some((itemNode) => itemNode.kind == "error"))) throw new TypeError("Error workflows require Flow model version 5.");
6381
+ }
6362
6382
  //#endregion
6363
6383
  //#region src/flow/common/change.ts
6364
6384
  var schemaKeywords = /* @__PURE__ */ new Set([
@@ -9621,6 +9641,7 @@ function triggerKey(value) {
9621
9641
  };
9622
9642
  }
9623
9643
  var triggerKinds = /* @__PURE__ */ new Set([
9644
+ "error",
9624
9645
  "cron",
9625
9646
  "integration",
9626
9647
  "poll",
@@ -10003,6 +10024,17 @@ function variable(value) {
10003
10024
  version: 1
10004
10025
  };
10005
10026
  }
10027
+ function errorListener(value) {
10028
+ const source = record$2(value);
10029
+ if (typeof source.enabled != "boolean") return invalidResponse();
10030
+ return {
10031
+ flowId: string$1(source.flowId),
10032
+ flowName: string$1(source.flowName),
10033
+ nodeId: string$1(source.nodeId),
10034
+ nodeName: string$1(source.nodeName),
10035
+ enabled: source.enabled
10036
+ };
10037
+ }
10006
10038
  //#endregion
10007
10039
  //#region src/control/common/publicationDecoders.ts
10008
10040
  function publication(value) {
@@ -10272,6 +10304,7 @@ function runDetails(value) {
10272
10304
  };
10273
10305
  const details = {
10274
10306
  ...summary,
10307
+ ...errorHandling(source),
10275
10308
  closureDigest: string$1(source.closureDigest),
10276
10309
  engineContract: string$1(source.engineContract),
10277
10310
  engineDigest: string$1(source.engineDigest),
@@ -10371,10 +10404,7 @@ function runResult(value) {
10371
10404
  const error = record$2(source.error);
10372
10405
  return {
10373
10406
  ...base,
10374
- error: {
10375
- code: string$1(error.code),
10376
- message: string$1(error.message)
10377
- },
10407
+ error: runFailure(error),
10378
10408
  status: "failed"
10379
10409
  };
10380
10410
  }
@@ -10382,15 +10412,52 @@ function runResult(value) {
10382
10412
  const error = record$2(source.error);
10383
10413
  return {
10384
10414
  ...base,
10385
- error: {
10386
- code: string$1(error.code),
10387
- message: string$1(error.message)
10388
- },
10415
+ error: runFailure(error),
10389
10416
  status: "indeterminate"
10390
10417
  };
10391
10418
  }
10392
10419
  return invalidResponse();
10393
10420
  }
10421
+ function errorHandling(source) {
10422
+ const errorSource = source.errorSource == null ? void 0 : record$2(source.errorSource);
10423
+ if (source.errorDispatches != null && !Array.isArray(source.errorDispatches)) return invalidResponse();
10424
+ return {
10425
+ ...errorSource == null ? {} : { errorSource: {
10426
+ flowId: string$1(errorSource.flowId),
10427
+ runId: string$1(errorSource.runId)
10428
+ } },
10429
+ ...source.errorDispatches == null ? {} : { errorDispatches: source.errorDispatches.map((value) => {
10430
+ const dispatch = record$2(value);
10431
+ const flowId = string$1(dispatch.flowId);
10432
+ switch (dispatch.status) {
10433
+ case "pending": return {
10434
+ status: "pending",
10435
+ flowId
10436
+ };
10437
+ case "dispatched": return {
10438
+ status: "dispatched",
10439
+ flowId,
10440
+ runId: string$1(dispatch.runId)
10441
+ };
10442
+ case "failed": return {
10443
+ status: "failed",
10444
+ flowId,
10445
+ message: string$1(dispatch.message)
10446
+ };
10447
+ default: return invalidResponse();
10448
+ }
10449
+ }) }
10450
+ };
10451
+ }
10452
+ function runFailure(error) {
10453
+ return {
10454
+ code: string$1(error.code),
10455
+ message: string$1(error.message),
10456
+ ...error.nodeId === void 0 ? {} : { nodeId: string$1(error.nodeId) },
10457
+ ...error.jobId === void 0 ? {} : { jobId: string$1(error.jobId) },
10458
+ ...error.path === void 0 ? {} : { path: (Array.isArray(error.path) ? error.path : invalidResponse()).map(string$1) }
10459
+ };
10460
+ }
10394
10461
  //#endregion
10395
10462
  //#region src/control/common/random.ts
10396
10463
  function randomId() {
@@ -10689,6 +10756,11 @@ var ControlClient = class {
10689
10756
  async getFlow(flowId) {
10690
10757
  return flow(await this.request(`/v1/flows/${segment(flowId)}`));
10691
10758
  }
10759
+ async getErrorListeners(flowId, signal) {
10760
+ const source = record$2(await this.request(`/v1/flows/${segment(flowId)}/error-listeners`, { signal }));
10761
+ if (source.version != 1 || !Array.isArray(source.listeners)) return invalidResponse();
10762
+ return source.listeners.map(errorListener);
10763
+ }
10692
10764
  async renameFlow(flowId, name) {
10693
10765
  return flow(await this.request(`/v1/flows/${segment(flowId)}`, {
10694
10766
  body: JSON.stringify({
@@ -24,6 +24,13 @@ export type { RunStatus } from './run-lifecycle.js';
24
24
  export { ApiError, controlErrorCode, controlErrorMetadata, type ControlErrorCode } from './control-api-errors.js';
25
25
  export type { FlowCatalogEvent, FlowChangeEvent } from './flow-notifications.js';
26
26
  export type ControlRequest = (path: string, init?: RequestInit) => Promise<Response>;
27
+ export interface ErrorListener {
28
+ readonly flowId: string;
29
+ readonly flowName: string;
30
+ readonly nodeId: string;
31
+ readonly nodeName: string;
32
+ readonly enabled: boolean;
33
+ }
27
34
  export interface Flow {
28
35
  readonly live?: {
29
36
  readonly enabled: boolean;
@@ -78,7 +85,7 @@ export interface TriggerBinding {
78
85
  readonly endpointUrl?: string;
79
86
  readonly flowId: string;
80
87
  readonly health: 'failed' | 'healthy' | 'initializing' | 'needs_reauth' | 'suspended';
81
- readonly kind: 'cron' | 'integration' | 'poll' | 'webhook';
88
+ readonly kind: 'error' | 'cron' | 'integration' | 'poll' | 'webhook';
82
89
  readonly lastErrorCode?: string;
83
90
  readonly operatorState: 'active' | 'paused';
84
91
  readonly runtimeVersion: number;
@@ -336,7 +343,24 @@ export interface RunWait {
336
343
  readonly waitId: string;
337
344
  readonly waitingSince: string;
338
345
  }
346
+ export type ErrorDispatch = {
347
+ readonly status: 'pending';
348
+ readonly flowId: string;
349
+ } | {
350
+ readonly status: 'dispatched';
351
+ readonly flowId: string;
352
+ readonly runId: string;
353
+ } | {
354
+ readonly status: 'failed';
355
+ readonly flowId: string;
356
+ readonly message: string;
357
+ };
339
358
  type RunDetailsBase = Run & {
359
+ readonly errorDispatches?: readonly ErrorDispatch[];
360
+ readonly errorSource?: {
361
+ readonly flowId: string;
362
+ readonly runId: string;
363
+ };
340
364
  readonly closureDigest: string;
341
365
  readonly engineContract: string;
342
366
  readonly engineDigest: string;
@@ -379,6 +403,13 @@ export interface RunCancellation {
379
403
  readonly status: Extract<RunStatus, 'canceled' | 'completed' | 'failed' | 'indeterminate'>;
380
404
  readonly version: 1;
381
405
  }
406
+ export interface RunFailure {
407
+ readonly code: string;
408
+ readonly message: string;
409
+ readonly nodeId?: string;
410
+ readonly jobId?: string;
411
+ readonly path?: readonly string[];
412
+ }
382
413
  export type RunResult = {
383
414
  readonly finishedAt: string;
384
415
  readonly result: JsonValue;
@@ -386,10 +417,7 @@ export type RunResult = {
386
417
  readonly status: 'completed';
387
418
  readonly version: 1;
388
419
  } | {
389
- readonly error: {
390
- readonly code: string;
391
- readonly message: string;
392
- };
420
+ readonly error: RunFailure;
393
421
  readonly finishedAt: string;
394
422
  readonly runId: string;
395
423
  readonly status: 'failed' | 'indeterminate';
@@ -714,6 +742,7 @@ export declare class ControlClient {
714
742
  deleteVariable(name: string): Promise<void>;
715
743
  createFlow(name: string, idempotencyKey?: string, teamId?: string): Promise<Flow>;
716
744
  getFlow(flowId: string): Promise<Flow>;
745
+ getErrorListeners(flowId: string, signal?: AbortSignal): Promise<readonly ErrorListener[]>;
717
746
  renameFlow(flowId: string, name: string): Promise<Flow>;
718
747
  deleteFlow(flowId: string): Promise<Flow>;
719
748
  listTriggerKeys(signal?: AbortSignal, locale?: string): Promise<readonly TriggerKeySummary[]>;
@@ -6071,6 +6071,7 @@ var endpoint = object({
6071
6071
  ])),
6072
6072
  successStatus: number()
6073
6073
  });
6074
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
6074
6075
  var trigger = {
6075
6076
  name: text,
6076
6077
  description: text.optional(),
@@ -6128,6 +6129,11 @@ var node = union([
6128
6129
  ...trigger,
6129
6130
  kind: literal("manual")
6130
6131
  }),
6132
+ strictObject({
6133
+ ...trigger,
6134
+ kind: literal("error"),
6135
+ sourceFlowIds: sourceFlowIds.optional()
6136
+ }),
6131
6137
  object({
6132
6138
  ...trigger,
6133
6139
  kind: literal("webhook"),
@@ -6199,7 +6205,11 @@ var document = object({
6199
6205
  tasks: record(text, managed)
6200
6206
  });
6201
6207
  var revision = object({
6202
- modelVersion: union([literal(2), literal(4)]),
6208
+ modelVersion: union([
6209
+ literal(2),
6210
+ literal(4),
6211
+ literal(5)
6212
+ ]),
6203
6213
  document,
6204
6214
  modules: record(text, module)
6205
6215
  });
@@ -6209,9 +6219,16 @@ revision.extend({
6209
6219
  });
6210
6220
  function decodeRevisionContent(value) {
6211
6221
  checkJsonDepth(value);
6212
- return revision.parse(value);
6222
+ const content = revision.parse(value);
6223
+ checkErrorModelVersion(content);
6224
+ return content;
6213
6225
  }
6214
6226
  var shapes = {
6227
+ "graph.trigger.sources.set": {
6228
+ nodeId: text,
6229
+ before: sourceFlowIds.optional(),
6230
+ value: sourceFlowIds.optional()
6231
+ },
6215
6232
  "binding.create": {
6216
6233
  bindingId: text,
6217
6234
  binding
@@ -6385,6 +6402,9 @@ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, sha
6385
6402
  kind: literal(kind),
6386
6403
  ...shape
6387
6404
  })])).values()])).min(1);
6405
+ function checkErrorModelVersion(content) {
6406
+ if (content.modelVersion < 5 && [content.document.graph, ...Object.values(content.document.subflows).map((item) => item.graph)].some((item) => Object.values(item.nodes).some((itemNode) => itemNode.kind == "error"))) throw new TypeError("Error workflows require Flow model version 5.");
6407
+ }
6388
6408
  //#endregion
6389
6409
  //#region src/flow/common/condition.ts
6390
6410
  var unaryOperator = (operator) => operator.startsWith("is");
@@ -9566,6 +9586,67 @@ function createSchemaComparer() {
9566
9586
  createSchemaComparer();
9567
9587
  //#endregion
9568
9588
  //#region src/trigger/common/contract.ts
9589
+ var errorOutputs = [
9590
+ {
9591
+ handle: "workflow",
9592
+ nullable: false,
9593
+ jsonSchema: {
9594
+ type: "object",
9595
+ additionalProperties: false,
9596
+ required: [
9597
+ "flowId",
9598
+ "name",
9599
+ "revisionId",
9600
+ "publicationId"
9601
+ ],
9602
+ properties: {
9603
+ flowId: { type: "string" },
9604
+ name: { type: "string" },
9605
+ revisionId: { type: "string" },
9606
+ publicationId: { type: ["string", "null"] }
9607
+ }
9608
+ }
9609
+ },
9610
+ {
9611
+ handle: "execution",
9612
+ nullable: false,
9613
+ jsonSchema: {
9614
+ type: "object",
9615
+ additionalProperties: false,
9616
+ required: [
9617
+ "runId",
9618
+ "status",
9619
+ "startedAt",
9620
+ "finishedAt"
9621
+ ],
9622
+ properties: {
9623
+ runId: { type: "string" },
9624
+ status: { enum: ["failed", "indeterminate"] },
9625
+ startedAt: { type: ["string", "null"] },
9626
+ finishedAt: { type: "string" }
9627
+ }
9628
+ }
9629
+ },
9630
+ {
9631
+ handle: "error",
9632
+ nullable: false,
9633
+ jsonSchema: {
9634
+ type: "object",
9635
+ additionalProperties: false,
9636
+ required: ["code", "message"],
9637
+ properties: {
9638
+ code: { type: "string" },
9639
+ message: { type: "string" },
9640
+ nodeId: { type: "string" },
9641
+ jobId: { type: "string" },
9642
+ path: {
9643
+ type: "array",
9644
+ items: { type: "string" }
9645
+ }
9646
+ }
9647
+ }
9648
+ }
9649
+ ];
9569
9650
  var webhookOutputs = [
9570
9651
  {
9571
9652
  handle: "headers",
@@ -9610,6 +9691,7 @@ var cronOutputs = [{
9610
9691
  }];
9611
9692
  function triggerOutputDefinitions(trigger) {
9612
9693
  switch (trigger.kind) {
9694
+ case "error": return errorOutputs;
9613
9695
  case "manual": return [];
9614
9696
  case "cron": return cronOutputs;
9615
9697
  case "poll":
@@ -9638,6 +9720,7 @@ function nodeInputPorts(document, node) {
9638
9720
  case "cron":
9639
9721
  case "integration":
9640
9722
  case "poll":
9723
+ case "error":
9641
9724
  case "manual":
9642
9725
  case "webhook": return {};
9643
9726
  }
@@ -9688,6 +9771,7 @@ function nodeOutputPorts(document, node) {
9688
9771
  case "cron":
9689
9772
  case "integration":
9690
9773
  case "poll":
9774
+ case "error":
9691
9775
  case "manual":
9692
9776
  case "webhook": return triggerOutputPorts(node);
9693
9777
  }
@@ -9839,6 +9923,7 @@ function inspectNode(document, node) {
9839
9923
  })) }))
9840
9924
  }))
9841
9925
  };
9926
+ case "error":
9842
9927
  case "manual":
9843
9928
  case "cron":
9844
9929
  case "subflow": return {
@@ -10023,6 +10108,7 @@ function triggerKey(value) {
10023
10108
  };
10024
10109
  }
10025
10110
  var triggerKinds = /* @__PURE__ */ new Set([
10111
+ "error",
10026
10112
  "cron",
10027
10113
  "integration",
10028
10114
  "poll",
@@ -10528,6 +10614,17 @@ function variable(value) {
10528
10614
  version: 1
10529
10615
  };
10530
10616
  }
10617
+ function errorListener(value) {
10618
+ const source = record$1(value);
10619
+ if (typeof source.enabled != "boolean") return invalidResponse();
10620
+ return {
10621
+ flowId: string$1(source.flowId),
10622
+ flowName: string$1(source.flowName),
10623
+ nodeId: string$1(source.nodeId),
10624
+ nodeName: string$1(source.nodeName),
10625
+ enabled: source.enabled
10626
+ };
10627
+ }
10531
10628
  //#endregion
10532
10629
  //#region src/control/common/publicationDecoders.ts
10533
10630
  function publication(value) {
@@ -10797,6 +10894,7 @@ function runDetails(value) {
10797
10894
  };
10798
10895
  const details = {
10799
10896
  ...summary,
10897
+ ...errorHandling(source),
10800
10898
  closureDigest: string$1(source.closureDigest),
10801
10899
  engineContract: string$1(source.engineContract),
10802
10900
  engineDigest: string$1(source.engineDigest),
@@ -10896,10 +10994,7 @@ function runResult(value) {
10896
10994
  const error = record$1(source.error);
10897
10995
  return {
10898
10996
  ...base,
10899
- error: {
10900
- code: string$1(error.code),
10901
- message: string$1(error.message)
10902
- },
10997
+ error: runFailure(error),
10903
10998
  status: "failed"
10904
10999
  };
10905
11000
  }
@@ -10907,15 +11002,52 @@ function runResult(value) {
10907
11002
  const error = record$1(source.error);
10908
11003
  return {
10909
11004
  ...base,
10910
- error: {
10911
- code: string$1(error.code),
10912
- message: string$1(error.message)
10913
- },
11005
+ error: runFailure(error),
10914
11006
  status: "indeterminate"
10915
11007
  };
10916
11008
  }
10917
11009
  return invalidResponse();
10918
11010
  }
11011
+ function errorHandling(source) {
11012
+ const errorSource = source.errorSource == null ? void 0 : record$1(source.errorSource);
11013
+ if (source.errorDispatches != null && !Array.isArray(source.errorDispatches)) return invalidResponse();
11014
+ return {
11015
+ ...errorSource == null ? {} : { errorSource: {
11016
+ flowId: string$1(errorSource.flowId),
11017
+ runId: string$1(errorSource.runId)
11018
+ } },
11019
+ ...source.errorDispatches == null ? {} : { errorDispatches: source.errorDispatches.map((value) => {
11020
+ const dispatch = record$1(value);
11021
+ const flowId = string$1(dispatch.flowId);
11022
+ switch (dispatch.status) {
11023
+ case "pending": return {
11024
+ status: "pending",
11025
+ flowId
11026
+ };
11027
+ case "dispatched": return {
11028
+ status: "dispatched",
11029
+ flowId,
11030
+ runId: string$1(dispatch.runId)
11031
+ };
11032
+ case "failed": return {
11033
+ status: "failed",
11034
+ flowId,
11035
+ message: string$1(dispatch.message)
11036
+ };
11037
+ default: return invalidResponse();
11038
+ }
11039
+ }) }
11040
+ };
11041
+ }
11042
+ function runFailure(error) {
11043
+ return {
11044
+ code: string$1(error.code),
11045
+ message: string$1(error.message),
11046
+ ...error.nodeId === void 0 ? {} : { nodeId: string$1(error.nodeId) },
11047
+ ...error.jobId === void 0 ? {} : { jobId: string$1(error.jobId) },
11048
+ ...error.path === void 0 ? {} : { path: (Array.isArray(error.path) ? error.path : invalidResponse()).map(string$1) }
11049
+ };
11050
+ }
10919
11051
  //#endregion
10920
11052
  //#region src/control/common/random.ts
10921
11053
  function randomId() {
@@ -11214,6 +11346,11 @@ var ControlClient = class {
11214
11346
  async getFlow(flowId) {
11215
11347
  return flow(await this.request(`/v1/flows/${segment(flowId)}`));
11216
11348
  }
11349
+ async getErrorListeners(flowId, signal) {
11350
+ const source = record$1(await this.request(`/v1/flows/${segment(flowId)}/error-listeners`, { signal }));
11351
+ if (source.version != 1 || !Array.isArray(source.listeners)) return invalidResponse();
11352
+ return source.listeners.map(errorListener);
11353
+ }
11217
11354
  async renameFlow(flowId, name) {
11218
11355
  return flow(await this.request(`/v1/flows/${segment(flowId)}`, {
11219
11356
  body: JSON.stringify({
@@ -6021,6 +6021,7 @@ var endpoint = object({
6021
6021
  ])),
6022
6022
  successStatus: number()
6023
6023
  });
6024
+ var sourceFlowIds = array(text$1.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
6024
6025
  var trigger$1 = {
6025
6026
  name: text$1,
6026
6027
  description: text$1.optional(),
@@ -6078,6 +6079,11 @@ var node = union([
6078
6079
  ...trigger$1,
6079
6080
  kind: literal("manual")
6080
6081
  }),
6082
+ strictObject({
6083
+ ...trigger$1,
6084
+ kind: literal("error"),
6085
+ sourceFlowIds: sourceFlowIds.optional()
6086
+ }),
6081
6087
  object({
6082
6088
  ...trigger$1,
6083
6089
  kind: literal("webhook"),
@@ -6149,7 +6155,11 @@ var document = object({
6149
6155
  tasks: record(text$1, managed)
6150
6156
  });
6151
6157
  object({
6152
- modelVersion: union([literal(2), literal(4)]),
6158
+ modelVersion: union([
6159
+ literal(2),
6160
+ literal(4),
6161
+ literal(5)
6162
+ ]),
6153
6163
  document,
6154
6164
  modules: record(text$1, module)
6155
6165
  }).extend({
@@ -6157,6 +6167,11 @@ object({
6157
6167
  version: literal(1)
6158
6168
  });
6159
6169
  var shapes = {
6170
+ "graph.trigger.sources.set": {
6171
+ nodeId: text$1,
6172
+ before: sourceFlowIds.optional(),
6173
+ value: sourceFlowIds.optional()
6174
+ },
6160
6175
  "binding.create": {
6161
6176
  bindingId: text$1,
6162
6177
  binding
@@ -10449,6 +10464,7 @@ var eventSourceRevisionSchema = strictObject({
10449
10464
  var target = { kind: "flow" };
10450
10465
  var descriptions = {
10451
10466
  "manual": "A Manual start node.",
10467
+ "error": "An Error Trigger. Publish and enable this Flow before selecting it as another Flow’s error workflow.",
10452
10468
  "webhook": "A Webhook start node.",
10453
10469
  "cron": "An hourly scheduled start node.",
10454
10470
  "poll": "Gmail polling by key; replace CONNECTION_ID with an active Gmail connection.",
@@ -10471,6 +10487,12 @@ var authoringExamples = Object.keys(descriptions).map((name) => ({
10471
10487
  function authoringExample(name) {
10472
10488
  let operations;
10473
10489
  switch (name) {
10490
+ case "error":
10491
+ operations = createBuiltinTrigger(target, "error", {
10492
+ kind: "error",
10493
+ name: "Error Trigger"
10494
+ });
10495
+ break;
10474
10496
  case "manual":
10475
10497
  operations = createBuiltinTrigger(target, "start", {
10476
10498
  kind: "manual",
@@ -5825,6 +5825,7 @@ var endpoint = object({
5825
5825
  ])),
5826
5826
  successStatus: number()
5827
5827
  });
5828
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
5828
5829
  var trigger = {
5829
5830
  name: text,
5830
5831
  description: text.optional(),
@@ -5882,6 +5883,11 @@ var node = union([
5882
5883
  ...trigger,
5883
5884
  kind: literal("manual")
5884
5885
  }),
5886
+ strictObject({
5887
+ ...trigger,
5888
+ kind: literal("error"),
5889
+ sourceFlowIds: sourceFlowIds.optional()
5890
+ }),
5885
5891
  object({
5886
5892
  ...trigger,
5887
5893
  kind: literal("webhook"),
@@ -5953,7 +5959,11 @@ var document = object({
5953
5959
  tasks: record$1(text, managed)
5954
5960
  });
5955
5961
  var revision = object({
5956
- modelVersion: union([literal(2), literal(4)]),
5962
+ modelVersion: union([
5963
+ literal(2),
5964
+ literal(4),
5965
+ literal(5)
5966
+ ]),
5957
5967
  document,
5958
5968
  modules: record$1(text, module)
5959
5969
  });
@@ -6113,7 +6123,7 @@ function repairRevisionEnvelope(value) {
6113
6123
  checkJsonDepth(value);
6114
6124
  const envelopeSource = record(value);
6115
6125
  if (envelopeSource.kind != "open-flow-flow-revision" || envelopeSource.version != 1) throw new TypeError("The value is not an Open Flow Revision envelope.");
6116
- if (typeof envelopeSource.modelVersion == "number" && envelopeSource.modelVersion > 4) throw new TypeError("The Flow model is newer than this package.");
6126
+ if (typeof envelopeSource.modelVersion == "number" && envelopeSource.modelVersion > 5) throw new TypeError("The Flow model is newer than this package.");
6117
6127
  const sourceDocument = record(envelopeSource.modelVersion == 1 || envelopeSource.modelVersion == 2 ? upgradeLegacyDocument(envelopeSource.document) : envelopeSource.document);
6118
6128
  const bindings = record(sourceDocument.bindings);
6119
6129
  const sourceGraph = repairGraph(sourceDocument.graph, bindings);
@@ -6126,7 +6136,7 @@ function repairRevisionEnvelope(value) {
6126
6136
  return result.success ? [[id, result.data]] : [];
6127
6137
  }));
6128
6138
  return decodeRevisionContent({
6129
- modelVersion: 4,
6139
+ modelVersion: 5,
6130
6140
  document: {
6131
6141
  bindings: repairedEntries(sourceDocument.bindings, binding),
6132
6142
  graph: sourceGraph,
@@ -6142,7 +6152,9 @@ function decodeFlowDocument(value) {
6142
6152
  }
6143
6153
  function decodeRevisionContent(value) {
6144
6154
  checkJsonDepth(value);
6145
- return revision.parse(value);
6155
+ const content = revision.parse(value);
6156
+ checkErrorModelVersion(content);
6157
+ return content;
6146
6158
  }
6147
6159
  function decodeRevisionEnvelope(value) {
6148
6160
  checkJsonDepth(value);
@@ -6152,6 +6164,7 @@ function decodeRevisionEnvelope(value) {
6152
6164
  document: upgradeLegacyDocument(revisionSource.document)
6153
6165
  } : value;
6154
6166
  const content = envelope.parse(candidate);
6167
+ checkErrorModelVersion(content);
6155
6168
  return {
6156
6169
  modelVersion: content.modelVersion,
6157
6170
  document: content.document,
@@ -6159,6 +6172,11 @@ function decodeRevisionEnvelope(value) {
6159
6172
  };
6160
6173
  }
6161
6174
  var shapes = {
6175
+ "graph.trigger.sources.set": {
6176
+ nodeId: text,
6177
+ before: sourceFlowIds.optional(),
6178
+ value: sourceFlowIds.optional()
6179
+ },
6162
6180
  "binding.create": {
6163
6181
  bindingId: text,
6164
6182
  binding
@@ -6332,6 +6350,9 @@ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, sha
6332
6350
  kind: literal(kind),
6333
6351
  ...shape
6334
6352
  })])).values()])).min(1);
6353
+ function checkErrorModelVersion(content) {
6354
+ if (content.modelVersion < 5 && [content.document.graph, ...Object.values(content.document.subflows).map((item) => item.graph)].some((item) => Object.values(item.nodes).some((itemNode) => itemNode.kind == "error"))) throw new TypeError("Error workflows require Flow model version 5.");
6355
+ }
6335
6356
  //#endregion
6336
6357
  //#region src/flow/common/encoding.ts
6337
6358
  var encoder = new TextEncoder();
@@ -6606,6 +6627,10 @@ function canonicalTriggerNode(trigger) {
6606
6627
  name: trigger.name
6607
6628
  });
6608
6629
  switch (trigger.kind) {
6630
+ case "error": return {
6631
+ ...common(trigger.kind),
6632
+ ...trigger.sourceFlowIds == null ? {} : { sourceFlowIds: [...trigger.sourceFlowIds] }
6633
+ };
6609
6634
  case "manual": return common(trigger.kind);
6610
6635
  case "webhook": return {
6611
6636
  ...common(trigger.kind),
@@ -6705,7 +6730,7 @@ function revisionRepairKind(bytes) {
6705
6730
  return;
6706
6731
  }
6707
6732
  const source = value;
6708
- return typeof source.modelVersion == "number" && source.modelVersion < 4 ? "upgrade" : "repair";
6733
+ return typeof source.modelVersion == "number" && source.modelVersion < 5 ? "upgrade" : "repair";
6709
6734
  }
6710
6735
  function repairRevision(bytes) {
6711
6736
  return repairRevisionEnvelope(revisionValue(bytes));