@prisma-next/contract 0.3.0-pr.99.5 → 0.3.0

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 (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +43 -254
  3. package/dist/contract-types-MYdoYIIh.d.mts +314 -0
  4. package/dist/contract-types-MYdoYIIh.d.mts.map +1 -0
  5. package/dist/hashing-CyaA_Qvf.mjs +196 -0
  6. package/dist/hashing-CyaA_Qvf.mjs.map +1 -0
  7. package/dist/hashing.d.mts +29 -0
  8. package/dist/hashing.d.mts.map +1 -0
  9. package/dist/hashing.mjs +3 -0
  10. package/dist/testing.d.mts +29 -0
  11. package/dist/testing.d.mts.map +1 -0
  12. package/dist/testing.mjs +58 -0
  13. package/dist/testing.mjs.map +1 -0
  14. package/dist/types-aMyNgejf.mjs +14 -0
  15. package/dist/types-aMyNgejf.mjs.map +1 -0
  16. package/dist/types.d.mts +2 -2
  17. package/dist/types.mjs +2 -10
  18. package/dist/validate-contract.d.mts +37 -0
  19. package/dist/validate-contract.d.mts.map +1 -0
  20. package/dist/validate-contract.mjs +3 -0
  21. package/dist/validate-domain-CpCcTlqJ.mjs +165 -0
  22. package/dist/validate-domain-CpCcTlqJ.mjs.map +1 -0
  23. package/dist/validate-domain.d.mts +24 -0
  24. package/dist/validate-domain.d.mts.map +1 -0
  25. package/dist/validate-domain.mjs +3 -0
  26. package/package.json +15 -8
  27. package/schemas/data-contract-document-v1.json +5 -5
  28. package/src/canonicalization.ts +263 -0
  29. package/src/contract-types.ts +55 -0
  30. package/src/domain-types.ts +95 -0
  31. package/src/exports/hashing.ts +2 -0
  32. package/src/exports/testing.ts +1 -0
  33. package/src/exports/types.ts +36 -20
  34. package/src/exports/validate-contract.ts +6 -0
  35. package/src/exports/validate-domain.ts +5 -0
  36. package/src/hashing.ts +53 -0
  37. package/src/testing-factories.ts +101 -0
  38. package/src/types.ts +102 -248
  39. package/src/validate-contract.ts +101 -0
  40. package/src/validate-domain.ts +227 -0
  41. package/dist/framework-components-B-XOtXw3.d.mts +0 -854
  42. package/dist/framework-components-B-XOtXw3.d.mts.map +0 -1
  43. package/dist/framework-components.d.mts +0 -2
  44. package/dist/framework-components.mjs +0 -70
  45. package/dist/framework-components.mjs.map +0 -1
  46. package/dist/ir-B8zNqals.d.mts +0 -79
  47. package/dist/ir-B8zNqals.d.mts.map +0 -1
  48. package/dist/ir.d.mts +0 -2
  49. package/dist/ir.mjs +0 -46
  50. package/dist/ir.mjs.map +0 -1
  51. package/dist/pack-manifest-types.d.mts +0 -2
  52. package/dist/pack-manifest-types.mjs +0 -1
  53. package/dist/types.mjs.map +0 -1
  54. package/src/exports/framework-components.ts +0 -36
  55. package/src/exports/ir.ts +0 -1
  56. package/src/exports/pack-manifest-types.ts +0 -6
  57. package/src/framework-components.ts +0 -717
  58. package/src/ir.ts +0 -113
@@ -0,0 +1,314 @@
1
+ //#region src/domain-types.d.ts
2
+ type ScalarFieldType = {
3
+ readonly kind: 'scalar';
4
+ readonly codecId: string;
5
+ readonly typeParams?: Record<string, unknown>;
6
+ };
7
+ type ValueObjectFieldType = {
8
+ readonly kind: 'valueObject';
9
+ readonly name: string;
10
+ };
11
+ type UnionFieldType = {
12
+ readonly kind: 'union';
13
+ readonly members: ReadonlyArray<ScalarFieldType | ValueObjectFieldType>;
14
+ };
15
+ type ContractFieldType = ScalarFieldType | ValueObjectFieldType | UnionFieldType;
16
+ type ContractField = {
17
+ readonly nullable: boolean;
18
+ readonly type: ContractFieldType;
19
+ readonly many?: true;
20
+ readonly dict?: true;
21
+ };
22
+ type ContractRelationOn = {
23
+ readonly localFields: readonly string[];
24
+ readonly targetFields: readonly string[];
25
+ };
26
+ type ContractReferenceRelation = {
27
+ readonly to: string;
28
+ readonly cardinality: '1:1' | '1:N' | 'N:1';
29
+ readonly on: ContractRelationOn;
30
+ };
31
+ type ContractEmbedRelation = {
32
+ readonly to: string;
33
+ readonly cardinality: '1:1' | '1:N';
34
+ };
35
+ type ContractRelation = ContractReferenceRelation | ContractEmbedRelation;
36
+ type ContractDiscriminator = {
37
+ readonly field: string;
38
+ };
39
+ type ContractVariantEntry = {
40
+ readonly value: string;
41
+ };
42
+ type ContractValueObject = {
43
+ readonly fields: Record<string, ContractField>;
44
+ };
45
+ type ModelStorageBase = Readonly<Record<string, unknown>>;
46
+ interface ContractModelBase<TModelStorage extends ModelStorageBase = ModelStorageBase> {
47
+ readonly fields: Record<string, ContractField>;
48
+ readonly relations: Record<string, ContractRelation>;
49
+ readonly storage: TModelStorage;
50
+ readonly discriminator?: ContractDiscriminator;
51
+ readonly variants?: Record<string, ContractVariantEntry>;
52
+ readonly base?: string;
53
+ readonly owner?: string;
54
+ }
55
+ interface ContractModel<TModelStorage extends ModelStorageBase = ModelStorageBase> extends ContractModelBase<TModelStorage> {
56
+ readonly fields: Record<string, ContractField>;
57
+ }
58
+ type HasModelsWithRelations = {
59
+ readonly models: Record<string, {
60
+ readonly relations: Record<string, ContractRelation>;
61
+ }>;
62
+ };
63
+ type ReferenceRelationKeys<TContract extends HasModelsWithRelations, ModelName extends string & keyof TContract['models']> = { [K in keyof TContract['models'][ModelName]['relations']]: TContract['models'][ModelName]['relations'][K] extends ContractReferenceRelation ? K : never }[keyof TContract['models'][ModelName]['relations']];
64
+ type EmbedRelationKeys<TContract extends HasModelsWithRelations, ModelName extends string & keyof TContract['models']> = { [K in keyof TContract['models'][ModelName]['relations']]: TContract['models'][ModelName]['relations'][K] extends ContractReferenceRelation ? never : K }[keyof TContract['models'][ModelName]['relations']];
65
+ //#endregion
66
+ //#region src/types.d.ts
67
+ /**
68
+ * Unique symbol used as the key for branding types.
69
+ */
70
+ declare const $: unique symbol;
71
+ /**
72
+ * A helper type to brand a given type with a unique identifier.
73
+ *
74
+ * @template TKey Text used as the brand key.
75
+ * @template TValue Optional value associated with the brand key. Defaults to `true`.
76
+ */
77
+ type Brand<TKey extends string | number | symbol, TValue = true> = {
78
+ [$]: { [K in TKey]: TValue };
79
+ };
80
+ /**
81
+ * Base type for storage contract hashes.
82
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
83
+ * `type StorageHash = StorageHashBase<'sha256:abc123...'>`
84
+ */
85
+ type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;
86
+ /**
87
+ * Base type for execution contract hashes.
88
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
89
+ * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`
90
+ */
91
+ type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;
92
+ declare function executionHash<const T extends string>(value: T): ExecutionHashBase<T>;
93
+ declare function coreHash<const T extends string>(value: T): StorageHashBase<T>;
94
+ /**
95
+ * Base type for profile contract hashes.
96
+ * Emitted contract.d.ts files use this with the hash value as a type parameter:
97
+ * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`
98
+ */
99
+ type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
100
+ declare function profileHash<const T extends string>(value: T): ProfileHashBase<T>;
101
+ /**
102
+ * Base type for family-specific storage blocks.
103
+ * Family storage types (SqlStorage, MongoStorage, etc.) extend this to carry the
104
+ * storage hash alongside family-specific data (tables, collections, etc.).
105
+ */
106
+ interface StorageBase<THash extends string = string> {
107
+ readonly storageHash: StorageHashBase<THash>;
108
+ }
109
+ interface FieldType {
110
+ readonly type: string;
111
+ readonly nullable: boolean;
112
+ readonly items?: FieldType;
113
+ readonly properties?: Record<string, FieldType>;
114
+ }
115
+ type GeneratedValueSpec = {
116
+ readonly id: string;
117
+ readonly params?: Record<string, unknown>;
118
+ };
119
+ type JsonPrimitive = string | number | boolean | null;
120
+ type JsonValue = JsonPrimitive | {
121
+ readonly [key: string]: JsonValue;
122
+ } | readonly JsonValue[];
123
+ type ColumnDefaultLiteralValue = JsonValue;
124
+ type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | Date;
125
+ type ColumnDefault = {
126
+ readonly kind: 'literal';
127
+ readonly value: ColumnDefaultLiteralInputValue;
128
+ } | {
129
+ readonly kind: 'function';
130
+ readonly expression: string;
131
+ };
132
+ type ExecutionMutationDefaultValue = {
133
+ readonly kind: 'generator';
134
+ readonly id: GeneratedValueSpec['id'];
135
+ readonly params?: Record<string, unknown>;
136
+ };
137
+ type ExecutionMutationDefault = {
138
+ readonly ref: {
139
+ readonly table: string;
140
+ readonly column: string;
141
+ };
142
+ readonly onCreate?: ExecutionMutationDefaultValue;
143
+ readonly onUpdate?: ExecutionMutationDefaultValue;
144
+ };
145
+ type ExecutionSection<THash extends string = string> = {
146
+ readonly executionHash: ExecutionHashBase<THash>;
147
+ readonly mutations: {
148
+ readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
149
+ };
150
+ };
151
+ interface Source {
152
+ readonly readOnly: boolean;
153
+ readonly projection: Record<string, FieldType>;
154
+ readonly origin?: Record<string, unknown>;
155
+ readonly capabilities?: Record<string, boolean>;
156
+ }
157
+ interface DocIndex {
158
+ readonly name: string;
159
+ readonly keys: Record<string, 'asc' | 'desc'>;
160
+ readonly unique?: boolean;
161
+ readonly where?: Expr;
162
+ }
163
+ type Expr = {
164
+ readonly kind: 'eq';
165
+ readonly path: ReadonlyArray<string>;
166
+ readonly value: unknown;
167
+ } | {
168
+ readonly kind: 'exists';
169
+ readonly path: ReadonlyArray<string>;
170
+ };
171
+ interface DocCollection {
172
+ readonly name: string;
173
+ readonly id?: {
174
+ readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';
175
+ };
176
+ readonly fields: Record<string, FieldType>;
177
+ readonly indexes?: ReadonlyArray<DocIndex>;
178
+ readonly readOnly?: boolean;
179
+ }
180
+ interface ParamDescriptor {
181
+ readonly index?: number;
182
+ readonly name?: string;
183
+ readonly codecId?: string;
184
+ readonly nativeType?: string;
185
+ readonly nullable?: boolean;
186
+ readonly source: 'dsl' | 'raw' | 'lane';
187
+ readonly refs?: {
188
+ table: string;
189
+ column: string;
190
+ };
191
+ }
192
+ interface PlanRefs {
193
+ readonly tables?: readonly string[];
194
+ readonly columns?: ReadonlyArray<{
195
+ table: string;
196
+ column: string;
197
+ }>;
198
+ readonly indexes?: ReadonlyArray<{
199
+ readonly table: string;
200
+ readonly columns: ReadonlyArray<string>;
201
+ readonly name?: string;
202
+ }>;
203
+ }
204
+ interface PlanMeta {
205
+ readonly target: string;
206
+ readonly targetFamily?: string;
207
+ readonly storageHash: string;
208
+ readonly profileHash?: string;
209
+ readonly lane: string;
210
+ readonly annotations?: {
211
+ codecs?: Record<string, string>;
212
+ [key: string]: unknown;
213
+ };
214
+ readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;
215
+ readonly refs?: PlanRefs;
216
+ readonly projection?: Record<string, string> | ReadonlyArray<string>;
217
+ /**
218
+ * Optional mapping of projection alias → column type ID (fully qualified ns/name@version).
219
+ * Used for codec resolution when AST+refs don't provide enough type info.
220
+ */
221
+ readonly projectionTypes?: Record<string, string>;
222
+ }
223
+ /**
224
+ * Canonical execution plan shape used by runtimes.
225
+ *
226
+ * - Row is the inferred result row type (TypeScript-only).
227
+ * - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).
228
+ *
229
+ * The payload executed by the runtime is represented by the sql + params pair
230
+ * for now; future families can specialize this via Ast or additional metadata.
231
+ */
232
+ interface ExecutionPlan<Row = unknown, Ast = unknown> {
233
+ readonly sql: string;
234
+ readonly params: readonly unknown[];
235
+ readonly ast?: Ast;
236
+ readonly meta: PlanMeta;
237
+ /**
238
+ * Phantom property to carry the Row generic for type-level utilities.
239
+ * Not set at runtime; used only for ResultType extraction.
240
+ */
241
+ readonly _row?: Row;
242
+ }
243
+ /**
244
+ * Utility type to extract the Row type from an ExecutionPlan.
245
+ * Example: `type Row = ResultType<typeof plan>`
246
+ *
247
+ * Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).
248
+ * SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter
249
+ * for type extraction.
250
+ */
251
+ type ResultType<P> = P extends ExecutionPlan<infer R, unknown> ? R : P extends {
252
+ readonly _Row?: infer R;
253
+ } ? R : never;
254
+ /**
255
+ * Contract marker record stored in the database.
256
+ * Represents the current contract identity for a database.
257
+ */
258
+ interface ContractMarkerRecord {
259
+ readonly storageHash: string;
260
+ readonly profileHash: string;
261
+ readonly contractJson: unknown | null;
262
+ readonly canonicalVersion: number | null;
263
+ readonly updatedAt: Date;
264
+ readonly appTag: string | null;
265
+ readonly meta: Record<string, unknown>;
266
+ }
267
+ //#endregion
268
+ //#region src/contract-types.d.ts
269
+ /**
270
+ * Execution section for the unified contract (ADR 182).
271
+ *
272
+ * Unlike the legacy {@link import('./types').ExecutionSection}, this type
273
+ * requires `executionHash` — when an execution section is present, its
274
+ * hash must be too (consistent with `StorageBase.storageHash`).
275
+ *
276
+ * @template THash Literal hash string type for type-safe hash tracking.
277
+ */
278
+ type ContractExecutionSection<THash extends string = string> = {
279
+ readonly executionHash: ExecutionHashBase<THash>;
280
+ readonly mutations: {
281
+ readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
282
+ };
283
+ };
284
+ /**
285
+ * Unified contract representation (ADR 182).
286
+ *
287
+ * A `Contract` is the canonical in-memory representation of a data contract.
288
+ * It is model-first (domain models carry their own storage bridge) and
289
+ * family-parameterized (SQL, Mongo, etc. specialize via `TStorage` and model
290
+ * storage generics on `ContractModel`).
291
+ *
292
+ * JSON persistence fields (`schemaVersion`, `sources`) are not represented
293
+ * here — they are handled at the serialization boundary.
294
+ *
295
+ * @template TStorage Family-specific storage block (extends {@link StorageBase}).
296
+ * @template TModels Record of model name → {@link ContractModel} with
297
+ * family-specific model storage.
298
+ */
299
+ interface Contract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModelBase>> {
300
+ readonly target: string;
301
+ readonly targetFamily: string;
302
+ readonly roots: Record<string, string>;
303
+ readonly models: TModels;
304
+ readonly valueObjects?: Record<string, ContractValueObject>;
305
+ readonly storage: TStorage;
306
+ readonly capabilities: Record<string, Record<string, boolean>>;
307
+ readonly extensionPacks: Record<string, unknown>;
308
+ readonly execution?: ContractExecutionSection;
309
+ readonly profileHash: ProfileHashBase<string>;
310
+ readonly meta: Record<string, unknown>;
311
+ }
312
+ //#endregion
313
+ export { executionHash as A, ContractRelationOn as B, PlanRefs as C, StorageBase as D, Source as E, ContractFieldType as F, ReferenceRelationKeys as G, ContractVariantEntry as H, ContractModel as I, ValueObjectFieldType as J, ScalarFieldType as K, ContractModelBase as L, ContractDiscriminator as M, ContractEmbedRelation as N, StorageHashBase as O, ContractField as P, ContractReferenceRelation as R, PlanMeta as S, ResultType as T, EmbedRelationKeys as U, ContractValueObject as V, ModelStorageBase as W, FieldType as _, ColumnDefault as a, JsonValue as b, ContractMarkerRecord as c, ExecutionHashBase as d, ExecutionMutationDefault as f, Expr as g, ExecutionSection as h, Brand as i, profileHash as j, coreHash as k, DocCollection as l, ExecutionPlan as m, ContractExecutionSection as n, ColumnDefaultLiteralInputValue as o, ExecutionMutationDefaultValue as p, UnionFieldType as q, $ as r, ColumnDefaultLiteralValue as s, Contract as t, DocIndex as u, GeneratedValueSpec as v, ProfileHashBase as w, ParamDescriptor as x, JsonPrimitive as y, ContractRelation as z };
314
+ //# sourceMappingURL=contract-types-MYdoYIIh.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-types-MYdoYIIh.d.mts","names":[],"sources":["../src/domain-types.ts","../src/types.ts","../src/contract-types.ts"],"sourcesContent":[],"mappings":";KAAY,eAAA;EAAA,SAAA,IAAA,EAAA,QAAe;EAMf,SAAA,OAAA,EAAA,MAAoB;EAKpB,SAAA,UAAc,CAAA,EARF,MAQE,CAAA,MAAA,EAAA,OAAA,CAAA;CAEQ;AAAkB,KAPxC,oBAAA,GAOwC;EAAhC,SAAA,IAAA,EAAA,aAAA;EAAa,SAAA,IAAA,EAAA,MAAA;AAGjC,CAAA;AAAgC,KALpB,cAAA,GAKoB;EAAkB,SAAA,IAAA,EAAA,OAAA;EAAuB,SAAA,OAAA,EAHrD,aAGqD,CAHv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5C,SAAA,YAAA,CAAA,EErBF,MFqBE,CAAA,MAAA,EErBa,mBFqBb,CAAA;EACM,SAAA,OAAA,EErBd,QFqBc;EAAf,SAAA,YAAA,EEpBM,MFoBN,CAAA,MAAA,EEpBqB,MFoBrB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EADT,SAAA,cAAA,EElBiB,MFkBjB,CAAA,MAAA,EAAA,OAAA,CAAA;EAAiB,SAAA,SAAA,CAAA,EEjBJ,wBFiBI;EAMtB,SAAA,WAAA,EEtBmB,eFsBG,CAAA,MAAA,CAAA;EAC4C,SAAA,IAAA,EEtBtD,MFsBsD,CAAA,MAAA,EAAA,OAAA,CAAA"}
@@ -0,0 +1,196 @@
1
+ import { isArrayEqual } from "@prisma-next/utils/array-equal";
2
+ import { ifDefined } from "@prisma-next/utils/defined";
3
+ import { createHash } from "node:crypto";
4
+
5
+ //#region src/canonicalization.ts
6
+ const TOP_LEVEL_ORDER = [
7
+ "schemaVersion",
8
+ "canonicalVersion",
9
+ "targetFamily",
10
+ "target",
11
+ "profileHash",
12
+ "roots",
13
+ "models",
14
+ "valueObjects",
15
+ "storage",
16
+ "execution",
17
+ "capabilities",
18
+ "extensionPacks",
19
+ "meta"
20
+ ];
21
+ function isDefaultValue(value) {
22
+ if (value === false) return true;
23
+ if (value === null) return false;
24
+ if (Array.isArray(value) && value.length === 0) return true;
25
+ if (typeof value === "object" && value !== null) return Object.keys(value).length === 0;
26
+ return false;
27
+ }
28
+ function omitDefaults(obj, path) {
29
+ if (obj === null || typeof obj !== "object") return obj;
30
+ if (Array.isArray(obj)) return obj.map((item) => omitDefaults(item, path));
31
+ const result = {};
32
+ for (const [key, value] of Object.entries(obj)) {
33
+ const currentPath = [...path, key];
34
+ if (key === "_generated") continue;
35
+ if (key === "generated" && value === false) continue;
36
+ if ((key === "onDelete" || key === "onUpdate") && value === "noAction") continue;
37
+ if (isDefaultValue(value)) {
38
+ const isRequiredModels = isArrayEqual(currentPath, ["models"]);
39
+ const isRequiredTables = isArrayEqual(currentPath, ["storage", "tables"]);
40
+ const isRequiredCollections = isArrayEqual(currentPath, ["storage", "collections"]);
41
+ const isCollectionEntry = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[1]], ["storage", "collections"]);
42
+ const isRequiredRoots = isArrayEqual(currentPath, ["roots"]);
43
+ const isRequiredExtensionPacks = isArrayEqual(currentPath, ["extensionPacks"]);
44
+ const isRequiredCapabilities = isArrayEqual(currentPath, ["capabilities"]);
45
+ const isRequiredMeta = isArrayEqual(currentPath, ["meta"]);
46
+ const isRequiredExecutionDefaults = isArrayEqual(currentPath, [
47
+ "execution",
48
+ "mutations",
49
+ "defaults"
50
+ ]);
51
+ const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === "extensionPacks";
52
+ const isModelRelations = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[2]], ["models", "relations"]);
53
+ const isModelStorage = currentPath.length === 3 && isArrayEqual([currentPath[0], currentPath[2]], ["models", "storage"]);
54
+ const isTableUniques = currentPath.length === 4 && isArrayEqual([
55
+ currentPath[0],
56
+ currentPath[1],
57
+ currentPath[3]
58
+ ], [
59
+ "storage",
60
+ "tables",
61
+ "uniques"
62
+ ]);
63
+ const isTableIndexes = currentPath.length === 4 && isArrayEqual([
64
+ currentPath[0],
65
+ currentPath[1],
66
+ currentPath[3]
67
+ ], [
68
+ "storage",
69
+ "tables",
70
+ "indexes"
71
+ ]);
72
+ const isTableForeignKeys = currentPath.length === 4 && isArrayEqual([
73
+ currentPath[0],
74
+ currentPath[1],
75
+ currentPath[3]
76
+ ], [
77
+ "storage",
78
+ "tables",
79
+ "foreignKeys"
80
+ ]);
81
+ const isFkBooleanField = currentPath.length === 5 && currentPath[0] === "storage" && currentPath[1] === "tables" && currentPath[3] === "foreignKeys" && (key === "constraint" || key === "index");
82
+ if (!isRequiredModels && !isRequiredTables && !isRequiredCollections && !isCollectionEntry && !isRequiredRoots && !isRequiredExtensionPacks && !isRequiredCapabilities && !isRequiredMeta && !isRequiredExecutionDefaults && !isExtensionNamespace && !isModelRelations && !isModelStorage && !isTableUniques && !isTableIndexes && !isTableForeignKeys && !isFkBooleanField && !(key === "nullable")) continue;
83
+ }
84
+ result[key] = omitDefaults(value, currentPath);
85
+ }
86
+ return result;
87
+ }
88
+ function sortObjectKeys(obj) {
89
+ if (obj === null || typeof obj !== "object") return obj;
90
+ if (Array.isArray(obj)) return obj.map((item) => sortObjectKeys(item));
91
+ const sorted = {};
92
+ const keys = Object.keys(obj).sort();
93
+ for (const key of keys) sorted[key] = sortObjectKeys(obj[key]);
94
+ return sorted;
95
+ }
96
+ function sortIndexesAndUniques(storage) {
97
+ if (!storage || typeof storage !== "object") return storage;
98
+ const storageObj = storage;
99
+ if (!storageObj.tables || typeof storageObj.tables !== "object") return storage;
100
+ const tables = storageObj.tables;
101
+ const result = { ...storageObj };
102
+ result.tables = {};
103
+ const sortedTableNames = Object.keys(tables).sort();
104
+ for (const tableName of sortedTableNames) {
105
+ const table = tables[tableName];
106
+ if (!table || typeof table !== "object") {
107
+ result.tables[tableName] = table;
108
+ continue;
109
+ }
110
+ const tableObj = table;
111
+ const sortedTable = { ...tableObj };
112
+ if (Array.isArray(tableObj.indexes)) sortedTable.indexes = [...tableObj.indexes].sort((a, b) => {
113
+ const nameA = a?.name || "";
114
+ const nameB = b?.name || "";
115
+ return nameA.localeCompare(nameB);
116
+ });
117
+ if (Array.isArray(tableObj.uniques)) sortedTable.uniques = [...tableObj.uniques].sort((a, b) => {
118
+ const nameA = a?.name || "";
119
+ const nameB = b?.name || "";
120
+ return nameA.localeCompare(nameB);
121
+ });
122
+ result.tables[tableName] = sortedTable;
123
+ }
124
+ return result;
125
+ }
126
+ function orderTopLevel(obj) {
127
+ const ordered = {};
128
+ const remaining = new Set(Object.keys(obj));
129
+ for (const key of TOP_LEVEL_ORDER) if (remaining.has(key)) {
130
+ ordered[key] = obj[key];
131
+ remaining.delete(key);
132
+ }
133
+ for (const key of Array.from(remaining).sort()) ordered[key] = obj[key];
134
+ return ordered;
135
+ }
136
+ function canonicalizeContractToObject(contract, options) {
137
+ const withDefaultsOmitted = omitDefaults({
138
+ ...ifDefined("schemaVersion", options?.schemaVersion),
139
+ targetFamily: contract.targetFamily,
140
+ target: contract.target,
141
+ profileHash: contract.profileHash,
142
+ roots: contract.roots,
143
+ models: contract.models,
144
+ ...ifDefined("valueObjects", contract.valueObjects),
145
+ storage: contract.storage,
146
+ ...ifDefined("execution", contract.execution),
147
+ extensionPacks: contract.extensionPacks,
148
+ capabilities: contract.capabilities,
149
+ meta: contract.meta
150
+ }, []);
151
+ const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted["storage"]);
152
+ return orderTopLevel(sortObjectKeys({
153
+ ...withDefaultsOmitted,
154
+ storage: withSortedIndexes
155
+ }));
156
+ }
157
+ function canonicalizeContract(contract, options) {
158
+ return JSON.stringify(canonicalizeContractToObject(contract, options), null, 2);
159
+ }
160
+
161
+ //#endregion
162
+ //#region src/hashing.ts
163
+ const SCHEMA_VERSION = "1";
164
+ function sha256(content) {
165
+ const hash = createHash("sha256");
166
+ hash.update(content);
167
+ return `sha256:${hash.digest("hex")}`;
168
+ }
169
+ function hashContract(section) {
170
+ return canonicalizeContract({
171
+ targetFamily: section["targetFamily"],
172
+ target: section["target"],
173
+ roots: {},
174
+ models: {},
175
+ storage: section["storage"] ?? {},
176
+ execution: section["execution"],
177
+ extensionPacks: {},
178
+ capabilities: section["capabilities"] ?? {},
179
+ meta: {},
180
+ profileHash: "",
181
+ ...section
182
+ }, { schemaVersion: SCHEMA_VERSION });
183
+ }
184
+ function computeStorageHash(args) {
185
+ return sha256(hashContract(args));
186
+ }
187
+ function computeExecutionHash(args) {
188
+ return sha256(hashContract(args));
189
+ }
190
+ function computeProfileHash(args) {
191
+ return sha256(hashContract(args));
192
+ }
193
+
194
+ //#endregion
195
+ export { canonicalizeContractToObject as a, canonicalizeContract as i, computeProfileHash as n, computeStorageHash as r, computeExecutionHash as t };
196
+ //# sourceMappingURL=hashing-CyaA_Qvf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing-CyaA_Qvf.mjs","names":["result: Record<string, unknown>","sorted: Record<string, unknown>","result: StorageObject","sortedTable: TableObject","ordered: Record<string, unknown>"],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"sourcesContent":["import { isArrayEqual } from '@prisma-next/utils/array-equal';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\nimport type { Contract } from './contract-types';\n\nconst TOP_LEVEL_ORDER = [\n 'schemaVersion',\n 'canonicalVersion',\n 'targetFamily',\n 'target',\n 'profileHash',\n 'roots',\n 'models',\n 'valueObjects',\n 'storage',\n 'execution',\n 'capabilities',\n 'extensionPacks',\n 'meta',\n] as const;\n\nfunction isDefaultValue(value: unknown): boolean {\n if (value === false) return true;\n if (value === null) return false;\n if (Array.isArray(value) && value.length === 0) return true;\n if (typeof value === 'object' && value !== null) {\n const keys = Object.keys(value);\n return keys.length === 0;\n }\n return false;\n}\n\nfunction omitDefaults(obj: unknown, path: readonly string[]): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => omitDefaults(item, path));\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = [...path, key];\n\n if (key === '_generated') {\n continue;\n }\n\n if (key === 'generated' && value === false) {\n continue;\n }\n\n if ((key === 'onDelete' || key === 'onUpdate') && value === 'noAction') {\n continue;\n }\n\n if (isDefaultValue(value)) {\n const isRequiredModels = isArrayEqual(currentPath, ['models']);\n const isRequiredTables = isArrayEqual(currentPath, ['storage', 'tables']);\n const isRequiredCollections = isArrayEqual(currentPath, ['storage', 'collections']);\n const isCollectionEntry =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[1]], ['storage', 'collections']);\n const isRequiredRoots = isArrayEqual(currentPath, ['roots']);\n const isRequiredExtensionPacks = isArrayEqual(currentPath, ['extensionPacks']);\n const isRequiredCapabilities = isArrayEqual(currentPath, ['capabilities']);\n const isRequiredMeta = isArrayEqual(currentPath, ['meta']);\n const isRequiredExecutionDefaults = isArrayEqual(currentPath, [\n 'execution',\n 'mutations',\n 'defaults',\n ]);\n const isExtensionNamespace = currentPath.length === 2 && currentPath[0] === 'extensionPacks';\n const isModelRelations =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[2]], ['models', 'relations']);\n const isModelStorage =\n currentPath.length === 3 &&\n isArrayEqual([currentPath[0], currentPath[2]], ['models', 'storage']);\n const isTableUniques =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'uniques'],\n );\n const isTableIndexes =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'indexes'],\n );\n const isTableForeignKeys =\n currentPath.length === 4 &&\n isArrayEqual(\n [currentPath[0], currentPath[1], currentPath[3]],\n ['storage', 'tables', 'foreignKeys'],\n );\n\n const isFkBooleanField =\n currentPath.length === 5 &&\n currentPath[0] === 'storage' &&\n currentPath[1] === 'tables' &&\n currentPath[3] === 'foreignKeys' &&\n (key === 'constraint' || key === 'index');\n\n const isNullableField = key === 'nullable';\n\n if (\n !isRequiredModels &&\n !isRequiredTables &&\n !isRequiredCollections &&\n !isCollectionEntry &&\n !isRequiredRoots &&\n !isRequiredExtensionPacks &&\n !isRequiredCapabilities &&\n !isRequiredMeta &&\n !isRequiredExecutionDefaults &&\n !isExtensionNamespace &&\n !isModelRelations &&\n !isModelStorage &&\n !isTableUniques &&\n !isTableIndexes &&\n !isTableForeignKeys &&\n !isFkBooleanField &&\n !isNullableField\n ) {\n continue;\n }\n }\n\n result[key] = omitDefaults(value, currentPath);\n }\n\n return result;\n}\n\nfunction sortObjectKeys(obj: unknown): unknown {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => sortObjectKeys(item));\n }\n\n const sorted: Record<string, unknown> = {};\n const keys = Object.keys(obj).sort();\n for (const key of keys) {\n sorted[key] = sortObjectKeys((obj as Record<string, unknown>)[key]);\n }\n\n return sorted;\n}\n\ntype StorageObject = {\n tables?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\ntype TableObject = {\n indexes?: unknown[];\n uniques?: unknown[];\n [key: string]: unknown;\n};\n\nfunction sortIndexesAndUniques(storage: unknown): unknown {\n if (!storage || typeof storage !== 'object') {\n return storage;\n }\n\n const storageObj = storage as StorageObject;\n if (!storageObj.tables || typeof storageObj.tables !== 'object') {\n return storage;\n }\n\n const tables = storageObj.tables;\n const result: StorageObject = { ...storageObj };\n\n result.tables = {};\n const sortedTableNames = Object.keys(tables).sort();\n for (const tableName of sortedTableNames) {\n const table = tables[tableName];\n if (!table || typeof table !== 'object') {\n result.tables[tableName] = table;\n continue;\n }\n\n const tableObj = table as TableObject;\n const sortedTable: TableObject = { ...tableObj };\n\n if (Array.isArray(tableObj.indexes)) {\n sortedTable.indexes = [...tableObj.indexes].sort((a, b) => {\n const nameA = (a as { name?: string })?.name || '';\n const nameB = (b as { name?: string })?.name || '';\n return nameA.localeCompare(nameB);\n });\n }\n\n if (Array.isArray(tableObj.uniques)) {\n sortedTable.uniques = [...tableObj.uniques].sort((a, b) => {\n const nameA = (a as { name?: string })?.name || '';\n const nameB = (b as { name?: string })?.name || '';\n return nameA.localeCompare(nameB);\n });\n }\n\n result.tables[tableName] = sortedTable;\n }\n\n return result;\n}\n\nexport function orderTopLevel(obj: Record<string, unknown>): Record<string, unknown> {\n const ordered: Record<string, unknown> = {};\n const remaining = new Set(Object.keys(obj));\n\n for (const key of TOP_LEVEL_ORDER) {\n if (remaining.has(key)) {\n ordered[key] = obj[key];\n remaining.delete(key);\n }\n }\n\n for (const key of Array.from(remaining).sort()) {\n ordered[key] = obj[key];\n }\n\n return ordered;\n}\n\nexport function canonicalizeContractToObject(\n contract: Contract,\n options?: { schemaVersion?: string },\n): Record<string, unknown> {\n const normalized: Record<string, unknown> = {\n ...ifDefined('schemaVersion', options?.schemaVersion),\n targetFamily: contract.targetFamily,\n target: contract.target,\n profileHash: contract.profileHash,\n roots: contract.roots,\n models: contract.models,\n ...ifDefined('valueObjects', contract.valueObjects),\n storage: contract.storage,\n ...ifDefined('execution', contract.execution),\n extensionPacks: contract.extensionPacks,\n capabilities: contract.capabilities,\n meta: contract.meta,\n };\n const withDefaultsOmitted = omitDefaults(normalized, []) as Record<string, unknown>;\n const withSortedIndexes = sortIndexesAndUniques(withDefaultsOmitted['storage']);\n const withSortedStorage = { ...withDefaultsOmitted, storage: withSortedIndexes };\n const withSortedKeys = sortObjectKeys(withSortedStorage) as Record<string, unknown>;\n return orderTopLevel(withSortedKeys);\n}\n\nexport function canonicalizeContract(\n contract: Contract,\n options?: { schemaVersion?: string },\n): string {\n return JSON.stringify(canonicalizeContractToObject(contract, options), null, 2);\n}\n","import { createHash } from 'node:crypto';\nimport { canonicalizeContract } from './canonicalization';\nimport type { Contract } from './contract-types';\nimport type { ExecutionHashBase, ProfileHashBase, StorageHashBase } from './types';\n\nconst SCHEMA_VERSION = '1';\n\nfunction sha256(content: string): string {\n const hash = createHash('sha256');\n hash.update(content);\n return `sha256:${hash.digest('hex')}`;\n}\n\nfunction hashContract(section: Record<string, unknown>): string {\n const contract = {\n targetFamily: section['targetFamily'],\n target: section['target'],\n roots: {},\n models: {},\n storage: section['storage'] ?? {},\n execution: section['execution'],\n extensionPacks: {},\n capabilities: section['capabilities'] ?? {},\n meta: {},\n profileHash: '',\n ...section,\n } as Contract;\n return canonicalizeContract(contract, { schemaVersion: SCHEMA_VERSION });\n}\n\nexport function computeStorageHash(args: {\n target: string;\n targetFamily: string;\n storage: Record<string, unknown>;\n}): StorageHashBase<string> {\n return sha256(hashContract(args)) as StorageHashBase<string>;\n}\n\nexport function computeExecutionHash(args: {\n target: string;\n targetFamily: string;\n execution: Record<string, unknown>;\n}): ExecutionHashBase<string> {\n return sha256(hashContract(args)) as ExecutionHashBase<string>;\n}\n\nexport function computeProfileHash(args: {\n target: string;\n targetFamily: string;\n capabilities: Record<string, Record<string, boolean>>;\n}): ProfileHashBase<string> {\n return sha256(hashContract(args)) as ProfileHashBase<string>;\n}\n"],"mappings":";;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAS,eAAe,OAAyB;AAC/C,KAAI,UAAU,MAAO,QAAO;AAC5B,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,EAAG,QAAO;AACvD,KAAI,OAAO,UAAU,YAAY,UAAU,KAEzC,QADa,OAAO,KAAK,MAAM,CACnB,WAAW;AAEzB,QAAO;;AAGT,SAAS,aAAa,KAAc,MAAkC;AACpE,KAAI,QAAQ,QAAQ,OAAO,QAAQ,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,SAAS,aAAa,MAAM,KAAK,CAAC;CAGpD,MAAMA,SAAkC,EAAE;AAE1C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,EAAE;EAC9C,MAAM,cAAc,CAAC,GAAG,MAAM,IAAI;AAElC,MAAI,QAAQ,aACV;AAGF,MAAI,QAAQ,eAAe,UAAU,MACnC;AAGF,OAAK,QAAQ,cAAc,QAAQ,eAAe,UAAU,WAC1D;AAGF,MAAI,eAAe,MAAM,EAAE;GACzB,MAAM,mBAAmB,aAAa,aAAa,CAAC,SAAS,CAAC;GAC9D,MAAM,mBAAmB,aAAa,aAAa,CAAC,WAAW,SAAS,CAAC;GACzE,MAAM,wBAAwB,aAAa,aAAa,CAAC,WAAW,cAAc,CAAC;GACnF,MAAM,oBACJ,YAAY,WAAW,KACvB,aAAa,CAAC,YAAY,IAAI,YAAY,GAAG,EAAE,CAAC,WAAW,cAAc,CAAC;GAC5E,MAAM,kBAAkB,aAAa,a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jC,WAAW,QAAQ;EACnB,gBAAgB,EAAE;EAClB,cAAc,QAAQ,mBAAmB,EAAE;EAC3C,MAAM,EAAE;EACR,aAAa;EACb,GAAG;EACJ,EACqC,EAAE,eAAe,gBAAgB,CAAC;;AAG1E,SAAgB,mBAAmB,MAIP;AAC1B,QAAO,OAAO,aAAa,KAAK,CAAC;;AAGnC,SAAgB,qBAAqB,MAIP;AAC5B,QAAO,OAAO,aAAa,KAAK,CAAC;;AAGnC,SAAgB,mBAAmB,MAIP;AAC1B,QAAO,OAAO,aAAa,KAAK,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { O as StorageHashBase, d as ExecutionHashBase, t as Contract, w as ProfileHashBase } from "./contract-types-MYdoYIIh.mjs";
2
+
3
+ //#region src/canonicalization.d.ts
4
+ declare function canonicalizeContractToObject(contract: Contract, options?: {
5
+ schemaVersion?: string;
6
+ }): Record<string, unknown>;
7
+ declare function canonicalizeContract(contract: Contract, options?: {
8
+ schemaVersion?: string;
9
+ }): string;
10
+ //#endregion
11
+ //#region src/hashing.d.ts
12
+ declare function computeStorageHash(args: {
13
+ target: string;
14
+ targetFamily: string;
15
+ storage: Record<string, unknown>;
16
+ }): StorageHashBase<string>;
17
+ declare function computeExecutionHash(args: {
18
+ target: string;
19
+ targetFamily: string;
20
+ execution: Record<string, unknown>;
21
+ }): ExecutionHashBase<string>;
22
+ declare function computeProfileHash(args: {
23
+ target: string;
24
+ targetFamily: string;
25
+ capabilities: Record<string, Record<string, boolean>>;
26
+ }): ProfileHashBase<string>;
27
+ //#endregion
28
+ export { canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
29
+ //# sourceMappingURL=hashing.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing.d.mts","names":[],"sources":["../src/canonicalization.ts","../src/hashing.ts"],"sourcesContent":[],"mappings":";;;iBAwOgB,4BAAA,WACJ,iBAwBZ;EAzBgB,aAAA,CAAA,EAAA,MAAA;AAyBhB,CAAA,CAAA,EAtBG,MAsBa,CAAA,MAAA,EAAA,OAAA,CAAoB;iBAApB,oBAAA,WACJ;;;;;iBCpOI,kBAAA;;ED0MA,YAAA,EAAA,MAAA;EAyBA,OAAA,EChOL,MDgOK,CAAA,MAAA,EAAoB,OAAA,CAAA;IC/NhC;iBAIY,oBAAA;;EARA,YAAA,EAAA,MAAA;EAQA,SAAA,EAGH,MAHG,CAAA,MAAoB,EAAA,OAAA,CAAA;AAQpC,CAAA,CAAA,EAJI,iBAIY,CAAA,MAAkB,CAAA;AAGH,iBAHf,kBAAA,CAGe,IAAA,EAAA;EAAf,MAAA,EAAA,MAAA;EACZ,YAAA,EAAA,MAAA;EAAe,YAAA,EADH,MACG,CAAA,MAAA,EADY,MACZ,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;IAAf"}
@@ -0,0 +1,3 @@
1
+ import { a as canonicalizeContractToObject, i as canonicalizeContract, n as computeProfileHash, r as computeStorageHash, t as computeExecutionHash } from "./hashing-CyaA_Qvf.mjs";
2
+
3
+ export { canonicalizeContract, canonicalizeContractToObject, computeExecutionHash, computeProfileHash, computeStorageHash };
@@ -0,0 +1,29 @@
1
+ import { D as StorageBase, I as ContractModel, L as ContractModelBase, O as StorageHashBase, V as ContractValueObject, W as ModelStorageBase, h as ExecutionSection, t as Contract, w as ProfileHashBase } from "./contract-types-MYdoYIIh.mjs";
2
+
3
+ //#region src/testing-factories.d.ts
4
+ type ContractOverrides<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModel>> = {
5
+ target?: string;
6
+ targetFamily?: string;
7
+ roots?: Record<string, string>;
8
+ models?: TModels;
9
+ storage?: Omit<TStorage, 'storageHash'>;
10
+ valueObjects?: Record<string, ContractValueObject>;
11
+ capabilities?: Record<string, Record<string, boolean>>;
12
+ extensionPacks?: Record<string, unknown>;
13
+ execution?: Omit<ExecutionSection, 'executionHash'>;
14
+ profileHash?: ProfileHashBase<string>;
15
+ meta?: Record<string, unknown>;
16
+ };
17
+ declare const DUMMY_HASH: StorageHashBase<"sha256:test">;
18
+ declare function createContract<TStorage extends StorageBase = StorageBase, TModels extends Record<string, ContractModelBase> = Record<string, ContractModel>>(overrides?: ContractOverrides<TStorage, TModels>): Contract<TStorage, TModels>;
19
+ type SqlStorageLike = StorageBase & {
20
+ readonly tables: Record<string, unknown>;
21
+ readonly types?: Record<string, unknown>;
22
+ };
23
+ type SqlModelLike = ContractModel<ModelStorageBase & {
24
+ table: string;
25
+ }>;
26
+ declare function createSqlContract(overrides?: ContractOverrides<SqlStorageLike, Record<string, SqlModelLike>>): Contract<SqlStorageLike, Record<string, SqlModelLike>>;
27
+ //#endregion
28
+ export { DUMMY_HASH, createContract, createSqlContract };
29
+ //# sourceMappingURL=testing.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.mts","names":[],"sources":["../src/testing-factories.ts"],"sourcesContent":[],"mappings":";;;AAS8E,KAGzE,iBAAA,CAAA,iBACc,WADG,GACW,WADX,EAAA,gBAEJ,MAFI,CAAA,MAAA,EAEW,iBAFX,CAAA,GAEgC,MAFhC,CAAA,MAAA,EAE+C,aAF/C,CAAA,CAAA,GAAA;EACH,MAAA,CAAA,EAAA,MAAA;EAAc,YAAA,CAAA,EAAA,MAAA;EACA,KAAA,CAAA,EAIvB,MAJuB,CAAA,MAAA,EAAA,MAAA,CAAA;EAAf,MAAA,CAAA,EAKP,OALO;EAAmD,OAAA,CAAA,EAMzD,IANyD,CAMpD,QANoD,EAAA,aAAA,CAAA;EAAf,YAAA,CAAA,EAOrC,MAPqC,CAAA,MAAA,EAOtB,mBAPsB,CAAA;EAI5C,YAAA,CAAA,EAIO,MAJP,CAAA,MAAA,EAIsB,MAJtB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EACC,cAAA,CAAA,EAIQ,MAJR,CAAA,MAAA,EAAA,OAAA,CAAA;EACM,SAAA,CAAA,EAIH,IAJG,CAIE,gBAJF,EAAA,eAAA,CAAA;EA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