@prisma/orm-target-sqlite 0.16.0-dev.36
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/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/adapter-DizMsGCb-n4h4w8ms.d.mts +22 -0
- package/dist/adapter-DizMsGCb-n4h4w8ms.d.mts.map +1 -0
- package/dist/adapter-m_BtnNSn.d.mts +2 -0
- package/dist/adapter-wc9p_v2Z-y8pzqMfG.mjs +997 -0
- package/dist/adapter-wc9p_v2Z-y8pzqMfG.mjs.map +1 -0
- package/dist/adapter.d.mts +14 -0
- package/dist/adapter.mjs +6 -0
- package/dist/adapter__adapter.d.mts +4 -0
- package/dist/adapter__adapter.mjs +2 -0
- package/dist/adapter__codec-types.d.mts +4 -0
- package/dist/adapter__codec-types.mjs +1 -0
- package/dist/adapter__column-types.d.mts +2 -0
- package/dist/adapter__column-types.mjs +2 -0
- package/dist/adapter__control.d.mts +5 -0
- package/dist/adapter__control.mjs +261 -0
- package/dist/adapter__control.mjs.map +1 -0
- package/dist/adapter__runtime.d.mts +2 -0
- package/dist/adapter__runtime.mjs +32 -0
- package/dist/adapter__runtime.mjs.map +1 -0
- package/dist/adapter__types.d.mts +3 -0
- package/dist/adapter__types.mjs +1 -0
- package/dist/codec-descriptor-BcgD9f3L-BjEkn9Ob.d.mts +31 -0
- package/dist/codec-descriptor-BcgD9f3L-BjEkn9Ob.d.mts.map +1 -0
- package/dist/codec-descriptor-CyCQXvSl.d.mts +2 -0
- package/dist/codec-descriptor-kVCSW1OR-CPatZUPM.mjs +104 -0
- package/dist/codec-descriptor-kVCSW1OR-CPatZUPM.mjs.map +1 -0
- package/dist/codec-descriptor-rFuZ9DzY-DO0k8l6N.d.mts +1 -0
- package/dist/codec-ids-ChRBs2aB.d.mts +1 -0
- package/dist/codec-ids-DocGjhs--CHhP1jNZ.d.mts +13 -0
- package/dist/codec-ids-DocGjhs--CHhP1jNZ.d.mts.map +1 -0
- package/dist/codec-ids-xicqpuAa-DHnKqnIs.mjs +13 -0
- package/dist/codec-ids-xicqpuAa-DHnKqnIs.mjs.map +1 -0
- package/dist/codec-types-DKB--ltR-CIuvX0zx.d.mts +24 -0
- package/dist/codec-types-DKB--ltR-CIuvX0zx.d.mts.map +1 -0
- package/dist/codec-types-Tw3EFTjf.d.mts +1 -0
- package/dist/codec-types-wPDlPoD7.d.mts +2 -0
- package/dist/codecs-1-oOsTPG-Bv518Lbm.d.mts +155 -0
- package/dist/codecs-1-oOsTPG-Bv518Lbm.d.mts.map +1 -0
- package/dist/codecs-CM_2W3uA.mjs +345 -0
- package/dist/codecs-CM_2W3uA.mjs.map +1 -0
- package/dist/codecs-j-8RDkOt.d.mts +1 -0
- package/dist/column-types-StKUDF6A.mjs +34 -0
- package/dist/column-types-StKUDF6A.mjs.map +1 -0
- package/dist/column-types-iWGuW-0W.d.mts +33 -0
- package/dist/column-types-iWGuW-0W.d.mts.map +1 -0
- package/dist/contract-free-CCLAXZV2.d.mts +88 -0
- package/dist/contract-free-CCLAXZV2.d.mts.map +1 -0
- package/dist/contract-free-DElSXD0q.mjs +90 -0
- package/dist/contract-free-DElSXD0q.mjs.map +1 -0
- package/dist/control--wMueaTg.d.mts +61 -0
- package/dist/control--wMueaTg.d.mts.map +1 -0
- package/dist/control-8G9x72lw.mjs +42 -0
- package/dist/control-8G9x72lw.mjs.map +1 -0
- package/dist/control-DLO163u8.d.mts +19 -0
- package/dist/control-DLO163u8.d.mts.map +1 -0
- package/dist/control-cahq7u71.d.mts +117 -0
- package/dist/control-cahq7u71.d.mts.map +1 -0
- package/dist/control-tables-D_o8dKRB-BXi43noL.mjs +12 -0
- package/dist/control-tables-D_o8dKRB-BXi43noL.mjs.map +1 -0
- package/dist/control-tables-Dua-YcJL.d.mts +12 -0
- package/dist/control-tables-Dua-YcJL.d.mts.map +1 -0
- package/dist/ddl-CW34JvfE-rd1ZIxOn.mjs +66 -0
- package/dist/ddl-CW34JvfE-rd1ZIxOn.mjs.map +1 -0
- package/dist/ddl-CfSqNT0M.d.mts +1 -0
- package/dist/default-normalizer-B9V7TY5u.d.mts +7 -0
- package/dist/default-normalizer-B9V7TY5u.d.mts.map +1 -0
- package/dist/default-normalizer-DuoHj9-O-DsK7lJZn.mjs +69 -0
- package/dist/default-normalizer-DuoHj9-O-DsK7lJZn.mjs.map +1 -0
- package/dist/descriptor-meta-CbYkqTkO-DEJNrICG.mjs +30 -0
- package/dist/descriptor-meta-CbYkqTkO-DEJNrICG.mjs.map +1 -0
- package/dist/descriptor-meta-DnwDwnGg-D3f936hn.mjs +23 -0
- package/dist/descriptor-meta-DnwDwnGg-D3f936hn.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-BkXK3OjD-CxZdKHCw.mjs +13 -0
- package/dist/descriptor-meta-runtime-BkXK3OjD-CxZdKHCw.mjs.map +1 -0
- package/dist/descriptor-meta-vjJkUDsn-Hz3rnAnk.mjs +70 -0
- package/dist/descriptor-meta-vjJkUDsn-Hz3rnAnk.mjs.map +1 -0
- package/dist/driver.d.mts +3 -0
- package/dist/driver.mjs +2 -0
- package/dist/driver__control.d.mts +2 -0
- package/dist/driver__control.mjs +2 -0
- package/dist/driver__runtime.d.mts +2 -0
- package/dist/driver__runtime.mjs +197 -0
- package/dist/driver__runtime.mjs.map +1 -0
- package/dist/errors-CKsaaSnD-BeB4JS8h.mjs +38 -0
- package/dist/errors-CKsaaSnD-BeB4JS8h.mjs.map +1 -0
- package/dist/migration-jsmNRI_8.mjs +47 -0
- package/dist/migration-jsmNRI_8.mjs.map +1 -0
- package/dist/migration-uylRe5MP.d.mts +43 -0
- package/dist/migration-uylRe5MP.d.mts.map +1 -0
- package/dist/native-type-normalizer-CO2wKGL6.d.mts +12 -0
- package/dist/native-type-normalizer-CO2wKGL6.d.mts.map +1 -0
- package/dist/native-type-normalizer-GpQMEyN5.mjs +14 -0
- package/dist/native-type-normalizer-GpQMEyN5.mjs.map +1 -0
- package/dist/nodes-D8EC1yCx-rpfpuJ4T.d.mts +29 -0
- package/dist/nodes-D8EC1yCx-rpfpuJ4T.d.mts.map +1 -0
- package/dist/nodes-DUZSdX86-BBEEaxXY.mjs +33 -0
- package/dist/nodes-DUZSdX86-BBEEaxXY.mjs.map +1 -0
- package/dist/op-factory-call-C_or6163-B_LDzC37.mjs +829 -0
- package/dist/op-factory-call-C_or6163-B_LDzC37.mjs.map +1 -0
- package/dist/op-factory-call-DoHN7Q7L.d.mts +161 -0
- package/dist/op-factory-call-DoHN7Q7L.d.mts.map +1 -0
- package/dist/pack-BfwyQ0b3.d.mts +93 -0
- package/dist/pack-BfwyQ0b3.d.mts.map +1 -0
- package/dist/planner-Bxdi7jZF.d.mts +104 -0
- package/dist/planner-Bxdi7jZF.d.mts.map +1 -0
- package/dist/planner-DiGcIjl1-QnNAhVmX.mjs +811 -0
- package/dist/planner-DiGcIjl1-QnNAhVmX.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration-BuJysRxx-CaDUbNVx.d.mts +31 -0
- package/dist/planner-produced-sqlite-migration-BuJysRxx-CaDUbNVx.d.mts.map +1 -0
- package/dist/planner-produced-sqlite-migration-C8nxPT0P-DdBqfmAD.mjs +150 -0
- package/dist/planner-produced-sqlite-migration-C8nxPT0P-DdBqfmAD.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration-uySoqJO-.d.mts +1 -0
- package/dist/planner-target-details-CIQ789Gc-C5U4yVY9.mjs +15 -0
- package/dist/planner-target-details-CIQ789Gc-C5U4yVY9.mjs.map +1 -0
- package/dist/planner-target-details-xR6UfIcz-CMahymzq.d.mts +13 -0
- package/dist/planner-target-details-xR6UfIcz-CMahymzq.d.mts.map +1 -0
- package/dist/render-ops-B10yqmdG.d.mts +11 -0
- package/dist/render-ops-B10yqmdG.d.mts.map +1 -0
- package/dist/render-ops-DIOn_wOx-D33LOy3b.mjs +27 -0
- package/dist/render-ops-DIOn_wOx-D33LOy3b.mjs.map +1 -0
- package/dist/runtime-B1coahKC.d.mts +15 -0
- package/dist/runtime-B1coahKC.d.mts.map +1 -0
- package/dist/runtime-B99c4n56.d.mts +28 -0
- package/dist/runtime-B99c4n56.d.mts.map +1 -0
- package/dist/runtime-tbBYTw7Z.d.mts +10 -0
- package/dist/runtime-tbBYTw7Z.d.mts.map +1 -0
- package/dist/shared-BYAX0FaQ--VvRXVRC.d.mts +68 -0
- package/dist/shared-BYAX0FaQ--VvRXVRC.d.mts.map +1 -0
- package/dist/sql-utils-0SJZOd7Q.d.mts +18 -0
- package/dist/sql-utils-0SJZOd7Q.d.mts.map +1 -0
- package/dist/sql-utils-DqPXZBMA-Mm27NNjs.mjs +35 -0
- package/dist/sql-utils-DqPXZBMA-Mm27NNjs.mjs.map +1 -0
- package/dist/sqlite-contract-view-BpNMaU2m-COMDaGaq.d.mts +31 -0
- package/dist/sqlite-contract-view-BpNMaU2m-COMDaGaq.d.mts.map +1 -0
- package/dist/sqlite-contract-view-CnDITHEE-BvjSbmzL.mjs +151 -0
- package/dist/sqlite-contract-view-CnDITHEE-BvjSbmzL.mjs.map +1 -0
- package/dist/sqlite-migration-CV6LIqhx-D5eMTAbH.mjs +94 -0
- package/dist/sqlite-migration-CV6LIqhx-D5eMTAbH.mjs.map +1 -0
- package/dist/sqlite-migration-o23JHwzY-CwNJcqwl.d.mts +105 -0
- package/dist/sqlite-migration-o23JHwzY-CwNJcqwl.d.mts.map +1 -0
- package/dist/target.d.mts +28 -0
- package/dist/target.mjs +19 -0
- package/dist/target__codec-descriptor.d.mts +3 -0
- package/dist/target__codec-descriptor.mjs +2 -0
- package/dist/target__codec-ids.d.mts +3 -0
- package/dist/target__codec-ids.mjs +2 -0
- package/dist/target__codec-types.d.mts +4 -0
- package/dist/target__codec-types.mjs +1 -0
- package/dist/target__codecs.d.mts +3 -0
- package/dist/target__codecs.mjs +2 -0
- package/dist/target__contract-free.d.mts +2 -0
- package/dist/target__contract-free.mjs +3 -0
- package/dist/target__control-tables.d.mts +2 -0
- package/dist/target__control-tables.mjs +2 -0
- package/dist/target__control.d.mts +3 -0
- package/dist/target__control.mjs +432 -0
- package/dist/target__control.mjs.map +1 -0
- package/dist/target__ddl.d.mts +3 -0
- package/dist/target__ddl.mjs +2 -0
- package/dist/target__default-normalizer.d.mts +2 -0
- package/dist/target__default-normalizer.mjs +2 -0
- package/dist/target__migration.d.mts +3 -0
- package/dist/target__migration.mjs +3 -0
- package/dist/target__native-type-normalizer.d.mts +2 -0
- package/dist/target__native-type-normalizer.mjs +2 -0
- package/dist/target__op-factory-call.d.mts +2 -0
- package/dist/target__op-factory-call.mjs +2 -0
- package/dist/target__pack.d.mts +2 -0
- package/dist/target__pack.mjs +2 -0
- package/dist/target__planner-produced-sqlite-migration.d.mts +3 -0
- package/dist/target__planner-produced-sqlite-migration.mjs +2 -0
- package/dist/target__planner-target-details.d.mts +2 -0
- package/dist/target__planner-target-details.mjs +2 -0
- package/dist/target__planner.d.mts +2 -0
- package/dist/target__planner.mjs +2 -0
- package/dist/target__render-ops.d.mts +2 -0
- package/dist/target__render-ops.mjs +2 -0
- package/dist/target__runtime.d.mts +3 -0
- package/dist/target__runtime.mjs +17 -0
- package/dist/target__runtime.mjs.map +1 -0
- package/dist/target__sql-utils.d.mts +2 -0
- package/dist/target__sql-utils.mjs +2 -0
- package/dist/types-C5FSREvo-Bm6N5Kog.d.mts +25 -0
- package/dist/types-C5FSREvo-Bm6N5Kog.d.mts.map +1 -0
- package/dist/types-DiH2oWUJ.d.mts +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { a as sqliteCodec, n as buildSqliteCodecDescriptorRegistry, r as defineSqliteCodecs, t as SqliteCodecDescriptor } from "./codec-descriptor-kVCSW1OR-CPatZUPM.mjs";
|
|
2
|
+
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-xicqpuAa-DHnKqnIs.mjs";
|
|
3
|
+
import { n as sqliteError } from "./errors-CKsaaSnD-BeB4JS8h.mjs";
|
|
4
|
+
import { CodecImpl, column, voidParamsSchema } from "@prisma/orm-framework/components/codec";
|
|
5
|
+
import { CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlVarcharDescriptor } from "@prisma/orm-family-sql/relational-core/ast";
|
|
6
|
+
import { buildCodecDescriptorRegistry } from "@prisma/orm-family-sql/relational-core/codec-descriptor-registry";
|
|
7
|
+
//#region ../../../3-targets/3-targets/sqlite/dist/codecs.mjs
|
|
8
|
+
/**
|
|
9
|
+
* Projects the expression unchanged, for codecs whose canonical JSON is what
|
|
10
|
+
* SQLite's own JSON conversion already produces.
|
|
11
|
+
*
|
|
12
|
+
* Identity here is a claim about the target's behaviour, not an absence of one:
|
|
13
|
+
* the codec's conformance cases are what test it, including at the boundaries
|
|
14
|
+
* of the representation where a native conversion would be most likely to
|
|
15
|
+
* diverge.
|
|
16
|
+
*/
|
|
17
|
+
const identityJsonProjection = (expression) => expression;
|
|
18
|
+
/**
|
|
19
|
+
* Projects an integer-valued expression as decimal text.
|
|
20
|
+
*
|
|
21
|
+
* The cast is part of the projected expression, so it applies before the JSON
|
|
22
|
+
* constructor sees the value: handed an INTEGER directly, the constructor emits
|
|
23
|
+
* a JSON number, and SQLite's 64-bit range does not survive being read back as
|
|
24
|
+
* a double. Casting the constructor's result would be too late.
|
|
25
|
+
*/
|
|
26
|
+
const decimalTextJsonProjection = (expression) => CastExpr.as(expression, "TEXT");
|
|
27
|
+
/**
|
|
28
|
+
* Projects a BLOB as hexadecimal text.
|
|
29
|
+
*
|
|
30
|
+
* SQLite's JSON functions reject a BLOB argument outright, so the encoding has
|
|
31
|
+
* to replace the native conversion rather than post-process it. `hex()` emits
|
|
32
|
+
* uppercase and never wraps at any length, which is the spelling `encodeJson`
|
|
33
|
+
* pins.
|
|
34
|
+
*
|
|
35
|
+
* `hex(NULL)` is `''` rather than NULL, and `''` is the hex of an empty blob —
|
|
36
|
+
* so without the NULL check an absent blob and an empty one would both project
|
|
37
|
+
* as `''`, and `decodeJson` accepts `''` because zero hex pairs is a valid
|
|
38
|
+
* empty blob. The check keeps the two distinguishable.
|
|
39
|
+
*/
|
|
40
|
+
const hexJsonProjection = (expression) => CaseExpr.of([{
|
|
41
|
+
condition: NullCheckExpr.isNull(expression),
|
|
42
|
+
value: LiteralExpr.of(null)
|
|
43
|
+
}], FunctionCallExpr.of("hex", [expression]));
|
|
44
|
+
const JSON_RETAG_FN = "json";
|
|
45
|
+
/**
|
|
46
|
+
* Re-applies SQLite's JSON subtype to a document-valued expression.
|
|
47
|
+
*
|
|
48
|
+
* SQLite carries "this text is JSON" as a subtype on the value rather than in
|
|
49
|
+
* its type, and the subtype does not survive a derived table: a document that
|
|
50
|
+
* `json_object` produced arrives one level out as plain text, so the enclosing
|
|
51
|
+
* constructor embeds it as a *string containing JSON* rather than as a
|
|
52
|
+
* document. `json()` re-applies the subtype, which is what makes the value nest
|
|
53
|
+
* as a document again.
|
|
54
|
+
*
|
|
55
|
+
* The loss happens at the first derived-table boundary and does not compound, so
|
|
56
|
+
* a retag is needed where the document is consumed rather than at every level it
|
|
57
|
+
* passes through.
|
|
58
|
+
*
|
|
59
|
+
* Applying this twice is a no-op — SQLite's `json()` is idempotent, and the
|
|
60
|
+
* wrapper collapses rather than nesting so the rendered SQL says so too. It is
|
|
61
|
+
* safe on any valid JSON text, including scalars, and on NULL; it raises
|
|
62
|
+
* `malformed JSON` on text that is not JSON, which is the correct failure for a
|
|
63
|
+
* value that was never a document.
|
|
64
|
+
*/
|
|
65
|
+
const jsonDocumentRetag = (expression) => isJsonRetag(expression) ? expression : FunctionCallExpr.of(JSON_RETAG_FN, [expression]);
|
|
66
|
+
/** Whether an expression is already a retag, so applying one again would only nest. */
|
|
67
|
+
const isJsonRetag = (expression) => expression instanceof FunctionCallExpr && expression.fn === JSON_RETAG_FN && expression.args.length === 1;
|
|
68
|
+
const DECIMAL_INTEGER = /^-?\d+$/;
|
|
69
|
+
const UPPERCASE_HEX = /^(?:[0-9A-F]{2})*$/;
|
|
70
|
+
/**
|
|
71
|
+
* JSON has no spelling for an infinity or a NaN, and SQLite renders one as
|
|
72
|
+
* `9.0e+999`, which reads back as `Infinity` rather than failing. A real is
|
|
73
|
+
* therefore carried only where it is finite.
|
|
74
|
+
*/
|
|
75
|
+
const finiteReal = (value, code) => {
|
|
76
|
+
if (!Number.isFinite(value)) throw sqliteError(code, "sqlite/real@1 value must be a finite number", { meta: {
|
|
77
|
+
codecId: SQLITE_REAL_CODEC_ID,
|
|
78
|
+
received: String(value)
|
|
79
|
+
} });
|
|
80
|
+
return value;
|
|
81
|
+
};
|
|
82
|
+
const sqliteSqlCharDescriptor = sqliteCodec(sqlCharDescriptor, { jsonProjection: identityJsonProjection });
|
|
83
|
+
const sqliteSqlVarcharDescriptor = sqliteCodec(sqlVarcharDescriptor, { jsonProjection: identityJsonProjection });
|
|
84
|
+
const sqliteSqlIntDescriptor = sqliteCodec(sqlIntDescriptor, { jsonProjection: identityJsonProjection });
|
|
85
|
+
const sqliteSqlFloatDescriptor = sqliteCodec(sqlFloatDescriptor, { jsonProjection: identityJsonProjection });
|
|
86
|
+
var SqliteTextCodec = class extends CodecImpl {
|
|
87
|
+
async encode(value, _ctx) {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
async decode(wire, _ctx) {
|
|
91
|
+
return wire;
|
|
92
|
+
}
|
|
93
|
+
encodeJson(value) {
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
decodeJson(json) {
|
|
97
|
+
return json;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var SqliteTextDescriptor = class extends SqliteCodecDescriptor {
|
|
101
|
+
jsonProjection(expression) {
|
|
102
|
+
return expression;
|
|
103
|
+
}
|
|
104
|
+
codecId = SQLITE_TEXT_CODEC_ID;
|
|
105
|
+
traits = [
|
|
106
|
+
"equality",
|
|
107
|
+
"order",
|
|
108
|
+
"textual"
|
|
109
|
+
];
|
|
110
|
+
targetTypes = ["text"];
|
|
111
|
+
paramsSchema = voidParamsSchema;
|
|
112
|
+
factory() {
|
|
113
|
+
return () => new SqliteTextCodec(this);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const sqliteTextDescriptor = new SqliteTextDescriptor();
|
|
117
|
+
const sqliteTextColumn = () => column(sqliteTextDescriptor.factory(), sqliteTextDescriptor.codecId, void 0, "text");
|
|
118
|
+
var SqliteIntegerCodec = class extends CodecImpl {
|
|
119
|
+
async encode(value, _ctx) {
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
async decode(wire, _ctx) {
|
|
123
|
+
return wire;
|
|
124
|
+
}
|
|
125
|
+
encodeJson(value) {
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
decodeJson(json) {
|
|
129
|
+
return json;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var SqliteIntegerDescriptor = class extends SqliteCodecDescriptor {
|
|
133
|
+
jsonProjection(expression) {
|
|
134
|
+
return expression;
|
|
135
|
+
}
|
|
136
|
+
codecId = SQLITE_INTEGER_CODEC_ID;
|
|
137
|
+
traits = [
|
|
138
|
+
"equality",
|
|
139
|
+
"order",
|
|
140
|
+
"numeric"
|
|
141
|
+
];
|
|
142
|
+
targetTypes = ["integer"];
|
|
143
|
+
paramsSchema = voidParamsSchema;
|
|
144
|
+
factory() {
|
|
145
|
+
return () => new SqliteIntegerCodec(this);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const sqliteIntegerDescriptor = new SqliteIntegerDescriptor();
|
|
149
|
+
const sqliteIntegerColumn = () => column(sqliteIntegerDescriptor.factory(), sqliteIntegerDescriptor.codecId, void 0, "integer");
|
|
150
|
+
var SqliteRealCodec = class extends CodecImpl {
|
|
151
|
+
async encode(value, _ctx) {
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
async decode(wire, _ctx) {
|
|
155
|
+
return wire;
|
|
156
|
+
}
|
|
157
|
+
encodeJson(value) {
|
|
158
|
+
return finiteReal(value, "RUNTIME.ENCODE_FAILED");
|
|
159
|
+
}
|
|
160
|
+
decodeJson(json) {
|
|
161
|
+
if (typeof json !== "number") throw sqliteError("RUNTIME.DECODE_FAILED", "sqlite/real@1 database JSON value must be a number", { meta: {
|
|
162
|
+
codecId: SQLITE_REAL_CODEC_ID,
|
|
163
|
+
received: typeof json
|
|
164
|
+
} });
|
|
165
|
+
return finiteReal(json, "RUNTIME.DECODE_FAILED");
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var SqliteRealDescriptor = class extends SqliteCodecDescriptor {
|
|
169
|
+
jsonProjection(expression) {
|
|
170
|
+
return expression;
|
|
171
|
+
}
|
|
172
|
+
codecId = SQLITE_REAL_CODEC_ID;
|
|
173
|
+
traits = [
|
|
174
|
+
"equality",
|
|
175
|
+
"order",
|
|
176
|
+
"numeric"
|
|
177
|
+
];
|
|
178
|
+
targetTypes = ["real"];
|
|
179
|
+
paramsSchema = voidParamsSchema;
|
|
180
|
+
factory() {
|
|
181
|
+
return () => new SqliteRealCodec(this);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const sqliteRealDescriptor = new SqliteRealDescriptor();
|
|
185
|
+
const sqliteRealColumn = () => column(sqliteRealDescriptor.factory(), sqliteRealDescriptor.codecId, void 0, "real");
|
|
186
|
+
var SqliteBlobCodec = class extends CodecImpl {
|
|
187
|
+
async encode(value, _ctx) {
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
async decode(wire, _ctx) {
|
|
191
|
+
return wire;
|
|
192
|
+
}
|
|
193
|
+
encodeJson(value) {
|
|
194
|
+
return Buffer.from(value).toString("hex").toUpperCase();
|
|
195
|
+
}
|
|
196
|
+
decodeJson(json) {
|
|
197
|
+
if (typeof json !== "string" || !UPPERCASE_HEX.test(json)) throw sqliteError("RUNTIME.DECODE_FAILED", "sqlite/blob@1 database JSON value must be uppercase hexadecimal text", { meta: {
|
|
198
|
+
codecId: SQLITE_BLOB_CODEC_ID,
|
|
199
|
+
received: typeof json
|
|
200
|
+
} });
|
|
201
|
+
return new Uint8Array(Buffer.from(json, "hex"));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var SqliteBlobDescriptor = class extends SqliteCodecDescriptor {
|
|
205
|
+
jsonProjection(expression) {
|
|
206
|
+
return hexJsonProjection(expression);
|
|
207
|
+
}
|
|
208
|
+
codecId = SQLITE_BLOB_CODEC_ID;
|
|
209
|
+
traits = ["equality"];
|
|
210
|
+
targetTypes = ["blob"];
|
|
211
|
+
paramsSchema = voidParamsSchema;
|
|
212
|
+
factory() {
|
|
213
|
+
return () => new SqliteBlobCodec(this);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const sqliteBlobDescriptor = new SqliteBlobDescriptor();
|
|
217
|
+
const sqliteBlobColumn = () => column(sqliteBlobDescriptor.factory(), sqliteBlobDescriptor.codecId, void 0, "blob");
|
|
218
|
+
var SqliteDatetimeCodec = class extends CodecImpl {
|
|
219
|
+
parseDate(value) {
|
|
220
|
+
const date = new Date(value);
|
|
221
|
+
if (Number.isNaN(date.getTime())) throw sqliteError("RUNTIME.DECODE_FAILED", `sqlite/datetime@1 value must be a valid ISO-8601 string: ${value}`, { meta: {
|
|
222
|
+
codecId: SQLITE_DATETIME_CODEC_ID,
|
|
223
|
+
received: value
|
|
224
|
+
} });
|
|
225
|
+
return date;
|
|
226
|
+
}
|
|
227
|
+
async encode(value, _ctx) {
|
|
228
|
+
return value.toISOString();
|
|
229
|
+
}
|
|
230
|
+
async decode(wire, _ctx) {
|
|
231
|
+
return this.parseDate(wire);
|
|
232
|
+
}
|
|
233
|
+
encodeJson(value) {
|
|
234
|
+
return value.toISOString();
|
|
235
|
+
}
|
|
236
|
+
decodeJson(json) {
|
|
237
|
+
if (typeof json !== "string") throw sqliteError("RUNTIME.DECODE_FAILED", "sqlite/datetime@1 contract value must be an ISO-8601 string", { meta: {
|
|
238
|
+
codecId: SQLITE_DATETIME_CODEC_ID,
|
|
239
|
+
received: typeof json
|
|
240
|
+
} });
|
|
241
|
+
return this.parseDate(json);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
var SqliteDatetimeDescriptor = class extends SqliteCodecDescriptor {
|
|
245
|
+
jsonProjection(expression) {
|
|
246
|
+
return expression;
|
|
247
|
+
}
|
|
248
|
+
codecId = SQLITE_DATETIME_CODEC_ID;
|
|
249
|
+
traits = ["equality", "order"];
|
|
250
|
+
targetTypes = ["text"];
|
|
251
|
+
paramsSchema = voidParamsSchema;
|
|
252
|
+
factory() {
|
|
253
|
+
return () => new SqliteDatetimeCodec(this);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const sqliteDatetimeDescriptor = new SqliteDatetimeDescriptor();
|
|
257
|
+
const sqliteDatetimeColumn = () => column(sqliteDatetimeDescriptor.factory(), sqliteDatetimeDescriptor.codecId, void 0, "text");
|
|
258
|
+
var SqliteJsonCodec = class extends CodecImpl {
|
|
259
|
+
async encode(value, _ctx) {
|
|
260
|
+
return JSON.stringify(value);
|
|
261
|
+
}
|
|
262
|
+
async decode(wire, _ctx) {
|
|
263
|
+
return typeof wire === "string" ? JSON.parse(wire) : wire;
|
|
264
|
+
}
|
|
265
|
+
encodeJson(value) {
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
decodeJson(json) {
|
|
269
|
+
return json;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var SqliteJsonDescriptor = class extends SqliteCodecDescriptor {
|
|
273
|
+
jsonProjection(expression) {
|
|
274
|
+
return jsonDocumentRetag(expression);
|
|
275
|
+
}
|
|
276
|
+
codecId = SQLITE_JSON_CODEC_ID;
|
|
277
|
+
traits = ["equality"];
|
|
278
|
+
targetTypes = ["text"];
|
|
279
|
+
paramsSchema = voidParamsSchema;
|
|
280
|
+
factory() {
|
|
281
|
+
return () => new SqliteJsonCodec(this);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
const sqliteJsonDescriptor = new SqliteJsonDescriptor();
|
|
285
|
+
const sqliteJsonColumn = () => column(sqliteJsonDescriptor.factory(), sqliteJsonDescriptor.codecId, void 0, "text");
|
|
286
|
+
var SqliteBigintCodec = class extends CodecImpl {
|
|
287
|
+
async encode(value, _ctx) {
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
290
|
+
async decode(wire, _ctx) {
|
|
291
|
+
return BigInt(wire);
|
|
292
|
+
}
|
|
293
|
+
encodeJson(value) {
|
|
294
|
+
return value.toString();
|
|
295
|
+
}
|
|
296
|
+
decodeJson(json) {
|
|
297
|
+
if (typeof json !== "string" || !DECIMAL_INTEGER.test(json)) throw sqliteError("RUNTIME.DECODE_FAILED", "sqlite/bigint@1 database JSON value must be a decimal string", { meta: {
|
|
298
|
+
codecId: SQLITE_BIGINT_CODEC_ID,
|
|
299
|
+
received: typeof json
|
|
300
|
+
} });
|
|
301
|
+
return BigInt(json);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var SqliteBigintDescriptor = class extends SqliteCodecDescriptor {
|
|
305
|
+
jsonProjection(expression) {
|
|
306
|
+
return decimalTextJsonProjection(expression);
|
|
307
|
+
}
|
|
308
|
+
codecId = SQLITE_BIGINT_CODEC_ID;
|
|
309
|
+
traits = [
|
|
310
|
+
"equality",
|
|
311
|
+
"order",
|
|
312
|
+
"numeric"
|
|
313
|
+
];
|
|
314
|
+
targetTypes = ["integer"];
|
|
315
|
+
paramsSchema = voidParamsSchema;
|
|
316
|
+
factory() {
|
|
317
|
+
return () => new SqliteBigintCodec(this);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const sqliteBigintDescriptor = new SqliteBigintDescriptor();
|
|
321
|
+
const sqliteBigintColumn = () => column(sqliteBigintDescriptor.factory(), sqliteBigintDescriptor.codecId, void 0, "integer");
|
|
322
|
+
const codecDescriptors = defineSqliteCodecs([
|
|
323
|
+
sqliteSqlCharDescriptor,
|
|
324
|
+
sqliteSqlVarcharDescriptor,
|
|
325
|
+
sqliteSqlIntDescriptor,
|
|
326
|
+
sqliteSqlFloatDescriptor,
|
|
327
|
+
sqliteTextDescriptor,
|
|
328
|
+
sqliteIntegerDescriptor,
|
|
329
|
+
sqliteRealDescriptor,
|
|
330
|
+
sqliteBlobDescriptor,
|
|
331
|
+
sqliteDatetimeDescriptor,
|
|
332
|
+
sqliteJsonDescriptor,
|
|
333
|
+
sqliteBigintDescriptor
|
|
334
|
+
]);
|
|
335
|
+
/**
|
|
336
|
+
* Registry of every codec descriptor shipped by `@internal/target-sqlite`.
|
|
337
|
+
*
|
|
338
|
+
* 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.
|
|
339
|
+
*/
|
|
340
|
+
const sqliteCodecRegistry = buildCodecDescriptorRegistry(codecDescriptors);
|
|
341
|
+
const sqliteCodecDescriptorRegistry = buildSqliteCodecDescriptorRegistry(codecDescriptors);
|
|
342
|
+
//#endregion
|
|
343
|
+
export { sqliteCodecRegistry as a, sqliteJsonColumn as c, sqliteCodecDescriptorRegistry as i, sqliteRealColumn as l, sqliteBigintColumn as n, sqliteDatetimeColumn as o, sqliteBlobColumn as r, sqliteIntegerColumn as s, jsonDocumentRetag as t, sqliteTextColumn as u };
|
|
344
|
+
|
|
345
|
+
//# sourceMappingURL=codecs-CM_2W3uA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs-CM_2W3uA.mjs","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/codecs.mjs"],"sourcesContent":["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-xicqpuAa.mjs\";\nimport { a as sqliteCodec, n as buildSqliteCodecDescriptorRegistry, r as defineSqliteCodecs, t as SqliteCodecDescriptor } from \"./codec-descriptor-kVCSW1OR.mjs\";\nimport { n as sqliteError } from \"./errors-CKsaaSnD.mjs\";\nimport { CaseExpr, CastExpr, FunctionCallExpr, LiteralExpr, NullCheckExpr, sqlCharDescriptor, sqlFloatDescriptor, sqlIntDescriptor, sqlVarcharDescriptor } from \"@internal/sql-relational-core/ast\";\nimport { CodecImpl, column, voidParamsSchema } from \"@internal/framework-components/codec\";\nimport { buildCodecDescriptorRegistry } from \"@internal/sql-relational-core/codec-descriptor-registry\";\n//#region src/core/codecs.ts\n/**\n* Projects the expression unchanged, for codecs whose canonical JSON is what\n* SQLite's own JSON conversion already produces.\n*\n* Identity here is a claim about the target's behaviour, not an absence of one:\n* the codec's conformance cases are what test it, including at the boundaries\n* of the representation where a native conversion would be most likely to\n* diverge.\n*/\nconst identityJsonProjection = (expression) => expression;\n/**\n* Projects an integer-valued expression as decimal text.\n*\n* The cast is part of the projected expression, so it applies before the JSON\n* constructor sees the value: handed an INTEGER directly, the constructor emits\n* a JSON number, and SQLite's 64-bit range does not survive being read back as\n* a double. Casting the constructor's result would be too late.\n*/\nconst decimalTextJsonProjection = (expression) => CastExpr.as(expression, \"TEXT\");\n/**\n* Projects a BLOB as hexadecimal text.\n*\n* SQLite's JSON functions reject a BLOB argument outright, so the encoding has\n* to replace the native conversion rather than post-process it. `hex()` emits\n* uppercase and never wraps at any length, which is the spelling `encodeJson`\n* pins.\n*\n* `hex(NULL)` is `''` rather than NULL, and `''` is the hex of an empty blob —\n* so without the NULL check an absent blob and an empty one would both project\n* as `''`, and `decodeJson` accepts `''` because zero hex pairs is a valid\n* empty blob. The check keeps the two distinguishable.\n*/\nconst hexJsonProjection = (expression) => CaseExpr.of([{\n\tcondition: NullCheckExpr.isNull(expression),\n\tvalue: LiteralExpr.of(null)\n}], FunctionCallExpr.of(\"hex\", [expression]));\nconst JSON_RETAG_FN = \"json\";\n/**\n* Re-applies SQLite's JSON subtype to a document-valued expression.\n*\n* SQLite carries \"this text is JSON\" as a subtype on the value rather than in\n* its type, and the subtype does not survive a derived table: a document that\n* `json_object` produced arrives one level out as plain text, so the enclosing\n* constructor embeds it as a *string containing JSON* rather than as a\n* document. `json()` re-applies the subtype, which is what makes the value nest\n* as a document again.\n*\n* The loss happens at the first derived-table boundary and does not compound, so\n* a retag is needed where the document is consumed rather than at every level it\n* passes through.\n*\n* Applying this twice is a no-op — SQLite's `json()` is idempotent, and the\n* wrapper collapses rather than nesting so the rendered SQL says so too. It is\n* safe on any valid JSON text, including scalars, and on NULL; it raises\n* `malformed JSON` on text that is not JSON, which is the correct failure for a\n* value that was never a document.\n*/\nconst jsonDocumentRetag = (expression) => isJsonRetag(expression) ? expression : FunctionCallExpr.of(JSON_RETAG_FN, [expression]);\n/** Whether an expression is already a retag, so applying one again would only nest. */\nconst isJsonRetag = (expression) => expression instanceof FunctionCallExpr && expression.fn === JSON_RETAG_FN && expression.args.length === 1;\nconst DECIMAL_INTEGER = /^-?\\d+$/;\nconst UPPERCASE_HEX = /^(?:[0-9A-F]{2})*$/;\n/**\n* JSON has no spelling for an infinity or a NaN, and SQLite renders one as\n* `9.0e+999`, which reads back as `Infinity` rather than failing. A real is\n* therefore carried only where it is finite.\n*/\nconst finiteReal = (value, code) => {\n\tif (!Number.isFinite(value)) throw sqliteError(code, \"sqlite/real@1 value must be a finite number\", { meta: {\n\t\tcodecId: SQLITE_REAL_CODEC_ID,\n\t\treceived: String(value)\n\t} });\n\treturn value;\n};\nconst sqliteSqlCharDescriptor = sqliteCodec(sqlCharDescriptor, { jsonProjection: identityJsonProjection });\nconst sqliteSqlVarcharDescriptor = sqliteCodec(sqlVarcharDescriptor, { jsonProjection: identityJsonProjection });\nconst sqliteSqlIntDescriptor = sqliteCodec(sqlIntDescriptor, { jsonProjection: identityJsonProjection });\nconst sqliteSqlFloatDescriptor = sqliteCodec(sqlFloatDescriptor, { jsonProjection: identityJsonProjection });\nvar SqliteTextCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn value;\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn wire;\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn json;\n\t}\n};\nvar SqliteTextDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn expression;\n\t}\n\tcodecId = SQLITE_TEXT_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"textual\"\n\t];\n\ttargetTypes = [\"text\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteTextCodec(this);\n\t}\n};\nconst sqliteTextDescriptor = new SqliteTextDescriptor();\nconst sqliteTextColumn = () => column(sqliteTextDescriptor.factory(), sqliteTextDescriptor.codecId, void 0, \"text\");\nvar SqliteIntegerCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn value;\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn wire;\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn json;\n\t}\n};\nvar SqliteIntegerDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn expression;\n\t}\n\tcodecId = SQLITE_INTEGER_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t];\n\ttargetTypes = [\"integer\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteIntegerCodec(this);\n\t}\n};\nconst sqliteIntegerDescriptor = new SqliteIntegerDescriptor();\nconst sqliteIntegerColumn = () => column(sqliteIntegerDescriptor.factory(), sqliteIntegerDescriptor.codecId, void 0, \"integer\");\nvar SqliteRealCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn value;\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn wire;\n\t}\n\tencodeJson(value) {\n\t\treturn finiteReal(value, \"RUNTIME.ENCODE_FAILED\");\n\t}\n\tdecodeJson(json) {\n\t\tif (typeof json !== \"number\") throw sqliteError(\"RUNTIME.DECODE_FAILED\", \"sqlite/real@1 database JSON value must be a number\", { meta: {\n\t\t\tcodecId: SQLITE_REAL_CODEC_ID,\n\t\t\treceived: typeof json\n\t\t} });\n\t\treturn finiteReal(json, \"RUNTIME.DECODE_FAILED\");\n\t}\n};\nvar SqliteRealDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn expression;\n\t}\n\tcodecId = SQLITE_REAL_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t];\n\ttargetTypes = [\"real\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteRealCodec(this);\n\t}\n};\nconst sqliteRealDescriptor = new SqliteRealDescriptor();\nconst sqliteRealColumn = () => column(sqliteRealDescriptor.factory(), sqliteRealDescriptor.codecId, void 0, \"real\");\nvar SqliteBlobCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn value;\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn wire;\n\t}\n\tencodeJson(value) {\n\t\treturn Buffer.from(value).toString(\"hex\").toUpperCase();\n\t}\n\tdecodeJson(json) {\n\t\tif (typeof json !== \"string\" || !UPPERCASE_HEX.test(json)) throw sqliteError(\"RUNTIME.DECODE_FAILED\", \"sqlite/blob@1 database JSON value must be uppercase hexadecimal text\", { meta: {\n\t\t\tcodecId: SQLITE_BLOB_CODEC_ID,\n\t\t\treceived: typeof json\n\t\t} });\n\t\treturn new Uint8Array(Buffer.from(json, \"hex\"));\n\t}\n};\nvar SqliteBlobDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn hexJsonProjection(expression);\n\t}\n\tcodecId = SQLITE_BLOB_CODEC_ID;\n\ttraits = [\"equality\"];\n\ttargetTypes = [\"blob\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteBlobCodec(this);\n\t}\n};\nconst sqliteBlobDescriptor = new SqliteBlobDescriptor();\nconst sqliteBlobColumn = () => column(sqliteBlobDescriptor.factory(), sqliteBlobDescriptor.codecId, void 0, \"blob\");\nvar SqliteDatetimeCodec = class extends CodecImpl {\n\tparseDate(value) {\n\t\tconst date = new Date(value);\n\t\tif (Number.isNaN(date.getTime())) throw sqliteError(\"RUNTIME.DECODE_FAILED\", `sqlite/datetime@1 value must be a valid ISO-8601 string: ${value}`, { meta: {\n\t\t\tcodecId: SQLITE_DATETIME_CODEC_ID,\n\t\t\treceived: value\n\t\t} });\n\t\treturn date;\n\t}\n\tasync encode(value, _ctx) {\n\t\treturn value.toISOString();\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn this.parseDate(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn value.toISOString();\n\t}\n\tdecodeJson(json) {\n\t\tif (typeof json !== \"string\") throw sqliteError(\"RUNTIME.DECODE_FAILED\", \"sqlite/datetime@1 contract value must be an ISO-8601 string\", { meta: {\n\t\t\tcodecId: SQLITE_DATETIME_CODEC_ID,\n\t\t\treceived: typeof json\n\t\t} });\n\t\treturn this.parseDate(json);\n\t}\n};\nvar SqliteDatetimeDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn expression;\n\t}\n\tcodecId = SQLITE_DATETIME_CODEC_ID;\n\ttraits = [\"equality\", \"order\"];\n\ttargetTypes = [\"text\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteDatetimeCodec(this);\n\t}\n};\nconst sqliteDatetimeDescriptor = new SqliteDatetimeDescriptor();\nconst sqliteDatetimeColumn = () => column(sqliteDatetimeDescriptor.factory(), sqliteDatetimeDescriptor.codecId, void 0, \"text\");\nvar SqliteJsonCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn JSON.stringify(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn typeof wire === \"string\" ? JSON.parse(wire) : wire;\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn json;\n\t}\n};\nvar SqliteJsonDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn jsonDocumentRetag(expression);\n\t}\n\tcodecId = SQLITE_JSON_CODEC_ID;\n\ttraits = [\"equality\"];\n\ttargetTypes = [\"text\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteJsonCodec(this);\n\t}\n};\nconst sqliteJsonDescriptor = new SqliteJsonDescriptor();\nconst sqliteJsonColumn = () => column(sqliteJsonDescriptor.factory(), sqliteJsonDescriptor.codecId, void 0, \"text\");\nvar SqliteBigintCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn value;\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn BigInt(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn value.toString();\n\t}\n\tdecodeJson(json) {\n\t\tif (typeof json !== \"string\" || !DECIMAL_INTEGER.test(json)) throw sqliteError(\"RUNTIME.DECODE_FAILED\", \"sqlite/bigint@1 database JSON value must be a decimal string\", { meta: {\n\t\t\tcodecId: SQLITE_BIGINT_CODEC_ID,\n\t\t\treceived: typeof json\n\t\t} });\n\t\treturn BigInt(json);\n\t}\n};\nvar SqliteBigintDescriptor = class extends SqliteCodecDescriptor {\n\tjsonProjection(expression) {\n\t\treturn decimalTextJsonProjection(expression);\n\t}\n\tcodecId = SQLITE_BIGINT_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t];\n\ttargetTypes = [\"integer\"];\n\tparamsSchema = voidParamsSchema;\n\tfactory() {\n\t\treturn () => new SqliteBigintCodec(this);\n\t}\n};\nconst sqliteBigintDescriptor = new SqliteBigintDescriptor();\nconst sqliteBigintColumn = () => column(sqliteBigintDescriptor.factory(), sqliteBigintDescriptor.codecId, void 0, \"integer\");\nconst codecDescriptors = defineSqliteCodecs([\n\tsqliteSqlCharDescriptor,\n\tsqliteSqlVarcharDescriptor,\n\tsqliteSqlIntDescriptor,\n\tsqliteSqlFloatDescriptor,\n\tsqliteTextDescriptor,\n\tsqliteIntegerDescriptor,\n\tsqliteRealDescriptor,\n\tsqliteBlobDescriptor,\n\tsqliteDatetimeDescriptor,\n\tsqliteJsonDescriptor,\n\tsqliteBigintDescriptor\n]);\n//#endregion\n//#region src/core/registry.ts\n/**\n* Registry of every codec descriptor shipped by `@internal/target-sqlite`.\n*\n* 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.\n*/\nconst sqliteCodecRegistry = buildCodecDescriptorRegistry(codecDescriptors);\nconst sqliteCodecDescriptorRegistry = buildSqliteCodecDescriptorRegistry(codecDescriptors);\n//#endregion\nexport { jsonDocumentRetag, sqliteBigintColumn, sqliteBlobColumn, sqliteCodecDescriptorRegistry, sqliteCodecRegistry, sqliteDatetimeColumn, sqliteIntegerColumn, sqliteJsonColumn, sqliteRealColumn, sqliteTextColumn };\n\n//# sourceMappingURL=codecs.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,0BAA0B,eAAe;;;;;;;;;AAS/C,MAAM,6BAA6B,eAAe,SAAS,GAAG,YAAY,MAAM;;;;;;;;;;;;;;AAchF,MAAM,qBAAqB,eAAe,SAAS,GAAG,CAAC;CACtD,WAAW,cAAc,OAAO,UAAU;CAC1C,OAAO,YAAY,GAAG,IAAI;AAC3B,CAAC,GAAG,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC5C,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;AAqBtB,MAAM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SAAS;GACT,UAAU,OAAO;EAClB,EAAE,CAAC;EACH,OAAO,OAAO,IAAI;CACnB;AACD;AACA,IAAI,yBAAyB,cAAc,sBAAsB;CAChE,eAAe,YAAY;EAC1B,OAAO,0BAA0B,UAAU;CAC5C;CACA,UAAU;CACV,SAAS;EACR;EACA;EACA;CACD;CACA,cAAc,CAAC,SAAS;CACxB,eAAe;CACf,UAAU;EACT,aAAa,IAAI,kBAAkB,IAAI;CACxC;AACD;AACA,MAAM,yBAAyB,IAAI,uBAAuB;AAC1D,MAAM,2BAA2B,OAAO,uBAAuB,QAAQ,GAAG,uBAAuB,SAAS,KAAK,GAAG,SAAS;AAC3H,MAAM,mBAAmB,mBAAmB;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;AAQD,MAAM,sBAAsB,6BAA6B,gBAAgB;AACzE,MAAM,gCAAgC,mCAAmC,gBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./codecs-1-oOsTPG-Bv518Lbm.mjs";
|
|
@@ -0,0 +1,34 @@
|
|
|
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-xicqpuAa-DHnKqnIs.mjs";
|
|
2
|
+
//#region ../../../3-targets/6-adapters/sqlite/dist/column-types.mjs
|
|
3
|
+
const textColumn = {
|
|
4
|
+
codecId: SQLITE_TEXT_CODEC_ID,
|
|
5
|
+
nativeType: "text"
|
|
6
|
+
};
|
|
7
|
+
const integerColumn = {
|
|
8
|
+
codecId: SQLITE_INTEGER_CODEC_ID,
|
|
9
|
+
nativeType: "integer"
|
|
10
|
+
};
|
|
11
|
+
const realColumn = {
|
|
12
|
+
codecId: SQLITE_REAL_CODEC_ID,
|
|
13
|
+
nativeType: "real"
|
|
14
|
+
};
|
|
15
|
+
const blobColumn = {
|
|
16
|
+
codecId: SQLITE_BLOB_CODEC_ID,
|
|
17
|
+
nativeType: "blob"
|
|
18
|
+
};
|
|
19
|
+
const datetimeColumn = {
|
|
20
|
+
codecId: SQLITE_DATETIME_CODEC_ID,
|
|
21
|
+
nativeType: "text"
|
|
22
|
+
};
|
|
23
|
+
const jsonColumn = {
|
|
24
|
+
codecId: SQLITE_JSON_CODEC_ID,
|
|
25
|
+
nativeType: "text"
|
|
26
|
+
};
|
|
27
|
+
const bigintColumn = {
|
|
28
|
+
codecId: SQLITE_BIGINT_CODEC_ID,
|
|
29
|
+
nativeType: "integer"
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { jsonColumn as a, integerColumn as i, blobColumn as n, realColumn as o, datetimeColumn as r, textColumn as s, bigintColumn as t };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=column-types-StKUDF6A.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types-StKUDF6A.mjs","names":[],"sources":["../../../../3-targets/6-adapters/sqlite/dist/column-types.mjs"],"sourcesContent":["import { 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 } from \"@internal/target-sqlite/codec-ids\";\n//#region src/core/column-types.ts\nconst textColumn = {\n\tcodecId: SQLITE_TEXT_CODEC_ID,\n\tnativeType: \"text\"\n};\nconst integerColumn = {\n\tcodecId: SQLITE_INTEGER_CODEC_ID,\n\tnativeType: \"integer\"\n};\nconst realColumn = {\n\tcodecId: SQLITE_REAL_CODEC_ID,\n\tnativeType: \"real\"\n};\nconst blobColumn = {\n\tcodecId: SQLITE_BLOB_CODEC_ID,\n\tnativeType: \"blob\"\n};\nconst datetimeColumn = {\n\tcodecId: SQLITE_DATETIME_CODEC_ID,\n\tnativeType: \"text\"\n};\nconst jsonColumn = {\n\tcodecId: SQLITE_JSON_CODEC_ID,\n\tnativeType: \"text\"\n};\nconst bigintColumn = {\n\tcodecId: SQLITE_BIGINT_CODEC_ID,\n\tnativeType: \"integer\"\n};\n//#endregion\nexport { bigintColumn, blobColumn, datetimeColumn, integerColumn, jsonColumn, realColumn, textColumn };\n\n//# sourceMappingURL=column-types.mjs.map"],"mappings":";;AAEA,MAAM,aAAa;CAClB,SAAS;CACT,YAAY;AACb;AACA,MAAM,gBAAgB;CACrB,SAAS;CACT,YAAY;AACb;AACA,MAAM,aAAa;CAClB,SAAS;CACT,YAAY;AACb;AACA,MAAM,aAAa;CAClB,SAAS;CACT,YAAY;AACb;AACA,MAAM,iBAAiB;CACtB,SAAS;CACT,YAAY;AACb;AACA,MAAM,aAAa;CAClB,SAAS;CACT,YAAY;AACb;AACA,MAAM,eAAe;CACpB,SAAS;CACT,YAAY;AACb"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region ../../../3-targets/6-adapters/sqlite/dist/column-types.d.mts
|
|
2
|
+
//#region src/core/column-types.d.ts
|
|
3
|
+
declare const textColumn: {
|
|
4
|
+
readonly codecId: "sqlite/text@1";
|
|
5
|
+
readonly nativeType: "text";
|
|
6
|
+
};
|
|
7
|
+
declare const integerColumn: {
|
|
8
|
+
readonly codecId: "sqlite/integer@1";
|
|
9
|
+
readonly nativeType: "integer";
|
|
10
|
+
};
|
|
11
|
+
declare const realColumn: {
|
|
12
|
+
readonly codecId: "sqlite/real@1";
|
|
13
|
+
readonly nativeType: "real";
|
|
14
|
+
};
|
|
15
|
+
declare const blobColumn: {
|
|
16
|
+
readonly codecId: "sqlite/blob@1";
|
|
17
|
+
readonly nativeType: "blob";
|
|
18
|
+
};
|
|
19
|
+
declare const datetimeColumn: {
|
|
20
|
+
readonly codecId: "sqlite/datetime@1";
|
|
21
|
+
readonly nativeType: "text";
|
|
22
|
+
};
|
|
23
|
+
declare const jsonColumn: {
|
|
24
|
+
readonly codecId: "sqlite/json@1";
|
|
25
|
+
readonly nativeType: "text";
|
|
26
|
+
};
|
|
27
|
+
declare const bigintColumn: {
|
|
28
|
+
readonly codecId: "sqlite/bigint@1";
|
|
29
|
+
readonly nativeType: "integer";
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { jsonColumn as a, integerColumn as i, blobColumn as n, realColumn as o, datetimeColumn as r, textColumn as s, bigintColumn as t };
|
|
33
|
+
//# sourceMappingURL=column-types-iWGuW-0W.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-types-iWGuW-0W.d.mts","names":[],"sources":["../../../../3-targets/6-adapters/sqlite/dist/column-types.d.mts"],"mappings":";;cACc;WACH;WACA;;cAEG;WACH;WACA;;cAEG;WACH;WACA;;cAEG;WACH;WACA;;cAEG;WACH;WACA;;cAEG;WACH;WACA;;cAEG;WACH;WACA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { n as SqliteCreateTable } from "./nodes-D8EC1yCx-rpfpuJ4T.mjs";
|
|
2
|
+
import { DdlColumn, DdlNode, DdlTableConstraint, SelectAst } from "@prisma/orm-family-sql/relational-core/ast";
|
|
3
|
+
import { ColumnDescriptor, ColumnSchema, TableHandle } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
4
|
+
//#region ../../../3-targets/3-targets/sqlite/dist/contract-free.d.mts
|
|
5
|
+
//#region src/contract-free/checks.d.ts
|
|
6
|
+
interface ColumnExistsCheckBuilder {
|
|
7
|
+
columnAbsent(): SelectAst;
|
|
8
|
+
columnPresent(): SelectAst;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Typed builder for the migration planner's column-existence checks. Produces
|
|
12
|
+
* `SELECT COUNT(*) {=|>} 0 AS "result" FROM pragma_table_info(?) WHERE "name" = ?`
|
|
13
|
+
* ASTs with the table and column names bound as text parameters — never
|
|
14
|
+
* inlined into the SQL.
|
|
15
|
+
*/
|
|
16
|
+
declare function columnExistsAst(table: string, column: string): ColumnExistsCheckBuilder;
|
|
17
|
+
interface TableExistsCheckBuilder {
|
|
18
|
+
tableAbsent(): SelectAst;
|
|
19
|
+
tablePresent(): SelectAst;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Typed builder for table-existence checks over `sqlite_master`.
|
|
23
|
+
* Produces `SELECT COUNT(*) {=|>} 0 AS "result" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?`
|
|
24
|
+
* with the table name and the literal `'table'` bound as text parameters.
|
|
25
|
+
*/
|
|
26
|
+
declare function tableExistsAst(tableName: string): TableExistsCheckBuilder;
|
|
27
|
+
interface IndexExistsCheckBuilder {
|
|
28
|
+
indexAbsent(): SelectAst;
|
|
29
|
+
indexPresent(): SelectAst;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Typed builder for index-existence checks over `sqlite_master`.
|
|
33
|
+
* Produces `SELECT COUNT(*) {=|>} 0 AS "result" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?`
|
|
34
|
+
* with the index name and the literal `'index'` bound as text parameters.
|
|
35
|
+
*/
|
|
36
|
+
declare function indexExistsAst(indexName: string): IndexExistsCheckBuilder;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/contract-free/columns.d.ts
|
|
39
|
+
type ColOpts = {
|
|
40
|
+
readonly nullable?: boolean;
|
|
41
|
+
};
|
|
42
|
+
declare const text: (opts?: ColOpts) => ColumnDescriptor;
|
|
43
|
+
declare const integer: (opts?: ColOpts) => ColumnDescriptor;
|
|
44
|
+
declare const jsonText: (opts?: ColOpts) => ColumnDescriptor;
|
|
45
|
+
declare const datetime: (opts?: ColOpts) => ColumnDescriptor;
|
|
46
|
+
/**
|
|
47
|
+
* Declare a SQLite control-plane table with a typed column schema. SQLite tables
|
|
48
|
+
* are addressed by a flat name (no schema prefix).
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* const marker = sqliteTable('_prisma_marker', {
|
|
52
|
+
* space: text(),
|
|
53
|
+
* core_hash: text(),
|
|
54
|
+
* updated_at: datetime(),
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function sqliteTable<Schema extends ColumnSchema>(name: string, columns: Schema): TableHandle<Schema>;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/contract-free/control-bootstrap.d.ts
|
|
61
|
+
declare function buildSignMarkerBootstrapQueries(): readonly DdlNode[];
|
|
62
|
+
declare function buildControlTableBootstrapQueries(): readonly DdlNode[];
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/contract-free/ddl.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* Build a SQLite `CREATE TABLE` query node.
|
|
67
|
+
*
|
|
68
|
+
* Pass `constraints` for table-level composite primary keys, foreign keys, and
|
|
69
|
+
* unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},
|
|
70
|
+
* and {@link UniqueConstraint} classes from `@internal/sql-relational-core/ast`.
|
|
71
|
+
*
|
|
72
|
+
* Precondition: identifiers (`table`, column names/types) are emitted to SQL
|
|
73
|
+
* verbatim — they are not quoted or escaped, so callers must pass pre-trusted
|
|
74
|
+
* values (e.g. fixed control-plane identifiers). String-literal default values,
|
|
75
|
+
* by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
|
|
76
|
+
* Identifier quoting for untrusted identifiers is added when the migration
|
|
77
|
+
* planner adopts this lowering path.
|
|
78
|
+
*/
|
|
79
|
+
declare function createTable(options: {
|
|
80
|
+
readonly table: string;
|
|
81
|
+
readonly schema?: string;
|
|
82
|
+
readonly ifNotExists?: boolean;
|
|
83
|
+
readonly columns: readonly DdlColumn[];
|
|
84
|
+
readonly constraints?: readonly DdlTableConstraint[];
|
|
85
|
+
}): SqliteCreateTable;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { buildSignMarkerBootstrapQueries as a, datetime as c, jsonText as d, sqliteTable as f, buildControlTableBootstrapQueries as i, indexExistsAst as l, text as m, IndexExistsCheckBuilder as n, columnExistsAst as o, tableExistsAst as p, TableExistsCheckBuilder as r, createTable as s, ColumnExistsCheckBuilder as t, integer as u };
|
|
88
|
+
//# sourceMappingURL=contract-free-CCLAXZV2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-free-CCLAXZV2.d.mts","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/contract-free.d.mts"],"mappings":";;;;;UAIU;EACR,gBAAgB;EAChB,iBAAiB;;;;;;;;iBAQF,gBAAgB,eAAe,iBAAiB;UACvD;EACR,eAAe;EACf,gBAAgB;;;;;;;iBAOD,eAAe,oBAAoB;UAC1C;EACR,eAAe;EACf,gBAAgB;;;;;;;iBAOD,eAAe,oBAAoB;;;KAG/C;WACM;;cAEG,OAAO,OAAO,YAAY;cAC1B,UAAU,OAAO,YAAY;cAC7B,WAAW,OAAO,YAAY;cAC9B,WAAW,OAAO,YAAY;;;;;;;;;;;;;iBAa3B,YAAY,eAAe,cAAc,cAAc,SAAS,SAAS,YAAY;;;iBAGrF,4CAA4C;iBAC5C,8CAA8C;;;;;;;;;;;;;;;;;iBAiB9C,YAAY;WAClB;WACA;WACA;WACA,kBAAkB;WAClB,uBAAuB;IAC9B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID } from "./codec-ids-xicqpuAa-DHnKqnIs.mjs";
|
|
2
|
+
import { n as createTable } from "./ddl-CW34JvfE-rd1ZIxOn.mjs";
|
|
3
|
+
import { TableSource } from "@prisma/orm-family-sql/relational-core/ast";
|
|
4
|
+
import { col, fn, lit, table } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
5
|
+
import { APP_SPACE_ID } from "@prisma/orm-framework/components/control";
|
|
6
|
+
//#region ../../../3-targets/3-targets/sqlite/dist/contract-free.mjs
|
|
7
|
+
const desc = (codecId, opts) => ({
|
|
8
|
+
codecId,
|
|
9
|
+
nullable: opts?.nullable ?? false
|
|
10
|
+
});
|
|
11
|
+
const text = (opts) => desc(SQLITE_TEXT_CODEC_ID, opts);
|
|
12
|
+
const integer = (opts) => desc(SQLITE_INTEGER_CODEC_ID, opts);
|
|
13
|
+
const jsonText = (opts) => desc(SQLITE_JSON_CODEC_ID, opts);
|
|
14
|
+
const datetime = (opts) => desc(SQLITE_DATETIME_CODEC_ID, opts);
|
|
15
|
+
/**
|
|
16
|
+
* Declare a SQLite control-plane table with a typed column schema. SQLite tables
|
|
17
|
+
* are addressed by a flat name (no schema prefix).
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const marker = sqliteTable('_prisma_marker', {
|
|
21
|
+
* space: text(),
|
|
22
|
+
* core_hash: text(),
|
|
23
|
+
* updated_at: datetime(),
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function sqliteTable(name, columns) {
|
|
28
|
+
return table(TableSource.named(name), columns);
|
|
29
|
+
}
|
|
30
|
+
const markerColumns = [
|
|
31
|
+
col("space", "TEXT", {
|
|
32
|
+
notNull: true,
|
|
33
|
+
primaryKey: true,
|
|
34
|
+
default: lit(APP_SPACE_ID)
|
|
35
|
+
}),
|
|
36
|
+
col("core_hash", "TEXT", { notNull: true }),
|
|
37
|
+
col("profile_hash", "TEXT", { notNull: true }),
|
|
38
|
+
col("contract_json", "TEXT"),
|
|
39
|
+
col("canonical_version", "INTEGER"),
|
|
40
|
+
col("updated_at", "TEXT", {
|
|
41
|
+
notNull: true,
|
|
42
|
+
default: fn("datetime('now')")
|
|
43
|
+
}),
|
|
44
|
+
col("app_tag", "TEXT"),
|
|
45
|
+
col("meta", "TEXT", {
|
|
46
|
+
notNull: true,
|
|
47
|
+
default: lit("{}")
|
|
48
|
+
}),
|
|
49
|
+
col("invariants", "TEXT", {
|
|
50
|
+
notNull: true,
|
|
51
|
+
default: lit("[]")
|
|
52
|
+
})
|
|
53
|
+
];
|
|
54
|
+
const ledgerColumns = [
|
|
55
|
+
col("id", "INTEGER PRIMARY KEY AUTOINCREMENT"),
|
|
56
|
+
col("created_at", "TEXT", {
|
|
57
|
+
notNull: true,
|
|
58
|
+
default: fn("strftime('%Y-%m-%dT%H:%M:%fZ','now')")
|
|
59
|
+
}),
|
|
60
|
+
col("space", "TEXT", { notNull: true }),
|
|
61
|
+
col("migration_name", "TEXT", { notNull: true }),
|
|
62
|
+
col("migration_hash", "TEXT", { notNull: true }),
|
|
63
|
+
col("origin_core_hash", "TEXT"),
|
|
64
|
+
col("origin_profile_hash", "TEXT"),
|
|
65
|
+
col("destination_core_hash", "TEXT", { notNull: true }),
|
|
66
|
+
col("destination_profile_hash", "TEXT"),
|
|
67
|
+
col("contract_json_before", "TEXT"),
|
|
68
|
+
col("contract_json_after", "TEXT"),
|
|
69
|
+
col("operations", "TEXT", { notNull: true })
|
|
70
|
+
];
|
|
71
|
+
const markerTable = createTable({
|
|
72
|
+
table: "_prisma_marker",
|
|
73
|
+
ifNotExists: true,
|
|
74
|
+
columns: markerColumns
|
|
75
|
+
});
|
|
76
|
+
const ledgerTable = createTable({
|
|
77
|
+
table: "_prisma_ledger",
|
|
78
|
+
ifNotExists: true,
|
|
79
|
+
columns: ledgerColumns
|
|
80
|
+
});
|
|
81
|
+
function buildSignMarkerBootstrapQueries() {
|
|
82
|
+
return [markerTable];
|
|
83
|
+
}
|
|
84
|
+
function buildControlTableBootstrapQueries() {
|
|
85
|
+
return [markerTable, ledgerTable];
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { jsonText as a, integer as i, buildSignMarkerBootstrapQueries as n, sqliteTable as o, datetime as r, text as s, buildControlTableBootstrapQueries as t };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=contract-free-DElSXD0q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-free-DElSXD0q.mjs","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/contract-free.mjs"],"sourcesContent":["import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID } from \"./codec-ids-xicqpuAa.mjs\";\nimport { i as tableExistsAst, n as columnExistsAst, r as indexExistsAst, t as createTable } from \"./ddl-CW34JvfE.mjs\";\nimport { TableSource } from \"@internal/sql-relational-core/ast\";\nimport { APP_SPACE_ID } from \"@internal/framework-components/control\";\nimport { col, fn, lit, table } from \"@internal/sql-relational-core/contract-free\";\n//#region src/contract-free/columns.ts\nconst desc = (codecId, opts) => ({\n\tcodecId,\n\tnullable: opts?.nullable ?? false\n});\nconst text = (opts) => desc(SQLITE_TEXT_CODEC_ID, opts);\nconst integer = (opts) => desc(SQLITE_INTEGER_CODEC_ID, opts);\nconst jsonText = (opts) => desc(SQLITE_JSON_CODEC_ID, opts);\nconst datetime = (opts) => desc(SQLITE_DATETIME_CODEC_ID, opts);\n/**\n* Declare a SQLite control-plane table with a typed column schema. SQLite tables\n* are addressed by a flat name (no schema prefix).\n*\n* ```ts\n* const marker = sqliteTable('_prisma_marker', {\n* space: text(),\n* core_hash: text(),\n* updated_at: datetime(),\n* });\n* ```\n*/\nfunction sqliteTable(name, columns) {\n\treturn table(TableSource.named(name), columns);\n}\n//#endregion\n//#region src/contract-free/control-bootstrap.ts\nconst markerColumns = [\n\tcol(\"space\", \"TEXT\", {\n\t\tnotNull: true,\n\t\tprimaryKey: true,\n\t\tdefault: lit(APP_SPACE_ID)\n\t}),\n\tcol(\"core_hash\", \"TEXT\", { notNull: true }),\n\tcol(\"profile_hash\", \"TEXT\", { notNull: true }),\n\tcol(\"contract_json\", \"TEXT\"),\n\tcol(\"canonical_version\", \"INTEGER\"),\n\tcol(\"updated_at\", \"TEXT\", {\n\t\tnotNull: true,\n\t\tdefault: fn(\"datetime('now')\")\n\t}),\n\tcol(\"app_tag\", \"TEXT\"),\n\tcol(\"meta\", \"TEXT\", {\n\t\tnotNull: true,\n\t\tdefault: lit(\"{}\")\n\t}),\n\tcol(\"invariants\", \"TEXT\", {\n\t\tnotNull: true,\n\t\tdefault: lit(\"[]\")\n\t})\n];\nconst ledgerColumns = [\n\tcol(\"id\", \"INTEGER PRIMARY KEY AUTOINCREMENT\"),\n\tcol(\"created_at\", \"TEXT\", {\n\t\tnotNull: true,\n\t\tdefault: fn(\"strftime('%Y-%m-%dT%H:%M:%fZ','now')\")\n\t}),\n\tcol(\"space\", \"TEXT\", { notNull: true }),\n\tcol(\"migration_name\", \"TEXT\", { notNull: true }),\n\tcol(\"migration_hash\", \"TEXT\", { notNull: true }),\n\tcol(\"origin_core_hash\", \"TEXT\"),\n\tcol(\"origin_profile_hash\", \"TEXT\"),\n\tcol(\"destination_core_hash\", \"TEXT\", { notNull: true }),\n\tcol(\"destination_profile_hash\", \"TEXT\"),\n\tcol(\"contract_json_before\", \"TEXT\"),\n\tcol(\"contract_json_after\", \"TEXT\"),\n\tcol(\"operations\", \"TEXT\", { notNull: true })\n];\nconst markerTable = createTable({\n\ttable: \"_prisma_marker\",\n\tifNotExists: true,\n\tcolumns: markerColumns\n});\nconst ledgerTable = createTable({\n\ttable: \"_prisma_ledger\",\n\tifNotExists: true,\n\tcolumns: ledgerColumns\n});\nfunction buildSignMarkerBootstrapQueries() {\n\treturn [markerTable];\n}\nfunction buildControlTableBootstrapQueries() {\n\treturn [markerTable, ledgerTable];\n}\n//#endregion\nexport { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, columnExistsAst, createTable, datetime, indexExistsAst, integer, jsonText, sqliteTable, tableExistsAst, text };\n\n//# sourceMappingURL=contract-free.mjs.map"],"mappings":";;;;;;AAMA,MAAM,QAAQ,SAAS,UAAU;CAChC;CACA,UAAU,MAAM,YAAY;AAC7B;AACA,MAAM,QAAQ,SAAS,KAAK,sBAAsB,IAAI;AAC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