@prisma-next/target-sqlite 0.14.0-dev.20 → 0.14.0-dev.22
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/control.d.mts +3 -4
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +2 -2
- package/dist/{descriptor-meta-DxmEeTJ-.mjs → descriptor-meta-Dxx2A6PT.mjs} +3 -10
- package/dist/descriptor-meta-Dxx2A6PT.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-BkXK3OjD.mjs +12 -0
- package/dist/descriptor-meta-runtime-BkXK3OjD.mjs.map +1 -0
- package/dist/pack.mjs +1 -1
- package/dist/runtime.d.mts +4 -3
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/{sqlite-contract-serializer--iaDgC8e.mjs → sqlite-contract-serializer-BYXc_ZaG.mjs} +20 -8
- package/dist/sqlite-contract-serializer-BYXc_ZaG.mjs.map +1 -0
- package/package.json +18 -18
- package/src/core/sqlite-contract-serializer.ts +41 -14
- package/src/core/sqlite-unbound-database.ts +8 -8
- package/dist/descriptor-meta-DxmEeTJ-.mjs.map +0 -1
- package/dist/sqlite-contract-serializer--iaDgC8e.mjs.map +0 -1
package/dist/control.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { t as SqlitePlanTargetDetails } from "./planner-target-details-xR6UfIcz.mjs";
|
|
2
2
|
import { SqlControlTargetDescriptor } from "@prisma-next/family-sql/control";
|
|
3
|
-
import { SqlNamespaceEntries,
|
|
4
|
-
import { NamespaceBase } from "@prisma-next/framework-components/ir";
|
|
3
|
+
import { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, StorageTable } from "@prisma-next/sql-contract/types";
|
|
5
4
|
|
|
6
5
|
//#region src/core/control-target.d.ts
|
|
7
6
|
declare const sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails>;
|
|
@@ -16,7 +15,7 @@ type SqliteDatabaseInput = {
|
|
|
16
15
|
* `entries.table` and unqualified `qualifyTable()` emission for runtime
|
|
17
16
|
* SQL rendering.
|
|
18
17
|
*/
|
|
19
|
-
declare class SqliteDatabase extends
|
|
18
|
+
declare class SqliteDatabase extends SqlNamespaceBase {
|
|
20
19
|
readonly kind: string;
|
|
21
20
|
readonly id: string;
|
|
22
21
|
readonly entries: SqlNamespaceEntries;
|
|
@@ -56,7 +55,7 @@ declare class SqliteUnboundDatabase extends SqliteDatabase {
|
|
|
56
55
|
* user-declared SQLite namespaces, so this throw is a structural
|
|
57
56
|
* safety net rather than a user-facing surface.
|
|
58
57
|
*/
|
|
59
|
-
declare function sqliteCreateNamespace(input:
|
|
58
|
+
declare function sqliteCreateNamespace(input: SqlNamespaceInput): SqliteDatabase | SqliteUnboundDatabase;
|
|
60
59
|
//#endregion
|
|
61
60
|
export { type SqlitePlanTargetDetails, SqliteUnboundDatabase, sqliteControlTargetDescriptor as default, sqliteCreateNamespace };
|
|
62
61
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-target.ts","../src/core/sqlite-unbound-database.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-target.ts","../src/core/sqlite-unbound-database.ts"],"mappings":";;;;;cAgCM,6BAAA,EAA+B,0BAA0B,WAAW,uBAAA;;;KClB9D,mBAAA;EAAA,SACD,EAAA;EAAA,SACA,OAAA,EAAS,mBAAmB;AAAA;ADH4C;;;;AAmBc;AAnBd,cCatE,cAAA,SAAuB,gBAAA;EAAA,SACjB,IAAA;EAAA,SAER,EAAA;EAAA,SACA,OAAA,EAAS,mBAAA;cAEN,KAAA,EAAO,mBAAA;EAAA,IAyBf,KAAA,IAAS,QAAA,CAAS,MAAA,SAAe,YAAA;EAIrC,SAAA;EAIA,YAAA,CAAa,SAAA;AAAA;;;AAjDwB;AAUvC;;;;;;;;;;;;;;cA6Da,qBAAA,SAA8B,cAAc;EAAA,gBACvC,QAAA,EAAU,qBAAA;EAAA,QAEnB,WAAA;AAAA;;;;;;;;;AAzBuB;AAsBhC;iBAmCgB,qBAAA,CACd,KAAA,EAAO,iBAAA,GACN,cAAA,GAAiB,qBAAA"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-
|
|
1
|
+
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-Dxx2A6PT.mjs";
|
|
2
2
|
import { t as parseSqliteDefault } from "./default-normalizer-DuoHj9-O.mjs";
|
|
3
3
|
import { t as normalizeSqliteNativeType } from "./native-type-normalizer-CiSyVmMP.mjs";
|
|
4
4
|
import { r as MARKER_TABLE_NAME } from "./control-tables-7KwMyJ6i.mjs";
|
|
5
5
|
import { h as renderDefaultLiteral } from "./op-factory-call-DmdfD1yd.mjs";
|
|
6
6
|
import { n as createSqliteMigrationPlanner } from "./planner-Ciq8p_dL.mjs";
|
|
7
|
-
import { n as SqliteUnboundDatabase, r as sqliteCreateNamespace, t as SqliteContractSerializer } from "./sqlite-contract-serializer
|
|
7
|
+
import { n as SqliteUnboundDatabase, r as sqliteCreateNamespace, t as SqliteContractSerializer } from "./sqlite-contract-serializer-BYXc_ZaG.mjs";
|
|
8
8
|
import { contractToSchemaIR, runnerFailure, runnerSuccess } from "@prisma-next/family-sql/control";
|
|
9
9
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
10
10
|
import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as sqliteTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-BkXK3OjD.mjs";
|
|
1
2
|
import { temporalAuthoringPresets } from "@prisma-next/family-sql/control";
|
|
2
3
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
3
4
|
//#region src/core/authoring.ts
|
|
@@ -5,20 +6,12 @@ const sqliteAuthoringFieldPresets = { temporal: /* @__PURE__ */ temporalAuthorin
|
|
|
5
6
|
codecId: "sqlite/datetime@1",
|
|
6
7
|
nativeType: "text"
|
|
7
8
|
}) };
|
|
8
|
-
const sqliteTargetDescriptorMetaRuntime = {
|
|
9
|
-
kind: "target",
|
|
10
|
-
familyId: "sql",
|
|
11
|
-
targetId: "sqlite",
|
|
12
|
-
id: "sqlite",
|
|
13
|
-
version: "0.0.1",
|
|
14
|
-
capabilities: {}
|
|
15
|
-
};
|
|
16
9
|
const sqliteTargetDescriptorMeta = {
|
|
17
10
|
...sqliteTargetDescriptorMetaRuntime,
|
|
18
11
|
defaultNamespaceId: UNBOUND_NAMESPACE_ID,
|
|
19
12
|
authoring: { field: sqliteAuthoringFieldPresets }
|
|
20
13
|
};
|
|
21
14
|
//#endregion
|
|
22
|
-
export {
|
|
15
|
+
export { sqliteTargetDescriptorMeta as t };
|
|
23
16
|
|
|
24
|
-
//# sourceMappingURL=descriptor-meta-
|
|
17
|
+
//# sourceMappingURL=descriptor-meta-Dxx2A6PT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-Dxx2A6PT.mjs","names":[],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqliteAuthoringFieldPresets = {\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'sqlite/datetime@1',\n nativeType: 'text',\n }),\n} as const satisfies AuthoringFieldNamespace;\n","import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { CodecTypes } from '../exports/codec-types';\nimport { sqliteAuthoringFieldPresets } from './authoring';\nimport { sqliteTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';\n\nconst sqliteTargetDescriptorMetaBase = {\n ...sqliteTargetDescriptorMetaRuntime,\n defaultNamespaceId: UNBOUND_NAMESPACE_ID,\n authoring: {\n field: sqliteAuthoringFieldPresets,\n },\n} as const;\n\nexport const sqliteTargetDescriptorMeta: typeof sqliteTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = sqliteTargetDescriptorMetaBase;\n"],"mappings":";;;;AAGA,MAAa,8BAA8B,EACzC,UAA0B,yCAAyB;CACjD,SAAS;CACT,YAAY;AACd,CAAC,EACH;ACKA,MAAa,6BAET;CATF,GAAG;CACH,oBAAoB;CACpB,WAAW,EACT,OAAO,4BACT;AAKE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const sqliteTargetDescriptorMetaRuntime = {
|
|
2
|
+
kind: "target",
|
|
3
|
+
familyId: "sql",
|
|
4
|
+
targetId: "sqlite",
|
|
5
|
+
id: "sqlite",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
capabilities: {}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { sqliteTargetDescriptorMetaRuntime as t };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=descriptor-meta-runtime-BkXK3OjD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-runtime-BkXK3OjD.mjs","names":[],"sources":["../src/core/descriptor-meta-runtime.ts"],"sourcesContent":["// Runtime-safe slice of the sqlite target descriptor metadata.\n//\n// This file exists separately from ./descriptor-meta on purpose: the runtime\n// plane reads only `kind/familyId/targetId/id/version/capabilities` (plus the\n// `__codecTypes` phantom). The `authoring` slot lives on the pack/control\n// descriptor only, because authoring contributions are consumed at\n// contract-construction time by `assembleAuthoringContributions` (control\n// plane) and the PSL interpreter — never at runtime.\n//\n// Keeping the runtime closure free of the `./authoring` import is what lets\n// the bundler tree-shake `@prisma-next/family-sql/control` (and its\n// transitive `verify-sql-schema` chunk) out of the runtime entry. Do not\n// add an `authoring` field here — if you need to, the pack/control meta in\n// `./descriptor-meta` is the right place. See TML-2766 for context.\nimport type { CodecTypes } from '../exports/codec-types';\n\nconst sqliteTargetDescriptorMetaRuntimeBase = {\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 sqliteTargetDescriptorMetaRuntime: typeof sqliteTargetDescriptorMetaRuntimeBase & {\n readonly __codecTypes?: CodecTypes;\n} = sqliteTargetDescriptorMetaRuntimeBase;\n"],"mappings":"AAyBA,MAAa,oCAET;CAVF,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;AAKb"}
|
package/dist/pack.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-
|
|
1
|
+
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-Dxx2A6PT.mjs";
|
|
2
2
|
export { sqliteTargetDescriptorMeta as default };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SqlNamespaceInput, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
2
2
|
import { Namespace } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
4
4
|
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
import { RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
|
|
6
6
|
import { SqlRuntimeTargetDescriptor } from "@prisma-next/sql-runtime";
|
|
7
|
+
import { JsonObject } from "@prisma-next/utils/json";
|
|
7
8
|
|
|
8
9
|
//#region src/core/runtime-target.d.ts
|
|
9
10
|
interface SqliteRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'sqlite'> {}
|
|
@@ -18,8 +19,8 @@ declare const sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<'sqlite'
|
|
|
18
19
|
*/
|
|
19
20
|
declare class SqliteContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
|
|
20
21
|
constructor();
|
|
21
|
-
protected
|
|
22
|
-
|
|
22
|
+
protected hydrateSqlNamespaceEntry(nsId: string, raw: Record<string, unknown>): Namespace | SqlNamespaceInput;
|
|
23
|
+
serializeContract(contract: Contract<SqlStorage>): JsonObject;
|
|
23
24
|
}
|
|
24
25
|
//#endregion
|
|
25
26
|
export { SqliteContractSerializer, type SqliteRuntimeTargetInstance, sqliteRuntimeTargetDescriptor as default };
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts","../src/core/sqlite-contract-serializer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts","../src/core/sqlite-contract-serializer.ts"],"mappings":";;;;;;;;;UAIiB,2BAAA,SAAoC,qBAAqB;AAAA,cAEpE,6BAAA,EAA+B,0BAA0B,WAE7D,2BAAA;;;;;;;AAJF;;cCUa,wBAAA,SAAiC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;YAK5D,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,MAAA,oBACJ,SAAA,GAAY,iBAAA;EAQN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;AAAA"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as SqliteContractSerializer } from "./sqlite-contract-serializer
|
|
1
|
+
import { t as sqliteTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-BkXK3OjD.mjs";
|
|
2
|
+
import { t as SqliteContractSerializer } from "./sqlite-contract-serializer-BYXc_ZaG.mjs";
|
|
3
3
|
//#region src/core/runtime-target.ts
|
|
4
4
|
const sqliteRuntimeTargetDescriptor = {
|
|
5
5
|
...sqliteTargetDescriptorMetaRuntime,
|
package/dist/{sqlite-contract-serializer--iaDgC8e.mjs → sqlite-contract-serializer-BYXc_ZaG.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SqlNamespaceBase } from "@prisma-next/sql-contract/types";
|
|
2
|
+
import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
4
|
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
5
5
|
import { tableEntityKind } from "@prisma-next/sql-contract/entity-kinds";
|
|
@@ -10,7 +10,7 @@ const SQLITE_NAMESPACE_KIND = "sqlite-namespace";
|
|
|
10
10
|
* `entries.table` and unqualified `qualifyTable()` emission for runtime
|
|
11
11
|
* SQL rendering.
|
|
12
12
|
*/
|
|
13
|
-
var SqliteDatabase = class extends
|
|
13
|
+
var SqliteDatabase = class extends SqlNamespaceBase {
|
|
14
14
|
id;
|
|
15
15
|
entries;
|
|
16
16
|
constructor(input) {
|
|
@@ -98,15 +98,27 @@ var SqliteContractSerializer = class extends SqlContractSerializerBase {
|
|
|
98
98
|
constructor() {
|
|
99
99
|
super(/* @__PURE__ */ new Map());
|
|
100
100
|
}
|
|
101
|
-
get defaultNamespaceId() {
|
|
102
|
-
return sqliteTargetDescriptorMeta.defaultNamespaceId;
|
|
103
|
-
}
|
|
104
101
|
hydrateSqlNamespaceEntry(nsId, raw) {
|
|
105
|
-
if (raw instanceof NamespaceBase) return raw;
|
|
106
102
|
return buildSqliteNamespace(blindCast(super.hydrateSqlNamespaceEntry(nsId, raw)));
|
|
107
103
|
}
|
|
104
|
+
serializeContract(contract) {
|
|
105
|
+
const { storage, ...rest } = contract;
|
|
106
|
+
const namespacesJson = {};
|
|
107
|
+
for (const [nsId, ns] of Object.entries(storage.namespaces)) namespacesJson[nsId] = {
|
|
108
|
+
id: ns.id,
|
|
109
|
+
entries: { table: blindCast(JSON.parse(JSON.stringify(ns.entries.table ?? {}))) }
|
|
110
|
+
};
|
|
111
|
+
return blindCast({
|
|
112
|
+
...rest,
|
|
113
|
+
storage: {
|
|
114
|
+
storageHash: String(storage.storageHash),
|
|
115
|
+
namespaces: namespacesJson,
|
|
116
|
+
...storage.types !== void 0 ? { types: blindCast(JSON.parse(JSON.stringify(storage.types))) } : {}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
108
120
|
};
|
|
109
121
|
//#endregion
|
|
110
122
|
export { SqliteUnboundDatabase as n, sqliteCreateNamespace as r, SqliteContractSerializer as t };
|
|
111
123
|
|
|
112
|
-
//# sourceMappingURL=sqlite-contract-serializer
|
|
124
|
+
//# sourceMappingURL=sqlite-contract-serializer-BYXc_ZaG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-contract-serializer-BYXc_ZaG.mjs","names":[],"sources":["../src/core/sqlite-unbound-database.ts","../src/core/sqlite-contract-serializer.ts"],"sourcesContent":["import {\n freezeNode,\n hydrateNamespaceEntities,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { tableEntityKind } from '@prisma-next/sql-contract/entity-kinds';\nimport {\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceInput,\n type StorageTable,\n} from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\n\nexport type SqliteDatabaseInput = {\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n};\n\nconst SQLITE_NAMESPACE_KIND = 'sqlite-namespace' as const;\n\n/**\n * SQLite namespace concretion carrying table metadata under\n * `entries.table` and unqualified `qualifyTable()` emission for runtime\n * SQL rendering.\n */\nexport class SqliteDatabase extends SqlNamespaceBase {\n declare readonly kind: string;\n\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n\n constructor(input: SqliteDatabaseInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n new Map([['table', tableEntityKind]]),\n 'carry',\n );\n\n this.entries = Object.freeze(\n blindCast<\n SqlNamespaceEntries,\n \"SQLite's table-only descriptor map hydrates table→StorageTable and carries every other kind raw, so this open-dict result satisfies SqlNamespaceEntries; the descriptor Map erases the per-kind Node type from the return.\"\n >(dispatched),\n );\n Object.defineProperty(this, 'kind', {\n value: SQLITE_NAMESPACE_KIND,\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n qualifier(): string {\n return '';\n }\n\n qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n}\n\n/**\n * SQLite target `Namespace` concretion. SQLite has no schema or\n * database-namespacing concept at the SQL level — there is exactly one\n * effective namespace per connection, so the target ships a single\n * singleton bound to the framework's `UNBOUND_NAMESPACE_ID` slot.\n *\n * Qualifier emission elides the prefix entirely: rendered DDL and\n * queries look unqualified (`CREATE TABLE \"users\" (...)`), matching\n * SQLite's native dialect. Call sites stay polymorphic — they ask the\n * namespace for its qualifier and consume the empty/unqualified result\n * the same way Postgres consumes a `\"schema\"` prefix.\n *\n * The SQLite PSL interpreter rejects every explicit `namespace { … }`\n * block with a diagnostic naming SQLite; only the implicit\n * `__unspecified__` AST bucket reaches the SQLite interpreter, which\n * lowers it to this singleton.\n */\nexport class SqliteUnboundDatabase extends SqliteDatabase {\n static readonly instance: SqliteUnboundDatabase = new SqliteUnboundDatabase();\n\n private constructor() {\n super({ id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n}\n\nexport function buildSqliteNamespace(\n input: SqlNamespaceInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n if (input.id !== UNBOUND_NAMESPACE_ID) {\n throw new Error(\n `buildSqliteNamespace: SQLite has no schema concept; the only valid namespace id is \"${UNBOUND_NAMESPACE_ID}\" (received \"${input.id}\").`,\n );\n }\n const tableKind = input.entries['table'];\n const tableCount = tableKind !== undefined ? Object.keys(tableKind).length : 0;\n const hasUnknownKinds = Object.keys(input.entries).some((kind) => kind !== 'table');\n if (tableCount === 0 && !hasUnknownKinds) {\n return SqliteUnboundDatabase.instance;\n }\n return new SqliteDatabase({ id: input.id, entries: input.entries });\n}\n\n/**\n * Target-supplied `Namespace` factory the SQLite target plumbs through\n * `defineContract({ createNamespace })`. SQLite has only one\n * effective namespace slot — the framework `UNBOUND_NAMESPACE_ID`\n * sentinel — so the factory always returns the singleton or a fresh\n * `SqliteDatabase` for the unbound slot with tables. The SQL family's\n * defensive validation in `defineContract` already rejects\n * user-declared SQLite namespaces, so this throw is a structural\n * safety net rather than a user-facing surface.\n */\nexport function sqliteCreateNamespace(\n input: SqlNamespaceInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n return buildSqliteNamespace(input);\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlContractSerializerBase } from '@prisma-next/family-sql/ir';\nimport type { Namespace } from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport { buildSqliteNamespace } from './sqlite-unbound-database';\n\n/**\n * SQLite target `ContractSerializer` concretion. Mirrors the Postgres\n * shape: inherits the full SQL-family deserialization pipeline and\n * materialises namespace entries as SQLite database concretions that\n * expose `qualifyTable()` for runtime SQL rendering.\n */\nexport class SqliteContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n super(new Map());\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Record<string, unknown>,\n ): Namespace | SqlNamespaceInput {\n const hydrated = blindCast<\n SqlNamespaceInput,\n 'raw is always plain JSON, so super.hydrateSqlNamespaceEntry returns SqlNamespaceInput'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n return buildSqliteNamespace(hydrated);\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n namespacesJson[nsId] = {\n id: ns.id,\n entries: {\n table: blindCast<\n JsonObject,\n 'JSON.parse(JSON.stringify(...)) strips class methods; result is a plain JsonObject'\n >(JSON.parse(JSON.stringify(ns.entries.table ?? {}))),\n },\n };\n }\n return blindCast<\n JsonObject,\n 'rest + storage are serialized plain values; spread preserves JSON-clean contract envelope'\n >({\n ...rest,\n storage: {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n ...(storage.types !== undefined\n ? {\n types: blindCast<\n JsonObject,\n 'JSON.parse(JSON.stringify(...)) strips class methods; result is plain JsonObject'\n >(JSON.parse(JSON.stringify(storage.types))),\n }\n : {}),\n },\n });\n }\n}\n"],"mappings":";;;;;;AAmBA,MAAM,wBAAwB;;;;;;AAO9B,IAAa,iBAAb,cAAoC,iBAAiB;CAGnD;CACA;CAEA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAEhB,MAAM,aAAa,yBACjB,MAAM,SACN,IAAI,IAAI,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,GACpC,OACF;EAEA,KAAK,UAAU,OAAO,OACpB,UAGE,UAAU,CACd;EACA,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;CAEA,IAAI,QAAgD;EAClD,OAAO,KAAK,QAAQ,SAAS,OAAO,OAAO,CAAC,CAAC;CAC/C;CAEA,YAAoB;EAClB,OAAO;CACT;CAEA,aAAa,WAA2B;EACtC,OAAO,IAAI,UAAU;CACvB;AACF;;;;;;;;;;;;;;;;;;AAmBA,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,OAAgB,WAAkC,IAAI,sBAAsB;CAE5E,cAAsB;EACpB,MAAM;GAAE,IAAI;GAAsB,SAAS,EAAE,OAAO,CAAC,EAAE;EAAE,CAAC;CAC5D;AACF;AAEA,SAAgB,qBACd,OACwC;CACxC,IAAI,MAAM,OAAO,sBACf,MAAM,IAAI,MACR,uFAAuF,qBAAqB,eAAe,MAAM,GAAG,IACtI;CAEF,MAAM,YAAY,MAAM,QAAQ;CAChC,MAAM,aAAa,cAAc,KAAA,IAAY,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS;CAC7E,MAAM,kBAAkB,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,MAAM,SAAS,SAAS,OAAO;CAClF,IAAI,eAAe,KAAK,CAAC,iBACvB,OAAO,sBAAsB;CAE/B,OAAO,IAAI,eAAe;EAAE,IAAI,MAAM;EAAI,SAAS,MAAM;CAAQ,CAAC;AACpE;;;;;;;;;;;AAYA,SAAgB,sBACd,OACwC;CACxC,OAAO,qBAAqB,KAAK;AACnC;;;;;;;;;AChHA,IAAa,2BAAb,cAA8C,0BAAgD;CAC5F,cAAc;EACZ,sBAAM,IAAI,IAAI,CAAC;CACjB;CAEA,yBACE,MACA,KAC+B;EAK/B,OAAO,qBAJU,UAGf,MAAM,yBAAyB,MAAM,GAAG,CACP,CAAC;CACtC;CAEA,kBAA2B,UAA4C;EACrE,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,iBAA6C,CAAC;EACpD,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,QAAQ,UAAU,GACxD,eAAe,QAAQ;GACrB,IAAI,GAAG;GACP,SAAS,EACP,OAAO,UAGL,KAAK,MAAM,KAAK,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,EACtD;EACF;EAEF,OAAO,UAGL;GACA,GAAG;GACH,SAAS;IACP,aAAa,OAAO,QAAQ,WAAW;IACvC,YAAY;IACZ,GAAI,QAAQ,UAAU,KAAA,IAClB,EACE,OAAO,UAGL,KAAK,MAAM,KAAK,UAAU,QAAQ,KAAK,CAAC,CAAC,EAC7C,IACA,CAAC;GACP;EACF,CAAC;CACH;AACF"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-sqlite",
|
|
3
|
-
"version": "0.14.0-dev.
|
|
3
|
+
"version": "0.14.0-dev.22",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/cli": "0.14.0-dev.
|
|
9
|
-
"@prisma-next/contract": "0.14.0-dev.
|
|
10
|
-
"@prisma-next/errors": "0.14.0-dev.
|
|
11
|
-
"@prisma-next/family-sql": "0.14.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.14.0-dev.
|
|
13
|
-
"@prisma-next/migration-tools": "0.14.0-dev.
|
|
14
|
-
"@prisma-next/sql-contract": "0.14.0-dev.
|
|
15
|
-
"@prisma-next/sql-errors": "0.14.0-dev.
|
|
16
|
-
"@prisma-next/sql-relational-core": "0.14.0-dev.
|
|
17
|
-
"@prisma-next/sql-runtime": "0.14.0-dev.
|
|
18
|
-
"@prisma-next/sql-schema-ir": "0.14.0-dev.
|
|
19
|
-
"@prisma-next/ts-render": "0.14.0-dev.
|
|
20
|
-
"@prisma-next/utils": "0.14.0-dev.
|
|
8
|
+
"@prisma-next/cli": "0.14.0-dev.22",
|
|
9
|
+
"@prisma-next/contract": "0.14.0-dev.22",
|
|
10
|
+
"@prisma-next/errors": "0.14.0-dev.22",
|
|
11
|
+
"@prisma-next/family-sql": "0.14.0-dev.22",
|
|
12
|
+
"@prisma-next/framework-components": "0.14.0-dev.22",
|
|
13
|
+
"@prisma-next/migration-tools": "0.14.0-dev.22",
|
|
14
|
+
"@prisma-next/sql-contract": "0.14.0-dev.22",
|
|
15
|
+
"@prisma-next/sql-errors": "0.14.0-dev.22",
|
|
16
|
+
"@prisma-next/sql-relational-core": "0.14.0-dev.22",
|
|
17
|
+
"@prisma-next/sql-runtime": "0.14.0-dev.22",
|
|
18
|
+
"@prisma-next/sql-schema-ir": "0.14.0-dev.22",
|
|
19
|
+
"@prisma-next/ts-render": "0.14.0-dev.22",
|
|
20
|
+
"@prisma-next/utils": "0.14.0-dev.22",
|
|
21
21
|
"@standard-schema/spec": "1.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@prisma-next/driver-sqlite": "0.14.0-dev.
|
|
25
|
-
"@prisma-next/test-utils": "0.14.0-dev.
|
|
26
|
-
"@prisma-next/tsconfig": "0.14.0-dev.
|
|
27
|
-
"@prisma-next/tsdown": "0.14.0-dev.
|
|
24
|
+
"@prisma-next/driver-sqlite": "0.14.0-dev.22",
|
|
25
|
+
"@prisma-next/test-utils": "0.14.0-dev.22",
|
|
26
|
+
"@prisma-next/tsconfig": "0.14.0-dev.22",
|
|
27
|
+
"@prisma-next/tsdown": "0.14.0-dev.22",
|
|
28
28
|
"tsdown": "0.22.1",
|
|
29
29
|
"typescript": "5.9.3",
|
|
30
30
|
"vitest": "4.1.8"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Contract } from '@prisma-next/contract/types';
|
|
2
2
|
import { SqlContractSerializerBase } from '@prisma-next/family-sql/ir';
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
3
|
+
import type { Namespace } from '@prisma-next/framework-components/ir';
|
|
4
|
+
import type { SqlNamespaceInput, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
5
5
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
6
|
-
import {
|
|
6
|
+
import type { JsonObject } from '@prisma-next/utils/json';
|
|
7
7
|
import { buildSqliteNamespace } from './sqlite-unbound-database';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -17,21 +17,48 @@ export class SqliteContractSerializer extends SqlContractSerializerBase<Contract
|
|
|
17
17
|
super(new Map());
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
protected override get defaultNamespaceId(): string {
|
|
21
|
-
return sqliteTargetDescriptorMeta.defaultNamespaceId;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
20
|
protected override hydrateSqlNamespaceEntry(
|
|
25
21
|
nsId: string,
|
|
26
|
-
raw:
|
|
27
|
-
): Namespace |
|
|
28
|
-
if (raw instanceof NamespaceBase) {
|
|
29
|
-
return raw;
|
|
30
|
-
}
|
|
22
|
+
raw: Record<string, unknown>,
|
|
23
|
+
): Namespace | SqlNamespaceInput {
|
|
31
24
|
const hydrated = blindCast<
|
|
32
|
-
|
|
33
|
-
'
|
|
25
|
+
SqlNamespaceInput,
|
|
26
|
+
'raw is always plain JSON, so super.hydrateSqlNamespaceEntry returns SqlNamespaceInput'
|
|
34
27
|
>(super.hydrateSqlNamespaceEntry(nsId, raw));
|
|
35
28
|
return buildSqliteNamespace(hydrated);
|
|
36
29
|
}
|
|
30
|
+
|
|
31
|
+
override serializeContract(contract: Contract<SqlStorage>): JsonObject {
|
|
32
|
+
const { storage, ...rest } = contract;
|
|
33
|
+
const namespacesJson: Record<string, JsonObject> = {};
|
|
34
|
+
for (const [nsId, ns] of Object.entries(storage.namespaces)) {
|
|
35
|
+
namespacesJson[nsId] = {
|
|
36
|
+
id: ns.id,
|
|
37
|
+
entries: {
|
|
38
|
+
table: blindCast<
|
|
39
|
+
JsonObject,
|
|
40
|
+
'JSON.parse(JSON.stringify(...)) strips class methods; result is a plain JsonObject'
|
|
41
|
+
>(JSON.parse(JSON.stringify(ns.entries.table ?? {}))),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return blindCast<
|
|
46
|
+
JsonObject,
|
|
47
|
+
'rest + storage are serialized plain values; spread preserves JSON-clean contract envelope'
|
|
48
|
+
>({
|
|
49
|
+
...rest,
|
|
50
|
+
storage: {
|
|
51
|
+
storageHash: String(storage.storageHash),
|
|
52
|
+
namespaces: namespacesJson,
|
|
53
|
+
...(storage.types !== undefined
|
|
54
|
+
? {
|
|
55
|
+
types: blindCast<
|
|
56
|
+
JsonObject,
|
|
57
|
+
'JSON.parse(JSON.stringify(...)) strips class methods; result is plain JsonObject'
|
|
58
|
+
>(JSON.parse(JSON.stringify(storage.types))),
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
37
64
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
freezeNode,
|
|
3
3
|
hydrateNamespaceEntities,
|
|
4
|
-
NamespaceBase,
|
|
5
4
|
UNBOUND_NAMESPACE_ID,
|
|
6
5
|
} from '@prisma-next/framework-components/ir';
|
|
7
6
|
import { tableEntityKind } from '@prisma-next/sql-contract/entity-kinds';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import {
|
|
8
|
+
SqlNamespaceBase,
|
|
9
|
+
type SqlNamespaceEntries,
|
|
10
|
+
type SqlNamespaceInput,
|
|
11
|
+
type StorageTable,
|
|
12
12
|
} from '@prisma-next/sql-contract/types';
|
|
13
13
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
14
14
|
|
|
@@ -24,7 +24,7 @@ const SQLITE_NAMESPACE_KIND = 'sqlite-namespace' as const;
|
|
|
24
24
|
* `entries.table` and unqualified `qualifyTable()` emission for runtime
|
|
25
25
|
* SQL rendering.
|
|
26
26
|
*/
|
|
27
|
-
export class SqliteDatabase extends
|
|
27
|
+
export class SqliteDatabase extends SqlNamespaceBase {
|
|
28
28
|
declare readonly kind: string;
|
|
29
29
|
|
|
30
30
|
readonly id: string;
|
|
@@ -94,7 +94,7 @@ export class SqliteUnboundDatabase extends SqliteDatabase {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export function buildSqliteNamespace(
|
|
97
|
-
input:
|
|
97
|
+
input: SqlNamespaceInput,
|
|
98
98
|
): SqliteDatabase | SqliteUnboundDatabase {
|
|
99
99
|
if (input.id !== UNBOUND_NAMESPACE_ID) {
|
|
100
100
|
throw new Error(
|
|
@@ -121,7 +121,7 @@ export function buildSqliteNamespace(
|
|
|
121
121
|
* safety net rather than a user-facing surface.
|
|
122
122
|
*/
|
|
123
123
|
export function sqliteCreateNamespace(
|
|
124
|
-
input:
|
|
124
|
+
input: SqlNamespaceInput,
|
|
125
125
|
): SqliteDatabase | SqliteUnboundDatabase {
|
|
126
126
|
return buildSqliteNamespace(input);
|
|
127
127
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-DxmEeTJ-.mjs","names":[],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta-runtime.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqliteAuthoringFieldPresets = {\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'sqlite/datetime@1',\n nativeType: 'text',\n }),\n} as const satisfies AuthoringFieldNamespace;\n","// Runtime-safe slice of the sqlite target descriptor metadata.\n//\n// This file exists separately from ./descriptor-meta on purpose: the runtime\n// plane reads only `kind/familyId/targetId/id/version/capabilities` (plus the\n// `__codecTypes` phantom). The `authoring` slot lives on the pack/control\n// descriptor only, because authoring contributions are consumed at\n// contract-construction time by `assembleAuthoringContributions` (control\n// plane) and the PSL interpreter — never at runtime.\n//\n// Keeping the runtime closure free of the `./authoring` import is what lets\n// the bundler tree-shake `@prisma-next/family-sql/control` (and its\n// transitive `verify-sql-schema` chunk) out of the runtime entry. Do not\n// add an `authoring` field here — if you need to, the pack/control meta in\n// `./descriptor-meta` is the right place. See TML-2766 for context.\nimport type { CodecTypes } from '../exports/codec-types';\n\nconst sqliteTargetDescriptorMetaRuntimeBase = {\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 sqliteTargetDescriptorMetaRuntime: typeof sqliteTargetDescriptorMetaRuntimeBase & {\n readonly __codecTypes?: CodecTypes;\n} = sqliteTargetDescriptorMetaRuntimeBase;\n","import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { CodecTypes } from '../exports/codec-types';\nimport { sqliteAuthoringFieldPresets } from './authoring';\nimport { sqliteTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';\n\nconst sqliteTargetDescriptorMetaBase = {\n ...sqliteTargetDescriptorMetaRuntime,\n defaultNamespaceId: UNBOUND_NAMESPACE_ID,\n authoring: {\n field: sqliteAuthoringFieldPresets,\n },\n} as const;\n\nexport const sqliteTargetDescriptorMeta: typeof sqliteTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = sqliteTargetDescriptorMetaBase;\n"],"mappings":";;;AAGA,MAAa,8BAA8B,EACzC,UAA0B,yCAAyB;CACjD,SAAS;CACT,YAAY;AACd,CAAC,EACH;ACiBA,MAAa,oCAET;CAVF,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;AAKb;ACdJ,MAAa,6BAET;CATF,GAAG;CACH,oBAAoB;CACpB,WAAW,EACT,OAAO,4BACT;AAKE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-contract-serializer--iaDgC8e.mjs","names":[],"sources":["../src/core/sqlite-unbound-database.ts","../src/core/sqlite-contract-serializer.ts"],"sourcesContent":["import {\n freezeNode,\n hydrateNamespaceEntities,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { tableEntityKind } from '@prisma-next/sql-contract/entity-kinds';\nimport type {\n SqlNamespaceEntries,\n SqlNamespaceTablesInput,\n StorageTable,\n} from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\n\nexport type SqliteDatabaseInput = {\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n};\n\nconst SQLITE_NAMESPACE_KIND = 'sqlite-namespace' as const;\n\n/**\n * SQLite namespace concretion carrying table metadata under\n * `entries.table` and unqualified `qualifyTable()` emission for runtime\n * SQL rendering.\n */\nexport class SqliteDatabase extends NamespaceBase {\n declare readonly kind: string;\n\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n\n constructor(input: SqliteDatabaseInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n new Map([['table', tableEntityKind]]),\n 'carry',\n );\n\n this.entries = Object.freeze(\n blindCast<\n SqlNamespaceEntries,\n \"SQLite's table-only descriptor map hydrates table→StorageTable and carries every other kind raw, so this open-dict result satisfies SqlNamespaceEntries; the descriptor Map erases the per-kind Node type from the return.\"\n >(dispatched),\n );\n Object.defineProperty(this, 'kind', {\n value: SQLITE_NAMESPACE_KIND,\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n qualifier(): string {\n return '';\n }\n\n qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n}\n\n/**\n * SQLite target `Namespace` concretion. SQLite has no schema or\n * database-namespacing concept at the SQL level — there is exactly one\n * effective namespace per connection, so the target ships a single\n * singleton bound to the framework's `UNBOUND_NAMESPACE_ID` slot.\n *\n * Qualifier emission elides the prefix entirely: rendered DDL and\n * queries look unqualified (`CREATE TABLE \"users\" (...)`), matching\n * SQLite's native dialect. Call sites stay polymorphic — they ask the\n * namespace for its qualifier and consume the empty/unqualified result\n * the same way Postgres consumes a `\"schema\"` prefix.\n *\n * The SQLite PSL interpreter rejects every explicit `namespace { … }`\n * block with a diagnostic naming SQLite; only the implicit\n * `__unspecified__` AST bucket reaches the SQLite interpreter, which\n * lowers it to this singleton.\n */\nexport class SqliteUnboundDatabase extends SqliteDatabase {\n static readonly instance: SqliteUnboundDatabase = new SqliteUnboundDatabase();\n\n private constructor() {\n super({ id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n}\n\nexport function buildSqliteNamespace(\n input: SqlNamespaceTablesInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n if (input.id !== UNBOUND_NAMESPACE_ID) {\n throw new Error(\n `buildSqliteNamespace: SQLite has no schema concept; the only valid namespace id is \"${UNBOUND_NAMESPACE_ID}\" (received \"${input.id}\").`,\n );\n }\n const tableKind = input.entries['table'];\n const tableCount = tableKind !== undefined ? Object.keys(tableKind).length : 0;\n const hasUnknownKinds = Object.keys(input.entries).some((kind) => kind !== 'table');\n if (tableCount === 0 && !hasUnknownKinds) {\n return SqliteUnboundDatabase.instance;\n }\n return new SqliteDatabase({ id: input.id, entries: input.entries });\n}\n\n/**\n * Target-supplied `Namespace` factory the SQLite target plumbs through\n * `defineContract({ createNamespace })`. SQLite has only one\n * effective namespace slot — the framework `UNBOUND_NAMESPACE_ID`\n * sentinel — so the factory always returns the singleton or a fresh\n * `SqliteDatabase` for the unbound slot with tables. The SQL family's\n * defensive validation in `defineContract` already rejects\n * user-declared SQLite namespaces, so this throw is a structural\n * safety net rather than a user-facing surface.\n */\nexport function sqliteCreateNamespace(\n input: SqlNamespaceTablesInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n return buildSqliteNamespace(input);\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlContractSerializerBase } from '@prisma-next/family-sql/ir';\nimport { type Namespace, NamespaceBase } from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { buildSqliteNamespace } from './sqlite-unbound-database';\n\n/**\n * SQLite target `ContractSerializer` concretion. Mirrors the Postgres\n * shape: inherits the full SQL-family deserialization pipeline and\n * materialises namespace entries as SQLite database concretions that\n * expose `qualifyTable()` for runtime SQL rendering.\n */\nexport class SqliteContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n super(new Map());\n }\n\n protected override get defaultNamespaceId(): string {\n return sqliteTargetDescriptorMeta.defaultNamespaceId;\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const hydrated = blindCast<\n SqlNamespaceTablesInput,\n 'super.hydrateSqlNamespaceEntry returns the tables form when raw is not a NamespaceBase'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n return buildSqliteNamespace(hydrated);\n }\n}\n"],"mappings":";;;;;;AAmBA,MAAM,wBAAwB;;;;;;AAO9B,IAAa,iBAAb,cAAoC,cAAc;CAGhD;CACA;CAEA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAEhB,MAAM,aAAa,yBACjB,MAAM,SACN,IAAI,IAAI,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,GACpC,OACF;EAEA,KAAK,UAAU,OAAO,OACpB,UAGE,UAAU,CACd;EACA,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;CAEA,IAAI,QAAgD;EAClD,OAAO,KAAK,QAAQ,SAAS,OAAO,OAAO,CAAC,CAAC;CAC/C;CAEA,YAAoB;EAClB,OAAO;CACT;CAEA,aAAa,WAA2B;EACtC,OAAO,IAAI,UAAU;CACvB;AACF;;;;;;;;;;;;;;;;;;AAmBA,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,OAAgB,WAAkC,IAAI,sBAAsB;CAE5E,cAAsB;EACpB,MAAM;GAAE,IAAI;GAAsB,SAAS,EAAE,OAAO,CAAC,EAAE;EAAE,CAAC;CAC5D;AACF;AAEA,SAAgB,qBACd,OACwC;CACxC,IAAI,MAAM,OAAO,sBACf,MAAM,IAAI,MACR,uFAAuF,qBAAqB,eAAe,MAAM,GAAG,IACtI;CAEF,MAAM,YAAY,MAAM,QAAQ;CAChC,MAAM,aAAa,cAAc,KAAA,IAAY,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS;CAC7E,MAAM,kBAAkB,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,MAAM,SAAS,SAAS,OAAO;CAClF,IAAI,eAAe,KAAK,CAAC,iBACvB,OAAO,sBAAsB;CAE/B,OAAO,IAAI,eAAe;EAAE,IAAI,MAAM;EAAI,SAAS,MAAM;CAAQ,CAAC;AACpE;;;;;;;;;;;AAYA,SAAgB,sBACd,OACwC;CACxC,OAAO,qBAAqB,KAAK;AACnC;;;;;;;;;AChHA,IAAa,2BAAb,cAA8C,0BAAgD;CAC5F,cAAc;EACZ,sBAAM,IAAI,IAAI,CAAC;CACjB;CAEA,IAAuB,qBAA6B;EAClD,OAAO,2BAA2B;CACpC;CAEA,yBACE,MACA,KACqC;EACrC,IAAI,eAAe,eACjB,OAAO;EAMT,OAAO,qBAJU,UAGf,MAAM,yBAAyB,MAAM,GAAG,CACP,CAAC;CACtC;AACF"}
|