@prisma-next/target-sqlite 0.5.0-dev.9 → 0.6.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/codec-ids-CYwMu3-4.d.mts +13 -0
  2. package/dist/codec-ids-CYwMu3-4.d.mts.map +1 -0
  3. package/dist/codec-ids-CuUxYcd0.mjs +13 -0
  4. package/dist/codec-ids-CuUxYcd0.mjs.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -0
  6. package/dist/codec-ids.mjs +2 -0
  7. package/dist/codec-types-xLeyb_u4.d.mts +23 -0
  8. package/dist/codec-types-xLeyb_u4.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +3 -0
  10. package/dist/codec-types.mjs +2 -0
  11. package/dist/codecs-DEjc7dem.d.mts +203 -0
  12. package/dist/codecs-DEjc7dem.d.mts.map +1 -0
  13. package/dist/codecs-DVnHtVWW.mjs +220 -0
  14. package/dist/codecs-DVnHtVWW.mjs.map +1 -0
  15. package/dist/codecs.d.mts +2 -0
  16. package/dist/codecs.mjs +13 -0
  17. package/dist/codecs.mjs.map +1 -0
  18. package/dist/control.d.mts +4 -3
  19. package/dist/control.d.mts.map +1 -1
  20. package/dist/control.mjs +427 -5
  21. package/dist/control.mjs.map +1 -1
  22. package/dist/default-normalizer-3Fccw7yw.mjs +69 -0
  23. package/dist/default-normalizer-3Fccw7yw.mjs.map +1 -0
  24. package/dist/default-normalizer.d.mts +7 -0
  25. package/dist/default-normalizer.d.mts.map +1 -0
  26. package/dist/default-normalizer.mjs +2 -0
  27. package/dist/descriptor-meta-CE2Kbn9b.mjs +17 -0
  28. package/dist/descriptor-meta-CE2Kbn9b.mjs.map +1 -0
  29. package/dist/migration.d.mts +85 -0
  30. package/dist/migration.d.mts.map +1 -0
  31. package/dist/migration.mjs +49 -0
  32. package/dist/migration.mjs.map +1 -0
  33. package/dist/native-type-normalizer-BlN5XfD-.mjs +14 -0
  34. package/dist/native-type-normalizer-BlN5XfD-.mjs.map +1 -0
  35. package/dist/native-type-normalizer.d.mts +11 -0
  36. package/dist/native-type-normalizer.d.mts.map +1 -0
  37. package/dist/native-type-normalizer.mjs +2 -0
  38. package/dist/op-factory-call-DRKKURAO.mjs +279 -0
  39. package/dist/op-factory-call-DRKKURAO.mjs.map +1 -0
  40. package/dist/op-factory-call.d.mts +151 -0
  41. package/dist/op-factory-call.d.mts.map +1 -0
  42. package/dist/op-factory-call.mjs +2 -0
  43. package/dist/pack.d.mts +35 -1
  44. package/dist/pack.d.mts.map +1 -1
  45. package/dist/pack.mjs +2 -3
  46. package/dist/planner-A7dqS0u6.mjs +522 -0
  47. package/dist/planner-A7dqS0u6.mjs.map +1 -0
  48. package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts +29 -0
  49. package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts.map +1 -0
  50. package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs +110 -0
  51. package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs.map +1 -0
  52. package/dist/planner-produced-sqlite-migration.d.mts +2 -0
  53. package/dist/planner-produced-sqlite-migration.mjs +2 -0
  54. package/dist/planner-target-details-Bm71XPKb.mjs +15 -0
  55. package/dist/planner-target-details-Bm71XPKb.mjs.map +1 -0
  56. package/dist/planner-target-details-vhvZDWK1.d.mts +12 -0
  57. package/dist/planner-target-details-vhvZDWK1.d.mts.map +1 -0
  58. package/dist/planner-target-details.d.mts +2 -0
  59. package/dist/planner-target-details.mjs +2 -0
  60. package/dist/planner.d.mts +59 -0
  61. package/dist/planner.d.mts.map +1 -0
  62. package/dist/planner.mjs +2 -0
  63. package/dist/render-ops-CSRDT4YL.mjs +8 -0
  64. package/dist/render-ops-CSRDT4YL.mjs.map +1 -0
  65. package/dist/render-ops.d.mts +10 -0
  66. package/dist/render-ops.d.mts.map +1 -0
  67. package/dist/render-ops.mjs +2 -0
  68. package/dist/runtime.d.mts.map +1 -1
  69. package/dist/runtime.mjs +4 -8
  70. package/dist/runtime.mjs.map +1 -1
  71. package/dist/shared-qLsgTOZs.d.mts +69 -0
  72. package/dist/shared-qLsgTOZs.d.mts.map +1 -0
  73. package/dist/sql-utils-DhevMgef.mjs +35 -0
  74. package/dist/sql-utils-DhevMgef.mjs.map +1 -0
  75. package/dist/sql-utils.d.mts +22 -0
  76. package/dist/sql-utils.d.mts.map +1 -0
  77. package/dist/sql-utils.mjs +2 -0
  78. package/dist/sqlite-migration-BBJktVVw.mjs +16 -0
  79. package/dist/sqlite-migration-BBJktVVw.mjs.map +1 -0
  80. package/dist/sqlite-migration-DAb2NEX6.d.mts +17 -0
  81. package/dist/sqlite-migration-DAb2NEX6.d.mts.map +1 -0
  82. package/dist/statement-builders-Dne-LkAV.mjs +158 -0
  83. package/dist/statement-builders-Dne-LkAV.mjs.map +1 -0
  84. package/dist/statement-builders.d.mts +68 -0
  85. package/dist/statement-builders.d.mts.map +1 -0
  86. package/dist/statement-builders.mjs +2 -0
  87. package/dist/tables-D84zfPZI.mjs +403 -0
  88. package/dist/tables-D84zfPZI.mjs.map +1 -0
  89. package/package.json +33 -11
  90. package/src/core/authoring.ts +9 -0
  91. package/src/core/codec-helpers.ts +11 -0
  92. package/src/core/codec-ids.ts +13 -0
  93. package/src/core/codecs.ts +337 -0
  94. package/src/core/control-target.ts +53 -11
  95. package/src/core/default-normalizer.ts +92 -0
  96. package/src/core/descriptor-meta.ts +5 -1
  97. package/src/core/migrations/issue-planner.ts +586 -0
  98. package/src/core/migrations/op-factory-call.ts +369 -0
  99. package/src/core/migrations/operations/columns.ts +62 -0
  100. package/src/core/migrations/operations/data-transform.ts +51 -0
  101. package/src/core/migrations/operations/indexes.ts +52 -0
  102. package/src/core/migrations/operations/raw.ts +12 -0
  103. package/src/core/migrations/operations/shared.ts +120 -0
  104. package/src/core/migrations/operations/tables.ts +388 -0
  105. package/src/core/migrations/planner-ddl-builders.ts +142 -0
  106. package/src/core/migrations/planner-produced-sqlite-migration.ts +70 -0
  107. package/src/core/migrations/planner-strategies.ts +231 -0
  108. package/src/core/migrations/planner-target-details.ts +33 -0
  109. package/src/core/migrations/planner.ts +183 -0
  110. package/src/core/migrations/render-ops.ts +15 -0
  111. package/src/core/migrations/render-typescript.ts +91 -0
  112. package/src/core/migrations/runner.ts +724 -0
  113. package/src/core/migrations/sqlite-migration.ts +13 -0
  114. package/src/core/migrations/statement-builders.ts +212 -0
  115. package/src/core/native-type-normalizer.ts +9 -0
  116. package/src/core/registry.ts +11 -0
  117. package/src/core/runtime-target.ts +1 -3
  118. package/src/core/sql-utils.ts +47 -0
  119. package/src/exports/codec-ids.ts +13 -0
  120. package/src/exports/codec-types.ts +43 -0
  121. package/src/exports/codecs.ts +20 -0
  122. package/src/exports/control.ts +1 -0
  123. package/src/exports/default-normalizer.ts +1 -0
  124. package/src/exports/migration.ts +24 -0
  125. package/src/exports/native-type-normalizer.ts +1 -0
  126. package/src/exports/op-factory-call.ts +12 -0
  127. package/src/exports/planner-produced-sqlite-migration.ts +4 -0
  128. package/src/exports/planner-target-details.ts +2 -0
  129. package/src/exports/planner.ts +2 -0
  130. package/src/exports/render-ops.ts +1 -0
  131. package/src/exports/sql-utils.ts +1 -0
  132. package/src/exports/statement-builders.ts +12 -0
  133. package/dist/descriptor-meta-DbuuziYA.mjs +0 -14
  134. package/dist/descriptor-meta-DbuuziYA.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAA;EAAA,SAGhB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;AAAA,iBAOJ,eAAA,CAAgB,UAAA;AAAA,iBAchB,aAAA,CAAc,KAAA"}
@@ -0,0 +1,2 @@
1
+ import { n as escapeLiteral, r as quoteIdentifier, t as SqlEscapeError } from "./sql-utils-DhevMgef.mjs";
2
+ export { SqlEscapeError, escapeLiteral, quoteIdentifier };
@@ -0,0 +1,16 @@
1
+ import { Migration } from "@prisma-next/family-sql/migration";
2
+ //#region src/core/migrations/sqlite-migration.ts
3
+ /**
4
+ * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
5
+ * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the
6
+ * SQLite literal, so both user-authored migrations and renderer-generated
7
+ * scaffolds can extend `SqliteMigration` directly without redeclaring
8
+ * target-local identity.
9
+ */
10
+ var SqliteMigration = class extends Migration {
11
+ targetId = "sqlite";
12
+ };
13
+ //#endregion
14
+ export { SqliteMigration as t };
15
+
16
+ //# sourceMappingURL=sqlite-migration-BBJktVVw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-migration-BBJktVVw.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n */\nexport abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetails> {\n readonly targetId = 'sqlite' as const;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAsB,kBAAtB,cAA8CA,UAAsC;CAClF,WAAoB"}
@@ -0,0 +1,17 @@
1
+ import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
2
+ import { Migration } from "@prisma-next/family-sql/migration";
3
+
4
+ //#region src/core/migrations/sqlite-migration.d.ts
5
+ /**
6
+ * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
7
+ * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the
8
+ * SQLite literal, so both user-authored migrations and renderer-generated
9
+ * scaffolds can extend `SqliteMigration` directly without redeclaring
10
+ * target-local identity.
11
+ */
12
+ declare abstract class SqliteMigration extends Migration<SqlitePlanTargetDetails> {
13
+ readonly targetId: "sqlite";
14
+ }
15
+ //#endregion
16
+ export { SqliteMigration as t };
17
+ //# sourceMappingURL=sqlite-migration-DAb2NEX6.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-migration-DAb2NEX6.d.mts","names":[],"sources":["../src/core/migrations/sqlite-migration.ts"],"mappings":";;;;;;AAUA;;;;;uBAAsB,eAAA,SAAwB,SAAA,CAAa,uBAAA;EAAA,SAChD,QAAA;AAAA"}
@@ -0,0 +1,158 @@
1
+ import { APP_SPACE_ID as APP_SPACE_ID$1 } from "@prisma-next/framework-components/control";
2
+ //#region src/core/migrations/statement-builders.ts
3
+ const MARKER_TABLE_NAME = "_prisma_marker";
4
+ const LEDGER_TABLE_NAME = "_prisma_ledger";
5
+ /**
6
+ * Control tables the runner creates/manages. The planner must not drop these
7
+ * when reconciling "extra" tables against the contract.
8
+ */
9
+ const CONTROL_TABLE_NAMES = new Set([MARKER_TABLE_NAME, LEDGER_TABLE_NAME]);
10
+ /**
11
+ * Schema for `_prisma_marker`. The `space TEXT PRIMARY KEY` shape
12
+ * supports one row per loaded contract space (`'app'`,
13
+ * `'<extension-id>'`, …); brand-new databases create this shape
14
+ * directly. The migration runner detects pre-1.0 single-row markers
15
+ * (no `space` column) at boot and fails with a structured
16
+ * `LEGACY_MARKER_SHAPE` error rather than auto-rebuilding the table —
17
+ * see `specs/framework-mechanism.spec.md § 2`.
18
+ */
19
+ const ensureMarkerTableStatement = {
20
+ sql: `CREATE TABLE IF NOT EXISTS _prisma_marker (
21
+ space TEXT NOT NULL PRIMARY KEY DEFAULT '${APP_SPACE_ID$1}',
22
+ core_hash TEXT NOT NULL,
23
+ profile_hash TEXT NOT NULL,
24
+ contract_json TEXT,
25
+ canonical_version INTEGER,
26
+ updated_at TEXT NOT NULL DEFAULT (datetime('now')),
27
+ app_tag TEXT,
28
+ meta TEXT NOT NULL DEFAULT '{}',
29
+ invariants TEXT NOT NULL DEFAULT '[]'
30
+ )`,
31
+ params: []
32
+ };
33
+ const ensureLedgerTableStatement = {
34
+ sql: `CREATE TABLE IF NOT EXISTS _prisma_ledger (
35
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
36
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
37
+ origin_core_hash TEXT,
38
+ origin_profile_hash TEXT,
39
+ destination_core_hash TEXT NOT NULL,
40
+ destination_profile_hash TEXT,
41
+ contract_json_before TEXT,
42
+ contract_json_after TEXT,
43
+ operations TEXT NOT NULL
44
+ )`,
45
+ params: []
46
+ };
47
+ function readMarkerStatement(space) {
48
+ return {
49
+ sql: `SELECT
50
+ core_hash,
51
+ profile_hash,
52
+ contract_json,
53
+ canonical_version,
54
+ updated_at,
55
+ app_tag,
56
+ meta,
57
+ invariants
58
+ FROM _prisma_marker
59
+ WHERE space = ?`,
60
+ params: [space]
61
+ };
62
+ }
63
+ function buildWriteMarkerStatements(input) {
64
+ return {
65
+ insert: {
66
+ sql: `INSERT INTO _prisma_marker (
67
+ space,
68
+ core_hash,
69
+ profile_hash,
70
+ contract_json,
71
+ canonical_version,
72
+ updated_at,
73
+ app_tag,
74
+ meta,
75
+ invariants
76
+ ) VALUES (
77
+ ?,
78
+ ?,
79
+ ?,
80
+ ?,
81
+ ?,
82
+ datetime('now'),
83
+ ?,
84
+ ?,
85
+ ?
86
+ )`,
87
+ params: [
88
+ input.space,
89
+ input.storageHash,
90
+ input.profileHash,
91
+ jsonParam(input.contractJson),
92
+ input.canonicalVersion ?? null,
93
+ input.appTag ?? null,
94
+ jsonParam(input.meta ?? {}),
95
+ jsonParam(input.invariants)
96
+ ]
97
+ },
98
+ update: {
99
+ sql: `UPDATE _prisma_marker SET
100
+ core_hash = ?,
101
+ profile_hash = ?,
102
+ contract_json = ?,
103
+ canonical_version = ?,
104
+ updated_at = datetime('now'),
105
+ app_tag = ?,
106
+ meta = ?,
107
+ invariants = ?
108
+ WHERE space = ?`,
109
+ params: [
110
+ input.storageHash,
111
+ input.profileHash,
112
+ jsonParam(input.contractJson),
113
+ input.canonicalVersion ?? null,
114
+ input.appTag ?? null,
115
+ jsonParam(input.meta ?? {}),
116
+ jsonParam(input.invariants),
117
+ input.space
118
+ ]
119
+ }
120
+ };
121
+ }
122
+ function buildLedgerInsertStatement(input) {
123
+ return {
124
+ sql: `INSERT INTO _prisma_ledger (
125
+ origin_core_hash,
126
+ origin_profile_hash,
127
+ destination_core_hash,
128
+ destination_profile_hash,
129
+ contract_json_before,
130
+ contract_json_after,
131
+ operations
132
+ ) VALUES (
133
+ ?,
134
+ ?,
135
+ ?,
136
+ ?,
137
+ ?,
138
+ ?,
139
+ ?
140
+ )`,
141
+ params: [
142
+ input.originStorageHash ?? null,
143
+ input.originProfileHash ?? null,
144
+ input.destinationStorageHash,
145
+ input.destinationProfileHash ?? null,
146
+ jsonParam(input.contractJsonBefore),
147
+ jsonParam(input.contractJsonAfter),
148
+ jsonParam(input.operations)
149
+ ]
150
+ };
151
+ }
152
+ function jsonParam(value) {
153
+ return JSON.stringify(value ?? null);
154
+ }
155
+ //#endregion
156
+ export { buildLedgerInsertStatement as a, ensureMarkerTableStatement as c, MARKER_TABLE_NAME as i, readMarkerStatement as l, CONTROL_TABLE_NAMES as n, buildWriteMarkerStatements as o, LEDGER_TABLE_NAME as r, ensureLedgerTableStatement as s, APP_SPACE_ID$1 as t };
157
+
158
+ //# sourceMappingURL=statement-builders-Dne-LkAV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statement-builders-Dne-LkAV.mjs","names":["APP_SPACE_ID"],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":["import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\n\nexport { APP_SPACE_ID };\n\nexport interface SqlStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n}\n\nexport const MARKER_TABLE_NAME = '_prisma_marker';\nexport const LEDGER_TABLE_NAME = '_prisma_ledger';\n\n/**\n * Control tables the runner creates/manages. The planner must not drop these\n * when reconciling \"extra\" tables against the contract.\n */\nexport const CONTROL_TABLE_NAMES: ReadonlySet<string> = new Set([\n MARKER_TABLE_NAME,\n LEDGER_TABLE_NAME,\n]);\n\n/**\n * Schema for `_prisma_marker`. The `space TEXT PRIMARY KEY` shape\n * supports one row per loaded contract space (`'app'`,\n * `'<extension-id>'`, …); brand-new databases create this shape\n * directly. The migration runner detects pre-1.0 single-row markers\n * (no `space` column) at boot and fails with a structured\n * `LEGACY_MARKER_SHAPE` error rather than auto-rebuilding the table —\n * see `specs/framework-mechanism.spec.md § 2`.\n */\nexport const ensureMarkerTableStatement: SqlStatement = {\n sql: `CREATE TABLE IF NOT EXISTS _prisma_marker (\n space TEXT NOT NULL PRIMARY KEY DEFAULT '${APP_SPACE_ID}',\n core_hash TEXT NOT NULL,\n profile_hash TEXT NOT NULL,\n contract_json TEXT,\n canonical_version INTEGER,\n updated_at TEXT NOT NULL DEFAULT (datetime('now')),\n app_tag TEXT,\n meta TEXT NOT NULL DEFAULT '{}',\n invariants TEXT NOT NULL DEFAULT '[]'\n )`,\n params: [],\n};\n\nexport const ensureLedgerTableStatement: SqlStatement = {\n sql: `CREATE TABLE IF NOT EXISTS _prisma_ledger (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n created_at TEXT NOT NULL DEFAULT (datetime('now')),\n origin_core_hash TEXT,\n origin_profile_hash TEXT,\n destination_core_hash TEXT NOT NULL,\n destination_profile_hash TEXT,\n contract_json_before TEXT,\n contract_json_after TEXT,\n operations TEXT NOT NULL\n )`,\n params: [],\n};\n\nexport function readMarkerStatement(space: string): SqlStatement {\n return {\n sql: `SELECT\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n FROM _prisma_marker\n WHERE space = ?`,\n params: [space],\n };\n}\n\nexport interface WriteMarkerInput {\n /**\n * Logical space identifier for this marker row. Required at every\n * call site so the type system surfaces every place that needs to\n * thread the value (rather than letting an `?? APP_SPACE_ID`\n * fall-through silently collapse multi-space markers onto the\n * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}\n * (`'app'`); per-extension callers pass the extension's space id.\n */\n readonly space: string;\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number | null;\n readonly appTag?: string | null;\n readonly meta?: Record<string, unknown>;\n /**\n * Invariants to write into `marker.invariants`. Stored as a JSON-encoded\n * TEXT array — SQLite has no native array type. The runner is responsible\n * for merging with the existing column (no SQL-side merge here, unlike\n * Postgres) before passing them in: BEGIN EXCLUSIVE on the migration\n * transaction makes the read-then-merge-then-write sequence safe.\n */\n readonly invariants: readonly string[];\n}\n\nexport function buildWriteMarkerStatements(input: WriteMarkerInput): {\n readonly insert: SqlStatement;\n readonly update: SqlStatement;\n} {\n const params: readonly unknown[] = [\n input.space,\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n jsonParam(input.invariants),\n ];\n\n return {\n insert: {\n sql: `INSERT INTO _prisma_marker (\n space,\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n ) VALUES (\n ?,\n ?,\n ?,\n ?,\n ?,\n datetime('now'),\n ?,\n ?,\n ?\n )`,\n params,\n },\n update: {\n sql: `UPDATE _prisma_marker SET\n core_hash = ?,\n profile_hash = ?,\n contract_json = ?,\n canonical_version = ?,\n updated_at = datetime('now'),\n app_tag = ?,\n meta = ?,\n invariants = ?\n WHERE space = ?`,\n params: [\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n jsonParam(input.invariants),\n input.space,\n ],\n },\n };\n}\n\nexport interface LedgerInsertInput {\n readonly originStorageHash?: string | null;\n readonly originProfileHash?: string | null;\n readonly destinationStorageHash: string;\n readonly destinationProfileHash?: string | null;\n readonly contractJsonBefore?: unknown;\n readonly contractJsonAfter?: unknown;\n readonly operations: unknown;\n}\n\nexport function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {\n return {\n sql: `INSERT INTO _prisma_ledger (\n origin_core_hash,\n origin_profile_hash,\n destination_core_hash,\n destination_profile_hash,\n contract_json_before,\n contract_json_after,\n operations\n ) VALUES (\n ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?\n )`,\n params: [\n input.originStorageHash ?? null,\n input.originProfileHash ?? null,\n input.destinationStorageHash,\n input.destinationProfileHash ?? null,\n jsonParam(input.contractJsonBefore),\n jsonParam(input.contractJsonAfter),\n jsonParam(input.operations),\n ],\n };\n}\n\nfunction jsonParam(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n"],"mappings":";;AASA,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;;;;;AAMjC,MAAa,sBAA2C,IAAI,IAAI,CAC9D,mBACA,kBACD,CAAC;;;;;;;;;;AAWF,MAAa,6BAA2C;CACtD,KAAK;+CACwCA,eAAa;;;;;;;;;;CAU1D,QAAQ,EAAE;CACX;AAED,MAAa,6BAA2C;CACtD,KAAK;;;;;;;;;;;CAWL,QAAQ,EAAE;CACX;AAED,SAAgB,oBAAoB,OAA6B;CAC/D,OAAO;EACL,KAAK;;;;;;;;;;;EAWL,QAAQ,CAAC,MAAM;EAChB;;AA6BH,SAAgB,2BAA2B,OAGzC;CAYA,OAAO;EACL,QAAQ;GACN,KAAK;;;;;;;;;;;;;;;;;;;;;GAqBL,QAAA;IAjCF,MAAM;IACN,MAAM;IACN,MAAM;IACN,UAAU,MAAM,aAAa;IAC7B,MAAM,oBAAoB;IAC1B,MAAM,UAAU;IAChB,UAAU,MAAM,QAAQ,EAAE,CAAC;IAC3B,UAAU,MAAM,WAAW;IA0BnB;GACP;EACD,QAAQ;GACN,KAAK;;;;;;;;;;GAUL,QAAQ;IACN,MAAM;IACN,MAAM;IACN,UAAU,MAAM,aAAa;IAC7B,MAAM,oBAAoB;IAC1B,MAAM,UAAU;IAChB,UAAU,MAAM,QAAQ,EAAE,CAAC;IAC3B,UAAU,MAAM,WAAW;IAC3B,MAAM;IACP;GACF;EACF;;AAaH,SAAgB,2BAA2B,OAAwC;CACjF,OAAO;EACL,KAAK;;;;;;;;;;;;;;;;;EAiBL,QAAQ;GACN,MAAM,qBAAqB;GAC3B,MAAM,qBAAqB;GAC3B,MAAM;GACN,MAAM,0BAA0B;GAChC,UAAU,MAAM,mBAAmB;GACnC,UAAU,MAAM,kBAAkB;GAClC,UAAU,MAAM,WAAW;GAC5B;EACF;;AAGH,SAAS,UAAU,OAAwB;CACzC,OAAO,KAAK,UAAU,SAAS,KAAK"}
@@ -0,0 +1,68 @@
1
+ import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
2
+
3
+ //#region src/core/migrations/statement-builders.d.ts
4
+ interface SqlStatement {
5
+ readonly sql: string;
6
+ readonly params: readonly unknown[];
7
+ }
8
+ declare const MARKER_TABLE_NAME = "_prisma_marker";
9
+ declare const LEDGER_TABLE_NAME = "_prisma_ledger";
10
+ /**
11
+ * Control tables the runner creates/manages. The planner must not drop these
12
+ * when reconciling "extra" tables against the contract.
13
+ */
14
+ declare const CONTROL_TABLE_NAMES: ReadonlySet<string>;
15
+ /**
16
+ * Schema for `_prisma_marker`. The `space TEXT PRIMARY KEY` shape
17
+ * supports one row per loaded contract space (`'app'`,
18
+ * `'<extension-id>'`, …); brand-new databases create this shape
19
+ * directly. The migration runner detects pre-1.0 single-row markers
20
+ * (no `space` column) at boot and fails with a structured
21
+ * `LEGACY_MARKER_SHAPE` error rather than auto-rebuilding the table —
22
+ * see `specs/framework-mechanism.spec.md § 2`.
23
+ */
24
+ declare const ensureMarkerTableStatement: SqlStatement;
25
+ declare const ensureLedgerTableStatement: SqlStatement;
26
+ declare function readMarkerStatement(space: string): SqlStatement;
27
+ interface WriteMarkerInput {
28
+ /**
29
+ * Logical space identifier for this marker row. Required at every
30
+ * call site so the type system surfaces every place that needs to
31
+ * thread the value (rather than letting an `?? APP_SPACE_ID`
32
+ * fall-through silently collapse multi-space markers onto the
33
+ * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}
34
+ * (`'app'`); per-extension callers pass the extension's space id.
35
+ */
36
+ readonly space: string;
37
+ readonly storageHash: string;
38
+ readonly profileHash: string;
39
+ readonly contractJson?: unknown;
40
+ readonly canonicalVersion?: number | null;
41
+ readonly appTag?: string | null;
42
+ readonly meta?: Record<string, unknown>;
43
+ /**
44
+ * Invariants to write into `marker.invariants`. Stored as a JSON-encoded
45
+ * TEXT array — SQLite has no native array type. The runner is responsible
46
+ * for merging with the existing column (no SQL-side merge here, unlike
47
+ * Postgres) before passing them in: BEGIN EXCLUSIVE on the migration
48
+ * transaction makes the read-then-merge-then-write sequence safe.
49
+ */
50
+ readonly invariants: readonly string[];
51
+ }
52
+ declare function buildWriteMarkerStatements(input: WriteMarkerInput): {
53
+ readonly insert: SqlStatement;
54
+ readonly update: SqlStatement;
55
+ };
56
+ interface LedgerInsertInput {
57
+ readonly originStorageHash?: string | null;
58
+ readonly originProfileHash?: string | null;
59
+ readonly destinationStorageHash: string;
60
+ readonly destinationProfileHash?: string | null;
61
+ readonly contractJsonBefore?: unknown;
62
+ readonly contractJsonAfter?: unknown;
63
+ readonly operations: unknown;
64
+ }
65
+ declare function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement;
66
+ //#endregion
67
+ export { APP_SPACE_ID, CONTROL_TABLE_NAMES, LEDGER_TABLE_NAME, MARKER_TABLE_NAME, type SqlStatement, buildLedgerInsertStatement, buildWriteMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, readMarkerStatement };
68
+ //# sourceMappingURL=statement-builders.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statement-builders.d.mts","names":[],"sources":["../src/core/migrations/statement-builders.ts"],"mappings":";;;UAIiB,YAAA;EAAA,SACN,GAAA;EAAA,SACA,MAAA;AAAA;AAAA,cAGE,iBAAA;AAAA,cACA,iBAAA;AADb;;;;AAAA,cAOa,mBAAA,EAAqB,WAAA;AANlC;;;;;AAMA;;;;AANA,cAoBa,0BAAA,EAA4B,YAAA;AAAA,cAe5B,0BAAA,EAA4B,YAAA;AAAA,iBAezB,mBAAA,CAAoB,KAAA,WAAgB,YAAA;AAAA,UAiBnC,gBAAA;EA/CwB;;AAezC;;;;;AAeA;EA9ByC,SAwD9B,KAAA;EAAA,SACA,WAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA;EAAA,SACA,gBAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA,GAAO,MAAA;EAAM;;;;;;;EAAA,SAQb,UAAA;AAAA;AAAA,iBAGK,0BAAA,CAA2B,KAAA,EAAO,gBAAA;EAAA,SACvC,MAAA,EAAQ,YAAA;EAAA,SACR,MAAA,EAAQ,YAAA;AAAA;AAAA,UA+DF,iBAAA;EAAA,SACN,iBAAA;EAAA,SACA,iBAAA;EAAA,SACA,sBAAA;EAAA,SACA,sBAAA;EAAA,SACA,kBAAA;EAAA,SACA,iBAAA;EAAA,SACA,UAAA;AAAA;AAAA,iBAGK,0BAAA,CAA2B,KAAA,EAAO,iBAAA,GAAoB,YAAA"}
@@ -0,0 +1,2 @@
1
+ import { a as buildLedgerInsertStatement, c as ensureMarkerTableStatement, i as MARKER_TABLE_NAME, l as readMarkerStatement, n as CONTROL_TABLE_NAMES, o as buildWriteMarkerStatements, r as LEDGER_TABLE_NAME, s as ensureLedgerTableStatement, t as APP_SPACE_ID } from "./statement-builders-Dne-LkAV.mjs";
2
+ export { APP_SPACE_ID, CONTROL_TABLE_NAMES, LEDGER_TABLE_NAME, MARKER_TABLE_NAME, buildLedgerInsertStatement, buildWriteMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, readMarkerStatement };