@inf-monkeys-tech/monkeys 1.1.30 → 1.1.31

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.
@@ -5651,6 +5651,15 @@ var schemasCannotOverlap = (left, right) => {
5651
5651
  const values = (schema) => Object.prototype.hasOwnProperty.call(schema, "const") ? [schema.const] : Array.isArray(schema.enum) ? schema.enum : void 0;
5652
5652
  const av = values(a), bv = values(b);
5653
5653
  if (av && bv && av.every((value) => !bv.some((other) => canonicalContentHash(value) === canonicalContentHash(other)))) return true;
5654
+ const declaredTypes = (schema) => {
5655
+ const types = typeof schema.type === "string" ? [schema.type] : schema.type;
5656
+ if (!Array.isArray(types) || !types.length || types.some((type) => !["null", "boolean", "object", "array", "number", "integer", "string"].includes(type))) return void 0;
5657
+ return types.map((type) => type === "integer" ? "number" : type);
5658
+ };
5659
+ const valueTypes = (entries) => entries?.map((value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value);
5660
+ const disjoint = (leftTypes, rightTypes) => !!leftTypes && !!rightTypes && leftTypes.every((type) => !rightTypes.includes(type));
5661
+ const at = declaredTypes(a), bt = declaredTypes(b);
5662
+ if (disjoint(at, bt) || disjoint(valueTypes(av), bt) || disjoint(at, valueTypes(bv))) return true;
5654
5663
  if (a.type !== "object" || b.type !== "object") return false;
5655
5664
  const property = (schema, key) => schema.properties?.[key] ?? (schema.patternProperties ? true : schema.additionalProperties ?? true);
5656
5665
  return [...a.required ?? [], ...b.required ?? []].some((key) => schemasCannotOverlap(property(a, key), property(b, key)));
@@ -5688,6 +5697,31 @@ var boundAcceptsPrevious = (previous, next, direction) => {
5688
5697
  return previous.value !== next.value || !previous.inclusive || next.inclusive;
5689
5698
  };
5690
5699
  var numericRangesAcceptPrevious = (previous, next) => boundAcceptsPrevious(numericBound(previous, "lower"), numericBound(next, "lower"), "lower") && boundAcceptsPrevious(numericBound(previous, "upper"), numericBound(next, "upper"), "upper");
5700
+ var containsSchemaReference = (value) => !!value && typeof value === "object" && Object.entries(value).some(([key, child]) => ["$ref", "$dynamicRef", "$recursiveRef"].includes(key) || containsSchemaReference(child));
5701
+ var hasPositiveLocalReferences = (schema, names, root = true) => {
5702
+ if (typeof schema === "boolean") return true;
5703
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) return false;
5704
+ return Object.entries(schema).every(([key, value]) => {
5705
+ if (key === "$ref") return typeof value === "string" && [...names].some((name) => value === `#/$defs/${name.replace(/~/g, "~0").replace(/\//g, "~1")}`);
5706
+ if (["$dynamicRef", "$recursiveRef", "$dynamicAnchor", "$recursiveAnchor", "$anchor"].includes(key)) return false;
5707
+ if (key === "$id") return root;
5708
+ if (key === "$defs" || key === "properties") {
5709
+ if (key === "$defs" && !root) return false;
5710
+ return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((child) => hasPositiveLocalReferences(child, names, false));
5711
+ }
5712
+ if (["items", "additionalProperties"].includes(key)) return hasPositiveLocalReferences(value, names, false);
5713
+ if (["anyOf", "allOf"].includes(key)) return Array.isArray(value) && value.every((child) => hasPositiveLocalReferences(child, names, false));
5714
+ return !containsSchemaReference(value);
5715
+ });
5716
+ };
5717
+ var isUnreachableConditional = (previous, branch) => {
5718
+ if (previous.type !== "object" || !branch || typeof branch !== "object" || Array.isArray(branch)) return false;
5719
+ const rule = branch;
5720
+ if (!rule.if || Object.keys(rule).some((key) => !["if", "then"].includes(key))) return false;
5721
+ const condition = rule.if;
5722
+ 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;
5723
+ return condition.required.some((key) => typeof key === "string" && schemasCannotOverlap(previous.properties?.[key] ?? (previous.patternProperties ? true : previous.additionalProperties ?? true), condition.properties?.[key] ?? true));
5724
+ };
5691
5725
  var acceptsPreviousSchema = (previous, next) => {
5692
5726
  if (canonicalContentHash(previous) === canonicalContentHash(next) || next === true) return true;
5693
5727
  if (previous === false) return true;
@@ -5700,6 +5734,21 @@ var acceptsPreviousSchema = (previous, next) => {
5700
5734
  if (oldBranches) return oldBranches.every((branch) => acceptsPreviousSchema(branch, next));
5701
5735
  const newBranches = branches(after);
5702
5736
  if (newBranches) return newBranches.some((branch, index) => acceptsPreviousSchema(previous, branch) && (!after.oneOf || newBranches.every((other, otherIndex) => index === otherIndex || schemasCannotOverlap(previous, other))));
5737
+ if (canonicalContentHash(before.$defs ?? null) !== canonicalContentHash(after.$defs ?? null)) {
5738
+ const oldDefinitions = before.$defs, newDefinitions = after.$defs;
5739
+ if (!oldDefinitions || !newDefinitions || typeof oldDefinitions !== "object" || typeof newDefinitions !== "object" || Array.isArray(oldDefinitions) || Array.isArray(newDefinitions)) return false;
5740
+ const names = new Set(Object.keys(oldDefinitions));
5741
+ 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;
5742
+ delete before.$defs;
5743
+ delete after.$defs;
5744
+ }
5745
+ if (canonicalContentHash(before.allOf ?? null) !== canonicalContentHash(after.allOf ?? null)) {
5746
+ if (before.allOf !== void 0 && !Array.isArray(before.allOf) || !Array.isArray(after.allOf)) return false;
5747
+ const previousBranches = before.allOf ?? [];
5748
+ 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;
5749
+ if (before.allOf === void 0) delete after.allOf;
5750
+ else after.allOf = before.allOf;
5751
+ }
5703
5752
  const {
5704
5753
  properties: oldProperties,
5705
5754
  required: oldRequired,
@@ -7186,4 +7235,4 @@ export {
7186
7235
  PageCompositionSchema,
7187
7236
  compilePageComposition
7188
7237
  };
7189
- //# sourceMappingURL=chunk-DHPZLF57.mjs.map
7238
+ //# sourceMappingURL=chunk-N3RVZAFT.mjs.map