@prisma/orm-target-postgres 0.17.0-dev.1 → 0.17.0-dev.11

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.
Files changed (70) hide show
  1. package/dist/{adapter-DhqcO3YO-jzwDVcCv.mjs → adapter-BwjBEeND-B7-Hx3r9.mjs} +10 -4
  2. package/dist/adapter-BwjBEeND-B7-Hx3r9.mjs.map +1 -0
  3. package/dist/adapter.d.mts +2 -1
  4. package/dist/adapter.mjs +4 -3
  5. package/dist/adapter__adapter.mjs +1 -1
  6. package/dist/adapter__control.mjs +2 -2
  7. package/dist/adapter__control.mjs.map +1 -1
  8. package/dist/adapter__runtime.mjs +4 -4
  9. package/dist/adapter__runtime.mjs.map +1 -1
  10. package/dist/adapter__sql-renderer.d.mts +2 -0
  11. package/dist/adapter__sql-renderer.mjs +2 -0
  12. package/dist/aggregates-CgqNfj2O.d.mts +10 -0
  13. package/dist/aggregates-CgqNfj2O.d.mts.map +1 -0
  14. package/dist/aggregates-ftUgi-eC.mjs +102 -0
  15. package/dist/aggregates-ftUgi-eC.mjs.map +1 -0
  16. package/dist/{codecs-CBl0nD44-CaWPc1bd.mjs → codecs-CBl0nD44-CjInu_aV.mjs} +2 -2
  17. package/dist/{codecs-CBl0nD44-CaWPc1bd.mjs.map → codecs-CBl0nD44-CjInu_aV.mjs.map} +1 -1
  18. package/dist/{codecs-CHIVTNZs.mjs → codecs-rujsdlZR.mjs} +2 -2
  19. package/dist/{codecs-CHIVTNZs.mjs.map → codecs-rujsdlZR.mjs.map} +1 -1
  20. package/dist/{control-DRMWptiJ.mjs → control-BzDnaGim.mjs} +5 -5
  21. package/dist/{control-DRMWptiJ.mjs.map → control-BzDnaGim.mjs.map} +1 -1
  22. package/dist/{control-adapter-B9t0g7Pf-HrCxlM65.mjs → control-adapter-CipVam9p-B-E2SF8_.mjs} +9 -578
  23. package/dist/control-adapter-CipVam9p-B-E2SF8_.mjs.map +1 -0
  24. package/dist/{control-policy-Cl3RRSPg-CT3QGpR3.mjs → control-policy-Cl3RRSPg-BUi6pcI-.mjs} +3 -3
  25. package/dist/{control-policy-Cl3RRSPg-CT3QGpR3.mjs.map → control-policy-Cl3RRSPg-BUi6pcI-.mjs.map} +1 -1
  26. package/dist/{descriptor-meta-2IlVC6_d-DnV00Qd_.mjs → descriptor-meta--MCrvIgj-DFsLFDj1.mjs} +6 -4
  27. package/dist/descriptor-meta--MCrvIgj-DFsLFDj1.mjs.map +1 -0
  28. package/dist/{descriptor-meta-DnHabAS3-C53XXPQw.mjs → descriptor-meta-DnHabAS3-BiTguA3K.mjs} +2 -2
  29. package/dist/{descriptor-meta-DnHabAS3-C53XXPQw.mjs.map → descriptor-meta-DnHabAS3-BiTguA3K.mjs.map} +1 -1
  30. package/dist/{diff-database-schema-BfRs2vrG-D2o4KII0.mjs → diff-database-schema-BfRs2vrG-DInOv5LW.mjs} +2 -2
  31. package/dist/{diff-database-schema-BfRs2vrG-D2o4KII0.mjs.map → diff-database-schema-BfRs2vrG-DInOv5LW.mjs.map} +1 -1
  32. package/dist/driver.d.mts +1 -1
  33. package/dist/driver__runtime.d.mts +1 -1
  34. package/dist/driver__runtime.mjs +107 -70
  35. package/dist/driver__runtime.mjs.map +1 -1
  36. package/dist/{op-factory-call-DifL68KT-Bo6pxs-R.mjs → op-factory-call-DifL68KT-CNFEDNsf.mjs} +2 -2
  37. package/dist/{op-factory-call-DifL68KT-Bo6pxs-R.mjs.map → op-factory-call-DifL68KT-CNFEDNsf.mjs.map} +1 -1
  38. package/dist/{planner-Bmje9ii8-B99fEsNM.mjs → planner-Bmje9ii8-DdjXZxyD.mjs} +5 -5
  39. package/dist/{planner-Bmje9ii8-B99fEsNM.mjs.map → planner-Bmje9ii8-DdjXZxyD.mjs.map} +1 -1
  40. package/dist/{planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs → planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs} +2 -2
  41. package/dist/{planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs.map → planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs.map} +1 -1
  42. package/dist/{planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs → planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs} +2 -2
  43. package/dist/{planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs.map → planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs.map} +1 -1
  44. package/dist/{postgres-migration-CJshdIZn-DYYjgdD0.mjs → postgres-migration-CJshdIZn-CT6Cxd4x.mjs} +2 -2
  45. package/dist/{postgres-migration-CJshdIZn-DYYjgdD0.mjs.map → postgres-migration-CJshdIZn-CT6Cxd4x.mjs.map} +1 -1
  46. package/dist/{runtime-CDewySU9.d.mts → runtime-lHBKgjB9.d.mts} +3 -2
  47. package/dist/runtime-lHBKgjB9.d.mts.map +1 -0
  48. package/dist/sql-renderer-CZE98PJj-Bx5D-Txz.mjs +579 -0
  49. package/dist/sql-renderer-CZE98PJj-Bx5D-Txz.mjs.map +1 -0
  50. package/dist/sql-renderer-Cyls5Xy4.d.mts +19 -0
  51. package/dist/sql-renderer-Cyls5Xy4.d.mts.map +1 -0
  52. package/dist/target.d.mts +2 -1
  53. package/dist/target.mjs +13 -12
  54. package/dist/target__aggregates.d.mts +2 -0
  55. package/dist/target__aggregates.mjs +2 -0
  56. package/dist/target__codecs.mjs +2 -2
  57. package/dist/target__control.mjs +1 -1
  58. package/dist/target__diff-database-schema.mjs +1 -1
  59. package/dist/target__issue-planner.mjs +1 -1
  60. package/dist/target__migration.mjs +2 -2
  61. package/dist/target__op-factory-call.mjs +1 -1
  62. package/dist/target__pack.mjs +1 -1
  63. package/dist/target__planner-ddl-builders.mjs +1 -1
  64. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  65. package/dist/target__planner.mjs +2 -2
  66. package/package.json +11 -9
  67. package/dist/adapter-DhqcO3YO-jzwDVcCv.mjs.map +0 -1
  68. package/dist/control-adapter-B9t0g7Pf-HrCxlM65.mjs.map +0 -1
  69. package/dist/descriptor-meta-2IlVC6_d-DnV00Qd_.mjs.map +0 -1
  70. package/dist/runtime-CDewySU9.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"diff-database-schema-BfRs2vrG-D2o4KII0.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-BfRs2vrG.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Ba5ZebHM.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-CxqlLW47.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-Cl3RRSPg.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\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\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\n}\n/**\n* Projects a Postgres contract into the expected schema-diff tree: a\n* `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`\n* per Postgres namespace, each holding its `PostgresTableSchemaNode`s with\n* their `PostgresPolicySchemaNode`s, plus the database roles on the root.\n*\n* Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,\n* single `{ tables }` map (and throws on cross-namespace name collisions, with\n* no RLS/role concept) for SQLite's single-schema world. This is the\n* Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.\n* It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)\n* for column/FK/index building and only adds the Postgres tree/policy/role shape.\n*\n* Tables are grouped by their owning namespace (resolved DDL schema name) so\n* the tree mirrors Postgres's object hierarchy. The DDL schema name is\n* resolved once per namespace.\n*\n* A policy that references a table absent from its namespace is a malformed\n* contract — the loop throws rather than fabricating a stub table.\n*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\n/**\n* Whether a diff issue's subject node is cluster-scoped — it carries its own\n* `namespaceId` field (only role and policy diff nodes do) and that\n* coordinate is the unbound sentinel, meaning the node is not owned by any\n* schema/namespace. A role node is always cluster-scoped (roles are\n* cluster-level objects); a policy node's `namespaceId` is always its\n* table's resolved DDL schema, never the sentinel. Namespace-ownership\n* scoping (which compares `issue.path[1]` against the set of DDL schemas\n* the contract owns) makes no sense for a cluster-scoped subject — its path\n* segment at that index is the object's own name, not a schema name — so\n* such an issue bypasses that scoping entirely.\n*/\nfunction isClusterScopedIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\n}\n/**\n* Drops contract namespaces that declare no tables from the verdict-diff\n* expected tree and the relational owned-schema set. The legacy relational\n* walk skipped a table-less namespace (e.g. an enums-only schema) before\n* pairing, so neither its DDL schema's absence nor that schema's live\n* relational contents ever reached the verdict — the pruned tree\n* reproduces that. The prune loses no expected policies: policies attach\n* to tables, so a table-less namespace carries none (the projection\n* throws on a policy referencing an absent table). Live policies in a\n* pruned schema remain governed via the full owned set (see\n* {@link diffPostgresSchema}).\n*/\nfunction pruneTableLessNamespaces(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\n}\n/**\n* Resolves a verdict-diff issue's subject's declared control policy directly\n* from the contract, by delegating to the same node-typed resolver\n* ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to\n* gate DDL calls. `undefined` when the issue resolves to no contract subject.\n*\n* A role issue resolves through that same resolver to `external`\n* unconditionally (see its role branch), regardless of the contract's own\n* default policy: a role is referenced by the contract but not owned, and\n* `external`'s existing semantics — a missing declared subject still fails,\n* every extra is suppressed — are exactly the wanted asymmetric grading for\n* a cluster object the framework does not own.\n*/\nfunction resolveControlPolicy(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\n}\n/**\n* The Postgres full-tree node diff for the family verify verdict: derive\n* the expected tree (resolved leaf values, expander threaded, FK schemas\n* resolved, table-less namespaces pruned), run the generic\n* differ over the trees as derived, and scope out `not-expected` findings under namespaces the\n* contract does not own. Ownership scoping bypasses cluster-scoped subjects\n* (roles today), mirroring the legacy decomposition: relational extras check\n* the PRUNED owned set (the legacy\n* per-namespace walk never visited a table-less namespace, so its live\n* relational contents are invisible), while `structural` extras (RLS\n* policies) check the FULL owned set (the legacy policy diff governed\n* every contract schema regardless of tables — RLS governance does not\n* shrink because a namespace declares no tables). The codec `verifyType`\n* hooks run once per contract namespace with tables against that\n* namespace's paired actual node (the hooks read namespace-scoped state\n* such as `nativeEnums`).\n*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\n}\n/**\n* Adds an empty namespace node to the actual tree for every expected namespace\n* absent from it. The relational plan diff pairs on namespace: a contract\n* namespace whose live schema does not exist yet must surface each of its\n* tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace\n* `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`\n* with no tables). Padding makes the namespaces pair, so only table/column/\n* policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized\n* namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the\n* tree diff — matching the retired per-namespace-paired relational walk, which\n* paired a missing schema against an empty namespace node.\n*/\nfunction padActualNamespaces(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\n}\n/**\n* The Postgres planner's diff input: the SAME tree-building\n* `diffPostgresSchema` uses (expander threaded, FK schemas resolved,\n* table-less namespaces pruned, cluster-scope-aware ownership filter) plus\n* actual namespace padding (so a missing\n* schema's tables surface as `not-found` instead of a swallowed namespace\n* `not-found`). One differ drives both verify and plan; this is the\n* plan-side derivation. The single issue list covers tables / columns /\n* constraints / indexes / defaults AND policies — the caller splits it\n* (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in\n* `CREATE SCHEMA` separately.\n*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };\n\n//# sourceMappingURL=diff-database-schema-BfRs2vrG.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,eAAe;CACvB,OAAO;EACN,UAAU,uBAAuB;EACjC,IAAI;CACL;AACD;AACA,SAAS,eAAe,aAAa,WAAW;CAC/C,OAAO;EACN,aAAa;EACb;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;EACA;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;CACD;AACD;AACA,SAAS,cAAc,MAAM;CAC5B,OAAO,CAAC,aAAa,GAAG;EACvB,UAAU,uBAAuB;EACjC,IAAI;CACL,CAAC;AACF;;;;;;;AAOA,SAAS,gBAAgB,aAAa,WAAW,SAAS;CACzD,OAAO,QAAQ,KAAK,WAAW,CAAC,GAAG,eAAe,aAAa,SAAS,GAAG;EAC1E,UAAU,yBAAyB;EACnC,IAAI,UAAU;CACf,CAAC,CAAC;AACH;AACA,SAAS,aAAa,QAAQ,aAAa;CAC1C,OAAO,IAAI,yBAAyB;EACnC,QAAQ,SAAS,OAAO,MAAM,OAAO,MAAM;EAC3C,WAAW,OAAO;EAClB;EACA,WAAW,OAAO;EAClB,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,YAAY,OAAO;EACnB,WAAW,CAAC,eAAe,aAAa,OAAO,SA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AAU,MAAM,QAAQ;CACjD,2BAA2B,OAAO,MAAM,YAAY;CACpD,MAAM,SAAS,MAAM;CACrB,MAAM,eAAe,qCAAqC,kBAAkB;EAC3E,qBAAqB;EACrB,GAAG,UAAU,oBAAoB,wBAAwB,MAAM,mBAAmB,CAAC;EACnF,gBAAgB;CACjB,CAAC;CACD,MAAM,WAAW,yBAAyB,YAAY;CACtD,MAAM,eAAe,oBAAoB,UAAU,MAAM;CACzD,MAAM,kBAAkB,iBAAiB,QAAQ;CACjD,MAAM,kBAAkB,iBAAiB,YAAY;CACrD,OAAO;EACN;EACA,QAAQ;EACR,QAAQ,UAAU,YAAY,UAAU,YAAY,CAAC,CAAC,CAAC,QAAQ,UAAU;GACxE,IAAI,aAAa,KAAK,MAAM,gBAAgB,OAAO;GACnD,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM,cAAc,+BAA+B,OAAO,8BAA8B;GACxF,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,QAAQ,gBAAgB,eAAe,kBAAkB,gBAAA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"diff-database-schema-BfRs2vrG-DInOv5LW.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-BfRs2vrG.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Ba5ZebHM.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-CxqlLW47.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-Cl3RRSPg.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\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\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\n}\n/**\n* Projects a Postgres contract into the expected schema-diff tree: a\n* `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`\n* per Postgres namespace, each holding its `PostgresTableSchemaNode`s with\n* their `PostgresPolicySchemaNode`s, plus the database roles on the root.\n*\n* Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,\n* single `{ tables }` map (and throws on cross-namespace name collisions, with\n* no RLS/role concept) for SQLite's single-schema world. This is the\n* Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.\n* It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)\n* for column/FK/index building and only adds the Postgres tree/policy/role shape.\n*\n* Tables are grouped by their owning namespace (resolved DDL schema name) so\n* the tree mirrors Postgres's object hierarchy. The DDL schema name is\n* resolved once per namespace.\n*\n* A policy that references a table absent from its namespace is a malformed\n* contract — the loop throws rather than fabricating a stub table.\n*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\n/**\n* Whether a diff issue's subject node is cluster-scoped — it carries its own\n* `namespaceId` field (only role and policy diff nodes do) and that\n* coordinate is the unbound sentinel, meaning the node is not owned by any\n* schema/namespace. A role node is always cluster-scoped (roles are\n* cluster-level objects); a policy node's `namespaceId` is always its\n* table's resolved DDL schema, never the sentinel. Namespace-ownership\n* scoping (which compares `issue.path[1]` against the set of DDL schemas\n* the contract owns) makes no sense for a cluster-scoped subject — its path\n* segment at that index is the object's own name, not a schema name — so\n* such an issue bypasses that scoping entirely.\n*/\nfunction isClusterScopedIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\n}\n/**\n* Drops contract namespaces that declare no tables from the verdict-diff\n* expected tree and the relational owned-schema set. The legacy relational\n* walk skipped a table-less namespace (e.g. an enums-only schema) before\n* pairing, so neither its DDL schema's absence nor that schema's live\n* relational contents ever reached the verdict — the pruned tree\n* reproduces that. The prune loses no expected policies: policies attach\n* to tables, so a table-less namespace carries none (the projection\n* throws on a policy referencing an absent table). Live policies in a\n* pruned schema remain governed via the full owned set (see\n* {@link diffPostgresSchema}).\n*/\nfunction pruneTableLessNamespaces(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\n}\n/**\n* Resolves a verdict-diff issue's subject's declared control policy directly\n* from the contract, by delegating to the same node-typed resolver\n* ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to\n* gate DDL calls. `undefined` when the issue resolves to no contract subject.\n*\n* A role issue resolves through that same resolver to `external`\n* unconditionally (see its role branch), regardless of the contract's own\n* default policy: a role is referenced by the contract but not owned, and\n* `external`'s existing semantics — a missing declared subject still fails,\n* every extra is suppressed — are exactly the wanted asymmetric grading for\n* a cluster object the framework does not own.\n*/\nfunction resolveControlPolicy(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\n}\n/**\n* The Postgres full-tree node diff for the family verify verdict: derive\n* the expected tree (resolved leaf values, expander threaded, FK schemas\n* resolved, table-less namespaces pruned), run the generic\n* differ over the trees as derived, and scope out `not-expected` findings under namespaces the\n* contract does not own. Ownership scoping bypasses cluster-scoped subjects\n* (roles today), mirroring the legacy decomposition: relational extras check\n* the PRUNED owned set (the legacy\n* per-namespace walk never visited a table-less namespace, so its live\n* relational contents are invisible), while `structural` extras (RLS\n* policies) check the FULL owned set (the legacy policy diff governed\n* every contract schema regardless of tables — RLS governance does not\n* shrink because a namespace declares no tables). The codec `verifyType`\n* hooks run once per contract namespace with tables against that\n* namespace's paired actual node (the hooks read namespace-scoped state\n* such as `nativeEnums`).\n*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\n}\n/**\n* Adds an empty namespace node to the actual tree for every expected namespace\n* absent from it. The relational plan diff pairs on namespace: a contract\n* namespace whose live schema does not exist yet must surface each of its\n* tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace\n* `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`\n* with no tables). Padding makes the namespaces pair, so only table/column/\n* policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized\n* namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the\n* tree diff — matching the retired per-namespace-paired relational walk, which\n* paired a missing schema against an empty namespace node.\n*/\nfunction padActualNamespaces(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\n}\n/**\n* The Postgres planner's diff input: the SAME tree-building\n* `diffPostgresSchema` uses (expander threaded, FK schemas resolved,\n* table-less namespaces pruned, cluster-scope-aware ownership filter) plus\n* actual namespace padding (so a missing\n* schema's tables surface as `not-found` instead of a swallowed namespace\n* `not-found`). One differ drives both verify and plan; this is the\n* plan-side derivation. The single issue list covers tables / columns /\n* constraints / indexes / defaults AND policies — the caller splits it\n* (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in\n* `CREATE SCHEMA` separately.\n*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };\n\n//# sourceMappingURL=diff-database-schema-BfRs2vrG.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,eAAe;CACvB,OAAO;EACN,UAAU,uBAAuB;EACjC,IAAI;CACL;AACD;AACA,SAAS,eAAe,aAAa,WAAW;CAC/C,OAAO;EACN,aAAa;EACb;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;EACA;GACC,UA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AAQ,gBAAgB,eAAe,kBAAkB,gBAAA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
package/dist/driver.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { t as PostgresControlDriver } from "./control-B-FTbEnE.mjs";
2
- import { i as QueryResult, n as PostgresDriverCreateOptions, r as PostgresRuntimeDriver, t as PostgresBinding } from "./runtime-CDewySU9.mjs";
2
+ import { i as QueryResult, n as PostgresDriverCreateOptions, r as PostgresRuntimeDriver, t as PostgresBinding } from "./runtime-lHBKgjB9.mjs";
3
3
  export { type PostgresBinding, PostgresControlDriver, type PostgresDriverCreateOptions, PostgresRuntimeDriver, type QueryResult };
@@ -1,2 +1,2 @@
1
- import { a as postgresRuntimeDriverDescriptor, i as QueryResult, n as PostgresDriverCreateOptions, r as PostgresRuntimeDriver, t as PostgresBinding } from "./runtime-CDewySU9.mjs";
1
+ import { a as postgresRuntimeDriverDescriptor, i as QueryResult, n as PostgresDriverCreateOptions, r as PostgresRuntimeDriver, t as PostgresBinding } from "./runtime-lHBKgjB9.mjs";
2
2
  export { type PostgresBinding, type PostgresDriverCreateOptions, PostgresRuntimeDriver, type QueryResult, postgresRuntimeDriverDescriptor as default };
@@ -1,7 +1,25 @@
1
1
  import { i as postgresDriverDescriptorMeta, n as isPostgresError, r as normalizePgError, t as isAlreadyConnectedError } from "./normalize-error-CNjgVO71-CLlZ3CuJ.mjs";
2
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
2
3
  import { Pool } from "pg";
3
4
  import Cursor from "pg-cursor";
4
5
  //#region ../../../3-targets/7-drivers/postgres/dist/runtime.mjs
6
+ function driverError(code, message, details) {
7
+ const error = new Error(message);
8
+ Object.defineProperty(error, "name", {
9
+ value: "RuntimeError",
10
+ configurable: true
11
+ });
12
+ return details === void 0 ? Object.assign(error, {
13
+ code,
14
+ category: "DRIVER",
15
+ severity: "error"
16
+ }) : Object.assign(error, {
17
+ code,
18
+ category: "DRIVER",
19
+ severity: "error",
20
+ details
21
+ });
22
+ }
5
23
  function callbackToPromise(fn) {
6
24
  return new Promise((resolve, reject) => {
7
25
  fn((err, result) => {
@@ -69,7 +87,7 @@ function buildConnectionOptions(options) {
69
87
  };
70
88
  }
71
89
  function isStalePreparedStatementError(error) {
72
- if (!(error instanceof Error)) return false;
90
+ if (!(error instanceof Error) || !("code" in error) || typeof error.code !== "string") return false;
73
91
  const code = error.code;
74
92
  return code === "26000" || code === "0A000";
75
93
  }
@@ -102,44 +120,91 @@ var PostgresQueryable = class {
102
120
  constructor(options) {
103
121
  this.options = options;
104
122
  }
105
- async *execute(request) {
123
+ async *query(request) {
106
124
  try {
107
- yield* this.runQuery(request);
125
+ const preparedStatementHandle = request.preparedStatementHandle;
126
+ if (preparedStatementHandle === void 0 || !this.options.preparedStatementsEnabled) {
127
+ yield* this.runQuery(request);
128
+ return;
129
+ }
130
+ const name = this.preparedStatementName(preparedStatementHandle);
131
+ yield* this.withStaleHandleStreamRetry(preparedStatementHandle, name, (name) => this.runQuery(request, name));
108
132
  } catch (error) {
109
133
  throw normalizePgError(error);
110
134
  }
111
135
  }
112
- async *executePrepared(request) {
113
- if (!this.options.preparedStatementsEnabled) {
114
- yield* this.execute(request);
115
- return;
116
- }
117
- let handle = request.handle.get();
118
- if (handle === void 0) {
119
- handle = this.options.handleAllocator.mint();
120
- request.handle.set(handle);
136
+ async execute(request) {
137
+ try {
138
+ const preparedStatementHandle = request.preparedStatementHandle;
139
+ if (preparedStatementHandle === void 0 || !this.options.preparedStatementsEnabled) return await this.runExecute(request);
140
+ const name = this.preparedStatementName(preparedStatementHandle);
141
+ return await this.withStaleHandleRetry(preparedStatementHandle, name, (name) => this.runExecute(request, name));
142
+ } catch (error) {
143
+ throw normalizePgError(error);
121
144
  }
122
- yield* this.withStaleHandleRetry(request, handle, (h) => this.runQuery(request, h));
123
145
  }
124
- async *withStaleHandleRetry(request, handle, attempt) {
125
- let yielded = false;
146
+ preparedStatementName(handle) {
147
+ const existingName = handle.get();
148
+ if (typeof existingName === "string") return existingName;
149
+ const mintedName = this.options.handleAllocator.mint();
150
+ handle.set(mintedName);
151
+ return mintedName;
152
+ }
153
+ async withStaleHandleRetry(preparedStatementHandle, name, attempt) {
126
154
  try {
127
- for await (const row of attempt(handle)) {
128
- yielded = true;
129
- yield row;
130
- }
131
- return;
155
+ return await attempt(name);
132
156
  } catch (error) {
133
- if (yielded || !isStalePreparedStatementError(error)) throw normalizePgError(error);
134
- const retryHandle = this.options.handleAllocator.mint();
135
- request.handle.set(retryHandle);
157
+ if (!isStalePreparedStatementError(error)) throw error;
158
+ const retryName = this.options.handleAllocator.mint();
159
+ preparedStatementHandle.set(retryName);
136
160
  try {
137
- yield* attempt(retryHandle);
161
+ return await attempt(retryName);
138
162
  } catch (retryError) {
139
- throw normalizePgError(retryError);
163
+ throw prepareFailedError(retryError, retryName);
140
164
  }
141
165
  }
142
166
  }
167
+ async *withStaleHandleStreamRetry(preparedStatementHandle, name, attempt) {
168
+ const stream = await this.withStaleHandleRetry(preparedStatementHandle, name, async (name) => {
169
+ const iterator = attempt(name)[Symbol.asyncIterator]();
170
+ return {
171
+ iterator,
172
+ first: await iterator.next()
173
+ };
174
+ });
175
+ if (stream.first.done) return;
176
+ let streamCompleted = false;
177
+ try {
178
+ yield stream.first.value;
179
+ while (true) {
180
+ const next = await stream.iterator.next();
181
+ if (next.done) {
182
+ streamCompleted = true;
183
+ return;
184
+ }
185
+ yield next.value;
186
+ }
187
+ } finally {
188
+ if (!streamCompleted) await stream.iterator.return?.();
189
+ }
190
+ }
191
+ async runExecute(request, name) {
192
+ const client = await this.acquireClient();
193
+ try {
194
+ const releaseLock = await acquireClientQueryLock(client);
195
+ try {
196
+ return { affectedRows: (await client.query({
197
+ name,
198
+ text: request.sql,
199
+ values: blindCast(request.params ?? [])
200
+ })).rowCount ?? 0 };
201
+ } finally {
202
+ releaseLock();
203
+ }
204
+ } finally {
205
+ await this.releaseClient(client);
206
+ }
207
+ }
143
208
  inExplicitTransaction() {
144
209
  return false;
145
210
  }
@@ -149,7 +214,7 @@ var PostgresQueryable = class {
149
214
  if (!this.options.cursorDisabled) {
150
215
  const releaseLock = await acquireClientQueryLock(client);
151
216
  try {
152
- for await (const row of this.streamWithPortalProtection(client, request, this.options.cursorBatchSize, name)) yield row;
217
+ for await (const row of this.streamWithPortalProtection(client, request, this.options.cursorBatchSize, name)) yield blindCast(row);
153
218
  return;
154
219
  } catch (cursorError) {
155
220
  if (!(cursorError instanceof Error) || isPostgresError(cursorError)) throw cursorError;
@@ -157,7 +222,7 @@ var PostgresQueryable = class {
157
222
  releaseLock();
158
223
  }
159
224
  }
160
- for await (const row of this.executeBuffered(client, request.sql, request.params, name)) yield row;
225
+ for await (const row of this.executeBuffered(client, request.sql, request.params, name)) yield blindCast(row);
161
226
  } finally {
162
227
  await this.releaseClient(client);
163
228
  }
@@ -168,20 +233,7 @@ var PostgresQueryable = class {
168
233
  try {
169
234
  const releaseLock = await acquireClientQueryLock(client);
170
235
  try {
171
- return { rows: (await client.query(text, request.params).catch(rethrowNormalizedError)).rows };
172
- } finally {
173
- releaseLock();
174
- }
175
- } finally {
176
- await this.releaseClient(client);
177
- }
178
- }
179
- async query(sql, params) {
180
- const client = await this.acquireClient();
181
- try {
182
- const releaseLock = await acquireClientQueryLock(client);
183
- try {
184
- return await client.query(sql, params).catch(rethrowNormalizedError);
236
+ return { rows: blindCast((await client.query(text, request.params === void 0 ? void 0 : [...request.params]).catch(rethrowNormalizedError)).rows) };
185
237
  } finally {
186
238
  releaseLock();
187
239
  }
@@ -213,7 +265,7 @@ var PostgresQueryable = class {
213
265
  }
214
266
  }
215
267
  async *executeWithCursor(client, sql, params, cursorBatchSize, name) {
216
- const values = params ?? [];
268
+ const values = blindCast(params ?? []);
217
269
  const cursor = client.query(name === void 0 ? new Cursor(sql, values) : new NamedCursor({
218
270
  name,
219
271
  text: sql,
@@ -233,7 +285,7 @@ var PostgresQueryable = class {
233
285
  const config = {
234
286
  name,
235
287
  text: sql,
236
- values: params ?? []
288
+ values: blindCast(params ?? [])
237
289
  };
238
290
  const releaseLock = await acquireClientQueryLock(client);
239
291
  let result;
@@ -242,7 +294,7 @@ var PostgresQueryable = class {
242
294
  } finally {
243
295
  releaseLock();
244
296
  }
245
- for (const row of result.rows) yield row;
297
+ for (const row of blindCast(result.rows)) yield row;
246
298
  }
247
299
  };
248
300
  var PostgresConnectionImpl = class extends PostgresQueryable {
@@ -465,23 +517,13 @@ function closeCursor(cursor) {
465
517
  function rethrowNormalizedError(error) {
466
518
  throw normalizePgError(error);
467
519
  }
520
+ function prepareFailedError(retryError, handle) {
521
+ const cause = normalizePgError(retryError);
522
+ return Object.assign(driverError("DRIVER.PREPARE_FAILED", `Prepared statement failed again after re-preparing with a fresh handle: ${cause.message}`, { handle }), { cause });
523
+ }
468
524
  const USE_BEFORE_CONNECT_MESSAGE = "Postgres driver not connected. Call connect(binding) before acquireConnection or execute.";
469
525
  const ALREADY_CONNECTED_MESSAGE = "Postgres driver already connected. Call close() before reconnecting with a new binding.";
470
- function driverError(code, message, details) {
471
- const error = new Error(message);
472
- Object.defineProperty(error, "name", {
473
- value: "RuntimeError",
474
- configurable: true
475
- });
476
- return Object.assign(error, {
477
- code,
478
- category: "DRIVER",
479
- severity: "error",
480
- message,
481
- details
482
- });
483
- }
484
- function unboundExecute() {
526
+ function unboundQuery() {
485
527
  return { [Symbol.asyncIterator]() {
486
528
  return { async next() {
487
529
  throw driverError("DRIVER.NOT_CONNECTED", USE_BEFORE_CONNECT_MESSAGE);
@@ -536,9 +578,8 @@ var PostgresUnboundDriverImpl = class {
536
578
  };
537
579
  const wrapped = {
538
580
  beginTransaction: connection.beginTransaction.bind(connection),
539
- execute: connection.execute.bind(connection),
540
- executePrepared: connection.executePrepared.bind(connection),
541
581
  query: connection.query.bind(connection),
582
+ execute: connection.execute.bind(connection),
542
583
  release: async () => {
543
584
  try {
544
585
  await connection.release();
@@ -565,15 +606,14 @@ var PostgresUnboundDriverImpl = class {
565
606
  }
566
607
  this.#closed = true;
567
608
  }
568
- execute(request) {
609
+ query(request) {
569
610
  const delegate = this.#delegate;
570
- if (delegate === null) return unboundExecute();
571
- return delegate.execute(request);
611
+ return delegate === null ? unboundQuery() : delegate.query(request);
572
612
  }
573
- executePrepared(request) {
613
+ async execute(request) {
574
614
  const delegate = this.#delegate;
575
- if (delegate === null) return unboundExecute();
576
- return delegate.executePrepared(request);
615
+ if (delegate === null) throw driverError("DRIVER.NOT_CONNECTED", USE_BEFORE_CONNECT_MESSAGE);
616
+ return delegate.execute(request);
577
617
  }
578
618
  async explain(request) {
579
619
  const delegate = this.#requireDelegate();
@@ -581,9 +621,6 @@ var PostgresUnboundDriverImpl = class {
581
621
  if (explain === void 0) throw driverError("DRIVER.NOT_CONNECTED", USE_BEFORE_CONNECT_MESSAGE);
582
622
  return explain.call(delegate, request);
583
623
  }
584
- async query(sql, params) {
585
- return this.#requireDelegate().query(sql, params);
586
- }
587
624
  };
588
625
  const postgresRuntimeDriverDescriptor = {
589
626
  ...postgresDriverDescriptorMeta,
@@ -1 +1 @@
1
- {"version":3,"file":"driver__runtime.mjs","names":["#queue","#connection","#onRelease","#onDestroy","#transactionOpen","#onSettled","#settle","#closed","#connectionMutex","#closeWhileHoldingLease","#connected","#connectPromise","#cursorOpts","#preparedStatements","#delegate","#requireDelegate","#wrapConnection"],"sources":["../../../../3-targets/7-drivers/postgres/dist/runtime.mjs"],"sourcesContent":["import { i as postgresDriverDescriptorMeta, n as isPostgresError, r as normalizePgError, t as isAlreadyConnectedError } from \"./normalize-error-CNjgVO71.mjs\";\nimport { Pool } from \"pg\";\nimport Cursor from \"pg-cursor\";\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)) 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 *execute(request) {\n\t\ttry {\n\t\t\tyield* this.runQuery(request);\n\t\t} catch (error) {\n\t\t\tthrow normalizePgError(error);\n\t\t}\n\t}\n\tasync *executePrepared(request) {\n\t\tif (!this.options.preparedStatementsEnabled) {\n\t\t\tyield* this.execute(request);\n\t\t\treturn;\n\t\t}\n\t\tlet handle = request.handle.get();\n\t\tif (handle === void 0) {\n\t\t\thandle = this.options.handleAllocator.mint();\n\t\t\trequest.handle.set(handle);\n\t\t}\n\t\tyield* this.withStaleHandleRetry(request, handle, (h) => this.runQuery(request, h));\n\t}\n\tasync *withStaleHandleRetry(request, handle, attempt) {\n\t\tlet yielded = false;\n\t\ttry {\n\t\t\tfor await (const row of attempt(handle)) {\n\t\t\t\tyielded = true;\n\t\t\t\tyield row;\n\t\t\t}\n\t\t\treturn;\n\t\t} catch (error) {\n\t\t\tif (yielded || !isStalePreparedStatementError(error)) throw normalizePgError(error);\n\t\t\tconst retryHandle = this.options.handleAllocator.mint();\n\t\t\trequest.handle.set(retryHandle);\n\t\t\ttry {\n\t\t\t\tyield* attempt(retryHandle);\n\t\t\t} catch (retryError) {\n\t\t\t\tthrow normalizePgError(retryError);\n\t\t\t}\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\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 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\tfor await (const row of this.executeBuffered(client, request.sql, request.params, name)) yield row;\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\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: (await client.query(text, 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 query(sql, params) {\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 await client.query(sql, params).catch(rethrowNormalizedError);\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 = params ?? [];\n\t\tconst cursor = client.query(name === void 0 ? new Cursor(sql, values) : new NamedCursor({\n\t\t\tname,\n\t\t\ttext: sql,\n\t\t\tvalues\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: params ?? []\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\tfor (const row of result.rows) yield row;\n\t}\n};\nvar PostgresConnectionImpl = class extends PostgresQueryable {\n\t#connection;\n\t#onRelease;\n\t#onDestroy;\n\t#transactionOpen = false;\n\tconstructor(connection, options, onRelease, onDestroy) {\n\t\tsuper(options);\n\t\tthis.#connection = connection;\n\t\tthis.#onRelease = onRelease;\n\t\tthis.#onDestroy = onDestroy;\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.#transactionOpen;\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.#transactionOpen = true;\n\t\treturn new PostgresTransactionImpl(this.#connection, this.options, () => {\n\t\t\tthis.#transactionOpen = 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 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\tconstructor(options) {\n\t\tsuper(buildConnectionOptions(options));\n\t\tthis.directClient = options.connect.client;\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();\n\t\t\t\t} finally {\n\t\t\t\t\treleaseLease();\n\t\t\t\t}\n\t\t\t});\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();\n\t\t} finally {\n\t\t\treleaseLease();\n\t\t}\n\t}\n\tasync #closeWhileHoldingLease() {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tawait this.directClient.end();\n\t\tthis.#connected = false;\n\t}\n\tasync acquireClient() {\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: 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: 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: 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}\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 ALREADY_CONNECTED_MESSAGE = \"Postgres driver already connected. Call close() before reconnecting with a new binding.\";\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 Object.assign(error, {\n\t\tcode,\n\t\tcategory: \"DRIVER\",\n\t\tseverity: \"error\",\n\t\tmessage,\n\t\tdetails\n\t});\n}\nfunction unboundExecute() {\n\treturn { [Symbol.asyncIterator]() {\n\t\treturn { async next() {\n\t\t\tthrow driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\n\t\t} };\n\t} };\n}\nvar PostgresUnboundDriverImpl = class {\n\tfamilyId = \"sql\";\n\ttargetId = \"postgres\";\n\t#delegate = null;\n\t#closed = false;\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\tif (this.#closed) return \"closed\";\n\t\treturn \"unbound\";\n\t}\n\t#requireDelegate() {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) throw driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\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.#closed = false;\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.#closed = true;\n\t\t\t}\n\t\t};\n\t\tconst wrapped = {\n\t\t\tbeginTransaction: connection.beginTransaction.bind(connection),\n\t\t\texecute: connection.execute.bind(connection),\n\t\t\texecutePrepared: connection.executePrepared.bind(connection),\n\t\t\tquery: connection.query.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\tif (delegate !== null) {\n\t\t\tthis.#delegate = null;\n\t\t\tawait delegate.close();\n\t\t}\n\t\tthis.#closed = true;\n\t}\n\texecute(request) {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) return unboundExecute();\n\t\treturn delegate.execute(request);\n\t}\n\texecutePrepared(request) {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) return unboundExecute();\n\t\treturn delegate.executePrepared(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\tasync query(sql, params) {\n\t\treturn this.#requireDelegate().query(sql, params);\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 };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;AAIA,SAAS,kBAAkB,IAAI;CAC9B,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,IAAI,KAAK,WAAW;GACnB,IAAI,KAAK;IACR,OAAO,GAAG;IACV;GACD;GACA,QAAQ,MAAM;EACf,CAAC;CACF,CAAC;AACF;AAGA,IAAI,oBAAoB;;AAExB,IAAI,cAAc,cAAc,OAAO;CACtC;CACA,YAAY,MAAM;EACjB,MAAM,KAAK,MAAM,CAAC,GAAG,KAAK,MAAM,GAAG,KAAK,MAAM;EAC9C,KAAK,OAAO,KAAK;EACjB,KAAK,SAAS,KAAK;CACpB;CACA,YAAY,YAAY;EACvB,MAAM,OAAO;EACb,MAAM,OAAO;EACb,KAAK,QAAQ;EACb,KAAK,aAAa;EAClB,KAAK,UAAU,MAAM;EACrB,IAAI,CAAC,KAAK,iBAAiB,KAAK,OAAO;GACtC,MAAM,eAAe;IACpB,MAAM,KAAK;IACX,MAAM,KAAK;IACX,OAAO,CAAC;GACT;GACA,KAAK,MAAM,cAAc,IAAI;EAC9B;EACA,MAAM,cAAc;GACnB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,QAAQ,KAAK,UAAU,CAAC;EACzB;EACA,KAAK,KAAK,aAAa,IAAI;EAC3B,KAAK,SAAS;GACb,MAAM;GACN,MAAM,KAAK;EACZ,GAAG,IAAI;EACP,KAAK,MAAM;EACX,IAAI,KA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AAiB,CAAC,CAAC,MAAM,KAAK,MAAM;CACjD;AACD;AACA,MAAM,kCAAkC;CACvC,GAAG;CACH,OAAO,SAAS;EACf,OAAO,IAAI,0BAA0B,OAAO;CAC7C;AACD"}
1
+ {"version":3,"file":"driver__runtime.mjs","names":["#queue","#connection","#onRelease","#onDestroy","#transactionOpen","#onSettled","#settle","#closed","#connectionMutex","#closeWhileHoldingLease","#connected","#connectPromise","#cursorOpts","#preparedStatements","#delegate","#requireDelegate","#wrapConnection"],"sources":["../../../../3-targets/7-drivers/postgres/dist/runtime.mjs"],"sourcesContent":["import { i as postgresDriverDescriptorMeta, n as isPostgresError, r as normalizePgError, t as isAlreadyConnectedError } from \"./normalize-error-CNjgVO71.mjs\";\nimport { Pool } from \"pg\";\nimport { blindCast } from \"@internal/utils/casts\";\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\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\tfor await (const row of this.executeBuffered(client, request.sql, request.params, name)) yield blindCast(row);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client);\n\t\t}\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 cursor = client.query(name === void 0 ? new Cursor(sql, values) : new NamedCursor({\n\t\t\tname,\n\t\t\ttext: sql,\n\t\t\tvalues\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};\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\tfor (const row of blindCast(result.rows)) yield row;\n\t}\n};\nvar PostgresConnectionImpl = class extends PostgresQueryable {\n\t#connection;\n\t#onRelease;\n\t#onDestroy;\n\t#transactionOpen = false;\n\tconstructor(connection, options, onRelease, onDestroy) {\n\t\tsuper(options);\n\t\tthis.#connection = connection;\n\t\tthis.#onRelease = onRelease;\n\t\tthis.#onDestroy = onDestroy;\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.#transactionOpen;\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.#transactionOpen = true;\n\t\treturn new PostgresTransactionImpl(this.#connection, this.options, () => {\n\t\t\tthis.#transactionOpen = 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 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\tconstructor(options) {\n\t\tsuper(buildConnectionOptions(options));\n\t\tthis.directClient = options.connect.client;\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();\n\t\t\t\t} finally {\n\t\t\t\t\treleaseLease();\n\t\t\t\t}\n\t\t\t});\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();\n\t\t} finally {\n\t\t\treleaseLease();\n\t\t}\n\t}\n\tasync #closeWhileHoldingLease() {\n\t\tif (this.#closed) return;\n\t\tthis.#closed = true;\n\t\tawait this.directClient.end();\n\t\tthis.#connected = false;\n\t}\n\tasync acquireClient() {\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: 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: 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: 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 ALREADY_CONNECTED_MESSAGE = \"Postgres driver already connected. Call close() before reconnecting with a new binding.\";\nfunction unboundQuery() {\n\treturn { [Symbol.asyncIterator]() {\n\t\treturn { async next() {\n\t\t\tthrow driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\n\t\t} };\n\t} };\n}\nvar PostgresUnboundDriverImpl = class {\n\tfamilyId = \"sql\";\n\ttargetId = \"postgres\";\n\t#delegate = null;\n\t#closed = false;\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\tif (this.#closed) return \"closed\";\n\t\treturn \"unbound\";\n\t}\n\t#requireDelegate() {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) throw driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\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.#closed = false;\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.#closed = true;\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\tif (delegate !== null) {\n\t\t\tthis.#delegate = null;\n\t\t\tawait delegate.close();\n\t\t}\n\t\tthis.#closed = true;\n\t}\n\tquery(request) {\n\t\tconst delegate = this.#delegate;\n\t\treturn delegate === null ? unboundQuery() : delegate.query(request);\n\t}\n\tasync execute(request) {\n\t\tconst delegate = this.#delegate;\n\t\tif (delegate === null) throw driverError(\"DRIVER.NOT_CONNECTED\", USE_BEFORE_CONNECT_MESSAGE);\n\t\treturn delegate.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 };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;AAKA,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,I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AW,QAAQ,MAAM;IAChC,UAAU;KACT,kBAAkB;IACnB;GACD;EACD;EACA,IAAI,WAAW,SAAS,QAAQ,UAAU,WAAW,QAAQ,KAAK,UAAU;EAC5E,OAAO;CACR;CACA,MAAM,QAAQ;EACb,MAAM,WAAW,KAAKO;EACtB,IAAI,aAAa,MAAM;GACtB,KAAKA,YAAY;GACjB,MAAM,SAAS,MAAM;EACtB;EACA,KAAKP,UAAU;CAChB;CACA,MAAM,SAAS;EACd,MAAM,WAAW,KAAKO;EACtB,OAAO,aAAa,OAAO,aAAa,IAAI,SAAS,MAAM,OAAO;CACnE;CACA,MAAM,QAAQ,SAAS;EACtB,MAAM,WAAW,KAAKA;EACtB,IAAI,aAAa,MAAM,MAAM,YAAY,wBAAwB,0BAA0B;EAC3F,OAAO,SAAS,QAAQ,OAAO;CAChC;CACA,MAAM,QAAQ,SAAS;EACtB,MAAM,WAAW,KAAKC,iBAAiB;EACvC,MAAM,UAAU,SAAS;EACzB,IAAI,YAAY,KAAK,GAAG,MAAM,YAAY,wBAAwB,0BAA0B;EAC5F,OAAO,QAAQ,KAAK,UAAU,OAAO;CACtC;AACD;AACA,MAAM,kCAAkC;CACvC,GAAG;CACH,OAAO,SAAS;EACf,OAAO,IAAI,0BAA0B,OAAO;CAC7C;AACD"}
@@ -3,7 +3,7 @@ import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs
3
3
  import { a as validateEnumValueLength, i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from "./sql-utils-BnBlQxyh-DaX9Nb7Z.mjs";
4
4
  import { C as nativeEnumValueExistsAst, D as tableExistsAst, E as rlsPolicyExistsAst, O as tableIsEmptyAst, S as nativeEnumTypeExistsAst, T as rlsEnabledAst, _ as dropIndex$1, a as columnDefaultAst, b as extensionExistsAst, c as columnTypeAst, d as createPolicy, f as createSchema, g as dropDefaultAction, h as disableRowLevelSecurity$1, i as alterTable, l as constraintExistsAst, m as createType, n as alterIndexRename, o as columnExistsAst, p as createTable, r as alterPolicyRename, s as columnNullabilityAst, t as addColumnAction, u as createIndex$1, v as dropPolicy, w as noNullValuesAst, x as indexExistsAst, y as dropType } from "./ddl-BdP4q3KY-Duef4uHw.mjs";
5
5
  import { n as qualifyTableName } from "./planner-sql-checks-DRc_78n8-C9nHOrvU.mjs";
6
- import { n as buildColumnTypeSql } from "./planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs";
6
+ import { n as buildColumnTypeSql } from "./planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs";
7
7
  import { FunctionColumnDefault, LiteralColumnDefault } from "@prisma/orm-family-sql/relational-core/ast";
8
8
  import { blindCast } from "@prisma/orm-framework/utils/casts";
9
9
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
@@ -2006,4 +2006,4 @@ var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
2006
2006
  //#endregion
2007
2007
  export { RenamePostgresRlsPolicyCall as A, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, installExtension as F, postgresDefaultToDdlColumnDefault as I, SetNotNullCall as M, buildTargetDetails as N, RawSqlCall as O, createExtension as P, DropIndexCall as S, DropPostgresRlsPolicyCall as T, DisableRowLevelSecurityCall as _, AddNotNullColumnDirectCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddNativeEnumValueCall as i, SetDefaultCall as j, RenameIndexCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddNotNullColumnWithTempDefaultCall as o, CreatePostgresRlsPolicyCall as p, AddForeignKeyCall as r, AddPrimaryKeyCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y };
2008
2008
 
2009
- //# sourceMappingURL=op-factory-call-DifL68KT-Bo6pxs-R.mjs.map
2009
+ //# sourceMappingURL=op-factory-call-DifL68KT-CNFEDNsf.mjs.map