json-schema-compatibility-checker 1.0.2 → 1.0.3

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 (59) hide show
  1. package/dist/chunk-8me729r7.js +5 -0
  2. package/dist/chunk-8me729r7.js.map +12 -0
  3. package/dist/chunk-8qenxa2z.js +7 -0
  4. package/dist/chunk-8qenxa2z.js.map +10 -0
  5. package/dist/{chunk-pyrx217p.js → chunk-ayae82am.js} +4 -4
  6. package/dist/{chunk-pyrx217p.js.map → chunk-ayae82am.js.map} +1 -1
  7. package/dist/chunk-etwjsbj3.js +5 -0
  8. package/dist/{chunk-yg81ax5m.js.map → chunk-etwjsbj3.js.map} +2 -2
  9. package/dist/{chunk-07z7fc5q.js → chunk-gdf3h8q4.js} +3 -3
  10. package/dist/{chunk-07z7fc5q.js.map → chunk-gdf3h8q4.js.map} +1 -1
  11. package/dist/chunk-jy9206ze.js +5 -0
  12. package/dist/chunk-jy9206ze.js.map +10 -0
  13. package/dist/chunk-k92ftyzf.js +5 -0
  14. package/dist/chunk-k92ftyzf.js.map +10 -0
  15. package/dist/{chunk-q7kq4fgq.js → chunk-mfe3cw5r.js} +3 -3
  16. package/dist/{chunk-q7kq4fgq.js.map → chunk-mfe3cw5r.js.map} +1 -1
  17. package/dist/{chunk-jkdzdb3r.js → chunk-w1ypc97a.js} +3 -3
  18. package/dist/{chunk-jkdzdb3r.js.map → chunk-w1ypc97a.js.map} +1 -1
  19. package/dist/{chunk-yqhv3py7.js → chunk-ywa6h8q4.js} +4 -4
  20. package/dist/{chunk-yqhv3py7.js.map → chunk-ywa6h8q4.js.map} +1 -1
  21. package/dist/condition-resolver.js +2 -2
  22. package/dist/condition-resolver.js.map +1 -1
  23. package/dist/differ.js +2 -2
  24. package/dist/differ.js.map +1 -1
  25. package/dist/format-validator.js +2 -2
  26. package/dist/format-validator.js.map +1 -1
  27. package/dist/formatter.d.ts +14 -2
  28. package/dist/formatter.js +2 -2
  29. package/dist/formatter.js.map +1 -1
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +2 -2
  32. package/dist/index.js.map +1 -1
  33. package/dist/json-schema-compatibility-checker.js +2 -2
  34. package/dist/json-schema-compatibility-checker.js.map +1 -1
  35. package/dist/merge-engine.js +2 -2
  36. package/dist/merge-engine.js.map +1 -1
  37. package/dist/normalizer.js +2 -2
  38. package/dist/normalizer.js.map +1 -1
  39. package/dist/pattern-subset.js +2 -2
  40. package/dist/pattern-subset.js.map +1 -1
  41. package/dist/semantic-diff/analyzer.d.ts +25 -0
  42. package/dist/semantic-diff/detectors.d.ts +79 -0
  43. package/dist/semantic-diff/index.d.ts +3 -0
  44. package/dist/semantic-diff/types.d.ts +81 -0
  45. package/dist/subset-checker.js +2 -2
  46. package/dist/subset-checker.js.map +1 -1
  47. package/dist/types.d.ts +6 -3
  48. package/dist/utils.js +2 -2
  49. package/dist/utils.js.map +1 -1
  50. package/package.json +48 -48
  51. package/dist/chunk-2ddbnbyq.js +0 -5
  52. package/dist/chunk-2ddbnbyq.js.map +0 -10
  53. package/dist/chunk-b55zsn5n.js +0 -5
  54. package/dist/chunk-b55zsn5n.js.map +0 -10
  55. package/dist/chunk-jybaxgmh.js +0 -5
  56. package/dist/chunk-jybaxgmh.js.map +0 -10
  57. package/dist/chunk-y8c2z1m3.js +0 -6
  58. package/dist/chunk-y8c2z1m3.js.map +0 -10
  59. package/dist/chunk-yg81ax5m.js +0 -5
@@ -0,0 +1,79 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ import type { SchemaDiff } from "../types";
3
+ import type { SemanticDiff } from "./types";
4
+ /** Formate un type JSON Schema pour l'affichage (string, array → "string | number") */
5
+ export declare function formatType(type: unknown): string;
6
+ /**
7
+ * Détecte les propriétés requises par le target que le source ne fournit pas.
8
+ *
9
+ * Condition : la propriété est dans `sup.required` mais n'existe pas
10
+ * dans `sub.properties`.
11
+ *
12
+ * Regroupe les diffs structurels `properties.X added` + `required changed`
13
+ * en un seul diagnostic.
14
+ */
15
+ export declare function detectMissingRequiredProperties(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
16
+ /**
17
+ * Détecte les propriétés optionnelles dans le source mais requises par le target.
18
+ *
19
+ * Condition : la propriété existe dans `sub.properties` (mais pas dans
20
+ * `sub.required`), et elle est dans `sup.required`.
21
+ *
22
+ * Ne se déclenche que si la propriété n'a pas déjà été détectée comme
23
+ * `missing-required-property`.
24
+ */
25
+ export declare function detectPropertiesNotGuaranteed(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
26
+ /**
27
+ * Détecte les propriétés fournies par le source que le target interdit.
28
+ *
29
+ * Condition : la propriété existe dans `sub.properties` mais pas dans
30
+ * `sup.properties`, et `sup.additionalProperties === false`.
31
+ */
32
+ export declare function detectPropertiesNotAllowed(_sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
33
+ /**
34
+ * Détecte les incompatibilités de type sur les propriétés ou à la racine.
35
+ *
36
+ * Distingue deux cas :
37
+ * - `type-mismatch` : types complètement différents (string vs number)
38
+ * - `type-too-wide` : source est un superset du target (string|number vs string)
39
+ */
40
+ export declare function detectTypeDiffs(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
41
+ /**
42
+ * Détecte les incompatibilités d'enum : source autorise des valeurs
43
+ * que target n'accepte pas.
44
+ */
45
+ export declare function detectEnumDiffs(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
46
+ /**
47
+ * Détecte les incompatibilités de const : valeurs const différentes.
48
+ */
49
+ export declare function detectConstDiffs(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
50
+ /**
51
+ * Détecte les contraintes du target plus strictes que celles du source.
52
+ *
53
+ * Couvre : minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf,
54
+ * minLength, maxLength, minItems, maxItems, minProperties, maxProperties.
55
+ */
56
+ export declare function detectConstraintDiffs(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
57
+ /**
58
+ * Détecte les conflits d'additionalProperties :
59
+ * source autorise des propriétés supplémentaires, target les interdit.
60
+ */
61
+ export declare function detectAdditionalPropertiesConflict(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
62
+ /**
63
+ * Détecte les incompatibilités de schema d'items (arrays).
64
+ */
65
+ export declare function detectItemsDiffs(_sub: JSONSchema7, _sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
66
+ /**
67
+ * Détecte les incompatibilités de format (email, uri, date-time, etc.).
68
+ */
69
+ export declare function detectFormatDiffs(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
70
+ /**
71
+ * Détecte les incompatibilités de pattern regex.
72
+ */
73
+ export declare function detectPatternDiffs(sub: JSONSchema7, sup: JSONSchema7, diffs: SchemaDiff[], consumed: Set<number>): SemanticDiff[];
74
+ /**
75
+ * Convertit les diffs structurels non consommés en `schema-incompatible`.
76
+ *
77
+ * C'est le catch-all pour les cas non couverts par les détecteurs spécifiques.
78
+ */
79
+ export declare function createFallbackDiff(diff: SchemaDiff): SemanticDiff;
@@ -0,0 +1,3 @@
1
+ export { computeSemanticDiffs } from "./analyzer";
2
+ export { formatType } from "./detectors";
3
+ export type { SemanticDiff, SemanticDiffType } from "./types";
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Types de diffs sémantiques possibles.
3
+ *
4
+ * Chaque type correspond à une catégorie d'incompatibilité
5
+ * entre un schema source et un schema target.
6
+ */
7
+ export type SemanticDiffType =
8
+ /** Target exige une propriété que source ne fournit pas du tout */
9
+ "missing-required-property"
10
+ /** La propriété existe dans source mais est optionnelle, target l'exige */
11
+ | "property-not-guaranteed"
12
+ /** Même propriété, types complètement incompatibles (string vs number) */
13
+ | "type-mismatch"
14
+ /** Source produit un type plus large que ce que target accepte (string|number vs string) */
15
+ | "type-too-wide"
16
+ /** Source autorise des valeurs enum que target n'accepte pas */
17
+ | "enum-not-subset"
18
+ /** Valeurs const incompatibles */
19
+ | "const-mismatch"
20
+ /** Source a des contraintes plus larges (min/max/length/items/etc.) */
21
+ | "constraint-too-loose"
22
+ /** Source autorise des propriétés supplémentaires, target les interdit */
23
+ | "additional-properties-conflict"
24
+ /** Source fournit une propriété que target interdit (additionalProperties: false) */
25
+ | "property-not-allowed"
26
+ /** Contrainte de format incompatible */
27
+ | "format-mismatch"
28
+ /** Pattern regex du source pas inclus dans celui du target */
29
+ | "pattern-not-subset"
30
+ /** Schema des items d'un array incompatible */
31
+ | "incompatible-items"
32
+ /** Incompatibilité générique (catch-all pour les cas non couverts) */
33
+ | "schema-incompatible";
34
+ /**
35
+ * Un diagnostic sémantique décrivant une incompatibilité entre deux schemas.
36
+ *
37
+ * Contrairement aux `SchemaDiff` structurels (qui comparent original vs merged),
38
+ * les `SemanticDiff` décrivent le problème en termes compréhensibles :
39
+ * - Quel est le problème (`type`)
40
+ * - Où il se situe (`path`)
41
+ * - Pourquoi c'est incompatible (`message`)
42
+ * - Données structurées pour l'exploiter programmatiquement (`details`)
43
+ *
44
+ * @example
45
+ * ```
46
+ * {
47
+ * type: 'missing-required-property',
48
+ * path: 'properties.meetingId',
49
+ * message: "Target requires property 'meetingId' (string) which source does not provide",
50
+ * details: { property: 'meetingId', targetSchema: { type: 'string' } }
51
+ * }
52
+ * ```
53
+ */
54
+ export interface SemanticDiff {
55
+ /** Catégorie sémantique de l'incompatibilité */
56
+ type: SemanticDiffType;
57
+ /** Chemin JSON-path vers l'élément problématique (ex: "properties.meetingId") */
58
+ path: string;
59
+ /** Message humain lisible décrivant le problème */
60
+ message: string;
61
+ /**
62
+ * Données structurées associées au diagnostic.
63
+ *
64
+ * Le contenu varie selon le `type` :
65
+ *
66
+ * - `missing-required-property` → `{ property, targetSchema }`
67
+ * - `property-not-guaranteed` → `{ property }`
68
+ * - `type-mismatch` → `{ property?, sourceType, targetType }`
69
+ * - `type-too-wide` → `{ property?, sourceType, targetType }`
70
+ * - `enum-not-subset` → `{ property?, sourceValues, targetValues, extraValues }`
71
+ * - `const-mismatch` → `{ property?, sourceConst, targetConst }`
72
+ * - `constraint-too-loose` → `{ property?, constraint, sourceValue, targetValue }`
73
+ * - `additional-properties-conflict` → `{ sourceAllows, targetAllows }`
74
+ * - `property-not-allowed` → `{ property }`
75
+ * - `format-mismatch` → `{ property?, sourceFormat, targetFormat }`
76
+ * - `pattern-not-subset` → `{ property?, sourcePattern, targetPattern }`
77
+ * - `incompatible-items` → `{ reason }`
78
+ * - `schema-incompatible` → `{ reason }`
79
+ */
80
+ details: Record<string, unknown>;
81
+ }
@@ -1,4 +1,4 @@
1
- import{b as a,c as b,d as c,e as d,f as e}from"./chunk-b55zsn5n.js";import"./chunk-q7kq4fgq.js";import"./chunk-jybaxgmh.js";import"./chunk-07z7fc5q.js";import"./chunk-yqhv3py7.js";import"./chunk-jkdzdb3r.js";export{b as isAtomicSubsetOf,a as getBranchesTyped,d as checkBranchedSup,c as checkBranchedSub,e as checkAtomic};
1
+ import{c as a,d as b,e as c,f as d,g as e}from"./chunk-8me729r7.js";import"./chunk-mfe3cw5r.js";import"./chunk-k92ftyzf.js";import"./chunk-gdf3h8q4.js";import"./chunk-ywa6h8q4.js";import"./chunk-w1ypc97a.js";export{b as isAtomicSubsetOf,a as getBranchesTyped,d as checkBranchedSup,c as checkBranchedSub,e as checkAtomic};
2
2
 
3
- //# debugId=F9684ED9F9ECB1E264756E2164756E21
3
+ //# debugId=EBA7C5BEF7728E5A64756E2164756E21
4
4
  //# sourceMappingURL=subset-checker.js.map
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "F9684ED9F9ECB1E264756E2164756E21",
7
+ "debugId": "EBA7C5BEF7728E5A64756E2164756E21",
8
8
  "names": []
9
9
  }
package/dist/types.d.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import type { JSONSchema7, JSONSchema7Definition } from "json-schema";
2
+ import type { SemanticDiff } from "./semantic-diff/types";
2
3
  export interface SchemaDiff {
3
4
  /** Chemin JSON-path-like vers la divergence (ex: "properties.user.required") */
4
5
  path: string;
5
6
  /** Type de divergence */
6
7
  type: "added" | "removed" | "changed";
7
- /** Valeur dans le schema original (sub) */
8
- expected: unknown;
8
+ /** Valeur dans le schema original (sub / source) */
9
+ sourceValue: unknown;
9
10
  /** Valeur dans le schema mergé (intersection) */
10
- actual: unknown;
11
+ mergedValue: unknown;
11
12
  }
12
13
  export interface SubsetResult {
13
14
  /** true si sub ⊆ sup (toute valeur valide pour sub est valide pour sup) */
@@ -16,6 +17,8 @@ export interface SubsetResult {
16
17
  merged: JSONSchema7Definition | null;
17
18
  /** Différences structurelles détectées entre sub et l'intersection */
18
19
  diffs: SchemaDiff[];
20
+ /** Diagnostics sémantiques lisibles décrivant POURQUOI les schemas sont incompatibles */
21
+ semanticDiffs: SemanticDiff[];
19
22
  }
20
23
  export interface ConnectionResult extends SubsetResult {
21
24
  /** Direction lisible du check */
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import{A as f,v as a,w as b,x as c,y as d,z as e}from"./chunk-jkdzdb3r.js";export{e as unionStrings,f as schemaDeepEqual,d as omitKeys,a as isPlainObj,b as hasOwn,c as deepEqual};
1
+ import{A as d,B as e,C as f,x as a,y as b,z as c}from"./chunk-w1ypc97a.js";export{e as unionStrings,f as schemaDeepEqual,d as omitKeys,a as isPlainObj,b as hasOwn,c as deepEqual};
2
2
 
3
- //# debugId=A54C3DD64AB7F25664756E2164756E21
3
+ //# debugId=4FECD0E4BE3551A564756E2164756E21
4
4
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "A54C3DD64AB7F25664756E2164756E21",
7
+ "debugId": "4FECD0E4BE3551A564756E2164756E21",
8
8
  "names": []
9
9
  }
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
1
  {
2
- "name": "json-schema-compatibility-checker",
3
- "version": "1.0.2",
4
- "license": "MIT",
5
- "description": "A tool to check compatibility between two JSON Schemas.",
6
- "author": {
7
- "email": "arthurtinseau@live.fr",
8
- "url": "https://github.com/atinseau/json-schema-compatibility-checker",
9
- "name": "atinseau"
10
- },
11
- "main": "dist/index.js",
12
- "types": "dist/index.d.ts",
13
- "type": "module",
14
- "sideEffects": false,
15
- "exports": {
16
- ".": {
17
- "types": "./dist/index.d.ts",
18
- "import": "./dist/index.js"
19
- }
20
- },
21
- "files": [
22
- "dist",
23
- "README.md"
24
- ],
25
- "scripts": {
26
- "prepare": "lefthook install",
27
- "build:bun": "bun build src/*.ts --outdir ./dist --production --minify --root src --sourcemap --splitting --target node --format esm --packages external --chunk-naming='chunk-[hash].js'",
28
- "build:tsc": "tsc --project tsconfig.build.json",
29
- "build": "bun --parallel build:bun build:tsc",
30
- "prepublishOnly": "bun run build",
31
- "check-types": "tsc --noEmit",
32
- "check": "biome check --write --unsafe",
33
- "test": "bun test",
34
- "bench": "bun run benchmarks/run.ts"
35
- },
36
- "devDependencies": {
37
- "@biomejs/biome": "2.4.3",
38
- "@types/bun": "latest",
39
- "lefthook": "^2.1.1",
40
- "mitata": "^1.0.34"
41
- },
42
- "peerDependencies": {
43
- "typescript": "^5"
44
- },
45
- "dependencies": {
46
- "@x0k/json-schema-merge": "1.0.2",
47
- "class-validator": "0.14.3",
48
- "randexp": "0.5.3"
49
- }
2
+ "name": "json-schema-compatibility-checker",
3
+ "version": "1.0.3",
4
+ "license": "MIT",
5
+ "description": "A tool to check compatibility between two JSON Schemas.",
6
+ "author": {
7
+ "email": "arthurtinseau@live.fr",
8
+ "url": "https://github.com/atinseau/json-schema-compatibility-checker",
9
+ "name": "atinseau"
10
+ },
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "scripts": {
26
+ "prepare": "lefthook install",
27
+ "build:bun": "bun build src/*.ts --outdir ./dist --production --minify --root src --sourcemap --splitting --target node --format esm --packages external --chunk-naming='chunk-[hash].js'",
28
+ "build:tsc": "tsc --project tsconfig.build.json",
29
+ "build": "bun --parallel build:bun build:tsc",
30
+ "prepublishOnly": "bun run build",
31
+ "check-types": "tsc --noEmit",
32
+ "check": "biome check --write --unsafe",
33
+ "test": "bun test",
34
+ "bench": "bun run benchmarks/run.ts"
35
+ },
36
+ "devDependencies": {
37
+ "@biomejs/biome": "2.4.3",
38
+ "@types/bun": "latest",
39
+ "lefthook": "2.1.1",
40
+ "mitata": "1.0.34"
41
+ },
42
+ "peerDependencies": {
43
+ "typescript": "^5"
44
+ },
45
+ "dependencies": {
46
+ "@x0k/json-schema-merge": "1.0.2",
47
+ "class-validator": "0.14.3",
48
+ "randexp": "0.5.3"
49
+ }
50
50
  }
@@ -1,5 +0,0 @@
1
- import{b as U,c as V,d as Y,e as Z,f as _}from"./chunk-b55zsn5n.js";import{k as Q}from"./chunk-pyrx217p.js";import{m as W}from"./chunk-y8c2z1m3.js";import{n as X}from"./chunk-yg81ax5m.js";import{u as J}from"./chunk-yqhv3py7.js";import{x as K}from"./chunk-jkdzdb3r.js";class F{engine;constructor(){this.engine=new X}isSubset(j,x){if(j===x)return!0;if(K(j,x))return!0;let w=J(j),G=J(x);if(w!==j&&G!==x&&K(w,G))return!0;if(w!==G&&K(w,G))return!0;let{branches:H}=U(w);if(H.length>1||H[0]!==w)return H.every((L)=>V(L,G,this.engine));return V(w,G,this.engine)}check(j,x){if(j===x)return{isSubset:!0,merged:j,diffs:[]};if(K(j,x))return{isSubset:!0,merged:j,diffs:[]};let w=J(j),G=J(x);if(K(w,G))return{isSubset:!0,merged:w,diffs:[]};let{branches:H,type:L}=U(w),{branches:N,type:$}=U(G);if(H.length>1||H[0]!==w)return Y(H,G,this.engine,L);if(N.length>1||N[0]!==G)return Z(w,N,this.engine,$);return _(w,G,this.engine)}canConnect(j,x){return{...this.check(j,x),direction:"sourceOutput ⊆ targetInput"}}isEqual(j,x){return this.engine.isEqual(J(j),J(x))}intersect(j,x){if(j===x||K(j,x))return J(j);let w=J(j),G=J(x);if(K(w,G))return w;let H=this.engine.merge(w,G);if(H===null)return null;if(K(H,w)||K(H,G))return H;return J(H)}resolveConditions(j,x){return Q(j,x,this.engine)}checkResolved(j,x,w,G){let H=Q(j,w,this.engine),L=Q(x,G??w,this.engine);return{...this.check(H.resolved,L.resolved),resolvedSub:H,resolvedSup:L}}normalize(j){return J(j)}formatResult(j,x){return W(j,x)}}
2
- export{F as a};
3
-
4
- //# debugId=E1A6658650822D7D64756E2164756E21
5
- //# sourceMappingURL=chunk-2ddbnbyq.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/json-schema-compatibility-checker.ts"],
4
- "sourcesContent": [
5
- "import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport { resolveConditions } from \"./condition-resolver\";\nimport { formatResult } from \"./formatter\";\nimport { MergeEngine } from \"./merge-engine\";\nimport { normalize } from \"./normalizer\";\nimport {\n\tarePatternsEquivalent,\n\tisPatternSubset,\n\tisTrivialPattern,\n} from \"./pattern-subset\";\nimport type { BranchResult, BranchType } from \"./subset-checker\";\nimport {\n\tcheckAtomic,\n\tcheckBranchedSub,\n\tcheckBranchedSup,\n\tgetBranchesTyped,\n\tisAtomicSubsetOf,\n} from \"./subset-checker\";\nimport type {\n\tConnectionResult,\n\tResolvedConditionResult,\n\tSchemaDiff,\n\tSubsetResult,\n} from \"./types\";\nimport { deepEqual } from \"./utils\";\n\n// ─── Re-exports ──────────────────────────────────────────────────────────────\n\nexport type {\n\tSchemaDiff,\n\tSubsetResult,\n\tConnectionResult,\n\tResolvedConditionResult,\n\tBranchType,\n\tBranchResult,\n};\n\nexport {\n\tnormalize,\n\tresolveConditions,\n\tformatResult,\n\tMergeEngine,\n\tisPatternSubset,\n\tarePatternsEquivalent,\n\tisTrivialPattern,\n};\n\n// ─── Main Class ──────────────────────────────────────────────────────────────\n//\n// Façade légère qui orchestre les sous-modules pour vérifier la compatibilité\n// entre JSON Schemas (Draft-07).\n//\n// Principe mathématique :\n// A ⊆ B ⟺ A ∩ B ≡ A\n//\n// En JSON Schema :\n// - A ∩ B = allOf([A, B]) résolu via merge\n// - ≡ = comparaison structurelle\n//\n// @example\n// ```ts\n// const checker = new JsonSchemaCompatibilityChecker();\n//\n// checker.isSubset(strict, loose); // true\n// checker.check(loose, strict); // { isSubset: false, diffs: [...] }\n// checker.canConnect(nodeA.output, nodeB.input); // ConnectionResult\n// ```\n\nexport class JsonSchemaCompatibilityChecker {\n\tprivate readonly engine: MergeEngine;\n\n\tconstructor() {\n\t\tthis.engine = new MergeEngine();\n\t}\n\n\t// ── Subset check (boolean) ─────────────────────────────────────────────\n\n\t/**\n\t * Vérifie si `sub ⊆ sup`.\n\t * Toute valeur valide pour sub est-elle aussi valide pour sup ?\n\t *\n\t * Point 6 — Utilise `getBranchesTyped` pour distinguer `anyOf` de `oneOf`\n\t * en interne, bien que le résultat boolean ne reflète pas la distinction.\n\t */\n\tisSubset(sub: JSONSchema7Definition, sup: JSONSchema7Definition): boolean {\n\t\t// ── Identity short-circuit ──\n\t\t// If sub and sup are the same reference, sub ⊆ sup is trivially true.\n\t\t// This avoids the entire normalize + merge + compare pipeline.\n\t\tif (sub === sup) return true;\n\n\t\t// ── Pre-normalize structural equality ──\n\t\t// If sub and sup are structurally identical before normalization,\n\t\t// they represent the same schema → sub ⊆ sup trivially.\n\t\t// This avoids the WeakMap overhead of normalize() for common cases\n\t\t// like {} ⊆ {} or identical schema objects with different references.\n\t\tif (deepEqual(sub, sup)) return true;\n\n\t\tconst nSub = normalize(sub);\n\t\tconst nSup = normalize(sup);\n\n\t\t// ── Post-normalize structural identity ──\n\t\t// After normalization, schemas that were syntactically different\n\t\t// but semantically equivalent become structurally equal\n\t\t// (e.g. {const:1} vs {const:1, type:\"integer\"}).\n\t\tif (nSub !== sub && nSup !== sup && deepEqual(nSub, nSup)) return true;\n\t\tif (nSub !== nSup && deepEqual(nSub, nSup)) return true;\n\n\t\tconst { branches: subBranches } = getBranchesTyped(nSub);\n\n\t\tif (subBranches.length > 1 || subBranches[0] !== nSub) {\n\t\t\treturn subBranches.every((branch) =>\n\t\t\t\tisAtomicSubsetOf(branch, nSup, this.engine),\n\t\t\t);\n\t\t}\n\n\t\treturn isAtomicSubsetOf(nSub, nSup, this.engine);\n\t}\n\n\t// ── Subset check (detailed) ────────────────────────────────────────────\n\n\t/**\n\t * Vérifie `sub ⊆ sup` et retourne un diagnostic complet\n\t * avec les diffs structurels.\n\t *\n\t * Point 6 — Utilise `getBranchesTyped` pour distinguer `anyOf` de `oneOf`\n\t * dans les paths de diff (ex: `anyOf[0]` vs `oneOf[0]`).\n\t */\n\tcheck(sub: JSONSchema7Definition, sup: JSONSchema7Definition): SubsetResult {\n\t\t// ── Identity short-circuit ──\n\t\t// Same reference → no diffs, no merge needed.\n\t\tif (sub === sup) {\n\t\t\treturn { isSubset: true, merged: sub, diffs: [] };\n\t\t}\n\n\t\t// ── Pre-normalize structural equality ──\n\t\t// Avoids WeakMap overhead for identical schemas ({} ⊆ {}, etc.).\n\t\tif (deepEqual(sub, sup)) {\n\t\t\treturn { isSubset: true, merged: sub, diffs: [] };\n\t\t}\n\n\t\tconst nSub = normalize(sub);\n\t\tconst nSup = normalize(sup);\n\n\t\t// ── Post-normalize structural identity ──\n\t\t// Catches semantically equivalent schemas after normalization.\n\t\tif (deepEqual(nSub, nSup)) {\n\t\t\treturn { isSubset: true, merged: nSub, diffs: [] };\n\t\t}\n\n\t\tconst { branches: subBranches, type: subBranchType } =\n\t\t\tgetBranchesTyped(nSub);\n\t\tconst { branches: supBranches, type: supBranchType } =\n\t\t\tgetBranchesTyped(nSup);\n\n\t\t// anyOf/oneOf dans sub\n\t\tif (subBranches.length > 1 || subBranches[0] !== nSub) {\n\t\t\treturn checkBranchedSub(subBranches, nSup, this.engine, subBranchType);\n\t\t}\n\n\t\t// anyOf/oneOf dans sup uniquement\n\t\tif (supBranches.length > 1 || supBranches[0] !== nSup) {\n\t\t\treturn checkBranchedSup(nSub, supBranches, this.engine, supBranchType);\n\t\t}\n\n\t\t// Cas standard\n\t\treturn checkAtomic(nSub, nSup, this.engine);\n\t}\n\n\t// ── Connection check ───────────────────────────────────────────────────\n\n\t/**\n\t * Vérifie si la sortie d'un nœud source peut alimenter l'entrée d'un nœud cible.\n\t *\n\t * Sémantique : `sourceOutput ⊆ targetInput`\n\t * → Toute donnée produite par source sera acceptée par target.\n\t */\n\tcanConnect(\n\t\tsourceOutput: JSONSchema7Definition,\n\t\ttargetInput: JSONSchema7Definition,\n\t): ConnectionResult {\n\t\tconst result = this.check(sourceOutput, targetInput);\n\t\treturn { ...result, direction: \"sourceOutput ⊆ targetInput\" };\n\t}\n\n\t// ── Equality ───────────────────────────────────────────────────────────\n\n\t/**\n\t * Vérifie l'égalité structurelle entre deux schemas.\n\t */\n\tisEqual(a: JSONSchema7Definition, b: JSONSchema7Definition): boolean {\n\t\treturn this.engine.isEqual(normalize(a), normalize(b));\n\t}\n\n\t// ── Intersection ───────────────────────────────────────────────────────\n\n\t/**\n\t * Calcule l'intersection de deux schemas (allOf merge).\n\t * Retourne null si les schemas sont incompatibles.\n\t *\n\t * Le résultat est normalisé pour éliminer les artefacts structurels\n\t * du merge (ex: `enum` redondant quand `const` est présent).\n\t */\n\tintersect(\n\t\ta: JSONSchema7Definition,\n\t\tb: JSONSchema7Definition,\n\t): JSONSchema7Definition | null {\n\t\t// ── Identity short-circuit ──\n\t\t// If a and b are the same reference or structurally equal,\n\t\t// intersection is just normalize(a) — skip the merge entirely.\n\t\tif (a === b || deepEqual(a, b)) return normalize(a);\n\n\t\tconst nA = normalize(a);\n\t\tconst nB = normalize(b);\n\n\t\t// ── Post-normalize identity ──\n\t\tif (deepEqual(nA, nB)) return nA;\n\n\t\tconst merged = this.engine.merge(nA, nB);\n\t\tif (merged === null) return null;\n\t\t// Fast path: if merge result equals one of the normalized inputs,\n\t\t// it's already normalized — skip redundant normalize call.\n\t\tif (deepEqual(merged, nA) || deepEqual(merged, nB)) return merged;\n\t\treturn normalize(merged);\n\t}\n\n\t// ── Condition resolution ───────────────────────────────────────────────\n\n\t/**\n\t * Résout les `if/then/else` d'un schema en évaluant le `if` contre\n\t * des données partielles (discriminants).\n\t */\n\tresolveConditions(\n\t\tschema: JSONSchema7,\n\t\tdata: Record<string, unknown>,\n\t): ResolvedConditionResult {\n\t\treturn resolveConditions(schema, data, this.engine);\n\t}\n\n\t// ── Resolved check ────────────────────────────────────────────────────\n\n\t/**\n\t * Raccourci : résout les conditions des deux schemas puis vérifie sub ⊆ sup.\n\t *\n\t * Utile quand le superset contient des if/then/else et que tu connais\n\t * les valeurs discriminantes que le subset va produire.\n\t */\n\tcheckResolved(\n\t\tsub: JSONSchema7,\n\t\tsup: JSONSchema7,\n\t\tsubData: Record<string, unknown>,\n\t\tsupData?: Record<string, unknown>,\n\t): SubsetResult & {\n\t\tresolvedSub: ResolvedConditionResult;\n\t\tresolvedSup: ResolvedConditionResult;\n\t} {\n\t\tconst resolvedSub = resolveConditions(sub, subData, this.engine);\n\t\tconst resolvedSup = resolveConditions(sup, supData ?? subData, this.engine);\n\t\tconst result = this.check(resolvedSub.resolved, resolvedSup.resolved);\n\n\t\treturn { ...result, resolvedSub, resolvedSup };\n\t}\n\n\t// ── Normalization ──────────────────────────────────────────────────────\n\n\t/**\n\t * Normalise un schema : infère `type` depuis `const`/`enum`,\n\t * et normalise récursivement tous les sous-schemas.\n\t */\n\tnormalize(def: JSONSchema7Definition): JSONSchema7Definition {\n\t\treturn normalize(def);\n\t}\n\n\t// ── Formatting ─────────────────────────────────────────────────────────\n\n\t/**\n\t * Formate un SubsetResult en chaîne lisible (utile pour logs/debug).\n\t */\n\tformatResult(label: string, result: SubsetResult): string {\n\t\treturn formatResult(label, result);\n\t}\n}\n"
6
- ],
7
- "mappings": "0SAoEO,AAAM,LAA+B,LAC1B,CAEjB,KAAW,EAAG,CACb,KAAK,OAAS,IAAI,EAYnB,QAAQ,CAAC,EAA4B,EAAqC,CAIzE,GAAI,IAAQ,EAAK,MAAO,GAOxB,GAAI,EAAU,EAAK,CAAG,EAAG,MAAO,GAEhC,IAAM,EAAO,EAAU,CAAG,EACpB,EAAO,EAAU,CAAG,EAM1B,GAAI,IAAS,GAAO,IAAS,GAAO,EAAU,EAAM,CAAI,EAAG,MAAO,GAClE,GAAI,IAAS,GAAQ,EAAU,EAAM,CAAI,EAAG,MAAO,GAEnD,IAAQ,SAAU,GAAgB,EAAiB,CAAI,EAEvD,GAAI,EAAY,OAAS,GAAK,EAAY,KAAO,EAChD,OAAO,EAAY,MAAM,CAAC,IACzB,EAAiB,EAAQ,EAAM,KAAK,MAAM,CAC3C,EAGD,OAAO,EAAiB,EAAM,EAAM,KAAK,MAAM,EAYhD,KAAK,CAAC,EAA4B,EAA0C,CAG3E,GAAI,IAAQ,EACX,MAAO,CAAE,SAAU,GAAM,OAAQ,EAAK,MAAO,CAAC,CAAE,EAKjD,GAAI,EAAU,EAAK,CAAG,EACrB,MAAO,CAAE,SAAU,GAAM,OAAQ,EAAK,MAAO,CAAC,CAAE,EAGjD,IAAM,EAAO,EAAU,CAAG,EACpB,EAAO,EAAU,CAAG,EAI1B,GAAI,EAAU,EAAM,CAAI,EACvB,MAAO,CAAE,SAAU,GAAM,OAAQ,EAAM,MAAO,CAAC,CAAE,EAGlD,IAAQ,SAAU,EAAa,KAAM,GACpC,EAAiB,CAAI,GACd,SAAU,EAAa,KAAM,GACpC,EAAiB,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650822D7D64756E2164756E21",
9
- "names": []
10
- }
@@ -1,5 +0,0 @@
1
- import{h as j}from"./chunk-q7kq4fgq.js";import{l as B}from"./chunk-jybaxgmh.js";import{s as k}from"./chunk-07z7fc5q.js";import{u as z}from"./chunk-yqhv3py7.js";import{v as K,w as W,x as V,y as R}from"./chunk-jkdzdb3r.js";var v={branches:[!0],type:"none"},g={branches:[!1],type:"none"},T=new WeakMap;function S(x){if(typeof x==="boolean")return x?v:g;if(W(x,"anyOf")&&Array.isArray(x.anyOf))return{branches:x.anyOf,type:"anyOf"};if(W(x,"oneOf")&&Array.isArray(x.oneOf))return{branches:x.oneOf,type:"oneOf"};let X=T.get(x);if(X===void 0)X={branches:[x],type:"none"},T.set(x,X);return X}function C(x,X){if(typeof x==="boolean"||typeof X==="boolean")return null;if(W(X,"not")&&K(X.not)){let Z=X.not;if(K(Z.properties)&&Array.isArray(Z.required)){let{properties:G,required:Q}=Z;if(K(x.properties)){let Y=x.properties,J=Array.isArray(x.required)?x.required:[],$=Object.keys(G);if($.some((_)=>{let L=G[_];if(typeof L==="boolean")return!1;let H=L;if(Q.includes(_)&&!J.includes(_)&&!W(Y,_))return!0;if(!W(Y,_))return!1;let M=Y[_];if(typeof M==="boolean")return!1;let A=M;if(W(H,"const")&&W(A,"const")){if(!V(H.const,A.const))return!0}if(W(H,"enum")&&Array.isArray(H.enum)){if(W(A,"const")){if(!H.enum.some((N)=>V(N,A.const)))return!0}if(W(A,"enum")&&Array.isArray(A.enum)){if(A.enum.every((N)=>!H.enum?.some((D)=>V(N,D))))return!0}}return!1}))return!0;if($.every((_)=>{let L=G[_];if(typeof L==="boolean")return!0;let H=L;if(Q.includes(_)&&!J.includes(_))return!1;if(!W(Y,_))return!1;let M=Y[_];if(typeof M==="boolean")return!0;let A=M;if(W(H,"const")&&W(A,"const"))return V(H.const,A.const);if(W(H,"enum")&&Array.isArray(H.enum)){if(W(A,"const"))return H.enum.some((F)=>V(F,A.const));if(W(A,"enum")&&Array.isArray(A.enum))return A.enum.every((F)=>H.enum?.some((N)=>V(F,N)))}return!1}))return!1}}if(W(Z,"const")&&W(x,"const")){let G=Z.const,Q=x.const;if(V(Q,G))return!1;return!0}if(W(Z,"enum")&&Array.isArray(Z.enum)&&W(x,"enum")&&Array.isArray(x.enum)){if(x.enum.every((Q)=>!Z.enum?.some((Y)=>V(Q,Y))))return!0}if(W(Z,"type")&&W(x,"type")){let G=Z.type,Q=x.type;if(typeof G==="string"&&typeof Q==="string"){if(!W(Z,"const")&&!W(Z,"enum")&&!K(Z.properties)){if(Q===G)return!1;return!0}}if(Array.isArray(G)&&typeof Q==="string"){if(G.includes(Q))return!1;return!0}}if(W(Z,"anyOf")&&Array.isArray(Z.anyOf)){let G=Z.anyOf;if(G.every((J)=>{if(typeof J==="boolean")return!J;return C(x,{not:J})===!0}))return!0;if(G.some((J)=>{if(typeof J==="boolean")return J;return C(x,{not:J})===!1}))return!1}if(W(Z,"oneOf")&&Array.isArray(Z.oneOf)){let G=Z.oneOf;if(G.every((J)=>{if(typeof J==="boolean")return!J;return C(x,{not:J})===!0}))return!0;if(G.some((J)=>{if(typeof J==="boolean")return J;return C(x,{not:J})===!1}))return!1}if(W(Z,"format")&&W(x,"format")){let G=x.format,Q=Z.format;if(G===Q)return!1;return!0}}if(W(x,"not")&&W(X,"not")){if(V(x.not,X.not))return!0}return null}function E(x,X,Z=!0){if(typeof X==="boolean"||typeof x==="boolean")return X;let G=X;if(Z&&W(G,"not"))G=R(G,["not"]);if(K(G.properties)&&K(x.properties)){let Q=x.properties,Y=G.properties,J;for(let $ of Object.keys(Y)){let U=Y[$],I=Q[$];if(U!==void 0&&I!==void 0&&typeof U!=="boolean"&&typeof I!=="boolean"&&W(U,"not")){if(C(I,U)===!0){if(!J)J={...Y};J[$]=R(U,["not"])}}}if(J)G={...G,properties:J}}return G}function q(x,X){if(typeof x==="boolean"||typeof X==="boolean")return X;let Z=X,G=Z,Q=!1;function Y(){if(!Q)G={...Z},Q=!0;return G}if(W(G,"pattern")&&W(x,"pattern")&&G.pattern!==x.pattern){if(j(x.pattern,G.pattern)===!0)G=R(Y(),["pattern"]),Q=!0}if(K(G.properties)&&K(x.properties)){let J=x.properties,$=G.properties,U=!1,I;for(let _ of Object.keys($)){let L=$[_],H=J[_];if(L!==void 0&&H!==void 0&&typeof L!=="boolean"&&typeof H!=="boolean"&&W(L,"pattern")&&W(H,"pattern")&&L.pattern!==H.pattern){if(j(H.pattern,L.pattern)===!0){if(!I)I={...$};I[_]=R(L,["pattern"]),U=!0}}}if(U&&I)Y().properties=I}if(K(G.items)&&typeof G.items!=="boolean"&&K(x.items)&&typeof x.items!=="boolean"){let J=x.items,$=G.items;if(W($,"pattern")&&W(J,"pattern")&&$.pattern!==J.pattern){if(j(J.pattern,$.pattern)===!0)Y().items=R($,["pattern"])}}return G}function w(x,X,Z){let{branches:G}=S(X);if(G.length===1&&G[0]===X){let Q=C(x,X);if(Q===!1)return!1;if(typeof x!=="boolean"&&typeof X!=="boolean"&&W(x,"format")&&W(X,"format")&&x.format!==X.format){if(k(x.format,X.format)!==!0)return!1}if(typeof x!=="boolean"&&typeof X!=="boolean"&&W(x,"pattern")&&W(X,"pattern")&&x.pattern!==X.pattern){if(j(x.pattern,X.pattern)===!1)return!1}let Y=X;if(typeof X!=="boolean"){if(Q===!0){if(Y=E(x,X,!0),typeof Y!=="boolean"&&Object.keys(Y).length===0)return!0}else Y=E(x,X,!1);Y=q(x,Y)}let J=Z.merge(x,Y);if(J===null)return!1;if(V(J,x))return!0;let $=z(J);return V($,x)||Z.isEqual($,x)}return G.some((Q)=>{let Y=C(x,Q);if(Y===!1)return!1;if(typeof x!=="boolean"&&typeof Q!=="boolean"&&W(x,"pattern")&&W(Q,"pattern")&&x.pattern!==Q.pattern){if(j(x.pattern,Q.pattern)===!1)return!1}let J=Q;if(typeof Q!=="boolean"){if(Y===!0){if(J=E(x,Q,!0),typeof J!=="boolean"&&Object.keys(J).length===0)return!0}else J=E(x,Q,!1);J=q(x,J)}let $=Z.merge(x,J);if($===null)return!1;if(V($,x))return!0;let U=z($);return V(U,x)||Z.isEqual(U,x)})}function f(x,X,Z,G="anyOf"){let Q=[],Y=!0,J=G==="none"?"anyOf":G;for(let $=0;$<x.length;$++){let U=x[$];if(U===void 0)continue;if(!w(U,X,Z))Y=!1,Q.push({path:`${J}[${$}]`,type:"changed",expected:U,actual:"Branch not accepted by superset"})}return{isSubset:Y,merged:Y?G==="oneOf"?{oneOf:x}:{anyOf:x}:null,diffs:Q}}function P(x,X,Z,G="anyOf"){for(let Y of X){let J=Y;if(typeof x!=="boolean"&&typeof Y!=="boolean")J=q(x,Y);let $=Z.merge(x,J);if($!==null){if(V($,x))return{isSubset:!0,merged:$,diffs:[]};let U=z($);if(V(U,x)||Z.isEqual(U,x))return{isSubset:!0,merged:$,diffs:[]}}}return{isSubset:!1,merged:null,diffs:[{path:"$",type:"changed",expected:x,actual:`No branch in superset's ${G==="none"?"anyOf":G} accepts this schema`}]}}function i(x,X,Z){let G=X;if(typeof x!=="boolean"&&typeof X!=="boolean")G=q(x,X);try{let Q=Z.mergeOrThrow(x,G);if(V(Q,x))return{isSubset:!0,merged:Q,diffs:[]};let Y=z(Q);if(V(Y,x)||Z.isEqual(Y,x))return{isSubset:!0,merged:Y,diffs:[]};let J=B(x,Y,"");return{isSubset:!1,merged:Y,diffs:J}}catch(Q){return{isSubset:!1,merged:null,diffs:[{path:"$",type:"changed",expected:x,actual:`Incompatible: ${Q instanceof Error?Q.message:String(Q)}`}]}}}
2
- export{S as b,w as c,f as d,P as e,i as f};
3
-
4
- //# debugId=B8207E42E9F16E9764756E2164756E21
5
- //# sourceMappingURL=chunk-b55zsn5n.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/subset-checker.ts"],
4
- "sourcesContent": [
5
- "import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport { computeDiffs } from \"./differ\";\nimport { isFormatSubset } from \"./format-validator\";\nimport type { MergeEngine } from \"./merge-engine\";\nimport { normalize } from \"./normalizer\";\nimport { isPatternSubset } from \"./pattern-subset\";\nimport type { SchemaDiff, SubsetResult } from \"./types\";\nimport { deepEqual, hasOwn, isPlainObj, omitKeys } from \"./utils\";\n\n// ─── Subset Checker ──────────────────────────────────────────────────────────\n//\n// Logique de vérification sub ⊆ sup via l'approche :\n// A ⊆ B ⟺ A ∩ B ≡ A\n//\n// Gère les cas :\n// - Schemas atomiques (pas de anyOf/oneOf)\n// - anyOf/oneOf dans sub → chaque branche doit être acceptée par sup\n// - anyOf/oneOf dans sup → au moins une branche doit accepter sub\n// - Point 6 : Distinction anyOf / oneOf dans les messages de diff\n// - Point 7 : Raisonnement étendu sur `not` (evaluateNot)\n// - not.type, not.const, not.enum (existants)\n// - not avec properties+required (1.1)\n// - not avec anyOf/oneOf (1.2)\n// - not dans sub (1.3)\n// - not.format (format-vs-format)\n//\n// Utilise des helpers natifs partagés depuis `./utils` pour des performances\n// optimales (deepEqual, hasOwn, isPlainObj, omitKeys).\n\n// ─── Branch type ─────────────────────────────────────────────────────────────\n\n/**\n * Type de branchement détecté dans un schema.\n *\n * Point 6 — Distingue `anyOf` de `oneOf` pour produire des messages\n * de diff plus précis. `\"none\"` indique un schema atomique (pas de branches).\n *\n * Note : la sémantique d'exclusivité de `oneOf` n'est pas vérifiée\n * (ce serait un problème NP-hard en général). Le checker traite `oneOf`\n * comme `anyOf` pour le subset checking, ce qui est correct pour le cas\n * `sub ⊆ sup` mais peut produire des faux-positifs si les branches\n * du sub se chevauchent.\n */\nexport type BranchType = \"anyOf\" | \"oneOf\" | \"none\";\n\nexport interface BranchResult {\n\t/** Les branches extraites du schema */\n\tbranches: JSONSchema7Definition[];\n\t/** Le type de branchement détecté */\n\ttype: BranchType;\n}\n\n// ─── Branch extraction ───────────────────────────────────────────────────────\n\n// Pre-allocated singleton results for boolean schemas to avoid per-call allocations.\n// These are safe because the branches arrays are never mutated after creation.\nconst BRANCH_TRUE: BranchResult = { branches: [true], type: \"none\" };\nconst BRANCH_FALSE: BranchResult = { branches: [false], type: \"none\" };\n\n/**\n * WeakMap cache for atomic (no anyOf/oneOf) schema branch results.\n * Avoids allocating `{ branches: [def], type: \"none\" }` on every call\n * for the same schema object. Since normalized schemas are cached and\n * return the same reference, this cache hits frequently.\n */\nconst atomicBranchCache = new WeakMap<object, BranchResult>();\n\n/**\n * Extrait les branches d'un schema et le type de branchement.\n *\n * Retourne les éléments de `anyOf`/`oneOf` s'ils existent, sinon retourne\n * le schema lui-même dans un tableau avec type `\"none\"`.\n *\n * Point 6 — Distingue `anyOf` de `oneOf` dans les paths de diff.\n *\n * Optimisation : réutilise des objets pré-alloués pour les cas boolean\n * (true/false) et un WeakMap cache pour les schemas atomiques afin\n * d'éviter les allocations sur ces chemins fréquents.\n */\nexport function getBranchesTyped(def: JSONSchema7Definition): BranchResult {\n\tif (typeof def === \"boolean\") {\n\t\treturn def ? BRANCH_TRUE : BRANCH_FALSE;\n\t}\n\tif (hasOwn(def, \"anyOf\") && Array.isArray(def.anyOf)) {\n\t\treturn { branches: def.anyOf, type: \"anyOf\" };\n\t}\n\tif (hasOwn(def, \"oneOf\") && Array.isArray(def.oneOf)) {\n\t\treturn { branches: def.oneOf, type: \"oneOf\" };\n\t}\n\t// Cache atomic results per schema object to avoid repeated allocations.\n\tlet cached = atomicBranchCache.get(def);\n\tif (cached === undefined) {\n\t\tcached = { branches: [def], type: \"none\" };\n\t\tatomicBranchCache.set(def, cached);\n\t}\n\treturn cached;\n}\n\n// ─── `not` reasoning (Point 7 — étendu) ─────────────────────────────────────\n\n/**\n * Raisonnement étendu sur `not` pour les cas courants.\n *\n * Point 7 — Vérifie la compatibilité quand `sup` et/ou `sub` contiennent `not` :\n *\n * **Cas existants (not dans sup) :**\n * - `not.type` : type exclu vs type de sub\n * - `not.const` : const exclu vs const de sub\n * - `not.enum` : valeurs exclues vs enum de sub\n *\n * **Cas ajoutés :**\n * - 1.1 — `not` avec `properties` + `required` : vérifier que les propriétés\n * de sub sont incompatibles avec celles du `not` (const/enum différents)\n * - 1.2 — `not` avec `anyOf`/`oneOf` : `not(anyOf([A,B]))` ≡ `allOf([not(A), not(B)])`,\n * donc sub doit être incompatible avec CHAQUE branche\n * - 1.3 — `not` dans `sub` (pas seulement dans `sup`) : un sub avec `not`\n * accepte un ensemble trop large pour être un sous-ensemble d'un sup concret\n * - `not.format` : format-vs-format via `isFormatSubset`\n *\n * Contrat ternaire conservateur :\n * - `true` → compatible (certain)\n * - `false` → incompatible (certain)\n * - `null` → indéterminé (laisser le merge engine décider)\n *\n * En cas de doute → `null`. Ne JAMAIS retourner `true` sans certitude.\n *\n * Utilise `_.has`, `_.get`, `_.isEqual`, `_.includes`, `_.every`, `_.some`,\n * `_.keys`, `_.isPlainObject`, `_.isArray` pour des vérifications concises.\n */\nfunction evaluateNot(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n): boolean | null {\n\tif (typeof sub === \"boolean\" || typeof sup === \"boolean\") return null;\n\n\t// ── 1.3 — `not` dans sub (pas dans sup) ──\n\t// Un `not` dans sub est une restriction supplémentaire : il exclut des\n\t// valeurs de l'ensemble accepté par sub, ce qui le rend potentiellement\n\t// plus petit — donc plus susceptible d'être ⊆ sup, pas moins.\n\t// On laisse le merge engine décider : allOf(sub, sup) préservera le `not`\n\t// de sub, et la comparaison merged ≡ sub donnera le bon résultat.\n\t// Exception : si les deux ont `not`, on traite l'identité plus bas.\n\n\t// Vérifier `not` dans sup\n\tif (hasOwn(sup, \"not\") && isPlainObj(sup.not)) {\n\t\tconst notSchema = sup.not as JSONSchema7;\n\n\t\t// ── 1.1 — Cas not avec properties + required ──\n\t\t// IMPORTANT : ce check est placé AVANT le check not.type car quand\n\t\t// le not a à la fois `type` et `properties`, le check not.type seul\n\t\t// produirait un faux négatif (ex: sub type=object et not type=object\n\t\t// retournerait false, mais les properties pourraient être incompatibles\n\t\t// ce qui rendrait sub compatible avec le not).\n\t\t// Si not contient des properties avec const/enum et required,\n\t\t// vérifier que les propriétés de sub sont incompatibles avec celles du not.\n\t\tif (isPlainObj(notSchema.properties) && Array.isArray(notSchema.required)) {\n\t\t\tconst notProps = notSchema.properties as Record<\n\t\t\t\tstring,\n\t\t\t\tJSONSchema7Definition\n\t\t\t>;\n\t\t\tconst notRequired = notSchema.required as string[];\n\n\t\t\t// sub doit avoir des properties pour qu'on puisse comparer\n\t\t\tif (isPlainObj(sub.properties)) {\n\t\t\t\tconst subProps = sub.properties as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tJSONSchema7Definition\n\t\t\t\t>;\n\t\t\t\tconst subRequired = Array.isArray(sub.required)\n\t\t\t\t\t? (sub.required as string[])\n\t\t\t\t\t: [];\n\t\t\t\tconst notPropKeys = Object.keys(notProps);\n\n\t\t\t\t// Pour que sub soit compatible avec not(schema),\n\t\t\t\t// il suffit qu'au moins UNE propriété du not soit incompatible avec sub.\n\t\t\t\t// Cela signifie que sub ne peut jamais valider le schema inside not.\n\t\t\t\tconst hasIncompatibleProp = notPropKeys.some((key) => {\n\t\t\t\t\tconst notPropDef = notProps[key];\n\t\t\t\t\tif (typeof notPropDef === \"boolean\") return false;\n\t\t\t\t\tconst notProp = notPropDef as JSONSchema7;\n\n\t\t\t\t\t// Si la propriété est required dans not mais PAS dans sub.required\n\t\t\t\t\t// et qu'elle n'existe pas dans sub.properties → sub peut ne pas\n\t\t\t\t\t// avoir cette propriété → le not schema ne matcherait pas → compatible\n\t\t\t\t\tif (\n\t\t\t\t\t\tnotRequired.includes(key) &&\n\t\t\t\t\t\t!subRequired.includes(key) &&\n\t\t\t\t\t\t!hasOwn(subProps, key)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn true; // Propriété absente de sub → not ne matche pas\n\t\t\t\t\t}\n\n\t\t\t\t\t// Comparer les const/enum de la propriété\n\t\t\t\t\tif (!hasOwn(subProps, key)) return false;\n\t\t\t\t\tconst subPropDef = subProps[key];\n\t\t\t\t\tif (typeof subPropDef === \"boolean\") return false;\n\t\t\t\t\tconst subProp = subPropDef as JSONSchema7;\n\n\t\t\t\t\t// not.prop a un const, sub.prop a un const différent → incompatible pour cette prop\n\t\t\t\t\tif (hasOwn(notProp, \"const\") && hasOwn(subProp, \"const\")) {\n\t\t\t\t\t\tif (!deepEqual(notProp.const, subProp.const)) {\n\t\t\t\t\t\t\treturn true; // Consts différents → sub ne matche pas le not\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// not.prop a un enum, sub.prop a un const ou enum dont aucune valeur\n\t\t\t\t\t// n'est dans not.enum → incompatible pour cette prop\n\t\t\t\t\tif (hasOwn(notProp, \"enum\") && Array.isArray(notProp.enum)) {\n\t\t\t\t\t\tif (hasOwn(subProp, \"const\")) {\n\t\t\t\t\t\t\tconst inNotEnum = notProp.enum.some((v) =>\n\t\t\t\t\t\t\t\tdeepEqual(v, subProp.const),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (!inNotEnum) return true; // sub.const absent du not.enum\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasOwn(subProp, \"enum\") && Array.isArray(subProp.enum)) {\n\t\t\t\t\t\t\tconst noneInNotEnum = subProp.enum.every(\n\t\t\t\t\t\t\t\t(v) => !notProp.enum?.some((nv) => deepEqual(v, nv)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (noneInNotEnum) return true; // Aucune valeur de sub.enum dans not.enum\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\n\t\t\t\tif (hasIncompatibleProp) return true;\n\n\t\t\t\t// Vérification inverse : si TOUTES les propriétés du not matchent sub\n\t\t\t\t// exactement (même const, sub a les required du not), alors sub VIOLE le not\n\t\t\t\tconst allPropsMatch = notPropKeys.every((key) => {\n\t\t\t\t\tconst notPropDef = notProps[key];\n\t\t\t\t\tif (typeof notPropDef === \"boolean\") return true;\n\t\t\t\t\tconst notProp = notPropDef as JSONSchema7;\n\n\t\t\t\t\t// La propriété doit être dans sub.required si elle est dans not.required\n\t\t\t\t\tif (notRequired.includes(key) && !subRequired.includes(key))\n\t\t\t\t\t\treturn false;\n\t\t\t\t\tif (!hasOwn(subProps, key)) return false;\n\t\t\t\t\tconst subPropDef = subProps[key];\n\t\t\t\t\tif (typeof subPropDef === \"boolean\") return true;\n\t\t\t\t\tconst subProp = subPropDef as JSONSchema7;\n\n\t\t\t\t\t// Vérifier const match\n\t\t\t\t\tif (hasOwn(notProp, \"const\") && hasOwn(subProp, \"const\")) {\n\t\t\t\t\t\treturn deepEqual(notProp.const, subProp.const);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Vérifier enum inclusion\n\t\t\t\t\tif (hasOwn(notProp, \"enum\") && Array.isArray(notProp.enum)) {\n\t\t\t\t\t\tif (hasOwn(subProp, \"const\")) {\n\t\t\t\t\t\t\treturn notProp.enum.some((v) => deepEqual(v, subProp.const));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasOwn(subProp, \"enum\") && Array.isArray(subProp.enum)) {\n\t\t\t\t\t\t\t// Toutes les valeurs de sub.enum sont dans not.enum\n\t\t\t\t\t\t\treturn subProp.enum.every((v) =>\n\t\t\t\t\t\t\t\tnotProp.enum?.some((nv) => deepEqual(v, nv)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn false; // Indéterminé pour cette propriété\n\t\t\t\t});\n\n\t\t\t\tif (allPropsMatch) return false; // sub matche exactement le not → incompatible\n\t\t\t}\n\t\t}\n\n\t\t// ── Cas not.const ──\n\t\t// IMPORTANT : ce check est placé AVANT not.type car quand le not a\n\t\t// à la fois `type` et `const`, le check not.type seul produirait un\n\t\t// faux négatif (ex: sub type=string const=\"active\" et not type=string\n\t\t// const=\"deleted\" → le type check retournerait false car même type,\n\t\t// alors que les consts sont différents → compatible).\n\t\tif (hasOwn(notSchema, \"const\") && hasOwn(sub, \"const\")) {\n\t\t\tconst notConst = notSchema.const;\n\t\t\tconst subConst = sub.const;\n\t\t\tif (deepEqual(subConst, notConst)) return false;\n\t\t\treturn true;\n\t\t}\n\n\t\t// ── Cas not.enum ──\n\t\t// Aussi placé AVANT not.type pour la même raison.\n\t\tif (\n\t\t\thasOwn(notSchema, \"enum\") &&\n\t\t\tArray.isArray(notSchema.enum) &&\n\t\t\thasOwn(sub, \"enum\") &&\n\t\t\tArray.isArray(sub.enum)\n\t\t) {\n\t\t\t// Toutes les valeurs de sub.enum doivent être absentes de not.enum\n\t\t\tconst allExcluded = sub.enum.every(\n\t\t\t\t(val) => !notSchema.enum?.some((notVal) => deepEqual(val, notVal)),\n\t\t\t);\n\t\t\tif (allExcluded) return true;\n\t\t\t// Certaines valeurs de sub sont dans not.enum → pas automatiquement faux,\n\t\t\t// le merge engine peut encore gérer\n\t\t}\n\n\t\t// ── Cas not.type ──\n\t\t// Placé APRÈS not.const, not.enum et properties+required pour ne pas\n\t\t// court-circuiter les cas où le not a des contraintes plus spécifiques.\n\t\t// Le check type seul est un fallback pour les not schemas simples\n\t\t// (ex: { not: { type: \"string\" } }).\n\t\tif (hasOwn(notSchema, \"type\") && hasOwn(sub, \"type\")) {\n\t\t\tconst notType = notSchema.type;\n\t\t\tconst subType = sub.type;\n\n\t\t\t// Si les deux sont des strings simples\n\t\t\tif (typeof notType === \"string\" && typeof subType === \"string\") {\n\t\t\t\t// Ne retourner que si le not n'a PAS de contraintes plus spécifiques\n\t\t\t\t// (const, enum, properties) qui auraient dû être traitées plus haut\n\t\t\t\tif (\n\t\t\t\t\t!hasOwn(notSchema, \"const\") &&\n\t\t\t\t\t!hasOwn(notSchema, \"enum\") &&\n\t\t\t\t\t!isPlainObj(notSchema.properties)\n\t\t\t\t) {\n\t\t\t\t\tif (subType === notType) return false; // Incompatible : sub est exactement le type exclu\n\t\t\t\t\treturn true; // Compatible : sub est un type différent du type exclu\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Si notType est un tableau, sub.type doit ne pas être dedans\n\t\t\tif (Array.isArray(notType) && typeof subType === \"string\") {\n\t\t\t\tif (notType.includes(subType)) return false;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// ── 1.2 — Cas not avec anyOf / oneOf ──\n\t\t// not(anyOf([A, B])) ≡ allOf([not(A), not(B)])\n\t\t// Pour que sub ⊆ not(anyOf(...)), sub doit être incompatible avec CHAQUE branche.\n\t\tif (hasOwn(notSchema, \"anyOf\") && Array.isArray(notSchema.anyOf)) {\n\t\t\tconst branches = notSchema.anyOf as JSONSchema7Definition[];\n\t\t\t// Pour chaque branche du not.anyOf, vérifier que sub est incompatible\n\t\t\tconst allIncompatible = branches.every((branch) => {\n\t\t\t\tif (typeof branch === \"boolean\") return !branch; // not(true) = rien, not(false) = tout\n\t\t\t\t// Créer un sup virtuel { not: branch } et vérifier récursivement\n\t\t\t\tconst result = evaluateNot(sub, { not: branch });\n\t\t\t\t// result = true → sub est compatible avec not(branch) → sub ⊄ branch → OK\n\t\t\t\t// result = false → sub est incompatible avec not(branch) → sub ⊆ branch → pas OK\n\t\t\t\t// result = null → indéterminé\n\t\t\t\treturn result === true;\n\t\t\t});\n\t\t\tif (allIncompatible) return true;\n\n\t\t\t// Vérifier si au moins une branche accepte sub → incompatible avec not(anyOf)\n\t\t\tconst anyBranchMatches = branches.some((branch) => {\n\t\t\t\tif (typeof branch === \"boolean\") return branch;\n\t\t\t\tconst result = evaluateNot(sub, { not: branch });\n\t\t\t\treturn result === false; // sub est incompatible avec not(branch) → sub ⊆ branch\n\t\t\t});\n\t\t\tif (anyBranchMatches) return false;\n\t\t}\n\n\t\t// Même logique pour oneOf (dans le contexte du not, traité comme anyOf)\n\t\tif (hasOwn(notSchema, \"oneOf\") && Array.isArray(notSchema.oneOf)) {\n\t\t\tconst branches = notSchema.oneOf as JSONSchema7Definition[];\n\t\t\tconst allIncompatible = branches.every((branch) => {\n\t\t\t\tif (typeof branch === \"boolean\") return !branch;\n\t\t\t\tconst result = evaluateNot(sub, { not: branch });\n\t\t\t\treturn result === true;\n\t\t\t});\n\t\t\tif (allIncompatible) return true;\n\n\t\t\tconst anyBranchMatches = branches.some((branch) => {\n\t\t\t\tif (typeof branch === \"boolean\") return branch;\n\t\t\t\tconst result = evaluateNot(sub, { not: branch });\n\t\t\t\treturn result === false;\n\t\t\t});\n\t\t\tif (anyBranchMatches) return false;\n\t\t}\n\n\t\t// ── Cas not.format (format-vs-format uniquement) ──\n\t\t// Si not a un format et sub aussi, vérifier la compatibilité\n\t\tif (hasOwn(notSchema, \"format\") && hasOwn(sub, \"format\")) {\n\t\t\tconst subFormat = sub.format as string;\n\t\t\tconst notFormat = notSchema.format as string;\n\t\t\tif (subFormat === notFormat) return false; // Incompatible : sub a exactement le format exclu\n\t\t\t// Formats différents → compatible (approximation conservatrice)\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Vérifier `not` dans sub ET dans sup (identité : { not: X } ⊆ { not: X })\n\tif (hasOwn(sub, \"not\") && hasOwn(sup, \"not\")) {\n\t\tif (deepEqual(sub.not, sup.not)) return true;\n\t}\n\n\treturn null; // Pas d'avis → laisser le merge engine décider\n}\n\n// ─── Not stripping helper ────────────────────────────────────────────────────\n\n/**\n * Retire le mot-clé `not` d'un schema pour permettre un merge propre\n * quand `evaluateNot` a déjà confirmé la compatibilité.\n *\n * Gère aussi le `not` imbriqué dans les `properties` : si une propriété\n * de `sup` a un `not` qui est compatible avec la propriété correspondante\n * de `sub`, on le retire également.\n *\n * Retourne le schema nettoyé, ou `null` si le schema est vide après retrait.\n *\n * Utilise `_.omit`, `_.has`, `_.keys`, `_.isEmpty`, `_.isPlainObject`.\n */\nfunction stripNotFromSup(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n\tstripTopLevel: boolean = true,\n): JSONSchema7Definition {\n\tif (typeof sup === \"boolean\" || typeof sub === \"boolean\") return sup;\n\n\tlet result = sup as JSONSchema7;\n\n\t// ── Retirer le `not` de niveau supérieur (seulement si confirmé) ──\n\tif (stripTopLevel && hasOwn(result, \"not\")) {\n\t\tresult = omitKeys(result as unknown as Record<string, unknown>, [\n\t\t\t\"not\",\n\t\t]) as JSONSchema7;\n\t}\n\n\t// ── Retirer les `not` dans les propriétés communes ──\n\t// Si sup.properties[key] a un `not` et que evaluateNot(sub.prop, sup.prop)\n\t// confirme la compatibilité, on retire le `not` de cette propriété aussi.\n\tif (\n\t\tisPlainObj(result.properties) &&\n\t\tisPlainObj((sub as JSONSchema7).properties)\n\t) {\n\t\tconst subProps = (sub as JSONSchema7).properties as Record<\n\t\t\tstring,\n\t\t\tJSONSchema7Definition\n\t\t>;\n\t\tconst supProps = result.properties as Record<string, JSONSchema7Definition>;\n\t\tlet newProps: Record<string, JSONSchema7Definition> | undefined;\n\n\t\tfor (const key of Object.keys(supProps)) {\n\t\t\tconst supPropDef = supProps[key];\n\t\t\tconst subPropDef = subProps[key];\n\t\t\tif (\n\t\t\t\tsupPropDef !== undefined &&\n\t\t\t\tsubPropDef !== undefined &&\n\t\t\t\ttypeof supPropDef !== \"boolean\" &&\n\t\t\t\ttypeof subPropDef !== \"boolean\" &&\n\t\t\t\thasOwn(supPropDef, \"not\")\n\t\t\t) {\n\t\t\t\t// Vérifier la compatibilité du not au niveau de la propriété\n\t\t\t\tconst propNotResult = evaluateNot(subPropDef, supPropDef);\n\t\t\t\tif (propNotResult === true) {\n\t\t\t\t\t// Lazy allocate newProps only on first modification\n\t\t\t\t\tif (!newProps) newProps = { ...supProps };\n\t\t\t\t\tnewProps[key] = omitKeys(\n\t\t\t\t\t\tsupPropDef as unknown as Record<string, unknown>,\n\t\t\t\t\t\t[\"not\"],\n\t\t\t\t\t) as JSONSchema7Definition;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (newProps) {\n\t\t\tresult = { ...result, properties: newProps };\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ─── Pattern stripping helper ────────────────────────────────────────────────\n\n/**\n * Retire le `pattern` de `sup` quand `isPatternSubset` a confirmé que\n * sub.pattern ⊆ sup.pattern par échantillonnage.\n *\n * Fonctionne comme `stripNotFromSup` : on retire la contrainte de sup\n * qui est déjà satisfaite par sub, pour éviter que le merge engine\n * produise un pattern combiné (lookahead conjunction) structurellement\n * différent du pattern de sub, ce qui causerait un faux négatif.\n *\n * Récurse dans les `properties` pour traiter les patterns imbriqués.\n *\n * @param sub Le schema sub (utilisé pour extraire les patterns à comparer)\n * @param sup Le schema sup dont on retire les patterns confirmés\n * @returns Le schema sup nettoyé\n */\nfunction stripPatternFromSup(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n): JSONSchema7Definition {\n\tif (typeof sub === \"boolean\" || typeof sup === \"boolean\") return sup;\n\n\tconst supObj: JSONSchema7 = sup;\n\n\t// Lazy copy-on-write: only create a copy when the first mutation is needed.\n\tlet result: JSONSchema7 = supObj;\n\tlet copied = false;\n\n\tfunction ensureCopy(): JSONSchema7 {\n\t\tif (!copied) {\n\t\t\tresult = { ...supObj };\n\t\t\tcopied = true;\n\t\t}\n\t\treturn result;\n\t}\n\n\t// ── Top-level pattern ──\n\tif (\n\t\thasOwn(result, \"pattern\") &&\n\t\thasOwn(sub, \"pattern\") &&\n\t\tresult.pattern !== (sub as JSONSchema7).pattern\n\t) {\n\t\tconst patResult = isPatternSubset(\n\t\t\t(sub as JSONSchema7).pattern as string,\n\t\t\tresult.pattern as string,\n\t\t);\n\t\tif (patResult === true) {\n\t\t\tresult = omitKeys(ensureCopy() as unknown as Record<string, unknown>, [\n\t\t\t\t\"pattern\",\n\t\t\t]) as JSONSchema7;\n\t\t\tcopied = true;\n\t\t}\n\t}\n\n\t// ── Patterns dans les propriétés communes ──\n\tif (\n\t\tisPlainObj(result.properties) &&\n\t\tisPlainObj((sub as JSONSchema7).properties)\n\t) {\n\t\tconst subProps = (sub as JSONSchema7).properties as Record<\n\t\t\tstring,\n\t\t\tJSONSchema7Definition\n\t\t>;\n\t\tconst supProps = result.properties as Record<string, JSONSchema7Definition>;\n\t\tlet propsModified = false;\n\t\tlet newProps: Record<string, JSONSchema7Definition> | undefined;\n\n\t\tfor (const key of Object.keys(supProps)) {\n\t\t\tconst supPropDef = supProps[key];\n\t\t\tconst subPropDef = subProps[key];\n\t\t\tif (\n\t\t\t\tsupPropDef !== undefined &&\n\t\t\t\tsubPropDef !== undefined &&\n\t\t\t\ttypeof supPropDef !== \"boolean\" &&\n\t\t\t\ttypeof subPropDef !== \"boolean\" &&\n\t\t\t\thasOwn(supPropDef, \"pattern\") &&\n\t\t\t\thasOwn(subPropDef, \"pattern\") &&\n\t\t\t\tsupPropDef.pattern !== subPropDef.pattern\n\t\t\t) {\n\t\t\t\tconst propPatResult = isPatternSubset(\n\t\t\t\t\t(subPropDef as JSONSchema7).pattern as string,\n\t\t\t\t\t(supPropDef as JSONSchema7).pattern as string,\n\t\t\t\t);\n\t\t\t\tif (propPatResult === true) {\n\t\t\t\t\tif (!newProps) newProps = { ...supProps };\n\t\t\t\t\tnewProps[key] = omitKeys(\n\t\t\t\t\t\tsupPropDef as unknown as Record<string, unknown>,\n\t\t\t\t\t\t[\"pattern\"],\n\t\t\t\t\t) as JSONSchema7Definition;\n\t\t\t\t\tpropsModified = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (propsModified && newProps) {\n\t\t\tensureCopy().properties = newProps;\n\t\t}\n\t}\n\n\t// ── Pattern dans items (single schema) ──\n\tif (\n\t\tisPlainObj(result.items) &&\n\t\ttypeof result.items !== \"boolean\" &&\n\t\tisPlainObj((sub as JSONSchema7).items) &&\n\t\ttypeof (sub as JSONSchema7).items !== \"boolean\"\n\t) {\n\t\tconst subItems = (sub as JSONSchema7).items as JSONSchema7;\n\t\tconst supItems = result.items as JSONSchema7;\n\t\tif (\n\t\t\thasOwn(supItems, \"pattern\") &&\n\t\t\thasOwn(subItems, \"pattern\") &&\n\t\t\tsupItems.pattern !== subItems.pattern\n\t\t) {\n\t\t\tconst itemsPatResult = isPatternSubset(\n\t\t\t\tsubItems.pattern as string,\n\t\t\t\tsupItems.pattern as string,\n\t\t\t);\n\t\t\tif (itemsPatResult === true) {\n\t\t\t\tensureCopy().items = omitKeys(\n\t\t\t\t\tsupItems as unknown as Record<string, unknown>,\n\t\t\t\t\t[\"pattern\"],\n\t\t\t\t) as JSONSchema7Definition;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ─── Atomic subset check ─────────────────────────────────────────────────────\n\n/**\n * Vérifie si `sub ⊆ sup` pour deux schemas sans anyOf/oneOf (ou avec\n * anyOf/oneOf uniquement côté sup).\n *\n * Point 7 — Intègre un pré-check `not` étendu (`evaluateNot`) avant le merge.\n *\n * Quand `evaluateNot` confirme la compatibilité (`true`), on retire le `not`\n * de `sup` avant le merge pour éviter que le merge engine ajoute une contrainte\n * `not` que `sub` n'a pas (ce qui ferait échouer `isEqual(merged, sub)`).\n *\n * Pattern pre-check — Quand les deux schemas ont des patterns différents,\n * vérifie l'inclusion par échantillonnage via `isPatternSubset`. Si confirmé,\n * retire le pattern de sup avant le merge (même stratégie que pour `not`).\n *\n * Principe : merge(sub, sup) ≡ sub → sub est un sous-ensemble de sup.\n *\n * Utilise `_.some`, `_.has`, `_.omit`, `_.keys`, `_.isEmpty` pour la logique.\n */\nexport function isAtomicSubsetOf(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n\tengine: MergeEngine,\n): boolean {\n\tconst { branches: supBranches } = getBranchesTyped(sup);\n\n\t// Schema simple → merge direct\n\tif (supBranches.length === 1 && supBranches[0] === sup) {\n\t\t// Point 7 : pré-check `not` étendu\n\t\tconst notResult = evaluateNot(sub, sup);\n\t\tif (notResult === false) return false;\n\n\t\t// ── Format pre-check ──\n\t\t// Si les deux schemas ont un `format` différent, vérifier que\n\t\t// sub.format ⊆ sup.format. Sinon, sub ne peut pas être ⊆ sup.\n\t\t// Cela complète hasFormatConflict (qui gère le merge) en gérant\n\t\t// la direction du subset check que le merge ne peut pas résoudre.\n\t\tif (\n\t\t\ttypeof sub !== \"boolean\" &&\n\t\t\ttypeof sup !== \"boolean\" &&\n\t\t\thasOwn(sub, \"format\") &&\n\t\t\thasOwn(sup, \"format\") &&\n\t\t\tsub.format !== sup.format\n\t\t) {\n\t\t\tconst fmtResult = isFormatSubset(\n\t\t\t\tsub.format as string,\n\t\t\t\tsup.format as string,\n\t\t\t);\n\t\t\tif (fmtResult !== true) return false;\n\t\t}\n\n\t\t// ── Pattern pre-check ──\n\t\t// Si les deux schemas ont des patterns différents, vérifier l'inclusion\n\t\t// par échantillonnage. Si sub.pattern ⊄ sup.pattern (contre-exemple trouvé),\n\t\t// on retourne false immédiatement. Sinon, on pourra retirer le pattern\n\t\t// de sup pour éviter le faux négatif structurel du merge.\n\t\tif (\n\t\t\ttypeof sub !== \"boolean\" &&\n\t\t\ttypeof sup !== \"boolean\" &&\n\t\t\thasOwn(sub, \"pattern\") &&\n\t\t\thasOwn(sup, \"pattern\") &&\n\t\t\tsub.pattern !== sup.pattern\n\t\t) {\n\t\t\tconst patResult = isPatternSubset(\n\t\t\t\tsub.pattern as string,\n\t\t\t\tsup.pattern as string,\n\t\t\t);\n\t\t\tif (patResult === false) return false;\n\t\t}\n\n\t\t// Retirer `not` de sup (top-level et/ou dans les properties)\n\t\t// quand evaluateNot confirme la compatibilité au niveau correspondant.\n\t\t// Cela évite que le merge engine ajoute une contrainte `not` que sub n'a pas\n\t\t// (ce qui ferait merged ≠ sub et produirait un faux négatif).\n\t\tlet effectiveSup = sup;\n\t\tif (typeof sup !== \"boolean\") {\n\t\t\t// Si top-level not est confirmé compatible → retirer le not top-level\n\t\t\tif (notResult === true) {\n\t\t\t\teffectiveSup = stripNotFromSup(sub, sup, true);\n\t\t\t\t// Si sup n'avait QUE `not` → sub est compatible (le not est résolu)\n\t\t\t\tif (\n\t\t\t\t\ttypeof effectiveSup !== \"boolean\" &&\n\t\t\t\t\tObject.keys(effectiveSup).length === 0\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Même si le top-level not n'est pas confirmé (null), on tente\n\t\t\t\t// de retirer les `not` dans les properties individuelles\n\t\t\t\t// sans toucher au `not` top-level\n\t\t\t\teffectiveSup = stripNotFromSup(sub, sup, false);\n\t\t\t}\n\n\t\t\t// Retirer les patterns de sup confirmés par échantillonnage.\n\t\t\t// Même stratégie que pour `not` : on retire la contrainte déjà\n\t\t\t// satisfaite par sub pour éviter que le merge produise un pattern\n\t\t\t// combiné (lookahead conjunction) structurellement ≠ sub.\n\t\t\teffectiveSup = stripPatternFromSup(sub, effectiveSup);\n\t\t}\n\n\t\tconst merged = engine.merge(sub, effectiveSup);\n\t\tif (merged === null) return false;\n\t\t// Fast path: if merged is already structurally equal to sub,\n\t\t// skip normalize entirely. This is the common case when sub ⊆ sup\n\t\t// (A ∩ B = A), saving O(n) normalize traversal on wide schemas.\n\t\tif (deepEqual(merged, sub)) return true;\n\t\t// Slow path: normalize to eliminate merge artifacts (e.g. redundant\n\t\t// enum when const is present), then compare.\n\t\tconst normalizedMerged = normalize(merged);\n\t\treturn (\n\t\t\tdeepEqual(normalizedMerged, sub) || engine.isEqual(normalizedMerged, sub)\n\t\t);\n\t}\n\n\t// anyOf/oneOf dans sup → au moins une branche doit accepter sub\n\treturn supBranches.some((branch) => {\n\t\t// Point 7 : pré-check `not` étendu par branche\n\t\tconst notResult = evaluateNot(sub, branch);\n\t\tif (notResult === false) return false;\n\n\t\t// ── Pattern pre-check par branche ──\n\t\tif (\n\t\t\ttypeof sub !== \"boolean\" &&\n\t\t\ttypeof branch !== \"boolean\" &&\n\t\t\thasOwn(sub, \"pattern\") &&\n\t\t\thasOwn(branch, \"pattern\") &&\n\t\t\tsub.pattern !== branch.pattern\n\t\t) {\n\t\t\tconst patResult = isPatternSubset(\n\t\t\t\tsub.pattern as string,\n\t\t\t\tbranch.pattern as string,\n\t\t\t);\n\t\t\tif (patResult === false) return false;\n\t\t}\n\n\t\t// Même logique de strip pour les branches\n\t\tlet effectiveBranch = branch;\n\t\tif (typeof branch !== \"boolean\") {\n\t\t\tif (notResult === true) {\n\t\t\t\teffectiveBranch = stripNotFromSup(sub, branch, true);\n\t\t\t\tif (\n\t\t\t\t\ttypeof effectiveBranch !== \"boolean\" &&\n\t\t\t\t\tObject.keys(effectiveBranch).length === 0\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\teffectiveBranch = stripNotFromSup(sub, branch, false);\n\t\t\t}\n\n\t\t\t// Strip patterns confirmés par échantillonnage\n\t\t\teffectiveBranch = stripPatternFromSup(sub, effectiveBranch);\n\t\t}\n\n\t\tconst merged = engine.merge(sub, effectiveBranch);\n\t\tif (merged === null) return false;\n\t\t// Fast path: skip normalize if merged already equals sub\n\t\tif (deepEqual(merged, sub)) return true;\n\t\tconst normalizedBranch = normalize(merged);\n\t\treturn (\n\t\t\tdeepEqual(normalizedBranch, sub) || engine.isEqual(normalizedBranch, sub)\n\t\t);\n\t});\n}\n\n// ─── Full subset check (with diffs) ─────────────────────────────────────────\n\n/**\n * Vérifie `sub ⊆ sup` pour un sub qui a des branches (anyOf/oneOf).\n * Chaque branche de sub doit être acceptée par sup.\n *\n * Point 6 — Utilise `getBranchesTyped` pour distinguer `anyOf[i]` de\n * `oneOf[i]` dans les paths de diff.\n *\n * Utilise `_.every` / `_.flatMap` / `_.map` pour une itération idiomatique.\n */\nexport function checkBranchedSub(\n\tsubBranches: JSONSchema7Definition[],\n\tsup: JSONSchema7Definition,\n\tengine: MergeEngine,\n\tbranchType: BranchType = \"anyOf\",\n): SubsetResult {\n\tconst allDiffs: SchemaDiff[] = [];\n\tlet allSubset = true;\n\n\t// Point 6 : utilise le type de branche réel pour le path\n\tconst branchLabel = branchType === \"none\" ? \"anyOf\" : branchType;\n\n\tfor (let i = 0; i < subBranches.length; i++) {\n\t\tconst branch = subBranches[i];\n\t\tif (branch === undefined) continue;\n\t\tif (!isAtomicSubsetOf(branch, sup, engine)) {\n\t\t\tallSubset = false;\n\t\t\tallDiffs.push({\n\t\t\t\tpath: `${branchLabel}[${i}]`,\n\t\t\t\ttype: \"changed\",\n\t\t\t\texpected: branch,\n\t\t\t\tactual: \"Branch not accepted by superset\",\n\t\t\t});\n\t\t}\n\t}\n\n\treturn {\n\t\tisSubset: allSubset,\n\t\tmerged: allSubset\n\t\t\t? branchType === \"oneOf\"\n\t\t\t\t? { oneOf: subBranches }\n\t\t\t\t: { anyOf: subBranches }\n\t\t\t: null,\n\t\tdiffs: allDiffs,\n\t};\n}\n\n/**\n * Vérifie `sub ⊆ sup` pour un sup qui a des branches (anyOf/oneOf).\n * Au moins une branche de sup doit accepter sub.\n *\n * Point 6 — Utilise le type de branche de sup pour des messages plus précis.\n *\n * Utilise `_.some` pour trouver la première branche compatible.\n */\nexport function checkBranchedSup(\n\tsub: JSONSchema7Definition,\n\tsupBranches: JSONSchema7Definition[],\n\tengine: MergeEngine,\n\tbranchType: BranchType = \"anyOf\",\n): SubsetResult {\n\tfor (const branch of supBranches) {\n\t\t// Strip patterns confirmés par échantillonnage avant le merge\n\t\tlet effectiveBranch = branch;\n\t\tif (typeof sub !== \"boolean\" && typeof branch !== \"boolean\") {\n\t\t\teffectiveBranch = stripPatternFromSup(sub, branch);\n\t\t}\n\t\tconst merged = engine.merge(sub, effectiveBranch);\n\t\tif (merged !== null) {\n\t\t\t// Fast path: skip normalize if merged already equals sub\n\t\t\tif (deepEqual(merged, sub)) {\n\t\t\t\treturn { isSubset: true, merged, diffs: [] };\n\t\t\t}\n\t\t\tconst normalizedMerged = normalize(merged);\n\t\t\tif (\n\t\t\t\tdeepEqual(normalizedMerged, sub) ||\n\t\t\t\tengine.isEqual(normalizedMerged, sub)\n\t\t\t) {\n\t\t\t\treturn { isSubset: true, merged, diffs: [] };\n\t\t\t}\n\t\t}\n\t}\n\n\t// Point 6 : message précis selon le type de branche\n\tconst branchLabel = branchType === \"none\" ? \"anyOf\" : branchType;\n\n\treturn {\n\t\tisSubset: false,\n\t\tmerged: null,\n\t\tdiffs: [\n\t\t\t{\n\t\t\t\tpath: \"$\",\n\t\t\t\ttype: \"changed\",\n\t\t\t\texpected: sub,\n\t\t\t\tactual: `No branch in superset's ${branchLabel} accepts this schema`,\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Vérifie `sub ⊆ sup` pour deux schemas atomiques (sans anyOf/oneOf).\n * Utilise `mergeOrThrow` pour capturer les erreurs d'incompatibilité.\n *\n * Utilise `deepEqual` pour la comparaison structurelle (avec short-circuit\n * par référence et comptage de clés).\n */\nexport function checkAtomic(\n\tsub: JSONSchema7Definition,\n\tsup: JSONSchema7Definition,\n\tengine: MergeEngine,\n): SubsetResult {\n\t// Strip patterns confirmés par échantillonnage avant le merge,\n\t// même stratégie que dans isAtomicSubsetOf pour éviter les faux négatifs\n\t// structurels causés par la conjonction de patterns en lookahead.\n\tlet effectiveSup = sup;\n\tif (typeof sub !== \"boolean\" && typeof sup !== \"boolean\") {\n\t\teffectiveSup = stripPatternFromSup(sub, sup);\n\t}\n\n\ttry {\n\t\tconst merged = engine.mergeOrThrow(sub, effectiveSup);\n\n\t\t// Fast path: skip normalize if merged already equals sub\n\t\tif (deepEqual(merged, sub)) {\n\t\t\treturn { isSubset: true, merged, diffs: [] };\n\t\t}\n\n\t\tconst normalizedMerged = normalize(merged);\n\n\t\tif (\n\t\t\tdeepEqual(normalizedMerged, sub) ||\n\t\t\tengine.isEqual(normalizedMerged, sub)\n\t\t) {\n\t\t\treturn { isSubset: true, merged: normalizedMerged, diffs: [] };\n\t\t}\n\n\t\tconst diffs = computeDiffs(sub, normalizedMerged, \"\");\n\t\treturn { isSubset: false, merged: normalizedMerged, diffs };\n\t} catch (e) {\n\t\treturn {\n\t\t\tisSubset: false,\n\t\t\tmerged: null,\n\t\t\tdiffs: [\n\t\t\t\t{\n\t\t\t\t\tpath: \"$\",\n\t\t\t\t\ttype: \"changed\",\n\t\t\t\t\texpected: sub,\n\t\t\t\t\tactual: `Incompatible: ${e instanceof Error ? e.message : String(e)}`,\n\t\t\t\t},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,EAAkB,CAAG,GAC/B,EAAO,QAAQ,EAAkB,CAAG,EAEpC,MAAO,CAAE,SAAU,GAAM,OAAQ,EAAkB,MAAO,CAAC,CAAE,EAG9D,IAAM,EAAQ,EAAa,EAAK,EAAkB,EAAE,EACpD,MAAO,CAAE,SAAU,GAAO,OAAQ,EAAkB,OAAM,EACzD,MAAO,EAAG,CACX,MAAO,CACN,SAAU,GACV,OAAQ,KACR,MAAO,CACN,CACC,KAAM,IACN,KAAM,UACN,SAAU,EACV,OAAQ,iBAAiB,aAAa,MAAQ,EAAE,QAAU,OAAO,CAAC,GACnE,CACD,CACD",
8
- "debugId": "B8207E42E9F16E9764756E2164756E21",
9
- "names": []
10
- }
@@ -1,5 +0,0 @@
1
- import{v as M,x as Q,z as W}from"./chunk-jkdzdb3r.js";var $=new Set(["items","additionalProperties","additionalItems","contains","propertyNames","not","if","then","else"]),C=new Set(["properties","patternProperties","dependencies"]);function T(z,A,F){return $.has(z)&&M(A)&&M(F)}function U(z,A,F){return C.has(z)&&M(A)&&M(F)}function X(z,A,F){if(typeof z==="boolean"||typeof A==="boolean"){if(z!==A)return[{path:F||"$",type:"changed",expected:z,actual:A}];return[]}let N=W(Object.keys(z),Object.keys(A)),H=[];for(let x of N){let G=F?`${F}.${x}`:x,w=z[x],v=A[x];if(w===void 0&&v!==void 0){H.push({path:G,type:"added",expected:void 0,actual:v});continue}if(w!==void 0&&v===void 0){H.push({path:G,type:"removed",expected:w,actual:void 0});continue}if(w!==void 0&&v!==void 0&&!Q(w,v)){if(T(x,w,v)){let B=X(w,v,G);for(let J of B)H.push(J);continue}if(U(x,w,v)){let B=q(w,v,G,x);for(let J of B)H.push(J);continue}H.push({path:G,type:"changed",expected:w,actual:v})}}return H}function q(z,A,F,N){let H=W(Object.keys(z),Object.keys(A)),x=[];for(let G of H){let w=`${F}.${G}`,v=z[G],B=A[G];if(v===void 0&&B!==void 0){x.push({path:w,type:"added",expected:void 0,actual:B});continue}if(v!==void 0&&B===void 0){x.push({path:w,type:"removed",expected:v,actual:void 0});continue}if(v!==void 0&&B!==void 0){if(N==="dependencies"&&(Array.isArray(v)||Array.isArray(B))){if(!Q(v,B))x.push({path:w,type:"changed",expected:v,actual:B});continue}let J=X(v,B,w);for(let Z of J)x.push(Z)}}return x}
2
- export{X as l};
3
-
4
- //# debugId=587A5E069FE6D21A64756E2164756E21
5
- //# sourceMappingURL=chunk-jybaxgmh.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/differ.ts"],
4
- "sourcesContent": [
5
- "import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport type { SchemaDiff } from \"./types\";\nimport { deepEqual, isPlainObj, unionStrings } from \"./utils\";\n\n// ─── Schema Differ ───────────────────────────────────────────────────────────\n//\n// Calcul des différences structurelles entre un schema original et son\n// intersection (merged). Utilisé pour produire des diagnostics lisibles\n// quand sub ⊄ sup.\n//\n// Utilise des méthodes natives JS pour des performances optimales.\n\n// ─── Recursive diff keys ─────────────────────────────────────────────────────\n\n/** Mots-clés dont la valeur est un sous-schema unique (récursion possible) */\nconst RECURSIVE_KEYS: ReadonlySet<string> = new Set([\n\t\"items\",\n\t\"additionalProperties\",\n\t\"additionalItems\",\n\t\"contains\",\n\t\"propertyNames\",\n\t\"not\",\n\t\"if\",\n\t\"then\",\n\t\"else\",\n]);\n\n/**\n * Mots-clés dont la valeur est un `Record<string, JSONSchema7Definition>`.\n * Chaque propriété est un sous-schema → récursion au niveau des clés.\n *\n * `dependencies` est inclus ici avec une gestion spéciale (forme tableau\n * vs forme schema) dans\n `computePropertyDiffs`.\n *\n * Point 3 — dependencies ajouté ici (avec gestion spéciale forme tableau).\n */\nconst PROPERTIES_LIKE_KEYS: ReadonlySet<string> = new Set([\n\t\"properties\",\n\t\"patternProperties\",\n\t\"dependencies\",\n]);\n\n// ─── Internal helpers ────────────────────────────────────────────────────────\n\n/**\n * Vérifie si on peut récurser dans un mot-clé single-schema :\n * la clé doit être dans RECURSIVE_KEYS et les deux valeurs doivent être\n * des objets (pas des tableaux, pas null).\n */\nfunction canRecurseInto(\n\tkey: string,\n\torigVal: unknown,\n\tmergedVal: unknown,\n): boolean {\n\treturn (\n\t\tRECURSIVE_KEYS.has(key) && isPlainObj(origVal) && isPlainObj(mergedVal)\n\t);\n}\n\n/**\n * Vérifie si un mot-clé est un objet de propriétés récursable.\n *\n * Utilise `_.includes` sur le Set pour une vérification concise.\n */\nfunction isPropertiesLikeObject(\n\tkey: string,\n\torigVal: unknown,\n\tmergedVal: unknown,\n): boolean {\n\treturn (\n\t\tPROPERTIES_LIKE_KEYS.has(key) &&\n\t\tisPlainObj(origVal) &&\n\t\tisPlainObj(mergedVal)\n\t);\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Compare un schema original avec sa version mergée et retourne la liste\n * des différences structurelles.\n *\n * @param original Le schema sub tel qu'il était avant le merge\n * @param merged Le schema résultant de l'intersection allOf(sub, sup)\n * @param path Chemin JSON-path courant (vide à la racine)\n *\n * Point 9 — Utilise `deepEqual` au lieu de `JSON.stringify` pour comparer\n * les valeurs, ce qui élimine la dépendance à l'ordre des clés.\n */\nexport function computeDiffs(\n\toriginal: JSONSchema7Definition,\n\tmerged: JSONSchema7Definition,\n\tpath: string,\n): SchemaDiff[] {\n\t// Cas boolean schemas\n\tif (typeof original === \"boolean\" || typeof merged === \"boolean\") {\n\t\tif (original !== merged) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: path || \"$\",\n\t\t\t\t\ttype: \"changed\",\n\t\t\t\t\texpected: original,\n\t\t\t\t\tactual: merged,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\treturn [];\n\t}\n\n\t// Collecter toutes les clés des deux schemas\n\tconst allKeys = unionStrings(\n\t\tObject.keys(original),\n\t\tObject.keys(merged),\n\t) as (keyof JSONSchema7)[];\n\n\tconst result: SchemaDiff[] = [];\n\tfor (const key of allKeys) {\n\t\tconst currentPath = path ? `${path}.${key}` : key;\n\t\tconst origVal = original[key];\n\t\tconst mergedVal = merged[key];\n\n\t\t// Clé ajoutée par le merge\n\t\tif (origVal === undefined && mergedVal !== undefined) {\n\t\t\tresult.push({\n\t\t\t\tpath: currentPath,\n\t\t\t\ttype: \"added\",\n\t\t\t\texpected: undefined,\n\t\t\t\tactual: mergedVal,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Clé supprimée par le merge\n\t\tif (origVal !== undefined && mergedVal === undefined) {\n\t\t\tresult.push({\n\t\t\t\tpath: currentPath,\n\t\t\t\ttype: \"removed\",\n\t\t\t\texpected: origVal,\n\t\t\t\tactual: undefined,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Les deux sont définies — vérifier si elles diffèrent\n\t\t// Point 9 : deepEqual pour une comparaison profonde indépendante de l'ordre des clés\n\t\tif (\n\t\t\torigVal !== undefined &&\n\t\t\tmergedVal !== undefined &&\n\t\t\t!deepEqual(origVal, mergedVal)\n\t\t) {\n\t\t\t// Récurser dans les sous-schemas uniques\n\t\t\tif (canRecurseInto(key, origVal, mergedVal)) {\n\t\t\t\tconst sub = computeDiffs(\n\t\t\t\t\torigVal as JSONSchema7Definition,\n\t\t\t\t\tmergedVal as JSONSchema7Definition,\n\t\t\t\t\tcurrentPath,\n\t\t\t\t);\n\t\t\t\tfor (const d of sub) result.push(d);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Récurser dans les objets de propriétés (properties, patternProperties, dependencies)\n\t\t\tif (isPropertiesLikeObject(key, origVal, mergedVal)) {\n\t\t\t\tconst sub = computePropertyDiffs(\n\t\t\t\t\torigVal as Record<string, JSONSchema7Definition>,\n\t\t\t\t\tmergedVal as Record<string, JSONSchema7Definition>,\n\t\t\t\t\tcurrentPath,\n\t\t\t\t\tkey,\n\t\t\t\t);\n\t\t\t\tfor (const d of sub) result.push(d);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Valeur scalaire ou structure non-récursable\n\t\t\tresult.push({\n\t\t\t\tpath: currentPath,\n\t\t\t\ttype: \"changed\",\n\t\t\t\texpected: origVal,\n\t\t\t\tactual: mergedVal,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ─── Property-level diffs ────────────────────────────────────────────────────\n\n/**\n * Calcule les diffs au niveau des propriétés d'un objet `properties`,\n * `patternProperties`, ou `dependencies`.\n *\n * Pour `dependencies` (Point 3), gère les deux formes :\n * - Forme 1 (tableau de strings) : comparaison directe via `deepEqual`\n * - Forme 2 (sous-schema) : récursion via `computeDiffs`\n *\n * Fusionne les clés des deux côtés et produit un tableau aplati de diffs.\n */\nfunction computePropertyDiffs(\n\toriginal: Record<string, JSONSchema7Definition | string[]>,\n\tmerged: Record<string, JSONSchema7Definition | string[]>,\n\tbasePath: string,\n\tparentKey: string,\n): SchemaDiff[] {\n\tconst allPropKeys = unionStrings(Object.keys(original), Object.keys(merged));\n\n\tconst result: SchemaDiff[] = [];\n\tfor (const key of allPropKeys) {\n\t\tconst currentPath = `${basePath}.${key}`;\n\t\tconst origVal = original[key];\n\t\tconst mergedVal = merged[key];\n\n\t\tif (origVal === undefined && mergedVal !== undefined) {\n\t\t\tresult.push({\n\t\t\t\tpath: currentPath,\n\t\t\t\ttype: \"added\",\n\t\t\t\texpected: undefined,\n\t\t\t\tactual: mergedVal,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (origVal !== undefined && mergedVal === undefined) {\n\t\t\tresult.push({\n\t\t\t\tpath: currentPath,\n\t\t\t\ttype: \"removed\",\n\t\t\t\texpected: origVal,\n\t\t\t\tactual: undefined,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (origVal !== undefined && mergedVal !== undefined) {\n\t\t\t// Pour `dependencies`, les valeurs peuvent être des tableaux de strings (forme 1)\n\t\t\t// On ne récurse que si les deux valeurs sont des objets (sous-schemas)\n\t\t\tif (\n\t\t\t\tparentKey === \"dependencies\" &&\n\t\t\t\t(Array.isArray(origVal) || Array.isArray(mergedVal))\n\t\t\t) {\n\t\t\t\t// Comparaison directe pour les tableaux de strings\n\t\t\t\tif (!deepEqual(origVal, mergedVal)) {\n\t\t\t\t\tresult.push({\n\t\t\t\t\t\tpath: currentPath,\n\t\t\t\t\t\ttype: \"changed\",\n\t\t\t\t\t\texpected: origVal,\n\t\t\t\t\t\tactual: mergedVal,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Récursion standard pour les sous-schemas\n\t\t\tconst sub = computeDiffs(\n\t\t\t\torigVal as JSONSchema7Definition,\n\t\t\t\tmergedVal as JSONSchema7Definition,\n\t\t\t\tcurrentPath,\n\t\t\t);\n\t\t\tfor (const d of sub) result.push(d);\n\t\t}\n\t}\n\n\treturn result;\n}\n"
6
- ],
7
- "mappings": "sDAeA,IAAM,EAAsC,IAAI,IAAI,CACnD,QACA,uBACA,kBACA,WACA,gBACA,MACA,KACA,OACA,MACD,CAAC,EAYK,EAA4C,IAAI,IAAI,CACzD,aACA,oBACA,cACD,CAAC,EASD,SAAS,CAAc,CACtB,EACA,EACA,EACU,CACV,OACC,EAAe,IAAI,CAAG,GAAK,EAAW,CAAO,GAAK,EAAW,CAAS,EASxE,SAAS,CAAsB,CAC9B,EACA,EACA,EACU,CACV,OACC,EAAqB,IAAI,CAAG,GAC5B,EAAW,CAAO,GAClB,EAAW,CAAS,EAiBf,SAAS,CAAY,CAC3B,EACA,EACA,EACe,CAEf,GAAI,OAAO,IAAa,WAAa,OAAO,IAAW,UAAW,CACjE,GAAI,IAAa,EAChB,MAAO,CACN,CACC,KAAM,GAAQ,IACd,KAAM,UACN,SAAU,EACV,OAAQ,CACT,CACD,EAED,MAAO,CAAC,EAIT,IAAM,EAAU,EACf,OAAO,KAAK,CAAQ,EACpB,OAAO,KAAK,CAAM,CACnB,EAEM,EAAuB,CAAC,EAC9B,QAAW,KAAO,EAAS,CAC1B,IAAM,EAAc,EAAO,GAAG,KAAQ,IAAQ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CAAS,GACjD,CAED,GAAI,CAAC,EAAU,EAAS,CAAS,EAChC,EAAO,KAAK,CACX,KAAM,EACN,KAAM,UACN,SAAU,EACV,OAAQ,CACT,CAAC,EAEF,SAID,IAAM,EAAM,EACX,EACA,EACA,CACD,EACA,QAAW,KAAK,EAAK,EAAO,KAAK,CAAC,GAIpC,OAAO",
8
- "debugId": "587A5E069FE6D21A64756E2164756E21",
9
- "names": []
10
- }
@@ -1,6 +0,0 @@
1
- function B(j){switch(j.type){case"added":return` + ${j.path}: ${JSON.stringify(j.actual)}`;case"removed":return` - ${j.path}: was ${JSON.stringify(j.expected)}`;default:return` ~ ${j.path}: ${JSON.stringify(j.expected)} → ${JSON.stringify(j.actual)}`}}function G(j,w){let z=[`${w.isSubset?"✅":"❌"} ${j}: ${w.isSubset}`];if(!w.isSubset&&w.diffs.length>0){z.push(" Diffs:");for(let A of w.diffs)z.push(` ${B(A)}`)}return z.join(`
2
- `)}
3
- export{G as m};
4
-
5
- //# debugId=A2490CE4A5AB928D64756E2164756E21
6
- //# sourceMappingURL=chunk-y8c2z1m3.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/formatter.ts"],
4
- "sourcesContent": [
5
- "import type { SubsetResult } from \"./types\";\n\n// ─── Result Formatter ────────────────────────────────────────────────────────\n//\n// Formate un `SubsetResult` en chaîne lisible pour logs / debug.\n\n/**\n * Formate un diff individuel en ligne lisible avec préfixe iconique.\n *\n * @param d Le diff à formater\n * @returns Ligne formatée avec +, - ou ~ selon le type\n */\nfunction formatDiffLine(d: {\n\ttype: string;\n\tpath: string;\n\texpected: unknown;\n\tactual: unknown;\n}): string {\n\tswitch (d.type) {\n\t\tcase \"added\":\n\t\t\treturn ` + ${d.path}: ${JSON.stringify(d.actual)}`;\n\t\tcase \"removed\":\n\t\t\treturn ` - ${d.path}: was ${JSON.stringify(d.expected)}`;\n\t\tdefault:\n\t\t\treturn ` ~ ${d.path}: ${JSON.stringify(d.expected)} → ${JSON.stringify(d.actual)}`;\n\t}\n}\n\n/**\n * Formate un SubsetResult en chaîne lisible (utile pour logs/debug).\n *\n * @param label Label descriptif du check (ex: \"strict ⊆ loose\")\n * @param result Le résultat du check à formater\n * @returns Chaîne multi-lignes formatée avec icônes et diffs\n *\n * @example\n * ```\n * ✅ strict ⊆ loose: true\n * ```\n *\n * @example\n * ```\n * ❌ loose ⊆ strict: false\n * Diffs:\n * ~ required: [\"name\"] → [\"name\",\"age\"]\n * + properties.age: {\"type\":\"number\"}\n * ```\n */\nexport function formatResult(label: string, result: SubsetResult): string {\n\tconst icon = result.isSubset ? \"✅\" : \"❌\";\n\tconst lines: string[] = [`${icon} ${label}: ${result.isSubset}`];\n\n\tif (!result.isSubset && result.diffs.length > 0) {\n\t\tlines.push(\" Diffs:\");\n\n\t\tfor (const d of result.diffs) {\n\t\t\tlines.push(` ${formatDiffLine(d)}`);\n\t\t}\n\t}\n\n\treturn lines.join(\"\\n\");\n}\n"
6
- ],
7
- "mappings": "AAYA,SAAS,CAAc,CAAC,EAKb,CACV,OAAQ,EAAE,UACJ,QACJ,MAAO,OAAO,EAAE,SAAS,KAAK,UAAU,EAAE,MAAM,QAC5C,UACJ,MAAO,OAAO,EAAE,aAAa,KAAK,UAAU,EAAE,QAAQ,YAEtD,MAAO,OAAO,EAAE,SAAS,KAAK,UAAU,EAAE,QAAQ,OAAM,KAAK,UAAU,EAAE,MAAM,KAwB3E,SAAS,CAAY,CAAC,EAAe,EAA8B,CAEzE,IAAM,EAAkB,CAAC,GADZ,EAAO,SAAW,IAAK,OACA,MAAU,EAAO,UAAU,EAE/D,GAAI,CAAC,EAAO,UAAY,EAAO,MAAM,OAAS,EAAG,CAChD,EAAM,KAAK,WAAW,EAEtB,QAAW,KAAK,EAAO,MACtB,EAAM,KAAK,QAAQ,EAAe,CAAC,GAAG,EAIxC,OAAO,EAAM,KAAK;AAAA,CAAI",
8
- "debugId": "A2490CE4A5AB928D64756E2164756E21",
9
- "names": []
10
- }
@@ -1,5 +0,0 @@
1
- import{s as q}from"./chunk-07z7fc5q.js";import{v as x,w as X,x as _}from"./chunk-jkdzdb3r.js";import{createComparator as K,createMerger as T,createShallowAllOfMerge as E}from"@x0k/json-schema-merge";import{createDeduplicator as I,createIntersector as V}from"@x0k/json-schema-merge/lib/array";function j(z,B){if(typeof z==="boolean"||typeof B==="boolean")return!1;let Q=X(z,"const"),J=X(B,"const"),U=z.const,Z=B.const,G=z.enum,Y=B.enum;if(Q&&J)return!_(U,Z);if(Q&&Array.isArray(Y))return!Y.some(($)=>_($,U));if(J&&Array.isArray(G))return!G.some(($)=>_($,Z));return!1}var F=["items","additionalProperties","contains","propertyNames","not"],M=["properties","patternProperties"];function v(z,B){if(j(z,B))return!0;if(typeof z==="boolean"||typeof B==="boolean")return!1;for(let Q of F){let J=z[Q],U=B[Q];if(x(J)&&x(U)&&v(J,U))return!0}for(let Q of M){let J=z[Q],U=B[Q];if(!x(J)||!x(U))continue;let Z=J,G=U;for(let Y of Object.keys(Z)){let $=Z[Y],W=G[Y];if($!==void 0&&W!==void 0&&X(G,Y)&&v($,W))return!0}}if(Array.isArray(z.items)&&Array.isArray(B.items)){let Q=z.items,J=B.items,U=Math.min(Q.length,J.length);for(let Z=0;Z<U;Z++){let G=Q[Z],Y=J[Z];if(G===void 0||Y===void 0)continue;if(v(G,Y))return!0}}return!1}function A(z,B){if(typeof z==="boolean"||typeof B==="boolean")return!1;let Q=x(z.properties)?z.properties:void 0,J=x(B.properties)?B.properties:void 0;if(!Q&&!J)return!1;let U=Q?Object.keys(Q):[],Z=J?Object.keys(J):[],G=Array.isArray(z.required)?z.required:[],Y=Array.isArray(B.required)?B.required:[];if(z.additionalProperties===!1&&Q&&J){if(Y.some((W)=>!X(Q,W)&&X(J,W))&&U.length>0)return!0}if(x(z.additionalProperties)&&typeof z.additionalProperties!=="boolean"&&Q&&J){let $=z.additionalProperties;if(X($,"type")){let W=$.type;if(Y.some((N)=>{if(X(Q,N))return!1;if(!X(J,N))return!1;let g=J[N];if(typeof g==="boolean")return!1;let L=g;if(!X(L,"type"))return!1;if(typeof W==="string"&&typeof L.type==="string")return W!==L.type&&!(W==="number"&&L.type==="integer")&&!(W==="integer"&&L.type==="number");return!1}))return!0}}if(B.additionalProperties===!1&&J&&Q){if(G.some((W)=>!X(J,W)&&X(Q,W))&&Z.length>0)return!0}if(x(B.additionalProperties)&&typeof B.additionalProperties!=="boolean"&&J&&Q){let $=B.additionalProperties;if(X($,"type")){let W=$.type;if(G.some((N)=>{if(X(J,N))return!1;if(!X(Q,N))return!1;let g=Q[N];if(typeof g==="boolean")return!1;let L=g;if(!X(L,"type"))return!1;if(typeof W==="string"&&typeof L.type==="string")return W!==L.type&&!(W==="number"&&L.type==="integer")&&!(W==="integer"&&L.type==="number");return!1}))return!0}}if(Q&&J)for(let $ of U){if(!X(J,$))continue;let W=Q[$],R=J[$];if(typeof W==="boolean"||typeof R==="boolean")continue;if(A(W,R))return!0}return!1}function H(z,B){if(typeof z==="boolean"||typeof B==="boolean")return!1;if(X(z,"format")&&X(B,"format")){let Q=z.format,J=B.format;if(Q!==J){if(q(Q,J)!==!0){if(q(J,Q)!==!0)return!0}}}if(x(z.properties)&&x(B.properties)){let Q=z.properties,J=B.properties;for(let U of Object.keys(Q)){let Z=Q[U],G=J[U];if(Z!==void 0&&G!==void 0&&X(J,U)&&H(Z,G))return!0}}if(x(z.items)&&x(B.items)){if(H(z.items,B.items))return!0}if(x(z.additionalProperties)&&x(B.additionalProperties)){if(H(z.additionalProperties,B.additionalProperties))return!0}return!1}class u{compareFn;shallowAllOfMergeFn;constructor(){let{compareSchemaDefinitions:z,compareSchemaValues:B}=K(),Q=(U,Z)=>{if(U===null&&Z===null)return 0;return B(U,Z)},{mergeArrayOfSchemaDefinitions:J}=T({intersectJson:V(Q),deduplicateJsonSchemaDef:I(z)});this.compareFn=z,this.shallowAllOfMergeFn=E(J)}merge(z,B){if(v(z,B))return null;if(H(z,B))return null;if(A(z,B))return null;try{return this.shallowAllOfMergeFn({allOf:[z,B]})}catch{return null}}mergeOrThrow(z,B){if(v(z,B))throw Error("Incompatible const values: schemas have conflicting const constraints");if(H(z,B))throw Error("Incompatible format values: schemas have conflicting format constraints");if(A(z,B))throw Error("Incompatible additionalProperties: required properties conflict with additionalProperties constraint");return this.shallowAllOfMergeFn({allOf:[z,B]})}compare(z,B){return this.compareFn(z,B)}isEqual(z,B){return this.compareFn(z,B)===0}}
2
- export{u as n};
3
-
4
- //# debugId=4666F85E3B6FD5BA64756E2164756E21
5
- //# sourceMappingURL=chunk-yg81ax5m.js.map