@prisma-next/family-sql 0.5.0-dev.7 → 0.5.0-dev.70

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 (69) hide show
  1. package/README.md +2 -2
  2. package/dist/{authoring-type-constructors-BAR65pSK.mjs → authoring-type-constructors-F4JpCJl7.mjs} +14 -15
  3. package/dist/authoring-type-constructors-F4JpCJl7.mjs.map +1 -0
  4. package/dist/control-adapter.d.mts +26 -2
  5. package/dist/control-adapter.d.mts.map +1 -1
  6. package/dist/control-adapter.mjs +1 -1
  7. package/dist/control.d.mts +122 -40
  8. package/dist/control.d.mts.map +1 -1
  9. package/dist/control.mjs +1168 -22
  10. package/dist/control.mjs.map +1 -1
  11. package/dist/migration.d.mts +22 -24
  12. package/dist/migration.d.mts.map +1 -1
  13. package/dist/migration.mjs +25 -24
  14. package/dist/migration.mjs.map +1 -1
  15. package/dist/pack.d.mts +35 -23
  16. package/dist/pack.d.mts.map +1 -1
  17. package/dist/pack.mjs +3 -5
  18. package/dist/pack.mjs.map +1 -1
  19. package/dist/runtime.d.mts +19 -2
  20. package/dist/runtime.d.mts.map +1 -1
  21. package/dist/runtime.mjs +26 -4
  22. package/dist/runtime.mjs.map +1 -1
  23. package/dist/schema-verify.d.mts +2 -4
  24. package/dist/schema-verify.d.mts.map +1 -1
  25. package/dist/schema-verify.mjs +2 -3
  26. package/dist/test-utils.mjs +1 -2
  27. package/dist/timestamp-now-generator-BWp8S2sa.mjs +86 -0
  28. package/dist/timestamp-now-generator-BWp8S2sa.mjs.map +1 -0
  29. package/dist/{types-C6K4mxDM.d.mts → types-CIdiS2QK.d.mts} +202 -23
  30. package/dist/types-CIdiS2QK.d.mts.map +1 -0
  31. package/dist/verify-pRYxnpiG.mjs +81 -0
  32. package/dist/verify-pRYxnpiG.mjs.map +1 -0
  33. package/dist/{verify-sql-schema-Ovz7RXR5.mjs → verify-sql-schema-C84vejAP.mjs} +2 -6
  34. package/dist/verify-sql-schema-C84vejAP.mjs.map +1 -0
  35. package/dist/{verify-sql-schema-BBhkqEDo.d.mts → verify-sql-schema-CPHiuYHR.d.mts} +2 -3
  36. package/dist/verify-sql-schema-CPHiuYHR.d.mts.map +1 -0
  37. package/dist/verify.d.mts +16 -21
  38. package/dist/verify.d.mts.map +1 -1
  39. package/dist/verify.mjs +2 -3
  40. package/package.json +22 -21
  41. package/src/core/authoring-field-presets.ts +35 -23
  42. package/src/core/control-adapter.ts +32 -0
  43. package/src/core/control-descriptor.ts +2 -1
  44. package/src/core/control-instance.ts +115 -15
  45. package/src/core/migrations/field-event-planner.ts +196 -0
  46. package/src/core/migrations/plan-helpers.ts +4 -0
  47. package/src/core/migrations/types.ts +198 -21
  48. package/src/core/operation-preview.ts +62 -0
  49. package/src/core/psl-contract-infer/default-mapping.ts +56 -0
  50. package/src/core/psl-contract-infer/name-transforms.ts +178 -0
  51. package/src/core/psl-contract-infer/postgres-default-mapping.ts +16 -0
  52. package/src/core/psl-contract-infer/postgres-type-map.ts +165 -0
  53. package/src/core/psl-contract-infer/printer-config.ts +55 -0
  54. package/src/core/psl-contract-infer/raw-default-parser.ts +91 -0
  55. package/src/core/psl-contract-infer/relation-inference.ts +196 -0
  56. package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +832 -0
  57. package/src/core/sql-migration.ts +25 -23
  58. package/src/core/timestamp-now-generator.ts +74 -0
  59. package/src/core/timestamp-now-runtime-generator.ts +24 -0
  60. package/src/core/verify.ts +46 -108
  61. package/src/exports/control.ts +11 -1
  62. package/src/exports/runtime.ts +2 -0
  63. package/src/exports/verify.ts +1 -1
  64. package/dist/authoring-type-constructors-BAR65pSK.mjs.map +0 -1
  65. package/dist/types-C6K4mxDM.d.mts.map +0 -1
  66. package/dist/verify-4GshvY4p.mjs +0 -122
  67. package/dist/verify-4GshvY4p.mjs.map +0 -1
  68. package/dist/verify-sql-schema-BBhkqEDo.d.mts.map +0 -1
  69. package/dist/verify-sql-schema-Ovz7RXR5.mjs.map +0 -1
@@ -1,10 +1,11 @@
1
- import { ControlAdapterDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, DataTransformOperation, MigratableTargetDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerSuccessValue, OperationContext, SchemaIssue, SchemaViewCapable, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
1
+ import { ContractSpace, ControlAdapterDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, MigratableTargetDescriptor, MigrationOperationPolicy, MigrationPlan, MigrationPlanOperation, MigrationPlannerConflict, MigrationPlannerFailureResult, MigrationPlannerSuccessResult, MigrationRunnerExecutionChecks, MigrationRunnerFailure, MigrationRunnerSuccessValue, OperationContext, OperationPreview, OperationPreviewCapable, PslContractInferCapable, SchemaIssue, SchemaViewCapable, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
2
2
  import { Result } from "@prisma-next/utils/result";
3
- import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
4
3
  import { Contract } from "@prisma-next/contract/types";
4
+ import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
5
5
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
6
- import { SqlStorage, StorageTypeInstance } from "@prisma-next/sql-contract/types";
6
+ import { SqlStorage, StorageColumn, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
7
7
  import { TypesImportSpec } from "@prisma-next/framework-components/emission";
8
+ import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
8
9
  import { SqlOperationDescriptor } from "@prisma-next/sql-operations";
9
10
 
10
11
  //#region src/core/control-instance.d.ts
@@ -32,7 +33,7 @@ interface SchemaVerifyOptions {
32
33
  */
33
34
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
34
35
  }
35
- interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchemaIR>, SchemaViewCapable<SqlSchemaIR>, SqlFamilyInstanceState {
36
+ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchemaIR>, SchemaViewCapable<SqlSchemaIR>, PslContractInferCapable<SqlSchemaIR>, OperationPreviewCapable, SqlFamilyInstanceState {
36
37
  validateContract(contractJson: unknown): Contract;
37
38
  verify(options: {
38
39
  readonly driver: ControlDriverInstance<'sql', string>;
@@ -42,6 +43,21 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
42
43
  readonly configPath?: string;
43
44
  }): Promise<VerifyDatabaseResult>;
44
45
  schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
46
+ /**
47
+ * Verify a contract against an already-introspected schema slice.
48
+ *
49
+ * Used by the aggregate verifier to invoke per-member verification
50
+ * with the live schema pre-projected to the member's claimed slice
51
+ * via `projectSchemaToSpace`. Closes F23 — without per-member
52
+ * pre-projection, single-contract verifiers see other-space tables
53
+ * as `extras`.
54
+ */
55
+ schemaVerifyAgainstSchema(options: {
56
+ readonly contract: unknown;
57
+ readonly schema: SqlSchemaIR;
58
+ readonly strict: boolean;
59
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
60
+ }): VerifyDatabaseSchemaResult;
45
61
  sign(options: {
46
62
  readonly driver: ControlDriverInstance<'sql', string>;
47
63
  readonly contract: unknown;
@@ -52,6 +68,8 @@ interface SqlControlFamilyInstance extends ControlFamilyInstance<'sql', SqlSchem
52
68
  readonly driver: ControlDriverInstance<'sql', string>;
53
69
  readonly contract?: unknown;
54
70
  }): Promise<SqlSchemaIR>;
71
+ inferPslContract(schemaIR: SqlSchemaIR): PslDocumentAst;
72
+ toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
55
73
  }
56
74
  //#endregion
57
75
  //#region src/core/migrations/types.d.ts
@@ -92,6 +110,39 @@ interface ResolveIdentityValueInput {
92
110
  readonly codecId?: string;
93
111
  readonly typeParams?: Record<string, unknown>;
94
112
  }
113
+ /**
114
+ * Per-field lifecycle event a codec hook can react to.
115
+ *
116
+ * Fired during app-space migration emission as the SQL family diffs the
117
+ * prior contract against the new contract.
118
+ *
119
+ * - `'added'` — the field is present in the new contract but not the prior.
120
+ * - `'dropped'` — the field is present in the prior contract but not the new.
121
+ * - `'altered'` — the field is present in both and any property other than
122
+ * `codecId` differs. Codec-id changes are a v1 non-goal:
123
+ * when only `codecId` differs, no `'altered'` event fires.
124
+ */
125
+ type FieldEvent = 'added' | 'dropped' | 'altered';
126
+ /**
127
+ * Context passed to {@link CodecControlHooks.onFieldEvent}.
128
+ *
129
+ * `tableName` and `fieldName` are always populated; `priorTable` /
130
+ * `priorField` carry the prior contract's view of the table and column
131
+ * (present for `'dropped'` and `'altered'`); `newTable` / `newField`
132
+ * carry the new contract's view (present for `'added'` and `'altered'`).
133
+ *
134
+ * The hook only ever receives app-space contract IR — extension-space
135
+ * fields are scoped out by the API: the hook is wired at the
136
+ * application emitter only.
137
+ */
138
+ interface FieldEventContext {
139
+ readonly tableName: string;
140
+ readonly fieldName: string;
141
+ readonly priorTable?: StorageTable;
142
+ readonly newTable?: StorageTable;
143
+ readonly priorField?: StorageColumn;
144
+ readonly newField?: StorageColumn;
145
+ }
95
146
  interface CodecControlHooks<TTargetDetails = unknown> {
96
147
  planTypeOperations?: (options: {
97
148
  readonly typeName: string;
@@ -132,10 +183,36 @@ interface CodecControlHooks<TTargetDetails = unknown> {
132
183
  * - undefined: no opinion; planner may use built-in fallbacks
133
184
  */
134
185
  resolveIdentityValue?: (input: ResolveIdentityValueInput) => string | null | undefined;
186
+ /**
187
+ * Reacts to per-field added / dropped / altered events as the app-space
188
+ * emitter diffs the prior contract against the new contract. Returned
189
+ * ops are inlined into the app-space migration's `ops.json` alongside
190
+ * the user's structural ops.
191
+ *
192
+ * Synchronous. Each returned op must carry its own `invariantId`. Hooks
193
+ * are dispatched per `(table, field)` based on the field's `codecId`
194
+ * (the new field's codec for `'added'` / `'altered'`; the prior field's
195
+ * codec for `'dropped'`).
196
+ */
197
+ onFieldEvent?: (event: FieldEvent, ctx: FieldEventContext) => readonly SqlMigrationPlanOperation<TTargetDetails>[];
135
198
  }
136
199
  interface SqlControlExtensionDescriptor<TTargetId extends string> extends ControlExtensionDescriptor<'sql', TTargetId> {
137
200
  readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
138
201
  readonly queryOperations?: () => ReadonlyArray<SqlOperationDescriptor>;
202
+ /**
203
+ * Schema-contributing extensions opt into the per-space planner / runner /
204
+ * verifier by setting this field. Extensions without it are codec-only or
205
+ * query-ops-only — today's behaviour preserved.
206
+ *
207
+ * The shape comes from `@prisma-next/framework-components/control`
208
+ * (`ContractSpace`) — contract-space identity is a framework concept,
209
+ * not a SQL-specific one. The SQL family specialises the generic to
210
+ * `Contract<SqlStorage>` so descriptor authors continue to see a
211
+ * typed contract value.
212
+ *
213
+ * @see specs/framework-mechanism.spec.md § 1.
214
+ */
215
+ readonly contractSpace?: ContractSpace<Contract<SqlStorage>>;
139
216
  }
140
217
  interface SqlControlAdapterDescriptor<TTargetId extends string> extends ControlAdapterDescriptor<'sql', TTargetId> {
141
218
  readonly queryOperations?: () => ReadonlyArray<SqlOperationDescriptor>;
@@ -143,6 +220,15 @@ interface SqlControlAdapterDescriptor<TTargetId extends string> extends ControlA
143
220
  interface SqlMigrationPlanOperationStep {
144
221
  readonly description: string;
145
222
  readonly sql: string;
223
+ /**
224
+ * Optional parameter values bound at execution time. The runner forwards
225
+ * these to `driver.query(sql, params ?? [])`, so step authors can use
226
+ * placeholder syntax (`$1`, `$2`, …) instead of inlining literals into
227
+ * the SQL string. Reuses the driver's parameter binder rather than
228
+ * rolling per-target literal serialization for every type the planner
229
+ * may emit.
230
+ */
231
+ readonly params?: readonly unknown[];
146
232
  readonly meta?: AnyRecord;
147
233
  }
148
234
  /**
@@ -168,21 +254,26 @@ interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlanOperati
168
254
  readonly postcheck: readonly SqlMigrationPlanOperationStep[];
169
255
  readonly meta?: AnyRecord;
170
256
  }
171
- /**
172
- * Union of all operation shapes a SQL-family migration may emit: schema-facing
173
- * `SqlMigrationPlanOperation`s and family-agnostic `DataTransformOperation`s.
174
- *
175
- * Mirrors `AnyMongoMigrationOperation` in shape — the runner already handles
176
- * both branches via `isDataTransformOperation`, and authored `migration.ts`
177
- * files must be able to intermix `dataTransform(endContract, …)` calls with
178
- * DDL factory calls (e.g. `setNotNull(…)`) in a single `operations` array.
179
- */
180
- type AnySqlMigrationOperation<TTargetDetails> = SqlMigrationPlanOperation<TTargetDetails> | DataTransformOperation;
181
257
  interface SqlMigrationPlanContractInfo {
182
258
  readonly storageHash: string;
183
259
  readonly profileHash?: string;
184
260
  }
185
261
  interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
262
+ /**
263
+ * Contract space this plan applies to. The runner uses this to key the
264
+ * `prisma_contract.marker` row it writes/reads (`space = <spaceId>`),
265
+ * so per-extension plans hit per-extension marker rows instead of all
266
+ * collapsing onto the app's row.
267
+ *
268
+ * App-plan callers pass `APP_SPACE_ID` (`'app'`); per-extension plans
269
+ * pass the extension's space id. Required at every call site so the
270
+ * type system surfaces every place that needs to thread the value
271
+ * (rather than letting an `?? APP_SPACE_ID` fall-through silently
272
+ * collapse multi-space markers onto the `'app'` row).
273
+ *
274
+ * @see specs/framework-mechanism.spec.md § 2.
275
+ */
276
+ readonly spaceId: string;
186
277
  /**
187
278
  * Origin contract identity that the plan expects the database to currently be at.
188
279
  * If omitted or null, the runner skips origin validation entirely.
@@ -193,6 +284,15 @@ interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
193
284
  */
194
285
  readonly destination: SqlMigrationPlanContractInfo;
195
286
  readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
287
+ /**
288
+ * Sorted, deduplicated invariant ids declared by this plan's data-transform
289
+ * ops. Required at the SQL-family layer (the SQL runners consume this as
290
+ * the source of truth for marker writes and self-edge no-op checks); the
291
+ * framework-level {@link MigrationPlan.providedInvariants} stays optional
292
+ * because `db init` / `db update` plans don't have a corresponding
293
+ * migration manifest.
294
+ */
295
+ readonly providedInvariants: readonly string[];
196
296
  readonly meta?: AnyRecord;
197
297
  }
198
298
  type SqlPlannerConflictKind = 'typeMismatch' | 'nullabilityConflict' | 'indexIncompatible' | 'foreignKeyConflict' | 'missingButNonAdditive' | 'unsupportedOperation';
@@ -223,14 +323,29 @@ interface SqlMigrationPlannerPlanOptions {
223
323
  readonly policy: MigrationOperationPolicy;
224
324
  readonly schemaName?: string;
225
325
  /**
226
- * The "from" contract (state the planner assumes the database starts at).
227
- * Only `migration plan` supplies this; `db update` / `db init` reconcile
228
- * against the live schema with no old contract. Strategies that need
229
- * from/to column-shape comparisons (unsafe type change, nullability
326
+ * Contract space the plan applies to. The planner stamps this onto
327
+ * the produced {@link SqlMigrationPlan.spaceId} so the runner keys
328
+ * the marker row by the right space. App-plan callers pass
329
+ * `APP_SPACE_ID`; per-extension callers pass the extension's space
330
+ * id.
331
+ */
332
+ readonly spaceId: string;
333
+ /**
334
+ * The "from" contract (state the planner assumes the database starts at),
335
+ * or `null` for reconciliation flows that have no prior contract.
336
+ *
337
+ * Required at every call site so the structural fact "I have a prior
338
+ * contract / I don't" is visible in the type. `migration plan` supplies
339
+ * the previous bundle's `metadata.toContract`; `db update` / `db init`
340
+ * reconcile against the live schema and pass `null`. Strategies that
341
+ * need from/to column-shape comparisons (unsafe type change, nullability
230
342
  * tightening) use this to decide whether to emit `dataTransform`
231
- * placeholders.
343
+ * placeholders; they short-circuit when it is `null`.
344
+ *
345
+ * Planners also derive the "from" identity they stamp onto the produced
346
+ * plan's `describe()` as `fromContract?.storage.storageHash ?? null`.
232
347
  */
233
- readonly fromContract?: Contract<SqlStorage> | null;
348
+ readonly fromContract: Contract<SqlStorage> | null;
234
349
  /**
235
350
  * Active framework components participating in this composition.
236
351
  * SQL targets can interpret this list to derive database dependencies.
@@ -248,6 +363,14 @@ interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
248
363
  interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
249
364
  readonly plan: SqlMigrationPlan<TTargetDetails>;
250
365
  readonly driver: ControlDriverInstance<'sql', string>;
366
+ /**
367
+ * Logical contract space this plan applies to. When omitted the
368
+ * runner derives the space from {@link SqlMigrationPlan.spaceId};
369
+ * when supplied, the runner asserts it matches `plan.spaceId` so a
370
+ * caller cannot accidentally write the marker row for a different
371
+ * space than the plan was produced for.
372
+ */
373
+ readonly space?: string;
251
374
  /**
252
375
  * Destination contract IR.
253
376
  * Must correspond to `plan.destination` and is used for schema verification and marker/ledger writes.
@@ -274,7 +397,7 @@ interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
274
397
  */
275
398
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
276
399
  }
277
- type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'MARKER_ORIGIN_MISMATCH' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'EXECUTION_FAILED';
400
+ type SqlMigrationRunnerErrorCode = 'DESTINATION_CONTRACT_MISMATCH' | 'LEGACY_MARKER_SHAPE' | 'MARKER_ORIGIN_MISMATCH' | 'POLICY_VIOLATION' | 'PRECHECK_FAILED' | 'POSTCHECK_FAILED' | 'SCHEMA_VERIFY_FAILED' | 'FOREIGN_KEY_VIOLATION' | 'EXECUTION_FAILED';
278
401
  interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
279
402
  readonly code: SqlMigrationRunnerErrorCode;
280
403
  readonly meta?: AnyRecord;
@@ -282,8 +405,54 @@ interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
282
405
  interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {}
283
406
  type SqlMigrationRunnerResult = Result<SqlMigrationRunnerSuccessValue, SqlMigrationRunnerFailure>;
284
407
  interface SqlMigrationRunner<TTargetDetails> {
408
+ /**
409
+ * Apply a single migration plan, opening and managing its own
410
+ * transaction (and any target-specific connection-level setup, e.g.
411
+ * SQLite's `PRAGMA foreign_keys` toggle). Existing single-space
412
+ * callers route through here.
413
+ */
285
414
  execute(options: SqlMigrationRunnerExecuteOptions<TTargetDetails>): Promise<SqlMigrationRunnerResult>;
415
+ /**
416
+ * Apply a single migration plan against an already-open connection
417
+ * **without** opening a transaction. The caller is responsible for
418
+ * wrapping the call (and any siblings) in `BEGIN` / `COMMIT` /
419
+ * `ROLLBACK`. Used by the per-space runner wiring to fan out across
420
+ * contract spaces inside one outer transaction so a mid-apply
421
+ * failure rolls back every space's writes.
422
+ *
423
+ * Idempotent control-table setup (`prisma_contract.*`) and marker
424
+ * writes use `options.space` to address the per-space marker row.
425
+ */
426
+ executeOnConnection(options: SqlMigrationRunnerExecuteOptions<TTargetDetails>): Promise<SqlMigrationRunnerResult>;
427
+ /**
428
+ * Apply per-space plans across multiple contract spaces inside a
429
+ * single outer transaction. The caller orders the input list
430
+ * (typically via the aggregate planner's `applyOrder`: extensions
431
+ * alphabetical, then app); the runner is responsible for opening
432
+ * / committing the outer
433
+ * transaction (and any target-specific connection-level setup such
434
+ * as the SQLite FK pragma toggle). A failure on any space rolls
435
+ * back every space's writes.
436
+ *
437
+ * Each space's `SqlMigrationRunnerExecuteOptions` must reference the
438
+ * same `driver` (the connection the outer transaction is open on).
439
+ * Per-space marker writes use `options.space` to address the row.
440
+ */
441
+ executeAcrossSpaces(options: {
442
+ readonly driver: ControlDriverInstance<'sql', string>;
443
+ readonly perSpaceOptions: ReadonlyArray<SqlMigrationRunnerExecuteOptions<TTargetDetails>>;
444
+ }): Promise<MultiSpaceRunnerResult>;
286
445
  }
446
+ interface MultiSpaceRunnerSuccessValue {
447
+ readonly perSpaceResults: ReadonlyArray<{
448
+ readonly space: string;
449
+ readonly value: SqlMigrationRunnerSuccessValue;
450
+ }>;
451
+ }
452
+ interface MultiSpaceRunnerFailure extends SqlMigrationRunnerFailure {
453
+ readonly failingSpace: string;
454
+ }
455
+ type MultiSpaceRunnerResult = Result<MultiSpaceRunnerSuccessValue, MultiSpaceRunnerFailure>;
287
456
  interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails> extends MigratableTargetDescriptor<'sql', TTargetId, SqlControlFamilyInstance> {
288
457
  readonly queryOperations?: () => ReadonlyArray<SqlOperationDescriptor>;
289
458
  createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
@@ -291,11 +460,21 @@ interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails> e
291
460
  }
292
461
  interface CreateSqlMigrationPlanOptions<TTargetDetails> {
293
462
  readonly targetId: string;
463
+ /**
464
+ * Contract space this plan applies to. Mirrors {@link SqlMigrationPlan.spaceId}.
465
+ */
466
+ readonly spaceId: string;
294
467
  readonly origin?: SqlMigrationPlanContractInfo | null;
295
468
  readonly destination: SqlMigrationPlanContractInfo;
296
469
  readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
470
+ /**
471
+ * Sorted, deduplicated invariant ids for this plan; mirrors the required
472
+ * field on {@link SqlMigrationPlan}. Callers without a migration manifest
473
+ * (`db init`, `db update`, planner-built plans) pass `[]`.
474
+ */
475
+ readonly providedInvariants: readonly string[];
297
476
  readonly meta?: AnyRecord;
298
477
  }
299
478
  //#endregion
300
- export { SqlPlannerFailureResult as A, SqlMigrationRunnerFailure as C, SqlPlannerConflict as D, SqlPlanTargetDetails as E, isDatabaseDependencyProvider as F, SchemaVerifyOptions as I, SqlControlFamilyInstance as L, SqlPlannerSuccessResult as M, StorageTypePlanResult as N, SqlPlannerConflictKind as O, collectInitDependencies as P, SqlMigrationRunnerExecuteOptions as S, SqlMigrationRunnerSuccessValue as T, SqlMigrationPlanner as _, ComponentDatabaseDependency as a, SqlMigrationRunnerErrorCode as b, ResolveIdentityValueInput as c, SqlControlTargetDescriptor as d, SqlMigrationPlan as f, SqlMigrationPlanOperationTarget as g, SqlMigrationPlanOperationStep as h, ComponentDatabaseDependencies as i, SqlPlannerResult as j, SqlPlannerConflictLocation as k, SqlControlAdapterDescriptor as l, SqlMigrationPlanOperation as m, AnySqlMigrationOperation as n, CreateSqlMigrationPlanOptions as o, SqlMigrationPlanContractInfo as p, CodecControlHooks as r, ExpandNativeTypeInput as s, AnyRecord as t, SqlControlExtensionDescriptor as u, SqlMigrationPlannerPlanOptions as v, SqlMigrationRunnerResult as w, SqlMigrationRunnerExecuteCallbacks as x, SqlMigrationRunner as y };
301
- //# sourceMappingURL=types-C6K4mxDM.d.mts.map
479
+ export { SqlPlanTargetDetails as A, SchemaVerifyOptions as B, SqlMigrationRunner as C, SqlMigrationRunnerFailure as D, SqlMigrationRunnerExecuteOptions as E, SqlPlannerResult as F, SqlPlannerSuccessResult as I, StorageTypePlanResult as L, SqlPlannerConflictKind as M, SqlPlannerConflictLocation as N, SqlMigrationRunnerResult as O, SqlPlannerFailureResult as P, collectInitDependencies as R, SqlMigrationPlannerPlanOptions as S, SqlMigrationRunnerExecuteCallbacks as T, SqlControlFamilyInstance as V, SqlMigrationPlanContractInfo as _, CreateSqlMigrationPlanOptions as a, SqlMigrationPlanOperationTarget as b, FieldEventContext as c, MultiSpaceRunnerSuccessValue as d, ResolveIdentityValueInput as f, SqlMigrationPlan as g, SqlControlTargetDescriptor as h, ComponentDatabaseDependency as i, SqlPlannerConflict as j, SqlMigrationRunnerSuccessValue as k, MultiSpaceRunnerFailure as l, SqlControlExtensionDescriptor as m, CodecControlHooks as n, ExpandNativeTypeInput as o, SqlControlAdapterDescriptor as p, ComponentDatabaseDependencies as r, FieldEvent as s, AnyRecord as t, MultiSpaceRunnerResult as u, SqlMigrationPlanOperation as v, SqlMigrationRunnerErrorCode as w, SqlMigrationPlanner as x, SqlMigrationPlanOperationStep as y, isDatabaseDependencyProvider as z };
480
+ //# sourceMappingURL=types-CIdiS2QK.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-CIdiS2QK.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/migrations/types.ts"],"mappings":";;;;;;;;;;;UAkKU,eAAA;EAAA,SACC,MAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;AAAA;AAAA,KAGN,uBAAA,GAA0B,GAAA,SAAY,eAAA;AAAA,UAEjC,sBAAA;EAAA,SACC,gBAAA,EAAkB,aAAA,CAAc,eAAA;EAAA,SAChC,oBAAA,EAAsB,aAAA,CAAc,eAAA;EAAA,SACpC,YAAA,EAAc,aAAA;EAAA,SACd,oBAAA,EAAsB,uBAAA;AAAA;AAAA,UAGhB,mBAAA;EAAA,SACN,MAAA,EAAQ,qBAAA;EAAA,SACR,QAAA;EAAA,SACA,MAAA;EAAA,SACA,OAAA,GAAU,gBAAA;EAbU;;AAA2B;;EAA3B,SAkBpB,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;AAAA,UAG7B,wBAAA,SACP,qBAAA,QAA6B,WAAA,GACnC,iBAAA,CAAkB,WAAA,GAClB,uBAAA,CAAwB,WAAA,GACxB,uBAAA,EACA,sBAAA;EACF,gBAAA,CAAiB,YAAA,YAAwB,QAAA;EAEzC,MAAA,CAAO,OAAA;IAAA,SACI,MAAA,EAAQ,qBAAA;IAAA,SACR,QAAA;IAAA,SACA,gBAAA;IAAA,SACA,YAAA;IAAA,SACA,UAAA;EAAA,IACP,OAAA,CAAQ,oBAAA;EAEZ,YAAA,CAAa,OAAA,EAAS,mBAAA,GAAsB,OAAA,CAAQ,0BAAA;EAjC3C;;;;;;;;;EA4CT,yBAAA,CAA0B,OAAA;IAAA,SACf,QAAA;IAAA,SACA,MAAA,EAAQ,WAAA;IAAA,SACR,MAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8B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AA,EAAS,gCAAA,CAAiC,cAAA,IACzC,OAAA,CAAQ,wBAAA;EAtQiC;;;;;;;;;;;EAmR5C,mBAAA,CACE,OAAA,EAAS,gCAAA,CAAiC,cAAA,IACzC,OAAA,CAAQ,wBAAA;EArRkC;;;;;;;;;;;;;;EAqS7C,mBAAA,CAAoB,OAAA;IAAA,SACT,MAAA,EAAQ,qBAAA;IAAA,SACR,eAAA,EAAiB,aAAA,CAAc,gCAAA,CAAiC,cAAA;EAAA,IACvE,OAAA,CAAQ,sBAAA;AAAA;AAAA,UAGG,4BAAA;EAAA,SACN,eAAA,EAAiB,aAAA;IAAA,SACf,KAAA;IAAA,SACA,KAAA,EAAO,8BAAA;EAAA;AAAA;AAAA,UAIH,uBAAA,SAAgC,yBAAA;EAAA,SACtC,YAAA;AAAA;AAAA,KAGC,sBAAA,GAAyB,MAAA,CAAO,4BAAA,EAA8B,uBAAA;AAAA,UAEzD,0BAAA,mDACP,0BAAA,QAAkC,SAAA,EAAW,wBAAA;EAAA,SAC5C,eAAA,SAAwB,aAAA,CAAc,sBAAA;EAC/C,aAAA,CAAc,MAAA,EAAQ,wBAAA,GAA2B,mBAAA,CAAoB,cAAA;EACrE,YAAA,CAAa,MAAA,EAAQ,wBAAA,GAA2B,kBAAA,CAAmB,cAAA;AAAA;AAAA,UAGpD,6BAAA;EAAA,SACN,QAAA;EArSA;;;EAAA,SAySA,OAAA;EAAA,SACA,MAAA,GAAS,4BAAA;EAAA,SACT,WAAA,EAAa,4BAAA;EAAA,SACb,UAAA,WAAqB,yBAAA,CAA0B,cAAA;EAxRrB;;;;AAKrC;EALqC,SA8R1B,kBAAA;EAAA,SACA,IAAA,GAAO,SAAA;AAAA"}
@@ -0,0 +1,81 @@
1
+ import { type } from "arktype";
2
+ //#region src/core/verify.ts
3
+ const MetaSchema = type({ "[string]": "unknown" });
4
+ function parseMeta(meta) {
5
+ if (meta === null || meta === void 0) return {};
6
+ let parsed;
7
+ if (typeof meta === "string") try {
8
+ parsed = JSON.parse(meta);
9
+ } catch {
10
+ return {};
11
+ }
12
+ else parsed = meta;
13
+ const result = MetaSchema(parsed);
14
+ if (result instanceof type.errors) return {};
15
+ return result;
16
+ }
17
+ /**
18
+ * SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;
19
+ * Postgres uses `jsonb` and returns an already-parsed value. Normalize both
20
+ * here so `ContractMarkerRecord.contractJson` is always the structured form.
21
+ */
22
+ function parseContractJson(value) {
23
+ if (value === null || value === void 0) return null;
24
+ if (typeof value !== "string") return value;
25
+ try {
26
+ return JSON.parse(value);
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+ const ContractMarkerRowSchema = type({
32
+ core_hash: "string",
33
+ profile_hash: "string",
34
+ "contract_json?": "unknown | null",
35
+ "canonical_version?": "number | null",
36
+ "updated_at?": "Date | string",
37
+ "app_tag?": "string | null",
38
+ "meta?": "unknown | null",
39
+ invariants: type("string").array()
40
+ });
41
+ /**
42
+ * Parses a contract marker row from database query result.
43
+ * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).
44
+ */
45
+ function parseContractMarkerRow(row) {
46
+ const result = ContractMarkerRowSchema(row);
47
+ if (result instanceof type.errors) {
48
+ const messages = result.map((p) => p.message).join("; ");
49
+ throw new Error(`Invalid contract marker row: ${messages}`);
50
+ }
51
+ const updatedAt = result.updated_at ? result.updated_at instanceof Date ? result.updated_at : new Date(result.updated_at) : /* @__PURE__ */ new Date();
52
+ return {
53
+ storageHash: result.core_hash,
54
+ profileHash: result.profile_hash,
55
+ contractJson: parseContractJson(result.contract_json),
56
+ canonicalVersion: result.canonical_version ?? null,
57
+ updatedAt,
58
+ appTag: result.app_tag ?? null,
59
+ meta: parseMeta(result.meta),
60
+ invariants: result.invariants
61
+ };
62
+ }
63
+ /**
64
+ * Collects supported codec type IDs from adapter and extension manifests.
65
+ * Returns a sorted, unique array of type IDs that are declared in the manifests.
66
+ * This enables coverage checks by comparing contract column types against supported types.
67
+ *
68
+ * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.
69
+ * The manifests declare which codec types are available, but the actual type IDs
70
+ * are defined in the codec-types TypeScript modules that are imported.
71
+ *
72
+ * For MVP, we return an empty array since extracting type IDs from TypeScript modules
73
+ * would require runtime evaluation or static analysis. This can be enhanced later.
74
+ */
75
+ function collectSupportedCodecTypeIds(descriptors) {
76
+ return [];
77
+ }
78
+ //#endregion
79
+ export { parseContractMarkerRow as n, collectSupportedCodecTypeIds as t };
80
+
81
+ //# sourceMappingURL=verify-pRYxnpiG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-pRYxnpiG.mjs","names":[],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\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\n/**\n * SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;\n * Postgres uses `jsonb` and returns an already-parsed value. Normalize both\n * here so `ContractMarkerRecord.contractJson` is always the structured form.\n */\nfunction parseContractJson(value: unknown): unknown {\n if (value === null || value === undefined) return null;\n if (typeof value !== 'string') return value;\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n}\n\n/**\n * Wire shape of a `prisma_contract.marker` row as it comes out of a SQL\n * driver. Snake-cased to match the on-disk column names. Shared by every\n * SQL target's `readMarker` so each runner doesn't redeclare it inline.\n */\nexport type ContractMarkerRow = {\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 // SQLite stores arrays as JSON-TEXT, so this is `string` on the wire from\n // a SQLite driver and `string[]` from a Postgres driver. Targets normalize\n // before passing to `parseContractMarkerRow`.\n invariants: 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 invariants: type('string').array(),\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 updatedAt = result.updated_at\n ? result.updated_at instanceof Date\n ? result.updated_at\n : new Date(result.updated_at)\n : new Date();\n\n return {\n storageHash: result.core_hash,\n profileHash: result.profile_hash,\n contractJson: parseContractJson(result.contract_json),\n canonicalVersion: result.canonical_version ?? null,\n updatedAt,\n appTag: result.app_tag ?? null,\n meta: parseMeta(result.meta),\n invariants: result.invariants,\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":";;AAGA,MAAM,aAAa,KAAK,EAAE,YAAY,WAAW,CAAC;AAElD,SAAS,UAAU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ma-next/framework-components/control";
2
2
  import { ifDefined } from "@prisma-next/utils/defined";
3
-
4
3
  //#region src/core/assembly.ts
5
4
  function hasCodecControlHooks(descriptor) {
6
5
  if (typeof descriptor !== "object" || descriptor === null) return false;
@@ -28,7 +27,6 @@ function extractCodecControlHooks(descriptors) {
28
27
  }
29
28
  return hooks;
30
29
  }
31
-
32
30
  //#endregion
33
31
  //#region src/core/migrations/types.ts
34
32
  function isDatabaseDependencyProvider(value) {
@@ -44,7 +42,6 @@ function collectInitDependencies(components) {
44
42
  }
45
43
  return result;
46
44
  }
47
-
48
45
  //#endregion
49
46
  //#region src/core/schema-verify/verify-helpers.ts
50
47
  /**
@@ -453,7 +450,6 @@ function getReferentialActionMismatches(contractFK, schemaFK) {
453
450
  function normalizeReferentialAction(action) {
454
451
  return action === "noAction" ? void 0 : action;
455
452
  }
456
-
457
453
  //#endregion
458
454
  //#region src/core/schema-verify/verify-sql-schema.ts
459
455
  /**
@@ -1123,7 +1119,7 @@ function formatLiteralValue(value) {
1123
1119
  if (typeof value === "string") return value;
1124
1120
  return JSON.stringify(value);
1125
1121
  }
1126
-
1127
1122
  //#endregion
1128
1123
  export { verifyDatabaseDependencies as a, extractCodecControlHooks as c, isUniqueConstraintSatisfied as i, arraysEqual as n, collectInitDependencies as o, isIndexSatisfied as r, isDatabaseDependencyProvider as s, verifySqlSchema as t };
1129
- //# sourceMappingURL=verify-sql-schema-Ovz7RXR5.mjs.map
1124
+
1125
+ //# sourceMappingURL=verify-sql-schema-C84vejAP.mjs.map