@prisma-next/family-sql 0.3.0-dev.16 → 0.3.0-dev.162

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 (118) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +58 -22
  3. package/dist/authoring-type-constructors-DgU-RFaP.mjs +203 -0
  4. package/dist/authoring-type-constructors-DgU-RFaP.mjs.map +1 -0
  5. package/dist/control-adapter.d.mts +54 -0
  6. package/dist/control-adapter.d.mts.map +1 -0
  7. package/dist/control-adapter.mjs +1 -0
  8. package/dist/control.d.mts +386 -0
  9. package/dist/control.d.mts.map +1 -0
  10. package/dist/control.mjs +643 -0
  11. package/dist/control.mjs.map +1 -0
  12. package/dist/operation-descriptors.d.mts +380 -0
  13. package/dist/operation-descriptors.d.mts.map +1 -0
  14. package/dist/operation-descriptors.mjs +294 -0
  15. package/dist/operation-descriptors.mjs.map +1 -0
  16. package/dist/pack.d.mts +248 -0
  17. package/dist/pack.d.mts.map +1 -0
  18. package/dist/pack.mjs +18 -0
  19. package/dist/pack.mjs.map +1 -0
  20. package/dist/runtime.d.mts +27 -0
  21. package/dist/runtime.d.mts.map +1 -0
  22. package/dist/runtime.mjs +38 -0
  23. package/dist/runtime.mjs.map +1 -0
  24. package/dist/schema-verify.d.mts +48 -0
  25. package/dist/schema-verify.d.mts.map +1 -0
  26. package/dist/schema-verify.mjs +3 -0
  27. package/dist/test-utils.d.mts +2 -0
  28. package/dist/test-utils.mjs +3 -0
  29. package/dist/types-BaUzKt6Q.d.mts +353 -0
  30. package/dist/types-BaUzKt6Q.d.mts.map +1 -0
  31. package/dist/verify-DZHtfcmj.mjs +108 -0
  32. package/dist/verify-DZHtfcmj.mjs.map +1 -0
  33. package/dist/verify-sql-schema-BBhkqEDo.d.mts +67 -0
  34. package/dist/verify-sql-schema-BBhkqEDo.d.mts.map +1 -0
  35. package/dist/verify-sql-schema-lR-tlboL.mjs +1174 -0
  36. package/dist/verify-sql-schema-lR-tlboL.mjs.map +1 -0
  37. package/dist/verify.d.mts +31 -0
  38. package/dist/verify.d.mts.map +1 -0
  39. package/dist/verify.mjs +3 -0
  40. package/package.json +38 -46
  41. package/src/core/assembly.ts +132 -92
  42. package/src/core/authoring-field-presets.ts +207 -0
  43. package/src/core/authoring-type-constructors.ts +17 -0
  44. package/src/core/control-adapter.ts +18 -10
  45. package/src/core/control-descriptor.ts +28 -0
  46. package/src/core/control-instance.ts +700 -0
  47. package/src/core/migrations/contract-to-schema-ir.ts +269 -0
  48. package/src/core/migrations/descriptor-schemas.ts +172 -0
  49. package/src/core/migrations/operation-descriptors.ts +213 -0
  50. package/src/core/migrations/policies.ts +1 -1
  51. package/src/core/migrations/types.ts +199 -175
  52. package/src/core/runtime-descriptor.ts +19 -41
  53. package/src/core/runtime-instance.ts +11 -133
  54. package/src/core/schema-verify/verify-helpers.ts +206 -106
  55. package/src/core/schema-verify/verify-sql-schema.ts +964 -414
  56. package/src/core/verify.ts +4 -13
  57. package/src/exports/control.ts +31 -8
  58. package/src/exports/operation-descriptors.ts +52 -0
  59. package/src/exports/pack.ts +16 -0
  60. package/src/exports/runtime.ts +2 -6
  61. package/src/exports/schema-verify.ts +10 -2
  62. package/src/exports/test-utils.ts +3 -4
  63. package/dist/chunk-BHEGVBY7.js +0 -772
  64. package/dist/chunk-BHEGVBY7.js.map +0 -1
  65. package/dist/chunk-SQ2VWYDV.js +0 -589
  66. package/dist/chunk-SQ2VWYDV.js.map +0 -1
  67. package/dist/chunk-SU7LN2UH.js +0 -96
  68. package/dist/chunk-SU7LN2UH.js.map +0 -1
  69. package/dist/core/assembly.d.ts +0 -25
  70. package/dist/core/assembly.d.ts.map +0 -1
  71. package/dist/core/control-adapter.d.ts +0 -42
  72. package/dist/core/control-adapter.d.ts.map +0 -1
  73. package/dist/core/descriptor.d.ts +0 -24
  74. package/dist/core/descriptor.d.ts.map +0 -1
  75. package/dist/core/instance.d.ts +0 -140
  76. package/dist/core/instance.d.ts.map +0 -1
  77. package/dist/core/migrations/plan-helpers.d.ts +0 -20
  78. package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
  79. package/dist/core/migrations/policies.d.ts +0 -6
  80. package/dist/core/migrations/policies.d.ts.map +0 -1
  81. package/dist/core/migrations/types.d.ts +0 -280
  82. package/dist/core/migrations/types.d.ts.map +0 -1
  83. package/dist/core/runtime-descriptor.d.ts +0 -19
  84. package/dist/core/runtime-descriptor.d.ts.map +0 -1
  85. package/dist/core/runtime-instance.d.ts +0 -54
  86. package/dist/core/runtime-instance.d.ts.map +0 -1
  87. package/dist/core/schema-verify/verify-helpers.d.ts +0 -50
  88. package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
  89. package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
  90. package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
  91. package/dist/core/verify.d.ts +0 -39
  92. package/dist/core/verify.d.ts.map +0 -1
  93. package/dist/exports/control-adapter.d.ts +0 -2
  94. package/dist/exports/control-adapter.d.ts.map +0 -1
  95. package/dist/exports/control-adapter.js +0 -1
  96. package/dist/exports/control-adapter.js.map +0 -1
  97. package/dist/exports/control.d.ts +0 -13
  98. package/dist/exports/control.d.ts.map +0 -1
  99. package/dist/exports/control.js +0 -149
  100. package/dist/exports/control.js.map +0 -1
  101. package/dist/exports/runtime.d.ts +0 -8
  102. package/dist/exports/runtime.d.ts.map +0 -1
  103. package/dist/exports/runtime.js +0 -64
  104. package/dist/exports/runtime.js.map +0 -1
  105. package/dist/exports/schema-verify.d.ts +0 -11
  106. package/dist/exports/schema-verify.d.ts.map +0 -1
  107. package/dist/exports/schema-verify.js +0 -11
  108. package/dist/exports/schema-verify.js.map +0 -1
  109. package/dist/exports/test-utils.d.ts +0 -7
  110. package/dist/exports/test-utils.d.ts.map +0 -1
  111. package/dist/exports/test-utils.js +0 -17
  112. package/dist/exports/test-utils.js.map +0 -1
  113. package/dist/exports/verify.d.ts +0 -2
  114. package/dist/exports/verify.d.ts.map +0 -1
  115. package/dist/exports/verify.js +0 -11
  116. package/dist/exports/verify.js.map +0 -1
  117. package/src/core/descriptor.ts +0 -33
  118. package/src/core/instance.ts +0 -903
@@ -1,117 +1,157 @@
1
- import type { OperationManifest } from '@prisma-next/contract/pack-manifest-types';
2
- import type { TypesImportSpec } from '@prisma-next/contract/types';
1
+ import type { AuthoringContributions } from '@prisma-next/framework-components/authoring';
2
+ import type { Codec } from '@prisma-next/framework-components/codec';
3
+ import type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';
4
+ import { assertUniqueCodecOwner } from '@prisma-next/framework-components/control';
5
+ import type { TypesImportSpec } from '@prisma-next/framework-components/emission';
3
6
  import type {
4
- ControlAdapterDescriptor,
5
- ControlExtensionDescriptor,
6
- ControlTargetDescriptor,
7
- } from '@prisma-next/core-control-plane/types';
8
- import type { OperationRegistry, OperationSignature } from '@prisma-next/operations';
9
- import { createOperationRegistry } from '@prisma-next/operations';
10
-
11
- /**
12
- * Assembles an operation registry from descriptors (adapter, target, extensions).
13
- * Loops over descriptors, extracts operations, converts them using the provided
14
- * conversion function, and registers them in a new registry.
15
- */
16
- export function assembleOperationRegistry(
17
- descriptors: ReadonlyArray<
18
- | ControlTargetDescriptor<'sql', string>
19
- | ControlAdapterDescriptor<'sql', string>
20
- | ControlExtensionDescriptor<'sql', string>
21
- >,
22
- convertOperationManifest: (manifest: OperationManifest) => OperationSignature,
23
- ): OperationRegistry {
24
- const registry = createOperationRegistry();
7
+ CodecControlHooks,
8
+ ControlMutationDefaultFunctionEntry,
9
+ ControlMutationDefaultGeneratorDescriptor,
10
+ PslScalarTypeDescriptor,
11
+ SqlControlStaticContributions,
12
+ } from './migrations/types';
25
13
 
26
- for (const descriptor of descriptors) {
27
- const operations = descriptor.operations ?? [];
28
- for (const operationManifest of operations as ReadonlyArray<OperationManifest>) {
29
- const signature = convertOperationManifest(operationManifest);
30
- registry.register(signature);
31
- }
32
- }
14
+ export interface SqlControlDescriptorWithContributions extends SqlControlStaticContributions {
15
+ readonly id: string;
16
+ readonly authoring?: AuthoringContributions;
17
+ readonly types?: {
18
+ readonly codecTypes?: {
19
+ readonly import?: TypesImportSpec;
20
+ readonly codecInstances?: ReadonlyArray<Codec>;
21
+ readonly typeImports?: ReadonlyArray<TypesImportSpec>;
22
+ };
23
+ readonly operationTypes?: { readonly import: TypesImportSpec };
24
+ };
25
+ }
26
+
27
+ export interface AssembledControlMutationDefaultContributions {
28
+ readonly defaultFunctionRegistry: ReadonlyMap<string, ControlMutationDefaultFunctionEntry>;
29
+ readonly generatorDescriptors: readonly ControlMutationDefaultGeneratorDescriptor[];
30
+ }
31
+
32
+ export interface AssembledPslInterpretationContributions
33
+ extends AssembledControlMutationDefaultContributions {
34
+ readonly scalarTypeDescriptors: ReadonlyMap<string, PslScalarTypeDescriptor>;
35
+ }
33
36
 
34
- return registry;
37
+ type CodecControlHooksMap = Record<string, CodecControlHooks>;
38
+
39
+ function hasCodecControlHooks(descriptor: unknown): descriptor is {
40
+ readonly id: string;
41
+ readonly types: {
42
+ readonly codecTypes: {
43
+ readonly controlPlaneHooks: CodecControlHooksMap;
44
+ };
45
+ };
46
+ } {
47
+ if (typeof descriptor !== 'object' || descriptor === null) {
48
+ return false;
49
+ }
50
+ const d = descriptor as { types?: { codecTypes?: { controlPlaneHooks?: unknown } } };
51
+ const hooks = d.types?.codecTypes?.controlPlaneHooks;
52
+ return hooks !== null && hooks !== undefined && typeof hooks === 'object';
35
53
  }
36
54
 
37
- /**
38
- * Extracts codec type imports from descriptors for contract.d.ts generation.
39
- */
40
- export function extractCodecTypeImports(
41
- descriptors: ReadonlyArray<
42
- | ControlTargetDescriptor<'sql', string>
43
- | ControlAdapterDescriptor<'sql', string>
44
- | ControlExtensionDescriptor<'sql', string>
45
- >,
46
- ): ReadonlyArray<TypesImportSpec> {
47
- const imports: TypesImportSpec[] = [];
55
+ export function extractCodecControlHooks(
56
+ descriptors: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>,
57
+ ): Map<string, CodecControlHooks> {
58
+ const hooks = new Map<string, CodecControlHooks>();
59
+ const owners = new Map<string, string>();
48
60
 
49
61
  for (const descriptor of descriptors) {
50
- const types = descriptor.types;
51
- const codecTypes = types?.codecTypes;
52
- if (codecTypes?.import) {
53
- imports.push(codecTypes.import);
62
+ if (typeof descriptor !== 'object' || descriptor === null) {
63
+ continue;
64
+ }
65
+ if (!hasCodecControlHooks(descriptor)) {
66
+ continue;
67
+ }
68
+ const controlPlaneHooks = descriptor.types.codecTypes.controlPlaneHooks;
69
+ for (const [codecId, hook] of Object.entries(controlPlaneHooks)) {
70
+ assertUniqueCodecOwner({
71
+ codecId,
72
+ owners,
73
+ descriptorId: descriptor.id,
74
+ entityLabel: 'control hooks',
75
+ entityOwnershipLabel: 'owner',
76
+ });
77
+ hooks.set(codecId, hook);
78
+ owners.set(codecId, descriptor.id);
54
79
  }
55
80
  }
56
81
 
57
- return imports;
82
+ return hooks;
58
83
  }
59
84
 
60
- /**
61
- * Extracts operation type imports from descriptors for contract.d.ts generation.
62
- */
63
- export function extractOperationTypeImports(
64
- descriptors: ReadonlyArray<
65
- | ControlTargetDescriptor<'sql', string>
66
- | ControlAdapterDescriptor<'sql', string>
67
- | ControlExtensionDescriptor<'sql', string>
68
- >,
69
- ): ReadonlyArray<TypesImportSpec> {
70
- const imports: TypesImportSpec[] = [];
85
+ export function assembleControlMutationDefaultContributions(
86
+ descriptors: ReadonlyArray<SqlControlDescriptorWithContributions>,
87
+ ): AssembledControlMutationDefaultContributions {
88
+ const defaultFunctionRegistry = new Map<string, ControlMutationDefaultFunctionEntry>();
89
+ const functionOwners = new Map<string, string>();
90
+ const generatorMap = new Map<string, ControlMutationDefaultGeneratorDescriptor>();
91
+ const generatorOwners = new Map<string, string>();
71
92
 
72
93
  for (const descriptor of descriptors) {
73
- const types = descriptor.types;
74
- const operationTypes = types?.operationTypes;
75
- if (operationTypes?.import) {
76
- imports.push(operationTypes.import);
94
+ const contributions = descriptor.controlMutationDefaults?.();
95
+ if (!contributions) {
96
+ continue;
97
+ }
98
+
99
+ for (const generatorDescriptor of contributions.generatorDescriptors) {
100
+ const owner = generatorOwners.get(generatorDescriptor.id);
101
+ if (owner) {
102
+ throw new Error(
103
+ `Duplicate mutation default generator id "${generatorDescriptor.id}". Descriptor "${descriptor.id}" conflicts with "${owner}".`,
104
+ );
105
+ }
106
+ generatorMap.set(generatorDescriptor.id, generatorDescriptor);
107
+ generatorOwners.set(generatorDescriptor.id, descriptor.id);
108
+ }
109
+
110
+ for (const [functionName, handler] of contributions.defaultFunctionRegistry) {
111
+ const owner = functionOwners.get(functionName);
112
+ if (owner) {
113
+ throw new Error(
114
+ `Duplicate mutation default function "${functionName}". Descriptor "${descriptor.id}" conflicts with "${owner}".`,
115
+ );
116
+ }
117
+ defaultFunctionRegistry.set(functionName, handler);
118
+ functionOwners.set(functionName, descriptor.id);
77
119
  }
78
120
  }
79
121
 
80
- return imports;
122
+ return {
123
+ defaultFunctionRegistry,
124
+ generatorDescriptors: Array.from(generatorMap.values()),
125
+ };
81
126
  }
82
127
 
83
- /**
84
- * Extracts extension IDs from descriptors in deterministic order:
85
- * [adapter.id, target.id, ...extensions.map(e => e.id)]
86
- * Deduplicates while preserving stable order.
87
- */
88
- export function extractExtensionIds(
89
- adapter: ControlAdapterDescriptor<'sql', string>,
90
- target: ControlTargetDescriptor<'sql', string>,
91
- extensions: ReadonlyArray<ControlExtensionDescriptor<'sql', string>>,
92
- ): ReadonlyArray<string> {
93
- const ids: string[] = [];
94
- const seen = new Set<string>();
95
-
96
- // Add adapter first
97
- if (!seen.has(adapter.id)) {
98
- ids.push(adapter.id);
99
- seen.add(adapter.id);
100
- }
128
+ export function assemblePslInterpretationContributions(
129
+ descriptors: ReadonlyArray<SqlControlDescriptorWithContributions>,
130
+ ): AssembledPslInterpretationContributions {
131
+ const mutationDefaults = assembleControlMutationDefaultContributions(descriptors);
132
+ const scalarTypeDescriptors = new Map<string, PslScalarTypeDescriptor>();
133
+ const scalarOwners = new Map<string, string>();
101
134
 
102
- // Add target second
103
- if (!seen.has(target.id)) {
104
- ids.push(target.id);
105
- seen.add(target.id);
106
- }
135
+ for (const descriptor of descriptors) {
136
+ const pslTypeContributions = descriptor.pslTypeDescriptors?.();
137
+ if (!pslTypeContributions) {
138
+ continue;
139
+ }
107
140
 
108
- // Add extensions in order
109
- for (const ext of extensions) {
110
- if (!seen.has(ext.id)) {
111
- ids.push(ext.id);
112
- seen.add(ext.id);
141
+ for (const [typeName, scalarDescriptor] of pslTypeContributions.scalarTypeDescriptors) {
142
+ const owner = scalarOwners.get(typeName);
143
+ if (owner) {
144
+ throw new Error(
145
+ `Duplicate PSL scalar type descriptor "${typeName}". Descriptor "${descriptor.id}" conflicts with "${owner}".`,
146
+ );
147
+ }
148
+ scalarTypeDescriptors.set(typeName, scalarDescriptor);
149
+ scalarOwners.set(typeName, descriptor.id);
113
150
  }
114
151
  }
115
152
 
116
- return ids;
153
+ return {
154
+ ...mutationDefaults,
155
+ scalarTypeDescriptors,
156
+ };
117
157
  }
@@ -0,0 +1,207 @@
1
+ import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';
2
+
3
+ const CHARACTER_CODEC_ID = 'sql/char@1';
4
+ const CHARACTER_NATIVE_TYPE = 'character';
5
+
6
+ const nanoidOptionsArgument = {
7
+ kind: 'object',
8
+ optional: true,
9
+ properties: {
10
+ size: {
11
+ kind: 'number',
12
+ optional: true,
13
+ integer: true,
14
+ minimum: 2,
15
+ maximum: 255,
16
+ },
17
+ },
18
+ } as const;
19
+
20
+ export const sqlFamilyAuthoringFieldPresets = {
21
+ text: {
22
+ kind: 'fieldPreset',
23
+ output: {
24
+ codecId: 'sql/text@1',
25
+ nativeType: 'text',
26
+ },
27
+ },
28
+ timestamp: {
29
+ kind: 'fieldPreset',
30
+ output: {
31
+ codecId: 'sql/timestamp@1',
32
+ nativeType: 'timestamp',
33
+ },
34
+ },
35
+ createdAt: {
36
+ kind: 'fieldPreset',
37
+ output: {
38
+ codecId: 'sql/timestamp@1',
39
+ nativeType: 'timestamp',
40
+ default: {
41
+ kind: 'function',
42
+ expression: 'CURRENT_TIMESTAMP',
43
+ },
44
+ },
45
+ },
46
+ uuid: {
47
+ kind: 'fieldPreset',
48
+ output: {
49
+ codecId: CHARACTER_CODEC_ID,
50
+ nativeType: CHARACTER_NATIVE_TYPE,
51
+ typeParams: {
52
+ length: 36,
53
+ },
54
+ },
55
+ },
56
+ ulid: {
57
+ kind: 'fieldPreset',
58
+ output: {
59
+ codecId: CHARACTER_CODEC_ID,
60
+ nativeType: CHARACTER_NATIVE_TYPE,
61
+ typeParams: {
62
+ length: 26,
63
+ },
64
+ },
65
+ },
66
+ nanoid: {
67
+ kind: 'fieldPreset',
68
+ args: [nanoidOptionsArgument],
69
+ output: {
70
+ codecId: CHARACTER_CODEC_ID,
71
+ nativeType: CHARACTER_NATIVE_TYPE,
72
+ typeParams: {
73
+ length: {
74
+ kind: 'arg',
75
+ index: 0,
76
+ path: ['size'],
77
+ default: 21,
78
+ },
79
+ },
80
+ },
81
+ },
82
+ cuid2: {
83
+ kind: 'fieldPreset',
84
+ output: {
85
+ codecId: CHARACTER_CODEC_ID,
86
+ nativeType: CHARACTER_NATIVE_TYPE,
87
+ typeParams: {
88
+ length: 24,
89
+ },
90
+ },
91
+ },
92
+ ksuid: {
93
+ kind: 'fieldPreset',
94
+ output: {
95
+ codecId: CHARACTER_CODEC_ID,
96
+ nativeType: CHARACTER_NATIVE_TYPE,
97
+ typeParams: {
98
+ length: 27,
99
+ },
100
+ },
101
+ },
102
+ id: {
103
+ uuidv4: {
104
+ kind: 'fieldPreset',
105
+ output: {
106
+ codecId: CHARACTER_CODEC_ID,
107
+ nativeType: CHARACTER_NATIVE_TYPE,
108
+ typeParams: {
109
+ length: 36,
110
+ },
111
+ executionDefault: {
112
+ kind: 'generator',
113
+ id: 'uuidv4',
114
+ },
115
+ id: true,
116
+ },
117
+ },
118
+ uuidv7: {
119
+ kind: 'fieldPreset',
120
+ output: {
121
+ codecId: CHARACTER_CODEC_ID,
122
+ nativeType: CHARACTER_NATIVE_TYPE,
123
+ typeParams: {
124
+ length: 36,
125
+ },
126
+ executionDefault: {
127
+ kind: 'generator',
128
+ id: 'uuidv7',
129
+ },
130
+ id: true,
131
+ },
132
+ },
133
+ ulid: {
134
+ kind: 'fieldPreset',
135
+ output: {
136
+ codecId: CHARACTER_CODEC_ID,
137
+ nativeType: CHARACTER_NATIVE_TYPE,
138
+ typeParams: {
139
+ length: 26,
140
+ },
141
+ executionDefault: {
142
+ kind: 'generator',
143
+ id: 'ulid',
144
+ },
145
+ id: true,
146
+ },
147
+ },
148
+ nanoid: {
149
+ kind: 'fieldPreset',
150
+ args: [nanoidOptionsArgument],
151
+ output: {
152
+ codecId: CHARACTER_CODEC_ID,
153
+ nativeType: CHARACTER_NATIVE_TYPE,
154
+ typeParams: {
155
+ length: {
156
+ kind: 'arg',
157
+ index: 0,
158
+ path: ['size'],
159
+ default: 21,
160
+ },
161
+ },
162
+ executionDefault: {
163
+ kind: 'generator',
164
+ id: 'nanoid',
165
+ params: {
166
+ size: {
167
+ kind: 'arg',
168
+ index: 0,
169
+ path: ['size'],
170
+ },
171
+ },
172
+ },
173
+ id: true,
174
+ },
175
+ },
176
+ cuid2: {
177
+ kind: 'fieldPreset',
178
+ output: {
179
+ codecId: CHARACTER_CODEC_ID,
180
+ nativeType: CHARACTER_NATIVE_TYPE,
181
+ typeParams: {
182
+ length: 24,
183
+ },
184
+ executionDefault: {
185
+ kind: 'generator',
186
+ id: 'cuid2',
187
+ },
188
+ id: true,
189
+ },
190
+ },
191
+ ksuid: {
192
+ kind: 'fieldPreset',
193
+ output: {
194
+ codecId: CHARACTER_CODEC_ID,
195
+ nativeType: CHARACTER_NATIVE_TYPE,
196
+ typeParams: {
197
+ length: 27,
198
+ },
199
+ executionDefault: {
200
+ kind: 'generator',
201
+ id: 'ksuid',
202
+ },
203
+ id: true,
204
+ },
205
+ },
206
+ },
207
+ } as const satisfies AuthoringFieldNamespace;
@@ -0,0 +1,17 @@
1
+ import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';
2
+
3
+ export const sqlFamilyAuthoringTypes = {
4
+ sql: {
5
+ String: {
6
+ kind: 'typeConstructor',
7
+ args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],
8
+ output: {
9
+ codecId: 'sql/varchar@1',
10
+ nativeType: 'character varying',
11
+ typeParams: {
12
+ length: { kind: 'arg', index: 0 },
13
+ },
14
+ },
15
+ },
16
+ },
17
+ } as const satisfies AuthoringTypeNamespace;
@@ -1,8 +1,9 @@
1
1
  import type {
2
2
  ControlAdapterInstance,
3
3
  ControlDriverInstance,
4
- } from '@prisma-next/core-control-plane/types';
4
+ } from '@prisma-next/framework-components/control';
5
5
  import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
6
+ import type { DefaultNormalizer, NativeTypeNormalizer } from './schema-verify/verify-sql-schema';
6
7
 
7
8
  /**
8
9
  * SQL control adapter interface for control-plane operations.
@@ -12,13 +13,6 @@ import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
12
13
  */
13
14
  export interface SqlControlAdapter<TTarget extends string = string>
14
15
  extends ControlAdapterInstance<'sql', TTarget> {
15
- /**
16
- * The target ID this adapter implements.
17
- * Used for type tracking and runtime validation.
18
- * @deprecated Use targetId from ControlAdapterInstance instead
19
- */
20
- readonly target: TTarget;
21
-
22
16
  /**
23
17
  * Introspects a database schema and returns a raw SqlSchemaIR.
24
18
  *
@@ -27,15 +21,29 @@ export interface SqlControlAdapter<TTarget extends string = string>
27
21
  * Type mapping and enrichment are handled separately by enrichment helpers.
28
22
  *
29
23
  * @param driver - ControlDriverInstance instance for executing queries (target-specific)
30
- * @param contractIR - Optional contract IR for contract-guided introspection (filtering, optimization)
24
+ * @param contract - Optional contract for contract-guided introspection (filtering, optimization)
31
25
  * @param schema - Schema name to introspect (defaults to 'public')
32
26
  * @returns Promise resolving to SqlSchemaIR representing the live database schema
33
27
  */
34
28
  introspect(
35
29
  driver: ControlDriverInstance<'sql', TTarget>,
36
- contractIR?: unknown,
30
+ contract?: unknown,
37
31
  schema?: string,
38
32
  ): Promise<SqlSchemaIR>;
33
+
34
+ /**
35
+ * Optional target-specific normalizer for raw database default expressions.
36
+ * When provided, schema defaults (raw strings) are normalized before comparison
37
+ * with contract defaults (ColumnDefault objects) during schema verification.
38
+ */
39
+ readonly normalizeDefault?: DefaultNormalizer;
40
+
41
+ /**
42
+ * Optional target-specific normalizer for schema native type names.
43
+ * When provided, schema native types (from introspection) are normalized
44
+ * before comparison with contract native types during schema verification.
45
+ */
46
+ readonly normalizeNativeType?: NativeTypeNormalizer;
39
47
  }
40
48
 
41
49
  /**
@@ -0,0 +1,28 @@
1
+ import type {
2
+ ControlFamilyDescriptor,
3
+ ControlStack,
4
+ } from '@prisma-next/framework-components/control';
5
+ import { sqlEmission } from '@prisma-next/sql-contract-emitter';
6
+ import { sqlFamilyAuthoringFieldPresets } from './authoring-field-presets';
7
+ import { sqlFamilyAuthoringTypes } from './authoring-type-constructors';
8
+ import { createSqlFamilyInstance, type SqlControlFamilyInstance } from './control-instance';
9
+
10
+ export class SqlFamilyDescriptor
11
+ implements ControlFamilyDescriptor<'sql', SqlControlFamilyInstance>
12
+ {
13
+ readonly kind = 'family' as const;
14
+ readonly id = 'sql';
15
+ readonly familyId = 'sql' as const;
16
+ readonly version = '0.0.1';
17
+ readonly emission = sqlEmission;
18
+ readonly authoring = {
19
+ field: sqlFamilyAuthoringFieldPresets,
20
+ type: sqlFamilyAuthoringTypes,
21
+ } as const;
22
+
23
+ create<TTargetId extends string>(
24
+ stack: ControlStack<'sql', TTargetId>,
25
+ ): SqlControlFamilyInstance {
26
+ return createSqlFamilyInstance(stack);
27
+ }
28
+ }