@prisma-next/target-sqlite 0.12.0-dev.2 → 0.12.0-dev.21

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 (70) hide show
  1. package/dist/{codec-ids-C4UfWqAE.d.mts → codec-ids-yG2RRHnw.d.mts} +1 -1
  2. package/dist/{codec-ids-C4UfWqAE.d.mts.map → codec-ids-yG2RRHnw.d.mts.map} +1 -1
  3. package/dist/codec-ids.d.mts +1 -1
  4. package/dist/{codec-types-B2ci-b_W.d.mts → codec-types-CM7OkQLM.d.mts} +2 -2
  5. package/dist/{codec-types-B2ci-b_W.d.mts.map → codec-types-CM7OkQLM.d.mts.map} +1 -1
  6. package/dist/codec-types.d.mts +2 -2
  7. package/dist/{codecs-DqDWNIKq.d.mts → codecs-t6YnHZkK.d.mts} +2 -2
  8. package/dist/{codecs-DqDWNIKq.d.mts.map → codecs-t6YnHZkK.d.mts.map} +1 -1
  9. package/dist/codecs.d.mts +1 -1
  10. package/dist/contract-free.d.mts +27 -0
  11. package/dist/contract-free.d.mts.map +1 -0
  12. package/dist/contract-free.mjs +80 -0
  13. package/dist/contract-free.mjs.map +1 -0
  14. package/dist/control.d.mts +1 -1
  15. package/dist/control.d.mts.map +1 -1
  16. package/dist/control.mjs +37 -89
  17. package/dist/control.mjs.map +1 -1
  18. package/dist/ddl.d.mts +2 -0
  19. package/dist/ddl.mjs +2 -0
  20. package/dist/{descriptor-meta-DIbCXU65.mjs → descriptor-meta-rKforwQA.mjs} +3 -1
  21. package/dist/descriptor-meta-rKforwQA.mjs.map +1 -0
  22. package/dist/migration.d.mts +2 -2
  23. package/dist/nodes-09ul6DNV.mjs +28 -0
  24. package/dist/nodes-09ul6DNV.mjs.map +1 -0
  25. package/dist/nodes-D8LGV4Yk.d.mts +27 -0
  26. package/dist/nodes-D8LGV4Yk.d.mts.map +1 -0
  27. package/dist/op-factory-call.d.mts +2 -2
  28. package/dist/pack.d.mts +2 -1
  29. package/dist/pack.d.mts.map +1 -1
  30. package/dist/pack.mjs +1 -1
  31. package/dist/{planner-BBvwGy0f.mjs → planner-Cygvz9Wp.mjs} +3 -3
  32. package/dist/{planner-BBvwGy0f.mjs.map → planner-Cygvz9Wp.mjs.map} +1 -1
  33. package/dist/{planner-produced-sqlite-migration-D4FSvPE4.d.mts → planner-produced-sqlite-migration-BwFkd0br.d.mts} +3 -3
  34. package/dist/{planner-produced-sqlite-migration-D4FSvPE4.d.mts.map → planner-produced-sqlite-migration-BwFkd0br.d.mts.map} +1 -1
  35. package/dist/planner-produced-sqlite-migration.d.mts +1 -1
  36. package/dist/{planner-target-details-B-VJkUsu.d.mts → planner-target-details-RVPqF2ug.d.mts} +1 -1
  37. package/dist/{planner-target-details-B-VJkUsu.d.mts.map → planner-target-details-RVPqF2ug.d.mts.map} +1 -1
  38. package/dist/planner-target-details.d.mts +1 -1
  39. package/dist/planner.d.mts +2 -2
  40. package/dist/planner.mjs +1 -1
  41. package/dist/render-ops.d.mts +1 -1
  42. package/dist/runtime.d.mts +17 -1
  43. package/dist/runtime.d.mts.map +1 -1
  44. package/dist/runtime.mjs +2 -1
  45. package/dist/runtime.mjs.map +1 -1
  46. package/dist/{shared-DDOJntxk.d.mts → shared-Bw5G0I-c.d.mts} +2 -2
  47. package/dist/{shared-DDOJntxk.d.mts.map → shared-Bw5G0I-c.d.mts.map} +1 -1
  48. package/dist/sqlite-contract-serializer-Hy7WQPea.mjs +100 -0
  49. package/dist/sqlite-contract-serializer-Hy7WQPea.mjs.map +1 -0
  50. package/dist/{sqlite-migration-Feio34n3.d.mts → sqlite-migration-D-O3Glz1.d.mts} +2 -2
  51. package/dist/{sqlite-migration-Feio34n3.d.mts.map → sqlite-migration-D-O3Glz1.d.mts.map} +1 -1
  52. package/dist/{statement-builders-BiRmeyJM.mjs → statement-builders-D1Q_i4sb.mjs} +14 -2
  53. package/dist/statement-builders-D1Q_i4sb.mjs.map +1 -0
  54. package/dist/statement-builders.d.mts +3 -0
  55. package/dist/statement-builders.d.mts.map +1 -1
  56. package/dist/statement-builders.mjs +1 -1
  57. package/package.json +20 -18
  58. package/src/contract-free/control-bootstrap.ts +54 -0
  59. package/src/contract-free/ddl.ts +21 -0
  60. package/src/core/ddl/nodes.ts +41 -0
  61. package/src/core/descriptor-meta.ts +2 -0
  62. package/src/core/migrations/runner.ts +53 -25
  63. package/src/core/migrations/statement-builders.ts +16 -1
  64. package/src/core/sqlite-contract-serializer.ts +38 -9
  65. package/src/core/sqlite-unbound-database.ts +30 -0
  66. package/src/exports/contract-free.ts +5 -0
  67. package/src/exports/ddl.ts +6 -0
  68. package/src/exports/runtime.ts +1 -0
  69. package/dist/descriptor-meta-DIbCXU65.mjs.map +0 -1
  70. package/dist/statement-builders-BiRmeyJM.mjs.map +0 -1
@@ -10,4 +10,4 @@ declare const SQLITE_JSON_CODEC_ID: "sqlite/json@1";
10
10
  declare const SQLITE_BIGINT_CODEC_ID: "sqlite/bigint@1";
11
11
  //#endregion
12
12
  export { SQLITE_JSON_CODEC_ID as a, SQL_CHAR_CODEC_ID as c, SQL_VARCHAR_CODEC_ID as d, SQLITE_INTEGER_CODEC_ID as i, SQL_FLOAT_CODEC_ID as l, SQLITE_BLOB_CODEC_ID as n, SQLITE_REAL_CODEC_ID as o, SQLITE_DATETIME_CODEC_ID as r, SQLITE_TEXT_CODEC_ID as s, SQLITE_BIGINT_CODEC_ID as t, SQL_INT_CODEC_ID as u };
13
- //# sourceMappingURL=codec-ids-C4UfWqAE.d.mts.map
13
+ //# sourceMappingURL=codec-ids-yG2RRHnw.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-ids-C4UfWqAE.d.mts","names":[],"sources":["../src/core/codec-ids.ts"],"mappings":";;;cAMa,oBAAA;AAAA,cACA,uBAAA;AAAA,cACA,oBAAA;AAAA,cACA,oBAAA;AAAA,cACA,wBAAA;AAAA,cACA,oBAAA;AAAA,cACA,sBAAA"}
1
+ {"version":3,"file":"codec-ids-yG2RRHnw.d.mts","names":[],"sources":["../src/core/codec-ids.ts"],"mappings":";;;cAMa,oBAAA;AAAA,cACA,uBAAA;AAAA,cACA,oBAAA;AAAA,cACA,oBAAA;AAAA,cACA,wBAAA;AAAA,cACA,oBAAA;AAAA,cACA,sBAAA"}
@@ -1,2 +1,2 @@
1
- import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-C4UfWqAE.mjs";
1
+ import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-yG2RRHnw.mjs";
2
2
  export { SQLITE_BIGINT_CODEC_ID, SQLITE_BLOB_CODEC_ID, SQLITE_DATETIME_CODEC_ID, SQLITE_INTEGER_CODEC_ID, SQLITE_JSON_CODEC_ID, SQLITE_REAL_CODEC_ID, SQLITE_TEXT_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID };
@@ -1,4 +1,4 @@
1
- import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, i as SqliteDatetimeDescriptor, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, r as SqliteBlobDescriptor, s as SqliteRealDescriptor } from "./codecs-DqDWNIKq.mjs";
1
+ import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, i as SqliteDatetimeDescriptor, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, r as SqliteBlobDescriptor, s as SqliteRealDescriptor } from "./codecs-t6YnHZkK.mjs";
2
2
  import * as _$_prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
3
3
  import { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
4
4
 
@@ -20,4 +20,4 @@ type Resolve<T> = { readonly [K in keyof T]: { readonly [P in keyof T[K]]: T[K][
20
20
  type CodecTypes = Resolve<ExtractCodecTypes<typeof codecDescriptorMap>>;
21
21
  //#endregion
22
22
  export { CodecTypes as t };
23
- //# sourceMappingURL=codec-types-B2ci-b_W.d.mts.map
23
+ //# sourceMappingURL=codec-types-CM7OkQLM.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec-types-B2ci-b_W.d.mts","names":[],"sources":["../src/exports/codec-types.ts"],"mappings":";;;;;cAwBM,kBAAA;EAAA,eAYI,uCAAA,CAAA,iBAAA;EAAA;;;;;;;;;;;KAEL,OAAA,6BAAoC,CAAA,0BAA2B,CAAA,CAAE,CAAA,IAAK,CAAA,CAAE,CAAA,EAAG,CAAA;AAAA,KAEpE,UAAA,GAAa,OAAA,CAAQ,iBAAA,QAAyB,kBAAA"}
1
+ {"version":3,"file":"codec-types-CM7OkQLM.d.mts","names":[],"sources":["../src/exports/codec-types.ts"],"mappings":";;;;;cAwBM,kBAAA;EAAA,eAYI,uCAAA,CAAA,iBAAA;EAAA;;;;;;;;;;;KAEL,OAAA,6BAAoC,CAAA,0BAA2B,CAAA,CAAE,CAAA,IAAK,CAAA,CAAE,CAAA,EAAG,CAAA;AAAA,KAEpE,UAAA,GAAa,OAAA,CAAQ,iBAAA,QAAyB,kBAAA"}
@@ -1,3 +1,3 @@
1
- import { g as JsonValue } from "./codecs-DqDWNIKq.mjs";
2
- import { t as CodecTypes } from "./codec-types-B2ci-b_W.mjs";
1
+ import { g as JsonValue } from "./codecs-t6YnHZkK.mjs";
2
+ import { t as CodecTypes } from "./codec-types-CM7OkQLM.mjs";
3
3
  export { CodecTypes, JsonValue };
@@ -1,4 +1,4 @@
1
- import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-C4UfWqAE.mjs";
1
+ import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-yG2RRHnw.mjs";
2
2
  import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
3
3
  import { CodecCallContext, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
4
4
  import * as _$_standard_schema_spec0 from "@standard-schema/spec";
@@ -123,4 +123,4 @@ declare const sqliteBigintColumn: () => _$_prisma_next_framework_components_code
123
123
  declare const sqliteCodecRegistry: CodecDescriptorRegistry;
124
124
  //#endregion
125
125
  export { SqliteIntegerDescriptor as a, SqliteTextDescriptor as c, sqliteDatetimeColumn as d, sqliteIntegerColumn as f, JsonValue$1 as g, sqliteTextColumn as h, SqliteDatetimeDescriptor as i, sqliteBigintColumn as l, sqliteRealColumn as m, SqliteBigintDescriptor as n, SqliteJsonDescriptor as o, sqliteJsonColumn as p, SqliteBlobDescriptor as r, SqliteRealDescriptor as s, sqliteCodecRegistry as t, sqliteBlobColumn as u };
126
- //# sourceMappingURL=codecs-DqDWNIKq.d.mts.map
126
+ //# sourceMappingURL=codecs-t6YnHZkK.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codecs-DqDWNIKq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AK,oBAAA,KAAyB,eAAA;AAAA;AAAA,cAOxC,gBAAA,QAAgB,0CAAA,CAAA,UAAA,CAAA,eAAA;AAAA,cAMhB,iBAAA,SAA0B,SAAA,QAC9B,sBAAA;EAKD,MAAA,CAAO,KAAA,UAAe,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAG/C,MAAA,CAAO,IAAA,mBAAuB,IAAA,EAAM,gBAAA,GAAmB,OAAA;EAG7D,UAAA,CAAW,KAAA,WAAgB,SAAA;EAG3B,UAAA,CAAW,IAAA,EAAM,SAAA;AAAA;AAAA,cAQN,sBAAA,SAA+B,mBAAA;EAAA,SACxB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA,EAJgB,wBAAA,CAIJ,gBAAA;EACrB,OAAA,CAAA,IAAY,GAAA,EAAK,oBAAA,KAAyB,iBAAA;AAAA;AAAA,cAOxC,kBAAA,QAAkB,0CAAA,CAAA,UAAA,CAAA,iBAAA;;;;;;;;cCrTlB,mBAAA,EAAqB,uBACc"}
package/dist/codecs.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, d as sqliteDatetimeColumn, f as sqliteIntegerColumn, g as JsonValue, h as sqliteTextColumn, i as SqliteDatetimeDescriptor, l as sqliteBigintColumn, m as sqliteRealColumn, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, p as sqliteJsonColumn, r as SqliteBlobDescriptor, s as SqliteRealDescriptor, t as sqliteCodecRegistry, u as sqliteBlobColumn } from "./codecs-DqDWNIKq.mjs";
1
+ import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, d as sqliteDatetimeColumn, f as sqliteIntegerColumn, g as JsonValue, h as sqliteTextColumn, i as SqliteDatetimeDescriptor, l as sqliteBigintColumn, m as sqliteRealColumn, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, p as sqliteJsonColumn, r as SqliteBlobDescriptor, s as SqliteRealDescriptor, t as sqliteCodecRegistry, u as sqliteBlobColumn } from "./codecs-t6YnHZkK.mjs";
2
2
  export { JsonValue, SqliteBigintDescriptor, SqliteBlobDescriptor, SqliteDatetimeDescriptor, SqliteIntegerDescriptor, SqliteJsonDescriptor, SqliteRealDescriptor, SqliteTextDescriptor, sqliteBigintColumn, sqliteBlobColumn, sqliteCodecRegistry, sqliteDatetimeColumn, sqliteIntegerColumn, sqliteJsonColumn, sqliteRealColumn, sqliteTextColumn };
@@ -0,0 +1,27 @@
1
+ import { n as SqliteCreateTable } from "./nodes-D8LGV4Yk.mjs";
2
+ import { DdlColumn, DdlNode } from "@prisma-next/sql-relational-core/ast";
3
+
4
+ //#region src/contract-free/control-bootstrap.d.ts
5
+ declare function buildSignMarkerBootstrapQueries(): readonly DdlNode[];
6
+ declare function buildControlTableBootstrapQueries(): readonly DdlNode[];
7
+ //#endregion
8
+ //#region src/contract-free/ddl.d.ts
9
+ /**
10
+ * Build a SQLite `CREATE TABLE` query node.
11
+ *
12
+ * Precondition: identifiers (`table`, column names/types) are emitted to SQL
13
+ * verbatim — they are not quoted or escaped, so callers must pass pre-trusted
14
+ * values (e.g. fixed control-plane identifiers). String-literal default values,
15
+ * by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
16
+ * Identifier quoting for untrusted identifiers is added when the migration
17
+ * planner adopts this lowering path.
18
+ */
19
+ declare function createTable(options: {
20
+ readonly table: string;
21
+ readonly schema?: string;
22
+ readonly ifNotExists?: boolean;
23
+ readonly columns: readonly DdlColumn[];
24
+ }): SqliteCreateTable;
25
+ //#endregion
26
+ export { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createTable };
27
+ //# sourceMappingURL=contract-free.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/control-bootstrap.ts","../src/contract-free/ddl.ts"],"mappings":";;;;iBA+CgB,+BAAA,CAAA,YAA4C,OAAO;AAAA,iBAInD,iCAAA,CAAA,YAA8C,OAAO;;;;;AAJrE;;;;AAAmE;AAInE;;;iBCtCgB,WAAA,CAAY,OAAA;EAAA,SACjB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA,WAAkB,SAAA;AAAA,IACzB,iBAAiB"}
@@ -0,0 +1,80 @@
1
+ import { t as SqliteCreateTable } from "./nodes-09ul6DNV.mjs";
2
+ import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
3
+ import { col, fn, lit } from "@prisma-next/sql-relational-core/contract-free";
4
+ //#region src/contract-free/ddl.ts
5
+ /**
6
+ * Build a SQLite `CREATE TABLE` query node.
7
+ *
8
+ * Precondition: identifiers (`table`, column names/types) are emitted to SQL
9
+ * verbatim — they are not quoted or escaped, so callers must pass pre-trusted
10
+ * values (e.g. fixed control-plane identifiers). String-literal default values,
11
+ * by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
12
+ * Identifier quoting for untrusted identifiers is added when the migration
13
+ * planner adopts this lowering path.
14
+ */
15
+ function createTable(options) {
16
+ return new SqliteCreateTable(options);
17
+ }
18
+ //#endregion
19
+ //#region src/contract-free/control-bootstrap.ts
20
+ const markerColumns = [
21
+ col("space", "TEXT", {
22
+ notNull: true,
23
+ primaryKey: true,
24
+ default: lit(APP_SPACE_ID)
25
+ }),
26
+ col("core_hash", "TEXT", { notNull: true }),
27
+ col("profile_hash", "TEXT", { notNull: true }),
28
+ col("contract_json", "TEXT"),
29
+ col("canonical_version", "INTEGER"),
30
+ col("updated_at", "TEXT", {
31
+ notNull: true,
32
+ default: fn("datetime('now')")
33
+ }),
34
+ col("app_tag", "TEXT"),
35
+ col("meta", "TEXT", {
36
+ notNull: true,
37
+ default: lit("{}")
38
+ }),
39
+ col("invariants", "TEXT", {
40
+ notNull: true,
41
+ default: lit("[]")
42
+ })
43
+ ];
44
+ const ledgerColumns = [
45
+ col("id", "INTEGER PRIMARY KEY AUTOINCREMENT"),
46
+ col("created_at", "TEXT", {
47
+ notNull: true,
48
+ default: fn("strftime('%Y-%m-%dT%H:%M:%fZ','now')")
49
+ }),
50
+ col("space", "TEXT", { notNull: true }),
51
+ col("migration_name", "TEXT", { notNull: true }),
52
+ col("migration_hash", "TEXT", { notNull: true }),
53
+ col("origin_core_hash", "TEXT"),
54
+ col("origin_profile_hash", "TEXT"),
55
+ col("destination_core_hash", "TEXT", { notNull: true }),
56
+ col("destination_profile_hash", "TEXT"),
57
+ col("contract_json_before", "TEXT"),
58
+ col("contract_json_after", "TEXT"),
59
+ col("operations", "TEXT", { notNull: true })
60
+ ];
61
+ const markerTable = createTable({
62
+ table: "_prisma_marker",
63
+ ifNotExists: true,
64
+ columns: markerColumns
65
+ });
66
+ const ledgerTable = createTable({
67
+ table: "_prisma_ledger",
68
+ ifNotExists: true,
69
+ columns: ledgerColumns
70
+ });
71
+ function buildSignMarkerBootstrapQueries() {
72
+ return [markerTable];
73
+ }
74
+ function buildControlTableBootstrapQueries() {
75
+ return [markerTable, ledgerTable];
76
+ }
77
+ //#endregion
78
+ export { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createTable };
79
+
80
+ //# sourceMappingURL=contract-free.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-free.mjs","names":[],"sources":["../src/contract-free/ddl.ts","../src/contract-free/control-bootstrap.ts"],"sourcesContent":["import type { DdlColumn } from '@prisma-next/sql-relational-core/ast';\nimport { SqliteCreateTable } from '../core/ddl/nodes';\n\n/**\n * Build a SQLite `CREATE TABLE` query node.\n *\n * Precondition: identifiers (`table`, column names/types) are emitted to SQL\n * verbatim — they are not quoted or escaped, so callers must pass pre-trusted\n * values (e.g. fixed control-plane identifiers). String-literal default values,\n * by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.\n * Identifier quoting for untrusted identifiers is added when the migration\n * planner adopts this lowering path.\n */\nexport function createTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n}): SqliteCreateTable {\n return new SqliteCreateTable(options);\n}\n","import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport type { DdlNode } from '@prisma-next/sql-relational-core/ast';\nimport { col, fn, lit } from '@prisma-next/sql-relational-core/contract-free';\nimport { createTable } from './ddl';\n\nconst markerColumns = [\n col('space', 'TEXT', { notNull: true, primaryKey: true, default: lit(APP_SPACE_ID) }),\n col('core_hash', 'TEXT', { notNull: true }),\n col('profile_hash', 'TEXT', { notNull: true }),\n col('contract_json', 'TEXT'),\n col('canonical_version', 'INTEGER'),\n col('updated_at', 'TEXT', { notNull: true, default: fn(\"datetime('now')\") }),\n col('app_tag', 'TEXT'),\n col('meta', 'TEXT', { notNull: true, default: lit('{}') }),\n col('invariants', 'TEXT', { notNull: true, default: lit('[]') }),\n] as const;\n\nconst ledgerColumns = [\n col('id', 'INTEGER PRIMARY KEY AUTOINCREMENT'),\n col('created_at', 'TEXT', {\n notNull: true,\n default: fn(\"strftime('%Y-%m-%dT%H:%M:%fZ','now')\"),\n }),\n col('space', 'TEXT', { notNull: true }),\n col('migration_name', 'TEXT', { notNull: true }),\n col('migration_hash', 'TEXT', { notNull: true }),\n col('origin_core_hash', 'TEXT'),\n col('origin_profile_hash', 'TEXT'),\n col('destination_core_hash', 'TEXT', { notNull: true }),\n col('destination_profile_hash', 'TEXT'),\n col('contract_json_before', 'TEXT'),\n col('contract_json_after', 'TEXT'),\n col('operations', 'TEXT', { notNull: true }),\n] as const;\n\nconst markerTable = createTable({\n table: '_prisma_marker',\n ifNotExists: true,\n columns: markerColumns,\n});\n\nconst ledgerTable = createTable({\n table: '_prisma_ledger',\n ifNotExists: true,\n columns: ledgerColumns,\n});\n\nexport function buildSignMarkerBootstrapQueries(): readonly DdlNode[] {\n return [markerTable];\n}\n\nexport function buildControlTableBootstrapQueries(): readonly DdlNode[] {\n return [markerTable, ledgerTable];\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,YAAY,SAKN;CACpB,OAAO,IAAI,kBAAkB,OAAO;AACtC;;;ACfA,MA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CAAwD;CACtE,OAAO,CAAC,aAAa,WAAW;AAClC"}
@@ -1,4 +1,4 @@
1
- import { t as SqlitePlanTargetDetails } from "./planner-target-details-B-VJkUsu.mjs";
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
2
2
  import { SqlControlTargetDescriptor } from "@prisma-next/family-sql/control";
3
3
  import { StorageTable } from "@prisma-next/sql-contract/types";
4
4
  import { NamespaceBase } from "@prisma-next/framework-components/ir";
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-target.ts","../src/core/sqlite-unbound-database.ts"],"mappings":";;;;;;cAkCM,6BAAA,EAA+B,0BAA0B,WAAW,uBAAA;;;;;;;AAnBS;;;;AAmBc;;;;ACVjG;;;;;cAAa,qBAAA,SAA8B,aAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;EAAA,SAEjB,IAAA;EAAA,SACA,EAAA;EAAA,SACA,MAAA,EAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,QAElC,WAAA,CAAA;EAMP,SAAA,CAAA;EAIA,YAAA,CAAa,SAAA;AAAA;;;;;;;;;;;iBAeC,qBAAA,CAAsB,EAAA,WAAa,qBAAqB"}
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-target.ts","../src/core/sqlite-unbound-database.ts"],"mappings":";;;;;;cAkCM,6BAAA,EAA+B,0BAA0B,WAAW,uBAAA;;;;;;;;;;;;;;;;;;;;cCoB7D,qBAAA,SAA8B,aAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;EAAA,SAEjB,IAAA;EAAA,SACA,EAAA;EAAA,SACA,MAAA,EAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,QAElC,WAAA,CAAA;EAMP,SAAA,CAAA;EAIA,YAAA,CAAa,SAAA;AAAA;;;;;;;;;;;iBAeC,qBAAA,CAAsB,EAAA,WAAa,qBAAqB"}
package/dist/control.mjs CHANGED
@@ -1,18 +1,18 @@
1
- import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-DIbCXU65.mjs";
1
+ import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-rKforwQA.mjs";
2
2
  import { t as parseSqliteDefault } from "./default-normalizer-CWKVYSxS.mjs";
3
3
  import { t as normalizeSqliteNativeType } from "./native-type-normalizer-HvkimyB8.mjs";
4
4
  import { d as renderDefaultLiteral } from "./tables-gB0XiFu8.mjs";
5
- import { n as createSqliteMigrationPlanner } from "./planner-BBvwGy0f.mjs";
6
- import { a as buildLedgerInsertStatement, c as ensureMarkerTableStatement, i as MARKER_TABLE_NAME, l as readMarkerStatement, o as buildWriteMarkerStatements, s as ensureLedgerTableStatement } from "./statement-builders-BiRmeyJM.mjs";
5
+ import { n as createSqliteMigrationPlanner } from "./planner-Cygvz9Wp.mjs";
6
+ import { a as buildLedgerInsertStatement, i as MARKER_TABLE_NAME, l as readMarkerStatement, o as buildWriteMarkerStatements } from "./statement-builders-D1Q_i4sb.mjs";
7
+ import { n as SqliteUnboundDatabase, r as sqliteCreateNamespace, t as SqliteContractSerializer } from "./sqlite-contract-serializer-Hy7WQPea.mjs";
7
8
  import { contractToSchemaIR, runnerFailure, runnerSuccess } from "@prisma-next/family-sql/control";
8
9
  import { SqlStorage } from "@prisma-next/sql-contract/types";
9
10
  import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
10
11
  import { notOk, ok, okVoid } from "@prisma-next/utils/result";
11
12
  import { ifDefined } from "@prisma-next/utils/defined";
12
- import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
13
13
  import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
14
14
  import { parseContractMarkerRow } from "@prisma-next/family-sql/verify";
15
- import { SqlContractSerializerBase, SqlSchemaVerifierBase } from "@prisma-next/family-sql/ir";
15
+ import { SqlSchemaVerifierBase } from "@prisma-next/family-sql/ir";
16
16
  //#region src/core/migrations/runner.ts
17
17
  function createSqliteMigrationRunner(family) {
18
18
  return new SqliteMigrationRunner(family);
@@ -36,7 +36,7 @@ var SqliteMigrationRunner = class {
36
36
  if (!destinationCheck.ok) return destinationCheck;
37
37
  const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);
38
38
  if (!policyCheck.ok) return policyCheck;
39
- const ensureResult = await this.ensureControlTables(driver);
39
+ const ensureResult = await this.ensureControlTables(driver, options.destinationContract);
40
40
  if (!ensureResult.ok) return ensureResult;
41
41
  const existingMarker = await this.readMarker(driver, space);
42
42
  const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);
@@ -80,7 +80,7 @@ var SqliteMigrationRunner = class {
80
80
  const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));
81
81
  if (!(isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting)) {
82
82
  await this.upsertMarker(driver, options, existingMarker, space);
83
- await this.recordLedgerEntry(driver, options, existingMarker, executedOperations);
83
+ await this.recordLedgerEntries(driver, options, existingMarker, executedOperations);
84
84
  }
85
85
  return runnerSuccess({
86
86
  operationsPlanned: options.plan.operations.length,
@@ -181,11 +181,11 @@ var SqliteMigrationRunner = class {
181
181
  executedOperations
182
182
  });
183
183
  }
184
- async ensureControlTables(driver) {
184
+ async ensureControlTables(driver, contract) {
185
185
  const legacyDetection = await this.detectLegacyMarkerShape(driver);
186
186
  if (!legacyDetection.ok) return legacyDetection;
187
- await this.executeStatement(driver, ensureMarkerTableStatement);
188
- await this.executeStatement(driver, ensureLedgerTableStatement);
187
+ const lowererContext = { contract };
188
+ for (const query of this.family.bootstrapControlTableQueries()) await this.executeStatement(driver, this.family.lowerAst(query, lowererContext));
189
189
  return okVoid();
190
190
  }
191
191
  async detectLegacyMarkerShape(driver) {
@@ -340,17 +340,33 @@ var SqliteMigrationRunner = class {
340
340
  const statement = existingMarker ? writeStatements.update : writeStatements.insert;
341
341
  await this.executeStatement(driver, statement);
342
342
  }
343
- async recordLedgerEntry(driver, options, existingMarker, executedOperations) {
344
- const ledgerStatement = buildLedgerInsertStatement({
345
- originStorageHash: existingMarker?.storageHash ?? null,
346
- originProfileHash: existingMarker?.profileHash ?? null,
347
- destinationStorageHash: options.plan.destination.storageHash,
348
- destinationProfileHash: options.plan.destination.profileHash ?? options.destinationContract.profileHash ?? options.plan.destination.storageHash,
349
- contractJsonBefore: existingMarker?.contractJson ?? null,
350
- contractJsonAfter: options.destinationContract,
351
- operations: executedOperations
352
- });
353
- await this.executeStatement(driver, ledgerStatement);
343
+ async recordLedgerEntries(driver, options, existingMarker, executedOperations) {
344
+ const plan = options.plan;
345
+ const space = plan.spaceId;
346
+ const destinationProfileHash = plan.destination.profileHash ?? options.destinationContract.profileHash ?? plan.destination.storageHash;
347
+ const edges = options.migrationEdges;
348
+ const totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);
349
+ if (totalEdgeOps !== plan.operations.length) throw new Error(`Ledger write: plan.operations length (${plan.operations.length}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`);
350
+ let offset = 0;
351
+ const lastIndex = edges.length - 1;
352
+ for (const [i, edge] of edges.entries()) {
353
+ const edgeOps = executedOperations.slice(offset, offset + edge.operationCount);
354
+ offset += edge.operationCount;
355
+ const isFirst = i === 0;
356
+ const isLast = i === lastIndex;
357
+ await this.executeStatement(driver, buildLedgerInsertStatement({
358
+ space,
359
+ migrationName: edge.dirName,
360
+ migrationHash: edge.migrationHash,
361
+ originStorageHash: edge.from === "" ? null : edge.from,
362
+ originProfileHash: isFirst && existingMarker?.storageHash === edge.from ? existingMarker.profileHash ?? null : null,
363
+ destinationStorageHash: edge.to,
364
+ destinationProfileHash: isLast && edge.to === plan.destination.storageHash ? destinationProfileHash : null,
365
+ contractJsonBefore: isFirst ? existingMarker?.contractJson ?? null : null,
366
+ contractJsonAfter: isLast ? options.destinationContract : null,
367
+ operations: edgeOps
368
+ }));
369
+ }
354
370
  }
355
371
  async beginExclusiveTransaction(driver) {
356
372
  await driver.query("BEGIN EXCLUSIVE");
@@ -370,24 +386,6 @@ var SqliteMigrationRunner = class {
370
386
  }
371
387
  };
372
388
  //#endregion
373
- //#region src/core/sqlite-contract-serializer.ts
374
- /**
375
- * SQLite target `ContractSerializer` concretion. Mirrors the Postgres
376
- * shape: inherits the full SQL-family deserialization pipeline. Today's
377
- * SQLite contract shape is the family-shared shape; no target-specific
378
- * polymorphic `storage.types` factories are registered yet.
379
- *
380
- * `serializeContract` falls through to the family-base default —
381
- * SQLite's contract is JSON-clean today. Once target-only fields land
382
- * (e.g. per-target derived storage fields) this is the home for
383
- * stripping them from the persisted envelope.
384
- */
385
- var SqliteContractSerializer = class extends SqlContractSerializerBase {
386
- constructor() {
387
- super(/* @__PURE__ */ new Map());
388
- }
389
- };
390
- //#endregion
391
389
  //#region src/core/sqlite-schema-verifier.ts
392
390
  /**
393
391
  * SQLite target `SchemaVerifier` concretion. Mirrors the Postgres
@@ -447,56 +445,6 @@ const sqliteControlTargetDescriptor = {
447
445
  }
448
446
  };
449
447
  //#endregion
450
- //#region src/core/sqlite-unbound-database.ts
451
- /**
452
- * SQLite target `Namespace` concretion. SQLite has no schema or
453
- * database-namespacing concept at the SQL level — there is exactly one
454
- * effective namespace per connection, so the target ships a single
455
- * singleton bound to the framework's `UNBOUND_NAMESPACE_ID` slot.
456
- *
457
- * Qualifier emission elides the prefix entirely: rendered DDL and
458
- * queries look unqualified (`CREATE TABLE "users" (...)`), matching
459
- * SQLite's native dialect. Call sites stay polymorphic — they ask the
460
- * namespace for its qualifier and consume the empty/unqualified result
461
- * the same way Postgres consumes a `"schema"` prefix.
462
- *
463
- * The SQLite PSL interpreter rejects every explicit `namespace { … }`
464
- * block with a diagnostic naming SQLite; only the implicit
465
- * `__unspecified__` AST bucket reaches the SQLite interpreter, which
466
- * lowers it to this singleton.
467
- */
468
- var SqliteUnboundDatabase = class SqliteUnboundDatabase extends NamespaceBase {
469
- static instance = new SqliteUnboundDatabase();
470
- kind = "database";
471
- id = UNBOUND_NAMESPACE_ID;
472
- tables;
473
- constructor() {
474
- super();
475
- this.tables = Object.freeze({});
476
- freezeNode(this);
477
- }
478
- qualifier() {
479
- return "";
480
- }
481
- qualifyTable(tableName) {
482
- return `"${tableName}"`;
483
- }
484
- };
485
- /**
486
- * Target-supplied `Namespace` factory the SQLite target plumbs through
487
- * `defineContract({ createNamespace })`. SQLite has only one
488
- * effective namespace slot — the framework `UNBOUND_NAMESPACE_ID`
489
- * sentinel — so the factory always returns the singleton and rejects
490
- * any other coordinate. The SQL family's defensive validation in
491
- * `defineContract` already rejects user-declared SQLite namespaces, so
492
- * this throw is a structural safety net rather than a user-facing
493
- * surface.
494
- */
495
- function sqliteCreateNamespace(id) {
496
- if (id === UNBOUND_NAMESPACE_ID) return SqliteUnboundDatabase.instance;
497
- throw new Error(`sqliteCreateNamespace: SQLite has no schema concept; the only valid namespace id is "${UNBOUND_NAMESPACE_ID}" (received "${id}").`);
498
- }
499
- //#endregion
500
448
  export { SqliteUnboundDatabase, sqliteControlTargetDescriptor as default, sqliteCreateNamespace };
501
449
 
502
450
  //# sourceMappingURL=control.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.mjs","names":[],"sources":["../src/core/migrations/runner.ts","../src/core/sqlite-contract-serializer.ts","../src/core/sqlite-schema-verifier.ts","../src/core/control-target.ts","../src/core/sqlite-unbound-database.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlControlFamilyInstance,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationRunner,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n SqlMigrationRunnerSuccessValue,\n} from '@prisma-next/family-sql/control';\nimport { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';\nimport type {\n ControlDriverInstance,\n MigrationRunnerResult,\n} from '@prisma-next/framework-components/control';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok, okVoid } from '@prisma-next/utils/result';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport {\n buildLedgerInsertStatement,\n buildWriteMarkerStatements,\n ensureLedgerTableStatement,\n ensureMarkerTableStatement,\n MARKER_TABLE_NAME,\n readMarkerStatement,\n type SqlStatement,\n} from './statement-builders';\n\nexport function createSqliteMigrationRunner(\n family: SqlControlFamilyInstance,\n): SqlMigrationRunner<SqlitePlanTargetDetails> {\n return new SqliteMigrationRunner(family);\n}\n\nclass SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {\n constructor(private readonly family: SqlControlFamilyInstance) {}\n\n /**\n * Apply the plan against an already-open connection without managing\n * the transaction lifecycle. The caller ({@link SqliteMigrationRunner.execute})\n * owns BEGIN/COMMIT/ROLLBACK and any connection-level setup (FK pragma\n * toggle, FK integrity check).\n */\n async executeOnConnection(\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<SqlMigrationRunnerResult> {\n const driver = options.driver;\n if (options.space !== undefined && options.space !== options.plan.spaceId) {\n throw new Error(\n `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`,\n );\n }\n const space = options.plan.spaceId;\n\n const destinationCheck = this.ensurePlanMatchesDestinationContract(\n options.plan.destination,\n options.destinationContract,\n );\n if (!destinationCheck.ok) return destinationCheck;\n\n const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);\n if (!policyCheck.ok) return policyCheck;\n\n const ensureResult = await this.ensureControlTables(driver);\n if (!ensureResult.ok) return ensureResult;\n const existingMarker = await this.readMarker(driver, space);\n\n const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n if (!markerCheck.ok) return markerCheck;\n\n const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n const isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;\n const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\n let operationsExecuted: number;\n let executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n\n if (skipOperations) {\n operationsExecuted = 0;\n executedOperations = [];\n } else {\n const applyResult = await this.applyPlan(driver, options);\n if (!applyResult.ok) return applyResult;\n operationsExecuted = applyResult.value.operationsExecuted;\n executedOperations = applyResult.value.executedOperations;\n }\n\n if (space === APP_SPACE_ID) {\n const schemaIR = await this.family.introspect({\n driver,\n contract: options.destinationContract,\n });\n\n const schemaVerifyResult = verifySqlSchema({\n contract: options.destinationContract,\n schema: schemaIR,\n strict: options.strictVerification ?? true,\n context: options.context ?? {},\n typeMetadataRegistry: this.family.typeMetadataRegistry,\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n if (!schemaVerifyResult.ok) {\n return runnerFailure('SCHEMA_VERIFY_FAILED', schemaVerifyResult.summary, {\n why: 'The resulting database schema does not satisfy the destination contract.',\n meta: { issues: schemaVerifyResult.schema.issues },\n });\n }\n }\n\n // Self-edge no-op detection: see Postgres runner for the rationale\n // (kept symmetric across both targets).\n const incomingInvariants = options.plan.providedInvariants;\n const existingInvariants = new Set(existingMarker?.invariants ?? []);\n const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));\n const isSelfEdgeNoOp = isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting;\n\n if (!isSelfEdgeNoOp) {\n await this.upsertMarker(driver, options, existingMarker, space);\n await this.recordLedgerEntry(driver, options, existingMarker, executedOperations);\n }\n\n return runnerSuccess({\n operationsPlanned: options.plan.operations.length,\n operationsExecuted,\n });\n }\n\n async execute(options: {\n readonly driver: ControlDriverInstance<'sql', string>;\n readonly perSpaceOptions: ReadonlyArray<\n SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>\n >;\n }): Promise<MigrationRunnerResult> {\n const driver = options.driver;\n const perSpaceOptions = options.perSpaceOptions;\n\n if (perSpaceOptions.length === 0) {\n return ok({ perSpaceResults: [] });\n }\n\n // FK pragma toggle and the FK integrity check both span the outer\n // transaction: PRAGMA foreign_keys is a no-op inside a transaction, so the\n // toggle has to wrap BEGIN/COMMIT.\n const fkWasEnabled = await this.readForeignKeysEnabled(driver);\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = OFF');\n }\n\n try {\n await this.beginExclusiveTransaction(driver);\n let committed = false;\n try {\n const perSpaceResults: Array<{\n space: string;\n value: SqlMigrationRunnerSuccessValue;\n }> = [];\n let lastProcessedSpace: string | undefined;\n for (const spaceOptions of perSpaceOptions) {\n const space = spaceOptions.space ?? spaceOptions.plan.spaceId;\n const result = await this.executeOnConnection({ ...spaceOptions, driver, space });\n if (!result.ok) {\n return notOk({ ...result.failure, failingSpace: space });\n }\n perSpaceResults.push({ space, value: result.value });\n lastProcessedSpace = space;\n }\n\n if (fkWasEnabled) {\n const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);\n if (!fkIntegrityCheck.ok) {\n // Post-loop integrity violations cannot be attributed to a\n // single per-space step (the cumulative effect of all\n // applied plans was needed to reveal the broken\n // reference). Surface the last successfully-applied space\n // so operators can investigate from the most recent\n // migration first.\n return notOk({\n ...fkIntegrityCheck.failure,\n failingSpace: lastProcessedSpace ?? APP_SPACE_ID,\n });\n }\n }\n\n await this.commitTransaction(driver);\n committed = true;\n return ok({ perSpaceResults });\n } finally {\n if (!committed) {\n await this.rollbackTransaction(driver);\n }\n }\n } finally {\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = ON');\n }\n }\n }\n\n private async readForeignKeysEnabled(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<boolean> {\n const result = await driver.query<{ foreign_keys: number }>('PRAGMA foreign_keys');\n const row = result.rows[0];\n return row?.foreign_keys === 1;\n }\n\n private async verifyForeignKeyIntegrity(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const result = await driver.query<Record<string, unknown>>('PRAGMA foreign_key_check');\n if (result.rows.length === 0) {\n return okVoid();\n }\n return runnerFailure(\n 'FOREIGN_KEY_VIOLATION',\n `Foreign key integrity check failed after migration: ${result.rows.length} violation(s).`,\n {\n why: 'PRAGMA foreign_key_check reported violations after applying recreate-table operations.',\n meta: { violations: result.rows },\n },\n );\n }\n\n private async applyPlan(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<\n Result<\n {\n readonly operationsExecuted: number;\n readonly executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n },\n SqlMigrationRunnerFailure\n >\n > {\n const checks = options.executionChecks;\n const runPrechecks = checks?.prechecks !== false;\n const runPostchecks = checks?.postchecks !== false;\n const runIdempotency = checks?.idempotencyChecks !== false;\n\n let operationsExecuted = 0;\n const executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> = [];\n\n for (const operation of options.plan.operations) {\n options.callbacks?.onOperationStart?.(operation);\n try {\n if (runPostchecks && runIdempotency) {\n const postcheckAlreadySatisfied = await this.expectationsAreSatisfied(\n driver,\n operation.postcheck,\n );\n if (postcheckAlreadySatisfied) {\n executedOperations.push(this.createSkipRecord(operation));\n continue;\n }\n }\n\n if (runPrechecks) {\n const precheckResult = await this.runExpectationSteps(\n driver,\n operation.precheck,\n operation,\n 'precheck',\n );\n if (!precheckResult.ok) {\n return precheckResult;\n }\n }\n\n const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n if (!executeResult.ok) {\n return executeResult;\n }\n\n if (runPostchecks) {\n const postcheckResult = await this.runExpectationSteps(\n driver,\n operation.postcheck,\n operation,\n 'postcheck',\n );\n if (!postcheckResult.ok) {\n return postcheckResult;\n }\n }\n\n executedOperations.push(operation);\n operationsExecuted += 1;\n } finally {\n options.callbacks?.onOperationComplete?.(operation);\n }\n }\n return ok({ operationsExecuted, executedOperations });\n }\n\n private async ensureControlTables(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n // Pre-1.0 zero-range guardrail: detect a pre-cleanup single-row\n // marker table (no `space` column) and surface a structured failure\n // rather than silently rebuilding the table into the per-space\n // shape. See `specs/framework-mechanism.spec.md § 2`.\n const legacyDetection = await this.detectLegacyMarkerShape(driver);\n if (!legacyDetection.ok) {\n return legacyDetection;\n }\n await this.executeStatement(driver, ensureMarkerTableStatement);\n await this.executeStatement(driver, ensureLedgerTableStatement);\n return okVoid();\n }\n\n private async detectLegacyMarkerShape(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const tableInfo = await driver.query<{ name: string }>(\n `PRAGMA table_info(\"${MARKER_TABLE_NAME}\")`,\n );\n if (tableInfo.rows.length === 0) {\n return okVoid();\n }\n const columns = new Set(tableInfo.rows.map((row) => row.name));\n if (columns.has('space')) {\n return okVoid();\n }\n return runnerFailure(\n 'LEGACY_MARKER_SHAPE',\n `Legacy marker-table shape detected on ${MARKER_TABLE_NAME} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${MARKER_TABLE_NAME}\\` and re-run \\`dbInit\\` to reinitialise from a clean baseline.`,\n {\n meta: {\n table: MARKER_TABLE_NAME,\n columns: [...columns].sort(),\n },\n },\n );\n }\n\n private async readMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n space: string,\n ): Promise<ContractMarkerRecord | null> {\n const stmt = readMarkerStatement(space);\n try {\n const result = await driver.query<ContractMarkerRow>(stmt.sql, stmt.params);\n const row = result.rows[0];\n if (!row) return null;\n // SQLite stores arrays as JSON-encoded TEXT (no native array type), so\n // the driver returns `invariants` as a string. Decode before delegating\n // to the shared row schema, which expects `string[]`.\n const invariants =\n typeof row.invariants === 'string'\n ? (JSON.parse(row.invariants) as unknown)\n : row.invariants;\n return parseContractMarkerRow({ ...row, invariants });\n } catch (error) {\n // Table might not exist yet\n if (error instanceof Error && error.message.includes('no such table')) {\n return null;\n }\n throw error;\n }\n }\n\n private async runExpectationSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n phase: 'precheck' | 'postcheck',\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n const code = phase === 'precheck' ? 'PRECHECK_FAILED' : 'POSTCHECK_FAILED';\n return runnerFailure(\n code,\n `Operation ${operation.id} failed during ${phase}: ${step.description}`,\n {\n meta: {\n operationId: operation.id,\n phase,\n stepDescription: step.description,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private async runExecuteSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n try {\n await driver.query(step.sql, step.params ?? []);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return runnerFailure(\n 'EXECUTION_FAILED',\n `Operation ${operation.id} failed during execution: ${step.description}`,\n {\n why: message,\n meta: {\n operationId: operation.id,\n stepDescription: step.description,\n sql: step.sql,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private stepResultIsTrue(rows: readonly Record<string, unknown>[]): boolean {\n if (!rows || rows.length === 0) {\n return false;\n }\n const firstRow = rows[0];\n const firstValue = firstRow ? Object.values(firstRow)[0] : undefined;\n if (typeof firstValue === 'number') {\n return firstValue !== 0;\n }\n if (typeof firstValue === 'boolean') {\n return firstValue;\n }\n if (typeof firstValue === 'string') {\n const lower = firstValue.toLowerCase();\n if (lower === 'true' || lower === '1') return true;\n if (lower === 'false' || lower === '0') return false;\n return firstValue.length > 0;\n }\n return Boolean(firstValue);\n }\n\n private async expectationsAreSatisfied(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n ): Promise<boolean> {\n if (steps.length === 0) {\n return false;\n }\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n return false;\n }\n }\n return true;\n }\n\n private createSkipRecord(\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): SqlMigrationPlanOperation<SqlitePlanTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...ifDefined('summary', operation.summary),\n operationClass: operation.operationClass,\n target: operation.target,\n precheck: Object.freeze([]),\n execute: Object.freeze([]),\n postcheck: Object.freeze([...operation.postcheck]),\n meta: Object.freeze({\n ...(operation.meta ?? {}),\n runner: Object.freeze({ skipped: true, reason: 'postcheck_pre_satisfied' }),\n }),\n });\n }\n\n private markerMatchesDestination(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): boolean {\n if (!marker) return false;\n if (marker.storageHash !== plan.destination.storageHash) return false;\n if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) {\n return false;\n }\n return true;\n }\n\n private enforcePolicyCompatibility(\n policy: MigrationOperationPolicy,\n operations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Result<void, SqlMigrationRunnerFailure> {\n const allowedClasses = new Set(policy.allowedOperationClasses);\n for (const operation of operations) {\n if (!allowedClasses.has(operation.operationClass)) {\n return runnerFailure(\n 'POLICY_VIOLATION',\n `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`,\n {\n why: `Policy only allows: ${policy.allowedOperationClasses.join(', ')}.`,\n meta: {\n operationId: operation.id,\n operationClass: operation.operationClass,\n allowedClasses: policy.allowedOperationClasses,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private ensureMarkerCompatibility(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): Result<void, SqlMigrationRunnerFailure> {\n const origin = plan.origin ?? null;\n if (!origin) {\n return okVoid();\n }\n if (!marker) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Missing contract marker: expected origin storage hash ${origin.storageHash}.`,\n { meta: { expectedOriginStorageHash: origin.storageHash } },\n );\n }\n if (marker.storageHash !== origin.storageHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`,\n {\n meta: {\n markerStorageHash: marker.storageHash,\n expectedOriginStorageHash: origin.storageHash,\n },\n },\n );\n }\n if (origin.profileHash && marker.profileHash !== origin.profileHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`,\n {\n meta: {\n markerProfileHash: marker.profileHash,\n expectedOriginProfileHash: origin.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private ensurePlanMatchesDestinationContract(\n destination: SqlMigrationPlanContractInfo,\n contract: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['destinationContract'],\n ): Result<void, SqlMigrationRunnerFailure> {\n if (destination.storageHash !== contract.storage.storageHash) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`,\n {\n meta: {\n planStorageHash: destination.storageHash,\n contractStorageHash: contract.storage.storageHash,\n },\n },\n );\n }\n if (\n destination.profileHash &&\n contract.profileHash &&\n destination.profileHash !== contract.profileHash\n ) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`,\n {\n meta: {\n planProfileHash: destination.profileHash,\n contractProfileHash: contract.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private async upsertMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n space: string,\n ): Promise<void> {\n // SQLite has no native array type, so we can't merge invariants in SQL\n // the way Postgres does. Merge client-side under the runner's\n // BEGIN EXCLUSIVE — sort + dedupe so the JSON-encoded value is stable.\n const merged = new Set<string>(existingMarker?.invariants ?? []);\n for (const inv of options.plan.providedInvariants) merged.add(inv);\n const invariants = Array.from(merged).sort();\n const writeStatements = buildWriteMarkerStatements({\n space,\n storageHash: options.plan.destination.storageHash,\n profileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJson: options.destinationContract,\n canonicalVersion: null,\n meta: {},\n invariants,\n });\n const statement = existingMarker ? writeStatements.update : writeStatements.insert;\n await this.executeStatement(driver, statement);\n }\n\n private async recordLedgerEntry(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Promise<void> {\n const ledgerStatement = buildLedgerInsertStatement({\n originStorageHash: existingMarker?.storageHash ?? null,\n originProfileHash: existingMarker?.profileHash ?? null,\n destinationStorageHash: options.plan.destination.storageHash,\n destinationProfileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJsonBefore: existingMarker?.contractJson ?? null,\n contractJsonAfter: options.destinationContract,\n operations: executedOperations,\n });\n await this.executeStatement(driver, ledgerStatement);\n }\n\n private async beginExclusiveTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('BEGIN EXCLUSIVE');\n }\n\n private async commitTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('COMMIT');\n }\n\n private async rollbackTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('ROLLBACK');\n }\n\n private async executeStatement(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n statement: SqlStatement,\n ): Promise<void> {\n if (statement.params.length > 0) {\n await driver.query(statement.sql, statement.params);\n return;\n }\n await driver.query(statement.sql);\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlContractSerializerBase } from '@prisma-next/family-sql/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\n\n/**\n * SQLite target `ContractSerializer` concretion. Mirrors the Postgres\n * shape: inherits the full SQL-family deserialization pipeline. Today's\n * SQLite contract shape is the family-shared shape; no target-specific\n * polymorphic `storage.types` factories are registered yet.\n *\n * `serializeContract` falls through to the family-base default —\n * SQLite's contract is JSON-clean today. Once target-only fields land\n * (e.g. per-target derived storage fields) this is the home for\n * stripping them from the persisted envelope.\n */\nexport class SqliteContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n super(new Map());\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlSchemaVerifierBase } from '@prisma-next/family-sql/ir';\nimport type { SchemaIssue, SchemaVerifyOptions } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * SQLite target `SchemaVerifier` concretion. Mirrors the Postgres\n * shape: hooks return the empty list pending the call-site migration\n * that routes the existing verifier behaviour through the SPI.\n */\nexport class SqliteSchemaVerifier extends SqlSchemaVerifierBase<Contract<SqlStorage>, SqlSchemaIR> {\n protected verifyCommonSqlSchema(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n\n protected verifyTargetExtensions(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n}\n","import type { ColumnDefault, Contract } from '@prisma-next/contract/types';\nimport type {\n SqlControlFamilyInstance,\n SqlControlTargetDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport type {\n ControlTargetInstance,\n MigrationPlanner,\n MigrationRunner,\n} from '@prisma-next/framework-components/control';\nimport { SqlStorage, type StorageColumn } from '@prisma-next/sql-contract/types';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { createSqliteMigrationPlanner } from './migrations/planner';\nimport { renderDefaultLiteral } from './migrations/planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './migrations/planner-target-details';\nimport { createSqliteMigrationRunner } from './migrations/runner';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\nimport { SqliteSchemaVerifier } from './sqlite-schema-verifier';\n\nfunction isSqlContract(contract: Contract | null): contract is Contract<SqlStorage> | null {\n return contract === null || contract.storage instanceof SqlStorage;\n}\n\nfunction sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\nconst sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails> =\n {\n ...sqliteTargetDescriptorMeta,\n contractSerializer: new SqliteContractSerializer(),\n schemaVerifier: new SqliteSchemaVerifier(),\n migrations: {\n createPlanner(_family: SqlControlFamilyInstance): MigrationPlanner<'sql', 'sqlite'> {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family) as MigrationRunner<'sql', 'sqlite'>;\n },\n contractToSchema(contract, _frameworkComponents) {\n // The framework SPI types `contract` as the generic\n // `Contract | null`. Any contract reaching the sqlite\n // target descriptor is SQL-family by construction (the\n // family contract resolver would have refused to bind a\n // sqlite target otherwise); the `isSqlContract` predicate\n // encodes that invariant at runtime + narrows the generic\n // to `Contract<SqlStorage>` without a blind cast.\n if (!isSqlContract(contract)) {\n throw new Error(\n 'sqliteControlTargetDescriptor.contractToSchema received a non-SQL contract; expected Contract<SqlStorage>',\n );\n }\n return contractToSchemaIR(contract, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n });\n },\n },\n create(): ControlTargetInstance<'sql', 'sqlite'> {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n createPlanner(_family: SqlControlFamilyInstance) {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family);\n },\n };\n\nexport default sqliteControlTargetDescriptor;\n","import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { StorageTable } from '@prisma-next/sql-contract/types';\n\n/**\n * SQLite target `Namespace` concretion. SQLite has no schema or\n * database-namespacing concept at the SQL level — there is exactly one\n * effective namespace per connection, so the target ships a single\n * singleton bound to the framework's `UNBOUND_NAMESPACE_ID` slot.\n *\n * Qualifier emission elides the prefix entirely: rendered DDL and\n * queries look unqualified (`CREATE TABLE \"users\" (...)`), matching\n * SQLite's native dialect. Call sites stay polymorphic — they ask the\n * namespace for its qualifier and consume the empty/unqualified result\n * the same way Postgres consumes a `\"schema\"` prefix.\n *\n * The SQLite PSL interpreter rejects every explicit `namespace { … }`\n * block with a diagnostic naming SQLite; only the implicit\n * `__unspecified__` AST bucket reaches the SQLite interpreter, which\n * lowers it to this singleton.\n */\nexport class SqliteUnboundDatabase extends NamespaceBase {\n static readonly instance: SqliteUnboundDatabase = new SqliteUnboundDatabase();\n\n readonly kind = 'database' as const;\n readonly id = UNBOUND_NAMESPACE_ID;\n readonly tables: Readonly<Record<string, StorageTable>>;\n\n private constructor() {\n super();\n this.tables = Object.freeze({});\n freezeNode(this);\n }\n\n qualifier(): string {\n return '';\n }\n\n qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n}\n\n/**\n * Target-supplied `Namespace` factory the SQLite target plumbs through\n * `defineContract({ createNamespace })`. SQLite has only one\n * effective namespace slot — the framework `UNBOUND_NAMESPACE_ID`\n * sentinel — so the factory always returns the singleton and rejects\n * any other coordinate. The SQL family's defensive validation in\n * `defineContract` already rejects user-declared SQLite namespaces, so\n * this throw is a structural safety net rather than a user-facing\n * surface.\n */\nexport function sqliteCreateNamespace(id: string): SqliteUnboundDatabase {\n if (id === UNBOUND_NAMESPACE_ID) {\n return SqliteUnboundDatabase.instance;\n }\n throw new Error(\n `sqliteCreateNamespace: SQLite has no schema concept; the only valid namespace id is \"${UNBOUND_NAMESPACE_ID}\" (received \"${id}\").`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAgB,4BACd,QAC6C;CAC7C,OAAO,IAAI,sBAAsB,MAAM;AACzC;AAEA,IAAM,wBAAN,MAAmF;CACpD;CAA7B,YAAY,QAAmD;EAAlC,KAAA,SAAA;CAAmC;;;;;;;CAQhE,MAAM,oBACJ,SACmC;EACnC,MAAM,SAAS,QAAQ;EACvB,IAAI,QAAQ,UAAU,KAAA,KAAa,QAAQ,UAAU,QAAQ,KAAK,SAChE,MAAM,IAAI,MACR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AAW,IAAI;CACjB;CAEA,YAAoB;EAClB,OAAO;CACT;CAEA,aAAa,WAA2B;EACtC,OAAO,IAAI,UAAU;CACvB;AACF;;;;;;;;;;;AAYA,SAAgB,sBAAsB,IAAmC;CACvE,IAAI,OAAO,sBACT,OAAO,sBAAsB;CAE/B,MAAM,IAAI,MACR,wFAAwF,qBAAqB,eAAe,GAAG,IACjI;AACF"}
1
+ {"version":3,"file":"control.mjs","names":[],"sources":["../src/core/migrations/runner.ts","../src/core/sqlite-schema-verifier.ts","../src/core/control-target.ts"],"sourcesContent":["import type { Contract, ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlControlFamilyInstance,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationRunner,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n SqlMigrationRunnerSuccessValue,\n} from '@prisma-next/family-sql/control';\nimport { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';\nimport type {\n ControlDriverInstance,\n MigrationRunnerResult,\n} from '@prisma-next/framework-components/control';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok, okVoid } from '@prisma-next/utils/result';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport {\n buildLedgerInsertStatement,\n buildWriteMarkerStatements,\n MARKER_TABLE_NAME,\n readMarkerStatement,\n type SqlStatement,\n} from './statement-builders';\n\nexport function createSqliteMigrationRunner(\n family: SqlControlFamilyInstance,\n): SqlMigrationRunner<SqlitePlanTargetDetails> {\n return new SqliteMigrationRunner(family);\n}\n\nclass SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {\n constructor(private readonly family: SqlControlFamilyInstance) {}\n\n /**\n * Apply the plan against an already-open connection without managing\n * the transaction lifecycle. The caller ({@link SqliteMigrationRunner.execute})\n * owns BEGIN/COMMIT/ROLLBACK and any connection-level setup (FK pragma\n * toggle, FK integrity check).\n */\n async executeOnConnection(\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<SqlMigrationRunnerResult> {\n const driver = options.driver;\n if (options.space !== undefined && options.space !== options.plan.spaceId) {\n throw new Error(\n `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`,\n );\n }\n const space = options.plan.spaceId;\n\n const destinationCheck = this.ensurePlanMatchesDestinationContract(\n options.plan.destination,\n options.destinationContract,\n );\n if (!destinationCheck.ok) return destinationCheck;\n\n const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);\n if (!policyCheck.ok) return policyCheck;\n\n const ensureResult = await this.ensureControlTables(driver, options.destinationContract);\n if (!ensureResult.ok) return ensureResult;\n const existingMarker = await this.readMarker(driver, space);\n\n const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n if (!markerCheck.ok) return markerCheck;\n\n const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n const isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;\n const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\n let operationsExecuted: number;\n let executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n\n if (skipOperations) {\n operationsExecuted = 0;\n executedOperations = [];\n } else {\n const applyResult = await this.applyPlan(driver, options);\n if (!applyResult.ok) return applyResult;\n operationsExecuted = applyResult.value.operationsExecuted;\n executedOperations = applyResult.value.executedOperations;\n }\n\n if (space === APP_SPACE_ID) {\n const schemaIR = await this.family.introspect({\n driver,\n contract: options.destinationContract,\n });\n\n const schemaVerifyResult = verifySqlSchema({\n contract: options.destinationContract,\n schema: schemaIR,\n strict: options.strictVerification ?? true,\n context: options.context ?? {},\n typeMetadataRegistry: this.family.typeMetadataRegistry,\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n if (!schemaVerifyResult.ok) {\n return runnerFailure('SCHEMA_VERIFY_FAILED', schemaVerifyResult.summary, {\n why: 'The resulting database schema does not satisfy the destination contract.',\n meta: { issues: schemaVerifyResult.schema.issues },\n });\n }\n }\n\n // Self-edge no-op detection: see Postgres runner for the rationale\n // (kept symmetric across both targets).\n const incomingInvariants = options.plan.providedInvariants;\n const existingInvariants = new Set(existingMarker?.invariants ?? []);\n const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));\n const isSelfEdgeNoOp = isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting;\n\n if (!isSelfEdgeNoOp) {\n await this.upsertMarker(driver, options, existingMarker, space);\n await this.recordLedgerEntries(driver, options, existingMarker, executedOperations);\n }\n\n return runnerSuccess({\n operationsPlanned: options.plan.operations.length,\n operationsExecuted,\n });\n }\n\n async execute(options: {\n readonly driver: ControlDriverInstance<'sql', string>;\n readonly perSpaceOptions: ReadonlyArray<\n SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>\n >;\n }): Promise<MigrationRunnerResult> {\n const driver = options.driver;\n const perSpaceOptions = options.perSpaceOptions;\n\n if (perSpaceOptions.length === 0) {\n return ok({ perSpaceResults: [] });\n }\n\n // FK pragma toggle and the FK integrity check both span the outer\n // transaction: PRAGMA foreign_keys is a no-op inside a transaction, so the\n // toggle has to wrap BEGIN/COMMIT.\n const fkWasEnabled = await this.readForeignKeysEnabled(driver);\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = OFF');\n }\n\n try {\n await this.beginExclusiveTransaction(driver);\n let committed = false;\n try {\n const perSpaceResults: Array<{\n space: string;\n value: SqlMigrationRunnerSuccessValue;\n }> = [];\n let lastProcessedSpace: string | undefined;\n for (const spaceOptions of perSpaceOptions) {\n const space = spaceOptions.space ?? spaceOptions.plan.spaceId;\n const result = await this.executeOnConnection({ ...spaceOptions, driver, space });\n if (!result.ok) {\n return notOk({ ...result.failure, failingSpace: space });\n }\n perSpaceResults.push({ space, value: result.value });\n lastProcessedSpace = space;\n }\n\n if (fkWasEnabled) {\n const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);\n if (!fkIntegrityCheck.ok) {\n // Post-loop integrity violations cannot be attributed to a\n // single per-space step (the cumulative effect of all\n // applied plans was needed to reveal the broken\n // reference). Surface the last successfully-applied space\n // so operators can investigate from the most recent\n // migration first.\n return notOk({\n ...fkIntegrityCheck.failure,\n failingSpace: lastProcessedSpace ?? APP_SPACE_ID,\n });\n }\n }\n\n await this.commitTransaction(driver);\n committed = true;\n return ok({ perSpaceResults });\n } finally {\n if (!committed) {\n await this.rollbackTransaction(driver);\n }\n }\n } finally {\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = ON');\n }\n }\n }\n\n private async readForeignKeysEnabled(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<boolean> {\n const result = await driver.query<{ foreign_keys: number }>('PRAGMA foreign_keys');\n const row = result.rows[0];\n return row?.foreign_keys === 1;\n }\n\n private async verifyForeignKeyIntegrity(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const result = await driver.query<Record<string, unknown>>('PRAGMA foreign_key_check');\n if (result.rows.length === 0) {\n return okVoid();\n }\n return runnerFailure(\n 'FOREIGN_KEY_VIOLATION',\n `Foreign key integrity check failed after migration: ${result.rows.length} violation(s).`,\n {\n why: 'PRAGMA foreign_key_check reported violations after applying recreate-table operations.',\n meta: { violations: result.rows },\n },\n );\n }\n\n private async applyPlan(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<\n Result<\n {\n readonly operationsExecuted: number;\n readonly executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n },\n SqlMigrationRunnerFailure\n >\n > {\n const checks = options.executionChecks;\n const runPrechecks = checks?.prechecks !== false;\n const runPostchecks = checks?.postchecks !== false;\n const runIdempotency = checks?.idempotencyChecks !== false;\n\n let operationsExecuted = 0;\n const executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> = [];\n\n for (const operation of options.plan.operations) {\n options.callbacks?.onOperationStart?.(operation);\n try {\n if (runPostchecks && runIdempotency) {\n const postcheckAlreadySatisfied = await this.expectationsAreSatisfied(\n driver,\n operation.postcheck,\n );\n if (postcheckAlreadySatisfied) {\n executedOperations.push(this.createSkipRecord(operation));\n continue;\n }\n }\n\n if (runPrechecks) {\n const precheckResult = await this.runExpectationSteps(\n driver,\n operation.precheck,\n operation,\n 'precheck',\n );\n if (!precheckResult.ok) {\n return precheckResult;\n }\n }\n\n const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n if (!executeResult.ok) {\n return executeResult;\n }\n\n if (runPostchecks) {\n const postcheckResult = await this.runExpectationSteps(\n driver,\n operation.postcheck,\n operation,\n 'postcheck',\n );\n if (!postcheckResult.ok) {\n return postcheckResult;\n }\n }\n\n executedOperations.push(operation);\n operationsExecuted += 1;\n } finally {\n options.callbacks?.onOperationComplete?.(operation);\n }\n }\n return ok({ operationsExecuted, executedOperations });\n }\n\n private async ensureControlTables(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n contract: Contract<SqlStorage>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const legacyDetection = await this.detectLegacyMarkerShape(driver);\n if (!legacyDetection.ok) {\n return legacyDetection;\n }\n const lowererContext = { contract };\n for (const query of this.family.bootstrapControlTableQueries()) {\n await this.executeStatement(driver, this.family.lowerAst(query, lowererContext));\n }\n return okVoid();\n }\n\n private async detectLegacyMarkerShape(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const tableInfo = await driver.query<{ name: string }>(\n `PRAGMA table_info(\"${MARKER_TABLE_NAME}\")`,\n );\n if (tableInfo.rows.length === 0) {\n return okVoid();\n }\n const columns = new Set(tableInfo.rows.map((row) => row.name));\n if (columns.has('space')) {\n return okVoid();\n }\n return runnerFailure(\n 'LEGACY_MARKER_SHAPE',\n `Legacy marker-table shape detected on ${MARKER_TABLE_NAME} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${MARKER_TABLE_NAME}\\` and re-run \\`dbInit\\` to reinitialise from a clean baseline.`,\n {\n meta: {\n table: MARKER_TABLE_NAME,\n columns: [...columns].sort(),\n },\n },\n );\n }\n\n private async readMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n space: string,\n ): Promise<ContractMarkerRecord | null> {\n const stmt = readMarkerStatement(space);\n try {\n const result = await driver.query<ContractMarkerRow>(stmt.sql, stmt.params);\n const row = result.rows[0];\n if (!row) return null;\n // SQLite stores arrays as JSON-encoded TEXT (no native array type), so\n // the driver returns `invariants` as a string. Decode before delegating\n // to the shared row schema, which expects `string[]`.\n const invariants =\n typeof row.invariants === 'string'\n ? (JSON.parse(row.invariants) as unknown)\n : row.invariants;\n return parseContractMarkerRow({ ...row, invariants });\n } catch (error) {\n // Table might not exist yet\n if (error instanceof Error && error.message.includes('no such table')) {\n return null;\n }\n throw error;\n }\n }\n\n private async runExpectationSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n phase: 'precheck' | 'postcheck',\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n const code = phase === 'precheck' ? 'PRECHECK_FAILED' : 'POSTCHECK_FAILED';\n return runnerFailure(\n code,\n `Operation ${operation.id} failed during ${phase}: ${step.description}`,\n {\n meta: {\n operationId: operation.id,\n phase,\n stepDescription: step.description,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private async runExecuteSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n try {\n await driver.query(step.sql, step.params ?? []);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return runnerFailure(\n 'EXECUTION_FAILED',\n `Operation ${operation.id} failed during execution: ${step.description}`,\n {\n why: message,\n meta: {\n operationId: operation.id,\n stepDescription: step.description,\n sql: step.sql,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private stepResultIsTrue(rows: readonly Record<string, unknown>[]): boolean {\n if (!rows || rows.length === 0) {\n return false;\n }\n const firstRow = rows[0];\n const firstValue = firstRow ? Object.values(firstRow)[0] : undefined;\n if (typeof firstValue === 'number') {\n return firstValue !== 0;\n }\n if (typeof firstValue === 'boolean') {\n return firstValue;\n }\n if (typeof firstValue === 'string') {\n const lower = firstValue.toLowerCase();\n if (lower === 'true' || lower === '1') return true;\n if (lower === 'false' || lower === '0') return false;\n return firstValue.length > 0;\n }\n return Boolean(firstValue);\n }\n\n private async expectationsAreSatisfied(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n ): Promise<boolean> {\n if (steps.length === 0) {\n return false;\n }\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n return false;\n }\n }\n return true;\n }\n\n private createSkipRecord(\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): SqlMigrationPlanOperation<SqlitePlanTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...ifDefined('summary', operation.summary),\n operationClass: operation.operationClass,\n target: operation.target,\n precheck: Object.freeze([]),\n execute: Object.freeze([]),\n postcheck: Object.freeze([...operation.postcheck]),\n meta: Object.freeze({\n ...(operation.meta ?? {}),\n runner: Object.freeze({ skipped: true, reason: 'postcheck_pre_satisfied' }),\n }),\n });\n }\n\n private markerMatchesDestination(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): boolean {\n if (!marker) return false;\n if (marker.storageHash !== plan.destination.storageHash) return false;\n if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) {\n return false;\n }\n return true;\n }\n\n private enforcePolicyCompatibility(\n policy: MigrationOperationPolicy,\n operations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Result<void, SqlMigrationRunnerFailure> {\n const allowedClasses = new Set(policy.allowedOperationClasses);\n for (const operation of operations) {\n if (!allowedClasses.has(operation.operationClass)) {\n return runnerFailure(\n 'POLICY_VIOLATION',\n `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`,\n {\n why: `Policy only allows: ${policy.allowedOperationClasses.join(', ')}.`,\n meta: {\n operationId: operation.id,\n operationClass: operation.operationClass,\n allowedClasses: policy.allowedOperationClasses,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private ensureMarkerCompatibility(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): Result<void, SqlMigrationRunnerFailure> {\n const origin = plan.origin ?? null;\n if (!origin) {\n return okVoid();\n }\n if (!marker) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Missing contract marker: expected origin storage hash ${origin.storageHash}.`,\n { meta: { expectedOriginStorageHash: origin.storageHash } },\n );\n }\n if (marker.storageHash !== origin.storageHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`,\n {\n meta: {\n markerStorageHash: marker.storageHash,\n expectedOriginStorageHash: origin.storageHash,\n },\n },\n );\n }\n if (origin.profileHash && marker.profileHash !== origin.profileHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`,\n {\n meta: {\n markerProfileHash: marker.profileHash,\n expectedOriginProfileHash: origin.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private ensurePlanMatchesDestinationContract(\n destination: SqlMigrationPlanContractInfo,\n contract: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['destinationContract'],\n ): Result<void, SqlMigrationRunnerFailure> {\n if (destination.storageHash !== contract.storage.storageHash) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`,\n {\n meta: {\n planStorageHash: destination.storageHash,\n contractStorageHash: contract.storage.storageHash,\n },\n },\n );\n }\n if (\n destination.profileHash &&\n contract.profileHash &&\n destination.profileHash !== contract.profileHash\n ) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`,\n {\n meta: {\n planProfileHash: destination.profileHash,\n contractProfileHash: contract.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private async upsertMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n space: string,\n ): Promise<void> {\n // SQLite has no native array type, so we can't merge invariants in SQL\n // the way Postgres does. Merge client-side under the runner's\n // BEGIN EXCLUSIVE — sort + dedupe so the JSON-encoded value is stable.\n const merged = new Set<string>(existingMarker?.invariants ?? []);\n for (const inv of options.plan.providedInvariants) merged.add(inv);\n const invariants = Array.from(merged).sort();\n const writeStatements = buildWriteMarkerStatements({\n space,\n storageHash: options.plan.destination.storageHash,\n profileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJson: options.destinationContract,\n canonicalVersion: null,\n meta: {},\n invariants,\n });\n const statement = existingMarker ? writeStatements.update : writeStatements.insert;\n await this.executeStatement(driver, statement);\n }\n\n private async recordLedgerEntries(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Promise<void> {\n const plan = options.plan;\n const space = plan.spaceId;\n const destinationProfileHash =\n plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n plan.destination.storageHash;\n const edges = options.migrationEdges;\n const totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);\n if (totalEdgeOps !== plan.operations.length) {\n throw new Error(\n `Ledger write: plan.operations length (${plan.operations.length}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`,\n );\n }\n // The ledger records the operations as executed — idempotency-skipped ops\n // are substituted with skip records (empty `execute`) by `applyPlan`, so the\n // journal reflects what actually ran rather than the raw plan.\n let offset = 0;\n const lastIndex = edges.length - 1;\n for (const [i, edge] of edges.entries()) {\n const edgeOps = executedOperations.slice(offset, offset + edge.operationCount);\n offset += edge.operationCount;\n const isFirst = i === 0;\n const isLast = i === lastIndex;\n await this.executeStatement(\n driver,\n buildLedgerInsertStatement({\n space,\n migrationName: edge.dirName,\n migrationHash: edge.migrationHash,\n originStorageHash: edge.from === '' ? null : edge.from,\n originProfileHash:\n isFirst && existingMarker?.storageHash === edge.from\n ? (existingMarker.profileHash ?? null)\n : null,\n destinationStorageHash: edge.to,\n destinationProfileHash:\n isLast && edge.to === plan.destination.storageHash ? destinationProfileHash : null,\n contractJsonBefore: isFirst ? (existingMarker?.contractJson ?? null) : null,\n contractJsonAfter: isLast ? options.destinationContract : null,\n operations: edgeOps,\n }),\n );\n }\n }\n\n private async beginExclusiveTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('BEGIN EXCLUSIVE');\n }\n\n private async commitTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('COMMIT');\n }\n\n private async rollbackTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('ROLLBACK');\n }\n\n private async executeStatement(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n statement: SqlStatement,\n ): Promise<void> {\n if (statement.params.length > 0) {\n await driver.query(statement.sql, statement.params);\n return;\n }\n await driver.query(statement.sql);\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlSchemaVerifierBase } from '@prisma-next/family-sql/ir';\nimport type { SchemaIssue, SchemaVerifyOptions } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * SQLite target `SchemaVerifier` concretion. Mirrors the Postgres\n * shape: hooks return the empty list pending the call-site migration\n * that routes the existing verifier behaviour through the SPI.\n */\nexport class SqliteSchemaVerifier extends SqlSchemaVerifierBase<Contract<SqlStorage>, SqlSchemaIR> {\n protected verifyCommonSqlSchema(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n\n protected verifyTargetExtensions(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n}\n","import type { ColumnDefault, Contract } from '@prisma-next/contract/types';\nimport type {\n SqlControlFamilyInstance,\n SqlControlTargetDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport type {\n ControlTargetInstance,\n MigrationPlanner,\n MigrationRunner,\n} from '@prisma-next/framework-components/control';\nimport { SqlStorage, type StorageColumn } from '@prisma-next/sql-contract/types';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { createSqliteMigrationPlanner } from './migrations/planner';\nimport { renderDefaultLiteral } from './migrations/planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './migrations/planner-target-details';\nimport { createSqliteMigrationRunner } from './migrations/runner';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\nimport { SqliteSchemaVerifier } from './sqlite-schema-verifier';\n\nfunction isSqlContract(contract: Contract | null): contract is Contract<SqlStorage> | null {\n return contract === null || contract.storage instanceof SqlStorage;\n}\n\nfunction sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\nconst sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails> =\n {\n ...sqliteTargetDescriptorMeta,\n contractSerializer: new SqliteContractSerializer(),\n schemaVerifier: new SqliteSchemaVerifier(),\n migrations: {\n createPlanner(_family: SqlControlFamilyInstance): MigrationPlanner<'sql', 'sqlite'> {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family) as MigrationRunner<'sql', 'sqlite'>;\n },\n contractToSchema(contract, _frameworkComponents) {\n // The framework SPI types `contract` as the generic\n // `Contract | null`. Any contract reaching the sqlite\n // target descriptor is SQL-family by construction (the\n // family contract resolver would have refused to bind a\n // sqlite target otherwise); the `isSqlContract` predicate\n // encodes that invariant at runtime + narrows the generic\n // to `Contract<SqlStorage>` without a blind cast.\n if (!isSqlContract(contract)) {\n throw new Error(\n 'sqliteControlTargetDescriptor.contractToSchema received a non-SQL contract; expected Contract<SqlStorage>',\n );\n }\n return contractToSchemaIR(contract, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n });\n },\n },\n create(): ControlTargetInstance<'sql', 'sqlite'> {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n createPlanner(_family: SqlControlFamilyInstance) {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family);\n },\n };\n\nexport default sqliteControlTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAgB,4BACd,QAC6C;CAC7C,OAAO,IAAI,sBAAsB,MAAM;AACzC;AAEA,IAAM,wBAAN,MAAmF;CACpD;CAA7B,YAAY,QAAmD;EAAlC,KAAA,SAAA;CAAmC;;;;;;;CAQhE,MAAM,oBACJ,SACmC;EACnC,MAAM,SAAS,QAAQ;EACvB,IAAI,QAAQ,UAAU,KAAA,KAAa,QAAQ,UAAU,QAAQ,KAAK,SAChE,MAAM,IAAI,MACR,sCAAsC,QAAQ,MAAM,iCAAiC,QAAQ,KAAK,QAAQ,EAC5G;EAEF,MAAM,QAAQ,QAAQ,KAAK;EAE3B,MAAM,mBAAmB,KAAK,qCAC5B,QAAQ,KAAK,aACb,QAAQ,mBACV;EACA,IAAI,CAAC,iBAAiB,IAAI,OAAO;EAEjC,MAAM,cAAc,KAAK,2BAA2B,QAAQ,QAAQ,QAAQ,KAAK,UAAU;EAC3F,IAAI,CAAC,YAAY,IAAI,OAAO;EAE5B,MAAM,eAAe,MAAM,KAAK,oBAAoB,QAAQ,QAAQ,mBAAmB;EACvF,IAAI,CAAC,aAAa,IAAI,OAAO;EAC7B,MAAM,iBAA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