@prisma-next/target-sqlite 0.5.0-dev.60 → 0.5.0-dev.61
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-DyLO2Rfx.d.mts +13 -0
- package/dist/codec-ids-DyLO2Rfx.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -13
- package/dist/codec-types-Bbzv7qCW.d.mts +24 -0
- package/dist/codec-types-Bbzv7qCW.d.mts.map +1 -0
- package/dist/codec-types.d.mts +4 -7
- package/dist/codec-types.mjs +2 -2
- package/dist/codecs-BqDitp2X.d.mts +127 -0
- package/dist/codecs-BqDitp2X.d.mts.map +1 -0
- package/dist/codecs-CDcidsHL.mjs +221 -0
- package/dist/codecs-CDcidsHL.mjs.map +1 -0
- package/dist/codecs.d.mts +3 -2
- package/dist/codecs.mjs +13 -2
- package/dist/codecs.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/descriptor-meta-BA2YAFQq.mjs.map +1 -1
- package/dist/migration.d.mts +2 -2
- package/dist/{op-factory-call-BPPSCdTB.d.mts → op-factory-call-dUIOao68.d.mts} +3 -3
- package/dist/{op-factory-call-BPPSCdTB.d.mts.map → op-factory-call-dUIOao68.d.mts.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/pack.d.mts +3 -1
- package/dist/pack.d.mts.map +1 -1
- package/dist/{planner-produced-sqlite-migration-RVneETNy.d.mts → planner-produced-sqlite-migration-BfIIUtxe.d.mts} +4 -4
- package/dist/{planner-produced-sqlite-migration-RVneETNy.d.mts.map → planner-produced-sqlite-migration-BfIIUtxe.d.mts.map} +1 -1
- package/dist/planner-produced-sqlite-migration.d.mts +4 -4
- package/dist/{planner-target-details-DTIFFx4L.d.mts → planner-target-details-CtWRvse0.d.mts} +1 -1
- package/dist/{planner-target-details-DTIFFx4L.d.mts.map → planner-target-details-CtWRvse0.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +5 -5
- package/dist/render-ops.d.mts +3 -3
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-BNtoZqdo.d.mts → shared-D_1fFqLf.d.mts} +2 -2
- package/dist/{shared-BNtoZqdo.d.mts.map → shared-D_1fFqLf.d.mts.map} +1 -1
- package/dist/{sqlite-migration-BYgrMZdR.d.mts → sqlite-migration-BeR1cikr.d.mts} +2 -2
- package/dist/{sqlite-migration-BYgrMZdR.d.mts.map → sqlite-migration-BeR1cikr.d.mts.map} +1 -1
- package/package.json +15 -15
- package/src/core/codec-helpers.ts +11 -0
- package/src/core/codecs.ts +316 -98
- package/src/core/descriptor-meta.ts +1 -1
- package/src/core/registry.ts +11 -0
- package/src/core/runtime-target.ts +1 -3
- package/src/exports/codec-types.ts +40 -3
- package/src/exports/codecs.ts +20 -1
- package/dist/codec-ids.d.mts.map +0 -1
- package/dist/codec-types.d.mts.map +0 -1
- package/dist/codecs-5GJysiEg.mjs +0 -95
- package/dist/codecs-5GJysiEg.mjs.map +0 -1
- package/dist/codecs-D4jgBM6T.d.mts +0 -139
- package/dist/codecs-D4jgBM6T.d.mts.map +0 -1
package/dist/{planner-target-details-DTIFFx4L.d.mts → planner-target-details-CtWRvse0.d.mts}
RENAMED
|
@@ -9,4 +9,4 @@ interface SqlitePlanTargetDetails {
|
|
|
9
9
|
declare function buildTargetDetails(objectType: OperationClass, name: string, table?: string): SqlitePlanTargetDetails;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { buildTargetDetails as n, SqlitePlanTargetDetails as t };
|
|
12
|
-
//# sourceMappingURL=planner-target-details-
|
|
12
|
+
//# sourceMappingURL=planner-target-details-CtWRvse0.d.mts.map
|
package/dist/{planner-target-details-DTIFFx4L.d.mts.map → planner-target-details-CtWRvse0.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-target-details-
|
|
1
|
+
{"version":3,"file":"planner-target-details-CtWRvse0.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"sourcesContent":[],"mappings":";KAEY,cAAA;AAAA,UAMK,uBAAA,CANS;EAMT,SAAA,MAAA,EAAA,MAAA;EAaD,SAAA,UAAA,EAXO,cAYT;;;;iBADE,kBAAA,aACF,+CAGX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-CtWRvse0.mjs";
|
|
2
2
|
export { type SqlitePlanTargetDetails, buildTargetDetails };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import "./shared-
|
|
3
|
-
import "./sqlite-migration-
|
|
4
|
-
import "./op-factory-call-
|
|
5
|
-
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-CtWRvse0.mjs";
|
|
2
|
+
import "./shared-D_1fFqLf.mjs";
|
|
3
|
+
import "./sqlite-migration-BeR1cikr.mjs";
|
|
4
|
+
import "./op-factory-call-dUIOao68.mjs";
|
|
5
|
+
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-BfIIUtxe.mjs";
|
|
6
6
|
import { MigrationOperationPolicy, SqlMigrationPlanner, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
7
7
|
import { Contract } from "@prisma-next/contract/types";
|
|
8
8
|
import { MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import "./shared-
|
|
3
|
-
import { l as SqliteOpFactoryCall } from "./op-factory-call-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-CtWRvse0.mjs";
|
|
2
|
+
import "./shared-D_1fFqLf.mjs";
|
|
3
|
+
import { l as SqliteOpFactoryCall } from "./op-factory-call-dUIOao68.mjs";
|
|
4
4
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
5
5
|
|
|
6
6
|
//#region src/core/migrations/render-ops.d.ts
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts"],"sourcesContent":[],"mappings":";;;;UAIiB,2BAAA,SAAoC;AAArD,cAEM,6BAFuC,EAER,0BAFqC,CAAA,QAAA,EAIxE,2BAJwE,CAAA"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-BA2YAFQq.mjs";
|
|
2
|
-
import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
|
|
3
2
|
|
|
4
3
|
//#region src/core/runtime-target.ts
|
|
5
4
|
const sqliteRuntimeTargetDescriptor = {
|
|
6
5
|
...sqliteTargetDescriptorMeta,
|
|
7
|
-
codecs: () =>
|
|
8
|
-
parameterizedCodecs: () => [],
|
|
6
|
+
codecs: () => [],
|
|
9
7
|
create() {
|
|
10
8
|
return {
|
|
11
9
|
familyId: "sql",
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":["sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n>"],"sources":["../src/core/runtime-target.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":["sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n>"],"sources":["../src/core/runtime-target.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\n\nexport interface SqliteRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'sqlite'> {}\n\nconst sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n> = {\n ...sqliteTargetDescriptorMeta,\n codecs: () => [],\n create(): SqliteRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n};\n\nexport default sqliteRuntimeTargetDescriptor;\n"],"mappings":";;;AAMA,MAAMA,gCAGF;CACF,GAAG;CACH,cAAc,EAAE;CAChB,SAAsC;AACpC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,6BAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-CtWRvse0.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ReferentialAction } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
@@ -66,4 +66,4 @@ interface SqliteIndexSpec {
|
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
68
|
export { SqliteTableSpec as i, SqliteColumnSpec as n, SqliteIndexSpec as r, Op as t };
|
|
69
|
-
//# sourceMappingURL=shared-
|
|
69
|
+
//# sourceMappingURL=shared-D_1fFqLf.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-D_1fFqLf.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"sourcesContent":[],"mappings":";;;;;KAKY,EAAA,GAAK,0BAA0B;AAkC3C;AAKA;AAgBA;;;;;;AAYA;;;;;;;;UA7CiB,gBAAA;;;;;;;UAQA,oBAAA;;;UAIA,gBAAA;;;;UAKA,oBAAA;;;;;;;sBAOK;sBACA;;;;;;;UAQL,eAAA;6BACY;wBACL;8BACM;kCACI;;;;;;;UAQjB,eAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-CtWRvse0.mjs";
|
|
2
2
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/sqlite-migration.d.ts
|
|
@@ -15,4 +15,4 @@ declare abstract class SqliteMigration extends Migration<SqlitePlanTargetDetails
|
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
17
|
export { SqliteMigration as t };
|
|
18
|
-
//# sourceMappingURL=sqlite-migration-
|
|
18
|
+
//# sourceMappingURL=sqlite-migration-BeR1cikr.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-migration-
|
|
1
|
+
{"version":3,"file":"sqlite-migration-BeR1cikr.d.mts","names":[],"sources":["../src/core/migrations/sqlite-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;AAUA;;;;;uBAAsB,eAAA,SAAwB,UAAa"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-sqlite",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.61",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/cli": "0.5.0-dev.
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/family-sql": "0.5.0-dev.
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/
|
|
14
|
-
"@prisma-next/sql-errors": "0.5.0-dev.
|
|
15
|
-
"@prisma-next/sql-relational-core": "0.5.0-dev.
|
|
16
|
-
"@prisma-next/sql-runtime": "0.5.0-dev.
|
|
17
|
-
"@prisma-next/sql-schema-ir": "0.5.0-dev.
|
|
18
|
-
"@prisma-next/ts-render": "0.5.0-dev.
|
|
19
|
-
"@prisma-next/
|
|
20
|
-
"@prisma-next/utils": "0.5.0-dev.
|
|
8
|
+
"@prisma-next/cli": "0.5.0-dev.61",
|
|
9
|
+
"@prisma-next/errors": "0.5.0-dev.61",
|
|
10
|
+
"@prisma-next/family-sql": "0.5.0-dev.61",
|
|
11
|
+
"@prisma-next/framework-components": "0.5.0-dev.61",
|
|
12
|
+
"@prisma-next/migration-tools": "0.5.0-dev.61",
|
|
13
|
+
"@prisma-next/sql-contract": "0.5.0-dev.61",
|
|
14
|
+
"@prisma-next/sql-errors": "0.5.0-dev.61",
|
|
15
|
+
"@prisma-next/sql-relational-core": "0.5.0-dev.61",
|
|
16
|
+
"@prisma-next/sql-runtime": "0.5.0-dev.61",
|
|
17
|
+
"@prisma-next/sql-schema-ir": "0.5.0-dev.61",
|
|
18
|
+
"@prisma-next/ts-render": "0.5.0-dev.61",
|
|
19
|
+
"@prisma-next/contract": "0.5.0-dev.61",
|
|
20
|
+
"@prisma-next/utils": "0.5.0-dev.61"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"tsdown": "0.18.4",
|
|
24
24
|
"typescript": "5.9.3",
|
|
25
25
|
"vitest": "4.0.17",
|
|
26
|
+
"@prisma-next/driver-sqlite": "0.5.0-dev.61",
|
|
26
27
|
"@prisma-next/test-utils": "0.0.1",
|
|
27
|
-
"@prisma-next/driver-sqlite": "0.5.0-dev.60",
|
|
28
28
|
"@prisma-next/tsconfig": "0.0.0",
|
|
29
29
|
"@prisma-next/tsdown": "0.0.0"
|
|
30
30
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local `JsonValue` alias for the SQLite target. Codec implementations live in `codecs.ts` (TML-2357); this module retains only the JSON-shape alias the surrounding adapter and tests still import.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type JsonValue =
|
|
6
|
+
| string
|
|
7
|
+
| number
|
|
8
|
+
| boolean
|
|
9
|
+
| null
|
|
10
|
+
| { readonly [key: string]: JsonValue }
|
|
11
|
+
| readonly JsonValue[];
|
package/src/core/codecs.ts
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Native SQLite target codecs (TML-2357). Mirrors the Postgres codec class form in `packages/3-targets/3-targets/postgres/src/core/codecs.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Each codec ships as three artifacts:
|
|
5
|
+
*
|
|
6
|
+
* 1. A `SqliteXCodec` class extending {@link CodecImpl} that wraps the encode/decode/encodeJson/decodeJson conversions inline. SQLite's runtime conversions are simple enough that there is no shared helper module; the class bodies are the single source of truth. 2. A `SqliteXDescriptor` class extending {@link CodecDescriptorImpl} declaring the codec id, traits, target types, and params schema. SQLite codecs do not carry
|
|
7
|
+
* `meta` (no per-target native-type meta today) and are all non-parameterized. 3. A per-codec column helper (`sqliteXColumn`) that calls `descriptor.factory()` directly and packages the result into a {@link ColumnSpec} via the framework {@link column} packager. The helper is tied to its descriptor with `satisfies ColumnHelperFor` + `ColumnHelperForStrict` (every SQLite codec's resolved type is well-defined).
|
|
8
|
+
*
|
|
9
|
+
* After TML-2357 this is the canonical source of SQLite codec metadata and runtime behaviour — the legacy `mkCodec` / `defineCodec` carriers (and the parallel `byScalar` / `codecDescriptorDefinitions` collection exports) retired with the deletion sweep.
|
|
10
|
+
*
|
|
11
|
+
* Audit: every SQLite codec is non-parameterized and parameter-stateless; `factory()` takes no params (`P = void`) and returns a fresh codec constructed solely from `this`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { JsonValue } from '@prisma-next/contract/types';
|
|
15
|
+
import {
|
|
16
|
+
type AnyCodecDescriptor,
|
|
17
|
+
type CodecCallContext,
|
|
18
|
+
CodecDescriptorImpl,
|
|
19
|
+
CodecImpl,
|
|
20
|
+
type CodecInstanceContext,
|
|
21
|
+
type ColumnHelperFor,
|
|
22
|
+
type ColumnHelperForStrict,
|
|
23
|
+
column,
|
|
24
|
+
voidParamsSchema,
|
|
25
|
+
} from '@prisma-next/framework-components/codec';
|
|
26
|
+
import {
|
|
27
|
+
sqlCharDescriptor,
|
|
28
|
+
sqlFloatDescriptor,
|
|
29
|
+
sqlIntDescriptor,
|
|
30
|
+
sqlVarcharDescriptor,
|
|
31
|
+
} from '@prisma-next/sql-relational-core/ast';
|
|
2
32
|
import {
|
|
3
33
|
SQLITE_BIGINT_CODEC_ID,
|
|
4
34
|
SQLITE_BLOB_CODEC_ID,
|
|
@@ -9,111 +39,299 @@ import {
|
|
|
9
39
|
SQLITE_TEXT_CODEC_ID,
|
|
10
40
|
} from './codec-ids';
|
|
11
41
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
targetTypes
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
export class SqliteTextCodec extends CodecImpl<
|
|
43
|
+
typeof SQLITE_TEXT_CODEC_ID,
|
|
44
|
+
readonly ['equality', 'order', 'textual'],
|
|
45
|
+
string,
|
|
46
|
+
string
|
|
47
|
+
> {
|
|
48
|
+
async encode(value: string, _ctx: CodecCallContext): Promise<string> {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
async decode(wire: string, _ctx: CodecCallContext): Promise<string> {
|
|
52
|
+
return wire;
|
|
53
|
+
}
|
|
54
|
+
encodeJson(value: string): JsonValue {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
decodeJson(json: JsonValue): string {
|
|
58
|
+
return json as string;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class SqliteTextDescriptor extends CodecDescriptorImpl<void> {
|
|
63
|
+
override readonly codecId = SQLITE_TEXT_CODEC_ID;
|
|
64
|
+
override readonly traits = ['equality', 'order', 'textual'] as const;
|
|
65
|
+
override readonly targetTypes = ['text'] as const;
|
|
66
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
67
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteTextCodec {
|
|
68
|
+
return () => new SqliteTextCodec(this);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const sqliteTextDescriptor = new SqliteTextDescriptor();
|
|
73
|
+
|
|
74
|
+
export const sqliteTextColumn = () =>
|
|
75
|
+
column(sqliteTextDescriptor.factory(), sqliteTextDescriptor.codecId, undefined, 'text');
|
|
76
|
+
|
|
77
|
+
sqliteTextColumn satisfies ColumnHelperFor<SqliteTextDescriptor>;
|
|
78
|
+
sqliteTextColumn satisfies ColumnHelperForStrict<SqliteTextDescriptor>;
|
|
79
|
+
|
|
80
|
+
export class SqliteIntegerCodec extends CodecImpl<
|
|
81
|
+
typeof SQLITE_INTEGER_CODEC_ID,
|
|
82
|
+
readonly ['equality', 'order', 'numeric'],
|
|
83
|
+
number,
|
|
84
|
+
number
|
|
85
|
+
> {
|
|
86
|
+
async encode(value: number, _ctx: CodecCallContext): Promise<number> {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
async decode(wire: number, _ctx: CodecCallContext): Promise<number> {
|
|
90
|
+
return wire;
|
|
91
|
+
}
|
|
92
|
+
encodeJson(value: number): JsonValue {
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
decodeJson(json: JsonValue): number {
|
|
96
|
+
return json as number;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class SqliteIntegerDescriptor extends CodecDescriptorImpl<void> {
|
|
101
|
+
override readonly codecId = SQLITE_INTEGER_CODEC_ID;
|
|
102
|
+
override readonly traits = ['equality', 'order', 'numeric'] as const;
|
|
103
|
+
override readonly targetTypes = ['integer'] as const;
|
|
104
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
105
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteIntegerCodec {
|
|
106
|
+
return () => new SqliteIntegerCodec(this);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const sqliteIntegerDescriptor = new SqliteIntegerDescriptor();
|
|
111
|
+
|
|
112
|
+
export const sqliteIntegerColumn = () =>
|
|
113
|
+
column(sqliteIntegerDescriptor.factory(), sqliteIntegerDescriptor.codecId, undefined, 'integer');
|
|
114
|
+
|
|
115
|
+
sqliteIntegerColumn satisfies ColumnHelperFor<SqliteIntegerDescriptor>;
|
|
116
|
+
sqliteIntegerColumn satisfies ColumnHelperForStrict<SqliteIntegerDescriptor>;
|
|
117
|
+
|
|
118
|
+
export class SqliteRealCodec extends CodecImpl<
|
|
119
|
+
typeof SQLITE_REAL_CODEC_ID,
|
|
120
|
+
readonly ['equality', 'order', 'numeric'],
|
|
121
|
+
number,
|
|
122
|
+
number
|
|
123
|
+
> {
|
|
124
|
+
async encode(value: number, _ctx: CodecCallContext): Promise<number> {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
async decode(wire: number, _ctx: CodecCallContext): Promise<number> {
|
|
128
|
+
return wire;
|
|
129
|
+
}
|
|
130
|
+
encodeJson(value: number): JsonValue {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
decodeJson(json: JsonValue): number {
|
|
134
|
+
return json as number;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export class SqliteRealDescriptor extends CodecDescriptorImpl<void> {
|
|
139
|
+
override readonly codecId = SQLITE_REAL_CODEC_ID;
|
|
140
|
+
override readonly traits = ['equality', 'order', 'numeric'] as const;
|
|
141
|
+
override readonly targetTypes = ['real'] as const;
|
|
142
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
143
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteRealCodec {
|
|
144
|
+
return () => new SqliteRealCodec(this);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const sqliteRealDescriptor = new SqliteRealDescriptor();
|
|
149
|
+
|
|
150
|
+
export const sqliteRealColumn = () =>
|
|
151
|
+
column(sqliteRealDescriptor.factory(), sqliteRealDescriptor.codecId, undefined, 'real');
|
|
152
|
+
|
|
153
|
+
sqliteRealColumn satisfies ColumnHelperFor<SqliteRealDescriptor>;
|
|
154
|
+
sqliteRealColumn satisfies ColumnHelperForStrict<SqliteRealDescriptor>;
|
|
155
|
+
|
|
156
|
+
export class SqliteBlobCodec extends CodecImpl<
|
|
157
|
+
typeof SQLITE_BLOB_CODEC_ID,
|
|
158
|
+
readonly ['equality'],
|
|
159
|
+
Uint8Array,
|
|
160
|
+
Uint8Array
|
|
161
|
+
> {
|
|
162
|
+
async encode(value: Uint8Array, _ctx: CodecCallContext): Promise<Uint8Array> {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
async decode(wire: Uint8Array, _ctx: CodecCallContext): Promise<Uint8Array> {
|
|
166
|
+
return wire;
|
|
167
|
+
}
|
|
168
|
+
encodeJson(value: Uint8Array): JsonValue {
|
|
169
|
+
return Buffer.from(value).toString('base64');
|
|
170
|
+
}
|
|
171
|
+
decodeJson(json: JsonValue): Uint8Array {
|
|
57
172
|
if (typeof json !== 'string') {
|
|
58
173
|
throw new TypeError('sqlite/blob@1 contract value must be a base64 string');
|
|
59
174
|
}
|
|
60
175
|
return new Uint8Array(Buffer.from(json, 'base64'));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export class SqliteBlobDescriptor extends CodecDescriptorImpl<void> {
|
|
180
|
+
override readonly codecId = SQLITE_BLOB_CODEC_ID;
|
|
181
|
+
override readonly traits = ['equality'] as const;
|
|
182
|
+
override readonly targetTypes = ['blob'] as const;
|
|
183
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
184
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteBlobCodec {
|
|
185
|
+
return () => new SqliteBlobCodec(this);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const sqliteBlobDescriptor = new SqliteBlobDescriptor();
|
|
190
|
+
|
|
191
|
+
export const sqliteBlobColumn = () =>
|
|
192
|
+
column(sqliteBlobDescriptor.factory(), sqliteBlobDescriptor.codecId, undefined, 'blob');
|
|
193
|
+
|
|
194
|
+
sqliteBlobColumn satisfies ColumnHelperFor<SqliteBlobDescriptor>;
|
|
195
|
+
sqliteBlobColumn satisfies ColumnHelperForStrict<SqliteBlobDescriptor>;
|
|
196
|
+
|
|
197
|
+
export class SqliteDatetimeCodec extends CodecImpl<
|
|
198
|
+
typeof SQLITE_DATETIME_CODEC_ID,
|
|
199
|
+
readonly ['equality', 'order'],
|
|
200
|
+
string,
|
|
201
|
+
Date
|
|
202
|
+
> {
|
|
203
|
+
// Reject `Invalid Date` (NaN-time) at every decode ingress so consumers never receive a Date object whose downstream operations silently produce NaN. Mirrors the stricter ISO-8601 validation on the postgres timestamp helpers.
|
|
204
|
+
private parseDate(value: string): Date {
|
|
205
|
+
const date = new Date(value);
|
|
206
|
+
if (Number.isNaN(date.getTime())) {
|
|
207
|
+
throw new TypeError(`sqlite/datetime@1 value must be a valid ISO-8601 string: ${value}`);
|
|
208
|
+
}
|
|
209
|
+
return date;
|
|
210
|
+
}
|
|
211
|
+
async encode(value: Date, _ctx: CodecCallContext): Promise<string> {
|
|
212
|
+
return value.toISOString();
|
|
213
|
+
}
|
|
214
|
+
async decode(wire: string, _ctx: CodecCallContext): Promise<Date> {
|
|
215
|
+
return this.parseDate(wire);
|
|
216
|
+
}
|
|
217
|
+
encodeJson(value: Date): JsonValue {
|
|
218
|
+
return value.toISOString();
|
|
219
|
+
}
|
|
220
|
+
decodeJson(json: JsonValue): Date {
|
|
72
221
|
if (typeof json !== 'string') {
|
|
73
222
|
throw new TypeError('sqlite/datetime@1 contract value must be an ISO-8601 string');
|
|
74
223
|
}
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
224
|
+
return this.parseDate(json);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export class SqliteDatetimeDescriptor extends CodecDescriptorImpl<void> {
|
|
229
|
+
override readonly codecId = SQLITE_DATETIME_CODEC_ID;
|
|
230
|
+
override readonly traits = ['equality', 'order'] as const;
|
|
231
|
+
override readonly targetTypes = ['text'] as const;
|
|
232
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
233
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteDatetimeCodec {
|
|
234
|
+
return () => new SqliteDatetimeCodec(this);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export const sqliteDatetimeDescriptor = new SqliteDatetimeDescriptor();
|
|
239
|
+
|
|
240
|
+
export const sqliteDatetimeColumn = () =>
|
|
241
|
+
column(sqliteDatetimeDescriptor.factory(), sqliteDatetimeDescriptor.codecId, undefined, 'text');
|
|
242
|
+
|
|
243
|
+
sqliteDatetimeColumn satisfies ColumnHelperFor<SqliteDatetimeDescriptor>;
|
|
244
|
+
sqliteDatetimeColumn satisfies ColumnHelperForStrict<SqliteDatetimeDescriptor>;
|
|
245
|
+
|
|
246
|
+
export class SqliteJsonCodec extends CodecImpl<
|
|
247
|
+
typeof SQLITE_JSON_CODEC_ID,
|
|
248
|
+
readonly ['equality'],
|
|
249
|
+
string | JsonValue,
|
|
250
|
+
JsonValue
|
|
251
|
+
> {
|
|
252
|
+
async encode(value: JsonValue, _ctx: CodecCallContext): Promise<string> {
|
|
253
|
+
return JSON.stringify(value);
|
|
254
|
+
}
|
|
255
|
+
async decode(wire: string | JsonValue, _ctx: CodecCallContext): Promise<JsonValue> {
|
|
256
|
+
return typeof wire === 'string' ? (JSON.parse(wire) as JsonValue) : wire;
|
|
257
|
+
}
|
|
258
|
+
encodeJson(value: JsonValue): JsonValue {
|
|
259
|
+
return value;
|
|
260
|
+
}
|
|
261
|
+
decodeJson(json: JsonValue): JsonValue {
|
|
262
|
+
return json;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export class SqliteJsonDescriptor extends CodecDescriptorImpl<void> {
|
|
267
|
+
override readonly codecId = SQLITE_JSON_CODEC_ID;
|
|
268
|
+
override readonly traits = ['equality'] as const;
|
|
269
|
+
override readonly targetTypes = ['text'] as const;
|
|
270
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
271
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteJsonCodec {
|
|
272
|
+
return () => new SqliteJsonCodec(this);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export const sqliteJsonDescriptor = new SqliteJsonDescriptor();
|
|
277
|
+
|
|
278
|
+
export const sqliteJsonColumn = () =>
|
|
279
|
+
column(sqliteJsonDescriptor.factory(), sqliteJsonDescriptor.codecId, undefined, 'text');
|
|
280
|
+
|
|
281
|
+
sqliteJsonColumn satisfies ColumnHelperFor<SqliteJsonDescriptor>;
|
|
282
|
+
sqliteJsonColumn satisfies ColumnHelperForStrict<SqliteJsonDescriptor>;
|
|
283
|
+
|
|
284
|
+
export class SqliteBigintCodec extends CodecImpl<
|
|
285
|
+
typeof SQLITE_BIGINT_CODEC_ID,
|
|
286
|
+
readonly ['equality', 'order', 'numeric'],
|
|
287
|
+
number | bigint,
|
|
288
|
+
bigint
|
|
289
|
+
> {
|
|
290
|
+
async encode(value: bigint, _ctx: CodecCallContext): Promise<number | bigint> {
|
|
291
|
+
return value;
|
|
292
|
+
}
|
|
293
|
+
async decode(wire: number | bigint, _ctx: CodecCallContext): Promise<bigint> {
|
|
294
|
+
return BigInt(wire);
|
|
295
|
+
}
|
|
296
|
+
encodeJson(value: bigint): JsonValue {
|
|
297
|
+
return value.toString();
|
|
298
|
+
}
|
|
299
|
+
decodeJson(json: JsonValue): bigint {
|
|
96
300
|
if (typeof json !== 'string' && typeof json !== 'number') {
|
|
97
301
|
throw new TypeError('sqlite/bigint@1 contract value must be a string or number');
|
|
98
302
|
}
|
|
99
303
|
return BigInt(json);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export class SqliteBigintDescriptor extends CodecDescriptorImpl<void> {
|
|
308
|
+
override readonly codecId = SQLITE_BIGINT_CODEC_ID;
|
|
309
|
+
override readonly traits = ['equality', 'order', 'numeric'] as const;
|
|
310
|
+
override readonly targetTypes = ['integer'] as const;
|
|
311
|
+
override readonly paramsSchema = voidParamsSchema;
|
|
312
|
+
override factory(): (ctx: CodecInstanceContext) => SqliteBigintCodec {
|
|
313
|
+
return () => new SqliteBigintCodec(this);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export const sqliteBigintDescriptor = new SqliteBigintDescriptor();
|
|
318
|
+
|
|
319
|
+
export const sqliteBigintColumn = () =>
|
|
320
|
+
column(sqliteBigintDescriptor.factory(), sqliteBigintDescriptor.codecId, undefined, 'integer');
|
|
321
|
+
|
|
322
|
+
sqliteBigintColumn satisfies ColumnHelperFor<SqliteBigintDescriptor>;
|
|
323
|
+
sqliteBigintColumn satisfies ColumnHelperForStrict<SqliteBigintDescriptor>;
|
|
324
|
+
|
|
325
|
+
export const codecDescriptors: readonly AnyCodecDescriptor[] = [
|
|
326
|
+
sqlCharDescriptor,
|
|
327
|
+
sqlVarcharDescriptor,
|
|
328
|
+
sqlIntDescriptor,
|
|
329
|
+
sqlFloatDescriptor,
|
|
330
|
+
sqliteTextDescriptor,
|
|
331
|
+
sqliteIntegerDescriptor,
|
|
332
|
+
sqliteRealDescriptor,
|
|
333
|
+
sqliteBlobDescriptor,
|
|
334
|
+
sqliteDatetimeDescriptor,
|
|
335
|
+
sqliteJsonDescriptor,
|
|
336
|
+
sqliteBigintDescriptor,
|
|
337
|
+
];
|
|
@@ -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',
|