@prisma-next/target-sqlite 0.12.0 → 0.13.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.
- package/dist/{codec-ids-CYwMu3-4.d.mts → codec-ids-BfPkjMmk.d.mts} +1 -1
- package/dist/{codec-ids-CYwMu3-4.d.mts.map → codec-ids-BfPkjMmk.d.mts.map} +1 -1
- package/dist/{codec-ids-CuUxYcd0.mjs → codec-ids-DSU7S2Li.mjs} +1 -1
- package/dist/{codec-ids-CuUxYcd0.mjs.map → codec-ids-DSU7S2Li.mjs.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/codec-ids.mjs +1 -1
- package/dist/{codec-types-DNauB5UT.d.mts → codec-types-izdPhp_9.d.mts} +6 -7
- package/dist/codec-types-izdPhp_9.d.mts.map +1 -0
- package/dist/codec-types.d.mts +3 -3
- package/dist/{codecs-BAlEiSeP.d.mts → codecs-BGeJavlQ.d.mts} +16 -18
- package/dist/codecs-BGeJavlQ.d.mts.map +1 -0
- package/dist/{codecs-DVnHtVWW.mjs → codecs-DsC4OGmU.mjs} +2 -2
- package/dist/{codecs-DVnHtVWW.mjs.map → codecs-DsC4OGmU.mjs.map} +1 -1
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +1 -1
- package/dist/contract-free.d.mts +55 -0
- package/dist/contract-free.d.mts.map +1 -0
- package/dist/contract-free.mjs +111 -0
- package/dist/contract-free.mjs.map +1 -0
- package/dist/control-tables-7KwMyJ6i.mjs +12 -0
- package/dist/control-tables-7KwMyJ6i.mjs.map +1 -0
- package/dist/control-tables.d.mts +11 -0
- package/dist/control-tables.d.mts.map +1 -0
- package/dist/control-tables.mjs +2 -0
- package/dist/control.d.mts +31 -15
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +66 -124
- package/dist/control.mjs.map +1 -1
- package/dist/ddl.d.mts +2 -0
- package/dist/ddl.mjs +2 -0
- package/dist/{default-normalizer-3Fccw7yw.mjs → default-normalizer-DuoHj9-O.mjs} +1 -1
- package/dist/{default-normalizer-3Fccw7yw.mjs.map → default-normalizer-DuoHj9-O.mjs.map} +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/descriptor-meta-Dxx2A6PT.mjs +17 -0
- package/dist/descriptor-meta-Dxx2A6PT.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-BkXK3OjD.mjs +12 -0
- package/dist/descriptor-meta-runtime-BkXK3OjD.mjs.map +1 -0
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +3 -3
- package/dist/{native-type-normalizer-BlN5XfD-.mjs → native-type-normalizer-CiSyVmMP.mjs} +1 -1
- package/dist/{native-type-normalizer-BlN5XfD-.mjs.map → native-type-normalizer-CiSyVmMP.mjs.map} +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/nodes-D0k4z7NL.mjs +33 -0
- package/dist/nodes-D0k4z7NL.mjs.map +1 -0
- package/dist/nodes-VzaaeUTb.d.mts +29 -0
- package/dist/nodes-VzaaeUTb.d.mts.map +1 -0
- package/dist/{op-factory-call-BnPhI25-.mjs → op-factory-call-DymqdXQW.mjs} +2 -2
- package/dist/{op-factory-call-BnPhI25-.mjs.map → op-factory-call-DymqdXQW.mjs.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.d.mts.map +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +9 -7
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CEKTRydl.mjs → planner-DSNDwQy9.mjs} +9 -9
- package/dist/planner-DSNDwQy9.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-CI9LdXPr.d.mts → planner-produced-sqlite-migration-C1yqJAiM.d.mts} +3 -3
- package/dist/{planner-produced-sqlite-migration-CI9LdXPr.d.mts.map → planner-produced-sqlite-migration-C1yqJAiM.d.mts.map} +1 -1
- package/dist/{planner-produced-sqlite-migration-DCsg3RDZ.mjs → planner-produced-sqlite-migration-DowV_vHw.mjs} +3 -3
- package/dist/{planner-produced-sqlite-migration-DCsg3RDZ.mjs.map → planner-produced-sqlite-migration-DowV_vHw.mjs.map} +1 -1
- package/dist/planner-produced-sqlite-migration.d.mts +1 -1
- package/dist/planner-produced-sqlite-migration.mjs +1 -1
- package/dist/{planner-target-details-Bm71XPKb.mjs → planner-target-details-H8z9TFDg.mjs} +1 -1
- package/dist/{planner-target-details-Bm71XPKb.mjs.map → planner-target-details-H8z9TFDg.mjs.map} +1 -1
- package/dist/{planner-target-details-vhvZDWK1.d.mts → planner-target-details-xR6UfIcz.d.mts} +1 -1
- package/dist/{planner-target-details-vhvZDWK1.d.mts.map → planner-target-details-xR6UfIcz.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner-target-details.mjs +1 -1
- package/dist/planner.d.mts +2 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{render-ops-CSRDT4YL.mjs → render-ops-CFRbJ3Yb.mjs} +1 -1
- package/dist/{render-ops-CSRDT4YL.mjs.map → render-ops-CFRbJ3Yb.mjs.map} +1 -1
- package/dist/render-ops.d.mts +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/runtime.d.mts +17 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +4 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-qLsgTOZs.d.mts → shared-Dhc8mLK1.d.mts} +2 -2
- package/dist/{shared-qLsgTOZs.d.mts.map → shared-Dhc8mLK1.d.mts.map} +1 -1
- package/dist/{sql-utils-DhevMgef.mjs → sql-utils-CV8Bdgtc.mjs} +1 -1
- package/dist/{sql-utils-DhevMgef.mjs.map → sql-utils-CV8Bdgtc.mjs.map} +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/sqlite-contract-serializer-jcRu8aHh.mjs +101 -0
- package/dist/sqlite-contract-serializer-jcRu8aHh.mjs.map +1 -0
- package/dist/{sqlite-migration-BBJktVVw.mjs → sqlite-migration-CUqgmzQH.mjs} +1 -1
- package/dist/{sqlite-migration-BBJktVVw.mjs.map → sqlite-migration-CUqgmzQH.mjs.map} +1 -1
- package/dist/{sqlite-migration-DAb2NEX6.d.mts → sqlite-migration-D4XGYzgQ.d.mts} +2 -2
- package/dist/{sqlite-migration-DAb2NEX6.d.mts.map → sqlite-migration-D4XGYzgQ.d.mts.map} +1 -1
- package/dist/{tables-DGRRJasz.mjs → tables-CjB7vXCr.mjs} +5 -11
- package/dist/tables-CjB7vXCr.mjs.map +1 -0
- package/package.json +23 -21
- package/src/contract-free/columns.ts +44 -0
- package/src/contract-free/control-bootstrap.ts +54 -0
- package/src/contract-free/ddl.ts +26 -0
- package/src/core/authoring.ts +1 -1
- package/src/core/control-tables.ts +11 -0
- package/src/core/control-target.ts +4 -6
- package/src/core/ddl/nodes.ts +54 -0
- package/src/core/descriptor-meta-runtime.ts +28 -0
- package/src/core/descriptor-meta.ts +4 -6
- package/src/core/migrations/issue-planner.ts +1 -1
- package/src/core/migrations/operations/shared.ts +1 -8
- package/src/core/migrations/planner-strategies.ts +1 -1
- package/src/core/migrations/runner.ts +78 -83
- package/src/core/runtime-target.ts +2 -2
- package/src/core/sqlite-contract-serializer.ts +21 -9
- package/src/core/sqlite-unbound-database.ts +113 -26
- package/src/exports/contract-free.ts +6 -0
- package/src/exports/control-tables.ts +5 -0
- package/src/exports/ddl.ts +6 -0
- package/src/exports/runtime.ts +1 -0
- package/dist/codec-types-DNauB5UT.d.mts.map +0 -1
- package/dist/codecs-BAlEiSeP.d.mts.map +0 -1
- package/dist/descriptor-meta-CE2Kbn9b.mjs +0 -17
- package/dist/descriptor-meta-CE2Kbn9b.mjs.map +0 -1
- package/dist/planner-CEKTRydl.mjs.map +0 -1
- package/dist/statement-builders-Dne-LkAV.mjs +0 -158
- package/dist/statement-builders-Dne-LkAV.mjs.map +0 -1
- package/dist/statement-builders.d.mts +0 -68
- package/dist/statement-builders.d.mts.map +0 -1
- package/dist/statement-builders.mjs +0 -2
- package/dist/tables-DGRRJasz.mjs.map +0 -1
- package/src/core/migrations/statement-builders.ts +0 -212
- package/src/exports/statement-builders.ts +0 -12
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
|
|
2
|
-
|
|
3
|
-
export { APP_SPACE_ID };
|
|
4
|
-
|
|
5
|
-
export interface SqlStatement {
|
|
6
|
-
readonly sql: string;
|
|
7
|
-
readonly params: readonly unknown[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const MARKER_TABLE_NAME = '_prisma_marker';
|
|
11
|
-
export const LEDGER_TABLE_NAME = '_prisma_ledger';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Control tables the runner creates/manages. The planner must not drop these
|
|
15
|
-
* when reconciling "extra" tables against the contract.
|
|
16
|
-
*/
|
|
17
|
-
export const CONTROL_TABLE_NAMES: ReadonlySet<string> = new Set([
|
|
18
|
-
MARKER_TABLE_NAME,
|
|
19
|
-
LEDGER_TABLE_NAME,
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Schema for `_prisma_marker`. The `space TEXT PRIMARY KEY` shape
|
|
24
|
-
* supports one row per loaded contract space (`'app'`,
|
|
25
|
-
* `'<extension-id>'`, …); brand-new databases create this shape
|
|
26
|
-
* directly. The migration runner detects pre-1.0 single-row markers
|
|
27
|
-
* (no `space` column) at boot and fails with a structured
|
|
28
|
-
* `LEGACY_MARKER_SHAPE` error rather than auto-rebuilding the table —
|
|
29
|
-
* see `specs/framework-mechanism.spec.md § 2`.
|
|
30
|
-
*/
|
|
31
|
-
export const ensureMarkerTableStatement: SqlStatement = {
|
|
32
|
-
sql: `CREATE TABLE IF NOT EXISTS _prisma_marker (
|
|
33
|
-
space TEXT NOT NULL PRIMARY KEY DEFAULT '${APP_SPACE_ID}',
|
|
34
|
-
core_hash TEXT NOT NULL,
|
|
35
|
-
profile_hash TEXT NOT NULL,
|
|
36
|
-
contract_json TEXT,
|
|
37
|
-
canonical_version INTEGER,
|
|
38
|
-
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
39
|
-
app_tag TEXT,
|
|
40
|
-
meta TEXT NOT NULL DEFAULT '{}',
|
|
41
|
-
invariants TEXT NOT NULL DEFAULT '[]'
|
|
42
|
-
)`,
|
|
43
|
-
params: [],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const ensureLedgerTableStatement: SqlStatement = {
|
|
47
|
-
sql: `CREATE TABLE IF NOT EXISTS _prisma_ledger (
|
|
48
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
49
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
50
|
-
origin_core_hash TEXT,
|
|
51
|
-
origin_profile_hash TEXT,
|
|
52
|
-
destination_core_hash TEXT NOT NULL,
|
|
53
|
-
destination_profile_hash TEXT,
|
|
54
|
-
contract_json_before TEXT,
|
|
55
|
-
contract_json_after TEXT,
|
|
56
|
-
operations TEXT NOT NULL
|
|
57
|
-
)`,
|
|
58
|
-
params: [],
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export function readMarkerStatement(space: string): SqlStatement {
|
|
62
|
-
return {
|
|
63
|
-
sql: `SELECT
|
|
64
|
-
core_hash,
|
|
65
|
-
profile_hash,
|
|
66
|
-
contract_json,
|
|
67
|
-
canonical_version,
|
|
68
|
-
updated_at,
|
|
69
|
-
app_tag,
|
|
70
|
-
meta,
|
|
71
|
-
invariants
|
|
72
|
-
FROM _prisma_marker
|
|
73
|
-
WHERE space = ?`,
|
|
74
|
-
params: [space],
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface WriteMarkerInput {
|
|
79
|
-
/**
|
|
80
|
-
* Logical space identifier for this marker row. Required at every
|
|
81
|
-
* call site so the type system surfaces every place that needs to
|
|
82
|
-
* thread the value (rather than letting an `?? APP_SPACE_ID`
|
|
83
|
-
* fall-through silently collapse per-space markers onto the
|
|
84
|
-
* `'app'` row). App-plan callers pass {@link APP_SPACE_ID}
|
|
85
|
-
* (`'app'`); per-extension callers pass the extension's space id.
|
|
86
|
-
*/
|
|
87
|
-
readonly space: string;
|
|
88
|
-
readonly storageHash: string;
|
|
89
|
-
readonly profileHash: string;
|
|
90
|
-
readonly contractJson?: unknown;
|
|
91
|
-
readonly canonicalVersion?: number | null;
|
|
92
|
-
readonly appTag?: string | null;
|
|
93
|
-
readonly meta?: Record<string, unknown>;
|
|
94
|
-
/**
|
|
95
|
-
* Invariants to write into `marker.invariants`. Stored as a JSON-encoded
|
|
96
|
-
* TEXT array — SQLite has no native array type. The runner is responsible
|
|
97
|
-
* for merging with the existing column (no SQL-side merge here, unlike
|
|
98
|
-
* Postgres) before passing them in: BEGIN EXCLUSIVE on the migration
|
|
99
|
-
* transaction makes the read-then-merge-then-write sequence safe.
|
|
100
|
-
*/
|
|
101
|
-
readonly invariants: readonly string[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function buildWriteMarkerStatements(input: WriteMarkerInput): {
|
|
105
|
-
readonly insert: SqlStatement;
|
|
106
|
-
readonly update: SqlStatement;
|
|
107
|
-
} {
|
|
108
|
-
const params: readonly unknown[] = [
|
|
109
|
-
input.space,
|
|
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
|
-
];
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
insert: {
|
|
121
|
-
sql: `INSERT INTO _prisma_marker (
|
|
122
|
-
space,
|
|
123
|
-
core_hash,
|
|
124
|
-
profile_hash,
|
|
125
|
-
contract_json,
|
|
126
|
-
canonical_version,
|
|
127
|
-
updated_at,
|
|
128
|
-
app_tag,
|
|
129
|
-
meta,
|
|
130
|
-
invariants
|
|
131
|
-
) VALUES (
|
|
132
|
-
?,
|
|
133
|
-
?,
|
|
134
|
-
?,
|
|
135
|
-
?,
|
|
136
|
-
?,
|
|
137
|
-
datetime('now'),
|
|
138
|
-
?,
|
|
139
|
-
?,
|
|
140
|
-
?
|
|
141
|
-
)`,
|
|
142
|
-
params,
|
|
143
|
-
},
|
|
144
|
-
update: {
|
|
145
|
-
sql: `UPDATE _prisma_marker SET
|
|
146
|
-
core_hash = ?,
|
|
147
|
-
profile_hash = ?,
|
|
148
|
-
contract_json = ?,
|
|
149
|
-
canonical_version = ?,
|
|
150
|
-
updated_at = datetime('now'),
|
|
151
|
-
app_tag = ?,
|
|
152
|
-
meta = ?,
|
|
153
|
-
invariants = ?
|
|
154
|
-
WHERE space = ?`,
|
|
155
|
-
params: [
|
|
156
|
-
input.storageHash,
|
|
157
|
-
input.profileHash,
|
|
158
|
-
jsonParam(input.contractJson),
|
|
159
|
-
input.canonicalVersion ?? null,
|
|
160
|
-
input.appTag ?? null,
|
|
161
|
-
jsonParam(input.meta ?? {}),
|
|
162
|
-
jsonParam(input.invariants),
|
|
163
|
-
input.space,
|
|
164
|
-
],
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface LedgerInsertInput {
|
|
170
|
-
readonly originStorageHash?: string | null;
|
|
171
|
-
readonly originProfileHash?: string | null;
|
|
172
|
-
readonly destinationStorageHash: string;
|
|
173
|
-
readonly destinationProfileHash?: string | null;
|
|
174
|
-
readonly contractJsonBefore?: unknown;
|
|
175
|
-
readonly contractJsonAfter?: unknown;
|
|
176
|
-
readonly operations: unknown;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {
|
|
180
|
-
return {
|
|
181
|
-
sql: `INSERT INTO _prisma_ledger (
|
|
182
|
-
origin_core_hash,
|
|
183
|
-
origin_profile_hash,
|
|
184
|
-
destination_core_hash,
|
|
185
|
-
destination_profile_hash,
|
|
186
|
-
contract_json_before,
|
|
187
|
-
contract_json_after,
|
|
188
|
-
operations
|
|
189
|
-
) VALUES (
|
|
190
|
-
?,
|
|
191
|
-
?,
|
|
192
|
-
?,
|
|
193
|
-
?,
|
|
194
|
-
?,
|
|
195
|
-
?,
|
|
196
|
-
?
|
|
197
|
-
)`,
|
|
198
|
-
params: [
|
|
199
|
-
input.originStorageHash ?? null,
|
|
200
|
-
input.originProfileHash ?? null,
|
|
201
|
-
input.destinationStorageHash,
|
|
202
|
-
input.destinationProfileHash ?? null,
|
|
203
|
-
jsonParam(input.contractJsonBefore),
|
|
204
|
-
jsonParam(input.contractJsonAfter),
|
|
205
|
-
jsonParam(input.operations),
|
|
206
|
-
],
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function jsonParam(value: unknown): string {
|
|
211
|
-
return JSON.stringify(value ?? null);
|
|
212
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
APP_SPACE_ID,
|
|
3
|
-
buildLedgerInsertStatement,
|
|
4
|
-
buildWriteMarkerStatements,
|
|
5
|
-
CONTROL_TABLE_NAMES,
|
|
6
|
-
ensureLedgerTableStatement,
|
|
7
|
-
ensureMarkerTableStatement,
|
|
8
|
-
LEDGER_TABLE_NAME,
|
|
9
|
-
MARKER_TABLE_NAME,
|
|
10
|
-
readMarkerStatement,
|
|
11
|
-
type SqlStatement,
|
|
12
|
-
} from '../core/migrations/statement-builders';
|