@prisma-next/target-sqlite 0.16.0-dev.32 → 0.16.0-dev.34

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.
Files changed (52) hide show
  1. package/README.md +4 -0
  2. package/dist/codec-descriptor-2XsVwVp_.d.mts +30 -0
  3. package/dist/codec-descriptor-2XsVwVp_.d.mts.map +1 -0
  4. package/dist/codec-descriptor-BlnLtrba.d.mts +1 -0
  5. package/dist/codec-descriptor-DuYu6llI.mjs +111 -0
  6. package/dist/codec-descriptor-DuYu6llI.mjs.map +1 -0
  7. package/dist/codec-descriptor.d.mts +3 -0
  8. package/dist/codec-descriptor.mjs +2 -0
  9. package/dist/codec-types-BjeYtMEc.d.mts +23 -0
  10. package/dist/codec-types-BjeYtMEc.d.mts.map +1 -0
  11. package/dist/codec-types.d.mts +2 -2
  12. package/dist/codec-types.mjs +0 -1
  13. package/dist/{codecs-DGgo--O0.d.mts → codecs-D7gJOOpT.d.mts} +20 -10
  14. package/dist/codecs-D7gJOOpT.d.mts.map +1 -0
  15. package/dist/codecs.d.mts +2 -2
  16. package/dist/codecs.mjs +51 -22
  17. package/dist/codecs.mjs.map +1 -1
  18. package/dist/control.mjs +4 -4
  19. package/dist/{errors-B1JPoWDh.mjs → errors-By5PHAHj.mjs} +2 -2
  20. package/dist/{errors-B1JPoWDh.mjs.map → errors-By5PHAHj.mjs.map} +1 -1
  21. package/dist/migration.mjs +2 -2
  22. package/dist/{op-factory-call-BkqsWGiy.mjs → op-factory-call-D0iJ2rLo.mjs} +4 -4
  23. package/dist/{op-factory-call-BkqsWGiy.mjs.map → op-factory-call-D0iJ2rLo.mjs.map} +1 -1
  24. package/dist/op-factory-call.mjs +1 -1
  25. package/dist/pack.d.mts +1 -1
  26. package/dist/{planner-ByBNEpyf.mjs → planner-CuM2U40p.mjs} +4 -4
  27. package/dist/{planner-ByBNEpyf.mjs.map → planner-CuM2U40p.mjs.map} +1 -1
  28. package/dist/{planner-produced-sqlite-migration-kDBbdV5A.mjs → planner-produced-sqlite-migration-BtBhUMCI.mjs} +3 -3
  29. package/dist/{planner-produced-sqlite-migration-kDBbdV5A.mjs.map → planner-produced-sqlite-migration-BtBhUMCI.mjs.map} +1 -1
  30. package/dist/planner-produced-sqlite-migration.mjs +1 -1
  31. package/dist/planner.mjs +1 -1
  32. package/dist/{render-ops-BAw6MQWl.mjs → render-ops--tc17bbl.mjs} +2 -2
  33. package/dist/{render-ops-BAw6MQWl.mjs.map → render-ops--tc17bbl.mjs.map} +1 -1
  34. package/dist/render-ops.mjs +1 -1
  35. package/dist/runtime.mjs +1 -1
  36. package/dist/{sql-utils-BMteAbKH.mjs → sql-utils-Y5kXNiUB.mjs} +2 -2
  37. package/dist/{sql-utils-BMteAbKH.mjs.map → sql-utils-Y5kXNiUB.mjs.map} +1 -1
  38. package/dist/sql-utils.mjs +1 -1
  39. package/dist/{sqlite-contract-view-BKHdFV5Y.mjs → sqlite-contract-view-C9DFAHHV.mjs} +3 -3
  40. package/dist/{sqlite-contract-view-BKHdFV5Y.mjs.map → sqlite-contract-view-C9DFAHHV.mjs.map} +1 -1
  41. package/dist/{sqlite-migration-DEqyJo40.mjs → sqlite-migration-BWnQUTne.mjs} +4 -4
  42. package/dist/{sqlite-migration-DEqyJo40.mjs.map → sqlite-migration-BWnQUTne.mjs.map} +1 -1
  43. package/package.json +19 -18
  44. package/src/core/codec-descriptor.ts +253 -0
  45. package/src/core/codecs.ts +55 -16
  46. package/src/core/registry.ts +3 -0
  47. package/src/exports/codec-descriptor.ts +11 -0
  48. package/src/exports/codec-types.ts +8 -10
  49. package/src/exports/codecs.ts +1 -1
  50. package/dist/codec-types-CcFkbJ3o.d.mts +0 -21
  51. package/dist/codec-types-CcFkbJ3o.d.mts.map +0 -1
  52. package/dist/codecs-DGgo--O0.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-contract-view-BKHdFV5Y.mjs","names":[],"sources":["../src/core/sqlite-unbound-database.ts","../src/core/sqlite-contract-serializer.ts","../src/core/sqlite-contract-view.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';\nimport { sqliteError } from './errors';\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\n/**\n * The SQLite target's rejection of expression and partial indexes: the\n * family-shared authoring surfaces parse `expression:`/`where:` for every\n * SQL target, but SQLite neither renders nor introspects them (project\n * non-goal) — a contract carrying one must fail loudly at lowering instead\n * of silently producing an unverifiable index. Target-owned so no family\n * code branches on the target.\n */\nfunction rejectSqlBodyIndexes(input: SqlNamespaceInput): void {\n const tables = input.entries['table'];\n if (tables === undefined) return;\n for (const [tableName, table] of Object.entries(tables)) {\n const indexes = blindCast<\n { readonly indexes?: readonly { name?: string; expression?: string; where?: string }[] },\n 'namespace table entries are StorageTable/StorageTableInput shapes; only the index list is read here'\n >(table).indexes;\n for (const index of indexes ?? []) {\n if (index.expression !== undefined || index.where !== undefined) {\n throw sqliteError(\n 'CONTRACT.ARGUMENT_INVALID',\n `SQLite does not support expression or partial indexes: index \"${index.name ?? '<unnamed>'}\" on table \"${tableName}\" declares ${index.expression !== undefined ? 'an expression' : 'a where predicate'}. Use a fields-only index, or author this index against a Postgres target.`,\n );\n }\n }\n }\n}\n\nexport function buildSqliteNamespace(\n input: SqlNamespaceInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n rejectSqlBodyIndexes(input);\n if (input.id !== UNBOUND_NAMESPACE_ID) {\n throw sqliteError(\n 'CONTRACT.NAMESPACE_INVALID',\n `buildSqliteNamespace: SQLite has no schema concept; the only valid namespace id is \"${UNBOUND_NAMESPACE_ID}\" (received \"${input.id}\").`,\n { meta: { 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: this.serializeNamespaceEntries(ns.entries),\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 ? { types: this.serializeJsonObject(storage.types) } : {}),\n },\n });\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport {\n buildSqlSingleNamespaceView,\n type SqlSingleNamespaceView,\n} from '@prisma-next/sql-contract/contract-view';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\n\n/**\n * A SQLite contract view: the deserialized contract intersected with by-name\n * accessors. It is substitutable for `Contract` (carries `storage`, `domain`,\n * …) and also exposes the single default namespace unwrapped with the SQL\n * built-in kinds promoted:\n *\n * ```ts\n * const view = SqliteContractView.fromJson<Contract>(contractJson);\n * view.table.users // typed table leaf\n * view.entries.policy.X // pack-contributed kind (singular key)\n * view.storage // the full contract is still present\n * ```\n *\n * SQLite has `sql.enums: false`, so it never emits `valueSet` entries; the\n * `valueSet` slot is therefore an empty map.\n */\nexport type SqliteContractView<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> =\n SqlSingleNamespaceView<TContract>;\n\nexport const SqliteContractView = {\n /** Wrap an already-deserialized SQLite contract in a view. */\n from<TContract extends Contract<SqlStorage>>(contract: TContract): SqliteContractView<TContract> {\n return buildSqlSingleNamespaceView(contract);\n },\n\n /** Deserialize a SQLite contract JSON envelope and wrap it in a view. */\n fromJson<TContract extends Contract<SqlStorage> = Contract<SqlStorage>>(\n json: unknown,\n ): SqliteContractView<TContract> {\n const contract = new SqliteContractSerializer().deserializeContract<TContract>(json);\n return buildSqlSingleNamespaceView(contract);\n },\n};\n"],"mappings":";;;;;;;;AAoBA,MAAM,wBAAwB;;;;;;AAO9B,IAAa,iBAAb,cAAoC,iBAAiB;CAGnD;CACA;CAEA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAEhB,MAAM,aAAa,yBACjB,MAAM,yBACN,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;;;;;;;;;AAUA,SAAS,qBAAqB,OAAgC;CAC5D,MAAM,SAAS,MAAM,QAAQ;CAC7B,IAAI,WAAW,KAAA,GAAW;CAC1B,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,MAAM,GAAG;EACvD,MAAM,UAAU,UAGd,KAAK,CAAC,CAAC;EACT,KAAK,MAAM,SAAS,WAAW,CAAC,GAC9B,IAAI,MAAM,eAAe,KAAA,KAAa,MAAM,UAAU,KAAA,GACpD,MAAM,YACJ,6BACA,iEAAiE,MAAM,QAAQ,YAAY,cAAc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,CAAC;GAC1F;EACF,CAAC;CACH;AACF;;;ACxBA,MAAa,qBAAqB;;CAEhC,KAA6C,UAAoD;EAC/F,OAAO,4BAA4B,QAAQ;CAC7C;;CAGA,SACE,MAC+B;EAE/B,OAAO,4BADU,IAAI,yBAAyB,CAAC,CAAC,oBAA+B,IACrC,CAAC;CAC7C;AACF"}
1
+ {"version":3,"file":"sqlite-contract-view-C9DFAHHV.mjs","names":[],"sources":["../src/core/sqlite-unbound-database.ts","../src/core/sqlite-contract-serializer.ts","../src/core/sqlite-contract-view.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';\nimport { sqliteError } from './errors';\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\n/**\n * The SQLite target's rejection of expression and partial indexes: the\n * family-shared authoring surfaces parse `expression:`/`where:` for every\n * SQL target, but SQLite neither renders nor introspects them (project\n * non-goal) — a contract carrying one must fail loudly at lowering instead\n * of silently producing an unverifiable index. Target-owned so no family\n * code branches on the target.\n */\nfunction rejectSqlBodyIndexes(input: SqlNamespaceInput): void {\n const tables = input.entries['table'];\n if (tables === undefined) return;\n for (const [tableName, table] of Object.entries(tables)) {\n const indexes = blindCast<\n { readonly indexes?: readonly { name?: string; expression?: string; where?: string }[] },\n 'namespace table entries are StorageTable/StorageTableInput shapes; only the index list is read here'\n >(table).indexes;\n for (const index of indexes ?? []) {\n if (index.expression !== undefined || index.where !== undefined) {\n throw sqliteError(\n 'CONTRACT.ARGUMENT_INVALID',\n `SQLite does not support expression or partial indexes: index \"${index.name ?? '<unnamed>'}\" on table \"${tableName}\" declares ${index.expression !== undefined ? 'an expression' : 'a where predicate'}. Use a fields-only index, or author this index against a Postgres target.`,\n );\n }\n }\n }\n}\n\nexport function buildSqliteNamespace(\n input: SqlNamespaceInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n rejectSqlBodyIndexes(input);\n if (input.id !== UNBOUND_NAMESPACE_ID) {\n throw sqliteError(\n 'CONTRACT.NAMESPACE_INVALID',\n `buildSqliteNamespace: SQLite has no schema concept; the only valid namespace id is \"${UNBOUND_NAMESPACE_ID}\" (received \"${input.id}\").`,\n { meta: { 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: this.serializeNamespaceEntries(ns.entries),\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 ? { types: this.serializeJsonObject(storage.types) } : {}),\n },\n });\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport {\n buildSqlSingleNamespaceView,\n type SqlSingleNamespaceView,\n} from '@prisma-next/sql-contract/contract-view';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\n\n/**\n * A SQLite contract view: the deserialized contract intersected with by-name\n * accessors. It is substitutable for `Contract` (carries `storage`, `domain`,\n * …) and also exposes the single default namespace unwrapped with the SQL\n * built-in kinds promoted:\n *\n * ```ts\n * const view = SqliteContractView.fromJson<Contract>(contractJson);\n * view.table.users // typed table leaf\n * view.entries.policy.X // pack-contributed kind (singular key)\n * view.storage // the full contract is still present\n * ```\n *\n * SQLite has `sql.enums: false`, so it never emits `valueSet` entries; the\n * `valueSet` slot is therefore an empty map.\n */\nexport type SqliteContractView<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> =\n SqlSingleNamespaceView<TContract>;\n\nexport const SqliteContractView = {\n /** Wrap an already-deserialized SQLite contract in a view. */\n from<TContract extends Contract<SqlStorage>>(contract: TContract): SqliteContractView<TContract> {\n return buildSqlSingleNamespaceView(contract);\n },\n\n /** Deserialize a SQLite contract JSON envelope and wrap it in a view. */\n fromJson<TContract extends Contract<SqlStorage> = Contract<SqlStorage>>(\n json: unknown,\n ): SqliteContractView<TContract> {\n const contract = new SqliteContractSerializer().deserializeContract<TContract>(json);\n return buildSqlSingleNamespaceView(contract);\n },\n};\n"],"mappings":";;;;;;;;AAoBA,MAAM,wBAAwB;;;;;;AAO9B,IAAa,iBAAb,cAAoC,iBAAiB;CAGnD;CACA;CAEA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAEhB,MAAM,aAAa,yBACjB,MAAM,yBACN,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;;;;;;;;;AAUA,SAAS,qBAAqB,OAAgC;CAC5D,MAAM,SAAS,MA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AAC,MAAM,OAAO,OAAO,QAAQ,QAAQ,UAAU,GACxD,eAAe,QAAQ;GACrB,IAAI,GAAG;GACP,SAAS,KAAK,0BAA0B,GAAG,OAAO;EACpD;EAEF,OAAO,UAGL;GACA,GAAG;GACH,SAAS;IACP,aAAa,OAAO,QAAQ,WAAW;IACvC,YAAY;IACZ,GAAI,QAAQ,UAAU,KAAA,IAAY,EAAE,OAAO,KAAK,oBAAoB,QAAQ,KAAK,EAAE,IAAI,CAAC;GAC1F;EACF,CAAC;CACH;AACF;;;ACxBA,MAAa,qBAAqB;;CAEhC,KAA6C,UAAoD;EAC/F,OAAO,4BAA4B,QAAQ;CAC7C;;CAGA,SACE,MAC+B;EAE/B,OAAO,4BADU,IAAI,yBAAyB,CAAC,CAAC,oBAA+B,IACrC,CAAC;CAC7C;AACF"}
@@ -1,6 +1,6 @@
1
- import { t as errorSqliteMigrationStackMissing } from "./errors-B1JPoWDh.mjs";
2
- import { a as DropColumnCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-BkqsWGiy.mjs";
3
- import { t as SqliteContractView } from "./sqlite-contract-view-BKHdFV5Y.mjs";
1
+ import { t as errorSqliteMigrationStackMissing } from "./errors-By5PHAHj.mjs";
2
+ import { a as DropColumnCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-D0iJ2rLo.mjs";
3
+ import { t as SqliteContractView } from "./sqlite-contract-view-C9DFAHHV.mjs";
4
4
  import { blindCast } from "@prisma-next/utils/casts";
5
5
  import { Migration } from "@prisma-next/family-sql/migration";
6
6
  import { MigrationContractViews } from "@prisma-next/migration-tools/migration";
@@ -91,4 +91,4 @@ var SqliteMigration = class extends Migration {
91
91
  //#endregion
92
92
  export { SqliteMigration as t };
93
93
 
94
- //# sourceMappingURL=sqlite-migration-DEqyJo40.mjs.map
94
+ //# sourceMappingURL=sqlite-migration-BWnQUTne.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-migration-DEqyJo40.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { errorSqliteMigrationStackMissing } from '../errors';\nimport { SqliteContractView } from '../sqlite-contract-view';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n RecreateTableCall,\n} from './op-factory-call';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n *\n * The constructor materializes a single SQLite `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected instance methods\n * forward to the corresponding `*Call` with that stored adapter, so user\n * migrations can write `this.createTable({...})` without threading the adapter\n * through every call.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its snapshot-store `contract.json` imports to\n * `startContractJson` / `endContractJson` gets fully-typed view accessors:\n * `this.endContract` is a `SqliteContractView<End>`\n * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),\n * built lazily from the JSON fields via the shared `MigrationContractViews`\n * helper. Mirrors `MongoMigration`'s view getters; the framework base derives\n * `describe()` from the same JSON.\n */\nexport abstract class SqliteMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<SqlitePlanTargetDetails, 'sqlite', Start, End> {\n readonly targetId = 'sqlite' as const;\n\n /**\n * Materialized SQLite control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;\n\n #endView = new MigrationContractViews<SqliteContractView<End>>(this, 'SqliteMigration', (json) =>\n SqliteContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<SqliteContractView<Start>>(\n this,\n 'SqliteMigration',\n (json) => SqliteContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'sqlite'>) {\n super(stack);\n this.controlAdapter = stack?.adapter\n ? blindCast<\n SqlControlAdapter<'sqlite'>,\n 'The SQLite descriptor create() returns SqlControlAdapter<sqlite>; typed as wider ControlAdapterInstance at the framework boundary'\n >(stack.adapter.create(stack))\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'sqlite'> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed SQLite view over this migration's end-state contract — sole\n * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.\n * Throws if no `endContractJson` was provided.\n */\n get endContract(): SqliteContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed SQLite view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): SqliteContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n protected createTable(options: {\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<Op> {\n return new CreateTableCall(options.table, options.columns, options.constraints).toOp(\n this.controlAdapterFor('createTable'),\n );\n }\n\n protected dropTable(options: { readonly table: string }): Promise<Op> {\n return new DropTableCall(options.table).toOp(this.controlAdapterFor('dropTable'));\n }\n\n protected addColumn(options: {\n readonly table: string;\n readonly column: SqliteColumnSpec;\n }): Promise<Op> {\n return new AddColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {\n return new DropColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected createIndex(options: {\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n }): Promise<Op> {\n return new CreateIndexCall(options.table, options.index, options.columns).toOp(\n this.controlAdapterFor('createIndex'),\n );\n }\n\n protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {\n return new DropIndexCall(options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected recreateTable(options: {\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n }): Promise<Op> {\n return new RecreateTableCall(options).toOp(this.controlAdapterFor('recreateTable'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAsB,kBAAtB,cAGUA,UAA4D;CACpE,WAAoB;;;;;;;CAQpB;CAEA,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ACd,OAAO,IAAI,kBAAkB,OAAO,CAAC,CAAC,KAAK,KAAK,kBAAkB,eAAe,CAAC;CACpF;AACF"}
1
+ {"version":3,"file":"sqlite-migration-BWnQUTne.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { errorSqliteMigrationStackMissing } from '../errors';\nimport { SqliteContractView } from '../sqlite-contract-view';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n RecreateTableCall,\n} from './op-factory-call';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n *\n * The constructor materializes a single SQLite `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected instance methods\n * forward to the corresponding `*Call` with that stored adapter, so user\n * migrations can write `this.createTable({...})` without threading the adapter\n * through every call.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its snapshot-store `contract.json` imports to\n * `startContractJson` / `endContractJson` gets fully-typed view accessors:\n * `this.endContract` is a `SqliteContractView<End>`\n * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),\n * built lazily from the JSON fields via the shared `MigrationContractViews`\n * helper. Mirrors `MongoMigration`'s view getters; the framework base derives\n * `describe()` from the same JSON.\n */\nexport abstract class SqliteMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<SqlitePlanTargetDetails, 'sqlite', Start, End> {\n readonly targetId = 'sqlite' as const;\n\n /**\n * Materialized SQLite control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;\n\n #endView = new MigrationContractViews<SqliteContractView<End>>(this, 'SqliteMigration', (json) =>\n SqliteContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<SqliteContractView<Start>>(\n this,\n 'SqliteMigration',\n (json) => SqliteContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'sqlite'>) {\n super(stack);\n this.controlAdapter = stack?.adapter\n ? blindCast<\n SqlControlAdapter<'sqlite'>,\n 'The SQLite descriptor create() returns SqlControlAdapter<sqlite>; typed as wider ControlAdapterInstance at the framework boundary'\n >(stack.adapter.create(stack))\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'sqlite'> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed SQLite view over this migration's end-state contract — sole\n * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.\n * Throws if no `endContractJson` was provided.\n */\n get endContract(): SqliteContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed SQLite view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): SqliteContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n protected createTable(options: {\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<Op> {\n return new CreateTableCall(options.table, options.columns, options.constraints).toOp(\n this.controlAdapterFor('createTable'),\n );\n }\n\n protected dropTable(options: { readonly table: string }): Promise<Op> {\n return new DropTableCall(options.table).toOp(this.controlAdapterFor('dropTable'));\n }\n\n protected addColumn(options: {\n readonly table: string;\n readonly column: SqliteColumnSpec;\n }): Promise<Op> {\n return new AddColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {\n return new DropColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected createIndex(options: {\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n }): Promise<Op> {\n return new CreateIndexCall(options.table, options.index, options.columns).toOp(\n this.controlAdapterFor('createIndex'),\n );\n }\n\n protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {\n return new DropIndexCall(options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected recreateTable(options: {\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n }): Promise<Op> {\n return new RecreateTableCall(options).toOp(this.controlAdapterFor('recreateTable'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAsB,kBAAtB,cA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kBAAkB,WAAW,CACpC;CACF;CAEA,cAAwB,SAQR;EACd,OAAO,IAAI,kBAAkB,OAAO,CAAC,CAAC,KAAK,KAAK,kBAAkB,eAAe,CAAC;CACpF;AACF"}
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "@prisma-next/target-sqlite",
3
- "version": "0.16.0-dev.32",
3
+ "version": "0.16.0-dev.34",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@prisma-next/cli": "0.16.0-dev.32",
9
- "@prisma-next/contract": "0.16.0-dev.32",
10
- "@prisma-next/errors": "0.16.0-dev.32",
11
- "@prisma-next/family-sql": "0.16.0-dev.32",
12
- "@prisma-next/framework-components": "0.16.0-dev.32",
13
- "@prisma-next/migration-tools": "0.16.0-dev.32",
14
- "@prisma-next/sql-contract": "0.16.0-dev.32",
15
- "@prisma-next/sql-errors": "0.16.0-dev.32",
16
- "@prisma-next/sql-relational-core": "0.16.0-dev.32",
17
- "@prisma-next/sql-runtime": "0.16.0-dev.32",
18
- "@prisma-next/sql-schema-ir": "0.16.0-dev.32",
19
- "@prisma-next/ts-render": "0.16.0-dev.32",
20
- "@prisma-next/utils": "0.16.0-dev.32",
8
+ "@prisma-next/cli": "0.16.0-dev.34",
9
+ "@prisma-next/contract": "0.16.0-dev.34",
10
+ "@prisma-next/errors": "0.16.0-dev.34",
11
+ "@prisma-next/family-sql": "0.16.0-dev.34",
12
+ "@prisma-next/framework-components": "0.16.0-dev.34",
13
+ "@prisma-next/migration-tools": "0.16.0-dev.34",
14
+ "@prisma-next/sql-contract": "0.16.0-dev.34",
15
+ "@prisma-next/sql-errors": "0.16.0-dev.34",
16
+ "@prisma-next/sql-relational-core": "0.16.0-dev.34",
17
+ "@prisma-next/sql-runtime": "0.16.0-dev.34",
18
+ "@prisma-next/sql-schema-ir": "0.16.0-dev.34",
19
+ "@prisma-next/ts-render": "0.16.0-dev.34",
20
+ "@prisma-next/utils": "0.16.0-dev.34",
21
21
  "@standard-schema/spec": "1.1.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@prisma-next/driver-sqlite": "0.16.0-dev.32",
25
- "@prisma-next/test-utils": "0.16.0-dev.32",
26
- "@prisma-next/tsconfig": "0.16.0-dev.32",
27
- "@prisma-next/tsdown": "0.16.0-dev.32",
24
+ "@prisma-next/driver-sqlite": "0.16.0-dev.34",
25
+ "@prisma-next/test-utils": "0.16.0-dev.34",
26
+ "@prisma-next/tsconfig": "0.16.0-dev.34",
27
+ "@prisma-next/tsdown": "0.16.0-dev.34",
28
28
  "tsdown": "0.22.8",
29
29
  "typescript": "5.9.3",
30
30
  "vitest": "4.1.10"
@@ -42,6 +42,7 @@
42
42
  "src"
43
43
  ],
44
44
  "exports": {
45
+ "./codec-descriptor": "./dist/codec-descriptor.mjs",
45
46
  "./codec-ids": "./dist/codec-ids.mjs",
46
47
  "./codec-types": "./dist/codec-types.mjs",
47
48
  "./codecs": "./dist/codecs.mjs",
@@ -0,0 +1,253 @@
1
+ import type { JsonValue } from '@prisma-next/contract/types';
2
+ import {
3
+ type AnyCodecDescriptor,
4
+ type Codec,
5
+ type CodecDescriptor,
6
+ CodecDescriptorImpl,
7
+ type CodecInstanceContext,
8
+ type CodecMeta,
9
+ type CodecRef,
10
+ type CodecTrait,
11
+ validateCodecTypeParams,
12
+ } from '@prisma-next/framework-components/codec';
13
+ import type { ProjectionExpr } from '@prisma-next/sql-relational-core/ast';
14
+ import { blindCast } from '@prisma-next/utils/casts';
15
+ import { structuredError } from '@prisma-next/utils/structured-error';
16
+
17
+ const SQLITE_CODEC_DESCRIPTOR_KIND = 'sqlite-codec' as const;
18
+
19
+ export interface AnySqliteCodecDescriptor extends AnyCodecDescriptor {
20
+ readonly descriptorKind: typeof SQLITE_CODEC_DESCRIPTOR_KIND;
21
+ projectJson(expression: ProjectionExpr, ref: CodecRef): ProjectionExpr;
22
+ }
23
+
24
+ export abstract class SqliteCodecDescriptor<P = void>
25
+ extends CodecDescriptorImpl<P>
26
+ implements AnySqliteCodecDescriptor
27
+ {
28
+ readonly descriptorKind = SQLITE_CODEC_DESCRIPTOR_KIND;
29
+
30
+ protected abstract jsonProjection(expression: ProjectionExpr, params: P): ProjectionExpr;
31
+
32
+ projectJson(expression: ProjectionExpr, ref: CodecRef): ProjectionExpr {
33
+ if (ref.many === true) {
34
+ throw structuredError(
35
+ 'SQLITE.CODEC_DESCRIPTOR_ARRAY_UNSUPPORTED',
36
+ `Codec '${ref.codecId}' uses CodecRef.many, but SQLite codec descriptors do not support stored scalar arrays.`,
37
+ {
38
+ why: 'SQLite has no stored scalar-array codec protocol, so applying a scalar projection to the whole stored array would be ambiguous.',
39
+ fix: 'Use a scalar CodecRef or introduce an explicit target representation before projecting stored arrays.',
40
+ meta: { codecId: ref.codecId },
41
+ },
42
+ );
43
+ }
44
+
45
+ return this.jsonProjection(expression, this.validateParams(ref));
46
+ }
47
+
48
+ private validateParams(ref: CodecRef): P {
49
+ return blindCast<
50
+ P,
51
+ 'validateCodecTypeParams synchronously validates this descriptor schema before the typed hook'
52
+ >(validateCodecTypeParams(this, ref));
53
+ }
54
+ }
55
+
56
+ type DescriptorParams<D extends AnyCodecDescriptor> =
57
+ D extends CodecDescriptor<infer P> ? P : never;
58
+
59
+ export interface SqliteCodecOptions<P> {
60
+ readonly jsonProjection: (expression: ProjectionExpr, params: P) => ProjectionExpr;
61
+ }
62
+
63
+ export type AdaptedSqliteCodecDescriptor<D extends AnyCodecDescriptor> = Pick<
64
+ D,
65
+ keyof CodecDescriptor<DescriptorParams<D>>
66
+ > &
67
+ Pick<AnySqliteCodecDescriptor, 'descriptorKind' | 'projectJson'>;
68
+
69
+ class SqliteCodecDescriptorAdapter<D extends AnyCodecDescriptor> extends SqliteCodecDescriptor<
70
+ DescriptorParams<D>
71
+ > {
72
+ override readonly codecId: string;
73
+ override readonly traits: readonly CodecTrait[];
74
+ override readonly targetTypes: readonly string[];
75
+ override readonly paramsSchema: D['paramsSchema'];
76
+ override readonly metaFor?: (params: DescriptorParams<D>) => CodecMeta | undefined;
77
+ override readonly renderOutputType?: (params: DescriptorParams<D>) => string | undefined;
78
+ override readonly renderInputType?: (params: DescriptorParams<D>) => string | undefined;
79
+ override readonly renderValueLiteral?: (
80
+ value: JsonValue,
81
+ side: 'output' | 'input',
82
+ ) => string | undefined;
83
+
84
+ constructor(
85
+ private readonly descriptor: D,
86
+ private readonly options: SqliteCodecOptions<DescriptorParams<D>>,
87
+ ) {
88
+ super();
89
+ this.codecId = descriptor.codecId;
90
+ this.traits = descriptor.traits;
91
+ this.targetTypes = descriptor.targetTypes;
92
+ this.paramsSchema = descriptor.paramsSchema;
93
+
94
+ if (descriptor.meta !== undefined) {
95
+ Object.defineProperty(this, 'meta', {
96
+ value: descriptor.meta,
97
+ enumerable: true,
98
+ });
99
+ }
100
+
101
+ const metaFor = descriptor.metaFor;
102
+ if (metaFor !== undefined) {
103
+ this.metaFor = (params) => metaFor.call(descriptor, params);
104
+ }
105
+
106
+ const renderOutputType = descriptor.renderOutputType;
107
+ if (renderOutputType !== undefined) {
108
+ this.renderOutputType = (params) => renderOutputType.call(descriptor, params);
109
+ }
110
+
111
+ const renderInputType = descriptor.renderInputType;
112
+ if (renderInputType !== undefined) {
113
+ this.renderInputType = (params) => renderInputType.call(descriptor, params);
114
+ }
115
+
116
+ const renderValueLiteral = descriptor.renderValueLiteral;
117
+ if (renderValueLiteral !== undefined) {
118
+ this.renderValueLiteral = (value, side) => renderValueLiteral.call(descriptor, value, side);
119
+ }
120
+ }
121
+
122
+ override get isParameterized(): boolean {
123
+ return this.descriptor.isParameterized;
124
+ }
125
+
126
+ override readonly factory = (
127
+ params: DescriptorParams<D>,
128
+ ): ((ctx: CodecInstanceContext) => Codec<string, readonly CodecTrait[], unknown, unknown>) =>
129
+ this.descriptor.factory(params);
130
+
131
+ protected override jsonProjection(
132
+ expression: ProjectionExpr,
133
+ params: DescriptorParams<D>,
134
+ ): ProjectionExpr {
135
+ return this.options.jsonProjection(expression, params);
136
+ }
137
+ }
138
+
139
+ export function sqliteCodec<D extends AnyCodecDescriptor>(
140
+ descriptor: D,
141
+ options: SqliteCodecOptions<DescriptorParams<D>>,
142
+ ): AdaptedSqliteCodecDescriptor<D> {
143
+ return blindCast<
144
+ AdaptedSqliteCodecDescriptor<D>,
145
+ 'the adapter delegates every ordinary descriptor member while adding the validated SQLite protocol'
146
+ >(new SqliteCodecDescriptorAdapter(descriptor, options));
147
+ }
148
+
149
+ export function defineSqliteCodecs<const Descriptors extends readonly AnySqliteCodecDescriptor[]>(
150
+ descriptors: Descriptors,
151
+ ): Descriptors {
152
+ return descriptors;
153
+ }
154
+
155
+ export function isSqliteCodecDescriptor(value: unknown): value is AnySqliteCodecDescriptor {
156
+ return (
157
+ typeof value === 'object' &&
158
+ value !== null &&
159
+ 'descriptorKind' in value &&
160
+ value.descriptorKind === SQLITE_CODEC_DESCRIPTOR_KIND &&
161
+ 'codecId' in value &&
162
+ typeof value.codecId === 'string' &&
163
+ 'traits' in value &&
164
+ Array.isArray(value.traits) &&
165
+ 'targetTypes' in value &&
166
+ Array.isArray(value.targetTypes) &&
167
+ value.targetTypes.every((targetType) => typeof targetType === 'string') &&
168
+ 'paramsSchema' in value &&
169
+ isObjectLike(value.paramsSchema) &&
170
+ '~standard' in value.paramsSchema &&
171
+ isObjectLike(value.paramsSchema['~standard']) &&
172
+ 'validate' in value.paramsSchema['~standard'] &&
173
+ typeof value.paramsSchema['~standard'].validate === 'function' &&
174
+ 'isParameterized' in value &&
175
+ typeof value.isParameterized === 'boolean' &&
176
+ 'factory' in value &&
177
+ typeof value.factory === 'function' &&
178
+ 'projectJson' in value &&
179
+ typeof value.projectJson === 'function'
180
+ );
181
+ }
182
+
183
+ function isObjectLike(value: unknown): value is object {
184
+ return (typeof value === 'object' && value !== null) || typeof value === 'function';
185
+ }
186
+
187
+ export interface SqliteCodecDescriptorRegistry {
188
+ descriptorFor(codecId: string): AnySqliteCodecDescriptor | undefined;
189
+ values(): IterableIterator<AnySqliteCodecDescriptor>;
190
+ }
191
+
192
+ class SqliteCodecDescriptorRegistryImpl implements SqliteCodecDescriptorRegistry {
193
+ readonly #descriptors: ReadonlyMap<string, AnySqliteCodecDescriptor>;
194
+
195
+ constructor(descriptors: ReadonlyMap<string, AnySqliteCodecDescriptor>) {
196
+ this.#descriptors = descriptors;
197
+ Object.freeze(this);
198
+ }
199
+
200
+ descriptorFor(codecId: string): AnySqliteCodecDescriptor | undefined {
201
+ return this.#descriptors.get(codecId);
202
+ }
203
+
204
+ *values(): IterableIterator<AnySqliteCodecDescriptor> {
205
+ yield* this.#descriptors.values();
206
+ }
207
+ }
208
+
209
+ export function buildSqliteCodecDescriptorRegistry(
210
+ descriptors: ReadonlyArray<unknown>,
211
+ ): SqliteCodecDescriptorRegistry {
212
+ const byId = new Map<string, AnySqliteCodecDescriptor>();
213
+
214
+ for (const descriptor of descriptors) {
215
+ if (!isSqliteCodecDescriptor(descriptor)) {
216
+ const codecId = candidateCodecId(descriptor);
217
+ throw structuredError(
218
+ 'SQLITE.CODEC_DESCRIPTOR_INVALID',
219
+ `Codec descriptor '${codecId}' is not a valid SQLite codec descriptor.`,
220
+ {
221
+ why: 'SQLite codec registries require the sqlite-codec discriminant and complete target descriptor methods.',
222
+ fix: 'Extend SqliteCodecDescriptor or adapt a generic descriptor with sqliteCodec().',
223
+ meta: { codecId },
224
+ },
225
+ );
226
+ }
227
+
228
+ if (byId.has(descriptor.codecId)) {
229
+ throw structuredError(
230
+ 'SQLITE.CODEC_DESCRIPTOR_DUPLICATE',
231
+ `Duplicate SQLite codec descriptor id '${descriptor.codecId}'.`,
232
+ {
233
+ why: 'Each codecId must resolve to exactly one SQLite descriptor during registry composition.',
234
+ fix: 'Remove the duplicate target, adapter, or extension contribution.',
235
+ meta: { codecId: descriptor.codecId },
236
+ },
237
+ );
238
+ }
239
+
240
+ byId.set(descriptor.codecId, descriptor);
241
+ }
242
+
243
+ return new SqliteCodecDescriptorRegistryImpl(byId);
244
+ }
245
+
246
+ function candidateCodecId(value: unknown): string {
247
+ return typeof value === 'object' &&
248
+ value !== null &&
249
+ 'codecId' in value &&
250
+ typeof value.codecId === 'string'
251
+ ? value.codecId
252
+ : '<unknown>';
253
+ }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Each codec ships as three artifacts:
5
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
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 SqliteCodecDescriptor} declaring the codec id, traits, target types, params schema, and current scalar JSON projection. SQLite codecs do not carry
7
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
8
  *
9
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.
@@ -13,9 +13,7 @@
13
13
 
14
14
  import type { JsonValue } from '@prisma-next/contract/types';
15
15
  import {
16
- type AnyCodecDescriptor,
17
16
  type CodecCallContext,
18
- CodecDescriptorImpl,
19
17
  CodecImpl,
20
18
  type CodecInstanceContext,
21
19
  type ColumnHelperFor,
@@ -24,11 +22,13 @@ import {
24
22
  voidParamsSchema,
25
23
  } from '@prisma-next/framework-components/codec';
26
24
  import {
25
+ type ProjectionExpr,
27
26
  sqlCharDescriptor,
28
27
  sqlFloatDescriptor,
29
28
  sqlIntDescriptor,
30
29
  sqlVarcharDescriptor,
31
30
  } from '@prisma-next/sql-relational-core/ast';
31
+ import { defineSqliteCodecs, SqliteCodecDescriptor, sqliteCodec } from './codec-descriptor';
32
32
  import {
33
33
  SQLITE_BIGINT_CODEC_ID,
34
34
  SQLITE_BLOB_CODEC_ID,
@@ -40,6 +40,24 @@ import {
40
40
  } from './codec-ids';
41
41
  import { sqliteError } from './errors';
42
42
 
43
+ const identityJsonProjection = (expression: ProjectionExpr): ProjectionExpr => expression;
44
+
45
+ export const sqliteSqlCharDescriptor = sqliteCodec(sqlCharDescriptor, {
46
+ jsonProjection: identityJsonProjection,
47
+ });
48
+
49
+ export const sqliteSqlVarcharDescriptor = sqliteCodec(sqlVarcharDescriptor, {
50
+ jsonProjection: identityJsonProjection,
51
+ });
52
+
53
+ export const sqliteSqlIntDescriptor = sqliteCodec(sqlIntDescriptor, {
54
+ jsonProjection: identityJsonProjection,
55
+ });
56
+
57
+ export const sqliteSqlFloatDescriptor = sqliteCodec(sqlFloatDescriptor, {
58
+ jsonProjection: identityJsonProjection,
59
+ });
60
+
43
61
  export class SqliteTextCodec extends CodecImpl<
44
62
  typeof SQLITE_TEXT_CODEC_ID,
45
63
  readonly ['equality', 'order', 'textual'],
@@ -60,7 +78,10 @@ export class SqliteTextCodec extends CodecImpl<
60
78
  }
61
79
  }
62
80
 
63
- export class SqliteTextDescriptor extends CodecDescriptorImpl<void> {
81
+ export class SqliteTextDescriptor extends SqliteCodecDescriptor<void> {
82
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
83
+ return expression;
84
+ }
64
85
  override readonly codecId = SQLITE_TEXT_CODEC_ID;
65
86
  override readonly traits = ['equality', 'order', 'textual'] as const;
66
87
  override readonly targetTypes = ['text'] as const;
@@ -98,7 +119,10 @@ export class SqliteIntegerCodec extends CodecImpl<
98
119
  }
99
120
  }
100
121
 
101
- export class SqliteIntegerDescriptor extends CodecDescriptorImpl<void> {
122
+ export class SqliteIntegerDescriptor extends SqliteCodecDescriptor<void> {
123
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
124
+ return expression;
125
+ }
102
126
  override readonly codecId = SQLITE_INTEGER_CODEC_ID;
103
127
  override readonly traits = ['equality', 'order', 'numeric'] as const;
104
128
  override readonly targetTypes = ['integer'] as const;
@@ -136,7 +160,10 @@ export class SqliteRealCodec extends CodecImpl<
136
160
  }
137
161
  }
138
162
 
139
- export class SqliteRealDescriptor extends CodecDescriptorImpl<void> {
163
+ export class SqliteRealDescriptor extends SqliteCodecDescriptor<void> {
164
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
165
+ return expression;
166
+ }
140
167
  override readonly codecId = SQLITE_REAL_CODEC_ID;
141
168
  override readonly traits = ['equality', 'order', 'numeric'] as const;
142
169
  override readonly targetTypes = ['real'] as const;
@@ -183,7 +210,10 @@ export class SqliteBlobCodec extends CodecImpl<
183
210
  }
184
211
  }
185
212
 
186
- export class SqliteBlobDescriptor extends CodecDescriptorImpl<void> {
213
+ export class SqliteBlobDescriptor extends SqliteCodecDescriptor<void> {
214
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
215
+ return expression;
216
+ }
187
217
  override readonly codecId = SQLITE_BLOB_CODEC_ID;
188
218
  override readonly traits = ['equality'] as const;
189
219
  override readonly targetTypes = ['blob'] as const;
@@ -240,7 +270,10 @@ export class SqliteDatetimeCodec extends CodecImpl<
240
270
  }
241
271
  }
242
272
 
243
- export class SqliteDatetimeDescriptor extends CodecDescriptorImpl<void> {
273
+ export class SqliteDatetimeDescriptor extends SqliteCodecDescriptor<void> {
274
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
275
+ return expression;
276
+ }
244
277
  override readonly codecId = SQLITE_DATETIME_CODEC_ID;
245
278
  override readonly traits = ['equality', 'order'] as const;
246
279
  override readonly targetTypes = ['text'] as const;
@@ -278,7 +311,10 @@ export class SqliteJsonCodec extends CodecImpl<
278
311
  }
279
312
  }
280
313
 
281
- export class SqliteJsonDescriptor extends CodecDescriptorImpl<void> {
314
+ export class SqliteJsonDescriptor extends SqliteCodecDescriptor<void> {
315
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
316
+ return expression;
317
+ }
282
318
  override readonly codecId = SQLITE_JSON_CODEC_ID;
283
319
  override readonly traits = ['equality'] as const;
284
320
  override readonly targetTypes = ['text'] as const;
@@ -338,7 +374,10 @@ export class SqliteBigintCodec extends CodecImpl<
338
374
  }
339
375
  }
340
376
 
341
- export class SqliteBigintDescriptor extends CodecDescriptorImpl<void> {
377
+ export class SqliteBigintDescriptor extends SqliteCodecDescriptor<void> {
378
+ protected override jsonProjection(expression: ProjectionExpr): ProjectionExpr {
379
+ return expression;
380
+ }
342
381
  override readonly codecId = SQLITE_BIGINT_CODEC_ID;
343
382
  override readonly traits = ['equality', 'order', 'numeric'] as const;
344
383
  override readonly targetTypes = ['integer'] as const;
@@ -356,11 +395,11 @@ export const sqliteBigintColumn = () =>
356
395
  sqliteBigintColumn satisfies ColumnHelperFor<SqliteBigintDescriptor>;
357
396
  sqliteBigintColumn satisfies ColumnHelperForStrict<SqliteBigintDescriptor>;
358
397
 
359
- export const codecDescriptors: readonly AnyCodecDescriptor[] = [
360
- sqlCharDescriptor,
361
- sqlVarcharDescriptor,
362
- sqlIntDescriptor,
363
- sqlFloatDescriptor,
398
+ export const codecDescriptors = defineSqliteCodecs([
399
+ sqliteSqlCharDescriptor,
400
+ sqliteSqlVarcharDescriptor,
401
+ sqliteSqlIntDescriptor,
402
+ sqliteSqlFloatDescriptor,
364
403
  sqliteTextDescriptor,
365
404
  sqliteIntegerDescriptor,
366
405
  sqliteRealDescriptor,
@@ -368,4 +407,4 @@ export const codecDescriptors: readonly AnyCodecDescriptor[] = [
368
407
  sqliteDatetimeDescriptor,
369
408
  sqliteJsonDescriptor,
370
409
  sqliteBigintDescriptor,
371
- ];
410
+ ]);
@@ -1,5 +1,6 @@
1
1
  import { buildCodecDescriptorRegistry } from '@prisma-next/sql-relational-core/codec-descriptor-registry';
2
2
  import type { CodecDescriptorRegistry } from '@prisma-next/sql-relational-core/query-lane-context';
3
+ import { buildSqliteCodecDescriptorRegistry } from './codec-descriptor';
3
4
  import { codecDescriptors } from './codecs';
4
5
 
5
6
  /**
@@ -9,3 +10,5 @@ import { codecDescriptors } from './codecs';
9
10
  */
10
11
  export const sqliteCodecRegistry: CodecDescriptorRegistry =
11
12
  buildCodecDescriptorRegistry(codecDescriptors);
13
+
14
+ export const sqliteCodecDescriptorRegistry = buildSqliteCodecDescriptorRegistry(codecDescriptors);
@@ -0,0 +1,11 @@
1
+ export {
2
+ type AdaptedSqliteCodecDescriptor,
3
+ type AnySqliteCodecDescriptor,
4
+ buildSqliteCodecDescriptorRegistry,
5
+ defineSqliteCodecs,
6
+ isSqliteCodecDescriptor,
7
+ SqliteCodecDescriptor,
8
+ type SqliteCodecDescriptorRegistry,
9
+ type SqliteCodecOptions,
10
+ sqliteCodec,
11
+ } from '../core/codec-descriptor';
@@ -5,12 +5,6 @@
5
5
  */
6
6
 
7
7
  import type { ExtractCodecTypes } from '@prisma-next/sql-relational-core/ast';
8
- import {
9
- sqlCharDescriptor,
10
- sqlFloatDescriptor,
11
- sqlIntDescriptor,
12
- sqlVarcharDescriptor,
13
- } from '@prisma-next/sql-relational-core/ast';
14
8
  import type { JsonValue } from '../core/codec-helpers';
15
9
  import {
16
10
  sqliteBigintDescriptor,
@@ -19,14 +13,18 @@ import {
19
13
  sqliteIntegerDescriptor,
20
14
  sqliteJsonDescriptor,
21
15
  sqliteRealDescriptor,
16
+ sqliteSqlCharDescriptor,
17
+ sqliteSqlFloatDescriptor,
18
+ sqliteSqlIntDescriptor,
19
+ sqliteSqlVarcharDescriptor,
22
20
  sqliteTextDescriptor,
23
21
  } from '../core/codecs';
24
22
 
25
23
  const codecDescriptorMap = {
26
- char: sqlCharDescriptor,
27
- varchar: sqlVarcharDescriptor,
28
- int: sqlIntDescriptor,
29
- float: sqlFloatDescriptor,
24
+ char: sqliteSqlCharDescriptor,
25
+ varchar: sqliteSqlVarcharDescriptor,
26
+ int: sqliteSqlIntDescriptor,
27
+ float: sqliteSqlFloatDescriptor,
30
28
  text: sqliteTextDescriptor,
31
29
  integer: sqliteIntegerDescriptor,
32
30
  real: sqliteRealDescriptor,