@prisma-next/target-postgres 0.14.0-dev.39 → 0.14.0-dev.40

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 (106) hide show
  1. package/dist/{authoring-CZmSQriw.mjs → authoring-BX1WHIdN.mjs} +2 -2
  2. package/dist/authoring-BX1WHIdN.mjs.map +1 -0
  3. package/dist/contract-free.mjs +2 -2
  4. package/dist/control.d.mts.map +1 -1
  5. package/dist/control.mjs +633 -16
  6. package/dist/control.mjs.map +1 -1
  7. package/dist/{ddl-CGf6UABz.mjs → ddl-BmLIe1z_.mjs} +2 -2
  8. package/dist/{ddl-CGf6UABz.mjs.map → ddl-BmLIe1z_.mjs.map} +1 -1
  9. package/dist/{descriptor-meta-Du6olWQI.mjs → descriptor-meta-tjatyhtZ.mjs} +3 -3
  10. package/dist/{descriptor-meta-Du6olWQI.mjs.map → descriptor-meta-tjatyhtZ.mjs.map} +1 -1
  11. package/dist/{issue-planner-C-CwZd8D.mjs → issue-planner-DbFvaAgu.mjs} +5 -5
  12. package/dist/issue-planner-DbFvaAgu.mjs.map +1 -0
  13. package/dist/issue-planner.d.mts +1 -1
  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-DPJR7tJc.d.mts → op-factory-call-CJWUxyUW.d.mts} +2 -2
  18. package/dist/{op-factory-call-DPJR7tJc.d.mts.map → op-factory-call-CJWUxyUW.d.mts.map} +1 -1
  19. package/dist/{op-factory-call-DArx_1HM.mjs → op-factory-call-t65c4jyY.mjs} +3 -3
  20. package/dist/op-factory-call-t65c4jyY.mjs.map +1 -0
  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 -2
  24. package/dist/pack.mjs +1 -1
  25. package/dist/{planner-BQ7lSqbm.mjs → planner-CG2pLHk-.mjs} +310 -126
  26. package/dist/planner-CG2pLHk-.mjs.map +1 -0
  27. package/dist/{planner-produced-postgres-migration-3ppG0t3i.mjs → planner-produced-postgres-migration-BolD0Mvc.mjs} +2 -2
  28. package/dist/{planner-produced-postgres-migration-3ppG0t3i.mjs.map → planner-produced-postgres-migration-BolD0Mvc.mjs.map} +1 -1
  29. package/dist/{planner-produced-postgres-migration-BauTSigX.d.mts → planner-produced-postgres-migration-Cz9--XOT.d.mts} +2 -2
  30. package/dist/{planner-produced-postgres-migration-BauTSigX.d.mts.map → planner-produced-postgres-migration-Cz9--XOT.d.mts.map} +1 -1
  31. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  32. package/dist/planner-produced-postgres-migration.mjs +1 -1
  33. package/dist/{planner-sql-checks-CyjaoKhm.mjs → planner-sql-checks-DE9c4519.mjs} +2 -2
  34. package/dist/{planner-sql-checks-CyjaoKhm.mjs.map → planner-sql-checks-DE9c4519.mjs.map} +1 -1
  35. package/dist/planner-sql-checks.mjs +1 -1
  36. package/dist/planner.d.mts +73 -22
  37. package/dist/planner.d.mts.map +1 -1
  38. package/dist/planner.mjs +2 -2
  39. package/dist/{postgres-contract-view-CoRZewAp.mjs → postgres-contract-view-BegduLr6.mjs} +3 -3
  40. package/dist/{postgres-contract-view-CoRZewAp.mjs.map → postgres-contract-view-BegduLr6.mjs.map} +1 -1
  41. package/dist/postgres-database-schema-node-os8ogEap.d.mts +183 -0
  42. package/dist/postgres-database-schema-node-os8ogEap.d.mts.map +1 -0
  43. package/dist/{postgres-migration-BVjq0iFW.mjs → postgres-migration-BfMmK6tv.mjs} +3 -3
  44. package/dist/{postgres-migration-BVjq0iFW.mjs.map → postgres-migration-BfMmK6tv.mjs.map} +1 -1
  45. package/dist/{postgres-migration-UtGCjw5j.d.mts → postgres-migration-D7kNVWVG.d.mts} +2 -2
  46. package/dist/{postgres-migration-UtGCjw5j.d.mts.map → postgres-migration-D7kNVWVG.d.mts.map} +1 -1
  47. package/dist/{postgres-rls-policy-12wAEQhs.d.mts → postgres-rls-policy--CSddvMR.d.mts} +8 -16
  48. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  49. package/dist/{postgres-schema-DLcc3W2-.mjs → postgres-schema-BLIHBEfX.mjs} +34 -64
  50. package/dist/postgres-schema-BLIHBEfX.mjs.map +1 -0
  51. package/dist/{postgres-schema-DJUEkWg-.d.mts → postgres-schema-BywoeKlt.d.mts} +9 -10
  52. package/dist/postgres-schema-BywoeKlt.d.mts.map +1 -0
  53. package/dist/postgres-table-schema-node-1nNc8XDT.mjs +248 -0
  54. package/dist/postgres-table-schema-node-1nNc8XDT.mjs.map +1 -0
  55. package/dist/resolve-ddl-schema-CL1RR1mx.mjs +20 -0
  56. package/dist/resolve-ddl-schema-CL1RR1mx.mjs.map +1 -0
  57. package/dist/runtime.mjs +1 -1
  58. package/dist/schema-ir-annotations.d.mts +9 -3
  59. package/dist/schema-ir-annotations.d.mts.map +1 -1
  60. package/dist/schema-ir-annotations.mjs +1 -1
  61. package/dist/types.d.mts +4 -4
  62. package/dist/types.mjs +3 -3
  63. package/package.json +20 -19
  64. package/src/core/authoring.ts +2 -2
  65. package/src/core/entity-kinds.ts +2 -2
  66. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +125 -0
  67. package/src/core/migrations/diff-database-schema.ts +191 -0
  68. package/src/core/migrations/issue-planner.ts +1 -1
  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 +117 -68
  72. package/src/core/{schema-ir/postgres-schema-ir-annotations.ts → migrations/resolve-ddl-schema.ts} +8 -6
  73. package/src/core/migrations/runner.ts +13 -16
  74. package/src/core/migrations/verify-postgres-namespaces.ts +22 -14
  75. package/src/core/{schema-ir/postgres-rls-policy.ts → postgres-rls-policy.ts} +6 -43
  76. package/src/core/{schema-ir/postgres-role.ts → postgres-role.ts} +6 -21
  77. package/src/core/postgres-schema.ts +2 -2
  78. package/src/core/psl-infer/infer-psl-contract.ts +834 -0
  79. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  80. package/src/core/psl-infer/postgres-type-map.ts +157 -0
  81. package/src/core/schema-ir/postgres-database-schema-node.ts +63 -0
  82. package/src/core/schema-ir/postgres-namespace-schema-node.ts +61 -0
  83. package/src/core/schema-ir/postgres-policy-schema-node.ts +93 -0
  84. package/src/core/schema-ir/postgres-role-schema-node.ts +66 -0
  85. package/src/core/schema-ir/{postgres-table-ir.ts → postgres-table-schema-node.ts} +29 -18
  86. package/src/core/schema-ir/schema-node-kinds.ts +28 -0
  87. package/src/exports/control.ts +30 -2
  88. package/src/exports/planner.ts +2 -5
  89. package/src/exports/schema-ir-annotations.ts +1 -1
  90. package/src/exports/types.ts +23 -15
  91. package/dist/authoring-CZmSQriw.mjs.map +0 -1
  92. package/dist/issue-planner-C-CwZd8D.mjs.map +0 -1
  93. package/dist/op-factory-call-DArx_1HM.mjs.map +0 -1
  94. package/dist/planner-BQ7lSqbm.mjs.map +0 -1
  95. package/dist/postgres-rls-policy-12wAEQhs.d.mts.map +0 -1
  96. package/dist/postgres-schema-DJUEkWg-.d.mts.map +0 -1
  97. package/dist/postgres-schema-DLcc3W2-.mjs.map +0 -1
  98. package/dist/postgres-schema-ir-BJl_a3J7.d.mts +0 -102
  99. package/dist/postgres-schema-ir-BJl_a3J7.d.mts.map +0 -1
  100. package/dist/postgres-schema-ir-I_FiUndw.mjs +0 -133
  101. package/dist/postgres-schema-ir-I_FiUndw.mjs.map +0 -1
  102. package/dist/postgres-schema-ir-annotations-BbDSiwx2.mjs +0 -14
  103. package/dist/postgres-schema-ir-annotations-BbDSiwx2.mjs.map +0 -1
  104. package/src/core/migrations/contract-to-postgres-schema-ir.ts +0 -91
  105. package/src/core/migrations/diff-postgres-schema.ts +0 -55
  106. package/src/core/schema-ir/postgres-schema-ir.ts +0 -138
@@ -0,0 +1,183 @@
1
+ import { r as RlsPolicyOperation } from "./postgres-rls-policy--CSddvMR.mjs";
2
+ import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
3
+ import { DiffableNode } from "@prisma-next/framework-components/control";
4
+
5
+ //#region src/core/schema-ir/postgres-policy-schema-node.d.ts
6
+ interface PostgresPolicySchemaNodeInput {
7
+ /** Full wire name: `<prefix>_<8hex>`. */
8
+ readonly name: string;
9
+ /** User-supplied prefix (the part before the `_<8hex>` suffix). */
10
+ readonly prefix: string;
11
+ /** Name of the table this policy attaches to, by name within the same schema. */
12
+ readonly tableName: string;
13
+ /** Namespace coordinate (schema name). */
14
+ readonly namespaceId: string;
15
+ readonly operation: RlsPolicyOperation;
16
+ /** Sorted role names rendered in `TO <roles>`. */
17
+ readonly roles: readonly string[];
18
+ /** USING predicate SQL string, if present. */
19
+ readonly using?: string;
20
+ /** WITH CHECK predicate SQL string, if present. */
21
+ readonly withCheck?: string;
22
+ /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
23
+ readonly permissive: boolean;
24
+ }
25
+ /**
26
+ * Schema-diff leaf node for a Postgres row-level security policy.
27
+ *
28
+ * This is a derived, transient node walked by the differ — it is NEVER serialized.
29
+ * Built by project-from-contract and project-from-database from their respective
30
+ * `PostgresRlsPolicy` contract entities / introspected rows.
31
+ *
32
+ * `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is
33
+ * body-equality. `isEqualTo` compares names only — never byte-compare predicate
34
+ * bodies, because Postgres reprints them.
35
+ */
36
+ declare class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {
37
+ readonly nodeKind: "postgres-policy";
38
+ readonly name: string;
39
+ readonly prefix: string;
40
+ readonly tableName: string;
41
+ readonly namespaceId: string;
42
+ readonly operation: RlsPolicyOperation;
43
+ readonly roles: readonly string[];
44
+ readonly using?: string;
45
+ readonly withCheck?: string;
46
+ readonly permissive: boolean;
47
+ constructor(input: PostgresPolicySchemaNodeInput);
48
+ get id(): string;
49
+ children(): readonly DiffableNode[];
50
+ isEqualTo(other: DiffableNode): boolean;
51
+ static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode;
52
+ static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode;
53
+ }
54
+ //#endregion
55
+ //#region src/core/schema-ir/postgres-table-schema-node.d.ts
56
+ interface PostgresTableSchemaNodeInput extends SqlTableIRInput {
57
+ readonly policies?: readonly PostgresPolicySchemaNode[];
58
+ }
59
+ /**
60
+ * Postgres-specific table schema-diff node. Carries all `SqlTableIR` fields
61
+ * plus `policies`, and implements `DiffableNode` so the table instance is
62
+ * directly the diff-tree node — no separate wrapper needed.
63
+ *
64
+ * Extends `SqlSchemaIRNode` directly rather than `SqlTableIR` because
65
+ * `SqlTableIR` calls `freezeNode` in its own constructor, which prevents
66
+ * subclass field initialisation.
67
+ *
68
+ * `id` is the table name. `children()` returns the policy nodes on this table.
69
+ * `isEqualTo` is identity — two table nodes are equal iff their ids (names)
70
+ * match. Columns are not compared here; they become child nodes later.
71
+ */
72
+ declare class PostgresTableSchemaNode extends SqlSchemaIRNode implements DiffableNode {
73
+ readonly nodeKind: "postgres-table";
74
+ readonly name: string;
75
+ readonly columns: Readonly<Record<string, SqlColumnIR>>;
76
+ readonly foreignKeys: ReadonlyArray<SqlForeignKeyIR>;
77
+ readonly uniques: ReadonlyArray<SqlUniqueIR>;
78
+ readonly indexes: ReadonlyArray<SqlIndexIR>;
79
+ readonly primaryKey?: PrimaryKey;
80
+ readonly annotations?: SqlAnnotations;
81
+ readonly checks?: ReadonlyArray<SqlCheckConstraintIR>;
82
+ readonly policies: readonly PostgresPolicySchemaNode[];
83
+ constructor(input: PostgresTableSchemaNodeInput);
84
+ get id(): string;
85
+ isEqualTo(other: DiffableNode): boolean;
86
+ children(): readonly DiffableNode[];
87
+ static is(node: SqlSchemaIRNode): node is PostgresTableSchemaNode;
88
+ static assert(node: SqlSchemaIRNode): asserts node is PostgresTableSchemaNode;
89
+ }
90
+ //#endregion
91
+ //#region src/core/schema-ir/postgres-namespace-schema-node.d.ts
92
+ interface PostgresNamespaceSchemaNodeInput {
93
+ readonly schemaName: string;
94
+ readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
95
+ readonly nativeEnumTypeNames: readonly string[];
96
+ }
97
+ /**
98
+ * One-per-Postgres-schema diff-tree node. Groups the tables belonging to a
99
+ * single namespace and satisfies the `SqlSchemaIR` shape so legacy per-schema
100
+ * consumers (verifySqlSchema, the relational planner, toSchemaView) can
101
+ * accept it unchanged in Unit 6.
102
+ *
103
+ * `id` is the schema name. `isEqualTo` is identity — two namespace nodes are
104
+ * equal iff their ids (schema names) match. `children()` returns the table
105
+ * nodes. Per-schema metadata is carried on the typed `nativeEnumTypeNames`
106
+ * field, not an annotations bag.
107
+ */
108
+ declare class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {
109
+ readonly nodeKind: "postgres-namespace";
110
+ readonly schemaName: string;
111
+ readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;
112
+ readonly nativeEnumTypeNames: readonly string[];
113
+ constructor(input: PostgresNamespaceSchemaNodeInput);
114
+ get id(): string;
115
+ isEqualTo(other: DiffableNode): boolean;
116
+ children(): readonly DiffableNode[];
117
+ static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode;
118
+ static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode;
119
+ }
120
+ //#endregion
121
+ //#region src/core/schema-ir/postgres-role-schema-node.d.ts
122
+ interface PostgresRoleSchemaNodeInput {
123
+ readonly name: string;
124
+ /**
125
+ * Namespace coordinate. Roles are cluster-scoped; callers pass
126
+ * `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.
127
+ */
128
+ readonly namespaceId: string;
129
+ }
130
+ /**
131
+ * Schema-diff leaf node for a Postgres database role.
132
+ *
133
+ * This is a derived, transient node walked by the differ — it is NEVER serialized.
134
+ * Built by project-from-contract and project-from-database from their respective
135
+ * `PostgresRole` contract entities / introspected rows.
136
+ *
137
+ * Roles are cluster-scoped, so `id` is the role name alone. `isEqualTo` compares
138
+ * names — name-equality is role-equality for cluster-scoped objects.
139
+ */
140
+ declare class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {
141
+ readonly nodeKind: "postgres-role";
142
+ readonly name: string;
143
+ readonly namespaceId: string;
144
+ constructor(input: PostgresRoleSchemaNodeInput);
145
+ get id(): string;
146
+ children(): readonly DiffableNode[];
147
+ isEqualTo(other: DiffableNode): boolean;
148
+ static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode;
149
+ static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode;
150
+ }
151
+ //#endregion
152
+ //#region src/core/schema-ir/postgres-database-schema-node.d.ts
153
+ interface PostgresDatabaseSchemaNodeInput {
154
+ readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
155
+ readonly roles: readonly PostgresRoleSchemaNode[];
156
+ readonly existingSchemas: readonly string[];
157
+ readonly pgVersion: string;
158
+ }
159
+ /**
160
+ * The root of the Postgres schema-diff tree: one node per database.
161
+ *
162
+ * `id` is the fixed sentinel `'database'` — the root has no siblings and
163
+ * the value is never emitted into migration paths. `isEqualTo` is identity
164
+ * (roots always share the `'database'` id). `children()` returns namespace
165
+ * nodes only; roles are held on the root but not yielded (role diffing is a
166
+ * later slice).
167
+ */
168
+ declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {
169
+ readonly nodeKind: "postgres-database";
170
+ readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
171
+ readonly roles: readonly PostgresRoleSchemaNode[];
172
+ readonly existingSchemas: readonly string[];
173
+ readonly pgVersion: string;
174
+ constructor(input: PostgresDatabaseSchemaNodeInput);
175
+ get id(): string;
176
+ isEqualTo(other: DiffableNode): boolean;
177
+ children(): readonly DiffableNode[];
178
+ static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode;
179
+ static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode;
180
+ }
181
+ //#endregion
182
+ export { PostgresNamespaceSchemaNode as a, PostgresTableSchemaNodeInput as c, PostgresRoleSchemaNodeInput as i, PostgresPolicySchemaNode as l, PostgresDatabaseSchemaNodeInput as n, PostgresNamespaceSchemaNodeInput as o, PostgresRoleSchemaNode as r, PostgresTableSchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresPolicySchemaNodeInput as u };
183
+ //# sourceMappingURL=postgres-database-schema-node-os8ogEap.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-database-schema-node-os8ogEap.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts","../src/core/schema-ir/postgres-database-schema-node.ts"],"mappings":";;;;;UAOiB,6BAAA;;WAEN,IAAA;EAFmC;EAAA,SAInC,MAAA;EAK6B;EAAA,SAH7B,SAAA;EAFA;EAAA,SAIA,WAAA;EAAA,SACA,SAAA,EAAW,kBAAkB;EAA7B;EAAA,SAEA,KAAA;EAAA;EAAA,SAEA,KAAA;EAEA;EAAA,SAAA,SAAA;EAEU;EAAA,SAAV,UAAA;AAAA;;;;;;;;;;;;cAcE,wBAAA,SAAiC,eAAA,YAA2B,YAAA;EAAA,SACrD,QAAA;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,6BAAA;EAAA,IAcf,EAAA;EAIJ,QAAA,aAAqB,YAAA;EAIrB,SAAA,CAAU,KAAA,EAAO,YAAA;EAAA,OASV,EAAA,CAAG,IAAA,EAAM,eAAA,GAAkB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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-DArx_1HM.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-t65c4jyY.mjs";
2
2
  import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
- import { t as PostgresContractView } from "./postgres-contract-view-CoRZewAp.mjs";
3
+ import { t as PostgresContractView } from "./postgres-contract-view-BegduLr6.mjs";
4
4
  import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
5
5
  import { Migration } from "@prisma-next/family-sql/migration";
6
6
  import { MigrationContractViews } from "@prisma-next/migration-tools/migration";
@@ -161,4 +161,4 @@ var PostgresMigration = class extends Migration {
161
161
  //#endregion
162
162
  export { PostgresMigration as t };
163
163
 
164
- //# sourceMappingURL=postgres-migration-BVjq0iFW.mjs.map
164
+ //# sourceMappingURL=postgres-migration-BfMmK6tv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-BVjq0iFW.mjs","names":["SqlMigration","#endView","#startView"],"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 { MigrationContractViews } from '@prisma-next/migration-tools/migration';\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 { PostgresContractView } from '../postgres-contract-view';\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<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\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 #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\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 * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ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AAC,CAAC,KACvE,KAAK,cACP;CACF;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,WAAqB,SAM6C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,eACT,QAAQ,QACR,QAAQ,OACR,QAAQ,QACR,QAAQ,YACR,QAAQ,cACV,CAAC,CAAC,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
+ {"version":3,"file":"postgres-migration-BfMmK6tv.mjs","names":["SqlMigration","#endView","#startView"],"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 { MigrationContractViews } from '@prisma-next/migration-tools/migration';\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 { PostgresContractView } from '../postgres-contract-view';\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<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\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 #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\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 * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAy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3C,OAAO,IAAI,eAAe,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACvE,KAAK,cACP;CACF;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,WAAqB,SAM6C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,eACT,QAAQ,QACR,QAAQ,OACR,QAAQ,QACR,QAAQ,YACR,QAAQ,cACV,CAAC,CAAC,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,6 +1,6 @@
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-DPJR7tJc.mjs";
3
+ import { s as AlterColumnTypeOptions, w as ForeignKeySpec } from "./op-factory-call-CJWUxyUW.mjs";
4
4
  import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
5
5
  import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
6
6
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
@@ -191,4 +191,4 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
191
191
  }
192
192
  //#endregion
193
193
  export { PostgresMigration as t };
194
- //# sourceMappingURL=postgres-migration-UtGCjw5j.d.mts.map
194
+ //# sourceMappingURL=postgres-migration-D7kNVWVG.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-UtGCjw5j.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;;;;AC2C3B;;;;;;;;;;;;;;;AD7CA,uBC6CsB,iBAAA,eACN,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,eAClC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,WACpC,SAAA,CAAa,yBAAA,cAAuC,KAAA,EAAO,GAAA;EAAA;WAC1D,QAAA;EA4CiC;;;;;;EAAA,mBApCvB,cAAA,EAAgB,iBAAA;cAavB,KAAA,GAAQ,YAAA;EAoCjB;;;;;EAAA,IArBC,WAAA,IAAe,oBAAA,CAAqB,GAAA;EA2DF;;;;EAAA,IAnDlC,aAAA,IAAiB,oBAAA,CAAqB,KAAA;EA8D9B;;;;;EAAA,UArDF,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,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,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-D7kNVWVG.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;;;;AC2C3B;;;;;;;;;;;;;;;AD7CA,uBC6CsB,iBAAA,eACN,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,eAClC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,WACpC,SAAA,CAAa,yBAAA,cAAuC,KAAA,EAAO,GAAA;EAAA;WAC1D,QAAA;EA4CiC;;;;;;EAAA,mBApCvB,cAAA,EAAgB,iBAAA;cAavB,KAAA,GAAQ,YAAA;EAoCjB;;;;;EAAA,IArBC,WAAA,IAAe,oBAAA,CAAqB,GAAA;EA2DF;;;;EAAA,IAnDlC,aAAA,IAAiB,oBAAA,CAAqB,KAAA;EA8D9B;;;;;EAAA,UArDF,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAgFzB;;;;;EAAA,UApEF,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBA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A;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -1,7 +1,6 @@
1
1
  import { SqlNode } from "@prisma-next/sql-contract/types";
2
- import { DiffableNode } from "@prisma-next/framework-components/control";
3
2
 
4
- //#region src/core/schema-ir/postgres-rls-policy.d.ts
3
+ //#region src/core/postgres-rls-policy.d.ts
5
4
  type RlsPolicyOperation = 'select' | 'insert' | 'update' | 'delete' | 'all';
6
5
  interface PostgresRlsPolicyInput {
7
6
  /** Full wire name: `<prefix>_<8hex>`. Stored as-is; hashing is not this class's job. */
@@ -23,7 +22,11 @@ interface PostgresRlsPolicyInput {
23
22
  readonly permissive: boolean;
24
23
  }
25
24
  /**
26
- * Postgres IR class for a row-level security policy (`CREATE POLICY … ON …`).
25
+ * Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).
26
+ *
27
+ * This is an authored, serialized Contract-IR entity — it is registered as an entity
28
+ * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
29
+ * the schema-diff tree uses `PostgresPolicySchemaNode` for that role.
27
30
  *
28
31
  * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
29
32
  * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
@@ -31,7 +34,7 @@ interface PostgresRlsPolicyInput {
31
34
  * survives JSON serialization and enables dispatch. The literal matches the
32
35
  * entries key (one-string rule: node.kind === entries key === entity kind).
33
36
  */
34
- declare class PostgresRlsPolicy extends SqlNode implements DiffableNode {
37
+ declare class PostgresRlsPolicy extends SqlNode {
35
38
  readonly kind: "policy";
36
39
  readonly name: string;
37
40
  readonly prefix: string;
@@ -43,18 +46,7 @@ declare class PostgresRlsPolicy extends SqlNode implements DiffableNode {
43
46
  readonly withCheck?: string;
44
47
  readonly permissive: boolean;
45
48
  constructor(input: PostgresRlsPolicyInput);
46
- get id(): string;
47
- children(): readonly DiffableNode[];
48
- /**
49
- * Equality by wire name only. The wire name is `<prefix>_<sha256(body)[0..8]>`,
50
- * so name-equality IS body-equality — two policies with different bodies
51
- * have different hashes and therefore different names. We deliberately
52
- * skip comparing bodies directly because Postgres reprints predicate
53
- * expressions (e.g. strips outer parentheses), so a byte-compare against
54
- * the authored body would produce false mismatches on a clean re-verify.
55
- */
56
- isEqualTo(other: DiffableNode): boolean;
57
49
  }
58
50
  //#endregion
59
51
  export { PostgresRlsPolicyInput as n, RlsPolicyOperation as r, PostgresRlsPolicy as t };
60
- //# sourceMappingURL=postgres-rls-policy-12wAEQhs.d.mts.map
52
+ //# sourceMappingURL=postgres-rls-policy--CSddvMR.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-rls-policy--CSddvMR.d.mts","names":[],"sources":["../src/core/postgres-rls-policy.ts"],"mappings":";;;KAGY,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;AAgBrB;;;;;;;;;;cAAa,iBAAA,SAA0B,OAAA;EAAA,SACnB,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;AAAA"}
@@ -8,28 +8,13 @@ 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-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
11
+ //#region src/core/postgres-rls-policy.ts
31
12
  /**
32
- * Postgres IR class for a row-level security policy (`CREATE POLICY … ON …`).
13
+ * Postgres contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).
14
+ *
15
+ * This is an authored, serialized Contract-IR entity — it is registered as an entity
16
+ * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
17
+ * the schema-diff tree uses `PostgresPolicySchemaNode` for that role.
33
18
  *
34
19
  * Target-only concept — no SQL-family abstract. Extends `SqlNode` directly.
35
20
  * Frozen at construction via `freezeNode(this)`. The `kind: 'policy'`
@@ -59,38 +44,15 @@ var PostgresRlsPolicy = class extends SqlNode {
59
44
  this.permissive = input.permissive;
60
45
  freezeNode(this);
61
46
  }
62
- get id() {
63
- return this.name;
64
- }
65
- children() {
66
- return [];
67
- }
68
- /**
69
- * Equality by wire name only. The wire name is `<prefix>_<sha256(body)[0..8]>`,
70
- * so name-equality IS body-equality — two policies with different bodies
71
- * have different hashes and therefore different names. We deliberately
72
- * skip comparing bodies directly because Postgres reprints predicate
73
- * expressions (e.g. strips outer parentheses), so a byte-compare against
74
- * the authored body would produce false mismatches on a clean re-verify.
75
- */
76
- isEqualTo(other) {
77
- if (!isPostgresRlsPolicy(other)) throw new Error(`PostgresRlsPolicy.isEqualTo: expected a PostgresRlsPolicy, got ${other.constructor?.name ?? typeof other}`);
78
- return this.name === other.name;
79
- }
80
47
  };
81
- function isPostgresRlsPolicy(node) {
82
- return node !== void 0 && "kind" in node && node.kind === "policy";
83
- }
84
- function assertPostgresRlsPolicy(node) {
85
- if (!isPostgresRlsPolicy(node)) {
86
- const kind = node !== void 0 && "kind" in node ? String(node.kind) : typeof node;
87
- throw new Error(`planPostgresSchemaDiff: expected a PostgresRlsPolicy on the policy-diff path but got ${kind}`);
88
- }
89
- }
90
48
  //#endregion
91
- //#region src/core/schema-ir/postgres-role.ts
49
+ //#region src/core/postgres-role.ts
92
50
  /**
93
- * Postgres IR class for a database role (`CREATE ROLE …`).
51
+ * Postgres contract-IR class for a database role (`CREATE ROLE …`).
52
+ *
53
+ * This is an authored, serialized Contract-IR entity — it is registered as an entity
54
+ * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
55
+ * the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
94
56
  *
95
57
  * Roles are cluster-scoped, so their namespace coordinate is always
96
58
  * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
@@ -98,7 +60,7 @@ function assertPostgresRlsPolicy(node) {
98
60
  * The `kind: 'role'` discriminant is enumerable so it survives JSON.
99
61
  * Matches the entries key (one-string rule).
100
62
  */
101
- var PostgresRole = class PostgresRole extends SqlNode {
63
+ var PostgresRole = class extends SqlNode {
102
64
  kind = "role";
103
65
  name;
104
66
  namespaceId;
@@ -108,19 +70,27 @@ var PostgresRole = class PostgresRole extends SqlNode {
108
70
  this.namespaceId = input.namespaceId;
109
71
  freezeNode(this);
110
72
  }
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 [];
117
- }
118
- isEqualTo(other) {
119
- if (!(other instanceof PostgresRole)) throw new Error(`PostgresRole.isEqualTo: expected a PostgresRole, got ${other.constructor?.name ?? typeof other}`);
120
- return this.name === other.name;
121
- }
122
73
  };
123
74
  //#endregion
75
+ //#region src/core/postgres-validators.ts
76
+ const PostgresRoleSchema = type({
77
+ kind: "'role'",
78
+ name: "string",
79
+ namespaceId: "string"
80
+ });
81
+ const PostgresRlsPolicySchema = type({
82
+ kind: "'policy'",
83
+ name: "string",
84
+ prefix: "string",
85
+ tableName: "string",
86
+ namespaceId: "string",
87
+ operation: "'select' | 'insert' | 'update' | 'delete' | 'all'",
88
+ roles: type.string.array().readonly(),
89
+ "using?": "string",
90
+ "withCheck?": "string",
91
+ permissive: "boolean"
92
+ });
93
+ //#endregion
124
94
  //#region src/core/ast/table-source.ts
125
95
  var PostgresTableSource = class extends TableSource {
126
96
  schema;
@@ -363,6 +333,6 @@ function postgresCreateNamespace(input) {
363
333
  return new PostgresSchema(schemaInput);
364
334
  }
365
335
  //#endregion
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 };
336
+ export { policyEntityKind as a, PostgresRlsPolicySchema as c, PostgresRlsPolicy as d, postgresCreateNamespace as i, PostgresRoleSchema as l, PostgresUnboundSchema as n, roleEntityKind as o, isPostgresSchema as r, PostgresTableSource as s, PostgresSchema as t, PostgresRole as u };
367
337
 
368
- //# sourceMappingURL=postgres-schema-DLcc3W2-.mjs.map
338
+ //# sourceMappingURL=postgres-schema-BLIHBEfX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-BLIHBEfX.mjs","names":[],"sources":["../src/core/postgres-rls-policy.ts","../src/core/postgres-role.ts","../src/core/postgres-validators.ts","../src/core/ast/table-source.ts","../src/core/entity-kinds.ts","../src/core/postgres-schema.ts"],"sourcesContent":["import { 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 contract-IR class for a row-level security policy (`CREATE POLICY … ON …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresPolicySchemaNode` for that role.\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 {\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","import { 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 contract-IR class for a database role (`CREATE ROLE …`).\n *\n * This is an authored, serialized Contract-IR entity — it is registered as an entity\n * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;\n * the schema-diff tree uses `PostgresRoleSchemaNode` for that 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 {\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","import { type } from 'arktype';\n\nexport const PostgresRoleSchema = type({\n kind: \"'role'\",\n name: 'string',\n namespaceId: 'string',\n});\n\nexport const PostgresRlsPolicySchema = type({\n kind: \"'policy'\",\n name: 'string',\n prefix: 'string',\n tableName: 'string',\n namespaceId: 'string',\n operation: \"'select' | 'insert' | 'update' | 'delete' | 'all'\",\n roles: type.string.array().readonly(),\n 'using?': 'string',\n 'withCheck?': 'string',\n permissive: 'boolean',\n});\n","import {\n type AnyFromSource,\n type AstRewriter,\n TableSource,\n} from '@prisma-next/sql-relational-core/ast';\n\nexport class PostgresTableSource extends TableSource {\n readonly schema: string | undefined;\n\n constructor(options: {\n readonly name: string;\n readonly schema?: string;\n readonly alias?: string;\n }) {\n super(options.name, options.alias);\n this.schema = options.schema;\n this.freeze();\n }\n\n override rewrite(rewriter: AstRewriter): AnyFromSource {\n return rewriter.tableSource ? rewriter.tableSource(this) : this;\n }\n}\n","import type { EntityKindDescriptor } from '@prisma-next/framework-components/ir';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from './postgres-rls-policy';\nimport { PostgresRole, type PostgresRoleInput } from './postgres-role';\nimport { PostgresRlsPolicySchema, PostgresRoleSchema } from './postgres-validators';\n\nexport const policyEntityKind: EntityKindDescriptor<PostgresRlsPolicyInput, PostgresRlsPolicy> = {\n kind: 'policy',\n schema: PostgresRlsPolicySchema,\n construct: (input) => new PostgresRlsPolicy(input),\n};\n\nexport const roleEntityKind: EntityKindDescriptor<PostgresRoleInput, PostgresRole> = {\n kind: 'role',\n schema: PostgresRoleSchema,\n construct: (input) => new PostgresRole(input),\n};\n","import 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 './postgres-rls-policy';\nimport type { PostgresRole } from './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":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAa,oBAAb,cAAuC,QAAQ;CAC7C,OAAyB;CACzB;CACA;CACA;CACA;CACA;CACA;CAGA;CAEA,YAAY,OAA+B;EACzC,MA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GACN,QAAQ,KAAK;GACb,GAAG,UAAU,SAAS,KAAK;EAC7B,CAAC;CACH;;;;;;;;;;;;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"}
@@ -1,11 +1,10 @@
1
1
  import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
2
- import { t as PostgresRlsPolicy } from "./postgres-rls-policy-12wAEQhs.mjs";
2
+ import { t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.mjs";
3
3
  import { SqlNamespaceBase, SqlNamespaceEntries, SqlNamespaceInput, SqlNode, SqlStorage, StorageTable, StorageValueSet } from "@prisma-next/sql-contract/types";
4
4
  import { CfExpr } from "@prisma-next/sql-relational-core/contract-free";
5
- import { DiffableNode } from "@prisma-next/framework-components/control";
6
5
  import { Contract } from "@prisma-next/contract/types";
7
6
 
8
- //#region src/core/schema-ir/postgres-role.d.ts
7
+ //#region src/core/postgres-role.d.ts
9
8
  interface PostgresRoleInput {
10
9
  readonly name: string;
11
10
  /**
@@ -15,7 +14,11 @@ interface PostgresRoleInput {
15
14
  readonly namespaceId: string;
16
15
  }
17
16
  /**
18
- * Postgres IR class for a database role (`CREATE ROLE …`).
17
+ * Postgres contract-IR class for a database role (`CREATE ROLE …`).
18
+ *
19
+ * This is an authored, serialized Contract-IR entity — it is registered as an entity
20
+ * kind, extends `SqlNode`, and is stored in `contract.json`. It is NOT a DiffableNode;
21
+ * the schema-diff tree uses `PostgresRoleSchemaNode` for that role.
19
22
  *
20
23
  * Roles are cluster-scoped, so their namespace coordinate is always
21
24
  * `UNBOUND_NAMESPACE_ID`. Target-only concept — no SQL-family abstract.
@@ -23,15 +26,11 @@ interface PostgresRoleInput {
23
26
  * The `kind: 'role'` discriminant is enumerable so it survives JSON.
24
27
  * Matches the entries key (one-string rule).
25
28
  */
26
- declare class PostgresRole extends SqlNode implements DiffableNode {
29
+ declare class PostgresRole extends SqlNode {
27
30
  readonly kind: "role";
28
31
  readonly name: string;
29
32
  readonly namespaceId: string;
30
33
  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
34
  }
36
35
  //#endregion
37
36
  //#region src/core/postgres-schema.d.ts
@@ -187,4 +186,4 @@ declare function isPostgresSchema(ns: unknown): ns is PostgresSchema;
187
186
  declare function postgresCreateNamespace(input: SqlNamespaceInput): PostgresSchema;
188
187
  //#endregion
189
188
  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
189
+ //# sourceMappingURL=postgres-schema-BywoeKlt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-BywoeKlt.d.mts","names":[],"sources":["../src/core/postgres-role.ts","../src/core/postgres-schema.ts"],"mappings":";;;;;;;UAGiB,iBAAA;EAAA,SACN,IAAA;;;;;WAKA,WAAW;AAAA;;;AAAA;AAgBtB;;;;;;;;;;cAAa,YAAA,SAAqB,OAAO;EAAA,SACrB,IAAA;EAAA,SACT,IAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,iBAAA;AAAA;;;KCJT,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;;;;;;;;ADLf;;;;ACJtC;;;cA0Ba,cAAA,SAAuB,gBAAA;EA1BL;;;;AAAwC;AAEvE;;EAF+B,OAkCtB,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;EAhFZ;;;;;EAyFxB,SA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