@oomol-lab/open-flow 0.1.0-beta.61 → 0.1.0-beta.62

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.
@@ -22,15 +22,6 @@ function dequal(foo, bar) {
22
22
  return foo !== foo && bar !== bar;
23
23
  }
24
24
  //#endregion
25
- //#region src/openapi/common/authBindings.ts
26
- /** Never allow credentials to enter a Revision as literal node inputs. */
27
- function assertOpenApiAuthBindings(document) {
28
- for (const node of Object.values(document.graph.nodes)) {
29
- if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
30
- for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
31
- }
32
- }
33
- //#endregion
34
25
  //#region ../../node_modules/.bun/zod@4.6.5/node_modules/zod/v4/core/util.js
35
26
  function getEnumValues(entries) {
36
27
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
@@ -5699,27 +5690,6 @@ function preprocess(fn, schema) {
5699
5690
  out: schema
5700
5691
  });
5701
5692
  }
5702
- function checkJsonDepth(value, depth = 0) {
5703
- if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
5704
- if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
5705
- }
5706
- //#endregion
5707
- //#region src/flow/common/triggerScheduleSchema.ts
5708
- var triggerScheduleSchema = array(union([object({
5709
- type: literal("cron"),
5710
- expression: string$1(),
5711
- timezone: string$1()
5712
- }), object({
5713
- type: literal("every"),
5714
- unit: _enum([
5715
- "day",
5716
- "hour",
5717
- "minute",
5718
- "month",
5719
- "week"
5720
- ]),
5721
- value: number()
5722
- })]));
5723
5693
  //#endregion
5724
5694
  //#region src/flow/common/webhookMethod.ts
5725
5695
  var webhookMethods = [
@@ -5729,677 +5699,112 @@ var webhookMethods = [
5729
5699
  "PATCH",
5730
5700
  "DELETE"
5731
5701
  ];
5732
- var text = string$1();
5733
- var json$3 = json$4();
5734
- var strings$1 = array(text);
5735
- var port$1 = object({
5736
- description: text.optional(),
5737
- jsonSchema: json$3,
5738
- nullable: boolean(),
5739
- handle: text
5740
- });
5741
- var input = port$1.extend({ value: json$3.optional() });
5742
- var group = object({
5743
- collapsed: boolean().optional(),
5744
- group: text
5745
- });
5746
- var source = union([object({
5747
- kind: literal("node"),
5748
- nodeId: text,
5749
- output: text,
5750
- field: text.optional()
5751
- }), object({
5752
- kind: literal("binding"),
5753
- bindingId: text
5754
- })]);
5755
- var fixedInput = union([object({ kind: literal("unset") }), object({
5756
- kind: literal("value"),
5757
- value: json$3
5758
- })]);
5759
- var mapping = union([fixedInput, object({
5760
- kind: literal("sources"),
5761
- sources: array(source)
5762
- })]);
5763
- var inputs = record$3(text, mapping);
5764
- var ports$1 = {
5765
- inputs: array(union([input, group])),
5766
- outputs: array(union([port$1, group]))
5767
- };
5768
- var capability = union([
5769
- strictObject({
5770
- kind: literal("connector"),
5771
- action: text,
5772
- connectionId: text.optional(),
5773
- connections: array(strictObject({
5774
- connectionId: text,
5775
- alias: text.optional()
5776
- }))
5777
- }),
5778
- strictObject({
5779
- kind: literal("connector"),
5780
- mode: literal("shared")
5781
- }),
5782
- strictObject({
5783
- kind: literal("connector"),
5784
- mode: literal("independent"),
5785
- actions: array(strictObject({
5786
- action: text,
5787
- connectionId: text.optional()
5788
- }))
5789
- }),
5790
- strictObject({
5791
- kind: literal("connector"),
5792
- actionHints: array(text).optional(),
5793
- connectionHints: array(strictObject({
5794
- action: text,
5795
- connectionId: text,
5796
- alias: text.optional()
5797
- })).optional()
5798
- })
5702
+ function webhookSupportsBody(method) {
5703
+ return method !== "GET";
5704
+ }
5705
+ //#endregion
5706
+ //#region src/openapi/common/authBindings.ts
5707
+ /** Never allow credentials to enter a Revision as literal node inputs. */
5708
+ function assertOpenApiAuthBindings(document) {
5709
+ for (const node of Object.values(document.graph.nodes)) {
5710
+ if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
5711
+ for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
5712
+ }
5713
+ }
5714
+ //#endregion
5715
+ //#region src/flow/common/change.ts
5716
+ var schemaKeywords = /* @__PURE__ */ new Set([
5717
+ "const",
5718
+ "enum",
5719
+ "exclusiveMaximum",
5720
+ "exclusiveMinimum",
5721
+ "maximum",
5722
+ "maxItems",
5723
+ "maxLength",
5724
+ "maxProperties",
5725
+ "minimum",
5726
+ "minItems",
5727
+ "minLength",
5728
+ "minProperties",
5729
+ "multipleOf",
5730
+ "pattern",
5731
+ "required",
5732
+ "type"
5799
5733
  ]);
5800
- var inline = object({
5801
- ...ports$1,
5802
- name: text,
5803
- moduleId: text,
5804
- capabilities: array(capability).optional()
5734
+ function isSchemaKeyword(value) {
5735
+ return schemaKeywords.has(value);
5736
+ }
5737
+ //#endregion
5738
+ //#region src/json-schema-subset/utils.ts
5739
+ var nextId = 0;
5740
+ function createId() {
5741
+ const id = nextId;
5742
+ nextId += 1;
5743
+ return id;
5744
+ }
5745
+ function deepFreeze(target) {
5746
+ if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
5747
+ for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
5748
+ Object.freeze(target);
5749
+ }
5750
+ return target;
5751
+ }
5752
+ function pick(target, keys) {
5753
+ const newTarget = {};
5754
+ for (const key of keys) if (key in target) newTarget[key] = target[key];
5755
+ return newTarget;
5756
+ }
5757
+ function deepCopy(value) {
5758
+ if (typeof value !== "object" || value === null) return value;
5759
+ else if (Array.isArray(value)) {
5760
+ const array = [];
5761
+ for (const [i, element] of value.entries()) array[i] = deepCopy(element);
5762
+ return array;
5763
+ } else {
5764
+ const newObject = {};
5765
+ for (const key in value) newObject[key] = deepCopy(value[key]);
5766
+ return newObject;
5767
+ }
5768
+ }
5769
+ function isDeepEquals(value1, value2) {
5770
+ if (value1 === value2) return true;
5771
+ if (value1 === null) return false;
5772
+ if (typeof value1 !== "object") return false;
5773
+ if (typeof value1 !== typeof value2) return false;
5774
+ if (Array.isArray(value1)) {
5775
+ if (!Array.isArray(value2)) return false;
5776
+ if (value1.length !== value2.length) return false;
5777
+ for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
5778
+ } else {
5779
+ if (Array.isArray(value2)) return false;
5780
+ for (const key in value1) {
5781
+ if (!(key in value2)) return false;
5782
+ if (!isDeepEquals(value1[key], value2[key])) return false;
5783
+ }
5784
+ for (const key in value2) if (!(key in value1)) return false;
5785
+ }
5786
+ return true;
5787
+ }
5788
+ //#endregion
5789
+ //#region src/json-schema-subset/expression/result.ts
5790
+ var ExpressionSingleResult = Object.freeze({
5791
+ Equals: 0,
5792
+ Containing: 1,
5793
+ ContainedBy: 2,
5794
+ Rejection: 3,
5795
+ Intersection: 4
5805
5796
  });
5806
- var agentValue = union([object({
5807
- kind: literal("value"),
5808
- value: json$3
5809
- }), object({
5810
- kind: literal("input"),
5811
- input: text
5812
- })]);
5813
- var agentInput = union([agentValue, object({ kind: literal("model") })]);
5814
- var decisionQuestion = discriminatedUnion("type", [
5815
- strictObject({
5816
- name: text,
5817
- instructions: text,
5818
- type: literal("noul"),
5819
- criteria: strictObject({
5820
- true: text.optional(),
5821
- false: text.optional()
5822
- }).optional()
5823
- }),
5824
- strictObject({
5825
- name: text,
5826
- instructions: text,
5827
- type: literal("choice"),
5828
- criteria: array(strictObject({
5829
- name: text,
5830
- description: text
5831
- }))
5832
- }),
5833
- strictObject({
5834
- name: text,
5835
- instructions: text,
5836
- type: literal("score"),
5837
- criteria: strings$1
5838
- })
5839
- ]);
5840
- var managedFields = object({
5841
- ...ports$1,
5842
- name: text,
5843
- executor: union([
5844
- object({
5845
- kind: literal("connector"),
5846
- action: text,
5847
- connectionId: text.optional()
5848
- }),
5849
- object({
5850
- kind: literal("openapi"),
5851
- sourceUrl: text,
5852
- method: text,
5853
- path: text,
5854
- serverUrl: text,
5855
- document: json$3,
5856
- auth: array(object({
5857
- id: text,
5858
- type: _enum([
5859
- "bearer",
5860
- "basic",
5861
- "apiKey"
5862
- ]),
5863
- name: text.optional(),
5864
- in: _enum(["header", "query"]).optional()
5865
- }))
5866
- }),
5867
- strictObject({
5868
- kind: literal("decision"),
5869
- questions: array(decisionQuestion)
5870
- }),
5871
- object({
5872
- kind: literal("llm"),
5873
- mode: _enum(["chat", "json"])
5874
- }),
5875
- object({
5876
- kind: literal("agent"),
5877
- code: boolean().optional(),
5878
- model: text,
5879
- prompt: text,
5880
- maxRounds: number(),
5881
- tools: array(object({
5882
- id: text,
5883
- name: text,
5884
- description: text,
5885
- action: text,
5886
- connectionId: text.optional(),
5887
- approval: boolean(),
5888
- inputs: array(input.extend({ source: agentInput }))
5889
- })),
5890
- notification: object({
5891
- action: text,
5892
- connectionId: text.optional(),
5893
- inputDefinitions: array(input),
5894
- messageHandle: text,
5895
- inputs: record$3(text, agentValue)
5896
- }).optional()
5897
- })
5898
- ])
5899
- });
5900
- var managed = managedFields.transform(limitDecisionTask);
5901
- var operand$1 = union([object({
5902
- kind: literal("value"),
5903
- value: json$3.optional(),
5904
- jsonSchema: json$3.optional()
5905
- }), object({
5906
- kind: literal("source"),
5907
- source
5908
- })]);
5909
- var condition = {
5910
- matchMode: _enum(["first", "all"]),
5911
- cases: array(object({
5912
- description: text.optional(),
5913
- output: text,
5914
- groups: array(object({ expressions: array(object({
5915
- left: operand$1,
5916
- operator: _enum([
5917
- "!=",
5918
- "<",
5919
- "<=",
5920
- "==",
5921
- ">",
5922
- ">=",
5923
- "contains",
5924
- "endsWith",
5925
- "hasKey",
5926
- "hasValue",
5927
- "isEmpty",
5928
- "isFalse",
5929
- "isNotEmpty",
5930
- "isNotNull",
5931
- "isNull",
5932
- "isTrue",
5933
- "notContains",
5934
- "notHasKey",
5935
- "notHasValue",
5936
- "startsWith"
5937
- ]),
5938
- right: operand$1.optional()
5939
- })) }))
5940
- }))
5941
- };
5942
- var wait = {
5943
- inputDefinitions: array(input),
5944
- prompt: text
5945
- };
5946
- var webhookOptions = object({
5947
- allowedMethods: never().optional(),
5948
- allowedOrigins: strings$1.optional(),
5949
- noResponseBody: never().optional(),
5950
- responseData: text.optional(),
5951
- responseHeaders: record$3(text, text).optional(),
5952
- responseStatusCode: number().int().min(200).max(599).optional()
5953
- });
5954
- var webhook = {
5955
- bodyFields: array(input),
5956
- method: _enum(webhookMethods),
5957
- options: webhookOptions.optional()
5958
- };
5959
- var definition = {
5960
- configInputs: ports$1.inputs,
5961
- definitionVersion: literal(2),
5962
- description: text,
5963
- displayName: text,
5964
- key: text,
5965
- name: text,
5966
- outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
5967
- provider: text
5968
- };
5969
- var endpoint = object({
5970
- body: object({
5971
- allowArray: boolean(),
5972
- allowEmpty: boolean(),
5973
- formats: array(_enum([
5974
- "form",
5975
- "json",
5976
- "multipart",
5977
- "text"
5978
- ]))
5979
- }),
5980
- methods: array(_enum([
5981
- "DELETE",
5982
- "GET",
5983
- "HEAD",
5984
- "PATCH",
5985
- "POST",
5986
- "PUT"
5987
- ])),
5988
- successStatus: number()
5989
- });
5990
- var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
5991
- var trigger = {
5992
- name: text,
5993
- description: text.optional(),
5994
- icon: text.optional()
5995
- };
5996
- var base = {
5997
- maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
5998
- inputs,
5999
- name: text.optional(),
6000
- description: text.optional(),
6001
- icon: text.optional(),
6002
- timeoutMs: number().optional()
6003
- };
6004
- var node = union([
6005
- object({
6006
- ...base,
6007
- inputs: record$3(text, never()),
6008
- kind: literal("condition"),
6009
- ...condition
6010
- }),
6011
- object({
6012
- ...base,
6013
- inputs: unknown().transform(() => ({})).default({}),
6014
- kind: literal("value"),
6015
- values: array(input)
6016
- }),
6017
- object({
6018
- ...base,
6019
- kind: literal("task"),
6020
- task: union([inline, managed]),
6021
- additionalInputs: array(input).optional()
6022
- }),
6023
- strictObject({
6024
- ...base,
6025
- kind: literal("approval"),
6026
- ...wait
6027
- }).omit({ timeoutMs: true }),
6028
- strictObject({
6029
- ...base,
6030
- kind: literal("wait"),
6031
- ...wait
6032
- }).omit({ timeoutMs: true }),
6033
- object({
6034
- ...trigger,
6035
- kind: literal("manual")
6036
- }),
6037
- strictObject({
6038
- ...trigger,
6039
- kind: literal("error"),
6040
- sourceFlowIds: sourceFlowIds.optional()
6041
- }),
6042
- object({
6043
- ...trigger,
6044
- kind: literal("webhook"),
6045
- ...webhook
6046
- }),
6047
- object({
6048
- ...trigger,
6049
- kind: literal("cron"),
6050
- cronTimes: triggerScheduleSchema
6051
- }),
6052
- object({
6053
- ...trigger,
6054
- kind: literal("poll"),
6055
- connectionId: text.min(1).optional(),
6056
- config: record$3(text, fixedInput),
6057
- definition: object({
6058
- ...definition,
6059
- type: literal("poll")
6060
- }),
6061
- pollTimes: triggerScheduleSchema
6062
- }),
6063
- object({
6064
- ...trigger,
6065
- kind: literal("integration"),
6066
- connectionId: text.min(1).optional(),
6067
- config: record$3(text, fixedInput),
6068
- definition: object({
6069
- ...definition,
6070
- type: literal("integration"),
6071
- endpoint
6072
- })
6073
- })
6074
- ]);
6075
- /** Configuration schemas shared by the node authoring boundary. */
6076
- var authoringDefinitionSchemas = {
6077
- input,
6078
- port: port$1,
6079
- ports: ports$1,
6080
- condition: strictObject(condition),
6081
- wait: strictObject(wait),
6082
- webhook: strictObject(webhook),
6083
- schedule: triggerScheduleSchema,
6084
- capabilities: array(capability),
6085
- connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
6086
- openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
6087
- decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
6088
- llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
6089
- agent: managedFields.shape.executor.options[4].omit({
6090
- kind: true,
6091
- notification: true
6092
- }).strict()
6093
- };
6094
- var edge = object({
6095
- source: text,
6096
- target: text,
6097
- sourceHandle: text.optional()
6098
- });
6099
- var at = {
6100
- nodeId: text,
6101
- target: never().optional()
6102
- };
6103
- var graph = object({
6104
- nodes: record$3(text, node),
6105
- edges: array(edge).default([])
6106
- });
6107
- var binding = object({
6108
- kind: literal("variable"),
6109
- target: text
6110
- });
6111
- var module = object({
6112
- name: text,
6113
- imports: strings$1,
6114
- source: text
6115
- });
6116
- var document = preprocess(rejectRetiredDefinitions, object({
6117
- bindings: record$3(text, binding),
6118
- graph
6119
- }));
6120
- var revision = object({
6121
- modelVersion: union([
6122
- literal(2),
6123
- literal(4),
6124
- literal(5),
6125
- literal(6)
6126
- ]),
6127
- document,
6128
- modules: record$3(text, module)
6129
- });
6130
- revision.extend({
6131
- kind: literal("open-flow-flow-revision"),
6132
- version: literal(1)
6133
- });
6134
- function rejectRetiredDefinitions(value) {
6135
- const candidate = record$2(value);
6136
- if (candidate.tasks !== void 0 && (candidate.tasks === null || typeof candidate.tasks !== "object" || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)) throw new TypeError("Independent Task definitions are no longer supported.");
6137
- if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
6138
- const subflows = candidate.subflows;
6139
- if (subflows !== void 0 && (subflows === null || typeof subflows !== "object" || Array.isArray(subflows) || Object.keys(subflows).length > 0)) throw new TypeError("Subflows are no longer supported.");
6140
- if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
6141
- return value;
6142
- }
6143
- function record$2(value) {
6144
- return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
6145
- }
6146
- function decodeRevisionContent(value) {
6147
- checkJsonDepth(value);
6148
- const content = revision.parse(value);
6149
- checkModelVersion(content);
6150
- assertOpenApiAuthBindings(content.document);
6151
- return content;
6152
- }
6153
- var shapes = {
6154
- "graph.trigger.sources.set": {
6155
- nodeId: text,
6156
- before: sourceFlowIds.optional(),
6157
- value: sourceFlowIds.optional()
6158
- },
6159
- "binding.create": {
6160
- bindingId: text,
6161
- binding
6162
- },
6163
- "binding.delete": { bindingId: text },
6164
- "binding.target.set": {
6165
- bindingId: text,
6166
- before: text,
6167
- value: text
6168
- },
6169
- "graph.edge.connect": {
6170
- edge,
6171
- target: never().optional()
6172
- },
6173
- "graph.edge.disconnect": {
6174
- edge,
6175
- target: never().optional()
6176
- },
6177
- "graph.node.create": {
6178
- ...at,
6179
- node
6180
- },
6181
- "graph.node.replace": {
6182
- ...at,
6183
- before: node,
6184
- node
6185
- },
6186
- "graph.node.delete": at,
6187
- "graph.node.field.set": union([
6188
- object({
6189
- ...at,
6190
- kind: literal("graph.node.field.set"),
6191
- field: literal("connectionId"),
6192
- before: text.min(1).optional(),
6193
- value: text.min(1).optional()
6194
- }),
6195
- object({
6196
- ...at,
6197
- kind: literal("graph.node.field.set"),
6198
- field: _enum([
6199
- "description",
6200
- "icon",
6201
- "name"
6202
- ]),
6203
- before: text.optional(),
6204
- value: text.optional()
6205
- }),
6206
- object({
6207
- ...at,
6208
- kind: literal("graph.node.field.set"),
6209
- field: literal("maxExecutions"),
6210
- before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
6211
- value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
6212
- }),
6213
- object({
6214
- ...at,
6215
- kind: literal("graph.node.field.set"),
6216
- field: literal("timeoutMs"),
6217
- before: number().optional(),
6218
- value: number().optional()
6219
- })
6220
- ]),
6221
- "graph.node.input.set": {
6222
- ...at,
6223
- handle: text,
6224
- before: mapping.optional(),
6225
- value: mapping.optional()
6226
- },
6227
- "graph.node.additional-inputs.set": {
6228
- ...at,
6229
- before: array(input).optional(),
6230
- value: array(input).optional()
6231
- },
6232
- "graph.node.condition.set": {
6233
- ...at,
6234
- before: object(condition),
6235
- value: object(condition)
6236
- },
6237
- "graph.node.values.set": {
6238
- ...at,
6239
- before: array(input),
6240
- value: array(input)
6241
- },
6242
- "graph.node.resolution.set": {
6243
- ...at,
6244
- before: object(wait),
6245
- value: object(wait)
6246
- },
6247
- "graph.node.webhook.set": {
6248
- ...at,
6249
- before: object(webhook),
6250
- value: object(webhook)
6251
- },
6252
- "graph.node.task.ports.set": {
6253
- ...at,
6254
- before: object(ports$1),
6255
- value: object(ports$1)
6256
- },
6257
- "graph.node.task.name.set": {
6258
- ...at,
6259
- before: text,
6260
- value: text
6261
- },
6262
- "graph.node.task.capabilities.set": {
6263
- ...at,
6264
- before: array(capability).optional(),
6265
- value: array(capability).optional()
6266
- },
6267
- "graph.trigger.config.set": {
6268
- nodeId: text,
6269
- name: text,
6270
- before: fixedInput.optional(),
6271
- value: fixedInput.optional()
6272
- },
6273
- "graph.trigger.schedule.set": {
6274
- nodeId: text,
6275
- before: triggerScheduleSchema,
6276
- value: triggerScheduleSchema
6277
- },
6278
- "module.create": {
6279
- moduleId: text,
6280
- module
6281
- },
6282
- "module.delete": { moduleId: text },
6283
- "module.rename": {
6284
- moduleId: text,
6285
- before: text,
6286
- name: text
6287
- },
6288
- "module.source.replace": {
6289
- moduleId: text,
6290
- beforeImports: strings$1,
6291
- beforeSource: text,
6292
- imports: strings$1,
6293
- source: text
6294
- },
6295
- "graph.node.task.set": {
6296
- ...at,
6297
- before: union([inline, managed]),
6298
- value: union([inline, managed])
6299
- }
6300
- };
6301
- array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
6302
- kind: literal(kind),
6303
- ...shape
6304
- })])).values()])).min(1);
6305
- function checkModelVersion(content) {
6306
- if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
6307
- if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
6308
- }
6309
- //#endregion
6310
- //#region src/flow/common/change.ts
6311
- var schemaKeywords = /* @__PURE__ */ new Set([
6312
- "const",
6313
- "enum",
6314
- "exclusiveMaximum",
6315
- "exclusiveMinimum",
6316
- "maximum",
6317
- "maxItems",
6318
- "maxLength",
6319
- "maxProperties",
6320
- "minimum",
6321
- "minItems",
6322
- "minLength",
6323
- "minProperties",
6324
- "multipleOf",
6325
- "pattern",
6326
- "required",
6327
- "type"
6328
- ]);
6329
- function isSchemaKeyword(value) {
6330
- return schemaKeywords.has(value);
6331
- }
6332
- //#endregion
6333
- //#region src/json-schema-subset/utils.ts
6334
- var nextId = 0;
6335
- function createId() {
6336
- const id = nextId;
6337
- nextId += 1;
6338
- return id;
6339
- }
6340
- function deepFreeze(target) {
6341
- if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
6342
- for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
6343
- Object.freeze(target);
6344
- }
6345
- return target;
6346
- }
6347
- function pick(target, keys) {
6348
- const newTarget = {};
6349
- for (const key of keys) if (key in target) newTarget[key] = target[key];
6350
- return newTarget;
6351
- }
6352
- function deepCopy(value) {
6353
- if (typeof value !== "object" || value === null) return value;
6354
- else if (Array.isArray(value)) {
6355
- const array = [];
6356
- for (const [i, element] of value.entries()) array[i] = deepCopy(element);
6357
- return array;
6358
- } else {
6359
- const newObject = {};
6360
- for (const key in value) newObject[key] = deepCopy(value[key]);
6361
- return newObject;
6362
- }
6363
- }
6364
- function isDeepEquals(value1, value2) {
6365
- if (value1 === value2) return true;
6366
- if (value1 === null) return false;
6367
- if (typeof value1 !== "object") return false;
6368
- if (typeof value1 !== typeof value2) return false;
6369
- if (Array.isArray(value1)) {
6370
- if (!Array.isArray(value2)) return false;
6371
- if (value1.length !== value2.length) return false;
6372
- for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
6373
- } else {
6374
- if (Array.isArray(value2)) return false;
6375
- for (const key in value1) {
6376
- if (!(key in value2)) return false;
6377
- if (!isDeepEquals(value1[key], value2[key])) return false;
6378
- }
6379
- for (const key in value2) if (!(key in value1)) return false;
6380
- }
6381
- return true;
6382
- }
6383
- //#endregion
6384
- //#region src/json-schema-subset/expression/result.ts
6385
- var ExpressionSingleResult = Object.freeze({
6386
- Equals: 0,
6387
- Containing: 1,
6388
- ContainedBy: 2,
6389
- Rejection: 3,
6390
- Intersection: 4
6391
- });
6392
- var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
6393
- var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
6394
- var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
6395
- var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
6396
- var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
6397
- var ExpressionMaskList = deepFreeze([
6398
- [ExpressionSingleResult.Equals, ExpressionEquals],
6399
- [ExpressionSingleResult.Containing, ExpressionContaining],
6400
- [ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
6401
- [ExpressionSingleResult.Rejection, ExpressionRejection],
6402
- [ExpressionSingleResult.Intersection, ExpressionIntersection]
5797
+ var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
5798
+ var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
5799
+ var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
5800
+ var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
5801
+ var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
5802
+ var ExpressionMaskList = deepFreeze([
5803
+ [ExpressionSingleResult.Equals, ExpressionEquals],
5804
+ [ExpressionSingleResult.Containing, ExpressionContaining],
5805
+ [ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
5806
+ [ExpressionSingleResult.Rejection, ExpressionRejection],
5807
+ [ExpressionSingleResult.Intersection, ExpressionIntersection]
6403
5808
  ]);
6404
5809
  var ExpressionAny = (() => {
6405
5810
  let expression = 0;
@@ -7933,1247 +7338,1845 @@ function splitRangeGreaterBranch(range1, range2) {
7933
7338
  fromLeft: true,
7934
7339
  range: range1
7935
7340
  }
7936
- };
7341
+ };
7342
+ }
7343
+ if (max2.num <= max1.num) {
7344
+ let hasRight = true;
7345
+ let isRightRangeOverride = false;
7346
+ if (max1.num === max2.num) {
7347
+ const exclusive1 = max2.exclusive;
7348
+ const exclusive2 = max1.exclusive;
7349
+ hasRight = exclusive1 !== exclusive2;
7350
+ isRightRangeOverride = !exclusive1 && exclusive2;
7351
+ }
7352
+ if (!isRightRangeOverride) {
7353
+ let right;
7354
+ if (hasRight) right = {
7355
+ fromLeft: true,
7356
+ range: [reversalExclusive(max2), max1]
7357
+ };
7358
+ return {
7359
+ left: {
7360
+ fromLeft: false,
7361
+ range: [min2, reversalExclusive(min1)]
7362
+ },
7363
+ center: [min1, max2],
7364
+ right
7365
+ };
7366
+ }
7367
+ }
7368
+ return {
7369
+ left: {
7370
+ fromLeft: false,
7371
+ range: [min2, reversalExclusive(min1)]
7372
+ },
7373
+ center: [min1, max1],
7374
+ right: {
7375
+ fromLeft: false,
7376
+ range: [reversalExclusive(max1), max2]
7377
+ }
7378
+ };
7379
+ }
7380
+ function splitRangeEqualsBranch(range1, range2) {
7381
+ const [min1, max1] = range1;
7382
+ const [min2, max2] = range2;
7383
+ const exclusive1 = min1.exclusive;
7384
+ const exclusive2 = min2.exclusive;
7385
+ let left;
7386
+ let centerBegin = min1;
7387
+ if (!exclusive1 && exclusive2) {
7388
+ centerBegin = min2;
7389
+ left = {
7390
+ fromLeft: true,
7391
+ range: [min1, reversalExclusive(min2)]
7392
+ };
7393
+ } else if (exclusive1 && !exclusive2) left = {
7394
+ fromLeft: false,
7395
+ range: [min2, reversalExclusive(min1)]
7396
+ };
7397
+ if (max1.num <= max2.num) {
7398
+ let hasRight = true;
7399
+ let isLeftRangeOverride = false;
7400
+ if (max1.num === max2.num) {
7401
+ const maxExclusive1 = max1.exclusive;
7402
+ const maxExclusive2 = max2.exclusive;
7403
+ hasRight = maxExclusive1 !== maxExclusive2;
7404
+ isLeftRangeOverride = !maxExclusive1 && maxExclusive2;
7405
+ }
7406
+ if (!isLeftRangeOverride) {
7407
+ let right;
7408
+ if (hasRight) right = {
7409
+ fromLeft: false,
7410
+ range: [reversalExclusive(max1), max2]
7411
+ };
7412
+ return {
7413
+ left,
7414
+ center: [centerBegin, max1],
7415
+ right
7416
+ };
7417
+ }
7418
+ }
7419
+ return {
7420
+ left,
7421
+ center: [centerBegin, max2],
7422
+ right: {
7423
+ fromLeft: true,
7424
+ range: [reversalExclusive(max2), max1]
7425
+ }
7426
+ };
7427
+ }
7428
+ function reversalExclusive(point) {
7429
+ return {
7430
+ num: point.num,
7431
+ exclusive: !point.exclusive
7432
+ };
7433
+ }
7434
+ //#endregion
7435
+ //#region src/json-schema-subset/checker/range.ts
7436
+ var createRangeSplitter = (undefinedMin) => (min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
7437
+ const { left, center, right } = splitRange$3([{
7438
+ num: min1,
7439
+ exclusive: false
7440
+ }, {
7441
+ num: max1,
7442
+ exclusive: false
7443
+ }], [{
7444
+ num: min2,
7445
+ exclusive: false
7446
+ }, {
7447
+ num: max2,
7448
+ exclusive: false
7449
+ }]);
7450
+ let leftItem;
7451
+ let rightItem;
7452
+ let intersectionItem;
7453
+ if (left) leftItem = {
7454
+ min: left.range[0].num,
7455
+ max: left.range[1].num,
7456
+ isFrom1: left.fromLeft
7457
+ };
7458
+ if (right) rightItem = {
7459
+ min: right.range[0].num,
7460
+ max: right.range[1].num,
7461
+ isFrom1: right.fromLeft
7462
+ };
7463
+ if (center) intersectionItem = {
7464
+ min: center[0].num,
7465
+ max: center[1].num
7466
+ };
7467
+ return {
7468
+ left: leftItem,
7469
+ right: rightItem,
7470
+ intersection: intersectionItem
7471
+ };
7472
+ };
7473
+ function toExpressionSingleResult({ left, right, intersection }) {
7474
+ if (!intersection) return ExpressionSingleResult.Rejection;
7475
+ let extra1 = false;
7476
+ let extra2 = false;
7477
+ if (left) {
7478
+ if (left.isFrom1) extra1 = true;
7479
+ else extra2 = true;
7480
+ }
7481
+ if (right) {
7482
+ if (right.isFrom1) extra1 = true;
7483
+ else extra2 = true;
7484
+ }
7485
+ if (extra1 && extra2) return ExpressionSingleResult.Intersection;
7486
+ if (extra1) return ExpressionSingleResult.Containing;
7487
+ if (extra2) return ExpressionSingleResult.ContainedBy;
7488
+ return ExpressionSingleResult.Equals;
7489
+ }
7490
+ //#endregion
7491
+ //#region src/json-schema-subset/checker/array.ts
7492
+ var splitRange$2 = createRangeSplitter(0);
7493
+ var quantum$1 = makeQuantum([
7494
+ "hasCommon",
7495
+ "hasExtra1",
7496
+ "hasExtra2",
7497
+ "hasRejection",
7498
+ "hasCommonBroken"
7499
+ ]);
7500
+ function calculateArray({ calculate }, schema1, schema2) {
7501
+ const splitResult = splitRange$2(schema1.minItems, schema1.maxItems, schema2.minItems, schema2.maxItems);
7502
+ const splitExpression = toExpressionSingleResult(splitResult);
7503
+ if (splitExpression === ExpressionSingleResult.Rejection) return ExpressionRejection;
7504
+ const [items1, additionalItems1] = normalizeArray(schema1);
7505
+ const [items2, additionalItems2] = normalizeArray(schema2);
7506
+ const itemsLength = Math.max(items1.length, items2.length) + 1;
7507
+ const length = Math.min(itemsLength, splitResult.intersection.max);
7508
+ const quantumVariable = quantum$1.variable({});
7509
+ const minItems = Math.min(schema1.minItems ?? 0, schema2.minItems ?? 0);
7510
+ for (let i = 0; i < length; i++) {
7511
+ const expression = calculate(items1[i] ?? additionalItems1, items2[i] ?? additionalItems2);
7512
+ quantumVariable.push(expression, (singleExpression, variable) => {
7513
+ switch (singleExpression) {
7514
+ case ExpressionSingleResult.Equals:
7515
+ if (!variable.hasRejection) variable.hasCommon = true;
7516
+ break;
7517
+ case ExpressionSingleResult.Containing:
7518
+ if (!variable.hasRejection) variable.hasCommon = true;
7519
+ variable.hasExtra1 = true;
7520
+ break;
7521
+ case ExpressionSingleResult.ContainedBy:
7522
+ if (!variable.hasRejection) variable.hasCommon = true;
7523
+ variable.hasExtra2 = true;
7524
+ break;
7525
+ case ExpressionSingleResult.Intersection:
7526
+ if (!variable.hasRejection) variable.hasCommon = true;
7527
+ variable.hasExtra1 = true;
7528
+ variable.hasExtra2 = true;
7529
+ break;
7530
+ case ExpressionSingleResult.Rejection:
7531
+ if (i < minItems) variable.hasCommonBroken = true;
7532
+ variable.hasRejection = true;
7533
+ variable.hasExtra1 = true;
7534
+ variable.hasExtra2 = true;
7535
+ }
7536
+ });
7937
7537
  }
7938
- if (max2.num <= max1.num) {
7939
- let hasRight = true;
7940
- let isRightRangeOverride = false;
7941
- if (max1.num === max2.num) {
7942
- const exclusive1 = max2.exclusive;
7943
- const exclusive2 = max1.exclusive;
7944
- hasRight = exclusive1 !== exclusive2;
7945
- isRightRangeOverride = !exclusive1 && exclusive2;
7538
+ quantumVariable.update((variable) => {
7539
+ switch (splitExpression) {
7540
+ case ExpressionSingleResult.Containing:
7541
+ variable.hasExtra1 = true;
7542
+ break;
7543
+ case ExpressionSingleResult.ContainedBy:
7544
+ variable.hasExtra2 = true;
7545
+ break;
7546
+ case ExpressionSingleResult.Intersection:
7547
+ variable.hasExtra1 = true;
7548
+ variable.hasExtra2 = true;
7946
7549
  }
7947
- if (!isRightRangeOverride) {
7948
- let right;
7949
- if (hasRight) right = {
7950
- fromLeft: true,
7951
- range: [reversalExclusive(max2), max1]
7952
- };
7953
- return {
7954
- left: {
7955
- fromLeft: false,
7956
- range: [min2, reversalExclusive(min1)]
7957
- },
7958
- center: [min1, max2],
7959
- right
7960
- };
7550
+ if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
7551
+ else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
7552
+ if (schema1.maxItems === 0 || schema2.maxItems === 0) {
7553
+ variable.hasCommon = true;
7554
+ if (schema1.maxItems !== 0) variable.hasExtra1 = true;
7555
+ if (schema2.maxItems !== 0) variable.hasExtra2 = true;
7961
7556
  }
7557
+ });
7558
+ let expression = 0;
7559
+ for (const { hasExtra1, hasExtra2, hasCommon, hasCommonBroken } of quantumVariable) {
7560
+ let finalHasCommon = hasCommon;
7561
+ if (hasCommonBroken) finalHasCommon = false;
7562
+ if (!finalHasCommon) expression |= ExpressionRejection;
7563
+ else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
7564
+ else if (hasExtra1) expression |= ExpressionContaining;
7565
+ else if (hasExtra2) expression |= ExpressionContainedBy;
7566
+ else expression |= ExpressionEquals;
7962
7567
  }
7963
- return {
7964
- left: {
7965
- fromLeft: false,
7966
- range: [min2, reversalExclusive(min1)]
7967
- },
7968
- center: [min1, max1],
7969
- right: {
7970
- fromLeft: false,
7971
- range: [reversalExclusive(max1), max2]
7972
- }
7973
- };
7568
+ return expression;
7974
7569
  }
7975
- function splitRangeEqualsBranch(range1, range2) {
7976
- const [min1, max1] = range1;
7977
- const [min2, max2] = range2;
7978
- const exclusive1 = min1.exclusive;
7979
- const exclusive2 = min2.exclusive;
7980
- let left;
7981
- let centerBegin = min1;
7982
- if (!exclusive1 && exclusive2) {
7983
- centerBegin = min2;
7984
- left = {
7985
- fromLeft: true,
7986
- range: [min1, reversalExclusive(min2)]
7987
- };
7988
- } else if (exclusive1 && !exclusive2) left = {
7989
- fromLeft: false,
7990
- range: [min2, reversalExclusive(min1)]
7570
+ function normalizeArray({ items, additionalItems }) {
7571
+ if (Array.isArray(items)) return [items, additionalItems ?? ANY];
7572
+ else return [[], items ?? ANY];
7573
+ }
7574
+ //#endregion
7575
+ //#region src/json-schema-subset/checker/cache.ts
7576
+ function wrapEqualsCheckerWithCache(check) {
7577
+ const map = /* @__PURE__ */ new Map();
7578
+ return (value1, value2) => {
7579
+ const isObject1 = isCompiledObject(value1);
7580
+ if (isObject1 !== isCompiledObject(value2)) return false;
7581
+ if (!isObject1) return value1 === value2;
7582
+ return getWithCache(map, value1, value2, check);
7991
7583
  };
7992
- if (max1.num <= max2.num) {
7993
- let hasRight = true;
7994
- let isLeftRangeOverride = false;
7995
- if (max1.num === max2.num) {
7996
- const maxExclusive1 = max1.exclusive;
7997
- const maxExclusive2 = max2.exclusive;
7998
- hasRight = maxExclusive1 !== maxExclusive2;
7999
- isLeftRangeOverride = !maxExclusive1 && maxExclusive2;
7584
+ }
7585
+ function wrapSchemaCalculatorWithCache(check) {
7586
+ const map = /* @__PURE__ */ new Map();
7587
+ return (schema1, schema2) => getWithCache(map, schema1, schema2, check);
7588
+ }
7589
+ function getWithCache(map, node1, node2, check) {
7590
+ const key = `${getId(node1)}/${getId(node2)}`;
7591
+ let result = map.get(key);
7592
+ if (result === void 0) map.set(key, result = check(node1, node2));
7593
+ return result;
7594
+ }
7595
+ //#endregion
7596
+ //#region src/json-schema-subset/checker/enumAndConst.ts
7597
+ function calculateEnumAndEnum(context, schema1, schema2) {
7598
+ const enumList1 = normalizeEnumList(schema1);
7599
+ const enumList2 = normalizeEnumList(schema2);
7600
+ let foundExtra1 = false;
7601
+ let foundExtra2 = false;
7602
+ let foundIntersection = false;
7603
+ for (const enum1 of enumList1) {
7604
+ if (hasEqualsEnum(context, enumList2, enum1)) foundIntersection = true;
7605
+ else foundExtra1 = true;
7606
+ if (foundExtra1 && foundIntersection) break;
7607
+ }
7608
+ for (const enum2 of enumList2) {
7609
+ if (hasEqualsEnum(context, enumList1, enum2)) foundIntersection = true;
7610
+ else foundExtra2 = true;
7611
+ if (foundExtra2 && foundIntersection) break;
7612
+ }
7613
+ if (!foundIntersection) return ExpressionRejection;
7614
+ if (foundExtra1 && foundExtra2) return ExpressionIntersection;
7615
+ if (foundExtra1) return ExpressionContaining;
7616
+ if (foundExtra2) return ExpressionContainedBy;
7617
+ return ExpressionEquals;
7618
+ }
7619
+ function calculateEnumAndSchema(enumSchema, schema) {
7620
+ let hasValid = false;
7621
+ let hasInvalid = false;
7622
+ for (const enumValue of normalizeEnumList(enumSchema)) {
7623
+ switch (valid(schema, enumValue)) {
7624
+ case ValidResult.Valid:
7625
+ hasValid = true;
7626
+ break;
7627
+ case ValidResult.Invalid:
7628
+ hasInvalid = true;
7629
+ break;
7630
+ case ValidResult.Unknown: return ExpressionAny;
8000
7631
  }
8001
- if (!isLeftRangeOverride) {
8002
- let right;
8003
- if (hasRight) right = {
8004
- fromLeft: false,
8005
- range: [reversalExclusive(max1), max2]
8006
- };
8007
- return {
8008
- left,
8009
- center: [centerBegin, max1],
8010
- right
8011
- };
7632
+ if (hasValid && hasInvalid) break;
7633
+ }
7634
+ if (hasValid && hasInvalid) return ExpressionIntersection;
7635
+ if (hasValid) return ExpressionEquals | ExpressionContainedBy;
7636
+ if (hasInvalid) return ExpressionRejection;
7637
+ if (getKind(schema) === CompiledKind.Never) return ExpressionEquals;
7638
+ return ExpressionContainedBy;
7639
+ }
7640
+ function normalizeEnumList({ const: constValue, enum: enumList }) {
7641
+ if (constValue !== void 0) return [constValue];
7642
+ if (enumList) return enumList;
7643
+ throw new Error("invalid branch");
7644
+ }
7645
+ function hasEqualsEnum({ isEquals }, enumList, checkedEnum) {
7646
+ for (const searchedEnum of enumList) if (isEquals(searchedEnum, checkedEnum)) return true;
7647
+ return false;
7648
+ }
7649
+ //#endregion
7650
+ //#region src/json-schema-subset/checker/equals.ts
7651
+ function schemaEqualsChecker(extendsContext) {
7652
+ function isSchemaEquals(schema1, schema2) {
7653
+ const isExtends1 = extendsContext.isExtendsSchema(schema1);
7654
+ const isExtends2 = extendsContext.isExtendsSchema(schema2);
7655
+ if (isExtends1 || isExtends2) return extendsContext.equals(schema1, schema2);
7656
+ else return isCompiledSchemaEquals(schema1, schema2);
7657
+ }
7658
+ const equalsMap = /* @__PURE__ */ new Map();
7659
+ function isCompiledSchemaEquals(schema1, schema2) {
7660
+ const id1 = getId(schema1);
7661
+ const id2 = getId(schema2);
7662
+ if (id1 === id2) return true;
7663
+ const key = `${id1}/${id2}`;
7664
+ let isEquals = equalsMap.get(key);
7665
+ if (isEquals === void 0) {
7666
+ isEquals = isObjectLikeEquals(schema1, schema2);
7667
+ equalsMap.set(key, isEquals);
8012
7668
  }
7669
+ return isEquals;
8013
7670
  }
8014
- return {
8015
- left,
8016
- center: [centerBegin, max2],
8017
- right: {
8018
- fromLeft: true,
8019
- range: [reversalExclusive(max2), max1]
7671
+ function isObjectLikeEquals(object1, object2) {
7672
+ if (Array.isArray(object1)) {
7673
+ if (!Array.isArray(object2)) return false;
7674
+ if (object1.length !== object2.length) return false;
7675
+ for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
7676
+ } else {
7677
+ if (Array.isArray(object2)) return false;
7678
+ for (const key in object1) {
7679
+ if (!(key in object2)) return false;
7680
+ if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
7681
+ }
7682
+ for (const key in object2) if (!(key in object1)) return false;
8020
7683
  }
8021
- };
7684
+ return true;
7685
+ }
7686
+ function isValueEquals(value1, value2) {
7687
+ if (value1 === value2) return true;
7688
+ if (value1 === null) return false;
7689
+ if (typeof value1 !== "object") return false;
7690
+ if (typeof value1 !== typeof value2) return false;
7691
+ if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
7692
+ return isObjectLikeEquals(value1, value2);
7693
+ }
7694
+ return isSchemaEquals;
8022
7695
  }
8023
- function reversalExclusive(point) {
7696
+ //#endregion
7697
+ //#region src/json-schema-subset/checker/numeric/integerNormalizer.ts
7698
+ function normalizeInteger(schema) {
7699
+ const floatRange = pickRange(schema);
7700
+ const multipleOf = schema.multipleOf ?? 1;
7701
+ const range = cutRange(floatRange, multipleOf);
7702
+ if (!range) return null;
8024
7703
  return {
8025
- num: point.num,
8026
- exclusive: !point.exclusive
7704
+ multipleOf,
7705
+ range
8027
7706
  };
8028
7707
  }
8029
- //#endregion
8030
- //#region src/json-schema-subset/checker/range.ts
8031
- var createRangeSplitter = (undefinedMin) => (min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
8032
- const { left, center, right } = splitRange$3([{
8033
- num: min1,
7708
+ function isPointRange([point1, point2]) {
7709
+ if (point1.num !== point2.num) return false;
7710
+ if (point1.exclusive) return false;
7711
+ if (point2.exclusive) return false;
7712
+ return true;
7713
+ }
7714
+ function cutRange(range, multipleOf) {
7715
+ if (!range) return;
7716
+ const [originMin, originMax] = range;
7717
+ let min = nextInteger(originMin.num, multipleOf);
7718
+ let max = previousInteger(originMax.num, multipleOf);
7719
+ if (min === originMin.num && originMin.exclusive) min += multipleOf;
7720
+ if (max === originMax.num && originMax.exclusive) max -= multipleOf;
7721
+ if (min > max) return;
7722
+ if (min === max) {
7723
+ if (min === Number.POSITIVE_INFINITY) return;
7724
+ if (min === Number.NEGATIVE_INFINITY) return;
7725
+ }
7726
+ return [{
7727
+ num: min,
8034
7728
  exclusive: false
8035
7729
  }, {
8036
- num: max1,
8037
- exclusive: false
8038
- }], [{
8039
- num: min2,
7730
+ num: max,
8040
7731
  exclusive: false
8041
- }, {
8042
- num: max2,
7732
+ }];
7733
+ }
7734
+ function nextInteger(float, multipleOf) {
7735
+ return Math.ceil(float / multipleOf) * multipleOf;
7736
+ }
7737
+ function previousInteger(float, multipleOf) {
7738
+ return Math.floor(float / multipleOf) * multipleOf;
7739
+ }
7740
+ //#endregion
7741
+ //#region src/json-schema-subset/checker/numeric/float.ts
7742
+ function calculateFloat(schema1, schema2) {
7743
+ const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
7744
+ if (!center) return ExpressionRejection;
7745
+ let extraLeft = false;
7746
+ let extraRight = false;
7747
+ if (left) {
7748
+ if (left.fromLeft) extraLeft = true;
7749
+ else extraRight = true;
7750
+ }
7751
+ if (right) {
7752
+ if (right.fromLeft) extraLeft = true;
7753
+ else extraRight = true;
7754
+ }
7755
+ if (extraLeft && extraRight) return ExpressionIntersection;
7756
+ if (extraLeft) return ExpressionContaining;
7757
+ if (extraRight) return ExpressionContainedBy;
7758
+ return ExpressionEquals;
7759
+ }
7760
+ function calculateFloatAndInteger(schema1, schema2) {
7761
+ const floatRange = pickRange(schema1);
7762
+ const integer = normalizeInteger(schema2);
7763
+ if (!integer) return ExpressionContaining;
7764
+ const result = splitRange$3(floatRange, integer.range);
7765
+ const intCenter = cutRange(result.center, integer.multipleOf);
7766
+ const leftIntRange = unwrapAndCutRange(result.left, integer.multipleOf);
7767
+ const rightIntRange = unwrapAndCutRange(result.right, integer.multipleOf);
7768
+ if (!result.center) return ExpressionRejection;
7769
+ let extraFloat = false;
7770
+ let extraInteger = false;
7771
+ if (result.left?.fromLeft) extraFloat = true;
7772
+ if (result.right?.fromLeft) extraFloat = true;
7773
+ if (!intCenter || !isPointRange(result.center)) extraFloat = true;
7774
+ if (leftIntRange) extraInteger = true;
7775
+ if (rightIntRange) extraInteger = true;
7776
+ if (extraFloat && extraInteger) return ExpressionIntersection;
7777
+ if (extraFloat) return ExpressionContaining;
7778
+ if (extraInteger) return ExpressionContainedBy;
7779
+ return ExpressionEquals;
7780
+ }
7781
+ function pickRange(schema) {
7782
+ let point1;
7783
+ let point2;
7784
+ if (schema.exclusiveMinimum !== void 0) point1 = {
7785
+ num: schema.exclusiveMinimum,
7786
+ exclusive: true
7787
+ };
7788
+ else if (schema.minimum !== void 0) point1 = {
7789
+ num: schema.minimum,
8043
7790
  exclusive: false
8044
- }]);
8045
- let leftItem;
8046
- let rightItem;
8047
- let intersectionItem;
8048
- if (left) leftItem = {
8049
- min: left.range[0].num,
8050
- max: left.range[1].num,
8051
- isFrom1: left.fromLeft
8052
7791
  };
8053
- if (right) rightItem = {
8054
- min: right.range[0].num,
8055
- max: right.range[1].num,
8056
- isFrom1: right.fromLeft
7792
+ else point1 = {
7793
+ num: Number.NEGATIVE_INFINITY,
7794
+ exclusive: true
8057
7795
  };
8058
- if (center) intersectionItem = {
8059
- min: center[0].num,
8060
- max: center[1].num
7796
+ if (schema.exclusiveMaximum !== void 0) point2 = {
7797
+ num: schema.exclusiveMaximum,
7798
+ exclusive: true
8061
7799
  };
8062
- return {
8063
- left: leftItem,
8064
- right: rightItem,
8065
- intersection: intersectionItem
7800
+ else if (schema.maximum !== void 0) point2 = {
7801
+ num: schema.maximum,
7802
+ exclusive: false
8066
7803
  };
8067
- };
8068
- function toExpressionSingleResult({ left, right, intersection }) {
8069
- if (!intersection) return ExpressionSingleResult.Rejection;
8070
- let extra1 = false;
8071
- let extra2 = false;
8072
- if (left) {
8073
- if (left.isFrom1) extra1 = true;
8074
- else extra2 = true;
7804
+ else point2 = {
7805
+ num: Number.POSITIVE_INFINITY,
7806
+ exclusive: true
7807
+ };
7808
+ return [point1, point2];
7809
+ }
7810
+ function unwrapAndCutRange(side, multipleOf) {
7811
+ if (!side) return;
7812
+ if (side.fromLeft) return;
7813
+ return cutRange(side.range, multipleOf);
7814
+ }
7815
+ //#endregion
7816
+ //#region src/json-schema-subset/checker/numeric/integer.ts
7817
+ function calculateInteger(schema1, schema2) {
7818
+ const integer1 = normalizeInteger(schema1);
7819
+ const integer2 = normalizeInteger(schema2);
7820
+ if (!integer1 && !integer2) return ExpressionEquals;
7821
+ if (!integer1) return ExpressionContainedBy;
7822
+ if (!integer2) return ExpressionContaining;
7823
+ const { range: range1, multipleOf: multipleOf1 } = integer1;
7824
+ const { range: range2, multipleOf: multipleOf2 } = integer2;
7825
+ const result = splitRange$3(range1, range2);
7826
+ let centerRange;
7827
+ let lcm = 0;
7828
+ if (result.center) {
7829
+ lcm = getLCM(multipleOf1, multipleOf2);
7830
+ centerRange = cutRange(result.center, lcm);
8075
7831
  }
8076
- if (right) {
8077
- if (right.isFrom1) extra1 = true;
8078
- else extra2 = true;
7832
+ if (!centerRange) return ExpressionRejection;
7833
+ let extraLeft = false;
7834
+ let extraRight = false;
7835
+ const { left, right } = result;
7836
+ if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
7837
+ if (left.fromLeft) extraLeft = true;
7838
+ else extraRight = true;
8079
7839
  }
8080
- if (extra1 && extra2) return ExpressionSingleResult.Intersection;
8081
- if (extra1) return ExpressionSingleResult.Containing;
8082
- if (extra2) return ExpressionSingleResult.ContainedBy;
8083
- return ExpressionSingleResult.Equals;
7840
+ if (right && cutRange(right.range, right.fromLeft ? multipleOf1 : multipleOf2)) {
7841
+ if (right.fromLeft) extraLeft = true;
7842
+ else extraRight = true;
7843
+ }
7844
+ extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
7845
+ extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
7846
+ if (extraLeft && extraRight) return ExpressionIntersection;
7847
+ if (extraLeft) return ExpressionContaining;
7848
+ if (extraRight) return ExpressionContainedBy;
7849
+ return ExpressionEquals;
7850
+ }
7851
+ function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
7852
+ const result = splitRange$3(range, lcmCenterRange);
7853
+ if (cutRange(result.left?.range, multipleOf)) return true;
7854
+ if (cutRange(result.right?.range, multipleOf)) return true;
7855
+ const center = cutRange(result.center, multipleOf);
7856
+ if (!center) return false;
7857
+ const lcmCenterLength = rangeLength(lcmCenterRange);
7858
+ if (rangeLength(center) > lcmCenterLength) return true;
7859
+ if (lcmCenterLength === 1) return false;
7860
+ if (multipleOf < lcm) return true;
7861
+ return false;
7862
+ }
7863
+ /** Returns the least common multiple. */
7864
+ function getLCM(a, b) {
7865
+ return a * b / getGCD(a, b);
7866
+ }
7867
+ /** @returns The greatest common divisor. */
7868
+ function getGCD(a, b) {
7869
+ if (a === 0) return b;
7870
+ return getGCD(b % a, a);
7871
+ }
7872
+ function rangeLength(range) {
7873
+ if (!range) return 0;
7874
+ const [point1, point2] = range;
7875
+ return point2.num - point1.num + 1;
8084
7876
  }
8085
7877
  //#endregion
8086
- //#region src/json-schema-subset/checker/array.ts
8087
- var splitRange$2 = createRangeSplitter(0);
8088
- var quantum$1 = makeQuantum([
8089
- "hasCommon",
8090
- "hasExtra1",
8091
- "hasExtra2",
8092
- "hasRejection",
8093
- "hasCommonBroken"
8094
- ]);
8095
- function calculateArray({ calculate }, schema1, schema2) {
8096
- const splitResult = splitRange$2(schema1.minItems, schema1.maxItems, schema2.minItems, schema2.maxItems);
8097
- const splitExpression = toExpressionSingleResult(splitResult);
8098
- if (splitExpression === ExpressionSingleResult.Rejection) return ExpressionRejection;
8099
- const [items1, additionalItems1] = normalizeArray(schema1);
8100
- const [items2, additionalItems2] = normalizeArray(schema2);
8101
- const itemsLength = Math.max(items1.length, items2.length) + 1;
8102
- const length = Math.min(itemsLength, splitResult.intersection.max);
8103
- const quantumVariable = quantum$1.variable({});
8104
- const minItems = Math.min(schema1.minItems ?? 0, schema2.minItems ?? 0);
8105
- for (let i = 0; i < length; i++) {
8106
- const expression = calculate(items1[i] ?? additionalItems1, items2[i] ?? additionalItems2);
8107
- quantumVariable.push(expression, (singleExpression, variable) => {
8108
- switch (singleExpression) {
8109
- case ExpressionSingleResult.Equals:
8110
- if (!variable.hasRejection) variable.hasCommon = true;
8111
- break;
8112
- case ExpressionSingleResult.Containing:
8113
- if (!variable.hasRejection) variable.hasCommon = true;
8114
- variable.hasExtra1 = true;
8115
- break;
8116
- case ExpressionSingleResult.ContainedBy:
8117
- if (!variable.hasRejection) variable.hasCommon = true;
8118
- variable.hasExtra2 = true;
8119
- break;
8120
- case ExpressionSingleResult.Intersection:
8121
- if (!variable.hasRejection) variable.hasCommon = true;
8122
- variable.hasExtra1 = true;
8123
- variable.hasExtra2 = true;
8124
- break;
8125
- case ExpressionSingleResult.Rejection:
8126
- if (i < minItems) variable.hasCommonBroken = true;
8127
- variable.hasRejection = true;
8128
- variable.hasExtra1 = true;
8129
- variable.hasExtra2 = true;
8130
- }
8131
- });
7878
+ //#region src/json-schema-subset/checker/numeric/checker.ts
7879
+ function calculateNumeric(schema1, schema2) {
7880
+ if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) return ExpressionAny;
7881
+ const isFloat1 = isFloat(schema1);
7882
+ const isFloat2 = isFloat(schema2);
7883
+ if (isFloat1 && isFloat2) return calculateFloat(schema1, schema2);
7884
+ else if (isFloat1) return calculateFloatAndInteger(schema1, schema2);
7885
+ else if (isFloat2) return swap(calculateFloatAndInteger(schema2, schema1));
7886
+ else return calculateInteger(schema1, schema2);
7887
+ }
7888
+ function isUndefinedNumber(schema) {
7889
+ const { multipleOf } = schema;
7890
+ if (multipleOf === void 0) return false;
7891
+ if (!Number.isInteger(multipleOf)) return true;
7892
+ if (multipleOf < 0) return true;
7893
+ return false;
7894
+ }
7895
+ function isFloat(schema) {
7896
+ const { multipleOf } = schema;
7897
+ if (multipleOf !== void 0 && Number.isInteger(multipleOf)) return false;
7898
+ if (schema.type === "integer") return false;
7899
+ return true;
7900
+ }
7901
+ //#endregion
7902
+ //#region src/json-schema-subset/checker/object.ts
7903
+ var splitRange$1 = createRangeSplitter(0);
7904
+ var quantum = makeQuantum([
7905
+ "hasCommonInRequired",
7906
+ "hasCommonOutRequired",
7907
+ "hasExtra1",
7908
+ "hasExtra2",
7909
+ "hasRejection"
7910
+ ]);
7911
+ function calculateObject(context, schema1, schema2) {
7912
+ if (isPropertiesCountCannotMatch(schema1, schema2)) return ExpressionRejection;
7913
+ const splitRequiredResult = splitRequired(schema1, schema2);
7914
+ if (!splitRequiredResult) return ExpressionRejection;
7915
+ const getProperty1 = createPropertySchemaGetter(schema1);
7916
+ const getProperty2 = createPropertySchemaGetter(schema2);
7917
+ const calculateKey = (key) => {
7918
+ const propertySchema1 = getProperty1(key);
7919
+ const propertySchema2 = getProperty2(key);
7920
+ if (areNotBothNever(propertySchema1, propertySchema2)) return context.calculate(propertySchema1, propertySchema2);
7921
+ else return 0;
7922
+ };
7923
+ const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult;
7924
+ const quantumVariable = quantum.variable({});
7925
+ for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
7926
+ for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
7927
+ for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
7928
+ const { hasOptional1, hasOptional2 } = splitRequiredResult;
7929
+ if (hasOptional1 || hasOptional2) {
7930
+ const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
7931
+ for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
7932
+ const expression = calculateKey(optionalKey);
7933
+ if (expression !== 0) quantumVariable.push(expression, calculator);
7934
+ }
7935
+ const additionalProperties1 = schema1.additionalProperties ?? ANY;
7936
+ const additionalProperties2 = schema2.additionalProperties ?? ANY;
7937
+ if (areNotBothNever(additionalProperties1, additionalProperties2)) {
7938
+ const expression = context.calculate(additionalProperties1, additionalProperties2);
7939
+ quantumVariable.push(expression, calculator);
7940
+ }
8132
7941
  }
8133
7942
  quantumVariable.update((variable) => {
8134
- switch (splitExpression) {
8135
- case ExpressionSingleResult.Containing:
8136
- variable.hasExtra1 = true;
8137
- break;
8138
- case ExpressionSingleResult.ContainedBy:
8139
- variable.hasExtra2 = true;
8140
- break;
8141
- case ExpressionSingleResult.Intersection:
8142
- variable.hasExtra1 = true;
8143
- variable.hasExtra2 = true;
8144
- }
8145
- if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
8146
- else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
8147
- if (schema1.maxItems === 0 || schema2.maxItems === 0) {
8148
- variable.hasCommon = true;
8149
- if (schema1.maxItems !== 0) variable.hasExtra1 = true;
8150
- if (schema2.maxItems !== 0) variable.hasExtra2 = true;
7943
+ if (!variable.hasRejection) {
7944
+ if (extraRequired1.size > 0) variable.hasExtra2 = true;
7945
+ if (extraRequired2.size > 0) variable.hasExtra1 = true;
8151
7946
  }
8152
7947
  });
7948
+ const { requiredKeysCount } = splitRequiredResult;
8153
7949
  let expression = 0;
8154
- for (const { hasExtra1, hasExtra2, hasCommon, hasCommonBroken } of quantumVariable) {
8155
- let finalHasCommon = hasCommon;
8156
- if (hasCommonBroken) finalHasCommon = false;
8157
- if (!finalHasCommon) expression |= ExpressionRejection;
8158
- else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
8159
- else if (hasExtra1) expression |= ExpressionContaining;
8160
- else if (hasExtra2) expression |= ExpressionContainedBy;
8161
- else expression |= ExpressionEquals;
8162
- }
7950
+ for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
7951
+ else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
7952
+ else if (hasRejection) expression |= ExpressionRejection;
7953
+ else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
7954
+ else if (hasExtra1) expression |= ExpressionContaining;
7955
+ else if (hasExtra2) expression |= ExpressionContainedBy;
7956
+ else expression |= ExpressionEquals;
8163
7957
  return expression;
8164
7958
  }
8165
- function normalizeArray({ items, additionalItems }) {
8166
- if (Array.isArray(items)) return [items, additionalItems ?? ANY];
8167
- else return [[], items ?? ANY];
7959
+ function isPropertiesCountCannotMatch(schema1, schema2) {
7960
+ return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
8168
7961
  }
8169
- //#endregion
8170
- //#region src/json-schema-subset/checker/cache.ts
8171
- function wrapEqualsCheckerWithCache(check) {
8172
- const map = /* @__PURE__ */ new Map();
8173
- return (value1, value2) => {
8174
- const isObject1 = isCompiledObject(value1);
8175
- if (isObject1 !== isCompiledObject(value2)) return false;
8176
- if (!isObject1) return value1 === value2;
8177
- return getWithCache(map, value1, value2, check);
7962
+ function splitRequired(schema1, schema2) {
7963
+ const extraRequired1 = new Set(schema1.required);
7964
+ const extraRequired2 = new Set(schema2.required);
7965
+ const commonRequired = /* @__PURE__ */ new Set();
7966
+ const wholeRequired = /* @__PURE__ */ new Set();
7967
+ const requiredCount1 = extraRequired1.size;
7968
+ const requiredCount2 = extraRequired2.size;
7969
+ for (const key of extraRequired1) {
7970
+ if (extraRequired2.has(key)) commonRequired.add(key);
7971
+ wholeRequired.add(key);
7972
+ }
7973
+ for (const key of extraRequired2) {
7974
+ if (extraRequired1.has(key)) commonRequired.add(key);
7975
+ wholeRequired.add(key);
7976
+ }
7977
+ const requiredKeysCount = wholeRequired.size;
7978
+ for (const key of commonRequired) {
7979
+ extraRequired1.delete(key);
7980
+ extraRequired2.delete(key);
7981
+ }
7982
+ const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
7983
+ const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
7984
+ if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
7985
+ return {
7986
+ requiredKeysCount,
7987
+ extraRequired1,
7988
+ extraRequired2,
7989
+ commonRequired,
7990
+ hasOptional1: maxProperties1 > requiredCount1,
7991
+ hasOptional2: maxProperties2 > requiredCount2
8178
7992
  };
8179
7993
  }
8180
- function wrapSchemaCalculatorWithCache(check) {
8181
- const map = /* @__PURE__ */ new Map();
8182
- return (schema1, schema2) => getWithCache(map, schema1, schema2, check);
8183
- }
8184
- function getWithCache(map, node1, node2, check) {
8185
- const key = `${getId(node1)}/${getId(node2)}`;
8186
- let result = map.get(key);
8187
- if (result === void 0) map.set(key, result = check(node1, node2));
8188
- return result;
7994
+ function getOptionalKeys(schema1, schema2) {
7995
+ const optionalKeys = new Set(schema1.required);
7996
+ const properties1 = schema1.properties;
7997
+ const properties2 = schema2.properties;
7998
+ const required1 = schema1.required;
7999
+ const required2 = schema2.required;
8000
+ if (properties1) for (const key in properties1) optionalKeys.add(key);
8001
+ if (properties2) for (const key in properties2) optionalKeys.add(key);
8002
+ if (required1) for (const key of required1) optionalKeys.delete(key);
8003
+ if (required2) for (const key of required2) optionalKeys.delete(key);
8004
+ return optionalKeys;
8189
8005
  }
8190
- //#endregion
8191
- //#region src/json-schema-subset/checker/enumAndConst.ts
8192
- function calculateEnumAndEnum(context, schema1, schema2) {
8193
- const enumList1 = normalizeEnumList(schema1);
8194
- const enumList2 = normalizeEnumList(schema2);
8195
- let foundExtra1 = false;
8196
- let foundExtra2 = false;
8197
- let foundIntersection = false;
8198
- for (const enum1 of enumList1) {
8199
- if (hasEqualsEnum(context, enumList2, enum1)) foundIntersection = true;
8200
- else foundExtra1 = true;
8201
- if (foundExtra1 && foundIntersection) break;
8006
+ var calculateCommonRequiredExpression = (singleExpression, variable) => {
8007
+ switch (singleExpression) {
8008
+ case ExpressionSingleResult.Equals:
8009
+ variable.hasCommonInRequired = true;
8010
+ break;
8011
+ case ExpressionSingleResult.Containing:
8012
+ variable.hasExtra1 = true;
8013
+ variable.hasCommonInRequired = true;
8014
+ break;
8015
+ case ExpressionSingleResult.ContainedBy:
8016
+ variable.hasExtra2 = true;
8017
+ variable.hasCommonInRequired = true;
8018
+ break;
8019
+ case ExpressionSingleResult.Intersection:
8020
+ variable.hasExtra1 = true;
8021
+ variable.hasExtra2 = true;
8022
+ variable.hasCommonInRequired = true;
8023
+ break;
8024
+ case ExpressionSingleResult.Rejection: variable.hasRejection = true;
8202
8025
  }
8203
- for (const enum2 of enumList2) {
8204
- if (hasEqualsEnum(context, enumList1, enum2)) foundIntersection = true;
8205
- else foundExtra2 = true;
8206
- if (foundExtra2 && foundIntersection) break;
8026
+ };
8027
+ var calculateExtraRequiredExpression1 = (singleExpression, variable) => {
8028
+ switch (singleExpression) {
8029
+ case ExpressionSingleResult.Equals:
8030
+ case ExpressionSingleResult.ContainedBy:
8031
+ variable.hasCommonInRequired = true;
8032
+ break;
8033
+ case ExpressionSingleResult.Intersection:
8034
+ case ExpressionSingleResult.Containing:
8035
+ variable.hasExtra1 = true;
8036
+ variable.hasCommonInRequired = true;
8037
+ break;
8038
+ case ExpressionSingleResult.Rejection: variable.hasRejection = true;
8207
8039
  }
8208
- if (!foundIntersection) return ExpressionRejection;
8209
- if (foundExtra1 && foundExtra2) return ExpressionIntersection;
8210
- if (foundExtra1) return ExpressionContaining;
8211
- if (foundExtra2) return ExpressionContainedBy;
8212
- return ExpressionEquals;
8213
- }
8214
- function calculateEnumAndSchema(enumSchema, schema) {
8215
- let hasValid = false;
8216
- let hasInvalid = false;
8217
- for (const enumValue of normalizeEnumList(enumSchema)) {
8218
- switch (valid(schema, enumValue)) {
8219
- case ValidResult.Valid:
8220
- hasValid = true;
8221
- break;
8222
- case ValidResult.Invalid:
8223
- hasInvalid = true;
8224
- break;
8225
- case ValidResult.Unknown: return ExpressionAny;
8226
- }
8227
- if (hasValid && hasInvalid) break;
8040
+ };
8041
+ var calculateExtraRequiredExpression2 = (singleExpression, variable) => {
8042
+ switch (singleExpression) {
8043
+ case ExpressionSingleResult.Equals:
8044
+ case ExpressionSingleResult.Containing:
8045
+ variable.hasCommonInRequired = true;
8046
+ break;
8047
+ case ExpressionSingleResult.Intersection:
8048
+ case ExpressionSingleResult.ContainedBy:
8049
+ variable.hasExtra2 = true;
8050
+ variable.hasCommonInRequired = true;
8051
+ break;
8052
+ case ExpressionSingleResult.Rejection: variable.hasRejection = true;
8053
+ }
8054
+ };
8055
+ var calculateOptionalExpression = (hasOptional1, hasOptional2) => (singleExpression, variable) => {
8056
+ if (variable.hasRejection) return;
8057
+ let foundExtraPossibility1 = false;
8058
+ let foundExtraPossibility2 = false;
8059
+ let foundCommonPossibility = false;
8060
+ switch (singleExpression) {
8061
+ case ExpressionSingleResult.Equals:
8062
+ foundCommonPossibility = true;
8063
+ break;
8064
+ case ExpressionSingleResult.Containing:
8065
+ foundExtraPossibility1 = true;
8066
+ foundCommonPossibility = true;
8067
+ break;
8068
+ case ExpressionSingleResult.ContainedBy:
8069
+ foundExtraPossibility2 = true;
8070
+ foundCommonPossibility = true;
8071
+ break;
8072
+ case ExpressionSingleResult.Intersection:
8073
+ foundExtraPossibility1 = true;
8074
+ foundExtraPossibility2 = true;
8075
+ foundCommonPossibility = true;
8076
+ break;
8077
+ case ExpressionSingleResult.Rejection:
8078
+ foundExtraPossibility1 = true;
8079
+ foundExtraPossibility2 = true;
8228
8080
  }
8229
- if (hasValid && hasInvalid) return ExpressionIntersection;
8230
- if (hasValid) return ExpressionEquals | ExpressionContainedBy;
8231
- if (hasInvalid) return ExpressionRejection;
8232
- if (getKind(schema) === CompiledKind.Never) return ExpressionEquals;
8233
- return ExpressionContainedBy;
8234
- }
8235
- function normalizeEnumList({ const: constValue, enum: enumList }) {
8236
- if (constValue !== void 0) return [constValue];
8237
- if (enumList) return enumList;
8238
- throw new Error("invalid branch");
8081
+ if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
8082
+ if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
8083
+ if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
8084
+ };
8085
+ function createPropertySchemaGetter(schema) {
8086
+ const properties = schema.properties;
8087
+ const propertyNames = schema.propertyNames;
8088
+ const additionalProperties = schema.additionalProperties;
8089
+ const patternProperties = [];
8090
+ if (schema.patternProperties) for (const pattern in schema.patternProperties) {
8091
+ const valueSchema = schema.patternProperties[pattern];
8092
+ const regExp = new RegExp(pattern, "i");
8093
+ patternProperties.push({
8094
+ pattern: regExp,
8095
+ schema: valueSchema
8096
+ });
8097
+ }
8098
+ return (key) => {
8099
+ if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
8100
+ for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
8101
+ const propertySchema = (properties && properties[key]) ?? additionalProperties;
8102
+ if (!propertySchema) return ANY;
8103
+ return propertySchema;
8104
+ };
8239
8105
  }
8240
- function hasEqualsEnum({ isEquals }, enumList, checkedEnum) {
8241
- for (const searchedEnum of enumList) if (isEquals(searchedEnum, checkedEnum)) return true;
8242
- return false;
8106
+ function areNotBothNever(schema1, schema2) {
8107
+ const kind1 = getKind(schema1);
8108
+ const kind2 = getKind(schema2);
8109
+ return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
8243
8110
  }
8244
8111
  //#endregion
8245
- //#region src/json-schema-subset/checker/equals.ts
8246
- function schemaEqualsChecker(extendsContext) {
8247
- function isSchemaEquals(schema1, schema2) {
8248
- const isExtends1 = extendsContext.isExtendsSchema(schema1);
8249
- const isExtends2 = extendsContext.isExtendsSchema(schema2);
8250
- if (isExtends1 || isExtends2) return extendsContext.equals(schema1, schema2);
8251
- else return isCompiledSchemaEquals(schema1, schema2);
8252
- }
8253
- const equalsMap = /* @__PURE__ */ new Map();
8254
- function isCompiledSchemaEquals(schema1, schema2) {
8255
- const id1 = getId(schema1);
8256
- const id2 = getId(schema2);
8257
- if (id1 === id2) return true;
8258
- const key = `${id1}/${id2}`;
8259
- let isEquals = equalsMap.get(key);
8260
- if (isEquals === void 0) {
8261
- isEquals = isObjectLikeEquals(schema1, schema2);
8262
- equalsMap.set(key, isEquals);
8263
- }
8264
- return isEquals;
8265
- }
8266
- function isObjectLikeEquals(object1, object2) {
8267
- if (Array.isArray(object1)) {
8268
- if (!Array.isArray(object2)) return false;
8269
- if (object1.length !== object2.length) return false;
8270
- for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
8271
- } else {
8272
- if (Array.isArray(object2)) return false;
8273
- for (const key in object1) {
8274
- if (!(key in object2)) return false;
8275
- if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
8276
- }
8277
- for (const key in object2) if (!(key in object1)) return false;
8278
- }
8279
- return true;
8280
- }
8281
- function isValueEquals(value1, value2) {
8282
- if (value1 === value2) return true;
8283
- if (value1 === null) return false;
8284
- if (typeof value1 !== "object") return false;
8285
- if (typeof value1 !== typeof value2) return false;
8286
- if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
8287
- return isObjectLikeEquals(value1, value2);
8112
+ //#region src/json-schema-subset/checker/string.ts
8113
+ var splitRange = createRangeSplitter(0);
8114
+ function calculateString(schema1, schema2) {
8115
+ if (schema2.format && !schema1.format) return ExpressionContaining;
8116
+ if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
8117
+ const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
8118
+ const hasPattern1 = !!schema1.pattern;
8119
+ const hasPattern2 = !!schema2.pattern;
8120
+ switch (expression) {
8121
+ case ExpressionSingleResult.Rejection: return ExpressionRejection;
8122
+ case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
8123
+ case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
8124
+ case ExpressionSingleResult.Equals:
8125
+ if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
8126
+ if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
8127
+ if (hasPattern2) return ExpressionEquals | ExpressionContaining;
8128
+ return ExpressionEquals;
8129
+ case ExpressionSingleResult.Intersection:
8130
+ if (hasPattern1 && hasPattern2) return ExpressionAny;
8131
+ if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
8132
+ if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
8133
+ return ExpressionIntersection;
8288
8134
  }
8289
- return isSchemaEquals;
8290
8135
  }
8291
8136
  //#endregion
8292
- //#region src/json-schema-subset/checker/numeric/integerNormalizer.ts
8293
- function normalizeInteger(schema) {
8294
- const floatRange = pickRange(schema);
8295
- const multipleOf = schema.multipleOf ?? 1;
8296
- const range = cutRange(floatRange, multipleOf);
8297
- if (!range) return null;
8137
+ //#region src/json-schema-subset/checker/checker.ts
8138
+ function checkWithResult(extendsContext, schema1, schema2) {
8139
+ const context = {};
8140
+ const errorPaths = [];
8141
+ const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
8142
+ const describe = describer();
8143
+ const equals = schemaEqualsChecker(extendsContext);
8144
+ context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
8145
+ context.calculate = expression$1({
8146
+ describe,
8147
+ equals,
8148
+ calculate,
8149
+ observeCalculation: (left, right, result, swapped) => {
8150
+ if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
8151
+ const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
8152
+ if (errorPath) errorPaths.push(errorPath);
8153
+ }
8154
+ });
8155
+ Object.freeze(context);
8156
+ const comparisonExpression = context.calculate(schema1, schema2);
8298
8157
  return {
8299
- multipleOf,
8300
- range
8158
+ errorPath: errorPaths[0],
8159
+ expression: comparisonExpression
8301
8160
  };
8302
8161
  }
8303
- function isPointRange([point1, point2]) {
8304
- if (point1.num !== point2.num) return false;
8305
- if (point1.exclusive) return false;
8306
- if (point2.exclusive) return false;
8307
- return true;
8308
- }
8309
- function cutRange(range, multipleOf) {
8310
- if (!range) return;
8311
- const [originMin, originMax] = range;
8312
- let min = nextInteger(originMin.num, multipleOf);
8313
- let max = previousInteger(originMax.num, multipleOf);
8314
- if (min === originMin.num && originMin.exclusive) min += multipleOf;
8315
- if (max === originMax.num && originMax.exclusive) max -= multipleOf;
8316
- if (min > max) return;
8317
- if (min === max) {
8318
- if (min === Number.POSITIVE_INFINITY) return;
8319
- if (min === Number.NEGATIVE_INFINITY) return;
8162
+ var describer = () => (schema) => {
8163
+ let description;
8164
+ switch (getKind(schema)) {
8165
+ case CompiledKind.Not:
8166
+ description = {
8167
+ kind: ExpressionKind.Not,
8168
+ expression: schema.not
8169
+ };
8170
+ break;
8171
+ case CompiledKind.Combination:
8172
+ if ("allOf" in schema) description = {
8173
+ kind: ExpressionKind.AllOf,
8174
+ expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
8175
+ };
8176
+ else if ("anyOf" in schema) description = {
8177
+ kind: ExpressionKind.AnyOf,
8178
+ expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
8179
+ };
8180
+ else if ("oneOf" in schema) description = {
8181
+ kind: ExpressionKind.OneOf,
8182
+ expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
8183
+ };
8184
+ else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
8185
+ break;
8186
+ default: description = { kind: ExpressionKind.Leaf };
8320
8187
  }
8321
- return [{
8322
- num: min,
8323
- exclusive: false
8324
- }, {
8325
- num: max,
8326
- exclusive: false
8327
- }];
8328
- }
8329
- function nextInteger(float, multipleOf) {
8330
- return Math.ceil(float / multipleOf) * multipleOf;
8331
- }
8332
- function previousInteger(float, multipleOf) {
8333
- return Math.floor(float / multipleOf) * multipleOf;
8334
- }
8335
- //#endregion
8336
- //#region src/json-schema-subset/checker/numeric/float.ts
8337
- function calculateFloat(schema1, schema2) {
8338
- const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
8339
- if (!center) return ExpressionRejection;
8340
- let extraLeft = false;
8341
- let extraRight = false;
8342
- if (left) {
8343
- if (left.fromLeft) extraLeft = true;
8344
- else extraRight = true;
8188
+ return description;
8189
+ };
8190
+ var calculator = (extendsContext, context) => (schema1, schema2) => {
8191
+ const kind1 = getKind(schema1);
8192
+ const kind2 = getKind(schema2);
8193
+ if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
8194
+ switch (kind1) {
8195
+ case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
8196
+ case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
8345
8197
  }
8346
- if (right) {
8347
- if (right.fromLeft) extraLeft = true;
8348
- else extraRight = true;
8198
+ switch (kind2) {
8199
+ case CompiledKind.Any: return ExpressionContainedBy;
8200
+ case CompiledKind.Never: return ExpressionContaining;
8349
8201
  }
8350
- if (extraLeft && extraRight) return ExpressionIntersection;
8351
- if (extraLeft) return ExpressionContaining;
8352
- if (extraRight) return ExpressionContainedBy;
8353
- return ExpressionEquals;
8354
- }
8355
- function calculateFloatAndInteger(schema1, schema2) {
8356
- const floatRange = pickRange(schema1);
8357
- const integer = normalizeInteger(schema2);
8358
- if (!integer) return ExpressionContaining;
8359
- const result = splitRange$3(floatRange, integer.range);
8360
- const intCenter = cutRange(result.center, integer.multipleOf);
8361
- const leftIntRange = unwrapAndCutRange(result.left, integer.multipleOf);
8362
- const rightIntRange = unwrapAndCutRange(result.right, integer.multipleOf);
8363
- if (!result.center) return ExpressionRejection;
8364
- let extraFloat = false;
8365
- let extraInteger = false;
8366
- if (result.left?.fromLeft) extraFloat = true;
8367
- if (result.right?.fromLeft) extraFloat = true;
8368
- if (!intCenter || !isPointRange(result.center)) extraFloat = true;
8369
- if (leftIntRange) extraInteger = true;
8370
- if (rightIntRange) extraInteger = true;
8371
- if (extraFloat && extraInteger) return ExpressionIntersection;
8372
- if (extraFloat) return ExpressionContaining;
8373
- if (extraInteger) return ExpressionContainedBy;
8374
- return ExpressionEquals;
8202
+ if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) return calculateEnumAndEnum(context, schema1, schema2);
8203
+ if (kind1 === CompiledKind.EnumOrConst) return calculateEnumAndSchema(schema1, schema2);
8204
+ if (kind2 === CompiledKind.EnumOrConst) return swap(calculateEnumAndSchema(schema2, schema1));
8205
+ if (kind1 !== kind2) return ExpressionRejection;
8206
+ switch (kind1) {
8207
+ case CompiledKind.Null: return ExpressionEquals;
8208
+ case CompiledKind.Numeric: return calculateNumeric(schema1, schema2);
8209
+ case CompiledKind.String: return calculateString(schema1, schema2);
8210
+ case CompiledKind.Boolean: return ExpressionEquals;
8211
+ case CompiledKind.Object: return calculateObject(context, schema1, schema2);
8212
+ case CompiledKind.Array: return calculateArray(context, schema1, schema2);
8213
+ default: throw new Error(`invalid kind ${kind1}`);
8214
+ }
8215
+ };
8216
+ function rejectInSchemaList(schemaList, kind) {
8217
+ return schemaList.filter((e) => getKind(e) !== kind);
8375
8218
  }
8376
- function pickRange(schema) {
8377
- let point1;
8378
- let point2;
8379
- if (schema.exclusiveMinimum !== void 0) point1 = {
8380
- num: schema.exclusiveMinimum,
8381
- exclusive: true
8382
- };
8383
- else if (schema.minimum !== void 0) point1 = {
8384
- num: schema.minimum,
8385
- exclusive: false
8386
- };
8387
- else point1 = {
8388
- num: Number.NEGATIVE_INFINITY,
8389
- exclusive: true
8390
- };
8391
- if (schema.exclusiveMaximum !== void 0) point2 = {
8392
- num: schema.exclusiveMaximum,
8393
- exclusive: true
8394
- };
8395
- else if (schema.maximum !== void 0) point2 = {
8396
- num: schema.maximum,
8397
- exclusive: false
8398
- };
8399
- else point2 = {
8400
- num: Number.POSITIVE_INFINITY,
8401
- exclusive: true
8402
- };
8403
- return [point1, point2];
8219
+ function isDecisiveMismatch(result) {
8220
+ return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result));
8404
8221
  }
8405
- function unwrapAndCutRange(side, multipleOf) {
8406
- if (!side) return;
8407
- if (side.fromLeft) return;
8408
- return cutRange(side.range, multipleOf);
8222
+ function findMismatchPath(source, target) {
8223
+ const targetPath = getPath(target);
8224
+ if (!targetPath) return void 0;
8225
+ const sourceKind = getKind(source);
8226
+ const targetKind = getKind(target);
8227
+ if (sourceKind !== targetKind) return [...targetPath, "type"];
8228
+ const sourceSchema = source;
8229
+ const targetSchema = target;
8230
+ switch (targetKind) {
8231
+ case CompiledKind.String:
8232
+ if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
8233
+ if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
8234
+ if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
8235
+ if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
8236
+ break;
8237
+ case CompiledKind.Numeric:
8238
+ if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
8239
+ if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
8240
+ if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
8241
+ break;
8242
+ case CompiledKind.Array:
8243
+ if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
8244
+ if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
8245
+ if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
8246
+ break;
8247
+ case CompiledKind.Object: {
8248
+ const sourceRequired = new Set(sourceSchema.required ?? []);
8249
+ if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
8250
+ if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
8251
+ if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
8252
+ break;
8253
+ }
8254
+ case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
8255
+ }
8256
+ return targetPath;
8409
8257
  }
8410
8258
  //#endregion
8411
- //#region src/json-schema-subset/checker/numeric/integer.ts
8412
- function calculateInteger(schema1, schema2) {
8413
- const integer1 = normalizeInteger(schema1);
8414
- const integer2 = normalizeInteger(schema2);
8415
- if (!integer1 && !integer2) return ExpressionEquals;
8416
- if (!integer1) return ExpressionContainedBy;
8417
- if (!integer2) return ExpressionContaining;
8418
- const { range: range1, multipleOf: multipleOf1 } = integer1;
8419
- const { range: range2, multipleOf: multipleOf2 } = integer2;
8420
- const result = splitRange$3(range1, range2);
8421
- let centerRange;
8422
- let lcm = 0;
8423
- if (result.center) {
8424
- lcm = getLCM(multipleOf1, multipleOf2);
8425
- centerRange = cutRange(result.center, lcm);
8259
+ //#region src/json-schema-subset/extends/extendsContext.ts
8260
+ var ExtendsContext = class ExtendsContext {
8261
+ constructor(extendsSchemaClasses = []) {
8262
+ this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
8426
8263
  }
8427
- if (!centerRange) return ExpressionRejection;
8428
- let extraLeft = false;
8429
- let extraRight = false;
8430
- const { left, right } = result;
8431
- if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
8432
- if (left.fromLeft) extraLeft = true;
8433
- else extraRight = true;
8264
+ tryCompiledExtendsSchema(target, payload) {
8265
+ for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
8266
+ return null;
8434
8267
  }
8435
- if (right && cutRange(right.range, right.fromLeft ? multipleOf1 : multipleOf2)) {
8436
- if (right.fromLeft) extraLeft = true;
8437
- else extraRight = true;
8268
+ isExtendsSchema(target) {
8269
+ for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
8270
+ return false;
8438
8271
  }
8439
- extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
8440
- extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
8441
- if (extraLeft && extraRight) return ExpressionIntersection;
8442
- if (extraLeft) return ExpressionContaining;
8443
- if (extraRight) return ExpressionContainedBy;
8444
- return ExpressionEquals;
8445
- }
8446
- function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
8447
- const result = splitRange$3(range, lcmCenterRange);
8448
- if (cutRange(result.left?.range, multipleOf)) return true;
8449
- if (cutRange(result.right?.range, multipleOf)) return true;
8450
- const center = cutRange(result.center, multipleOf);
8451
- if (!center) return false;
8452
- const lcmCenterLength = rangeLength(lcmCenterRange);
8453
- if (rangeLength(center) > lcmCenterLength) return true;
8454
- if (lcmCenterLength === 1) return false;
8455
- if (multipleOf < lcm) return true;
8456
- return false;
8272
+ calculate(schema1, schema2) {
8273
+ const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
8274
+ let expressionResult = 0;
8275
+ let result;
8276
+ if (shouldSwap) result = schema2.compare(schema1);
8277
+ else result = schema1.compare(schema2);
8278
+ for (let expression of result) {
8279
+ if (shouldSwap) expression = ExtendsContext.swap(expression);
8280
+ expressionResult |= toExpression(expression);
8281
+ }
8282
+ return expressionResult;
8283
+ }
8284
+ equals(schema1, schema2) {
8285
+ if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
8286
+ else return schema1.equals(schema2);
8287
+ }
8288
+ findMatchedClass(schema1, schema2) {
8289
+ for (const schemaClass of this.extendsSchemaClasses) {
8290
+ if (schema1 instanceof schemaClass) return schemaClass;
8291
+ if (schema2 instanceof schemaClass) return schemaClass;
8292
+ }
8293
+ throw new Error("Invalid schema");
8294
+ }
8295
+ static swap(expression) {
8296
+ switch (expression) {
8297
+ case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
8298
+ case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
8299
+ default: return expression;
8300
+ }
8301
+ }
8302
+ };
8303
+ //#endregion
8304
+ //#region src/json-schema-subset/preprocessing.ts
8305
+ function preprocessSchema(schema, compile, printWarnLog = false) {
8306
+ const schemaResult = compile(schema);
8307
+ if (Array.isArray(schemaResult)) {
8308
+ const errorItems = [];
8309
+ collectWithPathPrefix(errorItems, schemaResult, "$");
8310
+ throw new SchemaError(errorItems);
8311
+ }
8312
+ const { schema: compiledSchema, warns } = schemaResult;
8313
+ if (printWarnLog && warns.length > 0) {
8314
+ console.warn(`found ${warns.length} warns after compile schema`);
8315
+ for (const warn of warns) console.warn(stringifySchemaError(warn));
8316
+ }
8317
+ return compiledSchema;
8457
8318
  }
8458
- /** Returns the least common multiple. */
8459
- function getLCM(a, b) {
8460
- return a * b / getGCD(a, b);
8319
+ function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
8320
+ const schemaResult1 = compile(schema1);
8321
+ const schemaResult2 = compile(schema2);
8322
+ if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
8323
+ const errorItems = [];
8324
+ if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
8325
+ if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
8326
+ throw new SchemaError(errorItems);
8327
+ }
8328
+ const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
8329
+ const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
8330
+ if (printWarnLog) {
8331
+ if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
8332
+ for (const warn of superWarns) console.warn(stringifySchemaError(warn));
8333
+ if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
8334
+ for (const warn of subWarns) console.warn(stringifySchemaError(warn));
8335
+ }
8336
+ return [compiledSchema1, compiledSchema2];
8461
8337
  }
8462
- /** @returns The greatest common divisor. */
8463
- function getGCD(a, b) {
8464
- if (a === 0) return b;
8465
- return getGCD(b % a, a);
8338
+ function collectWithPathPrefix(errorItems, compiledItems, prefix) {
8339
+ for (const compiledItem of compiledItems) {
8340
+ const replacedItem = {
8341
+ ...compiledItem,
8342
+ path: [prefix, ...compiledItem.path]
8343
+ };
8344
+ errorItems.push(replacedItem);
8345
+ }
8466
8346
  }
8467
- function rangeLength(range) {
8468
- if (!range) return 0;
8469
- const [point1, point2] = range;
8470
- return point2.num - point1.num + 1;
8347
+ //#endregion
8348
+ //#region src/json-schema-subset/global.ts
8349
+ var SubsetCompareResult = Object.freeze({
8350
+ True: 0,
8351
+ False: 1,
8352
+ Unknown: 2
8353
+ });
8354
+ function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
8355
+ const extendsContext = new ExtendsContext(extendsSchemaClasses);
8356
+ return Object.freeze({
8357
+ compile: (schema, payload, printWarnLog) => {
8358
+ const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
8359
+ return preprocessSchema(schema, compiler, printWarnLog);
8360
+ },
8361
+ isSubset: (superSchema, subSchema, printWarnLog = false) => {
8362
+ const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
8363
+ const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
8364
+ const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
8365
+ const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
8366
+ const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
8367
+ if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
8368
+ if (!foundTrueExpression && foundFalseExpression) return {
8369
+ errorPath,
8370
+ result: SubsetCompareResult.False
8371
+ };
8372
+ return { result: SubsetCompareResult.Unknown };
8373
+ }
8374
+ });
8471
8375
  }
8472
8376
  //#endregion
8473
- //#region src/json-schema-subset/checker/numeric/checker.ts
8474
- function calculateNumeric(schema1, schema2) {
8475
- if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) return ExpressionAny;
8476
- const isFloat1 = isFloat(schema1);
8477
- const isFloat2 = isFloat(schema2);
8478
- if (isFloat1 && isFloat2) return calculateFloat(schema1, schema2);
8479
- else if (isFloat1) return calculateFloatAndInteger(schema1, schema2);
8480
- else if (isFloat2) return swap(calculateFloatAndInteger(schema2, schema1));
8481
- else return calculateInteger(schema1, schema2);
8377
+ //#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
8378
+ var isString = (x) => typeof x === "string";
8379
+ var isArray = Array.isArray;
8380
+ var isObject = (x) => x !== null && typeof x === "object";
8381
+ var isPlainObject = (x) => isObject(x) && !isArray(x);
8382
+ var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
8383
+ //#endregion
8384
+ //#region src/flow/common/schemaComparer.ts
8385
+ function isStringLikeSchema(value) {
8386
+ return toPlainObject(value)?.type === "string";
8482
8387
  }
8483
- function isUndefinedNumber(schema) {
8484
- const { multipleOf } = schema;
8485
- if (multipleOf === void 0) return false;
8486
- if (!Number.isInteger(multipleOf)) return true;
8487
- if (multipleOf < 0) return true;
8488
- return false;
8388
+ function assertSchemaCompareContext(value) {
8389
+ const context = toPlainObject(value);
8390
+ const error = toPlainObject(context?.error);
8391
+ if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
8489
8392
  }
8490
- function isFloat(schema) {
8491
- const { multipleOf } = schema;
8492
- if (multipleOf !== void 0 && Number.isInteger(multipleOf)) return false;
8493
- if (schema.type === "integer") return false;
8494
- return true;
8393
+ function parseSchemaCompareContext(value) {
8394
+ if (value == null) return { error: {} };
8395
+ assertSchemaCompareContext(value);
8396
+ return value;
8495
8397
  }
8496
- //#endregion
8497
- //#region src/json-schema-subset/checker/object.ts
8498
- var splitRange$1 = createRangeSplitter(0);
8499
- var quantum = makeQuantum([
8500
- "hasCommonInRequired",
8501
- "hasCommonOutRequired",
8502
- "hasExtra1",
8503
- "hasExtra2",
8504
- "hasRejection"
8505
- ]);
8506
- function calculateObject(context, schema1, schema2) {
8507
- if (isPropertiesCountCannotMatch(schema1, schema2)) return ExpressionRejection;
8508
- const splitRequiredResult = splitRequired(schema1, schema2);
8509
- if (!splitRequiredResult) return ExpressionRejection;
8510
- const getProperty1 = createPropertySchemaGetter(schema1);
8511
- const getProperty2 = createPropertySchemaGetter(schema2);
8512
- const calculateKey = (key) => {
8513
- const propertySchema1 = getProperty1(key);
8514
- const propertySchema2 = getProperty2(key);
8515
- if (areNotBothNever(propertySchema1, propertySchema2)) return context.calculate(propertySchema1, propertySchema2);
8516
- else return 0;
8517
- };
8518
- const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult;
8519
- const quantumVariable = quantum.variable({});
8520
- for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
8521
- for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
8522
- for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
8523
- const { hasOptional1, hasOptional2 } = splitRequiredResult;
8524
- if (hasOptional1 || hasOptional2) {
8525
- const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
8526
- for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
8527
- const expression = calculateKey(optionalKey);
8528
- if (expression !== 0) quantumVariable.push(expression, calculator);
8398
+ var SpecialSchema = class SpecialSchema {
8399
+ static setError(fromSchema, toSchema, message) {
8400
+ if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
8401
+ else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
8402
+ }
8403
+ constructor(id, value, context) {
8404
+ this.id = id;
8405
+ this.value = value;
8406
+ this.context = parseSchemaCompareContext(context);
8407
+ }
8408
+ compare(other) {
8409
+ if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
8410
+ return this.compareImpl(other);
8411
+ }
8412
+ };
8413
+ var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
8414
+ static isMatch(value) {
8415
+ const enumValues = toPlainObject(value)?.enum;
8416
+ return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
8417
+ }
8418
+ constructor(id, value, context) {
8419
+ if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
8420
+ super(id, value, context);
8421
+ }
8422
+ compareImpl(other) {
8423
+ if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
8424
+ if (other instanceof SingleSelectSchema) {
8425
+ const f = new Set(this.value.enum);
8426
+ let result = ExpressionSingleResult.Equals;
8427
+ for (const v of other.value.enum) {
8428
+ if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
8429
+ f.delete(v);
8430
+ }
8431
+ if (f.size === 0) return [result];
8432
+ if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
8433
+ return [ExpressionSingleResult.Intersection];
8529
8434
  }
8530
- const additionalProperties1 = schema1.additionalProperties ?? ANY;
8531
- const additionalProperties2 = schema2.additionalProperties ?? ANY;
8532
- if (areNotBothNever(additionalProperties1, additionalProperties2)) {
8533
- const expression = context.calculate(additionalProperties1, additionalProperties2);
8534
- quantumVariable.push(expression, calculator);
8435
+ return [ExpressionSingleResult.Rejection];
8436
+ }
8437
+ equals(other) {
8438
+ if (other instanceof SingleSelectSchema) {
8439
+ const f = new Set(this.value.enum);
8440
+ for (const v of other.value.enum) {
8441
+ if (!f.has(v)) return false;
8442
+ f.delete(v);
8443
+ }
8444
+ return f.size === 0;
8535
8445
  }
8446
+ return false;
8536
8447
  }
8537
- quantumVariable.update((variable) => {
8538
- if (!variable.hasRejection) {
8539
- if (extraRequired1.size > 0) variable.hasExtra2 = true;
8540
- if (extraRequired2.size > 0) variable.hasExtra1 = true;
8448
+ };
8449
+ var BinarySchema = class BinarySchema extends SpecialSchema {
8450
+ static isMatch(value) {
8451
+ return toPlainObject(value)?.contentMediaType === "oomol/bin";
8452
+ }
8453
+ constructor(id, value, context) {
8454
+ if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
8455
+ super(id, value, context);
8456
+ }
8457
+ compareImpl(other) {
8458
+ if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
8459
+ else {
8460
+ SpecialSchema.setError(this, other, "edgeError.binDiffType");
8461
+ return [ExpressionSingleResult.Rejection];
8541
8462
  }
8463
+ }
8464
+ equals(other) {
8465
+ return other instanceof BinarySchema;
8466
+ }
8467
+ };
8468
+ var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
8469
+ static isMatch(value) {
8470
+ return toPlainObject(value)?.contentMediaType === "oomol/artifact";
8471
+ }
8472
+ constructor(id, value, context) {
8473
+ if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
8474
+ super(id, value, context);
8475
+ }
8476
+ compareImpl(other) {
8477
+ if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
8478
+ SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
8479
+ return [ExpressionSingleResult.Rejection];
8480
+ }
8481
+ equals(other) {
8482
+ return other instanceof ArtifactSchema;
8483
+ }
8484
+ };
8485
+ function createSchemaComparer() {
8486
+ return makeSubsetCompare({ extendsSchemaClasses: [
8487
+ SingleSelectSchema,
8488
+ BinarySchema,
8489
+ ArtifactSchema
8490
+ ] });
8491
+ }
8492
+ createSchemaComparer();
8493
+ //#endregion
8494
+ //#region src/decision/common/decision.ts
8495
+ var decisionLimits = {
8496
+ choice: 255,
8497
+ score: 10
8498
+ };
8499
+ /** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
8500
+ function limitDecisionQuestion(question) {
8501
+ if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
8502
+ if (question.type === "choice") return {
8503
+ ...question,
8504
+ criteria: question.criteria.slice(0, decisionLimits.choice)
8505
+ };
8506
+ return {
8507
+ ...question,
8508
+ criteria: question.criteria.slice(0, decisionLimits.score)
8509
+ };
8510
+ }
8511
+ function limitDecisionQuestions(questions) {
8512
+ const limited = questions.map(limitDecisionQuestion);
8513
+ return limited.every((question, i) => question === questions[i]) ? questions : limited;
8514
+ }
8515
+ /** Loading an oversized task also updates its previously generated output schemas. */
8516
+ function limitDecisionTask(task) {
8517
+ if (task.executor.kind !== "decision") return task;
8518
+ const original = task.executor.questions;
8519
+ const questions = limitDecisionQuestions(original);
8520
+ if (questions === original) return task;
8521
+ const outputs = task.outputs.map((port) => {
8522
+ if (!("handle" in port)) return port;
8523
+ const index = original.findIndex((question) => question.name === port.handle);
8524
+ if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
8525
+ return {
8526
+ ...port,
8527
+ jsonSchema: decisionAnswerSchema(questions[index])
8528
+ };
8542
8529
  });
8543
- const { requiredKeysCount } = splitRequiredResult;
8544
- let expression = 0;
8545
- for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
8546
- else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
8547
- else if (hasRejection) expression |= ExpressionRejection;
8548
- else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
8549
- else if (hasExtra1) expression |= ExpressionContaining;
8550
- else if (hasExtra2) expression |= ExpressionContainedBy;
8551
- else expression |= ExpressionEquals;
8552
- return expression;
8530
+ return {
8531
+ ...task,
8532
+ executor: {
8533
+ ...task.executor,
8534
+ questions
8535
+ },
8536
+ outputs
8537
+ };
8553
8538
  }
8554
- function isPropertiesCountCannotMatch(schema1, schema2) {
8555
- return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
8539
+ var probability = {
8540
+ type: "number",
8541
+ minimum: 0,
8542
+ maximum: 1
8543
+ };
8544
+ function decisionAnswerSchema(question) {
8545
+ return answerSchema(limitDecisionQuestion(question));
8556
8546
  }
8557
- function splitRequired(schema1, schema2) {
8558
- const extraRequired1 = new Set(schema1.required);
8559
- const extraRequired2 = new Set(schema2.required);
8560
- const commonRequired = /* @__PURE__ */ new Set();
8561
- const wholeRequired = /* @__PURE__ */ new Set();
8562
- const requiredCount1 = extraRequired1.size;
8563
- const requiredCount2 = extraRequired2.size;
8564
- for (const key of extraRequired1) {
8565
- if (extraRequired2.has(key)) commonRequired.add(key);
8566
- wholeRequired.add(key);
8567
- }
8568
- for (const key of extraRequired2) {
8569
- if (extraRequired1.has(key)) commonRequired.add(key);
8570
- wholeRequired.add(key);
8571
- }
8572
- const requiredKeysCount = wholeRequired.size;
8573
- for (const key of commonRequired) {
8574
- extraRequired1.delete(key);
8575
- extraRequired2.delete(key);
8547
+ function answerSchema(question) {
8548
+ const properties = { type: { const: question.type } };
8549
+ if (question.type === "noul") properties.noul = probability;
8550
+ else {
8551
+ const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
8552
+ properties.confidence = probability;
8553
+ properties.probabilities = {
8554
+ type: "object",
8555
+ properties: Object.fromEntries(keys.map((key) => [key, probability])),
8556
+ required: keys,
8557
+ additionalProperties: false
8558
+ };
8559
+ if (question.type === "choice") properties.choice = {
8560
+ type: "string",
8561
+ ...keys.length ? { enum: keys } : {}
8562
+ };
8563
+ else {
8564
+ properties.score = {
8565
+ type: "number",
8566
+ minimum: 0,
8567
+ maximum: Math.max(0, keys.length - 1)
8568
+ };
8569
+ properties.legend = {
8570
+ type: "object",
8571
+ properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
8572
+ required: keys,
8573
+ additionalProperties: false
8574
+ };
8575
+ }
8576
8576
  }
8577
- const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
8578
- const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
8579
- if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
8580
8577
  return {
8581
- requiredKeysCount,
8582
- extraRequired1,
8583
- extraRequired2,
8584
- commonRequired,
8585
- hasOptional1: maxProperties1 > requiredCount1,
8586
- hasOptional2: maxProperties2 > requiredCount2
8578
+ type: "object",
8579
+ properties,
8580
+ required: Object.keys(properties)
8587
8581
  };
8588
8582
  }
8589
- function getOptionalKeys(schema1, schema2) {
8590
- const optionalKeys = new Set(schema1.required);
8591
- const properties1 = schema1.properties;
8592
- const properties2 = schema2.properties;
8593
- const required1 = schema1.required;
8594
- const required2 = schema2.required;
8595
- if (properties1) for (const key in properties1) optionalKeys.add(key);
8596
- if (properties2) for (const key in properties2) optionalKeys.add(key);
8597
- if (required1) for (const key of required1) optionalKeys.delete(key);
8598
- if (required2) for (const key of required2) optionalKeys.delete(key);
8599
- return optionalKeys;
8583
+ function checkJsonDepth(value, depth = 0) {
8584
+ if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
8585
+ if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
8600
8586
  }
8601
- var calculateCommonRequiredExpression = (singleExpression, variable) => {
8602
- switch (singleExpression) {
8603
- case ExpressionSingleResult.Equals:
8604
- variable.hasCommonInRequired = true;
8605
- break;
8606
- case ExpressionSingleResult.Containing:
8607
- variable.hasExtra1 = true;
8608
- variable.hasCommonInRequired = true;
8609
- break;
8610
- case ExpressionSingleResult.ContainedBy:
8611
- variable.hasExtra2 = true;
8612
- variable.hasCommonInRequired = true;
8613
- break;
8614
- case ExpressionSingleResult.Intersection:
8615
- variable.hasExtra1 = true;
8616
- variable.hasExtra2 = true;
8617
- variable.hasCommonInRequired = true;
8618
- break;
8619
- case ExpressionSingleResult.Rejection: variable.hasRejection = true;
8620
- }
8587
+ //#endregion
8588
+ //#region src/flow/common/triggerScheduleSchema.ts
8589
+ var triggerScheduleSchema = array(union([object({
8590
+ type: literal("cron"),
8591
+ expression: string$1(),
8592
+ timezone: string$1()
8593
+ }), object({
8594
+ type: literal("every"),
8595
+ unit: _enum([
8596
+ "day",
8597
+ "hour",
8598
+ "minute",
8599
+ "month",
8600
+ "week"
8601
+ ]),
8602
+ value: number()
8603
+ })]));
8604
+ var text = string$1();
8605
+ var json$3 = json$4();
8606
+ var strings$1 = array(text);
8607
+ var port$1 = object({
8608
+ description: text.optional(),
8609
+ jsonSchema: json$3,
8610
+ nullable: boolean(),
8611
+ handle: text
8612
+ });
8613
+ var input = port$1.extend({ value: json$3.optional() });
8614
+ var group = object({
8615
+ collapsed: boolean().optional(),
8616
+ group: text
8617
+ });
8618
+ var source = union([object({
8619
+ kind: literal("node"),
8620
+ nodeId: text,
8621
+ output: text,
8622
+ field: text.optional()
8623
+ }), object({
8624
+ kind: literal("binding"),
8625
+ bindingId: text
8626
+ })]);
8627
+ var fixedInput = union([object({ kind: literal("unset") }), object({
8628
+ kind: literal("value"),
8629
+ value: json$3
8630
+ })]);
8631
+ var mapping = union([fixedInput, object({
8632
+ kind: literal("sources"),
8633
+ sources: array(source)
8634
+ })]);
8635
+ var inputs = record$3(text, mapping);
8636
+ var ports$1 = {
8637
+ inputs: array(union([input, group])),
8638
+ outputs: array(union([port$1, group]))
8621
8639
  };
8622
- var calculateExtraRequiredExpression1 = (singleExpression, variable) => {
8623
- switch (singleExpression) {
8624
- case ExpressionSingleResult.Equals:
8625
- case ExpressionSingleResult.ContainedBy:
8626
- variable.hasCommonInRequired = true;
8627
- break;
8628
- case ExpressionSingleResult.Intersection:
8629
- case ExpressionSingleResult.Containing:
8630
- variable.hasExtra1 = true;
8631
- variable.hasCommonInRequired = true;
8632
- break;
8633
- case ExpressionSingleResult.Rejection: variable.hasRejection = true;
8634
- }
8640
+ var capability = union([
8641
+ strictObject({
8642
+ kind: literal("connector"),
8643
+ action: text,
8644
+ connectionId: text.optional(),
8645
+ connections: array(strictObject({
8646
+ connectionId: text,
8647
+ alias: text.optional()
8648
+ }))
8649
+ }),
8650
+ strictObject({
8651
+ kind: literal("connector"),
8652
+ mode: literal("shared")
8653
+ }),
8654
+ strictObject({
8655
+ kind: literal("connector"),
8656
+ mode: literal("independent"),
8657
+ actions: array(strictObject({
8658
+ action: text,
8659
+ connectionId: text.optional()
8660
+ }))
8661
+ }),
8662
+ strictObject({
8663
+ kind: literal("connector"),
8664
+ actionHints: array(text).optional(),
8665
+ connectionHints: array(strictObject({
8666
+ action: text,
8667
+ connectionId: text,
8668
+ alias: text.optional()
8669
+ })).optional()
8670
+ })
8671
+ ]);
8672
+ var inline = object({
8673
+ ...ports$1,
8674
+ name: text,
8675
+ moduleId: text,
8676
+ capabilities: array(capability).optional()
8677
+ });
8678
+ var agentValue = union([object({
8679
+ kind: literal("value"),
8680
+ value: json$3
8681
+ }), object({
8682
+ kind: literal("input"),
8683
+ input: text
8684
+ })]);
8685
+ var agentInput = union([agentValue, object({ kind: literal("model") })]);
8686
+ var decisionQuestion = discriminatedUnion("type", [
8687
+ strictObject({
8688
+ name: text,
8689
+ instructions: text,
8690
+ type: literal("noul"),
8691
+ criteria: strictObject({
8692
+ true: text.optional(),
8693
+ false: text.optional()
8694
+ }).optional()
8695
+ }),
8696
+ strictObject({
8697
+ name: text,
8698
+ instructions: text,
8699
+ type: literal("choice"),
8700
+ criteria: array(strictObject({
8701
+ name: text,
8702
+ description: text
8703
+ }))
8704
+ }),
8705
+ strictObject({
8706
+ name: text,
8707
+ instructions: text,
8708
+ type: literal("score"),
8709
+ criteria: strings$1
8710
+ })
8711
+ ]);
8712
+ var managedFields = object({
8713
+ ...ports$1,
8714
+ name: text,
8715
+ executor: union([
8716
+ object({
8717
+ kind: literal("connector"),
8718
+ action: text,
8719
+ connectionId: text.optional()
8720
+ }),
8721
+ object({
8722
+ kind: literal("openapi"),
8723
+ sourceUrl: text,
8724
+ method: text,
8725
+ path: text,
8726
+ serverUrl: text,
8727
+ document: json$3,
8728
+ auth: array(object({
8729
+ id: text,
8730
+ type: _enum([
8731
+ "bearer",
8732
+ "basic",
8733
+ "apiKey"
8734
+ ]),
8735
+ name: text.optional(),
8736
+ in: _enum(["header", "query"]).optional()
8737
+ }))
8738
+ }),
8739
+ strictObject({
8740
+ kind: literal("decision"),
8741
+ questions: array(decisionQuestion)
8742
+ }),
8743
+ object({
8744
+ kind: literal("llm"),
8745
+ mode: _enum(["chat", "json"])
8746
+ }),
8747
+ object({
8748
+ kind: literal("agent"),
8749
+ code: boolean().optional(),
8750
+ model: text,
8751
+ prompt: text,
8752
+ maxRounds: number(),
8753
+ tools: array(object({
8754
+ id: text,
8755
+ name: text,
8756
+ description: text,
8757
+ action: text,
8758
+ connectionId: text.optional(),
8759
+ approval: boolean(),
8760
+ inputs: array(input.extend({ source: agentInput }))
8761
+ })),
8762
+ notification: object({
8763
+ action: text,
8764
+ connectionId: text.optional(),
8765
+ inputDefinitions: array(input),
8766
+ messageHandle: text,
8767
+ inputs: record$3(text, agentValue)
8768
+ }).optional()
8769
+ })
8770
+ ])
8771
+ });
8772
+ var managed = managedFields.transform(limitDecisionTask);
8773
+ var operand$1 = union([object({
8774
+ kind: literal("value"),
8775
+ value: json$3.optional(),
8776
+ jsonSchema: json$3.optional()
8777
+ }), object({
8778
+ kind: literal("source"),
8779
+ source
8780
+ })]);
8781
+ var condition = {
8782
+ matchMode: _enum(["first", "all"]),
8783
+ cases: array(object({
8784
+ description: text.optional(),
8785
+ output: text,
8786
+ groups: array(object({ expressions: array(object({
8787
+ left: operand$1,
8788
+ operator: _enum([
8789
+ "!=",
8790
+ "<",
8791
+ "<=",
8792
+ "==",
8793
+ ">",
8794
+ ">=",
8795
+ "contains",
8796
+ "endsWith",
8797
+ "hasKey",
8798
+ "hasValue",
8799
+ "isEmpty",
8800
+ "isFalse",
8801
+ "isNotEmpty",
8802
+ "isNotNull",
8803
+ "isNull",
8804
+ "isTrue",
8805
+ "notContains",
8806
+ "notHasKey",
8807
+ "notHasValue",
8808
+ "startsWith"
8809
+ ]),
8810
+ right: operand$1.optional()
8811
+ })) }))
8812
+ }))
8635
8813
  };
8636
- var calculateExtraRequiredExpression2 = (singleExpression, variable) => {
8637
- switch (singleExpression) {
8638
- case ExpressionSingleResult.Equals:
8639
- case ExpressionSingleResult.Containing:
8640
- variable.hasCommonInRequired = true;
8641
- break;
8642
- case ExpressionSingleResult.Intersection:
8643
- case ExpressionSingleResult.ContainedBy:
8644
- variable.hasExtra2 = true;
8645
- variable.hasCommonInRequired = true;
8646
- break;
8647
- case ExpressionSingleResult.Rejection: variable.hasRejection = true;
8648
- }
8814
+ var wait = {
8815
+ inputDefinitions: array(input),
8816
+ prompt: text
8649
8817
  };
8650
- var calculateOptionalExpression = (hasOptional1, hasOptional2) => (singleExpression, variable) => {
8651
- if (variable.hasRejection) return;
8652
- let foundExtraPossibility1 = false;
8653
- let foundExtraPossibility2 = false;
8654
- let foundCommonPossibility = false;
8655
- switch (singleExpression) {
8656
- case ExpressionSingleResult.Equals:
8657
- foundCommonPossibility = true;
8658
- break;
8659
- case ExpressionSingleResult.Containing:
8660
- foundExtraPossibility1 = true;
8661
- foundCommonPossibility = true;
8662
- break;
8663
- case ExpressionSingleResult.ContainedBy:
8664
- foundExtraPossibility2 = true;
8665
- foundCommonPossibility = true;
8666
- break;
8667
- case ExpressionSingleResult.Intersection:
8668
- foundExtraPossibility1 = true;
8669
- foundExtraPossibility2 = true;
8670
- foundCommonPossibility = true;
8671
- break;
8672
- case ExpressionSingleResult.Rejection:
8673
- foundExtraPossibility1 = true;
8674
- foundExtraPossibility2 = true;
8675
- }
8676
- if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
8677
- if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
8678
- if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
8818
+ var webhookOptions = object({
8819
+ allowedMethods: never().optional(),
8820
+ allowedOrigins: strings$1.optional(),
8821
+ noResponseBody: never().optional(),
8822
+ responseData: text.optional(),
8823
+ responseHeaders: record$3(text, text).optional(),
8824
+ responseStatusCode: number().int().min(200).max(599).optional()
8825
+ });
8826
+ var webhook = {
8827
+ bodyFields: array(input),
8828
+ method: _enum(webhookMethods),
8829
+ options: webhookOptions.optional()
8679
8830
  };
8680
- function createPropertySchemaGetter(schema) {
8681
- const properties = schema.properties;
8682
- const propertyNames = schema.propertyNames;
8683
- const additionalProperties = schema.additionalProperties;
8684
- const patternProperties = [];
8685
- if (schema.patternProperties) for (const pattern in schema.patternProperties) {
8686
- const valueSchema = schema.patternProperties[pattern];
8687
- const regExp = new RegExp(pattern, "i");
8688
- patternProperties.push({
8689
- pattern: regExp,
8690
- schema: valueSchema
8691
- });
8692
- }
8693
- return (key) => {
8694
- if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
8695
- for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
8696
- const propertySchema = (properties && properties[key]) ?? additionalProperties;
8697
- if (!propertySchema) return ANY;
8698
- return propertySchema;
8699
- };
8700
- }
8701
- function areNotBothNever(schema1, schema2) {
8702
- const kind1 = getKind(schema1);
8703
- const kind2 = getKind(schema2);
8704
- return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
8705
- }
8706
- //#endregion
8707
- //#region src/json-schema-subset/checker/string.ts
8708
- var splitRange = createRangeSplitter(0);
8709
- function calculateString(schema1, schema2) {
8710
- if (schema2.format && !schema1.format) return ExpressionContaining;
8711
- if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
8712
- const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
8713
- const hasPattern1 = !!schema1.pattern;
8714
- const hasPattern2 = !!schema2.pattern;
8715
- switch (expression) {
8716
- case ExpressionSingleResult.Rejection: return ExpressionRejection;
8717
- case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
8718
- case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
8719
- case ExpressionSingleResult.Equals:
8720
- if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
8721
- if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
8722
- if (hasPattern2) return ExpressionEquals | ExpressionContaining;
8723
- return ExpressionEquals;
8724
- case ExpressionSingleResult.Intersection:
8725
- if (hasPattern1 && hasPattern2) return ExpressionAny;
8726
- if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
8727
- if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
8728
- return ExpressionIntersection;
8729
- }
8730
- }
8731
- //#endregion
8732
- //#region src/json-schema-subset/checker/checker.ts
8733
- function checkWithResult(extendsContext, schema1, schema2) {
8734
- const context = {};
8735
- const errorPaths = [];
8736
- const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
8737
- const describe = describer();
8738
- const equals = schemaEqualsChecker(extendsContext);
8739
- context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
8740
- context.calculate = expression$1({
8741
- describe,
8742
- equals,
8743
- calculate,
8744
- observeCalculation: (left, right, result, swapped) => {
8745
- if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
8746
- const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
8747
- if (errorPath) errorPaths.push(errorPath);
8748
- }
8749
- });
8750
- Object.freeze(context);
8751
- const comparisonExpression = context.calculate(schema1, schema2);
8752
- return {
8753
- errorPath: errorPaths[0],
8754
- expression: comparisonExpression
8755
- };
8756
- }
8757
- var describer = () => (schema) => {
8758
- let description;
8759
- switch (getKind(schema)) {
8760
- case CompiledKind.Not:
8761
- description = {
8762
- kind: ExpressionKind.Not,
8763
- expression: schema.not
8764
- };
8765
- break;
8766
- case CompiledKind.Combination:
8767
- if ("allOf" in schema) description = {
8768
- kind: ExpressionKind.AllOf,
8769
- expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
8770
- };
8771
- else if ("anyOf" in schema) description = {
8772
- kind: ExpressionKind.AnyOf,
8773
- expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
8774
- };
8775
- else if ("oneOf" in schema) description = {
8776
- kind: ExpressionKind.OneOf,
8777
- expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
8778
- };
8779
- else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
8780
- break;
8781
- default: description = { kind: ExpressionKind.Leaf };
8782
- }
8783
- return description;
8831
+ var definition = {
8832
+ configInputs: ports$1.inputs,
8833
+ definitionVersion: literal(2),
8834
+ description: text,
8835
+ displayName: text,
8836
+ key: text,
8837
+ name: text,
8838
+ outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
8839
+ provider: text
8784
8840
  };
8785
- var calculator = (extendsContext, context) => (schema1, schema2) => {
8786
- const kind1 = getKind(schema1);
8787
- const kind2 = getKind(schema2);
8788
- if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
8789
- switch (kind1) {
8790
- case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
8791
- case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
8792
- }
8793
- switch (kind2) {
8794
- case CompiledKind.Any: return ExpressionContainedBy;
8795
- case CompiledKind.Never: return ExpressionContaining;
8796
- }
8797
- if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) return calculateEnumAndEnum(context, schema1, schema2);
8798
- if (kind1 === CompiledKind.EnumOrConst) return calculateEnumAndSchema(schema1, schema2);
8799
- if (kind2 === CompiledKind.EnumOrConst) return swap(calculateEnumAndSchema(schema2, schema1));
8800
- if (kind1 !== kind2) return ExpressionRejection;
8801
- switch (kind1) {
8802
- case CompiledKind.Null: return ExpressionEquals;
8803
- case CompiledKind.Numeric: return calculateNumeric(schema1, schema2);
8804
- case CompiledKind.String: return calculateString(schema1, schema2);
8805
- case CompiledKind.Boolean: return ExpressionEquals;
8806
- case CompiledKind.Object: return calculateObject(context, schema1, schema2);
8807
- case CompiledKind.Array: return calculateArray(context, schema1, schema2);
8808
- default: throw new Error(`invalid kind ${kind1}`);
8809
- }
8841
+ var endpoint = object({
8842
+ body: object({
8843
+ allowArray: boolean(),
8844
+ allowEmpty: boolean(),
8845
+ formats: array(_enum([
8846
+ "form",
8847
+ "json",
8848
+ "multipart",
8849
+ "text"
8850
+ ]))
8851
+ }),
8852
+ methods: array(_enum([
8853
+ "DELETE",
8854
+ "GET",
8855
+ "HEAD",
8856
+ "PATCH",
8857
+ "POST",
8858
+ "PUT"
8859
+ ])),
8860
+ successStatus: number()
8861
+ });
8862
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
8863
+ var trigger = {
8864
+ name: text,
8865
+ description: text.optional(),
8866
+ icon: text.optional()
8810
8867
  };
8811
- function rejectInSchemaList(schemaList, kind) {
8812
- return schemaList.filter((e) => getKind(e) !== kind);
8813
- }
8814
- function isDecisiveMismatch(result) {
8815
- return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result));
8816
- }
8817
- function findMismatchPath(source, target) {
8818
- const targetPath = getPath(target);
8819
- if (!targetPath) return void 0;
8820
- const sourceKind = getKind(source);
8821
- const targetKind = getKind(target);
8822
- if (sourceKind !== targetKind) return [...targetPath, "type"];
8823
- const sourceSchema = source;
8824
- const targetSchema = target;
8825
- switch (targetKind) {
8826
- case CompiledKind.String:
8827
- if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
8828
- if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
8829
- if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
8830
- if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
8831
- break;
8832
- case CompiledKind.Numeric:
8833
- if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
8834
- if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
8835
- if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
8836
- break;
8837
- case CompiledKind.Array:
8838
- if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
8839
- if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
8840
- if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
8841
- break;
8842
- case CompiledKind.Object: {
8843
- const sourceRequired = new Set(sourceSchema.required ?? []);
8844
- if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
8845
- if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
8846
- if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
8847
- break;
8848
- }
8849
- case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
8850
- }
8851
- return targetPath;
8852
- }
8853
- //#endregion
8854
- //#region src/json-schema-subset/extends/extendsContext.ts
8855
- var ExtendsContext = class ExtendsContext {
8856
- constructor(extendsSchemaClasses = []) {
8857
- this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
8858
- }
8859
- tryCompiledExtendsSchema(target, payload) {
8860
- for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
8861
- return null;
8862
- }
8863
- isExtendsSchema(target) {
8864
- for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
8865
- return false;
8866
- }
8867
- calculate(schema1, schema2) {
8868
- const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
8869
- let expressionResult = 0;
8870
- let result;
8871
- if (shouldSwap) result = schema2.compare(schema1);
8872
- else result = schema1.compare(schema2);
8873
- for (let expression of result) {
8874
- if (shouldSwap) expression = ExtendsContext.swap(expression);
8875
- expressionResult |= toExpression(expression);
8876
- }
8877
- return expressionResult;
8878
- }
8879
- equals(schema1, schema2) {
8880
- if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
8881
- else return schema1.equals(schema2);
8882
- }
8883
- findMatchedClass(schema1, schema2) {
8884
- for (const schemaClass of this.extendsSchemaClasses) {
8885
- if (schema1 instanceof schemaClass) return schemaClass;
8886
- if (schema2 instanceof schemaClass) return schemaClass;
8887
- }
8888
- throw new Error("Invalid schema");
8889
- }
8890
- static swap(expression) {
8891
- switch (expression) {
8892
- case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
8893
- case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
8894
- default: return expression;
8895
- }
8896
- }
8868
+ var base = {
8869
+ maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
8870
+ inputs,
8871
+ name: text.optional(),
8872
+ description: text.optional(),
8873
+ icon: text.optional(),
8874
+ timeoutMs: number().optional()
8897
8875
  };
8898
- //#endregion
8899
- //#region src/json-schema-subset/preprocessing.ts
8900
- function preprocessSchema(schema, compile, printWarnLog = false) {
8901
- const schemaResult = compile(schema);
8902
- if (Array.isArray(schemaResult)) {
8903
- const errorItems = [];
8904
- collectWithPathPrefix(errorItems, schemaResult, "$");
8905
- throw new SchemaError(errorItems);
8906
- }
8907
- const { schema: compiledSchema, warns } = schemaResult;
8908
- if (printWarnLog && warns.length > 0) {
8909
- console.warn(`found ${warns.length} warns after compile schema`);
8910
- for (const warn of warns) console.warn(stringifySchemaError(warn));
8911
- }
8912
- return compiledSchema;
8913
- }
8914
- function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
8915
- const schemaResult1 = compile(schema1);
8916
- const schemaResult2 = compile(schema2);
8917
- if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
8918
- const errorItems = [];
8919
- if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
8920
- if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
8921
- throw new SchemaError(errorItems);
8922
- }
8923
- const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
8924
- const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
8925
- if (printWarnLog) {
8926
- if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
8927
- for (const warn of superWarns) console.warn(stringifySchemaError(warn));
8928
- if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
8929
- for (const warn of subWarns) console.warn(stringifySchemaError(warn));
8930
- }
8931
- return [compiledSchema1, compiledSchema2];
8932
- }
8933
- function collectWithPathPrefix(errorItems, compiledItems, prefix) {
8934
- for (const compiledItem of compiledItems) {
8935
- const replacedItem = {
8936
- ...compiledItem,
8937
- path: [prefix, ...compiledItem.path]
8938
- };
8939
- errorItems.push(replacedItem);
8940
- }
8941
- }
8942
- //#endregion
8943
- //#region src/json-schema-subset/global.ts
8944
- var SubsetCompareResult = Object.freeze({
8945
- True: 0,
8946
- False: 1,
8947
- Unknown: 2
8876
+ var node = union([
8877
+ object({
8878
+ ...base,
8879
+ inputs: record$3(text, never()),
8880
+ kind: literal("condition"),
8881
+ ...condition
8882
+ }),
8883
+ object({
8884
+ ...base,
8885
+ inputs: unknown().transform(() => ({})).default({}),
8886
+ kind: literal("value"),
8887
+ values: array(input)
8888
+ }),
8889
+ object({
8890
+ ...base,
8891
+ kind: literal("task"),
8892
+ task: union([inline, managed]),
8893
+ additionalInputs: array(input).optional()
8894
+ }),
8895
+ strictObject({
8896
+ ...base,
8897
+ kind: literal("approval"),
8898
+ ...wait
8899
+ }).omit({ timeoutMs: true }),
8900
+ strictObject({
8901
+ ...base,
8902
+ kind: literal("wait"),
8903
+ ...wait
8904
+ }).omit({ timeoutMs: true }),
8905
+ object({
8906
+ ...trigger,
8907
+ kind: literal("manual")
8908
+ }),
8909
+ strictObject({
8910
+ ...trigger,
8911
+ kind: literal("error"),
8912
+ sourceFlowIds: sourceFlowIds.optional()
8913
+ }),
8914
+ object({
8915
+ ...trigger,
8916
+ kind: literal("webhook"),
8917
+ ...webhook
8918
+ }),
8919
+ object({
8920
+ ...trigger,
8921
+ kind: literal("cron"),
8922
+ cronTimes: triggerScheduleSchema
8923
+ }),
8924
+ object({
8925
+ ...trigger,
8926
+ kind: literal("poll"),
8927
+ connectionId: text.min(1).optional(),
8928
+ config: record$3(text, fixedInput),
8929
+ definition: object({
8930
+ ...definition,
8931
+ type: literal("poll")
8932
+ }),
8933
+ pollTimes: triggerScheduleSchema
8934
+ }),
8935
+ object({
8936
+ ...trigger,
8937
+ kind: literal("integration"),
8938
+ connectionId: text.min(1).optional(),
8939
+ config: record$3(text, fixedInput),
8940
+ definition: object({
8941
+ ...definition,
8942
+ type: literal("integration"),
8943
+ endpoint
8944
+ })
8945
+ })
8946
+ ]);
8947
+ /** Configuration schemas shared by the node authoring boundary. */
8948
+ var authoringDefinitionSchemas = {
8949
+ input,
8950
+ port: port$1,
8951
+ ports: ports$1,
8952
+ condition: strictObject(condition),
8953
+ wait: strictObject(wait),
8954
+ webhook: strictObject(webhook),
8955
+ schedule: triggerScheduleSchema,
8956
+ capabilities: array(capability),
8957
+ connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
8958
+ openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
8959
+ decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
8960
+ llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
8961
+ agent: managedFields.shape.executor.options[4].omit({
8962
+ kind: true,
8963
+ notification: true
8964
+ }).strict()
8965
+ };
8966
+ var edge = object({
8967
+ source: text,
8968
+ target: text,
8969
+ sourceHandle: text.optional()
8970
+ });
8971
+ var at = {
8972
+ nodeId: text,
8973
+ target: never().optional()
8974
+ };
8975
+ var graph = object({
8976
+ nodes: record$3(text, node),
8977
+ edges: array(edge).default([])
8978
+ });
8979
+ var binding$1 = object({
8980
+ kind: literal("variable"),
8981
+ target: text
8982
+ });
8983
+ var module = object({
8984
+ name: text,
8985
+ imports: strings$1,
8986
+ source: text
8948
8987
  });
8949
- function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
8950
- const extendsContext = new ExtendsContext(extendsSchemaClasses);
8951
- return Object.freeze({
8952
- compile: (schema, payload, printWarnLog) => {
8953
- const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
8954
- return preprocessSchema(schema, compiler, printWarnLog);
8955
- },
8956
- isSubset: (superSchema, subSchema, printWarnLog = false) => {
8957
- const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
8958
- const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
8959
- const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
8960
- const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
8961
- const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
8962
- if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
8963
- if (!foundTrueExpression && foundFalseExpression) return {
8964
- errorPath,
8965
- result: SubsetCompareResult.False
8966
- };
8967
- return { result: SubsetCompareResult.Unknown };
8968
- }
8969
- });
8970
- }
8971
- //#endregion
8972
- //#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
8973
- var isString = (x) => typeof x === "string";
8974
- var isArray = Array.isArray;
8975
- var isObject = (x) => x !== null && typeof x === "object";
8976
- var isPlainObject = (x) => isObject(x) && !isArray(x);
8977
- var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
8978
- //#endregion
8979
- //#region src/flow/common/schemaComparer.ts
8980
- function isStringLikeSchema(value) {
8981
- return toPlainObject(value)?.type === "string";
8988
+ var document = preprocess(rejectRetiredDefinitions, object({
8989
+ bindings: record$3(text, binding$1),
8990
+ graph
8991
+ }));
8992
+ var revision = object({
8993
+ modelVersion: union([
8994
+ literal(2),
8995
+ literal(4),
8996
+ literal(5),
8997
+ literal(6)
8998
+ ]),
8999
+ document,
9000
+ modules: record$3(text, module)
9001
+ });
9002
+ revision.extend({
9003
+ kind: literal("open-flow-flow-revision"),
9004
+ version: literal(1)
9005
+ });
9006
+ function rejectRetiredDefinitions(value) {
9007
+ const candidate = record$2(value);
9008
+ if (candidate.tasks !== void 0 && (candidate.tasks === null || typeof candidate.tasks !== "object" || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)) throw new TypeError("Independent Task definitions are no longer supported.");
9009
+ if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
9010
+ const subflows = candidate.subflows;
9011
+ if (subflows !== void 0 && (subflows === null || typeof subflows !== "object" || Array.isArray(subflows) || Object.keys(subflows).length > 0)) throw new TypeError("Subflows are no longer supported.");
9012
+ if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
9013
+ return value;
8982
9014
  }
8983
- function assertSchemaCompareContext(value) {
8984
- const context = toPlainObject(value);
8985
- const error = toPlainObject(context?.error);
8986
- if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
9015
+ function record$2(value) {
9016
+ return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
8987
9017
  }
8988
- function parseSchemaCompareContext(value) {
8989
- if (value == null) return { error: {} };
8990
- assertSchemaCompareContext(value);
8991
- return value;
9018
+ function decodeRevisionContent(value) {
9019
+ checkJsonDepth(value);
9020
+ const content = revision.parse(value);
9021
+ checkModelVersion(content);
9022
+ assertOpenApiAuthBindings(content.document);
9023
+ return content;
8992
9024
  }
8993
- var SpecialSchema = class SpecialSchema {
8994
- static setError(fromSchema, toSchema, message) {
8995
- if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
8996
- else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
8997
- }
8998
- constructor(id, value, context) {
8999
- this.id = id;
9000
- this.value = value;
9001
- this.context = parseSchemaCompareContext(context);
9002
- }
9003
- compare(other) {
9004
- if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
9005
- return this.compareImpl(other);
9006
- }
9007
- };
9008
- var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
9009
- static isMatch(value) {
9010
- const enumValues = toPlainObject(value)?.enum;
9011
- return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
9012
- }
9013
- constructor(id, value, context) {
9014
- if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
9015
- super(id, value, context);
9016
- }
9017
- compareImpl(other) {
9018
- if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
9019
- if (other instanceof SingleSelectSchema) {
9020
- const f = new Set(this.value.enum);
9021
- let result = ExpressionSingleResult.Equals;
9022
- for (const v of other.value.enum) {
9023
- if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
9024
- f.delete(v);
9025
- }
9026
- if (f.size === 0) return [result];
9027
- if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
9028
- return [ExpressionSingleResult.Intersection];
9029
- }
9030
- return [ExpressionSingleResult.Rejection];
9031
- }
9032
- equals(other) {
9033
- if (other instanceof SingleSelectSchema) {
9034
- const f = new Set(this.value.enum);
9035
- for (const v of other.value.enum) {
9036
- if (!f.has(v)) return false;
9037
- f.delete(v);
9038
- }
9039
- return f.size === 0;
9040
- }
9041
- return false;
9042
- }
9043
- };
9044
- var BinarySchema = class BinarySchema extends SpecialSchema {
9045
- static isMatch(value) {
9046
- return toPlainObject(value)?.contentMediaType === "oomol/bin";
9047
- }
9048
- constructor(id, value, context) {
9049
- if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
9050
- super(id, value, context);
9051
- }
9052
- compareImpl(other) {
9053
- if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
9054
- else {
9055
- SpecialSchema.setError(this, other, "edgeError.binDiffType");
9056
- return [ExpressionSingleResult.Rejection];
9057
- }
9058
- }
9059
- equals(other) {
9060
- return other instanceof BinarySchema;
9061
- }
9062
- };
9063
- var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
9064
- static isMatch(value) {
9065
- return toPlainObject(value)?.contentMediaType === "oomol/artifact";
9066
- }
9067
- constructor(id, value, context) {
9068
- if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
9069
- super(id, value, context);
9070
- }
9071
- compareImpl(other) {
9072
- if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
9073
- SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
9074
- return [ExpressionSingleResult.Rejection];
9075
- }
9076
- equals(other) {
9077
- return other instanceof ArtifactSchema;
9025
+ var shapes = {
9026
+ "graph.trigger.sources.set": {
9027
+ nodeId: text,
9028
+ before: sourceFlowIds.optional(),
9029
+ value: sourceFlowIds.optional()
9030
+ },
9031
+ "binding.create": {
9032
+ bindingId: text,
9033
+ binding: binding$1
9034
+ },
9035
+ "binding.delete": { bindingId: text },
9036
+ "binding.target.set": {
9037
+ bindingId: text,
9038
+ before: text,
9039
+ value: text
9040
+ },
9041
+ "graph.edge.connect": {
9042
+ edge,
9043
+ target: never().optional()
9044
+ },
9045
+ "graph.edge.disconnect": {
9046
+ edge,
9047
+ target: never().optional()
9048
+ },
9049
+ "graph.node.create": {
9050
+ ...at,
9051
+ node
9052
+ },
9053
+ "graph.node.replace": {
9054
+ ...at,
9055
+ before: node,
9056
+ node
9057
+ },
9058
+ "graph.node.delete": at,
9059
+ "graph.node.field.set": union([
9060
+ object({
9061
+ ...at,
9062
+ kind: literal("graph.node.field.set"),
9063
+ field: literal("connectionId"),
9064
+ before: text.min(1).optional(),
9065
+ value: text.min(1).optional()
9066
+ }),
9067
+ object({
9068
+ ...at,
9069
+ kind: literal("graph.node.field.set"),
9070
+ field: _enum([
9071
+ "description",
9072
+ "icon",
9073
+ "name"
9074
+ ]),
9075
+ before: text.optional(),
9076
+ value: text.optional()
9077
+ }),
9078
+ object({
9079
+ ...at,
9080
+ kind: literal("graph.node.field.set"),
9081
+ field: literal("maxExecutions"),
9082
+ before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
9083
+ value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
9084
+ }),
9085
+ object({
9086
+ ...at,
9087
+ kind: literal("graph.node.field.set"),
9088
+ field: literal("timeoutMs"),
9089
+ before: number().optional(),
9090
+ value: number().optional()
9091
+ })
9092
+ ]),
9093
+ "graph.node.input.set": {
9094
+ ...at,
9095
+ handle: text,
9096
+ before: mapping.optional(),
9097
+ value: mapping.optional()
9098
+ },
9099
+ "graph.node.additional-inputs.set": {
9100
+ ...at,
9101
+ before: array(input).optional(),
9102
+ value: array(input).optional()
9103
+ },
9104
+ "graph.node.condition.set": {
9105
+ ...at,
9106
+ before: object(condition),
9107
+ value: object(condition)
9108
+ },
9109
+ "graph.node.values.set": {
9110
+ ...at,
9111
+ before: array(input),
9112
+ value: array(input)
9113
+ },
9114
+ "graph.node.resolution.set": {
9115
+ ...at,
9116
+ before: object(wait),
9117
+ value: object(wait)
9118
+ },
9119
+ "graph.node.webhook.set": {
9120
+ ...at,
9121
+ before: object(webhook),
9122
+ value: object(webhook)
9123
+ },
9124
+ "graph.node.task.ports.set": {
9125
+ ...at,
9126
+ before: object(ports$1),
9127
+ value: object(ports$1)
9128
+ },
9129
+ "graph.node.task.name.set": {
9130
+ ...at,
9131
+ before: text,
9132
+ value: text
9133
+ },
9134
+ "graph.node.task.capabilities.set": {
9135
+ ...at,
9136
+ before: array(capability).optional(),
9137
+ value: array(capability).optional()
9138
+ },
9139
+ "graph.trigger.config.set": {
9140
+ nodeId: text,
9141
+ name: text,
9142
+ before: fixedInput.optional(),
9143
+ value: fixedInput.optional()
9144
+ },
9145
+ "graph.trigger.schedule.set": {
9146
+ nodeId: text,
9147
+ before: triggerScheduleSchema,
9148
+ value: triggerScheduleSchema
9149
+ },
9150
+ "module.create": {
9151
+ moduleId: text,
9152
+ module
9153
+ },
9154
+ "module.delete": { moduleId: text },
9155
+ "module.rename": {
9156
+ moduleId: text,
9157
+ before: text,
9158
+ name: text
9159
+ },
9160
+ "module.source.replace": {
9161
+ moduleId: text,
9162
+ beforeImports: strings$1,
9163
+ beforeSource: text,
9164
+ imports: strings$1,
9165
+ source: text
9166
+ },
9167
+ "graph.node.task.set": {
9168
+ ...at,
9169
+ before: union([inline, managed]),
9170
+ value: union([inline, managed])
9078
9171
  }
9079
9172
  };
9080
- function createSchemaComparer() {
9081
- return makeSubsetCompare({ extendsSchemaClasses: [
9082
- SingleSelectSchema,
9083
- BinarySchema,
9084
- ArtifactSchema
9085
- ] });
9086
- }
9087
- createSchemaComparer();
9088
- //#endregion
9089
- //#region src/decision/common/decision.ts
9090
- var decisionLimits = {
9091
- choice: 255,
9092
- score: 10
9093
- };
9094
- /** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
9095
- function limitDecisionQuestion(question) {
9096
- if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
9097
- if (question.type === "choice") return {
9098
- ...question,
9099
- criteria: question.criteria.slice(0, decisionLimits.choice)
9100
- };
9101
- return {
9102
- ...question,
9103
- criteria: question.criteria.slice(0, decisionLimits.score)
9104
- };
9105
- }
9106
- function limitDecisionQuestions(questions) {
9107
- const limited = questions.map(limitDecisionQuestion);
9108
- return limited.every((question, i) => question === questions[i]) ? questions : limited;
9109
- }
9110
- /** Loading an oversized task also updates its previously generated output schemas. */
9111
- function limitDecisionTask(task) {
9112
- if (task.executor.kind !== "decision") return task;
9113
- const original = task.executor.questions;
9114
- const questions = limitDecisionQuestions(original);
9115
- if (questions === original) return task;
9116
- const outputs = task.outputs.map((port) => {
9117
- if (!("handle" in port)) return port;
9118
- const index = original.findIndex((question) => question.name === port.handle);
9119
- if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
9120
- return {
9121
- ...port,
9122
- jsonSchema: decisionAnswerSchema(questions[index])
9123
- };
9124
- });
9125
- return {
9126
- ...task,
9127
- executor: {
9128
- ...task.executor,
9129
- questions
9130
- },
9131
- outputs
9132
- };
9133
- }
9134
- var probability = {
9135
- type: "number",
9136
- minimum: 0,
9137
- maximum: 1
9138
- };
9139
- function decisionAnswerSchema(question) {
9140
- return answerSchema(limitDecisionQuestion(question));
9141
- }
9142
- function answerSchema(question) {
9143
- const properties = { type: { const: question.type } };
9144
- if (question.type === "noul") properties.noul = probability;
9145
- else {
9146
- const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
9147
- properties.confidence = probability;
9148
- properties.probabilities = {
9149
- type: "object",
9150
- properties: Object.fromEntries(keys.map((key) => [key, probability])),
9151
- required: keys,
9152
- additionalProperties: false
9153
- };
9154
- if (question.type === "choice") properties.choice = {
9155
- type: "string",
9156
- ...keys.length ? { enum: keys } : {}
9157
- };
9158
- else {
9159
- properties.score = {
9160
- type: "number",
9161
- minimum: 0,
9162
- maximum: Math.max(0, keys.length - 1)
9163
- };
9164
- properties.legend = {
9165
- type: "object",
9166
- properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
9167
- required: keys,
9168
- additionalProperties: false
9169
- };
9170
- }
9171
- }
9172
- return {
9173
- type: "object",
9174
- properties,
9175
- required: Object.keys(properties)
9176
- };
9173
+ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
9174
+ kind: literal(kind),
9175
+ ...shape
9176
+ })])).values()])).min(1);
9177
+ function checkModelVersion(content) {
9178
+ if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
9179
+ if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
9177
9180
  }
9178
9181
  //#endregion
9179
9182
  //#region src/control/common/authoringLlm.ts
@@ -9195,7 +9198,7 @@ var authenticationSchema = union([
9195
9198
  in: _enum(["header", "query"])
9196
9199
  })
9197
9200
  ]);
9198
- strictObject({
9201
+ var authoringOpenApiSchema = strictObject({
9199
9202
  sourceUrl: string$1().min(1),
9200
9203
  path: string$1().min(1),
9201
9204
  method: string$1().min(1),
@@ -9292,36 +9295,53 @@ var when = union([
9292
9295
  all,
9293
9296
  strictObject({ any: array(union([expression, all])) })
9294
9297
  ]);
9295
- strictObject({}), strictObject({ sourceFlowIds: array(id$1).optional() }), authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(), strictObject({ schedule: authoringDefinitionSchemas.schedule }), strictObject({
9296
- key: id$1,
9297
- connectionId: id$1.optional(),
9298
- schedule: authoringDefinitionSchemas.schedule
9299
- }), strictObject({
9300
- key: id$1,
9301
- connectionId: id$1.optional()
9302
- }), strictObject({
9303
- inputs: inputFields,
9304
- outputs: outputFields,
9305
- capabilities: authoringDefinitionSchemas.capabilities.optional()
9306
- }), authoringDefinitionSchemas.connector.strict(), authoringDefinitionSchemas.agent.omit({
9307
- prompt: true,
9308
- tools: true
9309
- }).extend({
9310
- inputs: inputFields,
9311
- resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9312
- tools: array(agentTool),
9313
- notification: notification.optional()
9314
- }).strict(), authoringLlmConfiguration.extend({ inputs: inputFields }), authoringDefinitionSchemas.decision, strictObject({
9315
- match: _enum(["first", "all"]),
9316
- branches: array(strictObject({
9317
- name: id$1,
9318
- description: string$1().optional(),
9319
- when
9320
- }))
9321
- }), strictObject({
9322
- values: patch,
9323
- outputs: outputFields
9324
- }), strictObject({ inputs: inputFields }), strictObject({ inputs: inputFields });
9298
+ var authoringConfigurations = {
9299
+ manual: strictObject({}),
9300
+ error: strictObject({ sourceFlowIds: array(id$1).optional() }),
9301
+ webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
9302
+ cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
9303
+ poll: strictObject({
9304
+ key: id$1,
9305
+ connectionId: id$1.optional(),
9306
+ schedule: authoringDefinitionSchemas.schedule
9307
+ }),
9308
+ integration: strictObject({
9309
+ key: id$1,
9310
+ connectionId: id$1.optional()
9311
+ }),
9312
+ code: strictObject({
9313
+ inputs: inputFields,
9314
+ outputs: outputFields,
9315
+ capabilities: authoringDefinitionSchemas.capabilities.optional()
9316
+ }),
9317
+ connector: authoringDefinitionSchemas.connector.strict(),
9318
+ openapi: authoringOpenApiSchema,
9319
+ agent: authoringDefinitionSchemas.agent.omit({
9320
+ prompt: true,
9321
+ tools: true
9322
+ }).extend({
9323
+ inputs: inputFields,
9324
+ resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9325
+ tools: array(agentTool),
9326
+ notification: notification.optional()
9327
+ }).strict(),
9328
+ llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
9329
+ decision: authoringDefinitionSchemas.decision,
9330
+ condition: strictObject({
9331
+ match: _enum(["first", "all"]),
9332
+ branches: array(strictObject({
9333
+ name: id$1,
9334
+ description: string$1().optional(),
9335
+ when
9336
+ }))
9337
+ }),
9338
+ value: strictObject({
9339
+ values: patch,
9340
+ outputs: outputFields
9341
+ }),
9342
+ wait: strictObject({ inputs: inputFields }),
9343
+ approval: strictObject({ inputs: inputFields })
9344
+ };
9325
9345
  var updates = strictObject({
9326
9346
  name: id$1.optional(),
9327
9347
  description: string$1().optional(),
@@ -9501,7 +9521,6 @@ var controlErrorCode = {
9501
9521
  publicationConflict: "publication.conflict",
9502
9522
  publicationNotFound: "publication.not-found",
9503
9523
  publicationUnsupported: "publication.unsupported",
9504
- resourceNotFound: "resource.not-found",
9505
9524
  publishOperationNotFound: "publication.operation-not-found",
9506
9525
  routeNotFound: "route.not-found",
9507
9526
  runConflict: "run.conflict",
@@ -9518,7 +9537,7 @@ var controlErrorCode = {
9518
9537
  variableLimitReached: "variable.limit-reached",
9519
9538
  variableNotFound: "variable.not-found"
9520
9539
  };
9521
- controlErrorCode.eventSourceInvalid, controlErrorCode.eventSourceIdentityUnavailable, controlErrorCode.eventSourceNotFound, controlErrorCode.eventSourceConflict, controlErrorCode.authenticationRequired, controlErrorCode.authorizationDenied, controlErrorCode.bindingUnresolved, controlErrorCode.connectorActionNotFound, controlErrorCode.connectorAccessConflict, controlErrorCode.connectorAccessInvalid, controlErrorCode.connectorAccessRequired, controlErrorCode.connectorAccessUnsupported, controlErrorCode.connectorUnconfigured, controlErrorCode.connectorUnavailable, controlErrorCode.connectorConsoleUnconfigured, controlErrorCode.engineUnavailable, controlErrorCode.engineUnsupported, controlErrorCode.flowInvalid, controlErrorCode.flowRepairRequired, controlErrorCode.flowUpgradeRequired, controlErrorCode.flowNotFound, controlErrorCode.flowBusy, controlErrorCode.flowConflict, controlErrorCode.flowPresentationConflict, controlErrorCode.flowRevisionConflict, controlErrorCode.liveConflict, controlErrorCode.liveNotFound, controlErrorCode.pageInvalidCursor, controlErrorCode.publicationConflict, controlErrorCode.publicationNotFound, controlErrorCode.publicationUnsupported, controlErrorCode.resourceNotFound, controlErrorCode.publishOperationNotFound, controlErrorCode.routeNotFound, controlErrorCode.runConflict, controlErrorCode.runEventsExpired, controlErrorCode.runInvalid, controlErrorCode.runNotFound, controlErrorCode.runNotTerminal, controlErrorCode.runOverloaded, controlErrorCode.runWaitNotFound, controlErrorCode.triggerKeyInvalid, controlErrorCode.triggerKeyNotFound, controlErrorCode.triggerNotFound, controlErrorCode.variableInvalid, controlErrorCode.variableLimitReached, controlErrorCode.variableNotFound;
9540
+ controlErrorCode.eventSourceInvalid, controlErrorCode.eventSourceIdentityUnavailable, controlErrorCode.eventSourceNotFound, controlErrorCode.eventSourceConflict, controlErrorCode.authenticationRequired, controlErrorCode.authorizationDenied, controlErrorCode.bindingUnresolved, controlErrorCode.connectorActionNotFound, controlErrorCode.connectorAccessConflict, controlErrorCode.connectorAccessInvalid, controlErrorCode.connectorAccessRequired, controlErrorCode.connectorAccessUnsupported, controlErrorCode.connectorUnconfigured, controlErrorCode.connectorUnavailable, controlErrorCode.connectorConsoleUnconfigured, controlErrorCode.engineUnavailable, controlErrorCode.engineUnsupported, controlErrorCode.flowInvalid, controlErrorCode.flowRepairRequired, controlErrorCode.flowUpgradeRequired, controlErrorCode.flowNotFound, controlErrorCode.flowBusy, controlErrorCode.flowConflict, controlErrorCode.flowPresentationConflict, controlErrorCode.flowRevisionConflict, controlErrorCode.liveConflict, controlErrorCode.liveNotFound, controlErrorCode.pageInvalidCursor, controlErrorCode.publicationConflict, controlErrorCode.publicationNotFound, controlErrorCode.publicationUnsupported, controlErrorCode.publishOperationNotFound, controlErrorCode.routeNotFound, controlErrorCode.runConflict, controlErrorCode.runEventsExpired, controlErrorCode.runInvalid, controlErrorCode.runNotFound, controlErrorCode.runNotTerminal, controlErrorCode.runOverloaded, controlErrorCode.runWaitNotFound, controlErrorCode.triggerKeyInvalid, controlErrorCode.triggerKeyNotFound, controlErrorCode.triggerNotFound, controlErrorCode.variableInvalid, controlErrorCode.variableLimitReached, controlErrorCode.variableNotFound;
9522
9541
  var ApiError = class extends Error {
9523
9542
  constructor(status, code, message, details) {
9524
9543
  super(message);
@@ -9554,19 +9573,155 @@ function exact(value, keys) {
9554
9573
  invalidResponse([missing.length > 0 ? `Missing fields: ${missing.join(", ")}.` : "", unexpected.length > 0 ? `Unexpected fields: ${unexpected.join(", ")}.` : ""].filter(Boolean).join(" "));
9555
9574
  }
9556
9575
  }
9557
- function integer(value) {
9558
- return Number.isSafeInteger(value) ? value : invalidResponse("Expected a safe integer.");
9559
- }
9560
- function jsonValue(value) {
9561
- if (value === null || typeof value == "boolean" || typeof value == "string") return value;
9562
- if (typeof value == "number" && Number.isFinite(value)) return value;
9563
- if (Array.isArray(value)) return value.map(jsonValue);
9576
+ function integer(value) {
9577
+ return Number.isSafeInteger(value) ? value : invalidResponse("Expected a safe integer.");
9578
+ }
9579
+ function jsonValue(value) {
9580
+ if (value === null || typeof value == "boolean" || typeof value == "string") return value;
9581
+ if (typeof value == "number" && Number.isFinite(value)) return value;
9582
+ if (Array.isArray(value)) return value.map(jsonValue);
9583
+ const source = record$1(value);
9584
+ return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item)]));
9585
+ }
9586
+ function optionalString(value) {
9587
+ if (value == null) return;
9588
+ return string(value);
9589
+ }
9590
+ //#endregion
9591
+ //#region src/control/common/publicationDecoders.ts
9592
+ function publication(value) {
9593
+ const source = record$1(value);
9594
+ const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
9595
+ if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
9596
+ const operation = source.operation;
9597
+ const sourcePublicationId = source.sourcePublicationId;
9598
+ if (source.version != 1) return invalidResponse();
9599
+ if (operation != "publish" && operation != "rollback") return invalidResponse();
9600
+ if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
9601
+ return {
9602
+ ...liveEnd == null ? {} : { liveEnd: {
9603
+ enabled: liveEnd.enabled,
9604
+ endedAt: string(liveEnd.endedAt)
9605
+ } },
9606
+ actorId: string(source.actorId),
9607
+ closureDigest: string(source.closureDigest),
9608
+ createdAt: string(source.createdAt),
9609
+ engineContract: string(source.engineContract),
9610
+ flowId: string(source.flowId),
9611
+ modelVersion: integer(source.modelVersion),
9612
+ operation,
9613
+ publicationId: string(source.publicationId),
9614
+ sharedAccessDigest: string(source.sharedAccessDigest),
9615
+ revisionDigest: string(source.revisionDigest),
9616
+ revisionId: string(source.revisionId),
9617
+ ...sourcePublicationId == null ? {} : { sourcePublicationId },
9618
+ version: 1
9619
+ };
9620
+ }
9621
+ function publishOperation(value) {
9622
+ const source = record$1(value);
9623
+ const status = source.status;
9624
+ const common = {
9625
+ createdAt: string(source.createdAt),
9626
+ flowId: string(source.flowId),
9627
+ operationId: string(source.operationId),
9628
+ revisionId: string(source.revisionId),
9629
+ updatedAt: string(source.updatedAt),
9630
+ version: 1
9631
+ };
9632
+ if (source.version != 1) return invalidResponse();
9633
+ switch (status) {
9634
+ case "pending":
9635
+ exact(source, [
9636
+ "createdAt",
9637
+ "flowId",
9638
+ "operationId",
9639
+ "revisionId",
9640
+ "status",
9641
+ "updatedAt",
9642
+ "version"
9643
+ ]);
9644
+ return {
9645
+ ...common,
9646
+ status
9647
+ };
9648
+ case "succeeded":
9649
+ exact(source, [
9650
+ "createdAt",
9651
+ "flowId",
9652
+ "operationId",
9653
+ "publicationId",
9654
+ "revisionId",
9655
+ "status",
9656
+ "updatedAt",
9657
+ "version"
9658
+ ]);
9659
+ return {
9660
+ ...common,
9661
+ publicationId: string(source.publicationId),
9662
+ status
9663
+ };
9664
+ case "failed": {
9665
+ exact(source, [
9666
+ "createdAt",
9667
+ "flowId",
9668
+ "issue",
9669
+ "operationId",
9670
+ "revisionId",
9671
+ "status",
9672
+ "updatedAt",
9673
+ "version"
9674
+ ]);
9675
+ const issue = record$1(source.issue);
9676
+ const nodeId = issue.nodeId;
9677
+ exact(issue, [
9678
+ "code",
9679
+ "message",
9680
+ ...nodeId == null ? [] : ["nodeId"]
9681
+ ]);
9682
+ return {
9683
+ ...common,
9684
+ issue: {
9685
+ code: string(issue.code),
9686
+ message: string(issue.message),
9687
+ ...nodeId == null ? {} : { nodeId: string(nodeId) }
9688
+ },
9689
+ status
9690
+ };
9691
+ }
9692
+ default: return invalidResponse();
9693
+ }
9694
+ }
9695
+ function live(value) {
9564
9696
  const source = record$1(value);
9565
- return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item)]));
9697
+ const status = source.status;
9698
+ const candidate = source.publication;
9699
+ if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
9700
+ if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
9701
+ if (status == "not-published" && candidate !== null) return invalidResponse();
9702
+ if (status != "not-published" && candidate === null) return invalidResponse();
9703
+ return {
9704
+ flowId: string(source.flowId),
9705
+ hasUnpublishedChanges: source.hasUnpublishedChanges,
9706
+ publication: candidate === null ? null : publication(candidate),
9707
+ revision: integer(source.revision),
9708
+ status,
9709
+ version: 1
9710
+ };
9566
9711
  }
9567
- function optionalString(value) {
9568
- if (value == null) return;
9569
- return string(value);
9712
+ function publicationPage(value) {
9713
+ const source = record$1(value);
9714
+ const nextCursor = source.nextCursor;
9715
+ const total = source.total;
9716
+ if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
9717
+ if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
9718
+ if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
9719
+ return {
9720
+ ...nextCursor == null ? {} : { nextCursor },
9721
+ publications: source.publications.map(publication),
9722
+ ...total == null ? {} : { total },
9723
+ version: 1
9724
+ };
9570
9725
  }
9571
9726
  //#endregion
9572
9727
  //#region src/trigger/common/configSchema.ts
@@ -9751,54 +9906,99 @@ function pollTriggerTestResult(value) {
9751
9906
  };
9752
9907
  }
9753
9908
  //#endregion
9754
- //#region src/control/common/publicationResources.ts
9755
- function context(source) {
9756
- if (source.version != 1 || source.status != "live" && source.status != "historical") return invalidResponse();
9757
- if (source.status == "live" ? typeof source.enabled != "boolean" : source.enabled !== void 0) return invalidResponse();
9758
- return {
9759
- flowId: string(source.flowId),
9760
- publicationId: string(source.publicationId),
9761
- revisionId: string(source.revisionId),
9762
- status: source.status,
9763
- ...source.enabled == null ? {} : { enabled: source.enabled },
9764
- version: 1
9765
- };
9766
- }
9767
- function resource(value, scope) {
9768
- const source = record$1(value);
9769
- const type = source.type;
9770
- if (source.kind != "trigger" || type != "webhook" && type != "cron" && type != "poll" && type != "integration" && type != "error") return invalidResponse();
9771
- if (source.description != null && typeof source.description != "string") return invalidResponse();
9772
- const resourceId = string(source.resourceId);
9773
- const runtime = source.runtime == null ? void 0 : triggerBinding(source.runtime);
9774
- if (runtime != null && (scope.status != "live" || runtime.flowId != scope.flowId || runtime.currentPublicationId != scope.publicationId || runtime.currentRevisionId != scope.revisionId || runtime.triggerNodeId != resourceId || runtime.kind != type)) return invalidResponse();
9775
- return {
9776
- resourceId,
9777
- kind: "trigger",
9778
- type,
9779
- name: string(source.name),
9780
- ...source.description == null ? {} : { description: source.description },
9781
- config: jsonValue(source.config),
9782
- inputs: jsonValue(source.inputs),
9783
- ...runtime == null ? {} : { runtime }
9784
- };
9785
- }
9786
- function decodePublicationResources(value) {
9909
+ //#region src/control/common/liveDetails.ts
9910
+ var metadata = {
9911
+ nodeId: string$1().min(1),
9912
+ name: string$1(),
9913
+ description: string$1().optional()
9914
+ };
9915
+ var binding = unknown().transform(triggerBinding);
9916
+ var provider = {
9917
+ provider: string$1().min(1),
9918
+ inputs: record$3(string$1(), discriminatedUnion("kind", [strictObject({
9919
+ kind: literal("value"),
9920
+ value: json$4()
9921
+ }), strictObject({ kind: literal("unset") })]))
9922
+ };
9923
+ var entrySchema = discriminatedUnion("type", [
9924
+ strictObject({
9925
+ ...metadata,
9926
+ type: literal("manual"),
9927
+ config: authoringConfigurations.manual
9928
+ }),
9929
+ strictObject({
9930
+ ...metadata,
9931
+ type: literal("webhook"),
9932
+ config: authoringConfigurations.webhook,
9933
+ binding
9934
+ }),
9935
+ strictObject({
9936
+ ...metadata,
9937
+ type: literal("cron"),
9938
+ config: authoringConfigurations.cron,
9939
+ binding
9940
+ }),
9941
+ strictObject({
9942
+ ...metadata,
9943
+ type: literal("error"),
9944
+ config: authoringConfigurations.error,
9945
+ binding
9946
+ }),
9947
+ strictObject({
9948
+ ...metadata,
9949
+ ...provider,
9950
+ type: literal("poll"),
9951
+ config: authoringConfigurations.poll,
9952
+ binding
9953
+ }),
9954
+ strictObject({
9955
+ ...metadata,
9956
+ ...provider,
9957
+ type: literal("integration"),
9958
+ config: authoringConfigurations.integration,
9959
+ binding
9960
+ })
9961
+ ]);
9962
+ function decodeLiveDetails(value) {
9787
9963
  const source = record$1(value);
9788
- const scope = context(source);
9789
- if (!Array.isArray(source.resources)) return invalidResponse();
9964
+ const flowId = string(source.flowId);
9965
+ if (source.version != 1 || !Array.isArray(source.entries)) return invalidResponse();
9966
+ if (source.publication === null) {
9967
+ if (source.status != "not-published" || source.entries.length != 0 || Object.hasOwn(source, "enabled")) return invalidResponse();
9968
+ return {
9969
+ flowId,
9970
+ publication: null,
9971
+ status: "not-published",
9972
+ entries: [],
9973
+ version: 1
9974
+ };
9975
+ }
9976
+ const current = publication(source.publication);
9977
+ const status = source.status;
9978
+ if (current.flowId != flowId || typeof source.enabled != "boolean") return invalidResponse();
9979
+ if (status != "runnable" && status != "suspended") return invalidResponse();
9980
+ if (!source.enabled && source.status == "runnable") return invalidResponse();
9790
9981
  return {
9791
- ...scope,
9792
- resources: source.resources.map((item) => resource(item, scope))
9982
+ flowId,
9983
+ publication: current,
9984
+ status,
9985
+ enabled: source.enabled,
9986
+ entries: decodeEntries(source.entries, current),
9987
+ version: 1
9793
9988
  };
9794
9989
  }
9795
- function decodePublicationResource(value) {
9796
- const source = record$1(value);
9797
- const scope = context(source);
9798
- return {
9799
- ...scope,
9800
- resource: resource(source.resource, scope)
9801
- };
9990
+ /** Both producers and consumers enforce the same published-entry invariants. */
9991
+ function decodeEntries(values, current) {
9992
+ const parsed = array(entrySchema).safeParse(values);
9993
+ if (!parsed.success) return invalidResponse();
9994
+ const ids = /* @__PURE__ */ new Set();
9995
+ for (const entry of parsed.data) {
9996
+ if (ids.has(entry.nodeId)) return invalidResponse();
9997
+ ids.add(entry.nodeId);
9998
+ if (entry.type != "manual" && (entry.binding.flowId != current.flowId || entry.binding.triggerNodeId != entry.nodeId || entry.binding.kind != entry.type || entry.binding.currentPublicationId != current.publicationId || entry.binding.currentRevisionId != current.revisionId)) return invalidResponse();
9999
+ if (entry.type == "webhook" && (!entry.binding.endpointUrl || !webhookSupportsBody(entry.config.method) && Object.keys(entry.config.body).length > 0)) return invalidResponse();
10000
+ }
10001
+ return parsed.data;
9802
10002
  }
9803
10003
  //#endregion
9804
10004
  //#region src/control/common/providerIconSprite.ts
@@ -10633,142 +10833,6 @@ function variableReferences(input) {
10633
10833
  };
10634
10834
  }
10635
10835
  //#endregion
10636
- //#region src/control/common/publicationDecoders.ts
10637
- function publication(value) {
10638
- const source = record$1(value);
10639
- const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
10640
- if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
10641
- const operation = source.operation;
10642
- const sourcePublicationId = source.sourcePublicationId;
10643
- if (source.version != 1) return invalidResponse();
10644
- if (operation != "publish" && operation != "rollback") return invalidResponse();
10645
- if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
10646
- return {
10647
- ...liveEnd == null ? {} : { liveEnd: {
10648
- enabled: liveEnd.enabled,
10649
- endedAt: string(liveEnd.endedAt)
10650
- } },
10651
- actorId: string(source.actorId),
10652
- closureDigest: string(source.closureDigest),
10653
- createdAt: string(source.createdAt),
10654
- engineContract: string(source.engineContract),
10655
- flowId: string(source.flowId),
10656
- modelVersion: integer(source.modelVersion),
10657
- operation,
10658
- publicationId: string(source.publicationId),
10659
- sharedAccessDigest: string(source.sharedAccessDigest),
10660
- revisionDigest: string(source.revisionDigest),
10661
- revisionId: string(source.revisionId),
10662
- ...sourcePublicationId == null ? {} : { sourcePublicationId },
10663
- version: 1
10664
- };
10665
- }
10666
- function publishOperation(value) {
10667
- const source = record$1(value);
10668
- const status = source.status;
10669
- const common = {
10670
- createdAt: string(source.createdAt),
10671
- flowId: string(source.flowId),
10672
- operationId: string(source.operationId),
10673
- revisionId: string(source.revisionId),
10674
- updatedAt: string(source.updatedAt),
10675
- version: 1
10676
- };
10677
- if (source.version != 1) return invalidResponse();
10678
- switch (status) {
10679
- case "pending":
10680
- exact(source, [
10681
- "createdAt",
10682
- "flowId",
10683
- "operationId",
10684
- "revisionId",
10685
- "status",
10686
- "updatedAt",
10687
- "version"
10688
- ]);
10689
- return {
10690
- ...common,
10691
- status
10692
- };
10693
- case "succeeded":
10694
- exact(source, [
10695
- "createdAt",
10696
- "flowId",
10697
- "operationId",
10698
- "publicationId",
10699
- "revisionId",
10700
- "status",
10701
- "updatedAt",
10702
- "version"
10703
- ]);
10704
- return {
10705
- ...common,
10706
- publicationId: string(source.publicationId),
10707
- status
10708
- };
10709
- case "failed": {
10710
- exact(source, [
10711
- "createdAt",
10712
- "flowId",
10713
- "issue",
10714
- "operationId",
10715
- "revisionId",
10716
- "status",
10717
- "updatedAt",
10718
- "version"
10719
- ]);
10720
- const issue = record$1(source.issue);
10721
- const nodeId = issue.nodeId;
10722
- exact(issue, [
10723
- "code",
10724
- "message",
10725
- ...nodeId == null ? [] : ["nodeId"]
10726
- ]);
10727
- return {
10728
- ...common,
10729
- issue: {
10730
- code: string(issue.code),
10731
- message: string(issue.message),
10732
- ...nodeId == null ? {} : { nodeId: string(nodeId) }
10733
- },
10734
- status
10735
- };
10736
- }
10737
- default: return invalidResponse();
10738
- }
10739
- }
10740
- function live(value) {
10741
- const source = record$1(value);
10742
- const status = source.status;
10743
- const candidate = source.publication;
10744
- if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
10745
- if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
10746
- if (status == "not-published" && candidate !== null) return invalidResponse();
10747
- if (status != "not-published" && candidate === null) return invalidResponse();
10748
- return {
10749
- flowId: string(source.flowId),
10750
- hasUnpublishedChanges: source.hasUnpublishedChanges,
10751
- publication: candidate === null ? null : publication(candidate),
10752
- revision: integer(source.revision),
10753
- status,
10754
- version: 1
10755
- };
10756
- }
10757
- function publicationPage(value) {
10758
- const source = record$1(value);
10759
- const nextCursor = source.nextCursor;
10760
- const total = source.total;
10761
- if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
10762
- if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
10763
- if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
10764
- return {
10765
- ...nextCursor == null ? {} : { nextCursor },
10766
- publications: source.publications.map(publication),
10767
- ...total == null ? {} : { total },
10768
- version: 1
10769
- };
10770
- }
10771
- //#endregion
10772
10836
  //#region src/control/common/revisionDecoders.ts
10773
10837
  function revisionMetadata(value) {
10774
10838
  const source = record$1(value);
@@ -11707,21 +11771,14 @@ var ControlClient = class {
11707
11771
  method: "POST"
11708
11772
  }));
11709
11773
  }
11774
+ async getLiveDetails(flowId, signal) {
11775
+ const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }));
11776
+ if (details.flowId != flowId) return invalidResponse();
11777
+ return details;
11778
+ }
11710
11779
  async getLive(flowId, signal) {
11711
11780
  return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }));
11712
11781
  }
11713
- async listPublicationResources(flowId, publicationId) {
11714
- const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
11715
- const result = decodePublicationResources(await this.request(`/v1/flows/${segment(flowId)}/resources${query}`));
11716
- if (result.flowId != flowId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
11717
- return result;
11718
- }
11719
- async getPublicationResource(flowId, resourceId, publicationId) {
11720
- const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
11721
- const result = decodePublicationResource(await this.request(`/v1/flows/${segment(flowId)}/resources/${segment(resourceId)}${query}`));
11722
- if (result.flowId != flowId || result.resource.resourceId != resourceId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
11723
- return result;
11724
- }
11725
11782
  async listPublications(flowId, options = {}, signal) {
11726
11783
  const parameters = new URLSearchParams();
11727
11784
  if (options.cursor != null) parameters.set("cursor", options.cursor);
@@ -13007,12 +13064,20 @@ var triggerControlApiConformanceCases = [{
13007
13064
  equal(binding.currentPublicationId, publicationId, "Trigger Publication");
13008
13065
  equal(binding.operatorState, void 0, "No individual Trigger control state");
13009
13066
  }
13067
+ const online = await client(harness).getLiveDetails(flowId);
13068
+ equal(online.publication?.publicationId, publicationId, "Online Publication");
13069
+ equal(online.entries.map((entry) => entry.type), ["cron", "webhook"], "Online entries");
13070
+ const onlineWebhook = online.entries.find((entry) => entry.type == "webhook");
13071
+ if (onlineWebhook?.type != "webhook") fail("Missing online Webhook.");
13072
+ equal(onlineWebhook.config.method, "POST", "Online request method");
13073
+ equal(onlineWebhook.config.body, {}, "Online request fields");
13010
13074
  const webhookPath = `${base}/webhook`;
13011
13075
  const endpointUrl = requiredString(record((await json(await request(harness, webhookPath), 200, "Read Webhook")).binding, "Webhook").endpointUrl, "Webhook endpoint");
13012
13076
  for (const action of ["pause", "resume"]) equal((await request(harness, `${webhookPath}/${action}`, {
13013
13077
  body: JSON.stringify({ version: 1 }),
13014
13078
  method: "POST"
13015
13079
  })).status, 404, "Individual Trigger control is unavailable");
13080
+ equal(onlineWebhook.binding.endpointUrl, endpointUrl, "Online endpoint shares binding authority");
13016
13081
  const enable = (enabled) => request(harness, `/v1/flows/${flowId}/enabled`, {
13017
13082
  method: "PUT",
13018
13083
  body: JSON.stringify({