@prisma-next/target-postgres 0.12.0-dev.7 → 0.12.0-dev.71

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 (200) hide show
  1. package/dist/{codec-ids-DliyCWPY.d.mts → codec-ids-B1vOchLE.d.mts} +3 -2
  2. package/dist/codec-ids-B1vOchLE.d.mts.map +1 -0
  3. package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-CTikp1if.mjs} +3 -2
  4. package/dist/codec-ids-CTikp1if.mjs.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -2
  6. package/dist/codec-ids.mjs +2 -2
  7. package/dist/{codec-types-BF1DXTPs.d.mts → codec-types-CnFiNML4.d.mts} +8 -9
  8. package/dist/codec-types-CnFiNML4.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +2 -2
  10. package/dist/{codecs-DuP3d9Au.d.mts → codecs-CBpEv4s5.d.mts} +33 -35
  11. package/dist/codecs-CBpEv4s5.d.mts.map +1 -0
  12. package/dist/codecs.d.mts +1 -1
  13. package/dist/codecs.mjs +37 -2
  14. package/dist/codecs.mjs.map +1 -1
  15. package/dist/contract-free.d.mts +80 -0
  16. package/dist/contract-free.d.mts.map +1 -0
  17. package/dist/contract-free.mjs +117 -0
  18. package/dist/contract-free.mjs.map +1 -0
  19. package/dist/control.d.mts +1 -1
  20. package/dist/control.d.mts.map +1 -1
  21. package/dist/control.mjs +66 -40
  22. package/dist/control.mjs.map +1 -1
  23. package/dist/{data-transform-CRkv2T_U.mjs → data-transform-D25tLeYU.mjs} +1 -1
  24. package/dist/{data-transform-CRkv2T_U.mjs.map → data-transform-D25tLeYU.mjs.map} +1 -1
  25. package/dist/{data-transform-CAPmAdxS.d.mts → data-transform-DGOqcLrf.d.mts} +2 -2
  26. package/dist/{data-transform-CAPmAdxS.d.mts.map → data-transform-DGOqcLrf.d.mts.map} +1 -1
  27. package/dist/data-transform.d.mts +1 -1
  28. package/dist/data-transform.mjs +1 -1
  29. package/dist/ddl-77SyXgFt.mjs +30 -0
  30. package/dist/ddl-77SyXgFt.mjs.map +1 -0
  31. package/dist/ddl.d.mts +2 -0
  32. package/dist/ddl.mjs +2 -0
  33. package/dist/{default-normalizer-DaAhmzBV.mjs → default-normalizer-DyyCHQWs.mjs} +1 -1
  34. package/dist/{default-normalizer-DaAhmzBV.mjs.map → default-normalizer-DyyCHQWs.mjs.map} +1 -1
  35. package/dist/default-normalizer.mjs +1 -1
  36. package/dist/{descriptor-meta-Uu8QaClr.mjs → descriptor-meta-DKmj-IMN.mjs} +3 -2
  37. package/dist/descriptor-meta-DKmj-IMN.mjs.map +1 -0
  38. package/dist/{descriptor-meta-runtime-DMRX39kp.mjs → descriptor-meta-runtime-My8_s4cs.mjs} +2 -2
  39. package/dist/{descriptor-meta-runtime-DMRX39kp.mjs.map → descriptor-meta-runtime-My8_s4cs.mjs.map} +1 -1
  40. package/dist/{enum-planning-DRA9LaMU.mjs → enum-planning-BCyvlFHk.mjs} +0 -0
  41. package/dist/{enum-planning-DRA9LaMU.mjs.map → enum-planning-BCyvlFHk.mjs.map} +1 -1
  42. package/dist/enum-planning.d.mts +1 -1
  43. package/dist/enum-planning.mjs +1 -1
  44. package/dist/{errors-BbnITmAD.mjs → errors-CUk87ByX.mjs} +1 -1
  45. package/dist/{errors-BbnITmAD.mjs.map → errors-CUk87ByX.mjs.map} +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs +1 -1
  48. package/dist/{issue-planner-BtaL6OfW.mjs → issue-planner-SHnDHfoQ.mjs} +130 -28
  49. package/dist/issue-planner-SHnDHfoQ.mjs.map +1 -0
  50. package/dist/issue-planner.d.mts +1 -1
  51. package/dist/issue-planner.d.mts.map +1 -1
  52. package/dist/issue-planner.mjs +1 -1
  53. package/dist/migration.d.mts +7 -8
  54. package/dist/migration.d.mts.map +1 -1
  55. package/dist/migration.mjs +5 -4
  56. package/dist/migration.mjs.map +1 -1
  57. package/dist/{native-type-normalizer-BNEQ9VDs.mjs → native-type-normalizer-Bc9XJzWC.mjs} +1 -1
  58. package/dist/{native-type-normalizer-BNEQ9VDs.mjs.map → native-type-normalizer-Bc9XJzWC.mjs.map} +1 -1
  59. package/dist/native-type-normalizer.mjs +1 -1
  60. package/dist/nodes-779hmCfL.d.mts +40 -0
  61. package/dist/nodes-779hmCfL.d.mts.map +1 -0
  62. package/dist/nodes-DZk2JZG3.mjs +47 -0
  63. package/dist/nodes-DZk2JZG3.mjs.map +1 -0
  64. package/dist/op-factory-call-D2aAUhmS.mjs +1307 -0
  65. package/dist/op-factory-call-D2aAUhmS.mjs.map +1 -0
  66. package/dist/{op-factory-call-CDlImOF_.d.mts → op-factory-call-DMA86_2D.d.mts} +39 -14
  67. package/dist/op-factory-call-DMA86_2D.d.mts.map +1 -0
  68. package/dist/op-factory-call.d.mts +2 -2
  69. package/dist/op-factory-call.mjs +2 -2
  70. package/dist/pack.d.mts +5 -6
  71. package/dist/pack.d.mts.map +1 -1
  72. package/dist/pack.mjs +1 -1
  73. package/dist/planner-Bv5LV2A-.mjs +344 -0
  74. package/dist/planner-Bv5LV2A-.mjs.map +1 -0
  75. package/dist/{planner-ddl-builders-BNMfSE9r.mjs → planner-ddl-builders-DDyptTt5.mjs} +4 -28
  76. package/dist/planner-ddl-builders-DDyptTt5.mjs.map +1 -0
  77. package/dist/planner-ddl-builders.d.mts +6 -7
  78. package/dist/planner-ddl-builders.d.mts.map +1 -1
  79. package/dist/planner-ddl-builders.mjs +2 -2
  80. package/dist/{planner-identity-values-nhVj0hp-.mjs → planner-identity-values-BIpa5p2I.mjs} +1 -1
  81. package/dist/{planner-identity-values-nhVj0hp-.mjs.map → planner-identity-values-BIpa5p2I.mjs.map} +1 -1
  82. package/dist/planner-identity-values.mjs +1 -1
  83. package/dist/{planner-produced-postgres-migration-D02NOhVQ.d.mts → planner-produced-postgres-migration-B4EDvLdz.d.mts} +5 -4
  84. package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +1 -0
  85. package/dist/{planner-produced-postgres-migration-D_nsXbhl.mjs → planner-produced-postgres-migration-NSEhWL0L.mjs} +8 -6
  86. package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +1 -0
  87. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  88. package/dist/planner-produced-postgres-migration.mjs +1 -1
  89. package/dist/{planner-schema-lookup-CGxxYfnD.mjs → planner-schema-lookup-CiVaAQP-.mjs} +1 -1
  90. package/dist/{planner-schema-lookup-CGxxYfnD.mjs.map → planner-schema-lookup-CiVaAQP-.mjs.map} +1 -1
  91. package/dist/planner-schema-lookup.mjs +1 -1
  92. package/dist/{planner-sql-checks-CfEiTXoQ.mjs → planner-sql-checks-DAdhnI2c.mjs} +41 -30
  93. package/dist/planner-sql-checks-DAdhnI2c.mjs.map +1 -0
  94. package/dist/planner-sql-checks.d.mts.map +1 -1
  95. package/dist/planner-sql-checks.mjs +1 -1
  96. package/dist/{planner-target-details-a_wuOiYf.d.mts → planner-target-details-CIY6tLeo.d.mts} +2 -2
  97. package/dist/planner-target-details-CIY6tLeo.d.mts.map +1 -0
  98. package/dist/planner-target-details.d.mts +2 -2
  99. package/dist/planner-type-resolution-836DExFN.mjs +20 -0
  100. package/dist/planner-type-resolution-836DExFN.mjs.map +1 -0
  101. package/dist/planner.d.mts +7 -3
  102. package/dist/planner.d.mts.map +1 -1
  103. package/dist/planner.mjs +1 -1
  104. package/dist/{postgres-contract-serializer-BnOboPWs.mjs → postgres-contract-serializer-DYTyXjPf.mjs} +33 -24
  105. package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +1 -0
  106. package/dist/{postgres-enum-type-CSzsvXrO.d.mts → postgres-enum-type-BVn63a89.d.mts} +1 -1
  107. package/dist/{postgres-enum-type-CSzsvXrO.d.mts.map → postgres-enum-type-BVn63a89.d.mts.map} +1 -1
  108. package/dist/{postgres-enum-type-BMgyxNyy.mjs → postgres-enum-type-DPKqCBem.mjs} +1 -1
  109. package/dist/{postgres-enum-type-BMgyxNyy.mjs.map → postgres-enum-type-DPKqCBem.mjs.map} +1 -1
  110. package/dist/{postgres-migration-BatbEvU6.mjs → postgres-migration-COore9Mz.mjs} +23 -3
  111. package/dist/postgres-migration-COore9Mz.mjs.map +1 -0
  112. package/dist/{postgres-migration-DRY8V-bQ.d.mts → postgres-migration-DZ_gLUOW.d.mts} +25 -3
  113. package/dist/postgres-migration-DZ_gLUOW.d.mts.map +1 -0
  114. package/dist/{postgres-schema-BxAuNFX0.mjs → postgres-schema-BuxCxbvB.mjs} +29 -14
  115. package/dist/postgres-schema-BuxCxbvB.mjs.map +1 -0
  116. package/dist/{render-ops-XhICjX_P.mjs → render-ops-BpjstrKQ.mjs} +4 -3
  117. package/dist/{render-ops-XhICjX_P.mjs.map → render-ops-BpjstrKQ.mjs.map} +1 -1
  118. package/dist/render-ops.d.mts +3 -2
  119. package/dist/render-ops.d.mts.map +1 -1
  120. package/dist/render-ops.mjs +1 -1
  121. package/dist/{render-typescript-K125n-RZ.mjs → render-typescript-KMgosran.mjs} +5 -2
  122. package/dist/render-typescript-KMgosran.mjs.map +1 -0
  123. package/dist/render-typescript.mjs +1 -1
  124. package/dist/runtime.d.mts.map +1 -1
  125. package/dist/runtime.mjs +2 -2
  126. package/dist/{shared-Do_a5ymU.d.mts → shared-DarONYBZ.d.mts} +5 -5
  127. package/dist/{shared-Do_a5ymU.d.mts.map → shared-DarONYBZ.d.mts.map} +1 -1
  128. package/dist/{sql-utils-CggjWNij.mjs → sql-utils-DcfMz4MQ.mjs} +1 -1
  129. package/dist/{sql-utils-CggjWNij.mjs.map → sql-utils-DcfMz4MQ.mjs.map} +1 -1
  130. package/dist/sql-utils.mjs +1 -1
  131. package/dist/{types-O40IcFV9.d.mts → types-BDKkx8MA.d.mts} +1 -1
  132. package/dist/types-BDKkx8MA.d.mts.map +1 -0
  133. package/dist/types.d.mts +16 -11
  134. package/dist/types.d.mts.map +1 -1
  135. package/dist/types.mjs +2 -2
  136. package/package.json +21 -20
  137. package/src/contract-free/columns.ts +49 -0
  138. package/src/contract-free/control-bootstrap.ts +55 -0
  139. package/src/contract-free/ddl.ts +37 -0
  140. package/src/core/ast/table-source.ts +23 -0
  141. package/src/core/codec-ids.ts +1 -0
  142. package/src/core/codecs.ts +44 -0
  143. package/src/core/ddl/nodes.ts +72 -0
  144. package/src/core/descriptor-meta.ts +1 -0
  145. package/src/core/migrations/control-policy.ts +234 -0
  146. package/src/core/migrations/issue-planner.ts +81 -13
  147. package/src/core/migrations/op-factory-call.ts +289 -46
  148. package/src/core/migrations/operations/constraints.ts +79 -10
  149. package/src/core/migrations/operations/dependencies.ts +0 -17
  150. package/src/core/migrations/operations/shared.ts +3 -3
  151. package/src/core/migrations/operations/tables.ts +1 -39
  152. package/src/core/migrations/planner-ddl-builders.ts +4 -46
  153. package/src/core/migrations/planner-produced-postgres-migration.ts +11 -6
  154. package/src/core/migrations/planner-sql-checks.ts +9 -9
  155. package/src/core/migrations/planner-strategies.ts +149 -11
  156. package/src/core/migrations/planner-target-details.ts +2 -1
  157. package/src/core/migrations/planner.ts +66 -8
  158. package/src/core/migrations/postgres-migration.ts +41 -0
  159. package/src/core/migrations/render-ops.ts +7 -2
  160. package/src/core/migrations/render-typescript.ts +5 -1
  161. package/src/core/migrations/runner.ts +78 -50
  162. package/src/core/postgres-contract-serializer.ts +52 -46
  163. package/src/core/postgres-schema.ts +43 -25
  164. package/src/exports/contract-free.ts +7 -0
  165. package/src/exports/control.ts +6 -8
  166. package/src/exports/ddl.ts +7 -0
  167. package/src/exports/migration.ts +11 -2
  168. package/src/exports/op-factory-call.ts +2 -0
  169. package/src/exports/planner-ddl-builders.ts +0 -1
  170. package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
  171. package/dist/codec-ids-DliyCWPY.d.mts.map +0 -1
  172. package/dist/codec-types-BF1DXTPs.d.mts.map +0 -1
  173. package/dist/codecs-DuP3d9Au.d.mts.map +0 -1
  174. package/dist/descriptor-meta-Uu8QaClr.mjs.map +0 -1
  175. package/dist/issue-planner-BtaL6OfW.mjs.map +0 -1
  176. package/dist/op-factory-call-CDlImOF_.d.mts.map +0 -1
  177. package/dist/op-factory-call-ewOd5q6L.mjs +0 -625
  178. package/dist/op-factory-call-ewOd5q6L.mjs.map +0 -1
  179. package/dist/planner-Bjz5pnLa.mjs +0 -177
  180. package/dist/planner-Bjz5pnLa.mjs.map +0 -1
  181. package/dist/planner-ddl-builders-BNMfSE9r.mjs.map +0 -1
  182. package/dist/planner-produced-postgres-migration-D02NOhVQ.d.mts.map +0 -1
  183. package/dist/planner-produced-postgres-migration-D_nsXbhl.mjs.map +0 -1
  184. package/dist/planner-sql-checks-CfEiTXoQ.mjs.map +0 -1
  185. package/dist/planner-target-details-a_wuOiYf.d.mts.map +0 -1
  186. package/dist/postgres-contract-serializer-BnOboPWs.mjs.map +0 -1
  187. package/dist/postgres-migration-BatbEvU6.mjs.map +0 -1
  188. package/dist/postgres-migration-DRY8V-bQ.d.mts.map +0 -1
  189. package/dist/postgres-schema-BxAuNFX0.mjs.map +0 -1
  190. package/dist/render-typescript-K125n-RZ.mjs.map +0 -1
  191. package/dist/statement-builders-DVI5IVAa.mjs +0 -131
  192. package/dist/statement-builders-DVI5IVAa.mjs.map +0 -1
  193. package/dist/statement-builders.d.mts +0 -51
  194. package/dist/statement-builders.d.mts.map +0 -1
  195. package/dist/statement-builders.mjs +0 -2
  196. package/dist/tables-DoA39Yqo.mjs +0 -516
  197. package/dist/tables-DoA39Yqo.mjs.map +0 -1
  198. package/dist/types-O40IcFV9.d.mts.map +0 -1
  199. package/src/core/migrations/statement-builders.ts +0 -183
  200. package/src/exports/statement-builders.ts +0 -8
@@ -1,5 +1,6 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-a_wuOiYf.mjs";
2
- import { n as DataTransformOptions } from "./data-transform-CAPmAdxS.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
+ import { n as DataTransformOptions } from "./data-transform-DGOqcLrf.mjs";
3
+ import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
3
4
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
4
5
  import { SqlStorage } from "@prisma-next/sql-contract/types";
5
6
  import { Migration } from "@prisma-next/family-sql/migration";
@@ -44,7 +45,28 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
44
45
  * `get operations()`; the adapter argument is hidden from the call site.
45
46
  */
46
47
  protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
48
+ /**
49
+ * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
50
+ * the supplied options and lowers it through the stored control adapter.
51
+ * Throws if no adapter is present (i.e. migration instantiated without a stack).
52
+ */
53
+ protected createTable(options: {
54
+ readonly schema?: string;
55
+ readonly table: string;
56
+ readonly ifNotExists?: boolean;
57
+ readonly columns: readonly DdlColumn[];
58
+ readonly constraints?: readonly DdlTableConstraint[];
59
+ }): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
60
+ /**
61
+ * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
62
+ * the supplied options and lowers it through the stored control adapter.
63
+ * Throws if no adapter is present (i.e. migration instantiated without a stack).
64
+ */
65
+ protected createSchema(options: {
66
+ readonly schema: string;
67
+ readonly ifNotExists?: boolean;
68
+ }): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
47
69
  }
48
70
  //#endregion
49
71
  export { PostgresMigration as t };
50
- //# sourceMappingURL=postgres-migration-DRY8V-bQ.d.mts.map
72
+ //# sourceMappingURL=postgres-migration-DZ_gLUOW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-DZ_gLUOW.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EAJiD;;;;;;EAAA,mBAYvC,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAAR;;;;;EAAA,UAeF,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,yBAAA,CAA0B,yBAAA;EAH3B;;;;;EAAA,UAeQ,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,yBAAA,CAA0B,yBAAA;EADnB;;;;;EAAA,UAkBD,YAAA,CAAa,OAAA;IAAA,SACZ,MAAA;IAAA,SACA,WAAA;EAAA,IACP,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -1,5 +1,5 @@
1
- import { t as PostgresEnumType } from "./postgres-enum-type-BMgyxNyy.mjs";
2
- import { n as escapeLiteral } from "./sql-utils-CggjWNij.mjs";
1
+ import { t as PostgresEnumType } from "./postgres-enum-type-DPKqCBem.mjs";
2
+ import { n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
3
3
  import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
4
4
  import { StorageTable } from "@prisma-next/sql-contract/types";
5
5
  //#region src/core/postgres-schema.ts
@@ -9,9 +9,10 @@ import { StorageTable } from "@prisma-next/sql-contract/types";
9
9
  * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
10
10
  * the Postgres PSL interpreter from `namespace { … }` AST buckets.
11
11
  *
12
- * Qualifier emission is the rendering seam: DDL / SQL emission asks the
13
- * namespace for its qualifier (`"<schema>"`) or for a qualified table
14
- * name (`"<schema>"."<table>"`) and consumes the result polymorphically.
12
+ * `entries` holds entity-kind slot maps (`table`, `type`). Qualifier
13
+ * emission is the rendering seam: DDL / SQL emission asks the namespace
14
+ * for its qualifier (`"<schema>"`) or for a qualified table name
15
+ * (`"<schema>"."<table>"`) and consumes the result polymorphically.
15
16
  * The unbound singleton below overrides these methods to elide the
16
17
  * prefix entirely — call sites stay polymorphic and never branch on
17
18
  * `id === UNBOUND_NAMESPACE_ID`.
@@ -26,13 +27,14 @@ var PostgresSchema = class extends NamespaceBase {
26
27
  */
27
28
  static unbound;
28
29
  id;
29
- tables;
30
- enum;
30
+ entries;
31
31
  constructor(input) {
32
32
  super();
33
33
  this.id = input.id;
34
- this.tables = Object.freeze(Object.fromEntries(Object.entries(input.tables ?? {}).map(([name, t]) => [name, t instanceof StorageTable ? t : new StorageTable(t)])));
35
- this.enum = Object.freeze(Object.fromEntries(Object.entries(input.enum ?? {}).map(([name, ty]) => [name, ty instanceof PostgresEnumType ? ty : new PostgresEnumType(ty)])));
34
+ this.entries = Object.freeze({
35
+ table: Object.freeze(Object.fromEntries(Object.entries(input.entries.table).map(([k, v]) => [k, v instanceof StorageTable ? v : new StorageTable(v)]))),
36
+ type: Object.freeze(Object.fromEntries(Object.entries(input.entries.type).map(([k, v]) => [k, v instanceof PostgresEnumType ? v : new PostgresEnumType(v)])))
37
+ });
36
38
  Object.defineProperty(this, "kind", {
37
39
  value: "schema",
38
40
  writable: false,
@@ -115,7 +117,13 @@ var PostgresSchema = class extends NamespaceBase {
115
117
  var PostgresUnboundSchema = class PostgresUnboundSchema extends PostgresSchema {
116
118
  static instance = new PostgresUnboundSchema();
117
119
  constructor(input) {
118
- super(input ?? { id: UNBOUND_NAMESPACE_ID });
120
+ super(input ?? {
121
+ id: UNBOUND_NAMESPACE_ID,
122
+ entries: {
123
+ table: {},
124
+ type: {}
125
+ }
126
+ });
119
127
  }
120
128
  qualifier() {
121
129
  return "";
@@ -151,11 +159,18 @@ function isPostgresSchema(ns) {
151
159
  * by reference and trust the resulting `SqlStorage.namespaces` map to
152
160
  * be value-stable for a given input set.
153
161
  */
154
- function postgresCreateNamespace(input) {
155
- if (input.id === UNBOUND_NAMESPACE_ID) return new PostgresUnboundSchema(input);
156
- return new PostgresSchema(input);
162
+ function postgresCreateNamespace(input, enumTypes) {
163
+ const schemaInput = {
164
+ id: input.id,
165
+ entries: {
166
+ table: input.entries.table,
167
+ type: enumTypes ?? {}
168
+ }
169
+ };
170
+ if (input.id === UNBOUND_NAMESPACE_ID) return new PostgresUnboundSchema(schemaInput);
171
+ return new PostgresSchema(schemaInput);
157
172
  }
158
173
  //#endregion
159
174
  export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
160
175
 
161
- //# sourceMappingURL=postgres-schema-BxAuNFX0.mjs.map
176
+ //# sourceMappingURL=postgres-schema-BuxCxbvB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-schema-BuxCxbvB.mjs","names":[],"sources":["../src/core/postgres-schema.ts"],"sourcesContent":["import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport {\n type PostgresEnumStorageEntry,\n type SqlNamespaceTablesInput,\n type SqlStorage,\n StorageTable,\n type StorageTableInput,\n} from '@prisma-next/sql-contract/types';\nimport { PostgresEnumType, type PostgresEnumTypeInput } from './postgres-enum-type';\nimport { escapeLiteral } from './sql-utils';\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: {\n readonly table: Record<string, StorageTable | StorageTableInput>;\n readonly type: Record<string, PostgresEnumType | PostgresEnumTypeInput>;\n };\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 slot maps (`table`, `type`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends NamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: Readonly<{\n readonly table: Readonly<Record<string, StorageTable>>;\n readonly type: Readonly<Record<string, PostgresEnumType>>;\n }>;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n this.entries = Object.freeze({\n table: Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.table).map(([k, v]) => [\n k,\n v instanceof StorageTable ? v : new StorageTable(v as StorageTableInput),\n ]),\n ),\n ),\n type: Object.freeze(\n Object.fromEntries(\n Object.entries(input.entries.type).map(([k, v]) => [\n k,\n v instanceof PostgresEnumType ? v : new PostgresEnumType(v as PostgresEnumTypeInput),\n ]),\n ),\n ),\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 /**\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 * 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` / `toRegclassLiteral` route through the\n * polymorphic `PostgresUnboundSchema` overrides and produce\n * unqualified (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 (`qualifyTableName`,\n * `toRegclassLiteral`) route through the polymorphic factory and\n * produce unqualified output 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: {}, type: {} } });\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\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(\n input: SqlNamespaceTablesInput,\n enumTypes?: Readonly<Record<string, PostgresEnumStorageEntry>>,\n): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n table: input.entries.table,\n type: (enumTypes ?? {}) as Record<string, PostgresEnumTypeInput>,\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAa,iBAAb,cAAoC,cAAc;;;;;;;;CAQhD,OAAO;CAGP;CACA;CAKA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAChB,KAAK,UAAU,OAAO,OAAO;GAC3B,OAAO,OAAO,OACZ,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAClD,GACA,aAAa,eAAe,IAAI,IAAI,aAAa,CAAsB,CACzE,CAAC,CACH,CACF;GACA,MAAM,OAAO,OACX,OAAO,YACL,OAAO,QAAQ,MAAM,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CACjD,GACA,aAAa,mBAAmB,IAAI,IAAI,iBAAiB,CAA0B,CACrF,CAAC,CACH,CACF;EACF,CAAC;EACD,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;;;;;;CAOA,YAAoB;EAClB,OAAO,IAAI,KAAK,GAAG;CACrB;;;;;;;CAQA,aAAa,WAA2B;EACtC,OAAO,IAAI,KAAK,GAAG,KAAK,UAAU;CACpC;;;;;;;CAQA,gBAAgB,MAAsB;EACpC,OAAO,IAAI,cAAc,KAAK,aAAa,IAAI,CAAC,EAAE;CACpD;;;;;;;;;CAUA,sBAA8B;EAC5B,OAAO,IAAI,cAAc,KAAK,EAAE,EAAE;CACpC;;;;;;;;;;;;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;IAAE,OAAO,CAAC;IAAG,MAAM,CAAC;GAAE;EAAE,CAAC;CAC/E;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;AAaA,SAAgB,wBACd,OACA,WACgB;CAChB,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,OAAO,MAAM,QAAQ;GACrB,MAAO,aAAa,CAAC;EACvB;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
@@ -1,3 +1,4 @@
1
+ import { blindCast } from "@prisma-next/utils/casts";
1
2
  //#region src/core/migrations/render-ops.ts
2
3
  /**
3
4
  * Asserts an op materialised by an `OpFactoryCall` targets postgres. The
@@ -10,9 +11,9 @@ function assertPostgresOp(op, callFactoryName) {
10
11
  const targetId = op.target?.id;
11
12
  if (targetId !== "postgres") throw new Error(`renderOps: expected postgres op but got target.id="${String(targetId)}" for op.id="${op.id}" (factoryName="${callFactoryName}"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`);
12
13
  }
13
- function renderOps(calls) {
14
+ function renderOps(calls, lowerer) {
14
15
  return calls.map((c) => {
15
- const op = c.toOp();
16
+ const op = blindCast(c).toOp(lowerer);
16
17
  assertPostgresOp(op, c.factoryName);
17
18
  return op;
18
19
  });
@@ -20,4 +21,4 @@ function renderOps(calls) {
20
21
  //#endregion
21
22
  export { renderOps as t };
22
23
 
23
- //# sourceMappingURL=render-ops-XhICjX_P.mjs.map
24
+ //# sourceMappingURL=render-ops-BpjstrKQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-ops-XhICjX_P.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Asserts an op materialised by an `OpFactoryCall` targets postgres. The\n * extension surface lets any contributor emit calls, so this is the\n * integration boundary where a stray non-postgres op would otherwise\n * silently flow through to postgres-shaped renderers — exactly the\n * place to fail loudly with op metadata (`id` + `target.id`).\n */\nfunction assertPostgresOp(\n op: ReturnType<OpFactoryCall['toOp']>,\n callFactoryName: string,\n): asserts op is Op {\n const targetId = (op as Partial<Op>).target?.id;\n if (targetId !== 'postgres') {\n throw new Error(\n `renderOps: expected postgres op but got target.id=\"${String(targetId)}\" for op.id=\"${op.id}\" (factoryName=\"${callFactoryName}\"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`,\n );\n }\n}\n\nexport function renderOps(calls: readonly OpFactoryCall[]): Op[] {\n return calls.map((c) => {\n const op = c.toOp();\n assertPostgresOp(op, c.factoryName);\n return op;\n });\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,iBACP,IACA,iBACkB;CAClB,MAAM,WAAY,GAAmB,QAAQ;CAC7C,IAAI,aAAa,YACf,MAAM,IAAI,MACR,sDAAsD,OAAO,QAAQ,EAAE,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,0HAChI;AAEJ;AAEA,SAAgB,UAAU,OAAuC;CAC/D,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,KAAK,EAAE,KAAK;EAClB,iBAAiB,IAAI,EAAE,WAAW;EAClC,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"render-ops-BpjstrKQ.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { Lowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Asserts an op materialised by an `OpFactoryCall` targets postgres. The\n * extension surface lets any contributor emit calls, so this is the\n * integration boundary where a stray non-postgres op would otherwise\n * silently flow through to postgres-shaped renderers — exactly the\n * place to fail loudly with op metadata (`id` + `target.id`).\n */\nfunction assertPostgresOp(\n op: ReturnType<OpFactoryCall['toOp']>,\n callFactoryName: string,\n): asserts op is Op {\n const targetId = (op as Partial<Op>).target?.id;\n if (targetId !== 'postgres') {\n throw new Error(\n `renderOps: expected postgres op but got target.id=\"${String(targetId)}\" for op.id=\"${op.id}\" (factoryName=\"${callFactoryName}\"). An OpFactoryCall produced an op for a different target on the postgres planner path; check the call's target binding.`,\n );\n }\n}\n\nexport function renderOps(calls: readonly OpFactoryCall[], lowerer?: Lowerer): Op[] {\n return calls.map((c) => {\n const op = blindCast<\n { toOp(lowerer?: Lowerer): ReturnType<OpFactoryCall['toOp']> },\n 'PG OpFactoryCall.toOp accepts an optional Lowerer; the framework interface omits it because not all targets need a lowerer — the PG target overrides with this extended signature'\n >(c).toOp(lowerer);\n assertPostgresOp(op, c.factoryName);\n return op;\n });\n}\n"],"mappings":";;;;;;;;;AAeA,SAAS,iBACP,IACA,iBACkB;CAClB,MAAM,WAAY,GAAmB,QAAQ;CAC7C,IAAI,aAAa,YACf,MAAM,IAAI,MACR,sDAAsD,OAAO,QAAQ,EAAE,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,0HAChI;AAEJ;AAEA,SAAgB,UAAU,OAAiC,SAAyB;CAClF,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,KAAK,UAGT,CAAC,CAAC,CAAC,KAAK,OAAO;EACjB,iBAAiB,IAAI,EAAE,WAAW;EAClC,OAAO;CACT,CAAC;AACH"}
@@ -1,10 +1,11 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-a_wuOiYf.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { OpFactoryCall } from "@prisma-next/framework-components/control";
4
+ import { Lowerer } from "@prisma-next/family-sql/control-adapter";
4
5
 
5
6
  //#region src/core/migrations/render-ops.d.ts
6
7
  type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
7
- declare function renderOps(calls: readonly OpFactoryCall[]): Op[];
8
+ declare function renderOps(calls: readonly OpFactoryCall[], lowerer?: Lowerer): Op[];
8
9
  //#endregion
9
10
  export { renderOps };
10
11
  //# sourceMappingURL=render-ops.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;KAIK,EAAA,GAAK,yBAAyB,CAAC,yBAAA;AAAA,iBAqBpB,SAAA,CAAU,KAAA,WAAgB,aAAA,KAAkB,EAAE"}
1
+ {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;;KAMK,EAAA,GAAK,yBAAyB,CAAC,yBAAA;AAAA,iBAqBpB,SAAA,CAAU,KAAA,WAAgB,aAAA,IAAiB,OAAA,GAAU,OAAA,GAAU,EAAA"}
@@ -1,2 +1,2 @@
1
- import { t as renderOps } from "./render-ops-XhICjX_P.mjs";
1
+ import { t as renderOps } from "./render-ops-BpjstrKQ.mjs";
2
2
  export { renderOps };
@@ -28,7 +28,7 @@ const BASE_IMPORTS = [{
28
28
  }];
29
29
  function renderCallsToTypeScript(calls, meta) {
30
30
  const imports = buildImports(calls);
31
- const operationsBody = calls.map((c) => c.renderTypeScript()).join(",\n");
31
+ const operationsBody = calls.map((c) => renderCall(c)).join(",\n");
32
32
  return [
33
33
  shebangLineFor(detectScaffoldRuntime()),
34
34
  imports,
@@ -46,6 +46,9 @@ function renderCallsToTypeScript(calls, meta) {
46
46
  ""
47
47
  ].join("\n");
48
48
  }
49
+ function renderCall(call) {
50
+ return call.renderTypeScript();
51
+ }
49
52
  function buildImports(calls) {
50
53
  const requirements = [...BASE_IMPORTS];
51
54
  for (const call of calls) for (const req of call.importRequirements()) requirements.push(req);
@@ -69,4 +72,4 @@ function indent(text, spaces) {
69
72
  //#endregion
70
73
  export { renderCallsToTypeScript as t };
71
74
 
72
- //# sourceMappingURL=render-typescript-K125n-RZ.mjs.map
75
+ //# sourceMappingURL=render-typescript-KMgosran.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-KMgosran.mjs","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `OpFactoryCall` renders itself via `renderTypeScript()` and\n * declares its own `importRequirements()`; this file just composes the module\n * source around those contributions. The design mirrors the Mongo target's\n * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required\n * (different factory module specifiers, different base-class name) but the\n * shape is, so future consolidation to a framework-level helper is mechanical.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/postgres/migration` so an authored Postgres\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint:\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `PostgresPlanTargetDetails` and the abstract `targetId`\n * to `'postgres'`, so user-authored migrations don't need to thread\n * target-details or redeclare `targetId`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n * The migration file owns this dependency directly: pulling CLI\n * machinery in at script run time is acceptable because the script's\n * whole purpose is to be invoked from the project that owns the\n * config.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => renderCall(c)).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction renderCall(call: OpFactoryCall): string {\n return call.renderTypeScript();\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAmC,QAAQ;AAAY,GAC1E;CAAE,iBAAiB;CAAmC,QAAQ;AAAe,CAC/E;AAEA,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,KAAK;CAClC,MAAM,iBAAiB,MAAM,KAAK,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;CAEjE,OAAO;EACL,eAAe,sBAAsB,CAAC;EACtC;EACA;EACA;EACA,oBAAoB,IAAI;EACxB;EACA;EACA,OAAO,gBAAgB,CAAC;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,WAAW,MAA6B;CAC/C,OAAO,KAAK,iBAAiB;AAC/B;AAEA,SAAS,aAAa,OAA6C;CACjE,MAAM,eAAoC,CAAC,GAAG,YAAY;CAC1D,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,mBAAmB,GACxC,aAAa,KAAK,GAAG;CAGzB,OAAO,cAAc,YAAY;AACnC;AAEA,SAAS,oBAAoB,MAAmC;CAC9D,MAAM,QAAkB,CAAC;CACzB,MAAM,KAAK,yBAAyB;CACpC,MAAM,KAAK,cAAc;CACzB,MAAM,KAAK,eAAe,KAAK,UAAU,KAAK,IAAI,EAAE,EAAE;CACtD,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,EAAE,EAAE,EAAE;CAClD,MAAM,KAAK,QAAQ;CACnB,MAAM,KAAK,KAAK;CAChB,MAAM,KAAK,EAAE;CACb,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,MAAM;CAC7B,OAAO,KACJ,MAAM,IAAI,CAAC,CACX,KAAK,SAAU,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,IAAK,CAAC,CACrD,KAAK,IAAI;AACd"}
@@ -1,2 +1,2 @@
1
- import { t as renderCallsToTypeScript } from "./render-typescript-K125n-RZ.mjs";
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-KMgosran.mjs";
2
2
  export { renderCallsToTypeScript };
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cA8Ea,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;YAQ9D,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EAuBN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAmDpD,0BAAA;EAAA,QAiBA,kBAAA;AAAA;;;UC3KO,6BAAA,SAAsC,qBAAqB;;;;;ADqE5E;;cC7DM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/postgres-contract-serializer.ts","../src/exports/runtime.ts"],"mappings":";;;;;;;;;cAyEa,0BAAA,SAAmC,yBAAA,CAA0B,QAAA,CAAS,UAAA;;YAQ9D,wBAAA,CACjB,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EA4CN,iBAAA,CAAkB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,UAAA;EAAA,QAuCpD,0BAAA;EAAA,QAmBA,kBAAA;AAAA;;;UCjLO,6BAAA,SAAsC,qBAAqB;;;;;ADgE5E;;cCxDM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-DMRX39kp.mjs";
2
- import { t as PostgresContractSerializer } from "./postgres-contract-serializer-BnOboPWs.mjs";
1
+ import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-My8_s4cs.mjs";
2
+ import { t as PostgresContractSerializer } from "./postgres-contract-serializer-DYTyXjPf.mjs";
3
3
  //#region src/exports/runtime.ts
4
4
  /**
5
5
  * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
@@ -1,13 +1,13 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-a_wuOiYf.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { ReferentialAction } from "@prisma-next/sql-contract/types";
4
4
 
5
5
  //#region src/core/migrations/operations/shared.d.ts
6
6
  type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
7
7
  /**
8
- * Literal-args shape for a column definition consumed by `createTable` and
9
- * `addColumn`. Fully materialized: codec expansion and default rendering have
10
- * already happened in the wrapper.
8
+ * Literal-args shape for a column definition consumed by `addColumn` and
9
+ * similar operations. Fully materialized: codec expansion and default
10
+ * rendering have already happened in the wrapper.
11
11
  *
12
12
  * - `typeSql` is the column's DDL type string (e.g. `"integer"`, `"SERIAL"`,
13
13
  * `"varchar(100)"`), already produced by `buildColumnTypeSql` in the
@@ -40,4 +40,4 @@ interface ForeignKeySpec {
40
40
  }
41
41
  //#endregion
42
42
  export { ForeignKeySpec as n, Op as r, ColumnSpec as t };
43
- //# sourceMappingURL=shared-Do_a5ymU.d.mts.map
43
+ //# sourceMappingURL=shared-DarONYBZ.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-Do_a5ymU.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAyB,CAAC,yBAAA;;AAA3C;;;;AAAoE;AAcpE;;;;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;AAAA;;;;;;UAQM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA"}
1
+ {"version":3,"file":"shared-DarONYBZ.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAyB,CAAC,yBAAA;;AAA3C;;;;AAAoE;AAcpE;;;;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;AAAA;;;;;;UAQM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA"}
@@ -75,4 +75,4 @@ function validateEnumValueLength(value, enumTypeName) {
75
75
  //#endregion
76
76
  export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
77
77
 
78
- //# sourceMappingURL=sql-utils-CggjWNij.mjs.map
78
+ //# sourceMappingURL=sql-utils-DcfMz4MQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils-CggjWNij.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres target.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n *\n * They live in `target-postgres` because both the control adapter (used at\n * emit time) and the runtime adapter (used at execute time) need the same\n * escaping/validation behavior, and the target package is the natural shared\n * home that both adapters can depend on without crossing planes.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,YAAY;CAEjF,IAAI,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,KAAK,GAC/B,YACF;CAEF,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,EAAE,EAAE,4BAA4B,sBAAsB,uCAC3F;CAEF,OAAO,IAAI,WAAW,QAAQ,MAAM,MAAI,EAAE;AAC5C;;;;;;;;;;;;AAaA,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,IAAI,GACrB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,KAAK,GAC1B,SACF;CAEF,OAAO,MAAM,QAAQ,MAAM,IAAI;AACjC;;;;AAKA,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,UAAU,EAAE,GAAG,gBAAgB,UAAU;AACrE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,MAAM,SAAS,uBACjB,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,EAAE,EAAE,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,SACF;AAEJ"}
1
+ {"version":3,"file":"sql-utils-DcfMz4MQ.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the Postgres target.\n *\n * These functions handle safe SQL identifier and literal escaping\n * with security validations to prevent injection and encoding issues.\n *\n * They live in `target-postgres` because both the control adapter (used at\n * emit time) and the runtime adapter (used at execute time) need the same\n * escaping/validation behavior, and the target package is the natural shared\n * home that both adapters can depend on without crossing planes.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nconst MAX_IDENTIFIER_LENGTH = 63;\n\n/**\n * Validates and quotes a PostgreSQL identifier (table, column, type, schema names).\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n * - Rejects empty identifiers\n * - Warns on identifiers exceeding PostgreSQL's 63-character limit\n *\n * @throws {SqlEscapeError} If the identifier contains null bytes or is empty\n */\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n if (identifier.length > MAX_IDENTIFIER_LENGTH) {\n console.warn(\n `Identifier \"${identifier.slice(0, 20)}...\" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character limit and will be truncated`,\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\n/**\n * Escapes a string literal for safe use in SQL statements.\n *\n * Security validations:\n * - Rejects null bytes which could cause truncation or unexpected behavior\n *\n * Note: This assumes PostgreSQL's `standard_conforming_strings` is ON (default since PG 9.1).\n * Backslashes are treated as literal characters, not escape sequences.\n *\n * @throws {SqlEscapeError} If the value contains null bytes\n */\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n\n/**\n * Builds a qualified name (schema.object) with proper quoting.\n */\nexport function qualifyName(schemaName: string, objectName: string): string {\n return `${quoteIdentifier(schemaName)}.${quoteIdentifier(objectName)}`;\n}\n\n/**\n * Validates that an enum value doesn't exceed PostgreSQL's label length limit.\n *\n * PostgreSQL enum labels have a maximum length of NAMEDATALEN-1 (63 bytes by default).\n * Unlike identifiers, enum labels that exceed this limit cause an error rather than\n * silent truncation.\n *\n * @param value - The enum value to validate\n * @param enumTypeName - Name of the enum type (for error messages)\n * @throws {SqlEscapeError} If the value exceeds the maximum length\n */\nexport function validateEnumValueLength(value: string, enumTypeName: string): void {\n if (value.length > MAX_IDENTIFIER_LENGTH) {\n throw new SqlEscapeError(\n `Enum value \"${value.slice(0, 20)}...\" for type \"${enumTypeName}\" exceeds PostgreSQL's ` +\n `${MAX_IDENTIFIER_LENGTH}-character label limit`,\n value,\n 'literal',\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,YAAY;CAEjF,IAAI,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,KAAK,GAC/B,YACF;CAEF,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,EAAE,EAAE,4BAA4B,sBAAsB,uCAC3F;CAEF,OAAO,IAAI,WAAW,QAAQ,MAAM,MAAI,EAAE;AAC5C;;;;;;;;;;;;AAaA,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,IAAI,GACrB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,KAAK,GAC1B,SACF;CAEF,OAAO,MAAM,QAAQ,MAAM,IAAI;AACjC;;;;AAKA,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,UAAU,EAAE,GAAG,gBAAgB,UAAU;AACrE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,MAAM,SAAS,uBACjB,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,EAAE,EAAE,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,SACF;AAEJ"}
@@ -1,2 +1,2 @@
1
- import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-CggjWNij.mjs";
1
+ import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-DcfMz4MQ.mjs";
2
2
  export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
@@ -7,4 +7,4 @@ type PostgresColumnDefault = ColumnDefault | {
7
7
  };
8
8
  //#endregion
9
9
  export { PostgresColumnDefault as t };
10
- //# sourceMappingURL=types-O40IcFV9.d.mts.map
10
+ //# sourceMappingURL=types-BDKkx8MA.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BDKkx8MA.d.mts","names":[],"sources":["../src/core/types.ts"],"mappings":";;;KAEY,qBAAA,GACR,aAAa;EAAA,SACF,IAAA;EAAA,SAA2B,IAAA;AAAA"}
package/dist/types.d.mts CHANGED
@@ -1,13 +1,15 @@
1
- import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-CSzsvXrO.mjs";
2
- import { t as PostgresColumnDefault } from "./types-O40IcFV9.mjs";
1
+ import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-BVn63a89.mjs";
2
+ import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
3
3
  import { NamespaceBase } from "@prisma-next/framework-components/ir";
4
- import { SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput } from "@prisma-next/sql-contract/types";
4
+ import { PostgresEnumStorageEntry, SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput } from "@prisma-next/sql-contract/types";
5
5
 
6
6
  //#region src/core/postgres-schema.d.ts
7
7
  interface PostgresSchemaInput {
8
8
  readonly id: string;
9
- readonly tables?: Record<string, StorageTable | StorageTableInput>;
10
- readonly enum?: Record<string, PostgresEnumType | PostgresEnumTypeInput>;
9
+ readonly entries: {
10
+ readonly table: Record<string, StorageTable | StorageTableInput>;
11
+ readonly type: Record<string, PostgresEnumType | PostgresEnumTypeInput>;
12
+ };
11
13
  }
12
14
  /**
13
15
  * Postgres target `Namespace` concretion — a Postgres schema (`CREATE
@@ -15,9 +17,10 @@ interface PostgresSchemaInput {
15
17
  * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by
16
18
  * the Postgres PSL interpreter from `namespace { … }` AST buckets.
17
19
  *
18
- * Qualifier emission is the rendering seam: DDL / SQL emission asks the
19
- * namespace for its qualifier (`"<schema>"`) or for a qualified table
20
- * name (`"<schema>"."<table>"`) and consumes the result polymorphically.
20
+ * `entries` holds entity-kind slot maps (`table`, `type`). Qualifier
21
+ * emission is the rendering seam: DDL / SQL emission asks the namespace
22
+ * for its qualifier (`"<schema>"`) or for a qualified table name
23
+ * (`"<schema>"."<table>"`) and consumes the result polymorphically.
21
24
  * The unbound singleton below overrides these methods to elide the
22
25
  * prefix entirely — call sites stay polymorphic and never branch on
23
26
  * `id === UNBOUND_NAMESPACE_ID`.
@@ -33,8 +36,10 @@ declare class PostgresSchema extends NamespaceBase {
33
36
  static unbound: PostgresUnboundSchema;
34
37
  readonly kind: 'schema';
35
38
  readonly id: string;
36
- readonly tables: Readonly<Record<string, StorageTable>>;
37
- readonly enum: Readonly<Record<string, PostgresEnumType>>;
39
+ readonly entries: Readonly<{
40
+ readonly table: Readonly<Record<string, StorageTable>>;
41
+ readonly type: Readonly<Record<string, PostgresEnumType>>;
42
+ }>;
38
43
  constructor(input: PostgresSchemaInput);
39
44
  /**
40
45
  * The bare schema qualifier as it would appear in a rendered SQL
@@ -115,7 +120,7 @@ declare class PostgresUnboundSchema extends PostgresSchema {
115
120
  * by reference and trust the resulting `SqlStorage.namespaces` map to
116
121
  * be value-stable for a given input set.
117
122
  */
118
- declare function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema;
123
+ declare function postgresCreateNamespace(input: SqlNamespaceTablesInput, enumTypes?: Readonly<Record<string, PostgresEnumStorageEntry>>): PostgresSchema;
119
124
  //#endregion
120
125
  export { type PostgresColumnDefault, PostgresEnumType, type PostgresEnumTypeInput, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
121
126
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;UAciB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,MAAA,GAAS,MAAA,SAAe,YAAA,GAAe,iBAAA;EAAA,SACvC,IAAA,GAAO,MAAA,SAAe,gBAAA,GAAmB,qBAAA;AAAA;;;;;;;;;;;;;;cAgBvC,cAAA,SAAuB,aAAA;EAhBzB;;;;;AAA8D;AAgBzE;EAhBW,OAwBF,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,MAAA,EAAQ,QAAA,CAAS,MAAA,SAAe,YAAA;EAAA,SAChC,IAAA,EAAM,QAAA,CAAS,MAAA,SAAe,gBAAA;cAE3B,KAAA,EAAO,mBAAA;EAFoB;;;;;EAmCvC,SAAA,CAAA;EAhD+C;;;;;;EA0D/C,YAAA,CAAa,SAAA;EA9CJ;;;;;;EAwDT,eAAA,CAAgB,IAAA;EAvDuB;;;;;;;;EAmEvC,mBAAA,CAAA;EAAA;;;;;AAekC;AAwBpC;;;;;EAxBE,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;;;;;;;;;;AAuCI;AA+B9B;;;;;;cA9Ca,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA,CAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA,CAAA;AAAA;;;;;;;;;;;;iBA+BK,uBAAA,CAAwB,KAAA,EAAO,uBAAA,GAA0B,cAAc"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/core/postgres-schema.ts"],"mappings":";;;;;;UAeiB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA;IAAA,SACE,KAAA,EAAO,MAAA,SAAe,YAAA,GAAe,iBAAA;IAAA,SACrC,IAAA,EAAM,MAAA,SAAe,gBAAA,GAAmB,qBAAA;EAAA;AAAA;;;;;;;;;;;;;;;cAkBxC,cAAA,SAAuB,aAAA;EAlBF;;;AAAwC;AAkB1E;;;EAlBkC,OA0BzB,OAAA,EAAS,qBAAA;EAAA,SAEC,IAAA;EAAA,SACR,EAAA;EAAA,SACA,OAAA,EAAS,QAAA;IAAA,SACP,KAAA,EAAO,QAAA,CAAS,MAAA,SAAe,YAAA;IAAA,SAC/B,IAAA,EAAM,QAAA,CAAS,MAAA,SAAe,gBAAA;EAAA;cAG7B,KAAA,EAAO,mBAAA;EAAA;;;;;EAmCnB,SAAA;EA5CO;;;;;;EAsDP,YAAA,CAAa,SAAA;EAjDK;;;;;;EA2DlB,eAAA,CAAgB,IAAA;;;;;;;;;EAYhB,mBAAA;EAeA;;;;AAAkC;AAwBpC;;;;;;EAxBE,aAAA,CAAc,QAAA,EAAU,UAAA;AAAA;;;;;;;;;;;;AAuCI;AA+B9B;;;;;;;cA9Ca,qBAAA,SAA8B,cAAA;EAAA,gBACzB,QAAA,EAAU,qBAAA;cAEd,KAAA,GAAQ,mBAAA;EAIX,SAAA;EAIA,YAAA,CAAa,SAAA;EAIb,mBAAA;AAAA;;;;;;;;;;;;iBA+BK,uBAAA,CACd,KAAA,EAAO,uBAAA,EACP,SAAA,GAAY,QAAA,CAAS,MAAA,SAAe,wBAAA,KACnC,cAAA"}
package/dist/types.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as PostgresEnumType } from "./postgres-enum-type-BMgyxNyy.mjs";
2
- import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-BxAuNFX0.mjs";
1
+ import { t as PostgresEnumType } from "./postgres-enum-type-DPKqCBem.mjs";
2
+ import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-BuxCxbvB.mjs";
3
3
  export { PostgresEnumType, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.12.0-dev.7",
3
+ "version": "0.12.0-dev.71",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "Postgres target pack for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/cli": "0.12.0-dev.7",
10
- "@prisma-next/contract": "0.12.0-dev.7",
11
- "@prisma-next/errors": "0.12.0-dev.7",
12
- "@prisma-next/family-sql": "0.12.0-dev.7",
13
- "@prisma-next/framework-components": "0.12.0-dev.7",
14
- "@prisma-next/migration-tools": "0.12.0-dev.7",
15
- "@prisma-next/ts-render": "0.12.0-dev.7",
16
- "@prisma-next/sql-contract": "0.12.0-dev.7",
17
- "@prisma-next/sql-errors": "0.12.0-dev.7",
18
- "@prisma-next/sql-operations": "0.12.0-dev.7",
19
- "@prisma-next/sql-relational-core": "0.12.0-dev.7",
20
- "@prisma-next/sql-schema-ir": "0.12.0-dev.7",
21
- "@prisma-next/utils": "0.12.0-dev.7",
9
+ "@prisma-next/cli": "0.12.0-dev.71",
10
+ "@prisma-next/contract": "0.12.0-dev.71",
11
+ "@prisma-next/errors": "0.12.0-dev.71",
12
+ "@prisma-next/family-sql": "0.12.0-dev.71",
13
+ "@prisma-next/framework-components": "0.12.0-dev.71",
14
+ "@prisma-next/migration-tools": "0.12.0-dev.71",
15
+ "@prisma-next/ts-render": "0.12.0-dev.71",
16
+ "@prisma-next/sql-contract": "0.12.0-dev.71",
17
+ "@prisma-next/sql-errors": "0.12.0-dev.71",
18
+ "@prisma-next/sql-operations": "0.12.0-dev.71",
19
+ "@prisma-next/sql-relational-core": "0.12.0-dev.71",
20
+ "@prisma-next/sql-schema-ir": "0.12.0-dev.71",
21
+ "@prisma-next/utils": "0.12.0-dev.71",
22
22
  "@standard-schema/spec": "^1.1.0",
23
23
  "arktype": "^2.2.0",
24
24
  "pathe": "^2.0.3"
25
25
  },
26
26
  "devDependencies": {
27
- "@prisma-next/test-utils": "0.12.0-dev.7",
28
- "@prisma-next/tsconfig": "0.12.0-dev.7",
29
- "@prisma-next/tsdown": "0.12.0-dev.7",
30
- "tsdown": "0.22.0",
27
+ "@prisma-next/test-utils": "0.12.0-dev.71",
28
+ "@prisma-next/tsconfig": "0.12.0-dev.71",
29
+ "@prisma-next/tsdown": "0.12.0-dev.71",
30
+ "tsdown": "0.22.1",
31
31
  "typescript": "5.9.3",
32
- "vitest": "4.1.6"
32
+ "vitest": "4.1.8"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "typescript": ">=5.9"
@@ -48,8 +48,10 @@
48
48
  "./codec-ids": "./dist/codec-ids.mjs",
49
49
  "./codec-types": "./dist/codec-types.mjs",
50
50
  "./codecs": "./dist/codecs.mjs",
51
+ "./contract-free": "./dist/contract-free.mjs",
51
52
  "./control": "./dist/control.mjs",
52
53
  "./data-transform": "./dist/data-transform.mjs",
54
+ "./ddl": "./dist/ddl.mjs",
53
55
  "./default-normalizer": "./dist/default-normalizer.mjs",
54
56
  "./enum-planning": "./dist/enum-planning.mjs",
55
57
  "./errors": "./dist/errors.mjs",
@@ -69,7 +71,6 @@
69
71
  "./render-typescript": "./dist/render-typescript.mjs",
70
72
  "./runtime": "./dist/runtime.mjs",
71
73
  "./sql-utils": "./dist/sql-utils.mjs",
72
- "./statement-builders": "./dist/statement-builders.mjs",
73
74
  "./types": "./dist/types.mjs",
74
75
  "./package.json": "./package.json"
75
76
  },
@@ -0,0 +1,49 @@
1
+ import {
2
+ type ColumnDescriptor,
3
+ type ColumnSchema,
4
+ type TableHandle,
5
+ table,
6
+ } from '@prisma-next/sql-relational-core/contract-free';
7
+ import { PostgresTableSource } from '../core/ast/table-source';
8
+ import {
9
+ PG_INT4_CODEC_ID,
10
+ PG_INT8_CODEC_ID,
11
+ PG_JSONB_CODEC_ID,
12
+ PG_TEXT_ARRAY_CODEC_ID,
13
+ PG_TEXT_CODEC_ID,
14
+ PG_TIMESTAMPTZ_CODEC_ID,
15
+ } from '../core/codec-ids';
16
+
17
+ type ColOpts = { readonly nullable?: boolean };
18
+
19
+ const desc = (codecId: string, opts?: ColOpts): ColumnDescriptor => ({
20
+ codecId,
21
+ nullable: opts?.nullable ?? false,
22
+ });
23
+
24
+ export const text = (opts?: ColOpts): ColumnDescriptor => desc(PG_TEXT_CODEC_ID, opts);
25
+ export const int4 = (opts?: ColOpts): ColumnDescriptor => desc(PG_INT4_CODEC_ID, opts);
26
+ export const int8 = (opts?: ColOpts): ColumnDescriptor => desc(PG_INT8_CODEC_ID, opts);
27
+ export const jsonb = (opts?: ColOpts): ColumnDescriptor => desc(PG_JSONB_CODEC_ID, opts);
28
+ export const textArray = (opts?: ColOpts): ColumnDescriptor => desc(PG_TEXT_ARRAY_CODEC_ID, opts);
29
+ export const timestamptz = (opts?: ColOpts): ColumnDescriptor =>
30
+ desc(PG_TIMESTAMPTZ_CODEC_ID, opts);
31
+
32
+ /**
33
+ * Declare a PostgreSQL control-plane table with a typed column schema. Wraps
34
+ * the generic `table()` factory with a `PostgresTableSource` so the renderer
35
+ * qualifies the table name with the optional schema prefix.
36
+ *
37
+ * ```ts
38
+ * const marker = pgTable(
39
+ * { name: 'marker', schema: 'prisma_contract' },
40
+ * { space: text(), core_hash: text(), updated_at: timestamptz() },
41
+ * );
42
+ * ```
43
+ */
44
+ export function pgTable<Schema extends ColumnSchema>(
45
+ source: { readonly name: string; readonly schema?: string; readonly alias?: string },
46
+ columns: Schema,
47
+ ): TableHandle<Schema> {
48
+ return table(new PostgresTableSource(source), columns);
49
+ }
@@ -0,0 +1,55 @@
1
+ import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
2
+ import type { DdlNode } from '@prisma-next/sql-relational-core/ast';
3
+ import { col, fn, lit } from '@prisma-next/sql-relational-core/contract-free';
4
+ import { createSchema, createTable } from './ddl';
5
+
6
+ const markerColumns = [
7
+ col('space', 'text', { notNull: true, primaryKey: true, default: lit(APP_SPACE_ID) }),
8
+ col('core_hash', 'text', { notNull: true }),
9
+ col('profile_hash', 'text', { notNull: true }),
10
+ col('contract_json', 'jsonb'),
11
+ col('canonical_version', 'int'),
12
+ col('updated_at', 'timestamptz', { notNull: true, default: fn('now()') }),
13
+ col('app_tag', 'text'),
14
+ col('meta', 'jsonb', { notNull: true, default: lit('{}') }),
15
+ col('invariants', 'text[]', { notNull: true, default: lit('{}') }),
16
+ ] as const;
17
+
18
+ const ledgerColumns = [
19
+ col('id', 'bigserial', { primaryKey: true }),
20
+ col('created_at', 'timestamptz', { notNull: true, default: fn('now()') }),
21
+ col('space', 'text', { notNull: true }),
22
+ col('migration_name', 'text', { notNull: true }),
23
+ col('migration_hash', 'text', { notNull: true }),
24
+ col('origin_core_hash', 'text'),
25
+ col('origin_profile_hash', 'text'),
26
+ col('destination_core_hash', 'text', { notNull: true }),
27
+ col('destination_profile_hash', 'text'),
28
+ col('contract_json_before', 'jsonb'),
29
+ col('contract_json_after', 'jsonb'),
30
+ col('operations', 'jsonb', { notNull: true }),
31
+ ] as const;
32
+
33
+ const markerTable = createTable({
34
+ schema: 'prisma_contract',
35
+ table: 'marker',
36
+ ifNotExists: true,
37
+ columns: markerColumns,
38
+ });
39
+
40
+ const ledgerTable = createTable({
41
+ schema: 'prisma_contract',
42
+ table: 'ledger',
43
+ ifNotExists: true,
44
+ columns: ledgerColumns,
45
+ });
46
+
47
+ const controlSchema = createSchema({ schema: 'prisma_contract', ifNotExists: true });
48
+
49
+ export function buildSignMarkerBootstrapQueries(): readonly DdlNode[] {
50
+ return [controlSchema, markerTable];
51
+ }
52
+
53
+ export function buildControlTableBootstrapQueries(): readonly DdlNode[] {
54
+ return [controlSchema, markerTable, ledgerTable];
55
+ }