@prisma-next/emitter 0.3.0-pr.99.6 → 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 (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -35
  3. package/dist/domain-type-generation.d.mts +38 -0
  4. package/dist/domain-type-generation.d.mts.map +1 -0
  5. package/dist/domain-type-generation.mjs +255 -0
  6. package/dist/domain-type-generation.mjs.map +1 -0
  7. package/dist/exports/index.d.mts +39 -0
  8. package/dist/exports/index.d.mts.map +1 -0
  9. package/dist/exports/index.mjs +106 -0
  10. package/dist/exports/index.mjs.map +1 -0
  11. package/dist/test/utils.d.mts +21 -0
  12. package/dist/test/utils.d.mts.map +1 -0
  13. package/dist/test/utils.mjs +18 -0
  14. package/dist/test/utils.mjs.map +1 -0
  15. package/dist/type-expression-safety-7_1tfJXA.mjs +8 -0
  16. package/dist/type-expression-safety-7_1tfJXA.mjs.map +1 -0
  17. package/dist/type-expression-safety.d.mts +5 -0
  18. package/dist/type-expression-safety.d.mts.map +1 -0
  19. package/dist/type-expression-safety.mjs +3 -0
  20. package/package.json +27 -11
  21. package/src/domain-type-generation.ts +429 -0
  22. package/src/emit-types.ts +23 -0
  23. package/src/emit.ts +68 -0
  24. package/src/exports/index.ts +14 -9
  25. package/src/generate-contract-dts.ts +117 -0
  26. package/src/type-expression-safety.ts +3 -0
  27. package/test/canonicalization.test.ts +196 -19
  28. package/test/domain-type-generation.test.ts +997 -0
  29. package/test/emitter.integration.test.ts +132 -187
  30. package/test/emitter.roundtrip.test.ts +117 -191
  31. package/test/emitter.test.ts +123 -494
  32. package/test/hashing.test.ts +9 -34
  33. package/test/mock-spi.ts +18 -0
  34. package/test/type-expression-safety.test.ts +34 -0
  35. package/test/utils.ts +30 -165
  36. package/dist/exports/index.js +0 -6
  37. package/dist/exports/index.js.map +0 -1
  38. package/dist/src/exports/index.d.ts +0 -4
  39. package/dist/src/exports/index.d.ts.map +0 -1
  40. package/dist/src/target-family.d.ts +0 -2
  41. package/dist/src/target-family.d.ts.map +0 -1
  42. package/dist/test/utils.d.ts +0 -14
  43. package/dist/test/utils.d.ts.map +0 -1
  44. package/dist/test/utils.js +0 -78
  45. package/dist/test/utils.js.map +0 -1
  46. package/src/target-family.ts +0 -7
  47. package/test/factories.test.ts +0 -274
@@ -1,59 +1,34 @@
1
- import { computeCoreHash, computeProfileHash } from '@prisma-next/core-control-plane/emission';
1
+ import { computeProfileHash, computeStorageHash } from '@prisma-next/contract/hashing';
2
2
  import { describe, expect, it } from 'vitest';
3
3
 
4
4
  describe('hashing', () => {
5
- it('computes core hash', () => {
6
- const contract = {
7
- schemaVersion: '1',
5
+ it('computes storage hash', () => {
6
+ const hash = computeStorageHash({
8
7
  targetFamily: 'sql',
9
8
  target: 'postgres',
10
- models: {},
11
- relations: {},
12
9
  storage: { tables: {} },
13
- extensionPacks: {},
14
- capabilities: {},
15
- meta: {},
16
- sources: {},
17
- };
18
-
19
- const hash = computeCoreHash(contract);
10
+ });
20
11
  expect(hash).toMatch(/^sha256:[a-f0-9]{64}$/);
21
12
  });
22
13
 
23
14
  it('computes profile hash', () => {
24
- const contract = {
25
- schemaVersion: '1',
15
+ const hash = computeProfileHash({
26
16
  targetFamily: 'sql',
27
17
  target: 'postgres',
28
- models: {},
29
- relations: {},
30
- storage: { tables: {} },
31
- extensionPacks: {},
32
18
  capabilities: { postgres: { jsonAgg: true } },
33
- meta: {},
34
- sources: {},
35
- };
36
-
37
- const hash = computeProfileHash(contract);
19
+ });
38
20
  expect(hash).toMatch(/^sha256:[a-f0-9]{64}$/);
39
21
  });
40
22
 
41
23
  it('produces stable hashes for identical input', () => {
42
- const contract = {
43
- schemaVersion: '1',
24
+ const args = {
44
25
  targetFamily: 'sql',
45
26
  target: 'postgres',
46
- models: {},
47
- relations: {},
48
27
  storage: { tables: {} },
49
- extensionPacks: {},
50
- capabilities: {},
51
- meta: {},
52
- sources: {},
53
28
  };
54
29
 
55
- const hash1 = computeCoreHash(contract);
56
- const hash2 = computeCoreHash(contract);
30
+ const hash1 = computeStorageHash(args);
31
+ const hash2 = computeStorageHash(args);
57
32
  expect(hash1).toBe(hash2);
58
33
  });
59
34
  });
@@ -0,0 +1,18 @@
1
+ import type { EmissionSpi } from '@prisma-next/framework-components/emission';
2
+
3
+ export function createMockSpi(overrides: Partial<EmissionSpi> = {}): EmissionSpi {
4
+ return {
5
+ id: 'sql',
6
+ generateStorageType: () =>
7
+ '{ readonly tables: Record<string, never>; readonly types: Record<string, never>; readonly storageHash: StorageHash }',
8
+ generateModelStorageType: () => 'Record<string, never>',
9
+ getFamilyImports: () => [
10
+ "import type { ContractWithTypeMaps, TypeMaps as TypeMapsType } from '@prisma-next/sql-contract/types';",
11
+ ],
12
+ getFamilyTypeAliases: () => 'export type LaneCodecTypes = CodecTypes;',
13
+ getTypeMapsExpression: () => 'TypeMapsType<CodecTypes, OperationTypes>',
14
+ getContractWrapper: (base, tm) =>
15
+ `export type Contract = ContractWithTypeMaps<${base}, ${tm}>;`,
16
+ ...overrides,
17
+ };
18
+ }
@@ -0,0 +1,34 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { isSafeTypeExpression } from '../src/type-expression-safety';
3
+
4
+ describe('isSafeTypeExpression', () => {
5
+ it('accepts normal type expressions', () => {
6
+ expect(isSafeTypeExpression('Char<36>')).toBe(true);
7
+ expect(isSafeTypeExpression('Vector<1536>')).toBe(true);
8
+ expect(isSafeTypeExpression("'USER' | 'ADMIN'")).toBe(true);
9
+ expect(isSafeTypeExpression('{ name: string; age: number }')).toBe(true);
10
+ expect(isSafeTypeExpression('Numeric<10, 2>')).toBe(true);
11
+ expect(isSafeTypeExpression('Timestamp<3>')).toBe(true);
12
+ });
13
+
14
+ it('rejects import expressions', () => {
15
+ expect(isSafeTypeExpression('import("fs")')).toBe(false);
16
+ expect(isSafeTypeExpression('import ("fs")')).toBe(false);
17
+ });
18
+
19
+ it('rejects require expressions', () => {
20
+ expect(isSafeTypeExpression('require("fs")')).toBe(false);
21
+ });
22
+
23
+ it('rejects declare statements', () => {
24
+ expect(isSafeTypeExpression('declare module "foo"')).toBe(false);
25
+ });
26
+
27
+ it('rejects export statements', () => {
28
+ expect(isSafeTypeExpression('export default 42')).toBe(false);
29
+ });
30
+
31
+ it('rejects eval expressions', () => {
32
+ expect(isSafeTypeExpression('eval("code")')).toBe(false);
33
+ });
34
+ });
package/test/utils.ts CHANGED
@@ -1,166 +1,31 @@
1
- import { type ContractIR, irHeader, irMeta } from '@prisma-next/contract/ir';
2
-
3
- /**
4
- * Factory function for creating ContractIR objects in tests.
5
- * Provides sensible defaults and allows overriding specific fields.
6
- * Uses the emitter factories internally for consistency.
7
- *
8
- * If a field is explicitly set to `undefined` in overrides, it will be omitted
9
- * from the result (useful for testing validation of missing fields).
10
- */
11
- export function createContractIR(
12
- overrides: Partial<ContractIR> & { coreHash?: string; profileHash?: string } = {},
13
- ): ContractIR {
14
- // Check if fields are explicitly undefined (not just missing)
15
- const hasTarget = 'target' in overrides;
16
- const hasTargetFamily = 'targetFamily' in overrides;
17
- const hasCoreHash = 'coreHash' in overrides;
18
- const hasSchemaVersion = 'schemaVersion' in overrides;
19
- const hasModels = 'models' in overrides;
20
- const hasRelations = 'relations' in overrides;
21
- const hasStorage = 'storage' in overrides;
22
- const hasCapabilities = 'capabilities' in overrides;
23
- const hasExtensionPacks = 'extensionPacks' in overrides;
24
- const hasMeta = 'meta' in overrides;
25
- const hasSources = 'sources' in overrides;
26
-
27
- // Build header, omitting fields that are explicitly undefined
28
- const headerOpts: {
29
- target?: string;
30
- targetFamily?: string;
31
- coreHash?: string;
32
- profileHash?: string;
33
- } = {};
34
-
35
- if (hasTarget && overrides.target !== undefined) {
36
- headerOpts.target = overrides.target;
37
- } else if (!hasTarget) {
38
- headerOpts.target = 'postgres';
39
- }
40
-
41
- if (hasTargetFamily && overrides.targetFamily !== undefined) {
42
- headerOpts.targetFamily = overrides.targetFamily;
43
- } else if (!hasTargetFamily) {
44
- headerOpts.targetFamily = 'sql';
45
- }
46
-
47
- if (hasCoreHash && overrides.coreHash !== undefined) {
48
- headerOpts.coreHash = overrides.coreHash;
49
- } else if (!hasCoreHash) {
50
- headerOpts.coreHash = 'sha256:test';
51
- }
52
-
53
- // profileHash is not part of ContractIR, but we can accept it for header creation
54
- if (overrides.profileHash !== undefined) {
55
- headerOpts.profileHash = overrides.profileHash;
56
- }
57
-
58
- const header = irHeader(
59
- headerOpts as {
60
- target: string;
61
- targetFamily: string;
62
- coreHash: string;
63
- profileHash?: string;
64
- },
65
- );
66
-
67
- // Build meta, handling explicitly undefined fields
68
- // If a field is explicitly undefined, we'll omit it from the result later
69
- const metaOpts: {
70
- capabilities?: Record<string, Record<string, boolean>>;
71
- extensionPacks?: Record<string, unknown>;
72
- meta?: Record<string, unknown>;
73
- sources?: Record<string, unknown>;
74
- } = {};
75
-
76
- if (hasCapabilities && overrides.capabilities !== undefined) {
77
- metaOpts.capabilities = overrides.capabilities;
78
- } else if (!hasCapabilities) {
79
- metaOpts.capabilities = {};
80
- }
81
-
82
- if (hasExtensionPacks && overrides.extensionPacks !== undefined) {
83
- metaOpts.extensionPacks = overrides.extensionPacks;
84
- } else if (!hasExtensionPacks) {
85
- metaOpts.extensionPacks = {};
86
- }
87
-
88
- if (hasMeta && overrides.meta !== undefined) {
89
- metaOpts.meta = overrides.meta;
90
- } else if (!hasMeta) {
91
- metaOpts.meta = {};
92
- }
93
-
94
- if (hasSources && overrides.sources !== undefined) {
95
- metaOpts.sources = overrides.sources;
96
- } else if (!hasSources) {
97
- metaOpts.sources = {};
98
- }
99
-
100
- const meta = irMeta(Object.keys(metaOpts).length > 0 ? metaOpts : undefined);
101
-
102
- // Build result by constructing the object directly (ContractIR doesn't include coreHash/profileHash)
103
- // When fields are explicitly undefined, include them as undefined (tests use type assertions to bypass TS)
104
- const result = {
105
- schemaVersion:
106
- hasSchemaVersion && overrides.schemaVersion !== undefined
107
- ? overrides.schemaVersion
108
- : hasSchemaVersion && overrides.schemaVersion === undefined
109
- ? (undefined as unknown as string)
110
- : header.schemaVersion,
111
- target: header.target,
112
- targetFamily: header.targetFamily,
113
- // Only include meta fields if they're not explicitly undefined
114
- capabilities:
115
- hasCapabilities && overrides.capabilities === undefined
116
- ? (undefined as unknown as Record<string, Record<string, boolean>>)
117
- : !hasCapabilities || overrides.capabilities !== undefined
118
- ? meta.capabilities
119
- : ({} as Record<string, Record<string, boolean>>),
120
- extensionPacks:
121
- hasExtensionPacks && overrides.extensionPacks === undefined
122
- ? (undefined as unknown as Record<string, unknown>)
123
- : !hasExtensionPacks || overrides.extensionPacks !== undefined
124
- ? meta.extensionPacks
125
- : ({} as Record<string, unknown>),
126
- meta:
127
- hasMeta && overrides.meta === undefined
128
- ? (undefined as unknown as Record<string, unknown>)
129
- : !hasMeta || overrides.meta !== undefined
130
- ? meta.meta
131
- : ({} as Record<string, unknown>),
132
- sources:
133
- hasSources && overrides.sources === undefined
134
- ? (undefined as unknown as Record<string, unknown>)
135
- : !hasSources || overrides.sources !== undefined
136
- ? meta.sources
137
- : ({} as Record<string, unknown>),
138
- // Only include family sections if they're not explicitly undefined
139
- storage:
140
- hasStorage && overrides.storage === undefined
141
- ? (undefined as unknown as Record<string, unknown>)
142
- : hasStorage && overrides.storage !== undefined
143
- ? (overrides.storage as Record<string, unknown>)
144
- : !hasStorage
145
- ? ({ tables: {} } as Record<string, unknown>)
146
- : ({} as Record<string, unknown>),
147
- models:
148
- hasModels && overrides.models === undefined
149
- ? (undefined as unknown as Record<string, unknown>)
150
- : hasModels && overrides.models !== undefined
151
- ? (overrides.models as Record<string, unknown>)
152
- : !hasModels
153
- ? {}
154
- : ({} as Record<string, unknown>),
155
- relations:
156
- hasRelations && overrides.relations === undefined
157
- ? (undefined as unknown as Record<string, unknown>)
158
- : hasRelations && overrides.relations !== undefined
159
- ? (overrides.relations as Record<string, unknown>)
160
- : !hasRelations
161
- ? {}
162
- : ({} as Record<string, unknown>),
163
- } as ContractIR;
164
-
165
- return result;
1
+ import { createContract } from '@prisma-next/contract/testing';
2
+ import type { Contract } from '@prisma-next/contract/types';
3
+
4
+ type TestContractOverrides = {
5
+ target?: string;
6
+ targetFamily?: string;
7
+ roots?: Record<string, string>;
8
+ models?: Record<string, unknown>;
9
+ storage?: Record<string, unknown>;
10
+ capabilities?: Record<string, Record<string, boolean>>;
11
+ extensionPacks?: Record<string, unknown>;
12
+ execution?: Record<string, unknown>;
13
+ meta?: Record<string, unknown>;
14
+ storageHash?: string;
15
+ schemaVersion?: string;
16
+ sources?: Record<string, unknown>;
17
+ };
18
+
19
+ export function createTestContract(overrides: TestContractOverrides = {}): Contract {
20
+ const { storageHash: _sh, schemaVersion: _sv, sources: _src, storage, ...rest } = overrides;
21
+ const cleanStorage = storage
22
+ ? (() => {
23
+ const { storageHash: _innerSh, ...storageRest } = storage as Record<string, unknown>;
24
+ return storageRest;
25
+ })()
26
+ : undefined;
27
+ return createContract({
28
+ ...rest,
29
+ ...(cleanStorage ? { storage: cleanStorage } : {}),
30
+ } as Parameters<typeof createContract>[0]);
166
31
  }
@@ -1,6 +0,0 @@
1
- // src/exports/index.ts
2
- import { emit } from "@prisma-next/core-control-plane/emission";
3
- export {
4
- emit
5
- };
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/exports/index.ts"],"sourcesContent":["// Re-export types from @prisma-next/contract for backward compatibility\nexport type {\n TargetFamilyHook,\n TypesImportSpec,\n ValidationContext,\n} from '@prisma-next/contract/types';\nexport type { EmitOptions, EmitResult } from '@prisma-next/core-control-plane/emission';\n// Re-export emit function and types from core-control-plane\nexport { emit } from '@prisma-next/core-control-plane/emission';\n"],"mappings":";AAQA,SAAS,YAAY;","names":[]}
@@ -1,4 +0,0 @@
1
- export type { TargetFamilyHook, TypesImportSpec, ValidationContext, } from '@prisma-next/contract/types';
2
- export type { EmitOptions, EmitResult } from '@prisma-next/core-control-plane/emission';
3
- export { emit } from '@prisma-next/core-control-plane/emission';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC"}
@@ -1,2 +0,0 @@
1
- export type { TargetFamilyHook, TypesImportSpec, ValidationContext, } from '@prisma-next/contract/types';
2
- //# sourceMappingURL=target-family.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"target-family.d.ts","sourceRoot":"","sources":["../../src/target-family.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,6BAA6B,CAAC"}
@@ -1,14 +0,0 @@
1
- import { type ContractIR } from '@prisma-next/contract/ir';
2
- /**
3
- * Factory function for creating ContractIR objects in tests.
4
- * Provides sensible defaults and allows overriding specific fields.
5
- * Uses the emitter factories internally for consistency.
6
- *
7
- * If a field is explicitly set to `undefined` in overrides, it will be omitted
8
- * from the result (useful for testing validation of missing fields).
9
- */
10
- export declare function createContractIR(overrides?: Partial<ContractIR> & {
11
- coreHash?: string;
12
- profileHash?: string;
13
- }): ContractIR;
14
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AAE7E;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,GAAE,OAAO,CAAC,UAAU,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAChF,UAAU,CAyJZ"}
@@ -1,78 +0,0 @@
1
- // test/utils.ts
2
- import { irHeader, irMeta } from "@prisma-next/contract/ir";
3
- function createContractIR(overrides = {}) {
4
- const hasTarget = "target" in overrides;
5
- const hasTargetFamily = "targetFamily" in overrides;
6
- const hasCoreHash = "coreHash" in overrides;
7
- const hasSchemaVersion = "schemaVersion" in overrides;
8
- const hasModels = "models" in overrides;
9
- const hasRelations = "relations" in overrides;
10
- const hasStorage = "storage" in overrides;
11
- const hasCapabilities = "capabilities" in overrides;
12
- const hasExtensionPacks = "extensionPacks" in overrides;
13
- const hasMeta = "meta" in overrides;
14
- const hasSources = "sources" in overrides;
15
- const headerOpts = {};
16
- if (hasTarget && overrides.target !== void 0) {
17
- headerOpts.target = overrides.target;
18
- } else if (!hasTarget) {
19
- headerOpts.target = "postgres";
20
- }
21
- if (hasTargetFamily && overrides.targetFamily !== void 0) {
22
- headerOpts.targetFamily = overrides.targetFamily;
23
- } else if (!hasTargetFamily) {
24
- headerOpts.targetFamily = "sql";
25
- }
26
- if (hasCoreHash && overrides.coreHash !== void 0) {
27
- headerOpts.coreHash = overrides.coreHash;
28
- } else if (!hasCoreHash) {
29
- headerOpts.coreHash = "sha256:test";
30
- }
31
- if (overrides.profileHash !== void 0) {
32
- headerOpts.profileHash = overrides.profileHash;
33
- }
34
- const header = irHeader(
35
- headerOpts
36
- );
37
- const metaOpts = {};
38
- if (hasCapabilities && overrides.capabilities !== void 0) {
39
- metaOpts.capabilities = overrides.capabilities;
40
- } else if (!hasCapabilities) {
41
- metaOpts.capabilities = {};
42
- }
43
- if (hasExtensionPacks && overrides.extensionPacks !== void 0) {
44
- metaOpts.extensionPacks = overrides.extensionPacks;
45
- } else if (!hasExtensionPacks) {
46
- metaOpts.extensionPacks = {};
47
- }
48
- if (hasMeta && overrides.meta !== void 0) {
49
- metaOpts.meta = overrides.meta;
50
- } else if (!hasMeta) {
51
- metaOpts.meta = {};
52
- }
53
- if (hasSources && overrides.sources !== void 0) {
54
- metaOpts.sources = overrides.sources;
55
- } else if (!hasSources) {
56
- metaOpts.sources = {};
57
- }
58
- const meta = irMeta(Object.keys(metaOpts).length > 0 ? metaOpts : void 0);
59
- const result = {
60
- schemaVersion: hasSchemaVersion && overrides.schemaVersion !== void 0 ? overrides.schemaVersion : hasSchemaVersion && overrides.schemaVersion === void 0 ? void 0 : header.schemaVersion,
61
- target: header.target,
62
- targetFamily: header.targetFamily,
63
- // Only include meta fields if they're not explicitly undefined
64
- capabilities: hasCapabilities && overrides.capabilities === void 0 ? void 0 : !hasCapabilities || overrides.capabilities !== void 0 ? meta.capabilities : {},
65
- extensionPacks: hasExtensionPacks && overrides.extensionPacks === void 0 ? void 0 : !hasExtensionPacks || overrides.extensionPacks !== void 0 ? meta.extensionPacks : {},
66
- meta: hasMeta && overrides.meta === void 0 ? void 0 : !hasMeta || overrides.meta !== void 0 ? meta.meta : {},
67
- sources: hasSources && overrides.sources === void 0 ? void 0 : !hasSources || overrides.sources !== void 0 ? meta.sources : {},
68
- // Only include family sections if they're not explicitly undefined
69
- storage: hasStorage && overrides.storage === void 0 ? void 0 : hasStorage && overrides.storage !== void 0 ? overrides.storage : !hasStorage ? { tables: {} } : {},
70
- models: hasModels && overrides.models === void 0 ? void 0 : hasModels && overrides.models !== void 0 ? overrides.models : !hasModels ? {} : {},
71
- relations: hasRelations && overrides.relations === void 0 ? void 0 : hasRelations && overrides.relations !== void 0 ? overrides.relations : !hasRelations ? {} : {}
72
- };
73
- return result;
74
- }
75
- export {
76
- createContractIR
77
- };
78
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../test/utils.ts"],"sourcesContent":["import { type ContractIR, irHeader, irMeta } from '@prisma-next/contract/ir';\n\n/**\n * Factory function for creating ContractIR objects in tests.\n * Provides sensible defaults and allows overriding specific fields.\n * Uses the emitter factories internally for consistency.\n *\n * If a field is explicitly set to `undefined` in overrides, it will be omitted\n * from the result (useful for testing validation of missing fields).\n */\nexport function createContractIR(\n overrides: Partial<ContractIR> & { coreHash?: string; profileHash?: string } = {},\n): ContractIR {\n // Check if fields are explicitly undefined (not just missing)\n const hasTarget = 'target' in overrides;\n const hasTargetFamily = 'targetFamily' in overrides;\n const hasCoreHash = 'coreHash' in overrides;\n const hasSchemaVersion = 'schemaVersion' in overrides;\n const hasModels = 'models' in overrides;\n const hasRelations = 'relations' in overrides;\n const hasStorage = 'storage' in overrides;\n const hasCapabilities = 'capabilities' in overrides;\n const hasExtensionPacks = 'extensionPacks' in overrides;\n const hasMeta = 'meta' in overrides;\n const hasSources = 'sources' in overrides;\n\n // Build header, omitting fields that are explicitly undefined\n const headerOpts: {\n target?: string;\n targetFamily?: string;\n coreHash?: string;\n profileHash?: string;\n } = {};\n\n if (hasTarget && overrides.target !== undefined) {\n headerOpts.target = overrides.target;\n } else if (!hasTarget) {\n headerOpts.target = 'postgres';\n }\n\n if (hasTargetFamily && overrides.targetFamily !== undefined) {\n headerOpts.targetFamily = overrides.targetFamily;\n } else if (!hasTargetFamily) {\n headerOpts.targetFamily = 'sql';\n }\n\n if (hasCoreHash && overrides.coreHash !== undefined) {\n headerOpts.coreHash = overrides.coreHash;\n } else if (!hasCoreHash) {\n headerOpts.coreHash = 'sha256:test';\n }\n\n // profileHash is not part of ContractIR, but we can accept it for header creation\n if (overrides.profileHash !== undefined) {\n headerOpts.profileHash = overrides.profileHash;\n }\n\n const header = irHeader(\n headerOpts as {\n target: string;\n targetFamily: string;\n coreHash: string;\n profileHash?: string;\n },\n );\n\n // Build meta, handling explicitly undefined fields\n // If a field is explicitly undefined, we'll omit it from the result later\n const metaOpts: {\n capabilities?: Record<string, Record<string, boolean>>;\n extensionPacks?: Record<string, unknown>;\n meta?: Record<string, unknown>;\n sources?: Record<string, unknown>;\n } = {};\n\n if (hasCapabilities && overrides.capabilities !== undefined) {\n metaOpts.capabilities = overrides.capabilities;\n } else if (!hasCapabilities) {\n metaOpts.capabilities = {};\n }\n\n if (hasExtensionPacks && overrides.extensionPacks !== undefined) {\n metaOpts.extensionPacks = overrides.extensionPacks;\n } else if (!hasExtensionPacks) {\n metaOpts.extensionPacks = {};\n }\n\n if (hasMeta && overrides.meta !== undefined) {\n metaOpts.meta = overrides.meta;\n } else if (!hasMeta) {\n metaOpts.meta = {};\n }\n\n if (hasSources && overrides.sources !== undefined) {\n metaOpts.sources = overrides.sources;\n } else if (!hasSources) {\n metaOpts.sources = {};\n }\n\n const meta = irMeta(Object.keys(metaOpts).length > 0 ? metaOpts : undefined);\n\n // Build result by constructing the object directly (ContractIR doesn't include coreHash/profileHash)\n // When fields are explicitly undefined, include them as undefined (tests use type assertions to bypass TS)\n const result = {\n schemaVersion:\n hasSchemaVersion && overrides.schemaVersion !== undefined\n ? overrides.schemaVersion\n : hasSchemaVersion && overrides.schemaVersion === undefined\n ? (undefined as unknown as string)\n : header.schemaVersion,\n target: header.target,\n targetFamily: header.targetFamily,\n // Only include meta fields if they're not explicitly undefined\n capabilities:\n hasCapabilities && overrides.capabilities === undefined\n ? (undefined as unknown as Record<string, Record<string, boolean>>)\n : !hasCapabilities || overrides.capabilities !== undefined\n ? meta.capabilities\n : ({} as Record<string, Record<string, boolean>>),\n extensionPacks:\n hasExtensionPacks && overrides.extensionPacks === undefined\n ? (undefined as unknown as Record<string, unknown>)\n : !hasExtensionPacks || overrides.extensionPacks !== undefined\n ? meta.extensionPacks\n : ({} as Record<string, unknown>),\n meta:\n hasMeta && overrides.meta === undefined\n ? (undefined as unknown as Record<string, unknown>)\n : !hasMeta || overrides.meta !== undefined\n ? meta.meta\n : ({} as Record<string, unknown>),\n sources:\n hasSources && overrides.sources === undefined\n ? (undefined as unknown as Record<string, unknown>)\n : !hasSources || overrides.sources !== undefined\n ? meta.sources\n : ({} as Record<string, unknown>),\n // Only include family sections if they're not explicitly undefined\n storage:\n hasStorage && overrides.storage === undefined\n ? (undefined as unknown as Record<string, unknown>)\n : hasStorage && overrides.storage !== undefined\n ? (overrides.storage as Record<string, unknown>)\n : !hasStorage\n ? ({ tables: {} } as Record<string, unknown>)\n : ({} as Record<string, unknown>),\n models:\n hasModels && overrides.models === undefined\n ? (undefined as unknown as Record<string, unknown>)\n : hasModels && overrides.models !== undefined\n ? (overrides.models as Record<string, unknown>)\n : !hasModels\n ? {}\n : ({} as Record<string, unknown>),\n relations:\n hasRelations && overrides.relations === undefined\n ? (undefined as unknown as Record<string, unknown>)\n : hasRelations && overrides.relations !== undefined\n ? (overrides.relations as Record<string, unknown>)\n : !hasRelations\n ? {}\n : ({} as Record<string, unknown>),\n } as ContractIR;\n\n return result;\n}\n"],"mappings":";AAAA,SAA0B,UAAU,cAAc;AAU3C,SAAS,iBACd,YAA+E,CAAC,GACpE;AAEZ,QAAM,YAAY,YAAY;AAC9B,QAAM,kBAAkB,kBAAkB;AAC1C,QAAM,cAAc,cAAc;AAClC,QAAM,mBAAmB,mBAAmB;AAC5C,QAAM,YAAY,YAAY;AAC9B,QAAM,eAAe,eAAe;AACpC,QAAM,aAAa,aAAa;AAChC,QAAM,kBAAkB,kBAAkB;AAC1C,QAAM,oBAAoB,oBAAoB;AAC9C,QAAM,UAAU,UAAU;AAC1B,QAAM,aAAa,aAAa;AAGhC,QAAM,aAKF,CAAC;AAEL,MAAI,aAAa,UAAU,WAAW,QAAW;AAC/C,eAAW,SAAS,UAAU;AAAA,EAChC,WAAW,CAAC,WAAW;AACrB,eAAW,SAAS;AAAA,EACtB;AAEA,MAAI,mBAAmB,UAAU,iBAAiB,QAAW;AAC3D,eAAW,eAAe,UAAU;AAAA,EACtC,WAAW,CAAC,iBAAiB;AAC3B,eAAW,eAAe;AAAA,EAC5B;AAEA,MAAI,eAAe,UAAU,aAAa,QAAW;AACnD,eAAW,WAAW,UAAU;AAAA,EAClC,WAAW,CAAC,aAAa;AACvB,eAAW,WAAW;AAAA,EACxB;AAGA,MAAI,UAAU,gBAAgB,QAAW;AACvC,eAAW,cAAc,UAAU;AAAA,EACrC;AAEA,QAAM,SAAS;AAAA,IACb;AAAA,EAMF;AAIA,QAAM,WAKF,CAAC;AAEL,MAAI,mBAAmB,UAAU,iBAAiB,QAAW;AAC3D,aAAS,eAAe,UAAU;AAAA,EACpC,WAAW,CAAC,iBAAiB;AAC3B,aAAS,eAAe,CAAC;AAAA,EAC3B;AAEA,MAAI,qBAAqB,UAAU,mBAAmB,QAAW;AAC/D,aAAS,iBAAiB,UAAU;AAAA,EACtC,WAAW,CAAC,mBAAmB;AAC7B,aAAS,iBAAiB,CAAC;AAAA,EAC7B;AAEA,MAAI,WAAW,UAAU,SAAS,QAAW;AAC3C,aAAS,OAAO,UAAU;AAAA,EAC5B,WAAW,CAAC,SAAS;AACnB,aAAS,OAAO,CAAC;AAAA,EACnB;AAEA,MAAI,cAAc,UAAU,YAAY,QAAW;AACjD,aAAS,UAAU,UAAU;AAAA,EAC/B,WAAW,CAAC,YAAY;AACtB,aAAS,UAAU,CAAC;AAAA,EACtB;AAEA,QAAM,OAAO,OAAO,OAAO,KAAK,QAAQ,EAAE,SAAS,IAAI,WAAW,MAAS;AAI3E,QAAM,SAAS;AAAA,IACb,eACE,oBAAoB,UAAU,kBAAkB,SAC5C,UAAU,gBACV,oBAAoB,UAAU,kBAAkB,SAC7C,SACD,OAAO;AAAA,IACf,QAAQ,OAAO;AAAA,IACf,cAAc,OAAO;AAAA;AAAA,IAErB,cACE,mBAAmB,UAAU,iBAAiB,SACzC,SACD,CAAC,mBAAmB,UAAU,iBAAiB,SAC7C,KAAK,eACJ,CAAC;AAAA,IACV,gBACE,qBAAqB,UAAU,mBAAmB,SAC7C,SACD,CAAC,qBAAqB,UAAU,mBAAmB,SACjD,KAAK,iBACJ,CAAC;AAAA,IACV,MACE,WAAW,UAAU,SAAS,SACzB,SACD,CAAC,WAAW,UAAU,SAAS,SAC7B,KAAK,OACJ,CAAC;AAAA,IACV,SACE,cAAc,UAAU,YAAY,SAC/B,SACD,CAAC,cAAc,UAAU,YAAY,SACnC,KAAK,UACJ,CAAC;AAAA;AAAA,IAEV,SACE,cAAc,UAAU,YAAY,SAC/B,SACD,cAAc,UAAU,YAAY,SACjC,UAAU,UACX,CAAC,aACE,EAAE,QAAQ,CAAC,EAAE,IACb,CAAC;AAAA,IACZ,QACE,aAAa,UAAU,WAAW,SAC7B,SACD,aAAa,UAAU,WAAW,SAC/B,UAAU,SACX,CAAC,YACC,CAAC,IACA,CAAC;AAAA,IACZ,WACE,gBAAgB,UAAU,cAAc,SACnC,SACD,gBAAgB,UAAU,cAAc,SACrC,UAAU,YACX,CAAC,eACC,CAAC,IACA,CAAC;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
@@ -1,7 +0,0 @@
1
- // Re-export types from @prisma-next/contract for backward compatibility
2
- // These types were moved to @prisma-next/contract to resolve dependency violations
3
- export type {
4
- TargetFamilyHook,
5
- TypesImportSpec,
6
- ValidationContext,
7
- } from '@prisma-next/contract/types';