@prisma-next/family-sql 0.3.0-pr.99.6 → 0.4.0-dev.1

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 +35 -43
  41. package/src/core/assembly.ts +123 -155
  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 +104 -22
  55. package/src/core/schema-verify/verify-sql-schema.ts +964 -418
  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 +4 -1
  62. package/src/exports/test-utils.ts +3 -4
  63. package/dist/chunk-GYEG3I7U.js +0 -624
  64. package/dist/chunk-GYEG3I7U.js.map +0 -1
  65. package/dist/chunk-SU7LN2UH.js +0 -96
  66. package/dist/chunk-SU7LN2UH.js.map +0 -1
  67. package/dist/chunk-XH2Y5NTD.js +0 -715
  68. package/dist/chunk-XH2Y5NTD.js.map +0 -1
  69. package/dist/core/assembly.d.ts +0 -43
  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 -28
  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 -96
  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 -15
  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 -909
@@ -0,0 +1,48 @@
1
+ import { i as verifySqlSchema, n as NativeTypeNormalizer, r as VerifySqlSchemaOptions } from "./verify-sql-schema-BBhkqEDo.mjs";
2
+ import { i as ComponentDatabaseDependency } from "./types-BaUzKt6Q.mjs";
3
+ import { SchemaIssue, SchemaVerificationNode } from "@prisma-next/framework-components/control";
4
+ import { SqlIndexIR, SqlSchemaIR, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
5
+
6
+ //#region src/core/schema-verify/verify-helpers.d.ts
7
+
8
+ /**
9
+ * Compares two arrays of strings for equality (order-sensitive).
10
+ */
11
+ declare function arraysEqual(a: readonly string[], b: readonly string[]): boolean;
12
+ /**
13
+ * Checks if a unique constraint requirement is satisfied by the given columns.
14
+ *
15
+ * Semantic satisfaction: a unique constraint requirement can be satisfied by:
16
+ * - A unique constraint with the same columns, OR
17
+ * - A unique index with the same columns
18
+ *
19
+ * @param uniques - The unique constraints in the schema table
20
+ * @param indexes - The indexes in the schema table
21
+ * @param columns - The columns required by the unique constraint
22
+ * @returns true if the requirement is satisfied
23
+ */
24
+ declare function isUniqueConstraintSatisfied(uniques: readonly SqlUniqueIR[], indexes: readonly SqlIndexIR[], columns: readonly string[]): boolean;
25
+ /**
26
+ * Checks if an index requirement is satisfied by the given columns.
27
+ *
28
+ * Semantic satisfaction: a non-unique index requirement can be satisfied by:
29
+ * - Any index (unique or non-unique) with the same columns, OR
30
+ * - A unique constraint with the same columns (stronger satisfies weaker)
31
+ *
32
+ * @param indexes - The indexes in the schema table
33
+ * @param uniques - The unique constraints in the schema table
34
+ * @param columns - The columns required by the index
35
+ * @returns true if the requirement is satisfied
36
+ */
37
+ declare function isIndexSatisfied(indexes: readonly SqlIndexIR[], uniques: readonly SqlUniqueIR[], columns: readonly string[]): boolean;
38
+ /**
39
+ * Verifies database dependencies are installed using component-owned verification hooks.
40
+ * Checks whether each dependency is satisfied by verifying its id is present in
41
+ * schema.dependencies (populated from introspection).
42
+ *
43
+ * Returns verification nodes for the tree.
44
+ */
45
+ declare function verifyDatabaseDependencies(dependencies: ReadonlyArray<ComponentDatabaseDependency<unknown>>, schema: SqlSchemaIR, issues: SchemaIssue[]): SchemaVerificationNode[];
46
+ //#endregion
47
+ export { type NativeTypeNormalizer, type VerifySqlSchemaOptions, arraysEqual, isIndexSatisfied, isUniqueConstraintSatisfied, verifyDatabaseDependencies, verifySqlSchema };
48
+ //# sourceMappingURL=schema-verify.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-verify.d.mts","names":[],"sources":["../src/core/schema-verify/verify-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;AAmFA;AA6YA;;AACgB,iBAvcA,WAAA,CAucA,CAAA,EAAA,SAAA,MAAA,EAAA,EAAA,CAAA,EAAA,SAAA,MAAA,EAAA,CAAA,EAAA,OAAA;;;;;;;;;;;;;iBAxaA,2BAAA,mBACI,iCACA;;;;;;;;;;;;;iBAwBJ,gBAAA,mBACI,gCACA;;;;;;;;iBA2YJ,0BAAA,eACA,cAAc,+CACpB,qBACA,gBACP"}
@@ -0,0 +1,3 @@
1
+ import { a as verifyDatabaseDependencies, i as isUniqueConstraintSatisfied, n as arraysEqual, r as isIndexSatisfied, t as verifySqlSchema } from "./verify-sql-schema-lR-tlboL.mjs";
2
+
3
+ export { arraysEqual, isIndexSatisfied, isUniqueConstraintSatisfied, verifyDatabaseDependencies, verifySqlSchema };
@@ -0,0 +1,2 @@
1
+ import { extractCodecTypeImports, extractComponentIds, extractOperationTypeImports, extractQueryOperationTypeImports } from "@prisma-next/framework-components/control";
2
+ export { extractCodecTypeImports, extractComponentIds, extractOperationTypeImports, extractQueryOperationTypeImports };
@@ -0,0 +1,3 @@
1
+ import { extractCodecTypeImports, extractComponentIds, extractOperationTypeImports, extractQueryOperationTypeImports } from "@prisma-next/framework-components/control";
2
+
3
+ export { extractCodecTypeImports, extractComponentIds, extractOperationTypeImports, extractQueryOperationTypeImports };
@@ -0,0 +1,353 @@
1
+ import { ControlAdapterDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, MigratableTargetDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerSuccessValue, OperationContext, SchemaIssue, SchemaViewCapable, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
2
+ import { Result } from "@prisma-next/utils/result";
3
+ import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
4
+ import { ColumnDefault, Contract, ExecutionMutationDefaultValue } from "@prisma-next/contract/types";
5
+ import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
6
+ import { SqlStorage, StorageTypeInstance } from "@prisma-next/sql-contract/types";
7
+ import { TypesImportSpec } from "@prisma-next/framework-components/emission";
8
+ import { SqlOperationDescriptor } from "@prisma-next/sql-operations";
9
+
10
+ //#region src/core/control-instance.d.ts
11
+ interface SqlTypeMetadata {
12
+ readonly typeId: string;
13
+ readonly familyId: 'sql';
14
+ readonly targetId: string;
15
+ readonly nativeType?: string;
16
+ }
17
+ type SqlTypeMetadataRegistry = Map<string, SqlTypeMetadata>;
18
+ interface SqlFamilyInstanceState {
19
+ readonly codecTypeImports: ReadonlyArray<TypesImportSpec>;
20
+ readonly operationTypeImports: ReadonlyArray<TypesImportSpec>;
21
+ readonly extensionIds: ReadonlyArray<string>;
22
+ readonly typeMetadataRegistry: SqlTypeMetadataRegistry;
23
+ }
24
+ interface SchemaVerifyOptions {
25
+ readonly driver: ControlDriverInstance<'sql', string>;
26
+ readonly contract: unknown;
27
+ readonly strict: boolean;
28
+ readonly context?: OperationContext;
29
+ /**
30
+ * Active framework components participating in this composition.
31
+ * All components must have matching familyId ('sql') and targetId.
32
+ */
33
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
34
+ }
35
+ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchemaIR>, SchemaViewCapable<SqlSchemaIR>, SqlFamilyInstanceState {
36
+ validateContract(contractJson: unknown): Contract;
37
+ verify(options: {
38
+ readonly driver: ControlDriverInstance<'sql', string>;
39
+ readonly contract: unknown;
40
+ readonly expectedTargetId: string;
41
+ readonly contractPath: string;
42
+ readonly configPath?: string;
43
+ }): Promise<VerifyDatabaseResult>;
44
+ schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
45
+ sign(options: {
46
+ readonly driver: ControlDriverInstance<'sql', string>;
47
+ readonly contract: unknown;
48
+ readonly contractPath: string;
49
+ readonly configPath?: string;
50
+ }): Promise<SignDatabaseResult>;
51
+ introspect(options: {
52
+ readonly driver: ControlDriverInstance<'sql', string>;
53
+ readonly contract?: unknown;
54
+ }): Promise<SqlSchemaIR>;
55
+ }
56
+ //#endregion
57
+ //#region src/core/migrations/types.d.ts
58
+ type AnyRecord = Readonly<Record<string, unknown>>;
59
+ type ControlMutationDefaultSpan = {
60
+ readonly start: {
61
+ readonly offset: number;
62
+ readonly line: number;
63
+ readonly column: number;
64
+ };
65
+ readonly end: {
66
+ readonly offset: number;
67
+ readonly line: number;
68
+ readonly column: number;
69
+ };
70
+ };
71
+ type ControlMutationDefaultFunctionCall = {
72
+ readonly name: string;
73
+ readonly raw: string;
74
+ readonly args: readonly {
75
+ readonly raw: string;
76
+ readonly span: ControlMutationDefaultSpan;
77
+ }[];
78
+ readonly span: ControlMutationDefaultSpan;
79
+ };
80
+ type ControlMutationDefaultLoweringContext = {
81
+ readonly sourceId: string;
82
+ readonly modelName: string;
83
+ readonly fieldName: string;
84
+ readonly columnCodecId?: string;
85
+ };
86
+ type ControlMutationDefaultFunctionResult = {
87
+ readonly ok: true;
88
+ readonly value: {
89
+ readonly kind: 'storage';
90
+ readonly defaultValue: ColumnDefault;
91
+ } | {
92
+ readonly kind: 'execution';
93
+ readonly generated: ExecutionMutationDefaultValue;
94
+ };
95
+ } | {
96
+ readonly ok: false;
97
+ readonly diagnostic: {
98
+ readonly code: string;
99
+ readonly message: string;
100
+ readonly sourceId?: string;
101
+ readonly span?: ControlMutationDefaultSpan;
102
+ };
103
+ };
104
+ type ControlMutationDefaultFunctionHandler = (input: {
105
+ readonly call: ControlMutationDefaultFunctionCall;
106
+ readonly context: ControlMutationDefaultLoweringContext;
107
+ }) => ControlMutationDefaultFunctionResult;
108
+ interface ControlMutationDefaultFunctionEntry {
109
+ readonly lower: ControlMutationDefaultFunctionHandler;
110
+ readonly usageSignatures?: readonly string[];
111
+ }
112
+ interface ControlMutationDefaultGeneratorDescriptor {
113
+ readonly id: string;
114
+ readonly applicableCodecIds: readonly string[];
115
+ readonly resolveGeneratedColumnDescriptor?: (input: {
116
+ readonly generated: {
117
+ readonly kind: string;
118
+ readonly id: string;
119
+ readonly params?: Record<string, unknown>;
120
+ };
121
+ }) => {
122
+ readonly codecId: string;
123
+ readonly nativeType: string;
124
+ readonly typeRef?: string;
125
+ readonly typeParams?: Record<string, unknown>;
126
+ } | undefined;
127
+ }
128
+ interface PslScalarTypeDescriptor {
129
+ readonly codecId: string;
130
+ readonly nativeType: string;
131
+ readonly typeRef?: string;
132
+ readonly typeParams?: Record<string, unknown>;
133
+ }
134
+ interface SqlControlStaticContributions {
135
+ readonly controlMutationDefaults?: () => {
136
+ readonly defaultFunctionRegistry: ReadonlyMap<string, ControlMutationDefaultFunctionEntry>;
137
+ readonly generatorDescriptors: ReadonlyArray<ControlMutationDefaultGeneratorDescriptor>;
138
+ };
139
+ readonly pslTypeDescriptors?: () => {
140
+ readonly scalarTypeDescriptors: ReadonlyMap<string, PslScalarTypeDescriptor>;
141
+ };
142
+ /** Query operation descriptors for the migration DSL client. Same static data as runtime descriptors. */
143
+ readonly queryOperations?: () => ReadonlyArray<SqlOperationDescriptor>;
144
+ }
145
+ interface ComponentDatabaseDependency<TTargetDetails> {
146
+ readonly id: string;
147
+ readonly label: string;
148
+ readonly install: readonly SqlMigrationPlanOperation<TTargetDetails>[];
149
+ }
150
+ interface ComponentDatabaseDependencies<TTargetDetails> {
151
+ readonly init?: readonly ComponentDatabaseDependency<TTargetDetails>[];
152
+ }
153
+ interface DatabaseDependencyProvider {
154
+ readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
155
+ }
156
+ declare function isDatabaseDependencyProvider(value: unknown): value is DatabaseDependencyProvider;
157
+ declare function collectInitDependencies(components: ReadonlyArray<unknown>): readonly ComponentDatabaseDependency<unknown>[];
158
+ interface StorageTypePlanResult<TTargetDetails> {
159
+ readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
160
+ }
161
+ /**
162
+ * Input for expanding parameterized native types.
163
+ */
164
+ interface ExpandNativeTypeInput {
165
+ readonly nativeType: string;
166
+ readonly codecId?: string;
167
+ readonly typeParams?: Record<string, unknown>;
168
+ }
169
+ /**
170
+ * Input for resolving an identity-value SQL literal used to backfill existing rows when
171
+ * adding a NOT NULL column without an explicit default.
172
+ *
173
+ * "Identity value" in the algebraic (monoid) sense: the neutral element for the type
174
+ * (0 for numbers, '' for strings, false for booleans, etc.).
175
+ */
176
+ interface ResolveIdentityValueInput {
177
+ readonly nativeType: string;
178
+ readonly codecId?: string;
179
+ readonly typeParams?: Record<string, unknown>;
180
+ }
181
+ interface CodecControlHooks<TTargetDetails = unknown> {
182
+ planTypeOperations?: (options: {
183
+ readonly typeName: string;
184
+ readonly typeInstance: StorageTypeInstance;
185
+ readonly contract: Contract<SqlStorage>;
186
+ readonly schema: SqlSchemaIR;
187
+ readonly schemaName?: string;
188
+ readonly policy: MigrationOperationPolicy;
189
+ }) => StorageTypePlanResult<TTargetDetails>;
190
+ verifyType?: (options: {
191
+ readonly typeName: string;
192
+ readonly typeInstance: StorageTypeInstance;
193
+ readonly schema: SqlSchemaIR;
194
+ readonly schemaName?: string;
195
+ }) => readonly SchemaIssue[];
196
+ introspectTypes?: (options: {
197
+ readonly driver: ControlDriverInstance<'sql', string>;
198
+ readonly schemaName?: string;
199
+ }) => Promise<Record<string, StorageTypeInstance>>;
200
+ /**
201
+ * Expands a parameterized native type to its full SQL representation.
202
+ * Used by schema verification to compare contract types against database types.
203
+ *
204
+ * For example, expands:
205
+ * - { nativeType: 'character varying', typeParams: { length: 255 } } -> 'character varying(255)'
206
+ * - { nativeType: 'numeric', typeParams: { precision: 10, scale: 2 } } -> 'numeric(10,2)'
207
+ *
208
+ * Returns the expanded type string, or the original nativeType if no expansion is needed.
209
+ */
210
+ expandNativeType?: (input: ExpandNativeTypeInput) => string;
211
+ /**
212
+ * Resolves the identity value (monoid neutral element) as a SQL literal for safely adding
213
+ * a NOT NULL column without an explicit default to a non-empty table.
214
+ *
215
+ * Return semantics:
216
+ * - string: use this literal
217
+ * - null: explicitly no safe identity value is known; fall back to another strategy
218
+ * - undefined: no opinion; planner may use built-in fallbacks
219
+ */
220
+ resolveIdentityValue?: (input: ResolveIdentityValueInput) => string | null | undefined;
221
+ }
222
+ interface SqlControlExtensionDescriptor<TTargetId extends string> extends ControlExtensionDescriptor<'sql', TTargetId>, SqlControlStaticContributions {
223
+ readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
224
+ }
225
+ interface SqlControlAdapterDescriptor<TTargetId extends string> extends ControlAdapterDescriptor<'sql', TTargetId>, SqlControlStaticContributions {}
226
+ interface SqlMigrationPlanOperationStep {
227
+ readonly description: string;
228
+ readonly sql: string;
229
+ readonly meta?: AnyRecord;
230
+ }
231
+ interface SqlMigrationPlanOperationTarget<TTargetDetails> {
232
+ readonly id: string;
233
+ readonly details?: TTargetDetails;
234
+ }
235
+ interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlanOperation {
236
+ readonly summary?: string;
237
+ readonly target: SqlMigrationPlanOperationTarget<TTargetDetails>;
238
+ readonly precheck: readonly SqlMigrationPlanOperationStep[];
239
+ readonly execute: readonly SqlMigrationPlanOperationStep[];
240
+ readonly postcheck: readonly SqlMigrationPlanOperationStep[];
241
+ readonly meta?: AnyRecord;
242
+ }
243
+ interface SqlMigrationPlanContractInfo {
244
+ readonly storageHash: string;
245
+ readonly profileHash?: string;
246
+ }
247
+ interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
248
+ /**
249
+ * Origin contract identity that the plan expects the database to currently be at.
250
+ * If omitted or null, the runner skips origin validation entirely.
251
+ */
252
+ readonly origin?: SqlMigrationPlanContractInfo | null;
253
+ /**
254
+ * Destination contract identity that the plan intends to reach.
255
+ */
256
+ readonly destination: SqlMigrationPlanContractInfo;
257
+ readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
258
+ readonly meta?: AnyRecord;
259
+ }
260
+ type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedOperation';
261
+ interface SqlPlannerConflictLocation {
262
+ readonly table?: string;
263
+ readonly column?: string;
264
+ readonly index?: string;
265
+ readonly constraint?: string;
266
+ readonly type?: string;
267
+ }
268
+ interface SqlPlannerConflict extends MigrationPlannerConflict {
269
+ readonly kind: SqlPlannerConflictKind;
270
+ readonly location?: SqlPlannerConflictLocation;
271
+ readonly meta?: AnyRecord;
272
+ }
273
+ interface SqlPlannerSuccessResult<TTargetDetails> extends Omit<MigrationPlannerSuccessResult, 'plan'> {
274
+ readonly kind: 'success';
275
+ readonly plan: SqlMigrationPlan<TTargetDetails>;
276
+ }
277
+ interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'conflicts'> {
278
+ readonly kind: 'failure';
279
+ readonly conflicts: readonly SqlPlannerConflict[];
280
+ }
281
+ type SqlPlannerResult<TTargetDetails> = SqlPlannerSuccessResult<TTargetDetails> | SqlPlannerFailureResult;
282
+ interface SqlMigrationPlannerPlanOptions {
283
+ readonly contract: Contract<SqlStorage>;
284
+ readonly schema: SqlSchemaIR;
285
+ readonly policy: MigrationOperationPolicy;
286
+ readonly schemaName?: string;
287
+ /**
288
+ * Active framework components participating in this composition.
289
+ * SQL targets can interpret this list to derive database dependencies.
290
+ * All components must have matching familyId ('sql') and targetId.
291
+ */
292
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
293
+ }
294
+ interface SqlMigrationPlanner<TTargetDetails> {
295
+ plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
296
+ }
297
+ interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
298
+ onOperationStart?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
299
+ onOperationComplete?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
300
+ }
301
+ interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
302
+ readonly plan: SqlMigrationPlan<TTargetDetails>;
303
+ readonly driver: ControlDriverInstance<'sql', string>;
304
+ /**
305
+ * Destination contract IR.
306
+ * Must correspond to `plan.destination` and is used for schema verification and marker/ledger writes.
307
+ */
308
+ readonly destinationContract: Contract<SqlStorage>;
309
+ /**
310
+ * Execution-time policy that defines which operation classes are allowed.
311
+ * The runner validates each operation against this policy before execution.
312
+ */
313
+ readonly policy: MigrationOperationPolicy;
314
+ readonly schemaName?: string;
315
+ readonly strictVerification?: boolean;
316
+ readonly callbacks?: SqlMigrationRunnerExecuteCallbacks<TTargetDetails>;
317
+ readonly context?: OperationContext;
318
+ /**
319
+ * Execution-time checks configuration.
320
+ * All checks default to `true` (enabled) when omitted.
321
+ */
322
+ readonly executionChecks?: MigrationRunnerExecutionChecks;
323
+ /**
324
+ * Active framework components participating in this composition.
325
+ * SQL targets can interpret this list to derive database dependencies.
326
+ * All components must have matching familyId ('sql') and targetId.
327
+ */
328
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
329
+ }
330
+ type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'MARKER_ORIGIN_MISMATCH' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'EXECUTION_FAILED';
331
+ interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
332
+ readonly code: SqlMigrationRunnerErrorCode;
333
+ readonly meta?: AnyRecord;
334
+ }
335
+ interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {}
336
+ type SqlMigrationRunnerResult = Result<SqlMigrationRunnerSuccessValue, SqlMigrationRunnerFailure>;
337
+ interface SqlMigrationRunner<TTargetDetails> {
338
+ execute(options: SqlMigrationRunnerExecuteOptions<TTargetDetails>): Promise<SqlMigrationRunnerResult>;
339
+ }
340
+ interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails> extends MigratableTargetDescriptor<'sql', TTargetId, SqlControlFamilyInstance>, SqlControlStaticContributions {
341
+ createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
342
+ createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
343
+ }
344
+ interface CreateSqlMigrationPlanOptions<TTargetDetails> {
345
+ readonly targetId: string;
346
+ readonly origin?: SqlMigrationPlanContractInfo | null;
347
+ readonly destination: SqlMigrationPlanContractInfo;
348
+ readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
349
+ readonly meta?: AnyRecord;
350
+ }
351
+ //#endregion
352
+ export { SqlPlannerConflict as A, SqlControlFamilyInstance as B, SqlMigrationRunner as C, SqlMigrationRunnerFailure as D, SqlMigrationRunnerExecuteOptions as E, SqlPlannerSuccessResult as F, StorageTypePlanResult as I, collectInitDependencies as L, SqlPlannerConflictLocation as M, SqlPlannerFailureResult as N, SqlMigrationRunnerResult as O, SqlPlannerResult as P, isDatabaseDependencyProvider as R, SqlMigrationPlannerPlanOptions as S, SqlMigrationRunnerExecuteCallbacks as T, SqlMigrationPlanContractInfo as _, ControlMutationDefaultFunctionEntry as a, SqlMigrationPlanOperationTarget as b, CreateSqlMigrationPlanOptions as c, ResolveIdentityValueInput as d, SqlControlAdapterDescriptor as f, SqlMigrationPlan as g, SqlControlTargetDescriptor as h, ComponentDatabaseDependency as i, SqlPlannerConflictKind as j, SqlMigrationRunnerSuccessValue as k, ExpandNativeTypeInput as l, SqlControlStaticContributions as m, CodecControlHooks as n, ControlMutationDefaultFunctionHandler as o, SqlControlExtensionDescriptor as p, ComponentDatabaseDependencies as r, ControlMutationDefaultGeneratorDescriptor as s, AnyRecord as t, PslScalarTypeDescriptor as u, SqlMigrationPlanOperation as v, SqlMigrationRunnerErrorCode as w, SqlMigrationPlanner as x, SqlMigrationPlanOperationStep as y, SchemaVerifyOptions as z };
353
+ //# sourceMappingURL=types-BaUzKt6Q.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BaUzKt6Q.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/migrations/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UA0JU,eAAA;;;;;AA1HsE;AA0HvD,KAOpB,uBAAA,GAA0B,GAAH,CAAA,MAAA,EAAe,eAAA,CAAA;AAAT,UAExB,sBAAA,CAAsB;EACW,SAAA,gBAAA,EAAd,aAAc,CAAA,eAAA,CAAA;EAAd,SAAA,oBAAA,EACI,aADJ,CACkB,eADlB,CAAA;EACkB,SAAA,YAAA,EACtB,aADsB,CAAA,MAAA,CAAA;EAAd,SAAA,oBAAA,EAEA,uBAFA;;AAEA,UAGhB,mBAAA,CAHgB;EAAuB,SAAA,MAAA,EAIrC,qBAJqC,CAAA,KAAA,EAAA,MAAA,CAAA;EAGvC,SAAA,QAAA,EAAA,OAAmB;EACjB,SAAA,MAAA,EAAA,OAAA;EAGE,SAAA,OAAA,CAAA,EAAA,gBAAA;EAKyB;;;AAG9C;EACuC,SAAA,mBAAA,EAJP,aAIO,CAJO,8BAIP,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;;AAGI,UAJ1B,wBAAA,SAC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,SAAA,IAAA,EAvGV,gBAuGU,CAvGO,cAuGP,CAAA;;UApGV,uBAAA,SAAgC,KAAK;;+BAEvB;;KAGnB,mCACR,wBAAwB,kBACxB;UAEa,8BAAA;qBACI,SAAS;mBACX;mBACA;;;;;;;gCAOa,cAAc;;UAG7B;gBACD,iCAAiC,iBAAiB;;UAGjD;+BACc,0BAA0B;kCACvB,0BAA0B;;UAG3C;iBACA,iBAAiB;mBACf;;;;;gCAKa,SAAS;;;;;mBAKtB;;;uBAGI,mCAAmC;qBACrC;;;;;6BAKQ;;;;;;gCAMG,cAAc;;KAGlC,2BAAA;UASK,yBAAA,SAAkC;iBAClC;kBACC;;UAGD,8BAAA,SAAuC;KAE5C,wBAAA,GAA2B,OACrC,gCACA;UAGe;mBAEJ,iCAAiC,kBACzC,QAAQ;;UAGI,6EACP,kCAAkC,WAAW,2BACnD;wBACoB,2BAA2B,oBAAoB;uBAChD,2BAA2B,mBAAmB;;UAGpD;;oBAEG;wBACI;gCACQ,0BAA0B;kBACxC"}
@@ -0,0 +1,108 @@
1
+ import { type } from "arktype";
2
+
3
+ //#region src/core/verify.ts
4
+ const MetaSchema = type({ "[string]": "unknown" });
5
+ function parseMeta(meta) {
6
+ if (meta === null || meta === void 0) return {};
7
+ let parsed;
8
+ if (typeof meta === "string") try {
9
+ parsed = JSON.parse(meta);
10
+ } catch {
11
+ return {};
12
+ }
13
+ else parsed = meta;
14
+ const result = MetaSchema(parsed);
15
+ if (result instanceof type.errors) return {};
16
+ return result;
17
+ }
18
+ const ContractMarkerRowSchema = type({
19
+ core_hash: "string",
20
+ profile_hash: "string",
21
+ "contract_json?": "unknown | null",
22
+ "canonical_version?": "number | null",
23
+ "updated_at?": "Date | string",
24
+ "app_tag?": "string | null",
25
+ "meta?": "unknown | null"
26
+ });
27
+ /**
28
+ * Parses a contract marker row from database query result.
29
+ * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).
30
+ */
31
+ function parseContractMarkerRow(row) {
32
+ const result = ContractMarkerRowSchema(row);
33
+ if (result instanceof type.errors) {
34
+ const messages = result.map((p) => p.message).join("; ");
35
+ throw new Error(`Invalid contract marker row: ${messages}`);
36
+ }
37
+ const validatedRow = result;
38
+ const updatedAt = validatedRow.updated_at ? validatedRow.updated_at instanceof Date ? validatedRow.updated_at : new Date(validatedRow.updated_at) : /* @__PURE__ */ new Date();
39
+ return {
40
+ storageHash: validatedRow.core_hash,
41
+ profileHash: validatedRow.profile_hash,
42
+ contractJson: validatedRow.contract_json ?? null,
43
+ canonicalVersion: validatedRow.canonical_version ?? null,
44
+ updatedAt,
45
+ appTag: validatedRow.app_tag ?? null,
46
+ meta: parseMeta(validatedRow.meta)
47
+ };
48
+ }
49
+ /**
50
+ * Returns the SQL statement to read the contract marker.
51
+ * This is a migration-plane helper (no runtime imports).
52
+ * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
53
+ */
54
+ function readMarkerSql() {
55
+ return {
56
+ sql: `select
57
+ core_hash,
58
+ profile_hash,
59
+ contract_json,
60
+ canonical_version,
61
+ updated_at,
62
+ app_tag,
63
+ meta
64
+ from prisma_contract.marker
65
+ where id = $1`,
66
+ params: [1]
67
+ };
68
+ }
69
+ /**
70
+ * Reads the contract marker from the database using the provided driver.
71
+ * Returns the parsed marker record or null if no marker is found.
72
+ * This abstracts SQL-specific details from the Control Plane.
73
+ *
74
+ * @param driver - ControlDriverInstance instance for executing queries
75
+ * @returns Promise resolving to ContractMarkerRecord or null if marker not found
76
+ */
77
+ async function readMarker(driver) {
78
+ const markerStatement = readMarkerSql();
79
+ try {
80
+ const queryResult = await driver.query(markerStatement.sql, markerStatement.params);
81
+ if (queryResult.rows.length === 0) return null;
82
+ const markerRow = queryResult.rows[0];
83
+ if (!markerRow) throw new Error("Database query returned unexpected result structure");
84
+ return parseContractMarkerRow(markerRow);
85
+ } catch (error) {
86
+ if (error instanceof Error && (error.message.includes("does not exist") || error.code === "42P01")) return null;
87
+ throw error;
88
+ }
89
+ }
90
+ /**
91
+ * Collects supported codec type IDs from adapter and extension manifests.
92
+ * Returns a sorted, unique array of type IDs that are declared in the manifests.
93
+ * This enables coverage checks by comparing contract column types against supported types.
94
+ *
95
+ * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.
96
+ * The manifests declare which codec types are available, but the actual type IDs
97
+ * are defined in the codec-types TypeScript modules that are imported.
98
+ *
99
+ * For MVP, we return an empty array since extracting type IDs from TypeScript modules
100
+ * would require runtime evaluation or static analysis. This can be enhanced later.
101
+ */
102
+ function collectSupportedCodecTypeIds(descriptors) {
103
+ return [];
104
+ }
105
+
106
+ //#endregion
107
+ export { readMarkerSql as i, parseContractMarkerRow as n, readMarker as r, collectSupportedCodecTypeIds as t };
108
+ //# sourceMappingURL=verify-DZHtfcmj.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-DZHtfcmj.mjs","names":["parsed: unknown"],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type { ControlDriverInstance } from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\n\nconst MetaSchema = type({ '[string]': 'unknown' });\n\nfunction parseMeta(meta: unknown): Record<string, unknown> {\n if (meta === null || meta === undefined) {\n return {};\n }\n\n let parsed: unknown;\n if (typeof meta === 'string') {\n try {\n parsed = JSON.parse(meta);\n } catch {\n return {};\n }\n } else {\n parsed = meta;\n }\n\n const result = MetaSchema(parsed);\n if (result instanceof type.errors) {\n return {};\n }\n\n return result as Record<string, unknown>;\n}\n\nconst ContractMarkerRowSchema = type({\n core_hash: 'string',\n profile_hash: 'string',\n 'contract_json?': 'unknown | null',\n 'canonical_version?': 'number | null',\n 'updated_at?': 'Date | string',\n 'app_tag?': 'string | null',\n 'meta?': 'unknown | null',\n});\n\n/**\n * Parses a contract marker row from database query result.\n * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).\n */\nexport function parseContractMarkerRow(row: unknown): ContractMarkerRecord {\n const result = ContractMarkerRowSchema(row);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid contract marker row: ${messages}`);\n }\n\n const validatedRow = result as {\n core_hash: string;\n profile_hash: string;\n contract_json?: unknown | null;\n canonical_version?: number | null;\n updated_at?: Date | string;\n app_tag?: string | null;\n meta?: unknown | null;\n };\n\n const updatedAt = validatedRow.updated_at\n ? validatedRow.updated_at instanceof Date\n ? validatedRow.updated_at\n : new Date(validatedRow.updated_at)\n : new Date();\n\n return {\n storageHash: validatedRow.core_hash,\n profileHash: validatedRow.profile_hash,\n contractJson: validatedRow.contract_json ?? null,\n canonicalVersion: validatedRow.canonical_version ?? null,\n updatedAt,\n appTag: validatedRow.app_tag ?? null,\n meta: parseMeta(validatedRow.meta),\n };\n}\n\n/**\n * Returns the SQL statement to read the contract marker.\n * This is a migration-plane helper (no runtime imports).\n * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.\n */\nexport function readMarkerSql(): { readonly sql: string; readonly params: readonly unknown[] } {\n return {\n sql: `select\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta\n from prisma_contract.marker\n where id = $1`,\n params: [1],\n };\n}\n\n/**\n * Reads the contract marker from the database using the provided driver.\n * Returns the parsed marker record or null if no marker is found.\n * This abstracts SQL-specific details from the Control Plane.\n *\n * @param driver - ControlDriverInstance instance for executing queries\n * @returns Promise resolving to ContractMarkerRecord or null if marker not found\n */\nexport async function readMarker(\n driver: ControlDriverInstance<'sql', string>,\n): Promise<ContractMarkerRecord | null> {\n const markerStatement = readMarkerSql();\n\n try {\n const queryResult = await driver.query<{\n core_hash: string;\n profile_hash: string;\n contract_json: unknown | null;\n canonical_version: number | null;\n updated_at: Date | string;\n app_tag: string | null;\n meta: unknown | null;\n }>(markerStatement.sql, markerStatement.params);\n\n if (queryResult.rows.length === 0) {\n return null;\n }\n\n const markerRow = queryResult.rows[0];\n if (!markerRow) {\n // If rows array has length > 0 but first element is undefined, this is an unexpected result structure\n throw new Error('Database query returned unexpected result structure');\n }\n\n return parseContractMarkerRow(markerRow);\n } catch (error) {\n // Handle case where marker table doesn't exist yet (empty database)\n // PostgreSQL error code 42P01 = undefined_table\n if (\n error instanceof Error &&\n (error.message.includes('does not exist') || (error as { code?: string }).code === '42P01')\n ) {\n return null;\n }\n throw error;\n }\n}\n\n/**\n * Collects supported codec type IDs from adapter and extension manifests.\n * Returns a sorted, unique array of type IDs that are declared in the manifests.\n * This enables coverage checks by comparing contract column types against supported types.\n *\n * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.\n * The manifests declare which codec types are available, but the actual type IDs\n * are defined in the codec-types TypeScript modules that are imported.\n *\n * For MVP, we return an empty array since extracting type IDs from TypeScript modules\n * would require runtime evaluation or static analysis. This can be enhanced later.\n */\nexport function collectSupportedCodecTypeIds(\n descriptors: ReadonlyArray<{ readonly id: string }>,\n): readonly string[] {\n // For MVP, return empty array\n // Future enhancement: Extract type IDs from codec-types modules via static analysis\n // or require manifests to explicitly list supported type IDs\n void descriptors;\n return [];\n}\n"],"mappings":";;;AAIA,MAAM,aAAa,KAAK,EAAE,YAAY,WAAW,CAAC;AAElD,SAAS,UAAU,MAAwC;AACzD,KAAI,SAAS,QAAQ,SAAS,OAC5B,QAAO,EAAE;CAGX,IAAIA;AACJ,KAAI,OAAO,SAAS,SAClB,KAAI;AACF,WAAS,KAAK,MAAM,KAAK;SACnB;AACN,SAAO,EAAE;;KAGX,UAAS;CAGX,MAAM,SAAS,WAAW,OAAO;AACjC,KAAI,kBAAkB,KAAK,OACzB,QAAO,EAAE;AAGX,QAAO;;AAGT,MAAM,0BAA0B,KAAK;CACnC,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,sBAAsB;CACtB,eAAe;CACf,YAAY;CACZ,SAAS;CACV,CAAC;;;;;AAMF,SAAgB,uBAAuB,KAAoC;CACzE,MAAM,SAAS,wBAAwB,IAAI;AAC3C,KAAI,kBAAkB,KAAK,QAAQ;EACjC,MAAM,WAAW,OAAO,KAAK,MAA2B,EAAE,QAAQ,CAAC,KAAK,KAAK;AAC7E,QAAM,IAAI,MAAM,gCAAgC,WAAW;;CAG7D,MAAM,eAAe;CAUrB,MAAM,YAAY,aAAa,aAC3B,aAAa,sBAAsB,OACjC,aAAa,aACb,IAAI,KAAK,aAAa,WAAW,mBACnC,IAAI,MAAM;AAEd,QAAO;EACL,aAAa,aAAa;EAC1B,aAAa,aAAa;EAC1B,cAAc,aAAa,iBAAiB;EAC5C,kBAAkB,aAAa,qBAAqB;EACpD;EACA,QAAQ,aAAa,WAAW;EAChC,MAAM,UAAU,aAAa,KAAK;EACnC;;;;;;;AAQH,SAAgB,gBAA+E;AAC7F,QAAO;EACL,KAAK;;;;;;;;;;EAUL,QAAQ,CAAC,EAAE;EACZ;;;;;;;;;;AAWH,eAAsB,WACpB,QACsC;CACtC,MAAM,kBAAkB,eAAe;AAEvC,KAAI;EACF,MAAM,cAAc,MAAM,OAAO,MAQ9B,gBAAgB,KAAK,gBAAgB,OAAO;AAE/C,MAAI,YAAY,KAAK,WAAW,EAC9B,QAAO;EAGT,MAAM,YAAY,YAAY,KAAK;AACnC,MAAI,CAAC,UAEH,OAAM,IAAI,MAAM,sDAAsD;AAGxE,SAAO,uBAAuB,UAAU;UACjC,OAAO;AAGd,MACE,iBAAiB,UAChB,MAAM,QAAQ,SAAS,iBAAiB,IAAK,MAA4B,SAAS,SAEnF,QAAO;AAET,QAAM;;;;;;;;;;;;;;;AAgBV,SAAgB,6BACd,aACmB;AAKnB,QAAO,EAAE"}
@@ -0,0 +1,67 @@
1
+ import { OperationContext, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
2
+ import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
3
+ import { ColumnDefault, Contract } from "@prisma-next/contract/types";
4
+ import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
5
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
6
+
7
+ //#region src/core/schema-verify/verify-sql-schema.d.ts
8
+
9
+ /**
10
+ * Function type for normalizing raw database default expressions into ColumnDefault.
11
+ * Target-specific implementations handle database dialect differences.
12
+ */
13
+ type DefaultNormalizer = (rawDefault: string, nativeType: string) => ColumnDefault | undefined;
14
+ /**
15
+ * Function type for normalizing schema native types to canonical form for comparison.
16
+ * Target-specific implementations handle dialect-specific type name variations
17
+ * (e.g., Postgres 'varchar' → 'character varying', 'timestamptz' normalization).
18
+ */
19
+ type NativeTypeNormalizer = (nativeType: string) => string;
20
+ /**
21
+ * Options for the pure schema verification function.
22
+ */
23
+ interface VerifySqlSchemaOptions {
24
+ /** The validated SQL contract to verify against */
25
+ readonly contract: Contract<SqlStorage>;
26
+ /** The schema IR from introspection (or another source) */
27
+ readonly schema: SqlSchemaIR;
28
+ /** Whether to run in strict mode (detects extra tables/columns) */
29
+ readonly strict: boolean;
30
+ /** Optional operation context for metadata */
31
+ readonly context?: OperationContext;
32
+ /** Type metadata registry for codec consistency warnings */
33
+ readonly typeMetadataRegistry: ReadonlyMap<string, {
34
+ nativeType?: string;
35
+ }>;
36
+ /**
37
+ * Active framework components participating in this composition.
38
+ * All components must have matching familyId ('sql') and targetId.
39
+ */
40
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
41
+ /**
42
+ * Optional target-specific normalizer for raw database default expressions.
43
+ * When provided, schema defaults (raw strings) are normalized before comparison
44
+ * with contract defaults (ColumnDefault objects).
45
+ */
46
+ readonly normalizeDefault?: DefaultNormalizer;
47
+ /**
48
+ * Optional target-specific normalizer for schema native type names.
49
+ * When provided, schema native types are normalized before comparison
50
+ * with contract native types (e.g., Postgres 'varchar' → 'character varying').
51
+ */
52
+ readonly normalizeNativeType?: NativeTypeNormalizer;
53
+ }
54
+ /**
55
+ * Verifies that a SqlSchemaIR matches a Contract.
56
+ *
57
+ * This is a pure function that does NOT perform any database I/O.
58
+ * It takes an already-introspected schema IR and compares it against
59
+ * the contract requirements.
60
+ *
61
+ * @param options - Verification options
62
+ * @returns VerifyDatabaseSchemaResult with verification tree and issues
63
+ */
64
+ declare function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabaseSchemaResult;
65
+ //#endregion
66
+ export { verifySqlSchema as i, NativeTypeNormalizer as n, VerifySqlSchemaOptions as r, DefaultNormalizer as t };
67
+ //# sourceMappingURL=verify-sql-schema-BBhkqEDo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-sql-schema-BBhkqEDo.d.mts","names":[],"sources":["../src/core/schema-verify/verify-sql-schema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAqEgC,KA9BpB,iBAAA,GA8BoB,CAAA,UAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,GA3B3B,aA2B2B,GAAA,SAAA;;;;AAyBhC;;KA7CY,oBAAA;;;;UAKK,sBAAA;;qBAEI,SAAS;;mBAEX;;;;qBAIE;;iCAEY;;;;;;;gCAKD,cAAc;;;;;;8BAMhB;;;;;;iCAMG;;;;;;;;;;;;iBAajB,eAAA,UAAyB,yBAAyB"}