@prisma/orm-postgres 8.0.0-rc.2-dev.2 → 8.0.0-rc.20
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/README.md +4 -7
- package/dist/config.d.mts +12 -4
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +34 -19
- package/dist/config.mjs.map +1 -1
- package/dist/contract-builder.d.mts +188 -58
- package/dist/contract-builder.d.mts.map +1 -1
- package/dist/contract-builder.mjs +91 -11
- package/dist/contract-builder.mjs.map +1 -1
- package/dist/contract-from-json-ZRZt8Cse-DMkmmOW1.d.mts +26 -0
- package/dist/contract-from-json-ZRZt8Cse-DMkmmOW1.d.mts.map +1 -0
- package/dist/contract-from-json-ePdyekFz-BPQdc8oQ.mjs +33 -0
- package/dist/contract-from-json-ePdyekFz-BPQdc8oQ.mjs.map +1 -0
- package/dist/contract__validate-once.d.mts +1 -0
- package/dist/contract__validate-once.mjs +2 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +1 -1
- package/dist/control.mjs.map +1 -1
- package/dist/{errors-DfWK9xep-CYOOg0sB.mjs → errors-DfWK9xep-CB07krZF.mjs} +2 -2
- package/dist/errors-DfWK9xep-CB07krZF.mjs.map +1 -0
- package/dist/family-contract__data-type-support.d.mts +1 -0
- package/dist/family-contract__data-type-support.mjs +2 -0
- package/dist/family-contract__data-type.d.mts +1 -0
- package/dist/family-contract__data-type.mjs +2 -0
- package/dist/family-contract__sql-expression.d.mts +1 -0
- package/dist/family-contract__sql-expression.mjs +2 -0
- package/dist/family__psl-build.d.mts +1 -0
- package/dist/family__psl-build.mjs +2 -0
- package/dist/internal__static-context.d.mts +2 -0
- package/dist/internal__static-context.mjs +2 -0
- package/dist/internal__transaction-members.d.mts +2 -0
- package/dist/internal__transaction-members.mjs +2 -0
- package/dist/internal__validate-contract.d.mts +2 -0
- package/dist/internal__validate-contract.mjs +2 -0
- package/dist/postgres-members-BuiQxl75-CRdesQuN.mjs +86 -0
- package/dist/postgres-members-BuiQxl75-CRdesQuN.mjs.map +1 -0
- package/dist/postgres-members-Cuvcnuok--adyzJpM.d.mts +48 -0
- package/dist/postgres-members-Cuvcnuok--adyzJpM.d.mts.map +1 -0
- package/dist/postgres-options-HIC8ThD0-k6eyhDIx.d.mts +28 -0
- package/dist/postgres-options-HIC8ThD0-k6eyhDIx.d.mts.map +1 -0
- package/dist/postgres-runtime-xWysBSgi-7GrCIG7R.mjs +108 -0
- package/dist/postgres-runtime-xWysBSgi-7GrCIG7R.mjs.map +1 -0
- package/dist/postgres-static-Bk5dTOiw-iFxbNeTA.mjs +80 -0
- package/dist/postgres-static-Bk5dTOiw-iFxbNeTA.mjs.map +1 -0
- package/dist/postgres-static-CGyjvgUc-C_iJje8L.d.mts +69 -0
- package/dist/postgres-static-CGyjvgUc-C_iJje8L.d.mts.map +1 -0
- package/dist/relational-core__collection-methods.d.mts +1 -0
- package/dist/relational-core__collection-methods.mjs +2 -0
- package/dist/relational-core__functions.d.mts +1 -0
- package/dist/relational-core__functions.mjs +2 -0
- package/dist/relational-core__index-reference.d.mts +1 -0
- package/dist/relational-core__index-reference.mjs +2 -0
- package/dist/runtime.d.mts +77 -4
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +66 -155
- package/dist/runtime.mjs.map +1 -1
- package/dist/serverless.d.mts +27 -40
- package/dist/serverless.d.mts.map +1 -1
- package/dist/serverless.mjs +120 -50
- package/dist/serverless.mjs.map +1 -1
- package/dist/static.d.mts +3 -24
- package/dist/static.mjs +3 -2
- package/dist/target__data-types.d.mts +1 -0
- package/dist/target__data-types.mjs +2 -0
- package/dist/target__full-text-index-authoring.d.mts +1 -0
- package/dist/target__full-text-index-authoring.mjs +2 -0
- package/dist/target__full-text.d.mts +1 -0
- package/dist/target__full-text.mjs +2 -0
- package/dist/target__marker-lock.d.mts +1 -0
- package/dist/target__marker-lock.mjs +2 -0
- package/dist/target__operation-types.d.mts +1 -0
- package/dist/target__operation-types.mjs +2 -0
- package/dist/utils__suppress-idle-connection-errors.d.mts +1 -0
- package/dist/utils__suppress-idle-connection-errors.mjs +2 -0
- package/dist/utils__text.d.mts +1 -0
- package/dist/utils__text.mjs +2 -0
- package/package.json +37 -19
- package/skills/prisma-8/SKILL.md +96 -0
- package/skills/prisma-8/references/build.md +142 -0
- package/skills/prisma-8/references/contract.md +544 -0
- package/skills/prisma-8/references/debug.md +149 -0
- package/skills/prisma-8/references/feedback.md +251 -0
- package/skills/prisma-8/references/migration-model.md +179 -0
- package/skills/prisma-8/references/migration-review.md +211 -0
- package/skills/prisma-8/references/migrations.md +581 -0
- package/skills/prisma-8/references/queries-mongo.md +238 -0
- package/skills/prisma-8/references/queries-postgres.md +710 -0
- package/skills/prisma-8/references/queries.md +253 -0
- package/skills/prisma-8/references/quickstart.md +317 -0
- package/skills/prisma-8/references/runtime.md +463 -0
- package/skills/prisma-8/references/supabase.md +234 -0
- package/skills/prisma-8/references/upgrade-app.md +102 -0
- package/skills/prisma-8/references/upgrade-extension.md +106 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.10-to-0.11/instructions.md +56 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/instructions.md +381 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-closed-mongo-contracts.ts +202 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-domain-namespaced-contracts.ts +201 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/re-emit-postgres-public-default.ts +198 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/instructions.md +339 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.12-to-0.13/re-emit-mti-variant-link-columns.ts +229 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/instructions.md +543 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.14-to-0.15/instructions.md +359 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.15-to-0.16/instructions.md +173 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/instructions.md +805 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.17-to-8.0.0-rc.1/instructions.md +72 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.7-to-0.8/instructions.md +8 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/instructions.md +36 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/instructions.md +86 -0
- package/skills/prisma-8/upgrading/app/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +588 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +639 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/multifile-psl/add-use-prisma-8-directive.mjs +60 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +332 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +489 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +1368 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +108 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +755 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +973 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/scripts/sql-expression-literals-psl/rewrite-sql-strings.mjs +271 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +1826 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +382 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/data-type-values/data-type-values.ts +1117 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/default-generators-to-on-create/rewrite-default-generators.mjs +86 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/mongo-field-storage-names/mongo-field-storage-names.ts +250 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +813 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +502 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1171 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +158 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +42 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +157 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +36 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +63 -0
- package/skills/prisma-8/upgrading/app/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +84 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.10-to-0.11/instructions.md +276 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/instructions.md +738 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/migrate-contract-testing-imports.ts +97 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/regenerate-extension-public-baseline.ts +223 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.11-to-0.12/strip-migration-labels-hints.ts +340 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.12-to-0.13/instructions.md +266 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/instructions.md +522 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/migration-op-factories-to-methods.ts +290 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.13-to-0.14/uuid-preset-rename.ts +43 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.14-to-0.15/instructions.md +803 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.15-to-0.16/instructions.md +219 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/instructions.md +731 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.16-to-0.17/strip-sha256-hash-prefixes.ts +382 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.17-to-8.0.0-rc.1/instructions.md +194 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.7-to-0.8/instructions.md +8 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/instructions.md +57 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.8-to-0.9/strip-inline-contracts.ts +226 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/instructions.md +150 -0
- package/skills/prisma-8/upgrading/extension/upgrades/0.9-to-0.10/stamp-storage-types-kind.ts +360 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md +746 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.10-to-8.0.0-rc.11/instructions.md +34 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/instructions.md +857 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.11-to-8.0.0-rc.12/scripts/psl-verbatim-table-names/add-model-map.mjs +256 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/instructions.md +504 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.12-to-8.0.0-rc.13/scripts/execution-ref-entry-field/rename-execution-ref-keys.ts +193 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.13-to-8.0.0-rc.14/instructions.md +143 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/instructions.md +2168 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.14-to-8.0.0-rc.15/scripts/data-type-in-contract/data-type-in-contract.ts +1492 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.15-to-8.0.0-rc.16/instructions.md +223 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.16-to-8.0.0-rc.17/instructions.md +583 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.17-to-8.0.0-rc.18/instructions.md +1008 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/instructions.md +2000 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/client-takes-contract-value/contract-from-json.ts +382 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.18-to-8.0.0-rc.19/scripts/remove-nocheck/remove-nocheck.ts +813 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/instructions.md +379 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.19-to-8.0.0-rc.20/scripts/expand-type-aliases/expand-type-aliases.ts +1171 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.2-to-8.0.0-rc.3/instructions.md +5 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.3-to-8.0.0-rc.4/instructions.md +137 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.4-to-8.0.0-rc.5/instructions.md +129 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.5-to-8.0.0-rc.6/instructions.md +102 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.6-to-8.0.0-rc.7/instructions.md +33 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.7-to-8.0.0-rc.8/instructions.md +35 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.8-to-8.0.0-rc.9/instructions.md +86 -0
- package/skills/prisma-8/upgrading/extension/upgrades/8.0.0-rc.9-to-8.0.0-rc.10/instructions.md +63 -0
- package/dist/adapter__operation-types.d.mts +0 -1
- package/dist/adapter__operation-types.mjs +0 -2
- package/dist/errors-DfWK9xep-CYOOg0sB.mjs.map +0 -1
- package/dist/family-contract__pack-types.d.mts +0 -1
- package/dist/family-contract__pack-types.mjs +0 -2
- package/dist/postgres-cOpneO7v-BHrCx-xd.d.mts +0 -133
- package/dist/postgres-cOpneO7v-BHrCx-xd.d.mts.map +0 -1
- package/dist/postgres-runtime-GybTEgP4-DpGY305_.mjs +0 -7
- package/dist/postgres-runtime-GybTEgP4-DpGY305_.mjs.map +0 -1
- package/dist/postgres-static-CRl91mRo-Dw1sFrog.mjs +0 -74
- package/dist/postgres-static-CRl91mRo-Dw1sFrog.mjs.map +0 -1
- package/dist/static.d.mts.map +0 -1
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import { t as postgresError } from "./errors-DfWK9xep-
|
|
1
|
+
import { t as postgresError } from "./errors-DfWK9xep-CB07krZF.mjs";
|
|
2
2
|
import { PG_ENUM_CODEC_ID } from "@prisma/orm-target-postgres/target/codec-ids";
|
|
3
3
|
import postgresPackRef from "@prisma/orm-target-postgres/target/pack";
|
|
4
4
|
import { PostgresNativeEnum, postgresCreateNamespace } from "@prisma/orm-target-postgres/target/types";
|
|
5
5
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
6
|
-
import { bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check,
|
|
6
|
+
import { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, member, model, now, rel, sql } from "@prisma/orm-family-sql/contract-ts/contract-builder";
|
|
7
|
+
import { postgresAdapterContractContributions } from "@prisma/orm-target-postgres/adapter/adapter";
|
|
7
8
|
import sqlFamilyPack from "@prisma/orm-family-sql/family/pack";
|
|
8
|
-
import {
|
|
9
|
+
import { assembleDataTypeSupport } from "@prisma/orm-framework/components/authoring";
|
|
10
|
+
import { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from "@prisma/orm-target-postgres/target/codecs";
|
|
11
|
+
import { requireSqlExpression } from "@prisma/orm-family-sql/contract/sql-expression";
|
|
12
|
+
import { FULL_TEXT_INDEX_TYPE, describeFullTextIndexProblem, fullTextIndexProblems, postgresCodecTraitsOf, weightGroupsOf } from "@prisma/orm-target-postgres/target/full-text-index-authoring";
|
|
13
|
+
import { DEFAULT_FULL_TEXT_SEARCH_LANGUAGE } from "@prisma/orm-target-postgres/target/sql-utils";
|
|
14
|
+
import { assertDefined } from "@prisma/orm-framework/utils/assertions";
|
|
9
15
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
10
16
|
import { POLICY_OPERATION_PREDICATES } from "@prisma/orm-target-postgres/target/rls-canonicalize";
|
|
11
|
-
//#region ../../../3-
|
|
17
|
+
//#region ../../../3-targets/postgres/9-facade/dist/contract-builder.mjs
|
|
18
|
+
const adapter = postgresAdapterContractContributions;
|
|
12
19
|
function defineContract(definition, factory) {
|
|
20
|
+
const extensions = Object.values(definition.extensions ?? {});
|
|
21
|
+
const dataTypeLookup = definition.dataTypeLookup ?? assembleDataTypeSupport([
|
|
22
|
+
sqlFamilyPack,
|
|
23
|
+
postgresPackRef,
|
|
24
|
+
...extensions
|
|
25
|
+
], () => void 0).support.lookup;
|
|
13
26
|
const bound = {
|
|
14
27
|
...definition,
|
|
15
|
-
|
|
28
|
+
adapter,
|
|
29
|
+
createNamespace: postgresCreateNamespace,
|
|
30
|
+
codecLookup: definition.codecLookup ?? assemblePostgresCodecRegistryWithBuiltins(extensions, dataTypeLookup),
|
|
31
|
+
dataTypeLookup
|
|
16
32
|
};
|
|
17
33
|
if (factory !== void 0) return buildBoundContract(sqlFamilyPack, postgresPackRef, bound, factory);
|
|
18
34
|
return buildBoundContract(sqlFamilyPack, postgresPackRef, bound);
|
|
@@ -29,6 +45,72 @@ function defineContract(definition, factory) {
|
|
|
29
45
|
* set, which is why the binding happens here, per target.
|
|
30
46
|
*/
|
|
31
47
|
const enumType = bindEnumType();
|
|
48
|
+
const { support } = assembleDataTypeSupport([sqlFamilyPack, postgresPackRef], () => void 0);
|
|
49
|
+
const helpers = createComposedAuthoringHelpers({
|
|
50
|
+
family: sqlFamilyPack,
|
|
51
|
+
target: postgresPackRef,
|
|
52
|
+
codecLookup: assemblePostgresCodecRegistryWithBuiltins([], support.lookup)
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* The field builders of the `defineContract` callback for Postgres, without extensions: `field.text()`, `field.temporal.timestamptz()`, `field.uuidString()`, and `field.column(columnType)`. Use it outside a contract, for example to declare the fields of a query fragment.
|
|
56
|
+
*/
|
|
57
|
+
const field = helpers.field;
|
|
58
|
+
/**
|
|
59
|
+
* The generator function calls of the `defineContract` callback for Postgres, without extensions, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.
|
|
60
|
+
*/
|
|
61
|
+
const gen = helpers.gen;
|
|
62
|
+
function isColumnRef(value) {
|
|
63
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
64
|
+
}
|
|
65
|
+
function fullTextIndex(fields, options) {
|
|
66
|
+
const fieldGroups = weightGroupsOf(fields, isColumnRef).map((group) => group.map((ref) => ref.fieldName));
|
|
67
|
+
refuseInvalid({ weightGroups: fieldGroups });
|
|
68
|
+
const language = options.language ?? DEFAULT_FULL_TEXT_SEARCH_LANGUAGE;
|
|
69
|
+
const fieldNames = fieldGroups.flat();
|
|
70
|
+
return {
|
|
71
|
+
kind: "index",
|
|
72
|
+
fields: fieldNames,
|
|
73
|
+
type: FULL_TEXT_INDEX_TYPE,
|
|
74
|
+
options: (columns) => {
|
|
75
|
+
const columnOf = new Map(fieldNames.map((fieldName, i) => [fieldName, columns[i]]));
|
|
76
|
+
refuseInvalid({
|
|
77
|
+
weightGroups: fieldGroups,
|
|
78
|
+
codecs: {
|
|
79
|
+
codecIdOf: (fieldName) => columnOf.get(fieldName)?.codecId,
|
|
80
|
+
traitsOf: postgresCodecTraitsOf
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const columnNameOf = (fieldName) => {
|
|
84
|
+
const column = columnOf.get(fieldName);
|
|
85
|
+
assertDefined(column, `fullTextIndex field "${fieldName}" was resolved to a column`);
|
|
86
|
+
return column.name;
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
weightGroups: fieldGroups.map((group) => group.map(columnNameOf)),
|
|
90
|
+
language
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
...options.where !== void 0 ? { where: requireSqlExpression(options.where, `${fullTextIndexOwner(fieldNames, options)} where`) } : {},
|
|
94
|
+
...options.name !== void 0 ? { name: options.name } : {},
|
|
95
|
+
...options.map !== void 0 ? { map: options.map } : {}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function fullTextIndexOwner(fieldNames, options) {
|
|
99
|
+
const name = options.name ?? options.map;
|
|
100
|
+
return name === void 0 ? `Full-text index on fields ${fieldNames.map((fieldName) => `"${fieldName}"`).join(", ")}` : `Full-text index "${name}"`;
|
|
101
|
+
}
|
|
102
|
+
function refuseInvalid(candidate) {
|
|
103
|
+
const [problem] = fullTextIndexProblems(candidate);
|
|
104
|
+
if (problem === void 0) return;
|
|
105
|
+
throw postgresError("CONTRACT.INDEX_INVALID", describeFullTextIndexProblem("fullTextIndex", problem), {
|
|
106
|
+
why: "Each top-level item of the fields is one weight group; Postgres has four weights, A to D, each field belongs to one group, and to_tsvector takes text.",
|
|
107
|
+
fix: "List each text field once, in at most four non-empty groups.",
|
|
108
|
+
meta: {
|
|
109
|
+
helper: "fullTextIndex",
|
|
110
|
+
fields: candidate.weightGroups
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
32
114
|
function buildNativeEnumHandle(name, typeName, members) {
|
|
33
115
|
if (typeName.trim().length === 0) throw postgresError("CONTRACT.ENUM_INVALID", `nativeEnum("${name}"): the Postgres type name must be a non-empty string.`, {
|
|
34
116
|
fix: "Pass a non-empty Postgres type name to .map(typeName).",
|
|
@@ -58,8 +140,8 @@ function buildNativeEnumHandle(name, typeName, members) {
|
|
|
58
140
|
* `deriveValueSetFromEntity` fold PSL's native enums go through — once
|
|
59
141
|
* `pg.enum(handle)` lands the entity in the field's owning namespace.
|
|
60
142
|
*
|
|
61
|
-
* The first argument is the entity `name` (the `entries.
|
|
62
|
-
* `entries.
|
|
143
|
+
* The first argument is the entity `name` (the `entries.valueSet` key). The
|
|
144
|
+
* Postgres type name, the `entries.native_enum` key, defaults to `name`; use
|
|
63
145
|
* `.map(typeName)` to override it (PSL's `@@map`).
|
|
64
146
|
*
|
|
65
147
|
* A handle referenced by columns in N different namespaces materialises N
|
|
@@ -106,8 +188,7 @@ function nativeEnum(name, ...members) {
|
|
|
106
188
|
return buildNativeEnumHandle(name, name, members);
|
|
107
189
|
}
|
|
108
190
|
/**
|
|
109
|
-
* Builds the deferred column descriptor for `handle`:
|
|
110
|
-
* name and `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same
|
|
191
|
+
* Builds the deferred column descriptor for `handle`: its `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same
|
|
111
192
|
* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),
|
|
112
193
|
* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity
|
|
113
194
|
* `name` (not the Postgres type name — they differ when `.map()` was used).
|
|
@@ -121,7 +202,6 @@ function pgEnumColumn(handle) {
|
|
|
121
202
|
if (resolved === void 0) throw new InternalError(`pg.enum("${handle.name}"): handle.entity is not a PostgresNativeEnum. This is an authoring-surface bug — nativeEnum() must always produce one.`);
|
|
122
203
|
return {
|
|
123
204
|
codecId: PG_ENUM_CODEC_ID,
|
|
124
|
-
nativeType: resolved.nativeType,
|
|
125
205
|
typeParams: resolved.typeParams,
|
|
126
206
|
entityRef: {
|
|
127
207
|
entityKind: handle.entityKind,
|
|
@@ -227,6 +307,6 @@ function policyAll(model, descriptor) {
|
|
|
227
307
|
return buildPolicyHandle("all", model, descriptor);
|
|
228
308
|
}
|
|
229
309
|
//#endregion
|
|
230
|
-
export { buildSqlContractFromDefinition, check, defineContract, enumType, field, member, model, nativeEnum, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role };
|
|
310
|
+
export { autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql };
|
|
231
311
|
|
|
232
312
|
//# sourceMappingURL=contract-builder.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/contract-builder.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresPackRef from \"@internal/target-postgres/pack\";\nimport { PostgresNativeEnum, postgresCreateNamespace } from \"@internal/target-postgres/types\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, field, member, model, rel } from \"@internal/sql-contract-ts/contract-builder\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { pgEnumDescriptor } from \"@internal/target-postgres/codecs\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { POLICY_OPERATION_PREDICATES } from \"@internal/target-postgres/rls-canonicalize\";\n//#region src/contract/define-contract.ts\nfunction defineContract(definition, factory) {\n\tconst bound = {\n\t\t...definition,\n\t\tcreateNamespace: postgresCreateNamespace\n\t};\n\tif (factory !== void 0) return buildBoundContract(sqlFamilyPack, postgresPackRef, bound, factory);\n\treturn buildBoundContract(sqlFamilyPack, postgresPackRef, bound);\n}\n//#endregion\n//#region src/contract/enum-type.ts\n/**\n* The `enumType` authors call when building a Postgres contract (re-exported\n* from `@internal/postgres/contract-builder`).\n*\n* `bindEnumType` is the core, codec-agnostic `enumType` factory; calling it with\n* the Postgres pack's codec typemap fixes which member-value type each codec\n* permits, so `member()` values are checked against the column's codec at\n* authoring time: `pg/text@1` requires `string`, `pg/int4@1` requires `number`,\n* and a mismatch is a compile error. The core `enumType` can't know the codec\n* set, which is why the binding happens here, per target.\n*/\nconst enumType = bindEnumType();\n//#endregion\n//#region src/contract/native-enum.ts\nfunction buildNativeEnumHandle(name, typeName, members) {\n\tif (typeName.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): the Postgres type name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty Postgres type name to .map(typeName).\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty type name\"\n\t\t}\n\t});\n\treturn {\n\t\tentityKind: \"native_enum\",\n\t\tname,\n\t\ttypeName,\n\t\tmembers,\n\t\tentity: new PostgresNativeEnum({\n\t\t\ttypeName,\n\t\t\tmembers\n\t\t}),\n\t\tmap: (mappedTypeName) => buildNativeEnumHandle(name, mappedTypeName, members)\n\t};\n}\n/**\n* Declares a native Postgres enum type for use with {@link pg}'s `.enum()`\n* column helper. Mirrors PSL's `native_enum <Name> { … }` lowering\n* (`lowerNativeEnumFromBlock`): validates a non-empty, duplicate-free member\n* list and builds the same {@link PostgresNativeEnum} entity. Its value-set is\n* derived generically at contract-build time — the same\n* `deriveValueSetFromEntity` fold PSL's native enums go through — once\n* `pg.enum(handle)` lands the entity in the field's owning namespace.\n*\n* The first argument is the entity `name` (the `entries.native_enum` /\n* `entries.valueSet` key). The Postgres type name defaults to `name`; use\n* `.map(typeName)` to override it (PSL's `@@map`).\n*\n* A handle referenced by columns in N different namespaces materialises N\n* native enum types (one per namespace) — by design: a Postgres type lives in\n* exactly one schema, and PSL can't share a type across schemas either.\n*\n* @example\n* ```ts\n* // name === Postgres type name\n* const Role = nativeEnum('Role', 'user', 'admin');\n* // entity name `AalLevel`, Postgres type `aal_level` (Supabase's auth.aal_level)\n* const AalLevel = nativeEnum('AalLevel', 'aal1', 'aal2', 'aal3').map('aal_level');\n* model('Session', { fields: { aal: field.column(pg.enum(AalLevel)).optional() } });\n* ```\n*/\nfunction nativeEnum(name, ...members) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", \"nativeEnum(): name must be a non-empty string.\", {\n\t\tfix: \"Pass a non-empty entity name as the first argument to nativeEnum().\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n\tif (members.length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): must have at least one member.`, {\n\t\twhy: \"Postgres rejects CREATE TYPE ... AS ENUM () with no labels.\",\n\t\tfix: \"Declare at least one member value after the name.\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"zero members\"\n\t\t}\n\t});\n\tconst seenValues = /* @__PURE__ */ new Set();\n\tfor (const value of members) {\n\t\tif (seenValues.has(value)) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): duplicate member value \"${value}\". Member values must be unique.`, {\n\t\t\tfix: \"Remove the duplicate member value.\",\n\t\t\tmeta: {\n\t\t\t\tenumName: name,\n\t\t\t\tmember: value,\n\t\t\t\treason: \"duplicate member value\"\n\t\t\t}\n\t\t});\n\t\tseenValues.add(value);\n\t}\n\treturn buildNativeEnumHandle(name, name, members);\n}\n/**\n* Builds the deferred column descriptor for `handle`: the bare Postgres type\n* name and `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same\n* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),\n* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity\n* `name` (not the Postgres type name — they differ when `.map()` was used).\n* Schema qualification and the storage `valueSet` ref are NOT computed here — a\n* `field.column(pg.enum(handle))` call runs before the enclosing `model(...)`\n* associates a namespace, so `buildSqlContractFromDefinition` resolves both\n* once the field's namespace is known.\n*/\nfunction pgEnumColumn(handle) {\n\tconst resolved = pgEnumDescriptor.columnFromEntity(handle.entity);\n\tif (resolved === void 0) throw new InternalError(`pg.enum(\"${handle.name}\"): handle.entity is not a PostgresNativeEnum. This is an authoring-surface bug — nativeEnum() must always produce one.`);\n\treturn {\n\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\tnativeType: resolved.nativeType,\n\t\ttypeParams: resolved.typeParams,\n\t\tentityRef: {\n\t\t\tentityKind: handle.entityKind,\n\t\t\tentityName: handle.name,\n\t\t\tentity: handle.entity\n\t\t}\n\t};\n}\n/** Postgres-specific TS type-constructor namespace, mirroring the PSL `pg.` prefix. */\nconst pg = { enum: pgEnumColumn };\n//#endregion\n//#region src/contract/rls.ts\nfunction assertNonEmptyName(helper, name) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty policy name.\",\n\t\tmeta: {\n\t\t\tpolicyName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n}\n/** The user-facing helper name per operation, for runtime error messages. */\nconst HELPER_NAMES = {\n\tselect: \"policySelect\",\n\tinsert: \"policyInsert\",\n\tupdate: \"policyUpdate\",\n\tdelete: \"policyDelete\",\n\tall: \"policyAll\"\n};\nfunction buildPolicyHandle(operation, model, descriptor) {\n\tconst helper = HELPER_NAMES[operation];\n\tconst support = POLICY_OPERATION_PREDICATES[operation];\n\tassertNonEmptyName(`${helper}(\"${descriptor.name}\")`, descriptor.name);\n\tconst supported = support.using && support.withCheck ? \"`using` and `withCheck`\" : support.using ? \"`using` only\" : \"`withCheck` only\";\n\tconst rejectPredicate = (predicate) => {\n\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" does not take a \\`${predicate}\\` predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\t\tfix: `Use only the predicates the ${operation.toUpperCase()} operation supports: ${supported}.`,\n\t\t\tmeta: {\n\t\t\t\tpolicyName: descriptor.name,\n\t\t\t\treason: `unsupported \\`${predicate}\\` predicate`\n\t\t\t}\n\t\t});\n\t};\n\tif (descriptor.using !== void 0 && !support.using) rejectPredicate(\"using\");\n\tif (descriptor.withCheck !== void 0 && !support.withCheck) rejectPredicate(\"withCheck\");\n\tif (descriptor.using === void 0 && descriptor.withCheck === void 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" requires at least one predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\tfix: `Provide at least one predicate: ${supported}.`,\n\t\tmeta: {\n\t\t\tpolicyName: descriptor.name,\n\t\t\treason: \"no predicate given\"\n\t\t}\n\t});\n\treturn Object.freeze({\n\t\tentityKind: \"policy\",\n\t\toperation,\n\t\tname: descriptor.name,\n\t\trefs: Object.freeze({ target: model }),\n\t\troles: Object.freeze([...descriptor.roles]),\n\t\t...ifDefined(\"using\", descriptor.using),\n\t\t...ifDefined(\"withCheck\", descriptor.withCheck)\n\t});\n}\n/**\n* Declares a Postgres role by name, mirroring PSL's bare role identifiers.\n* Returns an inert handle: referenced in a policy's `roles` it contributes\n* the bare name; placed in the `entities` list it declares the role\n* (`entries.role`), making it subject to the existence verify.\n*/\nfunction role(name) {\n\tassertNonEmptyName(`role(\"${name}\")`, name);\n\treturn Object.freeze({\n\t\tentityKind: \"role\",\n\t\tname\n\t});\n}\n/**\n* Marks a model's table RLS-controlled, mirroring PSL's `@@rls`. The\n* enablement marker (never the policy set) drives `ENABLE`/`DISABLE ROW\n* LEVEL SECURITY` planning.\n*/\nfunction rlsEnabled(model) {\n\treturn Object.freeze({\n\t\tentityKind: \"rls\",\n\t\trefs: Object.freeze({ target: model })\n\t});\n}\n/** Authors a `FOR SELECT` policy (PSL `policy_select`): row visibility via `using`. */\nfunction policySelect(model, descriptor) {\n\treturn buildPolicyHandle(\"select\", model, descriptor);\n}\n/** Authors a `FOR INSERT` policy (PSL `policy_insert`): new-row validation via `withCheck`. */\nfunction policyInsert(model, descriptor) {\n\treturn buildPolicyHandle(\"insert\", model, descriptor);\n}\n/** Authors a `FOR UPDATE` policy (PSL `policy_update`): takes `using` and `withCheck`. */\nfunction policyUpdate(model, descriptor) {\n\treturn buildPolicyHandle(\"update\", model, descriptor);\n}\n/** Authors a `FOR DELETE` policy (PSL `policy_delete`): row eligibility via `using`. */\nfunction policyDelete(model, descriptor) {\n\treturn buildPolicyHandle(\"delete\", model, descriptor);\n}\n/** Authors a `FOR ALL` policy (PSL `policy_all`): takes `using` and `withCheck`. */\nfunction policyAll(model, descriptor) {\n\treturn buildPolicyHandle(\"all\", model, descriptor);\n}\n//#endregion\nexport { buildSqlContractFromDefinition, check, defineContract, enumType, field, member, model, nativeEnum, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,QAAQ;EACb,GAAG;EACH,iBAAiB;CAClB;CACA,IAAI,YAAY,KAAK,GAAG,OAAO,mBAAmB,eAAe,iBAAiB,OAAO,OAAO;CAChG,OAAO,mBAAmB,eAAe,iBAAiB,KAAK;AAChE;;;;;;;;;;;;AAcA,MAAM,WAAW,aAAa;AAG9B,SAAS,sBAAsB,MAAM,UAAU,SAAS;CACvD,IAAI,SAAS,KAAK,CAAC,CAAC,WAAW,GAAG,MAAM,cAAc,yBAAyB,eAAe,KAAK,yDAAyD;EAC3J,KAAK;EACL,MAAM;GACL,UAAU;GACV,QAAQ;EACT;CACD,CAAC;CACD,OAAO;EACN,YAAY;EACZ;EACA;EACA;EACA,QAAQ,IAAI,mBAAmB;GAC9B;GACA;EACD,CAAC;EACD,MAAM,mBAAmB,sBAAsB,MAAM,gBAAgB,OAAO;CAC7E;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,WAAW,MAAM,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CACD,CAAC;AACF;;;;;;AAMA,SAAS,WAAW,OAAO;CAC1B,OAAO,OAAO,OAAO;EACpB,YAAY;EACZ,MAAM,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;CACtC,CAAC;AACF;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,UAAU,OAAO,YAAY;CACrC,OAAO,kBAAkB,OAAO,OAAO,UAAU;AAClD"}
|
|
1
|
+
{"version":3,"file":"contract-builder.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-builder.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { PG_ENUM_CODEC_ID } from \"@internal/target-postgres/codec-ids\";\nimport postgresPackRef from \"@internal/target-postgres/pack\";\nimport { PostgresNativeEnum, postgresCreateNamespace } from \"@internal/target-postgres/types\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { autoincrement, bindEnumType, buildBoundContract, buildSqlContractFromDefinition, check, createComposedAuthoringHelpers, member, model, now, rel, sql } from \"@internal/sql-contract-ts/contract-builder\";\nimport { postgresAdapterContractContributions } from \"@internal/adapter-postgres/adapter\";\nimport sqlFamilyPack from \"@internal/family-sql/pack\";\nimport { assembleDataTypeSupport } from \"@internal/framework-components/authoring\";\nimport { assemblePostgresCodecRegistryWithBuiltins, pgEnumDescriptor } from \"@internal/target-postgres/codecs\";\nimport { requireSqlExpression } from \"@internal/sql-contract/sql-expression\";\nimport { FULL_TEXT_INDEX_TYPE, describeFullTextIndexProblem, fullTextIndexProblems, postgresCodecTraitsOf, weightGroupsOf } from \"@internal/target-postgres/full-text-index-authoring\";\nimport { DEFAULT_FULL_TEXT_SEARCH_LANGUAGE } from \"@internal/target-postgres/sql-utils\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { POLICY_OPERATION_PREDICATES } from \"@internal/target-postgres/rls-canonicalize\";\n//#region src/contract/define-contract.ts\nconst adapter = postgresAdapterContractContributions;\nfunction defineContract(definition, factory) {\n\tconst extensions = Object.values(definition.extensions ?? {});\n\tconst dataTypeLookup = definition.dataTypeLookup ?? assembleDataTypeSupport([\n\t\tsqlFamilyPack,\n\t\tpostgresPackRef,\n\t\t...extensions\n\t], () => void 0).support.lookup;\n\tconst bound = {\n\t\t...definition,\n\t\tadapter,\n\t\tcreateNamespace: postgresCreateNamespace,\n\t\tcodecLookup: definition.codecLookup ?? assemblePostgresCodecRegistryWithBuiltins(extensions, dataTypeLookup),\n\t\tdataTypeLookup\n\t};\n\tif (factory !== void 0) return buildBoundContract(sqlFamilyPack, postgresPackRef, bound, factory);\n\treturn buildBoundContract(sqlFamilyPack, postgresPackRef, bound);\n}\n//#endregion\n//#region src/contract/enum-type.ts\n/**\n* The `enumType` authors call when building a Postgres contract (re-exported\n* from `@internal/postgres/contract-builder`).\n*\n* `bindEnumType` is the core, codec-agnostic `enumType` factory; calling it with\n* the Postgres pack's codec typemap fixes which member-value type each codec\n* permits, so `member()` values are checked against the column's codec at\n* authoring time: `pg/text@1` requires `string`, `pg/int4@1` requires `number`,\n* and a mismatch is a compile error. The core `enumType` can't know the codec\n* set, which is why the binding happens here, per target.\n*/\nconst enumType = bindEnumType();\n//#endregion\n//#region src/contract/field.ts\nconst { support } = assembleDataTypeSupport([sqlFamilyPack, postgresPackRef], () => void 0);\nconst helpers = createComposedAuthoringHelpers({\n\tfamily: sqlFamilyPack,\n\ttarget: postgresPackRef,\n\tcodecLookup: assemblePostgresCodecRegistryWithBuiltins([], support.lookup)\n});\n/**\n* The field builders of the `defineContract` callback for Postgres, without extensions: `field.text()`, `field.temporal.timestamptz()`, `field.uuidString()`, and `field.column(columnType)`. Use it outside a contract, for example to declare the fields of a query fragment.\n*/\nconst field = helpers.field;\n/**\n* The generator function calls of the `defineContract` callback for Postgres, without extensions, for `.onCreate(...)` and `.onUpdate(...)`: `gen.now()`, `gen.uuid(7)`, `gen.cuid(2)`, `gen.ulid()`, `gen.nanoid(16)` and `gen.ksuid()`.\n*/\nconst gen = helpers.gen;\n//#endregion\n//#region src/contract/full-text-index.ts\nfunction isColumnRef(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction fullTextIndex(fields, options) {\n\tconst fieldGroups = weightGroupsOf(fields, isColumnRef).map((group) => group.map((ref) => ref.fieldName));\n\trefuseInvalid({ weightGroups: fieldGroups });\n\tconst language = options.language ?? DEFAULT_FULL_TEXT_SEARCH_LANGUAGE;\n\tconst fieldNames = fieldGroups.flat();\n\treturn {\n\t\tkind: \"index\",\n\t\tfields: fieldNames,\n\t\ttype: FULL_TEXT_INDEX_TYPE,\n\t\toptions: (columns) => {\n\t\t\tconst columnOf = new Map(fieldNames.map((fieldName, i) => [fieldName, columns[i]]));\n\t\t\trefuseInvalid({\n\t\t\t\tweightGroups: fieldGroups,\n\t\t\t\tcodecs: {\n\t\t\t\t\tcodecIdOf: (fieldName) => columnOf.get(fieldName)?.codecId,\n\t\t\t\t\ttraitsOf: postgresCodecTraitsOf\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst columnNameOf = (fieldName) => {\n\t\t\t\tconst column = columnOf.get(fieldName);\n\t\t\t\tassertDefined(column, `fullTextIndex field \"${fieldName}\" was resolved to a column`);\n\t\t\t\treturn column.name;\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tweightGroups: fieldGroups.map((group) => group.map(columnNameOf)),\n\t\t\t\tlanguage\n\t\t\t};\n\t\t},\n\t\t...options.where !== void 0 ? { where: requireSqlExpression(options.where, `${fullTextIndexOwner(fieldNames, options)} where`) } : {},\n\t\t...options.name !== void 0 ? { name: options.name } : {},\n\t\t...options.map !== void 0 ? { map: options.map } : {}\n\t};\n}\nfunction fullTextIndexOwner(fieldNames, options) {\n\tconst name = options.name ?? options.map;\n\treturn name === void 0 ? `Full-text index on fields ${fieldNames.map((fieldName) => `\"${fieldName}\"`).join(\", \")}` : `Full-text index \"${name}\"`;\n}\nfunction refuseInvalid(candidate) {\n\tconst [problem] = fullTextIndexProblems(candidate);\n\tif (problem === void 0) return;\n\tthrow postgresError(\"CONTRACT.INDEX_INVALID\", describeFullTextIndexProblem(\"fullTextIndex\", problem), {\n\t\twhy: \"Each top-level item of the fields is one weight group; Postgres has four weights, A to D, each field belongs to one group, and to_tsvector takes text.\",\n\t\tfix: \"List each text field once, in at most four non-empty groups.\",\n\t\tmeta: {\n\t\t\thelper: \"fullTextIndex\",\n\t\t\tfields: candidate.weightGroups\n\t\t}\n\t});\n}\n//#endregion\n//#region src/contract/native-enum.ts\nfunction buildNativeEnumHandle(name, typeName, members) {\n\tif (typeName.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): the Postgres type name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty Postgres type name to .map(typeName).\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty type name\"\n\t\t}\n\t});\n\treturn {\n\t\tentityKind: \"native_enum\",\n\t\tname,\n\t\ttypeName,\n\t\tmembers,\n\t\tentity: new PostgresNativeEnum({\n\t\t\ttypeName,\n\t\t\tmembers\n\t\t}),\n\t\tmap: (mappedTypeName) => buildNativeEnumHandle(name, mappedTypeName, members)\n\t};\n}\n/**\n* Declares a native Postgres enum type for use with {@link pg}'s `.enum()`\n* column helper. Mirrors PSL's `native_enum <Name> { … }` lowering\n* (`lowerNativeEnumFromBlock`): validates a non-empty, duplicate-free member\n* list and builds the same {@link PostgresNativeEnum} entity. Its value-set is\n* derived generically at contract-build time — the same\n* `deriveValueSetFromEntity` fold PSL's native enums go through — once\n* `pg.enum(handle)` lands the entity in the field's owning namespace.\n*\n* The first argument is the entity `name` (the `entries.valueSet` key). The\n* Postgres type name, the `entries.native_enum` key, defaults to `name`; use\n* `.map(typeName)` to override it (PSL's `@@map`).\n*\n* A handle referenced by columns in N different namespaces materialises N\n* native enum types (one per namespace) — by design: a Postgres type lives in\n* exactly one schema, and PSL can't share a type across schemas either.\n*\n* @example\n* ```ts\n* // name === Postgres type name\n* const Role = nativeEnum('Role', 'user', 'admin');\n* // entity name `AalLevel`, Postgres type `aal_level` (Supabase's auth.aal_level)\n* const AalLevel = nativeEnum('AalLevel', 'aal1', 'aal2', 'aal3').map('aal_level');\n* model('Session', { fields: { aal: field.column(pg.enum(AalLevel)).optional() } });\n* ```\n*/\nfunction nativeEnum(name, ...members) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", \"nativeEnum(): name must be a non-empty string.\", {\n\t\tfix: \"Pass a non-empty entity name as the first argument to nativeEnum().\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n\tif (members.length === 0) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): must have at least one member.`, {\n\t\twhy: \"Postgres rejects CREATE TYPE ... AS ENUM () with no labels.\",\n\t\tfix: \"Declare at least one member value after the name.\",\n\t\tmeta: {\n\t\t\tenumName: name,\n\t\t\treason: \"zero members\"\n\t\t}\n\t});\n\tconst seenValues = /* @__PURE__ */ new Set();\n\tfor (const value of members) {\n\t\tif (seenValues.has(value)) throw postgresError(\"CONTRACT.ENUM_INVALID\", `nativeEnum(\"${name}\"): duplicate member value \"${value}\". Member values must be unique.`, {\n\t\t\tfix: \"Remove the duplicate member value.\",\n\t\t\tmeta: {\n\t\t\t\tenumName: name,\n\t\t\t\tmember: value,\n\t\t\t\treason: \"duplicate member value\"\n\t\t\t}\n\t\t});\n\t\tseenValues.add(value);\n\t}\n\treturn buildNativeEnumHandle(name, name, members);\n}\n/**\n* Builds the deferred column descriptor for `handle`: its `typeParams` come from `pgEnumDescriptor.columnFromEntity` (the same\n* authoring hook the PSL `pg.enum(Ref)` type constructor resolves through),\n* carrying `handle.entity` as the descriptor's `entityRef` keyed by the entity\n* `name` (not the Postgres type name — they differ when `.map()` was used).\n* Schema qualification and the storage `valueSet` ref are NOT computed here — a\n* `field.column(pg.enum(handle))` call runs before the enclosing `model(...)`\n* associates a namespace, so `buildSqlContractFromDefinition` resolves both\n* once the field's namespace is known.\n*/\nfunction pgEnumColumn(handle) {\n\tconst resolved = pgEnumDescriptor.columnFromEntity(handle.entity);\n\tif (resolved === void 0) throw new InternalError(`pg.enum(\"${handle.name}\"): handle.entity is not a PostgresNativeEnum. This is an authoring-surface bug — nativeEnum() must always produce one.`);\n\treturn {\n\t\tcodecId: PG_ENUM_CODEC_ID,\n\t\ttypeParams: resolved.typeParams,\n\t\tentityRef: {\n\t\t\tentityKind: handle.entityKind,\n\t\t\tentityName: handle.name,\n\t\t\tentity: handle.entity\n\t\t}\n\t};\n}\n/** Postgres-specific TS type-constructor namespace, mirroring the PSL `pg.` prefix. */\nconst pg = { enum: pgEnumColumn };\n//#endregion\n//#region src/contract/rls.ts\nfunction assertNonEmptyName(helper, name) {\n\tif (name.trim().length === 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: name must be a non-empty string.`, {\n\t\tfix: \"Pass a non-empty policy name.\",\n\t\tmeta: {\n\t\t\tpolicyName: name,\n\t\t\treason: \"empty name\"\n\t\t}\n\t});\n}\n/** The user-facing helper name per operation, for runtime error messages. */\nconst HELPER_NAMES = {\n\tselect: \"policySelect\",\n\tinsert: \"policyInsert\",\n\tupdate: \"policyUpdate\",\n\tdelete: \"policyDelete\",\n\tall: \"policyAll\"\n};\nfunction buildPolicyHandle(operation, model, descriptor) {\n\tconst helper = HELPER_NAMES[operation];\n\tconst support = POLICY_OPERATION_PREDICATES[operation];\n\tassertNonEmptyName(`${helper}(\"${descriptor.name}\")`, descriptor.name);\n\tconst supported = support.using && support.withCheck ? \"`using` and `withCheck`\" : support.using ? \"`using` only\" : \"`withCheck` only\";\n\tconst rejectPredicate = (predicate) => {\n\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" does not take a \\`${predicate}\\` predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\t\tfix: `Use only the predicates the ${operation.toUpperCase()} operation supports: ${supported}.`,\n\t\t\tmeta: {\n\t\t\t\tpolicyName: descriptor.name,\n\t\t\t\treason: `unsupported \\`${predicate}\\` predicate`\n\t\t\t}\n\t\t});\n\t};\n\tif (descriptor.using !== void 0 && !support.using) rejectPredicate(\"using\");\n\tif (descriptor.withCheck !== void 0 && !support.withCheck) rejectPredicate(\"withCheck\");\n\tif (descriptor.using === void 0 && descriptor.withCheck === void 0) throw postgresError(\"CONTRACT.POLICY_INVALID\", `${helper}: policy \"${descriptor.name}\" requires at least one predicate; the ${operation.toUpperCase()} operation uses ${supported}.`, {\n\t\tfix: `Provide at least one predicate: ${supported}.`,\n\t\tmeta: {\n\t\t\tpolicyName: descriptor.name,\n\t\t\treason: \"no predicate given\"\n\t\t}\n\t});\n\treturn Object.freeze({\n\t\tentityKind: \"policy\",\n\t\toperation,\n\t\tname: descriptor.name,\n\t\trefs: Object.freeze({ target: model }),\n\t\troles: Object.freeze([...descriptor.roles]),\n\t\t...ifDefined(\"using\", descriptor.using),\n\t\t...ifDefined(\"withCheck\", descriptor.withCheck)\n\t});\n}\n/**\n* Declares a Postgres role by name, mirroring PSL's bare role identifiers.\n* Returns an inert handle: referenced in a policy's `roles` it contributes\n* the bare name; placed in the `entities` list it declares the role\n* (`entries.role`), making it subject to the existence verify.\n*/\nfunction role(name) {\n\tassertNonEmptyName(`role(\"${name}\")`, name);\n\treturn Object.freeze({\n\t\tentityKind: \"role\",\n\t\tname\n\t});\n}\n/**\n* Marks a model's table RLS-controlled, mirroring PSL's `@@rls`. The\n* enablement marker (never the policy set) drives `ENABLE`/`DISABLE ROW\n* LEVEL SECURITY` planning.\n*/\nfunction rlsEnabled(model) {\n\treturn Object.freeze({\n\t\tentityKind: \"rls\",\n\t\trefs: Object.freeze({ target: model })\n\t});\n}\n/** Authors a `FOR SELECT` policy (PSL `policy_select`): row visibility via `using`. */\nfunction policySelect(model, descriptor) {\n\treturn buildPolicyHandle(\"select\", model, descriptor);\n}\n/** Authors a `FOR INSERT` policy (PSL `policy_insert`): new-row validation via `withCheck`. */\nfunction policyInsert(model, descriptor) {\n\treturn buildPolicyHandle(\"insert\", model, descriptor);\n}\n/** Authors a `FOR UPDATE` policy (PSL `policy_update`): takes `using` and `withCheck`. */\nfunction policyUpdate(model, descriptor) {\n\treturn buildPolicyHandle(\"update\", model, descriptor);\n}\n/** Authors a `FOR DELETE` policy (PSL `policy_delete`): row eligibility via `using`. */\nfunction policyDelete(model, descriptor) {\n\treturn buildPolicyHandle(\"delete\", model, descriptor);\n}\n/** Authors a `FOR ALL` policy (PSL `policy_all`): takes `using` and `withCheck`. */\nfunction policyAll(model, descriptor) {\n\treturn buildPolicyHandle(\"all\", model, descriptor);\n}\n//#endregion\nexport { autoincrement, buildSqlContractFromDefinition, check, defineContract, enumType, field, fullTextIndex, gen, member, model, nativeEnum, now, pg, policyAll, policyDelete, policyInsert, policySelect, policyUpdate, rel, rlsEnabled, role, sql };\n\n//# sourceMappingURL=contract-builder.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,UAAU;AAChB,SAAS,eAAe,YAAY,SAAS;CAC5C,MAAM,aAAa,OAAO,OAAO,WAAW,cAAc,CAAC,CAAC;CAC5D,MAAM,iBAAiB,WAAW,kBAAkB,wBAAwB;EAC3E;EACA;EACA,GAAG;CACJ,SAAS,KAAK,CAAC,CAAC,CAAC,QAAQ;CACzB,MAAM,QAAQ;EACb,GAAG;EACH;EACA,iBAAiB;EACjB,aAAa,WAAW,eAAe,0CAA0C,YAAY,cAAc;EAC3G;CACD;CAC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xC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,aAAa,OAAO,YAAY;CACxC,OAAO,kBAAkB,UAAU,OAAO,UAAU;AACrD;;AAEA,SAAS,UAAU,OAAO,YAAY;CACrC,OAAO,kBAAkB,OAAO,OAAO,UAAU;AAClD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
2
|
+
import { SqlStorage } from "@prisma/orm-family-sql/contract/types";
|
|
3
|
+
//#region ../../../3-targets/postgres/9-facade/dist/contract-from-json-ZRZt8Cse.d.mts
|
|
4
|
+
//#region src/static/contract-from-json.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Validates an emitted Postgres `contract.json` and returns it as the contract type the
|
|
7
|
+
* application names, ready to pass to `postgres({ contract })` and the other Postgres clients.
|
|
8
|
+
* Clients built from the result do not validate it again.
|
|
9
|
+
*
|
|
10
|
+
* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the
|
|
11
|
+
* returned value after the call: clients built from the value later do not validate it again.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import type { Contract } from './contract.d';
|
|
16
|
+
* import contractJson from './contract.json' with { type: 'json' };
|
|
17
|
+
*
|
|
18
|
+
* export const contract = contractFromJson<Contract>(contractJson);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function contractFromJson<TContract extends Contract<SqlStorage>>(json: unknown): TContract;
|
|
22
|
+
/** Validates a contract value for a Postgres client, once per value. */
|
|
23
|
+
declare function validatePostgresContract<TContract extends Contract<SqlStorage>>(contract: TContract): TContract;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { validatePostgresContract as n, contractFromJson as t };
|
|
26
|
+
//# sourceMappingURL=contract-from-json-ZRZt8Cse-DMkmmOW1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-from-json-ZRZt8Cse-DMkmmOW1.d.mts","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-from-json-ZRZt8Cse.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAmBiB,iBAAiB,kBAAkB,SAAS,aAAa,gBAAgB;;iBAEzE,yBAAyB,kBAAkB,SAAS,aAAa,UAAU,YAAY"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-postgres/target/runtime";
|
|
2
|
+
import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
|
|
3
|
+
//#region ../../../3-targets/postgres/9-facade/dist/contract-from-json-ePdyekFz.mjs
|
|
4
|
+
var version = "8.0.0-rc.20";
|
|
5
|
+
const serializer = new PostgresContractSerializer();
|
|
6
|
+
const validator = `${postgresTarget.targetId}@${version}`;
|
|
7
|
+
/**
|
|
8
|
+
* Validates an emitted Postgres `contract.json` and returns it as the contract type the
|
|
9
|
+
* application names, ready to pass to `postgres({ contract })` and the other Postgres clients.
|
|
10
|
+
* Clients built from the result do not validate it again.
|
|
11
|
+
*
|
|
12
|
+
* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the
|
|
13
|
+
* returned value after the call: clients built from the value later do not validate it again.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import type { Contract } from './contract.d';
|
|
18
|
+
* import contractJson from './contract.json' with { type: 'json' };
|
|
19
|
+
*
|
|
20
|
+
* export const contract = contractFromJson<Contract>(contractJson);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
function contractFromJson(json) {
|
|
24
|
+
return validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));
|
|
25
|
+
}
|
|
26
|
+
/** Validates a contract value for a Postgres client, once per value. */
|
|
27
|
+
function validatePostgresContract(contract) {
|
|
28
|
+
return validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { validatePostgresContract as n, contractFromJson as t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=contract-from-json-ePdyekFz-BPQdc8oQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-from-json-ePdyekFz-BPQdc8oQ.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/contract-from-json-ePdyekFz.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.20\";\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-ePdyekFz.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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/contract/validate-once";
|
package/dist/control.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControlClient, ControlClientOptions } from "@prisma/orm-toolchain/cli/control-api";
|
|
2
|
-
//#region ../../../3-
|
|
2
|
+
//#region ../../../3-targets/postgres/9-facade/dist/control.d.mts
|
|
3
3
|
//#region src/exports/control.d.ts
|
|
4
4
|
interface PostgresControlClientOptions {
|
|
5
5
|
/**
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../../../../3-
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/control.d.mts"],"mappings":";;;UAEU;;;;;;WAMC;;;;;WAKA,aAAa;;iBAEP,4BAA4B,UAAU,+BAA+B"}
|
package/dist/control.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import sql from "@prisma/orm-family-sql/family/control";
|
|
|
4
4
|
import postgres from "@prisma/orm-target-postgres/target/control";
|
|
5
5
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
6
6
|
import { createControlClient } from "@prisma/orm-toolchain/cli/control-api";
|
|
7
|
-
//#region ../../../3-
|
|
7
|
+
//#region ../../../3-targets/postgres/9-facade/dist/control.mjs
|
|
8
8
|
/**
|
|
9
9
|
* Control-API facade for Postgres.
|
|
10
10
|
*
|
package/dist/control.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.mjs","names":[],"sources":["../../../../3-
|
|
1
|
+
{"version":3,"file":"control.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/control.mjs"],"sourcesContent":["import postgresAdapter from \"@internal/adapter-postgres/control\";\nimport postgresDriver from \"@internal/driver-postgres/control\";\nimport sql from \"@internal/family-sql/control\";\nimport postgres from \"@internal/target-postgres/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { createControlClient } from \"@internal/cli/control-api\";\n//#region src/exports/control.ts\n/**\n* Control-API facade for Postgres.\n*\n* Collapses the five-package wiring required to drive control-side\n* operations (`dbInit`, `dbUpdate`, `dbVerify`, `migrate`, …) into\n* a single `createPostgresControlClient()` call. Mirrors what\n* `@internal/postgres/runtime` did for the query side.\n*/\nfunction createPostgresControlClient(options = {}) {\n\treturn createControlClient({\n\t\tfamily: sql,\n\t\ttarget: postgres,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\t...ifDefined(\"connection\", options.connection),\n\t\t...ifDefined(\"extensions\", options.extensions)\n\t});\n}\n//#endregion\nexport { createPostgresControlClient };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,4BAA4B,UAAU,CAAC,GAAG;CAClD,OAAO,oBAAoB;EAC1B,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,cAAc,QAAQ,UAAU;CAC9C,CAAC;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
2
|
-
//#region ../../../3-
|
|
2
|
+
//#region ../../../3-targets/postgres/9-facade/dist/errors-DfWK9xep.mjs
|
|
3
3
|
function postgresError(code, message, options) {
|
|
4
4
|
return structuredError(code, message, options);
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
7
|
export { postgresError as t };
|
|
8
8
|
|
|
9
|
-
//# sourceMappingURL=errors-DfWK9xep-
|
|
9
|
+
//# sourceMappingURL=errors-DfWK9xep-CB07krZF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-DfWK9xep-CB07krZF.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/errors-DfWK9xep.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction postgresError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\nexport { postgresError as t };\n\n//# sourceMappingURL=errors-DfWK9xep.mjs.map"],"mappings":";;AAEA,SAAS,cAAc,MAAM,SAAS,SAAS;CAC9C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/data-type-support";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/data-type";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/contract/sql-expression";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-family-sql/family/psl-build";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
2
|
+
import { activitySource, delegatingActivitySource, withTransaction, withTransactionMembers } from "@prisma/orm-family-sql/runtime";
|
|
3
|
+
import { orm, prepareQuery } from "@prisma/orm-family-sql/orm-client";
|
|
4
|
+
//#region ../../../3-targets/postgres/9-facade/dist/postgres-members-BuiQxl75.mjs
|
|
5
|
+
/**
|
|
6
|
+
* Builds the query members of a Postgres transaction over `txCtx`, so every statement they run goes through the transaction. `query` and `execute` are the transaction's own; `sql`, `raw` and `toSql` are the client's. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.
|
|
7
|
+
*/
|
|
8
|
+
function buildPostgresQueryMembers(options, txCtx) {
|
|
9
|
+
const { context, collections, sql, raw, toSql, prepareRuntime } = options;
|
|
10
|
+
return {
|
|
11
|
+
toSql,
|
|
12
|
+
sql,
|
|
13
|
+
raw,
|
|
14
|
+
orm: orm({
|
|
15
|
+
runtime: {
|
|
16
|
+
query(plan) {
|
|
17
|
+
return txCtx.query(plan);
|
|
18
|
+
},
|
|
19
|
+
execute(plan) {
|
|
20
|
+
return txCtx.execute(plan);
|
|
21
|
+
},
|
|
22
|
+
[activitySource]: delegatingActivitySource(() => txCtx)
|
|
23
|
+
},
|
|
24
|
+
context,
|
|
25
|
+
...ifDefined("collections", collections)
|
|
26
|
+
}),
|
|
27
|
+
prepare(declaration, callback) {
|
|
28
|
+
return prepareQuery(prepareRuntime(), declaration, callback);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function buildPostgresRuntimeBoundMembers(options) {
|
|
33
|
+
const { context, collections, sql, raw, enums, nativeEnums, toSql, getRuntime, getRuntimeForWork } = options;
|
|
34
|
+
const orm$1 = orm({
|
|
35
|
+
runtime: {
|
|
36
|
+
query(plan) {
|
|
37
|
+
return getRuntimeForWork().query(plan);
|
|
38
|
+
},
|
|
39
|
+
execute(plan) {
|
|
40
|
+
return getRuntimeForWork().execute(plan);
|
|
41
|
+
},
|
|
42
|
+
connection() {
|
|
43
|
+
return getRuntimeForWork().connection();
|
|
44
|
+
},
|
|
45
|
+
[activitySource]: delegatingActivitySource(() => getRuntimeForWork())
|
|
46
|
+
},
|
|
47
|
+
context,
|
|
48
|
+
...ifDefined("collections", collections)
|
|
49
|
+
});
|
|
50
|
+
function prepare(declaration, callback) {
|
|
51
|
+
return prepareQuery(getRuntimeForWork(), declaration, callback);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
orm: orm$1,
|
|
55
|
+
query(plan, execOptions) {
|
|
56
|
+
return getRuntimeForWork().query(plan, execOptions);
|
|
57
|
+
},
|
|
58
|
+
execute(plan, execOptions) {
|
|
59
|
+
return getRuntimeForWork().execute(plan, execOptions);
|
|
60
|
+
},
|
|
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
|
+
sql,
|
|
72
|
+
raw,
|
|
73
|
+
toSql,
|
|
74
|
+
prepareRuntime: getRuntimeForWork
|
|
75
|
+
}, txCtx),
|
|
76
|
+
enums,
|
|
77
|
+
nativeEnums
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { buildPostgresRuntimeBoundMembers as n, buildPostgresQueryMembers as t };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=postgres-members-BuiQxl75-CRdesQuN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-members-BuiQxl75-CRdesQuN.mjs","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/postgres-members-BuiQxl75.mjs"],"sourcesContent":["import { ifDefined } from \"@internal/utils/defined\";\nimport { activitySource, delegatingActivitySource, withTransaction, withTransactionMembers } from \"@internal/sql-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. `query` and `execute` are the transaction's own; `sql`, `raw` and `toSql` are the client's. 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, sql, raw, toSql, prepareRuntime } = options;\n\treturn {\n\t\ttoSql,\n\t\tsql,\n\t\traw,\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, sql, raw, enums, nativeEnums, toSql, 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\tquery(plan, execOptions) {\n\t\t\treturn getRuntimeForWork().query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn getRuntimeForWork().execute(plan, execOptions);\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(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\tsql,\n\t\t\t\t\t\traw,\n\t\t\t\t\t\ttoSql,\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-BuiQxl75.mjs.map"],"mappings":";;;;;;;AAOA,SAAS,0BAA0B,SAAS,OAAO;CAClD,MAAM,EAAE,SAAS,aAAa,KAAK,KAAK,OAAO,mBAAmB;CAClE,OAAO;EACN;EACA;EACA;EACA,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,KAAK,KAAK,OAAO,aAAa,OAAO,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,MAAM,MAAM,aAAa;GACxB,OAAO,kBAAkB,CAAC,CAAC,MAAM,MAAM,WAAW;EACnD;EACA,QAAQ,MAAM,aAAa;GAC1B,OAAO,kBAAkB,CAAC,CAAC,QAAQ,MAAM,WAAW;EACrD;EACA,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;MACA;MACA,gBAAgB;KACjB,GAAG,KAAK;KACR;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;CACD;AACD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { n as PostgresStaticContext, r as PostgresTargetId, t as NamespacedNativeEnums } from "./postgres-static-CGyjvgUc-C_iJje8L.mjs";
|
|
2
|
+
import { NamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
|
|
3
|
+
import { ExecutionContext, Runtime, SqlExecutionStackWithDriver, ToSqlMember, TransactionContext } from "@prisma/orm-family-sql/runtime";
|
|
4
|
+
import { CollectionClasses, NoCollectionClasses, PrepareMember, orm } from "@prisma/orm-family-sql/orm-client";
|
|
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 { RuntimeScope } from "@prisma/orm-family-sql/relational-core/types";
|
|
9
|
+
//#region ../../../3-targets/postgres/9-facade/dist/postgres-members-Cuvcnuok.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>, RuntimeScope, ToSqlMember {
|
|
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 sql: Db<TContract>;
|
|
26
|
+
readonly raw: RawLane<TContract>;
|
|
27
|
+
readonly toSql: ToSqlMember['toSql'];
|
|
28
|
+
readonly prepareRuntime: () => Runtime;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds the query members of a Postgres transaction over `txCtx`, so every statement they run goes through the transaction. `query` and `execute` are the transaction's own; `sql`, `raw` and `toSql` are the client's. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildPostgresQueryMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses>(options: PostgresQueryMembersOptions<TContract, TCollections>, txCtx: TransactionContext): Omit<PostgresQueryMembers<TContract, TCollections>, keyof RuntimeScope>;
|
|
34
|
+
interface PostgresStaticMembers<TContract extends Contract<SqlStorage>> extends PostgresStaticContext<TContract> {
|
|
35
|
+
readonly stack: SqlExecutionStackWithDriver<PostgresTargetId>;
|
|
36
|
+
}
|
|
37
|
+
interface PostgresRuntimeBoundMembers<TContract extends Contract<SqlStorage>, TCollections extends CollectionClasses = NoCollectionClasses> extends PrepareMember<TContract> {
|
|
38
|
+
readonly orm: OrmClient<TContract, TCollections>;
|
|
39
|
+
runtime(): Runtime;
|
|
40
|
+
transaction<R>(fn: (tx: PostgresTransactionContext<TContract, TCollections>) => PromiseLike<R>): Promise<R>;
|
|
41
|
+
}
|
|
42
|
+
interface PostgresLifecycleMembers {
|
|
43
|
+
close(): Promise<void>;
|
|
44
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { PostgresTransactionContext as a, PostgresStaticMembers as i, PostgresQueryMembers as n, buildPostgresQueryMembers as o, PostgresRuntimeBoundMembers as r, PostgresLifecycleMembers as t };
|
|
48
|
+
//# sourceMappingURL=postgres-members-Cuvcnuok--adyzJpM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-members-Cuvcnuok--adyzJpM.d.mts","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/postgres-members-Cuvcnuok.d.mts"],"mappings":";;;;;;;;;;KASK,UAAU,kBAAkB,SAAS,aAAa,qBAAqB,qBAAqB,kBAAkB,IAAI,WAAW;;UAExH,qBAAqB,kBAAkB,SAAS,aAAa,qBAAqB,oBAAoB,6BAA6B,cAAc,YAAY,cAAc;WAC1K,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,KAAK,GAAG;WACR,KAAK,QAAQ;WACb,OAAO;WACP,sBAAsB;;;;;iBAKhB,0BAA0B,kBAAkB,SAAS,aAAa,qBAAqB,mBAAmB,SAAS,4BAA4B,WAAW,eAAe,OAAO,qBAAqB,KAAK,qBAAqB,WAAW,qBAAqB;UACtQ,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,28 @@
|
|
|
1
|
+
import { r as PostgresTargetId } from "./postgres-static-CGyjvgUc-C_iJje8L.mjs";
|
|
2
|
+
import { Log, RuntimeMode, SqlMiddleware, SqlRuntimeExtensionDescriptor, VerifyMarkerOption } from "@prisma/orm-family-sql/runtime";
|
|
3
|
+
import "@prisma/orm-target-postgres/driver/runtime";
|
|
4
|
+
//#region ../../../3-targets/postgres/9-facade/dist/postgres-options-HIC8ThD0.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
|
+
readonly mode?: RuntimeMode;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { PostgresExecutionOptions as n, PostgresCursorOptions as t };
|
|
28
|
+
//# sourceMappingURL=postgres-options-HIC8ThD0-k6eyhDIx.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-options-HIC8ThD0-k6eyhDIx.d.mts","names":[],"sources":["../../../../3-targets/postgres/9-facade/dist/postgres-options-HIC8ThD0.d.mts"],"mappings":";;;;;;;;;;UASU;WACC;;;;;;UAMD;WACC,sBAAsB,8BAA8B;WACpD,sBAAsB;WACtB,eAAe;WACf,MAAM;WACN,SAAS;WACT,OAAO"}
|