@prisma/orm-postgres 8.0.0-rc.11-dev.10 → 8.0.0-rc.11-dev.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{postgres-CBDyBUe9-Dg4ZOUYS.d.mts → postgres-B-ZPMR9y-gRfTiPA0.d.mts} +6 -6
- package/dist/{postgres-CBDyBUe9-Dg4ZOUYS.d.mts.map → postgres-B-ZPMR9y-gRfTiPA0.d.mts.map} +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +23 -20
- package/dist/runtime.mjs.map +1 -1
- package/dist/serverless.d.mts +1 -1
- package/dist/static.d.mts +1 -1
- package/package.json +9 -9
- package/skills/prisma-8/SKILL.md +1 -1
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +24 -1
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +52 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { EnumAccessor, EnumEntriesToAccessors, NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
|
|
2
|
-
import { BindSiteParams, Declaration, ExecutionContext, ParamsFromDeclaration,
|
|
3
|
-
import { orm } from "@prisma/orm-family-sql/orm-client";
|
|
2
|
+
import { BindSiteParams, Declaration, ExecutionContext, ParamsFromDeclaration, Runtime, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor, TransactionContext, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
|
|
3
|
+
import { PreparedFrom, orm } from "@prisma/orm-family-sql/orm-client";
|
|
4
4
|
import { Client, Pool } from "pg";
|
|
5
5
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
6
6
|
import { ExtractCodecTypes, SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
7
7
|
import { Db, RawLane } from "@prisma/orm-family-sql/builder/types";
|
|
8
8
|
import { CodecTypesBase } from "@prisma/orm-family-sql/relational-core/expression";
|
|
9
|
-
import { SqlQueryPlan } from "@prisma/orm-family-sql/relational-core/plan";
|
|
10
|
-
//#region ../../../3-extensions/postgres/dist/postgres-
|
|
9
|
+
import { Preparable, SqlQueryPlan } from "@prisma/orm-family-sql/relational-core/plan";
|
|
10
|
+
//#region ../../../3-extensions/postgres/dist/postgres-B-ZPMR9y.d.mts
|
|
11
11
|
//#region src/runtime/binding.d.ts
|
|
12
12
|
declare const isPgPool: (pg: Pool | Client) => pg is Pool;
|
|
13
13
|
declare const isPgClient: (pg: Pool | Client) => pg is Client;
|
|
@@ -91,7 +91,7 @@ interface PostgresClient<TContract extends Contract<SqlStorage>> {
|
|
|
91
91
|
connect(bindingInput?: PostgresBindingInput): Promise<Runtime>;
|
|
92
92
|
runtime(): Runtime;
|
|
93
93
|
transaction<R>(fn: (tx: PostgresTransactionContext<TContract>) => PromiseLike<R>): Promise<R>;
|
|
94
|
-
prepare<D extends Declaration<CT>,
|
|
94
|
+
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>>;
|
|
95
95
|
close(): Promise<void>;
|
|
96
96
|
[Symbol.asyncDispose](): Promise<void>;
|
|
97
97
|
}
|
|
@@ -130,4 +130,4 @@ declare function postgres<TContract extends Contract<SqlStorage>>(options: Postg
|
|
|
130
130
|
declare function postgres<TContract extends Contract<SqlStorage>>(options: PostgresOptionsWithContractJson<TContract>): PostgresClient<TContract>;
|
|
131
131
|
//#endregion
|
|
132
132
|
export { PostgresOptionsBase as a, PostgresTargetId as c, isPgPool as d, postgres as f, PostgresOptions as i, buildNamespacedNativeEnums as l, PostgresBinding as n, PostgresOptionsWithContract as o, PostgresClient as r, PostgresOptionsWithContractJson as s, NamespacedNativeEnums as t, isPgClient as u };
|
|
133
|
-
//# sourceMappingURL=postgres-
|
|
133
|
+
//# sourceMappingURL=postgres-B-ZPMR9y-gRfTiPA0.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-
|
|
1
|
+
{"version":3,"file":"postgres-B-ZPMR9y-gRfTiPA0.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-B-ZPMR9y.d.mts"],"mappings":";;;;;;;;;;;cAUc,WAAW,IAAI,OAAO,WAAW,MAAM;cACvC,aAAa,IAAI,OAAO,WAAW,MAAM;KAClD;WACM;WACA;;WAEA;WACA,MAAM;;WAEN;WACA,QAAQ;;KAEd;WACM,SAAS;WACT;WACA;;WAEA;WACA;WACA;;WAEA,IAAI,OAAO;WACX;WACA;;;;iBAIM,2BAA2B,SAAS,aAAa,eAAe,eAAe;KAC3F,QAAQ,KAAK,QAAQ;KACrB,yBAAyB,OAAO;WAC1B;aACE,iBAAiB;;oBAEV,IAAI,uBAAuB,QAAQ,KAAK;KACvD;WACM;;KAEN,gBAAgB,iDAAiD,WAAW;WACtE,MAAM,QAAQ,OAAO;WACrB,OAAO,OAAO;;;;;;;;KAQpB,oBAAoB,cAAc;WAC5B,SAAS,gBAAgB;;KAE/B,6BAA6B,uBAAuB,WAAW,UAAU,QAAQ,WAAW,gBAAgB,oBAAoB,QAAQ;;;;;;;;;KASxI,sBAAsB,kBAAkB,wBAAwB,YAAY,qCAAqC,uBAAuB,6BAA6B,yBAAyB,mCAAmC;;;KAGjO;KACA,UAAU,kBAAkB,SAAS,eAAe,kBAAkB,IAAI;UACrE,2BAA2B,kBAAkB,SAAS,qBAAqB;WAC1E,KAAK,GAAG;WACR,KAAK,UAAU;WACf,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;;UAEpC,eAAe,kBAAkB,SAAS;WACzC,KAAK,GAAG;WACR,KAAK,UAAU;WACf,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;WACnC,KAAK,QAAQ;WACb,SAAS,iBAAiB;WAC1B,UAAU;WACV,OAAO,4BAA4B;EAC5C,QAAQ,eAAe,uBAAuB,QAAQ;EACtD,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,2BAA2B,eAAe,YAAY,KAAK,QAAQ;EAC3F,QAAQ,UAAU,YAAY,KAAK,UAAU,eAAe,8BAA8B,WAAW,iBAAiB,kBAAkB,YAAY,aAAa,GAAG,WAAW,QAAQ,eAAe,OAAO,IAAI,QAAQ,aAAa,sBAAsB,GAAG,KAAK;EACpQ,SAAS;GACR,OAAO,iBAAiB;;UAEjB;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf;aACE;aACA;;;UAGH;WACC,UAAU;WACV;WACA,KAAK,OAAO;;KAElB,4BAA4B,kBAAkB,SAAS,eAAe,yBAAyB;WACzF,UAAU;WACV;;KAEN,gCAAgC,kBAAkB,SAAS,eAAe,yBAAyB;WAC7F;WACA;WACA,YAAY;;KAElB,gBAAgB,kBAAkB,SAAS,eAAe,4BAA4B,aAAa,gCAAgC;;;;;;;;iBAQvH,SAAS,kBAAkB,SAAS,aAAa,SAAS,4BAA4B,aAAa,eAAe;iBAClH,SAAS,kBAAkB,SAAS,aAAa,SAAS,gCAAgC,aAAa,eAAe"}
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as PostgresOptionsBase, d as isPgPool, f as postgres, i as PostgresOptions, l as buildNamespacedNativeEnums, n as PostgresBinding, o as PostgresOptionsWithContract, r as PostgresClient, s as PostgresOptionsWithContractJson, t as NamespacedNativeEnums, u as isPgClient } from "./postgres-
|
|
1
|
+
import { a as PostgresOptionsBase, d as isPgPool, f as postgres, i as PostgresOptions, l as buildNamespacedNativeEnums, n as PostgresBinding, o as PostgresOptionsWithContract, r as PostgresClient, s as PostgresOptionsWithContractJson, t as NamespacedNativeEnums, u as isPgClient } from "./postgres-B-ZPMR9y-gRfTiPA0.mjs";
|
|
2
2
|
import { Runtime, SqlRuntimeBase } from "@prisma/orm-family-sql/runtime";
|
|
3
3
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
4
4
|
import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
package/dist/runtime.mjs
CHANGED
|
@@ -7,9 +7,10 @@ import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
|
7
7
|
import { sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
8
8
|
import { createExecutionContext, createSqlExecutionStack, withTransaction } from "@prisma/orm-family-sql/runtime";
|
|
9
9
|
import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-postgres/target/runtime";
|
|
10
|
+
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
10
11
|
import postgresDriver, { suppressIdleConnectionErrors } from "@prisma/orm-target-postgres/driver/runtime";
|
|
11
12
|
import { instantiateExecutionStack } from "@prisma/orm-framework/components/execution";
|
|
12
|
-
import { orm } from "@prisma/orm-family-sql/orm-client";
|
|
13
|
+
import { orm, prepareQuery } from "@prisma/orm-family-sql/orm-client";
|
|
13
14
|
import { Pool } from "pg";
|
|
14
15
|
//#region ../../../3-extensions/postgres/dist/runtime.mjs
|
|
15
16
|
const isPgPool = (pg) => "totalCount" in pg && "idleCount" in pg && "waitingCount" in pg;
|
|
@@ -77,7 +78,7 @@ function hasContractJson(options) {
|
|
|
77
78
|
const contractSerializer = new PostgresContractSerializer();
|
|
78
79
|
function resolveContract(options) {
|
|
79
80
|
const contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);
|
|
80
|
-
return contractSerializer.deserializeContract(contractJson);
|
|
81
|
+
return blindCast(contractSerializer.deserializeContract(contractJson));
|
|
81
82
|
}
|
|
82
83
|
function toRuntimeBinding(binding, options) {
|
|
83
84
|
if (binding.kind !== "url") return binding;
|
|
@@ -159,22 +160,26 @@ function postgres(options) {
|
|
|
159
160
|
});
|
|
160
161
|
return runtimeInstance;
|
|
161
162
|
};
|
|
163
|
+
const orm$1 = orm({
|
|
164
|
+
runtime: {
|
|
165
|
+
query(plan) {
|
|
166
|
+
return getRuntime().query(plan);
|
|
167
|
+
},
|
|
168
|
+
execute(plan) {
|
|
169
|
+
return getRuntime().execute(plan);
|
|
170
|
+
},
|
|
171
|
+
connection() {
|
|
172
|
+
return getRuntime().connection();
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
context
|
|
176
|
+
});
|
|
177
|
+
function prepare(declaration, callback) {
|
|
178
|
+
return prepareQuery(getRuntime(), declaration, callback);
|
|
179
|
+
}
|
|
162
180
|
return {
|
|
163
181
|
sql: sql$1,
|
|
164
|
-
orm: orm
|
|
165
|
-
runtime: {
|
|
166
|
-
query(plan) {
|
|
167
|
-
return getRuntime().query(plan);
|
|
168
|
-
},
|
|
169
|
-
execute(plan) {
|
|
170
|
-
return getRuntime().execute(plan);
|
|
171
|
-
},
|
|
172
|
-
connection() {
|
|
173
|
-
return getRuntime().connection();
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
context
|
|
177
|
-
}),
|
|
182
|
+
orm: orm$1,
|
|
178
183
|
enums,
|
|
179
184
|
nativeEnums,
|
|
180
185
|
raw: rawSqlTag,
|
|
@@ -201,9 +206,7 @@ function postgres(options) {
|
|
|
201
206
|
runtime() {
|
|
202
207
|
return getRuntime();
|
|
203
208
|
},
|
|
204
|
-
prepare
|
|
205
|
-
return getRuntime().prepare(declaration, (params) => callback(sql$1, params));
|
|
206
|
-
},
|
|
209
|
+
prepare,
|
|
207
210
|
transaction(fn) {
|
|
208
211
|
return withTransaction(getRuntime(), (txCtx) => {
|
|
209
212
|
const rawCodecInferer = stack.adapter.rawCodecInferer;
|
|
@@ -222,7 +225,7 @@ function postgres(options) {
|
|
|
222
225
|
},
|
|
223
226
|
context
|
|
224
227
|
});
|
|
225
|
-
return fn(Object.assign(Object.create(txCtx), {
|
|
228
|
+
return fn(Object.assign(castAs(Object.create(txCtx)), {
|
|
226
229
|
sql: txSql,
|
|
227
230
|
orm: txOrm,
|
|
228
231
|
enums,
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DBYpkrmX.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-GybTEgP4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm } from \"@internal/sql-orm-client\";\nimport { createExecutionContext, createSqlExecutionStack, withTransaction } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Pool } from \"pg\";\n//#region src/runtime/binding.ts\nconst isPgPool = (pg) => \"totalCount\" in pg && \"idleCount\" in pg && \"waitingCount\" in pg;\nconst isPgClient = (pg) => \"escapeIdentifier\" in pg && \"escapeLiteral\" in pg;\nfunction validatePostgresUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a non-empty string\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"empty url\"\n\t} });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a valid URL\", { meta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unparseable url\"\n\t\t} });\n\t}\n\tif (parsed.protocol !== \"postgres:\" && parsed.protocol !== \"postgresql:\") throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must use postgres:// or postgresql://\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t} });\n\treturn trimmed;\n}\nfunction resolvePostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) !== 1) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, or pg\", {\n\t\tfix: \"Pass exactly one of `binding`, `url`, or `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"zero or multiple binding inputs\"\n\t\t}\n\t});\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) return {\n\t\tkind: \"url\",\n\t\turl: validatePostgresUrl(options.url)\n\t};\n\tconst pgBinding = options.pg;\n\tif (pgBinding === void 0) throw new InternalError(\"Invariant violation: expected pg binding after validation\");\n\tif (isPgPool(pgBinding)) return {\n\t\tkind: \"pgPool\",\n\t\tpool: pgBinding\n\t};\n\tif (isPgClient(pgBinding)) return {\n\t\tkind: \"pgClient\",\n\t\tclient: pgBinding\n\t};\n\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Unable to determine pg binding type from pg input; use binding with explicit kind\", {\n\t\tfix: \"Pass `binding: { kind: \\\"pgPool\\\", pool }` or `binding: { kind: \\\"pgClient\\\", client }` instead of `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unrecognizable pg object\"\n\t\t}\n\t});\n}\nfunction resolveOptionalPostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) === 0) return;\n\treturn resolvePostgresBinding(options);\n}\n//#endregion\n//#region src/runtime/postgres.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn contractSerializer.deserializeContract(contractJson);\n}\nfunction toRuntimeBinding(binding, options) {\n\tif (binding.kind !== \"url\") return binding;\n\treturn {\n\t\tkind: \"pgPool\",\n\t\tpool: suppressIdleConnectionErrors(new Pool({\n\t\t\tconnectionString: binding.url,\n\t\t\tconnectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,\n\t\t\tidleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4\n\t\t}))\n\t};\n}\nfunction postgres(options) {\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalPostgresBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\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(\"Postgres runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconst runtimeBinding = toRuntimeBinding(resolvedBinding, options);\n\t\tif (resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\") {\n\t\t\tconst pool = runtimeBinding.pool;\n\t\t\tlet disposed = false;\n\t\t\townedDispose = async () => {\n\t\t\t\tif (disposed) return;\n\t\t\t\tdisposed = true;\n\t\t\t\tawait pool.end().then(() => void 0);\n\t\t\t};\n\t\t}\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedDispose?.().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\twhy: \"close() was called on this client.\",\n\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\tmeta: { extension: \"postgres\" }\n\t\t});\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({ cursor: { disabled: true } });\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new PostgresRuntimeImpl({\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});\n\t\treturn runtimeInstance;\n\t};\n\treturn {\n\t\tsql: sql$1,\n\t\torm: orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn getRuntime().query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t\t},\n\t\t\t\tconnection() {\n\t\t\t\t\treturn getRuntime().connection();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcontext\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\t\twhy: \"close() was called on this client.\",\n\t\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (driverConnected || connectPromise) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client already connected\", {\n\t\t\t\tfix: \"Call connect() at most once per client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (bindingInput !== void 0) binding = resolvePostgresBinding(bindingInput);\n\t\t\tif (binding === void 0) throw postgresError(\"RUNTIME.BINDING_MISSING\", \"Postgres binding not configured. Pass url/pg/binding to postgres(...) or call db.connect({ ... }).\", { meta: { extension: \"postgres\" } });\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(declaration, callback) {\n\t\t\treturn getRuntime().prepare(declaration, (params) => callback(sql$1, params));\n\t\t},\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(getRuntime(), (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSql = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t});\n\t\t\t\tconst txOrm = 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},\n\t\t\t\t\tcontext\n\t\t\t\t});\n\t\t\t\treturn fn(Object.assign(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\tnativeEnums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\tawait ownedDispose?.();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,YAAY,OAAO,gBAAgB,MAAM,eAAe,MAAM,kBAAkB;AACtF,MAAM,cAAc,OAAO,sBAAsB,MAAM,mBAAmB;AAC1E,SAAS,oBAAoB,KAAK;CACjC,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,cAAc,2BAA2B,2CAA2C,EAAE,MAAM;EAC3H,WAAW;EACX,QAAQ;CACT,EAAE,CAAC;CACH,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,cAAc,2BAA2B,oCAAoC,EAAE,MAAM;GAC1F,WAAW;GACX,QAAQ;EACT,EAAE,CAAC;CACJ;CACA,IAAI,OAAO,aAAa,eAAe,OAAO,aAAa,eAAe,MAAM,cAAc,2BAA2B,sDAAsD,EAAE,MAAM;EACtL,WAAW;EACX,QAAQ;EACR,UAAU,OAAO;CAClB,EAAE,CAAC;CACH,OAAO;AACR;AACA,SAAS,uBAAuB,SAAS;CACxC,IAAI,OAAO,QAAQ,YAAY,KAAK,CAAC,IAAI,OAAO,QAAQ,QAAQ,KAAK,CAAC,IAAI,OAAO,QAAQ,OAAO,KAAK,CAAC,MAAM,GAAG,MAAM,cAAc,2BAA2B,kDAAkD;EAC/M,KAAK;EACL,MAAM;GACL,WAAW;GACX,QAAQ;EACT;CACD,CAAC;CACD,IAAI,QAAQ,YAAY,KAAK,GAAG,OAAO,QAAQ;CAC/C,IAAI,QAAQ,QAAQ,KAAK,GAAG,OAAO;EAClC,MAAM;EACN,KAAK,oBAAoB,QAAQ,GAAG;CACrC;CACA,M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;IACtC,MAAM,QAAQ,IAAI;KACjB;KACA;IACD,CAAC;IACD,MAAM,QAAQ,IAAI;KACjB,SAAS;MACR,MAAM,MAAM;OACX,OAAO,MAAM,MAAM,IAAI;MACxB;MACA,QAAQ,MAAM;OACb,OAAO,MAAM,QAAQ,IAAI;MAC1B;KACD;KACA;IACD,CAAC;IACD,OAAO,GAAG,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;KAC7C,KAAK;KACL,KAAK;KACL;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,MAAM,QAAQ;GACb,IAAI,QAAQ;GACZ,SAAS;GACT,MAAM,gBAAgB,YAAY,KAAK,CAAC;GACxC,MAAM,eAAe;EACtB;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DBYpkrmX.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-GybTEgP4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { createExecutionContext, createSqlExecutionStack, withTransaction } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { Pool } from \"pg\";\n//#region src/runtime/binding.ts\nconst isPgPool = (pg) => \"totalCount\" in pg && \"idleCount\" in pg && \"waitingCount\" in pg;\nconst isPgClient = (pg) => \"escapeIdentifier\" in pg && \"escapeLiteral\" in pg;\nfunction validatePostgresUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a non-empty string\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"empty url\"\n\t} });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a valid URL\", { meta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unparseable url\"\n\t\t} });\n\t}\n\tif (parsed.protocol !== \"postgres:\" && parsed.protocol !== \"postgresql:\") throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must use postgres:// or postgresql://\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t} });\n\treturn trimmed;\n}\nfunction resolvePostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) !== 1) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, or pg\", {\n\t\tfix: \"Pass exactly one of `binding`, `url`, or `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"zero or multiple binding inputs\"\n\t\t}\n\t});\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) return {\n\t\tkind: \"url\",\n\t\turl: validatePostgresUrl(options.url)\n\t};\n\tconst pgBinding = options.pg;\n\tif (pgBinding === void 0) throw new InternalError(\"Invariant violation: expected pg binding after validation\");\n\tif (isPgPool(pgBinding)) return {\n\t\tkind: \"pgPool\",\n\t\tpool: pgBinding\n\t};\n\tif (isPgClient(pgBinding)) return {\n\t\tkind: \"pgClient\",\n\t\tclient: pgBinding\n\t};\n\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Unable to determine pg binding type from pg input; use binding with explicit kind\", {\n\t\tfix: \"Pass `binding: { kind: \\\"pgPool\\\", pool }` or `binding: { kind: \\\"pgClient\\\", client }` instead of `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unrecognizable pg object\"\n\t\t}\n\t});\n}\nfunction resolveOptionalPostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) === 0) return;\n\treturn resolvePostgresBinding(options);\n}\n//#endregion\n//#region src/runtime/postgres.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn blindCast(contractSerializer.deserializeContract(contractJson));\n}\nfunction toRuntimeBinding(binding, options) {\n\tif (binding.kind !== \"url\") return binding;\n\treturn {\n\t\tkind: \"pgPool\",\n\t\tpool: suppressIdleConnectionErrors(new Pool({\n\t\t\tconnectionString: binding.url,\n\t\t\tconnectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,\n\t\t\tidleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4\n\t\t}))\n\t};\n}\nfunction postgres(options) {\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalPostgresBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\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(\"Postgres runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconst runtimeBinding = toRuntimeBinding(resolvedBinding, options);\n\t\tif (resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\") {\n\t\t\tconst pool = runtimeBinding.pool;\n\t\t\tlet disposed = false;\n\t\t\townedDispose = async () => {\n\t\t\t\tif (disposed) return;\n\t\t\t\tdisposed = true;\n\t\t\t\tawait pool.end().then(() => void 0);\n\t\t\t};\n\t\t}\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedDispose?.().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\twhy: \"close() was called on this client.\",\n\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\tmeta: { extension: \"postgres\" }\n\t\t});\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({ cursor: { disabled: true } });\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new PostgresRuntimeImpl({\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});\n\t\treturn runtimeInstance;\n\t};\n\tconst orm$1 = orm({\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},\n\t\tcontext\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\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\t\twhy: \"close() was called on this client.\",\n\t\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (driverConnected || connectPromise) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client already connected\", {\n\t\t\t\tfix: \"Call connect() at most once per client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (bindingInput !== void 0) binding = resolvePostgresBinding(bindingInput);\n\t\t\tif (binding === void 0) throw postgresError(\"RUNTIME.BINDING_MISSING\", \"Postgres binding not configured. Pass url/pg/binding to postgres(...) or call db.connect({ ... }).\", { meta: { extension: \"postgres\" } });\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\treturn withTransaction(getRuntime(), (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSql = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t});\n\t\t\t\tconst txOrm = 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},\n\t\t\t\t\tcontext\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\tnativeEnums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\tawait ownedDispose?.();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,YAAY,OAAO,gBAAgB,MAAM,eAAe,MAAM,kBAAkB;AACtF,MAAM,cAAc,OAAO,sBAAsB,MAAM,mBAAmB;AAC1E,SAAS,oBAAoB,KAAK;CACjC,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,cAAc,2BAA2B,2CAA2C,EAAE,MAAM;EAC3H,WAAW;EACX,QAAQ;CACT,EAAE,CAAC;CACH,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,cAAc,2BAA2B,oCAAoC,EAAE,MAAM;GAC1F,WAAW;GACX,QAAQ;EACT,EAAE,CAAC;CACJ;CACA,IAAI,OAAO,aAAa,eAAe,OAAO,aAAa,eAAe,MAA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,EAAE,WAAW,WAAW;GAC/B,CAAC;GACD,IAAI,mBAAmB,gBAAgB,MAAM,cAAc,4BAA4B,qCAAqC;IAC3H,KAAK;IACL,MAAM,EAAE,WAAW,WAAW;GAC/B,CAAC;GACD,IAAI,iBAAiB,KAAK,GAAG,UAAU,uBAAuB,YAAY;GAC1E,IAAI,YAAY,KAAK,GAAG,MAAM,cAAc,2BAA2B,sGAAsG,EAAE,MAAM,EAAE,WAAW,WAAW,EAAE,CAAC;GAChN,MAAM,UAAU,WAAW;GAC3B,IAAI,iBAAiB,OAAO;GAC5B,MAAM,cAAc,OAAO;GAC3B,OAAO;EACR;EACA,UAAU;GACT,OAAO,WAAW;EACnB;EACA;EACA,YAAY,IAAI;GACf,OAAO,gBAAgB,WAAW,IAAI,UAAU;IAC/C,MAAM,kBAAkB,MAAM,QAAQ;IACtC,MAAM,QAAQ,IAAI;KACjB;KACA;IACD,CAAC;IACD,MAAM,QAAQ,IAAI;KACjB,SAAS;MACR,MAAM,MAAM;OACX,OAAO,MAAM,MAAM,IAAI;MACxB;MACA,QAAQ,MAAM;OACb,OAAO,MAAM,QAAQ,IAAI;MAC1B;KACD;KACA;IACD,CAAC;IACD,OAAO,GAAG,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC,GAAG;KACrD,KAAK;KACL,KAAK;KACL;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,MAAM,QAAQ;GACb,IAAI,QAAQ;GACZ,SAAS;GACT,MAAM,gBAAgB,YAAY,KAAK,CAAC;GACxC,MAAM,eAAe;EACtB;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
package/dist/serverless.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as PostgresTargetId } from "./postgres-
|
|
1
|
+
import { c as PostgresTargetId } from "./postgres-B-ZPMR9y-gRfTiPA0.mjs";
|
|
2
2
|
import { ExecutionContext, Runtime, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
|
|
3
3
|
import { PostgresDriverCreateOptions } from "@prisma/orm-target-postgres/driver/runtime";
|
|
4
4
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
package/dist/static.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-
|
|
1
|
+
import { c as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-B-ZPMR9y-gRfTiPA0.mjs";
|
|
2
2
|
import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
|
|
3
3
|
import { ExecutionContext, SqlRuntimeExtensionDescriptor } from "@prisma/orm-family-sql/runtime";
|
|
4
4
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/orm-postgres",
|
|
3
|
-
"version": "8.0.0-rc.11-dev.
|
|
3
|
+
"version": "8.0.0-rc.11-dev.12",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
"skills"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@prisma/orm-family-sql": "8.0.0-rc.11-dev.
|
|
14
|
-
"@prisma/orm-framework": "8.0.0-rc.11-dev.
|
|
15
|
-
"@prisma/orm-target-postgres": "8.0.0-rc.11-dev.
|
|
16
|
-
"@prisma/orm-toolchain": "8.0.0-rc.11-dev.
|
|
13
|
+
"@prisma/orm-family-sql": "8.0.0-rc.11-dev.12",
|
|
14
|
+
"@prisma/orm-framework": "8.0.0-rc.11-dev.12",
|
|
15
|
+
"@prisma/orm-target-postgres": "8.0.0-rc.11-dev.12",
|
|
16
|
+
"@prisma/orm-toolchain": "8.0.0-rc.11-dev.12",
|
|
17
17
|
"@types/node": "26.1.2",
|
|
18
18
|
"@types/pg": "8.20.4",
|
|
19
19
|
"pathe": "^2.0.3",
|
|
20
20
|
"pg": "8.22.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@internal/postgres": "8.0.0-rc.11-dev.
|
|
24
|
-
"@repo/tsconfig": "8.0.0-rc.11-dev.
|
|
25
|
-
"@internal/publish-surface": "8.0.0-rc.11-dev.
|
|
26
|
-
"@repo/tsdown": "8.0.0-rc.11-dev.
|
|
23
|
+
"@internal/postgres": "8.0.0-rc.11-dev.12",
|
|
24
|
+
"@repo/tsconfig": "8.0.0-rc.11-dev.12",
|
|
25
|
+
"@internal/publish-surface": "8.0.0-rc.11-dev.12",
|
|
26
|
+
"@repo/tsdown": "8.0.0-rc.11-dev.12",
|
|
27
27
|
"tsdown": "0.22.14",
|
|
28
28
|
"typescript": "5.9.3",
|
|
29
29
|
"vitest": "5.0.0-rc.2"
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
---
|
|
2
2
|
from: 8.0.0-rc.11
|
|
3
3
|
to: 8.0.0-rc.12
|
|
4
|
-
|
|
4
|
+
# contract.d.ts now orders every collection the way contract.json does; a re-emit reorders, nothing else.
|
|
5
|
+
changes:
|
|
6
|
+
- id: params-only-sql-facade-prepare
|
|
7
|
+
summary: Replace injected SQL-builder preparation callbacks with params-only callbacks and lexical facade SQL access.
|
|
5
8
|
---
|
|
9
|
+
|
|
10
|
+
## `params-only-sql-facade-prepare`
|
|
11
|
+
|
|
12
|
+
Find calls to `prepare(declaration, callback)` on clients created by the Postgres or SQLite facade (`@prisma/orm-postgres/runtime`, `@prisma/orm-sqlite/runtime`, or their `@internal/postgres/runtime` and `@internal/sqlite/runtime` counterparts). Resolve the receiver and callback rather than rewriting every method named `prepare`: native SQLite `database.prepare(sql)` and SQL runtime's existing params-only preparation are different APIs and must remain unchanged.
|
|
13
|
+
|
|
14
|
+
Change callbacks from `(sql, params) => ...` to `(params) => ...`. Replace references bound to the removed `sql` callback argument with the same facade receiver's lexical `.sql` property. Preserve the params argument's name, declaration, SQL chain, row selection, filters and invocation target/options. For extracted callbacks, capture the same client in the enclosing scope; do not capture an invocation target or evaluate the callback twice. Update explicit callback type annotations to accept only the placeholder-params argument.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// Before
|
|
18
|
+
const query = await db.prepare({ id: 'pg/int4@1' }, (sql, params) =>
|
|
19
|
+
sql.public.users.select('id').where((f, fns) => fns.eq(f.id, params.id)).build(),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// After
|
|
23
|
+
const query = await db.prepare({ id: 'pg/int4@1' }, (params) =>
|
|
24
|
+
db.sql.public.users.select('id').where((f, fns) => fns.eq(f.id, params.id)).build(),
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Apply the same translation to SQLite's flat SQL facade (`sql.users` becomes `db.sql.users`), retaining its existing codec ids. Keep `.query(target, params, options?)` and SQL statistics `.execute(target, params, options?)` calls unchanged. Do not rewrite historical release notes, applied upgrade recipes, generated contracts or tests as part of this source translation.
|
package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
---
|
|
2
2
|
from: 8.0.0-rc.11
|
|
3
3
|
to: 8.0.0-rc.12
|
|
4
|
-
|
|
4
|
+
# contract.d.ts now orders every collection the way contract.json does; a re-emit reorders, nothing else.
|
|
5
|
+
changes:
|
|
6
|
+
- id: expression-codec-on-return-type
|
|
7
|
+
summary: Move custom expression wrapper codec metadata to returnType.codec and remove the separate ExpressionImpl codec argument.
|
|
8
|
+
- id: shared-preparable-envelope
|
|
9
|
+
summary: Type ORM preparation descriptions with the shared compositional Preparable protocol and pass their contained plan to SQL runtime.
|
|
10
|
+
- id: params-only-sql-facade-prepare
|
|
11
|
+
summary: Replace injected SQL-builder preparation callbacks with params-only callbacks and lexical facade SQL access.
|
|
12
|
+
- id: preserve-prepared-reference-nullability
|
|
13
|
+
summary: Preserve declaration nullability when constructing or cloning PreparedParamRef AST nodes.
|
|
14
|
+
- id: preserve-orm-pagination-expressions
|
|
15
|
+
summary: Preserve expression-valued limit and offset when consuming ORM CollectionState.
|
|
5
16
|
---
|
|
17
|
+
|
|
18
|
+
## `expression-codec-on-return-type`
|
|
19
|
+
|
|
20
|
+
For custom SQL `Expression` wrappers, move an existing top-level `codec` reference into `returnType.codec`, preserving the complete reference including `typeParams`. Read metadata through `codecOf(expression)` or `expression.returnType.codec`, not `expression.codec`. Keep the existing `returnType.codecId` and nullability; wrappers without an explicit reference continue to use the declared codec id fallback. Do not remove or relocate unrelated codec fields on AST nodes, storage declarations, runtime bindings or scope descriptors.
|
|
21
|
+
|
|
22
|
+
For direct `ExpressionImpl` construction, change `new ExpressionImpl(ast, returnType, codec, projectionAst)` to `new ExpressionImpl(ast, { ...returnType, codec }, projectionAst)`. When the removed codec argument was `undefined`, keep `returnType` unchanged and move any fourth projection argument to the third position. Preserve projection-only lowering separately from predicate and ordering ASTs.
|
|
23
|
+
|
|
24
|
+
## `shared-preparable-envelope`
|
|
25
|
+
|
|
26
|
+
Replace imports of SQL ORM client's `RowQuery` with `Preparable` from `@internal/sql-relational-core/plan`. Supply both type arguments as `Preparable<DbRow, Result>` and return `{ plan, consume }`, where `plan` is a `SqlQueryPlan<DbRow>` and `consume` returns the complete ORM result. Read AST, parameters and metadata through `description.plan`; pass `description.plan` rather than the description to SQL runtime preparation. Keep the consumer's mapping setup outside invocation-time code.
|
|
27
|
+
|
|
28
|
+
For integrations accepting both SQL and ORM callbacks, constrain the callback result with `Q extends SqlQueryPlan | Preparable<unknown, unknown>` and use SQL ORM client's `prepareQuery` and `PreparedFrom<Params, Q>`. Preserve the concrete `Q` so SQL row/statistics types and ORM all/first result types remain distinct. Do not add identity consumers to plain SQL plans.
|
|
29
|
+
|
|
30
|
+
## `preserve-orm-pagination-expressions`
|
|
31
|
+
|
|
32
|
+
Update extension code that reads or mirrors ORM `CollectionState.limit` and `offset`: these fields now contain relational-core `LimitOffsetValue | undefined` (`number | AnyExpression | undefined`), not just numbers. Forward them unchanged to the existing `SelectAst.withLimit` and `withOffset` methods. If processing numeric literals separately, narrow with `typeof value === 'number'`; preserve expression nodes rather than coercing, serializing or boxing them as literal parameters. Test presence against `undefined`, not truthiness, so zero limits and offsets survive. Keep grouped post-aggregation paging's separate numeric state unchanged.
|
|
33
|
+
|
|
34
|
+
## `preserve-prepared-reference-nullability`
|
|
35
|
+
|
|
36
|
+
Find code that constructs or clones `PreparedParamRef` from SQL relational-core's AST exports. When constructing a reference from a nullable declaration, pass its declared boolean nullability as the third argument to `PreparedParamRef.of(name, codec, nullable)` or `new PreparedParamRef(name, codec, nullable)`. When cloning an existing reference, preserve `ref.nullable`: `PreparedParamRef.of(ref.name, ref.codec, ref.nullable)`. Keep the name and complete codec reference unchanged, and keep constructing frozen class instances rather than spreading nodes into plain objects. Do not derive this flag from a column's nullability or an invocation's bound value.
|
|
37
|
+
|
|
38
|
+
## `params-only-sql-facade-prepare`
|
|
39
|
+
|
|
40
|
+
Find calls to `prepare(declaration, callback)` on clients created by the Postgres or SQLite facade (`@prisma/orm-postgres/runtime`, `@prisma/orm-sqlite/runtime`, or their `@internal/postgres/runtime` and `@internal/sqlite/runtime` counterparts). Resolve the receiver and callback rather than rewriting every method named `prepare`: native SQLite `database.prepare(sql)` and SQL runtime's existing params-only preparation are different APIs and must remain unchanged.
|
|
41
|
+
|
|
42
|
+
Change callbacks from `(sql, params) => ...` to `(params) => ...`. Replace references bound to the removed `sql` callback argument with the same facade receiver's lexical `.sql` property. Preserve the params argument's name, declaration, SQL chain, row selection, filters and invocation target/options. For extracted callbacks, capture the same client in the enclosing scope; do not capture an invocation target or evaluate the callback twice. Update explicit callback type annotations to accept only the placeholder-params argument.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// Before
|
|
46
|
+
const query = await db.prepare({ id: 'pg/int4@1' }, (sql, params) =>
|
|
47
|
+
sql.public.users.select('id').where((f, fns) => fns.eq(f.id, params.id)).build(),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// After
|
|
51
|
+
const query = await db.prepare({ id: 'pg/int4@1' }, (params) =>
|
|
52
|
+
db.sql.public.users.select('id').where((f, fns) => fns.eq(f.id, params.id)).build(),
|
|
53
|
+
);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Apply the same translation to SQLite's flat SQL facade (`sql.users` becomes `db.sql.users`), retaining its existing codec ids. Keep `.query(target, params, options?)` and SQL statistics `.execute(target, params, options?)` calls unchanged. Do not rewrite historical release notes, applied upgrade recipes, generated contracts or tests as part of this source translation.
|