@prisma-next/target-postgres 0.12.0-dev.30 → 0.12.0-dev.32

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 (85) hide show
  1. package/dist/{codec-ids-BEVQ-gO4.d.mts → codec-ids-Cx7C07Y_.d.mts} +3 -2
  2. package/dist/codec-ids-Cx7C07Y_.d.mts.map +1 -0
  3. package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-DTqscwN9.mjs} +3 -2
  4. package/dist/codec-ids-DTqscwN9.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-ClVgENiR.d.mts → codec-types-BoxMGJk-.d.mts} +2 -2
  8. package/dist/{codec-types-ClVgENiR.d.mts.map → codec-types-BoxMGJk-.d.mts.map} +1 -1
  9. package/dist/codec-types.d.mts +1 -1
  10. package/dist/{codecs-BHrYhAZc.d.mts → codecs-DCSyTOCb.d.mts} +2 -2
  11. package/dist/codecs-DCSyTOCb.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 +43 -3
  16. package/dist/contract-free.d.mts.map +1 -1
  17. package/dist/contract-free.mjs +45 -3
  18. package/dist/contract-free.mjs.map +1 -1
  19. package/dist/control.d.mts +1 -1
  20. package/dist/control.mjs +41 -33
  21. package/dist/control.mjs.map +1 -1
  22. package/dist/{data-transform-C1ZpoMCt.d.mts → data-transform-5gLOgP68.d.mts} +2 -2
  23. package/dist/{data-transform-C1ZpoMCt.d.mts.map → data-transform-5gLOgP68.d.mts.map} +1 -1
  24. package/dist/data-transform.d.mts +1 -1
  25. package/dist/ddl.d.mts +1 -1
  26. package/dist/ddl.mjs +1 -1
  27. package/dist/{enum-planning-DHQE3zSH.mjs → enum-planning-Nt9TYPHe.mjs} +0 -0
  28. package/dist/{enum-planning-DHQE3zSH.mjs.map → enum-planning-Nt9TYPHe.mjs.map} +1 -1
  29. package/dist/enum-planning.d.mts +1 -1
  30. package/dist/enum-planning.mjs +1 -1
  31. package/dist/{issue-planner-ttX4mOiF.mjs → issue-planner-SUBi9fH8.mjs} +2 -2
  32. package/dist/{issue-planner-ttX4mOiF.mjs.map → issue-planner-SUBi9fH8.mjs.map} +1 -1
  33. package/dist/issue-planner.d.mts +1 -1
  34. package/dist/issue-planner.mjs +1 -1
  35. package/dist/migration.d.mts +3 -3
  36. package/dist/{nodes-BYSqasmC.mjs → nodes-DCC8-DhV.mjs} +1 -1
  37. package/dist/{nodes-BYSqasmC.mjs.map → nodes-DCC8-DhV.mjs.map} +1 -1
  38. package/dist/{nodes-BS8vS8gv.d.mts → nodes-DflxwrE8.d.mts} +1 -1
  39. package/dist/{nodes-BS8vS8gv.d.mts.map → nodes-DflxwrE8.d.mts.map} +1 -1
  40. package/dist/{op-factory-call-B9mYdDex.d.mts → op-factory-call-B-HEOf41.d.mts} +3 -3
  41. package/dist/{op-factory-call-B9mYdDex.d.mts.map → op-factory-call-B-HEOf41.d.mts.map} +1 -1
  42. package/dist/op-factory-call.d.mts +1 -1
  43. package/dist/pack.d.mts +2 -2
  44. package/dist/{planner-y-bVvDFR.mjs → planner-BruD4_LM.mjs} +3 -3
  45. package/dist/{planner-y-bVvDFR.mjs.map → planner-BruD4_LM.mjs.map} +1 -1
  46. package/dist/planner-ddl-builders.d.mts +1 -1
  47. package/dist/{planner-produced-postgres-migration-RdjC7aUC.d.mts → planner-produced-postgres-migration-Co71_VbU.d.mts} +3 -3
  48. package/dist/{planner-produced-postgres-migration-RdjC7aUC.d.mts.map → planner-produced-postgres-migration-Co71_VbU.d.mts.map} +1 -1
  49. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  50. package/dist/{planner-target-details-C1Ye0hb6.d.mts → planner-target-details-Dv5N6x6k.d.mts} +1 -1
  51. package/dist/{planner-target-details-C1Ye0hb6.d.mts.map → planner-target-details-Dv5N6x6k.d.mts.map} +1 -1
  52. package/dist/planner-target-details.d.mts +1 -1
  53. package/dist/planner.d.mts +1 -1
  54. package/dist/planner.mjs +1 -1
  55. package/dist/{postgres-contract-serializer-BYpK6TkY.mjs → postgres-contract-serializer-OfORJ-GY.mjs} +1 -1
  56. package/dist/{postgres-contract-serializer-BYpK6TkY.mjs.map → postgres-contract-serializer-OfORJ-GY.mjs.map} +1 -1
  57. package/dist/{postgres-enum-type-Bl6THBPg.d.mts → postgres-enum-type-CWwVGBNK.d.mts} +1 -1
  58. package/dist/{postgres-enum-type-Bl6THBPg.d.mts.map → postgres-enum-type-CWwVGBNK.d.mts.map} +1 -1
  59. package/dist/{postgres-migration-DLZtVVDM.d.mts → postgres-migration-BcKS2Lqq.d.mts} +3 -3
  60. package/dist/{postgres-migration-DLZtVVDM.d.mts.map → postgres-migration-BcKS2Lqq.d.mts.map} +1 -1
  61. package/dist/render-ops.d.mts +1 -1
  62. package/dist/runtime.mjs +1 -1
  63. package/dist/{shared-wRIzOjdd.d.mts → shared-CMqM-2BA.d.mts} +2 -2
  64. package/dist/{shared-wRIzOjdd.d.mts.map → shared-CMqM-2BA.d.mts.map} +1 -1
  65. package/dist/{types-DncetAjv.d.mts → types-kggVJs6C.d.mts} +1 -1
  66. package/dist/types-kggVJs6C.d.mts.map +1 -0
  67. package/dist/types.d.mts +2 -2
  68. package/package.json +17 -18
  69. package/src/contract-free/columns.ts +49 -0
  70. package/src/core/ast/table-source.ts +23 -0
  71. package/src/core/codec-ids.ts +1 -0
  72. package/src/core/codecs.ts +44 -0
  73. package/src/core/migrations/runner.ts +41 -47
  74. package/src/exports/contract-free.ts +2 -0
  75. package/dist/codec-ids-BEVQ-gO4.d.mts.map +0 -1
  76. package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
  77. package/dist/codecs-BHrYhAZc.d.mts.map +0 -1
  78. package/dist/statement-builders-Cd311EDF.mjs +0 -143
  79. package/dist/statement-builders-Cd311EDF.mjs.map +0 -1
  80. package/dist/statement-builders.d.mts +0 -51
  81. package/dist/statement-builders.d.mts.map +0 -1
  82. package/dist/statement-builders.mjs +0 -2
  83. package/dist/types-DncetAjv.d.mts.map +0 -1
  84. package/src/core/migrations/statement-builders.ts +0 -198
  85. package/src/exports/statement-builders.ts +0 -8
@@ -1,198 +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
- space text not null,
44
- migration_name text not null,
45
- migration_hash text not null,
46
- origin_core_hash text,
47
- origin_profile_hash text,
48
- destination_core_hash text not null,
49
- destination_profile_hash text,
50
- contract_json_before jsonb,
51
- contract_json_after jsonb,
52
- operations jsonb not null
53
- )`,
54
- params: [],
55
- };
56
-
57
- export interface MergeMarkerInput {
58
- /**
59
- * Logical space identifier for this marker row. Required at every
60
- * call site so the type system surfaces every place that needs to
61
- * thread the value (rather than letting an `?? APP_SPACE_ID`
62
- * fall-through silently collapse per-space markers onto the
63
- * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}
64
- * (`'app'`); per-extension callers (planner / runner / verifier
65
- * extensions over contract spaces) pass the extension's space id.
66
- */
67
- readonly space: string;
68
- readonly storageHash: string;
69
- readonly profileHash: string;
70
- readonly contractJson?: unknown;
71
- readonly canonicalVersion?: number | null;
72
- readonly appTag?: string | null;
73
- readonly meta?: Record<string, unknown>;
74
- /**
75
- * Invariants to merge into `marker.invariants`. INSERT writes them as
76
- * the initial value (callers are expected to pass a sorted, deduped
77
- * array). UPDATE merges them with the existing column server-side via
78
- * a single atomic SQL expression.
79
- */
80
- readonly invariants: readonly string[];
81
- }
82
-
83
- export function buildMergeMarkerStatements(input: MergeMarkerInput): {
84
- readonly insert: SqlStatement;
85
- readonly update: SqlStatement;
86
- } {
87
- const params: readonly unknown[] = [
88
- input.space,
89
- input.storageHash,
90
- input.profileHash,
91
- jsonParam(input.contractJson),
92
- input.canonicalVersion ?? null,
93
- input.appTag ?? null,
94
- jsonParam(input.meta ?? {}),
95
- input.invariants,
96
- ];
97
-
98
- return {
99
- insert: {
100
- sql: `insert into prisma_contract.marker (
101
- space,
102
- core_hash,
103
- profile_hash,
104
- contract_json,
105
- canonical_version,
106
- updated_at,
107
- app_tag,
108
- meta,
109
- invariants
110
- ) values (
111
- $1,
112
- $2,
113
- $3,
114
- $4::jsonb,
115
- $5,
116
- now(),
117
- $6,
118
- $7::jsonb,
119
- $8::text[]
120
- )`,
121
- params,
122
- },
123
- update: {
124
- // `invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)`
125
- // reads the current column value under the UPDATE's row lock, unions
126
- // with the incoming array, dedupes, and sorts ascending — single
127
- // statement, atomic, no read-then-write window.
128
- sql: `update prisma_contract.marker set
129
- core_hash = $2,
130
- profile_hash = $3,
131
- contract_json = $4::jsonb,
132
- canonical_version = $5,
133
- updated_at = now(),
134
- app_tag = $6,
135
- meta = $7::jsonb,
136
- invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)
137
- where space = $1`,
138
- params,
139
- },
140
- };
141
- }
142
-
143
- export interface LedgerInsertInput {
144
- readonly space: string;
145
- readonly migrationName: string;
146
- readonly migrationHash: string;
147
- readonly originStorageHash?: string | null;
148
- readonly originProfileHash?: string | null;
149
- readonly destinationStorageHash: string;
150
- readonly destinationProfileHash?: string | null;
151
- readonly contractJsonBefore?: unknown;
152
- readonly contractJsonAfter?: unknown;
153
- readonly operations: unknown;
154
- }
155
-
156
- export function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {
157
- return {
158
- sql: `insert into prisma_contract.ledger (
159
- space,
160
- migration_name,
161
- migration_hash,
162
- origin_core_hash,
163
- origin_profile_hash,
164
- destination_core_hash,
165
- destination_profile_hash,
166
- contract_json_before,
167
- contract_json_after,
168
- operations
169
- ) values (
170
- $1,
171
- $2,
172
- $3,
173
- $4,
174
- $5,
175
- $6,
176
- $7,
177
- $8::jsonb,
178
- $9::jsonb,
179
- $10::jsonb
180
- )`,
181
- params: [
182
- input.space,
183
- input.migrationName,
184
- input.migrationHash,
185
- input.originStorageHash ?? null,
186
- input.originProfileHash ?? null,
187
- input.destinationStorageHash,
188
- input.destinationProfileHash ?? null,
189
- jsonParam(input.contractJsonBefore),
190
- jsonParam(input.contractJsonAfter),
191
- jsonParam(input.operations),
192
- ],
193
- };
194
- }
195
-
196
- function jsonParam(value: unknown): string {
197
- return JSON.stringify(value ?? null);
198
- }
@@ -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';