@inf-monkeys-tech/monkeys 1.1.30 → 1.1.32

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.
@@ -5648,9 +5648,22 @@ var schemasCannotOverlap = (left, right) => {
5648
5648
  const a = left;
5649
5649
  const b = right;
5650
5650
  if (a.$ref || b.$ref) return false;
5651
+ for (const key of ["anyOf", "oneOf"]) {
5652
+ if (Array.isArray(a[key]) && a[key].every((branch) => schemasCannotOverlap(branch, b))) return true;
5653
+ if (Array.isArray(b[key]) && b[key].every((branch) => schemasCannotOverlap(a, branch))) return true;
5654
+ }
5651
5655
  const values = (schema) => Object.prototype.hasOwnProperty.call(schema, "const") ? [schema.const] : Array.isArray(schema.enum) ? schema.enum : void 0;
5652
5656
  const av = values(a), bv = values(b);
5653
5657
  if (av && bv && av.every((value) => !bv.some((other) => canonicalContentHash(value) === canonicalContentHash(other)))) return true;
5658
+ const declaredTypes = (schema) => {
5659
+ const types = typeof schema.type === "string" ? [schema.type] : schema.type;
5660
+ if (!Array.isArray(types) || !types.length || types.some((type) => !["null", "boolean", "object", "array", "number", "integer", "string"].includes(type))) return void 0;
5661
+ return types.map((type) => type === "integer" ? "number" : type);
5662
+ };
5663
+ const valueTypes = (entries) => entries?.map((value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value);
5664
+ const disjoint = (leftTypes, rightTypes) => !!leftTypes && !!rightTypes && leftTypes.every((type) => !rightTypes.includes(type));
5665
+ const at = declaredTypes(a), bt = declaredTypes(b);
5666
+ if (disjoint(at, bt) || disjoint(valueTypes(av), bt) || disjoint(at, valueTypes(bv))) return true;
5654
5667
  if (a.type !== "object" || b.type !== "object") return false;
5655
5668
  const property = (schema, key) => schema.properties?.[key] ?? (schema.patternProperties ? true : schema.additionalProperties ?? true);
5656
5669
  return [...a.required ?? [], ...b.required ?? []].some((key) => schemasCannotOverlap(property(a, key), property(b, key)));
@@ -5688,6 +5701,31 @@ var boundAcceptsPrevious = (previous, next, direction) => {
5688
5701
  return previous.value !== next.value || !previous.inclusive || next.inclusive;
5689
5702
  };
5690
5703
  var numericRangesAcceptPrevious = (previous, next) => boundAcceptsPrevious(numericBound(previous, "lower"), numericBound(next, "lower"), "lower") && boundAcceptsPrevious(numericBound(previous, "upper"), numericBound(next, "upper"), "upper");
5704
+ var containsSchemaReference = (value) => !!value && typeof value === "object" && Object.entries(value).some(([key, child]) => ["$ref", "$dynamicRef", "$recursiveRef"].includes(key) || containsSchemaReference(child));
5705
+ var hasPositiveLocalReferences = (schema, names, root = true) => {
5706
+ if (typeof schema === "boolean") return true;
5707
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) return false;
5708
+ return Object.entries(schema).every(([key, value]) => {
5709
+ if (key === "$ref") return typeof value === "string" && [...names].some((name) => value === `#/$defs/${name.replace(/~/g, "~0").replace(/\//g, "~1")}`);
5710
+ if (["$dynamicRef", "$recursiveRef", "$dynamicAnchor", "$recursiveAnchor", "$anchor"].includes(key)) return false;
5711
+ if (key === "$id") return root;
5712
+ if (key === "$defs" || key === "properties") {
5713
+ if (key === "$defs" && !root) return false;
5714
+ return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((child) => hasPositiveLocalReferences(child, names, false));
5715
+ }
5716
+ if (["items", "additionalProperties"].includes(key)) return hasPositiveLocalReferences(value, names, false);
5717
+ if (["anyOf", "allOf"].includes(key)) return Array.isArray(value) && value.every((child) => hasPositiveLocalReferences(child, names, false));
5718
+ return !containsSchemaReference(value);
5719
+ });
5720
+ };
5721
+ var isUnreachableConditional = (previous, branch) => {
5722
+ if (previous.type !== "object" || !branch || typeof branch !== "object" || Array.isArray(branch)) return false;
5723
+ const rule = branch;
5724
+ if (!rule.if || Object.keys(rule).some((key) => !["if", "then"].includes(key))) return false;
5725
+ const condition = rule.if;
5726
+ if (typeof condition !== "object" || Array.isArray(condition) || Object.keys(condition).some((key) => !["type", "properties", "required"].includes(key)) || condition.type !== void 0 && condition.type !== "object" || !Array.isArray(condition.required)) return false;
5727
+ return condition.required.some((key) => typeof key === "string" && schemasCannotOverlap(previous.properties?.[key] ?? (previous.patternProperties ? true : previous.additionalProperties ?? true), condition.properties?.[key] ?? true));
5728
+ };
5691
5729
  var acceptsPreviousSchema = (previous, next) => {
5692
5730
  if (canonicalContentHash(previous) === canonicalContentHash(next) || next === true) return true;
5693
5731
  if (previous === false) return true;
@@ -5695,11 +5733,36 @@ var acceptsPreviousSchema = (previous, next) => {
5695
5733
  const withoutAnnotations = (schema) => Object.fromEntries(Object.entries(schema).filter(([key]) => !["title", "description", "examples", "$comment"].includes(key)));
5696
5734
  const before = withoutAnnotations(previous);
5697
5735
  const after = withoutAnnotations(next);
5736
+ const union = (schema) => {
5737
+ const key = Array.isArray(schema.oneOf) && !schema.anyOf ? "oneOf" : Array.isArray(schema.anyOf) && !schema.oneOf ? "anyOf" : void 0;
5738
+ if (!key) return void 0;
5739
+ const { [key]: alternatives, ...siblings } = schema;
5740
+ return { key, alternatives, siblings };
5741
+ };
5742
+ const oldUnion = union(before), newUnion = union(after);
5743
+ if (oldUnion && newUnion && canonicalContentHash(oldUnion.siblings) === canonicalContentHash(newUnion.siblings)) {
5744
+ return oldUnion.alternatives.every((branch) => newUnion.alternatives.some((candidate, index) => acceptsPreviousSchema(branch, candidate) && (newUnion.key !== "oneOf" || newUnion.alternatives.every((other, otherIndex) => index === otherIndex || schemasCannotOverlap(branch, other)))));
5745
+ }
5698
5746
  const branches = (schema) => Object.keys(schema).length === 1 ? Array.isArray(schema.anyOf) ? schema.anyOf : Array.isArray(schema.oneOf) ? schema.oneOf : void 0 : void 0;
5699
5747
  const oldBranches = branches(before);
5700
5748
  if (oldBranches) return oldBranches.every((branch) => acceptsPreviousSchema(branch, next));
5701
5749
  const newBranches = branches(after);
5702
5750
  if (newBranches) return newBranches.some((branch, index) => acceptsPreviousSchema(previous, branch) && (!after.oneOf || newBranches.every((other, otherIndex) => index === otherIndex || schemasCannotOverlap(previous, other))));
5751
+ if (canonicalContentHash(before.$defs ?? null) !== canonicalContentHash(after.$defs ?? null)) {
5752
+ const oldDefinitions = before.$defs, newDefinitions = after.$defs;
5753
+ if (!oldDefinitions || !newDefinitions || typeof oldDefinitions !== "object" || typeof newDefinitions !== "object" || Array.isArray(oldDefinitions) || Array.isArray(newDefinitions)) return false;
5754
+ const names = new Set(Object.keys(oldDefinitions));
5755
+ if (names.size !== Object.keys(newDefinitions).length || [...names].some((name) => !Object.prototype.hasOwnProperty.call(newDefinitions, name)) || !hasPositiveLocalReferences(before, names) || !hasPositiveLocalReferences(after, names) || [...names].some((name) => !acceptsPreviousSchema(oldDefinitions[name], newDefinitions[name]))) return false;
5756
+ delete before.$defs;
5757
+ delete after.$defs;
5758
+ }
5759
+ if (canonicalContentHash(before.allOf ?? null) !== canonicalContentHash(after.allOf ?? null)) {
5760
+ if (before.allOf !== void 0 && !Array.isArray(before.allOf) || !Array.isArray(after.allOf)) return false;
5761
+ const previousBranches = before.allOf ?? [];
5762
+ if (previousBranches.some((branch) => !after.allOf.some((candidate) => canonicalContentHash(branch) === canonicalContentHash(candidate))) || after.allOf.some((branch) => !previousBranches.some((candidate) => canonicalContentHash(branch) === canonicalContentHash(candidate)) && !isUnreachableConditional(before, branch))) return false;
5763
+ if (before.allOf === void 0) delete after.allOf;
5764
+ else after.allOf = before.allOf;
5765
+ }
5703
5766
  const {
5704
5767
  properties: oldProperties,
5705
5768
  required: oldRequired,
@@ -7186,4 +7249,4 @@ export {
7186
7249
  PageCompositionSchema,
7187
7250
  compilePageComposition
7188
7251
  };
7189
- //# sourceMappingURL=chunk-DHPZLF57.mjs.map
7252
+ //# sourceMappingURL=chunk-OL3X34S6.mjs.map