@prisma-next/target-postgres 0.12.0 → 0.13.0-dev.1

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 (207) hide show
  1. package/dist/{codec-ids-D9fJ4HP5.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-CRlHq7Cz.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-Dud5KDNk.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-CdtGUWp2.mjs → data-transform-D25tLeYU.mjs} +1 -1
  24. package/dist/{data-transform-CdtGUWp2.mjs.map → data-transform-D25tLeYU.mjs.map} +1 -1
  25. package/dist/{data-transform-bmOKkygi.d.mts → data-transform-DGOqcLrf.d.mts} +2 -2
  26. package/dist/{data-transform-bmOKkygi.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-CRscvhS5.mjs → default-normalizer-DyyCHQWs.mjs} +1 -1
  34. package/dist/{default-normalizer-CRscvhS5.mjs.map → default-normalizer-DyyCHQWs.mjs.map} +1 -1
  35. package/dist/default-normalizer.mjs +1 -1
  36. package/dist/descriptor-meta-DKmj-IMN.mjs +14 -0
  37. package/dist/descriptor-meta-DKmj-IMN.mjs.map +1 -0
  38. package/dist/{descriptor-meta-DLA2xV6B.mjs → descriptor-meta-runtime-My8_s4cs.mjs} +82 -78
  39. package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +1 -0
  40. package/dist/{enum-planning-Dz0Ye3Lb.mjs → enum-planning-BCyvlFHk.mjs} +0 -0
  41. package/dist/{enum-planning-Dz0Ye3Lb.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--zafB5_n.mjs → errors-CUk87ByX.mjs} +1 -1
  45. package/dist/{errors--zafB5_n.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-ByQhUzS4.mjs → issue-planner-Br0pt1Ea.mjs} +130 -28
  49. package/dist/issue-planner-Br0pt1Ea.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-ClNPq__-.mjs → native-type-normalizer-Bc9XJzWC.mjs} +1 -1
  58. package/dist/{native-type-normalizer-ClNPq__-.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-Drccm_JD.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 +13 -12
  71. package/dist/pack.d.mts.map +1 -1
  72. package/dist/pack.mjs +1 -1
  73. package/dist/planner-CAYPJObw.mjs +344 -0
  74. package/dist/planner-CAYPJObw.mjs.map +1 -0
  75. package/dist/{planner-ddl-builders-BxRCSn_b.mjs → planner-ddl-builders-Cw2n2llW.mjs} +7 -30
  76. package/dist/planner-ddl-builders-Cw2n2llW.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-ojX-6cPV.mjs → planner-identity-values-BIpa5p2I.mjs} +1 -1
  81. package/dist/{planner-identity-values-ojX-6cPV.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-p-VKkCia.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-N1yqYg20.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-BGyukuzG.mjs → planner-schema-lookup-CiVaAQP-.mjs} +1 -1
  90. package/dist/{planner-schema-lookup-BGyukuzG.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-D3H-xOO1.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-CIj61DUj.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-YJvjKrmo.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-CNhPTDhy.d.mts → postgres-enum-type-BVn63a89.d.mts} +4 -1
  107. package/dist/postgres-enum-type-BVn63a89.d.mts.map +1 -0
  108. package/dist/{postgres-enum-type-DS-KLVRH.mjs → postgres-enum-type-DPKqCBem.mjs} +2 -1
  109. package/dist/postgres-enum-type-DPKqCBem.mjs.map +1 -0
  110. package/dist/{postgres-migration-uADmx0dW.mjs → postgres-migration-COore9Mz.mjs} +23 -3
  111. package/dist/postgres-migration-COore9Mz.mjs.map +1 -0
  112. package/dist/{postgres-migration-Fd4fQkBw.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-Bm7vjlOv.mjs → postgres-schema-BuxCxbvB.mjs} +29 -14
  115. package/dist/postgres-schema-BuxCxbvB.mjs.map +1 -0
  116. package/dist/{render-ops-BC2PtCkj.mjs → render-ops-BpjstrKQ.mjs} +4 -3
  117. package/dist/{render-ops-BC2PtCkj.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-CPk7hhWH.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 +3 -3
  126. package/dist/runtime.mjs.map +1 -1
  127. package/dist/{shared-ByhSooBS.d.mts → shared-DarONYBZ.d.mts} +5 -5
  128. package/dist/{shared-ByhSooBS.d.mts.map → shared-DarONYBZ.d.mts.map} +1 -1
  129. package/dist/{sql-utils-B_ruBD-M.mjs → sql-utils-DcfMz4MQ.mjs} +1 -1
  130. package/dist/{sql-utils-B_ruBD-M.mjs.map → sql-utils-DcfMz4MQ.mjs.map} +1 -1
  131. package/dist/sql-utils.mjs +1 -1
  132. package/dist/{types-D-XIpzHA.d.mts → types-BDKkx8MA.d.mts} +1 -1
  133. package/dist/types-BDKkx8MA.d.mts.map +1 -0
  134. package/dist/types.d.mts +16 -11
  135. package/dist/types.d.mts.map +1 -1
  136. package/dist/types.mjs +2 -2
  137. package/package.json +21 -20
  138. package/src/contract-free/columns.ts +49 -0
  139. package/src/contract-free/control-bootstrap.ts +55 -0
  140. package/src/contract-free/ddl.ts +37 -0
  141. package/src/core/ast/table-source.ts +23 -0
  142. package/src/core/authoring.ts +1 -1
  143. package/src/core/codec-ids.ts +1 -0
  144. package/src/core/codecs.ts +44 -0
  145. package/src/core/ddl/nodes.ts +72 -0
  146. package/src/core/descriptor-meta-runtime.ts +28 -0
  147. package/src/core/descriptor-meta.ts +3 -6
  148. package/src/core/migrations/control-policy.ts +234 -0
  149. package/src/core/migrations/issue-planner.ts +81 -13
  150. package/src/core/migrations/op-factory-call.ts +289 -46
  151. package/src/core/migrations/operations/constraints.ts +79 -10
  152. package/src/core/migrations/operations/dependencies.ts +0 -17
  153. package/src/core/migrations/operations/shared.ts +3 -3
  154. package/src/core/migrations/operations/tables.ts +1 -39
  155. package/src/core/migrations/planner-ddl-builders.ts +7 -48
  156. package/src/core/migrations/planner-produced-postgres-migration.ts +11 -6
  157. package/src/core/migrations/planner-sql-checks.ts +9 -9
  158. package/src/core/migrations/planner-strategies.ts +149 -11
  159. package/src/core/migrations/planner-target-details.ts +2 -1
  160. package/src/core/migrations/planner.ts +66 -8
  161. package/src/core/migrations/postgres-migration.ts +41 -0
  162. package/src/core/migrations/render-ops.ts +7 -2
  163. package/src/core/migrations/render-typescript.ts +5 -1
  164. package/src/core/migrations/runner.ts +78 -50
  165. package/src/core/postgres-contract-serializer.ts +52 -46
  166. package/src/core/postgres-enum-type.ts +4 -0
  167. package/src/core/postgres-schema.ts +43 -25
  168. package/src/exports/contract-free.ts +7 -0
  169. package/src/exports/control.ts +6 -8
  170. package/src/exports/ddl.ts +7 -0
  171. package/src/exports/migration.ts +11 -2
  172. package/src/exports/op-factory-call.ts +2 -0
  173. package/src/exports/planner-ddl-builders.ts +0 -1
  174. package/src/exports/runtime.ts +2 -2
  175. package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
  176. package/dist/codec-ids-D9fJ4HP5.d.mts.map +0 -1
  177. package/dist/codec-types-CRlHq7Cz.d.mts.map +0 -1
  178. package/dist/codecs-Dud5KDNk.d.mts.map +0 -1
  179. package/dist/descriptor-meta-DLA2xV6B.mjs.map +0 -1
  180. package/dist/issue-planner-ByQhUzS4.mjs.map +0 -1
  181. package/dist/op-factory-call-B0WNg30h.mjs +0 -625
  182. package/dist/op-factory-call-B0WNg30h.mjs.map +0 -1
  183. package/dist/op-factory-call-Drccm_JD.d.mts.map +0 -1
  184. package/dist/planner-ClF0y0YR.mjs +0 -177
  185. package/dist/planner-ClF0y0YR.mjs.map +0 -1
  186. package/dist/planner-ddl-builders-BxRCSn_b.mjs.map +0 -1
  187. package/dist/planner-produced-postgres-migration-N1yqYg20.mjs.map +0 -1
  188. package/dist/planner-produced-postgres-migration-p-VKkCia.d.mts.map +0 -1
  189. package/dist/planner-sql-checks-D3H-xOO1.mjs.map +0 -1
  190. package/dist/planner-target-details-CIj61DUj.d.mts.map +0 -1
  191. package/dist/postgres-contract-serializer-YJvjKrmo.mjs.map +0 -1
  192. package/dist/postgres-enum-type-CNhPTDhy.d.mts.map +0 -1
  193. package/dist/postgres-enum-type-DS-KLVRH.mjs.map +0 -1
  194. package/dist/postgres-migration-Fd4fQkBw.d.mts.map +0 -1
  195. package/dist/postgres-migration-uADmx0dW.mjs.map +0 -1
  196. package/dist/postgres-schema-Bm7vjlOv.mjs.map +0 -1
  197. package/dist/render-typescript-CPk7hhWH.mjs.map +0 -1
  198. package/dist/statement-builders-vImtdfmM.mjs +0 -131
  199. package/dist/statement-builders-vImtdfmM.mjs.map +0 -1
  200. package/dist/statement-builders.d.mts +0 -51
  201. package/dist/statement-builders.d.mts.map +0 -1
  202. package/dist/statement-builders.mjs +0 -2
  203. package/dist/tables-Dcb2q9zV.mjs +0 -516
  204. package/dist/tables-Dcb2q9zV.mjs.map +0 -1
  205. package/dist/types-D-XIpzHA.d.mts.map +0 -1
  206. package/src/core/migrations/statement-builders.ts +0 -183
  207. package/src/exports/statement-builders.ts +0 -8
@@ -1,183 +0,0 @@
1
- import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
2
-
3
- export { APP_SPACE_ID };
4
-
5
- export interface SqlStatement {
6
- readonly sql: string;
7
- readonly params: readonly unknown[];
8
- }
9
-
10
- export const ensurePrismaContractSchemaStatement: SqlStatement = {
11
- sql: 'create schema if not exists prisma_contract',
12
- params: [],
13
- };
14
-
15
- /**
16
- * Schema for `prisma_contract.marker`. The `space text` primary key
17
- * supports one row per loaded contract space (`'app'`,
18
- * `'<extension-id>'`, …); on a brand-new database `CREATE TABLE IF NOT
19
- * EXISTS` produces this shape directly. The migration runner detects
20
- * pre-1.0 single-row markers (no `space` column) at boot and fails with
21
- * a structured `LEGACY_MARKER_SHAPE` error rather than auto-migrating —
22
- * see `specs/framework-mechanism.spec.md § 2`.
23
- */
24
- export const ensureMarkerTableStatement: SqlStatement = {
25
- sql: `create table if not exists prisma_contract.marker (
26
- space text not null primary key default '${APP_SPACE_ID}',
27
- core_hash text not null,
28
- profile_hash text not null,
29
- contract_json jsonb,
30
- canonical_version int,
31
- updated_at timestamptz not null default now(),
32
- app_tag text,
33
- meta jsonb not null default '{}',
34
- invariants text[] not null default '{}'
35
- )`,
36
- params: [],
37
- };
38
-
39
- export const ensureLedgerTableStatement: SqlStatement = {
40
- sql: `create table if not exists prisma_contract.ledger (
41
- id bigserial primary key,
42
- created_at timestamptz not null default now(),
43
- origin_core_hash text,
44
- origin_profile_hash text,
45
- destination_core_hash text not null,
46
- destination_profile_hash text,
47
- contract_json_before jsonb,
48
- contract_json_after jsonb,
49
- operations jsonb not null
50
- )`,
51
- params: [],
52
- };
53
-
54
- export interface MergeMarkerInput {
55
- /**
56
- * Logical space identifier for this marker row. Required at every
57
- * call site so the type system surfaces every place that needs to
58
- * thread the value (rather than letting an `?? APP_SPACE_ID`
59
- * fall-through silently collapse per-space markers onto the
60
- * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}
61
- * (`'app'`); per-extension callers (planner / runner / verifier
62
- * extensions over contract spaces) pass the extension's space id.
63
- */
64
- readonly space: string;
65
- readonly storageHash: string;
66
- readonly profileHash: string;
67
- readonly contractJson?: unknown;
68
- readonly canonicalVersion?: number | null;
69
- readonly appTag?: string | null;
70
- readonly meta?: Record<string, unknown>;
71
- /**
72
- * Invariants to merge into `marker.invariants`. INSERT writes them as
73
- * the initial value (callers are expected to pass a sorted, deduped
74
- * array). UPDATE merges them with the existing column server-side via
75
- * a single atomic SQL expression.
76
- */
77
- readonly invariants: readonly string[];
78
- }
79
-
80
- export function buildMergeMarkerStatements(input: MergeMarkerInput): {
81
- readonly insert: SqlStatement;
82
- readonly update: SqlStatement;
83
- } {
84
- const params: readonly unknown[] = [
85
- input.space,
86
- input.storageHash,
87
- input.profileHash,
88
- jsonParam(input.contractJson),
89
- input.canonicalVersion ?? null,
90
- input.appTag ?? null,
91
- jsonParam(input.meta ?? {}),
92
- input.invariants,
93
- ];
94
-
95
- return {
96
- insert: {
97
- sql: `insert into prisma_contract.marker (
98
- space,
99
- core_hash,
100
- profile_hash,
101
- contract_json,
102
- canonical_version,
103
- updated_at,
104
- app_tag,
105
- meta,
106
- invariants
107
- ) values (
108
- $1,
109
- $2,
110
- $3,
111
- $4::jsonb,
112
- $5,
113
- now(),
114
- $6,
115
- $7::jsonb,
116
- $8::text[]
117
- )`,
118
- params,
119
- },
120
- update: {
121
- // `invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)`
122
- // reads the current column value under the UPDATE's row lock, unions
123
- // with the incoming array, dedupes, and sorts ascending — single
124
- // statement, atomic, no read-then-write window.
125
- sql: `update prisma_contract.marker set
126
- core_hash = $2,
127
- profile_hash = $3,
128
- contract_json = $4::jsonb,
129
- canonical_version = $5,
130
- updated_at = now(),
131
- app_tag = $6,
132
- meta = $7::jsonb,
133
- invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)
134
- where space = $1`,
135
- params,
136
- },
137
- };
138
- }
139
-
140
- export interface LedgerInsertInput {
141
- readonly originStorageHash?: string | null;
142
- readonly originProfileHash?: string | null;
143
- readonly destinationStorageHash: string;
144
- readonly destinationProfileHash?: string | null;
145
- readonly contractJsonBefore?: unknown;
146
- readonly contractJsonAfter?: unknown;
147
- readonly operations: unknown;
148
- }
149
-
150
- export function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {
151
- return {
152
- sql: `insert into prisma_contract.ledger (
153
- origin_core_hash,
154
- origin_profile_hash,
155
- destination_core_hash,
156
- destination_profile_hash,
157
- contract_json_before,
158
- contract_json_after,
159
- operations
160
- ) values (
161
- $1,
162
- $2,
163
- $3,
164
- $4,
165
- $5::jsonb,
166
- $6::jsonb,
167
- $7::jsonb
168
- )`,
169
- params: [
170
- input.originStorageHash ?? null,
171
- input.originProfileHash ?? null,
172
- input.destinationStorageHash,
173
- input.destinationProfileHash ?? null,
174
- jsonParam(input.contractJsonBefore),
175
- jsonParam(input.contractJsonAfter),
176
- jsonParam(input.operations),
177
- ],
178
- };
179
- }
180
-
181
- function jsonParam(value: unknown): string {
182
- return JSON.stringify(value ?? null);
183
- }
@@ -1,8 +0,0 @@
1
- export type { SqlStatement } from '../core/migrations/statement-builders';
2
- export {
3
- APP_SPACE_ID,
4
- buildMergeMarkerStatements,
5
- ensureLedgerTableStatement,
6
- ensureMarkerTableStatement,
7
- ensurePrismaContractSchemaStatement,
8
- } from '../core/migrations/statement-builders';