@prisma/orm-sqlite 8.0.0-rc.18-dev.34 → 8.0.0-rc.18-dev.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { a as SqliteTargetId, n as SqliteOptions, o as sqlite, r as SqliteOptionsBase, t as SqliteClient } from "./sqlite-0-P_ooKZ-CD-hUbzF.mjs";
1
+ import { a as SqliteQueryMembers, c as SqliteTransactionContext, i as SqliteOrm, l as sqlite, n as SqliteOptions, r as SqliteOptionsBase, s as SqliteTargetId, t as SqliteClient } from "./sqlite-nkzz9Mmw-Bp47g4Ms.mjs";
2
2
  import { Runtime, SqlRuntimeBase } from "@prisma/orm-family-sql/runtime";
3
3
  import "@prisma/orm-target-sqlite/driver/runtime";
4
4
  import { Contract } from "@prisma/orm-framework/contract/types";
@@ -20,5 +20,5 @@ type SqliteBindingInput = {
20
20
  interface SqliteRuntime extends Runtime {}
21
21
  declare class SqliteRuntimeImpl<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> extends SqlRuntimeBase<TContract> {}
22
22
  //#endregion
23
- export { type SqliteBindingInput, type SqliteClient, type SqliteOptions, type SqliteOptionsBase, type SqliteRuntime, SqliteRuntimeImpl, type SqliteTargetId, sqlite as default };
23
+ export { type SqliteBindingInput, type SqliteClient, type SqliteOptions, type SqliteOptionsBase, type SqliteOrm, type SqliteQueryMembers, type SqliteRuntime, SqliteRuntimeImpl, type SqliteTargetId, type SqliteTransactionContext, sqlite as default };
24
24
  //# sourceMappingURL=runtime.d.mts.map
package/dist/runtime.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { i as validateSqliteContract, t as buildSqliteStaticContext } from "./sqlite-static-Bo8giCaf-DOfD6Jpk.mjs";
1
+ import { i as validateSqliteContract, t as buildSqliteStaticContext } from "./sqlite-static-COTp2lKA-K9HBfPSv.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import sqliteAdapter from "@prisma/orm-target-sqlite/adapter/runtime";
4
4
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
5
- import { sql } from "@prisma/orm-family-sql/builder/runtime";
6
- import { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, withTransaction } from "@prisma/orm-family-sql/runtime";
5
+ import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
6
+ import { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, withTransaction, withTransactionMembers } from "@prisma/orm-family-sql/runtime";
7
7
  import sqliteTarget from "@prisma/orm-target-sqlite/target/runtime";
8
8
  import { assertDefined } from "@prisma/orm-framework/utils/assertions";
9
- import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
9
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
10
10
  import sqliteDriver from "@prisma/orm-target-sqlite/driver/runtime";
11
11
  import { instantiateExecutionStack } from "@prisma/orm-framework/components/execution";
12
12
  import { orm, prepareQuery } from "@prisma/orm-family-sql/orm-client";
@@ -30,10 +30,45 @@ function resolveOptionalSqliteBinding(options) {
30
30
  };
31
31
  }
32
32
  var SqliteRuntimeImpl = class extends SqlRuntimeBase {};
33
- function unboundOrm(orm) {
34
- const value = orm[UNBOUND_NAMESPACE_ID];
35
- assertDefined(value, "the unbound namespace always exists on a sqlite builder output");
36
- return blindCast(value);
33
+ function sqliteOrm(orm) {
34
+ const namespace = orm[UNBOUND_NAMESPACE_ID];
35
+ assertDefined(namespace, "the unbound namespace always exists on a sqlite builder output");
36
+ return blindCast(Reflect.get(namespace, "fragment") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, "fragment") } }) : namespace);
37
+ }
38
+ /**
39
+ * Builds the members of a SQLite transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.
40
+ */
41
+ function buildSqliteTransactionMembers(options, txCtx) {
42
+ const { context, collections, rawCodecInferer, enums, prepareRuntime } = options;
43
+ const sqlNamespace = sql({
44
+ context,
45
+ rawCodecInferer
46
+ })[UNBOUND_NAMESPACE_ID];
47
+ assertDefined(sqlNamespace, "the unbound namespace always exists on a sqlite builder output");
48
+ return {
49
+ sql: blindCast(sqlNamespace),
50
+ orm: sqliteOrm(orm({
51
+ runtime: {
52
+ query(plan) {
53
+ return txCtx.query(plan);
54
+ },
55
+ execute(plan) {
56
+ return txCtx.execute(plan);
57
+ },
58
+ [activitySource]: delegatingActivitySource(() => txCtx)
59
+ },
60
+ context,
61
+ ...ifDefined("collections", collections)
62
+ })),
63
+ raw: createRawLane({
64
+ context,
65
+ rawCodecInferer
66
+ }),
67
+ enums,
68
+ prepare(declaration, callback) {
69
+ return prepareQuery(prepareRuntime(), declaration, callback);
70
+ }
71
+ };
37
72
  }
38
73
  /**
39
74
  * Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from
@@ -66,7 +101,7 @@ function sqlite(options) {
66
101
  stack,
67
102
  driver: sqliteDriver
68
103
  });
69
- const { sql: sql$1, raw: rawSqlTag, enums } = buildSqliteStaticContext(contract, context, stack.adapter.rawCodecInferer);
104
+ const { sql, raw: rawSqlTag, enums } = buildSqliteStaticContext(contract, context, stack.adapter.rawCodecInferer);
70
105
  let runtimeInstance;
71
106
  let runtimeDriver;
72
107
  let driverConnected = false;
@@ -110,7 +145,7 @@ function sqlite(options) {
110
145
  });
111
146
  return runtimeInstance;
112
147
  };
113
- const orm$1 = unboundOrm(orm({
148
+ const orm$1 = sqliteOrm(orm({
114
149
  context,
115
150
  ...ifDefined("collections", options.collections),
116
151
  runtime: {
@@ -130,7 +165,7 @@ function sqlite(options) {
130
165
  return prepareQuery(getRuntime(), declaration, callback);
131
166
  }
132
167
  return {
133
- sql: sql$1,
168
+ sql,
134
169
  orm: orm$1,
135
170
  enums,
136
171
  raw: rawSqlTag,
@@ -160,31 +195,13 @@ function sqlite(options) {
160
195
  return Promise.reject(err);
161
196
  }
162
197
  return withTransaction(runtime, (txCtx) => {
163
- const rawCodecInferer = stack.adapter.rawCodecInferer;
164
- const txSqlNamespace = sql({
165
- context,
166
- rawCodecInferer
167
- })[UNBOUND_NAMESPACE_ID];
168
- assertDefined(txSqlNamespace, "the unbound namespace always exists on a sqlite builder output");
169
- const txSql = blindCast(txSqlNamespace);
170
- const txOrm = unboundOrm(orm({
171
- runtime: {
172
- query(plan) {
173
- return txCtx.query(plan);
174
- },
175
- execute(plan) {
176
- return txCtx.execute(plan);
177
- },
178
- [activitySource]: delegatingActivitySource(() => txCtx)
179
- },
198
+ return fn(withTransactionMembers(txCtx, buildSqliteTransactionMembers({
180
199
  context,
181
- ...ifDefined("collections", options.collections)
182
- }));
183
- return fn(Object.assign(castAs(Object.create(txCtx)), {
184
- sql: txSql,
185
- orm: txOrm,
186
- enums
187
- }));
200
+ collections: options.collections,
201
+ rawCodecInferer: stack.adapter.rawCodecInferer,
202
+ enums,
203
+ prepareRuntime: getRuntime
204
+ }, txCtx)));
188
205
  });
189
206
  },
190
207
  close() {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/runtime.mjs"],"sourcesContent":["import { i as validateSqliteContract, t as buildSqliteStaticContext } from \"./sqlite-static-Bo8giCaf.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport sqliteDriver from \"@internal/driver-sqlite/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, withTransaction } from \"@internal/sql-runtime\";\nimport sqliteTarget from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction sqliteError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction resolveSqliteBinding(input) {\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: input.path\n\t};\n}\nfunction resolveOptionalSqliteBinding(options) {\n\tif (options.path === void 0) return;\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: options.path\n\t};\n}\n//#endregion\n//#region src/runtime/sqlite-runtime.ts\nvar SqliteRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/sqlite.ts\nfunction unboundOrm(orm) {\n\tconst value = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(value, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn blindCast(value);\n}\n/**\n* Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-sqlite/static';\n* import sqlite from '@prisma/orm-sqlite/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = sqlite({ contract, path: './dev.db' });\n* ```\n*/\nfunction sqlite(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tlet binding = resolveOptionalSqliteBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\tdriver: sqliteDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: sqliteDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums } = buildSqliteStaticContext(contract, context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"SQLite runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create();\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new SqliteRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t\t...ifDefined(\"log\", options.log),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst orm$1 = unboundOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: {\n\t\t\tquery(plan) {\n\t\t\t\treturn getRuntime().query(plan);\n\t\t\t},\n\t\t\texecute(plan) {\n\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t},\n\t\t\tconnection() {\n\t\t\t\treturn getRuntime().connection();\n\t\t\t},\n\t\t\t[activitySource]: delegatingActivitySource(() => getRuntime())\n\t\t}\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(getRuntime(), declaration, callback);\n\t}\n\treturn {\n\t\tsql: sql$1,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\t\tif (driverConnected || connectPromise) throw sqliteError(\"DRIVER.ALREADY_CONNECTED\", \"SQLite client already connected\", { meta: { extension: \"sqlite\" } });\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveSqliteBinding(bindingInput);\n\t\t\tif (binding === void 0) throw sqliteError(\"RUNTIME.BINDING_MISSING\", \"SQLite binding not configured. Pass path to sqlite(...) or call db.connect({ path }).\", { meta: { extension: \"sqlite\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\tlet runtime;\n\t\t\ttry {\n\t\t\t\truntime = getRuntime();\n\t\t\t} catch (err) {\n\t\t\t\treturn Promise.reject(err);\n\t\t\t}\n\t\t\treturn withTransaction(runtime, (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSqlNamespace = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t})[UNBOUND_NAMESPACE_ID];\n\t\t\t\tassertDefined(txSqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\t\t\t\tconst txSql = blindCast(txSqlNamespace);\n\t\t\t\tconst txOrm = unboundOrm(orm({\n\t\t\t\t\truntime: {\n\t\t\t\t\t\tquery(plan) {\n\t\t\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute(plan) {\n\t\t\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t\t\t},\n\t\t\t\t\tcontext,\n\t\t\t\t\t...ifDefined(\"collections\", options.collections)\n\t\t\t\t}));\n\t\t\t\treturn fn(Object.assign(castAs(Object.create(txCtx)), {\n\t\t\t\t\tsql: txSql,\n\t\t\t\t\torm: txOrm,\n\t\t\t\t\tenums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { SqliteRuntimeImpl, sqlite as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,qBAAqB,OAAO;CACpC,OAAO;EACN,MAAM;EACN,MAAM,MAAM;CACb;AACD;AACA,SAAS,6BAA6B,SAAS;CAC9C,IAAI,QAAQ,SAAS,KAAK,GAAG;CAC7B,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;CACf;AACD;AAGA,IAAI,oBAAoB,cAAc,eAAe,CAAC;AAGtD,SAAS,WAAW,KAAK;CACxB,MAAM,QAAQ,IAAI;CAClB,cAAc,OAAO,gEAAgE;CAC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ACA;EACA,YAAY,IAAI;GACf,IAAI;GACJ,IAAI;IACH,UAAU,WAAW;GACtB,SAAS,KAAK;IACb,OAAO,QAAQ,OAAO,GAAG;GAC1B;GACA,OAAO,gBAAgB,UAAU,UAAU;IAC1C,MAAM,kBAAkB,MAAM,QAAQ;IACtC,MAAM,iBAAiB,IAAI;KAC1B;KACA;IACD,CAAC,CAAC,CAAC;IACH,cAAc,gBAAgB,gEAAgE;IAC9F,MAAM,QAAQ,UAAU,cAAc;IACtC,MAAM,QAAQ,WAAW,IAAI;KAC5B,SAAS;MACR,MAAM,MAAM;OACX,OAAO,MAAM,MAAM,IAAI;MACxB;MACA,QAAQ,MAAM;OACb,OAAO,MAAM,QAAQ,IAAI;MAC1B;OACC,iBAAiB,+BAA+B,KAAK;KACvD;KACA;KACA,GAAG,UAAU,eAAe,QAAQ,WAAW;IAChD,CAAC,CAAC;IACF,OAAO,GAAG,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC,GAAG;KACrD,KAAK;KACL,KAAK;KACL;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,QAAQ;GACP,IAAI,cAAc,OAAO;GACzB,SAAS;GACT,gBAAgB,YAAY;IAC3B,MAAM,gBAAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/runtime.mjs"],"sourcesContent":["import { i as validateSqliteContract, t as buildSqliteStaticContext } from \"./sqlite-static-COTp2lKA.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport sqliteDriver from \"@internal/driver-sqlite/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport sqliteTarget from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction sqliteError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction resolveSqliteBinding(input) {\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: input.path\n\t};\n}\nfunction resolveOptionalSqliteBinding(options) {\n\tif (options.path === void 0) return;\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: options.path\n\t};\n}\n//#endregion\n//#region src/runtime/sqlite-runtime.ts\nvar SqliteRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/sqlite.ts\nfunction sqliteOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a SQLite transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildSqliteTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, prepareRuntime } = options;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: sqliteOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime(), declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-sqlite/static';\n* import sqlite from '@prisma/orm-sqlite/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = sqlite({ contract, path: './dev.db' });\n* ```\n*/\nfunction sqlite(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tlet binding = resolveOptionalSqliteBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\tdriver: sqliteDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: sqliteDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums } = buildSqliteStaticContext(contract, context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"SQLite runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create();\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new SqliteRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t\t...ifDefined(\"log\", options.log),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst orm$1 = sqliteOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: {\n\t\t\tquery(plan) {\n\t\t\t\treturn getRuntime().query(plan);\n\t\t\t},\n\t\t\texecute(plan) {\n\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t},\n\t\t\tconnection() {\n\t\t\t\treturn getRuntime().connection();\n\t\t\t},\n\t\t\t[activitySource]: delegatingActivitySource(() => getRuntime())\n\t\t}\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(getRuntime(), declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\t\tif (driverConnected || connectPromise) throw sqliteError(\"DRIVER.ALREADY_CONNECTED\", \"SQLite client already connected\", { meta: { extension: \"sqlite\" } });\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveSqliteBinding(bindingInput);\n\t\t\tif (binding === void 0) throw sqliteError(\"RUNTIME.BINDING_MISSING\", \"SQLite binding not configured. Pass path to sqlite(...) or call db.connect({ path }).\", { meta: { extension: \"sqlite\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\tlet runtime;\n\t\t\ttry {\n\t\t\t\truntime = getRuntime();\n\t\t\t} catch (err) {\n\t\t\t\treturn Promise.reject(err);\n\t\t\t}\n\t\t\treturn withTransaction(runtime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildSqliteTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\tprepareRuntime: getRuntime\n\t\t\t\t}, txCtx)));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { SqliteRuntimeImpl, sqlite as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,qBAAqB,OAAO;CACpC,OAAO;EACN,MAAM;EACN,MAAM,MAAM;CACb;AACD;AACA,SAAS,6BAA6B,SAAS;CAC9C,IAAI,QAAQ,SAAS,KAAK,GAAG;CAC7B,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;CACf;AACD;AAGA,IAAI,oBAAoB,cAAc,eAAe,CAAC;AAGtD,SAAS,UAAU,KAAK;CACvB,MAAM,YAAY,IAAI;CACtB,cAAc,WAAW,gEAAgE;CACzF,OAAO,UAAU,QAAQ,IAAI,WAAW,UAAU,MAAM,KAAK,IAAI,OAAO,OAAO,WAAW,EAAE,UAAU,EAAE,OAAO,QAAQ,IAAI,KAAK,UAAU,EAAE,EAAE,CAAC,IAAI,SAAS;AAC7J;;;;AAIA,SAAS,8BAA8B,SAAS,OAAO;CACtD,MAAM,EAAE,SAAS,aAAa,iBAAiB,OAAO,mBAAmB;CACzE,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,OAAO;EACN,KAAK,UAAU,YAAY;EAC3B,KAAK,UAAU,IAAI;GAClB,SAAS;IACR,MAAM,MAAM;KACX,OAAO,MAAM,MAAM,IAAI;IACxB;IACA,QAAQ,MAAM;KACb,OAAO,MAAM,QAAQ,IAAI;IAC1B;KACC,iBAAiB,+BAA+B,KAAK;GACvD;GACA;GACA,GAAG,UAAU,eAAe,WAAW;EACxC,CAAC,CAAC;EACF,KAAK,cAAc;GAClB;GACA;EACD,CAAC;EACD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,OAAO;EACR;EACA,UAAU;GACT,OAAO,WAAW;EACnB;EACA;EACA,YAAY,IAAI;GACf,IAAI;GACJ,IAAI;IACH,UAAU,WAAW;GACtB,SAAS,KAAK;IACb,OAAO,QAAQ,OAAO,GAAG;GAC1B;GACA,OAAO,gBAAgB,UAAU,UAAU;IAC1C,OAAO,GAAG,uBAAuB,OAAO,8BAA8B;KACrE;KACA,aAAa,QAAQ;KACrB,iBAAiB,MAAM,QAAQ;KAC/B;KACA,gBAAgB;IACjB,GAAG,KAAK,CAAC,CAAC;GACX,CAAC;EACF;EACA,QAAQ;GACP,IAAI,cAAc,OAAO;GACzB,SAAS;GACT,gBAAgB,YAAY;IAC3B,MAAM,gBAAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
@@ -1,13 +1,12 @@
1
1
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
2
- import { BindSiteParams, Declaration, ExecutionContext, Log, ParamsFromDeclaration, Runtime, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor, TransactionContext, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
2
+ import { ExecutionContext, Log, Runtime, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor, TransactionContext, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
3
3
  import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
4
- import { CollectionClasses, NoCollectionClasses, PreparedFrom, orm } from "@prisma/orm-family-sql/orm-client";
4
+ import { CollectionClasses, NoCollectionClasses, OrmClientRootMembers, PrepareMember, orm } from "@prisma/orm-family-sql/orm-client";
5
5
  import { Contract } from "@prisma/orm-framework/contract/types";
6
- import { ExtractCodecTypes, SqlStorage } from "@prisma/orm-family-sql/contract/types";
6
+ import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
7
7
  import { Db, RawLane } from "@prisma/orm-family-sql/builder/types";
8
- import { CodecTypesBase } from "@prisma/orm-family-sql/relational-core/expression";
9
- import { Preparable, SqlQueryPlan } from "@prisma/orm-family-sql/relational-core/plan";
10
- //#region ../../../3-extensions/sqlite/dist/sqlite-0-P_ooKZ.d.mts
8
+ import "@prisma/orm-family-sql/relational-core/expression";
9
+ //#region ../../../3-extensions/sqlite/dist/sqlite-nkzz9Mmw.d.mts
11
10
  //#region src/static/sqlite-static.d.ts
12
11
  type UnboundSql$1<TContract extends Contract<SqlStorage>> = Db<TContract>[typeof UNBOUND_NAMESPACE_ID];
13
12
  type UnboundEnums<TContract extends Contract<SqlStorage>> = NamespacedEnums<TContract>[typeof UNBOUND_NAMESPACE_ID];
@@ -37,16 +36,19 @@ type SqliteTargetId = 'sqlite';
37
36
  type OrmClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = ReturnType<typeof orm<TContract, TCollections>>;
38
37
  type UnboundSql<TContract extends Contract<SqlStorage>> = Db<TContract>[typeof UNBOUND_NAMESPACE_ID];
39
38
  type UnboundOrm<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = OrmClient<TContract, TCollections>[typeof UNBOUND_NAMESPACE_ID];
40
- interface SqliteTransactionContext<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends TransactionContext {
39
+ /** The models of SQLite's single namespace, and `fragment` unless a model is named `fragment`. */
40
+ type SqliteOrm<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> = 'fragment' extends keyof UnboundOrm<TContract, TCollections> ? UnboundOrm<TContract, TCollections> : UnboundOrm<TContract, TCollections> & OrmClientRootMembers<TContract>;
41
+ /** The query members of a SQLite client, which its transactions offer with the same types. */
42
+ interface SqliteQueryMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PrepareMember<TContract> {
41
43
  readonly sql: UnboundSql<TContract>;
42
- readonly orm: UnboundOrm<TContract, TCollections>;
44
+ readonly orm: SqliteOrm<TContract, TCollections>;
45
+ readonly raw: RawLane<TContract>;
46
+ }
47
+ interface SqliteTransactionContext<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends TransactionContext, SqliteQueryMembers<TContract, TCollections> {
43
48
  readonly enums: SqliteStaticContext<TContract>['enums'];
44
49
  }
45
- interface SqliteClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> {
46
- readonly sql: UnboundSql<TContract>;
47
- readonly orm: UnboundOrm<TContract, TCollections>;
50
+ interface SqliteClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends SqliteQueryMembers<TContract, TCollections> {
48
51
  readonly enums: SqliteStaticContext<TContract>['enums'];
49
- readonly raw: RawLane<TContract>;
50
52
  readonly context: ExecutionContext<TContract>;
51
53
  readonly contract: TContract;
52
54
  readonly stack: SqlExecutionStackWithDriver<SqliteTargetId>;
@@ -54,7 +56,6 @@ interface SqliteClient<TContract extends Contract<SqlStorage>, TCollections exte
54
56
  readonly path: string;
55
57
  }): Promise<Runtime>;
56
58
  runtime(): Runtime;
57
- prepare<D extends Declaration<CT>, Q extends SqlQueryPlan | Preparable<unknown, unknown>, CT extends CodecTypesBase = ExtractCodecTypes<TContract>>(declaration: D, callback: (params: BindSiteParams<D>) => Q): Promise<PreparedFrom<ParamsFromDeclaration<D, CT>, Q>>;
58
59
  transaction<R>(fn: (tx: SqliteTransactionContext<TContract, TCollections>) => PromiseLike<R>): Promise<R>;
59
60
  close(): Promise<void>;
60
61
  [Symbol.asyncDispose](): Promise<void>;
@@ -89,5 +90,5 @@ type SqliteOptions<TContract extends Contract<SqlStorage>, TCollections extends
89
90
  */
90
91
  declare function sqlite<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses>(options: SqliteOptions<TContract, TCollections>): SqliteClient<TContract, TCollections>;
91
92
  //#endregion
92
- export { SqliteTargetId as a, SqliteStaticContext as i, SqliteOptions as n, sqlite as o, SqliteOptionsBase as r, sqliteStatic as s, SqliteClient as t };
93
- //# sourceMappingURL=sqlite-0-P_ooKZ-CD-hUbzF.d.mts.map
93
+ export { SqliteQueryMembers as a, SqliteTransactionContext as c, SqliteOrm as i, sqlite as l, SqliteOptions as n, SqliteStaticContext as o, SqliteOptionsBase as r, SqliteTargetId as s, SqliteClient as t, sqliteStatic as u };
94
+ //# sourceMappingURL=sqlite-nkzz9Mmw-Bp47g4Ms.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-nkzz9Mmw-Bp47g4Ms.d.mts","names":[],"sources":["../../../../3-extensions/sqlite/dist/sqlite-nkzz9Mmw.d.mts"],"mappings":";;;;;;;;;;KASK,aAAa,kBAAkB,SAAS,eAAe,GAAG,kBAAkB;KAC5E,aAAa,kBAAkB,SAAS,eAAe,gBAAgB,kBAAkB;UACpF,oBAAoB,kBAAkB,SAAS;WAC9C,SAAS,iBAAiB;WAC1B,UAAU;WACV,OAAO,aAAa;WACpB,KAAK,aAAa;WAClB,KAAK,QAAQ;;;;;;;;;;;iBAWP,aAAa,kBAAkB,SAAS,aAAa;WAC3D,UAAU;WACV,sBAAsB,8BAA8B;IAC3D,oBAAoB;;;KAGnB;KACA,UAAU,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,kBAAkB,IAAI,WAAW;KAC7H,WAAW,kBAAkB,SAAS,eAAe,GAAG,kBAAkB;KAC1E,WAAW,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,UAAU,WAAW,qBAAqB;;KAEvI,UAAU,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,gDAAgD,WAAW,WAAW,gBAAgB,WAAW,WAAW,gBAAgB,WAAW,WAAW,gBAAgB,qBAAqB;;UAE7Q,mBAAmB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,cAAc;WAC9I,KAAK,WAAW;WAChB,KAAK,UAAU,WAAW;WAC1B,KAAK,QAAQ;;UAEd,yBAAyB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,oBAAoB,mBAAmB,WAAW;WACxL,OAAO,oBAAoB;;UAE5B,aAAa,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,mBAAmB,WAAW;WACxJ,OAAO,oBAAoB;WAC3B,SAAS,iBAAiB;WAC1B,UAAU;WACV,OAAO,4BAA4B;EAC5C,QAAQ;aACG;MACP,QAAQ;EACZ,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,yBAAyB,WAAW,kBAAkB,YAAY,KAAK,QAAQ;EACvG,SAAS;GACR,OAAO,iBAAiB;;UAEjB;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf,MAAM;;KAEZ,cAAc,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,uBAAuB;WAChH,UAAU;WACV,cAAc;WACd;;;;;;;;;;;;;;;;;;;iBAmBM,OAAO,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,qBAAqB,SAAS,cAAc,WAAW,gBAAgB,aAAa,WAAW"}
@@ -7,8 +7,8 @@ import { assertDefined } from "@prisma/orm-framework/utils/assertions";
7
7
  import { blindCast } from "@prisma/orm-framework/utils/casts";
8
8
  import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
9
9
  import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
10
- //#region ../../../3-extensions/sqlite/dist/sqlite-static-Bo8giCaf.mjs
11
- var version = "8.0.0-rc.18-dev.34";
10
+ //#region ../../../3-extensions/sqlite/dist/sqlite-static-COTp2lKA.mjs
11
+ var version = "8.0.0-rc.18-dev.36";
12
12
  const serializer = new SqliteContractSerializer();
13
13
  const validator = `${sqliteTarget.targetId}@${version}`;
14
14
  /**
@@ -78,4 +78,4 @@ function sqliteStatic(options) {
78
78
  //#endregion
79
79
  export { validateSqliteContract as i, contractFromJson as n, sqliteStatic as r, buildSqliteStaticContext as t };
80
80
 
81
- //# sourceMappingURL=sqlite-static-Bo8giCaf-DOfD6Jpk.mjs.map
81
+ //# sourceMappingURL=sqlite-static-COTp2lKA-K9HBfPSv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-static-Bo8giCaf-DOfD6Jpk.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/sqlite-static-Bo8giCaf.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.18-dev.34\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, rawCodecInferer) {\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw` and `enums`. Use it where\n* loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-Bo8giCaf.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,iBAAiB;CACrE,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;CACD;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,MAAM,QAAQ,eAAe;AAClC"}
1
+ {"version":3,"file":"sqlite-static-COTp2lKA-K9HBfPSv.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/sqlite-static-COTp2lKA.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.18-dev.36\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, rawCodecInferer) {\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw` and `enums`. Use it where\n* loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-COTp2lKA.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,iBAAiB;CACrE,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;CACD;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,MAAM,QAAQ,eAAe;AAClC"}
package/dist/static.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as SqliteStaticContext, s as sqliteStatic } from "./sqlite-0-P_ooKZ-CD-hUbzF.mjs";
1
+ import { o as SqliteStaticContext, u as sqliteStatic } from "./sqlite-nkzz9Mmw-Bp47g4Ms.mjs";
2
2
  import { Contract } from "@prisma/orm-framework/contract/types";
3
3
  import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
4
4
  //#region ../../../3-extensions/sqlite/dist/static.d.mts
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as contractFromJson, r as sqliteStatic } from "./sqlite-static-Bo8giCaf-DOfD6Jpk.mjs";
1
+ import { n as contractFromJson, r as sqliteStatic } from "./sqlite-static-COTp2lKA-K9HBfPSv.mjs";
2
2
  export { contractFromJson, sqliteStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-sqlite",
3
- "version": "8.0.0-rc.18-dev.34",
3
+ "version": "8.0.0-rc.18-dev.36",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,17 +10,17 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.18-dev.34",
14
- "@prisma/orm-framework": "8.0.0-rc.18-dev.34",
15
- "@prisma/orm-target-sqlite": "8.0.0-rc.18-dev.34",
16
- "@prisma/orm-toolchain": "8.0.0-rc.18-dev.34",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.18-dev.36",
14
+ "@prisma/orm-framework": "8.0.0-rc.18-dev.36",
15
+ "@prisma/orm-target-sqlite": "8.0.0-rc.18-dev.36",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.18-dev.36",
17
17
  "pathe": "^2.0.3",
18
18
  "tinyglobby": "^0.2.17"
19
19
  },
20
20
  "devDependencies": {
21
- "@internal/sqlite": "8.0.0-rc.18-dev.34",
22
- "@repo/tsconfig": "8.0.0-rc.18-dev.34",
23
- "@repo/tsdown": "8.0.0-rc.18-dev.34",
21
+ "@internal/sqlite": "8.0.0-rc.18-dev.36",
22
+ "@repo/tsconfig": "8.0.0-rc.18-dev.36",
23
+ "@repo/tsdown": "8.0.0-rc.18-dev.36",
24
24
  "tsdown": "0.22.14",
25
25
  "typescript": "5.9.3"
26
26
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-sqlite'
18
- library_version: '8.0.0-rc.18-dev.34'
18
+ library_version: '8.0.0-rc.18-dev.36'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -132,7 +132,7 @@ If the envelope's `code` is not in this table, follow the envelope's `fix` field
132
132
  - **Studio / GUI database browser.** No first-party Studio. Workaround: `prisma db schema` for a CLI tree of the live schema, or use a third-party tool (TablePlus, DataGrip, `psql`) against your `DATABASE_URL`. If you need a built-in GUI, file a feature request via `references/feedback.md`.
133
133
  - **First-class query logger middleware.** No built-in "log every query" middleware ships with the framework. Workaround: write a small custom middleware that wraps each operation (see `references/runtime.md` for middleware composition). If you need a built-in query log, file a feature request via `references/feedback.md`.
134
134
  - **`EXPLAIN` integration.** No first-class `.explain()` on plans. Workaround: write the EXPLAIN as a raw query (``db.raw.sql`EXPLAIN ANALYZE ...` ``; see `references/queries.md`). If you need first-class EXPLAIN, file a feature request via `references/feedback.md`.
135
- - **Prepared statements are not a gap.** `db.prepare(declaration, (sql, params) => plan)` (or `runtime.prepare(...)`) builds a statement once; a row-returning statement runs with `ps.query(runtime, params)`, an affected-count one with `ps.execute(runtime, params)`. See *Prepared statements* in `references/queries.md`. TypedSQL (`.sql` files compiled to callables) is the thing that does not exist.
135
+ - **Prepared statements are not a gap.** `db.prepare(declaration, (params) => plan)` (or `runtime.prepare(...)`, or `tx.prepare(...)` inside a transaction) builds a statement once; a row-returning statement runs with `ps.query(target, params)`, an affected-count one with `ps.execute(target, params)`, where `target` is the runtime, a connection or a transaction's `tx`. See *Prepared statements* in `references/queries.md`. TypedSQL (`.sql` files compiled to callables) is the thing that does not exist.
136
136
 
137
137
  ## Asking for help when the envelope doesn't route
138
138
 
@@ -609,7 +609,7 @@ The SQL builder's `.orderBy(column, { direction, nulls })` takes the same null p
609
609
 
610
610
  ## Workflow — Transactions
611
611
 
612
- The concept: `db.transaction(fn)` opens a transaction and passes a `tx` context to the callback. `tx.orm` and `tx.sql` mirror `db.orm` / `db.sql` but ride the same transaction; `tx.query(plan)` / `tx.execute(plan)` run a SQL-builder plan within it (rows vs affected count, as on the runtime). The transaction commits on the callback's successful return and rolls back on any thrown error.
612
+ The concept: `db.transaction(fn)` opens a transaction and passes a `tx` context to the callback. `tx` offers the client's query members with the same types, and each runs inside the transaction: `sql`, `orm` (with the client's custom collection classes), `raw`, `prepare`, `query(plan)` (rows) and `execute(plan)` (affected count), plus `enums` and `nativeEnums`. A prepared statement runs on what it is given, so `ps.query(tx, params)` runs inside the transaction. See *Workflow — Transactions* in `references/runtime.md` for raw SQL and `tx.prepare`. The transaction commits on the callback's successful return and rolls back on any thrown error.
613
613
 
614
614
  ```typescript
615
615
  await db.transaction(async (tx) => {
@@ -10,7 +10,7 @@ Once the contract is emitted and the DB is up to date, this skill covers everyth
10
10
  - User wants to read, write, update, or delete data.
11
11
  - User wants to include / eager-load relations.
12
12
  - User wants to paginate, sort, filter, project.
13
- - User wants to wrap operations in a transaction (`db.transaction(...)` — Postgres and SQLite).
13
+ - User wants to wrap operations in a transaction (`db.transaction(...)` — Postgres, SQLite and Supabase role-bound clients).
14
14
  - User wants to aggregate (`count`, `sum`, `avg`, …).
15
15
  - User asks about query lanes (ORM vs SQL builder / query builder).
16
16
  - User mentions: *query, select, where, orderBy, limit, offset, take, skip, include, eager load, first, all, count, aggregate, create, update, delete, upsert, returning, drizzle-style, kysely-style, prisma client*.
@@ -136,12 +136,12 @@ There is no `.stream()` method on a client or on a connection.
136
136
 
137
137
  ## Prepared statements (Postgres, SQLite)
138
138
 
139
- `db.prepare(declaration, (sql, params) => plan)` builds a statement once and binds it per call. The declaration names each parameter's codec (`{ email: 'pg/text@1' }`); the callback receives the façade's `sql` builder plus typed `params` and returns a plan. A row-returning plan gives a `PreparedStatement` you run with `ps.query(runtime, params)`; a plan whose result is an affected count gives a `PreparedExecution` you run with `ps.execute(runtime, params)`. Declaring a parameter the plan never references throws `RUNTIME.PREPARE_UNUSED_PARAM`. `runtime.prepare(declaration, (params) => plan)` is the same thing on a `Runtime`.
139
+ `db.prepare(declaration, (params) => plan)` builds a statement once and binds it per call. The declaration names each parameter's codec (`{ email: 'pg/text@1' }`); the callback receives typed `params`, builds the plan with `db.sql` (or an ORM `.prepared` description), and returns it. A row-returning plan gives a `PreparedStatement` you run with `ps.query(target, params)`; a plan whose result is an affected count gives a `PreparedExecution` you run with `ps.execute(target, params)`. A prepared statement runs on what it is given: the runtime, a connection, a transaction's `tx`, or a Supabase role-bound client, which runs it under its role. `ps.query(tx, params)` runs inside the transaction. Preparing sends nothing to the database. Inside a transaction, `tx.prepare(...)` prepares without the outer client. Declaring a parameter the plan never references throws `RUNTIME.PREPARE_UNUSED_PARAM`. `runtime.prepare(declaration, (params) => plan)` is the same thing on a `Runtime`.
140
140
 
141
141
  ```typescript
142
142
  // examples/prisma-8-demo/src/queries/get-user-by-email-prepared.ts
143
- const ps = await db.prepare({ email: 'pg/text@1' }, (sql, params) =>
144
- sql.public.user
143
+ const ps = await db.prepare({ email: 'pg/text@1' }, (params) =>
144
+ db.sql.public.user
145
145
  .select('id', 'email', 'displayName', 'createdAt', 'kind')
146
146
  .where((f, fns) => fns.eq(f.email, params.email))
147
147
  .limit(1)
@@ -11,7 +11,7 @@ This skill covers the **runtime entry point** — `db.ts` — and how to compose
11
11
  - User wants to add middleware (lints, budgets, cache, custom).
12
12
  - User wants per-environment config (dev vs prod, multi-region).
13
13
  - User wants to switch between the Postgres, SQLite, and Mongo façades.
14
- - User wants to wrap operations in `db.transaction(...)` (Postgres and SQLite).
14
+ - User wants to wrap operations in `db.transaction(...)` (Postgres, SQLite and Supabase role-bound clients).
15
15
  - User is running a one-off script (`tsx my-script.ts`, Node CLI, CI task) and the process won't exit after queries finish, or they need script teardown (`db.close()`, `await using`).
16
16
  - User is deploying to a per-request runtime (Cloudflare Workers + Hyperdrive, AWS Lambda, Vercel Edge, Deno Deploy, Bun edge) and needs `postgresServerless()` with `postgres.connect({ url })` per request.
17
17
  - User mentions: *db.ts, postgres(), mongo(), middleware, lints, budgets, cache, query log, slow query, DATABASE_URL, .env, connection pool, poolOptions, dev vs prod, transactions, read replicas, multi-database, script won't exit, hangs, db.close, db.end, close connection, pool.end, await using, serverless, edge, Cloudflare Workers, Hyperdrive, postgresServerless, connect per request*.
@@ -355,7 +355,7 @@ export const db = postgres({
355
355
 
356
356
  ## Workflow — Transactions
357
357
 
358
- The concept applies to **Postgres and SQLite**. `db.transaction(fn)` opens a transaction, gives the callback a `tx` context with the same `sql` / `orm` surfaces as `db`, and commits on successful return / rolls back on any thrown error. Inside the callback, use `tx.sql` and `tx.orm` instead of `db.sql` / `db.orm` so the writes ride the transaction. The Mongo façade does not expose `db.transaction(...)`.
358
+ The concept applies to **Postgres, SQLite and Supabase**. `db.transaction(fn)` opens a transaction, passes the callback a `tx`, commits when the callback returns and rolls back when it throws. `tx` offers the client's query members with the same types: `sql`, `orm` (with the client's custom collection classes), `raw`, `prepare`, `query` (rows) and `execute` (affected count). Postgres and serverless-connection transactions also have `enums` and `nativeEnums`; SQLite's has `enums`. `tx` has no `close`, `[Symbol.asyncDispose]`, `transaction` or `runtime()`. Inside the callback, send every query through `tx`, not `db`, so it runs inside the transaction. A Supabase role-bound client (`asUser`, `asAnon`, `asServiceRole`) has `transaction(fn)` too, and its `tx` runs every statement under the bound role. The Mongo façade does not expose `db.transaction(...)`.
359
359
 
360
360
  ```typescript
361
361
  await db.transaction(async (tx) => {
@@ -365,7 +365,20 @@ await db.transaction(async (tx) => {
365
365
  });
366
366
  ```
367
367
 
368
- The callback returns whatever you return from it — the transaction wrapper passes it through. The `tx` object exposes `query(plan)` (rows) and `execute(plan)` (affected count) for SQL-builder plans inside the transaction.
368
+ The callback returns whatever you return from it — the transaction wrapper passes it through. Raw SQL and prepared statements work inside the transaction too:
369
+
370
+ ```typescript
371
+ await db.transaction(async (tx) => {
372
+ const posts = await tx.orm.public.Post.published().forUpdate().all();
373
+ await tx.execute(tx.raw.sql`UPDATE post SET pinned = false WHERE id = ${posts[0]!.id}`.affectedCount().build());
374
+ const byId = await tx.prepare({ id: 'pg/int4@1' }, (params) =>
375
+ tx.sql.public.post.select('id').where((f, fns) => fns.eq(f.id, params.id)).build(),
376
+ );
377
+ await byId.query(tx, { id: 1 });
378
+ });
379
+ ```
380
+
381
+ `published()` is a method of a custom collection class. A prepared statement runs on what it is given: `ps.query(tx, params)` runs inside the transaction, even when `ps` came from `db.prepare(...)`. `tx.prepare` exists so code inside a transaction needs nothing from the outer client. Preparing sends nothing to the database.
369
382
 
370
383
  ## Workflow — Switch between Postgres, SQLite, and Mongo
371
384
 
@@ -397,7 +410,7 @@ export const contract = contractFromJson<Contract>(contractJson);
397
410
  export const db = sqlite({ contract, path: 'app.db' });
398
411
  ```
399
412
 
400
- `path` is optional at construct time (you can call `db.connect({ path })` later); omit it and the façade still returns a client. The SQLite façade exposes the same `db.sql`, `db.orm`, `db.transaction(...)`, `db.close()`, and `[Symbol.asyncDispose]` surfaces as Postgres, with one addressing difference: SQLite has no schemas, so `db.sql` and `db.orm` are the unbound namespace itself (`db.orm.User`, `db.sql.user`) instead of Postgres's `db.orm.public.User` / `db.sql.public.user`. The Mongo façade shares `db.orm`, `db.close()`, and `[Symbol.asyncDispose]` but has no `db.sql` and no `db.transaction(...)`.
413
+ `path` is optional at construct time (you can call `db.connect({ path })` later); omit it and the façade still returns a client. The SQLite façade exposes the same `db.sql`, `db.orm`, `db.raw`, `db.prepare(...)`, `db.transaction(...)`, `db.close()`, and `[Symbol.asyncDispose]` surfaces as Postgres, with one addressing difference: SQLite has no schemas, so `db.sql` and `db.orm` are the unbound namespace itself (`db.orm.User`, `db.sql.user`) instead of Postgres's `db.orm.public.User` / `db.sql.public.user`. `db.orm` and `tx.orm` also offer `fragment` beside the models, unless a model is named `fragment`: `const titled = db.orm.fragment({ title: { codecId: 'sqlite/text@1', nullable: false } }, (rows) => rows.where((r) => r.title.eq('Hello')));` then `await db.orm.Post.with(titled).all();`. The Mongo façade shares `db.orm`, `db.close()`, and `[Symbol.asyncDispose]` but has no `db.sql` and no `db.transaction(...)`.
401
414
 
402
415
  The `db.sql` / `db.orm` surfaces stay the same in name; the operators each surface exposes are target-shaped (Mongo has no `JOIN`).
403
416
 
@@ -443,6 +456,6 @@ This skill is intentionally body-only; `prisma orm init --help`, the target `def
443
456
  - [ ] Per-env divergence (if any) gated by `NODE_ENV` or similar.
444
457
  - [ ] Did NOT hardcode credentials in any committed file.
445
458
  - [ ] Did NOT confabulate a `@internal/postgres/middleware` subpath, a `@internal/middleware-telemetry` package, a `@internal/postgres-extension-audit` package, or a type argument or `contractJson` option on `postgres(...)`.
446
- - [ ] Did NOT claim `db.transaction(...)` exists on the Mongo façade — only Postgres and SQLite expose it.
459
+ - [ ] Did NOT claim `db.transaction(...)` exists on the Mongo façade — only Postgres, SQLite and Supabase role-bound clients expose it.
447
460
  - [ ] Did NOT confabulate read-replica / multi-DB / extra pool config — pointed at *What Prisma 8 doesn't do yet* and routed to `references/feedback.md`.
448
461
  - [ ] For build-system / dev-server prompts (Vite plugin, Next.js plugin, …) routed to `references/build.md`.
@@ -25,7 +25,7 @@ This skill covers using Prisma 8 against a **Supabase** project end-to-end: comp
25
25
 
26
26
  - **The pack is an `external` contract space.** `@internal/extension-supabase/pack` ships a complete, introspection-generated contract of everything Supabase owns — the `auth` and `storage` schemas, their native enum types, and the platform roles (`anon`, `authenticated`, `service_role`) — all with control policy `external`. Composed via `extensions`, it means: the migration planner **emits no DDL** for those objects (Supabase manages them), and `db verify` **confirms they exist** in the live database. Your own tables stay `managed` as usual.
27
27
  - **Roles come from the pack; you never declare them.** RLS `roles = [authenticated]` identifiers resolve against the composed contract. Pointing the runtime at a non-Supabase Postgres fails verify with a `not-found` issue naming the missing role — the common "wrong database" misconfiguration surfaces before queries run.
28
- - **The runtime is role-first.** `supabase()` returns a `SupabaseDb` with **no top-level query surface** — there is no `db.sql` / `db.orm` until you bind a role. `await db.asUser(jwt)` / `db.asAnon()` / `db.asServiceRole()` each return a `RoleBoundDb` exposing `.sql`, `.orm`, `.raw`, `.query(plan)` (rows), `.execute(plan)` (affected count), and `.transaction(fn)`. This is deliberate: in a Supabase app there is no meaningful "no role" execution context, and defaulting to the connection's login role is a silent-RLS-bypass footgun.
28
+ - **The runtime is role-first.** `supabase()` returns a `SupabaseDb` with **no top-level query surface** — there is no `db.sql` / `db.orm` until you bind a role. `await db.asUser(jwt)` / `db.asAnon()` / `db.asServiceRole()` each return a `RoleBoundDb` exposing `.sql`, `.orm`, `.raw`, `.prepare(...)`, `.query(plan)` (rows), `.execute(plan)` (affected count), and `.transaction(fn)`. This is deliberate: in a Supabase app there is no meaningful "no role" execution context, and defaulting to the connection's login role is a silent-RLS-bypass footgun.
29
29
  - **Role binding is below middleware and cannot leak.** Each role-bound query runs on a connection that had `set_config('role', …)` and `set_config('request.jwt.claims', …)` applied beneath the user-middleware chain, with `RESET ALL` on release. Postgres-side `auth.uid()` / `auth.jwt()` read those session vars — RLS enforcement is Postgres's job; the runtime's job is binding the context.
30
30
  - **RLS is enforced by policies *and* grants.** Policies filter *rows*; `GRANT` controls *table access*. Prisma 8 authors and migrates the policies; it does not author grants (see *What Prisma 8 doesn't do yet*). A role with policies but no `GRANT` gets a permission error, not filtered rows. On Supabase your `public` tables already carry the platform-role grants via default privileges — the grant that is actually missing out of the box is `service_role`'s on `auth.*` / `storage.*` (see *Workflow — Grants*).
31
31
  - **JWT validation is eager and configurable — current Supabase projects need `jwksUrl`.** `asUser(jwt)` verifies the token (via `jose`) *before* any connection is acquired: signature + expiry against `jwksUrl` (asymmetric signing keys — **the default on current Supabase projects**, which sign ES256) **xor** `jwtSecret` (the symmetric HS256 secret — legacy projects only). Both or neither → a structured error with code `SUPABASE.CONFIG_INVALID`. Bad tokens throw a structured error with code `SUPABASE.JWT_INVALID` and a typed `meta.reason` — including a mismatch between the token's algorithm and the configured key source (an ES256 token against a `jwtSecret` client names the problem and tells you to switch to `jwksUrl`). The Postgres role is derived from the token's `role` claim (defaults to `authenticated`). Note: `supabase status` still prints a `JWT_SECRET` even on projects that sign ES256 — its presence does not mean your project uses it.
@@ -146,7 +146,7 @@ const updated = await userDb.orm.public.Profile
146
146
  .updateAndCount({ username: 'new-name' });
147
147
  ```
148
148
 
149
- Notes: `asAnon()` / `asServiceRole()` are sync; only `asUser` is async. Multi-namespace contracts address models by coordinate (`orm.public.Profile`, `sql.public.profile`) — see `references/queries.md` § *Namespace-aware accessors*. `RoleBoundDb.transaction(fn)` wraps work in a transaction on the role-bound session.
149
+ Notes: `asAnon()` / `asServiceRole()` are sync; only `asUser` is async. Multi-namespace contracts address models by coordinate (`orm.public.Profile`, `sql.public.profile`) — see `references/queries.md` § *Namespace-aware accessors*. `RoleBoundDb.transaction(fn)` wraps work in a transaction on the role-bound session; its `tx` offers `sql`, `orm` (with the client's custom collection classes), `raw`, `prepare`, `query` and `execute`, and runs every statement under the bound role. A prepared statement runs on what it is given: `ps.query(userDb, params)` runs under that client's role, and `ps.query(tx, params)` runs inside the transaction.
150
150
 
151
151
  ## Workflow — Admin reads of `auth.*` / `storage.*`
152
152
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqlite-0-P_ooKZ-CD-hUbzF.d.mts","names":[],"sources":["../../../../3-extensions/sqlite/dist/sqlite-0-P_ooKZ.d.mts"],"mappings":";;;;;;;;;;;KAUK,aAAa,kBAAkB,SAAS,eAAe,GAAG,kBAAkB;KAC5E,aAAa,kBAAkB,SAAS,eAAe,g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