@prisma/orm-postgres 8.0.0-rc.18-dev.34 → 8.0.0-rc.18-dev.35
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/{contract-from-json-DZ5ycGcM-VMuAQZ88.mjs → contract-from-json-Ds-MzzpK-C7YoiEiu.mjs} +3 -3
- package/dist/{contract-from-json-DZ5ycGcM-VMuAQZ88.mjs.map → contract-from-json-Ds-MzzpK-C7YoiEiu.mjs.map} +1 -1
- package/dist/internal__transaction-members.d.mts +2 -0
- package/dist/internal__transaction-members.mjs +2 -0
- package/dist/internal__validate-contract.mjs +1 -1
- package/dist/postgres-members-CXcalHlb-DswHs7AN.d.mts +46 -0
- package/dist/postgres-members-CXcalHlb-DswHs7AN.d.mts.map +1 -0
- package/dist/postgres-members-v66adEuo-PojCqobl.mjs +84 -0
- package/dist/postgres-members-v66adEuo-PojCqobl.mjs.map +1 -0
- package/dist/postgres-options-DWx_G43W-gniqIw7c.d.mts +27 -0
- package/dist/postgres-options-DWx_G43W-gniqIw7c.d.mts.map +1 -0
- package/dist/{postgres-runtime-BLsIqXbA-LizaG8Vd.mjs → postgres-runtime-BzttbbWZ-BKQVfbfA.mjs} +5 -63
- package/dist/postgres-runtime-BzttbbWZ-BKQVfbfA.mjs.map +1 -0
- package/dist/{postgres-static-BpQ18Rm3-B4IlOU06.mjs → postgres-static-D9ySwPXH-CiTRi24U.mjs} +5 -5
- package/dist/{postgres-static-BpQ18Rm3-B4IlOU06.mjs.map → postgres-static-D9ySwPXH-CiTRi24U.mjs.map} +1 -1
- package/dist/{postgres-static-CWKc2Lc4-vwO-rlxR.d.mts → postgres-static-_ysb7j8c-vhfnY6t8.d.mts} +2 -3
- package/dist/postgres-static-_ysb7j8c-vhfnY6t8.d.mts.map +1 -0
- package/dist/runtime.d.mts +5 -4
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +5 -4
- package/dist/runtime.mjs.map +1 -1
- package/dist/serverless.d.mts +3 -2
- package/dist/serverless.d.mts.map +1 -1
- package/dist/serverless.mjs +5 -4
- package/dist/serverless.mjs.map +1 -1
- package/dist/static.d.mts +1 -1
- package/dist/static.mjs +2 -2
- package/package.json +9 -8
- package/skills/prisma-8/SKILL.md +1 -1
- package/skills/prisma-8/references/debug.md +1 -1
- package/skills/prisma-8/references/queries-postgres.md +1 -1
- package/skills/prisma-8/references/queries.md +4 -4
- package/skills/prisma-8/references/runtime.md +18 -5
- package/skills/prisma-8/references/supabase.md +2 -2
- package/dist/postgres-options-CbQMRzbY-D-8O8RB7.d.mts +0 -56
- package/dist/postgres-options-CbQMRzbY-D-8O8RB7.d.mts.map +0 -1
- package/dist/postgres-runtime-BLsIqXbA-LizaG8Vd.mjs.map +0 -1
- package/dist/postgres-static-CWKc2Lc4-vwO-rlxR.d.mts.map +0 -1
package/dist/{contract-from-json-DZ5ycGcM-VMuAQZ88.mjs → contract-from-json-Ds-MzzpK-C7YoiEiu.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-postgres/target/runtime";
|
|
2
2
|
import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
|
|
3
|
-
//#region ../../../3-extensions/postgres/dist/contract-from-json-
|
|
4
|
-
var version = "8.0.0-rc.18-dev.
|
|
3
|
+
//#region ../../../3-extensions/postgres/dist/contract-from-json-Ds-MzzpK.mjs
|
|
4
|
+
var version = "8.0.0-rc.18-dev.35";
|
|
5
5
|
const serializer = new PostgresContractSerializer();
|
|
6
6
|
const validator = `${postgresTarget.targetId}@${version}`;
|
|
7
7
|
/**
|
|
@@ -30,4 +30,4 @@ function validatePostgresContract(contract) {
|
|
|
30
30
|
//#endregion
|
|
31
31
|
export { validatePostgresContract as n, contractFromJson as t };
|
|
32
32
|
|
|
33
|
-
//# sourceMappingURL=contract-from-json-
|
|
33
|
+
//# sourceMappingURL=contract-from-json-Ds-MzzpK-C7YoiEiu.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-from-json-
|
|
1
|
+
{"version":3,"file":"contract-from-json-Ds-MzzpK-C7YoiEiu.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/contract-from-json-Ds-MzzpK.mjs"],"sourcesContent":["import postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\n//#region package.json\nvar version = \"8.0.0-rc.18-dev.35\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new PostgresContractSerializer();\nconst validator = `${postgresTarget.targetId}@${version}`;\n/**\n* Validates an emitted Postgres `contract.json` and returns it as the contract type the\n* application names, ready to pass to `postgres({ contract })` and the other Postgres clients.\n* Clients built 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}\n/** Validates a contract value for a Postgres client, once per value. */\nfunction validatePostgresContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\nexport { validatePostgresContract as n, contractFromJson as t };\n\n//# sourceMappingURL=contract-from-json-Ds-MzzpK.mjs.map"],"mappings":";;;AAGA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,2BAA2B;AAClD,MAAM,YAAY,GAAG,eAAe,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiBhD,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;;AAEA,SAAS,yBAAyB,UAAU;CAC3C,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validatePostgresContract } from "./contract-from-json-
|
|
1
|
+
import { n as validatePostgresContract } from "./contract-from-json-Ds-MzzpK-C7YoiEiu.mjs";
|
|
2
2
|
export { validatePostgresContract };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { n as PostgresStaticContext, r as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-static-_ysb7j8c-vhfnY6t8.mjs";
|
|
2
|
+
import { ExecutionContext, Runtime, SqlExecutionStackWithDriver, TransactionContext } from "@prisma/orm-family-sql/runtime";
|
|
3
|
+
import { CollectionClasses, NoCollectionClasses, PrepareMember, orm } from "@prisma/orm-family-sql/orm-client";
|
|
4
|
+
import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
|
|
5
|
+
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
6
|
+
import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
7
|
+
import { Db, RawLane } from "@prisma/orm-family-sql/builder/types";
|
|
8
|
+
import { RawCodecInferer } from "@prisma/orm-family-sql/relational-core/expression";
|
|
9
|
+
//#region ../../../3-extensions/postgres/dist/postgres-members-CXcalHlb.d.mts
|
|
10
|
+
//#region src/runtime/postgres-members.d.ts
|
|
11
|
+
type OrmClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = ReturnType<typeof orm<TContract, TCollections>>;
|
|
12
|
+
/** The query members of a Postgres client, which its transactions and Supabase's role-bound clients offer with the same types. */
|
|
13
|
+
interface PostgresQueryMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PrepareMember<TContract> {
|
|
14
|
+
readonly sql: Db<TContract>;
|
|
15
|
+
readonly orm: OrmClient<TContract, TCollections>;
|
|
16
|
+
readonly raw: RawLane<TContract>;
|
|
17
|
+
}
|
|
18
|
+
interface PostgresTransactionContext<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends TransactionContext, PostgresQueryMembers<TContract, TCollections> {
|
|
19
|
+
readonly enums: NamespacedEnums<TContract>;
|
|
20
|
+
readonly nativeEnums: NamespacedNativeEnums<TContract>;
|
|
21
|
+
}
|
|
22
|
+
interface PostgresQueryMembersOptions<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> {
|
|
23
|
+
readonly context: ExecutionContext<TContract>;
|
|
24
|
+
readonly collections: TCollections | undefined;
|
|
25
|
+
readonly rawCodecInferer: RawCodecInferer;
|
|
26
|
+
readonly prepareRuntime: () => Runtime;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Builds the query members of a Postgres 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.
|
|
30
|
+
*/
|
|
31
|
+
declare function buildPostgresQueryMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses>(options: PostgresQueryMembersOptions<TContract, TCollections>, txCtx: TransactionContext): PostgresQueryMembers<TContract, TCollections>;
|
|
32
|
+
interface PostgresStaticMembers<TContract extends Contract<SqlStorage>> extends PostgresStaticContext<TContract> {
|
|
33
|
+
readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;
|
|
34
|
+
}
|
|
35
|
+
interface PostgresRuntimeBoundMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PrepareMember<TContract> {
|
|
36
|
+
readonly orm: OrmClient<TContract, TCollections>;
|
|
37
|
+
runtime(): Runtime;
|
|
38
|
+
transaction<R>(fn: (tx: PostgresTransactionContext<TContract, TCollections>) => PromiseLike<R>): Promise<R>;
|
|
39
|
+
}
|
|
40
|
+
interface PostgresLifecycleMembers {
|
|
41
|
+
close(): Promise<void>;
|
|
42
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { PostgresTransactionContext as a, PostgresStaticMembers as i, PostgresQueryMembers as n, buildPostgresQueryMembers as o, PostgresRuntimeBoundMembers as r, PostgresLifecycleMembers as t };
|
|
46
|
+
//# sourceMappingURL=postgres-members-CXcalHlb-DswHs7AN.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-members-CXcalHlb-DswHs7AN.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-members-CXcalHlb.d.mts"],"mappings":";;;;;;;;;;KASK,UAAU,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,kBAAkB,IAAI,WAAW;;UAExH,qBAAqB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,cAAc;WAChJ,KAAK,GAAG;WACR,KAAK,UAAU,WAAW;WAC1B,KAAK,QAAQ;;UAEd,2BAA2B,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,oBAAoB,qBAAqB,WAAW;WAC5L,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;;UAEpC,4BAA4B,kBAAkB,SAAS,aAAa,qBAAqB;WACxF,SAAS,iBAAiB;WAC1B,aAAa;WACb,iBAAiB;WACjB,sBAAsB;;;;;iBAKhB,0BAA0B,kBAAkB,SAAS,aAAa,qBAAqB,mBAAmB,SAAS,4BAA4B,WAAW,eAAe,OAAO,qBAAqB,qBAAqB,WAAW;UAC5O,sBAAsB,kBAAkB,SAAS,qBAAqB,sBAAsB;WAC3F,OAAO,4BAA4B;;UAEpC,4BAA4B,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,cAAc;WACvJ,KAAK,UAAU,WAAW;EACnC,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,2BAA2B,WAAW,kBAAkB,YAAY,KAAK,QAAQ;;UAEjG;EACR,SAAS;GACR,OAAO,iBAAiB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
2
|
+
import { activitySource, delegatingActivitySource, withTransaction, withTransactionMembers } from "@prisma/orm-family-sql/runtime";
|
|
3
|
+
import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
4
|
+
import { orm, prepareQuery } from "@prisma/orm-family-sql/orm-client";
|
|
5
|
+
//#region ../../../3-extensions/postgres/dist/postgres-members-v66adEuo.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Builds the query members of a Postgres 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.
|
|
8
|
+
*/
|
|
9
|
+
function buildPostgresQueryMembers(options, txCtx) {
|
|
10
|
+
const { context, collections, rawCodecInferer, prepareRuntime } = options;
|
|
11
|
+
return {
|
|
12
|
+
sql: sql({
|
|
13
|
+
context,
|
|
14
|
+
rawCodecInferer
|
|
15
|
+
}),
|
|
16
|
+
raw: createRawLane({
|
|
17
|
+
context,
|
|
18
|
+
rawCodecInferer
|
|
19
|
+
}),
|
|
20
|
+
orm: orm({
|
|
21
|
+
runtime: {
|
|
22
|
+
query(plan) {
|
|
23
|
+
return txCtx.query(plan);
|
|
24
|
+
},
|
|
25
|
+
execute(plan) {
|
|
26
|
+
return txCtx.execute(plan);
|
|
27
|
+
},
|
|
28
|
+
[activitySource]: delegatingActivitySource(() => txCtx)
|
|
29
|
+
},
|
|
30
|
+
context,
|
|
31
|
+
...ifDefined("collections", collections)
|
|
32
|
+
}),
|
|
33
|
+
prepare(declaration, callback) {
|
|
34
|
+
return prepareQuery(prepareRuntime(), declaration, callback);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function buildPostgresRuntimeBoundMembers(options) {
|
|
39
|
+
const { context, collections, rawCodecInferer, enums, nativeEnums, getRuntime, getRuntimeForWork } = options;
|
|
40
|
+
const orm$1 = orm({
|
|
41
|
+
runtime: {
|
|
42
|
+
query(plan) {
|
|
43
|
+
return getRuntimeForWork().query(plan);
|
|
44
|
+
},
|
|
45
|
+
execute(plan) {
|
|
46
|
+
return getRuntimeForWork().execute(plan);
|
|
47
|
+
},
|
|
48
|
+
connection() {
|
|
49
|
+
return getRuntimeForWork().connection();
|
|
50
|
+
},
|
|
51
|
+
[activitySource]: delegatingActivitySource(() => getRuntimeForWork())
|
|
52
|
+
},
|
|
53
|
+
context,
|
|
54
|
+
...ifDefined("collections", collections)
|
|
55
|
+
});
|
|
56
|
+
function prepare(declaration, callback) {
|
|
57
|
+
return prepareQuery(getRuntimeForWork(), declaration, callback);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
orm: orm$1,
|
|
61
|
+
runtime() {
|
|
62
|
+
return getRuntime();
|
|
63
|
+
},
|
|
64
|
+
prepare,
|
|
65
|
+
transaction(fn) {
|
|
66
|
+
return withTransaction(getRuntimeForWork(), (txCtx) => {
|
|
67
|
+
return fn(withTransactionMembers(txCtx, {
|
|
68
|
+
...buildPostgresQueryMembers({
|
|
69
|
+
context,
|
|
70
|
+
collections,
|
|
71
|
+
rawCodecInferer,
|
|
72
|
+
prepareRuntime: getRuntimeForWork
|
|
73
|
+
}, txCtx),
|
|
74
|
+
enums,
|
|
75
|
+
nativeEnums
|
|
76
|
+
}));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { buildPostgresRuntimeBoundMembers as n, buildPostgresQueryMembers as t };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=postgres-members-v66adEuo-PojCqobl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-members-v66adEuo-PojCqobl.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-members-v66adEuo.mjs"],"sourcesContent":["import { ifDefined } from \"@internal/utils/defined\";\nimport { activitySource, delegatingActivitySource, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\n//#region src/runtime/postgres-members.ts\n/**\n* Builds the query members of a Postgres 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 buildPostgresQueryMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, prepareRuntime } = options;\n\treturn {\n\t\tsql: sql({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\torm: 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\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime(), declaration, callback);\n\t\t}\n\t};\n}\nfunction buildPostgresRuntimeBoundMembers(options) {\n\tconst { context, collections, rawCodecInferer, enums, nativeEnums, getRuntime, getRuntimeForWork } = options;\n\tconst orm$1 = orm({\n\t\truntime: {\n\t\t\tquery(plan) {\n\t\t\t\treturn getRuntimeForWork().query(plan);\n\t\t\t},\n\t\t\texecute(plan) {\n\t\t\t\treturn getRuntimeForWork().execute(plan);\n\t\t\t},\n\t\t\tconnection() {\n\t\t\t\treturn getRuntimeForWork().connection();\n\t\t\t},\n\t\t\t[activitySource]: delegatingActivitySource(() => getRuntimeForWork())\n\t\t},\n\t\tcontext,\n\t\t...ifDefined(\"collections\", collections)\n\t});\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(getRuntimeForWork(), declaration, callback);\n\t}\n\treturn {\n\t\torm: orm$1,\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(getRuntimeForWork(), (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, {\n\t\t\t\t\t...buildPostgresQueryMembers({\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\tcollections,\n\t\t\t\t\t\trawCodecInferer,\n\t\t\t\t\t\tprepareRuntime: getRuntimeForWork\n\t\t\t\t\t}, txCtx),\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};\n}\n//#endregion\nexport { buildPostgresRuntimeBoundMembers as n, buildPostgresQueryMembers as t };\n\n//# sourceMappingURL=postgres-members-v66adEuo.mjs.map"],"mappings":";;;;;;;;AAQA,SAAS,0BAA0B,SAAS,OAAO;CAClD,MAAM,EAAE,SAAS,aAAa,iBAAiB,mBAAmB;CAClE,OAAO;EACN,KAAK,IAAI;GACR;GACA;EACD,CAAC;EACD,KAAK,cAAc;GAClB;GACA;EACD,CAAC;EACD,KAAK,IAAI;GACR,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;EACD,QAAQ,aAAa,UAAU;GAC9B,OAAO,aAAa,eAAe,GAAG,aAAa,QAAQ;EAC5D;CACD;AACD;AACA,SAAS,iCAAiC,SAAS;CAClD,MAAM,EAAE,SAAS,aAAa,iBAAiB,OAAO,aAAa,YAAY,sBAAsB;CACrG,MAAM,QAAQ,IAAI;EACjB,SAAS;GACR,MAAM,MAAM;IACX,OAAO,kBAAkB,CAAC,CAAC,MAAM,IAAI;GACtC;GACA,QAAQ,MAAM;IACb,OAAO,kBAAkB,CAAC,CAAC,QAAQ,IAAI;GACxC;GACA,aAAa;IACZ,OAAO,kBAAkB,CAAC,CAAC,WAAW;GACvC;IACC,iBAAiB,+BAA+B,kBAAkB,CAAC;EACrE;EACA;EACA,GAAG,UAAU,eAAe,WAAW;CACxC,CAAC;CACD,SAAS,QAAQ,aAAa,UAAU;EACvC,OAAO,aAAa,kBAAkB,GAAG,aAAa,QAAQ;CAC/D;CACA,OAAO;EACN,KAAK;EACL,UAAU;GACT,OAAO,WAAW;EACnB;EACA;EACA,YAAY,IAAI;GACf,OAAO,gBAAgB,kBAAkB,IAAI,UAAU;IACtD,OAAO,GAAG,uBAAuB,OAAO;KACvC,GAAG,0BAA0B;MAC5B;MACA;MACA;MACA,gBAAgB;KACjB,GAAG,KAAK;KACR;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;CACD;AACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { r as PostgresTargetId } from "./postgres-static-_ysb7j8c-vhfnY6t8.mjs";
|
|
2
|
+
import { Log, SqlMiddleware, SqlRuntimeExtensionDescriptor, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
|
|
3
|
+
import "@prisma/orm-target-postgres/driver/runtime";
|
|
4
|
+
//#region ../../../3-extensions/postgres/dist/postgres-options-DWx_G43W.d.mts
|
|
5
|
+
//#region src/runtime/postgres-options.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Server-side cursor for reads. Unset reads the whole result before the first row; set streams
|
|
8
|
+
* rows in batches of `batchSize`, 100 when omitted or `undefined`. A `batchSize` that is not a
|
|
9
|
+
* positive integer fails the factory call.
|
|
10
|
+
*/
|
|
11
|
+
interface PostgresCursorOptions {
|
|
12
|
+
readonly batchSize?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The options `postgres()` and `postgresServerless()` share: how queries run, not where the
|
|
16
|
+
* database is.
|
|
17
|
+
*/
|
|
18
|
+
interface PostgresExecutionOptions {
|
|
19
|
+
readonly extensions?: readonly SqlRuntimeExtensionDescriptor<PostgresTargetId>[];
|
|
20
|
+
readonly middleware?: readonly SqlMiddleware[];
|
|
21
|
+
readonly verifyMarker?: VerifyMarkerOption;
|
|
22
|
+
readonly log?: Log;
|
|
23
|
+
readonly cursor?: PostgresCursorOptions;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { PostgresExecutionOptions as n, PostgresCursorOptions as t };
|
|
27
|
+
//# sourceMappingURL=postgres-options-DWx_G43W-gniqIw7c.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-options-DWx_G43W-gniqIw7c.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-options-DWx_G43W.d.mts"],"mappings":";;;;;;;;;;UASU;WACC;;;;;;UAMD;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf,MAAM;WACN,SAAS"}
|
package/dist/{postgres-runtime-BLsIqXbA-LizaG8Vd.mjs → postgres-runtime-BzttbbWZ-BKQVfbfA.mjs}
RENAMED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { t as postgresError } from "./errors-DfWK9xep-CYOOg0sB.mjs";
|
|
2
2
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
3
3
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
4
|
+
import { SqlRuntimeBase } from "@prisma/orm-family-sql/runtime";
|
|
4
5
|
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
5
|
-
import { blindCast
|
|
6
|
-
import { SqlRuntimeBase, activitySource, delegatingActivitySource, withTransaction } from "@prisma/orm-family-sql/runtime";
|
|
7
|
-
import { sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
8
|
-
import { orm, prepareQuery } from "@prisma/orm-family-sql/orm-client";
|
|
6
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
9
7
|
import { type } from "arktype";
|
|
10
|
-
//#region ../../../3-extensions/postgres/dist/postgres-runtime-
|
|
8
|
+
//#region ../../../3-extensions/postgres/dist/postgres-runtime-BzttbbWZ.mjs
|
|
11
9
|
const isPgPool = (pg) => "totalCount" in pg && "idleCount" in pg && "waitingCount" in pg;
|
|
12
10
|
const isPgClient = (pg) => "escapeIdentifier" in pg && "escapeLiteral" in pg;
|
|
13
11
|
function validatePostgresUrl(url) {
|
|
@@ -67,62 +65,6 @@ function resolveOptionalPostgresBinding(options) {
|
|
|
67
65
|
if (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) === 0) return;
|
|
68
66
|
return resolvePostgresBinding(blindCast(options));
|
|
69
67
|
}
|
|
70
|
-
function buildPostgresRuntimeBoundMembers(options) {
|
|
71
|
-
const { context, collections, rawCodecInferer, enums, nativeEnums, getRuntime, getRuntimeForWork } = options;
|
|
72
|
-
const orm$1 = orm({
|
|
73
|
-
runtime: {
|
|
74
|
-
query(plan) {
|
|
75
|
-
return getRuntimeForWork().query(plan);
|
|
76
|
-
},
|
|
77
|
-
execute(plan) {
|
|
78
|
-
return getRuntimeForWork().execute(plan);
|
|
79
|
-
},
|
|
80
|
-
connection() {
|
|
81
|
-
return getRuntimeForWork().connection();
|
|
82
|
-
},
|
|
83
|
-
[activitySource]: delegatingActivitySource(() => getRuntimeForWork())
|
|
84
|
-
},
|
|
85
|
-
context,
|
|
86
|
-
...ifDefined("collections", collections)
|
|
87
|
-
});
|
|
88
|
-
function prepare(declaration, callback) {
|
|
89
|
-
return prepareQuery(getRuntimeForWork(), declaration, callback);
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
orm: orm$1,
|
|
93
|
-
runtime() {
|
|
94
|
-
return getRuntime();
|
|
95
|
-
},
|
|
96
|
-
prepare,
|
|
97
|
-
transaction(fn) {
|
|
98
|
-
return withTransaction(getRuntimeForWork(), (txCtx) => {
|
|
99
|
-
const txSql = sql({
|
|
100
|
-
context,
|
|
101
|
-
rawCodecInferer
|
|
102
|
-
});
|
|
103
|
-
const txOrm = orm({
|
|
104
|
-
runtime: {
|
|
105
|
-
query(plan) {
|
|
106
|
-
return txCtx.query(plan);
|
|
107
|
-
},
|
|
108
|
-
execute(plan) {
|
|
109
|
-
return txCtx.execute(plan);
|
|
110
|
-
},
|
|
111
|
-
[activitySource]: delegatingActivitySource(() => txCtx)
|
|
112
|
-
},
|
|
113
|
-
context,
|
|
114
|
-
...ifDefined("collections", collections)
|
|
115
|
-
});
|
|
116
|
-
return fn(Object.assign(castAs(Object.create(txCtx)), {
|
|
117
|
-
sql: txSql,
|
|
118
|
-
orm: txOrm,
|
|
119
|
-
enums,
|
|
120
|
-
nativeEnums
|
|
121
|
-
}));
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
68
|
/**
|
|
127
69
|
* Default time to wait for the database to accept a connection, for a client's pool and for a
|
|
128
70
|
* connection's `pg.Client`.
|
|
@@ -160,6 +102,6 @@ var PostgresRuntimeImpl = class extends SqlRuntimeBase {
|
|
|
160
102
|
}
|
|
161
103
|
};
|
|
162
104
|
//#endregion
|
|
163
|
-
export {
|
|
105
|
+
export { resolveOptionalPostgresBinding as a, toRuntimeOptions as c, isPgPool as i, validateCursorOptions as l, PostgresRuntimeImpl as n, resolvePostgresBinding as o, isPgClient as r, toDriverCursorOptions as s, DEFAULT_CONNECT_TIMEOUT_MILLIS as t, validatePostgresUrl as u };
|
|
164
106
|
|
|
165
|
-
//# sourceMappingURL=postgres-runtime-
|
|
107
|
+
//# sourceMappingURL=postgres-runtime-BzttbbWZ-BKQVfbfA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-runtime-BzttbbWZ-BKQVfbfA.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-runtime-BzttbbWZ.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { SqlRuntimeBase } from \"@internal/sql-runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { type } from \"arktype\";\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(blindCast(options));\n}\n//#endregion\n//#region src/runtime/postgres-options.ts\n/**\n* Default time to wait for the database to accept a connection, for a client's pool and for a\n* connection's `pg.Client`.\n*/\nconst DEFAULT_CONNECT_TIMEOUT_MILLIS = 2e4;\nconst cursorOptionsSchema = type({ \"batchSize?\": \"number.integer > 0 | undefined\" }).onUndeclaredKey(\"reject\");\nfunction validateCursorOptions(cursor, helper) {\n\tif (cursor === void 0) return;\n\tconst result = cursorOptionsSchema(cursor);\n\tif (result instanceof type.errors) throw postgresError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid cursor option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass cursor: {} or cursor: { batchSize: <positive integer> } to read through a server-side cursor, or leave cursor unset to read without one.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\thelper,\n\t\t\targument: \"cursor\",\n\t\t\treceived: cursor\n\t\t}\n\t});\n\treturn result;\n}\nfunction toDriverCursorOptions(cursor) {\n\treturn cursor === void 0 ? { disabled: true } : ifDefined(\"batchSize\", cursor.batchSize);\n}\nfunction toRuntimeOptions(options) {\n\treturn {\n\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t...ifDefined(\"log\", options.log)\n\t};\n}\n//#endregion\n//#region src/runtime/postgres-runtime.ts\nvar PostgresRuntimeImpl = class extends SqlRuntimeBase {\n\tgetListDecoder() {\n\t\treturn postgresTarget.listDecoder();\n\t}\n};\n//#endregion\nexport { validateCursorOptions as a, resolveOptionalPostgresBinding as c, toRuntimeOptions as i, resolvePostgresBinding as l, DEFAULT_CONNECT_TIMEOUT_MILLIS as n, isPgClient as o, toDriverCursorOptions as r, isPgPool as s, PostgresRuntimeImpl as t, validatePostgresUrl as u };\n\n//# sourceMappingURL=postgres-runtime-BzttbbWZ.mjs.map"],"mappings":";;;;;;;;AAQA,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,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,UAAU,OAAO,QAAQ,GAAG;CAChC;AACD;AAGA,IAAI,sBAAsB,cAAc,eAAe;CACtD,iBAAiB;EAChB,OAAO,eAAe,YAAY;CACnC;AACD"}
|
package/dist/{postgres-static-BpQ18Rm3-B4IlOU06.mjs → postgres-static-D9ySwPXH-CiTRi24U.mjs}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { n as validatePostgresContract } from "./contract-from-json-
|
|
1
|
+
import { n as validatePostgresContract } from "./contract-from-json-Ds-MzzpK-C7YoiEiu.mjs";
|
|
2
2
|
import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
|
|
3
|
-
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
4
|
-
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
3
|
import { createExecutionContext, createSqlExecutionStack } from "@prisma/orm-family-sql/runtime";
|
|
6
4
|
import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
5
|
+
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
6
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
7
7
|
import { buildNamespacedEnums, createEnumAccessor } from "@prisma/orm-framework/contract/enum-accessor";
|
|
8
8
|
import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
9
|
-
//#region ../../../3-extensions/postgres/dist/postgres-static-
|
|
9
|
+
//#region ../../../3-extensions/postgres/dist/postgres-static-D9ySwPXH.mjs
|
|
10
10
|
/**
|
|
11
11
|
* The accessors for one namespace's value sets, leaving out each value set whose name is a domain enum's in the same namespace: a domain enum's value set takes its enum's name and namespace, and `db.enums` holds that enum. The rest are native enum types, because `native_enum` is the only pack entity that derives a value set today. Reads plain contract data, so a `validateContract`'d JSON contract works as well as a hydrated one. A member is a value, as in `CREATE TYPE … AS ENUM ('a', 'b')`, so each value is also its own name.
|
|
12
12
|
*/
|
|
@@ -75,4 +75,4 @@ function postgresStatic(options) {
|
|
|
75
75
|
//#endregion
|
|
76
76
|
export { buildPostgresStaticContext as n, postgresStatic as r, buildNamespacedNativeEnums as t };
|
|
77
77
|
|
|
78
|
-
//# sourceMappingURL=postgres-static-
|
|
78
|
+
//# sourceMappingURL=postgres-static-D9ySwPXH-CiTRi24U.mjs.map
|
package/dist/{postgres-static-BpQ18Rm3-B4IlOU06.mjs.map → postgres-static-D9ySwPXH-CiTRi24U.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-static-
|
|
1
|
+
{"version":3,"file":"postgres-static-D9ySwPXH-CiTRi24U.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-static-D9ySwPXH.mjs"],"sourcesContent":["import { n as validatePostgresContract } from \"./contract-from-json-Ds-MzzpK.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { buildNamespacedEnums, createEnumAccessor } from \"@internal/contract/enum-accessor\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\n//#region src/runtime/native-enums.ts\n/**\n* The accessors for one namespace's value sets, leaving out each value set whose name is a domain enum's in the same namespace: a domain enum's value set takes its enum's name and namespace, and `db.enums` holds that enum. The rest are native enum types, because `native_enum` is the only pack entity that derives a value set today. Reads plain contract data, so a `validateContract`'d JSON contract works as well as a hydrated one. A member is a value, as in `CREATE TYPE … AS ENUM ('a', 'b')`, so each value is also its own name.\n*/\nfunction buildNativeEnumsMapForNamespace(storage, domain, namespaceId) {\n\tconst result = {};\n\tconst valueSets = storage.namespaces[namespaceId]?.entries.valueSet;\n\tif (!valueSets) return result;\n\tconst domainEnums = domain.namespaces[namespaceId]?.enum ?? {};\n\tfor (const [name, valueSet] of Object.entries(valueSets)) {\n\t\tif (Object.hasOwn(domainEnums, name)) continue;\n\t\tresult[name] = createEnumAccessor({\n\t\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\t\tmembers: valueSet.values.map((value) => ({\n\t\t\t\tname: String(value),\n\t\t\t\tvalue\n\t\t\t}))\n\t\t});\n\t}\n\treturn result;\n}\nfunction buildNamespacedNativeEnums(storage, domain) {\n\tconst result = {};\n\tfor (const namespaceId of Object.keys(storage.namespaces)) result[namespaceId] = buildNativeEnumsMapForNamespace(storage, domain, namespaceId);\n\treturn result;\n}\n//#endregion\n//#region src/static/postgres-static.ts\nfunction buildPostgresStaticContext(contract, context, rawCodecInferer) {\n\tconst sqlDb = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums: Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId }))),\n\t\tnativeEnums: blindCast(Object.freeze(buildNamespacedNativeEnums(context.contract.storage, context.contract.domain))),\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\n/**\n* The query surfaces of a Postgres client without a driver: `sql`, `raw`, `enums` and\n* `nativeEnums`. Use it where loading `pg` is not wanted, for example in browser code that reads\n* enums.\n*\n* @example\n* ```ts\n* const { enums } = postgresStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction postgresStatic(options) {\n\tconst contract = validatePostgresContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildPostgresStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { postgresStatic as n, buildNamespacedNativeEnums as r, buildPostgresStaticContext as t };\n\n//# sourceMappingURL=postgres-static-D9ySwPXH.mjs.map"],"mappings":";;;;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C,GAAG,MAAM,QAAQ,eAAe;AAClC"}
|
package/dist/{postgres-static-CWKc2Lc4-vwO-rlxR.d.mts → postgres-static-_ysb7j8c-vhfnY6t8.d.mts}
RENAMED
|
@@ -3,8 +3,7 @@ import { EnumAccessor, EnumEntriesToAccessors, NamespacedEnums } from "@prisma/o
|
|
|
3
3
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
4
4
|
import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
5
5
|
import { Db, RawLane } from "@prisma/orm-family-sql/builder/types";
|
|
6
|
-
|
|
7
|
-
//#region ../../../3-extensions/postgres/dist/postgres-static-CWKc2Lc4.d.mts
|
|
6
|
+
//#region ../../../3-extensions/postgres/dist/postgres-static-_ysb7j8c.d.mts
|
|
8
7
|
//#region src/runtime/native-enums.d.ts
|
|
9
8
|
declare function buildNamespacedNativeEnums(storage: SqlStorage, domain: Contract['domain']): Record<string, Record<string, EnumAccessor>>;
|
|
10
9
|
type Present<T> = Exclude<T, undefined>;
|
|
@@ -66,4 +65,4 @@ declare function postgresStatic<TContract extends Contract<SqlStorage>>(options:
|
|
|
66
65
|
}): PostgresStaticContext<TContract>;
|
|
67
66
|
//#endregion
|
|
68
67
|
export { postgresStatic as a, buildNamespacedNativeEnums as i, PostgresStaticContext as n, PostgresTargetId as r, NamespacedNativeEnums as t };
|
|
69
|
-
//# sourceMappingURL=postgres-static-
|
|
68
|
+
//# sourceMappingURL=postgres-static-_ysb7j8c-vhfnY6t8.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-static-_ysb7j8c-vhfnY6t8.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-static-_ysb7j8c.d.mts"],"mappings":";;;;;;;iBAOiB,2BAA2B,SAAS,YAAY,QAAQ,qBAAqB,eAAe,eAAe;KACvH,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,SAAS,+BAA+B,WAAW,WAAW,QAAQ,GAAG,mBAAmB,QAAQ,WAAW,gBAAgB,oBAAoB,QAAQ;KACxL,gBAAgB,kBAAkB,UAAU,MAAM,iBAAiB,oCAAoC,kCAAkC;WACnI,aAAa;yBACC,QAAQ,mBAAmB,QAAQ;;;;KAIvD,sBAAsB,kBAAkB,wBAAwB,YAAY,qCAAqC,uBAAuB,6BAA6B,yBAAyB,mCAAmC,MAAM,gBAAgB,WAAW;;;KAGlQ;;;UAGK,sBAAsB,kBAAkB,SAAS;WAChD,SAAS,iBAAiB;WAC1B,UAAU;WACV,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;WACnC,KAAK,GAAG;WACR,KAAK,QAAQ;;;;;;;;;;;;iBAYP,eAAe,kBAAkB,SAAS,aAAa;WAC7D,UAAU;WACV,sBAAsB,8BAA8B;IAC3D,sBAAsB"}
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { i as buildNamespacedNativeEnums, t as NamespacedNativeEnums } from "./postgres-static-
|
|
2
|
-
import { a as
|
|
1
|
+
import { i as buildNamespacedNativeEnums, t as NamespacedNativeEnums } from "./postgres-static-_ysb7j8c-vhfnY6t8.mjs";
|
|
2
|
+
import { a as PostgresTransactionContext, i as PostgresStaticMembers, n as PostgresQueryMembers, r as PostgresRuntimeBoundMembers, t as PostgresLifecycleMembers } from "./postgres-members-CXcalHlb-DswHs7AN.mjs";
|
|
3
|
+
import { n as PostgresExecutionOptions, t as PostgresCursorOptions } from "./postgres-options-DWx_G43W-gniqIw7c.mjs";
|
|
3
4
|
import { Runtime, SqlRuntimeBase } from "@prisma/orm-family-sql/runtime";
|
|
4
5
|
import { CollectionClasses, NoCollectionClasses } from "@prisma/orm-family-sql/orm-client";
|
|
5
6
|
import { Client, Pool } from "pg";
|
|
@@ -35,7 +36,7 @@ type PostgresBindingInput = {
|
|
|
35
36
|
};
|
|
36
37
|
//#endregion
|
|
37
38
|
//#region src/runtime/postgres.d.ts
|
|
38
|
-
interface PostgresClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PostgresStaticMembers<TContract>, PostgresRuntimeBoundMembers<TContract, TCollections>, PostgresLifecycleMembers {
|
|
39
|
+
interface PostgresClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PostgresQueryMembers<TContract, TCollections>, PostgresStaticMembers<TContract>, PostgresRuntimeBoundMembers<TContract, TCollections>, PostgresLifecycleMembers {
|
|
39
40
|
connect(bindingInput?: PostgresBindingInput): Promise<Runtime>;
|
|
40
41
|
}
|
|
41
42
|
interface PostgresOptionsBase extends PostgresExecutionOptions {
|
|
@@ -86,5 +87,5 @@ declare class PostgresRuntimeImpl<TContract extends Contract<SqlStorage> = Contr
|
|
|
86
87
|
protected getListDecoder(): PostgresListDecoder;
|
|
87
88
|
}
|
|
88
89
|
//#endregion
|
|
89
|
-
export { type NamespacedNativeEnums, type PostgresBinding, type PostgresClient, type PostgresCursorOptions, type PostgresFullTextMethods, type PostgresOptions, type PostgresOptionsBase, type PostgresRuntime, PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };
|
|
90
|
+
export { type NamespacedNativeEnums, type PostgresBinding, type PostgresClient, type PostgresCursorOptions, type PostgresFullTextMethods, type PostgresOptions, type PostgresOptionsBase, type PostgresQueryMembers, type PostgresRuntime, PostgresRuntimeImpl, type PostgresTransactionContext, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };
|
|
90
91
|
//# sourceMappingURL=runtime.d.mts.map
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.d.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.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;;;;UAID,eAAe,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,qBAAqB,WAAW,eAAe,sBAAsB,YAAY,4BAA4B,WAAW,eAAe;EAC5Q,QAAQ,eAAe,uBAAuB,QAAQ;;UAE9C,4BAA4B;WAC3B;aACE;aACA;;;UAGH;WACC,UAAU;WACV;WACA,KAAK,OAAO;;KAElB,gBAAgB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,uBAAuB,yBAAyB;WAC3I,UAAU;WACV,cAAc;;;;;;;;;;;;;;;;;;;iBAmBR,SAAS,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,qBAAqB,SAAS,gBAAgB,WAAW,gBAAgB,eAAe,WAAW;;;;;;;;;;UAUpM,wBAAwB;KAC7B,uBAAuB,oBAAoB,gBAAgB,mBAAmB,qBAAqB;cAC1F,oBAAoB,kBAAkB,SAAS,cAAc,SAAS,qBAAqB,eAAe;YAC5G,kBAAkB"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as postgresError } from "./errors-DfWK9xep-CYOOg0sB.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
2
|
+
import { n as buildPostgresRuntimeBoundMembers } from "./postgres-members-v66adEuo-PojCqobl.mjs";
|
|
3
|
+
import { n as validatePostgresContract } from "./contract-from-json-Ds-MzzpK-C7YoiEiu.mjs";
|
|
4
|
+
import { a as resolveOptionalPostgresBinding, c as toRuntimeOptions, i as isPgPool, l as validateCursorOptions, n as PostgresRuntimeImpl, o as resolvePostgresBinding, r as isPgClient, s as toDriverCursorOptions } from "./postgres-runtime-BzttbbWZ-BKQVfbfA.mjs";
|
|
5
|
+
import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-D9ySwPXH-CiTRi24U.mjs";
|
|
5
6
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
6
|
-
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
7
7
|
import { createExecutionContext, createSqlExecutionStack } from "@prisma/orm-family-sql/runtime";
|
|
8
|
+
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
8
9
|
import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
9
10
|
import postgresDriver, { suppressIdleConnectionErrors } from "@prisma/orm-target-postgres/driver/runtime";
|
|
10
11
|
import { instantiateExecutionStack } from "@prisma/orm-framework/components/execution";
|
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 { a as validateCursorOptions, c as
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions, c as resolveOptionalPostgresBinding, i as toRuntimeOptions, l as resolvePostgresBinding, o as isPgClient, r as toDriverCursorOptions, s as isPgPool, t as PostgresRuntimeImpl } from \"./postgres-runtime-BzttbbWZ.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-D9ySwPXH.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-Ds-MzzpK.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-v66adEuo.mjs\";\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 { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { Pool } from \"pg\";\n//#region src/runtime/postgres.ts\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}\n/**\n* Creates a lazy Postgres 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 static query surfaces are available\n* at once; the pool is created on the first query or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-postgres/static';\n* import postgres from '@prisma/orm-postgres/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 = postgres({ contract, url: process.env['DATABASE_URL']! });\n* ```\n*/\nfunction postgres(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgres\");\n\tconst contract = validatePostgresContract(options.contract);\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, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(contract, context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closePromise;\n\tlet ownsPool = false;\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\tconst ownedPool = resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\" ? runtimeBinding.pool : void 0;\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t\townsPool = ownedPool !== void 0;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedPool?.end().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closePromise !== void 0) 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: toDriverCursorOptions(cursor) });\n\t\truntimeDriver = driver;\n\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\truntimeInstance = runtime;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\treturn runtime;\n\t};\n\tconst closeOwnedRuntime = async () => {\n\t\tif (!driverConnected) await connectPromise?.catch(() => void 0);\n\t\tif (ownsPool) await runtimeInstance?.close();\n\t};\n\treturn {\n\t\tsql,\n\t\t...buildPostgresRuntimeBoundMembers({\n\t\t\tcontext,\n\t\t\tcollections: options.collections,\n\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\tgetRuntime,\n\t\t\tgetRuntimeForWork: getRuntime\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 (closePromise !== void 0) 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\tclose() {\n\t\t\tclosePromise ??= closeOwnedRuntime();\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 { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,iBAAiB,SAAS,SAAS;CAC3C,IAAI,QAAQ,SAAS,OAAO,OAAO;CACnC,OAAO;EACN,MAAM;EACN,MAAM,6BAA6B,IAAI,KAAK;GAC3C,kBAAkB,QAAQ;GAC1B,yBAAyB,QAAQ,aAAa,2BAA2B;GACzE,mBAAmB,QAAQ,aAAa,qBAAqB;EAC9D,CAAC,CAAC;CACH;AACD;;;;;;;;;;;;;;;;;;AAkBA,SAAS,SAAS,SAAS;CAC1B,MAAM,SAAS,sBAAsB,QAAQ,QAAQ,UAAU;CAC/D,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,IAAI,UAAU,+BAA+B,OAAO;CACpD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,MAAM,UAAU,uBAAuB;EACtC;EACA;EACA,QAAQ;CACT,CAAC;CACD,MAAM,EAAE,KAAK,KAAK,WAAW,OAAO,gBAAgB,2BAA2B,UAAU,SAAS,MAAM,QAAQ,eAAe;CAC/H,IAAI;CACJ,IAAI;CACJ,IAAI,kBAAkB;CACtB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,MAAM,gBAAgB,OAAO,oBAAoB;EAChD,IAAI,iBAAiB;EACrB,IAAI,CAAC,eAAe,MAAM,IAAI,cAAc,iCAAiC;EAC7E,IAAI,gBAAgB,OAAO;EAC3B,MAAM,iBAAiB,iBAAiB,iBAAiB,OAAO;EAChE,MAAM,YAAY,gBAAgB,SAAS,SAAS,eAAe,SAAS,WAAW,eAAe,OAAO,KAAK;EAClH,iBAAiB,cAAc,QAAQ,cAA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6BAA6B;IACrG,KAAK;IACL,KAAK;IACL,MAAM,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,QAAQ;GACP,iBAAiB,kBAAkB;GACnC,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
package/dist/serverless.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as PostgresStaticMembers, n as PostgresQueryMembers, r as PostgresRuntimeBoundMembers, t as PostgresLifecycleMembers } from "./postgres-members-CXcalHlb-DswHs7AN.mjs";
|
|
2
|
+
import { n as PostgresExecutionOptions, t as PostgresCursorOptions } from "./postgres-options-DWx_G43W-gniqIw7c.mjs";
|
|
2
3
|
import { CollectionClasses, NoCollectionClasses } from "@prisma/orm-family-sql/orm-client";
|
|
3
4
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
4
5
|
import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
5
6
|
import { PostgresFullTextMethods } from "@prisma/orm-target-postgres/target/full-text";
|
|
6
7
|
//#region ../../../3-extensions/postgres/dist/serverless.d.mts
|
|
7
8
|
//#region src/runtime/postgres-serverless.d.ts
|
|
8
|
-
interface PostgresServerlessConnection<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PostgresStaticMembers<TContract>, PostgresRuntimeBoundMembers<TContract, TCollections>, PostgresLifecycleMembers {}
|
|
9
|
+
interface PostgresServerlessConnection<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PostgresQueryMembers<TContract, TCollections>, PostgresStaticMembers<TContract>, PostgresRuntimeBoundMembers<TContract, TCollections>, PostgresLifecycleMembers {}
|
|
9
10
|
interface PostgresServerlessClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PostgresStaticMembers<TContract> {
|
|
10
11
|
connect(binding: {
|
|
11
12
|
readonly url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverless.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.d.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverless.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.d.mts"],"mappings":";;;;;;;;UAOU,6BAA6B,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,qBAAqB,WAAW,eAAe,sBAAsB,YAAY,4BAA4B,WAAW,eAAe;UAClR,yBAAyB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,sBAAsB;EACrK,QAAQ;aACG;MACP,QAAQ,6BAA6B,WAAW;;UAE5C,sCAAsC;KAC3C,0BAA0B,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,uBAAuB;WAC5H,UAAU;WACV,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BR,mBAAmB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,qBAAqB,SAAS,0BAA0B,WAAW,gBAAgB,yBAAyB,WAAW"}
|
package/dist/serverless.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as postgresError } from "./errors-DfWK9xep-CYOOg0sB.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
2
|
+
import { n as buildPostgresRuntimeBoundMembers } from "./postgres-members-v66adEuo-PojCqobl.mjs";
|
|
3
|
+
import { n as validatePostgresContract } from "./contract-from-json-Ds-MzzpK-C7YoiEiu.mjs";
|
|
4
|
+
import { c as toRuntimeOptions, l as validateCursorOptions, n as PostgresRuntimeImpl, s as toDriverCursorOptions, t as DEFAULT_CONNECT_TIMEOUT_MILLIS, u as validatePostgresUrl } from "./postgres-runtime-BzttbbWZ-BKQVfbfA.mjs";
|
|
5
|
+
import { n as buildPostgresStaticContext } from "./postgres-static-D9ySwPXH-CiTRi24U.mjs";
|
|
5
6
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
6
|
-
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
7
7
|
import { createExecutionContext, createSqlExecutionStack } from "@prisma/orm-family-sql/runtime";
|
|
8
|
+
import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
|
|
8
9
|
import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
9
10
|
import postgresDriver, { suppressIdleConnectionErrors } from "@prisma/orm-target-postgres/driver/runtime";
|
|
10
11
|
import { instantiateExecutionStack } from "@prisma/orm-framework/components/execution";
|
package/dist/serverless.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions,
|
|
1
|
+
{"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { a as validateCursorOptions, i as toRuntimeOptions, n as DEFAULT_CONNECT_TIMEOUT_MILLIS, r as toDriverCursorOptions, t as PostgresRuntimeImpl, u as validatePostgresUrl } from \"./postgres-runtime-BzttbbWZ.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-D9ySwPXH.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-Ds-MzzpK.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-v66adEuo.mjs\";\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 { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { Client } from \"pg\";\nimport { redactDatabaseUrl } from \"@internal/utils/redact-db-url\";\n//#region src/runtime/postgres-serverless.ts\nfunction closedConnectionError() {\n\treturn postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres connection is closed\", {\n\t\twhy: \"close() was called on this connection, or the await using scope that held it has ended.\",\n\t\tfix: \"Call connect({ url }) again to open a new connection.\",\n\t\tmeta: { extension: \"postgres\" }\n\t});\n}\nfunction connectionFailedError(url, cause) {\n\treturn postgresError(\"DRIVER.CONNECTION_FAILED\", \"Database connection failed\", {\n\t\twhy: cause instanceof Error ? cause.message : String(cause),\n\t\tfix: \"Verify the database URL, ensure the database is reachable, and confirm credentials/permissions\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\t...redactDatabaseUrl(url)\n\t\t},\n\t\tcause\n\t});\n}\n/**\n* Creates a serverless client for serverless and edge runtimes (Cloudflare Workers + Hyperdrive,\n* AWS Lambda, Vercel, Deno Deploy).\n*\n* The serverless client holds no database connection and has the static members. Each\n* `connect({ url })` opens one database connection, a fresh `pg.Client`, and returns a connection\n* with the members of a `postgres()` client except `connect`. It rejects with\n* `DRIVER.CONNECTION_FAILED` when the database refuses the connection, rejects the credentials,\n* or does not answer within 20 seconds. Close the connection with `await using` or `close()`.\n*\n* The client infers its contract type from `contract` and validates it once, when the client is\n* created; connections reuse it.\n*\n* @example\n* ```ts\n* const postgres = postgresServerless({ contract: contractFromJson<Contract>(contractJson) });\n*\n* export default {\n* async fetch(_req: Request, env: Env): Promise<Response> {\n* await using db = await postgres.connect({ url: env.HYPERDRIVE.connectionString });\n* const users = await db.orm.public.User.all();\n* return Response.json(users);\n* },\n* };\n* ```\n*/\nfunction postgresServerless(options) {\n\tconst cursor = validateCursorOptions(options.cursor, \"postgresServerless\");\n\tconst contract = validatePostgresContract(options.contract);\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 rawCodecInferer = stack.adapter.rawCodecInferer;\n\tconst { sql, raw, enums, nativeEnums } = buildPostgresStaticContext(contract, context, rawCodecInferer);\n\tconst buildRuntimeBoundMembers = (getRuntime, getRuntimeForWork) => buildPostgresRuntimeBoundMembers({\n\t\tcontext,\n\t\tcollections: options.collections,\n\t\trawCodecInferer,\n\t\tenums,\n\t\tnativeEnums,\n\t\tgetRuntime,\n\t\tgetRuntimeForWork\n\t});\n\tconst noRuntime = () => {\n\t\tthrow new InternalError(\"The serverless client has no runtime\");\n\t};\n\tbuildRuntimeBoundMembers(noRuntime, noRuntime);\n\tconst createConnection = (runtime) => {\n\t\tlet closing;\n\t\tconst close = () => {\n\t\t\tclosing ??= runtime.close();\n\t\t\treturn closing;\n\t\t};\n\t\tconst runtimeBoundMembers = buildRuntimeBoundMembers(() => {\n\t\t\tif (closing !== void 0) throw closedConnectionError();\n\t\t\treturn runtime;\n\t\t}, () => runtime);\n\t\treturn {\n\t\t\tsql,\n\t\t\traw,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\tcontext,\n\t\t\tcontract,\n\t\t\tstack,\n\t\t\t...runtimeBoundMembers,\n\t\t\tclose,\n\t\t\t[Symbol.asyncDispose]: close\n\t\t};\n\t};\n\treturn {\n\t\tsql,\n\t\traw,\n\t\tenums,\n\t\tnativeEnums,\n\t\tcontext,\n\t\tstack,\n\t\tcontract,\n\t\tasync connect(binding) {\n\t\t\tconst url = validatePostgresUrl(binding.url);\n\t\t\tconst driverDescriptor = stack.driver;\n\t\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\t\tconst pgClient = suppressIdleConnectionErrors(new Client({\n\t\t\t\tconnectionString: url,\n\t\t\t\tconnectionTimeoutMillis: DEFAULT_CONNECT_TIMEOUT_MILLIS\n\t\t\t}));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient: pgClient\n\t\t\t});\n\t\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\t\tcontext,\n\t\t\t\tadapter: stackInstance.adapter,\n\t\t\t\tdriver,\n\t\t\t\t...toRuntimeOptions(options),\n\t\t\t\tcloseRefusal: \"when-idle\"\n\t\t\t});\n\t\t\tconst connection = createConnection(runtime);\n\t\t\ttry {\n\t\t\t\tawait (await driver.acquireConnection()).release();\n\t\t\t} catch (err) {\n\t\t\t\tpgClient.end().catch(() => void 0);\n\t\t\t\tthrow connectionFailedError(url, err);\n\t\t\t}\n\t\t\treturn connection;\n\t\t}\n\t};\n}\n//#endregion\nexport { postgresServerless as default };\n\n//# sourceMappingURL=serverless.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,wBAAwB;CAChC,OAAO,cAAc,wBAAwB,iCAAiC;EAC7E,KAAK;EACL,KAAK;EACL,MAAM,EAAE,WAAW,WAAW;CAC/B,CAAC;AACF;AACA,SAAS,sBAAsB,KAAK,OAAO;CAC1C,OAAO,cAAc,4BAA4B,8BAA8B;EAC9E,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC1D,KAAK;EACL,MAAM;GACL,WAAW;GACX,GAAG,kBAAkB,GAAG;EACzB;EACA;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BAA6B,IAAI,OAAO;IACxD,kBAAkB;IAClB,yBAAyB;GAC1B,CAAC,CAAC;GACF,MAAM,OAAO,QAAQ;IACpB,MAAM;IACN,QAAQ;GACT,CAAC;GACD,MAAM,UAAU,IAAI,oBAAoB;IACvC;IACA,SAAS,cAAc;IACvB;IACA,GAAG,iBAAiB,OAAO;IAC3B,cAAc;GACf,CAAC;GACD,MAAM,aAAa,iBAAiB,OAAO;GAC3C,IAAI;IACH,OAAO,MAAM,OAAO,kBAAkB,EAAA,CAAG,QAAQ;GAClD,SAAS,KAAK;IACb,SAAS,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC;IACjC,MAAM,sBAAsB,KAAK,GAAG;GACrC;GACA,OAAO;EACR;CACD;AACD"}
|
package/dist/static.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { a as postgresStatic, n as PostgresStaticContext } from "./postgres-static-_ysb7j8c-vhfnY6t8.mjs";
|
|
1
2
|
import { t as contractFromJson } from "./contract-from-json-ZRZt8Cse-BkZYEfDX.mjs";
|
|
2
|
-
import { a as postgresStatic, n as PostgresStaticContext } from "./postgres-static-CWKc2Lc4-vwO-rlxR.mjs";
|
|
3
3
|
export { type PostgresStaticContext, contractFromJson, postgresStatic as default };
|
package/dist/static.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as contractFromJson } from "./contract-from-json-
|
|
2
|
-
import { r as postgresStatic } from "./postgres-static-
|
|
1
|
+
import { t as contractFromJson } from "./contract-from-json-Ds-MzzpK-C7YoiEiu.mjs";
|
|
2
|
+
import { r as postgresStatic } from "./postgres-static-D9ySwPXH-CiTRi24U.mjs";
|
|
3
3
|
export { contractFromJson, postgresStatic as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/orm-postgres",
|
|
3
|
-
"version": "8.0.0-rc.18-dev.
|
|
3
|
+
"version": "8.0.0-rc.18-dev.35",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"skills"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@prisma/orm-family-sql": "8.0.0-rc.18-dev.
|
|
14
|
-
"@prisma/orm-framework": "8.0.0-rc.18-dev.
|
|
15
|
-
"@prisma/orm-target-postgres": "8.0.0-rc.18-dev.
|
|
16
|
-
"@prisma/orm-toolchain": "8.0.0-rc.18-dev.
|
|
13
|
+
"@prisma/orm-family-sql": "8.0.0-rc.18-dev.35",
|
|
14
|
+
"@prisma/orm-framework": "8.0.0-rc.18-dev.35",
|
|
15
|
+
"@prisma/orm-target-postgres": "8.0.0-rc.18-dev.35",
|
|
16
|
+
"@prisma/orm-toolchain": "8.0.0-rc.18-dev.35",
|
|
17
17
|
"@types/node": "26.1.2",
|
|
18
18
|
"@types/pg": "8.20.4",
|
|
19
19
|
"arktype": "^2.2.2",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"tinyglobby": "^0.2.17"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@internal/postgres": "8.0.0-rc.18-dev.
|
|
26
|
-
"@repo/tsconfig": "8.0.0-rc.18-dev.
|
|
27
|
-
"@repo/tsdown": "8.0.0-rc.18-dev.
|
|
25
|
+
"@internal/postgres": "8.0.0-rc.18-dev.35",
|
|
26
|
+
"@repo/tsconfig": "8.0.0-rc.18-dev.35",
|
|
27
|
+
"@repo/tsdown": "8.0.0-rc.18-dev.35",
|
|
28
28
|
"tsdown": "0.22.14",
|
|
29
29
|
"typescript": "5.9.3"
|
|
30
30
|
},
|
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
"./family-contract/value-set-derivation-hook": "./dist/family-contract__value-set-derivation-hook.mjs",
|
|
110
110
|
"./family-runtime": "./dist/family-runtime.mjs",
|
|
111
111
|
"./family-runtime/internal/prepared-query": "./dist/family-runtime__internal__prepared-query.mjs",
|
|
112
|
+
"./internal/transaction-members": "./dist/internal__transaction-members.mjs",
|
|
112
113
|
"./internal/validate-contract": "./dist/internal__validate-contract.mjs",
|
|
113
114
|
"./migration": "./dist/migration.mjs",
|
|
114
115
|
"./migration-tools/aggregate": "./dist/migration-tools__aggregate.mjs",
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -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, (
|
|
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
|
|
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
|
|
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, (
|
|
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' }, (
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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,56 +0,0 @@
|
|
|
1
|
-
import { n as PostgresStaticContext, r as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-static-CWKc2Lc4-vwO-rlxR.mjs";
|
|
2
|
-
import { BindSiteParams, Declaration, Log, ParamsFromDeclaration, Runtime, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor, TransactionContext, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
|
|
3
|
-
import { CollectionClasses, NoCollectionClasses, PreparedFrom, orm } from "@prisma/orm-family-sql/orm-client";
|
|
4
|
-
import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
|
|
5
|
-
import "@prisma/orm-target-postgres/driver/runtime";
|
|
6
|
-
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
7
|
-
import { ExtractCodecTypes, SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
8
|
-
import { Db } from "@prisma/orm-family-sql/builder/types";
|
|
9
|
-
import { CodecTypesBase } from "@prisma/orm-family-sql/relational-core/expression";
|
|
10
|
-
import { Preparable, SqlQueryPlan } from "@prisma/orm-family-sql/relational-core/plan";
|
|
11
|
-
//#region ../../../3-extensions/postgres/dist/postgres-options-CbQMRzbY.d.mts
|
|
12
|
-
//#region src/runtime/postgres-members.d.ts
|
|
13
|
-
type OrmClient<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses> = ReturnType<typeof orm<TContract, TCollections>>;
|
|
14
|
-
interface PostgresTransactionContext<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends TransactionContext {
|
|
15
|
-
readonly sql: Db<TContract>;
|
|
16
|
-
readonly orm: OrmClient<TContract, TCollections>;
|
|
17
|
-
readonly enums: NamespacedEnums<TContract>;
|
|
18
|
-
readonly nativeEnums: NamespacedNativeEnums<TContract>;
|
|
19
|
-
}
|
|
20
|
-
interface PostgresStaticMembers<TContract extends Contract<SqlStorage>> extends PostgresStaticContext<TContract> {
|
|
21
|
-
readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;
|
|
22
|
-
}
|
|
23
|
-
interface PostgresRuntimeBoundMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> {
|
|
24
|
-
readonly orm: OrmClient<TContract, TCollections>;
|
|
25
|
-
runtime(): Runtime;
|
|
26
|
-
transaction<R>(fn: (tx: PostgresTransactionContext<TContract, TCollections>) => PromiseLike<R>): Promise<R>;
|
|
27
|
-
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>>;
|
|
28
|
-
}
|
|
29
|
-
interface PostgresLifecycleMembers {
|
|
30
|
-
close(): Promise<void>;
|
|
31
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/runtime/postgres-options.d.ts
|
|
35
|
-
/**
|
|
36
|
-
* Server-side cursor for reads. Unset reads the whole result before the first row; set streams
|
|
37
|
-
* rows in batches of `batchSize`, 100 when omitted or `undefined`. A `batchSize` that is not a
|
|
38
|
-
* positive integer fails the factory call.
|
|
39
|
-
*/
|
|
40
|
-
interface PostgresCursorOptions {
|
|
41
|
-
readonly batchSize?: number | undefined;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The options `postgres()` and `postgresServerless()` share: how queries run, not where the
|
|
45
|
-
* database is.
|
|
46
|
-
*/
|
|
47
|
-
interface PostgresExecutionOptions {
|
|
48
|
-
readonly extensions?: readonly SqlRuntimeExtensionDescriptor<PostgresTargetId>[];
|
|
49
|
-
readonly middleware?: readonly SqlMiddleware[];
|
|
50
|
-
readonly verifyMarker?: VerifyMarkerOption;
|
|
51
|
-
readonly log?: Log;
|
|
52
|
-
readonly cursor?: PostgresCursorOptions;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
export { PostgresStaticMembers as a, PostgresRuntimeBoundMembers as i, PostgresExecutionOptions as n, PostgresLifecycleMembers as r, PostgresCursorOptions as t };
|
|
56
|
-
//# sourceMappingURL=postgres-options-CbQMRzbY-D-8O8RB7.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-options-CbQMRzbY-D-8O8RB7.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-options-CbQMRzbY.d.mts"],"mappings":";;;;;;;;;;;;KAWK,UAAU,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,kBAAkB,IAAI,WAAW;UACxH,2BAA2B,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B;WACxI,KAAK,GAAG;WACR,KAAK,UAAU,WAAW;WAC1B,OAAO,gBAAgB;WACvB,aAAa,sBAAsB;;UAEpC,sBAAsB,kBAAkB,SAAS,qBAAqB,sBAAsB;WAC3F,OAAO,4BAA4B;;UAEpC,4BAA4B,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB;WAC5G,KAAK,UAAU,WAAW;EACnC,WAAW;EACX,YAAY,GAAG,KAAK,IAAI,2BAA2B,WAAW,kBAAkB,YAAY,KAAK,QAAQ;EACzG,QAAQ,UAAU,YAAY,KAAK,UAAU,eAAe,8BAA8B,WAAW,iBAAiB,kBAAkB,YAAY,aAAa,GAAG,WAAW,QAAQ,eAAe,OAAO,IAAI,QAAQ,aAAa,sBAAsB,GAAG,KAAK;;UAE5P;EACR,SAAS;GACR,OAAO,iBAAiB;;;;;;;;;UASjB;WACC;;;;;;UAMD;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf,MAAM;WACN,SAAS"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-runtime-BLsIqXbA-LizaG8Vd.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-runtime-BLsIqXbA.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { SqlRuntimeBase, activitySource, delegatingActivitySource, withTransaction } from \"@internal/sql-runtime\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { type } from \"arktype\";\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(blindCast(options));\n}\n//#endregion\n//#region src/runtime/postgres-members.ts\nfunction buildPostgresRuntimeBoundMembers(options) {\n\tconst { context, collections, rawCodecInferer, enums, nativeEnums, getRuntime, getRuntimeForWork } = options;\n\tconst orm$1 = orm({\n\t\truntime: {\n\t\t\tquery(plan) {\n\t\t\t\treturn getRuntimeForWork().query(plan);\n\t\t\t},\n\t\t\texecute(plan) {\n\t\t\t\treturn getRuntimeForWork().execute(plan);\n\t\t\t},\n\t\t\tconnection() {\n\t\t\t\treturn getRuntimeForWork().connection();\n\t\t\t},\n\t\t\t[activitySource]: delegatingActivitySource(() => getRuntimeForWork())\n\t\t},\n\t\tcontext,\n\t\t...ifDefined(\"collections\", collections)\n\t});\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(getRuntimeForWork(), declaration, callback);\n\t}\n\treturn {\n\t\torm: orm$1,\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(getRuntimeForWork(), (txCtx) => {\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\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t\t\t},\n\t\t\t\t\tcontext,\n\t\t\t\t\t...ifDefined(\"collections\", 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\tnativeEnums\n\t\t\t\t}));\n\t\t\t});\n\t\t}\n\t};\n}\n//#endregion\n//#region src/runtime/postgres-options.ts\n/**\n* Default time to wait for the database to accept a connection, for a client's pool and for a\n* connection's `pg.Client`.\n*/\nconst DEFAULT_CONNECT_TIMEOUT_MILLIS = 2e4;\nconst cursorOptionsSchema = type({ \"batchSize?\": \"number.integer > 0 | undefined\" }).onUndeclaredKey(\"reject\");\nfunction validateCursorOptions(cursor, helper) {\n\tif (cursor === void 0) return;\n\tconst result = cursorOptionsSchema(cursor);\n\tif (result instanceof type.errors) throw postgresError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid cursor option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass cursor: {} or cursor: { batchSize: <positive integer> } to read through a server-side cursor, or leave cursor unset to read without one.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\thelper,\n\t\t\targument: \"cursor\",\n\t\t\treceived: cursor\n\t\t}\n\t});\n\treturn result;\n}\nfunction toDriverCursorOptions(cursor) {\n\treturn cursor === void 0 ? { disabled: true } : ifDefined(\"batchSize\", cursor.batchSize);\n}\nfunction toRuntimeOptions(options) {\n\treturn {\n\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t...ifDefined(\"log\", options.log)\n\t};\n}\n//#endregion\n//#region src/runtime/postgres-runtime.ts\nvar PostgresRuntimeImpl = class extends SqlRuntimeBase {\n\tgetListDecoder() {\n\t\treturn postgresTarget.listDecoder();\n\t}\n};\n//#endregion\nexport { validateCursorOptions as a, isPgPool as c, validatePostgresUrl as d, toRuntimeOptions as i, resolveOptionalPostgresBinding as l, DEFAULT_CONNECT_TIMEOUT_MILLIS as n, buildPostgresRuntimeBoundMembers as o, toDriverCursorOptions as r, isPgClient as s, PostgresRuntimeImpl as t, resolvePostgresBinding as u };\n\n//# sourceMappingURL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,OAAO,OAAO,KAAK,CAAC,GAAG;KACrD,KAAK;KACL,KAAK;KACL;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;CACD;AACD;;;;;AAOA,MAAM,iCAAiC;AACvC,MAAM,sBAAsB,KAAK,EAAE,cAAc,iCAAiC,CAAC,CAAC,CAAC,gBAAgB,QAAQ;AAC7G,SAAS,sBAAsB,QAAQ,QAAQ;CAC9C,IAAI,WAAW,KAAK,GAAG;CACvB,MAAM,SAAS,oBAAoB,MAAM;CACzC,IAAI,kBAAkB,KAAK,QAAQ,MAAM,cAAc,4BAA4B,yBAAyB;EAC3G,KAAK,OAAO;EACZ,KAAK;EACL,MAAM;GACL,WAAW;GACX;GACA,UAAU;GACV,UAAU;EACX;CACD,CAAC;CACD,OAAO;AACR;AACA,SAAS,sBAAsB,QAAQ;CACtC,OAAO,WAAW,KAAK,IAAI,EAAE,UAAU,KAAK,IAAI,UAAU,aAAa,OAAO,SAAS;AACxF;AACA,SAAS,iBAAiB,SAAS;CAClC,OAAO;EACN,GAAG,UAAU,gBAAgB,QAAQ,YAAY;EACjD,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,OAAO,QAAQ,GAAG;CAChC;AACD;AAGA,IAAI,sBAAsB,cAAc,eAAe;CACtD,iBAAiB;EAChB,OAAO,eAAe,YAAY;CACnC;AACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-static-CWKc2Lc4-vwO-rlxR.d.mts","names":[],"sources":["../../../../3-extensions/postgres/dist/postgres-static-CWKc2Lc4.d.mts"],"mappings":";;;;;;;;iBAOiB,2BAA2B,SAAS,YAAY,QAAQ,qBAAqB,eAAe,eAAe;KACvH,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,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