@prisma-next/target-sqlite 0.5.0-dev.9 → 0.5.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 +13 -0
- package/dist/codec-ids-CYwMu3-4.d.mts.map +1 -0
- package/dist/codec-ids-CuUxYcd0.mjs +13 -0
- package/dist/codec-ids-CuUxYcd0.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -0
- package/dist/codec-ids.mjs +2 -0
- package/dist/codec-types-xLeyb_u4.d.mts +23 -0
- package/dist/codec-types-xLeyb_u4.d.mts.map +1 -0
- package/dist/codec-types.d.mts +3 -0
- package/dist/codec-types.mjs +2 -0
- package/dist/codecs-DEjc7dem.d.mts +203 -0
- package/dist/codecs-DEjc7dem.d.mts.map +1 -0
- package/dist/codecs-DVnHtVWW.mjs +220 -0
- package/dist/codecs-DVnHtVWW.mjs.map +1 -0
- package/dist/codecs.d.mts +2 -0
- package/dist/codecs.mjs +13 -0
- package/dist/codecs.mjs.map +1 -0
- package/dist/control.d.mts +4 -3
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +427 -5
- package/dist/control.mjs.map +1 -1
- package/dist/default-normalizer-3Fccw7yw.mjs +69 -0
- package/dist/default-normalizer-3Fccw7yw.mjs.map +1 -0
- package/dist/default-normalizer.d.mts +7 -0
- package/dist/default-normalizer.d.mts.map +1 -0
- package/dist/default-normalizer.mjs +2 -0
- package/dist/descriptor-meta-CE2Kbn9b.mjs +17 -0
- package/dist/descriptor-meta-CE2Kbn9b.mjs.map +1 -0
- package/dist/migration.d.mts +85 -0
- package/dist/migration.d.mts.map +1 -0
- package/dist/migration.mjs +49 -0
- package/dist/migration.mjs.map +1 -0
- package/dist/native-type-normalizer-BlN5XfD-.mjs +14 -0
- package/dist/native-type-normalizer-BlN5XfD-.mjs.map +1 -0
- package/dist/native-type-normalizer.d.mts +11 -0
- package/dist/native-type-normalizer.d.mts.map +1 -0
- package/dist/native-type-normalizer.mjs +2 -0
- package/dist/op-factory-call-DRKKURAO.mjs +279 -0
- package/dist/op-factory-call-DRKKURAO.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +151 -0
- package/dist/op-factory-call.d.mts.map +1 -0
- package/dist/op-factory-call.mjs +2 -0
- package/dist/pack.d.mts +35 -1
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -3
- package/dist/planner-A7dqS0u6.mjs +522 -0
- package/dist/planner-A7dqS0u6.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts +29 -0
- package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts.map +1 -0
- package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs +110 -0
- package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration.d.mts +2 -0
- package/dist/planner-produced-sqlite-migration.mjs +2 -0
- package/dist/planner-target-details-Bm71XPKb.mjs +15 -0
- package/dist/planner-target-details-Bm71XPKb.mjs.map +1 -0
- package/dist/planner-target-details-vhvZDWK1.d.mts +12 -0
- package/dist/planner-target-details-vhvZDWK1.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +2 -0
- package/dist/planner-target-details.mjs +2 -0
- package/dist/planner.d.mts +59 -0
- package/dist/planner.d.mts.map +1 -0
- package/dist/planner.mjs +2 -0
- package/dist/render-ops-CSRDT4YL.mjs +8 -0
- package/dist/render-ops-CSRDT4YL.mjs.map +1 -0
- package/dist/render-ops.d.mts +10 -0
- package/dist/render-ops.d.mts.map +1 -0
- package/dist/render-ops.mjs +2 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +4 -8
- package/dist/runtime.mjs.map +1 -1
- package/dist/shared-qLsgTOZs.d.mts +69 -0
- package/dist/shared-qLsgTOZs.d.mts.map +1 -0
- package/dist/sql-utils-DhevMgef.mjs +35 -0
- package/dist/sql-utils-DhevMgef.mjs.map +1 -0
- package/dist/sql-utils.d.mts +22 -0
- package/dist/sql-utils.d.mts.map +1 -0
- package/dist/sql-utils.mjs +2 -0
- package/dist/sqlite-migration-BBJktVVw.mjs +16 -0
- package/dist/sqlite-migration-BBJktVVw.mjs.map +1 -0
- package/dist/sqlite-migration-DAb2NEX6.d.mts +17 -0
- package/dist/sqlite-migration-DAb2NEX6.d.mts.map +1 -0
- package/dist/statement-builders-Dne-LkAV.mjs +158 -0
- package/dist/statement-builders-Dne-LkAV.mjs.map +1 -0
- package/dist/statement-builders.d.mts +68 -0
- package/dist/statement-builders.d.mts.map +1 -0
- package/dist/statement-builders.mjs +2 -0
- package/dist/tables-D84zfPZI.mjs +403 -0
- package/dist/tables-D84zfPZI.mjs.map +1 -0
- package/package.json +31 -9
- package/src/core/authoring.ts +9 -0
- package/src/core/codec-helpers.ts +11 -0
- package/src/core/codec-ids.ts +13 -0
- package/src/core/codecs.ts +337 -0
- package/src/core/control-target.ts +53 -11
- package/src/core/default-normalizer.ts +92 -0
- package/src/core/descriptor-meta.ts +5 -1
- package/src/core/migrations/issue-planner.ts +586 -0
- package/src/core/migrations/op-factory-call.ts +369 -0
- package/src/core/migrations/operations/columns.ts +62 -0
- package/src/core/migrations/operations/data-transform.ts +51 -0
- package/src/core/migrations/operations/indexes.ts +52 -0
- package/src/core/migrations/operations/raw.ts +12 -0
- package/src/core/migrations/operations/shared.ts +120 -0
- package/src/core/migrations/operations/tables.ts +388 -0
- package/src/core/migrations/planner-ddl-builders.ts +142 -0
- package/src/core/migrations/planner-produced-sqlite-migration.ts +70 -0
- package/src/core/migrations/planner-strategies.ts +231 -0
- package/src/core/migrations/planner-target-details.ts +33 -0
- package/src/core/migrations/planner.ts +183 -0
- package/src/core/migrations/render-ops.ts +15 -0
- package/src/core/migrations/render-typescript.ts +91 -0
- package/src/core/migrations/runner.ts +724 -0
- package/src/core/migrations/sqlite-migration.ts +13 -0
- package/src/core/migrations/statement-builders.ts +212 -0
- package/src/core/native-type-normalizer.ts +9 -0
- package/src/core/registry.ts +11 -0
- package/src/core/runtime-target.ts +1 -3
- package/src/core/sql-utils.ts +47 -0
- package/src/exports/codec-ids.ts +13 -0
- package/src/exports/codec-types.ts +43 -0
- package/src/exports/codecs.ts +20 -0
- package/src/exports/control.ts +1 -0
- package/src/exports/default-normalizer.ts +1 -0
- package/src/exports/migration.ts +24 -0
- package/src/exports/native-type-normalizer.ts +1 -0
- package/src/exports/op-factory-call.ts +12 -0
- package/src/exports/planner-produced-sqlite-migration.ts +4 -0
- package/src/exports/planner-target-details.ts +2 -0
- package/src/exports/planner.ts +2 -0
- package/src/exports/render-ops.ts +1 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/statement-builders.ts +12 -0
- package/dist/descriptor-meta-DbuuziYA.mjs +0 -14
- package/dist/descriptor-meta-DbuuziYA.mjs.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Migration as SqlMigration } from '@prisma-next/family-sql/migration';
|
|
2
|
+
import type { SqlitePlanTargetDetails } from './planner-target-details';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
|
|
6
|
+
* generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the
|
|
7
|
+
* SQLite literal, so both user-authored migrations and renderer-generated
|
|
8
|
+
* scaffolds can extend `SqliteMigration` directly without redeclaring
|
|
9
|
+
* target-local identity.
|
|
10
|
+
*/
|
|
11
|
+
export abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetails> {
|
|
12
|
+
readonly targetId = 'sqlite' as const;
|
|
13
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
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 multi-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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalizes SQLite native-type tokens for verifier comparison.
|
|
3
|
+
* Lives target-side so the planner / runner / adapter all share the same
|
|
4
|
+
* normalization without crossing the `target-sqlite` ↔ `adapter-sqlite`
|
|
5
|
+
* boundary.
|
|
6
|
+
*/
|
|
7
|
+
export function normalizeSqliteNativeType(nativeType: string): string {
|
|
8
|
+
return nativeType.trim().toLowerCase();
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';
|
|
2
|
+
import type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';
|
|
3
|
+
import { codecDescriptors } from './codecs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Registry of every codec descriptor shipped by `@prisma-next/target-sqlite`.
|
|
7
|
+
*
|
|
8
|
+
* Public consumer surface for the sqlite codec set: the sqlite adapter and any other consumer that needs to enumerate or look up a sqlite codec by id consumes this rather than the raw descriptor array. See ADR 208.
|
|
9
|
+
*/
|
|
10
|
+
export const sqliteCodecRegistry: CodecDescriptorRegistry =
|
|
11
|
+
buildCodecDescriptorRegistry(codecDescriptors);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';
|
|
2
|
-
import { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';
|
|
3
2
|
import type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';
|
|
4
3
|
import { sqliteTargetDescriptorMeta } from './descriptor-meta';
|
|
5
4
|
|
|
@@ -10,8 +9,7 @@ const sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<
|
|
|
10
9
|
SqliteRuntimeTargetInstance
|
|
11
10
|
> = {
|
|
12
11
|
...sqliteTargetDescriptorMeta,
|
|
13
|
-
codecs: () =>
|
|
14
|
-
parameterizedCodecs: () => [],
|
|
12
|
+
codecs: () => [],
|
|
15
13
|
create(): SqliteRuntimeTargetInstance {
|
|
16
14
|
return {
|
|
17
15
|
familyId: 'sql',
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared SQL utility functions for the SQLite target.
|
|
3
|
+
*
|
|
4
|
+
* These functions handle safe SQL identifier and literal escaping. They
|
|
5
|
+
* live in `target-sqlite` (mirroring `target-postgres/src/core/sql-utils.ts`)
|
|
6
|
+
* so both the control adapter (used at emit time) and the runtime adapter
|
|
7
|
+
* (used at execute time) can depend on them through a single one-way edge:
|
|
8
|
+
* `adapter-sqlite → target-sqlite`. Hosting them target-side avoids the
|
|
9
|
+
* cyclic workspace dependency that would arise if `target-sqlite` reached
|
|
10
|
+
* back into `adapter-sqlite` for these primitives.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export class SqlEscapeError extends Error {
|
|
14
|
+
constructor(
|
|
15
|
+
message: string,
|
|
16
|
+
public readonly value: string,
|
|
17
|
+
public readonly kind: 'identifier' | 'literal',
|
|
18
|
+
) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'SqlEscapeError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function quoteIdentifier(identifier: string): string {
|
|
25
|
+
if (identifier.length === 0) {
|
|
26
|
+
throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');
|
|
27
|
+
}
|
|
28
|
+
if (identifier.includes('\0')) {
|
|
29
|
+
throw new SqlEscapeError(
|
|
30
|
+
'Identifier cannot contain null bytes',
|
|
31
|
+
identifier.replace(/\0/g, '\\0'),
|
|
32
|
+
'identifier',
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return `"${identifier.replace(/"/g, '""')}"`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function escapeLiteral(value: string): string {
|
|
39
|
+
if (value.includes('\0')) {
|
|
40
|
+
throw new SqlEscapeError(
|
|
41
|
+
'Literal value cannot contain null bytes',
|
|
42
|
+
value.replace(/\0/g, '\\0'),
|
|
43
|
+
'literal',
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return value.replace(/'/g, "''");
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {
|
|
2
|
+
SQL_CHAR_CODEC_ID,
|
|
3
|
+
SQL_FLOAT_CODEC_ID,
|
|
4
|
+
SQL_INT_CODEC_ID,
|
|
5
|
+
SQL_VARCHAR_CODEC_ID,
|
|
6
|
+
SQLITE_BIGINT_CODEC_ID,
|
|
7
|
+
SQLITE_BLOB_CODEC_ID,
|
|
8
|
+
SQLITE_DATETIME_CODEC_ID,
|
|
9
|
+
SQLITE_INTEGER_CODEC_ID,
|
|
10
|
+
SQLITE_JSON_CODEC_ID,
|
|
11
|
+
SQLITE_REAL_CODEC_ID,
|
|
12
|
+
SQLITE_TEXT_CODEC_ID,
|
|
13
|
+
} from '../core/codec-ids';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codec type definitions for the SQLite target.
|
|
3
|
+
*
|
|
4
|
+
* Defining `CodecTypes` here (rather than re-exporting from `core/codecs`) keeps the tsdown DTS bundler from emitting a private chunk path in downstream `.d.mts` files: consumers see `CodecTypes` resolved via this public entry point rather than via a hash-named internal chunk (TML-2357).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ExtractCodecTypes } from '@prisma-next/sql-relational-core/ast';
|
|
8
|
+
import {
|
|
9
|
+
sqlCharDescriptor,
|
|
10
|
+
sqlFloatDescriptor,
|
|
11
|
+
sqlIntDescriptor,
|
|
12
|
+
sqlVarcharDescriptor,
|
|
13
|
+
} from '@prisma-next/sql-relational-core/ast';
|
|
14
|
+
import type { JsonValue } from '../core/codec-helpers';
|
|
15
|
+
import {
|
|
16
|
+
sqliteBigintDescriptor,
|
|
17
|
+
sqliteBlobDescriptor,
|
|
18
|
+
sqliteDatetimeDescriptor,
|
|
19
|
+
sqliteIntegerDescriptor,
|
|
20
|
+
sqliteJsonDescriptor,
|
|
21
|
+
sqliteRealDescriptor,
|
|
22
|
+
sqliteTextDescriptor,
|
|
23
|
+
} from '../core/codecs';
|
|
24
|
+
|
|
25
|
+
const codecDescriptorMap = {
|
|
26
|
+
char: sqlCharDescriptor,
|
|
27
|
+
varchar: sqlVarcharDescriptor,
|
|
28
|
+
int: sqlIntDescriptor,
|
|
29
|
+
float: sqlFloatDescriptor,
|
|
30
|
+
text: sqliteTextDescriptor,
|
|
31
|
+
integer: sqliteIntegerDescriptor,
|
|
32
|
+
real: sqliteRealDescriptor,
|
|
33
|
+
blob: sqliteBlobDescriptor,
|
|
34
|
+
datetime: sqliteDatetimeDescriptor,
|
|
35
|
+
json: sqliteJsonDescriptor,
|
|
36
|
+
bigint: sqliteBigintDescriptor,
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
type Resolve<T> = { readonly [K in keyof T]: { readonly [P in keyof T[K]]: T[K][P] } };
|
|
40
|
+
|
|
41
|
+
export type CodecTypes = Resolve<ExtractCodecTypes<typeof codecDescriptorMap>>;
|
|
42
|
+
|
|
43
|
+
export type { JsonValue };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type { JsonValue } from '../core/codec-helpers';
|
|
2
|
+
export type {
|
|
3
|
+
SqliteBigintDescriptor,
|
|
4
|
+
SqliteBlobDescriptor,
|
|
5
|
+
SqliteDatetimeDescriptor,
|
|
6
|
+
SqliteIntegerDescriptor,
|
|
7
|
+
SqliteJsonDescriptor,
|
|
8
|
+
SqliteRealDescriptor,
|
|
9
|
+
SqliteTextDescriptor,
|
|
10
|
+
} from '../core/codecs';
|
|
11
|
+
export {
|
|
12
|
+
sqliteBigintColumn,
|
|
13
|
+
sqliteBlobColumn,
|
|
14
|
+
sqliteDatetimeColumn,
|
|
15
|
+
sqliteIntegerColumn,
|
|
16
|
+
sqliteJsonColumn,
|
|
17
|
+
sqliteRealColumn,
|
|
18
|
+
sqliteTextColumn,
|
|
19
|
+
} from '../core/codecs';
|
|
20
|
+
export { sqliteCodecRegistry } from '../core/registry';
|
package/src/exports/control.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parseSqliteDefault } from '../core/default-normalizer';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Re-exported so a SQLite `migration.ts` only needs the single
|
|
2
|
+
// `@prisma-next/target-sqlite/migration` import for its base class and
|
|
3
|
+
// the CLI entrypoint, mirroring how `placeholder` is surfaced here. The
|
|
4
|
+
// renderer emits the entrypoint call as
|
|
5
|
+
// `MigrationCLI.run(import.meta.url, M)`.
|
|
6
|
+
export { MigrationCLI } from '@prisma-next/cli/migration-cli';
|
|
7
|
+
// Re-exported so user-edited migration.ts files only need to depend on
|
|
8
|
+
// `@prisma-next/target-sqlite/migration` to fill in planner-emitted
|
|
9
|
+
// `placeholder("…")` slots, instead of pulling in `@prisma-next/errors`
|
|
10
|
+
// directly. The planner emits an import from this same module.
|
|
11
|
+
export { placeholder } from '@prisma-next/errors/migration';
|
|
12
|
+
export { addColumn, dropColumn } from '../core/migrations/operations/columns';
|
|
13
|
+
export {
|
|
14
|
+
type DataTransformOptions,
|
|
15
|
+
dataTransform,
|
|
16
|
+
} from '../core/migrations/operations/data-transform';
|
|
17
|
+
export { createIndex, dropIndex } from '../core/migrations/operations/indexes';
|
|
18
|
+
export { rawSql } from '../core/migrations/operations/raw';
|
|
19
|
+
export { createTable, dropTable, recreateTable } from '../core/migrations/operations/tables';
|
|
20
|
+
// Target-owned base class for migrations. Aliased to `Migration` so
|
|
21
|
+
// user-edited migration.ts files (and the renderer's scaffold) read as
|
|
22
|
+
// `class M extends Migration { … }` without having to thread the
|
|
23
|
+
// target-details generic or redeclare `targetId`.
|
|
24
|
+
export { SqliteMigration as Migration } from '../core/migrations/sqlite-migration';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { normalizeSqliteNativeType } from '../core/native-type-normalizer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { renderOps } from '../core/migrations/render-ops';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { escapeLiteral, quoteIdentifier, SqlEscapeError } from '../core/sql-utils';
|
|
@@ -0,0 +1,12 @@
|
|
|
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';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/core/descriptor-meta.ts
|
|
2
|
-
const sqliteTargetDescriptorMetaBase = {
|
|
3
|
-
kind: "target",
|
|
4
|
-
familyId: "sql",
|
|
5
|
-
targetId: "sqlite",
|
|
6
|
-
id: "sqlite",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
capabilities: {}
|
|
9
|
-
};
|
|
10
|
-
const sqliteTargetDescriptorMeta = sqliteTargetDescriptorMetaBase;
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { sqliteTargetDescriptorMeta as t };
|
|
14
|
-
//# sourceMappingURL=descriptor-meta-DbuuziYA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-DbuuziYA.mjs","names":["sqliteTargetDescriptorMeta: typeof sqliteTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n}"],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { CodecTypes } from '@prisma-next/adapter-sqlite/codec-types';\n\nconst sqliteTargetDescriptorMetaBase = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'sqlite',\n id: 'sqlite',\n version: '0.0.1',\n capabilities: {},\n} as const;\n\nexport const sqliteTargetDescriptorMeta: typeof sqliteTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = sqliteTargetDescriptorMetaBase;\n"],"mappings":";AAEA,MAAM,iCAAiC;CACrC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EAAE;CACjB;AAED,MAAaA,6BAET"}
|