@oomol-lab/open-flow 0.1.0-beta.90 → 0.1.0-beta.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/browser/{FlowCanvas-C4iuvVKB.js → FlowCanvas-CZEphIhX.js} +169 -2324
  2. package/dist/browser/{createResourceDialog-BstGO0m4.js → createResourceDialog-CJbZa2gA.js} +2 -2
  3. package/dist/browser/{dialog-Bi-MVTGj.js → dialog-E1WkapJU.js} +10 -2
  4. package/dist/browser/{exportPng-DMsB9ku_.js → exportPng-c4or5th8.js} +2 -2
  5. package/dist/browser/{flowChanges-SKYJBr6X.js → flowChanges-DsLZdENA.js} +20 -37
  6. package/dist/browser/{flowWorkspace-4UHRaHcz.js → flowWorkspace-CxLQWUdj.js} +54 -19
  7. package/dist/browser/{markdownContent-B75ojl0E.js → markdownContent-BsdTdwBU.js} +1 -1
  8. package/dist/browser/preview.js +231 -68
  9. package/dist/browser/workbench.js +6 -6
  10. package/dist/browser/{workbenchSelect-CHOeceKA.js → workbenchSelect-BfQfMWuY.js} +1 -1
  11. package/dist/browser/{wrapLayout-DU5HG1qH.js → wrapLayout-ZOG4AikN.js} +2493 -200
  12. package/dist/command/index.js +58 -55
  13. package/dist/common/control-api-conformance.js +896 -8
  14. package/dist/common/control-api.js +896 -8
  15. package/dist/common/control-requests.js +17 -6
  16. package/dist/common/decision.js +10 -2
  17. package/dist/common/flow-authoring.js +896 -8
  18. package/dist/common/flow-change.js +896 -8
  19. package/dist/common/flow-encoding.js +896 -8
  20. package/dist/common/flow-semantics.js +10 -2
  21. package/dist/common/integration-trigger.js +10 -2
  22. package/dist/common/licenses.md +2 -0
  23. package/dist/common/mcp.js +896 -8
  24. package/dist/common/openapi.js +10 -2
  25. package/dist/common/poll-trigger.js +10 -2
  26. package/dist/common/provider-triggers.js +1 -1
  27. package/dist/common/scheduler.js +10 -2
  28. package/dist/common/webhook-trigger.js +890 -2
  29. package/dist/common/workflow.js +14 -3
  30. package/dist/render/browser/runtime.js +966 -59
  31. package/dist/render/node/index.js +792 -4
  32. package/package.json +1 -1
  33. package/src/control/common/authoringTools.ts +4 -2
  34. package/src/flow/common/schemaComparer.ts +12 -2
  35. package/src/json-schema-subset/checker/equals.ts +3 -0
  36. package/src/trigger/providers/catalog.generated.json +9 -1
  37. package/src/workflow/common/workflow.ts +4 -3
@@ -150,6 +150,886 @@ function encodeWebhookBody(value) {
150
150
  };
151
151
  }
152
152
  //#endregion
153
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
154
+ function deepCompareStrict(a, b) {
155
+ const typeofa = typeof a;
156
+ if (typeofa !== typeof b) return false;
157
+ if (Array.isArray(a)) {
158
+ if (!Array.isArray(b)) return false;
159
+ const length = a.length;
160
+ if (length !== b.length) return false;
161
+ for (let i = 0; i < length; i++) if (!deepCompareStrict(a[i], b[i])) return false;
162
+ return true;
163
+ }
164
+ if (typeofa === "object") {
165
+ if (!a || !b) return a === b;
166
+ const aKeys = Object.keys(a);
167
+ const bKeys = Object.keys(b);
168
+ if (aKeys.length !== bKeys.length) return false;
169
+ for (const k of aKeys) if (!deepCompareStrict(a[k], b[k])) return false;
170
+ return true;
171
+ }
172
+ return a === b;
173
+ }
174
+ //#endregion
175
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/pointer.js
176
+ function encodePointer(p) {
177
+ return encodeURI(escapePointer(p));
178
+ }
179
+ function escapePointer(p) {
180
+ return p.replace(/~/g, "~0").replace(/\//g, "~1");
181
+ }
182
+ //#endregion
183
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/dereference.js
184
+ var schemaArrayKeyword = {
185
+ prefixItems: true,
186
+ items: true,
187
+ allOf: true,
188
+ anyOf: true,
189
+ oneOf: true
190
+ };
191
+ var schemaMapKeyword = {
192
+ $defs: true,
193
+ definitions: true,
194
+ properties: true,
195
+ patternProperties: true,
196
+ dependentSchemas: true
197
+ };
198
+ var ignoredKeyword = {
199
+ id: true,
200
+ $id: true,
201
+ $ref: true,
202
+ $schema: true,
203
+ $anchor: true,
204
+ $vocabulary: true,
205
+ $comment: true,
206
+ default: true,
207
+ enum: true,
208
+ const: true,
209
+ required: true,
210
+ type: true,
211
+ maximum: true,
212
+ minimum: true,
213
+ exclusiveMaximum: true,
214
+ exclusiveMinimum: true,
215
+ multipleOf: true,
216
+ maxLength: true,
217
+ minLength: true,
218
+ pattern: true,
219
+ format: true,
220
+ maxItems: true,
221
+ minItems: true,
222
+ uniqueItems: true,
223
+ maxProperties: true,
224
+ minProperties: true
225
+ };
226
+ var initialBaseURI = typeof self !== "undefined" && self.location && self.location.origin !== "null" ? new URL(self.location.origin + self.location.pathname + location.search) : new URL("https://github.com/cfworker");
227
+ function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
228
+ if (schema && typeof schema === "object" && !Array.isArray(schema)) {
229
+ const id = schema.$id || schema.id;
230
+ if (id) {
231
+ const url = new URL(id, baseURI.href);
232
+ if (url.hash.length > 1) lookup[url.href] = schema;
233
+ else {
234
+ url.hash = "";
235
+ if (basePointer === "") baseURI = url;
236
+ else dereference(schema, lookup, baseURI);
237
+ }
238
+ }
239
+ } else if (schema !== true && schema !== false) return lookup;
240
+ const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
241
+ if (lookup[schemaURI] !== void 0) throw new Error(`Duplicate schema URI "${schemaURI}".`);
242
+ lookup[schemaURI] = schema;
243
+ if (schema === true || schema === false) return lookup;
244
+ if (schema.__absolute_uri__ === void 0) Object.defineProperty(schema, "__absolute_uri__", {
245
+ enumerable: false,
246
+ value: schemaURI
247
+ });
248
+ if (schema.$ref && schema.__absolute_ref__ === void 0) {
249
+ const url = new URL(schema.$ref, baseURI.href);
250
+ url.hash = url.hash;
251
+ Object.defineProperty(schema, "__absolute_ref__", {
252
+ enumerable: false,
253
+ value: url.href
254
+ });
255
+ }
256
+ if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === void 0) {
257
+ const url = new URL(schema.$recursiveRef, baseURI.href);
258
+ url.hash = url.hash;
259
+ Object.defineProperty(schema, "__absolute_recursive_ref__", {
260
+ enumerable: false,
261
+ value: url.href
262
+ });
263
+ }
264
+ if (schema.$anchor) {
265
+ const url = new URL("#" + schema.$anchor, baseURI.href);
266
+ lookup[url.href] = schema;
267
+ }
268
+ for (let key in schema) {
269
+ if (ignoredKeyword[key]) continue;
270
+ const keyBase = `${basePointer}/${encodePointer(key)}`;
271
+ const subSchema = schema[key];
272
+ if (Array.isArray(subSchema)) {
273
+ if (schemaArrayKeyword[key]) {
274
+ const length = subSchema.length;
275
+ for (let i = 0; i < length; i++) dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
276
+ }
277
+ } else if (schemaMapKeyword[key]) for (let subKey in subSchema) dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
278
+ else dereference(subSchema, lookup, baseURI, keyBase);
279
+ }
280
+ return lookup;
281
+ }
282
+ //#endregion
283
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/format.js
284
+ var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
285
+ var DAYS = [
286
+ 0,
287
+ 31,
288
+ 28,
289
+ 31,
290
+ 30,
291
+ 31,
292
+ 30,
293
+ 31,
294
+ 31,
295
+ 30,
296
+ 31,
297
+ 30,
298
+ 31
299
+ ];
300
+ var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
301
+ var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
302
+ var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
303
+ var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
304
+ var URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
305
+ var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
306
+ var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
307
+ var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
308
+ var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
309
+ var EMAIL = (input) => {
310
+ if (input[0] === "\"") return false;
311
+ const [name, host, ...rest] = input.split("@");
312
+ if (!name || !host || rest.length !== 0 || name.length > 64 || host.length > 253) return false;
313
+ if (name[0] === "." || name.endsWith(".") || name.includes("..")) return false;
314
+ if (!/^[a-z0-9.-]+$/i.test(host) || !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name)) return false;
315
+ return host.split(".").every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
316
+ };
317
+ var IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
318
+ var IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
319
+ var DURATION = (input) => input.length > 1 && input.length < 80 && (/^P\d+([.,]\d+)?W$/.test(input) || /^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) && /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input));
320
+ function bind(r) {
321
+ return r.test.bind(r);
322
+ }
323
+ var format = {
324
+ date,
325
+ time: time.bind(void 0, false),
326
+ "date-time": date_time,
327
+ duration: DURATION,
328
+ uri,
329
+ "uri-reference": bind(URIREF),
330
+ "uri-template": bind(URITEMPLATE),
331
+ url: bind(URL_),
332
+ email: EMAIL,
333
+ hostname: bind(HOSTNAME),
334
+ ipv4: bind(IPV4),
335
+ ipv6: bind(IPV6),
336
+ regex,
337
+ uuid: bind(UUID),
338
+ "json-pointer": bind(JSON_POINTER),
339
+ "json-pointer-uri-fragment": bind(JSON_POINTER_URI_FRAGMENT),
340
+ "relative-json-pointer": bind(RELATIVE_JSON_POINTER)
341
+ };
342
+ function isLeapYear(year) {
343
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
344
+ }
345
+ function date(str) {
346
+ const matches = str.match(DATE);
347
+ if (!matches) return false;
348
+ const year = +matches[1];
349
+ const month = +matches[2];
350
+ const day = +matches[3];
351
+ return month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
352
+ }
353
+ function time(full, str) {
354
+ const matches = str.match(TIME);
355
+ if (!matches) return false;
356
+ const hour = +matches[1];
357
+ const minute = +matches[2];
358
+ const second = +matches[3];
359
+ const timeZone = !!matches[5];
360
+ return (hour <= 23 && minute <= 59 && second <= 59 || hour == 23 && minute == 59 && second == 60) && (!full || timeZone);
361
+ }
362
+ var DATE_TIME_SEPARATOR = /t|\s/i;
363
+ function date_time(str) {
364
+ const dateTime = str.split(DATE_TIME_SEPARATOR);
365
+ return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
366
+ }
367
+ var NOT_URI_FRAGMENT = /\/|:/;
368
+ var URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
369
+ function uri(str) {
370
+ return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
371
+ }
372
+ var Z_ANCHOR = /[^\\]\\Z/;
373
+ function regex(str) {
374
+ if (Z_ANCHOR.test(str)) return false;
375
+ try {
376
+ new RegExp(str, "u");
377
+ return true;
378
+ } catch (e) {
379
+ return false;
380
+ }
381
+ }
382
+ //#endregion
383
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js
384
+ function ucs2length(s) {
385
+ let result = 0;
386
+ let length = s.length;
387
+ let index = 0;
388
+ let charCode;
389
+ while (index < length) {
390
+ result++;
391
+ charCode = s.charCodeAt(index++);
392
+ if (charCode >= 55296 && charCode <= 56319 && index < length) {
393
+ charCode = s.charCodeAt(index);
394
+ if ((charCode & 64512) == 56320) index++;
395
+ }
396
+ }
397
+ return result;
398
+ }
399
+ //#endregion
400
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validate.js
401
+ function validate(instance, schema, draft = "2019-09", lookup = dereference(schema), shortCircuit = true, recursiveAnchor = null, instanceLocation = "#", schemaLocation = "#", evaluated = Object.create(null)) {
402
+ if (schema === true) return {
403
+ valid: true,
404
+ errors: []
405
+ };
406
+ if (schema === false) return {
407
+ valid: false,
408
+ errors: [{
409
+ instanceLocation,
410
+ keyword: "false",
411
+ keywordLocation: instanceLocation,
412
+ error: "False boolean schema."
413
+ }]
414
+ };
415
+ const rawInstanceType = typeof instance;
416
+ let instanceType;
417
+ switch (rawInstanceType) {
418
+ case "boolean":
419
+ case "number":
420
+ case "string":
421
+ instanceType = rawInstanceType;
422
+ break;
423
+ case "object":
424
+ if (instance === null) instanceType = "null";
425
+ else if (Array.isArray(instance)) instanceType = "array";
426
+ else instanceType = "object";
427
+ break;
428
+ default: throw new Error(`Instances of "${rawInstanceType}" type are not supported.`);
429
+ }
430
+ const { $ref, $recursiveRef, $recursiveAnchor, type: $type, const: $const, enum: $enum, required: $required, not: $not, anyOf: $anyOf, allOf: $allOf, oneOf: $oneOf, if: $if, then: $then, else: $else, format: $format, properties: $properties, patternProperties: $patternProperties, additionalProperties: $additionalProperties, unevaluatedProperties: $unevaluatedProperties, minProperties: $minProperties, maxProperties: $maxProperties, propertyNames: $propertyNames, dependentRequired: $dependentRequired, dependentSchemas: $dependentSchemas, dependencies: $dependencies, prefixItems: $prefixItems, items: $items, additionalItems: $additionalItems, unevaluatedItems: $unevaluatedItems, contains: $contains, minContains: $minContains, maxContains: $maxContains, minItems: $minItems, maxItems: $maxItems, uniqueItems: $uniqueItems, minimum: $minimum, maximum: $maximum, exclusiveMinimum: $exclusiveMinimum, exclusiveMaximum: $exclusiveMaximum, multipleOf: $multipleOf, minLength: $minLength, maxLength: $maxLength, pattern: $pattern, __absolute_ref__, __absolute_recursive_ref__ } = schema;
431
+ const errors = [];
432
+ if ($recursiveAnchor === true && recursiveAnchor === null) recursiveAnchor = schema;
433
+ if ($recursiveRef === "#") {
434
+ const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
435
+ const keywordLocation = `${schemaLocation}/$recursiveRef`;
436
+ const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
437
+ if (!result.valid) errors.push({
438
+ instanceLocation,
439
+ keyword: "$recursiveRef",
440
+ keywordLocation,
441
+ error: "A subschema had errors."
442
+ }, ...result.errors);
443
+ }
444
+ if ($ref !== void 0) {
445
+ const refSchema = lookup[__absolute_ref__ || $ref];
446
+ if (refSchema === void 0) {
447
+ let message = `Unresolved $ref "${$ref}".`;
448
+ if (__absolute_ref__ && __absolute_ref__ !== $ref) message += ` Absolute URI "${__absolute_ref__}".`;
449
+ message += `\nKnown schemas:\n- ${Object.keys(lookup).join("\n- ")}`;
450
+ throw new Error(message);
451
+ }
452
+ const keywordLocation = `${schemaLocation}/$ref`;
453
+ const result = validate(instance, refSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated);
454
+ if (!result.valid) errors.push({
455
+ instanceLocation,
456
+ keyword: "$ref",
457
+ keywordLocation,
458
+ error: "A subschema had errors."
459
+ }, ...result.errors);
460
+ if (draft === "4" || draft === "7") return {
461
+ valid: errors.length === 0,
462
+ errors
463
+ };
464
+ }
465
+ if (Array.isArray($type)) {
466
+ let length = $type.length;
467
+ let valid = false;
468
+ for (let i = 0; i < length; i++) if (instanceType === $type[i] || $type[i] === "integer" && instanceType === "number" && instance % 1 === 0 && instance === instance) {
469
+ valid = true;
470
+ break;
471
+ }
472
+ if (!valid) errors.push({
473
+ instanceLocation,
474
+ keyword: "type",
475
+ keywordLocation: `${schemaLocation}/type`,
476
+ error: `Instance type "${instanceType}" is invalid. Expected "${$type.join("\", \"")}".`
477
+ });
478
+ } else if ($type === "integer") {
479
+ if (instanceType !== "number" || instance % 1 || instance !== instance) errors.push({
480
+ instanceLocation,
481
+ keyword: "type",
482
+ keywordLocation: `${schemaLocation}/type`,
483
+ error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
484
+ });
485
+ } else if ($type !== void 0 && instanceType !== $type) errors.push({
486
+ instanceLocation,
487
+ keyword: "type",
488
+ keywordLocation: `${schemaLocation}/type`,
489
+ error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
490
+ });
491
+ if ($const !== void 0) {
492
+ if (instanceType === "object" || instanceType === "array") {
493
+ if (!deepCompareStrict(instance, $const)) errors.push({
494
+ instanceLocation,
495
+ keyword: "const",
496
+ keywordLocation: `${schemaLocation}/const`,
497
+ error: `Instance does not match ${JSON.stringify($const)}.`
498
+ });
499
+ } else if (instance !== $const) errors.push({
500
+ instanceLocation,
501
+ keyword: "const",
502
+ keywordLocation: `${schemaLocation}/const`,
503
+ error: `Instance does not match ${JSON.stringify($const)}.`
504
+ });
505
+ }
506
+ if ($enum !== void 0) {
507
+ if (instanceType === "object" || instanceType === "array") {
508
+ if (!$enum.some((value) => deepCompareStrict(instance, value))) errors.push({
509
+ instanceLocation,
510
+ keyword: "enum",
511
+ keywordLocation: `${schemaLocation}/enum`,
512
+ error: `Instance does not match any of ${JSON.stringify($enum)}.`
513
+ });
514
+ } else if (!$enum.some((value) => instance === value)) errors.push({
515
+ instanceLocation,
516
+ keyword: "enum",
517
+ keywordLocation: `${schemaLocation}/enum`,
518
+ error: `Instance does not match any of ${JSON.stringify($enum)}.`
519
+ });
520
+ }
521
+ if ($not !== void 0) {
522
+ const keywordLocation = `${schemaLocation}/not`;
523
+ if (validate(instance, $not, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation).valid) errors.push({
524
+ instanceLocation,
525
+ keyword: "not",
526
+ keywordLocation,
527
+ error: "Instance matched \"not\" schema."
528
+ });
529
+ }
530
+ let subEvaluateds = [];
531
+ if ($anyOf !== void 0) {
532
+ const keywordLocation = `${schemaLocation}/anyOf`;
533
+ const errorsLength = errors.length;
534
+ let anyValid = false;
535
+ for (let i = 0; i < $anyOf.length; i++) {
536
+ const subSchema = $anyOf[i];
537
+ const subEvaluated = Object.create(evaluated);
538
+ const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
539
+ errors.push(...result.errors);
540
+ anyValid = anyValid || result.valid;
541
+ if (result.valid) subEvaluateds.push(subEvaluated);
542
+ }
543
+ if (anyValid) errors.length = errorsLength;
544
+ else errors.splice(errorsLength, 0, {
545
+ instanceLocation,
546
+ keyword: "anyOf",
547
+ keywordLocation,
548
+ error: "Instance does not match any subschemas."
549
+ });
550
+ }
551
+ if ($allOf !== void 0) {
552
+ const keywordLocation = `${schemaLocation}/allOf`;
553
+ const errorsLength = errors.length;
554
+ let allValid = true;
555
+ for (let i = 0; i < $allOf.length; i++) {
556
+ const subSchema = $allOf[i];
557
+ const subEvaluated = Object.create(evaluated);
558
+ const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
559
+ errors.push(...result.errors);
560
+ allValid = allValid && result.valid;
561
+ if (result.valid) subEvaluateds.push(subEvaluated);
562
+ }
563
+ if (allValid) errors.length = errorsLength;
564
+ else errors.splice(errorsLength, 0, {
565
+ instanceLocation,
566
+ keyword: "allOf",
567
+ keywordLocation,
568
+ error: `Instance does not match every subschema.`
569
+ });
570
+ }
571
+ if ($oneOf !== void 0) {
572
+ const keywordLocation = `${schemaLocation}/oneOf`;
573
+ const errorsLength = errors.length;
574
+ const matches = $oneOf.filter((subSchema, i) => {
575
+ const subEvaluated = Object.create(evaluated);
576
+ const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
577
+ errors.push(...result.errors);
578
+ if (result.valid) subEvaluateds.push(subEvaluated);
579
+ return result.valid;
580
+ }).length;
581
+ if (matches === 1) errors.length = errorsLength;
582
+ else errors.splice(errorsLength, 0, {
583
+ instanceLocation,
584
+ keyword: "oneOf",
585
+ keywordLocation,
586
+ error: `Instance does not match exactly one subschema (${matches} matches).`
587
+ });
588
+ }
589
+ if (instanceType === "object" || instanceType === "array") Object.assign(evaluated, ...subEvaluateds);
590
+ if ($if !== void 0) {
591
+ const keywordLocation = `${schemaLocation}/if`;
592
+ if (validate(instance, $if, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated).valid) {
593
+ if ($then !== void 0) {
594
+ const thenResult = validate(instance, $then, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/then`, evaluated);
595
+ if (!thenResult.valid) errors.push({
596
+ instanceLocation,
597
+ keyword: "if",
598
+ keywordLocation,
599
+ error: `Instance does not match "then" schema.`
600
+ }, ...thenResult.errors);
601
+ }
602
+ } else if ($else !== void 0) {
603
+ const elseResult = validate(instance, $else, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/else`, evaluated);
604
+ if (!elseResult.valid) errors.push({
605
+ instanceLocation,
606
+ keyword: "if",
607
+ keywordLocation,
608
+ error: `Instance does not match "else" schema.`
609
+ }, ...elseResult.errors);
610
+ }
611
+ }
612
+ if (instanceType === "object") {
613
+ if ($required !== void 0) {
614
+ for (const key of $required) if (!(key in instance)) errors.push({
615
+ instanceLocation,
616
+ keyword: "required",
617
+ keywordLocation: `${schemaLocation}/required`,
618
+ error: `Instance does not have required property "${key}".`
619
+ });
620
+ }
621
+ const keys = Object.keys(instance);
622
+ if ($minProperties !== void 0 && keys.length < $minProperties) errors.push({
623
+ instanceLocation,
624
+ keyword: "minProperties",
625
+ keywordLocation: `${schemaLocation}/minProperties`,
626
+ error: `Instance does not have at least ${$minProperties} properties.`
627
+ });
628
+ if ($maxProperties !== void 0 && keys.length > $maxProperties) errors.push({
629
+ instanceLocation,
630
+ keyword: "maxProperties",
631
+ keywordLocation: `${schemaLocation}/maxProperties`,
632
+ error: `Instance does not have at least ${$maxProperties} properties.`
633
+ });
634
+ if ($propertyNames !== void 0) {
635
+ const keywordLocation = `${schemaLocation}/propertyNames`;
636
+ for (const key in instance) {
637
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
638
+ const result = validate(key, $propertyNames, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
639
+ if (!result.valid) errors.push({
640
+ instanceLocation,
641
+ keyword: "propertyNames",
642
+ keywordLocation,
643
+ error: `Property name "${key}" does not match schema.`
644
+ }, ...result.errors);
645
+ }
646
+ }
647
+ if ($dependentRequired !== void 0) {
648
+ const keywordLocation = `${schemaLocation}/dependantRequired`;
649
+ for (const key in $dependentRequired) if (key in instance) {
650
+ const required = $dependentRequired[key];
651
+ for (const dependantKey of required) if (!(dependantKey in instance)) errors.push({
652
+ instanceLocation,
653
+ keyword: "dependentRequired",
654
+ keywordLocation,
655
+ error: `Instance has "${key}" but does not have "${dependantKey}".`
656
+ });
657
+ }
658
+ }
659
+ if ($dependentSchemas !== void 0) for (const key in $dependentSchemas) {
660
+ const keywordLocation = `${schemaLocation}/dependentSchemas`;
661
+ if (key in instance) {
662
+ const result = validate(instance, $dependentSchemas[key], draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`, evaluated);
663
+ if (!result.valid) errors.push({
664
+ instanceLocation,
665
+ keyword: "dependentSchemas",
666
+ keywordLocation,
667
+ error: `Instance has "${key}" but does not match dependant schema.`
668
+ }, ...result.errors);
669
+ }
670
+ }
671
+ if ($dependencies !== void 0) {
672
+ const keywordLocation = `${schemaLocation}/dependencies`;
673
+ for (const key in $dependencies) if (key in instance) {
674
+ const propsOrSchema = $dependencies[key];
675
+ if (Array.isArray(propsOrSchema)) {
676
+ for (const dependantKey of propsOrSchema) if (!(dependantKey in instance)) errors.push({
677
+ instanceLocation,
678
+ keyword: "dependencies",
679
+ keywordLocation,
680
+ error: `Instance has "${key}" but does not have "${dependantKey}".`
681
+ });
682
+ } else {
683
+ const result = validate(instance, propsOrSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`);
684
+ if (!result.valid) errors.push({
685
+ instanceLocation,
686
+ keyword: "dependencies",
687
+ keywordLocation,
688
+ error: `Instance has "${key}" but does not match dependant schema.`
689
+ }, ...result.errors);
690
+ }
691
+ }
692
+ }
693
+ const thisEvaluated = Object.create(null);
694
+ let stop = false;
695
+ if ($properties !== void 0) {
696
+ const keywordLocation = `${schemaLocation}/properties`;
697
+ for (const key in $properties) {
698
+ if (!(key in instance)) continue;
699
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
700
+ const result = validate(instance[key], $properties[key], draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(key)}`);
701
+ if (result.valid) evaluated[key] = thisEvaluated[key] = true;
702
+ else {
703
+ stop = shortCircuit;
704
+ errors.push({
705
+ instanceLocation,
706
+ keyword: "properties",
707
+ keywordLocation,
708
+ error: `Property "${key}" does not match schema.`
709
+ }, ...result.errors);
710
+ if (stop) break;
711
+ }
712
+ }
713
+ }
714
+ if (!stop && $patternProperties !== void 0) {
715
+ const keywordLocation = `${schemaLocation}/patternProperties`;
716
+ for (const pattern in $patternProperties) {
717
+ const regex = new RegExp(pattern, "u");
718
+ const subSchema = $patternProperties[pattern];
719
+ for (const key in instance) {
720
+ if (!regex.test(key)) continue;
721
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
722
+ const result = validate(instance[key], subSchema, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(pattern)}`);
723
+ if (result.valid) evaluated[key] = thisEvaluated[key] = true;
724
+ else {
725
+ stop = shortCircuit;
726
+ errors.push({
727
+ instanceLocation,
728
+ keyword: "patternProperties",
729
+ keywordLocation,
730
+ error: `Property "${key}" matches pattern "${pattern}" but does not match associated schema.`
731
+ }, ...result.errors);
732
+ }
733
+ }
734
+ }
735
+ }
736
+ if (!stop && $additionalProperties !== void 0) {
737
+ const keywordLocation = `${schemaLocation}/additionalProperties`;
738
+ for (const key in instance) {
739
+ if (thisEvaluated[key]) continue;
740
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
741
+ const result = validate(instance[key], $additionalProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
742
+ if (result.valid) evaluated[key] = true;
743
+ else {
744
+ stop = shortCircuit;
745
+ errors.push({
746
+ instanceLocation,
747
+ keyword: "additionalProperties",
748
+ keywordLocation,
749
+ error: `Property "${key}" does not match additional properties schema.`
750
+ }, ...result.errors);
751
+ }
752
+ }
753
+ } else if (!stop && $unevaluatedProperties !== void 0) {
754
+ const keywordLocation = `${schemaLocation}/unevaluatedProperties`;
755
+ for (const key in instance) if (!evaluated[key]) {
756
+ const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
757
+ const result = validate(instance[key], $unevaluatedProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
758
+ if (result.valid) evaluated[key] = true;
759
+ else errors.push({
760
+ instanceLocation,
761
+ keyword: "unevaluatedProperties",
762
+ keywordLocation,
763
+ error: `Property "${key}" does not match unevaluated properties schema.`
764
+ }, ...result.errors);
765
+ }
766
+ }
767
+ } else if (instanceType === "array") {
768
+ if ($maxItems !== void 0 && instance.length > $maxItems) errors.push({
769
+ instanceLocation,
770
+ keyword: "maxItems",
771
+ keywordLocation: `${schemaLocation}/maxItems`,
772
+ error: `Array has too many items (${instance.length} > ${$maxItems}).`
773
+ });
774
+ if ($minItems !== void 0 && instance.length < $minItems) errors.push({
775
+ instanceLocation,
776
+ keyword: "minItems",
777
+ keywordLocation: `${schemaLocation}/minItems`,
778
+ error: `Array has too few items (${instance.length} < ${$minItems}).`
779
+ });
780
+ const length = instance.length;
781
+ let i = 0;
782
+ let stop = false;
783
+ if ($prefixItems !== void 0) {
784
+ const keywordLocation = `${schemaLocation}/prefixItems`;
785
+ const length2 = Math.min($prefixItems.length, length);
786
+ for (; i < length2; i++) {
787
+ const result = validate(instance[i], $prefixItems[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
788
+ evaluated[i] = true;
789
+ if (!result.valid) {
790
+ stop = shortCircuit;
791
+ errors.push({
792
+ instanceLocation,
793
+ keyword: "prefixItems",
794
+ keywordLocation,
795
+ error: `Items did not match schema.`
796
+ }, ...result.errors);
797
+ if (stop) break;
798
+ }
799
+ }
800
+ }
801
+ if ($items !== void 0) {
802
+ const keywordLocation = `${schemaLocation}/items`;
803
+ if (Array.isArray($items)) {
804
+ const length2 = Math.min($items.length, length);
805
+ for (; i < length2; i++) {
806
+ const result = validate(instance[i], $items[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
807
+ evaluated[i] = true;
808
+ if (!result.valid) {
809
+ stop = shortCircuit;
810
+ errors.push({
811
+ instanceLocation,
812
+ keyword: "items",
813
+ keywordLocation,
814
+ error: `Items did not match schema.`
815
+ }, ...result.errors);
816
+ if (stop) break;
817
+ }
818
+ }
819
+ } else for (; i < length; i++) {
820
+ const result = validate(instance[i], $items, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
821
+ evaluated[i] = true;
822
+ if (!result.valid) {
823
+ stop = shortCircuit;
824
+ errors.push({
825
+ instanceLocation,
826
+ keyword: "items",
827
+ keywordLocation,
828
+ error: `Items did not match schema.`
829
+ }, ...result.errors);
830
+ if (stop) break;
831
+ }
832
+ }
833
+ if (!stop && $additionalItems !== void 0) {
834
+ const keywordLocation = `${schemaLocation}/additionalItems`;
835
+ for (; i < length; i++) {
836
+ const result = validate(instance[i], $additionalItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
837
+ evaluated[i] = true;
838
+ if (!result.valid) {
839
+ stop = shortCircuit;
840
+ errors.push({
841
+ instanceLocation,
842
+ keyword: "additionalItems",
843
+ keywordLocation,
844
+ error: `Items did not match additional items schema.`
845
+ }, ...result.errors);
846
+ }
847
+ }
848
+ }
849
+ }
850
+ if ($contains !== void 0) {
851
+ if (length === 0 && $minContains === void 0) errors.push({
852
+ instanceLocation,
853
+ keyword: "contains",
854
+ keywordLocation: `${schemaLocation}/contains`,
855
+ error: `Array is empty. It must contain at least one item matching the schema.`
856
+ });
857
+ else if ($minContains !== void 0 && length < $minContains) errors.push({
858
+ instanceLocation,
859
+ keyword: "minContains",
860
+ keywordLocation: `${schemaLocation}/minContains`,
861
+ error: `Array has less items (${length}) than minContains (${$minContains}).`
862
+ });
863
+ else {
864
+ const keywordLocation = `${schemaLocation}/contains`;
865
+ const errorsLength = errors.length;
866
+ let contained = 0;
867
+ for (let j = 0; j < length; j++) {
868
+ const result = validate(instance[j], $contains, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${j}`, keywordLocation);
869
+ if (result.valid) {
870
+ evaluated[j] = true;
871
+ contained++;
872
+ } else errors.push(...result.errors);
873
+ }
874
+ if (contained >= ($minContains || 0)) errors.length = errorsLength;
875
+ if ($minContains === void 0 && $maxContains === void 0 && contained === 0) errors.splice(errorsLength, 0, {
876
+ instanceLocation,
877
+ keyword: "contains",
878
+ keywordLocation,
879
+ error: `Array does not contain item matching schema.`
880
+ });
881
+ else if ($minContains !== void 0 && contained < $minContains) errors.push({
882
+ instanceLocation,
883
+ keyword: "minContains",
884
+ keywordLocation: `${schemaLocation}/minContains`,
885
+ error: `Array must contain at least ${$minContains} items matching schema. Only ${contained} items were found.`
886
+ });
887
+ else if ($maxContains !== void 0 && contained > $maxContains) errors.push({
888
+ instanceLocation,
889
+ keyword: "maxContains",
890
+ keywordLocation: `${schemaLocation}/maxContains`,
891
+ error: `Array may contain at most ${$maxContains} items matching schema. ${contained} items were found.`
892
+ });
893
+ }
894
+ }
895
+ if (!stop && $unevaluatedItems !== void 0) {
896
+ const keywordLocation = `${schemaLocation}/unevaluatedItems`;
897
+ for (; i < length; i++) {
898
+ if (evaluated[i]) continue;
899
+ const result = validate(instance[i], $unevaluatedItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
900
+ evaluated[i] = true;
901
+ if (!result.valid) errors.push({
902
+ instanceLocation,
903
+ keyword: "unevaluatedItems",
904
+ keywordLocation,
905
+ error: `Items did not match unevaluated items schema.`
906
+ }, ...result.errors);
907
+ }
908
+ }
909
+ if ($uniqueItems) for (let j = 0; j < length; j++) {
910
+ const a = instance[j];
911
+ const ao = typeof a === "object" && a !== null;
912
+ for (let k = 0; k < length; k++) {
913
+ if (j === k) continue;
914
+ const b = instance[k];
915
+ if (a === b || ao && typeof b === "object" && b !== null && deepCompareStrict(a, b)) {
916
+ errors.push({
917
+ instanceLocation,
918
+ keyword: "uniqueItems",
919
+ keywordLocation: `${schemaLocation}/uniqueItems`,
920
+ error: `Duplicate items at indexes ${j} and ${k}.`
921
+ });
922
+ j = Number.MAX_SAFE_INTEGER;
923
+ k = Number.MAX_SAFE_INTEGER;
924
+ }
925
+ }
926
+ }
927
+ } else if (instanceType === "number") {
928
+ if (draft === "4") {
929
+ if ($minimum !== void 0 && ($exclusiveMinimum === true && instance <= $minimum || instance < $minimum)) errors.push({
930
+ instanceLocation,
931
+ keyword: "minimum",
932
+ keywordLocation: `${schemaLocation}/minimum`,
933
+ error: `${instance} is less than ${$exclusiveMinimum ? "or equal to " : ""} ${$minimum}.`
934
+ });
935
+ if ($maximum !== void 0 && ($exclusiveMaximum === true && instance >= $maximum || instance > $maximum)) errors.push({
936
+ instanceLocation,
937
+ keyword: "maximum",
938
+ keywordLocation: `${schemaLocation}/maximum`,
939
+ error: `${instance} is greater than ${$exclusiveMaximum ? "or equal to " : ""} ${$maximum}.`
940
+ });
941
+ } else {
942
+ if ($minimum !== void 0 && instance < $minimum) errors.push({
943
+ instanceLocation,
944
+ keyword: "minimum",
945
+ keywordLocation: `${schemaLocation}/minimum`,
946
+ error: `${instance} is less than ${$minimum}.`
947
+ });
948
+ if ($maximum !== void 0 && instance > $maximum) errors.push({
949
+ instanceLocation,
950
+ keyword: "maximum",
951
+ keywordLocation: `${schemaLocation}/maximum`,
952
+ error: `${instance} is greater than ${$maximum}.`
953
+ });
954
+ if ($exclusiveMinimum !== void 0 && instance <= $exclusiveMinimum) errors.push({
955
+ instanceLocation,
956
+ keyword: "exclusiveMinimum",
957
+ keywordLocation: `${schemaLocation}/exclusiveMinimum`,
958
+ error: `${instance} is less than ${$exclusiveMinimum}.`
959
+ });
960
+ if ($exclusiveMaximum !== void 0 && instance >= $exclusiveMaximum) errors.push({
961
+ instanceLocation,
962
+ keyword: "exclusiveMaximum",
963
+ keywordLocation: `${schemaLocation}/exclusiveMaximum`,
964
+ error: `${instance} is greater than or equal to ${$exclusiveMaximum}.`
965
+ });
966
+ }
967
+ if ($multipleOf !== void 0) {
968
+ const remainder = instance % $multipleOf;
969
+ if (Math.abs(0 - remainder) >= 1.1920929e-7 && Math.abs($multipleOf - remainder) >= 1.1920929e-7) errors.push({
970
+ instanceLocation,
971
+ keyword: "multipleOf",
972
+ keywordLocation: `${schemaLocation}/multipleOf`,
973
+ error: `${instance} is not a multiple of ${$multipleOf}.`
974
+ });
975
+ }
976
+ } else if (instanceType === "string") {
977
+ const length = $minLength === void 0 && $maxLength === void 0 ? 0 : ucs2length(instance);
978
+ if ($minLength !== void 0 && length < $minLength) errors.push({
979
+ instanceLocation,
980
+ keyword: "minLength",
981
+ keywordLocation: `${schemaLocation}/minLength`,
982
+ error: `String is too short (${length} < ${$minLength}).`
983
+ });
984
+ if ($maxLength !== void 0 && length > $maxLength) errors.push({
985
+ instanceLocation,
986
+ keyword: "maxLength",
987
+ keywordLocation: `${schemaLocation}/maxLength`,
988
+ error: `String is too long (${length} > ${$maxLength}).`
989
+ });
990
+ if ($pattern !== void 0 && !new RegExp($pattern, "u").test(instance)) errors.push({
991
+ instanceLocation,
992
+ keyword: "pattern",
993
+ keywordLocation: `${schemaLocation}/pattern`,
994
+ error: `String does not match pattern.`
995
+ });
996
+ if ($format !== void 0 && format[$format] && !format[$format](instance)) errors.push({
997
+ instanceLocation,
998
+ keyword: "format",
999
+ keywordLocation: `${schemaLocation}/format`,
1000
+ error: `String does not match format "${$format}".`
1001
+ });
1002
+ }
1003
+ return {
1004
+ valid: errors.length === 0,
1005
+ errors
1006
+ };
1007
+ }
1008
+ //#endregion
1009
+ //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validator.js
1010
+ var Validator = class {
1011
+ schema;
1012
+ draft;
1013
+ shortCircuit;
1014
+ lookup;
1015
+ constructor(schema, draft = "2019-09", shortCircuit = true) {
1016
+ this.schema = schema;
1017
+ this.draft = draft;
1018
+ this.shortCircuit = shortCircuit;
1019
+ this.lookup = dereference(schema);
1020
+ }
1021
+ validate(instance) {
1022
+ return validate(instance, this.schema, this.draft, this.lookup, this.shortCircuit);
1023
+ }
1024
+ addSchema(schema, id) {
1025
+ if (id) schema = {
1026
+ ...schema,
1027
+ $id: id
1028
+ };
1029
+ dereference(schema, this.lookup);
1030
+ }
1031
+ };
1032
+ //#endregion
153
1033
  //#region src/json-schema-subset/utils.ts
154
1034
  var nextId = 0;
155
1035
  function createId() {
@@ -2103,6 +2983,7 @@ function schemaEqualsChecker(extendsContext) {
2103
2983
  if (value1 === null || value2 === null) return false;
2104
2984
  if (typeof value1 !== "object") return false;
2105
2985
  if (typeof value1 !== typeof value2) return false;
2986
+ if (extendsContext.isExtendsSchema(value1) || extendsContext.isExtendsSchema(value2)) return extendsContext.equals(value1, value2);
2106
2987
  if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
2107
2988
  return isObjectLikeEquals(value1, value2);
2108
2989
  }
@@ -2832,10 +3713,17 @@ var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
2832
3713
  }
2833
3714
  constructor(id, value, context) {
2834
3715
  if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
2835
- super(id, value, context);
3716
+ const validator = new Validator(structuredClone(value), "7");
3717
+ super(id, { enum: value.enum.filter((item) => validator.validate(item).valid) }, context);
2836
3718
  }
2837
3719
  compareImpl(other) {
2838
- if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
3720
+ if (this.value.enum.length == 0) return [(other instanceof SingleSelectSchema ? other.value.enum.length == 0 : isCompiledSchema(other) && getKind(other) === CompiledKind.Never) ? ExpressionSingleResult.Equals : ExpressionSingleResult.ContainedBy];
3721
+ if (isStringLikeSchema(other)) {
3722
+ const validator = new Validator(structuredClone(other), "7");
3723
+ const accepted = this.value.enum.filter((item) => validator.validate(item).valid).length;
3724
+ if (accepted == this.value.enum.length) return [ExpressionSingleResult.ContainedBy];
3725
+ return [accepted == 0 ? ExpressionSingleResult.Rejection : ExpressionSingleResult.Intersection];
3726
+ }
2839
3727
  if (other instanceof SingleSelectSchema) {
2840
3728
  const f = new Set(this.value.enum);
2841
3729
  let result = ExpressionSingleResult.Equals;