@prisma-next/target-postgres 0.14.0-dev.22 → 0.14.0-dev.23

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 (96) hide show
  1. package/dist/contract-free.mjs +2 -2
  2. package/dist/control.d.mts.map +1 -1
  3. package/dist/control.mjs +8 -7
  4. package/dist/control.mjs.map +1 -1
  5. package/dist/{ddl-BJPdPsT3.mjs → ddl-CGf6UABz.mjs} +2 -2
  6. package/dist/{ddl-BJPdPsT3.mjs.map → ddl-CGf6UABz.mjs.map} +1 -1
  7. package/dist/{descriptor-meta-CKpjK2Nv.mjs → descriptor-meta-Dvvpu_jU.mjs} +3 -3
  8. package/dist/{descriptor-meta-CKpjK2Nv.mjs.map → descriptor-meta-Dvvpu_jU.mjs.map} +1 -1
  9. package/dist/{descriptor-meta-runtime-DiVla56r.mjs → descriptor-meta-runtime-D5zHFKUz.mjs} +2 -2
  10. package/dist/descriptor-meta-runtime-D5zHFKUz.mjs.map +1 -0
  11. package/dist/{issue-planner-YwXUKGZ1.mjs → issue-planner-D5H1VuVP.mjs} +4 -4
  12. package/dist/{issue-planner-YwXUKGZ1.mjs.map → issue-planner-D5H1VuVP.mjs.map} +1 -1
  13. package/dist/issue-planner.d.mts +2 -2
  14. package/dist/issue-planner.mjs +1 -1
  15. package/dist/migration.d.mts +2 -2
  16. package/dist/migration.mjs +2 -2
  17. package/dist/{op-factory-call-DcY4BHNh.mjs → op-factory-call-DIdBDwmO.mjs} +3 -3
  18. package/dist/op-factory-call-DIdBDwmO.mjs.map +1 -0
  19. package/dist/{op-factory-call-CQ4P40QC.d.mts → op-factory-call-DPJR7tJc.d.mts} +3 -3
  20. package/dist/{op-factory-call-CQ4P40QC.d.mts.map → op-factory-call-DPJR7tJc.d.mts.map} +1 -1
  21. package/dist/op-factory-call.d.mts +1 -1
  22. package/dist/op-factory-call.mjs +1 -1
  23. package/dist/pack.d.mts +2 -3
  24. package/dist/pack.d.mts.map +1 -1
  25. package/dist/pack.mjs +1 -1
  26. package/dist/{planner-_ZHpIQ1-.mjs → planner-BnNEtGYM.mjs} +116 -76
  27. package/dist/planner-BnNEtGYM.mjs.map +1 -0
  28. package/dist/{planner-produced-postgres-migration-CNTSCMl7.d.mts → planner-produced-postgres-migration-BO-frvvN.d.mts} +2 -2
  29. package/dist/{planner-produced-postgres-migration-CNTSCMl7.d.mts.map → planner-produced-postgres-migration-BO-frvvN.d.mts.map} +1 -1
  30. package/dist/{planner-produced-postgres-migration-Dv5ZAvHt.mjs → planner-produced-postgres-migration-DzvdQ-7K.mjs} +2 -2
  31. package/dist/{planner-produced-postgres-migration-Dv5ZAvHt.mjs.map → planner-produced-postgres-migration-DzvdQ-7K.mjs.map} +1 -1
  32. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  33. package/dist/planner-produced-postgres-migration.mjs +1 -1
  34. package/dist/{planner-sql-checks-C7nLjabn.mjs → planner-sql-checks-CyjaoKhm.mjs} +2 -2
  35. package/dist/{planner-sql-checks-C7nLjabn.mjs.map → planner-sql-checks-CyjaoKhm.mjs.map} +1 -1
  36. package/dist/planner-sql-checks.mjs +1 -1
  37. package/dist/planner.d.mts +30 -35
  38. package/dist/planner.d.mts.map +1 -1
  39. package/dist/planner.mjs +2 -2
  40. package/dist/{postgres-contract-serializer-DJDGaS0q.mjs → postgres-contract-serializer-tGMiJcl4.mjs} +3 -3
  41. package/dist/{postgres-contract-serializer-DJDGaS0q.mjs.map → postgres-contract-serializer-tGMiJcl4.mjs.map} +1 -1
  42. package/dist/{postgres-migration-Bj0olfl3.mjs → postgres-migration-C8JZyTSJ.mjs} +2 -2
  43. package/dist/{postgres-migration-Bj0olfl3.mjs.map → postgres-migration-C8JZyTSJ.mjs.map} +1 -1
  44. package/dist/{postgres-migration-DJNJHcdP.d.mts → postgres-migration-Cs7zMOe1.d.mts} +3 -3
  45. package/dist/{postgres-migration-DJNJHcdP.d.mts.map → postgres-migration-Cs7zMOe1.d.mts.map} +1 -1
  46. package/dist/{postgres-rls-policy-D_z1osEq.d.mts → postgres-rls-policy-12wAEQhs.d.mts} +4 -4
  47. package/dist/postgres-rls-policy-12wAEQhs.d.mts.map +1 -0
  48. package/dist/{postgres-schema-Bn4tsMuo.d.mts → postgres-schema-DJUEkWg-.d.mts} +38 -5
  49. package/dist/postgres-schema-DJUEkWg-.d.mts.map +1 -0
  50. package/dist/{postgres-schema-DfuJq-q_.mjs → postgres-schema-DLcc3W2-.mjs} +37 -40
  51. package/dist/postgres-schema-DLcc3W2-.mjs.map +1 -0
  52. package/dist/postgres-schema-ir-BJl_a3J7.d.mts +102 -0
  53. package/dist/postgres-schema-ir-BJl_a3J7.d.mts.map +1 -0
  54. package/dist/postgres-schema-ir-I_FiUndw.mjs +133 -0
  55. package/dist/postgres-schema-ir-I_FiUndw.mjs.map +1 -0
  56. package/dist/{postgres-schema-ir-annotations-CWHQ-H9Y.mjs → postgres-schema-ir-annotations-BbDSiwx2.mjs} +4 -4
  57. package/dist/postgres-schema-ir-annotations-BbDSiwx2.mjs.map +1 -0
  58. package/dist/runtime.mjs +2 -2
  59. package/dist/schema-ir-annotations.d.mts +1 -1
  60. package/dist/schema-ir-annotations.d.mts.map +1 -1
  61. package/dist/schema-ir-annotations.mjs +1 -1
  62. package/dist/types.d.mts +4 -5
  63. package/dist/types.mjs +3 -3
  64. package/package.json +19 -19
  65. package/src/core/authoring.ts +2 -2
  66. package/src/core/entity-kinds.ts +2 -2
  67. package/src/core/migrations/contract-to-postgres-schema-ir.ts +91 -0
  68. package/src/core/migrations/diff-postgres-schema.ts +55 -0
  69. package/src/core/migrations/op-factory-call.ts +1 -1
  70. package/src/core/migrations/operations/rls.ts +1 -1
  71. package/src/core/migrations/planner.ts +44 -59
  72. package/src/core/migrations/verify-postgres-namespaces.ts +1 -1
  73. package/src/core/postgres-schema.ts +6 -2
  74. package/src/core/{postgres-rls-policy.ts → schema-ir/postgres-rls-policy.ts} +8 -10
  75. package/src/core/{postgres-role.ts → schema-ir/postgres-role.ts} +8 -9
  76. package/src/core/{postgres-schema-ir-annotations.ts → schema-ir/postgres-schema-ir-annotations.ts} +1 -1
  77. package/src/core/{postgres-schema-ir.ts → schema-ir/postgres-schema-ir.ts} +53 -16
  78. package/src/core/schema-ir/postgres-table-ir.ts +96 -0
  79. package/src/exports/control.ts +11 -12
  80. package/src/exports/planner.ts +5 -1
  81. package/src/exports/schema-ir-annotations.ts +1 -1
  82. package/src/exports/types.ts +15 -7
  83. package/dist/descriptor-meta-runtime-DiVla56r.mjs.map +0 -1
  84. package/dist/op-factory-call-DcY4BHNh.mjs.map +0 -1
  85. package/dist/planner-_ZHpIQ1-.mjs.map +0 -1
  86. package/dist/postgres-rls-policy-D_z1osEq.d.mts.map +0 -1
  87. package/dist/postgres-role-_CCuyPCQ.d.mts +0 -33
  88. package/dist/postgres-role-_CCuyPCQ.d.mts.map +0 -1
  89. package/dist/postgres-schema-Bn4tsMuo.d.mts.map +0 -1
  90. package/dist/postgres-schema-DfuJq-q_.mjs.map +0 -1
  91. package/dist/postgres-schema-ir-BF0X8jit.mjs +0 -66
  92. package/dist/postgres-schema-ir-BF0X8jit.mjs.map +0 -1
  93. package/dist/postgres-schema-ir-BQ3RpZMz.d.mts +0 -60
  94. package/dist/postgres-schema-ir-BQ3RpZMz.d.mts.map +0 -1
  95. package/dist/postgres-schema-ir-annotations-CWHQ-H9Y.mjs.map +0 -1
  96. package/src/core/migrations/verify-postgres-rls-policies.ts +0 -62
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-contract-serializer-DJDGaS0q.mjs","names":[],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type AnyEntityKindDescriptor,\n type Namespace,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject, JsonValue } from '@prisma-next/utils/json';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport { policyEntityKind, roleEntityKind } from './entity-kinds';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n 'factory' in output &&\n typeof output.factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits hydration factories\n * keyed by the descriptor's `discriminator`. Used for `storage.types`\n * (codec-triple hydration). Namespace entries hydration dispatches by\n * entries key, not discriminator — handled by `hydrateNamespaceEntities`.\n */\nfunction collectStorageTypesHydrators(\n namespace: AuthoringEntityTypeNamespace,\n): ReadonlyMap<string, SqlEntityHydrationFactory> {\n const registry = new Map<string, SqlEntityHydrationFactory>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n registry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return registry;\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor(extraPackEntityKinds: readonly AnyEntityKindDescriptor[] = []) {\n const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);\n super(storageTypesHydrators, [policyEntityKind, roleEntityKind, ...extraPackEntityKinds]);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Record<string, unknown>,\n ): Namespace | SqlNamespaceInput {\n const hydrated = blindCast<\n SqlNamespaceInput,\n 'raw is always plain JSON, so super.hydrateSqlNamespaceEntry returns SqlNamespaceInput'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n const allSlotsEmpty = Object.values(entries).every(\n (slot) => slot === undefined || Object.keys(slot).length === 0,\n );\n if (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) {\n return PostgresSchema.unbound;\n }\n const valueSetSlot = entries['valueSet'];\n const hasValueSets = valueSetSlot !== undefined && Object.keys(valueSetSlot).length > 0;\n return new PostgresSchema({\n id,\n entries: {\n ...entries,\n table: entries['table'] ?? {},\n ...(hasValueSets ? { valueSet: valueSetSlot } : {}),\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [\n tableName,\n this.serializeJsonObject(table),\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonObject(entry);\n }\n storageOut['types'] = typesOut;\n }\n return blindCast<\n JsonObject,\n 'contract minus storage plus a JSON-shaped storageOut is a JsonObject'\n >({\n ...rest,\n storage: storageOut,\n });\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.table)) {\n tablesOut[tableName] = this.serializeJsonObject(table);\n }\n const valueSetEntries = ns.valueSet;\n const valueSetOut: Record<string, JsonObject> = {};\n if (valueSetEntries !== undefined) {\n for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) {\n valueSetOut[valueSetName] = this.serializeJsonObject(valueSet);\n }\n }\n const roleOut: Record<string, JsonObject> = {};\n for (const [roleName, role] of Object.entries(ns.role)) {\n roleOut[roleName] = this.serializeJsonObject(role);\n }\n const policyOut: Record<string, JsonObject> = {};\n for (const [policyName, policy] of Object.entries(ns.policy)) {\n policyOut[policyName] = this.serializeJsonObject(policy);\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n ...(Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}),\n ...(Object.keys(roleOut).length > 0 ? { role: roleOut } : {}),\n ...(Object.keys(policyOut).length > 0 ? { policy: policyOut } : {}),\n },\n };\n }\n\n private serializeJsonObject(value: unknown): JsonObject {\n return blindCast<\n JsonObject,\n 'serializeJsonValue round-trips an IR node through JSON, yielding a JsonObject'\n >(this.serializeJsonValue(value));\n }\n\n private serializeJsonValue(value: unknown): JsonValue {\n return blindCast<JsonValue, 'JSON.parse(JSON.stringify(x)) yields a JsonValue'>(\n JSON.parse(JSON.stringify(value)),\n );\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,aAAa,UACb,OAAO,OAAO,YAAY;AAE9B;;;;;;;AAQA,SAAS,6BACP,WACgD;CAChD,MAAM,2BAAW,IAAI,I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GACP,MAAM,gBAAgB,4BAA4B;GAClD,SAAS;IACP,OAAO;IACP,GAAI,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,IAAI,EAAE,UAAU,YAAY,IAAI,CAAC;IACvE,GAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,MAAM,QAAQ,IAAI,CAAC;IAC3D,GAAI,OAAO,KAAK,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,QAAQ,UAAU,IAAI,CAAC;GACnE;EACF;CACF;CAEA,oBAA4B,OAA4B;EACtD,OAAO,UAGL,KAAK,mBAAmB,KAAK,CAAC;CAClC;CAEA,mBAA2B,OAA2B;EACpD,OAAO,UACL,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAClC;CACF;AACF"}
1
+ {"version":3,"file":"postgres-contract-serializer-tGMiJcl4.mjs","names":[],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type AnyEntityKindDescriptor,\n type Namespace,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject, JsonValue } from '@prisma-next/utils/json';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport { policyEntityKind, roleEntityKind } from './entity-kinds';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n 'factory' in output &&\n typeof output.factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits hydration factories\n * keyed by the descriptor's `discriminator`. Used for `storage.types`\n * (codec-triple hydration). Namespace entries hydration dispatches by\n * entries key, not discriminator — handled by `hydrateNamespaceEntities`.\n */\nfunction collectStorageTypesHydrators(\n namespace: AuthoringEntityTypeNamespace,\n): ReadonlyMap<string, SqlEntityHydrationFactory> {\n const registry = new Map<string, SqlEntityHydrationFactory>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n registry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return registry;\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor(extraPackEntityKinds: readonly AnyEntityKindDescriptor[] = []) {\n const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);\n super(storageTypesHydrators, [policyEntityKind, roleEntityKind, ...extraPackEntityKinds]);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Record<string, unknown>,\n ): Namespace | SqlNamespaceInput {\n const hydrated = blindCast<\n SqlNamespaceInput,\n 'raw is always plain JSON, so super.hydrateSqlNamespaceEntry returns SqlNamespaceInput'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n const allSlotsEmpty = Object.values(entries).every(\n (slot) => slot === undefined || Object.keys(slot).length === 0,\n );\n if (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) {\n return PostgresSchema.unbound;\n }\n const valueSetSlot = entries['valueSet'];\n const hasValueSets = valueSetSlot !== undefined && Object.keys(valueSetSlot).length > 0;\n return new PostgresSchema({\n id,\n entries: {\n ...entries,\n table: entries['table'] ?? {},\n ...(hasValueSets ? { valueSet: valueSetSlot } : {}),\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [\n tableName,\n this.serializeJsonObject(table),\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonObject(entry);\n }\n storageOut['types'] = typesOut;\n }\n return blindCast<\n JsonObject,\n 'contract minus storage plus a JSON-shaped storageOut is a JsonObject'\n >({\n ...rest,\n storage: storageOut,\n });\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.table)) {\n tablesOut[tableName] = this.serializeJsonObject(table);\n }\n const valueSetEntries = ns.valueSet;\n const valueSetOut: Record<string, JsonObject> = {};\n if (valueSetEntries !== undefined) {\n for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) {\n valueSetOut[valueSetName] = this.serializeJsonObject(valueSet);\n }\n }\n const roleOut: Record<string, JsonObject> = {};\n for (const [roleName, role] of Object.entries(ns.role)) {\n roleOut[roleName] = this.serializeJsonObject(role);\n }\n const policyOut: Record<string, JsonObject> = {};\n for (const [policyName, policy] of Object.entries(ns.policy)) {\n policyOut[policyName] = this.serializeJsonObject(policy);\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n ...(Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}),\n ...(Object.keys(roleOut).length > 0 ? { role: roleOut } : {}),\n ...(Object.keys(policyOut).length > 0 ? { policy: policyOut } : {}),\n },\n };\n }\n\n private serializeJsonObject(value: unknown): JsonObject {\n return blindCast<\n JsonObject,\n 'serializeJsonValue round-trips an IR node through JSON, yielding a JsonObject'\n >(this.serializeJsonValue(value));\n }\n\n private serializeJsonValue(value: unknown): JsonValue {\n return blindCast<JsonValue, 'JSON.parse(JSON.stringify(x)) yields a JsonValue'>(\n JSON.parse(JSON.stringify(value)),\n );\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,aAAa,UACb,OAAO,OAAO,YAAY;AAE9B;;;;;;;AAQA,SAAS,6BACP,WACgD;CAChD,MAAM,2BAAW,IAAI,IAAuC;CAC5D,MAAM,QAAQ,SAA6C;EACzD,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GAAG;GACvC,IAAI,gCAAgC,KAAK,GAAG;IAC1C,IAAI,mCAAmC,MAAM,MAAM,GAAG;KACpD,MAAM,EAAE,YAAY,MAAM;KAC1B,SAAS,IAAI,MAAM,gBAAgB,QAAQ,QAAQ,KAAK,sBAAsB,CAAC;IACjF;IACA;GACF;GACA,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,KAAK,KAAK;EAEd;CACF;CACA,KAAK,SAAS;CACd,OAAO;AACT;AAEA,IAAa,6BAAb,cAAgD,0BAAgD;CAC9F,YAAY,uBAA2D,CAAC,GAAG;E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AK,MAAM,KAAK,UAAU,KAAK,CAAC,CAClC;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { A as installExtension, E as SetNotNullCall, S as DropTableCall, T as SetDefaultCall, _ as DropConstraintCall, b as DropNotNullCall, c as AlterColumnTypeCall, f as CreateSchemaCall, g as DropColumnCall, h as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateTableCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropDefaultCall, y as DropIndexCall } from "./op-factory-call-DcY4BHNh.mjs";
1
+ import { A as installExtension, E as SetNotNullCall, S as DropTableCall, T as SetDefaultCall, _ as DropConstraintCall, b as DropNotNullCall, c as AlterColumnTypeCall, f as CreateSchemaCall, g as DropColumnCall, h as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateTableCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropDefaultCall, y as DropIndexCall } from "./op-factory-call-DIdBDwmO.mjs";
2
2
  import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
3
  import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
4
4
  import { Migration } from "@prisma-next/family-sql/migration";
@@ -142,4 +142,4 @@ var PostgresMigration = class extends Migration {
142
142
  //#endregion
143
143
  export { PostgresMigration as t };
144
144
 
145
- //# sourceMappingURL=postgres-migration-Bj0olfl3.mjs.map
145
+ //# sourceMappingURL=postgres-migration-C8JZyTSJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-Bj0olfl3.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapter,\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapter);\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapter);\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapter);\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapter);\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapter);\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapter,\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return installExtension(options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAG2C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACtE,KAAK,cACP;CACF;CAEA,cAAwB,SAK0C;EAChE,IAAI,CAAC,KAAK,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AAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,cACP;CACF;CAEA,iBAA2B,SAKuC;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,iBAAiB,SAAS,KAAK,cAAc;CACtD;AACF"}
1
+ {"version":3,"file":"postgres-migration-C8JZyTSJ.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapter,\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapter);\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapter);\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapter);\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapter);\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapter);\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapter,\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return installExtension(options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,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,KAAK,KAAK,cAAc;CAC5B;CAEA,YAAsB,SAI4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,OACR,QAAQ,SACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,cACP;CACF;CAEA,iBAA2B,SAKuC;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,iBAAiB,SAAS,KAAK,cAAc;CACtD;AACF"}
@@ -1,11 +1,11 @@
1
1
  import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
2
2
  import { n as DataTransformOptions } from "./data-transform-qKy1U5V9.mjs";
3
- import { s as AlterColumnTypeOptions, w as ForeignKeySpec } from "./op-factory-call-CQ4P40QC.mjs";
3
+ import { s as AlterColumnTypeOptions, w as ForeignKeySpec } from "./op-factory-call-DPJR7tJc.mjs";
4
4
  import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
5
5
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
6
6
  import { SqlStorage } from "@prisma-next/sql-contract/types";
7
- import { Migration } from "@prisma-next/family-sql/migration";
8
7
  import { ControlStack } from "@prisma-next/framework-components/control";
8
+ import { Migration } from "@prisma-next/family-sql/migration";
9
9
  import { Contract } from "@prisma-next/contract/types";
10
10
  import { ExecuteRequestLowerer, SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
11
11
 
@@ -178,4 +178,4 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
178
178
  }
179
179
  //#endregion
180
180
  export { PostgresMigration as t };
181
- //# sourceMappingURL=postgres-migration-DJNJHcdP.d.mts.map
181
+ //# sourceMappingURL=postgres-migration-Cs7zMOe1.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-DJNJHcdP.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;;;;ACyC3B;;;;;;;;;;;;;;;AD3CA,uBC2CsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EA+CL;;;;;;EAAA,mBAvCe,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAkFkB;;;;;EAAA,UAnE5B,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EA+Fd;;;;;EAAA,UAnFb,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EA4HlC;;;;;EAAA,UA3GM,YAAA,CAAa,OAAA;IAAA,SACZ,MAAA;IAAA,SACA,WAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAO5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA,EAAQ,SAAA;EAAA,IACf,OAAA,CAAQ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EAAS,sBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAY5B,UAAA,CAAW,OAAA;IAAA,SACV,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,UAAA,CAAW,OAAA;IAAA,SACV,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;IAAA,SACA,UAAA;IAAA,SACA,cAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAa5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;IAAA,SACA,MAAA,GAAS,iBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAa5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,gBAAA,CAAiB,OAAA;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
1
+ {"version":3,"file":"postgres-migration-Cs7zMOe1.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAA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,UAAA;IAAA,SACA,cAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAa5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,MAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;IAAA,SACA,MAAA,GAAS,iBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAa5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAS5B,gBAAA,CAAiB,OAAA;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -1,8 +1,7 @@
1
- import { EntityCoordinate } from "@prisma-next/framework-components/ir";
2
1
  import { SqlNode } from "@prisma-next/sql-contract/types";
3
2
  import { DiffableNode } from "@prisma-next/framework-components/control";
4
3
 
5
- //#region src/core/postgres-rls-policy.d.ts
4
+ //#region src/core/schema-ir/postgres-rls-policy.d.ts
6
5
  type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
7
6
  interface PostgresRlsPolicyInput {
8
7
  /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */
@@ -44,7 +43,8 @@ declare class PostgresRlsPolicy extends SqlNode implements DiffableNode {
44
43
  readonly withCheck?: string;
45
44
  readonly permissive: boolean;
46
45
  constructor(input: PostgresRlsPolicyInput);
47
- identity(): EntityCoordinate;
46
+ get id(): string;
47
+ children(): readonly DiffableNode[];
48
48
  /**
49
49
  * Equality by wire name only. The wire name is `<prefix>_<sha256(body)[0..8]>`,
50
50
  * so name-equality IS body-equality — two policies with different bodies
@@ -57,4 +57,4 @@ declare class PostgresRlsPolicy extends SqlNode implements DiffableNode {
57
57
  }
58
58
  //#endregion
59
59
  export { PostgresRlsPolicyInput as n, RlsPolicyOperation as r, PostgresRlsPolicy as t };
60
- //# sourceMappingURL=postgres-rls-policy-D_z1osEq.d.mts.map
60
+ //# sourceMappingURL=postgres-rls-policy-12wAEQhs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-rls-policy-12wAEQhs.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-rls-policy.ts"],"mappings":";;;;KAIY,kBAAA;AAAA,UAEK,sBAAA;EAFL;EAAA,SAID,IAAA;;WAEA,MAAA;EANmB;EAAA,SAQnB,SAAA;EAN4B;EAAA,SAQ5B,WAAA;EAAA,SACA,SAAA,EAAW,kBAAkB;EAP7B;EAAA,SASA,KAAA;EALA;EAAA,SAOA,KAAA;EAJA;EAAA,SAMA,SAAA;EAJA;EAAA,SAMA,UAAA;AAAA;;;AAAU;AAYrB;;;;;;cAAa,iBAAA,SAA0B,OAAA,YAAmB,YAAA;EAAA,SACtC,IAAA;EAAA,SACT,IAAA;EAAA,SACA,MAAA;EAAA,SACA,SAAA;EAAA,SACA,WAAA;EAAA,SACA,SAAA,EAAW,kBAAA;EAAA,SACX,KAAA;EAAA,SACQ,KAAA;EAAA,SACA,SAAA;EAAA,SACR,UAAA;cAEG,KAAA,EAAO,sBAAA;EAAA,IAcf,EAAA;EAIJ,QAAA,aAAqB,YAAA;EAvBZ;;;;;;;;EAmCT,SAAA,CAAU,KAAA,EAAO,YAAA;AAAA"}
@@ -1,10 +1,43 @@
1
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 { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
2
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy-12wAEQhs.mjs";
3
+ import { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, SqlNode, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
5
4
  import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
5
+ import { DiffableNode } from "@prisma-next/framework-components/control";
6
+ import { Contract } from "@prisma-next/contract/types";
6
7
 
8
+ //#region src/core/schema-ir/postgres-role.d.ts
9
+ interface PostgresRoleInput {
10
+ readonly name: string;
11
+ /**
12
+ * Namespace coordinate. Roles are cluster-scoped; pass `UNBOUND_NAMESPACE_ID`
13
+ * from `@prisma-next/framework-components/ir`.
14
+ */
15
+ readonly namespaceId: string;
16
+ }
17
+ /**
18
+ * Postgres IR class for a database role (`CREATE ROLE …`).
19
+ *
20
+ * Roles are cluster-scoped, so their namespace coordinate is always
21
+ * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
22
+ * Extends `SqlNode` directly, frozen at construction via `freezeNode(this)`.
23
+ * The `kind: 'role'` discriminant is enumerable so it survives JSON.
24
+ * Matches the entries key (one-string rule).
25
+ */
26
+ declare class PostgresRole extends SqlNode implements DiffableNode {
27
+ readonly kind: "role";
28
+ readonly name: string;
29
+ readonly namespaceId: string;
30
+ constructor(input: PostgresRoleInput);
31
+ /** Roles are cluster-unique; the name alone is sufficient as the id. */
32
+ get id(): string;
33
+ children(): readonly DiffableNode[];
34
+ isEqualTo(other: DiffableNode): boolean;
35
+ }
36
+ //#endregion
7
37
  //#region src/core/postgres-schema.d.ts
38
+ type PostgresContract = Contract<SqlStorage> & {
39
+ readonly target: 'postgres';
40
+ };
8
41
  type PostgresNamespaceEntries = SqlNamespaceEntries & {
9
42
  readonly policy?: Readonly<Record<string, PostgresRlsPolicy>>;
10
43
  readonly role?: Readonly<Record<string, PostgresRole>>;
@@ -153,5 +186,5 @@ declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
153
186
  */
154
187
  declare function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema;
155
188
  //#endregion
156
- export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
157
- //# sourceMappingURL=postgres-schema-Bn4tsMuo.d.mts.map
189
+ export { postgresCreateNamespace as a, isPostgresSchema as i, PostgresSchema as n, PostgresRole as o, PostgresUnboundSchema as r, PostgresRoleInput as s, PostgresContract as t };
190
+ //# sourceMappingURL=postgres-schema-DJUEkWg-.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-DJUEkWg-.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-role.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;;UAIiB,iBAAA;EAAA,SACN,IAAA;;;;;WAKA,WAAW;AAAA;;;AAAA;AAYtB;;;;;;cAAa,YAAA,SAAqB,OAAA,YAAmB,YAAA;EAAA,SACjC,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,iBAAA;EALgC;EAAA,IAa/C,EAAA;EAIJ,QAAA,aAAqB,YAAA;EAIrB,SAAA,CAAU,KAAA,EAAO,YAAA;AAAA;;;KCjBP,gBAAA,GAAmB,QAAQ,CAAC,UAAA;EAAA,SAAyB,MAAA;AAAA;AAAA,KAErD,wBAAA,GAA2B,mBAAA;EAAA,SAC5B,MAAA,GAAS,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,SACjC,IAAA,GAAO,QAAA,CAAS,MAAA,SAAe,YAAA;AAAA;AAAA,UAGzB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA;AAAA;;;;;;;;;;;;;;;cAiBxC,cAAA,SAAuB,gBAAA;EDblC;;;;;;AAI6B;EAJ7B,OCqBO,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,wBAAA;cAEN,KAAA,EAAO,mBAAA;EAAA,IAgCf,KAAA,IAAS,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,IAIjC,QAAA,IAAY,QAAA,CAAS,MAAA,SAAe,eAAA;EAAA,IAIpC,MAAA,IAAU,QAAA,CAAS,MAAA,SAAe,iBAAA;EAAA,IAIlC,IAAA,IAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EApF2B;;AAAM;AAEvE;;EA2FE,SAAA;EA3FqC;;;;;;EAqGrC,YAAA,CAAa,SAAA;EAnGW;;;;;;EA6GxB,eAAA,CAAgB,IAAA;EA7GP;;;;;AAA2C;AAGtD;;EAsHE,mBAAA;EApHmD;;;;;;;EA+HnD,sBAAA,IAA0B,MAAA;EA/HR;;;;;AAAuC;AAiB3D;EAyHE,WAAA,CAAY,SAAA,UAAmB,KAAA,YAAiB,mBAAA;;;;;;;;;;;;EAmBhD,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;;;;;;;;;;;;;;;;;cAwBb,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,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;;;;;;;;;;;;iBAenD,uBAAA,CAAwB,KAAA,EAAO,iBAAA,GAAoB,cAAc"}
@@ -8,7 +8,26 @@ import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@pri
8
8
  import { SqlNamespaceBase, SqlNode } from "@prisma-next/sql-contract/types";
9
9
  import { composeSqlEntityKinds } from "@prisma-next/sql-contract/entity-kinds";
10
10
  import { cfExpr } from "@prisma-next/sql-relational-core/contract-free";
11
- //#region src/core/postgres-rls-policy.ts
11
+ //#region src/core/postgres-validators.ts
12
+ const PostgresRoleSchema = type({
13
+ kind: "'role'",
14
+ name: "string",
15
+ namespaceId: "string"
16
+ });
17
+ const PostgresRlsPolicySchema = type({
18
+ kind: "'policy'",
19
+ name: "string",
20
+ prefix: "string",
21
+ tableName: "string",
22
+ namespaceId: "string",
23
+ operation: "'select' | 'insert' | 'update' | 'delete' | 'all'",
24
+ roles: type.string.array().readonly(),
25
+ "using?": "string",
26
+ "withCheck?": "string",
27
+ permissive: "boolean"
28
+ });
29
+ //#endregion
30
+ //#region src/core/schema-ir/postgres-rls-policy.ts
12
31
  /**
13
32
  * Postgres IR class for a row-level security policy (`CREATE POLICY … ON …`).
14
33
  *
@@ -40,13 +59,11 @@ var PostgresRlsPolicy = class extends SqlNode {
40
59
  this.permissive = input.permissive;
41
60
  freezeNode(this);
42
61
  }
43
- identity() {
44
- return {
45
- plane: "storage",
46
- namespaceId: this.namespaceId,
47
- entityKind: "policy",
48
- entityName: this.name
49
- };
62
+ get id() {
63
+ return this.name;
64
+ }
65
+ children() {
66
+ return [];
50
67
  }
51
68
  /**
52
69
  * Equality by wire name only. The wire name is `<prefix>_<sha256(body)[0..8]>`,
@@ -57,7 +74,7 @@ var PostgresRlsPolicy = class extends SqlNode {
57
74
  * the authored body would produce false mismatches on a clean re-verify.
58
75
  */
59
76
  isEqualTo(other) {
60
- if (!isPostgresRlsPolicy(other)) throw new Error(`PostgresRlsPolicy.isEqualTo: expected a PostgresRlsPolicy, got ${other.identity().entityKind}`);
77
+ if (!isPostgresRlsPolicy(other)) throw new Error(`PostgresRlsPolicy.isEqualTo: expected a PostgresRlsPolicy, got ${other.constructor?.name ?? typeof other}`);
61
78
  return this.name === other.name;
62
79
  }
63
80
  };
@@ -67,11 +84,11 @@ function isPostgresRlsPolicy(node) {
67
84
  function assertPostgresRlsPolicy(node) {
68
85
  if (!isPostgresRlsPolicy(node)) {
69
86
  const kind = node !== void 0 && "kind" in node ? String(node.kind) : typeof node;
70
- throw new Error(`planRlsDiff: expected a PostgresRlsPolicy on the policy-diff path but got ${kind}`);
87
+ throw new Error(`planPostgresSchemaDiff: expected a PostgresRlsPolicy on the policy-diff path but got ${kind}`);
71
88
  }
72
89
  }
73
90
  //#endregion
74
- //#region src/core/postgres-role.ts
91
+ //#region src/core/schema-ir/postgres-role.ts
75
92
  /**
76
93
  * Postgres IR class for a database role (`CREATE ROLE …`).
77
94
  *
@@ -91,39 +108,19 @@ var PostgresRole = class PostgresRole extends SqlNode {
91
108
  this.namespaceId = input.namespaceId;
92
109
  freezeNode(this);
93
110
  }
94
- identity() {
95
- return {
96
- plane: "storage",
97
- namespaceId: this.namespaceId,
98
- entityKind: "role",
99
- entityName: this.name
100
- };
111
+ /** Roles are cluster-unique; the name alone is sufficient as the id. */
112
+ get id() {
113
+ return this.name;
114
+ }
115
+ children() {
116
+ return [];
101
117
  }
102
118
  isEqualTo(other) {
103
- if (!(other instanceof PostgresRole)) throw new Error(`PostgresRole.isEqualTo: expected a PostgresRole, got ${other.identity().entityKind}`);
119
+ if (!(other instanceof PostgresRole)) throw new Error(`PostgresRole.isEqualTo: expected a PostgresRole, got ${other.constructor?.name ?? typeof other}`);
104
120
  return this.name === other.name;
105
121
  }
106
122
  };
107
123
  //#endregion
108
- //#region src/core/postgres-validators.ts
109
- const PostgresRoleSchema = type({
110
- kind: "'role'",
111
- name: "string",
112
- namespaceId: "string"
113
- });
114
- const PostgresRlsPolicySchema = type({
115
- kind: "'policy'",
116
- name: "string",
117
- prefix: "string",
118
- tableName: "string",
119
- namespaceId: "string",
120
- operation: "'select' | 'insert' | 'update' | 'delete' | 'all'",
121
- roles: type.string.array().readonly(),
122
- "using?": "string",
123
- "withCheck?": "string",
124
- permissive: "boolean"
125
- });
126
- //#endregion
127
124
  //#region src/core/ast/table-source.ts
128
125
  var PostgresTableSource = class extends TableSource {
129
126
  schema;
@@ -366,6 +363,6 @@ function postgresCreateNamespace(input) {
366
363
  return new PostgresSchema(schemaInput);
367
364
  }
368
365
  //#endregion
369
- export { policyEntityKind as a, PostgresRlsPolicySchema as c, PostgresRlsPolicy as d, assertPostgresRlsPolicy as f, postgresCreateNamespace as i, PostgresRoleSchema as l, PostgresUnboundSchema as n, roleEntityKind as o, isPostgresSchema as r, PostgresTableSource as s, PostgresSchema as t, PostgresRole as u };
366
+ export { policyEntityKind as a, PostgresRole as c, isPostgresRlsPolicy as d, PostgresRlsPolicySchema as f, postgresCreateNamespace as i, PostgresRlsPolicy as l, PostgresUnboundSchema as n, roleEntityKind as o, PostgresRoleSchema as p, isPostgresSchema as r, PostgresTableSource as s, PostgresSchema as t, assertPostgresRlsPolicy as u };
370
367
 
371
- //# sourceMappingURL=postgres-schema-DfuJq-q_.mjs.map
368
+ //# sourceMappingURL=postgres-schema-DLcc3W2-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-DLcc3W2-.mjs","names":[],"sources":["../src/core/postgres-validators.ts","../src/core/schema-ir/postgres-rls-policy.ts","../src/core/schema-ir/postgres-role.ts","../src/core/ast/table-source.ts","../src/core/entity-kinds.ts","../src/core/postgres-schema.ts"],"sourcesContent":["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 type { DiffableNode } from '@prisma-next/framework-components/control';\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 get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\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.constructor?.name ?? typeof other}`,\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 `planPostgresSchemaDiff: 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 { 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 /** Roles are cluster-unique; the name alone is sufficient as the id. */\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n if (!(other instanceof PostgresRole)) {\n throw new Error(\n `PostgresRole.isEqualTo: expected a PostgresRole, got ${other.constructor?.name ?? typeof other}`,\n );\n }\n return this.name === other.name;\n }\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 { PostgresRlsPolicySchema, PostgresRoleSchema } from './postgres-validators';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from './schema-ir/postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './schema-ir/postgres-role';\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 type { Contract } from '@prisma-next/contract/types';\nimport {\n freezeNode,\n hydrateNamespaceEntities,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { composeSqlEntityKinds } from '@prisma-next/sql-contract/entity-kinds';\nimport {\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceInput,\n type SqlStorage,\n type StorageTable,\n type StorageValueSet,\n} from '@prisma-next/sql-contract/types';\n\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 './schema-ir/postgres-rls-policy';\nimport type { PostgresRole } from './schema-ir/postgres-role';\nimport { escapeLiteral } from './sql-utils';\n\nexport type PostgresContract = Contract<SqlStorage> & { readonly target: 'postgres' };\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 SqlNamespaceBase {\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: SqlNamespaceInput): 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":";;;;;;;;;;;AAEA,MAAa,qBAAqB,KAAK;CACrC,MAAM;CACN,MAAM;CACN,aAAa;AACf,CAAC;AAED,MAAa,0BAA0B,KAAK;CAC1C,MAAM;CACN,MAAM;CACN,QAAQ;CACR,WAAW;CACX,aAAa;CACb,WAAW;CACX,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,SAAS;CACpC,UAAU;CACV,cAAc;CACd,YAAY;AACd,CAAC;;;;;;;;;;;;ACgBD,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,MAAM;EACvB,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;EAC3C,IAAI,MAAM,UAAU,KAAA,GAAW,KAAK,QAAQ,MAAM;EAClD,IAAI,MAAM,cAAc,KAAA,GAAW,KAAK,YAAY,MAAM;EAC1D,KAAK,aAAa,MAAM;EACxB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,WAAoC;EAClC,OAAO,CAAC;CACV;;;;;;;;;CAUA,UAAU,OAA8B;EACtC,IAAI,CAAC,oBAAoB,KAAK,GAC5B,MAAM,IAAI,MACR,kEAAkE,MAAM,aAAa,QAAQ,OAAO,OACtG;EAEF,OAAO,KAAK,SAA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;;;CAaA,cAAc,UAA8B;EAC1C,OAAO,KAAK;CACd;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,OAAgB,WAAkC,IAAI,sBAAsB;CAE5E,YAAY,OAA6B;EACvC,MAAM,SAAS;GAAE,IAAI;GAAsB,SAAS,EAAE,OAAO,CAAC,EAAE;EAAE,CAAC;CACrE;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;CAEA,yBAA0C;EACxC,OAAO,OAAO,IAAI,oBAAoB;GAAE,SAAS;GAAkB,UAAU;EAAM,CAAC;CACtF;CAEA,YAAqB,WAAmB,OAAqC;EAC3E,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,OAA0C;CAChF,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,102 @@
1
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy-12wAEQhs.mjs";
2
+ import { o as PostgresRole } from "./postgres-schema-DJUEkWg-.mjs";
3
+ import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlSchemaIRNode, SqlSchemaTarget, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
4
+ import { DiffableNode } from "@prisma-next/framework-components/control";
5
+
6
+ //#region src/core/schema-ir/postgres-table-ir.d.ts
7
+ interface PostgresTableIRInput extends SqlTableIRInput {
8
+ readonly rlsPolicies?: readonly PostgresRlsPolicy[];
9
+ }
10
+ /**
11
+ * Postgres-specific table IR node. Carries all `SqlTableIR` fields plus
12
+ * `rlsPolicies`, and implements `DiffableNode` so the table instance is
13
+ * directly the diff-tree node — no separate wrapper needed.
14
+ *
15
+ * Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because
16
+ * `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
17
+ * subclass field initialisation. Same pattern as `PostgresSchemaIR`.
18
+ *
19
+ * `id` is the table name. `children()` returns the policies on this table.
20
+ * `isEqualTo` is always true — table-level attributes are not diffed yet.
21
+ */
22
+ declare class PostgresTableIR extends SqlSchemaIRNode implements DiffableNode {
23
+ readonly name: string;
24
+ readonly columns: Readonly<Record<string, SqlColumnIR>>;
25
+ readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
26
+ readonly uniques: ReadonlyArray<SqlUniqueIR>;
27
+ readonly indexes: ReadonlyArray<SqlIndexIR>;
28
+ readonly primaryKey?: PrimaryKey;
29
+ readonly annotations?: SqlAnnotations;
30
+ readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;
31
+ readonly rlsPolicies: readonly PostgresRlsPolicy[];
32
+ constructor(input: PostgresTableIRInput);
33
+ get id(): string;
34
+ isEqualTo(_other: DiffableNode): boolean;
35
+ children(): readonly DiffableNode[];
36
+ }
37
+ declare function isPostgresTableIR(node: DiffableNode): node is PostgresTableIR;
38
+ //#endregion
39
+ //#region src/core/schema-ir/postgres-schema-ir.d.ts
40
+ interface PostgresSchemaIRInput {
41
+ readonly tables: Record<string, PostgresTableIR | (SqlTableIRInput & {
42
+ rlsPolicies?: readonly PostgresRlsPolicy[];
43
+ })>;
44
+ readonly pgSchemaName: string;
45
+ readonly pgVersion: string;
46
+ readonly roles: readonly PostgresRole[];
47
+ readonly existingSchemas: readonly string[];
48
+ readonly nativeEnumTypeNames: readonly string[];
49
+ }
50
+ /**
51
+ * Postgres-specific schema IR. Mirrors the structure of `SqlSchemaIR`
52
+ * (same `tables` + optional `annotations` fields) and adds typed fields for
53
+ * data the postgres adapter collects during introspection.
54
+ *
55
+ * Extends `SqlSchemaIRNode` directly rather than `SqlSchemaIR` because
56
+ * `SqlSchemaIR` calls `freezeNode` in its constructor, which prevents
57
+ * subclass field initialisation. `PostgresSchemaIR` replicates the minimal
58
+ * `SqlSchemaIR` structure and freezes itself at the end of its own
59
+ * constructor.
60
+ *
61
+ * `tables` holds `PostgresTableIR` instances which carry their own RLS
62
+ * policies. `children()` returns the tables directly — the table instances
63
+ * ARE the diff-tree nodes.
64
+ *
65
+ * Nothing RLS-specific leaks into the sql-family layer.
66
+ */
67
+ declare class PostgresSchemaIR extends SqlSchemaIRNode implements DiffableNode {
68
+ readonly nodeTarget: SqlSchemaTarget;
69
+ readonly tables: Readonly<Record<string, PostgresTableIR>>;
70
+ readonly annotations?: SqlAnnotations;
71
+ readonly pgSchemaName: string;
72
+ readonly pgVersion: string;
73
+ readonly roles: readonly PostgresRole[];
74
+ readonly existingSchemas: readonly string[];
75
+ readonly nativeEnumTypeNames: readonly string[];
76
+ constructor(input: PostgresSchemaIRInput);
77
+ get id(): string;
78
+ get rlsPolicies(): readonly PostgresRlsPolicy[];
79
+ isEqualTo(_other: DiffableNode): boolean;
80
+ children(): readonly DiffableNode[];
81
+ }
82
+ /**
83
+ * Structural guard for `PostgresSchemaIR`, narrowing on the `nodeTarget`
84
+ * discriminant rather than `instanceof`. `nodeTarget` is an enumerable own field
85
+ * (a plain class-field initializer), so it survives the `{ ...schema, tables }`
86
+ * spread the multi-space verify path (`projectSchemaToSpace`) produces — that
87
+ * projected object is not a class instance but retains every enumerable own
88
+ * property. The family-level `kind = 'sql-schema-ir'` discriminator is unusable
89
+ * here: it is shared by every SQL schema-IR node and is non-enumerable (dropped
90
+ * by the spread).
91
+ */
92
+ declare function isPostgresSchemaIR(schema: SqlSchemaIR): schema is PostgresSchemaIR;
93
+ declare function assertPostgresSchemaIR(schema: SqlSchemaIR): asserts schema is PostgresSchemaIR;
94
+ /**
95
+ * Returns `schema` as-is when it is a real `PostgresSchemaIR` instance, or
96
+ * reconstructs one when `projectSchemaToSpace` has spread the class into a
97
+ * plain object (losing prototype methods).
98
+ */
99
+ declare function ensurePostgresSchemaIR(schema: PostgresSchemaIR): PostgresSchemaIR;
100
+ //#endregion
101
+ export { isPostgresSchemaIR as a, isPostgresTableIR as c, ensurePostgresSchemaIR as i, PostgresSchemaIRInput as n, PostgresTableIR as o, assertPostgresSchemaIR as r, PostgresTableIRInput as s, PostgresSchemaIR as t };
102
+ //# sourceMappingURL=postgres-schema-ir-BJl_a3J7.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-ir-BJl_a3J7.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-table-ir.ts","../src/core/schema-ir/postgres-schema-ir.ts"],"mappings":";;;;;;UAeiB,oBAAA,SAA6B,eAAe;EAAA,SAClD,WAAA,YAAuB,iBAAA;AAAA;AADlC;;;;;;;;AACmD;AAenD;;;AAhBA,cAgBa,eAAA,SAAwB,eAAA,YAA2B,YAAA;EAAA,SACrD,IAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,WAAA;EAAA,SACjC,WAAA,EAAa,aAAA,CAAc,eAAA;EAAA,SAC3B,OAAA,EAAS,aAAA,CAAc,WAAA;EAAA,SACvB,OAAA,EAAS,aAAA,CAAc,UAAA;EAAA,SACf,UAAA,GAAa,UAAA;EAAA,SACb,WAAA,GAAc,cAAA;EAAA,SACd,MAAA,GAAS,aAAA,CAAc,oBAAA;EAAA,SAC/B,WAAA,WAAsB,iBAAA;cAEnB,KAAA,EAAO,oBAAA;EAAA,IAsCf,EAAA;EAIJ,SAAA,CAAU,MAAA,EAAQ,YAAA;EAIlB,QAAA,aAAqB,YAAA;AAAA;AAA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