@prisma-next/core-control-plane 0.3.0-dev.8 → 0.3.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 (97) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +31 -99
  3. package/dist/constants.d.mts +9 -0
  4. package/dist/constants.d.mts.map +1 -0
  5. package/dist/constants.mjs +10 -0
  6. package/dist/constants.mjs.map +1 -0
  7. package/dist/emission.d.mts +58 -0
  8. package/dist/emission.d.mts.map +1 -0
  9. package/dist/emission.mjs +315 -0
  10. package/dist/emission.mjs.map +1 -0
  11. package/dist/errors.d.mts +231 -0
  12. package/dist/errors.d.mts.map +1 -0
  13. package/dist/errors.mjs +330 -0
  14. package/dist/errors.mjs.map +1 -0
  15. package/dist/{schema-view.d.ts → schema-view-DObwT8x9.d.mts} +17 -14
  16. package/dist/schema-view-DObwT8x9.d.mts.map +1 -0
  17. package/dist/schema-view.d.mts +2 -0
  18. package/dist/schema-view.mjs +1 -0
  19. package/dist/stack.d.mts +30 -0
  20. package/dist/stack.d.mts.map +1 -0
  21. package/dist/stack.mjs +30 -0
  22. package/dist/stack.mjs.map +1 -0
  23. package/dist/types-BArIWumw.d.mts +615 -0
  24. package/dist/types-BArIWumw.d.mts.map +1 -0
  25. package/dist/types.d.mts +2 -0
  26. package/dist/types.mjs +1 -0
  27. package/package.json +31 -43
  28. package/src/constants.ts +5 -0
  29. package/src/emission/canonicalization.ts +68 -21
  30. package/src/emission/emit.ts +82 -21
  31. package/src/emission/hashing.ts +29 -27
  32. package/src/emission/types.ts +13 -2
  33. package/src/errors.ts +116 -12
  34. package/src/exports/constants.ts +1 -0
  35. package/src/exports/emission.ts +1 -1
  36. package/src/exports/errors.ts +6 -1
  37. package/src/exports/types.ts +0 -1
  38. package/src/migrations.ts +27 -1
  39. package/src/schema-view.ts +5 -5
  40. package/src/types.ts +24 -12
  41. package/dist/chunk-473ODD3P.js +0 -14
  42. package/dist/chunk-473ODD3P.js.map +0 -1
  43. package/dist/chunk-U5RYT6PT.js +0 -229
  44. package/dist/chunk-U5RYT6PT.js.map +0 -1
  45. package/dist/config-types.d.ts +0 -68
  46. package/dist/config-types.d.ts.map +0 -1
  47. package/dist/config-validation.d.ts +0 -10
  48. package/dist/config-validation.d.ts.map +0 -1
  49. package/dist/emission/canonicalization.d.ts +0 -6
  50. package/dist/emission/canonicalization.d.ts.map +0 -1
  51. package/dist/emission/emit.d.ts +0 -5
  52. package/dist/emission/emit.d.ts.map +0 -1
  53. package/dist/emission/hashing.d.ts +0 -17
  54. package/dist/emission/hashing.d.ts.map +0 -1
  55. package/dist/emission/types.d.ts +0 -16
  56. package/dist/emission/types.d.ts.map +0 -1
  57. package/dist/errors.d.ts +0 -183
  58. package/dist/errors.d.ts.map +0 -1
  59. package/dist/exports/config-types.d.ts +0 -3
  60. package/dist/exports/config-types.d.ts.map +0 -1
  61. package/dist/exports/config-types.js +0 -53
  62. package/dist/exports/config-types.js.map +0 -1
  63. package/dist/exports/config-validation.d.ts +0 -2
  64. package/dist/exports/config-validation.d.ts.map +0 -1
  65. package/dist/exports/config-validation.js +0 -252
  66. package/dist/exports/config-validation.js.map +0 -1
  67. package/dist/exports/emission.d.ts +0 -5
  68. package/dist/exports/emission.d.ts.map +0 -1
  69. package/dist/exports/emission.js +0 -310
  70. package/dist/exports/emission.js.map +0 -1
  71. package/dist/exports/errors.d.ts +0 -3
  72. package/dist/exports/errors.d.ts.map +0 -1
  73. package/dist/exports/errors.js +0 -43
  74. package/dist/exports/errors.js.map +0 -1
  75. package/dist/exports/schema-view.d.ts +0 -2
  76. package/dist/exports/schema-view.d.ts.map +0 -1
  77. package/dist/exports/schema-view.js +0 -1
  78. package/dist/exports/schema-view.js.map +0 -1
  79. package/dist/exports/stack.d.ts +0 -2
  80. package/dist/exports/stack.d.ts.map +0 -1
  81. package/dist/exports/stack.js +0 -7
  82. package/dist/exports/stack.js.map +0 -1
  83. package/dist/exports/types.d.ts +0 -3
  84. package/dist/exports/types.d.ts.map +0 -1
  85. package/dist/exports/types.js +0 -7
  86. package/dist/exports/types.js.map +0 -1
  87. package/dist/migrations.d.ts +0 -190
  88. package/dist/migrations.d.ts.map +0 -1
  89. package/dist/schema-view.d.ts.map +0 -1
  90. package/dist/stack.d.ts +0 -25
  91. package/dist/stack.d.ts.map +0 -1
  92. package/dist/types.d.ts +0 -411
  93. package/dist/types.d.ts.map +0 -1
  94. package/src/config-types.ts +0 -157
  95. package/src/config-validation.ts +0 -270
  96. package/src/exports/config-types.ts +0 -5
  97. package/src/exports/config-validation.ts +0 -1
@@ -1,270 +0,0 @@
1
- import type { PrismaNextConfig } from './config-types';
2
- import { errorConfigValidation } from './errors';
3
-
4
- /**
5
- * Validates that the config has the required structure.
6
- * This is pure validation logic with no file I/O or CLI awareness.
7
- *
8
- * @param config - Config object to validate
9
- * @throws CliStructuredError if config structure is invalid
10
- */
11
- export function validateConfig(config: unknown): asserts config is PrismaNextConfig {
12
- if (!config || typeof config !== 'object') {
13
- throw errorConfigValidation('object', {
14
- why: 'Config must be an object',
15
- });
16
- }
17
-
18
- const configObj = config as Record<string, unknown>;
19
-
20
- if (!configObj['family']) {
21
- throw errorConfigValidation('family');
22
- }
23
-
24
- if (!configObj['target']) {
25
- throw errorConfigValidation('target');
26
- }
27
-
28
- if (!configObj['adapter']) {
29
- throw errorConfigValidation('adapter');
30
- }
31
-
32
- // Validate family descriptor
33
- const family = configObj['family'] as Record<string, unknown>;
34
- if (family['kind'] !== 'family') {
35
- throw errorConfigValidation('family.kind', {
36
- why: 'Config.family must have kind: "family"',
37
- });
38
- }
39
- if (typeof family['familyId'] !== 'string') {
40
- throw errorConfigValidation('family.familyId', {
41
- why: 'Config.family must have familyId: string',
42
- });
43
- }
44
- if (typeof family['version'] !== 'string') {
45
- throw errorConfigValidation('family.version', {
46
- why: 'Config.family must have version: string',
47
- });
48
- }
49
- if (!family['hook'] || typeof family['hook'] !== 'object') {
50
- throw errorConfigValidation('family.hook', {
51
- why: 'Config.family must have hook: TargetFamilyHook',
52
- });
53
- }
54
- if (typeof family['create'] !== 'function') {
55
- throw errorConfigValidation('family.create', {
56
- why: 'Config.family must have create: function',
57
- });
58
- }
59
-
60
- const familyId = family['familyId'] as string;
61
-
62
- // Validate target descriptor
63
- const target = configObj['target'] as Record<string, unknown>;
64
- if (target['kind'] !== 'target') {
65
- throw errorConfigValidation('target.kind', {
66
- why: 'Config.target must have kind: "target"',
67
- });
68
- }
69
- if (typeof target['id'] !== 'string') {
70
- throw errorConfigValidation('target.id', {
71
- why: 'Config.target must have id: string',
72
- });
73
- }
74
- if (typeof target['familyId'] !== 'string') {
75
- throw errorConfigValidation('target.familyId', {
76
- why: 'Config.target must have familyId: string',
77
- });
78
- }
79
- if (typeof target['version'] !== 'string') {
80
- throw errorConfigValidation('target.version', {
81
- why: 'Config.target must have version: string',
82
- });
83
- }
84
- if (target['familyId'] !== familyId) {
85
- throw errorConfigValidation('target.familyId', {
86
- why: `Config.target.familyId must match Config.family.familyId (expected: ${familyId}, got: ${target['familyId']})`,
87
- });
88
- }
89
- if (typeof target['targetId'] !== 'string') {
90
- throw errorConfigValidation('target.targetId', {
91
- why: 'Config.target must have targetId: string',
92
- });
93
- }
94
- if (typeof target['create'] !== 'function') {
95
- throw errorConfigValidation('target.create', {
96
- why: 'Config.target must have create: function',
97
- });
98
- }
99
- const expectedTargetId = target['targetId'] as string;
100
-
101
- // Validate adapter descriptor
102
- const adapter = configObj['adapter'] as Record<string, unknown>;
103
- if (adapter['kind'] !== 'adapter') {
104
- throw errorConfigValidation('adapter.kind', {
105
- why: 'Config.adapter must have kind: "adapter"',
106
- });
107
- }
108
- if (typeof adapter['id'] !== 'string') {
109
- throw errorConfigValidation('adapter.id', {
110
- why: 'Config.adapter must have id: string',
111
- });
112
- }
113
- if (typeof adapter['familyId'] !== 'string') {
114
- throw errorConfigValidation('adapter.familyId', {
115
- why: 'Config.adapter must have familyId: string',
116
- });
117
- }
118
- if (typeof adapter['version'] !== 'string') {
119
- throw errorConfigValidation('adapter.version', {
120
- why: 'Config.adapter must have version: string',
121
- });
122
- }
123
- if (adapter['familyId'] !== familyId) {
124
- throw errorConfigValidation('adapter.familyId', {
125
- why: `Config.adapter.familyId must match Config.family.familyId (expected: ${familyId}, got: ${adapter['familyId']})`,
126
- });
127
- }
128
- if (typeof adapter['targetId'] !== 'string') {
129
- throw errorConfigValidation('adapter.targetId', {
130
- why: 'Config.adapter must have targetId: string',
131
- });
132
- }
133
- if (adapter['targetId'] !== expectedTargetId) {
134
- throw errorConfigValidation('adapter.targetId', {
135
- why: `Config.adapter.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${adapter['targetId']})`,
136
- });
137
- }
138
- if (typeof adapter['create'] !== 'function') {
139
- throw errorConfigValidation('adapter.create', {
140
- why: 'Config.adapter must have create: function',
141
- });
142
- }
143
-
144
- // Validate extensions array if present
145
- if (configObj['extensions'] !== undefined) {
146
- if (!Array.isArray(configObj['extensions'])) {
147
- throw errorConfigValidation('extensions', {
148
- why: 'Config.extensions must be an array',
149
- });
150
- }
151
- for (const ext of configObj['extensions']) {
152
- if (!ext || typeof ext !== 'object') {
153
- throw errorConfigValidation('extensions[]', {
154
- why: 'Config.extensions must contain ExtensionDescriptor objects',
155
- });
156
- }
157
- const extObj = ext as Record<string, unknown>;
158
- if (extObj['kind'] !== 'extension') {
159
- throw errorConfigValidation('extensions[].kind', {
160
- why: 'Config.extensions items must have kind: "extension"',
161
- });
162
- }
163
- if (typeof extObj['id'] !== 'string') {
164
- throw errorConfigValidation('extensions[].id', {
165
- why: 'Config.extensions items must have id: string',
166
- });
167
- }
168
- if (typeof extObj['familyId'] !== 'string') {
169
- throw errorConfigValidation('extensions[].familyId', {
170
- why: 'Config.extensions items must have familyId: string',
171
- });
172
- }
173
- if (typeof extObj['version'] !== 'string') {
174
- throw errorConfigValidation('extensions[].version', {
175
- why: 'Config.extensions items must have version: string',
176
- });
177
- }
178
- if (extObj['familyId'] !== familyId) {
179
- throw errorConfigValidation('extensions[].familyId', {
180
- why: `Config.extensions[].familyId must match Config.family.familyId (expected: ${familyId}, got: ${extObj['familyId']})`,
181
- });
182
- }
183
- if (typeof extObj['targetId'] !== 'string') {
184
- throw errorConfigValidation('extensions[].targetId', {
185
- why: 'Config.extensions items must have targetId: string',
186
- });
187
- }
188
- if (extObj['targetId'] !== expectedTargetId) {
189
- throw errorConfigValidation('extensions[].targetId', {
190
- why: `Config.extensions[].targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${extObj['targetId']})`,
191
- });
192
- }
193
- if (typeof extObj['create'] !== 'function') {
194
- throw errorConfigValidation('extensions[].create', {
195
- why: 'Config.extensions items must have create: function',
196
- });
197
- }
198
- }
199
- }
200
-
201
- // Validate driver descriptor if present
202
- if (configObj['driver'] !== undefined) {
203
- const driver = configObj['driver'] as Record<string, unknown>;
204
- if (driver['kind'] !== 'driver') {
205
- throw errorConfigValidation('driver.kind', {
206
- why: 'Config.driver must have kind: "driver"',
207
- });
208
- }
209
- if (typeof driver['id'] !== 'string') {
210
- throw errorConfigValidation('driver.id', {
211
- why: 'Config.driver must have id: string',
212
- });
213
- }
214
- if (typeof driver['version'] !== 'string') {
215
- throw errorConfigValidation('driver.version', {
216
- why: 'Config.driver must have version: string',
217
- });
218
- }
219
- if (typeof driver['familyId'] !== 'string') {
220
- throw errorConfigValidation('driver.familyId', {
221
- why: 'Config.driver must have familyId: string',
222
- });
223
- }
224
- if (driver['familyId'] !== familyId) {
225
- throw errorConfigValidation('driver.familyId', {
226
- why: `Config.driver.familyId must match Config.family.familyId (expected: ${familyId}, got: ${driver['familyId']})`,
227
- });
228
- }
229
- if (typeof driver['targetId'] !== 'string') {
230
- throw errorConfigValidation('driver.targetId', {
231
- why: 'Config.driver must have targetId: string',
232
- });
233
- }
234
- if (driver['targetId'] !== expectedTargetId) {
235
- throw errorConfigValidation('driver.targetId', {
236
- why: `Config.driver.targetId must match Config.target.targetId (expected: ${expectedTargetId}, got: ${driver['targetId']})`,
237
- });
238
- }
239
- if (typeof driver['create'] !== 'function') {
240
- throw errorConfigValidation('driver.create', {
241
- why: 'Config.driver must have create: function',
242
- });
243
- }
244
- }
245
-
246
- // Validate contract config if present (structure validation - defineConfig() handles normalization)
247
- if (configObj['contract'] !== undefined) {
248
- const contract = configObj['contract'] as Record<string, unknown>;
249
- if (!contract || typeof contract !== 'object') {
250
- throw errorConfigValidation('contract', {
251
- why: 'Config.contract must be an object',
252
- });
253
- }
254
- if (!('source' in contract)) {
255
- throw errorConfigValidation('contract.source', {
256
- why: 'Config.contract.source is required when contract is provided',
257
- });
258
- }
259
- if (contract['output'] !== undefined && typeof contract['output'] !== 'string') {
260
- throw errorConfigValidation('contract.output', {
261
- why: 'Config.contract.output must be a string when provided',
262
- });
263
- }
264
- if (contract['types'] !== undefined && typeof contract['types'] !== 'string') {
265
- throw errorConfigValidation('contract.types', {
266
- why: 'Config.contract.types must be a string when provided',
267
- });
268
- }
269
- }
270
- }
@@ -1,5 +0,0 @@
1
- export type {
2
- ContractConfig,
3
- PrismaNextConfig,
4
- } from '../config-types';
5
- export { defineConfig } from '../config-types';
@@ -1 +0,0 @@
1
- export { validateConfig } from '../config-validation';