@prisma/orm-postgres 8.0.0-rc.24-dev.12 → 8.0.0-rc.24-dev.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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-targets/postgres/9-facade/dist/contract-from-json-PooBVhkP.mjs
4
- var version = "8.0.0-rc.24-dev.12";
3
+ //#region ../../../3-targets/postgres/9-facade/dist/contract-from-json-BAyMAOCZ.mjs
4
+ var version = "8.0.0-rc.24-dev.14";
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-PooBVhkP-D73P8986.mjs.map
33
+ //# sourceMappingURL=contract-from-json-BAyMAOCZ-DRubZT3w.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-from-json-PooBVhkP-D73P8986.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-from-json-PooBVhkP.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.24-dev.12\";\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-PooBVhkP.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
+ {"version":3,"file":"contract-from-json-BAyMAOCZ-DRubZT3w.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-from-json-BAyMAOCZ.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.24-dev.14\";\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-BAyMAOCZ.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 buildPostgresStaticContext } from "./postgres-static-0dmoylj3-CXN-mFsT.mjs";
1
+ import { n as buildPostgresStaticContext } from "./postgres-static-DWlMG39w-CDBi8-fy.mjs";
2
2
  export { buildPostgresStaticContext };
@@ -1,2 +1,2 @@
1
- import { n as validatePostgresContract } from "./contract-from-json-PooBVhkP-D73P8986.mjs";
1
+ import { n as validatePostgresContract } from "./contract-from-json-BAyMAOCZ-DRubZT3w.mjs";
2
2
  export { validatePostgresContract };
@@ -1,4 +1,4 @@
1
- import { n as validatePostgresContract } from "./contract-from-json-PooBVhkP-D73P8986.mjs";
1
+ import { n as validatePostgresContract } from "./contract-from-json-BAyMAOCZ-DRubZT3w.mjs";
2
2
  import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
3
3
  import postgresTarget from "@prisma/orm-target-postgres/target/runtime";
4
4
  import { blindCast } from "@prisma/orm-framework/utils/casts";
@@ -6,7 +6,7 @@ import { buildNamespacedEnums, createEnumAccessor } from "@prisma/orm-framework/
6
6
  import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
7
7
  import { createExecutionContext, createSqlExecutionStack, createToSql } from "@prisma/orm-family-sql/runtime";
8
8
  import { createRawLane, sql } from "@prisma/orm-family-sql/builder/runtime";
9
- //#region ../../../3-targets/postgres/9-facade/dist/postgres-static-0dmoylj3.mjs
9
+ //#region ../../../3-targets/postgres/9-facade/dist/postgres-static-DWlMG39w.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
  */
@@ -77,4 +77,4 @@ function postgresStatic(options) {
77
77
  //#endregion
78
78
  export { buildPostgresStaticContext as n, postgresStatic as r, buildNamespacedNativeEnums as t };
79
79
 
80
- //# sourceMappingURL=postgres-static-0dmoylj3-CXN-mFsT.mjs.map
80
+ //# sourceMappingURL=postgres-static-DWlMG39w-CDBi8-fy.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-static-0dmoylj3-CXN-mFsT.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/postgres-static-0dmoylj3.mjs"],"sourcesContent":["import { n as validatePostgresContract } from \"./contract-from-json-PooBVhkP.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { buildNamespacedEnums, createEnumAccessor } from \"@internal/contract/enum-accessor\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-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, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\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\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a Postgres client without a driver: `sql`, `raw`, `enums`, `nativeEnums`\n* and `toSql`. 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);\n}\n//#endregion\nexport { postgresStatic as n, buildNamespacedNativeEnums as r, buildPostgresStaticContext as t };\n\n//# sourceMappingURL=postgres-static-0dmoylj3.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,gCAAgC,SAAS,QAAQ,aAAa;CACtE,MAAM,SAAS,CAAC;CAChB,MAAM,YAAY,QAAQ,WAAW,YAAY,EAAE,QAAQ;CAC3D,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,cAAc,OAAO,WAAW,YAAY,EAAE,QAAQ,CAAC;CAC7D,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,SAAS,GAAG;EACzD,IAAI,OAAO,OAAO,aAAa,IAAI,GAAG;EACtC,OAAO,QAAQ,mBAAmB;GACjC,SAAS;GACT,SAAS,SAAS,OAAO,KAAK,WAAW;IACxC,MAAM,OAAO,KAAK;IAClB;GACD,EAAE;EACH,CAAC;CACF;CACA,OAAO;AACR;AACA,SAAS,2BAA2B,SAAS,QAAQ;CACpD,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,eAAe,OAAO,KAAK,QAAQ,UAAU,GAAG,OAAO,eAAe,gCAAgC,SAAS,QAAQ,WAAW;CAC7I,OAAO;AACR;AAGA,SAAS,2BAA2B,UAAU,SAAS,OAAO;CAC7D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,QAAQ,IAAI;EACjB;EACA;CACD,CAAC;CACD,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,OAAO;EACN;EACA;EACA,OAAO,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;EAChI,aAAa,UAAU,OAAO,OAAO,2BAA2B,QAAQ,SAAS,SAAS,QAAQ,SAAS,MAAM,CAAC,CAAC;EACnH,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;;AAWA,SAAS,eAAe,SAAS;CAChC,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,2BAA2B,UAAU,uBAAuB;EAClE;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
1
+ {"version":3,"file":"postgres-static-DWlMG39w-CDBi8-fy.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/postgres-static-DWlMG39w.mjs"],"sourcesContent":["import { n as validatePostgresContract } from \"./contract-from-json-BAyMAOCZ.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresTarget from \"@internal/target-postgres/runtime\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { buildNamespacedEnums, createEnumAccessor } from \"@internal/contract/enum-accessor\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-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, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\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\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a Postgres client without a driver: `sql`, `raw`, `enums`, `nativeEnums`\n* and `toSql`. 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);\n}\n//#endregion\nexport { postgresStatic as n, buildNamespacedNativeEnums as r, buildPostgresStaticContext as t };\n\n//# sourceMappingURL=postgres-static-DWlMG39w.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,gCAAgC,SAAS,QAAQ,aAAa;CACtE,MAAM,SAAS,CAAC;CAChB,MAAM,YAAY,QAAQ,WAAW,YAAY,EAAE,QAAQ;CAC3D,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,cAAc,OAAO,WAAW,YAAY,EAAE,QAAQ,CAAC;CAC7D,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,SAAS,GAAG;EACzD,IAAI,OAAO,OAAO,aAAa,IAAI,GAAG;EACtC,OAAO,QAAQ,mBAAmB;GACjC,SAAS;GACT,SAAS,SAAS,OAAO,KAAK,WAAW;IACxC,MAAM,OAAO,KAAK;IAClB;GACD,EAAE;EACH,CAAC;CACF;CACA,OAAO;AACR;AACA,SAAS,2BAA2B,SAAS,QAAQ;CACpD,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,eAAe,OAAO,KAAK,QAAQ,UAAU,GAAG,OAAO,eAAe,gCAAgC,SAAS,QAAQ,WAAW;CAC7I,OAAO;AACR;AAGA,SAAS,2BAA2B,UAAU,SAAS,OAAO;CAC7D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,QAAQ,IAAI;EACjB;EACA;CACD,CAAC;CACD,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,OAAO;EACN;EACA;EACA,OAAO,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;EAChI,aAAa,UAAU,OAAO,OAAO,2BAA2B,QAAQ,SAAS,SAAS,QAAQ,SAAS,MAAM,CAAC,CAAC;EACnH,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;;AAWA,SAAS,eAAe,SAAS;CAChC,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,2BAA2B,UAAU,uBAAuB;EAClE;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
package/dist/runtime.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as postgresError } from "./errors-DfWK9xep-CB07krZF.mjs";
2
2
  import { i as validateTransactionOptions, n as toDriverCursorOptions, r as validateCursorOptions } from "./postgres-options-CZyV9Him-2OSYJKqo.mjs";
3
3
  import { a as resolveOptionalPostgresBinding, i as postgresBindingRules, n as isPgClient, o as resolvePostgresBinding, r as isPgPool, t as connectWithBinding } from "./binding-DkfRsUZE-Co5ssUZw.mjs";
4
- import { n as validatePostgresContract } from "./contract-from-json-PooBVhkP-D73P8986.mjs";
5
- import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-0dmoylj3-CXN-mFsT.mjs";
4
+ import { n as validatePostgresContract } from "./contract-from-json-BAyMAOCZ-DRubZT3w.mjs";
5
+ import { n as buildPostgresStaticContext, t as buildNamespacedNativeEnums } from "./postgres-static-DWlMG39w-CDBi8-fy.mjs";
6
6
  import { n as buildPostgresRuntimeBoundMembers } from "./postgres-members-B7ZvxGYc-D_L3NVGm.mjs";
7
7
  import { t as PostgresRuntimeImpl } from "./postgres-runtime-BKdag6p9-gHVB2jfC.mjs";
8
8
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { i as validateTransactionOptions, n as toDriverCursorOptions, r as validateCursorOptions } from \"./postgres-options-CZyV9Him.mjs\";\nimport { a as resolveOptionalPostgresBinding, i as postgresBindingRules, n as isPgClient, o as resolvePostgresBinding, r as isPgPool, t as connectWithBinding } from \"./binding-DkfRsUZE.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-0dmoylj3.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-PooBVhkP.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-B7ZvxGYc.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-BKdag6p9.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresTarget, { postgresIsolationLevels as IsolationLevel } from \"@internal/target-postgres/runtime\";\nimport postgresDriver from \"@internal/driver-postgres/runtime\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, toRuntimeOptions } from \"@internal/sql-runtime\";\n//#region src/runtime/postgres.ts\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 transactionOptions = validateTransactionOptions(options.transactionOptions);\n\tconst contract = validatePostgresContract(options.contract);\n\tlet binding = resolveOptionalPostgresBinding(options, postgresBindingRules);\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, toSql } = buildPostgresStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closePromise;\n\tconst closedError = () => postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\twhy: \"close() was called on this client.\",\n\t\tfix: \"Create a new postgres(...) client.\",\n\t\tmeta: { extension: \"postgres\" }\n\t});\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\tconnectPromise = connectWithBinding(runtimeDriver, resolvedBinding, options).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closePromise !== void 0) throw closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({ cursor: toDriverCursorOptions(cursor) });\n\t\truntimeDriver = driver;\n\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\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 closeRuntime = async () => {\n\t\tif (!driverConnected) await connectPromise?.catch(() => void 0);\n\t\tawait 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\tsql,\n\t\t\traw: rawSqlTag,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\ttoSql,\n\t\t\tgetRuntime,\n\t\t\tgetRuntimeForWork: getRuntime,\n\t\t\ttransactionOptions\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closePromise !== void 0) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closePromise !== void 0) throw closedError();\n\t\t\t\treturn runtime;\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\tif (closePromise !== void 0) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\tclose() {\n\t\t\tclosePromise ??= closeRuntime();\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 { IsolationLevel, PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,SAAS,SAAS;CAC1B,MAAM,SAAS,sBAAsB,QAAQ,QAAQ,UAAU;CAC/D,MAAM,qBAAqB,2BAA2B,QAAQ,kBAAkB;CAChF,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,IAAI,UAAU,+BAA+B,SAAS,oBAAoB;CAC1E,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,aAAa,UAAU,2BAA2B,UAAU,SAAS,KAAK;CAC9G,IAAI;CACJ,IAAI;CACJ,IAAI,kBAAkB;CACtB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,oBAAoB,cAAc,wBAAwB,6BAA6B;EAC5F,KAAK;EACL,KAAK;EACL,MAAM,EAAE,WAAW,WAAW;CAC/B,CAAC;CACD,MAAM,gBAAgB,OAAO,oBAAoB;EAChD,IAAI,iBAAiB;EACrB,IAAI,CAAC,eAAe,MAAM,IAAI,cAAc,iCAAiC;EAC7E,IAAI,gBAAgB,OAAO;EAC3B,iBAAiB,mBAAmB,eAAe,iBAAiB,OAAO,CAAC,CAAC,WAAW;GACvF,kBAAkB;EACnB,CAAC,CAAC,CAAC,OAAO,QAAQ;GACjB,yBAAyB;GACzB,iBAAiB,KAAK;GACtB,MAAM;EACP,CAAC;EACD,OAAO;CACR;CACA,MAAM,mBAAmB;EACxB,IAAI,iBAAiB,KAAK,GAAG,M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,MAAM,cAAc,OAAO;GAC3B,IAAI,iBAAiB,KAAK,GAAG,MAAM,YAAY;GAC/C,OAAO;EACR;EACA,QAAQ;GACP,iBAAiB,aAAa;GAC9B,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { i as validateTransactionOptions, n as toDriverCursorOptions, r as validateCursorOptions } from \"./postgres-options-CZyV9Him.mjs\";\nimport { a as resolveOptionalPostgresBinding, i as postgresBindingRules, n as isPgClient, o as resolvePostgresBinding, r as isPgPool, t as connectWithBinding } from \"./binding-DkfRsUZE.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DWlMG39w.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-BAyMAOCZ.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-B7ZvxGYc.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-BKdag6p9.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresTarget, { postgresIsolationLevels as IsolationLevel } from \"@internal/target-postgres/runtime\";\nimport postgresDriver from \"@internal/driver-postgres/runtime\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, toRuntimeOptions } from \"@internal/sql-runtime\";\n//#region src/runtime/postgres.ts\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 transactionOptions = validateTransactionOptions(options.transactionOptions);\n\tconst contract = validatePostgresContract(options.contract);\n\tlet binding = resolveOptionalPostgresBinding(options, postgresBindingRules);\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, toSql } = buildPostgresStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closePromise;\n\tconst closedError = () => postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\twhy: \"close() was called on this client.\",\n\t\tfix: \"Create a new postgres(...) client.\",\n\t\tmeta: { extension: \"postgres\" }\n\t});\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\tconnectPromise = connectWithBinding(runtimeDriver, resolvedBinding, options).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closePromise !== void 0) throw closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({ cursor: toDriverCursorOptions(cursor) });\n\t\truntimeDriver = driver;\n\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\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 closeRuntime = async () => {\n\t\tif (!driverConnected) await connectPromise?.catch(() => void 0);\n\t\tawait 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\tsql,\n\t\t\traw: rawSqlTag,\n\t\t\tenums,\n\t\t\tnativeEnums,\n\t\t\ttoSql,\n\t\t\tgetRuntime,\n\t\t\tgetRuntimeForWork: getRuntime,\n\t\t\ttransactionOptions\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closePromise !== void 0) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closePromise !== void 0) throw closedError();\n\t\t\t\treturn runtime;\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\tif (closePromise !== void 0) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\tclose() {\n\t\t\tclosePromise ??= closeRuntime();\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 { IsolationLevel, PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,SAAS,SAAS;CAC1B,MAAM,SAAS,sBAAsB,QAAQ,QAAQ,UAAU;CAC/D,MAAM,qBAAqB,2BAA2B,QAAQ,kBAAkB;CAChF,MAAM,WAAW,yBAAyB,QAAQ,QAAQ;CAC1D,IAAI,UAAU,+BAA+B,SAAS,oBAAoB;CAC1E,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,aAAa,UAAU,2BAA2B,UAAU,SAAS,KAAK;CAC9G,IAAI;CACJ,IAAI;CACJ,IAAI,kBAAkB;CACtB,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,oBAAoB,cAAc,wBAAwB,6BAA6B;EAC5F,KAAK;EACL,KAAK;EACL,MAAM,EAAE,WAAW,WAAW;CAC/B,CAAC;CACD,MAAM,gBAAgB,OAAO,oBAAoB;EAChD,IAAI,iBAAiB;EACrB,IAAI,CAAC,eAAe,MAAM,IAAI,cAAc,iCAAiC;EAC7E,IAAI,gBAAgB,OAAO;EAC3B,iBAAi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C/C,OAAO;GACR;GACA,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,IAAI,iBAAiB,KAAK,GAAG,MAAM,YAAY;GAC/C,OAAO;EACR;EACA,QAAQ;GACP,iBAAiB,aAAa;GAC9B,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
@@ -1,8 +1,8 @@
1
1
  import { t as postgresError } from "./errors-DfWK9xep-CB07krZF.mjs";
2
2
  import { i as validateTransactionOptions, n as toDriverCursorOptions, r as validateCursorOptions, t as DEFAULT_CONNECT_TIMEOUT_MILLIS } from "./postgres-options-CZyV9Him-2OSYJKqo.mjs";
3
3
  import { s as validatePostgresUrl } from "./binding-DkfRsUZE-Co5ssUZw.mjs";
4
- import { n as validatePostgresContract } from "./contract-from-json-PooBVhkP-D73P8986.mjs";
5
- import { n as buildPostgresStaticContext } from "./postgres-static-0dmoylj3-CXN-mFsT.mjs";
4
+ import { n as validatePostgresContract } from "./contract-from-json-BAyMAOCZ-DRubZT3w.mjs";
5
+ import { n as buildPostgresStaticContext } from "./postgres-static-DWlMG39w-CDBi8-fy.mjs";
6
6
  import { n as buildPostgresRuntimeBoundMembers } from "./postgres-members-B7ZvxGYc-D_L3NVGm.mjs";
7
7
  import { t as PostgresRuntimeImpl } from "./postgres-runtime-BKdag6p9-gHVB2jfC.mjs";
8
8
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -1 +1 @@
1
- {"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { i as validateTransactionOptions, n as toDriverCursorOptions, r as validateCursorOptions, t as DEFAULT_CONNECT_TIMEOUT_MILLIS } from \"./postgres-options-CZyV9Him.mjs\";\nimport { s as validatePostgresUrl } from \"./binding-DkfRsUZE.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-0dmoylj3.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-PooBVhkP.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-B7ZvxGYc.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-BKdag6p9.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresTarget, { postgresIsolationLevels as IsolationLevel } from \"@internal/target-postgres/runtime\";\nimport postgresDriver, { createPgClient, suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, toRuntimeOptions } from \"@internal/sql-runtime\";\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 transactionOptions = validateTransactionOptions(options.transactionOptions);\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 { sql, raw, enums, nativeEnums, toSql } = buildPostgresStaticContext(contract, context, stack);\n\tconst buildRuntimeBoundMembers = (getRuntime, getRuntimeForWork) => buildPostgresRuntimeBoundMembers({\n\t\tcontext,\n\t\tcollections: options.collections,\n\t\tsql,\n\t\traw,\n\t\tenums,\n\t\tnativeEnums,\n\t\ttoSql,\n\t\tgetRuntime,\n\t\tgetRuntimeForWork,\n\t\ttransactionOptions\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\ttoSql,\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\ttoSql,\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\tconst adapter = stack.adapter.create(stack);\n\t\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\t\tconst pgClient = suppressIdleConnectionErrors(createPgClient({\n\t\t\t\tconnectionString: url,\n\t\t\t\tconnectionTimeoutMillis: DEFAULT_CONNECT_TIMEOUT_MILLIS\n\t\t\t}, stack.target.sessionSettings ?? {}));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient: pgClient,\n\t\t\t\townedByDriver: true\n\t\t\t});\n\t\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\t\tcontext,\n\t\t\t\tadapter,\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\tawait driver.close().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 { IsolationLevel, postgresServerless as default };\n\n//# sourceMappingURL=serverless.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAA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,OAAO,eAAe;EACxB;CACD;CACA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM,QAAQ,SAAS;GACtB,MAAM,MAAM,oBAAoB,QAAQ,GAAG;GAC3C,MAAM,mBAAmB,MAAM;GAC/B,MAAM,UAAU,MAAM,QAAQ,OAAO,KAAK;GAC1C,MAAM,SAAS,iBAAiB,OAAO,EAAE,QAAQ,sBAAsB,MAAM,EAAE,CAAC;GAChF,MAAM,WAAW,6BAA6B,eAAe;IAC5D,kBAAkB;IAClB,yBAAyB;GAC1B,GAAG,MAAM,OAAO,mBAAmB,CAAC,CAAC,CAAC;GACtC,MAAM,OAAO,QAAQ;IACpB,MAAM;IACN,QAAQ;IACR,eAAe;GAChB,CAAC;GACD,MAAM,UAAU,IAAI,oBAAoB;IACvC;IACA;IACA;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,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;IACvC,MAAM,sBAAsB,KAAK,GAAG;GACrC;GACA,OAAO;EACR;CACD;AACD"}
1
+ {"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { i as validateTransactionOptions, n as toDriverCursorOptions, r as validateCursorOptions, t as DEFAULT_CONNECT_TIMEOUT_MILLIS } from \"./postgres-options-CZyV9Him.mjs\";\nimport { s as validatePostgresUrl } from \"./binding-DkfRsUZE.mjs\";\nimport { t as buildPostgresStaticContext } from \"./postgres-static-DWlMG39w.mjs\";\nimport { n as validatePostgresContract } from \"./contract-from-json-BAyMAOCZ.mjs\";\nimport { n as buildPostgresRuntimeBoundMembers } from \"./postgres-members-B7ZvxGYc.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-BKdag6p9.mjs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresTarget, { postgresIsolationLevels as IsolationLevel } from \"@internal/target-postgres/runtime\";\nimport postgresDriver, { createPgClient, suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, toRuntimeOptions } from \"@internal/sql-runtime\";\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 transactionOptions = validateTransactionOptions(options.transactionOptions);\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 { sql, raw, enums, nativeEnums, toSql } = buildPostgresStaticContext(contract, context, stack);\n\tconst buildRuntimeBoundMembers = (getRuntime, getRuntimeForWork) => buildPostgresRuntimeBoundMembers({\n\t\tcontext,\n\t\tcollections: options.collections,\n\t\tsql,\n\t\traw,\n\t\tenums,\n\t\tnativeEnums,\n\t\ttoSql,\n\t\tgetRuntime,\n\t\tgetRuntimeForWork,\n\t\ttransactionOptions\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\ttoSql,\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\ttoSql,\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\tconst adapter = stack.adapter.create(stack);\n\t\t\tconst driver = driverDescriptor.create({ cursor: toDriverCursorOptions(cursor) });\n\t\t\tconst pgClient = suppressIdleConnectionErrors(createPgClient({\n\t\t\t\tconnectionString: url,\n\t\t\t\tconnectionTimeoutMillis: DEFAULT_CONNECT_TIMEOUT_MILLIS\n\t\t\t}, stack.target.sessionSettings ?? {}));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient: pgClient,\n\t\t\t\townedByDriver: true\n\t\t\t});\n\t\t\tconst runtime = new PostgresRuntimeImpl({\n\t\t\t\tcontext,\n\t\t\t\tadapter,\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\tawait driver.close().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 { IsolationLevel, 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;E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A6B,eAAe;IAC5D,kBAAkB;IAClB,yBAAyB;GAC1B,GAAG,MAAM,OAAO,mBAAmB,CAAC,CAAC,CAAC;GACtC,MAAM,OAAO,QAAQ;IACpB,MAAM;IACN,QAAQ;IACR,eAAe;GAChB,CAAC;GACD,MAAM,UAAU,IAAI,oBAAoB;IACvC;IACA;IACA;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,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;IACvC,MAAM,sBAAsB,KAAK,GAAG;GACrC;GACA,OAAO;EACR;CACD;AACD"}
package/dist/static.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as contractFromJson } from "./contract-from-json-PooBVhkP-D73P8986.mjs";
2
- import { r as postgresStatic } from "./postgres-static-0dmoylj3-CXN-mFsT.mjs";
1
+ import { t as contractFromJson } from "./contract-from-json-BAyMAOCZ-DRubZT3w.mjs";
2
+ import { r as postgresStatic } from "./postgres-static-DWlMG39w-CDBi8-fy.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.24-dev.12",
3
+ "version": "8.0.0-rc.24-dev.14",
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.24-dev.12",
14
- "@prisma/orm-framework": "8.0.0-rc.24-dev.12",
15
- "@prisma/orm-target-postgres": "8.0.0-rc.24-dev.12",
16
- "@prisma/orm-toolchain": "8.0.0-rc.24-dev.12",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.24-dev.14",
14
+ "@prisma/orm-framework": "8.0.0-rc.24-dev.14",
15
+ "@prisma/orm-target-postgres": "8.0.0-rc.24-dev.14",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.24-dev.14",
17
17
  "@types/node": "26.1.2",
18
18
  "@types/pg": "8.20.4",
19
19
  "arktype": "^2.2.2",
@@ -23,9 +23,9 @@
23
23
  "tinyglobby": "^0.2.17"
24
24
  },
25
25
  "devDependencies": {
26
- "@internal/postgres": "8.0.0-rc.24-dev.12",
27
- "@repo/tsconfig": "8.0.0-rc.24-dev.12",
28
- "@repo/tsdown": "8.0.0-rc.24-dev.12",
26
+ "@internal/postgres": "8.0.0-rc.24-dev.14",
27
+ "@repo/tsconfig": "8.0.0-rc.24-dev.14",
28
+ "@repo/tsdown": "8.0.0-rc.24-dev.14",
29
29
  "tsdown": "0.22.14",
30
30
  "typescript": "5.9.3"
31
31
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-postgres'
18
- library_version: '8.0.0-rc.24-dev.12'
18
+ library_version: '8.0.0-rc.24-dev.14'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -118,7 +118,7 @@ model Post {
118
118
 
119
119
  Then run `pnpm prisma contract emit` (or rely on the Vite plugin — see `references/build.md`). Specify cascade behaviour explicitly with `onDelete` / `onUpdate`; the default is `Restrict`.
120
120
 
121
- **Integer, decimal, float, text, boolean and binary types.** On PostgreSQL, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean` and `Bytes` are convenience types: bare, each is the usual type (`Int` an `int4`, `BigInt` an `int8` read as a `bigint`, `Decimal` a `numeric` read as decimal text, `String` a `text`). An optional `storage` chooses another database type, and `BigInt` also takes `as`: `Int(storage: int2)`, `BigInt(as: number)` (an `int8` read as a `number` in the safe-integer range), `BigInt(storage: numeric)` (an integer of any size, read as a `bigint`), `Float(storage: float4)`, `Decimal(precision: 10, scale: 2)`, `String(storage: varchar, length: 12)`, `String(storage: char, length: 3)`. `String(length: 12)` is refused: `length` applies only to `varchar` and `char`. The contract stores the explicit type each call chooses, named after the database type (`Int2`, `Int4`, `Int8BigInt`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4`, `Float8`, `Text`, `Varchar`, `Char`, `Bool`, `Bytea`), and writing that type directly is the same. `SmallInt`, `BigIntNumber`, `Numeric`, `UnboundedInt`, `Real` and `VarChar` are deprecated names of `Int2`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4` and `Varchar`, and warn `PSL_DEPRECATED_SCALAR_NAME`. In a TypeScript contract: `type.BigInt({ as: 'number' })`, `type.String({ storage: 'varchar', length: 64 })`.
121
+ **Integer, decimal, float, text, boolean, binary and JSON types.** On PostgreSQL, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean`, `Bytes` and `Json` are convenience types: bare, each is the usual type (`Int` an `int4`, `BigInt` an `int8` read as a `bigint`, `Decimal` a `numeric` read as decimal text, `String` a `text`, `Json` a `json`). An optional `storage` chooses another database type, and `BigInt` also takes `as`: `Int(storage: int2)`, `BigInt(as: number)` (an `int8` read as a `number` in the safe-integer range), `BigInt(storage: numeric)` (an integer of any size, read as a `bigint`), `Float(storage: float4)`, `Decimal(precision: 10, scale: 2)`, `String(storage: varchar, length: 12)`, `String(storage: char, length: 3)`, `Json(storage: jsonb)`. `String(length: 12)` is refused: `length` applies only to `varchar` and `char`. The contract stores the explicit type each call chooses, named after the database type (`Int2`, `Int4`, `Int8BigInt`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4`, `Float8`, `Text`, `Varchar`, `Char`, `Bool`, `Bytea`, `Jsonb`; a `json` column is `PlainJson`), and writing that type directly is the same. A `json` column cannot be filtered by equality, and PostgreSQL refuses an index or a unique constraint on it; write `Json(storage: jsonb)` for a JSON field that needs any of these. `SmallInt`, `BigIntNumber`, `Numeric`, `UnboundedInt`, `Real` and `VarChar` are deprecated names of `Int2`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4` and `Varchar`, and warn `PSL_DEPRECATED_SCALAR_NAME`. In a TypeScript contract: `type.BigInt({ as: 'number' })`, `type.String({ storage: 'varchar', length: 64 })`, `type.Json({ storage: 'jsonb' })`.
122
122
 
123
123
  **Date and time types.** On PostgreSQL, write a field with a convenience type named for what it means: `DateTime` (a moment in time, a `timestamptz(3)` read as a JavaScript `Date`), `Date` (a calendar date, read as a string such as `"2024-02-29"`), `Time` (a time of day, read as a string) or `Duration` (an ISO 8601 duration string such as `"P1M"`). None needs `Temporal`. Optional arguments choose another explicit type: `as`, the value the application reads (`jsDate`, `temporal` or `string` for `DateTime`; `string` or `temporal` for `Date` and `Time`; `string` or `parts` for `Duration`), `storage`, the database type that stores it (`timestamptz` or `timestamp` for `DateTime`; `time` or, with `as: string`, `timetz` for `Time`), and `precision`: `DateTime(as: temporal)`, `DateTime(storage: timestamp)`, `Time(precision: 0)`. The contract stores only the explicit type, and `contract print` writes it; the full table is [Scalar types](https://github.com/prisma/orm/blob/main/docs/reference/scalar-types.md). SQLite has the same four types with the same defaults, all stored as text: `DateTime` reads a `Date`, `DateTime(as: temporal)` a `Temporal.Instant` and `DateTime(as: string)` the stored text `"2024-01-01T00:00:00.000Z"`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00.000"`, or `Temporal.PlainDate` and `Temporal.PlainTime` with `as: temporal`; `Duration` reads an ISO 8601 duration. SQLite has no `storage` choices and no `precision`: an instant and a time hold milliseconds. MySQL has the same four types with the same defaults: `DateTime` is a `datetime(3)` read as a `Date`, `storage: timestamp` picks a `timestamp` column (1970 to 2038), and `as: temporal` and `as: string` default to `precision: 6`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00"`; `Duration` is ISO 8601 text in a `varchar(191)`. Every MySQL instant is UTC, and a value written with more fraction digits than its column holds is cut to the column's precision, not rounded, but a value with digits below a microsecond (a `Temporal` value ending in `.123456789`) is refused, so round it to microseconds first; a column with no written precision holds whole seconds. `Time(3)` is refused, because the first argument is `as`; write `Time(precision: 3)`. In a TypeScript contract the helpers take one object: `type.DateTime({ as: 'string', precision: 6 })`, `type.Time({ storage: 'timetz' })`.
124
124
 
@@ -171,7 +171,7 @@ Note: scalar lists (e.g. `String[]`) are gated on the target's `sql.scalarList`
171
171
 
172
172
  ## Workflow — Edit a model / field / relation (TS builder)
173
173
 
174
- The concept: same model, different authoring surface. The façade re-exports `defineContract`, `field`, `model`, `rel`, plus the `family`/`target` packs as default exports of `@internal/postgres/family` and `@internal/postgres/target`. Use the callback overload (`defineContract({...}, ({ field, model, rel, type, gen }) => ({...}))`) to get the type constructors, type aliases and generator calls (`field.column(type.String())`, `field.column(type.Uuid()).id().onCreate(gen.uuid(7))`, `field.column(type.temporal.CreatedAt())`, `type.sql.String(35)`).
174
+ The concept: same model, different authoring surface. The façade re-exports `defineContract`, `field`, `model`, `rel`, plus the `family`/`target` packs as default exports of `@internal/postgres/family` and `@internal/postgres/target`. Use the callback overload (`defineContract({...}, ({ field, model, rel, type, gen }) => ({...}))`) to get the type constructors, type aliases and generator calls (`field.column(type.String())`, `field.column(type.Uuid()).id().onCreate(gen.uuid(7))`, `field.column(type.temporal.CreatedAt())`, `type.sql.Varchar(35)`).
175
175
 
176
176
  ```typescript
177
177
  import sqlFamily from '@internal/postgres/family';
@@ -210,7 +210,7 @@ Update callbacks return arrays of field operations (`.set`, `.inc`, `.push`, `.p
210
210
 
211
211
  ## Workflow — Prepared statements (`db.prepare`)
212
212
 
213
- The concept: `db.prepare(declaration, (p) => plan)` builds a query-builder plan once and runs it many times with different values. The declaration names each parameter's codec (`{ email: 'mongo/string@1' }`, or `{ codecId: 'mongo/string@1', nullable: true }` to allow `null`); unknown codec ids fail to compile. The callback receives one placeholder per name and puts it where a value goes: filter operators (`eq`, `in`, …), update operators (`set`, `push`, …), insert documents, `fn.literal(p.x)`, and `limit` / `skip` (with a codec whose input is a number, such as `mongo/int32@1`). Each run encodes the value with the declared codec. Preparing opens no connection; run the handle against `await db.runtime()`:
213
+ The concept: `db.prepare(declaration, (p) => plan)` builds a query-builder plan or an ORM read once and runs it many times with different values. The declaration names each parameter's codec (`{ email: 'mongo/string@1' }`, or `{ codecId: 'mongo/string@1', nullable: true }` to allow `null`); unknown codec ids fail to compile. The callback receives one placeholder per name and puts it where a value goes: filter operators (`eq`, `in`, …), update operators (`set`, `push`, …), insert documents, `fn.literal(p.x)`, and `limit` / `skip` (with a codec whose input is a number, such as `mongo/int32@1`). Each run encodes the value with the declared codec. Preparing opens no connection; run the handle against `await db.runtime()`:
214
214
 
215
215
  ```typescript
216
216
  const byAuthor = await db.prepare(
@@ -228,7 +228,18 @@ const runtime = await db.runtime();
228
228
  const recent = await byAuthor.query(runtime, { authorId: someHexId, take: 10 }).toArray();
229
229
  ```
230
230
 
231
- An `updateOne`, `updateMany`, `deleteOne` or `deleteMany` plan gives a handle with `execute(runtime, params)` as well as `query`, resolving `{ affectedRows }`. `runtime.prepare(...)` is the same thing on a `MongoRuntime`. A declared name the plan never uses throws `RUNTIME.PREPARE_UNUSED_PARAM`; a placeholder in a `db.raw` command throws `RUNTIME.PREPARE_RAW_PLACEHOLDER`; a placeholder whose name, codec id or nullability the declaration does not give throws `RUNTIME.PREPARE_UNDECLARED_PARAM`; a missing value at run time throws `RUNTIME.PREPARE_MISSING_PARAM`. A `db.raw` command with no placeholders can be prepared and is sent as written on each run. ORM reads (`.prepared.all()`) cannot be prepared yet. Design: [ADR 318](../../../docs/architecture%20docs/adrs/ADR%20318%20-%20MongoDB%20prepared%20statements.md).
231
+ An `updateOne`, `updateMany`, `deleteOne` or `deleteMany` plan gives a handle with `execute(runtime, params)` as well as `query`, resolving `{ affectedRows }`. `runtime.prepare(...)` on a `MongoRuntime` takes query-builder and raw plans only, not ORM reads. A declared name the plan never uses throws `RUNTIME.PREPARE_UNUSED_PARAM`; a placeholder in a `db.raw` command throws `RUNTIME.PREPARE_RAW_PLACEHOLDER`; a placeholder whose name, codec id or nullability the declaration does not give throws `RUNTIME.PREPARE_UNDECLARED_PARAM`; a missing value at run time throws `RUNTIME.PREPARE_MISSING_PARAM`. A `db.raw` command with no placeholders can be prepared and is sent as written on each run.
232
+
233
+ ORM reads are prepared through `.prepared.all()`, `.prepared.first()` and `.prepared.firstOrThrow()`. The handle's `query(runtime, params)` returns what the ad-hoc read returns: a row stream, `Row | null`, or `Row` (rejecting with `RUNTIME.NO_ROWS` when nothing matches). It has no `execute`.
234
+
235
+ ```typescript
236
+ const byEmail = await db.prepare({ email: 'mongo/string@1', take: 'mongo/int32@1' }, (p) =>
237
+ db.orm.users.where({ email: p.email }).include('posts').limit(p.take).prepared.all(),
238
+ );
239
+ const users = await byEmail.query(await db.runtime(), { email: 'alice@example.com', take: 5 }).toArray();
240
+ ```
241
+
242
+ In an ORM read, a placeholder goes in `limit`, `offset`, a scalar field's value in an object-form `where`, or the operand of a comparison (`$eq`, `$ne`, `$gt`, …) or an item of `$in` / `$nin` on a scalar field in a filter-expression `where`. Its codec must be the field's codec (the element codec on a list field, where it matches one item), and it may be nullable only on a nullable field that is not a list. Anything else (another operator, `$expr`, a value object, a whole list) throws `ORM.ARGUMENT_INVALID` when the `where` is built. ORM writes cannot be prepared; a write on a collection whose `where` holds a placeholder throws `ORM.ARGUMENT_INVALID`. `first()` and `firstOrThrow()` set the limit to 1, so a declared `limit` placeholder there throws `RUNTIME.PREPARE_UNUSED_PARAM`. Design: [ADR 318](../../../docs/architecture%20docs/adrs/ADR%20318%20-%20MongoDB%20prepared%20statements.md).
232
243
 
233
244
  ## Common Pitfalls (Mongo)
234
245
 
@@ -149,7 +149,7 @@ There is no `.stream()` method on a client or on a connection.
149
149
 
150
150
  ## Prepared statements (Postgres, SQLite, MySQL, MongoDB)
151
151
 
152
- This section covers the SQL clients. MongoDB's `db.prepare` has the same shape and runs against `await db.runtime()`; see *Workflow — Prepared statements* in [`queries-mongo.md`](queries-mongo.md).
152
+ This section covers the SQL clients. MongoDB's `db.prepare` has the same shape, takes query-builder plans and ORM `.prepared` reads, and runs against `await db.runtime()`; see *Workflow — Prepared statements* in [`queries-mongo.md`](queries-mongo.md).
153
153
 
154
154
  `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`.
155
155
 
@@ -219,7 +219,7 @@ Then run the snippet from *Your first arc* above against the `User` model. When
219
219
 
220
220
  ## Workflow — Brownfield-DB (existing database, no contract)
221
221
 
222
- The concept: against an existing database with no PN contract, `contract infer` walks the live schema (tables, columns, indexes — including expression and partial ones — constraints, and RLS enablement + policies) and writes a PSL contract that describes it. Where authoring would generate a CHECK constraint the database does not carry (the element-non-null check on a list column), infer writes the list with nullable elements (`String?[]`), which derives no such check, so the contract declares exactly what the database enforces. The reverse gap is closed too: a hand-written CHECK constraint the database enforces that authoring would never have generated comes back as `@@check(expression: <reprint>, map: "<name>")`, so it is a declared object from the first pull instead of an invisible extra a later destructive plan could drop. That inferred check warns (`PN_EXACT_NAME_BODY_COMPARISON`) the next time you run `contract emit` — expected, not a defect: the warning fires on any `map:` body regardless of who wrote it, and the comparison stays sound because both sides are Postgres's own reprint. Columns come back as the convenience types with their defaults, and only the arguments that differ: `int2` as `Int(storage: int2)`, `numeric(10,2)` as `Decimal(precision: 10, scale: 2)`, `varchar(12)` as `String(storage: varchar, length: 12)`, `timestamptz(3)` as `DateTime` (a JavaScript `Date`), a `timestamptz` with no declared precision as `DateTime(precision: 6)`, `timestamp(3)` as `DateTime(storage: timestamp)`, `date` as `Date`, `time` as `Time` and `interval` as `Duration` (ISO strings). A `Date` holds milliseconds, so a timestamp column whose values use microseconds reads with them dropped: change such a field to `DateTime(as: temporal)` or `DateTime(as: string)` to keep them. The result is a *starting point*, not the final contract — review and clean it up, then `db sign` to record the current contract hash as the marker (instead of letting `db init` try to recreate the schema from scratch). By default `db sign` also sets the `db` ref and stores the contract snapshot, so the next `migration plan` chains from the adopted schema — even when the database is named with `--db`. `--advance-ref <name>` writes another ref instead and `--no-advance-ref` writes none; in either case the next plan needs `--from` or a `db` ref you set yourself.
222
+ The concept: against an existing database with no PN contract, `contract infer` walks the live schema (tables, columns, indexes — including expression and partial ones — constraints, and RLS enablement + policies) and writes a PSL contract that describes it. Where authoring would generate a CHECK constraint the database does not carry (the element-non-null check on a list column), infer writes the list with nullable elements (`String?[]`), which derives no such check, so the contract declares exactly what the database enforces. The reverse gap is closed too: a hand-written CHECK constraint the database enforces that authoring would never have generated comes back as `@@check(expression: <reprint>, map: "<name>")`, so it is a declared object from the first pull instead of an invisible extra a later destructive plan could drop. That inferred check warns (`PN_EXACT_NAME_BODY_COMPARISON`) the next time you run `contract emit` — expected, not a defect: the warning fires on any `map:` body regardless of who wrote it, and the comparison stays sound because both sides are Postgres's own reprint. Columns come back as the convenience types with their defaults, and only the arguments that differ: `int2` as `Int(storage: int2)`, `numeric(10,2)` as `Decimal(precision: 10, scale: 2)`, `varchar(12)` as `String(storage: varchar, length: 12)`, `json` as `Json`, `jsonb` as `Json(storage: jsonb)`, `timestamptz(3)` as `DateTime` (a JavaScript `Date`), a `timestamptz` with no declared precision as `DateTime(precision: 6)`, `timestamp(3)` as `DateTime(storage: timestamp)`, `date` as `Date`, `time` as `Time` and `interval` as `Duration` (ISO strings). A `Date` holds milliseconds, so a timestamp column whose values use microseconds reads with them dropped: change such a field to `DateTime(as: temporal)` or `DateTime(as: string)` to keep them. The result is a *starting point*, not the final contract — review and clean it up, then `db sign` to record the current contract hash as the marker (instead of letting `db init` try to recreate the schema from scratch). By default `db sign` also sets the `db` ref and stores the contract snapshot, so the next `migration plan` chains from the adopted schema — even when the database is named with `--db`. `--advance-ref <name>` writes another ref instead and `--no-advance-ref` writes none; in either case the next plan needs `--from` or a `db` ref you set yourself.
223
223
 
224
224
  ```bash
225
225
  mkdir my-app && cd my-app