@prisma-next/target-postgres 0.14.0-dev.4 → 0.14.0-dev.41

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 (191) hide show
  1. package/dist/authoring-BX1WHIdN.mjs +220 -0
  2. package/dist/authoring-BX1WHIdN.mjs.map +1 -0
  3. package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
  4. package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
  5. package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
  6. package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
  7. package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-CueCoGD0.d.mts} +2 -2
  8. package/dist/{codec-types-DHCkwPKE.d.mts.map → codec-types-CueCoGD0.d.mts.map} +1 -1
  9. package/dist/codec-types.d.mts +1 -1
  10. package/dist/{codecs--0A5_4Bq.d.mts → codecs-Ca8upop6.d.mts} +12 -1
  11. package/dist/codecs-Ca8upop6.d.mts.map +1 -0
  12. package/dist/codecs.d.mts +1 -1
  13. package/dist/codecs.mjs +34 -1
  14. package/dist/codecs.mjs.map +1 -1
  15. package/dist/contract-free.d.mts +8 -3
  16. package/dist/contract-free.d.mts.map +1 -1
  17. package/dist/contract-free.mjs +3 -3
  18. package/dist/control.d.mts +1 -1
  19. package/dist/control.d.mts.map +1 -1
  20. package/dist/control.mjs +639 -21
  21. package/dist/control.mjs.map +1 -1
  22. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  23. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-qKy1U5V9.d.mts} +2 -2
  24. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-qKy1U5V9.d.mts.map} +1 -1
  25. package/dist/data-transform.d.mts +1 -1
  26. package/dist/{ddl-QDyOSeLc.mjs → ddl-BmLIe1z_.mjs} +62 -5
  27. package/dist/ddl-BmLIe1z_.mjs.map +1 -0
  28. package/dist/ddl.d.mts +3 -2
  29. package/dist/ddl.mjs +2 -2
  30. package/dist/{default-normalizer-DyyCHQWs.mjs → default-normalizer-Dug8Fez9.mjs} +119 -2
  31. package/dist/default-normalizer-Dug8Fez9.mjs.map +1 -0
  32. package/dist/default-normalizer.d.mts +1 -1
  33. package/dist/default-normalizer.d.mts.map +1 -1
  34. package/dist/default-normalizer.mjs +1 -1
  35. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
  36. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
  37. package/dist/descriptor-meta-tjatyhtZ.mjs +18 -0
  38. package/dist/descriptor-meta-tjatyhtZ.mjs.map +1 -0
  39. package/dist/{issue-planner-DL6g3CmE.mjs → issue-planner-DbFvaAgu.mjs} +35 -10
  40. package/dist/issue-planner-DbFvaAgu.mjs.map +1 -0
  41. package/dist/issue-planner.d.mts +3 -3
  42. package/dist/issue-planner.d.mts.map +1 -1
  43. package/dist/issue-planner.mjs +1 -1
  44. package/dist/migration.d.mts +5 -5
  45. package/dist/migration.mjs +4 -4
  46. package/dist/nodes-CSkPX3rI.d.mts +120 -0
  47. package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
  48. package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
  49. package/dist/nodes-Dh__NS58.mjs.map +1 -0
  50. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CJWUxyUW.d.mts} +44 -13
  51. package/dist/op-factory-call-CJWUxyUW.d.mts.map +1 -0
  52. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-t65c4jyY.mjs} +201 -28
  53. package/dist/op-factory-call-t65c4jyY.mjs.map +1 -0
  54. package/dist/op-factory-call.d.mts +1 -1
  55. package/dist/op-factory-call.mjs +1 -1
  56. package/dist/pack.d.mts +74 -2
  57. package/dist/pack.d.mts.map +1 -1
  58. package/dist/pack.mjs +1 -1
  59. package/dist/planner-CG2pLHk-.mjs +640 -0
  60. package/dist/planner-CG2pLHk-.mjs.map +1 -0
  61. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  62. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  63. package/dist/planner-ddl-builders.d.mts +2 -4
  64. package/dist/planner-ddl-builders.d.mts.map +1 -1
  65. package/dist/planner-ddl-builders.mjs +2 -2
  66. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-BolD0Mvc.mjs} +3 -3
  67. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-BolD0Mvc.mjs.map} +1 -1
  68. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-Cz9--XOT.d.mts} +4 -4
  69. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-Cz9--XOT.d.mts.map} +1 -1
  70. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  71. package/dist/planner-produced-postgres-migration.mjs +1 -1
  72. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-DE9c4519.mjs} +2 -2
  73. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-DE9c4519.mjs.map} +1 -1
  74. package/dist/planner-sql-checks.mjs +1 -1
  75. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  76. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  77. package/dist/planner-target-details.d.mts +1 -1
  78. package/dist/planner.d.mts +82 -4
  79. package/dist/planner.d.mts.map +1 -1
  80. package/dist/planner.mjs +2 -2
  81. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-BegduLr6.mjs} +50 -23
  82. package/dist/postgres-contract-view-BegduLr6.mjs.map +1 -0
  83. package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
  84. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
  85. package/dist/postgres-database-schema-node-os8ogEap.d.mts +183 -0
  86. package/dist/postgres-database-schema-node-os8ogEap.d.mts.map +1 -0
  87. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-BfMmK6tv.mjs} +21 -2
  88. package/dist/postgres-migration-BfMmK6tv.mjs.map +1 -0
  89. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-D7kNVWVG.d.mts} +19 -6
  90. package/dist/postgres-migration-D7kNVWVG.d.mts.map +1 -0
  91. package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
  92. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  93. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-BLIHBEfX.mjs} +108 -5
  94. package/dist/postgres-schema-BLIHBEfX.mjs.map +1 -0
  95. package/dist/postgres-schema-BywoeKlt.d.mts +189 -0
  96. package/dist/postgres-schema-BywoeKlt.d.mts.map +1 -0
  97. package/dist/postgres-table-schema-node-1nNc8XDT.mjs +248 -0
  98. package/dist/postgres-table-schema-node-1nNc8XDT.mjs.map +1 -0
  99. package/dist/render-ops.d.mts +1 -1
  100. package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
  101. package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
  102. package/dist/render-typescript.mjs +1 -1
  103. package/dist/resolve-ddl-schema-CL1RR1mx.mjs +20 -0
  104. package/dist/resolve-ddl-schema-CL1RR1mx.mjs.map +1 -0
  105. package/dist/rls-canonicalize.d.mts +2 -0
  106. package/dist/rls-canonicalize.mjs +2 -0
  107. package/dist/runtime.d.mts +7 -6
  108. package/dist/runtime.d.mts.map +1 -1
  109. package/dist/runtime.mjs +3 -3
  110. package/dist/runtime.mjs.map +1 -1
  111. package/dist/schema-ir-annotations.d.mts +14 -0
  112. package/dist/schema-ir-annotations.d.mts.map +1 -0
  113. package/dist/schema-ir-annotations.mjs +2 -0
  114. package/dist/types.d.mts +4 -140
  115. package/dist/types.mjs +3 -2
  116. package/package.json +22 -17
  117. package/src/contract-free/checks.ts +73 -0
  118. package/src/contract-free/ddl.ts +45 -1
  119. package/src/core/authoring.ts +115 -1
  120. package/src/core/codecs.ts +35 -1
  121. package/src/core/ddl/nodes.ts +94 -2
  122. package/src/core/default-normalizer.ts +122 -2
  123. package/src/core/descriptor-meta.ts +4 -0
  124. package/src/core/entity-kinds.ts +16 -0
  125. package/src/core/migrations/bound-schema.ts +10 -0
  126. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +125 -0
  127. package/src/core/migrations/control-policy.ts +3 -0
  128. package/src/core/migrations/diff-database-schema.ts +191 -0
  129. package/src/core/migrations/issue-planner.ts +44 -3
  130. package/src/core/migrations/op-factory-call.ts +109 -21
  131. package/src/core/migrations/operations/columns.ts +24 -12
  132. package/src/core/migrations/operations/data-transform.ts +6 -0
  133. package/src/core/migrations/operations/rls.ts +106 -0
  134. package/src/core/migrations/operations/shared.ts +0 -30
  135. package/src/core/migrations/planner-ddl-builders.ts +15 -56
  136. package/src/core/migrations/planner-recipes.ts +31 -13
  137. package/src/core/migrations/planner-strategies.ts +3 -11
  138. package/src/core/migrations/planner-target-details.ts +3 -1
  139. package/src/core/migrations/planner.ts +165 -33
  140. package/src/core/migrations/postgres-migration.ts +34 -4
  141. package/src/core/migrations/render-typescript.ts +42 -15
  142. package/src/core/migrations/resolve-ddl-schema.ts +24 -0
  143. package/src/core/migrations/runner.ts +13 -16
  144. package/src/core/migrations/verify-postgres-namespaces.ts +24 -19
  145. package/src/core/postgres-contract-serializer.ts +50 -33
  146. package/src/core/postgres-contract-view.ts +48 -0
  147. package/src/core/postgres-rls-policy.ts +64 -0
  148. package/src/core/postgres-role.ts +37 -0
  149. package/src/core/postgres-schema.ts +37 -13
  150. package/src/core/postgres-validators.ts +20 -0
  151. package/src/core/psl-infer/infer-psl-contract.ts +834 -0
  152. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  153. package/src/core/psl-infer/postgres-type-map.ts +157 -0
  154. package/src/core/rls/canonicalize.ts +48 -0
  155. package/src/core/schema-ir/postgres-database-schema-node.ts +63 -0
  156. package/src/core/schema-ir/postgres-namespace-schema-node.ts +61 -0
  157. package/src/core/schema-ir/postgres-policy-schema-node.ts +93 -0
  158. package/src/core/schema-ir/postgres-role-schema-node.ts +66 -0
  159. package/src/core/schema-ir/postgres-table-schema-node.ts +107 -0
  160. package/src/core/schema-ir/schema-node-kinds.ts +28 -0
  161. package/src/exports/contract-free.ts +7 -1
  162. package/src/exports/control.ts +39 -12
  163. package/src/exports/ddl.ts +4 -0
  164. package/src/exports/migration.ts +1 -0
  165. package/src/exports/planner-ddl-builders.ts +0 -2
  166. package/src/exports/planner.ts +2 -0
  167. package/src/exports/rls-canonicalize.ts +6 -0
  168. package/src/exports/runtime.ts +1 -0
  169. package/src/exports/schema-ir-annotations.ts +1 -0
  170. package/src/exports/types.ts +28 -0
  171. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  172. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  173. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  174. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  175. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  176. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  177. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  178. package/dist/nodes-pLeLgdis.d.mts +0 -67
  179. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  180. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  181. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  182. package/dist/planner-Bs_baQax.mjs +0 -324
  183. package/dist/planner-Bs_baQax.mjs.map +0 -1
  184. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  185. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  186. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  187. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  188. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  189. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  190. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  191. package/dist/types.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-table-schema-node-1nNc8XDT.mjs","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts","../src/core/schema-ir/postgres-database-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts"],"sourcesContent":["import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements\n * `DiffableNode` (the five `Postgres*SchemaNode` classes). `SqlSchemaIRNode`\n * alone is not a `DiffableNode` — its relational subclasses (`SqlColumnIR`, …)\n * carry no `id`/`isEqualTo`/`children` — so this intersection is the honest node\n * type the differ produces and the planner consumes (`SchemaDiff<SqlSchemaDiffNode>`).\n */\nexport type SqlSchemaDiffNode = SqlSchemaIRNode & DiffableNode;\n\n/**\n * The `nodeKind` discriminant for each Postgres schema-diff node. Each node\n * carries a unique value; the static `is`/`assert` guards compare against these\n * identifiers rather than spelling the string inline or using `instanceof`. The\n * field is an enumerable own property carried on every node instance.\n */\nexport const PostgresSchemaNodeKind = {\n database: 'postgres-database',\n namespace: 'postgres-namespace',\n table: 'postgres-table',\n policy: 'postgres-policy',\n role: 'postgres-role',\n} as const;\n\nexport type PostgresSchemaNodeKind =\n (typeof PostgresSchemaNodeKind)[keyof typeof PostgresSchemaNodeKind];\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNamespaceSchemaNode } from './postgres-namespace-schema-node';\nimport type { PostgresRoleSchemaNode } from './postgres-role-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresDatabaseSchemaNodeInput {\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n}\n\n/**\n * The root of the Postgres schema-diff tree: one node per database.\n *\n * `id` is the fixed sentinel `'database'` — the root has no siblings and\n * the value is never emitted into migration paths. `isEqualTo` is identity\n * (roots always share the `'database'` id). `children()` returns namespace\n * nodes only; roles are held on the root but not yielded (role diffing is a\n * later slice).\n */\nexport class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.database;\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n\n constructor(input: PostgresDatabaseSchemaNodeInput) {\n super();\n this.namespaces = Object.freeze({ ...input.namespaces });\n this.roles = Object.freeze([...input.roles]);\n this.existingSchemas = Object.freeze([...input.existingSchemas]);\n this.pgVersion = input.pgVersion;\n freezeNode(this);\n }\n\n get id(): string {\n return 'database';\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return Object.values(this.namespaces);\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.database;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode {\n if (!PostgresDatabaseSchemaNode.is(node)) {\n throw new Error(\n `Expected a PostgresDatabaseSchemaNode but got nodeKind=${node.nodeKind ?? 'undefined'}`,\n );\n }\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresTableSchemaNode } from './postgres-table-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresNamespaceSchemaNodeInput {\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n readonly nativeEnumTypeNames: readonly string[];\n}\n\n/**\n * One-per-Postgres-schema diff-tree node. Groups the tables belonging to a\n * single namespace and satisfies the `SqlSchemaIR` shape so legacy per-schema\n * consumers (verifySqlSchema, the relational planner, toSchemaView) can\n * accept it unchanged in Unit 6.\n *\n * `id` is the schema name. `isEqualTo` is identity — two namespace nodes are\n * equal iff their ids (schema names) match. `children()` returns the table\n * nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`\n * field, not an annotations bag.\n */\nexport class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.namespace;\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n readonly nativeEnumTypeNames: readonly string[];\n\n constructor(input: PostgresNamespaceSchemaNodeInput) {\n super();\n this.schemaName = input.schemaName;\n this.tables = Object.freeze({ ...input.tables });\n this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);\n freezeNode(this);\n }\n\n get id(): string {\n return this.schemaName;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return Object.values(this.tables);\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.namespace;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode {\n if (!PostgresNamespaceSchemaNode.is(node)) {\n throw new Error(\n `Expected a PostgresNamespaceSchemaNode but got nodeKind=${node.nodeKind ?? 'undefined'}`,\n );\n }\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { RlsPolicyOperation } from '../postgres-rls-policy';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresPolicySchemaNodeInput {\n /** Full wire name: `<prefix>_<8hex>`. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n}\n\n/**\n * Schema-diff leaf node for a Postgres row-level security policy.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRlsPolicy` contract entities / introspected rows.\n *\n * `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is\n * body-equality. `isEqualTo` compares names only — never byte-compare predicate\n * bodies, because Postgres reprints them.\n */\nexport class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.policy;\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n\n constructor(input: PostgresPolicySchemaNodeInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-policy kinds'\n >(other);\n PostgresPolicySchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.policy;\n }\n\n static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode {\n if (node === undefined || !PostgresPolicySchemaNode.is(node)) {\n throw new Error(\n `Expected a PostgresPolicySchemaNode but got nodeKind=${node?.nodeKind ?? 'undefined'}`,\n );\n }\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresRoleSchemaNodeInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; callers pass\n * `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n}\n\n/**\n * Schema-diff leaf node for a Postgres database role.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRole` contract entities / introspected rows.\n *\n * Roles are cluster-scoped, so `id` is the role name alone. `isEqualTo` compares\n * names — name-equality is role-equality for cluster-scoped objects.\n */\nexport class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.role;\n readonly name: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRoleSchemaNodeInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-role kinds'\n >(other);\n PostgresRoleSchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.role;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode {\n if (!PostgresRoleSchemaNode.is(node)) {\n throw new Error(\n `Expected a PostgresRoleSchemaNode but got nodeKind=${node.nodeKind ?? 'undefined'}`,\n );\n }\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport {\n PrimaryKey,\n type SqlAnnotations,\n SqlCheckConstraintIR,\n SqlColumnIR,\n SqlForeignKeyIR,\n SqlIndexIR,\n SqlSchemaIRNode,\n type SqlTableIRInput,\n SqlUniqueIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresPolicySchemaNode } from './postgres-policy-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresTableSchemaNodeInput extends SqlTableIRInput {\n readonly policies?: readonly PostgresPolicySchemaNode[];\n}\n\n/**\n * Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields\n * plus `policies`, and implements `DiffableNode` so the table instance is\n * directly the diff-tree node — no separate wrapper needed.\n *\n * Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because\n * `SqlTableIR` calls `freezeNode` in its own constructor, which prevents\n * subclass field initialisation.\n *\n * `id` is the table name. `children()` returns the policy nodes on this table.\n * `isEqualTo` is identity — two table nodes are equal iff their ids (names)\n * match. Columns are not compared here; they become child nodes later.\n */\nexport class PostgresTableSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.table;\n readonly name: string;\n readonly columns: Readonly<Record<string, SqlColumnIR>>;\n readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;\n readonly uniques: ReadonlyArray<SqlUniqueIR>;\n readonly indexes: ReadonlyArray<SqlIndexIR>;\n declare readonly primaryKey?: PrimaryKey;\n declare readonly annotations?: SqlAnnotations;\n declare readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;\n readonly policies: readonly PostgresPolicySchemaNode[];\n\n constructor(input: PostgresTableSchemaNodeInput) {\n super();\n this.name = input.name;\n this.columns = Object.freeze(\n Object.fromEntries(\n Object.entries(input.columns).map(([key, col]) => [\n key,\n col instanceof SqlColumnIR ? col : new SqlColumnIR(col),\n ]),\n ),\n );\n this.foreignKeys = Object.freeze(\n input.foreignKeys.map((fk) => (fk instanceof SqlForeignKeyIR ? fk : new SqlForeignKeyIR(fk))),\n );\n this.uniques = Object.freeze(\n input.uniques.map((u) => (u instanceof SqlUniqueIR ? u : new SqlUniqueIR(u))),\n );\n this.indexes = Object.freeze(\n input.indexes.map((i) => (i instanceof SqlIndexIR ? i : new SqlIndexIR(i))),\n );\n if (input.primaryKey !== undefined) {\n this.primaryKey =\n input.primaryKey instanceof PrimaryKey\n ? input.primaryKey\n : new PrimaryKey(input.primaryKey);\n }\n if (input.annotations !== undefined) this.annotations = input.annotations;\n if (input.checks !== undefined && input.checks.length > 0) {\n this.checks = Object.freeze(\n input.checks.map((c) =>\n c instanceof SqlCheckConstraintIR ? c : new SqlCheckConstraintIR(c),\n ),\n );\n }\n this.policies = Object.freeze([...(input.policies ?? [])]);\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return this.policies;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresTableSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.table;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresTableSchemaNode {\n if (!PostgresTableSchemaNode.is(node)) {\n throw new Error(\n `Expected a PostgresTableSchemaNode but got nodeKind=${node.nodeKind ?? 'undefined'}`,\n );\n }\n }\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { OpFactoryCall } from "@prisma-next/framework-components/control";
4
4
  import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
@@ -27,14 +27,18 @@ const BASE_IMPORTS = [{
27
27
  symbol: "MigrationCLI"
28
28
  }];
29
29
  function renderCallsToTypeScript(calls, meta) {
30
- const imports = buildImports(calls);
30
+ const imports = buildImports(calls, meta);
31
31
  const operationsBody = calls.map((c) => renderCall(c)).join(",\n");
32
+ const hasStart = meta.from !== null;
33
+ const startField = hasStart ? [" override readonly startContractJson = startContract;"] : [];
32
34
  return [
33
35
  shebangLineFor(detectScaffoldRuntime()),
34
36
  imports,
35
37
  "",
36
- "export default class M extends Migration {",
37
- buildDescribeMethod(meta),
38
+ `export default class M extends Migration<${hasStart ? "Start" : "never"}, End> {`,
39
+ ...startField,
40
+ " override readonly endContractJson = endContract;",
41
+ "",
38
42
  " override get operations() {",
39
43
  " return [",
40
44
  indent(operationsBody, 6),
@@ -49,21 +53,46 @@ function renderCallsToTypeScript(calls, meta) {
49
53
  function renderCall(call) {
50
54
  return call.renderTypeScript();
51
55
  }
52
- function buildImports(calls) {
53
- const requirements = [...BASE_IMPORTS];
56
+ function buildImports(calls, meta) {
57
+ const requirements = [...BASE_IMPORTS, ...contractImports(meta)];
54
58
  for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
55
59
  return renderImports(requirements);
56
60
  }
57
- function buildDescribeMethod(meta) {
58
- const lines = [];
59
- lines.push(" override describe() {");
60
- lines.push(" return {");
61
- lines.push(` from: ${JSON.stringify(meta.from)},`);
62
- lines.push(` to: ${JSON.stringify(meta.to)},`);
63
- lines.push(" };");
64
- lines.push(" }");
65
- lines.push("");
66
- return lines.join("\n");
61
+ /**
62
+ * The committed contract-JSON imports the scaffold reads its from/to identity
63
+ * from. `end-contract.json` is always present; `start-contract.json` is added
64
+ * only for a non-baseline migration (`meta.from !== null`). The matching
65
+ * `Contract` type imports (aliased `Start`/`End`) feed the
66
+ * `Migration<Start, End>` generics. Baseline emits `Migration<never, End>` with
67
+ * no start imports — `never` is the honest "no prior contract" Start.
68
+ */
69
+ function contractImports(meta) {
70
+ const reqs = [{
71
+ moduleSpecifier: "./end-contract.json",
72
+ symbol: "endContract",
73
+ kind: "default",
74
+ attributes: { type: "json" }
75
+ }, {
76
+ moduleSpecifier: "./end-contract",
77
+ symbol: "Contract",
78
+ alias: "End",
79
+ typeOnly: true
80
+ }];
81
+ if (meta.from !== null) {
82
+ reqs.push({
83
+ moduleSpecifier: "./start-contract.json",
84
+ symbol: "startContract",
85
+ kind: "default",
86
+ attributes: { type: "json" }
87
+ });
88
+ reqs.push({
89
+ moduleSpecifier: "./start-contract",
90
+ symbol: "Contract",
91
+ alias: "Start",
92
+ typeOnly: true
93
+ });
94
+ }
95
+ return reqs;
67
96
  }
68
97
  function indent(text, spaces) {
69
98
  const pad = " ".repeat(spaces);
@@ -72,4 +101,4 @@ function indent(text, spaces) {
72
101
  //#endregion
73
102
  export { renderCallsToTypeScript as t };
74
103
 
75
- //# sourceMappingURL=render-typescript-KMgosran.mjs.map
104
+ //# sourceMappingURL=render-typescript-7yqILcwr.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-7yqILcwr.mjs","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `OpFactoryCall` renders itself via `renderTypeScript()` and\n * declares its own `importRequirements()`; this file just composes the module\n * source around those contributions. The design mirrors the Mongo target's\n * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required\n * (different factory module specifiers, different base-class name) but the\n * shape is, so future consolidation to a framework-level helper is mechanical.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/postgres/migration` so an authored Postgres\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint:\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `PostgresPlanTargetDetails` and the abstract `targetId`\n * to `'postgres'`, so user-authored migrations don't need to thread\n * target-details or redeclare `targetId`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n * The migration file owns this dependency directly: pulling CLI\n * machinery in at script run time is acceptable because the script's\n * whole purpose is to be invoked from the project that owns the\n * config.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls, meta);\n const operationsBody = calls.map((c) => renderCall(c)).join(',\\n');\n const hasStart = meta.from !== null;\n const startField = hasStart ? [' override readonly startContractJson = startContract;'] : [];\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n `export default class M extends Migration<${hasStart ? 'Start' : 'never'}, End> {`,\n ...startField,\n ' override readonly endContractJson = endContract;',\n '',\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction renderCall(call: OpFactoryCall): string {\n return call.renderTypeScript();\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>, meta: RenderMigrationMeta): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS, ...contractImports(meta)];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\n/**\n * The committed contract-JSON imports the scaffold reads its from/to identity\n * from. `end-contract.json` is always present; `start-contract.json` is added\n * only for a non-baseline migration (`meta.from !== null`). The matching\n * `Contract` type imports (aliased `Start`/`End`) feed the\n * `Migration<Start, End>` generics. Baseline emits `Migration<never, End>` with\n * no start imports — `never` is the honest \"no prior contract\" Start.\n */\nfunction contractImports(meta: RenderMigrationMeta): readonly ImportRequirement[] {\n const reqs: ImportRequirement[] = [\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n { moduleSpecifier: './end-contract', symbol: 'Contract', alias: 'End', typeOnly: true },\n ];\n if (meta.from !== null) {\n reqs.push({\n moduleSpecifier: './start-contract.json',\n symbol: 'startContract',\n kind: 'default',\n attributes: { type: 'json' },\n });\n reqs.push({\n moduleSpecifier: './start-contract',\n symbol: 'Contract',\n alias: 'Start',\n typeOnly: true,\n });\n }\n return reqs;\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAmC,QAAQ;AAAY,GAC1E;CAAE,iBAAiB;CAAmC,QAAQ;AAAe,CAC/E;AAEA,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,OAAO,IAAI;CACxC,MAAM,iBAAiB,MAAM,KAAK,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;CACjE,MAAM,WAAW,KAAK,SAAS;CAC/B,MAAM,aAAa,WAAW,CAAC,wDAAwD,IAAI,CAAC;CAE5F,OAAO;EACL,eAAe,sBAAsB,CAAC;EACtC;EACA;EACA,4CAA4C,WAAW,UAAU,QAAQ;EACzE,GAAG;EACH;EACA;EACA;EACA;EACA,OAAO,gBAAgB,CAAC;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,WAAW,MAA6B;CAC/C,OAAO,KAAK,iBAAiB;AAC/B;AAEA,SAAS,aAAa,OAAqC,MAAmC;CAC5F,MAAM,eAAoC,CAAC,GAAG,cAAc,GAAG,gBAAgB,IAAI,CAAC;CACpF,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,mBAAmB,GACxC,aAAa,KAAK,GAAG;CAGzB,OAAO,cAAc,YAAY;AACnC;;;;;;;;;AAUA,SAAS,gBAAgB,MAAyD;CAChF,MAAM,OAA4B,CAChC;EACE,iBAAiB;EACjB,QAAQ;EACR,MAAM;EACN,YAAY,EAAE,MAAM,OAAO;CAC7B,GACA;EAAE,iBAAiB;EAAkB,QAAQ;EAAY,OAAO;EAAO,UAAU;CAAK,CACxF;CACA,IAAI,KAAK,SAAS,MAAM;EACtB,KAAK,KAAK;GACR,iBAAiB;GACjB,QAAQ;GACR,MAAM;GACN,YAAY,EAAE,MAAM,OAAO;EAC7B,CAAC;EACD,KAAK,KAAK;GACR,iBAAiB;GACjB,QAAQ;GACR,OAAO;GACP,UAAU;EACZ,CAAC;CACH;CACA,OAAO;AACT;AAEA,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,MAAM;CAC7B,OAAO,KACJ,MAAM,IAAI,CAAC,CACX,KAAK,SAAU,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,IAAK,CAAC,CACrD,KAAK,IAAI;AACd"}
@@ -1,2 +1,2 @@
1
- import { t as renderCallsToTypeScript } from "./render-typescript-KMgosran.mjs";
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-7yqILcwr.mjs";
2
2
  export { renderCallsToTypeScript };
@@ -0,0 +1,20 @@
1
+ import { r as isPostgresSchema } from "./postgres-schema-BLIHBEfX.mjs";
2
+ import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
3
+ //#region src/core/migrations/resolve-ddl-schema.ts
4
+ /**
5
+ * Given the contract's storage and a namespace id, returns the live Postgres
6
+ * DDL schema name that namespace maps to. A named Postgres namespace dispatches
7
+ * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to `public`
8
+ * (the search-path default for offline planning); a bare object payload (used
9
+ * by some tests) falls back to the namespace id itself.
10
+ */
11
+ function resolveDdlSchemaForNamespaceStorage(storage, namespaceId) {
12
+ if (namespaceId === UNBOUND_NAMESPACE_ID) return "public";
13
+ const namespace = storage.namespaces[namespaceId];
14
+ if (namespace && isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);
15
+ return namespaceId;
16
+ }
17
+ //#endregion
18
+ export { resolveDdlSchemaForNamespaceStorage as t };
19
+
20
+ //# sourceMappingURL=resolve-ddl-schema-CL1RR1mx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-ddl-schema-CL1RR1mx.mjs","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { isPostgresSchema } from '../postgres-schema';\n\n/**\n * Given the contract's storage and a namespace id, returns the live Postgres\n * DDL schema name that namespace maps to. A named Postgres namespace dispatches\n * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to `public`\n * (the search-path default for offline planning); a bare object payload (used\n * by some tests) falls back to the namespace id itself.\n */\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return 'public';\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,oCACd,SACA,aACQ;CACR,IAAI,gBAAgB,sBAClB,OAAO;CAET,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,aAAa,iBAAiB,SAAS,GACzC,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT"}
@@ -0,0 +1,2 @@
1
+ import { i as normalizePredicate, n as RlsPolicyOperation, r as computeContentHash, t as ContentHashParts } from "./canonicalize-CAbXtVtB.mjs";
2
+ export { type ContentHashParts, type RlsPolicyOperation, computeContentHash, normalizePredicate };
@@ -0,0 +1,2 @@
1
+ import { n as normalizePredicate, t as computeContentHash } from "./canonicalize-Bn3BM1Cn.mjs";
2
+ export { computeContentHash, normalizePredicate };
@@ -1,6 +1,7 @@
1
+ import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
1
2
  import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
2
- import { Namespace } from "@prisma-next/framework-components/ir";
3
- import { SqlNamespaceTablesInput, SqlStorage } from "@prisma-next/sql-contract/types";
3
+ import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir";
4
+ import { SqlNamespaceInput, SqlStorage } from "@prisma-next/sql-contract/types";
4
5
  import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
5
6
  import { Contract } from "@prisma-next/contract/types";
6
7
  import { RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
@@ -8,11 +9,11 @@ import { JsonObject } from "@prisma-next/utils/json";
8
9
 
9
10
  //#region src/core/postgres-contract-serializer.d.ts
10
11
  declare class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
11
- constructor();
12
- protected get defaultNamespaceId(): string;
13
- protected hydrateSqlNamespaceEntry(nsId: string, raw: Namespace | Record<string, unknown>): Namespace | SqlNamespaceTablesInput;
12
+ constructor(extraPackEntityKinds?: readonly AnyEntityKindDescriptor[]);
13
+ protected hydrateSqlNamespaceEntry(nsId: string, raw: Record<string, unknown>): Namespace | SqlNamespaceInput;
14
14
  serializeContract(contract: Contract<SqlStorage>): JsonObject;
15
15
  private serializePostgresNamespace;
16
+ private serializeJsonObject;
16
17
  private serializeJsonValue;
17
18
  }
18
19
  //#endregion
@@ -28,5 +29,5 @@ declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'p
28
29
  readonly codecs: () => readonly AnyCodecDescriptor[];
29
30
  };
30
31
  //#endregion
31
- export { PostgresContractSerializer, PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
32
+ export { PostgresContractSerializer, PostgresContractView, PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
32
33
  //# sourceMappingURL=runtime.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAkEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;gBAM1D,kBAAA;EAAA,UAIJ,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA0BN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QAyBA,kBAAA;AAAA;;;UChKO,6BAAA,SAAsC,qBAAqB;;;;;ADyD5E;;cCjDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;;cAqEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;cACrE,oBAAA,YAA+B,uBAAA;EAAA,UAKxB,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,MAAA,oBACJ,SAAA,GAAY,iBAAA;EAyBN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QA0CpD,0BAAA;EAAA,QAgCA,mBAAA;EAAA,QAOA,kBAAA;AAAA;;;UC9KO,6BAAA,SAAsC,qBAAqB;;;;;AD2D5E;;cCnDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { n as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-CpGygXpI.mjs";
2
- import { t as PostgresContractSerializer } from "./postgres-contract-serializer-k3TAcPMY.mjs";
1
+ import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-UwYdV8fD.mjs";
2
+ import { n as PostgresContractSerializer, t as PostgresContractView } from "./postgres-contract-view-BegduLr6.mjs";
3
3
  //#region src/exports/runtime.ts
4
4
  /**
5
5
  * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
@@ -18,6 +18,6 @@ const postgresRuntimeTargetDescriptor = {
18
18
  }
19
19
  };
20
20
  //#endregion
21
- export { PostgresContractSerializer, postgresRuntimeTargetDescriptor as default };
21
+ export { PostgresContractSerializer, PostgresContractView, postgresRuntimeTargetDescriptor as default };
22
22
 
23
23
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMetaRuntime } from '../core/descriptor-meta-runtime';\n\nexport { PostgresContractSerializer } from '../core/postgres-contract-serializer';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMetaRuntime,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;AAiBA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,CAAC;CACf,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMetaRuntime } from '../core/descriptor-meta-runtime';\n\nexport { PostgresContractSerializer } from '../core/postgres-contract-serializer';\nexport { PostgresContractView } from '../core/postgres-contract-view';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMetaRuntime,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;AAkBA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,CAAC;CACf,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;AACF"}
@@ -0,0 +1,14 @@
1
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
2
+
3
+ //#region src/core/migrations/resolve-ddl-schema.d.ts
4
+ /**
5
+ * Given the contract's storage and a namespace id, returns the live Postgres
6
+ * DDL schema name that namespace maps to. A named Postgres namespace dispatches
7
+ * to its `ddlSchemaName(storage)`; the unbound sentinel resolves to `public`
8
+ * (the search-path default for offline planning); a bare object payload (used
9
+ * by some tests) falls back to the namespace id itself.
10
+ */
11
+ declare function resolveDdlSchemaForNamespaceStorage(storage: SqlStorage, namespaceId: string): string;
12
+ //#endregion
13
+ export { resolveDdlSchemaForNamespaceStorage };
14
+ //# sourceMappingURL=schema-ir-annotations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-ir-annotations.d.mts","names":[],"sources":["../src/core/migrations/resolve-ddl-schema.ts"],"mappings":";;;;;AAWA;;;;;iBAAgB,mCAAA,CACd,OAAA,EAAS,UAAU,EACnB,WAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-CL1RR1mx.mjs";
2
+ export { resolveDdlSchemaForNamespaceStorage };
package/dist/types.d.mts CHANGED
@@ -1,141 +1,5 @@
1
- import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
1
+ import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.mjs";
2
2
  import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
3
- import { NamespaceBase } from "@prisma-next/framework-components/ir";
4
- import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
5
- import { SqlNamespaceEntries, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
6
-
7
- //#region src/core/postgres-schema.d.ts
8
- interface PostgresSchemaInput {
9
- readonly id: string;
10
- readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
11
- }
12
- /**
13
- * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
14
- * SCHEMA …`). Each Postgres `SqlStorage` carries a
15
- * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
16
- * the Postgres PSL interpreter from `namespace { … }` AST buckets.
17
- *
18
- * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
19
- * emission is the rendering seam: DDL / SQL emission asks the namespace
20
- * for its qualifier (`"<schema>"`) or for a qualified table name
21
- * (`"<schema>"."<table>"`) and consumes the result polymorphically.
22
- * The unbound singleton below overrides these methods to elide the
23
- * prefix entirely — call sites stay polymorphic and never branch on
24
- * `id === UNBOUND_NAMESPACE_ID`.
25
- */
26
- declare class PostgresSchema extends NamespaceBase {
27
- /**
28
- * Stable singleton reference for the late-bound slot. Materialised
29
- * lazily below the singleton subclass declaration so the static
30
- * initialiser sees the subclass before assigning. Consumers always
31
- * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
32
- * — same identity).
33
- */
34
- static unbound: PostgresUnboundSchema;
35
- readonly kind: 'schema';
36
- readonly id: string;
37
- readonly entries: SqlNamespaceEntries;
38
- constructor(input: PostgresSchemaInput);
39
- get table(): Readonly<Record<string, StorageTable>>;
40
- get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
41
- /**
42
- * The bare schema qualifier as it would appear in a rendered SQL
43
- * fragment (already quoted). The unbound-schema singleton overrides
44
- * this to return `''`.
45
- */
46
- qualifier(): string;
47
- /**
48
- * Qualify a table name with the schema prefix
49
- * (`"<schema>"."<table>"`). The unbound-schema singleton overrides
50
- * this to emit just `"<table>"` so the resolved DDL is unqualified
51
- * and `search_path` decides where the object lands at runtime.
52
- */
53
- qualifyTable(tableName: string): string;
54
- /**
55
- * Render a SQL string-literal containing the qualified-name form
56
- * suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
57
- * The unbound singleton overrides this to elide the schema prefix
58
- * (`'"user"'`) so `search_path` resolves the object at runtime.
59
- */
60
- regclassLiteral(name: string): string;
61
- /**
62
- * Render a SQL expression that evaluates to this namespace's schema
63
- * name at runtime, ready to drop into a `WHERE table_schema = …` /
64
- * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
65
- * literal (`'public'`); the unbound singleton overrides this to emit
66
- * `current_schema()` so catalog queries match whichever schema the
67
- * connection's `search_path` resolved at runtime.
68
- */
69
- schemaSqlExpression(): string;
70
- /**
71
- * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
72
- * builder-built catalog check compares `n.nspname` / `table_schema`
73
- * against. Named schemas bind the schema name as a text parameter; the
74
- * unbound singleton overrides this to the opaque `current_schema()`
75
- * expression so the live connection's `search_path` decides at runtime.
76
- */
77
- schemaFilterExpression(): CfExpr;
78
- /**
79
- * Typed-AST counterpart of {@link qualifyTable}: the FROM source a
80
- * builder-built check uses to address a user table in this namespace.
81
- * Named schemas qualify (`"schema"."table"`); the unbound singleton
82
- * overrides this to leave the table unqualified so `search_path`
83
- * resolves it at runtime.
84
- */
85
- tableSource(tableName: string, alias?: string): PostgresTableSource;
86
- /**
87
- * The bare schema name a DDL planner should target when emitting
88
- * statements that need to identify this namespace in the live
89
- * database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
90
- * catalog filters, planner conflict lookups). Named schemas resolve
91
- * to their own id. The `PostgresUnboundSchema` singleton inherits
92
- * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
93
- * through `qualifyTableName` route through the polymorphic
94
- * `PostgresUnboundSchema` overrides and produce unqualified
95
- * (search-path-resolved) output automatically.
96
- */
97
- ddlSchemaName(_storage: SqlStorage): string;
98
- }
99
- /**
100
- * Singleton subclass for the reserved sentinel namespace id
101
- * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
102
- * the connection's `search_path` resolves at runtime. Overrides
103
- * qualifier emission to elide the schema prefix; call sites that consume
104
- * `qualifier()` / `qualifyTable()` get unqualified output without
105
- * branching on the namespace id.
106
- *
107
- * This is the target-side materialization of "the framework provides
108
- * affordances; targets implement specifics": the framework names the
109
- * sentinel; Postgres decides what late-bound means here (the table
110
- * name, naked — the schema is supplied by the live connection's
111
- * `search_path`).
112
- *
113
- * `ddlSchemaName` is inherited from `PostgresSchema` and returns
114
- * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
115
- * route through the polymorphic factory and produce unqualified output
116
- * automatically.
117
- */
118
- declare class PostgresUnboundSchema extends PostgresSchema {
119
- static readonly instance: PostgresUnboundSchema;
120
- constructor(input?: PostgresSchemaInput);
121
- qualifier(): string;
122
- qualifyTable(tableName: string): string;
123
- schemaSqlExpression(): string;
124
- schemaFilterExpression(): CfExpr;
125
- tableSource(tableName: string, alias?: string): PostgresTableSource;
126
- }
127
- /**
128
- * Target-supplied `Namespace` factory the Postgres target plumbs
129
- * through `defineContract({ createNamespace })` and the SQL PSL
130
- * interpreter. Returns the unbound singleton for the framework
131
- * sentinel and a fresh `PostgresSchema` for any other coordinate.
132
- *
133
- * The factory has no per-call state — every named id deterministically
134
- * maps to a distinct schema instance — so callers can pass it through
135
- * by reference and trust the resulting `SqlStorage.namespaces` map to
136
- * be value-stable for a given input set.
137
- */
138
- declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
139
- //#endregion
140
- export { type PostgresColumnDefault, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
141
- //# sourceMappingURL=types.d.mts.map
3
+ import { a as postgresCreateNamespace, i as isPostgresSchema, n as PostgresSchema, o as PostgresRole, r as PostgresUnboundSchema, s as PostgresRoleInput, t as PostgresContract } from "./postgres-schema-BywoeKlt.mjs";
4
+ import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresPolicySchemaNode, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresTableSchemaNode, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNodeInput } from "./postgres-database-schema-node-os8ogEap.mjs";
5
+ export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresPolicySchemaNode, type PostgresPolicySchemaNodeInput, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresRoleSchemaNode, type PostgresRoleSchemaNodeInput, PostgresSchema, PostgresTableSchemaNode, type PostgresTableSchemaNodeInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, postgresCreateNamespace };
package/dist/types.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-COGZ1ark.mjs";
2
- export { PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
1
+ import { d as PostgresRlsPolicy, i as postgresCreateNamespace, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema, u as PostgresRole } from "./postgres-schema-BLIHBEfX.mjs";
2
+ import { a as PostgresDatabaseSchemaNode, i as PostgresNamespaceSchemaNode, n as PostgresRoleSchemaNode, r as PostgresPolicySchemaNode, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-1nNc8XDT.mjs";
3
+ export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresPolicySchemaNode, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema, PostgresTableSchemaNode, PostgresUnboundSchema, isPostgresSchema, postgresCreateNamespace };
package/package.json CHANGED
@@ -1,32 +1,35 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.14.0-dev.4",
3
+ "version": "0.14.0-dev.41",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Postgres target pack for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/cli": "0.14.0-dev.4",
10
- "@prisma-next/contract": "0.14.0-dev.4",
11
- "@prisma-next/errors": "0.14.0-dev.4",
12
- "@prisma-next/family-sql": "0.14.0-dev.4",
13
- "@prisma-next/framework-components": "0.14.0-dev.4",
14
- "@prisma-next/migration-tools": "0.14.0-dev.4",
15
- "@prisma-next/ts-render": "0.14.0-dev.4",
16
- "@prisma-next/sql-contract": "0.14.0-dev.4",
17
- "@prisma-next/sql-errors": "0.14.0-dev.4",
18
- "@prisma-next/sql-operations": "0.14.0-dev.4",
19
- "@prisma-next/sql-relational-core": "0.14.0-dev.4",
20
- "@prisma-next/sql-schema-ir": "0.14.0-dev.4",
21
- "@prisma-next/utils": "0.14.0-dev.4",
9
+ "@prisma-next/cli": "0.14.0-dev.41",
10
+ "@prisma-next/contract": "0.14.0-dev.41",
11
+ "@prisma-next/errors": "0.14.0-dev.41",
12
+ "@prisma-next/family-sql": "0.14.0-dev.41",
13
+ "@prisma-next/framework-components": "0.14.0-dev.41",
14
+ "@prisma-next/migration-tools": "0.14.0-dev.41",
15
+ "@prisma-next/sql-contract": "0.14.0-dev.41",
16
+ "@prisma-next/sql-errors": "0.14.0-dev.41",
17
+ "@prisma-next/sql-operations": "0.14.0-dev.41",
18
+ "@prisma-next/sql-relational-core": "0.14.0-dev.41",
19
+ "@prisma-next/sql-schema-ir": "0.14.0-dev.41",
20
+ "@prisma-next/ts-render": "0.14.0-dev.41",
21
+ "@prisma-next/utils": "0.14.0-dev.41",
22
22
  "@standard-schema/spec": "^1.1.0",
23
23
  "arktype": "^2.2.0",
24
24
  "pathe": "^2.0.3"
25
25
  },
26
26
  "devDependencies": {
27
- "@prisma-next/test-utils": "0.14.0-dev.4",
28
- "@prisma-next/tsconfig": "0.14.0-dev.4",
29
- "@prisma-next/tsdown": "0.14.0-dev.4",
27
+ "@prisma-next/psl-parser": "0.14.0-dev.41",
28
+ "@prisma-next/psl-printer": "0.14.0-dev.41",
29
+ "@prisma-next/sql-contract-psl": "0.14.0-dev.41",
30
+ "@prisma-next/test-utils": "0.14.0-dev.41",
31
+ "@prisma-next/tsconfig": "0.14.0-dev.41",
32
+ "@prisma-next/tsdown": "0.14.0-dev.41",
30
33
  "tsdown": "0.22.1",
31
34
  "typescript": "5.9.3",
32
35
  "vitest": "4.1.8"
@@ -68,7 +71,9 @@
68
71
  "./planner-target-details": "./dist/planner-target-details.mjs",
69
72
  "./render-ops": "./dist/render-ops.mjs",
70
73
  "./render-typescript": "./dist/render-typescript.mjs",
74
+ "./rls-canonicalize": "./dist/rls-canonicalize.mjs",
71
75
  "./runtime": "./dist/runtime.mjs",
76
+ "./schema-ir-annotations": "./dist/schema-ir-annotations.mjs",
72
77
  "./sql-utils": "./dist/sql-utils.mjs",
73
78
  "./types": "./dist/types.mjs",
74
79
  "./package.json": "./package.json"
@@ -345,6 +345,79 @@ export function extensionExistsAst(extensionName: string): ExtensionExistsCheckB
345
345
  };
346
346
  }
347
347
 
348
+ export interface RlsPolicyExistsCheckBuilder {
349
+ policyPresent(): SelectAst;
350
+ policyAbsent(): SelectAst;
351
+ }
352
+
353
+ /**
354
+ * Typed RLS-policy existence check over `pg_policies`, with schema, table,
355
+ * and policy names bound as text parameters (never inlined). The `schema`
356
+ * coordinate is the resolved live-database schema name (e.g. `'public'`),
357
+ * compared against `pg_policies.schemaname` as a bound parameter.
358
+ */
359
+ export function rlsPolicyExistsAst(options: {
360
+ readonly schema: string;
361
+ readonly table: string;
362
+ readonly policyName: string;
363
+ }): RlsPolicyExistsCheckBuilder {
364
+ const inner = () =>
365
+ exprSelect()
366
+ .from(cfTable('pg_policies'))
367
+ .project('one', cfExpr.lit(1))
368
+ .where(
369
+ cfExpr.allOf([
370
+ cfExpr.identifierRef('schemaname').eqParam(options.schema, PG_TEXT_CODEC_ID),
371
+ cfExpr.identifierRef('tablename').eqParam(options.table, PG_TEXT_CODEC_ID),
372
+ cfExpr.identifierRef('policyname').eqParam(options.policyName, PG_TEXT_CODEC_ID),
373
+ ]),
374
+ );
375
+ return {
376
+ policyPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),
377
+ policyAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),
378
+ };
379
+ }
380
+
381
+ export interface RlsEnabledCheckBuilder {
382
+ rlsEnabled(): SelectAst;
383
+ rlsDisabled(): SelectAst;
384
+ }
385
+
386
+ /**
387
+ * Typed row-level-security enabled check over `pg_class` joined to
388
+ * `pg_namespace`, comparing `pg_class.relrowsecurity` against the expected
389
+ * boolean. Schema and table names are bound as text parameters.
390
+ */
391
+ export function rlsEnabledAst(schema: string, table: string): RlsEnabledCheckBuilder {
392
+ const inner = (enabled: boolean) =>
393
+ exprSelect()
394
+ .from(cfTable('pg_class', 'c'))
395
+ .join(
396
+ cfTable('pg_namespace', 'n'),
397
+ cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),
398
+ )
399
+ .project('one', cfExpr.lit(1))
400
+ .where(
401
+ cfExpr.allOf([
402
+ cfExpr.columnRef('n', 'nspname').eqParam(schema, PG_TEXT_CODEC_ID),
403
+ cfExpr.columnRef('c', 'relname').eqParam(table, PG_TEXT_CODEC_ID),
404
+ enabled
405
+ ? cfExpr.columnRef('c', 'relrowsecurity')
406
+ : cfExpr.columnRef('c', 'relrowsecurity').not(),
407
+ ]),
408
+ );
409
+ return {
410
+ rlsEnabled: () =>
411
+ exprSelect()
412
+ .project('result', cfExpr.exists(inner(true)))
413
+ .build(),
414
+ rlsDisabled: () =>
415
+ exprSelect()
416
+ .project('result', cfExpr.exists(inner(false)))
417
+ .build(),
418
+ };
419
+ }
420
+
348
421
  export interface IndexExistsCheckBuilder {
349
422
  indexPresent(): SelectAst;
350
423
  indexAbsent(): SelectAst;