@prisma/orm-target-postgres 8.0.0-rc.14-dev.27 → 8.0.0-rc.14-dev.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-feboP3zp-Bahi4qVo.mjs → adapter-BNrSLsxC-CXrTrSvP.mjs} +5 -5
- package/dist/{adapter-feboP3zp-Bahi4qVo.mjs.map → adapter-BNrSLsxC-CXrTrSvP.mjs.map} +1 -1
- package/dist/adapter.mjs +5 -5
- package/dist/adapter__adapter.mjs +1 -1
- package/dist/adapter__control.mjs +7 -7
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +4 -4
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/{authoring-BX7WXyUK-BVUoTS2O.mjs → authoring-C5Ch8RNG-Qgq9GiOY.mjs} +4 -4
- package/dist/{authoring-BX7WXyUK-BVUoTS2O.mjs.map → authoring-C5Ch8RNG-Qgq9GiOY.mjs.map} +1 -1
- package/dist/{codec-helpers-PLBCguwU-BD8nGqjd.mjs → codec-helpers-BmUrP6U9-DuO9gpqZ.mjs} +13 -13
- package/dist/{codec-helpers-PLBCguwU-BD8nGqjd.mjs.map → codec-helpers-BmUrP6U9-DuO9gpqZ.mjs.map} +1 -1
- package/dist/{codecs-4MwR9yYB.mjs → codecs-CWXNVl1P.mjs} +2 -2
- package/dist/{codecs-4MwR9yYB.mjs.map → codecs-CWXNVl1P.mjs.map} +1 -1
- package/dist/{codecs-0cuTthSz-DK4dxeEE.mjs → codecs-CnbVrlil--FxLKWM5.mjs} +4 -4
- package/dist/{codecs-0cuTthSz-DK4dxeEE.mjs.map → codecs-CnbVrlil--FxLKWM5.mjs.map} +1 -1
- package/dist/{control-Dd31Nva0.mjs → control-CyiVFspE.mjs} +9 -9
- package/dist/{control-Dd31Nva0.mjs.map → control-CyiVFspE.mjs.map} +1 -1
- package/dist/{control-D6H04xaA.mjs → control-DJo3P3yL.mjs} +2 -2
- package/dist/control-DJo3P3yL.mjs.map +1 -0
- package/dist/{control-adapter-DzRjCCuc-CNJcK8FQ.mjs → control-adapter-Du0EcG5G-CT4qBFrG.mjs} +11 -6
- package/dist/control-adapter-Du0EcG5G-CT4qBFrG.mjs.map +1 -0
- package/dist/{control-policy-DHnC_3uu-8eaY0QaE.mjs → control-policy-BW5Cgq3Z-Dn2ZVBCP.mjs} +4 -4
- package/dist/{control-policy-DHnC_3uu-8eaY0QaE.mjs.map → control-policy-BW5Cgq3Z-Dn2ZVBCP.mjs.map} +1 -1
- package/dist/{data-type-entries-ofT74QIj-3aJ3Llba.mjs → data-type-entries-cjspFU7A-BBOIqLij.mjs} +3 -3
- package/dist/{data-type-entries-ofT74QIj-3aJ3Llba.mjs.map → data-type-entries-cjspFU7A-BBOIqLij.mjs.map} +1 -1
- package/dist/{data-types-B-8yirZ0-Ba7BPHAy.mjs → data-types-BGsYeBpf-B_5bvuEe.mjs} +3 -3
- package/dist/{data-types-B-8yirZ0-Ba7BPHAy.mjs.map → data-types-BGsYeBpf-B_5bvuEe.mjs.map} +1 -1
- package/dist/{default-normalizer-8E6ew8Nq-CMgRnBkj.mjs → default-normalizer-ByDD_gRm-CKeWEb0x.mjs} +3 -3
- package/dist/{default-normalizer-8E6ew8Nq-CMgRnBkj.mjs.map → default-normalizer-ByDD_gRm-CKeWEb0x.mjs.map} +1 -1
- package/dist/{descriptor-meta-BEigA5Gj-DCtx_hNw.mjs → descriptor-meta-BEigA5Gj-eY7nV4N_.mjs} +5 -5
- package/dist/{descriptor-meta-BEigA5Gj-DCtx_hNw.mjs.map → descriptor-meta-BEigA5Gj-eY7nV4N_.mjs.map} +1 -1
- package/dist/{descriptor-meta-CNocPizV-CM3vRsBg.mjs → descriptor-meta-Bvq6_NJ8-Cn_M79Lf.mjs} +4 -4
- package/dist/{descriptor-meta-CNocPizV-CM3vRsBg.mjs.map → descriptor-meta-Bvq6_NJ8-Cn_M79Lf.mjs.map} +1 -1
- package/dist/{diff-database-schema-Cybx3XZj-X5XgQc3e.mjs → diff-database-schema-_bbfF4oI-D_VmL4Ma.mjs} +4 -4
- package/dist/{diff-database-schema-Cybx3XZj-X5XgQc3e.mjs.map → diff-database-schema-_bbfF4oI-D_VmL4Ma.mjs.map} +1 -1
- package/dist/driver.mjs +2 -2
- package/dist/driver__control.mjs +1 -1
- package/dist/driver__runtime.mjs +1 -1
- package/dist/{full-text-index-expression-BZRAwQ6G-Bus1rjpq.mjs → full-text-index-expression-525ZZWf0-HIGVQbjL.mjs} +3 -3
- package/dist/{full-text-index-expression-BZRAwQ6G-Bus1rjpq.mjs.map → full-text-index-expression-525ZZWf0-HIGVQbjL.mjs.map} +1 -1
- package/dist/{infer-psl-contract-of3HBkov-DJeZHv6R.mjs → infer-psl-contract-Burb6YAz-DbKU4cXm.mjs} +6 -6
- package/dist/{infer-psl-contract-of3HBkov-DJeZHv6R.mjs.map → infer-psl-contract-Burb6YAz-DbKU4cXm.mjs.map} +1 -1
- package/dist/migration-PTHAY9Cv.mjs.map +1 -1
- package/dist/{op-factory-call-DMsjg_Mk-CNSo4lcs.mjs → op-factory-call-DkzlLBzN-Bc6l0sYN.mjs} +3 -3
- package/dist/{op-factory-call-DMsjg_Mk-CNSo4lcs.mjs.map → op-factory-call-DkzlLBzN-Bc6l0sYN.mjs.map} +1 -1
- package/dist/{planner-DKY41UXw-CcoVgq5N.mjs → planner-D7lEhXHR-8Wz1p_6j.mjs} +7 -7
- package/dist/{planner-DKY41UXw-CcoVgq5N.mjs.map → planner-D7lEhXHR-8Wz1p_6j.mjs.map} +1 -1
- package/dist/{planner-ddl-builders-BOvOAj1q-C4IJoysh.mjs → planner-ddl-builders-BZLzBmuq-BrpA53eH.mjs} +4 -4
- package/dist/{planner-ddl-builders-BOvOAj1q-C4IJoysh.mjs.map → planner-ddl-builders-BZLzBmuq-BrpA53eH.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-CajcTGOW-DV0ivYWc.mjs → planner-produced-postgres-migration-GZTusMRD-DPb6XqDu.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-CajcTGOW-DV0ivYWc.mjs.map → planner-produced-postgres-migration-GZTusMRD-DPb6XqDu.mjs.map} +1 -1
- package/dist/{postgres-contract-view-BqMwLieI-1pQRelL5.mjs → postgres-contract-view-Da0ymIZE-CBV3OE-k.mjs} +3 -3
- package/dist/{postgres-contract-view-BqMwLieI-1pQRelL5.mjs.map → postgres-contract-view-Da0ymIZE-CBV3OE-k.mjs.map} +1 -1
- package/dist/{postgres-migration-CMcrvJni-D7c38x5U.mjs → postgres-migration-Dq60Mixq-DYNJokZW.mjs} +8 -8
- package/dist/{postgres-migration-CMcrvJni-D7c38x5U.mjs.map → postgres-migration-Dq60Mixq-DYNJokZW.mjs.map} +1 -1
- package/dist/{prisma7-binding-JTOc8zQB.mjs → prisma7-binding-Dm24YoM6.mjs} +5 -5
- package/dist/{prisma7-binding-JTOc8zQB.mjs.map → prisma7-binding-Dm24YoM6.mjs.map} +1 -1
- package/dist/{runtime-D7XsforS.mjs → runtime-DugW4mig.mjs} +4 -4
- package/dist/runtime-DugW4mig.mjs.map +1 -0
- package/dist/{temporal-text-parsers-M28a91UF-D938VcZK.mjs → server-text-types-DeNPQpv5-DPxA9uXV.mjs} +8 -22
- package/dist/server-text-types-DeNPQpv5-DPxA9uXV.mjs.map +1 -0
- package/dist/{sql-renderer-CgUgFbU4-cg7P_Tlg.mjs → sql-renderer-CgUgFbU4-BY3PCrmG.mjs} +2 -2
- package/dist/{sql-renderer-CgUgFbU4-cg7P_Tlg.mjs.map → sql-renderer-CgUgFbU4-BY3PCrmG.mjs.map} +1 -1
- package/dist/target.mjs +17 -17
- package/dist/target__codecs.mjs +2 -2
- package/dist/target__control.mjs +3 -3
- package/dist/target__data-types.mjs +2 -2
- package/dist/target__default-normalizer.mjs +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.mjs +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-ddl-builders.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__prisma7-binding.mjs +1 -1
- package/dist/target__runtime.mjs +2 -2
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__sql-utils.mjs +1 -1
- package/package.json +9 -9
- package/dist/control-D6H04xaA.mjs.map +0 -1
- package/dist/control-adapter-DzRjCCuc-CNJcK8FQ.mjs.map +0 -1
- package/dist/runtime-D7XsforS.mjs.map +0 -1
- package/dist/temporal-text-parsers-M28a91UF-D938VcZK.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-migration-CMcrvJni-D7c38x5U.mjs","names":["#endView","#startView"],"sources":["../../../../3-targets/3-targets/postgres/dist/postgres-migration-CMcrvJni.mjs"],"sourcesContent":["import { t as errorPostgresMigrationStackMissing } from \"./errors-DYyzTYzE.mjs\";\nimport { _ as PostgresRlsPolicy, v as PostgresRlsEnablement } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-8E6ew8Nq.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-Bq4m2dD9.mjs\";\nimport { i as contractToPostgresDatabaseSchemaNode, r as buildPostgresNativeTypeExpander, t as buildPostgresPlanDiff } from \"./diff-database-schema-Cybx3XZj.mjs\";\nimport { c as issueNode, f as defaultForeignKeyName, m as defaultUniqueName, n as resolveNamespaceIdForDdlSchema, p as defaultPrimaryKeyName } from \"./control-policy-DHnC_3uu.mjs\";\nimport { A as RenameIndexCall, B as installExtension, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, M as RenameTableCall, N as SetDefaultCall, P as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as RenamePostgresRlsPolicyCall, k as RenameConstraintCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from \"./op-factory-call-DMsjg_Mk.mjs\";\nimport { n as renderDefaultLiteral } from \"./planner-ddl-builders-BOvOAj1q.mjs\";\nimport { t as PostgresContractView } from \"./postgres-contract-view-BqMwLieI.mjs\";\nimport { t as dataTransform } from \"./data-transform-Bo32KRbq.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { applyTableRename, buildDataTypeResolver } from \"@internal/family-sql/control\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { SqlCheckConstraintIR, SqlIndexIR } from \"@internal/sql-schema-ir/types\";\nimport { errorMigrationOperationOptionRemoved } from \"@internal/errors/migration\";\nimport { Migration } from \"@internal/family-sql/migration\";\nimport { MigrationContractViews } from \"@internal/migration-tools/migration\";\n//#region src/core/migrations/index-and-check-renames.ts\n/**\n* Rename post-pass for indexes, per `(schema, table)`, widening-only,\n* deterministic by sorted names — the same structure as the policy pass\n* below (which stays untouched: policies pair by hash only).\n*\n* Hash pairing (prefix-only renames): extras whose live names parse as\n* wire names, grouped by `(schema, table, hash)`; missing nodes iterated\n* in sorted-name order consume the sorted-name-first candidate.\n*\n* Content pairing (exact→wire convergence), after hash pairing has\n* consumed its matches: the remaining wire-named-missing nodes\n* (`prefix` defined) against the remaining extras of any name shape,\n* paired iff content-equal (columns ordered-strict both-defined-or-\n* both-undefined, `unique`/`type` strict, `options` loose, bodies\n* byte-equal).\n*\n* Leftovers proceed as create/drop exactly as before; without the\n* widening allowance the pass is skipped and pairing degrades to the\n* additive half, like the policy pass.\n*/\nfunction pairIndexRenames(options, issues) {\n\tconst consumed = /* @__PURE__ */ new Set();\n\tconst calls = [];\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst missing = [];\n\tconst extra = [];\n\tfor (const issue of issues) {\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0 || !SqlIndexIR.is(node)) continue;\n\t\tconst ddlSchema = issue.path[1];\n\t\tconst tableName = issue.path[2];\n\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t}\n\tif (missing.length === 0 || extra.length === 0) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\tfinding.ddlSchema,\n\t\tfinding.tableName,\n\t\thash\n\t]);\n\tconst rename = (missingFinding, candidate) => {\n\t\tconsumed.add(missingFinding.issue);\n\t\tconsumed.add(candidate.issue);\n\t\tcalls.push(new RenameIndexCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, candidate.node.name, missingFinding.node.name));\n\t};\n\tconst sortedMissing = [...missing].sort(byName);\n\tconst extrasByHash = /* @__PURE__ */ new Map();\n\tfor (const finding of extra) {\n\t\tconst parsed = parseWireName(finding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst key = pairingKey(finding, parsed.hash);\n\t\tconst group = extrasByHash.get(key) ?? [];\n\t\tgroup.push(finding);\n\t\textrasByHash.set(key, group);\n\t}\n\tfor (const group of extrasByHash.values()) group.sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\tif (candidate === void 0) continue;\n\t\trename(missingFinding, candidate);\n\t}\n\tconst sortedExtras = [...extra].sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tif (consumed.has(missingFinding.issue)) continue;\n\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\tconst candidate = sortedExtras.find((extraFinding) => !consumed.has(extraFinding.issue) && extraFinding.ddlSchema === missingFinding.ddlSchema && extraFinding.tableName === missingFinding.tableName && missingFinding.node.contentEquals(extraFinding.node, {\n\t\t\tcolumnPresence: \"matching\",\n\t\t\tbodies: \"verbatim\"\n\t\t}));\n\t\tif (candidate === void 0) continue;\n\t\trename(missingFinding, candidate);\n\t}\n\treturn {\n\t\tcalls,\n\t\tconsumed\n\t};\n}\n/**\n* Check-constraint rename post-pass: a `not-found` and a `not-expected`\n* check on the same table whose wire-name content hashes match but whose\n* prefixes differ is a prefix-only rename, and collapses into one\n* `ALTER TABLE … RENAME CONSTRAINT`.\n*\n* This is the index pass's hash-pairing phase and nothing else. There is\n* deliberately no content-pairing phase: a live check body is whatever\n* Postgres reprinted, so it never byte-matches the authored text, and\n* pairing an exact-named live check by content would bless whatever\n* predicate is actually live. Adoption of an old exact-named check stays\n* drop + add.\n*\n* Runs only when the policy allows `widening` (rename's class). Without it\n* the pass no-ops and the pair degrades to the slice-1 behavior: an add,\n* plus a drop when `destructive` is allowed too.\n*/\nfunction pairCheckRenames(options, issues) {\n\tconst consumed = /* @__PURE__ */ new Set();\n\tconst calls = [];\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst missing = [];\n\tconst extra = [];\n\tfor (const issue of issues) {\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0 || !SqlCheckConstraintIR.is(node)) continue;\n\t\tconst ddlSchema = issue.path[1];\n\t\tconst tableName = issue.path[2];\n\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t}\n\tif (missing.length === 0 || extra.length === 0) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\tfinding.ddlSchema,\n\t\tfinding.tableName,\n\t\thash\n\t]);\n\tconst sortedMissing = [...missing].sort(byName);\n\tconst extrasByHash = /* @__PURE__ */ new Map();\n\tfor (const finding of extra) {\n\t\tconst parsed = parseWireName(finding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst key = pairingKey(finding, parsed.hash);\n\t\tconst group = extrasByHash.get(key) ?? [];\n\t\tgroup.push(finding);\n\t\textrasByHash.set(key, group);\n\t}\n\tfor (const group of extrasByHash.values()) group.sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\tif (candidate === void 0) continue;\n\t\tconsumed.add(missingFinding.issue);\n\t\tconsumed.add(candidate.issue);\n\t\tcalls.push(new RenameConstraintCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, \"checkConstraint\", candidate.node.name, missingFinding.node.name));\n\t}\n\treturn {\n\t\tcalls,\n\t\tconsumed\n\t};\n}\n//#endregion\n//#region src/core/migrations/postgres-contract-to-schema.ts\nfunction postgresRenderDefault(def, column) {\n\tif (def.kind === \"function\") return def.expression;\n\treturn renderDefaultLiteral(def.value, column);\n}\n/**\n* The Postgres schema tree a contract describes, as the planner's \"from\" side:\n* the target descriptor's `migrations.contractToSchema` hook and the trees\n* `renameTable` compares to find its companion renames both go through here,\n* so they are built with the same expander, default renderer, default resolver\n* and data type resolver.\n*/\nfunction postgresContractToSchema(contract, frameworkComponents) {\n\tconst expander = buildPostgresNativeTypeExpander(frameworkComponents);\n\treturn contractToPostgresDatabaseSchemaNode(blindCast(contract), {\n\t\tannotationNamespace: \"pg\",\n\t\texpandNativeType: expander,\n\t\trenderDefault: postgresRenderDefault,\n\t\tresolveDefault: postgresResolveDefault,\n\t\t...ifDefined(\"dataTypeOf\", buildDataTypeResolver(frameworkComponents))\n\t});\n}\n//#endregion\n//#region src/core/migrations/rename-rls-references.ts\nfunction renamedMarker(marker, rename) {\n\tif (!(marker instanceof PostgresRlsEnablement) || marker.tableName !== rename.from) return marker;\n\treturn new PostgresRlsEnablement({\n\t\ttableName: rename.to,\n\t\tnamespaceId: marker.namespaceId\n\t});\n}\nfunction renamedPolicy(policy, rename) {\n\tif (!(policy instanceof PostgresRlsPolicy) || policy.tableName !== rename.from) return policy;\n\treturn new PostgresRlsPolicy({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: rename.to,\n\t\tnamespaceId: policy.namespaceId,\n\t\toperation: policy.operation,\n\t\troles: policy.roles,\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive\n\t});\n}\n/**\n* Moves the RLS marker and the policies of a renamed table onto its new name. The marker is keyed by table name; policies are keyed by their own name and only their `tableName` changes. Policy names do not derive from the table name, so none is renamed.\n*/\nfunction renameRlsReferences(entries, rename) {\n\tconst markers = entries[\"rls\"];\n\tconst policies = entries[\"policy\"];\n\treturn {\n\t\t...entries,\n\t\t...markers === void 0 ? {} : { rls: Object.fromEntries(Object.entries(markers).map(([tableName, marker]) => [tableName === rename.from ? rename.to : tableName, renamedMarker(marker, rename)])) },\n\t\t...policies === void 0 ? {} : { policy: Object.fromEntries(Object.entries(policies).map(([name, policy]) => [name, renamedPolicy(policy, rename)])) }\n\t};\n}\n//#endregion\n//#region src/core/migrations/table-rename-constraint-renames.ts\n/** The constraint of the next table the diff pairs with `node` and finds unchanged, as the diff compares them. */\nfunction unchangedIn(node, nextNodes) {\n\treturn nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));\n}\n/**\n* The constraint renames that follow a table rename. A primary key, unique constraint or foreign key the start contract left unnamed carries a name derived from the old table name. When the end contract keeps the same constraint unchanged, it is renamed to the name the end contract gives it explicitly, or otherwise to the name derived from the new table name. A constraint the end contract changes is not renamed, so it keeps its name in the database. A constraint the start contract named keeps its name. Indexes and checks are not handled here: their wire names pair by content hash in the index and check rename passes.\n*/\nfunction constraintRenamesForTableRename(input) {\n\tconst { schemaName, from, to, previous, next } = input;\n\tconst rename = (kind, oldName, unchanged, derivedName) => {\n\t\tif (unchanged === void 0) return [];\n\t\tconst newName = unchanged.name ?? derivedName;\n\t\treturn oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];\n\t};\n\tconst primaryKey = previous.primaryKey !== void 0 && previous.primaryKey.name === void 0 ? rename(\"primaryKey\", defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to)) : [];\n\tconst uniques = previous.uniques.filter((unique) => unique.name === void 0).flatMap((unique) => rename(\"unique\", defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));\n\tconst foreignKeys = previous.foreignKeys.filter((fk) => fk.name === void 0).flatMap((fk) => rename(\"foreignKey\", defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));\n\treturn [\n\t\t...primaryKey,\n\t\t...uniques,\n\t\t...foreignKeys\n\t];\n}\n//#endregion\n//#region src/core/migrations/table-rename-calls.ts\nconst RENAME_POLICY = { allowedOperationClasses: [\"widening\"] };\nfunction emissionSchemaForNamespace(contract, namespaceId) {\n\treturn namespaceId === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId);\n}\nfunction renamedTableNode(schema, contract, rename) {\n\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, rename.namespaceId);\n\tconst table = Object.values(schema.namespaces).find((namespace) => namespace.schemaName === ddlSchema)?.tables[rename.to];\n\tassertDefined(table, `a resolved rename names table \"${rename.to}\" in schema \"${ddlSchema}\"`);\n\treturn table;\n}\n/**\n* The calls a migration's `renameTable` emits: the table rename, then a rename of each primary key, unique constraint and foreign key the start contract left unnamed, and of each wire-named index and check whose prefix derives from the table name. Only objects the end contract leaves otherwise unchanged are renamed; an unchanged constraint takes the end contract's explicit name if it has one. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when the start contract lacks the table or the end contract lacks the new name.\n*/\nfunction postgresTableRenameCalls(input) {\n\tconst applied = applyTableRename({\n\t\tstartContract: input.startContract,\n\t\tendContract: input.endContract,\n\t\trename: input.rename,\n\t\trenameTableReferences: renameRlsReferences\n\t});\n\tif (!applied.ok) throw applied.failure;\n\tconst { rename } = applied.value;\n\tconst contract = input.endContract;\n\tconst schemaName = emissionSchemaForNamespace(contract, rename.namespaceId);\n\tconst previousSchema = postgresContractToSchema(applied.value.contract, input.frameworkComponents);\n\tconst nextSchema = postgresContractToSchema(contract, input.frameworkComponents);\n\tconst { issues } = buildPostgresPlanDiff({\n\t\tcontract,\n\t\tactualSchema: previousSchema,\n\t\tframeworkComponents: input.frameworkComponents\n\t});\n\tconst onRenamedTable = (call) => call.schemaName === schemaName && call.tableName === rename.to;\n\tconst pairing = {\n\t\tcontract,\n\t\tpolicy: RENAME_POLICY\n\t};\n\treturn [\n\t\tnew RenameTableCall(schemaName, rename.from, rename.to),\n\t\t...constraintRenamesForTableRename({\n\t\t\tschemaName,\n\t\t\tfrom: rename.from,\n\t\t\tto: rename.to,\n\t\t\tprevious: renamedTableNode(previousSchema, contract, rename),\n\t\t\tnext: renamedTableNode(nextSchema, contract, rename)\n\t\t}),\n\t\t...pairIndexRenames(pairing, issues).calls.filter(onRenamedTable),\n\t\t...pairCheckRenames(pairing, issues).calls.filter(onRenamedTable)\n\t];\n}\n//#endregion\n//#region src/core/migrations/postgres-migration.ts\n/**\n* Target-owned base class for Postgres migrations.\n*\n* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n* abstract `targetId` to the Postgres target-id string literal, so both\n* user-authored migrations and renderer-generated scaffolds (the output of\n* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n* redeclaring target-local identity.\n*\n* Mirrors `MongoMigration` in `@internal/family-mongo`: the renderer\n* emits `extends Migration` against a facade re-export of this class\n* from `@internal/postgres/migration`, keeping the authoring surface\n* target-scoped rather than family-scoped.\n*\n* The constructor materializes a single Postgres `SqlControlAdapter` from\n* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n* instance method forwards to the free `dataTransform` factory with that\n* stored adapter, so user migrations can write `this.dataTransform(...)`\n* without threading the adapter through every call.\n*\n* Every method requires an explicit `schema`. Postgres migrations name their\n* schema deliberately — there is no default and no `search_path`-relative\n* option. A migration that left the schema unspecified would resolve against\n* whatever `search_path` the connection happened to carry, and that ambiguity\n* is an antipattern in a migration. (The unbound/unspecified namespace concept\n* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n*/\nvar PostgresMigration = class extends Migration {\n\ttargetId = \"postgres\";\n\t/**\n\t* Materialized Postgres control adapter, created once per migration\n\t* instance from the injected stack. `undefined` only when the migration\n\t* was instantiated without a stack (test fixtures); `controlAdapterFor`\n\t* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n\t*/\n\tcontrolAdapter;\n\t#endView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\t#startView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\tconstructor(stack) {\n\t\tsuper(stack);\n\t\tthis.controlAdapter = stack?.adapter ? blindCast(stack.adapter.create(stack)) : void 0;\n\t}\n\tframeworkComponents() {\n\t\tconst stack = this.stack;\n\t\tif (stack === void 0) return [];\n\t\treturn [\n\t\t\tstack.target,\n\t\t\t...stack.adapter === void 0 ? [] : [stack.adapter],\n\t\t\t...stack.extensions\n\t\t];\n\t}\n\t/**\n\t* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n\t* `operation` when the migration was constructed without a `ControlStack`.\n\t* Single home for the null-check that every DDL/DML method shares.\n\t*/\n\tcontrolAdapterFor(operation) {\n\t\tif (!this.controlAdapter) throw errorPostgresMigrationStackMissing(operation);\n\t\treturn this.controlAdapter;\n\t}\n\t/**\n\t* The typed, schema-qualified Postgres view over this migration's end-state\n\t* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n\t* if no `endContractJson` was provided.\n\t*/\n\tget endContract() {\n\t\treturn this.#endView.endContract;\n\t}\n\t/**\n\t* The typed Postgres view over this migration's start-state contract, or\n\t* `null` for a baseline migration (no `startContractJson`).\n\t*/\n\tget startContract() {\n\t\treturn this.#startView.startContract;\n\t}\n\t/**\n\t* Instance-method wrapper around the free `dataTransform` factory that\n\t* supplies the stored control adapter. Authors call this from inside\n\t* `get operations()`; the adapter argument is hidden from the call site.\n\t*/\n\tdataTransform(contract, name, options) {\n\t\treturn dataTransform(contract, name, options, this.controlAdapterFor(\"dataTransform\"));\n\t}\n\t/**\n\t* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateTable(options) {\n\t\treturn new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapterFor(\"createTable\"));\n\t}\n\t/**\n\t* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateSchema(options) {\n\t\treturn new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor(\"createSchema\"));\n\t}\n\t/**\n\t* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n\t* native enum. Builds a typed DDL node and lowers it through the stored\n\t* control adapter (members render in declaration order). Throws if no adapter\n\t* is present.\n\t*/\n\tcreateNativeEnumType(options) {\n\t\treturn new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor(\"createNativeEnumType\"));\n\t}\n\t/**\n\t* Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n\t* through the stored control adapter. Throws if no adapter is present.\n\t*/\n\tdropNativeEnumType(options) {\n\t\treturn new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor(\"dropNativeEnumType\"));\n\t}\n\t/**\n\t* Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n\t* member to a managed native enum, lowered through the stored control\n\t* adapter. Throws if no adapter is present. Every appended value is its\n\t* own operation — call this once per value to append more than one.\n\t*/\n\taddNativeEnumValue(options) {\n\t\treturn new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(this.controlAdapterFor(\"addNativeEnumValue\"));\n\t}\n\taddColumn(options) {\n\t\treturn new AddColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"addColumn\"));\n\t}\n\taddPrimaryKey(options) {\n\t\treturn new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addPrimaryKey\"));\n\t}\n\taddUnique(options) {\n\t\treturn new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addUnique\"));\n\t}\n\taddForeignKey(options) {\n\t\treturn new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapterFor(\"addForeignKey\"));\n\t}\n\taddCheckConstraint(options) {\n\t\treturn new AddCheckConstraintCall(options.schema, options.table, options.constraint, options.expression).toOp(this.controlAdapterFor(\"addCheckConstraint\"));\n\t}\n\trenameCheckConstraint(options) {\n\t\treturn this.renameConstraint({\n\t\t\t...options,\n\t\t\tkind: \"checkConstraint\"\n\t\t});\n\t}\n\trenameConstraint(options) {\n\t\treturn new RenameConstraintCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.kind, options.from, options.to).toOp(this.controlAdapterFor(\"renameConstraint\"));\n\t}\n\tdropCheckConstraint(options) {\n\t\treturn new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapterFor(\"dropCheckConstraint\"));\n\t}\n\tdropConstraint(options) {\n\t\treturn new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? \"unique\").toOp(this.controlAdapterFor(\"dropConstraint\"));\n\t}\n\t/**\n\t* Emit the operations that rename a table: the table rename, then a rename of each primary key, unique constraint, foreign key, index and check whose name was derived from the old table name, read from this migration's start and end contracts. Spread the result into `operations`: `...this.renameTable({ table: 'userProfile', to: 'UserProfile' })`. `schema` names the table's namespace when more than one declares the table. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when the start contract lacks the table or the end contract lacks the new name.\n\t*/\n\trenameTable(options) {\n\t\tconst adapter = this.controlAdapterFor(\"renameTable\");\n\t\treturn postgresTableRenameCalls({\n\t\t\tstartContract: this.startContract,\n\t\t\tendContract: this.endContract,\n\t\t\trename: {\n\t\t\t\tnamespaceId: options.schema,\n\t\t\t\tfrom: options.table,\n\t\t\t\tto: options.to\n\t\t\t},\n\t\t\tframeworkComponents: this.frameworkComponents()\n\t\t}).map(async (call) => call.toOp(adapter));\n\t}\n\tdropTable(options) {\n\t\treturn new DropTableCall(options.schema, options.table).toOp(this.controlAdapterFor(\"dropTable\"));\n\t}\n\tdropColumn(options) {\n\t\treturn new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropColumn\"));\n\t}\n\talterColumnType(options) {\n\t\treturn new AlterColumnTypeCall(options.schema, options.table, options.column, options.options).toOp(this.controlAdapterFor(\"alterColumnType\"));\n\t}\n\tsetNotNull(options) {\n\t\treturn new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"setNotNull\"));\n\t}\n\tdropNotNull(options) {\n\t\treturn new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropNotNull\"));\n\t}\n\tsetDefault(options) {\n\t\trefuseEarlierSetDefaultOptions(options);\n\t\treturn new SetDefaultCall(options.schema, options.table, options.column, options.operationClass).toOp(this.controlAdapterFor(\"setDefault\"));\n\t}\n\tdropDefault(options) {\n\t\treturn new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropDefault\"));\n\t}\n\tcreateIndex(options) {\n\t\treturn new CreateIndexCall(options.schema, options.table, options.index, options.columns !== void 0 ? { columns: options.columns } : { expression: options.expression }, options.extras).toOp(this.controlAdapterFor(\"createIndex\"));\n\t}\n\trenameIndex(options) {\n\t\treturn new RenameIndexCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameIndex\"));\n\t}\n\tdropIndex(options) {\n\t\treturn new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor(\"dropIndex\"));\n\t}\n\tinstallExtension(options) {\n\t\treturn installExtension(options, this.controlAdapterFor(\"installExtension\"));\n\t}\n\tenableRowLevelSecurity(options) {\n\t\treturn new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"enableRowLevelSecurity\"));\n\t}\n\tdisableRowLevelSecurity(options) {\n\t\treturn new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"disableRowLevelSecurity\"));\n\t}\n\tcreateRlsPolicy(options) {\n\t\treturn new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy({\n\t\t\t...options.policy,\n\t\t\tusing: options.policy.using,\n\t\t\twithCheck: options.policy.withCheck\n\t\t})).toOp(this.controlAdapterFor(\"createRlsPolicy\"));\n\t}\n\tdropRlsPolicy(options) {\n\t\treturn new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor(\"dropRlsPolicy\"));\n\t}\n\trenameRlsPolicy(options) {\n\t\treturn new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameRlsPolicy\"));\n\t}\n};\n/**\n* `setDefault` options an earlier version wrote carry the column's name in `column` and its default as SQL text in `defaultSql`.\n*/\nfunction refuseEarlierSetDefaultOptions(options) {\n\tconst column = options.column;\n\tconst columnIsName = typeof column === \"string\";\n\tif (!columnIsName && !Object.hasOwn(options, \"defaultSql\")) return;\n\tthrow errorMigrationOperationOptionRemoved({\n\t\toperation: \"setDefault\",\n\t\toption: \"defaultSql\",\n\t\tsubject: `column ${JSON.stringify(columnIsName ? column : options.column.name)} of table ${JSON.stringify(options.table)}`,\n\t\trewrite: \"Pass the column as `col(name, type, { default, codecRef })`, with its default written as `lit(value)` or `fn(expression)`, in place of its name and `defaultSql`.\",\n\t\tupgradeEntry: \"migration-ts-column-defaults\"\n\t});\n}\n//#endregion\nexport { pairCheckRenames as a, postgresRenderDefault as i, emissionSchemaForNamespace as n, pairIndexRenames as o, postgresContractToSchema as r, PostgresMigration as t };\n\n//# sourceMappingURL=postgres-migration-CMcrvJni.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;CACvB,MAAM,eAAe,OAAO,WAAW;CACvC,IAAI,CAAC,gBAAgB,CAAC,OAAO,OAAO,SAAS,YAAY,GAAG;CAC5D,MAAM,qCAAqC;EAC1C,WAAW;EACX,QAAQ;EACR,SAAS,UAAU,KAAK,UAAU,eAAe,SAAS,QAAQ,OAAO,IAAI,EAAE,YAAY,KAAK,UAAU,QAAQ,KAAK;EACvH,SAAS;EACT,cAAc;CACf,CAAC;AACF"}
|
|
1
|
+
{"version":3,"file":"postgres-migration-Dq60Mixq-DYNJokZW.mjs","names":["#endView","#startView"],"sources":["../../../../3-targets/3-targets/postgres/dist/postgres-migration-Dq60Mixq.mjs"],"sourcesContent":["import { t as errorPostgresMigrationStackMissing } from \"./errors-DYyzTYzE.mjs\";\nimport { _ as PostgresRlsPolicy, v as PostgresRlsEnablement } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-ByDD_gRm.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-Bq4m2dD9.mjs\";\nimport { i as contractToPostgresDatabaseSchemaNode, r as buildPostgresNativeTypeExpander, t as buildPostgresPlanDiff } from \"./diff-database-schema-_bbfF4oI.mjs\";\nimport { c as issueNode, f as defaultForeignKeyName, m as defaultUniqueName, n as resolveNamespaceIdForDdlSchema, p as defaultPrimaryKeyName } from \"./control-policy-BW5Cgq3Z.mjs\";\nimport { A as RenameIndexCall, B as installExtension, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, M as RenameTableCall, N as SetDefaultCall, P as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as RenamePostgresRlsPolicyCall, k as RenameConstraintCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from \"./op-factory-call-DkzlLBzN.mjs\";\nimport { n as renderDefaultLiteral } from \"./planner-ddl-builders-BZLzBmuq.mjs\";\nimport { t as PostgresContractView } from \"./postgres-contract-view-Da0ymIZE.mjs\";\nimport { t as dataTransform } from \"./data-transform-Bo32KRbq.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { applyTableRename, buildDataTypeResolver } from \"@internal/family-sql/control\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { SqlCheckConstraintIR, SqlIndexIR } from \"@internal/sql-schema-ir/types\";\nimport { errorMigrationOperationOptionRemoved } from \"@internal/errors/migration\";\nimport { Migration } from \"@internal/family-sql/migration\";\nimport { MigrationContractViews } from \"@internal/migration-tools/migration\";\n//#region src/core/migrations/index-and-check-renames.ts\n/**\n* Rename post-pass for indexes, per `(schema, table)`, widening-only,\n* deterministic by sorted names — the same structure as the policy pass\n* below (which stays untouched: policies pair by hash only).\n*\n* Hash pairing (prefix-only renames): extras whose live names parse as\n* wire names, grouped by `(schema, table, hash)`; missing nodes iterated\n* in sorted-name order consume the sorted-name-first candidate.\n*\n* Content pairing (exact→wire convergence), after hash pairing has\n* consumed its matches: the remaining wire-named-missing nodes\n* (`prefix` defined) against the remaining extras of any name shape,\n* paired iff content-equal (columns ordered-strict both-defined-or-\n* both-undefined, `unique`/`type` strict, `options` loose, bodies\n* byte-equal).\n*\n* Leftovers proceed as create/drop exactly as before; without the\n* widening allowance the pass is skipped and pairing degrades to the\n* additive half, like the policy pass.\n*/\nfunction pairIndexRenames(options, issues) {\n\tconst consumed = /* @__PURE__ */ new Set();\n\tconst calls = [];\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst missing = [];\n\tconst extra = [];\n\tfor (const issue of issues) {\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0 || !SqlIndexIR.is(node)) continue;\n\t\tconst ddlSchema = issue.path[1];\n\t\tconst tableName = issue.path[2];\n\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t}\n\tif (missing.length === 0 || extra.length === 0) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\tfinding.ddlSchema,\n\t\tfinding.tableName,\n\t\thash\n\t]);\n\tconst rename = (missingFinding, candidate) => {\n\t\tconsumed.add(missingFinding.issue);\n\t\tconsumed.add(candidate.issue);\n\t\tcalls.push(new RenameIndexCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, candidate.node.name, missingFinding.node.name));\n\t};\n\tconst sortedMissing = [...missing].sort(byName);\n\tconst extrasByHash = /* @__PURE__ */ new Map();\n\tfor (const finding of extra) {\n\t\tconst parsed = parseWireName(finding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst key = pairingKey(finding, parsed.hash);\n\t\tconst group = extrasByHash.get(key) ?? [];\n\t\tgroup.push(finding);\n\t\textrasByHash.set(key, group);\n\t}\n\tfor (const group of extrasByHash.values()) group.sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\tif (candidate === void 0) continue;\n\t\trename(missingFinding, candidate);\n\t}\n\tconst sortedExtras = [...extra].sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tif (consumed.has(missingFinding.issue)) continue;\n\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\tconst candidate = sortedExtras.find((extraFinding) => !consumed.has(extraFinding.issue) && extraFinding.ddlSchema === missingFinding.ddlSchema && extraFinding.tableName === missingFinding.tableName && missingFinding.node.contentEquals(extraFinding.node, {\n\t\t\tcolumnPresence: \"matching\",\n\t\t\tbodies: \"verbatim\"\n\t\t}));\n\t\tif (candidate === void 0) continue;\n\t\trename(missingFinding, candidate);\n\t}\n\treturn {\n\t\tcalls,\n\t\tconsumed\n\t};\n}\n/**\n* Check-constraint rename post-pass: a `not-found` and a `not-expected`\n* check on the same table whose wire-name content hashes match but whose\n* prefixes differ is a prefix-only rename, and collapses into one\n* `ALTER TABLE … RENAME CONSTRAINT`.\n*\n* This is the index pass's hash-pairing phase and nothing else. There is\n* deliberately no content-pairing phase: a live check body is whatever\n* Postgres reprinted, so it never byte-matches the authored text, and\n* pairing an exact-named live check by content would bless whatever\n* predicate is actually live. Adoption of an old exact-named check stays\n* drop + add.\n*\n* Runs only when the policy allows `widening` (rename's class). Without it\n* the pass no-ops and the pair degrades to the slice-1 behavior: an add,\n* plus a drop when `destructive` is allowed too.\n*/\nfunction pairCheckRenames(options, issues) {\n\tconst consumed = /* @__PURE__ */ new Set();\n\tconst calls = [];\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst missing = [];\n\tconst extra = [];\n\tfor (const issue of issues) {\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0 || !SqlCheckConstraintIR.is(node)) continue;\n\t\tconst ddlSchema = issue.path[1];\n\t\tconst tableName = issue.path[2];\n\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t}\n\tif (missing.length === 0 || extra.length === 0) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\tfinding.ddlSchema,\n\t\tfinding.tableName,\n\t\thash\n\t]);\n\tconst sortedMissing = [...missing].sort(byName);\n\tconst extrasByHash = /* @__PURE__ */ new Map();\n\tfor (const finding of extra) {\n\t\tconst parsed = parseWireName(finding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst key = pairingKey(finding, parsed.hash);\n\t\tconst group = extrasByHash.get(key) ?? [];\n\t\tgroup.push(finding);\n\t\textrasByHash.set(key, group);\n\t}\n\tfor (const group of extrasByHash.values()) group.sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\tif (candidate === void 0) continue;\n\t\tconsumed.add(missingFinding.issue);\n\t\tconsumed.add(candidate.issue);\n\t\tcalls.push(new RenameConstraintCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, \"checkConstraint\", candidate.node.name, missingFinding.node.name));\n\t}\n\treturn {\n\t\tcalls,\n\t\tconsumed\n\t};\n}\n//#endregion\n//#region src/core/migrations/postgres-contract-to-schema.ts\nfunction postgresRenderDefault(def, column) {\n\tif (def.kind === \"function\") return def.expression;\n\treturn renderDefaultLiteral(def.value, column);\n}\n/**\n* The Postgres schema tree a contract describes, as the planner's \"from\" side:\n* the target descriptor's `migrations.contractToSchema` hook and the trees\n* `renameTable` compares to find its companion renames both go through here,\n* so they are built with the same expander, default renderer, default resolver\n* and data type resolver.\n*/\nfunction postgresContractToSchema(contract, frameworkComponents) {\n\tconst expander = buildPostgresNativeTypeExpander(frameworkComponents);\n\treturn contractToPostgresDatabaseSchemaNode(blindCast(contract), {\n\t\tannotationNamespace: \"pg\",\n\t\texpandNativeType: expander,\n\t\trenderDefault: postgresRenderDefault,\n\t\tresolveDefault: postgresResolveDefault,\n\t\t...ifDefined(\"dataTypeOf\", buildDataTypeResolver(frameworkComponents))\n\t});\n}\n//#endregion\n//#region src/core/migrations/rename-rls-references.ts\nfunction renamedMarker(marker, rename) {\n\tif (!(marker instanceof PostgresRlsEnablement) || marker.tableName !== rename.from) return marker;\n\treturn new PostgresRlsEnablement({\n\t\ttableName: rename.to,\n\t\tnamespaceId: marker.namespaceId\n\t});\n}\nfunction renamedPolicy(policy, rename) {\n\tif (!(policy instanceof PostgresRlsPolicy) || policy.tableName !== rename.from) return policy;\n\treturn new PostgresRlsPolicy({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: rename.to,\n\t\tnamespaceId: policy.namespaceId,\n\t\toperation: policy.operation,\n\t\troles: policy.roles,\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive\n\t});\n}\n/**\n* Moves the RLS marker and the policies of a renamed table onto its new name. The marker is keyed by table name; policies are keyed by their own name and only their `tableName` changes. Policy names do not derive from the table name, so none is renamed.\n*/\nfunction renameRlsReferences(entries, rename) {\n\tconst markers = entries[\"rls\"];\n\tconst policies = entries[\"policy\"];\n\treturn {\n\t\t...entries,\n\t\t...markers === void 0 ? {} : { rls: Object.fromEntries(Object.entries(markers).map(([tableName, marker]) => [tableName === rename.from ? rename.to : tableName, renamedMarker(marker, rename)])) },\n\t\t...policies === void 0 ? {} : { policy: Object.fromEntries(Object.entries(policies).map(([name, policy]) => [name, renamedPolicy(policy, rename)])) }\n\t};\n}\n//#endregion\n//#region src/core/migrations/table-rename-constraint-renames.ts\n/** The constraint of the next table the diff pairs with `node` and finds unchanged, as the diff compares them. */\nfunction unchangedIn(node, nextNodes) {\n\treturn nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));\n}\n/**\n* The constraint renames that follow a table rename. A primary key, unique constraint or foreign key the start contract left unnamed carries a name derived from the old table name. When the end contract keeps the same constraint unchanged, it is renamed to the name the end contract gives it explicitly, or otherwise to the name derived from the new table name. A constraint the end contract changes is not renamed, so it keeps its name in the database. A constraint the start contract named keeps its name. Indexes and checks are not handled here: their wire names pair by content hash in the index and check rename passes.\n*/\nfunction constraintRenamesForTableRename(input) {\n\tconst { schemaName, from, to, previous, next } = input;\n\tconst rename = (kind, oldName, unchanged, derivedName) => {\n\t\tif (unchanged === void 0) return [];\n\t\tconst newName = unchanged.name ?? derivedName;\n\t\treturn oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];\n\t};\n\tconst primaryKey = previous.primaryKey !== void 0 && previous.primaryKey.name === void 0 ? rename(\"primaryKey\", defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to)) : [];\n\tconst uniques = previous.uniques.filter((unique) => unique.name === void 0).flatMap((unique) => rename(\"unique\", defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));\n\tconst foreignKeys = previous.foreignKeys.filter((fk) => fk.name === void 0).flatMap((fk) => rename(\"foreignKey\", defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));\n\treturn [\n\t\t...primaryKey,\n\t\t...uniques,\n\t\t...foreignKeys\n\t];\n}\n//#endregion\n//#region src/core/migrations/table-rename-calls.ts\nconst RENAME_POLICY = { allowedOperationClasses: [\"widening\"] };\nfunction emissionSchemaForNamespace(contract, namespaceId) {\n\treturn namespaceId === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId);\n}\nfunction renamedTableNode(schema, contract, rename) {\n\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, rename.namespaceId);\n\tconst table = Object.values(schema.namespaces).find((namespace) => namespace.schemaName === ddlSchema)?.tables[rename.to];\n\tassertDefined(table, `a resolved rename names table \"${rename.to}\" in schema \"${ddlSchema}\"`);\n\treturn table;\n}\n/**\n* The calls a migration's `renameTable` emits: the table rename, then a rename of each primary key, unique constraint and foreign key the start contract left unnamed, and of each wire-named index and check whose prefix derives from the table name. Only objects the end contract leaves otherwise unchanged are renamed; an unchanged constraint takes the end contract's explicit name if it has one. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when the start contract lacks the table or the end contract lacks the new name.\n*/\nfunction postgresTableRenameCalls(input) {\n\tconst applied = applyTableRename({\n\t\tstartContract: input.startContract,\n\t\tendContract: input.endContract,\n\t\trename: input.rename,\n\t\trenameTableReferences: renameRlsReferences\n\t});\n\tif (!applied.ok) throw applied.failure;\n\tconst { rename } = applied.value;\n\tconst contract = input.endContract;\n\tconst schemaName = emissionSchemaForNamespace(contract, rename.namespaceId);\n\tconst previousSchema = postgresContractToSchema(applied.value.contract, input.frameworkComponents);\n\tconst nextSchema = postgresContractToSchema(contract, input.frameworkComponents);\n\tconst { issues } = buildPostgresPlanDiff({\n\t\tcontract,\n\t\tactualSchema: previousSchema,\n\t\tframeworkComponents: input.frameworkComponents\n\t});\n\tconst onRenamedTable = (call) => call.schemaName === schemaName && call.tableName === rename.to;\n\tconst pairing = {\n\t\tcontract,\n\t\tpolicy: RENAME_POLICY\n\t};\n\treturn [\n\t\tnew RenameTableCall(schemaName, rename.from, rename.to),\n\t\t...constraintRenamesForTableRename({\n\t\t\tschemaName,\n\t\t\tfrom: rename.from,\n\t\t\tto: rename.to,\n\t\t\tprevious: renamedTableNode(previousSchema, contract, rename),\n\t\t\tnext: renamedTableNode(nextSchema, contract, rename)\n\t\t}),\n\t\t...pairIndexRenames(pairing, issues).calls.filter(onRenamedTable),\n\t\t...pairCheckRenames(pairing, issues).calls.filter(onRenamedTable)\n\t];\n}\n//#endregion\n//#region src/core/migrations/postgres-migration.ts\n/**\n* Target-owned base class for Postgres migrations.\n*\n* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n* abstract `targetId` to the Postgres target-id string literal, so both\n* user-authored migrations and renderer-generated scaffolds (the output of\n* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n* redeclaring target-local identity.\n*\n* Mirrors `MongoMigration` in `@internal/family-mongo`: the renderer\n* emits `extends Migration` against a facade re-export of this class\n* from `@internal/postgres/migration`, keeping the authoring surface\n* target-scoped rather than family-scoped.\n*\n* The constructor materializes a single Postgres `SqlControlAdapter` from\n* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n* instance method forwards to the free `dataTransform` factory with that\n* stored adapter, so user migrations can write `this.dataTransform(...)`\n* without threading the adapter through every call.\n*\n* Every method requires an explicit `schema`. Postgres migrations name their\n* schema deliberately — there is no default and no `search_path`-relative\n* option. A migration that left the schema unspecified would resolve against\n* whatever `search_path` the connection happened to carry, and that ambiguity\n* is an antipattern in a migration. (The unbound/unspecified namespace concept\n* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n*/\nvar PostgresMigration = class extends Migration {\n\ttargetId = \"postgres\";\n\t/**\n\t* Materialized Postgres control adapter, created once per migration\n\t* instance from the injected stack. `undefined` only when the migration\n\t* was instantiated without a stack (test fixtures); `controlAdapterFor`\n\t* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n\t*/\n\tcontrolAdapter;\n\t#endView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\t#startView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\tconstructor(stack) {\n\t\tsuper(stack);\n\t\tthis.controlAdapter = stack?.adapter ? blindCast(stack.adapter.create(stack)) : void 0;\n\t}\n\tframeworkComponents() {\n\t\tconst stack = this.stack;\n\t\tif (stack === void 0) return [];\n\t\treturn [\n\t\t\tstack.target,\n\t\t\t...stack.adapter === void 0 ? [] : [stack.adapter],\n\t\t\t...stack.extensions\n\t\t];\n\t}\n\t/**\n\t* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n\t* `operation` when the migration was constructed without a `ControlStack`.\n\t* Single home for the null-check that every DDL/DML method shares.\n\t*/\n\tcontrolAdapterFor(operation) {\n\t\tif (!this.controlAdapter) throw errorPostgresMigrationStackMissing(operation);\n\t\treturn this.controlAdapter;\n\t}\n\t/**\n\t* The typed, schema-qualified Postgres view over this migration's end-state\n\t* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n\t* if no `endContractJson` was provided.\n\t*/\n\tget endContract() {\n\t\treturn this.#endView.endContract;\n\t}\n\t/**\n\t* The typed Postgres view over this migration's start-state contract, or\n\t* `null` for a baseline migration (no `startContractJson`).\n\t*/\n\tget startContract() {\n\t\treturn this.#startView.startContract;\n\t}\n\t/**\n\t* Instance-method wrapper around the free `dataTransform` factory that\n\t* supplies the stored control adapter. Authors call this from inside\n\t* `get operations()`; the adapter argument is hidden from the call site.\n\t*/\n\tdataTransform(contract, name, options) {\n\t\treturn dataTransform(contract, name, options, this.controlAdapterFor(\"dataTransform\"));\n\t}\n\t/**\n\t* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateTable(options) {\n\t\treturn new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapterFor(\"createTable\"));\n\t}\n\t/**\n\t* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateSchema(options) {\n\t\treturn new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor(\"createSchema\"));\n\t}\n\t/**\n\t* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n\t* native enum. Builds a typed DDL node and lowers it through the stored\n\t* control adapter (members render in declaration order). Throws if no adapter\n\t* is present.\n\t*/\n\tcreateNativeEnumType(options) {\n\t\treturn new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor(\"createNativeEnumType\"));\n\t}\n\t/**\n\t* Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n\t* through the stored control adapter. Throws if no adapter is present.\n\t*/\n\tdropNativeEnumType(options) {\n\t\treturn new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor(\"dropNativeEnumType\"));\n\t}\n\t/**\n\t* Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n\t* member to a managed native enum, lowered through the stored control\n\t* adapter. Throws if no adapter is present. Every appended value is its\n\t* own operation — call this once per value to append more than one.\n\t*/\n\taddNativeEnumValue(options) {\n\t\treturn new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(this.controlAdapterFor(\"addNativeEnumValue\"));\n\t}\n\taddColumn(options) {\n\t\treturn new AddColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"addColumn\"));\n\t}\n\taddPrimaryKey(options) {\n\t\treturn new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addPrimaryKey\"));\n\t}\n\taddUnique(options) {\n\t\treturn new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addUnique\"));\n\t}\n\taddForeignKey(options) {\n\t\treturn new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapterFor(\"addForeignKey\"));\n\t}\n\taddCheckConstraint(options) {\n\t\treturn new AddCheckConstraintCall(options.schema, options.table, options.constraint, options.expression).toOp(this.controlAdapterFor(\"addCheckConstraint\"));\n\t}\n\trenameCheckConstraint(options) {\n\t\treturn this.renameConstraint({\n\t\t\t...options,\n\t\t\tkind: \"checkConstraint\"\n\t\t});\n\t}\n\trenameConstraint(options) {\n\t\treturn new RenameConstraintCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.kind, options.from, options.to).toOp(this.controlAdapterFor(\"renameConstraint\"));\n\t}\n\tdropCheckConstraint(options) {\n\t\treturn new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapterFor(\"dropCheckConstraint\"));\n\t}\n\tdropConstraint(options) {\n\t\treturn new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? \"unique\").toOp(this.controlAdapterFor(\"dropConstraint\"));\n\t}\n\t/**\n\t* Emit the operations that rename a table: the table rename, then a rename of each primary key, unique constraint, foreign key, index and check whose name was derived from the old table name, read from this migration's start and end contracts. Spread the result into `operations`: `...this.renameTable({ table: 'userProfile', to: 'UserProfile' })`. `schema` names the table's namespace when more than one declares the table. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when the start contract lacks the table or the end contract lacks the new name.\n\t*/\n\trenameTable(options) {\n\t\tconst adapter = this.controlAdapterFor(\"renameTable\");\n\t\treturn postgresTableRenameCalls({\n\t\t\tstartContract: this.startContract,\n\t\t\tendContract: this.endContract,\n\t\t\trename: {\n\t\t\t\tnamespaceId: options.schema,\n\t\t\t\tfrom: options.table,\n\t\t\t\tto: options.to\n\t\t\t},\n\t\t\tframeworkComponents: this.frameworkComponents()\n\t\t}).map(async (call) => call.toOp(adapter));\n\t}\n\tdropTable(options) {\n\t\treturn new DropTableCall(options.schema, options.table).toOp(this.controlAdapterFor(\"dropTable\"));\n\t}\n\tdropColumn(options) {\n\t\treturn new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropColumn\"));\n\t}\n\talterColumnType(options) {\n\t\treturn new AlterColumnTypeCall(options.schema, options.table, options.column, options.options).toOp(this.controlAdapterFor(\"alterColumnType\"));\n\t}\n\tsetNotNull(options) {\n\t\treturn new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"setNotNull\"));\n\t}\n\tdropNotNull(options) {\n\t\treturn new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropNotNull\"));\n\t}\n\tsetDefault(options) {\n\t\trefuseEarlierSetDefaultOptions(options);\n\t\treturn new SetDefaultCall(options.schema, options.table, options.column, options.operationClass).toOp(this.controlAdapterFor(\"setDefault\"));\n\t}\n\tdropDefault(options) {\n\t\treturn new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropDefault\"));\n\t}\n\tcreateIndex(options) {\n\t\treturn new CreateIndexCall(options.schema, options.table, options.index, options.columns !== void 0 ? { columns: options.columns } : { expression: options.expression }, options.extras).toOp(this.controlAdapterFor(\"createIndex\"));\n\t}\n\trenameIndex(options) {\n\t\treturn new RenameIndexCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameIndex\"));\n\t}\n\tdropIndex(options) {\n\t\treturn new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor(\"dropIndex\"));\n\t}\n\tinstallExtension(options) {\n\t\treturn installExtension(options, this.controlAdapterFor(\"installExtension\"));\n\t}\n\tenableRowLevelSecurity(options) {\n\t\treturn new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"enableRowLevelSecurity\"));\n\t}\n\tdisableRowLevelSecurity(options) {\n\t\treturn new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"disableRowLevelSecurity\"));\n\t}\n\tcreateRlsPolicy(options) {\n\t\treturn new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy({\n\t\t\t...options.policy,\n\t\t\tusing: options.policy.using,\n\t\t\twithCheck: options.policy.withCheck\n\t\t})).toOp(this.controlAdapterFor(\"createRlsPolicy\"));\n\t}\n\tdropRlsPolicy(options) {\n\t\treturn new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor(\"dropRlsPolicy\"));\n\t}\n\trenameRlsPolicy(options) {\n\t\treturn new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameRlsPolicy\"));\n\t}\n};\n/**\n* `setDefault` options an earlier version wrote carry the column's name in `column` and its default as SQL text in `defaultSql`.\n*/\nfunction refuseEarlierSetDefaultOptions(options) {\n\tconst column = options.column;\n\tconst columnIsName = typeof column === \"string\";\n\tif (!columnIsName && !Object.hasOwn(options, \"defaultSql\")) return;\n\tthrow errorMigrationOperationOptionRemoved({\n\t\toperation: \"setDefault\",\n\t\toption: \"defaultSql\",\n\t\tsubject: `column ${JSON.stringify(columnIsName ? column : options.column.name)} of table ${JSON.stringify(options.table)}`,\n\t\trewrite: \"Pass the column as `col(name, type, { default, codecRef })`, with its default written as `lit(value)` or `fn(expression)`, in place of its name and `defaultSql`.\",\n\t\tupgradeEntry: \"migration-ts-column-defaults\"\n\t});\n}\n//#endregion\nexport { pairCheckRenames as a, postgresRenderDefault as i, emissionSchemaForNamespace as n, pairIndexRenames as o, postgresContractToSchema as r, PostgresMigration as t };\n\n//# sourceMappingURL=postgres-migration-Dq60Mixq.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAS,iBAAiB,SAAS,QAAQ;CAC1C,MAAM,2BAA2B,IAAI,IAAI;CACzC,MAAM,QAAQ,CAAC;CACf,IAAI,CAAC,QAAQ,OAAO,wBAAwB,SAAS,UAAU,GAAG,OAAO;EACxE;EACA;CAC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,QAAQ,OAAO,IAAI,EAAE,YAAY,KAAK,UAAU,QAAQ,KAAK;EACvH,SAAS;EACT,cAAc;CACf,CAAC;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { h as postgresCreateNamespace } from "./postgres-schema-C8slJGZo-CFGUyJPt.mjs";
|
|
2
|
-
import { m as postgresNowGeneratorIdFor } from "./authoring-
|
|
3
|
-
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-
|
|
4
|
-
import { t as parsePostgresDefault } from "./default-normalizer-
|
|
5
|
-
import { d as createPostgresTypeMap, l as buildPslDocumentAst, m as noColumnDefaults, t as EXISTING_COLUMN_DATE_TIME_TYPES, u as createPostgresDefaultMapping } from "./infer-psl-contract-
|
|
2
|
+
import { m as postgresNowGeneratorIdFor } from "./authoring-C5Ch8RNG-Qgq9GiOY.mjs";
|
|
3
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-Bvq6_NJ8-Cn_M79Lf.mjs";
|
|
4
|
+
import { t as parsePostgresDefault } from "./default-normalizer-ByDD_gRm-CKeWEb0x.mjs";
|
|
5
|
+
import { d as createPostgresTypeMap, l as buildPslDocumentAst, m as noColumnDefaults, t as EXISTING_COLUMN_DATE_TIME_TYPES, u as createPostgresDefaultMapping } from "./infer-psl-contract-Burb6YAz-DbKU4cXm.mjs";
|
|
6
6
|
import { SqlSchemaIR, SqlTableIR } from "@prisma/orm-family-sql/schema-ir/types";
|
|
7
7
|
import { toModelName } from "@prisma/orm-family-sql/family/psl-infer";
|
|
8
8
|
import { flatPslModels } from "@prisma/orm-framework/components/psl-ast";
|
|
@@ -330,4 +330,4 @@ const prisma7PostgresBinding = {
|
|
|
330
330
|
//#endregion
|
|
331
331
|
export { prisma7PostgresBinding as t };
|
|
332
332
|
|
|
333
|
-
//# sourceMappingURL=prisma7-binding-
|
|
333
|
+
//# sourceMappingURL=prisma7-binding-Dm24YoM6.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma7-binding-JTOc8zQB.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/prisma7-binding.mjs"],"sourcesContent":["import { c as postgresNowGeneratorIdFor } from \"./authoring-BX7WXyUK.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { t as postgresTargetDescriptorMeta } from \"./descriptor-meta-CNocPizV.mjs\";\nimport { t as parsePostgresDefault } from \"./default-normalizer-8E6ew8Nq.mjs\";\nimport { c as noColumnDefaults, g as EXISTING_COLUMN_DATE_TIME_TYPES, h as createPostgresTypeMap, r as createPostgresDefaultMapping, t as buildPslDocumentAst } from \"./infer-psl-contract-of3HBkov.mjs\";\nimport { SqlSchemaIR, SqlTableIR } from \"@internal/sql-schema-ir/types\";\nimport { toModelName } from \"@internal/family-sql/psl-infer\";\nimport { flatPslModels } from \"@internal/framework-components/psl-ast\";\n//#region src/core/prisma7-temporal-defaults.ts\nconst RFC_3339 = /^(\\d{4})-(\\d{2})-(\\d{2})[Tt ](\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?(?:[Zz]|([+-])(\\d{2}):(\\d{2}))$/;\nconst MICROS_PER_SECOND = 1e6;\nfunction pad(value, width = 2) {\n\treturn String(value).padStart(width, \"0\");\n}\n/**\n* The microseconds Postgres keeps for a fraction-of-a-second digit string. Every digit counts:\n* `.1234565` is an exact tie, and C's `rint` takes the even neighbour 123456, while `.1234565001`\n* is above the tie and rounds up to 123457.\n*/\nfunction fractionMicros(fraction) {\n\tconst micros = Number(`${fraction}000000`.slice(0, 6));\n\tconst beyondTie = fraction.slice(6).replace(/0+$/, \"\");\n\tif (beyondTie === \"\") return micros;\n\tif (beyondTie === \"5\") return micros % 2 === 0 ? micros : micros + 1;\n\treturn beyondTie > \"5\" ? micros + 1 : micros;\n}\nfunction fractionText(micros) {\n\treturn micros === 0 ? \"\" : `.${pad(micros, 6).replace(/0+$/, \"\")}`;\n}\nfunction offsetText(minutes) {\n\tconst magnitude = Math.abs(minutes);\n\tconst rest = magnitude % 60;\n\treturn `${minutes < 0 ? \"-\" : \"+\"}${pad(Math.floor(magnitude / 60))}${rest === 0 ? \"\" : `:${pad(rest)}`}`;\n}\n/**\n* The text of the column default Postgres stores for a Prisma 7 `DateTime`\n* default, which Prisma 7 writes as `'2024-01-02 03:04:05.123 +02:00'`:\n* `date` keeps the written date, `time` and `timestamp` the written wall-clock\n* time without the offset, and `timetz` the time with the written offset.\n* `timestamptz` is carried in its UTC form, the text a session in UTC prints\n* (`2024-01-02 01:04:05+00`, and `0001-12-31 23:30:00+00 BC` before year 1);\n* a session in another time zone prints the same instant differently.\n* Fractional seconds are rounded to microseconds; the column's own precision\n* does not change a stored default.\n*/\nfunction storedTemporalText(text, nativeType) {\n\tconst match = RFC_3339.exec(text);\n\tif (match === null) return void 0;\n\tconst [, year = \"\", month = \"\", day = \"\", hour, minute, second, fraction = \"\", sign, offsetHours, offsetMinutes] = match;\n\tif (nativeType === \"date\") return `${year}-${month}-${day}`;\n\tconst micros = fractionMicros(fraction);\n\tconst clockSeconds = Number(hour) * 3600 + Number(minute) * 60 + Number(second) + Math.floor(micros / MICROS_PER_SECOND);\n\tconst fractional = fractionText(micros % MICROS_PER_SECOND);\n\tconst offsetMinutesTotal = sign === void 0 ? 0 : (sign === \"-\" ? -1 : 1) * (Number(offsetHours) * 60 + Number(offsetMinutes));\n\tif (nativeType === \"time\" || nativeType === \"timetz\") {\n\t\tconst clock = `${pad(Math.floor(clockSeconds / 3600))}:${pad(Math.floor(clockSeconds / 60) % 60)}:${pad(clockSeconds % 60)}${fractional}`;\n\t\treturn nativeType === \"time\" ? clock : `${clock}${offsetText(offsetMinutesTotal)}`;\n\t}\n\tconst midnight = /* @__PURE__ */ new Date(0);\n\tmidnight.setUTCFullYear(Number(year), Number(month) - 1, Number(day));\n\tconst utcShift = nativeType === \"timestamptz\" ? offsetMinutesTotal * 60 : 0;\n\tconst stamp = new Date(midnight.getTime() + (clockSeconds - utcShift) * 1e3);\n\tconst astronomicalYear = stamp.getUTCFullYear();\n\tconst wallClock = `${pad(astronomicalYear > 0 ? astronomicalYear : 1 - astronomicalYear, 4)}-${pad(stamp.getUTCMonth() + 1)}-${pad(stamp.getUTCDate())} ${pad(stamp.getUTCHours())}:${pad(stamp.getUTCMinutes())}:${pad(stamp.getUTCSeconds())}${fractional}`;\n\tconst era = astronomicalYear > 0 ? \"\" : \" BC\";\n\treturn nativeType === \"timestamptz\" ? `${wallClock}+00${era}` : `${wallClock}${era}`;\n}\n//#endregion\n//#region src/core/prisma7-type-map.ts\n/**\n* What Prisma 7.10.0 creates in Postgres for each Prisma 7 scalar and `@db.*`\n* native type, expressed as the Prisma 8 authoring type constructor that\n* produces the same column. Derived from the SQL recorded in\n* `test/integration/test/fixtures/prisma7-source/reference/migration.sql`.\n* `args` are the constructor's positional arguments. A `@db.*` attribute's own\n* arguments replace them; without any, the column gets `args`, so `@db.Char`\n* is `Char(1)`, the `character(1)` Postgres stores for Prisma 7's `CHAR`.\n*/\nconst prisma7PostgresTypeMap = {\n\tscalars: {\n\t\tString: {\n\t\t\tconstructorName: \"String\",\n\t\t\targs: []\n\t\t},\n\t\tBoolean: {\n\t\t\tconstructorName: \"Boolean\",\n\t\t\targs: []\n\t\t},\n\t\tInt: {\n\t\t\tconstructorName: \"Int\",\n\t\t\targs: []\n\t\t},\n\t\tBigInt: {\n\t\t\tconstructorName: \"BigInt\",\n\t\t\targs: []\n\t\t},\n\t\tFloat: {\n\t\t\tconstructorName: \"Float\",\n\t\t\targs: []\n\t\t},\n\t\tDecimal: {\n\t\t\tconstructorName: \"Numeric\",\n\t\t\targs: [\"65\", \"30\"]\n\t\t},\n\t\tDateTime: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timestamp,\n\t\t\targs: [\"3\"]\n\t\t},\n\t\tJson: {\n\t\t\tconstructorName: \"Jsonb\",\n\t\t\targs: []\n\t\t},\n\t\tBytes: {\n\t\t\tconstructorName: \"Bytes\",\n\t\t\targs: []\n\t\t}\n\t},\n\tnativeTypes: {\n\t\tText: {\n\t\t\tconstructorName: \"String\",\n\t\t\targs: []\n\t\t},\n\t\tVarChar: {\n\t\t\tconstructorName: \"VarChar\",\n\t\t\targs: []\n\t\t},\n\t\tChar: {\n\t\t\tconstructorName: \"Char\",\n\t\t\targs: [\"1\"]\n\t\t},\n\t\tUuid: {\n\t\t\tconstructorName: \"Uuid\",\n\t\t\targs: []\n\t\t},\n\t\tInet: {\n\t\t\tconstructorName: \"Inet\",\n\t\t\targs: []\n\t\t},\n\t\tBoolean: {\n\t\t\tconstructorName: \"Boolean\",\n\t\t\targs: []\n\t\t},\n\t\tInteger: {\n\t\t\tconstructorName: \"Int\",\n\t\t\targs: []\n\t\t},\n\t\tSmallInt: {\n\t\t\tconstructorName: \"SmallInt\",\n\t\t\targs: []\n\t\t},\n\t\tBigInt: {\n\t\t\tconstructorName: \"BigInt\",\n\t\t\targs: []\n\t\t},\n\t\tReal: {\n\t\t\tconstructorName: \"Real\",\n\t\t\targs: []\n\t\t},\n\t\tDoublePrecision: {\n\t\t\tconstructorName: \"Float\",\n\t\t\targs: []\n\t\t},\n\t\tDecimal: {\n\t\t\tconstructorName: \"Numeric\",\n\t\t\targs: []\n\t\t},\n\t\tTimestamp: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timestamp,\n\t\t\targs: []\n\t\t},\n\t\tTimestamptz: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timestamptz,\n\t\t\targs: []\n\t\t},\n\t\tDate: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.date,\n\t\t\targs: []\n\t\t},\n\t\tTime: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.time,\n\t\t\targs: []\n\t\t},\n\t\tTimetz: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timetz,\n\t\t\targs: []\n\t\t},\n\t\tJson: {\n\t\t\tconstructorName: \"Json\",\n\t\t\targs: []\n\t\t},\n\t\tJsonB: {\n\t\t\tconstructorName: \"Jsonb\",\n\t\t\targs: []\n\t\t},\n\t\tByteA: {\n\t\t\tconstructorName: \"Bytes\",\n\t\t\targs: []\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/psl-infer/junction-relation-field-names.ts\nconst EMPTY_FOREIGN_KEY_EXTRAS = {\n\textraRelationsByTable: /* @__PURE__ */ new Map(),\n\tcrossSpaceFieldNamesByTable: /* @__PURE__ */ new Map(),\n\tdanglingForeignKeysByTable: /* @__PURE__ */ new Map()\n};\nfunction idTable(name) {\n\treturn new SqlTableIR({\n\t\tname,\n\t\tcolumns: { id: {\n\t\t\tname: \"id\",\n\t\t\tnativeType: \"int4\",\n\t\t\tnullable: false\n\t\t} },\n\t\tforeignKeys: [],\n\t\tuniques: [],\n\t\tindexes: [],\n\t\tprimaryKey: { columns: [\"id\"] }\n\t});\n}\n/**\n* The relation field names `contract infer` prints for an implicit\n* many-to-many junction table whose columns `A` and `B` reference `tableA`\n* and `tableB`, found by running infer's PSL construction on that table.\n*/\nfunction junctionRelationFieldNames(tableA, tableB) {\n\tlet junctionName = \"_junction\";\n\twhile ([tableA, tableB].some((table) => toModelName(table).name === toModelName(junctionName).name)) junctionName = `${junctionName}x`;\n\tconst column = (name) => ({\n\t\tname,\n\t\tnativeType: \"int4\",\n\t\tnullable: false\n\t});\n\tconst foreignKey = (columnName, referencedTable) => ({\n\t\tcolumns: [columnName],\n\t\treferencedTable,\n\t\treferencedColumns: [\"id\"]\n\t});\n\tconst junction = new SqlTableIR({\n\t\tname: junctionName,\n\t\tcolumns: {\n\t\t\tA: column(\"A\"),\n\t\t\tB: column(\"B\")\n\t\t},\n\t\tforeignKeys: [foreignKey(\"A\", tableA), foreignKey(\"B\", tableB)],\n\t\tuniques: [],\n\t\tindexes: [],\n\t\tprimaryKey: { columns: [\"A\", \"B\"] }\n\t});\n\tconst document = buildPslDocumentAst(new SqlSchemaIR({ tables: {\n\t\t[tableA]: idTable(tableA),\n\t\t[tableB]: idTable(tableB),\n\t\t[junctionName]: junction\n\t} }), {\n\t\ttypeMap: createPostgresTypeMap(),\n\t\tdefaultMapping: createPostgresDefaultMapping(),\n\t\tparseRawDefault: parsePostgresDefault,\n\t\tcolumnDefaults: noColumnDefaults\n\t}, EMPTY_FOREIGN_KEY_EXTRAS);\n\tconst junctionModelName = toModelName(junctionName).name;\n\tconst fields = flatPslModels(document).find((model) => model.name === junctionModelName)?.fields;\n\tconst scalarFieldCount = Object.keys(junction.columns).length;\n\tconst [a = \"\", b = \"\"] = (fields ?? []).slice(scalarFieldCount).map((field) => field.name);\n\treturn [a, b];\n}\n//#endregion\n//#region src/core/prisma7-binding.ts\nconst TEMPORAL_NATIVE_TYPES = /* @__PURE__ */ new Set([\n\t\"timestamp\",\n\t\"timestamptz\",\n\t\"date\",\n\t\"time\",\n\t\"timetz\"\n]);\nfunction isTemporalNativeType(nativeType) {\n\treturn TEMPORAL_NATIVE_TYPES.has(nativeType);\n}\nfunction sqlStringLiteral(value) {\n\treturn value === void 0 ? void 0 : `'${value.replace(/'/g, \"''\")}'`;\n}\nfunction base64ToHex(base64) {\n\tif (!/^[A-Za-z0-9+/]*={0,2}$/.test(base64) || base64.length % 4 !== 0) return void 0;\n\treturn `\\\\x${Buffer.from(base64, \"base64\").toString(\"hex\")}`;\n}\nfunction arrayLiteral(literals, typeName) {\n\treturn `ARRAY[${literals.join(\", \")}]::${typeName}[]`;\n}\n/**\n* What the Postgres target supplies to the Prisma 7 interpreter. A `Bytes` or\n* `DateTime` default is carried as the SQL literal of the default Postgres\n* stores (`'\\x68656c6c6f'`, `'2024-01-02 03:04:05'`), and a list default as an\n* `ARRAY[...]` of those literals cast to the column type, rather than as the\n* column codec's JSON form (base64, ISO 8601 text). Verify reads both forms as\n* the same value; the reader keeps the SQL literal because storing the value\n* instead changes the contract hash of every such schema (TML-3455).\n*/\nconst prisma7PostgresBinding = {\n\ttarget: postgresTargetDescriptorMeta,\n\tcreateNamespace: postgresCreateNamespace,\n\tproviders: [\"postgresql\", \"postgres\"],\n\ttypeMap: prisma7PostgresTypeMap,\n\tnativeEnum: {\n\t\tentityKind: \"native_enum\",\n\t\ttypeConstructor: [\"pg\", \"enum\"]\n\t},\n\tindexTypes: {\n\t\tBTree: \"btree\",\n\t\tHash: \"hash\",\n\t\tGin: \"gin\",\n\t\tGist: \"gist\",\n\t\tSpGist: \"spgist\",\n\t\tBrin: \"brin\"\n\t},\n\t/** `NAMEDATALEN - 1`. */\n\tidentifierMaxBytes: 63,\n\tjunctionRelationFieldNames,\n\tupdatedAtGeneratorId: postgresNowGeneratorIdFor,\n\tliteralDefaultForm: ({ nativeType, typeParams }) => {\n\t\tif (nativeType === \"json\" || nativeType === \"jsonb\") return { kind: \"json\" };\n\t\tif (nativeType === \"bytea\") return {\n\t\t\tkind: \"sqlExpression\",\n\t\t\tliteral: (text) => sqlStringLiteral(base64ToHex(text)),\n\t\t\tlist: (literals) => arrayLiteral(literals, \"BYTEA\")\n\t\t};\n\t\tif (!isTemporalNativeType(nativeType)) return void 0;\n\t\tconst precision = typeParams?.[\"precision\"];\n\t\tconst typeName = `${nativeType.toUpperCase()}${typeof precision === \"number\" ? `(${precision})` : \"\"}`;\n\t\treturn {\n\t\t\tkind: \"sqlExpression\",\n\t\t\tliteral: (text) => sqlStringLiteral(storedTemporalText(text, nativeType)),\n\t\t\tlist: (literals) => arrayLiteral(literals, typeName)\n\t\t};\n\t}\n};\n//#endregion\nexport { prisma7PostgresBinding };\n\n//# sourceMappingURL=prisma7-binding.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,WAAW;AACjB,MAAM,oBAAoB;AAC1B,SAAS,IAAI,OAAO,QAAQ,GAAG;CAC9B,OAAO,OAAO,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG;AACzC;;;;;;AAMA,SAAS,eAAe,UAAU;CACjC,MAAM,SAAS,OAAO,GAAG,SAAS,QAAQ,MAAM,GAAG,CAAC,C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W,GAAG,WAAW,YAAY,IAAI,OAAO,cAAc,WAAW,IAAI,UAAU,KAAK;EAClG,OAAO;GACN,MAAM;GACN,UAAU,SAAS,iBAAiB,mBAAmB,MAAM,UAAU,CAAC;GACxE,OAAO,aAAa,aAAa,UAAU,QAAQ;EACpD;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"prisma7-binding-Dm24YoM6.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/prisma7-binding.mjs"],"sourcesContent":["import { c as postgresNowGeneratorIdFor } from \"./authoring-C5Ch8RNG.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { t as postgresTargetDescriptorMeta } from \"./descriptor-meta-Bvq6_NJ8.mjs\";\nimport { t as parsePostgresDefault } from \"./default-normalizer-ByDD_gRm.mjs\";\nimport { c as noColumnDefaults, g as EXISTING_COLUMN_DATE_TIME_TYPES, h as createPostgresTypeMap, r as createPostgresDefaultMapping, t as buildPslDocumentAst } from \"./infer-psl-contract-Burb6YAz.mjs\";\nimport { SqlSchemaIR, SqlTableIR } from \"@internal/sql-schema-ir/types\";\nimport { toModelName } from \"@internal/family-sql/psl-infer\";\nimport { flatPslModels } from \"@internal/framework-components/psl-ast\";\n//#region src/core/prisma7-temporal-defaults.ts\nconst RFC_3339 = /^(\\d{4})-(\\d{2})-(\\d{2})[Tt ](\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?(?:[Zz]|([+-])(\\d{2}):(\\d{2}))$/;\nconst MICROS_PER_SECOND = 1e6;\nfunction pad(value, width = 2) {\n\treturn String(value).padStart(width, \"0\");\n}\n/**\n* The microseconds Postgres keeps for a fraction-of-a-second digit string. Every digit counts:\n* `.1234565` is an exact tie, and C's `rint` takes the even neighbour 123456, while `.1234565001`\n* is above the tie and rounds up to 123457.\n*/\nfunction fractionMicros(fraction) {\n\tconst micros = Number(`${fraction}000000`.slice(0, 6));\n\tconst beyondTie = fraction.slice(6).replace(/0+$/, \"\");\n\tif (beyondTie === \"\") return micros;\n\tif (beyondTie === \"5\") return micros % 2 === 0 ? micros : micros + 1;\n\treturn beyondTie > \"5\" ? micros + 1 : micros;\n}\nfunction fractionText(micros) {\n\treturn micros === 0 ? \"\" : `.${pad(micros, 6).replace(/0+$/, \"\")}`;\n}\nfunction offsetText(minutes) {\n\tconst magnitude = Math.abs(minutes);\n\tconst rest = magnitude % 60;\n\treturn `${minutes < 0 ? \"-\" : \"+\"}${pad(Math.floor(magnitude / 60))}${rest === 0 ? \"\" : `:${pad(rest)}`}`;\n}\n/**\n* The text of the column default Postgres stores for a Prisma 7 `DateTime`\n* default, which Prisma 7 writes as `'2024-01-02 03:04:05.123 +02:00'`:\n* `date` keeps the written date, `time` and `timestamp` the written wall-clock\n* time without the offset, and `timetz` the time with the written offset.\n* `timestamptz` is carried in its UTC form, the text a session in UTC prints\n* (`2024-01-02 01:04:05+00`, and `0001-12-31 23:30:00+00 BC` before year 1);\n* a session in another time zone prints the same instant differently.\n* Fractional seconds are rounded to microseconds; the column's own precision\n* does not change a stored default.\n*/\nfunction storedTemporalText(text, nativeType) {\n\tconst match = RFC_3339.exec(text);\n\tif (match === null) return void 0;\n\tconst [, year = \"\", month = \"\", day = \"\", hour, minute, second, fraction = \"\", sign, offsetHours, offsetMinutes] = match;\n\tif (nativeType === \"date\") return `${year}-${month}-${day}`;\n\tconst micros = fractionMicros(fraction);\n\tconst clockSeconds = Number(hour) * 3600 + Number(minute) * 60 + Number(second) + Math.floor(micros / MICROS_PER_SECOND);\n\tconst fractional = fractionText(micros % MICROS_PER_SECOND);\n\tconst offsetMinutesTotal = sign === void 0 ? 0 : (sign === \"-\" ? -1 : 1) * (Number(offsetHours) * 60 + Number(offsetMinutes));\n\tif (nativeType === \"time\" || nativeType === \"timetz\") {\n\t\tconst clock = `${pad(Math.floor(clockSeconds / 3600))}:${pad(Math.floor(clockSeconds / 60) % 60)}:${pad(clockSeconds % 60)}${fractional}`;\n\t\treturn nativeType === \"time\" ? clock : `${clock}${offsetText(offsetMinutesTotal)}`;\n\t}\n\tconst midnight = /* @__PURE__ */ new Date(0);\n\tmidnight.setUTCFullYear(Number(year), Number(month) - 1, Number(day));\n\tconst utcShift = nativeType === \"timestamptz\" ? offsetMinutesTotal * 60 : 0;\n\tconst stamp = new Date(midnight.getTime() + (clockSeconds - utcShift) * 1e3);\n\tconst astronomicalYear = stamp.getUTCFullYear();\n\tconst wallClock = `${pad(astronomicalYear > 0 ? astronomicalYear : 1 - astronomicalYear, 4)}-${pad(stamp.getUTCMonth() + 1)}-${pad(stamp.getUTCDate())} ${pad(stamp.getUTCHours())}:${pad(stamp.getUTCMinutes())}:${pad(stamp.getUTCSeconds())}${fractional}`;\n\tconst era = astronomicalYear > 0 ? \"\" : \" BC\";\n\treturn nativeType === \"timestamptz\" ? `${wallClock}+00${era}` : `${wallClock}${era}`;\n}\n//#endregion\n//#region src/core/prisma7-type-map.ts\n/**\n* What Prisma 7.10.0 creates in Postgres for each Prisma 7 scalar and `@db.*`\n* native type, expressed as the Prisma 8 authoring type constructor that\n* produces the same column. Derived from the SQL recorded in\n* `test/integration/test/fixtures/prisma7-source/reference/migration.sql`.\n* `args` are the constructor's positional arguments. A `@db.*` attribute's own\n* arguments replace them; without any, the column gets `args`, so `@db.Char`\n* is `Char(1)`, the `character(1)` Postgres stores for Prisma 7's `CHAR`.\n*/\nconst prisma7PostgresTypeMap = {\n\tscalars: {\n\t\tString: {\n\t\t\tconstructorName: \"String\",\n\t\t\targs: []\n\t\t},\n\t\tBoolean: {\n\t\t\tconstructorName: \"Boolean\",\n\t\t\targs: []\n\t\t},\n\t\tInt: {\n\t\t\tconstructorName: \"Int\",\n\t\t\targs: []\n\t\t},\n\t\tBigInt: {\n\t\t\tconstructorName: \"BigInt\",\n\t\t\targs: []\n\t\t},\n\t\tFloat: {\n\t\t\tconstructorName: \"Float\",\n\t\t\targs: []\n\t\t},\n\t\tDecimal: {\n\t\t\tconstructorName: \"Numeric\",\n\t\t\targs: [\"65\", \"30\"]\n\t\t},\n\t\tDateTime: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timestamp,\n\t\t\targs: [\"3\"]\n\t\t},\n\t\tJson: {\n\t\t\tconstructorName: \"Jsonb\",\n\t\t\targs: []\n\t\t},\n\t\tBytes: {\n\t\t\tconstructorName: \"Bytes\",\n\t\t\targs: []\n\t\t}\n\t},\n\tnativeTypes: {\n\t\tText: {\n\t\t\tconstructorName: \"String\",\n\t\t\targs: []\n\t\t},\n\t\tVarChar: {\n\t\t\tconstructorName: \"VarChar\",\n\t\t\targs: []\n\t\t},\n\t\tChar: {\n\t\t\tconstructorName: \"Char\",\n\t\t\targs: [\"1\"]\n\t\t},\n\t\tUuid: {\n\t\t\tconstructorName: \"Uuid\",\n\t\t\targs: []\n\t\t},\n\t\tInet: {\n\t\t\tconstructorName: \"Inet\",\n\t\t\targs: []\n\t\t},\n\t\tBoolean: {\n\t\t\tconstructorName: \"Boolean\",\n\t\t\targs: []\n\t\t},\n\t\tInteger: {\n\t\t\tconstructorName: \"Int\",\n\t\t\targs: []\n\t\t},\n\t\tSmallInt: {\n\t\t\tconstructorName: \"SmallInt\",\n\t\t\targs: []\n\t\t},\n\t\tBigInt: {\n\t\t\tconstructorName: \"BigInt\",\n\t\t\targs: []\n\t\t},\n\t\tReal: {\n\t\t\tconstructorName: \"Real\",\n\t\t\targs: []\n\t\t},\n\t\tDoublePrecision: {\n\t\t\tconstructorName: \"Float\",\n\t\t\targs: []\n\t\t},\n\t\tDecimal: {\n\t\t\tconstructorName: \"Numeric\",\n\t\t\targs: []\n\t\t},\n\t\tTimestamp: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timestamp,\n\t\t\targs: []\n\t\t},\n\t\tTimestamptz: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timestamptz,\n\t\t\targs: []\n\t\t},\n\t\tDate: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.date,\n\t\t\targs: []\n\t\t},\n\t\tTime: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.time,\n\t\t\targs: []\n\t\t},\n\t\tTimetz: {\n\t\t\tconstructorName: EXISTING_COLUMN_DATE_TIME_TYPES.timetz,\n\t\t\targs: []\n\t\t},\n\t\tJson: {\n\t\t\tconstructorName: \"Json\",\n\t\t\targs: []\n\t\t},\n\t\tJsonB: {\n\t\t\tconstructorName: \"Jsonb\",\n\t\t\targs: []\n\t\t},\n\t\tByteA: {\n\t\t\tconstructorName: \"Bytes\",\n\t\t\targs: []\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/psl-infer/junction-relation-field-names.ts\nconst EMPTY_FOREIGN_KEY_EXTRAS = {\n\textraRelationsByTable: /* @__PURE__ */ new Map(),\n\tcrossSpaceFieldNamesByTable: /* @__PURE__ */ new Map(),\n\tdanglingForeignKeysByTable: /* @__PURE__ */ new Map()\n};\nfunction idTable(name) {\n\treturn new SqlTableIR({\n\t\tname,\n\t\tcolumns: { id: {\n\t\t\tname: \"id\",\n\t\t\tnativeType: \"int4\",\n\t\t\tnullable: false\n\t\t} },\n\t\tforeignKeys: [],\n\t\tuniques: [],\n\t\tindexes: [],\n\t\tprimaryKey: { columns: [\"id\"] }\n\t});\n}\n/**\n* The relation field names `contract infer` prints for an implicit\n* many-to-many junction table whose columns `A` and `B` reference `tableA`\n* and `tableB`, found by running infer's PSL construction on that table.\n*/\nfunction junctionRelationFieldNames(tableA, tableB) {\n\tlet junctionName = \"_junction\";\n\twhile ([tableA, tableB].some((table) => toModelName(table).name === toModelName(junctionName).name)) junctionName = `${junctionName}x`;\n\tconst column = (name) => ({\n\t\tname,\n\t\tnativeType: \"int4\",\n\t\tnullable: false\n\t});\n\tconst foreignKey = (columnName, referencedTable) => ({\n\t\tcolumns: [columnName],\n\t\treferencedTable,\n\t\treferencedColumns: [\"id\"]\n\t});\n\tconst junction = new SqlTableIR({\n\t\tname: junctionName,\n\t\tcolumns: {\n\t\t\tA: column(\"A\"),\n\t\t\tB: column(\"B\")\n\t\t},\n\t\tforeignKeys: [foreignKey(\"A\", tableA), foreignKey(\"B\", tableB)],\n\t\tuniques: [],\n\t\tindexes: [],\n\t\tprimaryKey: { columns: [\"A\", \"B\"] }\n\t});\n\tconst document = buildPslDocumentAst(new SqlSchemaIR({ tables: {\n\t\t[tableA]: idTable(tableA),\n\t\t[tableB]: idTable(tableB),\n\t\t[junctionName]: junction\n\t} }), {\n\t\ttypeMap: createPostgresTypeMap(),\n\t\tdefaultMapping: createPostgresDefaultMapping(),\n\t\tparseRawDefault: parsePostgresDefault,\n\t\tcolumnDefaults: noColumnDefaults\n\t}, EMPTY_FOREIGN_KEY_EXTRAS);\n\tconst junctionModelName = toModelName(junctionName).name;\n\tconst fields = flatPslModels(document).find((model) => model.name === junctionModelName)?.fields;\n\tconst scalarFieldCount = Object.keys(junction.columns).length;\n\tconst [a = \"\", b = \"\"] = (fields ?? []).slice(scalarFieldCount).map((field) => field.name);\n\treturn [a, b];\n}\n//#endregion\n//#region src/core/prisma7-binding.ts\nconst TEMPORAL_NATIVE_TYPES = /* @__PURE__ */ new Set([\n\t\"timestamp\",\n\t\"timestamptz\",\n\t\"date\",\n\t\"time\",\n\t\"timetz\"\n]);\nfunction isTemporalNativeType(nativeType) {\n\treturn TEMPORAL_NATIVE_TYPES.has(nativeType);\n}\nfunction sqlStringLiteral(value) {\n\treturn value === void 0 ? void 0 : `'${value.replace(/'/g, \"''\")}'`;\n}\nfunction base64ToHex(base64) {\n\tif (!/^[A-Za-z0-9+/]*={0,2}$/.test(base64) || base64.length % 4 !== 0) return void 0;\n\treturn `\\\\x${Buffer.from(base64, \"base64\").toString(\"hex\")}`;\n}\nfunction arrayLiteral(literals, typeName) {\n\treturn `ARRAY[${literals.join(\", \")}]::${typeName}[]`;\n}\n/**\n* What the Postgres target supplies to the Prisma 7 interpreter. A `Bytes` or\n* `DateTime` default is carried as the SQL literal of the default Postgres\n* stores (`'\\x68656c6c6f'`, `'2024-01-02 03:04:05'`), and a list default as an\n* `ARRAY[...]` of those literals cast to the column type, rather than as the\n* column codec's JSON form (base64, ISO 8601 text). Verify reads both forms as\n* the same value; the reader keeps the SQL literal because storing the value\n* instead changes the contract hash of every such schema (TML-3455).\n*/\nconst prisma7PostgresBinding = {\n\ttarget: postgresTargetDescriptorMeta,\n\tcreateNamespace: postgresCreateNamespace,\n\tproviders: [\"postgresql\", \"postgres\"],\n\ttypeMap: prisma7PostgresTypeMap,\n\tnativeEnum: {\n\t\tentityKind: \"native_enum\",\n\t\ttypeConstructor: [\"pg\", \"enum\"]\n\t},\n\tindexTypes: {\n\t\tBTree: \"btree\",\n\t\tHash: \"hash\",\n\t\tGin: \"gin\",\n\t\tGist: \"gist\",\n\t\tSpGist: \"spgist\",\n\t\tBrin: \"brin\"\n\t},\n\t/** `NAMEDATALEN - 1`. */\n\tidentifierMaxBytes: 63,\n\tjunctionRelationFieldNames,\n\tupdatedAtGeneratorId: postgresNowGeneratorIdFor,\n\tliteralDefaultForm: ({ nativeType, typeParams }) => {\n\t\tif (nativeType === \"json\" || nativeType === \"jsonb\") return { kind: \"json\" };\n\t\tif (nativeType === \"bytea\") return {\n\t\t\tkind: \"sqlExpression\",\n\t\t\tliteral: (text) => sqlStringLiteral(base64ToHex(text)),\n\t\t\tlist: (literals) => arrayLiteral(literals, \"BYTEA\")\n\t\t};\n\t\tif (!isTemporalNativeType(nativeType)) return void 0;\n\t\tconst precision = typeParams?.[\"precision\"];\n\t\tconst typeName = `${nativeType.toUpperCase()}${typeof precision === \"number\" ? `(${precision})` : \"\"}`;\n\t\treturn {\n\t\t\tkind: \"sqlExpression\",\n\t\t\tliteral: (text) => sqlStringLiteral(storedTemporalText(text, nativeType)),\n\t\t\tlist: (literals) => arrayLiteral(literals, typeName)\n\t\t};\n\t}\n};\n//#endregion\nexport { prisma7PostgresBinding };\n\n//# sourceMappingURL=prisma7-binding.mjs.map"],"mappings":";;;;;;;;;AASA,MAA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O;EAC3E,IAAI,eAAe,SAAS,OAAO;GAClC,MAAM;GACN,UAAU,SAAS,iBAAiB,YAAY,IAAI,CAAC;GACrD,OAAO,aAAa,aAAa,UAAU,OAAO;EACnD;EACA,IAAI,CAAC,qBAAqB,UAAU,GAAG,OAAO,KAAK;EACnD,MAAM,YAAY,aAAa;EAC/B,MAAM,WAAW,GAAG,WAAW,YAAY,IAAI,OAAO,cAAc,WAAW,IAAI,UAAU,KAAK;EAClG,OAAO;GACN,MAAM;GACN,UAAU,SAAS,iBAAiB,mBAAmB,MAAM,UAAU,CAAC;GACxE,OAAO,aAAa,aAAa,UAAU,QAAQ;EACpD;CACD;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as postgresDriverDescriptorMeta, i as normalizePgError, n as isAlreadyConnectedError, o as
|
|
1
|
+
import { a as postgresDriverDescriptorMeta, i as normalizePgError, n as isAlreadyConnectedError, o as serverTextTypes, r as isPostgresError } from "./server-text-types-DeNPQpv5-DPxA9uXV.mjs";
|
|
2
2
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
3
3
|
import { Pool } from "pg";
|
|
4
4
|
import { suppressIdleConnectionErrors, suppressIdleConnectionErrors as suppressIdleConnectionErrors$1 } from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
|
|
@@ -269,7 +269,7 @@ var PostgresQueryable = class {
|
|
|
269
269
|
}
|
|
270
270
|
async *executeWithCursor(client, sql, params, cursorBatchSize, name) {
|
|
271
271
|
const values = blindCast(params ?? []);
|
|
272
|
-
const config = { types:
|
|
272
|
+
const config = { types: serverTextTypes };
|
|
273
273
|
const cursor = client.query(name === void 0 ? new Cursor(sql, values, config) : new NamedCursor({
|
|
274
274
|
name,
|
|
275
275
|
text: sql,
|
|
@@ -291,7 +291,7 @@ var PostgresQueryable = class {
|
|
|
291
291
|
name,
|
|
292
292
|
text: sql,
|
|
293
293
|
values: blindCast(params ?? []),
|
|
294
|
-
types:
|
|
294
|
+
types: serverTextTypes
|
|
295
295
|
};
|
|
296
296
|
const releaseLock = await acquireClientQueryLock(client);
|
|
297
297
|
let result;
|
|
@@ -657,4 +657,4 @@ const postgresRuntimeDriverDescriptor = {
|
|
|
657
657
|
//#endregion
|
|
658
658
|
export { suppressIdleConnectionErrors$1 as n, postgresRuntimeDriverDescriptor as t };
|
|
659
659
|
|
|
660
|
-
//# sourceMappingURL=runtime-
|
|
660
|
+
//# sourceMappingURL=runtime-DugW4mig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-DugW4mig.mjs","names":["#queue","#connection","#onRelease","#onDestroy","#txState","#onSettled","#settle","#closed","suppressIdleConnectionErrors$1","#connected","#connectionMutex","#closeWhileHoldingLease","#connectPromise","#cursorOpts","#preparedStatements","#delegate","#disconnectedState","#notConnectedError","#requireDelegate","#wrapConnection"],"sources":["../../../../3-targets/7-drivers/postgres/dist/runtime.mjs"],"sourcesContent":["import { a as normalizePgError, i as isPostgresError, n as serverTextTypes, o as postgresDriverDescriptorMeta, r as isAlreadyConnectedError } from \"./server-text-types-DeNPQpv5.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { suppressIdleConnectionErrors, suppressIdleConnectionErrors as suppressIdleConnectionErrors$1 } from \"@internal/utils/suppress-idle-connection-errors\";\nimport { Pool } from \"pg\";\nimport Cursor from \"pg-cursor\";\n//#region src/driver-error.ts\nfunction driverError(code, message, details) {\n\tconst error = new Error(message);\n\tObject.defineProperty(error, \"name\", {\n\t\tvalue: \"RuntimeError\",\n\t\tconfigurable: true\n\t});\n\treturn details === void 0 ? Object.assign(error, {\n\t\tcode,\n\t\tcategory: \"DRIVER\",\n\t\tseverity: \"error\"\n\t}) : Object.assign(error, {\n\t\tcode,\n\t\tcategory: \"DRIVER\",\n\t\tseverity: \"error\",\n\t\tdetails\n\t});\n}\n//#endregion\n//#region src/callback-to-promise.ts\nfunction callbackToPromise(fn) {\n\treturn new Promise((resolve, reject) => {\n\t\tfn((err, result) => {\n\t\t\tif (err) {\n\t\t\t\treject(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(result);\n\t\t});\n\t});\n}\n//#endregion\n//#region src/named-cursor.ts\nlet nextNamedPortalId = 1;\n/** Streaming cursor for a server-side named prepared statement. */\nvar NamedCursor = class extends Cursor {\n\tname;\n\tconstructor(opts) {\n\t\tsuper(opts.text, [...opts.values], opts.config);\n\t\tthis.name = opts.name;\n\t\tthis.submit = this.submitNamed;\n\t}\n\tsubmitNamed(connection) {\n\t\tconst self = this;\n\t\tconst conn = connection;\n\t\tself.state = \"submitted\";\n\t\tself.connection = conn;\n\t\tself._portal = `np_${nextNamedPortalId++}`;\n\t\tif (!conn.parsedStatements[this.name]) {\n\t\t\tconst parseMessage = {\n\t\t\t\ttext: self.text,\n\t\t\t\tname: this.name,\n\t\t\t\ttypes: []\n\t\t\t};\n\t\t\tconn.parse(parseMessage, true);\n\t\t}\n\t\tconst bindMessage = {\n\t\t\tportal: self._portal,\n\t\t\tstatement: this.name,\n\t\t\tvalues: self.values ?? []\n\t\t};\n\t\tconn.bind(bindMessage, true);\n\t\tconn.describe({\n\t\t\ttype: \"P\",\n\t\t\tname: self._portal\n\t\t}, true);\n\t\tconn.flush();\n\t\tif (self._conf.types) self._result._getTypeParser = self._conf.types.getTypeParser;\n\t\tconn.once(\"noData\", self._ifNoData);\n\t\tconn.once(\"rowDescription\", self._rowDescription);\n\t}\n};\n//#endregion\n//#region src/postgres-driver.ts\nconst DEFAULT_BATCH_SIZE = 100;\nconst DEFAULT_PREPARED_STATEMENTS = true;\nfunction createHandleAllocator() {\n\tlet next = 1;\n\treturn { mint: () => `pn_${next++}` };\n}\nfunction buildConnectionOptions(options) {\n\treturn {\n\t\t...options.cursor?.disabled ? { cursorDisabled: true } : {\n\t\t\tcursorBatchSize: options.cursor?.batchSize ?? DEFAULT_BATCH_SIZE,\n\t\t\tcursorDisabled: false\n\t\t},\n\t\tpreparedStatementsEnabled: options.preparedStatements ?? DEFAULT_PREPARED_STATEMENTS,\n\t\thandleAllocator: createHandleAllocator()\n\t};\n}\nfunction isStalePreparedStatementError(error) {\n\tif (!(error instanceof Error) || !(\"code\" in error) || typeof error.code !== \"string\") return false;\n\tconst code = error.code;\n\treturn code === \"26000\" || code === \"0A000\";\n}\nvar AsyncMutex = class {\n\t#queue = Promise.resolve();\n\tasync lock() {\n\t\tconst previous = this.#queue;\n\t\tlet releaseLock;\n\t\tthis.#queue = new Promise((resolve) => {\n\t\t\treleaseLock = resolve;\n\t\t});\n\t\tawait previous;\n\t\treturn () => {\n\t\t\treleaseLock?.();\n\t\t\treleaseLock = void 0;\n\t\t};\n\t}\n};\nconst clientQueryLocks = /* @__PURE__ */ new WeakMap();\nfunction acquireClientQueryLock(client) {\n\tlet mutex = clientQueryLocks.get(client);\n\tif (mutex === void 0) {\n\t\tmutex = new AsyncMutex();\n\t\tclientQueryLocks.set(client, mutex);\n\t}\n\treturn mutex.lock();\n}\nvar PostgresQueryable = class {\n\toptions;\n\tconstructor(options) {\n\t\tthis.options = options;\n\t}\n\tasync *query(request) {\n\t\ttry {\n\t\t\tconst preparedStatementHandle = request.preparedStatementHandle;\n\t\t\tif (preparedStatementHandle === void 0 || !this.options.preparedStatementsEnabled) {\n\t\t\t\tyield* this.runQuery(request);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst name = this.preparedStatementName(preparedStatementHandle);\n\t\t\tyield* this.withStaleHandleStreamRetry(preparedStatementHandle, name, (name) => this.runQuery(request, name));\n\t\t} catch (error) {\n\t\t\tthrow normalizePgError(error);\n\t\t}\n\t}\n\tasync execute(request) {\n\t\ttry {\n\t\t\tconst preparedStatementHandle = request.preparedStatementHandle;\n\t\t\tif (preparedStatementHandle === void 0 || !this.options.preparedStatementsEnabled) return await this.runExecute(request);\n\t\t\tconst name = this.preparedStatementName(preparedStatementHandle);\n\t\t\treturn await this.withStaleHandleRetry(preparedStatementHandle, name, (name) => this.runExecute(request, name));\n\t\t} catch (error) {\n\t\t\tthrow normalizePgError(error);\n\t\t}\n\t}\n\tpreparedStatementName(handle) {\n\t\tconst existingName = handle.get();\n\t\tif (typeof existingName === \"string\") return existingName;\n\t\tconst mintedName = this.options.handleAllocator.mint();\n\t\thandle.set(mintedName);\n\t\treturn mintedName;\n\t}\n\tasync withStaleHandleRetry(preparedStatementHandle, name, attempt) {\n\t\ttry {\n\t\t\treturn await attempt(name);\n\t\t} catch (error) {\n\t\t\tif (!isStalePreparedStatementError(error)) throw error;\n\t\t\tconst retryName = this.options.handleAllocator.mint();\n\t\t\tpreparedStatementHandle.set(retryName);\n\t\t\ttry {\n\t\t\t\treturn await attempt(retryName);\n\t\t\t} catch (retryError) {\n\t\t\t\tthrow prepareFailedError(retryError, retryName);\n\t\t\t}\n\t\t}\n\t}\n\tasync *withStaleHandleStreamRetry(preparedStatementHandle, name, attempt) {\n\t\tconst stream = await this.withStaleHandleRetry(preparedStatementHandle, name, async (name) => {\n\t\t\tconst iterator = attempt(name)[Symbol.asyncIterator]();\n\t\t\treturn {\n\t\t\t\titerator,\n\t\t\t\tfirst: await iterator.next()\n\t\t\t};\n\t\t});\n\t\tif (stream.first.done) return;\n\t\tlet streamCompleted = false;\n\t\ttry {\n\t\t\tyield stream.first.value;\n\t\t\twhile (true) {\n\t\t\t\tconst next = await stream.iterator.next();\n\t\t\t\tif (next.done) {\n\t\t\t\t\tstreamCompleted = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield next.value;\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!streamCompleted) await stream.iterator.return?.();\n\t\t}\n\t}\n\tasync runExecute(request, name) {\n\t\tconst client = await this.acquireClient();\n\t\ttry {\n\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\ttry {\n\t\t\t\treturn { affectedRows: (await client.query({\n\t\t\t\t\tname,\n\t\t\t\t\ttext: request.sql,\n\t\t\t\t\tvalues: blindCast(request.params ?? [])\n\t\t\t\t})).rowCount ?? 0 };\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\n\t}\n\tinExplicitTransaction() {\n\t\treturn false;\n\t}\n\tasync *runQuery(request, name) {\n\t\tconst client = await this.acquireClient();\n\t\tlet rows;\n\t\ttry {\n\t\t\tif (!this.options.cursorDisabled) {\n\t\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\t\ttry {\n\t\t\t\t\tfor await (const row of this.streamWithPortalProtection(client, request, this.options.cursorBatchSize, name)) yield blindCast(row);\n\t\t\t\t\treturn;\n\t\t\t\t} catch (cursorError) {\n\t\t\t\t\tif (!(cursorError instanceof Error) || isPostgresError(cursorError)) throw cursorError;\n\t\t\t\t} finally {\n\t\t\t\t\treleaseLock();\n\t\t\t\t}\n\t\t\t}\n\t\t\trows = await this.executeBuffered(client, request.sql, request.params, name);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\n\t\tfor (const row of rows) yield blindCast(row);\n\t}\n\tasync explain(request) {\n\t\tconst text = `EXPLAIN (FORMAT JSON) ${request.sql}`;\n\t\tconst client = await this.acquireClient();\n\t\ttry {\n\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\ttry {\n\t\t\t\treturn { rows: blindCast((await client.query(text, request.params === void 0 ? void 0 : [...request.params]).catch(rethrowNormalizedError)).rows) };\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\n\t}\n\tasync *streamWithPortalProtection(client, request, cursorBatchSize, name) {\n\t\tif (this.inExplicitTransaction()) {\n\t\t\tyield* this.executeWithCursor(client, request.sql, request.params, cursorBatchSize, name);\n\t\t\treturn;\n\t\t}\n\t\tawait client.query(\"BEGIN\");\n\t\tlet streamFailed = false;\n\t\ttry {\n\t\t\tyield* this.executeWithCursor(client, request.sql, request.params, cursorBatchSize, name);\n\t\t} catch (error) {\n\t\t\tstreamFailed = true;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait this.commitStreamSpan(client, streamFailed);\n\t\t}\n\t}\n\tasync commitStreamSpan(client, streamFailed) {\n\t\ttry {\n\t\t\tawait client.query(\"COMMIT\");\n\t\t} catch (commitError) {\n\t\t\tif (!streamFailed) throw commitError;\n\t\t}\n\t}\n\tasync *executeWithCursor(client, sql, params, cursorBatchSize, name) {\n\t\tconst values = blindCast(params ?? []);\n\t\tconst config = { types: serverTextTypes };\n\t\tconst cursor = client.query(name === void 0 ? new Cursor(sql, values, config) : new NamedCursor({\n\t\t\tname,\n\t\t\ttext: sql,\n\t\t\tvalues,\n\t\t\tconfig\n\t\t}));\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst rows = await readCursor(cursor, cursorBatchSize);\n\t\t\t\tif (rows.length === 0) break;\n\t\t\t\tfor (const row of rows) yield row;\n\t\t\t}\n\t\t} finally {\n\t\t\tawait closeCursor(cursor);\n\t\t}\n\t}\n\tasync executeBuffered(client, sql, params, name) {\n\t\tconst config = {\n\t\t\tname,\n\t\t\ttext: sql,\n\t\t\tvalues: blindCast(params ?? []),\n\t\t\ttypes: serverTextTypes\n\t\t};\n\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\tlet result;\n\t\ttry {\n\t\t\tresult = await client.query(config);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t\treturn blindCast(result.rows);\n\t}\n};\nvar PostgresConnectionImpl = class extends PostgresQueryable {\n\t#connection;\n\t#onRelease;\n\t#onDestroy;\n\t#txState;\n\tconstructor(connection, options, onRelease, onDestroy, txState) {\n\t\tsuper(options);\n\t\tthis.#connection = connection;\n\t\tthis.#onRelease = onRelease;\n\t\tthis.#onDestroy = onDestroy;\n\t\tthis.#txState = txState ?? { open: false };\n\t}\n\tacquireClient() {\n\t\treturn Promise.resolve(this.#connection);\n\t}\n\treleaseClient(_client) {\n\t\treturn Promise.resolve();\n\t}\n\tinExplicitTransaction() {\n\t\treturn this.#txState.open;\n\t}\n\tasync beginTransaction() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.#connection);\n\t\ttry {\n\t\t\tawait this.#connection.query(\"BEGIN\").catch(rethrowNormalizedError);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t\tthis.#txState.open = true;\n\t\treturn new PostgresTransactionImpl(this.#connection, this.options, () => {\n\t\t\tthis.#txState.open = false;\n\t\t});\n\t}\n\tasync release() {\n\t\tconst conn = this.#connection;\n\t\tif (\"release\" in conn) conn.release();\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onRelease = void 0;\n\t\tthis.#onDestroy = void 0;\n\t\tonRelease?.();\n\t}\n\tasync destroy(reason) {\n\t\tconst onDestroy = this.#onDestroy;\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onDestroy = void 0;\n\t\tthis.#onRelease = void 0;\n\t\tconst conn = this.#connection;\n\t\tif (\"release\" in conn) {\n\t\t\tconst releaseArg = reason instanceof Error ? reason : /* @__PURE__ */ new Error(\"Connection destroyed\");\n\t\t\tconn.release(releaseArg);\n\t\t}\n\t\tif (onDestroy) await onDestroy(reason);\n\t\telse onRelease?.();\n\t}\n};\nvar PostgresTransactionImpl = class extends PostgresQueryable {\n\t#connection;\n\t#onSettled;\n\tconstructor(connection, options, onSettled) {\n\t\tsuper(options);\n\t\tthis.#connection = connection;\n\t\tthis.#onSettled = onSettled;\n\t}\n\tacquireClient() {\n\t\treturn Promise.resolve(this.#connection);\n\t}\n\treleaseClient(_client) {\n\t\treturn Promise.resolve();\n\t}\n\tinExplicitTransaction() {\n\t\treturn true;\n\t}\n\t#settle() {\n\t\tconst onSettled = this.#onSettled;\n\t\tthis.#onSettled = void 0;\n\t\tonSettled?.();\n\t}\n\tasync commit() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.#connection);\n\t\ttry {\n\t\t\tawait this.#connection.query(\"COMMIT\").catch(rethrowNormalizedError);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t\tthis.#settle();\n\t\t}\n\t}\n\tasync rollback() {\n\t\tconst releaseLock = await acquireClientQueryLock(this.#connection);\n\t\ttry {\n\t\t\tawait this.#connection.query(\"ROLLBACK\").catch(rethrowNormalizedError);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t\tthis.#settle();\n\t\t}\n\t}\n};\nvar PostgresPoolDriverImpl = class extends PostgresQueryable {\n\tpool;\n\t#closed = false;\n\tconstructor(options) {\n\t\tsuper(buildConnectionOptions(options));\n\t\tthis.pool = options.connect.pool;\n\t}\n\tget state() {\n\t\treturn this.#closed ? \"closed\" : \"connected\";\n\t}\n\tasync connect(_binding) {}\n\tasync acquireConnection() {\n\t\treturn new PostgresConnectionImpl(await this.acquireClient(), this.options);\n\t}\n\tasync close() {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tawait this.pool.end();\n\t}\n\tasync acquireClient() {\n\t\treturn suppressIdleConnectionErrors$1(await this.pool.connect());\n\t}\n\tasync releaseClient(client) {\n\t\tclient.release();\n\t}\n};\nvar PostgresDirectDriverImpl = class extends PostgresQueryable {\n\tdirectClient;\n\t#connectionMutex = new AsyncMutex();\n\t#closed = false;\n\t#connected = false;\n\t#connectPromise;\n\t#txState = { open: false };\n\tconstructor(options) {\n\t\tsuper(buildConnectionOptions(options));\n\t\tthis.directClient = options.connect.client;\n\t\tthis.directClient.on(\"error\", () => {\n\t\t\tthis.#closed = true;\n\t\t\tthis.#connected = false;\n\t\t});\n\t}\n\tinExplicitTransaction() {\n\t\treturn this.#txState.open;\n\t}\n\tget state() {\n\t\treturn this.#closed ? \"closed\" : \"connected\";\n\t}\n\tasync connect(_binding) {}\n\tasync acquireConnection() {\n\t\tconst releaseLease = await this.#connectionMutex.lock();\n\t\ttry {\n\t\t\treturn new PostgresConnectionImpl(await this.acquireClient(), this.options, releaseLease, async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.#closeWhileHoldingLease({ waitForStatement: false });\n\t\t\t\t} finally {\n\t\t\t\t\treleaseLease();\n\t\t\t\t}\n\t\t\t}, this.#txState);\n\t\t} catch (error) {\n\t\t\treleaseLease();\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync close() {\n\t\tconst releaseLease = await this.#connectionMutex.lock();\n\t\ttry {\n\t\t\tawait this.#closeWhileHoldingLease({ waitForStatement: true });\n\t\t} finally {\n\t\t\treleaseLease();\n\t\t}\n\t}\n\tasync #closeWhileHoldingLease(options) {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tconst releaseQueryLock = options.waitForStatement ? await acquireClientQueryLock(this.directClient) : () => {};\n\t\ttry {\n\t\t\tawait this.directClient.end();\n\t\t} finally {\n\t\t\treleaseQueryLock();\n\t\t}\n\t\tthis.#connected = false;\n\t}\n\tasync acquireClient() {\n\t\tif (this.#closed) throw driverError(\"DRIVER.NOT_CONNECTED\", \"Postgres connection lost or closed. Create a new client to reconnect.\");\n\t\tif (this.#connected) return this.directClient;\n\t\tif (this.#connectPromise !== void 0) {\n\t\t\tawait this.#connectPromise;\n\t\t\treturn this.directClient;\n\t\t}\n\t\tthis.#connectPromise = (async () => {\n\t\t\ttry {\n\t\t\t\tawait this.directClient.connect();\n\t\t\t} catch (error) {\n\t\t\t\tif (!isAlreadyConnectedError(error)) throw error;\n\t\t\t} finally {\n\t\t\t\tthis.#connectPromise = void 0;\n\t\t\t}\n\t\t\tthis.#connected = true;\n\t\t})();\n\t\tawait this.#connectPromise;\n\t\treturn this.directClient;\n\t}\n\tasync releaseClient(_client) {}\n};\nfunction createBoundDriverFromBinding(binding, cursorOpts, extraOpts) {\n\tconst preparedStatements = extraOpts?.preparedStatements;\n\tswitch (binding.kind) {\n\t\tcase \"url\": return new PostgresPoolDriverImpl({\n\t\t\tconnect: { pool: suppressIdleConnectionErrors$1(new Pool({\n\t\t\t\tconnectionString: binding.url,\n\t\t\t\tconnectionTimeoutMillis: 2e4,\n\t\t\t\tidleTimeoutMillis: 3e4\n\t\t\t})) },\n\t\t\tcursor: cursorOpts,\n\t\t\tpreparedStatements\n\t\t});\n\t\tcase \"pgPool\": return new PostgresPoolDriverImpl({\n\t\t\tconnect: { pool: suppressIdleConnectionErrors$1(binding.pool) },\n\t\t\tcursor: cursorOpts,\n\t\t\tpreparedStatements\n\t\t});\n\t\tcase \"pgClient\": return new PostgresDirectDriverImpl({\n\t\t\tconnect: { client: suppressIdleConnectionErrors$1(binding.client) },\n\t\t\tcursor: cursorOpts,\n\t\t\tpreparedStatements\n\t\t});\n\t}\n}\nfunction readCursor(cursor, size) {\n\treturn callbackToPromise((cb) => {\n\t\tcursor.read(size, (err, rows) => cb(err, rows));\n\t});\n}\nfunction closeCursor(cursor) {\n\treturn callbackToPromise((cb) => cursor.close(cb));\n}\nfunction rethrowNormalizedError(error) {\n\tthrow normalizePgError(error);\n}\nfunction prepareFailedError(retryError, handle) {\n\tconst cause = normalizePgError(retryError);\n\treturn Object.assign(driverError(\"DRIVER.PREPARE_FAILED\", `Prepared statement failed again after re-preparing with a fresh handle: ${cause.message}`, { handle }), { cause });\n}\n//#endregion\n//#region src/exports/runtime.ts\nconst USE_BEFORE_CONNECT_MESSAGE = \"Postgres driver not connected. Call connect(binding) before acquireConnection or execute.\";\nconst CLOSED_MESSAGE = \"Postgres driver is closed. Call connect(binding) to reconnect.\";\nconst CONNECTION_LOST_MESSAGE = \"Postgres connection lost or closed. Call connect(binding) to reconnect.\";\nconst ALREADY_CONNECTED_MESSAGE = \"Postgres driver already connected. Call close() before reconnecting with a new binding.\";\nfunction unboundQuery(notConnected) {\n\treturn { [Symbol.asyncIterator]() {\n\t\treturn { async next() {\n\t\t\tthrow notConnected();\n\t\t} };\n\t} };\n}\nconst notConnectedMessages = {\n\tunbound: USE_BEFORE_CONNECT_MESSAGE,\n\tclosed: CLOSED_MESSAGE,\n\tconnectionLost: CONNECTION_LOST_MESSAGE\n};\nvar PostgresUnboundDriverImpl = class {\n\tfamilyId = \"sql\";\n\ttargetId = \"postgres\";\n\t#delegate = null;\n\t#disconnectedState = \"unbound\";\n\t#cursorOpts;\n\t#preparedStatements;\n\tconstructor(options) {\n\t\tthis.#cursorOpts = options?.cursor;\n\t\tthis.#preparedStatements = options?.preparedStatements;\n\t}\n\tget state() {\n\t\tif (this.#delegate !== null) return \"connected\";\n\t\treturn this.#disconnectedState === \"unbound\" ? \"unbound\" : \"closed\";\n\t}\n\t#notConnectedError() {\n\t\treturn driverError(\"DRIVER.NOT_CONNECTED\", notConnectedMessages[this.#disconnectedState]);\n\t}\n\t#requireDelegate() {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) throw this.#notConnectedError();\n\t\treturn delegate;\n\t}\n\tasync connect(binding) {\n\t\tif (this.#delegate !== null) throw driverError(\"DRIVER.ALREADY_CONNECTED\", ALREADY_CONNECTED_MESSAGE, { bindingKind: binding.kind });\n\t\tthis.#delegate = createBoundDriverFromBinding(binding, this.#cursorOpts, { preparedStatements: this.#preparedStatements });\n\t\tthis.#disconnectedState = \"unbound\";\n\t}\n\tasync acquireConnection() {\n\t\tconst delegate = this.#requireDelegate();\n\t\tconst connection = await delegate.acquireConnection();\n\t\treturn this.#wrapConnection(connection, delegate);\n\t}\n\t/**\n\t* Wraps an acquired connection so that teardown paths which close the\n\t* underlying delegate (notably `destroy()` on a pgClient binding, where\n\t* the single socket means a destroyed connection invalidates the driver)\n\t* also reset our own `#delegate` reference. Without this, a failed\n\t* transaction rollback would leave the outer unbound wrapper reporting\n\t* `connected` while routing subsequent work to an already-ended delegate.\n\t*/\n\t#wrapConnection(connection, delegate) {\n\t\tconst syncDelegateState = () => {\n\t\t\tif (this.#delegate === delegate && delegate.state === \"closed\") {\n\t\t\t\tthis.#delegate = null;\n\t\t\t\tthis.#disconnectedState = \"connectionLost\";\n\t\t\t}\n\t\t};\n\t\tconst wrapped = {\n\t\t\tbeginTransaction: connection.beginTransaction.bind(connection),\n\t\t\tquery: connection.query.bind(connection),\n\t\t\texecute: connection.execute.bind(connection),\n\t\t\trelease: async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait connection.release();\n\t\t\t\t} finally {\n\t\t\t\t\tsyncDelegateState();\n\t\t\t\t}\n\t\t\t},\n\t\t\tdestroy: async (reason) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait connection.destroy(reason);\n\t\t\t\t} finally {\n\t\t\t\t\tsyncDelegateState();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tif (connection.explain) wrapped.explain = connection.explain.bind(connection);\n\t\treturn wrapped;\n\t}\n\tasync close() {\n\t\tconst delegate = this.#delegate;\n\t\tthis.#delegate = null;\n\t\tthis.#disconnectedState = \"closed\";\n\t\tawait delegate?.close();\n\t}\n\tquery(request) {\n\t\tconst delegate = this.#delegate;\n\t\treturn delegate === null ? unboundQuery(() => this.#notConnectedError()) : delegate.query(request);\n\t}\n\tasync execute(request) {\n\t\treturn this.#requireDelegate().execute(request);\n\t}\n\tasync explain(request) {\n\t\tconst delegate = this.#requireDelegate();\n\t\tconst explain = delegate.explain;\n\t\tif (explain === void 0) throw driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\n\t\treturn explain.call(delegate, request);\n\t}\n};\nconst postgresRuntimeDriverDescriptor = {\n\t...postgresDriverDescriptorMeta,\n\tcreate(options) {\n\t\treturn new PostgresUnboundDriverImpl(options);\n\t}\n};\n//#endregion\nexport { postgresRuntimeDriverDescriptor as default, suppressIdleConnectionErrors };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;AAMA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,MAAM,QAAQ,IAAI,MAAM,OAAO;CAC/B,OAAO,eAAe,OAAO,QAAQ;EACpC,OAAO;EACP,cAAc;CACf,CAAC;CACD,OAAO,YAAY,KAAK,IAAI,OAAO,OAAO,OAAO;EAChD;EACA,UAAU;EACV,UAAU;CACX,CAAC,IAAI,OAAO,OAAO,OAAO;EACzB;EACA,UAAU;EACV,UAAU;EACV;CACD,CAAC;AACF;AAGA,SAAS,kBAAkB,IAAI;CAC9B,OAAO,IAA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ACD;AACA,MAAM,kCAAkC;CACvC,GAAG;CACH,OAAO,SAAS;EACf,OAAO,IAAI,0BAA0B,OAAO;CAC7C;AACD"}
|
package/dist/{temporal-text-parsers-M28a91UF-D938VcZK.mjs → server-text-types-DeNPQpv5-DPxA9uXV.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
2
2
|
import { SqlConnectionError, SqlQueryError } from "@prisma/orm-family-sql/errors";
|
|
3
3
|
import { types } from "pg";
|
|
4
|
-
//#region ../../../3-targets/7-drivers/postgres/dist/
|
|
4
|
+
//#region ../../../3-targets/7-drivers/postgres/dist/server-text-types-DeNPQpv5.mjs
|
|
5
5
|
const postgresDriverDescriptorMeta = {
|
|
6
6
|
kind: "driver",
|
|
7
7
|
familyId: "sql",
|
|
@@ -117,10 +117,6 @@ function normalizePgError(error) {
|
|
|
117
117
|
});
|
|
118
118
|
return error;
|
|
119
119
|
}
|
|
120
|
-
const DATE_OID = 1082;
|
|
121
|
-
const TIME_OID = 1083;
|
|
122
|
-
const TIMESTAMP_OID = 1114;
|
|
123
|
-
const TIMESTAMPTZ_OID = 1184;
|
|
124
120
|
const PG_TYPES_ARRAY_OIDS = /* @__PURE__ */ new Set([
|
|
125
121
|
651,
|
|
126
122
|
791,
|
|
@@ -151,27 +147,17 @@ const PG_TYPES_ARRAY_OIDS = /* @__PURE__ */ new Set([
|
|
|
151
147
|
3807,
|
|
152
148
|
3907
|
|
153
149
|
]);
|
|
154
|
-
|
|
155
|
-
DATE_OID,
|
|
156
|
-
TIME_OID,
|
|
157
|
-
TIMESTAMP_OID,
|
|
158
|
-
TIMESTAMPTZ_OID
|
|
159
|
-
]);
|
|
160
|
-
function getTypeParser(oid, format) {
|
|
150
|
+
function pgTypeParser(oid, format) {
|
|
161
151
|
return blindCast(types.getTypeParser)(oid, format);
|
|
162
152
|
}
|
|
163
153
|
function serverText(value) {
|
|
164
154
|
return value;
|
|
165
155
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
} };
|
|
171
|
-
}
|
|
172
|
-
const controlTextTypes = createTextTypes(PG_TYPES_ARRAY_OIDS);
|
|
173
|
-
const temporalTextTypes = createTextTypes(/* @__PURE__ */ new Set([...TEMPORAL_SCALAR_OIDS, ...PG_TYPES_ARRAY_OIDS]));
|
|
156
|
+
const serverTextTypes = { getTypeParser: () => serverText };
|
|
157
|
+
const controlTextTypes = { getTypeParser(oid, format) {
|
|
158
|
+
return PG_TYPES_ARRAY_OIDS.has(oid) ? serverText : pgTypeParser(oid, format);
|
|
159
|
+
} };
|
|
174
160
|
//#endregion
|
|
175
|
-
export { postgresDriverDescriptorMeta as a, normalizePgError as i, isAlreadyConnectedError as n,
|
|
161
|
+
export { postgresDriverDescriptorMeta as a, normalizePgError as i, isAlreadyConnectedError as n, serverTextTypes as o, isPostgresError as r, controlTextTypes as t };
|
|
176
162
|
|
|
177
|
-
//# sourceMappingURL=
|
|
163
|
+
//# sourceMappingURL=server-text-types-DeNPQpv5-DPxA9uXV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-text-types-DeNPQpv5-DPxA9uXV.mjs","names":[],"sources":["../../../../3-targets/7-drivers/postgres/dist/server-text-types-DeNPQpv5.mjs"],"sourcesContent":["import { SqlConnectionError, SqlQueryError } from \"@internal/sql-errors\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { types } from \"pg\";\n//#region src/core/descriptor-meta.ts\nconst postgresDriverDescriptorMeta = {\n\tkind: \"driver\",\n\tfamilyId: \"sql\",\n\ttargetId: \"postgres\",\n\tid: \"postgres\",\n\tversion: \"0.0.1\",\n\tcapabilities: {}\n};\n//#endregion\n//#region src/normalize-error.ts\n/**\n* Checks if an error is a connection-related error.\n*/\nfunction isConnectionError(error) {\n\tconst code = error.code;\n\tif (code) {\n\t\tif (code === \"ECONNRESET\" || code === \"ETIMEDOUT\" || code === \"ECONNREFUSED\" || code === \"ENOTFOUND\" || code === \"EHOSTUNREACH\") return true;\n\t}\n\tconst message = error.message.toLowerCase();\n\tif (message.includes(\"connection terminated\") || message.includes(\"connection closed\") || message.includes(\"connection refused\") || message.includes(\"connection timeout\") || message.includes(\"connection reset\")) return true;\n\treturn false;\n}\n/**\n* Checks if a connection error is transient (might succeed on retry).\n*/\nfunction isTransientConnectionError(error) {\n\tconst code = error.code;\n\tif (code) {\n\t\tif (code === \"ETIMEDOUT\" || code === \"ECONNRESET\") return true;\n\t\tif (code === \"ECONNREFUSED\") return false;\n\t}\n\tconst message = error.message.toLowerCase();\n\tif (message.includes(\"timeout\") || message.includes(\"connection reset\")) return true;\n\treturn false;\n}\n/**\n* PostgreSQL-specific error properties that indicate an error originated from pg library.\n* These properties are not present on Node.js system errors.\n* Excludes generic properties like 'detail', 'file', 'line', and 'position' that could appear on any error.\n*/\nconst PG_ERROR_PROPERTIES = [\n\t\"constraint\",\n\t\"table\",\n\t\"column\",\n\t\"hint\",\n\t\"internalPosition\",\n\t\"internalQuery\",\n\t\"where\",\n\t\"schema\",\n\t\"routine\"\n];\n/**\n* Type predicate to check if an error is a Postgres error from the pg library.\n*\n* Distinguishes pg library errors from Node.js system errors by checking for:\n* - SQLSTATE codes (5-character alphanumeric codes like '23505', '42601')\n* - pg-specific properties (constraint, table, column, hint, etc.) that Node.js errors don't have\n*\n* Node.js system errors (ECONNREFUSED, ETIMEDOUT, etc.) are excluded to prevent false positives.\n*/\nfunction isPostgresError(error) {\n\tif (!(error instanceof Error)) return false;\n\tconst pgError = error;\n\tif (pgError.code && isPostgresSqlState(pgError.code)) return true;\n\treturn PG_ERROR_PROPERTIES.some((prop) => pgError[prop] !== void 0);\n}\n/**\n* Checks if an error is an \"already connected\" error from pg.Client.connect().\n* When calling connect() on an already-connected client, pg throws an error that can be safely ignored.\n*/\nfunction isAlreadyConnectedError(error) {\n\tif (!(error instanceof Error)) return false;\n\tconst message = error.message.toLowerCase();\n\treturn message.includes(\"already\") && message.includes(\"connected\");\n}\n/**\n* Checks if an error code is a Postgres SQLSTATE (5-character alphanumeric code).\n* SQLSTATE codes are standardized SQL error codes (e.g., '23505' for unique violation).\n*/\nfunction isPostgresSqlState(code) {\n\tif (!code) return false;\n\treturn /^[A-Z0-9]{5}$/.test(code);\n}\n/**\n* Normalizes a Postgres error into a SQL-shared error type.\n*\n* - Postgres SQLSTATE errors (5-char codes like '23505') → SqlQueryError\n* - Connection errors (ECONNRESET, ETIMEDOUT, etc.) → SqlConnectionError\n* - Unknown errors → returns the original error as-is\n*\n* The original error is preserved via Error.cause to maintain stack traces.\n*\n* @param error - The error to normalize (typically from pg library)\n* @returns SqlQueryError for query-related failures\n* @returns SqlConnectionError for connection-related failures\n* @returns The original error if it cannot be normalized\n*/\nfunction normalizePgError(error) {\n\tif (!(error instanceof Error)) return new Error(String(error));\n\tconst pgError = error;\n\tif (isPostgresSqlState(pgError.code)) {\n\t\tconst options = {\n\t\t\tcause: error,\n\t\t\tsqlState: pgError.code\n\t\t};\n\t\tif (pgError.constraint !== void 0) options.constraint = pgError.constraint;\n\t\tif (pgError.table !== void 0) options.table = pgError.table;\n\t\tif (pgError.column !== void 0) options.column = pgError.column;\n\t\tif (pgError.detail !== void 0) options.detail = pgError.detail;\n\t\treturn new SqlQueryError(error.message, options);\n\t}\n\tif (isConnectionError(error)) return new SqlConnectionError(error.message, {\n\t\tcause: error,\n\t\ttransient: isTransientConnectionError(error)\n\t});\n\treturn error;\n}\n//#endregion\n//#region src/server-text-types.ts\nconst PG_TYPES_ARRAY_OIDS = /* @__PURE__ */ new Set([\n\t651,\n\t791,\n\t199,\n\t1e3,\n\t1001,\n\t1005,\n\t1007,\n\t1008,\n\t1009,\n\t1014,\n\t1015,\n\t1016,\n\t1017,\n\t1021,\n\t1022,\n\t1028,\n\t1040,\n\t1041,\n\t1115,\n\t1182,\n\t1183,\n\t1185,\n\t1187,\n\t1231,\n\t1270,\n\t2951,\n\t3807,\n\t3907\n]);\nfunction pgTypeParser(oid, format) {\n\treturn blindCast(types.getTypeParser)(oid, format);\n}\nfunction serverText(value) {\n\treturn value;\n}\nconst serverTextTypes = { getTypeParser: () => serverText };\nconst controlTextTypes = { getTypeParser(oid, format) {\n\treturn PG_TYPES_ARRAY_OIDS.has(oid) ? serverText : pgTypeParser(oid, format);\n} };\n//#endregion\nexport { normalizePgError as a, isPostgresError as i, serverTextTypes as n, postgresDriverDescriptorMeta as o, isAlreadyConnectedError as r, controlTextTypes as t };\n\n//# sourceMappingURL=server-text-types-DeNPQpv5.mjs.map"],"mappings":";;;;AAIA,MAAM,+BAA+B;CACpC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;AAChB;;;;AAMA,SAAS,kBAAkB,OAAO;CACjC,MAAM,OAAO,MAAM;CACnB,IAAI,MACC;MAAA,SAAS,gBAAgB,SAAS,eAAe,SAAS,kBAAkB,SAAS,eAAe,SAAS,gBAAgB,OAAO;CAAA;CAEzI,MAAM,UAAU,MAAM,QAAQ,YAAY;CAC1C,IAAI,QAAQ,SAAS,uBAAuB,KAAK,QAAQ,SAAS,mBAAmB,KAAK,QAAQ,SAAS,oBAAoB,KAAK,QAAQ,SAAS,oBAAoB,KAAK,QAAQ,SAAS,kBAAkB,GAAG,OAAO;CAC3N,OAAO;AACR;;;;AAIA,SAAS,2BAA2B,OAAO;CAC1C,MAAM,OAAO,MAAM;CACnB,IAAI,MAAM;EACT,IAAI,SAAS,eAAe,SAAS,cAAc,OAAO;EAC1D,IAAI,SAAS,gBAAgB,OAAO;CACrC;CACA,MAAM,UAAU,MAAM,QAAQ,YAAY;CAC1C,IAAI,QAAQ,SAAS,SAAS,KAAK,QAAQ,SAAS,kBAAkB,GAAG,OAAO;CAChF,OAAO;AACR;;;;;;AAMA,MAAM,sBAAsB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;;;;;;AAUA,SAAS,gBAAgB,OAAO;CAC/B,IAA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A;CACA;CACA;CACA;AACD,CAAC;AACD,SAAS,aAAa,KAAK,QAAQ;CAClC,OAAO,UAAU,MAAM,aAAa,CAAC,CAAC,KAAK,MAAM;AAClD;AACA,SAAS,WAAW,OAAO;CAC1B,OAAO;AACR;AACA,MAAM,kBAAkB,EAAE,qBAAqB,WAAW;AAC1D,MAAM,mBAAmB,EAAE,cAAc,KAAK,QAAQ;CACrD,OAAO,oBAAoB,IAAI,GAAG,IAAI,aAAa,aAAa,KAAK,MAAM;AAC5E,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as isPgEnumParams } from "./codecs-
|
|
1
|
+
import { o as isPgEnumParams } from "./codecs-CnbVrlil--FxLKWM5.mjs";
|
|
2
2
|
import { i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from "./sql-utils-Bh-mnsSY-D6hnFPrP.mjs";
|
|
3
3
|
import { LiteralExpr, collectOrderedParamRefs } from "@prisma/orm-family-sql/relational-core/ast";
|
|
4
4
|
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
@@ -513,4 +513,4 @@ function renderRawExpr(node, contract, pim) {
|
|
|
513
513
|
//#endregion
|
|
514
514
|
export { renderLoweredSql as n, adapterError as t };
|
|
515
515
|
|
|
516
|
-
//# sourceMappingURL=sql-renderer-CgUgFbU4-
|
|
516
|
+
//# sourceMappingURL=sql-renderer-CgUgFbU4-BY3PCrmG.mjs.map
|