@prisma-next/target-postgres 0.14.0-dev.2 → 0.14.0-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
  2. package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
  3. package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
  4. package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
  5. package/dist/codecs.mjs.map +1 -1
  6. package/dist/contract-free.d.mts +8 -3
  7. package/dist/contract-free.d.mts.map +1 -1
  8. package/dist/contract-free.mjs +3 -3
  9. package/dist/control.d.mts +1 -1
  10. package/dist/control.mjs +6 -6
  11. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  12. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-qKy1U5V9.d.mts} +2 -2
  13. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-qKy1U5V9.d.mts.map} +1 -1
  14. package/dist/data-transform.d.mts +1 -1
  15. package/dist/{ddl-QDyOSeLc.mjs → ddl-D1K9soOg.mjs} +62 -5
  16. package/dist/ddl-D1K9soOg.mjs.map +1 -0
  17. package/dist/ddl.d.mts +3 -2
  18. package/dist/ddl.mjs +2 -2
  19. package/dist/{default-normalizer-DyyCHQWs.mjs → default-normalizer-CzV8-QSu.mjs} +58 -2
  20. package/dist/default-normalizer-CzV8-QSu.mjs.map +1 -0
  21. package/dist/default-normalizer.d.mts +1 -1
  22. package/dist/default-normalizer.d.mts.map +1 -1
  23. package/dist/default-normalizer.mjs +1 -1
  24. package/dist/descriptor-meta-b_SzXwen.mjs +239 -0
  25. package/dist/descriptor-meta-b_SzXwen.mjs.map +1 -0
  26. package/dist/{issue-planner-DL6g3CmE.mjs → issue-planner-CUeQ7D83.mjs} +11 -9
  27. package/dist/issue-planner-CUeQ7D83.mjs.map +1 -0
  28. package/dist/issue-planner.d.mts +3 -3
  29. package/dist/issue-planner.d.mts.map +1 -1
  30. package/dist/issue-planner.mjs +1 -1
  31. package/dist/migration.d.mts +3 -3
  32. package/dist/migration.mjs +2 -2
  33. package/dist/nodes-CSkPX3rI.d.mts +120 -0
  34. package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
  35. package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
  36. package/dist/nodes-Dh__NS58.mjs.map +1 -0
  37. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CQ4P40QC.d.mts} +44 -13
  38. package/dist/op-factory-call-CQ4P40QC.d.mts.map +1 -0
  39. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-CyqPjAwf.mjs} +199 -28
  40. package/dist/op-factory-call-CyqPjAwf.mjs.map +1 -0
  41. package/dist/op-factory-call.d.mts +1 -1
  42. package/dist/op-factory-call.mjs +1 -1
  43. package/dist/pack.d.mts +74 -1
  44. package/dist/pack.d.mts.map +1 -1
  45. package/dist/pack.mjs +1 -1
  46. package/dist/{planner-Bs_baQax.mjs → planner-D5zY__R3.mjs} +115 -23
  47. package/dist/planner-D5zY__R3.mjs.map +1 -0
  48. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  49. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  50. package/dist/planner-ddl-builders.d.mts +2 -4
  51. package/dist/planner-ddl-builders.d.mts.map +1 -1
  52. package/dist/planner-ddl-builders.mjs +2 -2
  53. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-CNTSCMl7.d.mts} +3 -3
  54. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-CNTSCMl7.d.mts.map} +1 -1
  55. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-D8JHnu5j.mjs} +2 -2
  56. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-D8JHnu5j.mjs.map} +1 -1
  57. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  58. package/dist/planner-produced-postgres-migration.mjs +1 -1
  59. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-CI6Z21mm.mjs} +2 -2
  60. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CI6Z21mm.mjs.map} +1 -1
  61. package/dist/planner-sql-checks.mjs +1 -1
  62. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  63. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  64. package/dist/planner-target-details.d.mts +1 -1
  65. package/dist/planner.d.mts +35 -3
  66. package/dist/planner.d.mts.map +1 -1
  67. package/dist/planner.mjs +2 -2
  68. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-serializer-k5eg5ZUZ.mjs} +29 -16
  69. package/dist/postgres-contract-serializer-k5eg5ZUZ.mjs.map +1 -0
  70. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-BoqzWSkj.mjs} +2 -2
  71. package/dist/{postgres-migration-B5jKrXv3.mjs.map → postgres-migration-BoqzWSkj.mjs.map} +1 -1
  72. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DJNJHcdP.d.mts} +4 -4
  73. package/dist/{postgres-migration-Y4YBJqkS.d.mts.map → postgres-migration-DJNJHcdP.d.mts.map} +1 -1
  74. package/dist/postgres-rls-policy-D_z1osEq.d.mts +60 -0
  75. package/dist/postgres-rls-policy-D_z1osEq.d.mts.map +1 -0
  76. package/dist/postgres-role-_CCuyPCQ.d.mts +33 -0
  77. package/dist/postgres-role-_CCuyPCQ.d.mts.map +1 -0
  78. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-BVDr_61a.mjs} +139 -3
  79. package/dist/postgres-schema-BVDr_61a.mjs.map +1 -0
  80. package/dist/postgres-schema-D0h4lsw2.d.mts +158 -0
  81. package/dist/postgres-schema-D0h4lsw2.d.mts.map +1 -0
  82. package/dist/postgres-schema-ir-BF0X8jit.mjs +66 -0
  83. package/dist/postgres-schema-ir-BF0X8jit.mjs.map +1 -0
  84. package/dist/postgres-schema-ir-BQ3RpZMz.d.mts +60 -0
  85. package/dist/postgres-schema-ir-BQ3RpZMz.d.mts.map +1 -0
  86. package/dist/postgres-schema-ir-annotations-El62Sywa.mjs +14 -0
  87. package/dist/postgres-schema-ir-annotations-El62Sywa.mjs.map +1 -0
  88. package/dist/render-ops.d.mts +1 -1
  89. package/dist/rls-canonicalize.d.mts +2 -0
  90. package/dist/rls-canonicalize.mjs +2 -0
  91. package/dist/runtime.d.mts +3 -2
  92. package/dist/runtime.d.mts.map +1 -1
  93. package/dist/runtime.mjs +2 -2
  94. package/dist/schema-ir-annotations.d.mts +8 -0
  95. package/dist/schema-ir-annotations.d.mts.map +1 -0
  96. package/dist/schema-ir-annotations.mjs +2 -0
  97. package/dist/types.d.mts +5 -140
  98. package/dist/types.mjs +3 -2
  99. package/package.json +21 -17
  100. package/src/contract-free/checks.ts +73 -0
  101. package/src/contract-free/ddl.ts +45 -1
  102. package/src/core/authoring.ts +115 -1
  103. package/src/core/codecs.ts +1 -1
  104. package/src/core/ddl/nodes.ts +94 -2
  105. package/src/core/default-normalizer.ts +60 -2
  106. package/src/core/descriptor-meta.ts +4 -0
  107. package/src/core/entity-kinds.ts +16 -0
  108. package/src/core/migrations/bound-schema.ts +10 -0
  109. package/src/core/migrations/control-policy.ts +3 -0
  110. package/src/core/migrations/issue-planner.ts +8 -0
  111. package/src/core/migrations/op-factory-call.ts +106 -21
  112. package/src/core/migrations/operations/columns.ts +24 -12
  113. package/src/core/migrations/operations/data-transform.ts +6 -0
  114. package/src/core/migrations/operations/rls.ts +106 -0
  115. package/src/core/migrations/operations/shared.ts +0 -30
  116. package/src/core/migrations/planner-ddl-builders.ts +15 -56
  117. package/src/core/migrations/planner-recipes.ts +31 -13
  118. package/src/core/migrations/planner-strategies.ts +3 -11
  119. package/src/core/migrations/planner-target-details.ts +3 -1
  120. package/src/core/migrations/planner.ts +99 -1
  121. package/src/core/migrations/verify-postgres-namespaces.ts +12 -15
  122. package/src/core/migrations/verify-postgres-rls-policies.ts +62 -0
  123. package/src/core/postgres-contract-serializer.ts +43 -19
  124. package/src/core/postgres-rls-policy.ts +103 -0
  125. package/src/core/postgres-role.ts +53 -0
  126. package/src/core/postgres-schema-ir-annotations.ts +22 -0
  127. package/src/core/postgres-schema-ir.ts +101 -0
  128. package/src/core/postgres-schema.ts +24 -4
  129. package/src/core/postgres-validators.ts +20 -0
  130. package/src/core/rls/canonicalize.ts +48 -0
  131. package/src/exports/contract-free.ts +7 -1
  132. package/src/exports/ddl.ts +4 -0
  133. package/src/exports/planner-ddl-builders.ts +0 -2
  134. package/src/exports/planner.ts +1 -0
  135. package/src/exports/rls-canonicalize.ts +6 -0
  136. package/src/exports/schema-ir-annotations.ts +1 -0
  137. package/src/exports/types.ts +12 -0
  138. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  139. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  140. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  141. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  142. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  143. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  144. package/dist/nodes-pLeLgdis.d.mts +0 -67
  145. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  146. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  147. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  148. package/dist/planner-Bs_baQax.mjs.map +0 -1
  149. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  150. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  151. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  152. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  153. package/dist/types.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-BVDr_61a.mjs","names":[],"sources":["../src/core/postgres-rls-policy.ts","../src/core/postgres-role.ts","../src/core/postgres-validators.ts","../src/core/ast/table-source.ts","../src/core/entity-kinds.ts","../src/core/postgres-schema.ts"],"sourcesContent":["import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport type { EntityCoordinate } from '@prisma-next/framework-components/ir';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';\n\nexport interface PostgresRlsPolicyInput {\n /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */\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). Policies are schema-scoped. */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. Plain strings in this slice. */\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 * Postgres IR class for a row-level security policy (`CREATE POLICY … ON …`).\n *\n * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.\n * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`\n * discriminant is enumerable (overrides SqlNode's non-enumerable `'sql'`) so it\n * survives JSON serialization and enables dispatch. The literal matches the\n * entries key (one-string rule: node.kind === entries key === entity kind).\n */\nexport class PostgresRlsPolicy extends SqlNode implements DiffableNode {\n override readonly kind = 'policy' as const;\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: PostgresRlsPolicyInput) {\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 identity(): EntityCoordinate {\n return {\n plane: 'storage',\n namespaceId: this.namespaceId,\n entityKind: 'policy',\n entityName: this.name,\n };\n }\n\n /**\n * Equality by wire name only. The wire name is `<prefix>_<sha256(body)[0..8]>`,\n * so name-equality IS body-equality — two policies with different bodies\n * have different hashes and therefore different names. We deliberately\n * skip comparing bodies directly because Postgres reprints predicate\n * expressions (e.g. strips outer parentheses), so a byte-compare against\n * the authored body would produce false mismatches on a clean re-verify.\n */\n isEqualTo(other: DiffableNode): boolean {\n if (!isPostgresRlsPolicy(other)) {\n throw new Error(\n `PostgresRlsPolicy.isEqualTo: expected a PostgresRlsPolicy, got ${other.identity().entityKind}`,\n );\n }\n return this.name === other.name;\n }\n}\n\nexport function isPostgresRlsPolicy(node: DiffableNode | undefined): node is PostgresRlsPolicy {\n return node !== undefined && 'kind' in node && node.kind === 'policy';\n}\n\nexport function assertPostgresRlsPolicy(\n node: DiffableNode | undefined,\n): asserts node is PostgresRlsPolicy {\n if (!isPostgresRlsPolicy(node)) {\n const kind = node !== undefined && 'kind' in node ? String(node.kind) : typeof node;\n throw new Error(\n `planRlsDiff: expected a PostgresRlsPolicy on the policy-diff path but got ${kind}`,\n );\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport type { EntityCoordinate } from '@prisma-next/framework-components/ir';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresRoleInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`\n * from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n}\n\n/**\n * Postgres IR class for a database role (`CREATE ROLE …`).\n *\n * Roles are cluster-scoped, so their namespace coordinate is always\n * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.\n * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.\n * The `kind: 'role'` discriminant is enumerable so it survives JSON.\n * Matches the entries key (one-string rule).\n */\nexport class PostgresRole extends SqlNode implements DiffableNode {\n override readonly kind = 'role' as const;\n readonly name: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRoleInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n\n identity(): EntityCoordinate {\n return {\n plane: 'storage',\n namespaceId: this.namespaceId,\n entityKind: 'role',\n entityName: this.name,\n };\n }\n\n isEqualTo(other: DiffableNode): boolean {\n if (!(other instanceof PostgresRole)) {\n throw new Error(\n `PostgresRole.isEqualTo: expected a PostgresRole, got ${other.identity().entityKind}`,\n );\n }\n return this.name === other.name;\n }\n}\n","import { type } from 'arktype';\n\nexport const PostgresRoleSchema = type({\n kind: \"'role'\",\n name: 'string',\n namespaceId: 'string',\n});\n\nexport const PostgresRlsPolicySchema = type({\n kind: \"'policy'\",\n name: 'string',\n prefix: 'string',\n tableName: 'string',\n namespaceId: 'string',\n operation: \"'select' | 'insert' | 'update' | 'delete' | 'all'\",\n roles: type.string.array().readonly(),\n 'using?': 'string',\n 'withCheck?': 'string',\n permissive: 'boolean',\n});\n","import {\n type AnyFromSource,\n type AstRewriter,\n TableSource,\n} from '@prisma-next/sql-relational-core/ast';\n\nexport class PostgresTableSource extends TableSource {\n readonly schema: string | undefined;\n\n constructor(options: {\n readonly name: string;\n readonly schema?: string;\n readonly alias?: string;\n }) {\n super(options.name, options.alias);\n this.schema = options.schema;\n this.freeze();\n }\n\n override rewrite(rewriter: AstRewriter): AnyFromSource {\n return rewriter.tableSource ? rewriter.tableSource(this) : this;\n }\n}\n","import type { EntityKindDescriptor } from '@prisma-next/framework-components/ir';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport { PostgresRlsPolicySchema, PostgresRoleSchema } from './postgres-validators';\n\nexport const policyEntityKind: EntityKindDescriptor<PostgresRlsPolicyInput, PostgresRlsPolicy> = {\n kind: 'policy',\n schema: PostgresRlsPolicySchema,\n construct: (input) => new PostgresRlsPolicy(input),\n};\n\nexport const roleEntityKind: EntityKindDescriptor<PostgresRoleInput, PostgresRole> = {\n kind: 'role',\n schema: PostgresRoleSchema,\n construct: (input) => new PostgresRole(input),\n};\n","import {\n freezeNode,\n hydrateNamespaceEntities,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { composeSqlEntityKinds } from '@prisma-next/sql-contract/entity-kinds';\nimport type {\n SqlNamespaceEntries,\n SqlNamespaceTablesInput,\n SqlStorage,\n StorageTable,\n StorageValueSet,\n} from '@prisma-next/sql-contract/types';\nimport { type CfExpr, cfExpr } from '@prisma-next/sql-relational-core/contract-free';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PostgresTableSource } from './ast/table-source';\nimport { PG_TEXT_CODEC_ID } from './codec-ids';\nimport { policyEntityKind, roleEntityKind } from './entity-kinds';\nimport type { PostgresRlsPolicy } from './postgres-rls-policy';\nimport type { PostgresRole } from './postgres-role';\nimport { escapeLiteral } from './sql-utils';\n\nexport type PostgresNamespaceEntries = SqlNamespaceEntries & {\n readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;\n readonly role?: Readonly<Record<string, PostgresRole>>;\n};\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends NamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: PostgresNamespaceEntries;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n composeSqlEntityKinds([policyEntityKind, roleEntityKind]),\n 'carry',\n );\n\n // Drop an empty valueSet so presence signals non-emptiness.\n const valueSetRaw = dispatched['valueSet'];\n const withPresence =\n valueSetRaw !== undefined && Object.keys(valueSetRaw).length === 0\n ? { ...dispatched, valueSet: undefined }\n : dispatched;\n\n this.entries = Object.freeze(\n blindCast<\n PostgresNamespaceEntries,\n 'composeSqlEntityKinds([policyEntityKind, roleEntityKind]) supplies table→StorageTable, valueSet→StorageValueSet, policy→PostgresRlsPolicy, role→PostgresRole descriptors'\n >(withPresence),\n );\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined {\n return this.entries.valueSet;\n }\n\n get policy(): Readonly<Record<string, PostgresRlsPolicy>> {\n return this.entries.policy ?? Object.freeze({});\n }\n\n get role(): Readonly<Record<string, PostgresRole>> {\n return this.entries.role ?? Object.freeze({});\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a\n * builder-built catalog check compares `n.nspname` / `table_schema`\n * against. Named schemas bind the schema name as a text parameter; the\n * unbound singleton overrides this to the opaque `current_schema()`\n * expression so the live connection's `search_path` decides at runtime.\n */\n schemaFilterExpression(): CfExpr {\n return cfExpr.param(this.id, PG_TEXT_CODEC_ID);\n }\n\n /**\n * Typed-AST counterpart of {@link qualifyTable}: the FROM source a\n * builder-built check uses to address a user table in this namespace.\n * Named schemas qualify (`\"schema\".\"table\"`); the unbound singleton\n * overrides this to leave the table unqualified so `search_path`\n * resolves it at runtime.\n */\n tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n schema: this.id,\n ...ifDefined('alias', alias),\n });\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` route through the polymorphic\n * `PostgresUnboundSchema` overrides and produce unqualified\n * (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`\n * route through the polymorphic factory and produce unqualified output\n * automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n\n override schemaFilterExpression(): CfExpr {\n return cfExpr.raw('current_schema()', { codecId: PG_TEXT_CODEC_ID, nullable: false });\n }\n\n override tableSource(tableName: string, alias?: string): PostgresTableSource {\n return new PostgresTableSource({\n name: tableName,\n ...ifDefined('alias', alias),\n });\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set.\n */\nexport function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n ...input.entries,\n table: input.entries['table'] ?? {},\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,IAAa,oBAAb,cAAuC,QAAgC;CACrE,OAAyB;CACzB;CACA;CACA;CACA;CACA;CACA;CAGA;CAEA,YAAY,OAA+B;EACzC,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,SAAS,MAAM;EACpB,KAAK,YAAY,MAAM;EACvB,KAAK,cAAc,MAAM;EACzB,KAAK,YAAY,MA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,OAAO,IAAI,oBAAoB;GAC7B,MAAM;GACN,GAAG,UAAU,SAAS,KAAK;EAC7B,CAAC;CACH;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAgD;CACtF,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,GAAG,MAAM;GACT,OAAO,MAAM,QAAQ,YAAY,CAAC;EACpC;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
@@ -0,0 +1,158 @@
1
+ import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
2
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy-D_z1osEq.mjs";
3
+ import { t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
4
+ import { NamespaceBase } from "@prisma-next/framework-components/ir";
5
+ import { SqlNamespaceEntries, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
6
+ import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
7
+
8
+ //#region src/core/postgres-schema.d.ts
9
+ type PostgresNamespaceEntries = SqlNamespaceEntries & {
10
+ readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
11
+ readonly role?: Readonly<Record<string, PostgresRole>>;
12
+ };
13
+ interface PostgresSchemaInput {
14
+ readonly id: string;
15
+ readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
16
+ }
17
+ /**
18
+ * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
19
+ * SCHEMA …`). Each Postgres `SqlStorage` carries a
20
+ * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
21
+ * the Postgres PSL interpreter from `namespace { … }` AST buckets.
22
+ *
23
+ * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier
24
+ * emission is the rendering seam: DDL / SQL emission asks the namespace
25
+ * for its qualifier (`"<schema>"`) or for a qualified table name
26
+ * (`"<schema>"."<table>"`) and consumes the result polymorphically.
27
+ * The unbound singleton below overrides these methods to elide the
28
+ * prefix entirely — call sites stay polymorphic and never branch on
29
+ * `id === UNBOUND_NAMESPACE_ID`.
30
+ */
31
+ declare class PostgresSchema extends NamespaceBase {
32
+ /**
33
+ * Stable singleton reference for the late-bound slot. Materialised
34
+ * lazily below the singleton subclass declaration so the static
35
+ * initialiser sees the subclass before assigning. Consumers always
36
+ * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`
37
+ * — same identity).
38
+ */
39
+ static unbound: PostgresUnboundSchema;
40
+ readonly kind: 'schema';
41
+ readonly id: string;
42
+ readonly entries: PostgresNamespaceEntries;
43
+ constructor(input: PostgresSchemaInput);
44
+ get table(): Readonly<Record<string, StorageTable>>;
45
+ get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined;
46
+ get policy(): Readonly<Record<string, PostgresRlsPolicy>>;
47
+ get role(): Readonly<Record<string, PostgresRole>>;
48
+ /**
49
+ * The bare schema qualifier as it would appear in a rendered SQL
50
+ * fragment (already quoted). The unbound-schema singleton overrides
51
+ * this to return `''`.
52
+ */
53
+ qualifier(): string;
54
+ /**
55
+ * Qualify a table name with the schema prefix
56
+ * (`"<schema>"."<table>"`). The unbound-schema singleton overrides
57
+ * this to emit just `"<table>"` so the resolved DDL is unqualified
58
+ * and `search_path` decides where the object lands at runtime.
59
+ */
60
+ qualifyTable(tableName: string): string;
61
+ /**
62
+ * Render a SQL string-literal containing the qualified-name form
63
+ * suitable for `to_regclass(...)` arguments (e.g. `'"public"."user"'`).
64
+ * The unbound singleton overrides this to elide the schema prefix
65
+ * (`'"user"'`) so `search_path` resolves the object at runtime.
66
+ */
67
+ regclassLiteral(name: string): string;
68
+ /**
69
+ * Render a SQL expression that evaluates to this namespace's schema
70
+ * name at runtime, ready to drop into a `WHERE table_schema = …` /
71
+ * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL
72
+ * literal (`'public'`); the unbound singleton overrides this to emit
73
+ * `current_schema()` so catalog queries match whichever schema the
74
+ * connection's `search_path` resolved at runtime.
75
+ */
76
+ schemaSqlExpression(): string;
77
+ /**
78
+ * Typed-AST counterpart of {@link schemaSqlExpression}: the expression a
79
+ * builder-built catalog check compares `n.nspname` / `table_schema`
80
+ * against. Named schemas bind the schema name as a text parameter; the
81
+ * unbound singleton overrides this to the opaque `current_schema()`
82
+ * expression so the live connection's `search_path` decides at runtime.
83
+ */
84
+ schemaFilterExpression(): CfExpr;
85
+ /**
86
+ * Typed-AST counterpart of {@link qualifyTable}: the FROM source a
87
+ * builder-built check uses to address a user table in this namespace.
88
+ * Named schemas qualify (`"schema"."table"`); the unbound singleton
89
+ * overrides this to leave the table unqualified so `search_path`
90
+ * resolves it at runtime.
91
+ */
92
+ tableSource(tableName: string, alias?: string): PostgresTableSource;
93
+ /**
94
+ * The bare schema name a DDL planner should target when emitting
95
+ * statements that need to identify this namespace in the live
96
+ * database (e.g. `CREATE TABLE "<ddlSchemaName>"."<table>" …`,
97
+ * catalog filters, planner conflict lookups). Named schemas resolve
98
+ * to their own id. The `PostgresUnboundSchema` singleton inherits
99
+ * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch
100
+ * through `qualifyTableName` route through the polymorphic
101
+ * `PostgresUnboundSchema` overrides and produce unqualified
102
+ * (search-path-resolved) output automatically.
103
+ */
104
+ ddlSchemaName(_storage: SqlStorage): string;
105
+ }
106
+ /**
107
+ * Singleton subclass for the reserved sentinel namespace id
108
+ * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding
109
+ * the connection's `search_path` resolves at runtime. Overrides
110
+ * qualifier emission to elide the schema prefix; call sites that consume
111
+ * `qualifier()` / `qualifyTable()` get unqualified output without
112
+ * branching on the namespace id.
113
+ *
114
+ * This is the target-side materialization of "the framework provides
115
+ * affordances; targets implement specifics": the framework names the
116
+ * sentinel; Postgres decides what late-bound means here (the table
117
+ * name, naked — the schema is supplied by the live connection's
118
+ * `search_path`).
119
+ *
120
+ * `ddlSchemaName` is inherited from `PostgresSchema` and returns
121
+ * `UNBOUND_NAMESPACE_ID`. Downstream helpers such as `qualifyTableName`
122
+ * route through the polymorphic factory and produce unqualified output
123
+ * automatically.
124
+ */
125
+ declare class PostgresUnboundSchema extends PostgresSchema {
126
+ static readonly instance: PostgresUnboundSchema;
127
+ constructor(input?: PostgresSchemaInput);
128
+ qualifier(): string;
129
+ qualifyTable(tableName: string): string;
130
+ schemaSqlExpression(): string;
131
+ schemaFilterExpression(): CfExpr;
132
+ tableSource(tableName: string, alias?: string): PostgresTableSource;
133
+ }
134
+ /**
135
+ * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`
136
+ * so callers can dispatch to the polymorphic emission methods without
137
+ * branching at the call site. Uses the structural `kind` discriminator
138
+ * (`'schema'`) rather than `instanceof` so the check survives realm /
139
+ * bundle / hot-reload boundaries — matching the rest of the IR's
140
+ * narrowing convention. `PostgresUnboundSchema` passes through because
141
+ * it inherits the same `kind: 'schema'` from `PostgresSchema`.
142
+ */
143
+ declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
144
+ /**
145
+ * Target-supplied `Namespace` factory the Postgres target plumbs
146
+ * through `defineContract({ createNamespace })` and the SQL PSL
147
+ * interpreter. Returns the unbound singleton for the framework
148
+ * sentinel and a fresh `PostgresSchema` for any other coordinate.
149
+ *
150
+ * The factory has no per-call state — every named id deterministically
151
+ * maps to a distinct schema instance — so callers can pass it through
152
+ * by reference and trust the resulting `SqlStorage.namespaces` map to
153
+ * be value-stable for a given input set.
154
+ */
155
+ declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
156
+ //#endregion
157
+ export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
158
+ //# sourceMappingURL=postgres-schema-D0h4lsw2.d.mts.map
@@ -0,0 +1 @@
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YAAA,CAAa,SAAA;EAIb,mBAAA;EAIA,sBAAA,IAA0B,MAAA;EAI1B,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;AAAA;;;;;;;;;;iBAmB3C,gBAAA,CAAiB,EAAA,YAAc,EAAA,IAAM,cAAc;;AAnBW;AAmB9E;;;;;;;;AAAmE;iBAenD,uBAAA,CAAwB,KAAA,EAAO,uBAAA,GAA0B,cAAc"}
@@ -0,0 +1,66 @@
1
+ import { freezeNode } from "@prisma-next/framework-components/ir";
2
+ import { SqlSchemaIRNode, SqlTableIR } from "@prisma-next/sql-schema-ir/types";
3
+ //#region src/core/postgres-schema-ir.ts
4
+ /**
5
+ * Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`
6
+ * (same `tables` + optional `annotations` fields) and adds typed fields for
7
+ * data the postgres adapter collects during introspection.
8
+ *
9
+ * Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because
10
+ * `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents
11
+ * subclass field initialisation. `PostgresSchemaIR` replicates the minimal
12
+ * `SqlSchemaIR` structure and freezes itself at the end of its own
13
+ * constructor.
14
+ *
15
+ * RLS-specific fields (`rlsPolicies`, `roles`) are typed top-level fields on
16
+ * this class — no `Reflect.get`, no untyped annotation bag access. The
17
+ * `annotations.pg` bag is populated with only the subset the family layer
18
+ * reads (`nativeEnumTypeNames`, `existingSchemas`, `schema`) so family-layer
19
+ * PSL inference and namespace verification continue to work without knowing
20
+ * about RLS.
21
+ *
22
+ * Nothing RLS-specific leaks into the sql-family layer.
23
+ */
24
+ var PostgresSchemaIR = class extends SqlSchemaIRNode {
25
+ nodeTarget = "postgres";
26
+ tables;
27
+ pgSchemaName;
28
+ pgVersion;
29
+ rlsPolicies;
30
+ roles;
31
+ existingSchemas;
32
+ nativeEnumTypeNames;
33
+ constructor(input) {
34
+ super();
35
+ this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables).map(([key, t]) => [key, t instanceof SqlTableIR ? t : new SqlTableIR(t)])));
36
+ this.pgSchemaName = input.pgSchemaName;
37
+ this.pgVersion = input.pgVersion;
38
+ this.rlsPolicies = Object.freeze([...input.rlsPolicies]);
39
+ this.roles = Object.freeze([...input.roles]);
40
+ this.existingSchemas = Object.freeze([...input.existingSchemas]);
41
+ this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);
42
+ this.annotations = { pg: {
43
+ schema: input.pgSchemaName,
44
+ ...input.nativeEnumTypeNames.length > 0 && { nativeEnumTypeNames: input.nativeEnumTypeNames },
45
+ ...input.existingSchemas.length > 0 && { existingSchemas: input.existingSchemas }
46
+ } };
47
+ freezeNode(this);
48
+ }
49
+ };
50
+ /**
51
+ * Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`
52
+ * discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field
53
+ * (a plain class-field initializer), so it survives the `{ ...schema, tables }`
54
+ * spread the multi-space verify path (`projectSchemaToSpace`) produces — that
55
+ * projected object is not a class instance but retains every enumerable own
56
+ * property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable
57
+ * here: it is shared by every SQL schema-IR node and is non-enumerable (dropped
58
+ * by the spread).
59
+ */
60
+ function isPostgresSchemaIR(schema) {
61
+ return schema.nodeTarget === "postgres";
62
+ }
63
+ //#endregion
64
+ export { isPostgresSchemaIR as n, PostgresSchemaIR as t };
65
+
66
+ //# sourceMappingURL=postgres-schema-ir-BF0X8jit.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-ir-BF0X8jit.mjs","names":[],"sources":["../src/core/postgres-schema-ir.ts"],"sourcesContent":["import { freezeNode } from '@prisma-next/framework-components/ir';\nimport {\n type SqlAnnotations,\n type SqlSchemaIR,\n SqlSchemaIRNode,\n type SqlSchemaTarget,\n SqlTableIR,\n type SqlTableIRInput,\n} from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresRlsPolicy } from './postgres-rls-policy';\nimport type { PostgresRole } from './postgres-role';\n\nexport interface PostgresSchemaIRInput {\n readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;\n readonly pgSchemaName: string;\n readonly pgVersion: string;\n readonly rlsPolicies: readonly PostgresRlsPolicy[];\n readonly roles: readonly PostgresRole[];\n readonly existingSchemas: readonly string[];\n readonly nativeEnumTypeNames: readonly string[];\n}\n\n/**\n * Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`\n * (same `tables` + optional `annotations` fields) and adds typed fields for\n * data the postgres adapter collects during introspection.\n *\n * Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because\n * `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents\n * subclass field initialisation. `PostgresSchemaIR` replicates the minimal\n * `SqlSchemaIR` structure and freezes itself at the end of its own\n * constructor.\n *\n * RLS-specific fields (`rlsPolicies`, `roles`) are typed top-level fields on\n * this class — no `Reflect.get`, no untyped annotation bag access. The\n * `annotations.pg` bag is populated with only the subset the family layer\n * reads (`nativeEnumTypeNames`, `existingSchemas`, `schema`) so family-layer\n * PSL inference and namespace verification continue to work without knowing\n * about RLS.\n *\n * Nothing RLS-specific leaks into the sql-family layer.\n */\nexport class PostgresSchemaIR extends SqlSchemaIRNode {\n readonly nodeTarget: SqlSchemaTarget = 'postgres';\n readonly tables: Readonly<Record<string, SqlTableIR>>;\n declare readonly annotations?: SqlAnnotations;\n readonly pgSchemaName: string;\n readonly pgVersion: string;\n readonly rlsPolicies: readonly PostgresRlsPolicy[];\n readonly roles: readonly PostgresRole[];\n readonly existingSchemas: readonly string[];\n readonly nativeEnumTypeNames: readonly string[];\n\n constructor(input: PostgresSchemaIRInput) {\n super();\n this.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables).map(([key, t]) => [\n key,\n t instanceof SqlTableIR ? t : new SqlTableIR(t),\n ]),\n ),\n );\n this.pgSchemaName = input.pgSchemaName;\n this.pgVersion = input.pgVersion;\n this.rlsPolicies = Object.freeze([...input.rlsPolicies]);\n this.roles = Object.freeze([...input.roles]);\n this.existingSchemas = Object.freeze([...input.existingSchemas]);\n this.nativeEnumTypeNames = Object.freeze([...input.nativeEnumTypeNames]);\n // Populate the annotations.pg bag with only the subset the family layer\n // reads (nativeEnumTypeNames for PSL inference, existingSchemas for\n // namespace presence checks). rlsPolicies and roles are NOT placed here\n // — they are consumed directly via typed fields on this class.\n this.annotations = {\n pg: {\n schema: input.pgSchemaName,\n ...(input.nativeEnumTypeNames.length > 0 && {\n nativeEnumTypeNames: input.nativeEnumTypeNames,\n }),\n ...(input.existingSchemas.length > 0 && {\n existingSchemas: input.existingSchemas,\n }),\n },\n };\n freezeNode(this);\n }\n}\n\n/**\n * Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`\n * discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field\n * (a plain class-field initializer), so it survives the `{ ...schema, tables }`\n * spread the multi-space verify path (`projectSchemaToSpace`) produces — that\n * projected object is not a class instance but retains every enumerable own\n * property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable\n * here: it is shared by every SQL schema-IR node and is non-enumerable (dropped\n * by the spread).\n */\nexport function isPostgresSchemaIR(schema: SqlSchemaIR): schema is PostgresSchemaIR {\n return schema.nodeTarget === 'postgres';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,mBAAb,cAAsC,gBAAgB;CACpD,aAAuC;CACvC;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,OAA8B;EACxC,MAAM;EACN,KAAK,SAAS,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,OAAO,CAC7C,KACA,aAAa,aAAa,IAAI,IAAI,WAAW,CAAC,CAChD,CAAC,CACH,CACF;EACA,KAAK,eAAe,MAAM;EAC1B,KAAK,YAAY,MAAM;EACvB,KAAK,cAAc,OAAO,OAAO,CAAC,GAAG,MAAM,WAAW,CAAC;EACvD,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;EAC3C,KAAK,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,eAAe,CAAC;EAC/D,KAAK,sBAAsB,OAAO,OAAO,CAAC,GAAG,MAAM,mBAAmB,CAAC;EAKvE,KAAK,cAAc,EACjB,IAAI;GACF,QAAQ,MAAM;GACd,GAAI,MAAM,oBAAoB,SAAS,KAAK,EAC1C,qBAAqB,MAAM,oBAC7B;GACA,GAAI,MAAM,gBAAgB,SAAS,KAAK,EACtC,iBAAiB,MAAM,gBACzB;EACF,EACF;EACA,WAAW,IAAI;CACjB;AACF;;;;;;;;;;;AAYA,SAAgB,mBAAmB,QAAiD;CAClF,OAAO,OAAO,eAAe;AAC/B"}
@@ -0,0 +1,60 @@
1
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy-D_z1osEq.mjs";
2
+ import { t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
3
+ import { SqlAnnotations, SqlSchemaIR, SqlSchemaIRNode, SqlSchemaTarget, SqlTableIR, SqlTableIRInput } from "@prisma-next/sql-schema-ir/types";
4
+
5
+ //#region src/core/postgres-schema-ir.d.ts
6
+ interface PostgresSchemaIRInput {
7
+ readonly tables: Record<string, SqlTableIR | SqlTableIRInput>;
8
+ readonly pgSchemaName: string;
9
+ readonly pgVersion: string;
10
+ readonly rlsPolicies: readonly PostgresRlsPolicy[];
11
+ readonly roles: readonly PostgresRole[];
12
+ readonly existingSchemas: readonly string[];
13
+ readonly nativeEnumTypeNames: readonly string[];
14
+ }
15
+ /**
16
+ * Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`
17
+ * (same `tables` + optional `annotations` fields) and adds typed fields for
18
+ * data the postgres adapter collects during introspection.
19
+ *
20
+ * Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because
21
+ * `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents
22
+ * subclass field initialisation. `PostgresSchemaIR` replicates the minimal
23
+ * `SqlSchemaIR` structure and freezes itself at the end of its own
24
+ * constructor.
25
+ *
26
+ * RLS-specific fields (`rlsPolicies`, `roles`) are typed top-level fields on
27
+ * this class — no `Reflect.get`, no untyped annotation bag access. The
28
+ * `annotations.pg` bag is populated with only the subset the family layer
29
+ * reads (`nativeEnumTypeNames`, `existingSchemas`, `schema`) so family-layer
30
+ * PSL inference and namespace verification continue to work without knowing
31
+ * about RLS.
32
+ *
33
+ * Nothing RLS-specific leaks into the sql-family layer.
34
+ */
35
+ declare class PostgresSchemaIR extends SqlSchemaIRNode {
36
+ readonly nodeTarget: SqlSchemaTarget;
37
+ readonly tables: Readonly<Record<string, SqlTableIR>>;
38
+ readonly annotations?: SqlAnnotations;
39
+ readonly pgSchemaName: string;
40
+ readonly pgVersion: string;
41
+ readonly rlsPolicies: readonly PostgresRlsPolicy[];
42
+ readonly roles: readonly PostgresRole[];
43
+ readonly existingSchemas: readonly string[];
44
+ readonly nativeEnumTypeNames: readonly string[];
45
+ constructor(input: PostgresSchemaIRInput);
46
+ }
47
+ /**
48
+ * Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`
49
+ * discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field
50
+ * (a plain class-field initializer), so it survives the `{ ...schema, tables }`
51
+ * spread the multi-space verify path (`projectSchemaToSpace`) produces — that
52
+ * projected object is not a class instance but retains every enumerable own
53
+ * property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable
54
+ * here: it is shared by every SQL schema-IR node and is non-enumerable (dropped
55
+ * by the spread).
56
+ */
57
+ declare function isPostgresSchemaIR(schema: SqlSchemaIR): schema is PostgresSchemaIR;
58
+ //#endregion
59
+ export { PostgresSchemaIRInput as n, isPostgresSchemaIR as r, PostgresSchemaIR as t };
60
+ //# sourceMappingURL=postgres-schema-ir-BQ3RpZMz.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-ir-BQ3RpZMz.d.mts","names":[],"sources":["../src/core/postgres-schema-ir.ts"],"mappings":";;;;;UAYiB,qBAAA;EAAA,SACN,MAAA,EAAQ,MAAA,SAAe,UAAA,GAAa,eAAA;EAAA,SACpC,YAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA,WAAsB,iBAAA;EAAA,SACtB,KAAA,WAAgB,YAAA;EAAA,SAChB,eAAA;EAAA,SACA,mBAAA;AAAA;;;;;;;;;;;;;;;;;AAAmB;AAuB9B;;;cAAa,gBAAA,SAAyB,eAAA;EAAA,SAC3B,UAAA,EAAY,eAAA;EAAA,SACZ,MAAA,EAAQ,QAAA,CAAS,MAAA,SAAe,UAAA;EAAA,SACxB,WAAA,GAAc,cAAA;EAAA,SACtB,YAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA,WAAsB,iBAAA;EAAA,SACtB,KAAA,WAAgB,YAAA;EAAA,SAChB,eAAA;EAAA,SACA,mBAAA;cAEG,KAAA,EAAO,qBAAA;AAAA;;;;;;;;;;;iBA6CL,kBAAA,CAAmB,MAAA,EAAQ,WAAA,GAAc,MAAA,IAAU,gBAAgB"}
@@ -0,0 +1,14 @@
1
+ import { r as isPostgresSchema } from "./postgres-schema-BVDr_61a.mjs";
2
+ import { n as isPostgresSchemaIR } from "./postgres-schema-ir-BF0X8jit.mjs";
3
+ import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
4
+ //#region src/core/postgres-schema-ir-annotations.ts
5
+ function resolveDdlSchemaForNamespaceStorage(storage, namespaceId, schemaIr) {
6
+ if (namespaceId === UNBOUND_NAMESPACE_ID) return (schemaIr && isPostgresSchemaIR(schemaIr) ? schemaIr.pgSchemaName : void 0) ?? "public";
7
+ const namespace = storage.namespaces[namespaceId];
8
+ if (namespace && isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);
9
+ return namespaceId;
10
+ }
11
+ //#endregion
12
+ export { resolveDdlSchemaForNamespaceStorage as t };
13
+
14
+ //# sourceMappingURL=postgres-schema-ir-annotations-El62Sywa.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-ir-annotations-El62Sywa.mjs","names":[],"sources":["../src/core/postgres-schema-ir-annotations.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { isPostgresSchema } from './postgres-schema';\nimport { isPostgresSchemaIR } from './postgres-schema-ir';\n\nexport function resolveDdlSchemaForNamespaceStorage(\n storage: SqlStorage,\n namespaceId: string,\n schemaIr?: SqlSchemaIR,\n): string {\n if (namespaceId === UNBOUND_NAMESPACE_ID) {\n return (\n (schemaIr && isPostgresSchemaIR(schemaIr) ? schemaIr.pgSchemaName : undefined) ?? 'public'\n );\n }\n const namespace = storage.namespaces[namespaceId];\n if (namespace && isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n"],"mappings":";;;;AAMA,SAAgB,oCACd,SACA,aACA,UACQ;CACR,IAAI,gBAAgB,sBAClB,QACG,YAAY,mBAAmB,QAAQ,IAAI,SAAS,eAAe,KAAA,MAAc;CAGtF,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,aAAa,iBAAiB,SAAS,GACzC,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT"}
@@ -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";
@@ -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,5 +1,5 @@
1
1
  import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
2
- import { Namespace } from "@prisma-next/framework-components/ir";
2
+ import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir";
3
3
  import { SqlNamespaceTablesInput, SqlStorage } from "@prisma-next/sql-contract/types";
4
4
  import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
5
5
  import { Contract } from "@prisma-next/contract/types";
@@ -8,11 +8,12 @@ import { JsonObject } from "@prisma-next/utils/json";
8
8
 
9
9
  //#region src/core/postgres-contract-serializer.d.ts
10
10
  declare class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
11
- constructor();
11
+ constructor(extraPackEntityKinds?: readonly AnyEntityKindDescriptor[]);
12
12
  protected get defaultNamespaceId(): string;
13
13
  protected hydrateSqlNamespaceEntry(nsId: string, raw: Namespace | Record<string, unknown>): Namespace | SqlNamespaceTablesInput;
14
14
  serializeContract(contract: Contract<SqlStorage>): JsonObject;
15
15
  private serializePostgresNamespace;
16
+ private serializeJsonObject;
16
17
  private serializeJsonValue;
17
18
  }
18
19
  //#endregion
@@ -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,cAKpB,kBAAA;EAAA,UAIJ,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA4BN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QA0CpD,0BAAA;EAAA,QAgCA,mBAAA;EAAA,QAOA,kBAAA;AAAA;;;UCtLO,6BAAA,SAAsC,qBAAqB;;;;;AD4D5E;;cCpDM,+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 { n as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-b_SzXwen.mjs";
2
+ import { t as PostgresContractSerializer } from "./postgres-contract-serializer-k5eg5ZUZ.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
@@ -0,0 +1,8 @@
1
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
2
+ import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
3
+
4
+ //#region src/core/postgres-schema-ir-annotations.d.ts
5
+ declare function resolveDdlSchemaForNamespaceStorage(storage: SqlStorage, namespaceId: string, schemaIr?: SqlSchemaIR): string;
6
+ //#endregion
7
+ export { resolveDdlSchemaForNamespaceStorage };
8
+ //# sourceMappingURL=schema-ir-annotations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-ir-annotations.d.mts","names":[],"sources":["../src/core/postgres-schema-ir-annotations.ts"],"mappings":";;;;iBAMgB,mCAAA,CACd,OAAA,EAAS,UAAA,EACT,WAAA,UACA,QAAA,GAAW,WAAW"}
@@ -0,0 +1,2 @@
1
+ import { t as resolveDdlSchemaForNamespaceStorage } from "./postgres-schema-ir-annotations-El62Sywa.mjs";
2
+ export { resolveDdlSchemaForNamespaceStorage };
package/dist/types.d.mts CHANGED
@@ -1,141 +1,6 @@
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-D_z1osEq.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 { n as PostgresRoleInput, t as PostgresRole } from "./postgres-role-_CCuyPCQ.mjs";
4
+ import { i as postgresCreateNamespace, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-D0h4lsw2.mjs";
5
+ import { n as PostgresSchemaIRInput, r as isPostgresSchemaIR, t as PostgresSchemaIR } from "./postgres-schema-ir-BQ3RpZMz.mjs";
6
+ export { type PostgresColumnDefault, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresSchema, PostgresSchemaIR, type PostgresSchemaIRInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, isPostgresSchemaIR, 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-BVDr_61a.mjs";
2
+ import { n as isPostgresSchemaIR, t as PostgresSchemaIR } from "./postgres-schema-ir-BF0X8jit.mjs";
3
+ export { PostgresRlsPolicy, PostgresRole, PostgresSchema, PostgresSchemaIR, PostgresUnboundSchema, isPostgresSchema, isPostgresSchemaIR, postgresCreateNamespace };