@prisma-next/target-postgres 0.5.0-dev.8 → 0.5.0-dev.80

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 (180) hide show
  1. package/dist/{codec-ids-CojIXVf9.mjs → codec-ids-C5qzBqus.mjs} +4 -4
  2. package/dist/{codec-ids-CojIXVf9.mjs.map → codec-ids-C5qzBqus.mjs.map} +1 -1
  3. package/dist/codec-ids-CplrEfmx.d.mts +29 -0
  4. package/dist/codec-ids-CplrEfmx.d.mts.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -28
  6. package/dist/codec-ids.mjs +2 -3
  7. package/dist/codec-types-lrsb3N07.d.mts +79 -0
  8. package/dist/codec-types-lrsb3N07.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +2 -42
  10. package/dist/codec-types.mjs +1 -4
  11. package/dist/codecs-Cue97Xqf.d.mts +558 -0
  12. package/dist/codecs-Cue97Xqf.d.mts.map +1 -0
  13. package/dist/codecs.d.mts +13 -2
  14. package/dist/codecs.d.mts.map +1 -0
  15. package/dist/codecs.mjs +738 -3
  16. package/dist/codecs.mjs.map +1 -0
  17. package/dist/control.d.mts +1 -1
  18. package/dist/control.d.mts.map +1 -1
  19. package/dist/control.mjs +131 -94
  20. package/dist/control.mjs.map +1 -1
  21. package/dist/{data-transform-VfEGzXWt.mjs → data-transform-DKWXdHuZ.mjs} +25 -7
  22. package/dist/data-transform-DKWXdHuZ.mjs.map +1 -0
  23. package/dist/data-transform-bIeAcZIJ.d.mts +38 -0
  24. package/dist/data-transform-bIeAcZIJ.d.mts.map +1 -0
  25. package/dist/data-transform.d.mts +1 -1
  26. package/dist/data-transform.mjs +2 -3
  27. package/dist/{default-normalizer-DNOpRoOF.mjs → default-normalizer-C8XyZj85.mjs} +2 -2
  28. package/dist/{default-normalizer-DNOpRoOF.mjs.map → default-normalizer-C8XyZj85.mjs.map} +1 -1
  29. package/dist/default-normalizer.d.mts +0 -1
  30. package/dist/default-normalizer.d.mts.map +1 -1
  31. package/dist/default-normalizer.mjs +2 -3
  32. package/dist/descriptor-meta-Dde_BS3K.mjs +99 -0
  33. package/dist/descriptor-meta-Dde_BS3K.mjs.map +1 -0
  34. package/dist/{errors-AFvEPZ1R.mjs → errors-Chm2bKcS.mjs} +2 -3
  35. package/dist/{errors-AFvEPZ1R.mjs.map → errors-Chm2bKcS.mjs.map} +1 -1
  36. package/dist/errors.d.mts +0 -1
  37. package/dist/errors.d.mts.map +1 -1
  38. package/dist/errors.mjs +2 -3
  39. package/dist/{issue-planner-CFjB0_oO.mjs → issue-planner-B10B70JF.mjs} +9 -13
  40. package/dist/issue-planner-B10B70JF.mjs.map +1 -0
  41. package/dist/issue-planner.d.mts +2 -4
  42. package/dist/issue-planner.d.mts.map +1 -1
  43. package/dist/issue-planner.mjs +2 -3
  44. package/dist/migration.d.mts +3 -3
  45. package/dist/migration.d.mts.map +1 -1
  46. package/dist/migration.mjs +4 -5
  47. package/dist/migration.mjs.map +1 -1
  48. package/dist/{native-type-normalizer-CInai_oY.mjs → native-type-normalizer-Cry4QoLf.mjs} +2 -2
  49. package/dist/native-type-normalizer-Cry4QoLf.mjs.map +1 -0
  50. package/dist/native-type-normalizer.d.mts.map +1 -1
  51. package/dist/native-type-normalizer.mjs +2 -3
  52. package/dist/{op-factory-call-C3bWXKSP.d.mts → op-factory-call-CW8pzxmB.d.mts} +3 -4
  53. package/dist/op-factory-call-CW8pzxmB.d.mts.map +1 -0
  54. package/dist/{op-factory-call-BKlruaiC.mjs → op-factory-call-Cq8s4Fz1.mjs} +3 -4
  55. package/dist/{op-factory-call-BKlruaiC.mjs.map → op-factory-call-Cq8s4Fz1.mjs.map} +1 -1
  56. package/dist/op-factory-call.d.mts +1 -2
  57. package/dist/op-factory-call.mjs +2 -3
  58. package/dist/pack.d.mts +28 -9
  59. package/dist/pack.d.mts.map +1 -1
  60. package/dist/pack.mjs +2 -3
  61. package/dist/{planner-CLUvVhUN.mjs → planner-BvKUuqG-.mjs} +22 -16
  62. package/dist/planner-BvKUuqG-.mjs.map +1 -0
  63. package/dist/{planner-ddl-builders-Dxvw1LHw.mjs → planner-ddl-builders-CLB7Umhh.mjs} +4 -5
  64. package/dist/planner-ddl-builders-CLB7Umhh.mjs.map +1 -0
  65. package/dist/planner-ddl-builders.d.mts +1 -1
  66. package/dist/planner-ddl-builders.d.mts.map +1 -1
  67. package/dist/planner-ddl-builders.mjs +2 -3
  68. package/dist/{planner-identity-values-Dju-o5GF.mjs → planner-identity-values-DTx0gePL.mjs} +2 -3
  69. package/dist/{planner-identity-values-Dju-o5GF.mjs.map → planner-identity-values-DTx0gePL.mjs.map} +1 -1
  70. package/dist/planner-identity-values.d.mts +0 -1
  71. package/dist/planner-identity-values.d.mts.map +1 -1
  72. package/dist/planner-identity-values.mjs +2 -3
  73. package/dist/{planner-produced-postgres-migration-CRRTno6Z.d.mts → planner-produced-postgres-migration-CjxWIVgh.d.mts} +11 -7
  74. package/dist/planner-produced-postgres-migration-CjxWIVgh.d.mts.map +1 -0
  75. package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs → planner-produced-postgres-migration-DphktB2N.mjs} +16 -8
  76. package/dist/planner-produced-postgres-migration-DphktB2N.mjs.map +1 -0
  77. package/dist/planner-produced-postgres-migration.d.mts +1 -4
  78. package/dist/planner-produced-postgres-migration.mjs +2 -3
  79. package/dist/{planner-schema-lookup-B7lkypwn.mjs → planner-schema-lookup-B1ags8ys.mjs} +2 -2
  80. package/dist/{planner-schema-lookup-B7lkypwn.mjs.map → planner-schema-lookup-B1ags8ys.mjs.map} +1 -1
  81. package/dist/planner-schema-lookup.d.mts +0 -1
  82. package/dist/planner-schema-lookup.d.mts.map +1 -1
  83. package/dist/planner-schema-lookup.mjs +2 -3
  84. package/dist/{planner-sql-checks-7jkgm9TX.mjs → planner-sql-checks-DwZvGlV4.mjs} +3 -5
  85. package/dist/planner-sql-checks-DwZvGlV4.mjs.map +1 -0
  86. package/dist/planner-sql-checks.d.mts.map +1 -1
  87. package/dist/planner-sql-checks.mjs +2 -3
  88. package/dist/{planner-target-details-DH-azLu-.d.mts → planner-target-details-bVVcanWh.d.mts} +1 -1
  89. package/dist/planner-target-details-bVVcanWh.d.mts.map +1 -0
  90. package/dist/planner-target-details.d.mts +1 -1
  91. package/dist/planner-target-details.mjs +1 -1
  92. package/dist/planner.d.mts +21 -12
  93. package/dist/planner.d.mts.map +1 -1
  94. package/dist/planner.mjs +2 -4
  95. package/dist/{postgres-migration-qtmtbONe.mjs → postgres-migration-Bkv140RW.mjs} +4 -5
  96. package/dist/postgres-migration-Bkv140RW.mjs.map +1 -0
  97. package/dist/{postgres-migration-BjA3Zmts.d.mts → postgres-migration-UkcHfZAA.d.mts} +6 -6
  98. package/dist/postgres-migration-UkcHfZAA.d.mts.map +1 -0
  99. package/dist/render-ops--1nnfNus.mjs +23 -0
  100. package/dist/render-ops--1nnfNus.mjs.map +1 -0
  101. package/dist/render-ops.d.mts +3 -4
  102. package/dist/render-ops.d.mts.map +1 -1
  103. package/dist/render-ops.mjs +2 -3
  104. package/dist/{render-typescript-1rF_SB4g.mjs → render-typescript-D3doH-vX.mjs} +2 -14
  105. package/dist/render-typescript-D3doH-vX.mjs.map +1 -0
  106. package/dist/render-typescript.d.mts +3 -6
  107. package/dist/render-typescript.d.mts.map +1 -1
  108. package/dist/render-typescript.mjs +2 -3
  109. package/dist/runtime.d.mts +5 -9
  110. package/dist/runtime.d.mts.map +1 -1
  111. package/dist/runtime.mjs +7 -14
  112. package/dist/runtime.mjs.map +1 -1
  113. package/dist/{shared-Bxkt8pNO.d.mts → shared-MpwjwAjM.d.mts} +2 -2
  114. package/dist/shared-MpwjwAjM.d.mts.map +1 -0
  115. package/dist/{sql-utils-r-Lw535w.mjs → sql-utils-CggjWNij.mjs} +4 -2
  116. package/dist/sql-utils-CggjWNij.mjs.map +1 -0
  117. package/dist/sql-utils.d.mts.map +1 -1
  118. package/dist/sql-utils.mjs +2 -3
  119. package/dist/{statement-builders-BPnmt6wx.mjs → statement-builders-BT889jV0.mjs} +28 -13
  120. package/dist/statement-builders-BT889jV0.mjs.map +1 -0
  121. package/dist/statement-builders.d.mts +31 -3
  122. package/dist/statement-builders.d.mts.map +1 -1
  123. package/dist/statement-builders.mjs +2 -3
  124. package/dist/{tables-BmdW_FWO.mjs → tables-Ej122-iI.mjs} +4 -11
  125. package/dist/tables-Ej122-iI.mjs.map +1 -0
  126. package/dist/{types-ClK03Ojd.d.mts → types-CTqpysRY.d.mts} +1 -1
  127. package/dist/types-CTqpysRY.d.mts.map +1 -0
  128. package/dist/types.d.mts +1 -1
  129. package/dist/types.mjs +1 -1
  130. package/package.json +21 -19
  131. package/src/core/authoring.ts +5 -11
  132. package/src/core/codec-helpers.ts +135 -0
  133. package/src/core/codec-ids.ts +1 -0
  134. package/src/core/codec-type-map.ts +81 -0
  135. package/src/core/codecs.ts +941 -547
  136. package/src/core/descriptor-meta.ts +1 -1
  137. package/src/core/migrations/operations/data-transform.ts +86 -21
  138. package/src/core/migrations/planner-produced-postgres-migration.ts +17 -5
  139. package/src/core/migrations/planner.ts +62 -20
  140. package/src/core/migrations/postgres-migration.ts +3 -6
  141. package/src/core/migrations/render-ops.ts +26 -3
  142. package/src/core/migrations/render-typescript.ts +5 -9
  143. package/src/core/migrations/runner.ts +172 -151
  144. package/src/core/migrations/statement-builders.ts +49 -10
  145. package/src/core/registry.ts +11 -0
  146. package/src/exports/codec-types.ts +4 -13
  147. package/src/exports/codecs.ts +49 -2
  148. package/src/exports/runtime.ts +6 -11
  149. package/src/exports/statement-builders.ts +2 -1
  150. package/dist/codec-ids.d.mts.map +0 -1
  151. package/dist/codec-types.d.mts.map +0 -1
  152. package/dist/codecs-BQEm9_oo.d.mts +0 -319
  153. package/dist/codecs-BQEm9_oo.d.mts.map +0 -1
  154. package/dist/codecs-BoahtY_Q.mjs +0 -385
  155. package/dist/codecs-BoahtY_Q.mjs.map +0 -1
  156. package/dist/data-transform-CxFRBIUp.d.mts +0 -32
  157. package/dist/data-transform-CxFRBIUp.d.mts.map +0 -1
  158. package/dist/data-transform-VfEGzXWt.mjs.map +0 -1
  159. package/dist/descriptor-meta-BVoVtyp-.mjs +0 -120
  160. package/dist/descriptor-meta-BVoVtyp-.mjs.map +0 -1
  161. package/dist/issue-planner-CFjB0_oO.mjs.map +0 -1
  162. package/dist/native-type-normalizer-CInai_oY.mjs.map +0 -1
  163. package/dist/op-factory-call-C3bWXKSP.d.mts.map +0 -1
  164. package/dist/planner-CLUvVhUN.mjs.map +0 -1
  165. package/dist/planner-ddl-builders-Dxvw1LHw.mjs.map +0 -1
  166. package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +0 -1
  167. package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs.map +0 -1
  168. package/dist/planner-sql-checks-7jkgm9TX.mjs.map +0 -1
  169. package/dist/planner-target-details-DH-azLu-.d.mts.map +0 -1
  170. package/dist/postgres-migration-BjA3Zmts.d.mts.map +0 -1
  171. package/dist/postgres-migration-qtmtbONe.mjs.map +0 -1
  172. package/dist/render-ops-D6_DHdOK.mjs +0 -8
  173. package/dist/render-ops-D6_DHdOK.mjs.map +0 -1
  174. package/dist/render-typescript-1rF_SB4g.mjs.map +0 -1
  175. package/dist/shared-Bxkt8pNO.d.mts.map +0 -1
  176. package/dist/sql-utils-r-Lw535w.mjs.map +0 -1
  177. package/dist/statement-builders-BPnmt6wx.mjs.map +0 -1
  178. package/dist/tables-BmdW_FWO.mjs.map +0 -1
  179. package/dist/types-ClK03Ojd.d.mts.map +0 -1
  180. package/src/core/json-schema-type-expression.ts +0 -131
@@ -1 +1 @@
1
- export { };
1
+ export {};
@@ -1,9 +1,7 @@
1
- import "./shared-Bxkt8pNO.mjs";
2
- import "./op-factory-call-C3bWXKSP.mjs";
3
- import "./postgres-migration-BjA3Zmts.mjs";
4
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CRRTno6Z.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CjxWIVgh.mjs";
5
2
  import { MigrationOperationPolicy, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
6
3
  import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
4
+ import { Contract } from "@prisma-next/contract/types";
7
5
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
8
6
 
9
7
  //#region src/core/migrations/planner.d.ts
@@ -45,20 +43,31 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
45
43
  readonly contract: unknown;
46
44
  readonly schema: unknown;
47
45
  readonly policy: MigrationOperationPolicy;
48
- readonly fromHash?: string;
49
46
  /**
50
47
  * The "from" contract (state the planner assumes the database starts
51
- * at). Only `migration plan` supplies this; `db update` / `db init`
52
- * reconcile against the live schema with no old contract. When present
53
- * alongside the `'data'` operation class, strategies that need from/to
54
- * column shape comparisons (unsafe type change, nullability tightening)
55
- * activate.
48
+ * at), or `null` for reconciliation flows. Only `migration plan` ever
49
+ * supplies a non-null value; `db update` / `db init` reconcile against
50
+ * the live schema and pass `null`. When present alongside the
51
+ * `'data'` operation class, strategies that need from/to column-shape
52
+ * comparisons (unsafe type change, nullability tightening) activate.
53
+ *
54
+ * Typed as the framework `Contract | null` to satisfy the
55
+ * `MigrationPlanner` interface contract; `planSql` narrows to the SQL
56
+ * shape via `SqlMigrationPlannerPlanOptions`. Used to populate
57
+ * `describe().from` on the produced plan as
58
+ * `fromContract?.storage.storageHash ?? null`.
56
59
  */
57
- readonly fromContract?: unknown;
60
+ readonly fromContract: Contract | null;
58
61
  readonly schemaName?: string;
59
62
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
63
+ /**
64
+ * Contract space this plan applies to. Stamped onto the produced
65
+ * {@link TypeScriptRenderablePostgresMigration.spaceId} so the runner keys
66
+ * the marker row by the right space.
67
+ */
68
+ readonly spaceId: string;
60
69
  }): PostgresPlanResult;
61
- emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface;
70
+ emptyMigration(context: MigrationScaffoldContext, spaceId: string): MigrationPlanWithAuthoringSurface;
62
71
  private planSql;
63
72
  private ensureAdditivePolicy;
64
73
  private collectSchemaIssues;
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAkCU,aAAA;;;iBAQM,8BAAA,UACN,QAAQ,iBACf;;AA3B2F;AAyB9F;;;;;AAgBY,KAAA,kBAAA,GAAkB;EAoBjB,SAAA,IAAA,EAAA,SAAA;EAC0B,SAAA,IAAA,EApBQ,qCAoBR;CAKlB,GAxBjB,uBAwBiB;;;;;;;;;;;;;;;;;cANR,wBAAA,YAAoC;;sBACV;;;;qBAKlB;;;;;;;;;;;;kCAYa,cAAc;MAC1C;0BAIoB,2BAA2B"}
1
+ {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;UAuCU,aAAA;EAAA,SACC,aAAA;AAAA;AAAA,iBAOK,8BAAA,CACd,MAAA,GAAQ,OAAA,CAAQ,aAAA,IACf,wBAAA;;;;AAFH;;;;KAgBY,kBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,IAAA,EAAM,qCAAA;AAAA,IAC3C,uBAAA;;;;;;;AAFJ;;;;;;;;;;cAoBa,wBAAA,YAAoC,gBAAA;EAAA,iBAClB,MAAA;cAAA,MAAA,EAAQ,aAAA;EAErC,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IAiBa;;;;;;;;;;;;;;IAAA,SAFrB,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAFnC;;;;;IAAA,SAQA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAWK,OAAA;EAAA,QA6DA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
package/dist/planner.mjs CHANGED
@@ -1,4 +1,2 @@
1
- import "./issue-planner-CFjB0_oO.mjs";
2
- import { t as createPostgresMigrationPlanner } from "./planner-CLUvVhUN.mjs";
3
-
4
- export { createPostgresMigrationPlanner };
1
+ import { t as createPostgresMigrationPlanner } from "./planner-BvKUuqG-.mjs";
2
+ export { createPostgresMigrationPlanner };
@@ -1,7 +1,6 @@
1
- import { t as errorPostgresMigrationStackMissing } from "./errors-AFvEPZ1R.mjs";
2
- import { t as dataTransform } from "./data-transform-VfEGzXWt.mjs";
1
+ import { t as errorPostgresMigrationStackMissing } from "./errors-Chm2bKcS.mjs";
2
+ import { t as dataTransform } from "./data-transform-DKWXdHuZ.mjs";
3
3
  import { Migration } from "@prisma-next/family-sql/migration";
4
-
5
4
  //#region src/core/migrations/postgres-migration.ts
6
5
  /**
7
6
  * Target-owned base class for Postgres migrations.
@@ -46,7 +45,7 @@ var PostgresMigration = class extends Migration {
46
45
  return dataTransform(contract, name, options, this.controlAdapter);
47
46
  }
48
47
  };
49
-
50
48
  //#endregion
51
49
  export { PostgresMigration as t };
52
- //# sourceMappingURL=postgres-migration-qtmtbONe.mjs.map
50
+
51
+ //# sourceMappingURL=postgres-migration-Bkv140RW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-Bkv140RW.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\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 target-specific re-export of this\n * class from `@prisma-next/target-postgres/migration`, keeping the\n * authoring surface 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 */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,MAAM;EAIZ,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,MAAM,GAC5B,KAAA;;;;;;;CAQN,cACE,UACA,MACA,SACsD;EACtD,IAAI,CAAC,KAAK,gBACR,MAAM,oCAAoC;EAE5C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,eAAe"}
@@ -1,13 +1,13 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
- import { n as DataTransformOptions, r as PostgresDataTransformOperation } from "./data-transform-CxFRBIUp.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
2
+ import { n as DataTransformOptions } from "./data-transform-bIeAcZIJ.mjs";
3
+ import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
4
  import { Migration } from "@prisma-next/family-sql/migration";
5
+ import { ControlStack } from "@prisma-next/framework-components/control";
4
6
  import { Contract } from "@prisma-next/contract/types";
5
7
  import { SqlStorage } from "@prisma-next/sql-contract/types";
6
8
  import { SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
7
- import { ControlStack } from "@prisma-next/framework-components/control";
8
9
 
9
10
  //#region src/core/migrations/postgres-migration.d.ts
10
-
11
11
  /**
12
12
  * Target-owned base class for Postgres migrations.
13
13
  *
@@ -43,8 +43,8 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
43
43
  * supplies the stored control adapter. Authors call this from inside
44
44
  * `get operations()`; the adapter argument is hidden from the call site.
45
45
  */
46
- protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): PostgresDataTransformOperation;
46
+ protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
47
47
  }
48
48
  //#endregion
49
49
  export { PostgresMigration as t };
50
- //# sourceMappingURL=postgres-migration-BjA3Zmts.d.mts.map
50
+ //# sourceMappingURL=postgres-migration-UkcHfZAA.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-UkcHfZAA.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;;;;;;;qBAQU,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAgBlB;;;;;EAAA,UADQ,aAAA,mBAAgC,QAAA,CAAS,UAAA,EAAA,CACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,yBAAA,CAA0B,yBAAA;AAAA"}
@@ -0,0 +1,23 @@
1
+ //#region src/core/migrations/render-ops.ts
2
+ /**
3
+ * Asserts an op materialised by an `OpFactoryCall` targets postgres. The
4
+ * extension surface lets any contributor emit calls, so this is the
5
+ * integration boundary where a stray non-postgres op would otherwise
6
+ * silently flow through to postgres-shaped renderers — exactly the
7
+ * place to fail loudly with op metadata (`id` + `target.id`).
8
+ */
9
+ function assertPostgresOp(op, callFactoryName) {
10
+ const targetId = op.target?.id;
11
+ 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
+ function renderOps(calls) {
14
+ return calls.map((c) => {
15
+ const op = c.toOp();
16
+ assertPostgresOp(op, c.factoryName);
17
+ return op;
18
+ });
19
+ }
20
+ //#endregion
21
+ export { renderOps as t };
22
+
23
+ //# sourceMappingURL=render-ops--1nnfNus.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-ops--1nnfNus.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,SAAS,CAAC,eAAe,GAAG,GAAG,kBAAkB,gBAAgB,2HAC/H;;AAIL,SAAgB,UAAU,OAAuC;CAC/D,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,KAAK,EAAE,MAAM;EACnB,iBAAiB,IAAI,EAAE,YAAY;EACnC,OAAO;GACP"}
@@ -1,11 +1,10 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
- import "./shared-Bxkt8pNO.mjs";
3
- import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
4
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
+ import { OpFactoryCall } from "@prisma-next/framework-components/control";
5
4
 
6
5
  //#region src/core/migrations/render-ops.d.ts
7
6
  type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
8
- declare function renderOps(calls: readonly PostgresOpFactoryCall[]): Op[];
7
+ declare function renderOps(calls: readonly OpFactoryCall[]): Op[];
9
8
  //#endregion
10
9
  export { renderOps };
11
10
  //# sourceMappingURL=render-ops.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":[],"mappings":";;;;;;KAIK,EAAA,GAAK,0BAA0B;iBAEpB,SAAA,iBAA0B,0BAA0B"}
1
+ {"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;KAIK,EAAA,GAAK,yBAAA,CAA0B,yBAAA;AAAA,iBAqBpB,SAAA,CAAU,KAAA,WAAgB,aAAA,KAAkB,EAAA"}
@@ -1,3 +1,2 @@
1
- import { t as renderOps } from "./render-ops-D6_DHdOK.mjs";
2
-
3
- export { renderOps };
1
+ import { t as renderOps } from "./render-ops--1nnfNus.mjs";
2
+ export { renderOps };
@@ -1,18 +1,7 @@
1
1
  import { jsonToTsSource, renderImports } from "@prisma-next/ts-render";
2
2
  import { detectScaffoldRuntime, shebangLineFor } from "@prisma-next/migration-tools/migration-ts";
3
-
4
3
  //#region src/core/migrations/render-typescript.ts
5
4
  /**
6
- * Polymorphic TypeScript emitter for the Postgres migration IR.
7
- *
8
- * Each `PostgresOpFactoryCall` renders itself via `renderTypeScript()` and
9
- * declares its own `importRequirements()`; this file just composes the module
10
- * source around those contributions. The design mirrors the Mongo target's
11
- * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required
12
- * (different factory module specifiers, different base-class name) but the
13
- * shape is, so future consolidation to a framework-level helper is mechanical.
14
- */
15
- /**
16
5
  * Always-present base imports for the rendered scaffold. Both come from
17
6
  * `@prisma-next/target-postgres/migration` so an authored Postgres
18
7
  * `migration.ts` only needs a single dependency for its base class and
@@ -68,7 +57,6 @@ function buildDescribeMethod(meta) {
68
57
  lines.push(" return {");
69
58
  lines.push(` from: ${JSON.stringify(meta.from)},`);
70
59
  lines.push(` to: ${JSON.stringify(meta.to)},`);
71
- if (meta.kind) lines.push(` kind: ${JSON.stringify(meta.kind)},`);
72
60
  if (meta.labels && meta.labels.length > 0) lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
73
61
  lines.push(" };");
74
62
  lines.push(" }");
@@ -79,7 +67,7 @@ function indent(text, spaces) {
79
67
  const pad = " ".repeat(spaces);
80
68
  return text.split("\n").map((line) => line.trim() ? `${pad}${line}` : line).join("\n");
81
69
  }
82
-
83
70
  //#endregion
84
71
  export { renderCallsToTypeScript as t };
85
- //# sourceMappingURL=render-typescript-1rF_SB4g.mjs.map
72
+
73
+ //# sourceMappingURL=render-typescript-D3doH-vX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-D3doH-vX.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, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/target-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 target-owned 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/target-postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/target-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) => c.renderTypeScript()).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 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 if (meta.labels && meta.labels.length > 0) {\n lines.push(` labels: ${jsonToTsSource(meta.labels)},`);\n }\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":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAA0C,QAAQ;CAAa,EAClF;CAAE,iBAAiB;CAA0C,QAAQ;CAAgB,CACtF;AAED,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,MAAM;CACnC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,kBAAkB,CAAC,CAAC,KAAK,MAAM;CAEzE,OAAO;EACL,eAAe,uBAAuB,CAAC;EACvC;EACA;EACA;EACA,oBAAoB,KAAK;EACzB;EACA;EACA,OAAO,gBAAgB,EAAE;EACzB;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,aAAa,OAA6C;CACjE,MAAM,eAAoC,CAAC,GAAG,aAAa;CAC3D,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,oBAAoB,EACzC,aAAa,KAAK,IAAI;CAG1B,OAAO,cAAc,aAAa;;AAGpC,SAAS,oBAAoB,MAAmC;CAC9D,MAAM,QAAkB,EAAE;CAC1B,MAAM,KAAK,0BAA0B;CACrC,MAAM,KAAK,eAAe;CAC1B,MAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;CACvD,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,GAAG,CAAC,GAAG;CACnD,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,GACtC,MAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO,CAAC,GAAG;CAE7D,MAAM,KAAK,SAAS;CACpB,MAAM,KAAK,MAAM;CACjB,MAAM,KAAK,GAAG;CACd,OAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,OAAO;CAC9B,OAAO,KACJ,MAAM,KAAK,CACX,KAAK,SAAU,KAAK,MAAM,GAAG,GAAG,MAAM,SAAS,KAAM,CACrD,KAAK,KAAK"}
@@ -1,15 +1,12 @@
1
- import "./shared-Bxkt8pNO.mjs";
2
- import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
1
+ import { OpFactoryCall } from "@prisma-next/framework-components/control";
3
2
 
4
3
  //#region src/core/migrations/render-typescript.d.ts
5
-
6
4
  interface RenderMigrationMeta {
7
- readonly from: string;
5
+ readonly from: string | null;
8
6
  readonly to: string;
9
- readonly kind?: string;
10
7
  readonly labels?: readonly string[];
11
8
  }
12
- declare function renderCallsToTypeScript(calls: ReadonlyArray<PostgresOpFactoryCall>, meta: RenderMigrationMeta): string;
9
+ declare function renderCallsToTypeScript(calls: ReadonlyArray<OpFactoryCall>, meta: RenderMigrationMeta): string;
13
10
  //#endregion
14
11
  export { renderCallsToTypeScript };
15
12
  //# sourceMappingURL=render-typescript.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":[],"mappings":";;;;;UAeiB,mBAAA;;;;;;iBA8BD,uBAAA,QACP,cAAc,8BACf"}
1
+ {"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"mappings":";;;UAeiB,mBAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA;EAAA,SACA,MAAA;AAAA;AAAA,iBA0BK,uBAAA,CACd,KAAA,EAAO,aAAA,CAAc,aAAA,GACrB,IAAA,EAAM,mBAAA"}
@@ -1,3 +1,2 @@
1
- import { t as renderCallsToTypeScript } from "./render-typescript-1rF_SB4g.mjs";
2
-
3
- export { renderCallsToTypeScript };
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-D3doH-vX.mjs";
2
+ export { renderCallsToTypeScript };
@@ -1,20 +1,16 @@
1
- import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
1
+ import { AnyCodecDescriptor } from "@prisma-next/framework-components/codec";
2
2
  import { RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
3
3
 
4
4
  //#region src/exports/runtime.d.ts
5
5
  interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}
6
6
  /**
7
- * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`
8
- * from `@prisma-next/sql-runtime`. The target package is a control-plane
9
- * residence and must not pull the SQL execution-plane package into its
10
- * dependency closure. The runtime descriptor here is shaped to satisfy the
11
- * framework's `RuntimeTargetDescriptor` plus the structural
12
- * `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that
7
+ * 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
13
8
  * `@prisma-next/sql-runtime` consumers narrow to at composition time.
9
+ *
10
+ * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
14
11
  */
15
12
  declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'postgres', PostgresRuntimeTargetInstance> & {
16
- readonly codecs: () => ReturnType<typeof createCodecRegistry>;
17
- readonly parameterizedCodecs: () => readonly never[];
13
+ readonly codecs: () => readonly AnyCodecDescriptor[];
18
14
  };
19
15
  //#endregion
20
16
  export { PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":[],"mappings":";;;;UAOiB,6BAAA,SAAsC;AAAvD;AAAkG;;;;;;;;cAW5F,iCAAiC,2CAGrC;yBAEuB,kBAAkB"}
1
+ {"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/exports/runtime.ts"],"mappings":";;;;UAOiB,6BAAA,SAAsC,qBAAA;AAAvD;;;;;AAAkG;AAAlG,cAQM,+BAAA,EAAiC,uBAAA,oBAGrC,6BAAA;EAAA,SAES,MAAA,iBAAuB,kBAAA;AAAA"}
package/dist/runtime.mjs CHANGED
@@ -1,20 +1,14 @@
1
- import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-BVoVtyp-.mjs";
2
- import { createCodecRegistry } from "@prisma-next/sql-relational-core/ast";
3
-
1
+ import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-Dde_BS3K.mjs";
4
2
  //#region src/exports/runtime.ts
5
3
  /**
6
- * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`
7
- * from `@prisma-next/sql-runtime`. The target package is a control-plane
8
- * residence and must not pull the SQL execution-plane package into its
9
- * dependency closure. The runtime descriptor here is shaped to satisfy the
10
- * framework's `RuntimeTargetDescriptor` plus the structural
11
- * `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that
4
+ * 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
12
5
  * `@prisma-next/sql-runtime` consumers narrow to at composition time.
6
+ *
7
+ * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).
13
8
  */
14
9
  const postgresRuntimeTargetDescriptor = {
15
10
  ...postgresTargetDescriptorMeta,
16
- codecs: () => createCodecRegistry(),
17
- parameterizedCodecs: () => [],
11
+ codecs: () => [],
18
12
  create() {
19
13
  return {
20
14
  familyId: "sql",
@@ -22,8 +16,7 @@ const postgresRuntimeTargetDescriptor = {
22
16
  };
23
17
  }
24
18
  };
25
- var runtime_default = postgresRuntimeTargetDescriptor;
26
-
27
19
  //#endregion
28
- export { runtime_default as default };
20
+ export { postgresRuntimeTargetDescriptor as default };
21
+
29
22
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":["postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => ReturnType<typeof createCodecRegistry>;\n readonly parameterizedCodecs: () => readonly never[];\n}"],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { createCodecRegistry } from '@prisma-next/sql-relational-core/ast';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor`\n * from `@prisma-next/sql-runtime`. The target package is a control-plane\n * residence and must not pull the SQL execution-plane package into its\n * dependency closure. The runtime descriptor here is shaped to satisfy the\n * framework's `RuntimeTargetDescriptor` plus the structural\n * `SqlStaticContributions` (`codecs`, `parameterizedCodecs`) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => ReturnType<typeof createCodecRegistry>;\n readonly parameterizedCodecs: () => readonly never[];\n} = {\n ...postgresTargetDescriptorMeta,\n codecs: () => createCodecRegistry(),\n parameterizedCodecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAMA,kCAOF;CACF,GAAG;CACH,cAAc,qBAAqB;CACnC,2BAA2B,EAAE;CAC7B,SAAwC;AACtC,SAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ;AAED,sBAAe"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../src/exports/runtime.ts"],"sourcesContent":["import type { AnyCodecDescriptor } from '@prisma-next/framework-components/codec';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/framework-components/execution';\nimport { postgresTargetDescriptorMeta } from '../core/descriptor-meta';\n\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that\n * `@prisma-next/sql-runtime` consumers narrow to at composition time.\n *\n * The target itself contributes no codecs — postgres-specific codecs ship from the postgres adapter and from extension packs (pgvector, arktype-json, etc.).\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> & {\n readonly codecs: () => readonly AnyCodecDescriptor[];\n} = {\n ...postgresTargetDescriptorMeta,\n codecs: () => [],\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";;;;;;;;AAeA,MAAM,kCAMF;CACF,GAAG;CACH,cAAc,EAAE;CAChB,SAAwC;EACtC,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-bVVcanWh.mjs";
2
2
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
3
  import { ReferentialAction } from "@prisma-next/sql-contract/types";
4
4
 
@@ -38,4 +38,4 @@ interface ForeignKeySpec {
38
38
  }
39
39
  //#endregion
40
40
  export { ForeignKeySpec as n, Op as r, ColumnSpec as t };
41
- //# sourceMappingURL=shared-Bxkt8pNO.d.mts.map
41
+ //# sourceMappingURL=shared-MpwjwAjM.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-MpwjwAjM.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAA,CAA0B,yBAAA;;AAA3C;;;;;AAcA;;;;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;AAAA;;;;;UAOM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;AAAA"}
@@ -11,6 +11,8 @@
11
11
  * home that both adapters can depend on without crossing planes.
12
12
  */
13
13
  var SqlEscapeError = class extends Error {
14
+ value;
15
+ kind;
14
16
  constructor(message, value, kind) {
15
17
  super(message);
16
18
  this.value = value;
@@ -70,7 +72,7 @@ function qualifyName(schemaName, objectName) {
70
72
  function validateEnumValueLength(value, enumTypeName) {
71
73
  if (value.length > MAX_IDENTIFIER_LENGTH) throw new SqlEscapeError(`Enum value "${value.slice(0, 20)}..." for type "${enumTypeName}" exceeds PostgreSQL's ${MAX_IDENTIFIER_LENGTH}-character label limit`, value, "literal");
72
74
  }
73
-
74
75
  //#endregion
75
76
  export { validateEnumValueLength as a, quoteIdentifier as i, escapeLiteral as n, qualifyName as r, SqlEscapeError as t };
76
- //# sourceMappingURL=sql-utils-r-Lw535w.mjs.map
77
+
78
+ //# sourceMappingURL=sql-utils-CggjWNij.mjs.map
@@ -0,0 +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,QAAQ;EAHE,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;;;AAIhB,MAAM,wBAAwB;;;;;;;;;;;AAY9B,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;CAElF,IAAI,WAAW,SAAS,KAAK,EAC3B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;CAEH,IAAI,WAAW,SAAS,uBACtB,QAAQ,KACN,eAAe,WAAW,MAAM,GAAG,GAAG,CAAC,4BAA4B,sBAAsB,wCAC1F;CAEH,OAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;;;;;;;;;;;;AAc5C,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,KAAK,EACtB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;CAEH,OAAO,MAAM,QAAQ,MAAM,KAAK;;;;;AAMlC,SAAgB,YAAY,YAAoB,YAA4B;CAC1E,OAAO,GAAG,gBAAgB,WAAW,CAAC,GAAG,gBAAgB,WAAW;;;;;;;;;;;;;AActE,SAAgB,wBAAwB,OAAe,cAA4B;CACjF,IAAI,MAAM,SAAS,uBACjB,MAAM,IAAI,eACR,eAAe,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,aAAa,yBAC3D,sBAAsB,yBAC3B,OACA,UACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":[],"mappings":";;AAYA;AAuBA;AA8BA;AAcA;AAeA;;;;;;cAlFa,cAAA,SAAuB,KAAA;;;;;;;;;;;;;;;iBAuBpB,eAAA;;;;;;;;;;;;iBA8BA,aAAA;;;;iBAcA,WAAA;;;;;;;;;;;;iBAeA,uBAAA"}
1
+ {"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAA;EAAA,SAGhB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;;;;AAiDpB;;;;;AAcA;;iBA5CgB,eAAA,CAAgB,UAAA;;;AA2DhC;;;;;;;;;iBA7BgB,aAAA,CAAc,KAAA;;;;iBAcd,WAAA,CAAY,UAAA,UAAoB,UAAA;;;;;;;;;;;;iBAehC,uBAAA,CAAwB,KAAA,UAAe,YAAA"}
@@ -1,3 +1,2 @@
1
- import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-r-Lw535w.mjs";
2
-
3
- export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
1
+ import { a as validateEnumValueLength, i as quoteIdentifier, n as escapeLiteral, r as qualifyName, t as SqlEscapeError } from "./sql-utils-CggjWNij.mjs";
2
+ export { SqlEscapeError, escapeLiteral, qualifyName, quoteIdentifier, validateEnumValueLength };
@@ -1,18 +1,29 @@
1
+ import { APP_SPACE_ID as APP_SPACE_ID$1 } from "@prisma-next/framework-components/control";
1
2
  //#region src/core/migrations/statement-builders.ts
2
3
  const ensurePrismaContractSchemaStatement = {
3
4
  sql: "create schema if not exists prisma_contract",
4
5
  params: []
5
6
  };
7
+ /**
8
+ * Schema for `prisma_contract.marker`. The `space text` primary key
9
+ * supports one row per loaded contract space (`'app'`,
10
+ * `'<extension-id>'`, …); on a brand-new database `CREATE TABLE IF NOT
11
+ * EXISTS` produces this shape directly. The migration runner detects
12
+ * pre-1.0 single-row markers (no `space` column) at boot and fails with
13
+ * a structured `LEGACY_MARKER_SHAPE` error rather than auto-migrating —
14
+ * see `specs/framework-mechanism.spec.md § 2`.
15
+ */
6
16
  const ensureMarkerTableStatement = {
7
17
  sql: `create table if not exists prisma_contract.marker (
8
- id smallint primary key default 1,
18
+ space text not null primary key default '${APP_SPACE_ID$1}',
9
19
  core_hash text not null,
10
20
  profile_hash text not null,
11
21
  contract_json jsonb,
12
22
  canonical_version int,
13
23
  updated_at timestamptz not null default now(),
14
24
  app_tag text,
15
- meta jsonb not null default '{}'
25
+ meta jsonb not null default '{}',
26
+ invariants text[] not null default '{}'
16
27
  )`,
17
28
  params: []
18
29
  };
@@ -30,27 +41,29 @@ const ensureLedgerTableStatement = {
30
41
  )`,
31
42
  params: []
32
43
  };
33
- function buildWriteMarkerStatements(input) {
44
+ function buildMergeMarkerStatements(input) {
34
45
  const params = [
35
- 1,
46
+ input.space,
36
47
  input.storageHash,
37
48
  input.profileHash,
38
49
  jsonParam(input.contractJson),
39
50
  input.canonicalVersion ?? null,
40
51
  input.appTag ?? null,
41
- jsonParam(input.meta ?? {})
52
+ jsonParam(input.meta ?? {}),
53
+ input.invariants
42
54
  ];
43
55
  return {
44
56
  insert: {
45
57
  sql: `insert into prisma_contract.marker (
46
- id,
58
+ space,
47
59
  core_hash,
48
60
  profile_hash,
49
61
  contract_json,
50
62
  canonical_version,
51
63
  updated_at,
52
64
  app_tag,
53
- meta
65
+ meta,
66
+ invariants
54
67
  ) values (
55
68
  $1,
56
69
  $2,
@@ -59,7 +72,8 @@ function buildWriteMarkerStatements(input) {
59
72
  $5,
60
73
  now(),
61
74
  $6,
62
- $7::jsonb
75
+ $7::jsonb,
76
+ $8::text[]
63
77
  )`,
64
78
  params
65
79
  },
@@ -71,8 +85,9 @@ function buildWriteMarkerStatements(input) {
71
85
  canonical_version = $5,
72
86
  updated_at = now(),
73
87
  app_tag = $6,
74
- meta = $7::jsonb
75
- where id = $1`,
88
+ meta = $7::jsonb,
89
+ invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)
90
+ where space = $1`,
76
91
  params
77
92
  }
78
93
  };
@@ -110,7 +125,7 @@ function buildLedgerInsertStatement(input) {
110
125
  function jsonParam(value) {
111
126
  return JSON.stringify(value ?? null);
112
127
  }
113
-
114
128
  //#endregion
115
- export { ensurePrismaContractSchemaStatement as a, ensureMarkerTableStatement as i, buildWriteMarkerStatements as n, ensureLedgerTableStatement as r, buildLedgerInsertStatement as t };
116
- //# sourceMappingURL=statement-builders-BPnmt6wx.mjs.map
129
+ export { ensureMarkerTableStatement as a, ensureLedgerTableStatement as i, buildLedgerInsertStatement as n, ensurePrismaContractSchemaStatement as o, buildMergeMarkerStatements as r, APP_SPACE_ID$1 as t };
130
+
131
+ //# sourceMappingURL=statement-builders-BT889jV0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statement-builders-BT889jV0.mjs","names":["APP_SPACE_ID"],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":["import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\n\nexport { APP_SPACE_ID };\n\nexport interface SqlStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n}\n\nexport const ensurePrismaContractSchemaStatement: SqlStatement = {\n sql: 'create schema if not exists prisma_contract',\n params: [],\n};\n\n/**\n * Schema for `prisma_contract.marker`. The `space text` primary key\n * supports one row per loaded contract space (`'app'`,\n * `'<extension-id>'`, …); on a brand-new database `CREATE TABLE IF NOT\n * EXISTS` produces this shape directly. The migration runner detects\n * pre-1.0 single-row markers (no `space` column) at boot and fails with\n * a structured `LEGACY_MARKER_SHAPE` error rather than auto-migrating —\n * see `specs/framework-mechanism.spec.md § 2`.\n */\nexport const ensureMarkerTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.marker (\n space text not null primary key default '${APP_SPACE_ID}',\n core_hash text not null,\n profile_hash text not null,\n contract_json jsonb,\n canonical_version int,\n updated_at timestamptz not null default now(),\n app_tag text,\n meta jsonb not null default '{}',\n invariants text[] not null default '{}'\n )`,\n params: [],\n};\n\nexport const ensureLedgerTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.ledger (\n id bigserial primary key,\n created_at timestamptz not null default now(),\n origin_core_hash text,\n origin_profile_hash text,\n destination_core_hash text not null,\n destination_profile_hash text,\n contract_json_before jsonb,\n contract_json_after jsonb,\n operations jsonb not null\n )`,\n params: [],\n};\n\nexport interface MergeMarkerInput {\n /**\n * Logical space identifier for this marker row. Required at every\n * call site so the type system surfaces every place that needs to\n * thread the value (rather than letting an `?? APP_SPACE_ID`\n * fall-through silently collapse multi-space markers onto the\n * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}\n * (`'app'`); per-extension callers (planner / runner / verifier\n * extensions over contract spaces) pass the extension's space id.\n */\n readonly space: string;\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number | null;\n readonly appTag?: string | null;\n readonly meta?: Record<string, unknown>;\n /**\n * Invariants to merge into `marker.invariants`. INSERT writes them as\n * the initial value (callers are expected to pass a sorted, deduped\n * array). UPDATE merges them with the existing column server-side via\n * a single atomic SQL expression.\n */\n readonly invariants: readonly string[];\n}\n\nexport function buildMergeMarkerStatements(input: MergeMarkerInput): {\n readonly insert: SqlStatement;\n readonly update: SqlStatement;\n} {\n const params: readonly unknown[] = [\n input.space,\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n input.invariants,\n ];\n\n return {\n insert: {\n sql: `insert into prisma_contract.marker (\n space,\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n ) values (\n $1,\n $2,\n $3,\n $4::jsonb,\n $5,\n now(),\n $6,\n $7::jsonb,\n $8::text[]\n )`,\n params,\n },\n update: {\n // `invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)`\n // reads the current column value under the UPDATE's row lock, unions\n // with the incoming array, dedupes, and sorts ascending — single\n // statement, atomic, no read-then-write window.\n sql: `update prisma_contract.marker set\n core_hash = $2,\n profile_hash = $3,\n contract_json = $4::jsonb,\n canonical_version = $5,\n updated_at = now(),\n app_tag = $6,\n meta = $7::jsonb,\n invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)\n where space = $1`,\n params,\n },\n };\n}\n\nexport interface LedgerInsertInput {\n readonly originStorageHash?: string | null;\n readonly originProfileHash?: string | null;\n readonly destinationStorageHash: string;\n readonly destinationProfileHash?: string | null;\n readonly contractJsonBefore?: unknown;\n readonly contractJsonAfter?: unknown;\n readonly operations: unknown;\n}\n\nexport function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {\n return {\n sql: `insert into prisma_contract.ledger (\n origin_core_hash,\n origin_profile_hash,\n destination_core_hash,\n destination_profile_hash,\n contract_json_before,\n contract_json_after,\n operations\n ) values (\n $1,\n $2,\n $3,\n $4,\n $5::jsonb,\n $6::jsonb,\n $7::jsonb\n )`,\n params: [\n input.originStorageHash ?? null,\n input.originProfileHash ?? null,\n input.destinationStorageHash,\n input.destinationProfileHash ?? null,\n jsonParam(input.contractJsonBefore),\n jsonParam(input.contractJsonAfter),\n jsonParam(input.operations),\n ],\n };\n}\n\nfunction jsonParam(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n"],"mappings":";;AASA,MAAa,sCAAoD;CAC/D,KAAK;CACL,QAAQ,EAAE;CACX;;;;;;;;;;AAWD,MAAa,6BAA2C;CACtD,KAAK;+CACwCA,eAAa;;;;;;;;;;CAU1D,QAAQ,EAAE;CACX;AAED,MAAa,6BAA2C;CACtD,KAAK;;;;;;;;;;;CAWL,QAAQ,EAAE;CACX;AA4BD,SAAgB,2BAA2B,OAGzC;CACA,MAAM,SAA6B;EACjC,MAAM;EACN,MAAM;EACN,MAAM;EACN,UAAU,MAAM,aAAa;EAC7B,MAAM,oBAAoB;EAC1B,MAAM,UAAU;EAChB,UAAU,MAAM,QAAQ,EAAE,CAAC;EAC3B,MAAM;EACP;CAED,OAAO;EACL,QAAQ;GACN,KAAK;;;;;;;;;;;;;;;;;;;;;GAqBL;GACD;EACD,QAAQ;GAKN,KAAK;;;;;;;;;;GAUL;GACD;EACF;;AAaH,SAAgB,2BAA2B,OAAwC;CACjF,OAAO;EACL,KAAK;;;;;;;;;;;;;;;;;EAiBL,QAAQ;GACN,MAAM,qBAAqB;GAC3B,MAAM,qBAAqB;GAC3B,MAAM;GACN,MAAM,0BAA0B;GAChC,UAAU,MAAM,mBAAmB;GACnC,UAAU,MAAM,kBAAkB;GAClC,UAAU,MAAM,WAAW;GAC5B;EACF;;AAGH,SAAS,UAAU,OAAwB;CACzC,OAAO,KAAK,UAAU,SAAS,KAAK"}
@@ -1,23 +1,51 @@
1
+ import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
2
+
1
3
  //#region src/core/migrations/statement-builders.d.ts
2
4
  interface SqlStatement {
3
5
  readonly sql: string;
4
6
  readonly params: readonly unknown[];
5
7
  }
6
8
  declare const ensurePrismaContractSchemaStatement: SqlStatement;
9
+ /**
10
+ * Schema for `prisma_contract.marker`. The `space text` primary key
11
+ * supports one row per loaded contract space (`'app'`,
12
+ * `'<extension-id>'`, …); on a brand-new database `CREATE TABLE IF NOT
13
+ * EXISTS` produces this shape directly. The migration runner detects
14
+ * pre-1.0 single-row markers (no `space` column) at boot and fails with
15
+ * a structured `LEGACY_MARKER_SHAPE` error rather than auto-migrating —
16
+ * see `specs/framework-mechanism.spec.md § 2`.
17
+ */
7
18
  declare const ensureMarkerTableStatement: SqlStatement;
8
19
  declare const ensureLedgerTableStatement: SqlStatement;
9
- interface WriteMarkerInput {
20
+ interface MergeMarkerInput {
21
+ /**
22
+ * Logical space identifier for this marker row. Required at every
23
+ * call site so the type system surfaces every place that needs to
24
+ * thread the value (rather than letting an `?? APP_SPACE_ID`
25
+ * fall-through silently collapse multi-space markers onto the
26
+ * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}
27
+ * (`'app'`); per-extension callers (planner / runner / verifier
28
+ * extensions over contract spaces) pass the extension's space id.
29
+ */
30
+ readonly space: string;
10
31
  readonly storageHash: string;
11
32
  readonly profileHash: string;
12
33
  readonly contractJson?: unknown;
13
34
  readonly canonicalVersion?: number | null;
14
35
  readonly appTag?: string | null;
15
36
  readonly meta?: Record<string, unknown>;
37
+ /**
38
+ * Invariants to merge into `marker.invariants`. INSERT writes them as
39
+ * the initial value (callers are expected to pass a sorted, deduped
40
+ * array). UPDATE merges them with the existing column server-side via
41
+ * a single atomic SQL expression.
42
+ */
43
+ readonly invariants: readonly string[];
16
44
  }
17
- declare function buildWriteMarkerStatements(input: WriteMarkerInput): {
45
+ declare function buildMergeMarkerStatements(input: MergeMarkerInput): {
18
46
  readonly insert: SqlStatement;
19
47
  readonly update: SqlStatement;
20
48
  };
21
49
  //#endregion
22
- export { type SqlStatement, buildWriteMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
50
+ export { APP_SPACE_ID, type SqlStatement, buildMergeMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
23
51
  //# sourceMappingURL=statement-builders.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"statement-builders.d.mts","names":[],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":[],"mappings":";UAAiB,YAAA;EAAA,SAAA,GAAA,EAAA,MAAY;EAKhB,SAAA,MAAA,EAAA,SAAA,OAAA,EAAA;AAKb;AAca,cAnBA,mCAmB4B,EAnBS,YAgCjD;AAEgB,cA7BJ,0BAmCW,EAnCiB,YAmCjB;AAGR,cAxBH,0BAwB6B,EAxBD,YAwBC;AAAQ,UATjC,gBAAA,CASiC;EAC/B,SAAA,WAAA,EAAA,MAAA;EACA,SAAA,WAAA,EAAA,MAAA;EAAY,SAAA,YAAA,CAAA,EAAA,OAAA;;;kBALb;;iBAGF,0BAAA,QAAkC;mBAC/B;mBACA"}
1
+ {"version":3,"file":"statement-builders.d.mts","names":[],"sources":["../src/core/migrations/statement-builders.ts"],"mappings":";;;UAIiB,YAAA;EAAA,SACN,GAAA;EAAA,SACA,MAAA;AAAA;AAAA,cAGE,mCAAA,EAAqC,YAAA;;AAAlD;;;;;AAcA;;;cAAa,0BAAA,EAA4B,YAAA;AAAA,cAe5B,0BAAA,EAA4B,YAAA;AAAA,UAexB,gBAAA;EAFhB;;;;AAED;;;;;EAFC,SAYU,KAAA;EAAA,SACA,WAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA;EAAA,SACA,gBAAA;EAAA,SACA,MAAA;EAAA,SACA,IAAA,GAAO,MAAA;EAOP;;;AAGX;;;EAHW,SAAA,UAAA;AAAA;AAAA,iBAGK,0BAAA,CAA2B,KAAA,EAAO,gBAAA;EAAA,SACvC,MAAA,EAAQ,YAAA;EAAA,SACR,MAAA,EAAQ,YAAA;AAAA"}
@@ -1,3 +1,2 @@
1
- import { a as ensurePrismaContractSchemaStatement, i as ensureMarkerTableStatement, n as buildWriteMarkerStatements, r as ensureLedgerTableStatement } from "./statement-builders-BPnmt6wx.mjs";
2
-
3
- export { buildWriteMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
1
+ import { a as ensureMarkerTableStatement, i as ensureLedgerTableStatement, o as ensurePrismaContractSchemaStatement, r as buildMergeMarkerStatements, t as APP_SPACE_ID } from "./statement-builders-BT889jV0.mjs";
2
+ export { APP_SPACE_ID, buildMergeMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };