@prisma-next/target-sqlite 0.13.0-dev.3 → 0.13.0-dev.31
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.
- package/dist/contract-free.mjs +1 -20
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control.d.mts +5 -8
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +17 -19
- package/dist/control.mjs.map +1 -1
- package/dist/ddl-CH8V_qcd.mjs +23 -0
- package/dist/ddl-CH8V_qcd.mjs.map +1 -0
- package/dist/migration.d.mts +3 -3
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -3
- package/dist/migration.mjs.map +1 -1
- package/dist/{tables-CjB7vXCr.mjs → op-factory-call-z4TT72k3.mjs} +375 -32
- package/dist/op-factory-call-z4TT72k3.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +16 -12
- package/dist/op-factory-call.d.mts.map +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/{planner-DSNDwQy9.mjs → planner-jMHqfl1A.mjs} +80 -12
- package/dist/planner-jMHqfl1A.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-C1yqJAiM.d.mts → planner-produced-sqlite-migration-BWpnDmhM.d.mts} +5 -4
- package/dist/planner-produced-sqlite-migration-BWpnDmhM.d.mts.map +1 -0
- package/dist/{planner-produced-sqlite-migration-DowV_vHw.mjs → planner-produced-sqlite-migration-CyyvoPmm.mjs} +9 -5
- package/dist/planner-produced-sqlite-migration-CyyvoPmm.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration.d.mts +1 -1
- package/dist/planner-produced-sqlite-migration.mjs +1 -1
- package/dist/planner.d.mts +5 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/render-ops-BDW2tUeR.mjs +22 -0
- package/dist/render-ops-BDW2tUeR.mjs.map +1 -0
- package/dist/render-ops.d.mts +2 -1
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/{sqlite-contract-serializer-jcRu8aHh.mjs → sqlite-contract-serializer-B_Cu0o3G.mjs} +20 -4
- package/dist/sqlite-contract-serializer-B_Cu0o3G.mjs.map +1 -0
- package/dist/sqlite-migration-CJrASAxf.d.mts +46 -0
- package/dist/sqlite-migration-CJrASAxf.d.mts.map +1 -0
- package/dist/sqlite-migration-DhW4ycZV.mjs +73 -0
- package/dist/sqlite-migration-DhW4ycZV.mjs.map +1 -0
- package/package.json +18 -18
- package/src/core/control-target.ts +4 -4
- package/src/core/errors.ts +28 -0
- package/src/core/migrations/issue-planner.ts +151 -8
- package/src/core/migrations/op-factory-call.ts +162 -23
- package/src/core/migrations/planner-ddl-builders.ts +7 -16
- package/src/core/migrations/planner-produced-sqlite-migration.ts +8 -2
- package/src/core/migrations/planner-strategies.ts +3 -3
- package/src/core/migrations/planner.ts +14 -2
- package/src/core/migrations/render-ops.ts +37 -9
- package/src/core/migrations/runner.ts +16 -12
- package/src/core/migrations/sqlite-migration.ts +51 -1
- package/src/core/sqlite-unbound-database.ts +34 -51
- package/src/exports/migration.ts +9 -1
- package/dist/op-factory-call-DymqdXQW.mjs +0 -279
- package/dist/op-factory-call-DymqdXQW.mjs.map +0 -1
- package/dist/planner-DSNDwQy9.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-C1yqJAiM.d.mts.map +0 -1
- package/dist/planner-produced-sqlite-migration-DowV_vHw.mjs.map +0 -1
- package/dist/render-ops-CFRbJ3Yb.mjs +0 -8
- package/dist/render-ops-CFRbJ3Yb.mjs.map +0 -1
- package/dist/sqlite-contract-serializer-jcRu8aHh.mjs.map +0 -1
- package/dist/sqlite-migration-CUqgmzQH.mjs +0 -16
- package/dist/sqlite-migration-CUqgmzQH.mjs.map +0 -1
- package/dist/sqlite-migration-D4XGYzgQ.d.mts +0 -17
- package/dist/sqlite-migration-D4XGYzgQ.d.mts.map +0 -1
- package/dist/tables-CjB7vXCr.mjs.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { t as SqlitePlanTargetDetails } from "./planner-target-details-xR6UfIcz.mjs";
|
|
2
2
|
import { i as SqliteTableSpec, n as SqliteColumnSpec, r as SqliteIndexSpec } from "./shared-Dhc8mLK1.mjs";
|
|
3
|
+
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
3
4
|
import { MigrationOperationClass, SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
5
|
import { ImportRequirement, TsExpression } from "@prisma-next/ts-render";
|
|
5
6
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
7
|
+
import { ExecuteRequestLowerer, Lowerer } from "@prisma-next/family-sql/control-adapter";
|
|
6
8
|
|
|
7
9
|
//#region src/core/migrations/op-factory-call.d.ts
|
|
8
10
|
type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
|
|
@@ -10,7 +12,7 @@ declare abstract class SqliteOpFactoryCallNode extends TsExpression implements O
|
|
|
10
12
|
abstract readonly factoryName: string;
|
|
11
13
|
abstract readonly operationClass: MigrationOperationClass;
|
|
12
14
|
abstract readonly label: string;
|
|
13
|
-
abstract toOp(): Op
|
|
15
|
+
abstract toOp(lowerer?: Lowerer): Op | Promise<Op>;
|
|
14
16
|
importRequirements(): readonly ImportRequirement[];
|
|
15
17
|
protected freeze(): void;
|
|
16
18
|
}
|
|
@@ -18,11 +20,13 @@ declare class CreateTableCall extends SqliteOpFactoryCallNode {
|
|
|
18
20
|
readonly factoryName: "createTable";
|
|
19
21
|
readonly operationClass: "additive";
|
|
20
22
|
readonly tableName: string;
|
|
21
|
-
readonly
|
|
23
|
+
readonly columns: readonly DdlColumn[];
|
|
24
|
+
readonly constraints: readonly DdlTableConstraint[] | undefined;
|
|
22
25
|
readonly label: string;
|
|
23
|
-
constructor(tableName: string,
|
|
24
|
-
toOp(): Op
|
|
26
|
+
constructor(tableName: string, columns: readonly DdlColumn[], constraints?: readonly DdlTableConstraint[]);
|
|
27
|
+
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
25
28
|
renderTypeScript(): string;
|
|
29
|
+
importRequirements(): readonly ImportRequirement[];
|
|
26
30
|
}
|
|
27
31
|
declare class DropTableCall extends SqliteOpFactoryCallNode {
|
|
28
32
|
readonly factoryName: "dropTable";
|
|
@@ -30,7 +34,7 @@ declare class DropTableCall extends SqliteOpFactoryCallNode {
|
|
|
30
34
|
readonly tableName: string;
|
|
31
35
|
readonly label: string;
|
|
32
36
|
constructor(tableName: string);
|
|
33
|
-
toOp(): Op;
|
|
37
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
34
38
|
renderTypeScript(): string;
|
|
35
39
|
}
|
|
36
40
|
declare class RecreateTableCall extends SqliteOpFactoryCallNode {
|
|
@@ -58,7 +62,7 @@ declare class RecreateTableCall extends SqliteOpFactoryCallNode {
|
|
|
58
62
|
}[];
|
|
59
63
|
operationClass: MigrationOperationClass;
|
|
60
64
|
});
|
|
61
|
-
toOp(): Op;
|
|
65
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
62
66
|
renderTypeScript(): string;
|
|
63
67
|
}
|
|
64
68
|
declare class AddColumnCall extends SqliteOpFactoryCallNode {
|
|
@@ -69,7 +73,7 @@ declare class AddColumnCall extends SqliteOpFactoryCallNode {
|
|
|
69
73
|
readonly column: SqliteColumnSpec;
|
|
70
74
|
readonly label: string;
|
|
71
75
|
constructor(tableName: string, column: SqliteColumnSpec);
|
|
72
|
-
toOp(): Op;
|
|
76
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
73
77
|
renderTypeScript(): string;
|
|
74
78
|
}
|
|
75
79
|
declare class DropColumnCall extends SqliteOpFactoryCallNode {
|
|
@@ -79,7 +83,7 @@ declare class DropColumnCall extends SqliteOpFactoryCallNode {
|
|
|
79
83
|
readonly columnName: string;
|
|
80
84
|
readonly label: string;
|
|
81
85
|
constructor(tableName: string, columnName: string);
|
|
82
|
-
toOp(): Op;
|
|
86
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
83
87
|
renderTypeScript(): string;
|
|
84
88
|
}
|
|
85
89
|
declare class CreateIndexCall extends SqliteOpFactoryCallNode {
|
|
@@ -90,7 +94,7 @@ declare class CreateIndexCall extends SqliteOpFactoryCallNode {
|
|
|
90
94
|
readonly columns: readonly string[];
|
|
91
95
|
readonly label: string;
|
|
92
96
|
constructor(tableName: string, indexName: string, columns: readonly string[]);
|
|
93
|
-
toOp(): Op;
|
|
97
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
94
98
|
renderTypeScript(): string;
|
|
95
99
|
}
|
|
96
100
|
declare class DropIndexCall extends SqliteOpFactoryCallNode {
|
|
@@ -100,7 +104,7 @@ declare class DropIndexCall extends SqliteOpFactoryCallNode {
|
|
|
100
104
|
readonly indexName: string;
|
|
101
105
|
readonly label: string;
|
|
102
106
|
constructor(tableName: string, indexName: string);
|
|
103
|
-
toOp(): Op;
|
|
107
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
104
108
|
renderTypeScript(): string;
|
|
105
109
|
}
|
|
106
110
|
/**
|
|
@@ -123,7 +127,7 @@ declare class DataTransformCall extends SqliteOpFactoryCallNode {
|
|
|
123
127
|
readonly tableName: string;
|
|
124
128
|
readonly columnName: string;
|
|
125
129
|
constructor(id: string, label: string, tableName: string, columnName: string);
|
|
126
|
-
toOp(): Op;
|
|
130
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
127
131
|
renderTypeScript(): string;
|
|
128
132
|
importRequirements(): readonly ImportRequirement[];
|
|
129
133
|
}
|
|
@@ -142,7 +146,7 @@ declare class RawSqlCall extends SqliteOpFactoryCallNode {
|
|
|
142
146
|
readonly label: string;
|
|
143
147
|
readonly op: Op;
|
|
144
148
|
constructor(op: Op);
|
|
145
|
-
toOp(): Op;
|
|
149
|
+
toOp(_lowerer?: Lowerer): Op;
|
|
146
150
|
renderTypeScript(): string;
|
|
147
151
|
}
|
|
148
152
|
type SqliteOpFactoryCall = CreateTableCall | DropTableCall | RecreateTableCall | AddColumnCall | DropColumnCall | CreateIndexCall | DropIndexCall | DataTransformCall | RawSqlCall;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"op-factory-call.d.mts","names":[],"sources":["../src/core/migrations/op-factory-call.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"op-factory-call.d.mts","names":[],"sources":["../src/core/migrations/op-factory-call.ts"],"mappings":";;;;;;;;;KAmCK,EAAA,GAAK,yBAAyB,CAAC,uBAAA;AAAA,uBAIrB,uBAAA,SAAgC,YAAA,YAAwB,aAAA;EAAA,kBACnD,WAAA;EAAA,kBACA,cAAA,EAAgB,uBAAA;EAAA,kBAChB,KAAA;EAAA,SACT,IAAA,CAAK,OAAA,GAAU,OAAA,GAAU,EAAA,GAAK,OAAA,CAAQ,EAAA;EAE/C,kBAAA,aAA+B,iBAAA;EAAA,UAIrB,MAAA;AAAA;AAAA,cAuEC,eAAA,SAAwB,uBAAA;EAAA,SAC1B,WAAA;EAAA,SACA,cAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA,WAAkB,SAAA;EAAA,SAClB,WAAA,WAAsB,kBAAA;EAAA,SACtB,KAAA;cAGP,SAAA,UACA,OAAA,WAAkB,SAAA,IAClB,WAAA,YAAuB,kBAAA;EAUnB,IAAA,CAAK,OAAA,GAAU,qBAAA,GAAwB,OAAA,CAAQ,EAAA;EA0CrD,gBAAA;EAcS,kBAAA,aAA+B,iBAAA;AAAA;AAAA,cAe7B,aAAA,SAAsB,uBAAA;EAAA,SACxB,WAAA;EAAA,SACA,cAAA;EAAA,SACA,SAAA;EAAA,SACA,KAAA;cAEG,SAAA;EAOZ,IAAA,CAAK,QAAA,GAAW,OAAA,GAAU,EAAA;EAI1B,gBAAA;AAAA;AAAA,cAKW,iBAAA,SAA0B,uBAAA;EAAA,SAC5B,WAAA;EAAA,SACA,cAAA,EAAgB,uBAAA;EAAA,SAChB,SAAA;EAAA,SACA,aAAA,EAAe,eAAA;EA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G,SAAA,UAAmB,SAAA;EAQ/B,IAAA,CAAK,QAAA,GAAW,OAAA,GAAU,EAAA;EAI1B,gBAAA;AAAA;;;;;;;;;;;;;cAqBW,iBAAA,SAA0B,uBAAA;EAAA,SAC5B,WAAA;EAAA,SACA,cAAA;EAAA,SACA,EAAA;EAAA,SACA,KAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA;cAEG,EAAA,UAAY,KAAA,UAAe,SAAA,UAAmB,UAAA;EAS1D,IAAA,CAAK,QAAA,GAAW,OAAA,GAAU,EAAA;EAI1B,gBAAA;EAaS,kBAAA,aAA+B,iBAAA;AAAA;;;;;;;;;;cAqB7B,UAAA,SAAmB,uBAAA;EAAA,SACrB,WAAA;EAAA,SACA,cAAA,EAAgB,uBAAA;EAAA,SAChB,KAAA;EAAA,SACA,EAAA,EAAI,EAAA;cAED,EAAA,EAAI,EAAA;EAQhB,IAAA,CAAK,QAAA,GAAW,OAAA,GAAU,EAAA;EAI1B,gBAAA;AAAA;AAAA,KASU,mBAAA,GACR,eAAA,GACA,aAAA,GACA,iBAAA,GACA,aAAA,GACA,cAAA,GACA,eAAA,GACA,aAAA,GACA,iBAAA,GACA,UAAA"}
|
package/dist/op-factory-call.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DropColumnCall, c as RawSqlCall, i as DataTransformCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-
|
|
1
|
+
import { a as DropColumnCall, c as RawSqlCall, i as DataTransformCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-z4TT72k3.mjs";
|
|
2
2
|
export { AddColumnCall, CreateIndexCall, CreateTableCall, DataTransformCall, DropColumnCall, DropIndexCall, DropTableCall, RawSqlCall, RecreateTableCall };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { t as parseSqliteDefault } from "./default-normalizer-DuoHj9-O.mjs";
|
|
2
2
|
import { t as normalizeSqliteNativeType } from "./native-type-normalizer-CiSyVmMP.mjs";
|
|
3
3
|
import { t as CONTROL_TABLE_NAMES } from "./control-tables-7KwMyJ6i.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { _ as buildColumnTypeSql, a as DropColumnCall, b as resolveColumnTypeMetadata, d as buildRecreateSummary, g as buildColumnDefaultSql, i as DataTransformCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall, u as buildRecreatePostchecks, v as isInlineAutoincrementPrimaryKey } from "./op-factory-call-z4TT72k3.mjs";
|
|
5
|
+
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-CyyvoPmm.mjs";
|
|
6
|
+
import { DdlColumn, ForeignKeyConstraint, FunctionColumnDefault, LiteralColumnDefault, PrimaryKeyConstraint, UniqueConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
7
7
|
import { extractCodecControlHooks, planFieldEventOperations, plannerFailure } from "@prisma-next/family-sql/control";
|
|
8
8
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
9
9
|
import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
|
|
10
10
|
import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
|
|
11
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
12
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
11
13
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
12
14
|
//#region src/core/migrations/planner-strategies.ts
|
|
13
15
|
/**
|
|
@@ -22,7 +24,8 @@ import { notOk, ok } from "@prisma-next/utils/result";
|
|
|
22
24
|
* has.
|
|
23
25
|
*/
|
|
24
26
|
function tableAt(storage, namespaceId, tableName) {
|
|
25
|
-
|
|
27
|
+
const ns = storage.namespaces[namespaceId];
|
|
28
|
+
return ns !== void 0 ? ns.entries.table?.[tableName] : void 0;
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
31
|
* Default namespace coordinate for an issue that does not carry one
|
|
@@ -261,7 +264,7 @@ function isMissing(issue) {
|
|
|
261
264
|
function toColumnSpec(name, column, storageTypes, inlineAutoincrementPrimaryKey = false) {
|
|
262
265
|
return {
|
|
263
266
|
name,
|
|
264
|
-
typeSql: buildColumnTypeSql(column, storageTypes),
|
|
267
|
+
typeSql: buildColumnTypeSql(column, blindCast(storageTypes)),
|
|
265
268
|
defaultSql: buildColumnDefaultSql(column.default),
|
|
266
269
|
nullable: column.nullable,
|
|
267
270
|
...inlineAutoincrementPrimaryKey ? { inlineAutoincrementPrimaryKey: true } : {}
|
|
@@ -297,6 +300,67 @@ function toTableSpec(table, storageTypes) {
|
|
|
297
300
|
foreignKeys
|
|
298
301
|
};
|
|
299
302
|
}
|
|
303
|
+
function sqliteDefaultToDdlColumnDefault(columnDefault) {
|
|
304
|
+
if (!columnDefault) return void 0;
|
|
305
|
+
switch (columnDefault.kind) {
|
|
306
|
+
case "literal": return new LiteralColumnDefault(columnDefault.value);
|
|
307
|
+
case "function":
|
|
308
|
+
if (columnDefault.expression === "autoincrement()") return void 0;
|
|
309
|
+
return new FunctionColumnDefault(columnDefault.expression);
|
|
310
|
+
default: throw new Error(`sqliteDefaultToDdlColumnDefault: unhandled kind "${blindCast(columnDefault).kind}"`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Converts a `StorageTable` to the `DdlColumn[]` + `DdlTableConstraint[]`
|
|
315
|
+
* pair used by `CreateTableCall`. This is the structured form consumed by
|
|
316
|
+
* the DDL lowering path; `toTableSpec` / `toColumnSpec` remain in use for
|
|
317
|
+
* `RecreateTableCall` and `AddColumnCall` (Phase 2).
|
|
318
|
+
*/
|
|
319
|
+
function tableToDdlParts(table, storageTypes) {
|
|
320
|
+
const columns = Object.entries(table.columns).map(([name, column]) => {
|
|
321
|
+
const inlineAutoincrement = isInlineAutoincrementPrimaryKey(table, name);
|
|
322
|
+
const typeSql = buildColumnTypeSql(column, blindCast(storageTypes));
|
|
323
|
+
if (inlineAutoincrement) return new DdlColumn({
|
|
324
|
+
name,
|
|
325
|
+
type: `${typeSql} PRIMARY KEY AUTOINCREMENT`
|
|
326
|
+
});
|
|
327
|
+
const colDefault = sqliteDefaultToDdlColumnDefault(column.default);
|
|
328
|
+
const resolved = resolveColumnTypeMetadata(column, blindCast(storageTypes));
|
|
329
|
+
const codecRef = resolved.codecId ? {
|
|
330
|
+
codecId: resolved.codecId,
|
|
331
|
+
...resolved.typeParams !== void 0 ? { typeParams: blindCast(resolved.typeParams) } : {}
|
|
332
|
+
} : void 0;
|
|
333
|
+
return new DdlColumn({
|
|
334
|
+
name,
|
|
335
|
+
type: typeSql,
|
|
336
|
+
...!column.nullable ? { notNull: true } : {},
|
|
337
|
+
...colDefault !== void 0 ? { default: colDefault } : {},
|
|
338
|
+
...codecRef !== void 0 ? { codecRef } : {}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
const constraints = [];
|
|
342
|
+
const hasInlinePk = Object.entries(table.columns).some(([name]) => isInlineAutoincrementPrimaryKey(table, name));
|
|
343
|
+
if (table.primaryKey && !hasInlinePk) constraints.push(new PrimaryKeyConstraint({ columns: table.primaryKey.columns }));
|
|
344
|
+
for (const u of table.uniques) constraints.push(new UniqueConstraint({
|
|
345
|
+
columns: u.columns,
|
|
346
|
+
...u.name !== void 0 ? { name: u.name } : {}
|
|
347
|
+
}));
|
|
348
|
+
for (const fk of table.foreignKeys) {
|
|
349
|
+
if (fk.constraint === false) continue;
|
|
350
|
+
constraints.push(new ForeignKeyConstraint({
|
|
351
|
+
columns: fk.source.columns,
|
|
352
|
+
refTable: fk.target.tableName,
|
|
353
|
+
refColumns: fk.target.columns,
|
|
354
|
+
...ifDefined("name", fk.name),
|
|
355
|
+
...ifDefined("onDelete", fk.onDelete),
|
|
356
|
+
...ifDefined("onUpdate", fk.onUpdate)
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
columns,
|
|
361
|
+
constraints
|
|
362
|
+
};
|
|
363
|
+
}
|
|
300
364
|
const DEFAULT_POLICY = { allowedOperationClasses: [
|
|
301
365
|
"additive",
|
|
302
366
|
"widening",
|
|
@@ -313,8 +377,8 @@ function mapIssueToCall(issue, ctx) {
|
|
|
313
377
|
const namespaceId = resolveNamespaceIdForIssue(issue);
|
|
314
378
|
const contractTable = tableAt(ctx.toContract.storage, namespaceId, issue.table);
|
|
315
379
|
if (!contractTable) return notOk(issueConflict("unsupportedOperation", `Table "${issue.table}" in namespace "${namespaceId}" reported missing but not found in destination contract`));
|
|
316
|
-
const
|
|
317
|
-
const calls = [new CreateTableCall(issue.table,
|
|
380
|
+
const { columns: ddlColumns, constraints: ddlConstraints } = tableToDdlParts(contractTable, ctx.storageTypes);
|
|
381
|
+
const calls = [new CreateTableCall(issue.table, ddlColumns, ddlConstraints.length > 0 ? ddlConstraints : void 0)];
|
|
318
382
|
const declaredIndexColumnKeys = /* @__PURE__ */ new Set();
|
|
319
383
|
for (const index of contractTable.indexes) {
|
|
320
384
|
const indexName = index.name ?? defaultIndexName(issue.table, index.columns);
|
|
@@ -463,8 +527,8 @@ function planIssues(options) {
|
|
|
463
527
|
}
|
|
464
528
|
//#endregion
|
|
465
529
|
//#region src/core/migrations/planner.ts
|
|
466
|
-
function createSqliteMigrationPlanner() {
|
|
467
|
-
return new SqliteMigrationPlanner();
|
|
530
|
+
function createSqliteMigrationPlanner(lowerer) {
|
|
531
|
+
return new SqliteMigrationPlanner(lowerer);
|
|
468
532
|
}
|
|
469
533
|
/**
|
|
470
534
|
* SQLite migration planner — a thin wrapper over `planIssues`.
|
|
@@ -481,6 +545,10 @@ function createSqliteMigrationPlanner() {
|
|
|
481
545
|
* uniformly alongside user-declared indexes.
|
|
482
546
|
*/
|
|
483
547
|
var SqliteMigrationPlanner = class {
|
|
548
|
+
#lowerer;
|
|
549
|
+
constructor(lowerer) {
|
|
550
|
+
this.#lowerer = lowerer;
|
|
551
|
+
}
|
|
484
552
|
plan(options) {
|
|
485
553
|
return this.planSql(options);
|
|
486
554
|
}
|
|
@@ -488,7 +556,7 @@ var SqliteMigrationPlanner = class {
|
|
|
488
556
|
return new TypeScriptRenderableSqliteMigration([], {
|
|
489
557
|
from: context.fromHash,
|
|
490
558
|
to: context.toHash
|
|
491
|
-
}, spaceId);
|
|
559
|
+
}, spaceId, void 0, this.#lowerer);
|
|
492
560
|
}
|
|
493
561
|
planSql(options) {
|
|
494
562
|
const policyResult = this.ensureAdditivePolicy(options.policy);
|
|
@@ -523,7 +591,7 @@ var SqliteMigrationPlanner = class {
|
|
|
523
591
|
plan: new TypeScriptRenderableSqliteMigration(calls, {
|
|
524
592
|
from: options.fromContract?.storage.storageHash ?? null,
|
|
525
593
|
to: options.contract.storage.storageHash
|
|
526
|
-
}, options.spaceId, destination)
|
|
594
|
+
}, options.spaceId, destination, this.#lowerer)
|
|
527
595
|
};
|
|
528
596
|
}
|
|
529
597
|
ensureAdditivePolicy(policy) {
|
|
@@ -551,4 +619,4 @@ var SqliteMigrationPlanner = class {
|
|
|
551
619
|
//#endregion
|
|
552
620
|
export { createSqliteMigrationPlanner as n, SqliteMigrationPlanner as t };
|
|
553
621
|
|
|
554
|
-
//# sourceMappingURL=planner-
|
|
622
|
+
//# sourceMappingURL=planner-jMHqfl1A.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-jMHqfl1A.mjs","names":["exhaustive","#lowerer"],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts","../src/core/migrations/planner.ts"],"sourcesContent":["/**\n * SQLite migration strategies.\n *\n * Each strategy examines the issue list, consumes issues it handles, and\n * returns the `SqliteOpFactoryCall[]` to address them. The issue planner\n * runs each strategy in order and routes whatever's left through\n * `mapIssueToCall`.\n *\n * SQLite has no enums, no data-safe backfill, and no component-declared\n * database dependencies. The only recipe that needs strategy-level\n * multi-issue consumption is `recreateTable` (added in a later phase), which\n * absorbs type/nullability/default/constraint mismatches for a given table\n * into a single recreate operation.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationClass,\n MigrationOperationPolicy,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type {\n SqlStorage,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { toTableSpec } from './issue-planner';\nimport { DataTransformCall, RecreateTableCall, type SqliteOpFactoryCall } from './op-factory-call';\nimport type { SqliteIndexSpec } from './operations/shared';\nimport { buildRecreatePostchecks, buildRecreateSummary } from './operations/tables';\n\nexport interface StrategyContext {\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema: SqlSchemaIR;\n readonly policy: MigrationOperationPolicy;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\n/**\n * Look up a storage table by its explicit namespace coordinate. Returns\n * `undefined` when the namespace has no table by that name (or no such\n * namespace exists). Callers that get `undefined` MUST treat it as an\n * explicit conflict rather than silently falling back to a name-only\n * walk across namespaces — the SQLite target currently has a single\n * namespace, but this helper enforces the explicit-coordinate\n * discipline so a future multi-namespace SQLite shape inherits the\n * conflict-on-stale-coordinate behaviour the Postgres planner already\n * has.\n */\nexport function tableAt(\n storage: SqlStorage,\n namespaceId: string,\n tableName: string,\n): StorageTable | undefined {\n const ns = storage.namespaces[namespaceId];\n return ns !== undefined ? ns.entries.table?.[tableName] : undefined;\n}\n\n/**\n * Default namespace coordinate for an issue that does not carry one\n * explicitly. Hand-crafted unit-test issues fall back to `__unbound__`,\n * the only namespace any single-namespace contract carries —\n * verifier-emitted issues for legacy single-namespace contracts already\n * stamp this id explicitly. Typed structurally so issue variants\n * without a `namespaceId` slot flow through to the same fallback.\n */\nexport function resolveNamespaceIdForIssue(issue: { readonly namespaceId?: string }): string {\n return issue.namespaceId ?? UNBOUND_NAMESPACE_ID;\n}\n\nexport type CallMigrationStrategy = (\n issues: readonly SchemaIssue[],\n context: StrategyContext,\n) =>\n | {\n kind: 'match';\n issues: readonly SchemaIssue[];\n calls: readonly SqliteOpFactoryCall[];\n recipe?: boolean;\n }\n | { kind: 'no_match' };\n\n// ============================================================================\n// Recreate-table strategy\n// ============================================================================\n\nconst WIDENING_ISSUE_KINDS = new Set<SchemaIssue['kind']>(['default_mismatch', 'default_missing']);\n\nconst DESTRUCTIVE_ISSUE_KINDS = new Set<SchemaIssue['kind']>([\n 'extra_default',\n 'type_mismatch',\n 'primary_key_mismatch',\n 'foreign_key_mismatch',\n 'unique_constraint_mismatch',\n 'extra_foreign_key',\n 'extra_unique_constraint',\n 'extra_primary_key',\n]);\n\nfunction classifyIssue(issue: SchemaIssue): 'widening' | 'destructive' | null {\n if (issue.kind === 'enum_values_changed') return null;\n if (!issue.table) return null;\n if (issue.kind === 'nullability_mismatch') {\n // Relaxing (NOT NULL → nullable) is widening; tightening is destructive.\n return issue.expected === 'true' ? 'widening' : 'destructive';\n }\n if (WIDENING_ISSUE_KINDS.has(issue.kind)) return 'widening';\n if (DESTRUCTIVE_ISSUE_KINDS.has(issue.kind)) return 'destructive';\n return null;\n}\n\n/**\n * Groups recreate-eligible issues by table, decides per-table operation class\n * (destructive wins over widening), and emits one `RecreateTableCall` per\n * table. Returns unchanged-or-smaller issue list — issues the strategy\n * consumed are removed so `mapIssueToCall` doesn't double-handle them.\n */\nexport const recreateTableStrategy: CallMigrationStrategy = (issues, ctx) => {\n const byTable = new Map<\n string,\n { issues: SchemaIssue[]; hasDestructive: boolean; namespaceId: string }\n >();\n const consumed = new Set<SchemaIssue>();\n\n for (const issue of issues) {\n const cls = classifyIssue(issue);\n if (!cls) continue;\n if (issue.kind === 'enum_values_changed') continue;\n if (!issue.table) continue;\n const table = issue.table;\n const entry = byTable.get(table);\n if (entry) {\n entry.issues.push(issue);\n if (cls === 'destructive') entry.hasDestructive = true;\n } else {\n byTable.set(table, {\n issues: [issue],\n hasDestructive: cls === 'destructive',\n namespaceId: resolveNamespaceIdForIssue(issue),\n });\n }\n consumed.add(issue);\n }\n\n if (byTable.size === 0) return { kind: 'no_match' };\n\n const calls: SqliteOpFactoryCall[] = [];\n for (const [tableName, entry] of byTable) {\n const contractTable = tableAt(ctx.toContract.storage, entry.namespaceId, tableName);\n const schemaTable = ctx.schema.tables[tableName];\n if (!contractTable || !schemaTable) continue;\n const operationClass: MigrationOperationClass = entry.hasDestructive\n ? 'destructive'\n : 'widening';\n\n // Flatten the contract table to a self-contained spec — the Call holds\n // pre-rendered SQL fragments only, no `StorageColumn` or `storageTypes`.\n const tableSpec = toTableSpec(contractTable, ctx.storageTypes);\n\n const seenIndexColumnKeys = new Set<string>();\n const indexes: SqliteIndexSpec[] = [];\n for (const idx of contractTable.indexes) {\n const key = idx.columns.join(',');\n if (seenIndexColumnKeys.has(key)) continue;\n seenIndexColumnKeys.add(key);\n indexes.push({\n name: idx.name ?? defaultIndexName(tableName, idx.columns),\n columns: idx.columns,\n });\n }\n for (const fk of contractTable.foreignKeys) {\n if (fk.index === false) continue;\n const key = fk.source.columns.join(',');\n if (seenIndexColumnKeys.has(key)) continue;\n seenIndexColumnKeys.add(key);\n indexes.push({\n name: defaultIndexName(tableName, fk.source.columns),\n columns: fk.source.columns,\n });\n }\n\n calls.push(\n new RecreateTableCall({\n tableName,\n contractTable: tableSpec,\n schemaColumnNames: Object.keys(schemaTable.columns),\n indexes,\n summary: buildRecreateSummary(tableName, entry.issues),\n postchecks: buildRecreatePostchecks(tableName, entry.issues, tableSpec),\n operationClass,\n }),\n );\n }\n\n return {\n kind: 'match',\n issues: issues.filter((i) => !consumed.has(i)),\n calls,\n recipe: true,\n };\n};\n\n// ============================================================================\n// Nullability-tightening backfill strategy\n// ============================================================================\n\n/**\n * When the policy allows `'data'` and the contract tightens one or more\n * columns from nullable to NOT NULL, emit a `DataTransformCall` stub per\n * tightened column. The user fills the backfill `UPDATE` in the rendered\n * `migration.ts` before the subsequent `RecreateTableCall` copies data into\n * the tightened schema (whose `INSERT INTO temp SELECT … FROM old` would\n * otherwise fail at runtime if any `NULL`s remain).\n *\n * Does NOT consume the tightening issue — `recreateTableStrategy` still\n * needs it to produce the actual recreate that enforces the NOT NULL at\n * the schema level. The backfill op and the recreate op end up in the\n * recipe slot in strategy order (backfill first, recreate second), which\n * matches the required execution order.\n *\n * Mirrors Postgres's `nullableTighteningCallStrategy` / `'data'`-class\n * gating. When `'data'` is not in the policy (the default `db update` /\n * `db init` path), the strategy short-circuits and the recreate alone\n * runs with its current destructive-class gating — preserving today's\n * behavior where a tightening blows up at runtime if NULLs are present.\n */\nexport const nullabilityTighteningBackfillStrategy: CallMigrationStrategy = (issues, ctx) => {\n if (!ctx.policy.allowedOperationClasses.includes('data')) {\n return { kind: 'no_match' };\n }\n\n const calls: SqliteOpFactoryCall[] = [];\n for (const issue of issues) {\n if (issue.kind !== 'nullability_mismatch') continue;\n if (!issue.table || !issue.column) continue;\n // Tightening only: `expected === 'true'` means the contract wants the\n // column nullable (relaxing from NOT NULL → nullable), which is safe and\n // needs no backfill.\n if (issue.expected === 'true') continue;\n\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[issue.column];\n if (!column || column.nullable === true) continue;\n\n calls.push(\n new DataTransformCall(\n `data_migration.backfill-${issue.table}-${issue.column}`,\n `Backfill NULLs in \"${issue.table}\".\"${issue.column}\" before NOT NULL tightening`,\n issue.table,\n issue.column,\n ),\n );\n }\n\n if (calls.length === 0) return { kind: 'no_match' };\n\n return {\n kind: 'match',\n issues,\n calls,\n recipe: true,\n };\n};\n\nexport const sqlitePlannerStrategies: readonly CallMigrationStrategy[] = [\n nullabilityTighteningBackfillStrategy,\n recreateTableStrategy,\n];\n","/**\n * SQLite migration issue planner.\n *\n * Takes schema issues (from `verifySqlSchema`) and emits migration IR\n * (`SqliteOpFactoryCall[]`). Strategies consume issues they recognize and\n * produce specialized call sequences (e.g. recreateTableStrategy absorbs\n * type/nullability/default/constraint mismatches into a single recreate op);\n * remaining issues flow through `mapIssueToCall` for the default case.\n */\n\nimport type { Contract, JsonValue } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlPlannerConflict,\n SqlPlannerConflictLocation,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type {\n SqlStorage,\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport type { CodecRef, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport {\n DdlColumn,\n ForeignKeyConstraint,\n FunctionColumnDefault,\n LiteralColumnDefault,\n PrimaryKeyConstraint,\n UniqueConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { CONTROL_TABLE_NAMES } from '../control-tables';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n type SqliteOpFactoryCall,\n} from './op-factory-call';\nimport type {\n SqliteColumnSpec,\n SqliteForeignKeySpec,\n SqliteTableSpec,\n SqliteUniqueSpec,\n} from './operations/shared';\nimport {\n buildColumnDefaultSql,\n buildColumnTypeSql,\n isInlineAutoincrementPrimaryKey,\n resolveColumnTypeMetadata,\n} from './planner-ddl-builders';\nimport {\n type CallMigrationStrategy,\n resolveNamespaceIdForIssue,\n type StrategyContext,\n sqlitePlannerStrategies,\n tableAt,\n} from './planner-strategies';\n\nexport type { CallMigrationStrategy, StrategyContext };\n\n// ============================================================================\n// Issue kind ordering (dependency order)\n// ============================================================================\n\nconst ISSUE_KIND_ORDER: Record<string, number> = {\n // Drops (reconciliation — clear the way for creates)\n extra_foreign_key: 10,\n extra_unique_constraint: 11,\n extra_primary_key: 12,\n extra_index: 13,\n extra_default: 14,\n extra_column: 15,\n extra_table: 16,\n\n // Tables before columns\n missing_table: 20,\n\n // Columns before constraints\n missing_column: 30,\n\n // Reconciliation alters (on existing objects)\n type_mismatch: 40,\n nullability_mismatch: 41,\n default_missing: 42,\n default_mismatch: 43,\n\n // Constraints after columns exist\n primary_key_mismatch: 50,\n unique_constraint_mismatch: 51,\n index_mismatch: 52,\n foreign_key_mismatch: 60,\n};\n\nfunction issueOrder(issue: SchemaIssue): number {\n return ISSUE_KIND_ORDER[issue.kind] ?? 99;\n}\n\nfunction issueKey(issue: SchemaIssue): string {\n const table = 'table' in issue && typeof issue.table === 'string' ? issue.table : '';\n const column = 'column' in issue && typeof issue.column === 'string' ? issue.column : '';\n const name =\n 'indexOrConstraint' in issue && typeof issue.indexOrConstraint === 'string'\n ? issue.indexOrConstraint\n : '';\n return `${table}\\u0000${column}\\u0000${name}`;\n}\n\n// ============================================================================\n// Conflict helpers\n// ============================================================================\n\nfunction issueConflict(\n kind: SqlPlannerConflict['kind'],\n summary: string,\n location?: SqlPlannerConflict['location'],\n): SqlPlannerConflict {\n return {\n kind,\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction conflictKindForIssue(issue: SchemaIssue): SqlPlannerConflict['kind'] {\n switch (issue.kind) {\n case 'type_mismatch':\n return 'typeMismatch';\n case 'nullability_mismatch':\n return 'nullabilityConflict';\n case 'primary_key_mismatch':\n case 'unique_constraint_mismatch':\n case 'index_mismatch':\n case 'extra_primary_key':\n case 'extra_unique_constraint':\n return 'indexIncompatible';\n case 'foreign_key_mismatch':\n case 'extra_foreign_key':\n return 'foreignKeyConflict';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction issueLocation(issue: SchemaIssue): SqlPlannerConflictLocation | undefined {\n if (issue.kind === 'enum_values_changed') return undefined;\n const location: {\n table?: string;\n column?: string;\n constraint?: string;\n } = {};\n if (issue.table) location.table = issue.table;\n if (issue.column) location.column = issue.column;\n if (issue.indexOrConstraint) location.constraint = issue.indexOrConstraint;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n\nfunction conflictForDisallowedCall(\n call: SqliteOpFactoryCall,\n allowed: readonly string[],\n): SqlPlannerConflict {\n const summary = `Operation \"${call.label}\" requires class \"${call.operationClass}\", but policy allows only: ${allowed.join(', ')}`;\n const location = locationForCall(call);\n return {\n kind: conflictKindForCall(call),\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction conflictKindForCall(call: SqliteOpFactoryCall): SqlPlannerConflict['kind'] {\n switch (call.factoryName) {\n case 'createIndex':\n case 'dropIndex':\n return 'indexIncompatible';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction locationForCall(call: SqliteOpFactoryCall): SqlPlannerConflictLocation | undefined {\n const location: { table?: string; column?: string; index?: string } = {};\n if ('tableName' in call) location.table = call.tableName;\n if ('columnName' in call) location.column = call.columnName;\n if ('indexName' in call) location.index = call.indexName;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n\nfunction isMissing(issue: SchemaIssue): boolean {\n if (issue.kind === 'enum_values_changed') return false;\n return issue.actual === undefined;\n}\n\n// ============================================================================\n// StorageTable / StorageColumn → flat SqliteTableSpec\n// ============================================================================\n\n/**\n * Resolves codec / `typeRef` / default rendering into a flat\n * `SqliteColumnSpec`. Mirrors Postgres's `toColumnSpec`. Once a column is\n * flattened, downstream Calls and operation factories never see\n * `StorageColumn` again — they deal in pre-rendered SQL fragments.\n */\nexport function toColumnSpec(\n name: string,\n column: StorageColumn,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n inlineAutoincrementPrimaryKey = false,\n): SqliteColumnSpec {\n const typeSql = buildColumnTypeSql(\n column,\n blindCast<\n Record<string, StorageTypeInstance>,\n 'buildColumnTypeSql declares its storageTypes parameter as mutable Record while the planner stores it readonly; the helper does not mutate, so the readonly→mutable narrowing is sound'\n >(storageTypes),\n );\n const defaultSql = buildColumnDefaultSql(column.default);\n return {\n name,\n typeSql,\n defaultSql,\n nullable: column.nullable,\n ...(inlineAutoincrementPrimaryKey ? { inlineAutoincrementPrimaryKey: true } : {}),\n };\n}\n\n/**\n * Flattens a `StorageTable` into a `SqliteTableSpec` ready for\n * `CreateTableCall` / `RecreateTableCall`. Sole-column AUTOINCREMENT\n * primary keys are detected here and marked on the column spec so the\n * renderer emits `INTEGER PRIMARY KEY AUTOINCREMENT` inline.\n */\nexport function toTableSpec(\n table: StorageTable,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n): SqliteTableSpec {\n const columns: SqliteColumnSpec[] = Object.entries(table.columns).map(([name, column]) =>\n toColumnSpec(name, column, storageTypes, isInlineAutoincrementPrimaryKey(table, name)),\n );\n const uniques: SqliteUniqueSpec[] = table.uniques.map((u) => ({\n columns: u.columns,\n ...(u.name !== undefined ? { name: u.name } : {}),\n }));\n const foreignKeys: SqliteForeignKeySpec[] = table.foreignKeys.map((fk) => ({\n columns: fk.source.columns,\n references: { table: fk.target.tableName, columns: fk.target.columns },\n constraint: fk.constraint !== false,\n ...(fk.name !== undefined ? { name: fk.name } : {}),\n ...(fk.onDelete !== undefined ? { onDelete: fk.onDelete } : {}),\n ...(fk.onUpdate !== undefined ? { onUpdate: fk.onUpdate } : {}),\n }));\n return {\n columns,\n ...(table.primaryKey ? { primaryKey: { columns: table.primaryKey.columns } } : {}),\n uniques,\n foreignKeys,\n };\n}\n\n// ============================================================================\n// StorageTable / StorageColumn → DdlColumn[] + DdlTableConstraint[] (for CreateTableCall)\n// ============================================================================\n\nfunction sqliteDefaultToDdlColumnDefault(\n columnDefault: StorageColumn['default'],\n): DdlColumn['default'] {\n if (!columnDefault) return undefined;\n switch (columnDefault.kind) {\n case 'literal':\n return new LiteralColumnDefault(columnDefault.value);\n case 'function':\n // `autoincrement()` is not a DEFAULT clause — SQLite encodes it as\n // `INTEGER PRIMARY KEY AUTOINCREMENT` inline on the column. Skip it\n // here; the renderer also has a defensive guard for the same case.\n if (columnDefault.expression === 'autoincrement()') return undefined;\n return new FunctionColumnDefault(columnDefault.expression);\n default: {\n const exhaustive: never = columnDefault;\n throw new Error(\n `sqliteDefaultToDdlColumnDefault: unhandled kind \"${blindCast<{ kind: string }, 'exhaustiveness: surface the unhandled default kind'>(exhaustive).kind}\"`,\n );\n }\n }\n}\n\n/**\n * Converts a `StorageTable` to the `DdlColumn[]` + `DdlTableConstraint[]`\n * pair used by `CreateTableCall`. This is the structured form consumed by\n * the DDL lowering path; `toTableSpec` / `toColumnSpec` remain in use for\n * `RecreateTableCall` and `AddColumnCall` (Phase 2).\n */\nexport function tableToDdlParts(\n table: StorageTable,\n storageTypes: Record<string, StorageTypeInstance>,\n): { columns: DdlColumn[]; constraints: DdlTableConstraint[] } {\n const columns: DdlColumn[] = Object.entries(table.columns).map(([name, column]) => {\n const inlineAutoincrement = isInlineAutoincrementPrimaryKey(table, name);\n const typeSql = buildColumnTypeSql(\n column,\n blindCast<\n Record<string, StorageTypeInstance>,\n 'buildColumnTypeSql declares its storageTypes parameter as mutable Record while the planner stores it readonly; the helper does not mutate, so the readonly→mutable narrowing is sound'\n >(storageTypes),\n );\n\n if (inlineAutoincrement) {\n // `DdlColumn` has no SQLite-specific autoincrement flag, so the full\n // `PRIMARY KEY AUTOINCREMENT` clause is embedded in the `type` string.\n // The DDL renderer (`ddl-renderer.ts`) substring-detects `AUTOINCREMENT`\n // to suppress the normal NOT NULL / PRIMARY KEY / DEFAULT clause rendering\n // and emit the entire type string verbatim. Both sites must stay in sync.\n // The structural fix (a SQLite-specific column option) is tracked in TML-2866.\n return new DdlColumn({ name, type: `${typeSql} PRIMARY KEY AUTOINCREMENT` });\n }\n const colDefault = sqliteDefaultToDdlColumnDefault(column.default);\n const resolved = resolveColumnTypeMetadata(\n column,\n blindCast<\n Record<string, StorageTypeInstance>,\n 'resolveColumnTypeMetadata declares its storageTypes parameter as mutable Record while the planner stores it readonly; the helper does not mutate, so the readonly→mutable narrowing is sound'\n >(storageTypes),\n );\n const codecRef: CodecRef | undefined = resolved.codecId\n ? {\n codecId: resolved.codecId,\n ...(resolved.typeParams !== undefined\n ? {\n typeParams: blindCast<\n JsonValue,\n 'resolved.typeParams is JsonValue-shaped storage metadata; the narrowed (non-undefined) value lands in CodecRef.typeParams which is JsonValue'\n >(resolved.typeParams),\n }\n : {}),\n }\n : undefined;\n return new DdlColumn({\n name,\n type: typeSql,\n ...(!column.nullable ? { notNull: true } : {}),\n ...(colDefault !== undefined ? { default: colDefault } : {}),\n ...(codecRef !== undefined ? { codecRef } : {}),\n });\n });\n\n const constraints: DdlTableConstraint[] = [];\n\n const hasInlinePk = Object.entries(table.columns).some(([name]) =>\n isInlineAutoincrementPrimaryKey(table, name),\n );\n if (table.primaryKey && !hasInlinePk) {\n constraints.push(new PrimaryKeyConstraint({ columns: table.primaryKey.columns }));\n }\n\n for (const u of table.uniques) {\n constraints.push(\n new UniqueConstraint({\n columns: u.columns,\n ...(u.name !== undefined ? { name: u.name } : {}),\n }),\n );\n }\n\n for (const fk of table.foreignKeys) {\n if (fk.constraint === false) continue;\n constraints.push(\n new ForeignKeyConstraint({\n columns: fk.source.columns,\n refTable: fk.target.tableName,\n refColumns: fk.target.columns,\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n }),\n );\n }\n\n return { columns, constraints };\n}\n\n// ============================================================================\n// Issue planner\n// ============================================================================\n\nexport interface IssuePlannerOptions {\n readonly issues: readonly SchemaIssue[];\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema?: SqlSchemaIR;\n readonly policy?: MigrationOperationPolicy;\n readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n readonly strategies?: readonly CallMigrationStrategy[];\n}\n\nexport interface IssuePlannerValue {\n readonly calls: readonly SqliteOpFactoryCall[];\n}\n\nconst DEFAULT_POLICY: MigrationOperationPolicy = {\n allowedOperationClasses: ['additive', 'widening', 'destructive', 'data'],\n};\n\nfunction emptySchemaIR(): SqlSchemaIR {\n return { tables: {} };\n}\n\n// ============================================================================\n// Issue → Call mapping (per-issue default path)\n// ============================================================================\n\nfunction mapIssueToCall(\n issue: SchemaIssue,\n ctx: StrategyContext,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n switch (issue.kind) {\n case 'missing_table': {\n if (!issue.table) {\n return notOk(\n issueConflict('unsupportedOperation', 'Missing table issue has no table name'),\n );\n }\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const contractTable = tableAt(ctx.toContract.storage, namespaceId, issue.table);\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" in namespace \"${namespaceId}\" reported missing but not found in destination contract`,\n ),\n );\n }\n const { columns: ddlColumns, constraints: ddlConstraints } = tableToDdlParts(\n contractTable,\n ctx.storageTypes,\n );\n const calls: SqliteOpFactoryCall[] = [\n new CreateTableCall(\n issue.table,\n ddlColumns,\n ddlConstraints.length > 0 ? ddlConstraints : undefined,\n ),\n ];\n const declaredIndexColumnKeys = new Set<string>();\n for (const index of contractTable.indexes) {\n const indexName = index.name ?? defaultIndexName(issue.table, index.columns);\n declaredIndexColumnKeys.add(index.columns.join(','));\n calls.push(new CreateIndexCall(issue.table, indexName, index.columns));\n }\n for (const fk of contractTable.foreignKeys) {\n if (fk.index === false) continue;\n if (declaredIndexColumnKeys.has(fk.source.columns.join(','))) continue;\n const indexName = defaultIndexName(issue.table, fk.source.columns);\n calls.push(new CreateIndexCall(issue.table, indexName, fk.source.columns));\n }\n return ok(calls);\n }\n\n case 'missing_column': {\n if (!issue.table || !issue.column) {\n return notOk(\n issueConflict('unsupportedOperation', 'Missing column issue has no table/column name'),\n );\n }\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const contractTable2 = tableAt(ctx.toContract.storage, namespaceId, issue.table);\n const column = contractTable2?.columns[issue.column];\n if (!column) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n }\n const contractTable = contractTable2;\n const columnSpec = toColumnSpec(\n issue.column,\n column,\n ctx.storageTypes,\n contractTable ? isInlineAutoincrementPrimaryKey(contractTable, issue.column) : false,\n );\n return ok([new AddColumnCall(issue.table, columnSpec)]);\n }\n\n case 'index_mismatch': {\n if (!issue.table) {\n return notOk(issueConflict('indexIncompatible', 'Index issue has no table name'));\n }\n if (!isMissing(issue) || !issue.expected) {\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Index on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n }\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const columns = issue.expected.split(', ');\n const contractTable = tableAt(ctx.toContract.storage, namespaceId, issue.table);\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" not found in destination contract`,\n ),\n );\n }\n const explicitIndex = contractTable.indexes.find(\n (idx) => idx.columns.join(',') === columns.join(','),\n );\n const indexName = explicitIndex?.name ?? defaultIndexName(issue.table, columns);\n return ok([new CreateIndexCall(issue.table, indexName, columns)]);\n }\n\n case 'extra_table': {\n if (!issue.table) {\n return notOk(issueConflict('unsupportedOperation', 'Extra table issue has no table name'));\n }\n // Runner-owned control tables must never be dropped.\n if (CONTROL_TABLE_NAMES.has(issue.table)) return ok([]);\n return ok([new DropTableCall(issue.table)]);\n }\n\n case 'extra_column': {\n if (!issue.table || !issue.column) {\n return notOk(\n issueConflict('unsupportedOperation', 'Extra column issue has no table/column name'),\n );\n }\n return ok([new DropColumnCall(issue.table, issue.column)]);\n }\n\n case 'extra_index': {\n if (!issue.table || !issue.indexOrConstraint) {\n return notOk(\n issueConflict('unsupportedOperation', 'Extra index issue has no table/index name'),\n );\n }\n return ok([new DropIndexCall(issue.table, issue.indexOrConstraint)]);\n }\n\n // SQLite has no enum types (capability `sql.enums: false`). The verifier\n // should never emit `enum_values_changed` against a SQLite schema, so if\n // we receive one it is a verifier bug — surface it as an explicit\n // conflict rather than silently dropping it.\n case 'enum_values_changed':\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Received enum_values_changed against a SQLite schema (sql.enums: false) — verifier bug',\n ),\n );\n\n // Everything below is absorbed by recreateTableStrategy. If it falls\n // through here, policy or context didn't allow the recreate — surface as\n // a conflict.\n case 'type_mismatch':\n case 'nullability_mismatch':\n case 'default_mismatch':\n case 'default_missing':\n case 'extra_default':\n case 'primary_key_mismatch':\n case 'unique_constraint_mismatch':\n case 'foreign_key_mismatch':\n case 'extra_foreign_key':\n case 'extra_unique_constraint':\n case 'extra_primary_key':\n return notOk(issueConflict(conflictKindForIssue(issue), issue.message, issueLocation(issue)));\n\n default:\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Unhandled issue kind: ${(issue as SchemaIssue).kind}`,\n ),\n );\n }\n}\n\n// ============================================================================\n// Call categorization for final emission order\n// ============================================================================\n\ntype CallCategory =\n | 'drop-column'\n | 'drop-index'\n | 'drop-table'\n | 'create-table'\n | 'add-column'\n | 'create-index';\n\nfunction classifyCall(call: SqliteOpFactoryCall): CallCategory | null {\n switch (call.factoryName) {\n case 'createTable':\n return 'create-table';\n case 'addColumn':\n return 'add-column';\n case 'createIndex':\n return 'create-index';\n case 'dropColumn':\n return 'drop-column';\n case 'dropIndex':\n return 'drop-index';\n case 'dropTable':\n return 'drop-table';\n // recreateTable goes into the recipe slot; return null for bucketable.\n case 'recreateTable':\n return null;\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Top-level planIssues\n// ============================================================================\n\nexport function planIssues(\n options: IssuePlannerOptions,\n): Result<IssuePlannerValue, readonly SqlPlannerConflict[]> {\n const policyProvided = options.policy !== undefined;\n const policy = options.policy ?? DEFAULT_POLICY;\n const schema = options.schema ?? emptySchemaIR();\n const frameworkComponents = options.frameworkComponents ?? [];\n\n const context: StrategyContext = {\n toContract: options.toContract,\n fromContract: options.fromContract,\n codecHooks: options.codecHooks,\n storageTypes: options.storageTypes,\n schema,\n policy,\n frameworkComponents,\n };\n\n const strategies = options.strategies ?? sqlitePlannerStrategies;\n\n let remaining = options.issues;\n const recipeCalls: SqliteOpFactoryCall[] = [];\n const bucketableCalls: SqliteOpFactoryCall[] = [];\n\n for (const strategy of strategies) {\n const result = strategy(remaining, context);\n if (result.kind === 'match') {\n remaining = result.issues;\n if (result.recipe) {\n recipeCalls.push(...result.calls);\n } else {\n bucketableCalls.push(...result.calls);\n }\n }\n }\n\n const sorted = [...remaining].sort((a, b) => {\n const kindDelta = issueOrder(a) - issueOrder(b);\n if (kindDelta !== 0) return kindDelta;\n const keyA = issueKey(a);\n const keyB = issueKey(b);\n return keyA < keyB ? -1 : keyA > keyB ? 1 : 0;\n });\n\n const defaultCalls: SqliteOpFactoryCall[] = [];\n const conflicts: SqlPlannerConflict[] = [];\n\n for (const issue of sorted) {\n const result = mapIssueToCall(issue, context);\n if (result.ok) {\n defaultCalls.push(...result.value);\n } else {\n conflicts.push(result.failure);\n }\n }\n\n // Policy gating for recipe + bucketable. Default-mapped calls for disallowed\n // classes never get here (they're surfaced as per-issue conflicts above).\n const allowed = policy.allowedOperationClasses;\n let gatedRecipe = recipeCalls;\n let gatedBucketable = bucketableCalls;\n let gatedDefault = defaultCalls;\n if (policyProvided) {\n const sink = (acc: SqliteOpFactoryCall[]) => (call: SqliteOpFactoryCall) => {\n if (allowed.includes(call.operationClass)) {\n acc.push(call);\n return;\n }\n conflicts.push(conflictForDisallowedCall(call, allowed));\n };\n const gatedRecipeBucket: SqliteOpFactoryCall[] = [];\n const gatedBucketableBucket: SqliteOpFactoryCall[] = [];\n const gatedDefaultBucket: SqliteOpFactoryCall[] = [];\n recipeCalls.forEach(sink(gatedRecipeBucket));\n bucketableCalls.forEach(sink(gatedBucketableBucket));\n defaultCalls.forEach(sink(gatedDefaultBucket));\n gatedRecipe = gatedRecipeBucket;\n gatedBucketable = gatedBucketableBucket;\n gatedDefault = gatedDefaultBucket;\n }\n\n if (conflicts.length > 0) {\n return notOk(conflicts);\n }\n\n // Final emission order matches the current monolithic planner:\n // create-table → add-column → create-index → recreate → drop-column → drop-index → drop-table\n const combined = [...gatedDefault, ...gatedBucketable];\n const byCategory = (cat: CallCategory) => combined.filter((c) => classifyCall(c) === cat);\n\n const calls: SqliteOpFactoryCall[] = [\n ...byCategory('create-table'),\n ...byCategory('add-column'),\n ...byCategory('create-index'),\n ...gatedRecipe,\n ...byCategory('drop-column'),\n ...byCategory('drop-index'),\n ...byCategory('drop-table'),\n ];\n\n return ok({ calls });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlanner,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport { planIssues } from './issue-planner';\nimport {\n type SqliteMigrationDestinationInfo,\n TypeScriptRenderableSqliteMigration,\n} from './planner-produced-sqlite-migration';\nimport { sqlitePlannerStrategies } from './planner-strategies';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\nexport function createSqliteMigrationPlanner(\n lowerer: ExecuteRequestLowerer,\n): SqliteMigrationPlanner {\n return new SqliteMigrationPlanner(lowerer);\n}\n\nexport type SqlitePlanResult =\n | { readonly kind: 'success'; readonly plan: TypeScriptRenderableSqliteMigration }\n | SqlPlannerFailureResult;\n\n/**\n * SQLite migration planner — a thin wrapper over `planIssues`.\n *\n * `plan()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the registered\n * strategies. Strategies absorb groups of related issues into composite\n * recipes (e.g. recreating a table to apply type/nullability/default/\n * constraint changes at once); anything not absorbed by a strategy flows\n * through `mapIssueToCall` in the issue planner as a one-off call.\n *\n * FK-backing indexes are surfaced by `verifySqlSchema`'s index expansion\n * (see `verify-sql-schema.ts:459-469`), so `mapIssueToCall` handles them\n * uniformly alongside user-declared indexes.\n */\nexport class SqliteMigrationPlanner\n implements SqlMigrationPlanner<SqlitePlanTargetDetails>, MigrationPlanner<'sql', 'sqlite'>\n{\n readonly #lowerer: ExecuteRequestLowerer;\n\n constructor(lowerer: ExecuteRequestLowerer) {\n this.#lowerer = lowerer;\n }\n\n plan(options: {\n readonly contract: unknown;\n readonly schema: unknown;\n readonly policy: MigrationOperationPolicy;\n /**\n * The \"from\" contract (state the planner assumes the database starts at),\n * or `null` for reconciliation flows.\n *\n * Typed as the framework `Contract | null` to satisfy the\n * `MigrationPlanner` interface contract; `planSql` narrows to the SQL\n * shape via `SqlMigrationPlannerPlanOptions`. Used to populate\n * `describe().from` on the produced plan as\n * `fromContract?.storage.storageHash ?? null`.\n */\n readonly fromContract: Contract | null;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n /**\n * Contract space this plan applies to. Stamped onto the produced\n * {@link TypeScriptRenderableSqliteMigration.spaceId} so the runner keys\n * the marker row by the right space.\n */\n readonly spaceId: string;\n }): SqlitePlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): TypeScriptRenderableSqliteMigration {\n return new TypeScriptRenderableSqliteMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n undefined,\n this.#lowerer,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): SqlitePlanResult {\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) return policyResult;\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\n\n const result = planIssues({\n issues: schemaIssues,\n toContract: options.contract,\n fromContract: options.fromContract,\n codecHooks,\n storageTypes,\n schema: options.schema,\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: sqlitePlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n // Codec lifecycle hook (T2.2): inline `onFieldEvent`-emitted ops after\n // structural DDL. Sub-spec § 5 fixes the ordering as\n // `structural → added → dropped → altered`, with within-group sorting by\n // `(tableName, fieldName)` deterministic for byte-stable re-emits.\n // Hook fires only at the application emitter — extension-space planning\n // (M2 R2) never reaches this helper.\n const fieldEventOps = planFieldEventOperations({\n priorContract: options.fromContract,\n newContract: options.contract,\n codecHooks,\n });\n // Codec-emitted calls already conform to `OpFactoryCall` — render +\n // toOp + importRequirements ride directly through the same emit path\n // as structural ops, no `RawSqlCall` wrap.\n const calls = [...result.value.calls, ...fieldEventOps];\n\n const destination: SqliteMigrationDestinationInfo = {\n storageHash: options.contract.storage.storageHash,\n ...(options.contract.profileHash !== undefined\n ? { profileHash: options.contract.profileHash }\n : {}),\n };\n\n return {\n kind: 'success' as const,\n plan: new TypeScriptRenderableSqliteMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n destination,\n this.#lowerer,\n ),\n };\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy): SqlPlannerFailureResult | null {\n if (!policy.allowedOperationClasses.includes('additive')) {\n return plannerFailure([\n {\n kind: 'unsupportedOperation',\n summary: 'Migration planner requires additive operations be allowed',\n why: 'The planner requires the \"additive\" operation class to be allowed in the policy.',\n },\n ]);\n }\n return null;\n }\n\n private collectSchemaIssues(options: SqlMigrationPlannerPlanOptions): readonly SchemaIssue[] {\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyResult = verifySqlSchema({\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n return verifyResult.schema.issues;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,QACd,SACA,aACA,WAC0B;CAC1B,MAAM,KAAK,QAAQ,WAAW;CAC9B,OAAO,OAAO,KAAA,IAAY,GAAG,QAAQ,QAAQ,aAAa,KAAA;AAC5D;;;;;;;;;AAUA,SAAgB,2BAA2B,OAAkD;CAC3F,OAAO,MAAM,eAAe;AAC9B;AAkBA,MAAM,uBAAuB,IAAI,IAAyB,CAAC,oBAAoB,iBAAiB,CAAC;AAEjG,MAAM,0BAA0B,IAAI,IAAyB;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,cAAc,OA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ClB,QAAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,IAAI;GAC9B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;EACvB,CACkB,CAAC,CAAC,OAAO;CAC7B;AACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as SqlitePlanTargetDetails } from "./planner-target-details-xR6UfIcz.mjs";
|
|
2
|
-
import { t as SqliteMigration } from "./sqlite-migration-
|
|
2
|
+
import { t as SqliteMigration } from "./sqlite-migration-CJrASAxf.mjs";
|
|
3
3
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { MigrationPlanWithAuthoringSurface, OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
5
|
+
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
5
6
|
import { MigrationMeta } from "@prisma-next/migration-tools/migration";
|
|
6
7
|
|
|
7
8
|
//#region src/core/migrations/planner-produced-sqlite-migration.d.ts
|
|
@@ -12,8 +13,8 @@ interface SqliteMigrationDestinationInfo {
|
|
|
12
13
|
}
|
|
13
14
|
declare class TypeScriptRenderableSqliteMigration extends SqliteMigration implements MigrationPlanWithAuthoringSurface {
|
|
14
15
|
#private;
|
|
15
|
-
constructor(calls: readonly OpFactoryCall[], meta: MigrationMeta, spaceId: string, destination?: SqliteMigrationDestinationInfo);
|
|
16
|
-
get operations(): readonly Op[];
|
|
16
|
+
constructor(calls: readonly OpFactoryCall[], meta: MigrationMeta, spaceId: string, destination?: SqliteMigrationDestinationInfo, lowerer?: ExecuteRequestLowerer);
|
|
17
|
+
get operations(): readonly (Op | Promise<Op>)[];
|
|
17
18
|
describe(): MigrationMeta;
|
|
18
19
|
get destination(): SqliteMigrationDestinationInfo;
|
|
19
20
|
/**
|
|
@@ -26,4 +27,4 @@ declare class TypeScriptRenderableSqliteMigration extends SqliteMigration implem
|
|
|
26
27
|
}
|
|
27
28
|
//#endregion
|
|
28
29
|
export { TypeScriptRenderableSqliteMigration as n, SqliteMigrationDestinationInfo as t };
|
|
29
|
-
//# sourceMappingURL=planner-produced-sqlite-migration-
|
|
30
|
+
//# sourceMappingURL=planner-produced-sqlite-migration-BWpnDmhM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-sqlite-migration-BWpnDmhM.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-sqlite-migration.ts"],"mappings":";;;;;;;;KAYK,EAAA,GAAK,yBAAyB,CAAC,uBAAA;AAAA,UAEnB,8BAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAW;AAAA;AAAA,cAGT,mCAAA,SACH,eAAA,YACG,iCAAA;EAAA;cAUT,KAAA,WAAgB,aAAA,IAChB,IAAA,EAAM,aAAA,EACN,OAAA,UACA,WAAA,GAAc,8BAAA,EACd,OAAA,GAAU,qBAAA;EAAA,IAUC,UAAA,cAAwB,EAAA,GAAK,OAAA,CAAQ,EAAA;EAKzC,QAAA,IAAY,aAAA;EAAA,IAIR,WAAA,IAAe,8BAAA;EAtCR;AAGtB;;;;EAHsB,IA+ChB,OAAA;EAIJ,gBAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as renderOps } from "./render-ops-
|
|
2
|
-
import { t as SqliteMigration } from "./sqlite-migration-
|
|
1
|
+
import { t as renderOps } from "./render-ops-BDW2tUeR.mjs";
|
|
2
|
+
import { t as SqliteMigration } from "./sqlite-migration-DhW4ycZV.mjs";
|
|
3
3
|
import { renderImports } from "@prisma-next/ts-render";
|
|
4
4
|
import { detectScaffoldRuntime, shebangLineFor } from "@prisma-next/migration-tools/migration-ts";
|
|
5
5
|
//#region src/core/migrations/render-typescript.ts
|
|
@@ -70,15 +70,19 @@ var TypeScriptRenderableSqliteMigration = class extends SqliteMigration {
|
|
|
70
70
|
#meta;
|
|
71
71
|
#destination;
|
|
72
72
|
#spaceId;
|
|
73
|
-
|
|
73
|
+
#lowerer;
|
|
74
|
+
#operationsCache;
|
|
75
|
+
constructor(calls, meta, spaceId, destination, lowerer) {
|
|
74
76
|
super();
|
|
75
77
|
this.#calls = calls;
|
|
76
78
|
this.#meta = meta;
|
|
77
79
|
this.#spaceId = spaceId;
|
|
78
80
|
this.#destination = destination ?? { storageHash: meta.to };
|
|
81
|
+
this.#lowerer = lowerer;
|
|
79
82
|
}
|
|
80
83
|
get operations() {
|
|
81
|
-
|
|
84
|
+
this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);
|
|
85
|
+
return this.#operationsCache;
|
|
82
86
|
}
|
|
83
87
|
describe() {
|
|
84
88
|
return this.#meta;
|
|
@@ -104,4 +108,4 @@ var TypeScriptRenderableSqliteMigration = class extends SqliteMigration {
|
|
|
104
108
|
//#endregion
|
|
105
109
|
export { TypeScriptRenderableSqliteMigration as t };
|
|
106
110
|
|
|
107
|
-
//# sourceMappingURL=planner-produced-sqlite-migration-
|
|
111
|
+
//# sourceMappingURL=planner-produced-sqlite-migration-CyyvoPmm.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-sqlite-migration-CyyvoPmm.mjs","names":["#calls","#meta","#destination","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/render-typescript.ts","../src/core/migrations/planner-produced-sqlite-migration.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the SQLite migration IR. Mirrors the\n * Postgres `render-typescript.ts` — different base-class + factory module\n * specifier, same overall shape.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/sqlite/migration` so an authored SQLite\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint. Mirrors Postgres's `BASE_IMPORTS`.\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to\n * `'sqlite'`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n","import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\nimport { SqliteMigration } from './sqlite-migration';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport interface SqliteMigrationDestinationInfo {\n readonly storageHash: string;\n readonly profileHash?: string;\n}\n\nexport class TypeScriptRenderableSqliteMigration\n extends SqliteMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #destination: SqliteMigrationDestinationInfo;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache: readonly (Op | Promise<Op>)[] | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n destination?: SqliteMigrationDestinationInfo,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#destination = destination ?? { storageHash: meta.to };\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (Op | Promise<Op>)[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n override get destination(): SqliteMigrationDestinationInfo {\n return this.#destination;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner\n * keys the marker row by the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, {\n from: this.#meta.from,\n to: this.#meta.to,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,eAA6C,CACjD;CAAE,iBAA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C,QAAQ;EACb,KAAKE,WAAW;EAChB,KAAKD,eAAe,eAAe,EAAE,aAAa,KAAK,GAAG;EAC1D,KAAKE,WAAW;CAClB;CAEA,IAAa,aAA4C;EACvD,KAAKC,qBAAqB,UAAU,KAAKL,QAAQ,KAAKI,QAAQ;EAC9D,OAAO,KAAKC;CACd;CAEA,WAAmC;EACjC,OAAO,KAAKJ;CACd;CAEA,IAAa,cAA8C;EACzD,OAAO,KAAKC;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKH,QAAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;EACjB,CAAC;CACH;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-
|
|
1
|
+
import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-BWpnDmhM.mjs";
|
|
2
2
|
export { type SqliteMigrationDestinationInfo, TypeScriptRenderableSqliteMigration };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-
|
|
1
|
+
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-CyyvoPmm.mjs";
|
|
2
2
|
export { TypeScriptRenderableSqliteMigration };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { t as SqlitePlanTargetDetails } from "./planner-target-details-xR6UfIcz.mjs";
|
|
2
|
-
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-
|
|
2
|
+
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-BWpnDmhM.mjs";
|
|
3
3
|
import { MigrationOperationPolicy, SqlMigrationPlanner, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
|
|
5
5
|
import { Contract } from "@prisma-next/contract/types";
|
|
6
|
+
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
6
7
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
7
8
|
|
|
8
9
|
//#region src/core/migrations/planner.d.ts
|
|
9
|
-
declare function createSqliteMigrationPlanner(): SqliteMigrationPlanner;
|
|
10
|
+
declare function createSqliteMigrationPlanner(lowerer: ExecuteRequestLowerer): SqliteMigrationPlanner;
|
|
10
11
|
type SqlitePlanResult = {
|
|
11
12
|
readonly kind: 'success';
|
|
12
13
|
readonly plan: TypeScriptRenderableSqliteMigration;
|
|
@@ -26,6 +27,8 @@ type SqlitePlanResult = {
|
|
|
26
27
|
* uniformly alongside user-declared indexes.
|
|
27
28
|
*/
|
|
28
29
|
declare class SqliteMigrationPlanner implements SqlMigrationPlanner<SqlitePlanTargetDetails>, MigrationPlanner<'sql', 'sqlite'> {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(lowerer: ExecuteRequestLowerer);
|
|
29
32
|
plan(options: {
|
|
30
33
|
readonly contract: unknown;
|
|
31
34
|
readonly schema: unknown;
|
package/dist/planner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;;iBA8BgB,4BAAA,CACd,OAAA,EAAS,qBAAA,GACR,sBAAsB;AAAA,KAIb,gBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,IAAA,EAAM,mCAAA;AAAA,IAC3C,uBAAuB;;;;;;AANF;AAIzB;;;;;;;;cAkBa,sBAAA,YACA,mBAAA,CAAoB,uBAAA,GAA0B,gBAAA;EAAA;cAI7C,OAAA,EAAS,qBAAA;EAIrB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IAAA;;;;;;;;;;IAAA,SAWR,YAAA,EAAc,QAAA;IAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAvBf;;;;;IAAA,SA6BpB,OAAA;EAAA,IACP,gBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,mCAAA;EAAA,QAaK,OAAA;EAAA,QA8DA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
|
package/dist/planner.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-
|
|
1
|
+
import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-jMHqfl1A.mjs";
|
|
2
2
|
export { SqliteMigrationPlanner, createSqliteMigrationPlanner };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
2
|
+
import { isThenable } from "@prisma-next/utils/promise";
|
|
3
|
+
//#region src/core/migrations/render-ops.ts
|
|
4
|
+
function assertSqliteOp(op, callFactoryName) {
|
|
5
|
+
const targetId = blindCast(op).target?.id;
|
|
6
|
+
if (targetId !== "sqlite") throw new Error(`renderOps: expected sqlite op but got target.id="${String(targetId)}" for op.id="${op.id}" (factoryName="${callFactoryName}"). An OpFactoryCall produced an op for a different target on the sqlite planner path; check the call's target binding.`);
|
|
7
|
+
}
|
|
8
|
+
function renderOps(calls, lowerer) {
|
|
9
|
+
return calls.map((c) => {
|
|
10
|
+
const opOrPromise = blindCast(c).toOp(lowerer);
|
|
11
|
+
if (isThenable(opOrPromise)) return opOrPromise.then((op) => {
|
|
12
|
+
assertSqliteOp(op, c.factoryName);
|
|
13
|
+
return op;
|
|
14
|
+
});
|
|
15
|
+
assertSqliteOp(opOrPromise, c.factoryName);
|
|
16
|
+
return opOrPromise;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { renderOps as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=render-ops-BDW2tUeR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-ops-BDW2tUeR.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanOperation,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { isThenable } from '@prisma-next/utils/promise';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nfunction assertSqliteOp(op: MigrationPlanOperation, callFactoryName: string): asserts op is Op {\n const targetId = blindCast<\n { target?: { id?: string } },\n 'op.target is present on concrete SqlMigrationPlanOperation but absent on the framework MigrationPlanOperation base'\n >(op).target?.id;\n if (targetId !== 'sqlite') {\n throw new Error(\n `renderOps: expected sqlite op but got target.id=\"${String(targetId)}\" for op.id=\"${op.id}\" (factoryName=\"${callFactoryName}\"). An OpFactoryCall produced an op for a different target on the sqlite planner path; check the call's target binding.`,\n );\n }\n}\n\nexport function renderOps(\n calls: readonly OpFactoryCall[],\n lowerer?: ExecuteRequestLowerer,\n): (Op | Promise<Op>)[] {\n return calls.map((c) => {\n const opOrPromise = blindCast<\n { toOp(lowerer?: ExecuteRequestLowerer): Op | Promise<Op> },\n 'SQLite OpFactoryCall.toOp accepts an optional ExecuteRequestLowerer; the framework interface omits it because not all targets need a lowerer — the SQLite target overrides with this extended signature'\n >(c).toOp(lowerer);\n if (isThenable(opOrPromise)) {\n return opOrPromise.then((op) => {\n assertSqliteOp(op, c.factoryName);\n return op;\n });\n }\n assertSqliteOp(opOrPromise, c.factoryName);\n return opOrPromise;\n });\n}\n"],"mappings":";;;AAYA,SAAS,eAAe,IAA4B,iBAA2C;CAC7F,MAAM,WAAW,UAGf,EAAE,CAAC,CAAC,QAAQ;CACd,IAAI,aAAa,UACf,MAAM,IAAI,MACR,oDAAoD,OAAO,QAAQ,EAAE,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,wHAC9H;AAEJ;AAEA,SAAgB,UACd,OACA,SACsB;CACtB,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,cAAc,UAGlB,CAAC,CAAC,CAAC,KAAK,OAAO;EACjB,IAAI,WAAW,WAAW,GACxB,OAAO,YAAY,MAAM,OAAO;GAC9B,eAAe,IAAI,EAAE,WAAW;GAChC,OAAO;EACT,CAAC;EAEH,eAAe,aAAa,EAAE,WAAW;EACzC,OAAO;CACT,CAAC;AACH"}
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as SqlitePlanTargetDetails } from "./planner-target-details-xR6UfIcz.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
4
5
|
|
|
5
6
|
//#region src/core/migrations/render-ops.d.ts
|
|
6
7
|
type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
|
|
7
|
-
declare function renderOps(calls: readonly OpFactoryCall[]): Op[];
|
|
8
|
+
declare function renderOps(calls: readonly OpFactoryCall[], lowerer?: ExecuteRequestLowerer): (Op | Promise<Op>)[];
|
|
8
9
|
//#endregion
|
|
9
10
|
export { renderOps };
|
|
10
11
|
//# sourceMappingURL=render-ops.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;;KAUK,EAAA,GAAK,yBAAyB,CAAC,uBAAA;AAAA,iBAcpB,SAAA,CACd,KAAA,WAAgB,aAAA,IAChB,OAAA,GAAU,qBAAA,IACR,EAAA,GAAK,OAAA,CAAQ,EAAA"}
|