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

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 (45) hide show
  1. package/dist/browser/{createResourceDialog-BDtXpRSt.js → createResourceDialog-BsaBMf7_.js} +2 -1
  2. package/dist/browser/flow-authoring.js +46 -3
  3. package/dist/browser/flow-change.d.ts +6 -1
  4. package/dist/browser/flow-change.js +46 -3
  5. package/dist/browser/{flowChanges-BWSXSnMX.js → flowChanges-CcscgZsW.js} +3492 -1939
  6. package/dist/browser/{flowWorkspace-DBaq2Eks.js → flowWorkspace-CoT_ewLX.js} +904 -330
  7. package/dist/browser/{workbenchSelect-C9kwcUmN.js → icons-0s-Q_3lp.js} +48 -32
  8. package/dist/browser/licenses.md +204 -0
  9. package/dist/browser/preview.css +282 -179
  10. package/dist/browser/preview.js +4311 -2200
  11. package/dist/browser/theme.css +2 -0
  12. package/dist/browser/ui-hostNavigationActions.d.ts +13 -0
  13. package/dist/browser/ui-hostTooltip.d.ts +8 -0
  14. package/dist/browser/ui-logo.d.ts +5 -0
  15. package/dist/browser/ui.css +82 -8
  16. package/dist/browser/ui.d.ts +3 -0
  17. package/dist/browser/ui.js +172 -8
  18. package/dist/browser/workbench-contract.d.ts +4 -11
  19. package/dist/browser/workbench.css +346 -200
  20. package/dist/browser/workbench.d.ts +1 -1
  21. package/dist/browser/workbench.js +1056 -367
  22. package/dist/browser/workbenchSelect-BqUPacsr.js +31 -0
  23. package/dist/common/authoringExamples.d.ts +4 -3
  24. package/dist/common/connector-proxy.d.ts +32 -0
  25. package/dist/common/control-api-conformance.js +54 -3
  26. package/dist/common/control-api.d.ts +6 -0
  27. package/dist/common/control-api.js +58 -4
  28. package/dist/common/control-requests.d.ts +4 -0
  29. package/dist/common/control-requests.js +1299 -68
  30. package/dist/common/feishu-subscriptions.d.ts +1 -5
  31. package/dist/common/flow-connectionUsage.d.ts +1 -0
  32. package/dist/common/flow-encoding.js +34 -0
  33. package/dist/common/flow-semantics.js +675 -252
  34. package/dist/common/integration-trigger.js +23 -0
  35. package/dist/common/mcp.js +54 -3
  36. package/dist/common/openapi.d.ts +53 -0
  37. package/dist/common/openapi.js +10390 -0
  38. package/dist/common/poll-trigger.js +23 -0
  39. package/dist/common/provider-triggers.d.ts +1 -1
  40. package/dist/common/provider-triggers.js +166 -16204
  41. package/dist/common/run-events.js +1 -0
  42. package/dist/common/scheduler.d.ts +1 -1
  43. package/dist/common/scheduler.js +31 -1
  44. package/dist/common/webhook-trigger.js +23 -0
  45. package/package.json +5 -1
@@ -859,7 +859,7 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
859
859
  };
860
860
  var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
861
861
  var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
862
- var validate = ((schema, value, _ctx) => {
862
+ var validate$1 = ((schema, value, _ctx) => {
863
863
  const validator = schema._zod.bag.validator;
864
864
  if (validator !== void 0) {
865
865
  if (validator(value) !== COMPILE_INVALID) return true;
@@ -4991,7 +4991,7 @@ var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4991
4991
  own(this, "spa", value);
4992
4992
  },
4993
4993
  validate(data, params) {
4994
- return validate(this, data, params);
4994
+ return validate$1(this, data, params);
4995
4995
  },
4996
4996
  validateAsync(data, params) {
4997
4997
  return validateAsync$1(this, data, params);
@@ -5457,7 +5457,7 @@ var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
5457
5457
  return required(ZodNonOptional, this, args[0]);
5458
5458
  }
5459
5459
  });
5460
- function object(shape, params) {
5460
+ function object$1(shape, params) {
5461
5461
  return new ZodObject({
5462
5462
  type: "object",
5463
5463
  shape: shape ?? {},
@@ -5781,11 +5781,11 @@ function checkJsonDepth(value, depth = 0) {
5781
5781
  }
5782
5782
  //#endregion
5783
5783
  //#region src/flow/common/triggerScheduleSchema.ts
5784
- var triggerScheduleSchema = array(union([object({
5784
+ var triggerScheduleSchema = array(union([object$1({
5785
5785
  type: literal("cron"),
5786
5786
  expression: string(),
5787
5787
  timezone: string()
5788
- }), object({
5788
+ }), object$1({
5789
5789
  type: literal("every"),
5790
5790
  unit: _enum([
5791
5791
  "day",
@@ -5808,40 +5808,40 @@ var webhookMethods = [
5808
5808
  var text$1 = string();
5809
5809
  var json$2 = json$3();
5810
5810
  var strings = array(text$1);
5811
- var port = object({
5811
+ var port = object$1({
5812
5812
  description: text$1.optional(),
5813
5813
  jsonSchema: json$2,
5814
5814
  nullable: boolean(),
5815
5815
  handle: text$1
5816
5816
  });
5817
5817
  var input = port.extend({ value: json$2.optional() });
5818
- var group = object({
5818
+ var group = object$1({
5819
5819
  collapsed: boolean().optional(),
5820
5820
  group: text$1
5821
5821
  });
5822
- var nodeSource = object({
5822
+ var nodeSource = object$1({
5823
5823
  kind: literal("node"),
5824
5824
  nodeId: text$1,
5825
5825
  output: text$1,
5826
5826
  field: text$1.optional()
5827
5827
  });
5828
- var flowSource = object({
5828
+ var flowSource = object$1({
5829
5829
  kind: literal("flow"),
5830
5830
  input: text$1
5831
5831
  });
5832
5832
  var source = union([
5833
5833
  nodeSource,
5834
5834
  flowSource,
5835
- object({
5835
+ object$1({
5836
5836
  kind: literal("binding"),
5837
5837
  bindingId: text$1
5838
5838
  })
5839
5839
  ]);
5840
- var fixedInput = union([object({ kind: literal("unset") }), object({
5840
+ var fixedInput = union([object$1({ kind: literal("unset") }), object$1({
5841
5841
  kind: literal("value"),
5842
5842
  value: json$2
5843
5843
  })]);
5844
- var mapping = union([fixedInput, object({
5844
+ var mapping = union([fixedInput, object$1({
5845
5845
  kind: literal("sources"),
5846
5846
  sources: array(source)
5847
5847
  })]);
@@ -5882,40 +5882,58 @@ var capability = union([
5882
5882
  })).optional()
5883
5883
  })
5884
5884
  ]);
5885
- var inline = object({
5885
+ var inline = object$1({
5886
5886
  ...ports,
5887
5887
  name: text$1,
5888
5888
  moduleId: text$1,
5889
5889
  capabilities: array(capability).optional()
5890
5890
  });
5891
- var agentValue = union([object({
5891
+ var agentValue = union([object$1({
5892
5892
  kind: literal("value"),
5893
5893
  value: json$2
5894
- }), object({
5894
+ }), object$1({
5895
5895
  kind: literal("input"),
5896
5896
  input: text$1
5897
5897
  })]);
5898
- var agentInput = union([agentValue, object({ kind: literal("model") })]);
5899
- var managed = object({
5898
+ var agentInput = union([agentValue, object$1({ kind: literal("model") })]);
5899
+ var managed = object$1({
5900
5900
  ...ports,
5901
5901
  name: text$1,
5902
5902
  executor: union([
5903
- object({
5903
+ object$1({
5904
5904
  kind: literal("connector"),
5905
5905
  action: text$1,
5906
5906
  connectionId: text$1.optional()
5907
5907
  }),
5908
- object({
5908
+ object$1({
5909
+ kind: literal("openapi"),
5910
+ sourceUrl: text$1,
5911
+ method: text$1,
5912
+ path: text$1,
5913
+ serverUrl: text$1,
5914
+ document: json$2,
5915
+ auth: array(object$1({
5916
+ id: text$1,
5917
+ type: _enum([
5918
+ "bearer",
5919
+ "basic",
5920
+ "apiKey"
5921
+ ]),
5922
+ name: text$1.optional(),
5923
+ in: _enum(["header", "query"]).optional()
5924
+ }))
5925
+ }),
5926
+ object$1({
5909
5927
  kind: literal("llm"),
5910
5928
  mode: _enum(["chat", "json"])
5911
5929
  }),
5912
- object({
5930
+ object$1({
5913
5931
  kind: literal("agent"),
5914
5932
  code: boolean().optional(),
5915
5933
  model: text$1,
5916
5934
  prompt: text$1,
5917
5935
  maxRounds: number(),
5918
- tools: array(object({
5936
+ tools: array(object$1({
5919
5937
  id: text$1,
5920
5938
  name: text$1,
5921
5939
  description: text$1,
@@ -5924,7 +5942,7 @@ var managed = object({
5924
5942
  approval: boolean(),
5925
5943
  inputs: array(input.extend({ source: agentInput }))
5926
5944
  })),
5927
- notification: object({
5945
+ notification: object$1({
5928
5946
  taskId: text$1,
5929
5947
  messageHandle: text$1,
5930
5948
  inputs: record(text$1, agentValue)
@@ -5932,20 +5950,20 @@ var managed = object({
5932
5950
  })
5933
5951
  ])
5934
5952
  });
5935
- var operand = union([object({
5953
+ var operand = union([object$1({
5936
5954
  kind: literal("value"),
5937
5955
  value: json$2.optional(),
5938
5956
  jsonSchema: json$2.optional()
5939
- }), object({
5957
+ }), object$1({
5940
5958
  kind: literal("source"),
5941
5959
  source
5942
5960
  })]);
5943
5961
  var condition = {
5944
5962
  matchMode: _enum(["first", "all"]),
5945
- cases: array(object({
5963
+ cases: array(object$1({
5946
5964
  description: text$1.optional(),
5947
5965
  output: text$1,
5948
- groups: array(object({ expressions: array(object({
5966
+ groups: array(object$1({ expressions: array(object$1({
5949
5967
  left: operand,
5950
5968
  operator: _enum([
5951
5969
  "!=",
@@ -5977,7 +5995,7 @@ var wait = {
5977
5995
  inputDefinitions: array(input),
5978
5996
  prompt: text$1
5979
5997
  };
5980
- var webhookOptions = object({
5998
+ var webhookOptions = object$1({
5981
5999
  allowedMethods: never().optional(),
5982
6000
  allowedOrigins: strings.optional(),
5983
6001
  noResponseBody: never().optional(),
@@ -6000,8 +6018,8 @@ var definition = {
6000
6018
  outputs: array(port).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
6001
6019
  provider: text$1
6002
6020
  };
6003
- var endpoint = object({
6004
- body: object({
6021
+ var endpoint = object$1({
6022
+ body: object$1({
6005
6023
  allowArray: boolean(),
6006
6024
  allowEmpty: boolean(),
6007
6025
  formats: array(_enum([
@@ -6036,30 +6054,30 @@ var base = {
6036
6054
  timeoutMs: number().optional()
6037
6055
  };
6038
6056
  var node = union([
6039
- object({
6057
+ object$1({
6040
6058
  ...base,
6041
6059
  inputs: record(text$1, never()),
6042
6060
  kind: literal("condition"),
6043
6061
  ...condition
6044
6062
  }),
6045
- object({
6063
+ object$1({
6046
6064
  ...base,
6047
6065
  inputs: unknown().transform(() => ({})).default({}),
6048
6066
  kind: literal("value"),
6049
6067
  values: array(input)
6050
6068
  }),
6051
- object({
6069
+ object$1({
6052
6070
  ...base,
6053
6071
  kind: literal("subflow"),
6054
6072
  subflowId: text$1
6055
6073
  }),
6056
- object({
6074
+ object$1({
6057
6075
  ...base,
6058
6076
  kind: literal("task"),
6059
6077
  task: inline,
6060
6078
  additionalInputs: array(input).optional()
6061
6079
  }),
6062
- object({
6080
+ object$1({
6063
6081
  ...base,
6064
6082
  kind: literal("task"),
6065
6083
  taskId: text$1,
@@ -6075,7 +6093,7 @@ var node = union([
6075
6093
  kind: literal("wait"),
6076
6094
  ...wait
6077
6095
  }).omit({ timeoutMs: true }),
6078
- object({
6096
+ object$1({
6079
6097
  ...trigger$1,
6080
6098
  kind: literal("manual")
6081
6099
  }),
@@ -6084,44 +6102,44 @@ var node = union([
6084
6102
  kind: literal("error"),
6085
6103
  sourceFlowIds: sourceFlowIds.optional()
6086
6104
  }),
6087
- object({
6105
+ object$1({
6088
6106
  ...trigger$1,
6089
6107
  kind: literal("webhook"),
6090
6108
  ...webhook
6091
6109
  }),
6092
- object({
6110
+ object$1({
6093
6111
  ...trigger$1,
6094
6112
  kind: literal("cron"),
6095
6113
  cronTimes: triggerScheduleSchema
6096
6114
  }),
6097
- object({
6115
+ object$1({
6098
6116
  ...trigger$1,
6099
6117
  kind: literal("poll"),
6100
6118
  connectionId: text$1.min(1).optional(),
6101
6119
  config: record(text$1, fixedInput),
6102
- definition: object({
6120
+ definition: object$1({
6103
6121
  ...definition,
6104
6122
  type: literal("poll")
6105
6123
  }),
6106
6124
  pollTimes: triggerScheduleSchema
6107
6125
  }),
6108
- object({
6126
+ object$1({
6109
6127
  ...trigger$1,
6110
6128
  kind: literal("integration"),
6111
6129
  connectionId: text$1.min(1).optional(),
6112
6130
  config: record(text$1, fixedInput),
6113
- definition: object({
6131
+ definition: object$1({
6114
6132
  ...definition,
6115
6133
  type: literal("integration"),
6116
6134
  endpoint
6117
6135
  })
6118
6136
  })
6119
6137
  ]);
6120
- var target$1 = union([object({ kind: literal("flow") }), object({
6138
+ var target$1 = union([object$1({ kind: literal("flow") }), object$1({
6121
6139
  kind: literal("subflow"),
6122
6140
  id: text$1
6123
6141
  })]);
6124
- var edge = object({
6142
+ var edge = object$1({
6125
6143
  source: text$1,
6126
6144
  target: text$1,
6127
6145
  sourceHandle: text$1.optional()
@@ -6130,31 +6148,31 @@ var at = {
6130
6148
  nodeId: text$1,
6131
6149
  target: target$1
6132
6150
  };
6133
- var subflow = object({
6151
+ var subflow = object$1({
6134
6152
  name: text$1,
6135
6153
  inputs: array(input),
6136
6154
  outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
6137
6155
  });
6138
- var graph = object({
6156
+ var graph = object$1({
6139
6157
  nodes: record(text$1, node),
6140
6158
  edges: array(edge).default([])
6141
6159
  });
6142
- var binding = object({
6160
+ var binding = object$1({
6143
6161
  kind: literal("variable"),
6144
6162
  target: text$1
6145
6163
  });
6146
- var module = object({
6164
+ var module = object$1({
6147
6165
  name: text$1,
6148
6166
  imports: strings,
6149
6167
  source: text$1
6150
6168
  });
6151
- var document = object({
6169
+ var document = object$1({
6152
6170
  bindings: record(text$1, binding),
6153
6171
  graph,
6154
6172
  subflows: record(text$1, subflow.extend({ graph })),
6155
6173
  tasks: record(text$1, managed)
6156
6174
  });
6157
- object({
6175
+ object$1({
6158
6176
  modelVersion: union([
6159
6177
  literal(2),
6160
6178
  literal(4),
@@ -6196,14 +6214,14 @@ var shapes = {
6196
6214
  },
6197
6215
  "graph.node.delete": at,
6198
6216
  "graph.node.field.set": union([
6199
- object({
6217
+ object$1({
6200
6218
  ...at,
6201
6219
  kind: literal("graph.node.field.set"),
6202
6220
  field: literal("connectionId"),
6203
6221
  before: text$1.min(1).optional(),
6204
6222
  value: text$1.min(1).optional()
6205
6223
  }),
6206
- object({
6224
+ object$1({
6207
6225
  ...at,
6208
6226
  kind: literal("graph.node.field.set"),
6209
6227
  field: _enum([
@@ -6214,14 +6232,14 @@ var shapes = {
6214
6232
  before: text$1.optional(),
6215
6233
  value: text$1.optional()
6216
6234
  }),
6217
- object({
6235
+ object$1({
6218
6236
  ...at,
6219
6237
  kind: literal("graph.node.field.set"),
6220
6238
  field: literal("maxExecutions"),
6221
6239
  before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
6222
6240
  value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
6223
6241
  }),
6224
- object({
6242
+ object$1({
6225
6243
  ...at,
6226
6244
  kind: literal("graph.node.field.set"),
6227
6245
  field: literal("timeoutMs"),
@@ -6242,8 +6260,8 @@ var shapes = {
6242
6260
  },
6243
6261
  "graph.node.condition.set": {
6244
6262
  ...at,
6245
- before: object(condition),
6246
- value: object(condition)
6263
+ before: object$1(condition),
6264
+ value: object$1(condition)
6247
6265
  },
6248
6266
  "graph.node.values.set": {
6249
6267
  ...at,
@@ -6252,20 +6270,20 @@ var shapes = {
6252
6270
  },
6253
6271
  "graph.node.resolution.set": {
6254
6272
  ...at,
6255
- target: object({ kind: literal("flow") }),
6256
- before: object(wait),
6257
- value: object(wait)
6273
+ target: object$1({ kind: literal("flow") }),
6274
+ before: object$1(wait),
6275
+ value: object$1(wait)
6258
6276
  },
6259
6277
  "graph.node.webhook.set": {
6260
6278
  ...at,
6261
- target: object({ kind: literal("flow") }),
6262
- before: object(webhook),
6263
- value: object(webhook)
6279
+ target: object$1({ kind: literal("flow") }),
6280
+ before: object$1(webhook),
6281
+ value: object$1(webhook)
6264
6282
  },
6265
6283
  "graph.node.task.ports.set": {
6266
6284
  ...at,
6267
- before: object(ports),
6268
- value: object(ports)
6285
+ before: object$1(ports),
6286
+ value: object$1(ports)
6269
6287
  },
6270
6288
  "graph.node.task.name.set": {
6271
6289
  ...at,
@@ -6325,6 +6343,11 @@ var shapes = {
6325
6343
  before: text$1.optional(),
6326
6344
  value: text$1.optional()
6327
6345
  },
6346
+ "task.openapi.set": {
6347
+ taskId: text$1,
6348
+ before: managed,
6349
+ value: managed
6350
+ },
6328
6351
  "task.agent.set": {
6329
6352
  taskId: text$1,
6330
6353
  before: managed,
@@ -6341,7 +6364,7 @@ var shapes = {
6341
6364
  value: text$1
6342
6365
  }
6343
6366
  };
6344
- var variants = new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
6367
+ var variants = new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object$1({
6345
6368
  kind: literal(kind),
6346
6369
  ...shape
6347
6370
  })]));
@@ -6355,7 +6378,7 @@ function parseOperation(candidate, index, parse) {
6355
6378
  }
6356
6379
  }
6357
6380
  function decodeChangeOperation(candidate, index) {
6358
- const { kind } = parseOperation(candidate, index, object({ kind: text$1 }).parse);
6381
+ const { kind } = parseOperation(candidate, index, object$1({ kind: text$1 }).parse);
6359
6382
  const schema = variants.get(kind);
6360
6383
  if (schema == null) throw new TypeError(`operations[${index}]: Unknown operation ${JSON.stringify(kind)}.`);
6361
6384
  return parseOperation(candidate, index, schema.parse);
@@ -6376,6 +6399,136 @@ function resourceNameIssue(value) {
6376
6399
  if (!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(name)) return "specialCharacter";
6377
6400
  }
6378
6401
  //#endregion
6402
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
6403
+ function deepCompareStrict(a, b) {
6404
+ const typeofa = typeof a;
6405
+ if (typeofa !== typeof b) return false;
6406
+ if (Array.isArray(a)) {
6407
+ if (!Array.isArray(b)) return false;
6408
+ const length = a.length;
6409
+ if (length !== b.length) return false;
6410
+ for (let i = 0; i < length; i++) if (!deepCompareStrict(a[i], b[i])) return false;
6411
+ return true;
6412
+ }
6413
+ if (typeofa === "object") {
6414
+ if (!a || !b) return a === b;
6415
+ const aKeys = Object.keys(a);
6416
+ const bKeys = Object.keys(b);
6417
+ if (aKeys.length !== bKeys.length) return false;
6418
+ for (const k of aKeys) if (!deepCompareStrict(a[k], b[k])) return false;
6419
+ return true;
6420
+ }
6421
+ return a === b;
6422
+ }
6423
+ //#endregion
6424
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/pointer.js
6425
+ function encodePointer(p) {
6426
+ return encodeURI(escapePointer(p));
6427
+ }
6428
+ function escapePointer(p) {
6429
+ return p.replace(/~/g, "~0").replace(/\//g, "~1");
6430
+ }
6431
+ //#endregion
6432
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/dereference.js
6433
+ var schemaArrayKeyword = {
6434
+ prefixItems: true,
6435
+ items: true,
6436
+ allOf: true,
6437
+ anyOf: true,
6438
+ oneOf: true
6439
+ };
6440
+ var schemaMapKeyword = {
6441
+ $defs: true,
6442
+ definitions: true,
6443
+ properties: true,
6444
+ patternProperties: true,
6445
+ dependentSchemas: true
6446
+ };
6447
+ var ignoredKeyword = {
6448
+ id: true,
6449
+ $id: true,
6450
+ $ref: true,
6451
+ $schema: true,
6452
+ $anchor: true,
6453
+ $vocabulary: true,
6454
+ $comment: true,
6455
+ default: true,
6456
+ enum: true,
6457
+ const: true,
6458
+ required: true,
6459
+ type: true,
6460
+ maximum: true,
6461
+ minimum: true,
6462
+ exclusiveMaximum: true,
6463
+ exclusiveMinimum: true,
6464
+ multipleOf: true,
6465
+ maxLength: true,
6466
+ minLength: true,
6467
+ pattern: true,
6468
+ format: true,
6469
+ maxItems: true,
6470
+ minItems: true,
6471
+ uniqueItems: true,
6472
+ maxProperties: true,
6473
+ minProperties: true
6474
+ };
6475
+ var initialBaseURI = typeof self !== "undefined" && self.location && self.location.origin !== "null" ? new URL(self.location.origin + self.location.pathname + location.search) : new URL("https://github.com/cfworker");
6476
+ function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
6477
+ if (schema && typeof schema === "object" && !Array.isArray(schema)) {
6478
+ const id = schema.$id || schema.id;
6479
+ if (id) {
6480
+ const url = new URL(id, baseURI.href);
6481
+ if (url.hash.length > 1) lookup[url.href] = schema;
6482
+ else {
6483
+ url.hash = "";
6484
+ if (basePointer === "") baseURI = url;
6485
+ else dereference(schema, lookup, baseURI);
6486
+ }
6487
+ }
6488
+ } else if (schema !== true && schema !== false) return lookup;
6489
+ const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
6490
+ if (lookup[schemaURI] !== void 0) throw new Error(`Duplicate schema URI "${schemaURI}".`);
6491
+ lookup[schemaURI] = schema;
6492
+ if (schema === true || schema === false) return lookup;
6493
+ if (schema.__absolute_uri__ === void 0) Object.defineProperty(schema, "__absolute_uri__", {
6494
+ enumerable: false,
6495
+ value: schemaURI
6496
+ });
6497
+ if (schema.$ref && schema.__absolute_ref__ === void 0) {
6498
+ const url = new URL(schema.$ref, baseURI.href);
6499
+ url.hash = url.hash;
6500
+ Object.defineProperty(schema, "__absolute_ref__", {
6501
+ enumerable: false,
6502
+ value: url.href
6503
+ });
6504
+ }
6505
+ if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === void 0) {
6506
+ const url = new URL(schema.$recursiveRef, baseURI.href);
6507
+ url.hash = url.hash;
6508
+ Object.defineProperty(schema, "__absolute_recursive_ref__", {
6509
+ enumerable: false,
6510
+ value: url.href
6511
+ });
6512
+ }
6513
+ if (schema.$anchor) {
6514
+ const url = new URL("#" + schema.$anchor, baseURI.href);
6515
+ lookup[url.href] = schema;
6516
+ }
6517
+ for (let key in schema) {
6518
+ if (ignoredKeyword[key]) continue;
6519
+ const keyBase = `${basePointer}/${encodePointer(key)}`;
6520
+ const subSchema = schema[key];
6521
+ if (Array.isArray(subSchema)) {
6522
+ if (schemaArrayKeyword[key]) {
6523
+ const length = subSchema.length;
6524
+ for (let i = 0; i < length; i++) dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
6525
+ }
6526
+ } else if (schemaMapKeyword[key]) for (let subKey in subSchema) dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
6527
+ else dereference(subSchema, lookup, baseURI, keyBase);
6528
+ }
6529
+ return lookup;
6530
+ }
6531
+ //#endregion
6379
6532
  //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/format.js
6380
6533
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
6381
6534
  var DAYS = [
@@ -6476,6 +6629,656 @@ function regex(str) {
6476
6629
  }
6477
6630
  }
6478
6631
  //#endregion
6632
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js
6633
+ function ucs2length(s) {
6634
+ let result = 0;
6635
+ let length = s.length;
6636
+ let index = 0;
6637
+ let charCode;
6638
+ while (index < length) {
6639
+ result++;
6640
+ charCode = s.charCodeAt(index++);
6641
+ if (charCode >= 55296 && charCode <= 56319 && index < length) {
6642
+ charCode = s.charCodeAt(index);
6643
+ if ((charCode & 64512) == 56320) index++;
6644
+ }
6645
+ }
6646
+ return result;
6647
+ }
6648
+ //#endregion
6649
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validate.js
6650
+ function validate(instance, schema, draft = "2019-09", lookup = dereference(schema), shortCircuit = true, recursiveAnchor = null, instanceLocation = "#", schemaLocation = "#", evaluated = Object.create(null)) {
6651
+ if (schema === true) return {
6652
+ valid: true,
6653
+ errors: []
6654
+ };
6655
+ if (schema === false) return {
6656
+ valid: false,
6657
+ errors: [{
6658
+ instanceLocation,
6659
+ keyword: "false",
6660
+ keywordLocation: instanceLocation,
6661
+ error: "False boolean schema."
6662
+ }]
6663
+ };
6664
+ const rawInstanceType = typeof instance;
6665
+ let instanceType;
6666
+ switch (rawInstanceType) {
6667
+ case "boolean":
6668
+ case "number":
6669
+ case "string":
6670
+ instanceType = rawInstanceType;
6671
+ break;
6672
+ case "object":
6673
+ if (instance === null) instanceType = "null";
6674
+ else if (Array.isArray(instance)) instanceType = "array";
6675
+ else instanceType = "object";
6676
+ break;
6677
+ default: throw new Error(`Instances of "${rawInstanceType}" type are not supported.`);
6678
+ }
6679
+ const { $ref, $recursiveRef, $recursiveAnchor, type: $type, const: $const, enum: $enum, required: $required, not: $not, anyOf: $anyOf, allOf: $allOf, oneOf: $oneOf, if: $if, then: $then, else: $else, format: $format, properties: $properties, patternProperties: $patternProperties, additionalProperties: $additionalProperties, unevaluatedProperties: $unevaluatedProperties, minProperties: $minProperties, maxProperties: $maxProperties, propertyNames: $propertyNames, dependentRequired: $dependentRequired, dependentSchemas: $dependentSchemas, dependencies: $dependencies, prefixItems: $prefixItems, items: $items, additionalItems: $additionalItems, unevaluatedItems: $unevaluatedItems, contains: $contains, minContains: $minContains, maxContains: $maxContains, minItems: $minItems, maxItems: $maxItems, uniqueItems: $uniqueItems, minimum: $minimum, maximum: $maximum, exclusiveMinimum: $exclusiveMinimum, exclusiveMaximum: $exclusiveMaximum, multipleOf: $multipleOf, minLength: $minLength, maxLength: $maxLength, pattern: $pattern, __absolute_ref__, __absolute_recursive_ref__ } = schema;
6680
+ const errors = [];
6681
+ if ($recursiveAnchor === true && recursiveAnchor === null) recursiveAnchor = schema;
6682
+ if ($recursiveRef === "#") {
6683
+ const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
6684
+ const keywordLocation = `${schemaLocation}/$recursiveRef`;
6685
+ const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
6686
+ if (!result.valid) errors.push({
6687
+ instanceLocation,
6688
+ keyword: "$recursiveRef",
6689
+ keywordLocation,
6690
+ error: "A subschema had errors."
6691
+ }, ...result.errors);
6692
+ }
6693
+ if ($ref !== void 0) {
6694
+ const refSchema = lookup[__absolute_ref__ || $ref];
6695
+ if (refSchema === void 0) {
6696
+ let message = `Unresolved $ref "${$ref}".`;
6697
+ if (__absolute_ref__ && __absolute_ref__ !== $ref) message += ` Absolute URI "${__absolute_ref__}".`;
6698
+ message += `\nKnown schemas:\n- ${Object.keys(lookup).join("\n- ")}`;
6699
+ throw new Error(message);
6700
+ }
6701
+ const keywordLocation = `${schemaLocation}/$ref`;
6702
+ const result = validate(instance, refSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated);
6703
+ if (!result.valid) errors.push({
6704
+ instanceLocation,
6705
+ keyword: "$ref",
6706
+ keywordLocation,
6707
+ error: "A subschema had errors."
6708
+ }, ...result.errors);
6709
+ if (draft === "4" || draft === "7") return {
6710
+ valid: errors.length === 0,
6711
+ errors
6712
+ };
6713
+ }
6714
+ if (Array.isArray($type)) {
6715
+ let length = $type.length;
6716
+ let valid = false;
6717
+ for (let i = 0; i < length; i++) if (instanceType === $type[i] || $type[i] === "integer" && instanceType === "number" && instance % 1 === 0 && instance === instance) {
6718
+ valid = true;
6719
+ break;
6720
+ }
6721
+ if (!valid) errors.push({
6722
+ instanceLocation,
6723
+ keyword: "type",
6724
+ keywordLocation: `${schemaLocation}/type`,
6725
+ error: `Instance type "${instanceType}" is invalid. Expected "${$type.join("\", \"")}".`
6726
+ });
6727
+ } else if ($type === "integer") {
6728
+ if (instanceType !== "number" || instance % 1 || instance !== instance) errors.push({
6729
+ instanceLocation,
6730
+ keyword: "type",
6731
+ keywordLocation: `${schemaLocation}/type`,
6732
+ error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
6733
+ });
6734
+ } else if ($type !== void 0 && instanceType !== $type) errors.push({
6735
+ instanceLocation,
6736
+ keyword: "type",
6737
+ keywordLocation: `${schemaLocation}/type`,
6738
+ error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
6739
+ });
6740
+ if ($const !== void 0) {
6741
+ if (instanceType === "object" || instanceType === "array") {
6742
+ if (!deepCompareStrict(instance, $const)) errors.push({
6743
+ instanceLocation,
6744
+ keyword: "const",
6745
+ keywordLocation: `${schemaLocation}/const`,
6746
+ error: `Instance does not match ${JSON.stringify($const)}.`
6747
+ });
6748
+ } else if (instance !== $const) errors.push({
6749
+ instanceLocation,
6750
+ keyword: "const",
6751
+ keywordLocation: `${schemaLocation}/const`,
6752
+ error: `Instance does not match ${JSON.stringify($const)}.`
6753
+ });
6754
+ }
6755
+ if ($enum !== void 0) {
6756
+ if (instanceType === "object" || instanceType === "array") {
6757
+ if (!$enum.some((value) => deepCompareStrict(instance, value))) errors.push({
6758
+ instanceLocation,
6759
+ keyword: "enum",
6760
+ keywordLocation: `${schemaLocation}/enum`,
6761
+ error: `Instance does not match any of ${JSON.stringify($enum)}.`
6762
+ });
6763
+ } else if (!$enum.some((value) => instance === value)) errors.push({
6764
+ instanceLocation,
6765
+ keyword: "enum",
6766
+ keywordLocation: `${schemaLocation}/enum`,
6767
+ error: `Instance does not match any of ${JSON.stringify($enum)}.`
6768
+ });
6769
+ }
6770
+ if ($not !== void 0) {
6771
+ const keywordLocation = `${schemaLocation}/not`;
6772
+ if (validate(instance, $not, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation).valid) errors.push({
6773
+ instanceLocation,
6774
+ keyword: "not",
6775
+ keywordLocation,
6776
+ error: "Instance matched \"not\" schema."
6777
+ });
6778
+ }
6779
+ let subEvaluateds = [];
6780
+ if ($anyOf !== void 0) {
6781
+ const keywordLocation = `${schemaLocation}/anyOf`;
6782
+ const errorsLength = errors.length;
6783
+ let anyValid = false;
6784
+ for (let i = 0; i < $anyOf.length; i++) {
6785
+ const subSchema = $anyOf[i];
6786
+ const subEvaluated = Object.create(evaluated);
6787
+ const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
6788
+ errors.push(...result.errors);
6789
+ anyValid = anyValid || result.valid;
6790
+ if (result.valid) subEvaluateds.push(subEvaluated);
6791
+ }
6792
+ if (anyValid) errors.length = errorsLength;
6793
+ else errors.splice(errorsLength, 0, {
6794
+ instanceLocation,
6795
+ keyword: "anyOf",
6796
+ keywordLocation,
6797
+ error: "Instance does not match any subschemas."
6798
+ });
6799
+ }
6800
+ if ($allOf !== void 0) {
6801
+ const keywordLocation = `${schemaLocation}/allOf`;
6802
+ const errorsLength = errors.length;
6803
+ let allValid = true;
6804
+ for (let i = 0; i < $allOf.length; i++) {
6805
+ const subSchema = $allOf[i];
6806
+ const subEvaluated = Object.create(evaluated);
6807
+ const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
6808
+ errors.push(...result.errors);
6809
+ allValid = allValid && result.valid;
6810
+ if (result.valid) subEvaluateds.push(subEvaluated);
6811
+ }
6812
+ if (allValid) errors.length = errorsLength;
6813
+ else errors.splice(errorsLength, 0, {
6814
+ instanceLocation,
6815
+ keyword: "allOf",
6816
+ keywordLocation,
6817
+ error: `Instance does not match every subschema.`
6818
+ });
6819
+ }
6820
+ if ($oneOf !== void 0) {
6821
+ const keywordLocation = `${schemaLocation}/oneOf`;
6822
+ const errorsLength = errors.length;
6823
+ const matches = $oneOf.filter((subSchema, i) => {
6824
+ const subEvaluated = Object.create(evaluated);
6825
+ const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
6826
+ errors.push(...result.errors);
6827
+ if (result.valid) subEvaluateds.push(subEvaluated);
6828
+ return result.valid;
6829
+ }).length;
6830
+ if (matches === 1) errors.length = errorsLength;
6831
+ else errors.splice(errorsLength, 0, {
6832
+ instanceLocation,
6833
+ keyword: "oneOf",
6834
+ keywordLocation,
6835
+ error: `Instance does not match exactly one subschema (${matches} matches).`
6836
+ });
6837
+ }
6838
+ if (instanceType === "object" || instanceType === "array") Object.assign(evaluated, ...subEvaluateds);
6839
+ if ($if !== void 0) {
6840
+ const keywordLocation = `${schemaLocation}/if`;
6841
+ if (validate(instance, $if, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated).valid) {
6842
+ if ($then !== void 0) {
6843
+ const thenResult = validate(instance, $then, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/then`, evaluated);
6844
+ if (!thenResult.valid) errors.push({
6845
+ instanceLocation,
6846
+ keyword: "if",
6847
+ keywordLocation,
6848
+ error: `Instance does not match "then" schema.`
6849
+ }, ...thenResult.errors);
6850
+ }
6851
+ } else if ($else !== void 0) {
6852
+ const elseResult = validate(instance, $else, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/else`, evaluated);
6853
+ if (!elseResult.valid) errors.push({
6854
+ instanceLocation,
6855
+ keyword: "if",
6856
+ keywordLocation,
6857
+ error: `Instance does not match "else" schema.`
6858
+ }, ...elseResult.errors);
6859
+ }
6860
+ }
6861
+ if (instanceType === "object") {
6862
+ if ($required !== void 0) {
6863
+ for (const key of $required) if (!(key in instance)) errors.push({
6864
+ instanceLocation,
6865
+ keyword: "required",
6866
+ keywordLocation: `${schemaLocation}/required`,
6867
+ error: `Instance does not have required property "${key}".`
6868
+ });
6869
+ }
6870
+ const keys = Object.keys(instance);
6871
+ if ($minProperties !== void 0 && keys.length < $minProperties) errors.push({
6872
+ instanceLocation,
6873
+ keyword: "minProperties",
6874
+ keywordLocation: `${schemaLocation}/minProperties`,
6875
+ error: `Instance does not have at least ${$minProperties} properties.`
6876
+ });
6877
+ if ($maxProperties !== void 0 && keys.length > $maxProperties) errors.push({
6878
+ instanceLocation,
6879
+ keyword: "maxProperties",
6880
+ keywordLocation: `${schemaLocation}/maxProperties`,
6881
+ error: `Instance does not have at least ${$maxProperties} properties.`
6882
+ });
6883
+ if ($propertyNames !== void 0) {
6884
+ const keywordLocation = `${schemaLocation}/propertyNames`;
6885
+ for (const key in instance) {
6886
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
6887
+ const result = validate(key, $propertyNames, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
6888
+ if (!result.valid) errors.push({
6889
+ instanceLocation,
6890
+ keyword: "propertyNames",
6891
+ keywordLocation,
6892
+ error: `Property name "${key}" does not match schema.`
6893
+ }, ...result.errors);
6894
+ }
6895
+ }
6896
+ if ($dependentRequired !== void 0) {
6897
+ const keywordLocation = `${schemaLocation}/dependantRequired`;
6898
+ for (const key in $dependentRequired) if (key in instance) {
6899
+ const required = $dependentRequired[key];
6900
+ for (const dependantKey of required) if (!(dependantKey in instance)) errors.push({
6901
+ instanceLocation,
6902
+ keyword: "dependentRequired",
6903
+ keywordLocation,
6904
+ error: `Instance has "${key}" but does not have "${dependantKey}".`
6905
+ });
6906
+ }
6907
+ }
6908
+ if ($dependentSchemas !== void 0) for (const key in $dependentSchemas) {
6909
+ const keywordLocation = `${schemaLocation}/dependentSchemas`;
6910
+ if (key in instance) {
6911
+ const result = validate(instance, $dependentSchemas[key], draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`, evaluated);
6912
+ if (!result.valid) errors.push({
6913
+ instanceLocation,
6914
+ keyword: "dependentSchemas",
6915
+ keywordLocation,
6916
+ error: `Instance has "${key}" but does not match dependant schema.`
6917
+ }, ...result.errors);
6918
+ }
6919
+ }
6920
+ if ($dependencies !== void 0) {
6921
+ const keywordLocation = `${schemaLocation}/dependencies`;
6922
+ for (const key in $dependencies) if (key in instance) {
6923
+ const propsOrSchema = $dependencies[key];
6924
+ if (Array.isArray(propsOrSchema)) {
6925
+ for (const dependantKey of propsOrSchema) if (!(dependantKey in instance)) errors.push({
6926
+ instanceLocation,
6927
+ keyword: "dependencies",
6928
+ keywordLocation,
6929
+ error: `Instance has "${key}" but does not have "${dependantKey}".`
6930
+ });
6931
+ } else {
6932
+ const result = validate(instance, propsOrSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`);
6933
+ if (!result.valid) errors.push({
6934
+ instanceLocation,
6935
+ keyword: "dependencies",
6936
+ keywordLocation,
6937
+ error: `Instance has "${key}" but does not match dependant schema.`
6938
+ }, ...result.errors);
6939
+ }
6940
+ }
6941
+ }
6942
+ const thisEvaluated = Object.create(null);
6943
+ let stop = false;
6944
+ if ($properties !== void 0) {
6945
+ const keywordLocation = `${schemaLocation}/properties`;
6946
+ for (const key in $properties) {
6947
+ if (!(key in instance)) continue;
6948
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
6949
+ const result = validate(instance[key], $properties[key], draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(key)}`);
6950
+ if (result.valid) evaluated[key] = thisEvaluated[key] = true;
6951
+ else {
6952
+ stop = shortCircuit;
6953
+ errors.push({
6954
+ instanceLocation,
6955
+ keyword: "properties",
6956
+ keywordLocation,
6957
+ error: `Property "${key}" does not match schema.`
6958
+ }, ...result.errors);
6959
+ if (stop) break;
6960
+ }
6961
+ }
6962
+ }
6963
+ if (!stop && $patternProperties !== void 0) {
6964
+ const keywordLocation = `${schemaLocation}/patternProperties`;
6965
+ for (const pattern in $patternProperties) {
6966
+ const regex = new RegExp(pattern, "u");
6967
+ const subSchema = $patternProperties[pattern];
6968
+ for (const key in instance) {
6969
+ if (!regex.test(key)) continue;
6970
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
6971
+ const result = validate(instance[key], subSchema, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(pattern)}`);
6972
+ if (result.valid) evaluated[key] = thisEvaluated[key] = true;
6973
+ else {
6974
+ stop = shortCircuit;
6975
+ errors.push({
6976
+ instanceLocation,
6977
+ keyword: "patternProperties",
6978
+ keywordLocation,
6979
+ error: `Property "${key}" matches pattern "${pattern}" but does not match associated schema.`
6980
+ }, ...result.errors);
6981
+ }
6982
+ }
6983
+ }
6984
+ }
6985
+ if (!stop && $additionalProperties !== void 0) {
6986
+ const keywordLocation = `${schemaLocation}/additionalProperties`;
6987
+ for (const key in instance) {
6988
+ if (thisEvaluated[key]) continue;
6989
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
6990
+ const result = validate(instance[key], $additionalProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
6991
+ if (result.valid) evaluated[key] = true;
6992
+ else {
6993
+ stop = shortCircuit;
6994
+ errors.push({
6995
+ instanceLocation,
6996
+ keyword: "additionalProperties",
6997
+ keywordLocation,
6998
+ error: `Property "${key}" does not match additional properties schema.`
6999
+ }, ...result.errors);
7000
+ }
7001
+ }
7002
+ } else if (!stop && $unevaluatedProperties !== void 0) {
7003
+ const keywordLocation = `${schemaLocation}/unevaluatedProperties`;
7004
+ for (const key in instance) if (!evaluated[key]) {
7005
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
7006
+ const result = validate(instance[key], $unevaluatedProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
7007
+ if (result.valid) evaluated[key] = true;
7008
+ else errors.push({
7009
+ instanceLocation,
7010
+ keyword: "unevaluatedProperties",
7011
+ keywordLocation,
7012
+ error: `Property "${key}" does not match unevaluated properties schema.`
7013
+ }, ...result.errors);
7014
+ }
7015
+ }
7016
+ } else if (instanceType === "array") {
7017
+ if ($maxItems !== void 0 && instance.length > $maxItems) errors.push({
7018
+ instanceLocation,
7019
+ keyword: "maxItems",
7020
+ keywordLocation: `${schemaLocation}/maxItems`,
7021
+ error: `Array has too many items (${instance.length} > ${$maxItems}).`
7022
+ });
7023
+ if ($minItems !== void 0 && instance.length < $minItems) errors.push({
7024
+ instanceLocation,
7025
+ keyword: "minItems",
7026
+ keywordLocation: `${schemaLocation}/minItems`,
7027
+ error: `Array has too few items (${instance.length} < ${$minItems}).`
7028
+ });
7029
+ const length = instance.length;
7030
+ let i = 0;
7031
+ let stop = false;
7032
+ if ($prefixItems !== void 0) {
7033
+ const keywordLocation = `${schemaLocation}/prefixItems`;
7034
+ const length2 = Math.min($prefixItems.length, length);
7035
+ for (; i < length2; i++) {
7036
+ const result = validate(instance[i], $prefixItems[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
7037
+ evaluated[i] = true;
7038
+ if (!result.valid) {
7039
+ stop = shortCircuit;
7040
+ errors.push({
7041
+ instanceLocation,
7042
+ keyword: "prefixItems",
7043
+ keywordLocation,
7044
+ error: `Items did not match schema.`
7045
+ }, ...result.errors);
7046
+ if (stop) break;
7047
+ }
7048
+ }
7049
+ }
7050
+ if ($items !== void 0) {
7051
+ const keywordLocation = `${schemaLocation}/items`;
7052
+ if (Array.isArray($items)) {
7053
+ const length2 = Math.min($items.length, length);
7054
+ for (; i < length2; i++) {
7055
+ const result = validate(instance[i], $items[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
7056
+ evaluated[i] = true;
7057
+ if (!result.valid) {
7058
+ stop = shortCircuit;
7059
+ errors.push({
7060
+ instanceLocation,
7061
+ keyword: "items",
7062
+ keywordLocation,
7063
+ error: `Items did not match schema.`
7064
+ }, ...result.errors);
7065
+ if (stop) break;
7066
+ }
7067
+ }
7068
+ } else for (; i < length; i++) {
7069
+ const result = validate(instance[i], $items, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
7070
+ evaluated[i] = true;
7071
+ if (!result.valid) {
7072
+ stop = shortCircuit;
7073
+ errors.push({
7074
+ instanceLocation,
7075
+ keyword: "items",
7076
+ keywordLocation,
7077
+ error: `Items did not match schema.`
7078
+ }, ...result.errors);
7079
+ if (stop) break;
7080
+ }
7081
+ }
7082
+ if (!stop && $additionalItems !== void 0) {
7083
+ const keywordLocation = `${schemaLocation}/additionalItems`;
7084
+ for (; i < length; i++) {
7085
+ const result = validate(instance[i], $additionalItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
7086
+ evaluated[i] = true;
7087
+ if (!result.valid) {
7088
+ stop = shortCircuit;
7089
+ errors.push({
7090
+ instanceLocation,
7091
+ keyword: "additionalItems",
7092
+ keywordLocation,
7093
+ error: `Items did not match additional items schema.`
7094
+ }, ...result.errors);
7095
+ }
7096
+ }
7097
+ }
7098
+ }
7099
+ if ($contains !== void 0) {
7100
+ if (length === 0 && $minContains === void 0) errors.push({
7101
+ instanceLocation,
7102
+ keyword: "contains",
7103
+ keywordLocation: `${schemaLocation}/contains`,
7104
+ error: `Array is empty. It must contain at least one item matching the schema.`
7105
+ });
7106
+ else if ($minContains !== void 0 && length < $minContains) errors.push({
7107
+ instanceLocation,
7108
+ keyword: "minContains",
7109
+ keywordLocation: `${schemaLocation}/minContains`,
7110
+ error: `Array has less items (${length}) than minContains (${$minContains}).`
7111
+ });
7112
+ else {
7113
+ const keywordLocation = `${schemaLocation}/contains`;
7114
+ const errorsLength = errors.length;
7115
+ let contained = 0;
7116
+ for (let j = 0; j < length; j++) {
7117
+ const result = validate(instance[j], $contains, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${j}`, keywordLocation);
7118
+ if (result.valid) {
7119
+ evaluated[j] = true;
7120
+ contained++;
7121
+ } else errors.push(...result.errors);
7122
+ }
7123
+ if (contained >= ($minContains || 0)) errors.length = errorsLength;
7124
+ if ($minContains === void 0 && $maxContains === void 0 && contained === 0) errors.splice(errorsLength, 0, {
7125
+ instanceLocation,
7126
+ keyword: "contains",
7127
+ keywordLocation,
7128
+ error: `Array does not contain item matching schema.`
7129
+ });
7130
+ else if ($minContains !== void 0 && contained < $minContains) errors.push({
7131
+ instanceLocation,
7132
+ keyword: "minContains",
7133
+ keywordLocation: `${schemaLocation}/minContains`,
7134
+ error: `Array must contain at least ${$minContains} items matching schema. Only ${contained} items were found.`
7135
+ });
7136
+ else if ($maxContains !== void 0 && contained > $maxContains) errors.push({
7137
+ instanceLocation,
7138
+ keyword: "maxContains",
7139
+ keywordLocation: `${schemaLocation}/maxContains`,
7140
+ error: `Array may contain at most ${$maxContains} items matching schema. ${contained} items were found.`
7141
+ });
7142
+ }
7143
+ }
7144
+ if (!stop && $unevaluatedItems !== void 0) {
7145
+ const keywordLocation = `${schemaLocation}/unevaluatedItems`;
7146
+ for (; i < length; i++) {
7147
+ if (evaluated[i]) continue;
7148
+ const result = validate(instance[i], $unevaluatedItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
7149
+ evaluated[i] = true;
7150
+ if (!result.valid) errors.push({
7151
+ instanceLocation,
7152
+ keyword: "unevaluatedItems",
7153
+ keywordLocation,
7154
+ error: `Items did not match unevaluated items schema.`
7155
+ }, ...result.errors);
7156
+ }
7157
+ }
7158
+ if ($uniqueItems) for (let j = 0; j < length; j++) {
7159
+ const a = instance[j];
7160
+ const ao = typeof a === "object" && a !== null;
7161
+ for (let k = 0; k < length; k++) {
7162
+ if (j === k) continue;
7163
+ const b = instance[k];
7164
+ if (a === b || ao && typeof b === "object" && b !== null && deepCompareStrict(a, b)) {
7165
+ errors.push({
7166
+ instanceLocation,
7167
+ keyword: "uniqueItems",
7168
+ keywordLocation: `${schemaLocation}/uniqueItems`,
7169
+ error: `Duplicate items at indexes ${j} and ${k}.`
7170
+ });
7171
+ j = Number.MAX_SAFE_INTEGER;
7172
+ k = Number.MAX_SAFE_INTEGER;
7173
+ }
7174
+ }
7175
+ }
7176
+ } else if (instanceType === "number") {
7177
+ if (draft === "4") {
7178
+ if ($minimum !== void 0 && ($exclusiveMinimum === true && instance <= $minimum || instance < $minimum)) errors.push({
7179
+ instanceLocation,
7180
+ keyword: "minimum",
7181
+ keywordLocation: `${schemaLocation}/minimum`,
7182
+ error: `${instance} is less than ${$exclusiveMinimum ? "or equal to " : ""} ${$minimum}.`
7183
+ });
7184
+ if ($maximum !== void 0 && ($exclusiveMaximum === true && instance >= $maximum || instance > $maximum)) errors.push({
7185
+ instanceLocation,
7186
+ keyword: "maximum",
7187
+ keywordLocation: `${schemaLocation}/maximum`,
7188
+ error: `${instance} is greater than ${$exclusiveMaximum ? "or equal to " : ""} ${$maximum}.`
7189
+ });
7190
+ } else {
7191
+ if ($minimum !== void 0 && instance < $minimum) errors.push({
7192
+ instanceLocation,
7193
+ keyword: "minimum",
7194
+ keywordLocation: `${schemaLocation}/minimum`,
7195
+ error: `${instance} is less than ${$minimum}.`
7196
+ });
7197
+ if ($maximum !== void 0 && instance > $maximum) errors.push({
7198
+ instanceLocation,
7199
+ keyword: "maximum",
7200
+ keywordLocation: `${schemaLocation}/maximum`,
7201
+ error: `${instance} is greater than ${$maximum}.`
7202
+ });
7203
+ if ($exclusiveMinimum !== void 0 && instance <= $exclusiveMinimum) errors.push({
7204
+ instanceLocation,
7205
+ keyword: "exclusiveMinimum",
7206
+ keywordLocation: `${schemaLocation}/exclusiveMinimum`,
7207
+ error: `${instance} is less than ${$exclusiveMinimum}.`
7208
+ });
7209
+ if ($exclusiveMaximum !== void 0 && instance >= $exclusiveMaximum) errors.push({
7210
+ instanceLocation,
7211
+ keyword: "exclusiveMaximum",
7212
+ keywordLocation: `${schemaLocation}/exclusiveMaximum`,
7213
+ error: `${instance} is greater than or equal to ${$exclusiveMaximum}.`
7214
+ });
7215
+ }
7216
+ if ($multipleOf !== void 0) {
7217
+ const remainder = instance % $multipleOf;
7218
+ if (Math.abs(0 - remainder) >= 1.1920929e-7 && Math.abs($multipleOf - remainder) >= 1.1920929e-7) errors.push({
7219
+ instanceLocation,
7220
+ keyword: "multipleOf",
7221
+ keywordLocation: `${schemaLocation}/multipleOf`,
7222
+ error: `${instance} is not a multiple of ${$multipleOf}.`
7223
+ });
7224
+ }
7225
+ } else if (instanceType === "string") {
7226
+ const length = $minLength === void 0 && $maxLength === void 0 ? 0 : ucs2length(instance);
7227
+ if ($minLength !== void 0 && length < $minLength) errors.push({
7228
+ instanceLocation,
7229
+ keyword: "minLength",
7230
+ keywordLocation: `${schemaLocation}/minLength`,
7231
+ error: `String is too short (${length} < ${$minLength}).`
7232
+ });
7233
+ if ($maxLength !== void 0 && length > $maxLength) errors.push({
7234
+ instanceLocation,
7235
+ keyword: "maxLength",
7236
+ keywordLocation: `${schemaLocation}/maxLength`,
7237
+ error: `String is too long (${length} > ${$maxLength}).`
7238
+ });
7239
+ if ($pattern !== void 0 && !new RegExp($pattern, "u").test(instance)) errors.push({
7240
+ instanceLocation,
7241
+ keyword: "pattern",
7242
+ keywordLocation: `${schemaLocation}/pattern`,
7243
+ error: `String does not match pattern.`
7244
+ });
7245
+ if ($format !== void 0 && format[$format] && !format[$format](instance)) errors.push({
7246
+ instanceLocation,
7247
+ keyword: "format",
7248
+ keywordLocation: `${schemaLocation}/format`,
7249
+ error: `String does not match format "${$format}".`
7250
+ });
7251
+ }
7252
+ return {
7253
+ valid: errors.length === 0,
7254
+ errors
7255
+ };
7256
+ }
7257
+ //#endregion
7258
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validator.js
7259
+ var Validator = class {
7260
+ schema;
7261
+ draft;
7262
+ shortCircuit;
7263
+ lookup;
7264
+ constructor(schema, draft = "2019-09", shortCircuit = true) {
7265
+ this.schema = schema;
7266
+ this.draft = draft;
7267
+ this.shortCircuit = shortCircuit;
7268
+ this.lookup = dereference(schema);
7269
+ }
7270
+ validate(instance) {
7271
+ return validate(instance, this.schema, this.draft, this.lookup, this.shortCircuit);
7272
+ }
7273
+ addSchema(schema, id) {
7274
+ if (id) schema = {
7275
+ ...schema,
7276
+ $id: id
7277
+ };
7278
+ dereference(schema, this.lookup);
7279
+ }
7280
+ };
7281
+ //#endregion
6479
7282
  //#region src/json-schema-subset/utils.ts
6480
7283
  var nextId = 0;
6481
7284
  function createId() {
@@ -9231,6 +10034,416 @@ function createSchemaComparer() {
9231
10034
  ] });
9232
10035
  }
9233
10036
  createSchemaComparer();
10037
+ //#endregion
10038
+ //#region src/flow/common/schema.ts
10039
+ function schemaObject(schema) {
10040
+ return schema != null && typeof schema == "object" && !Array.isArray(schema) ? schema : void 0;
10041
+ }
10042
+ var validators = /* @__PURE__ */ new WeakMap();
10043
+ function matchesSchema(value, schema) {
10044
+ return schemaValidationErrors(value, schema).length == 0;
10045
+ }
10046
+ function schemaValidationErrors(value, schema) {
10047
+ if (typeof schema == "boolean") return schema ? [] : ["The schema does not allow any value."];
10048
+ const source = schemaObject(schema);
10049
+ if (source == null || source.properties != null && schemaObject(source.properties) == null) return ["Invalid output schema."];
10050
+ try {
10051
+ let validator = validators.get(source);
10052
+ if (validator == null) {
10053
+ const declaration = typeof source.$schema == "string" ? source.$schema : "";
10054
+ const draft = declaration.includes("draft-04") ? "4" : declaration.includes("draft-07") ? "7" : declaration.includes("2020-12") ? "2020-12" : "2019-09";
10055
+ validator = new Validator(structuredClone(source), draft);
10056
+ validators.set(source, validator);
10057
+ }
10058
+ const result = validator.validate(value);
10059
+ return result.valid ? [] : result.errors.map((issue) => `${issue.instanceLocation || "/"}: ${issue.error}`);
10060
+ } catch {
10061
+ return ["Output schema validation failed."];
10062
+ }
10063
+ }
10064
+ //#endregion
10065
+ //#region src/openapi/common/openapi.ts
10066
+ var methods = [
10067
+ "get",
10068
+ "put",
10069
+ "post",
10070
+ "delete",
10071
+ "options",
10072
+ "head",
10073
+ "patch",
10074
+ "trace"
10075
+ ];
10076
+ function object(value) {
10077
+ if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error("Expected an OpenAPI object.");
10078
+ return value;
10079
+ }
10080
+ function httpUrl(value, base) {
10081
+ const url = new URL(value, base);
10082
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.hash) throw new Error("An HTTP(S) URL without credentials or fragment is required.");
10083
+ return url.href;
10084
+ }
10085
+ function parseOpenApi(value) {
10086
+ const doc = object(value);
10087
+ if (typeof doc.openapi != "string" || !/^3\.[01]\.\d+$/.test(doc.openapi)) throw new Error("Only OpenAPI 3.0 and 3.1 JSON documents are supported.");
10088
+ object(doc.paths);
10089
+ return doc;
10090
+ }
10091
+ function pointer(doc, ref) {
10092
+ if (!ref.startsWith("#/")) throw new Error("External OpenAPI references are not supported.");
10093
+ let value = doc;
10094
+ for (const key of decodeURIComponent(ref.slice(2)).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"))) {
10095
+ const source = object(value);
10096
+ if (!Object.hasOwn(source, key)) throw new Error("An OpenAPI reference is missing.");
10097
+ value = source[key];
10098
+ }
10099
+ return value;
10100
+ }
10101
+ function resolved(doc, value) {
10102
+ let result = object(value);
10103
+ const seen = /* @__PURE__ */ new Set();
10104
+ while (typeof result.$ref == "string") {
10105
+ if (seen.has(result.$ref)) throw new Error("Circular non-schema reference is unsupported.");
10106
+ seen.add(result.$ref);
10107
+ const { $ref, ...siblings } = result;
10108
+ result = {
10109
+ ...object(pointer(doc, $ref)),
10110
+ ...siblings
10111
+ };
10112
+ }
10113
+ return result;
10114
+ }
10115
+ function operation(doc, path, method) {
10116
+ const item = resolved(doc, object(doc.paths)[path]);
10117
+ if (!methods.includes(method) || item[method] == null) throw new Error("The selected operation is no longer available.");
10118
+ return {
10119
+ item,
10120
+ op: object(item[method])
10121
+ };
10122
+ }
10123
+ function servers(value, path, method) {
10124
+ const doc = parseOpenApi(value);
10125
+ const { item, op } = operation(doc, path, method);
10126
+ const entries = op.servers ?? item.servers ?? doc.servers;
10127
+ if (!Array.isArray(entries) || entries.length == 0) return [{ url: "/" }];
10128
+ return entries.map(object);
10129
+ }
10130
+ function serverAddress(server, sourceUrl, variables = {}) {
10131
+ return httpUrl(String(server.url).replace(/\{([^}]+)\}/g, (_, name) => {
10132
+ const definition = object(object(server.variables)[name]);
10133
+ const value = variables[name] ?? definition.default;
10134
+ if (typeof value != "string" || Array.isArray(definition.enum) && !definition.enum.includes(value)) throw new Error("A server variable is invalid.");
10135
+ return value;
10136
+ }), sourceUrl);
10137
+ }
10138
+ function securityOptions(value, path, method) {
10139
+ const doc = parseOpenApi(value);
10140
+ const { op } = operation(doc, path, method);
10141
+ const requirements = op.security ?? doc.security ?? [];
10142
+ if (!Array.isArray(requirements)) throw new Error("Invalid security requirements.");
10143
+ if (!requirements.length) return [{
10144
+ label: "None",
10145
+ auth: []
10146
+ }];
10147
+ return requirements.map((entry) => {
10148
+ const names = Object.keys(object(entry));
10149
+ const label = names.join(" + ") || "None";
10150
+ try {
10151
+ if (!names.length) return {
10152
+ label,
10153
+ auth: []
10154
+ };
10155
+ const schemes = object(object(doc.components).securitySchemes);
10156
+ return {
10157
+ label,
10158
+ auth: names.map((id) => {
10159
+ const scheme = resolved(doc, schemes[id]);
10160
+ if (scheme.type == "http" && ["bearer", "basic"].includes(String(scheme.scheme).toLowerCase())) return {
10161
+ id,
10162
+ type: String(scheme.scheme).toLowerCase()
10163
+ };
10164
+ if (scheme.type == "apiKey" && (scheme.in == "header" || scheme.in == "query") && typeof scheme.name == "string") return {
10165
+ id,
10166
+ type: "apiKey",
10167
+ name: scheme.name,
10168
+ in: scheme.in
10169
+ };
10170
+ throw new Error("This security scheme is unsupported. Supply an access token using manual Bearer authentication if applicable.");
10171
+ })
10172
+ };
10173
+ } catch (error) {
10174
+ return {
10175
+ label,
10176
+ error: error.message
10177
+ };
10178
+ }
10179
+ });
10180
+ }
10181
+ function snapshot(documentValue, path, method) {
10182
+ const doc = parseOpenApi(documentValue);
10183
+ const { item, op } = operation(doc, path, method);
10184
+ const security = op.security ?? doc.security ?? [];
10185
+ const result = {
10186
+ openapi: doc.openapi,
10187
+ paths: { [path]: {
10188
+ [method]: op,
10189
+ ...item.parameters == null ? {} : { parameters: item.parameters }
10190
+ } },
10191
+ servers: servers(doc, path, method),
10192
+ security
10193
+ };
10194
+ const visited = /* @__PURE__ */ new Set();
10195
+ function copy(ref) {
10196
+ if (visited.has(ref)) return;
10197
+ visited.add(ref);
10198
+ const value = pointer(doc, ref);
10199
+ const keys = decodeURIComponent(ref.slice(2)).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
10200
+ if (keys.some((key) => [
10201
+ "__proto__",
10202
+ "constructor",
10203
+ "prototype"
10204
+ ].includes(key))) throw new Error("Unsupported reference key.");
10205
+ let target = result;
10206
+ for (const key of keys.slice(0, -1)) {
10207
+ if (!Object.hasOwn(target, key)) target[key] = {};
10208
+ target = object(target[key]);
10209
+ }
10210
+ target[keys.at(-1)] = structuredClone(value);
10211
+ visit(value);
10212
+ }
10213
+ function visit(value) {
10214
+ if (value == null || typeof value != "object") return;
10215
+ if (Array.isArray(value)) {
10216
+ value.forEach(visit);
10217
+ return;
10218
+ }
10219
+ if (typeof object(value).$ref == "string") copy(object(value).$ref);
10220
+ for (const [key, child] of Object.entries(value)) if (![
10221
+ "example",
10222
+ "examples",
10223
+ "default"
10224
+ ].includes(key)) visit(child);
10225
+ }
10226
+ visit(result);
10227
+ for (const entry of security) for (const name of Object.keys(object(entry))) copy(`#/components/securitySchemes/${name.replace(/~/g, "~0").replace(/\//g, "~1")}`);
10228
+ return structuredClone(result);
10229
+ }
10230
+ function schema$1(doc, schemaValue) {
10231
+ const defs = {};
10232
+ const ids = /* @__PURE__ */ new Map();
10233
+ function convert(value) {
10234
+ if (typeof value == "boolean") return value;
10235
+ const source = object(value);
10236
+ if (source.format == "binary" || source.$dynamicRef != null || source.$id != null) throw new Error("Binary and dynamically scoped schemas are unsupported.");
10237
+ const result = {};
10238
+ for (const [key, child] of Object.entries(source)) {
10239
+ if ([
10240
+ "nullable",
10241
+ "example",
10242
+ "xml",
10243
+ "discriminator",
10244
+ "__proto__"
10245
+ ].includes(key)) continue;
10246
+ if (key == "$ref") {
10247
+ if (typeof child != "string") throw new Error("Invalid schema reference.");
10248
+ let id = ids.get(child);
10249
+ if (id == null) {
10250
+ id = `s${ids.size}`;
10251
+ ids.set(child, id);
10252
+ defs[id] = convert(pointer(doc, child));
10253
+ }
10254
+ result.$ref = `#/$defs/${id}`;
10255
+ } else if ([
10256
+ "properties",
10257
+ "patternProperties",
10258
+ "$defs",
10259
+ "definitions",
10260
+ "dependentSchemas"
10261
+ ].includes(key)) result[key] = Object.fromEntries(Object.entries(object(child)).map(([name, childSchema]) => [name, convert(childSchema)]));
10262
+ else if ([
10263
+ "allOf",
10264
+ "anyOf",
10265
+ "oneOf",
10266
+ "prefixItems"
10267
+ ].includes(key)) {
10268
+ if (!Array.isArray(child)) throw new Error("Invalid schema composition.");
10269
+ result[key] = child.map(convert);
10270
+ } else if ([
10271
+ "items",
10272
+ "additionalProperties",
10273
+ "not",
10274
+ "if",
10275
+ "then",
10276
+ "else",
10277
+ "contains",
10278
+ "propertyNames",
10279
+ "unevaluatedProperties"
10280
+ ].includes(key)) result[key] = convert(child);
10281
+ else result[key] = child;
10282
+ }
10283
+ if (source.nullable === true) return { anyOf: [result, { type: "null" }] };
10284
+ for (const key of ["minimum", "maximum"]) {
10285
+ const exclusive = key == "minimum" ? "exclusiveMinimum" : "exclusiveMaximum";
10286
+ if (typeof result[exclusive] == "boolean") {
10287
+ if (result[exclusive] && typeof result[key] == "number") {
10288
+ result[exclusive] = result[key];
10289
+ delete result[key];
10290
+ } else delete result[exclusive];
10291
+ }
10292
+ }
10293
+ return result;
10294
+ }
10295
+ let converted = convert(schemaValue);
10296
+ if (typeof converted == "object" && converted != null && typeof object(converted).$ref == "string") {
10297
+ const id = String(object(converted).$ref).slice(8);
10298
+ const { $ref: _ref, ...siblings } = object(converted);
10299
+ converted = {
10300
+ ...object(defs[id]),
10301
+ ...siblings
10302
+ };
10303
+ }
10304
+ if (typeof converted == "boolean") return converted;
10305
+ return {
10306
+ $schema: "https://json-schema.org/draft/2020-12/schema",
10307
+ ...object(converted),
10308
+ ...Object.keys(defs).length ? { $defs: defs } : {}
10309
+ };
10310
+ }
10311
+ function parameters(config) {
10312
+ const doc = parseOpenApi(config.document);
10313
+ const { item, op } = operation(doc, config.path, config.method);
10314
+ const entries = /* @__PURE__ */ new Map();
10315
+ for (const value of [...item.parameters ?? [], ...op.parameters ?? []]) {
10316
+ const p = resolved(doc, value);
10317
+ if (![
10318
+ "path",
10319
+ "query",
10320
+ "header"
10321
+ ].includes(String(p.in)) || typeof p.name != "string" || p.content != null) throw new Error("Only schema-based path, query and header parameters are supported.");
10322
+ if (p.allowReserved === true) throw new Error("allowReserved parameters are unsupported.");
10323
+ if ((p.style ?? (p.in == "query" ? "form" : "simple")) != (p.in == "query" ? "form" : "simple")) throw new Error("Only form query and simple path/header serialization are supported.");
10324
+ entries.set(`${p.in}.${p.in == "header" ? p.name.toLowerCase() : p.name}`, p);
10325
+ }
10326
+ return [...entries.values()];
10327
+ }
10328
+ function jsonContent(doc, value) {
10329
+ const content = resolved(doc, value);
10330
+ const media = object(content.content);
10331
+ const mediaType = media["application/json"] != null ? "application/json" : Object.keys(media).find((key) => /^application\/.+\+json$/.test(key));
10332
+ const json = mediaType == null ? void 0 : media[mediaType];
10333
+ if (json == null) throw new Error("Only JSON request and response bodies are supported.");
10334
+ return {
10335
+ schema: schema$1(doc, object(json).schema ?? {}),
10336
+ required: content.required === true,
10337
+ mediaType
10338
+ };
10339
+ }
10340
+ function authHandles(auth) {
10341
+ return auth.flatMap((scheme) => scheme.type == "basic" ? [`auth.${scheme.id}.username`, `auth.${scheme.id}.password`] : [`auth.${scheme.id}.token`]);
10342
+ }
10343
+ function openApiTask(config, name = "OpenAPI") {
10344
+ if (!config.path) return {
10345
+ name,
10346
+ executor: config,
10347
+ inputs: [],
10348
+ outputs: []
10349
+ };
10350
+ const doc = parseOpenApi(config.document);
10351
+ const { op } = operation(doc, config.path, config.method);
10352
+ const params = parameters(config);
10353
+ const inputs = params.map((p) => {
10354
+ const jsonSchema = schema$1(doc, p.schema ?? {});
10355
+ const defaultValue = typeof jsonSchema == "boolean" ? void 0 : object(jsonSchema).default;
10356
+ return {
10357
+ handle: `${p.in}.${p.name}`,
10358
+ jsonSchema,
10359
+ nullable: p.required !== true && p.in != "path" || matchesSchema(null, jsonSchema),
10360
+ ...typeof p.description == "string" ? { description: p.description } : {},
10361
+ ...defaultValue === void 0 ? {} : { value: defaultValue }
10362
+ };
10363
+ });
10364
+ if (op.requestBody != null) {
10365
+ if (config.method == "get" || config.method == "head") throw new Error("GET and HEAD request bodies are unsupported.");
10366
+ const body = jsonContent(doc, op.requestBody);
10367
+ inputs.push({
10368
+ handle: "body",
10369
+ jsonSchema: body.schema,
10370
+ nullable: !body.required || matchesSchema(null, body.schema)
10371
+ });
10372
+ }
10373
+ const occupied = new Set(params.map((p) => `${p.in}.${p.in == "header" ? String(p.name).toLowerCase() : p.name}`));
10374
+ for (const auth of config.auth) {
10375
+ const location = auth.type == "apiKey" ? `${auth.in}.${auth.in == "header" ? auth.name?.toLowerCase() : auth.name}` : "header.authorization";
10376
+ if (occupied.has(location)) throw new Error("Authentication conflicts with a parameter or another security scheme.");
10377
+ if (auth.type == "apiKey" && (!auth.name || !["header", "query"].includes(auth.in ?? ""))) throw new Error("API Key requires a name and location.");
10378
+ occupied.add(location);
10379
+ }
10380
+ inputs.push(...authHandles(config.auth).map((handle) => ({
10381
+ handle,
10382
+ jsonSchema: { type: "string" },
10383
+ nullable: false
10384
+ })));
10385
+ const responses = object(op.responses);
10386
+ const schemas = [];
10387
+ for (const [status, response] of Object.entries(responses)) if (/^2\d\d$|^2XX$/.test(status) || status == "default") {
10388
+ const r = resolved(doc, response);
10389
+ if (r.content == null) schemas.push({ type: "null" });
10390
+ else {
10391
+ jsonContent(doc, r);
10392
+ for (const [mediaType, media] of Object.entries(object(r.content))) if (/^application\/(json|.+\+json)$/.test(mediaType)) schemas.push(schema$1(doc, object(media).schema ?? {}));
10393
+ }
10394
+ }
10395
+ if (!schemas.length) throw new Error("A successful JSON response definition is required.");
10396
+ return {
10397
+ name,
10398
+ executor: config,
10399
+ inputs,
10400
+ outputs: [
10401
+ {
10402
+ handle: "body",
10403
+ jsonSchema: schemas.length == 1 ? schemas[0] : {
10404
+ $schema: "https://json-schema.org/draft/2020-12/schema",
10405
+ anyOf: schemas.map((s, index) => inlineSchema(s, index))
10406
+ },
10407
+ nullable: config.method == "head" || schemas.some((item) => matchesSchema(null, item))
10408
+ },
10409
+ {
10410
+ handle: "statusCode",
10411
+ jsonSchema: { type: "integer" },
10412
+ nullable: false
10413
+ },
10414
+ {
10415
+ handle: "headers",
10416
+ jsonSchema: {
10417
+ type: "object",
10418
+ additionalProperties: { type: "string" }
10419
+ },
10420
+ nullable: false
10421
+ }
10422
+ ]
10423
+ };
10424
+ }
10425
+ function inlineSchema(value, index) {
10426
+ if (Array.isArray(value)) return value.map((item) => inlineSchema(item, index));
10427
+ if (value == null || typeof value != "object") return value;
10428
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, key == "$ref" && typeof child == "string" && child.startsWith("#/") ? `#/anyOf/${index}/${child.slice(2)}` : inlineSchema(child, index)]));
10429
+ }
10430
+ function selectOperation(value, sourceUrl, path, method) {
10431
+ const doc = snapshot(value, path, method);
10432
+ const choices = securityOptions(doc, path, method);
10433
+ const auth = choices.find((choice) => choice.auth != null)?.auth;
10434
+ if (auth == null) throw new Error(choices[0]?.error ?? "Unsupported authentication.");
10435
+ const config = {
10436
+ kind: "openapi",
10437
+ sourceUrl: httpUrl(sourceUrl),
10438
+ method,
10439
+ path,
10440
+ serverUrl: serverAddress(servers(doc, path, method)[0], sourceUrl),
10441
+ document: doc,
10442
+ auth
10443
+ };
10444
+ openApiTask(config);
10445
+ return config;
10446
+ }
9234
10447
  `${JSON.stringify("open-flow-engine/v5")}`, new Set([
9235
10448
  "assert",
9236
10449
  "assert/strict",
@@ -10408,7 +11621,7 @@ var triggerCreate = strictObject({
10408
11621
  function decodeDraftOperations(value) {
10409
11622
  checkJsonDepth(value);
10410
11623
  return array(unknown()).min(1).parse(value).map((candidate, index) => {
10411
- const { kind } = parseOperation(candidate, index, object({ kind: text }).parse);
11624
+ const { kind } = parseOperation(candidate, index, object$1({ kind: text }).parse);
10412
11625
  return kind == "graph.trigger.create" ? parseOperation(candidate, index, triggerCreate.parse) : decodeChangeOperation(candidate, index);
10413
11626
  });
10414
11627
  }
@@ -10464,11 +11677,12 @@ var eventSourceRevisionSchema = strictObject({
10464
11677
  var target = { kind: "flow" };
10465
11678
  var descriptions = {
10466
11679
  "manual": "A Manual start node.",
10467
- "error": "An Error Trigger. Publish and enable this Flow before selecting it as another Flow’s error workflow.",
11680
+ "error": "A Flow Error node. Select upstream Flows, then publish and enable this Flow to listen for failures in their automatic runs.",
10468
11681
  "webhook": "A Webhook start node.",
10469
11682
  "cron": "An hourly scheduled start node.",
10470
11683
  "poll": "Gmail polling by key; replace CONNECTION_ID with an active Gmail connection.",
10471
11684
  "integration": "Telegram webhook integration by key; replace CONNECTION_ID with an active Telegram connection.",
11685
+ "openapi": "A fixed JSON API operation. Replace the example document and URL before running.",
10472
11686
  "connector": "A Connector Task and its node. Replace ACTION_ID, CONNECTION_ID and port definitions using connector_get / connector show.",
10473
11687
  "code": "A JavaScript module and its node. Use Code for custom computation; use Connector Tasks for existing actions.",
10474
11688
  "condition": "A condition with true and false execution branches.",
@@ -10490,9 +11704,21 @@ function authoringExample(name) {
10490
11704
  case "error":
10491
11705
  operations = createBuiltinTrigger(target, "error", {
10492
11706
  kind: "error",
10493
- name: "Error Trigger"
11707
+ name: "Flow Error"
10494
11708
  });
10495
11709
  break;
11710
+ case "openapi":
11711
+ operations = createManagedTask(target, {
11712
+ nodeId: "api",
11713
+ taskId: "api-task"
11714
+ }, openApiTask(selectOperation({
11715
+ openapi: "3.1.0",
11716
+ paths: { "/items": { get: { responses: { "200": { content: { "application/json": { schema: {
11717
+ type: "array",
11718
+ items: { type: "string" }
11719
+ } } } } } } } }
11720
+ }, "https://api.example.com/openapi.json", "/items", "get")));
11721
+ break;
10496
11722
  case "manual":
10497
11723
  operations = createBuiltinTrigger(target, "start", {
10498
11724
  kind: "manual",
@@ -10732,6 +11958,10 @@ var trigger = strictObject({
10732
11958
  outputs: record(string(), json)
10733
11959
  });
10734
11960
  var schemas = {
11961
+ loadOpenApiDocument: strictObject({
11962
+ url: string().min(1).max(8192),
11963
+ version
11964
+ }),
10735
11965
  createEventSource: createEventSourceSchema,
10736
11966
  updateEventSource: updateEventSourceSchema,
10737
11967
  eventSourceRevision: eventSourceRevisionSchema,
@@ -10828,6 +12058,7 @@ function decoder(schema) {
10828
12058
  return (value) => schema.parse(value);
10829
12059
  }
10830
12060
  var controlRequests = {
12061
+ loadOpenApiDocument: decoder(schemas.loadOpenApiDocument),
10831
12062
  createEventSource: decoder(schemas.createEventSource),
10832
12063
  updateEventSource: decoder(schemas.updateEventSource),
10833
12064
  eventSourceRevision: decoder(schemas.eventSourceRevision),