@prisma-next/framework-components 0.5.0-dev.8 → 0.5.0-dev.81

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 (94) hide show
  1. package/README.md +53 -4
  2. package/dist/authoring.d.mts +2 -2
  3. package/dist/authoring.mjs +2 -122
  4. package/dist/codec-m_-FAyQn.d.mts +168 -0
  5. package/dist/codec-m_-FAyQn.d.mts.map +1 -0
  6. package/dist/codec.d.mts +48 -2
  7. package/dist/codec.d.mts.map +1 -0
  8. package/dist/codec.mjs +67 -4
  9. package/dist/codec.mjs.map +1 -1
  10. package/dist/components.d.mts +1 -1
  11. package/dist/components.mjs +2 -3
  12. package/dist/control.d.mts +420 -74
  13. package/dist/control.d.mts.map +1 -1
  14. package/dist/control.mjs +83 -49
  15. package/dist/control.mjs.map +1 -1
  16. package/dist/emission-types-BKa4bR9m.d.mts +39 -0
  17. package/dist/emission-types-BKa4bR9m.d.mts.map +1 -0
  18. package/dist/emission.d.mts +2 -2
  19. package/dist/emission.mjs +1 -1
  20. package/dist/execution.d.mts +5 -5
  21. package/dist/execution.d.mts.map +1 -1
  22. package/dist/execution.mjs +4 -6
  23. package/dist/execution.mjs.map +1 -1
  24. package/dist/{framework-authoring-D1-JZ37B.d.mts → framework-authoring-DGIQbNPt.d.mts} +43 -12
  25. package/dist/framework-authoring-DGIQbNPt.d.mts.map +1 -0
  26. package/dist/framework-authoring-DxXcjyJX.mjs +209 -0
  27. package/dist/framework-authoring-DxXcjyJX.mjs.map +1 -0
  28. package/dist/{framework-components-DFZMi2h7.d.mts → framework-components-BGo7HsbL.d.mts} +45 -55
  29. package/dist/framework-components-BGo7HsbL.d.mts.map +1 -0
  30. package/dist/{framework-components-C8ZhSwXe.mjs → framework-components-FdqmlGUj.mjs} +3 -3
  31. package/dist/framework-components-FdqmlGUj.mjs.map +1 -0
  32. package/dist/psl-ast-Ckn_G-jv.d.mts +159 -0
  33. package/dist/psl-ast-Ckn_G-jv.d.mts.map +1 -0
  34. package/dist/psl-ast.d.mts +2 -0
  35. package/dist/psl-ast.mjs +1 -0
  36. package/dist/runtime.d.mts +395 -19
  37. package/dist/runtime.d.mts.map +1 -1
  38. package/dist/runtime.mjs +256 -7
  39. package/dist/runtime.mjs.map +1 -1
  40. package/dist/{types-import-spec-C4sc7wbb.d.mts → types-import-spec-BxI5cSQy.d.mts} +2 -2
  41. package/dist/types-import-spec-BxI5cSQy.d.mts.map +1 -0
  42. package/package.json +10 -6
  43. package/src/control/control-capabilities.ts +96 -0
  44. package/src/{control-descriptors.ts → control/control-descriptors.ts} +7 -7
  45. package/src/{control-instances.ts → control/control-instances.ts} +52 -6
  46. package/src/{control-migration-types.ts → control/control-migration-types.ts} +251 -63
  47. package/src/control/control-operation-preview.ts +23 -0
  48. package/src/control/control-spaces.ts +82 -0
  49. package/src/{control-stack.ts → control/control-stack.ts} +77 -94
  50. package/src/control/emission-types.ts +49 -0
  51. package/src/control/psl-ast.ts +193 -0
  52. package/src/{execution-descriptors.ts → execution/execution-descriptors.ts} +7 -7
  53. package/src/{execution-instances.ts → execution/execution-instances.ts} +1 -1
  54. package/src/{execution-requirements.ts → execution/execution-requirements.ts} +1 -1
  55. package/src/execution/query-plan.ts +53 -0
  56. package/src/execution/race-against-abort.ts +89 -0
  57. package/src/execution/run-with-middleware.ts +153 -0
  58. package/src/execution/runtime-core.ts +133 -0
  59. package/src/execution/runtime-error.ts +94 -0
  60. package/src/execution/runtime-middleware.ts +235 -0
  61. package/src/exports/authoring.ts +5 -2
  62. package/src/exports/codec.ts +27 -2
  63. package/src/exports/components.ts +2 -2
  64. package/src/exports/control.ts +41 -13
  65. package/src/exports/emission.ts +2 -2
  66. package/src/exports/execution.ts +5 -5
  67. package/src/exports/psl-ast.ts +1 -0
  68. package/src/exports/runtime.ts +18 -5
  69. package/src/shared/codec-descriptor.ts +87 -0
  70. package/src/shared/codec-types.ts +79 -0
  71. package/src/shared/codec.ts +80 -0
  72. package/src/shared/column-spec.ts +83 -0
  73. package/src/{framework-authoring.ts → shared/framework-authoring.ts} +210 -23
  74. package/src/{framework-components.ts → shared/framework-components.ts} +22 -48
  75. package/src/{mutation-default-types.ts → shared/mutation-default-types.ts} +22 -2
  76. package/dist/authoring.mjs.map +0 -1
  77. package/dist/codec-types-DQ1Agjom.d.mts +0 -58
  78. package/dist/codec-types-DQ1Agjom.d.mts.map +0 -1
  79. package/dist/emission-types-BPAALJbF.d.mts +0 -24
  80. package/dist/emission-types-BPAALJbF.d.mts.map +0 -1
  81. package/dist/framework-authoring-D1-JZ37B.d.mts.map +0 -1
  82. package/dist/framework-components-C8ZhSwXe.mjs.map +0 -1
  83. package/dist/framework-components-DFZMi2h7.d.mts.map +0 -1
  84. package/dist/types-import-spec-C4sc7wbb.d.mts.map +0 -1
  85. package/src/codec-types.ts +0 -64
  86. package/src/control-capabilities.ts +0 -34
  87. package/src/emission-types.ts +0 -28
  88. package/src/runtime-error.ts +0 -55
  89. package/src/runtime-middleware.ts +0 -83
  90. /package/src/{control-result-types.ts → control/control-result-types.ts} +0 -0
  91. /package/src/{control-schema-view.ts → control/control-schema-view.ts} +0 -0
  92. /package/src/{async-iterable-result.ts → execution/async-iterable-result.ts} +0 -0
  93. /package/src/{execution-stack.ts → execution/execution-stack.ts} +0 -0
  94. /package/src/{types-import-spec.ts → shared/types-import-spec.ts} +0 -0
@@ -1,3 +1,12 @@
1
+ import type {
2
+ ColumnDefault,
3
+ ExecutionMutationDefaultPhases,
4
+ ExecutionMutationDefaultValue,
5
+ } from '@prisma-next/contract/types';
6
+ import {
7
+ isColumnDefaultLiteralInputValue,
8
+ isExecutionMutationDefaultValue,
9
+ } from '@prisma-next/contract/types';
1
10
  import { ifDefined } from '@prisma-next/utils/defined';
2
11
 
3
12
  export type AuthoringArgRef = {
@@ -24,6 +33,7 @@ interface AuthoringArgumentDescriptorCommon {
24
33
  export type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon &
25
34
  (
26
35
  | { readonly kind: 'string' }
36
+ | { readonly kind: 'boolean' }
27
37
  | {
28
38
  readonly kind: 'number';
29
39
  readonly integer?: boolean;
@@ -63,10 +73,15 @@ export type AuthoringColumnDefaultTemplate =
63
73
  | AuthoringColumnDefaultTemplateLiteral
64
74
  | AuthoringColumnDefaultTemplateFunction;
65
75
 
76
+ export interface AuthoringExecutionDefaultsTemplate {
77
+ readonly onCreate?: AuthoringTemplateValue;
78
+ readonly onUpdate?: AuthoringTemplateValue;
79
+ }
80
+
66
81
  export interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {
67
82
  readonly nullable?: boolean;
68
83
  readonly default?: AuthoringColumnDefaultTemplate;
69
- readonly executionDefault?: AuthoringTemplateValue;
84
+ readonly executionDefaults?: AuthoringExecutionDefaultsTemplate;
70
85
  readonly id?: boolean;
71
86
  readonly unique?: boolean;
72
87
  }
@@ -132,6 +147,148 @@ export function isAuthoringFieldPresetDescriptor(
132
147
  );
133
148
  }
134
149
 
150
+ /**
151
+ * Returns true when `namespace` is a non-leaf key in `contributions.field`.
152
+ *
153
+ * `AuthoringFieldNamespace` permits a leaf descriptor at any depth — including
154
+ * the root — so a top-level `field: { Foo: { kind: 'fieldPreset', ... } }`
155
+ * registration must NOT be treated as a "namespace" with sub-paths. Callers
156
+ * use this predicate to gate dot-namespaced lookups (e.g. PSL `@Foo.bar`).
157
+ */
158
+ export function hasRegisteredFieldNamespace(
159
+ contributions: AuthoringContributions | undefined,
160
+ namespace: string,
161
+ ): boolean {
162
+ if (contributions?.field === undefined || !Object.hasOwn(contributions.field, namespace)) {
163
+ return false;
164
+ }
165
+ return !isAuthoringFieldPresetDescriptor(contributions.field[namespace]);
166
+ }
167
+
168
+ function isPlainNamespaceObject(value: unknown): value is Record<string, unknown> {
169
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
170
+ }
171
+
172
+ /**
173
+ * Merges `source` into `target` recursively at the descriptor-namespace
174
+ * level. `leafGuard` decides which values are descriptors (terminal
175
+ * merge points; same-path registrations across components are reported
176
+ * as duplicates) versus sub-namespaces (recursion targets).
177
+ *
178
+ * Path segments are validated against prototype-pollution names
179
+ * (`__proto__`, `constructor`, `prototype`). A value that is neither a
180
+ * recognized leaf nor a plain object — e.g. a malformed descriptor
181
+ * where the canonical leaf guard rejected it for missing `output` —
182
+ * is reported as an invalid contribution rather than recursed into,
183
+ * which would either silently mangle state or infinite-loop on
184
+ * primitive properties.
185
+ *
186
+ * Within-registry duplicate detection is this walker's job;
187
+ * cross-registry detection runs separately via
188
+ * `assertNoCrossRegistryCollisions` after merging completes.
189
+ */
190
+ export function mergeAuthoringNamespaces(
191
+ target: Record<string, unknown>,
192
+ source: Record<string, unknown>,
193
+ path: readonly string[],
194
+ leafGuard: (value: unknown) => boolean,
195
+ label: string,
196
+ ): void {
197
+ const assertSafePath = (currentPath: readonly string[]) => {
198
+ const blockedSegment = currentPath.find(
199
+ (segment) => segment === '__proto__' || segment === 'constructor' || segment === 'prototype',
200
+ );
201
+ if (blockedSegment) {
202
+ throw new Error(
203
+ `Invalid authoring ${label} helper "${currentPath.join('.')}". Helper path segments must not use "${blockedSegment}".`,
204
+ );
205
+ }
206
+ };
207
+
208
+ for (const [key, sourceValue] of Object.entries(source)) {
209
+ const currentPath = [...path, key];
210
+ assertSafePath(currentPath);
211
+ const hasExistingValue = Object.hasOwn(target, key);
212
+ const existingValue = hasExistingValue ? target[key] : undefined;
213
+
214
+ if (!hasExistingValue) {
215
+ target[key] = sourceValue;
216
+ continue;
217
+ }
218
+
219
+ const existingIsLeaf = leafGuard(existingValue);
220
+ const sourceIsLeaf = leafGuard(sourceValue);
221
+
222
+ if (existingIsLeaf || sourceIsLeaf) {
223
+ throw new Error(
224
+ `Duplicate authoring ${label} helper "${currentPath.join('.')}". Helper names must be unique across composed packs.`,
225
+ );
226
+ }
227
+
228
+ if (!isPlainNamespaceObject(existingValue) || !isPlainNamespaceObject(sourceValue)) {
229
+ throw new Error(
230
+ `Invalid authoring ${label} helper "${currentPath.join('.')}". Expected a sub-namespace object or a recognized descriptor; received a malformed value.`,
231
+ );
232
+ }
233
+
234
+ mergeAuthoringNamespaces(existingValue, sourceValue, currentPath, leafGuard, label);
235
+ }
236
+ }
237
+
238
+ function collectAuthoringLeafPaths(
239
+ namespace: Readonly<Record<string, unknown>>,
240
+ isLeaf: (value: unknown) => boolean,
241
+ path: readonly string[] = [],
242
+ ): string[] {
243
+ const paths: string[] = [];
244
+ for (const [key, value] of Object.entries(namespace)) {
245
+ const currentPath = [...path, key];
246
+ if (isLeaf(value)) {
247
+ paths.push(currentPath.join('.'));
248
+ continue;
249
+ }
250
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
251
+ paths.push(
252
+ ...collectAuthoringLeafPaths(
253
+ value as Readonly<Record<string, unknown>>,
254
+ isLeaf,
255
+ currentPath,
256
+ ),
257
+ );
258
+ }
259
+ }
260
+ return paths;
261
+ }
262
+
263
+ export function assertNoCrossRegistryCollisions(
264
+ typeNamespace: AuthoringTypeNamespace,
265
+ fieldNamespace: AuthoringFieldNamespace,
266
+ ): void {
267
+ const typePaths = new Set(
268
+ collectAuthoringLeafPaths(typeNamespace, isAuthoringTypeConstructorDescriptor),
269
+ );
270
+ // Within-registry duplicate detection is handled upstream by the merge
271
+ // walker (`mergeAuthoringNamespaces` in control-stack.ts and
272
+ // `mergeHelperNamespaces` in composed-authoring-helpers.ts), which throws
273
+ // on same-path registrations within either registry before this check
274
+ // runs. This function only handles the cross-registry case — and an
275
+ // empty type namespace makes a cross-registry collision structurally
276
+ // impossible, so the early-out is sound.
277
+ if (typePaths.size === 0) {
278
+ return;
279
+ }
280
+ for (const fieldPath of collectAuthoringLeafPaths(
281
+ fieldNamespace,
282
+ isAuthoringFieldPresetDescriptor,
283
+ )) {
284
+ if (typePaths.has(fieldPath)) {
285
+ throw new Error(
286
+ `Ambiguous authoring registry path "${fieldPath}". The same path is registered as both a type constructor and a field preset; PSL resolution would be ambiguous. Register each path in only one of authoringContributions.field / authoringContributions.type.`,
287
+ );
288
+ }
289
+ }
290
+ }
291
+
135
292
  export function resolveAuthoringTemplateValue(
136
293
  template: AuthoringTemplateValue,
137
294
  args: readonly unknown[],
@@ -188,6 +345,13 @@ function validateAuthoringArgument(
188
345
  return;
189
346
  }
190
347
 
348
+ if (descriptor.kind === 'boolean') {
349
+ if (typeof value !== 'boolean') {
350
+ throw new Error(`Authoring helper argument at ${path} must be a boolean`);
351
+ }
352
+ return;
353
+ }
354
+
191
355
  if (descriptor.kind === 'stringArray') {
192
356
  if (!Array.isArray(value)) {
193
357
  throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
@@ -295,20 +459,17 @@ function resolveAuthoringStorageTypeTemplate(
295
459
  function resolveAuthoringColumnDefaultTemplate(
296
460
  template: AuthoringColumnDefaultTemplate,
297
461
  args: readonly unknown[],
298
- ):
299
- | {
300
- readonly kind: 'literal';
301
- readonly value: unknown;
302
- }
303
- | {
304
- readonly kind: 'function';
305
- readonly expression: string;
306
- } {
462
+ ): ColumnDefault {
307
463
  if (template.kind === 'literal') {
308
464
  const value = resolveAuthoringTemplateValue(template.value, args);
309
465
  if (value === undefined) {
310
466
  throw new Error('Resolved authoring literal default must not be undefined');
311
467
  }
468
+ if (!isColumnDefaultLiteralInputValue(value)) {
469
+ throw new Error(
470
+ `Resolved authoring literal default must be a JSON-serializable value or Date, received ${String(value)}`,
471
+ );
472
+ }
312
473
  return {
313
474
  kind: 'literal',
314
475
  value,
@@ -327,6 +488,40 @@ function resolveAuthoringColumnDefaultTemplate(
327
488
  };
328
489
  }
329
490
 
491
+ function resolveExecutionMutationDefaultPhase(
492
+ phase: 'onCreate' | 'onUpdate',
493
+ template: AuthoringTemplateValue,
494
+ args: readonly unknown[],
495
+ ): ExecutionMutationDefaultValue {
496
+ const value = resolveAuthoringTemplateValue(template, args);
497
+ if (!isExecutionMutationDefaultValue(value)) {
498
+ throw new Error(
499
+ `Authoring preset executionDefaults.${phase} did not resolve to a valid generator descriptor (kind: 'generator', id: string).`,
500
+ );
501
+ }
502
+ return value;
503
+ }
504
+
505
+ function resolveAuthoringExecutionDefaultsTemplate(
506
+ template: AuthoringExecutionDefaultsTemplate,
507
+ args: readonly unknown[],
508
+ ): ExecutionMutationDefaultPhases {
509
+ return {
510
+ ...ifDefined(
511
+ 'onCreate',
512
+ template.onCreate !== undefined
513
+ ? resolveExecutionMutationDefaultPhase('onCreate', template.onCreate, args)
514
+ : undefined,
515
+ ),
516
+ ...ifDefined(
517
+ 'onUpdate',
518
+ template.onUpdate !== undefined
519
+ ? resolveExecutionMutationDefaultPhase('onUpdate', template.onUpdate, args)
520
+ : undefined,
521
+ ),
522
+ };
523
+ }
524
+
330
525
  export function instantiateAuthoringTypeConstructor(
331
526
  descriptor: AuthoringTypeConstructorDescriptor,
332
527
  args: readonly unknown[],
@@ -348,16 +543,8 @@ export function instantiateAuthoringFieldPreset(
348
543
  readonly typeParams?: Record<string, unknown>;
349
544
  };
350
545
  readonly nullable: boolean;
351
- readonly default?:
352
- | {
353
- readonly kind: 'literal';
354
- readonly value: unknown;
355
- }
356
- | {
357
- readonly kind: 'function';
358
- readonly expression: string;
359
- };
360
- readonly executionDefault?: unknown;
546
+ readonly default?: ColumnDefault;
547
+ readonly executionDefaults?: ExecutionMutationDefaultPhases;
361
548
  readonly id: boolean;
362
549
  readonly unique: boolean;
363
550
  } {
@@ -371,9 +558,9 @@ export function instantiateAuthoringFieldPreset(
371
558
  : undefined,
372
559
  ),
373
560
  ...ifDefined(
374
- 'executionDefault',
375
- descriptor.output.executionDefault !== undefined
376
- ? resolveAuthoringTemplateValue(descriptor.output.executionDefault, args)
561
+ 'executionDefaults',
562
+ descriptor.output.executionDefaults !== undefined
563
+ ? resolveAuthoringExecutionDefaultsTemplate(descriptor.output.executionDefaults, args)
377
564
  : undefined,
378
565
  ),
379
566
  id: descriptor.output.id ?? false,
@@ -1,4 +1,4 @@
1
- import type { Codec } from './codec-types';
1
+ import type { AnyCodecDescriptor } from './codec-descriptor';
2
2
  import type { AuthoringContributions } from './framework-authoring';
3
3
  import type { ControlMutationDefaults } from './mutation-default-types';
4
4
  import type { TypesImportSpec } from './types-import-spec';
@@ -13,10 +13,7 @@ export interface ComponentMetadata {
13
13
  /**
14
14
  * Capabilities this component provides.
15
15
  *
16
- * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into
17
- * the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);
18
- * keep these declarations in sync. Targets are identifiers/descriptors and typically do not
19
- * declare capabilities.
16
+ * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`); keep these declarations in sync. Targets are identifiers/descriptors and typically do not declare capabilities.
20
17
  */
21
18
  readonly capabilities?: Record<string, unknown>;
22
19
 
@@ -24,29 +21,25 @@ export interface ComponentMetadata {
24
21
  readonly types?: {
25
22
  readonly codecTypes?: {
26
23
  /**
27
- * Base codec types import spec.
28
- * Optional: adapters typically provide this, extensions usually don't.
24
+ * Base codec types import spec. Optional: adapters typically provide this, extensions usually don't.
29
25
  */
30
26
  readonly import?: TypesImportSpec;
31
27
  /**
32
28
  * Additional type-only imports for parameterized codec branded types.
33
29
  *
34
- * These imports are included in generated `contract.d.ts` but are NOT treated as
35
- * codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
30
+ * These imports are included in generated `contract.d.ts` but are NOT treated as codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).
36
31
  *
37
32
  * Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`
38
33
  */
39
34
  readonly typeImports?: ReadonlyArray<TypesImportSpec>;
40
35
  /**
41
- * Optional control-plane hooks keyed by codecId.
42
- * Used by family-specific planners/verifiers to handle storage types.
36
+ * Optional control-plane hooks keyed by codecId. Used by family-specific planners/verifiers to handle storage types.
43
37
  */
44
38
  readonly controlPlaneHooks?: Record<string, unknown>;
45
39
  /**
46
- * Codec instances contributed by this component.
47
- * Used to build a CodecLookup for codec-dispatched type rendering during emission.
40
+ * Codec descriptors contributed by this component. Source of truth for codec-id-keyed metadata (`traits`, `targetTypes`, `meta`, `renderOutputType`) consumed by `extractCodecLookup`, and used to materialize representative `Codec` instances for codec-dispatched type rendering during emission.
48
41
  */
49
- readonly codecInstances?: ReadonlyArray<Codec>;
42
+ readonly codecDescriptors?: ReadonlyArray<AnyCodecDescriptor>;
50
43
  };
51
44
  readonly operationTypes?: { readonly import: TypesImportSpec };
52
45
  readonly queryOperationTypes?: { readonly import: TypesImportSpec };
@@ -61,21 +54,17 @@ export interface ComponentMetadata {
61
54
  /**
62
55
  * Optional pure-data authoring contributions exposed by this component.
63
56
  *
64
- * These contributions are safe to include on pack refs and descriptors because
65
- * they contain only declarative metadata. Higher-level authoring packages may
66
- * project them into concrete helper functions for TS-first workflows.
57
+ * These contributions are safe to include on pack refs and descriptors because they contain only declarative metadata. Higher-level authoring packages may project them into concrete helper functions for TS-first workflows.
67
58
  */
68
59
  readonly authoring?: AuthoringContributions;
69
60
 
70
61
  /**
71
- * Scalar type name to codec ID mapping contributed by this component.
72
- * Assembled by `createControlStack` with duplicate detection.
62
+ * Scalar type name to codec ID mapping contributed by this component. Assembled by `createControlStack` with duplicate detection.
73
63
  */
74
64
  readonly scalarTypeDescriptors?: ReadonlyMap<string, string>;
75
65
 
76
66
  /**
77
- * Mutation default function handlers and generator descriptors contributed
78
- * by this component. Assembled by `createControlStack` with duplicate detection.
67
+ * Mutation default function handlers and generator descriptors contributed by this component. Assembled by `createControlStack` with duplicate detection.
79
68
  */
80
69
  readonly controlMutationDefaults?: ControlMutationDefaults;
81
70
  }
@@ -83,13 +72,9 @@ export interface ComponentMetadata {
83
72
  /**
84
73
  * Base descriptor for any framework component.
85
74
  *
86
- * All component descriptors share these fundamental properties that identify
87
- * the component and provide its metadata. This interface is extended by
88
- * specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
75
+ * All component descriptors share these fundamental properties that identify the component and provide its metadata. This interface is extended by specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).
89
76
  *
90
- * @template Kind - Discriminator literal identifying the component type.
91
- * Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',
92
- * but the type accepts any string to allow ecosystem extensions.
77
+ * @template Kind - Discriminator literal identifying the component type. Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension', but the type accepts any string to allow ecosystem extensions.
93
78
  *
94
79
  * @example
95
80
  * ```ts
@@ -163,14 +148,12 @@ export function checkContractComponentRequirements(
163
148
  /**
164
149
  * Descriptor for a family component.
165
150
  *
166
- * A "family" represents a category of data sources with shared semantics
167
- * (e.g., SQL databases, document stores). Families define:
151
+ * A "family" represents a category of data sources with shared semantics (e.g., SQL databases, document stores). Families define:
168
152
  * - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)
169
153
  * - Contract structure (tables vs collections, columns vs fields)
170
154
  * - Type system and codecs
171
155
  *
172
- * Families are the top-level grouping. Each family contains multiple targets
173
- * (e.g., SQL family contains Postgres, MySQL, SQLite targets).
156
+ * Families are the top-level grouping. Each family contains multiple targets (e.g., SQL family contains Postgres, MySQL, SQLite targets).
174
157
  *
175
158
  * Extended by plane-specific descriptors:
176
159
  * - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations
@@ -195,13 +178,11 @@ export interface FamilyDescriptor<TFamilyId extends string> extends ComponentDes
195
178
  /**
196
179
  * Descriptor for a target component.
197
180
  *
198
- * A "target" represents a specific database or data store within a family
199
- * (e.g., Postgres, MySQL, MongoDB). Targets define:
181
+ * A "target" represents a specific database or data store within a family (e.g., Postgres, MySQL, MongoDB). Targets define:
200
182
  * - Native type mappings (e.g., Postgres int4 → TypeScript number)
201
183
  * - Target-specific capabilities (e.g., RETURNING, LATERAL joins)
202
184
  *
203
- * Targets are bound to a family and provide the target-specific implementation
204
- * details that adapters and drivers use.
185
+ * Targets are bound to a family and provide the target-specific implementation details that adapters and drivers use.
205
186
  *
206
187
  * Extended by plane-specific descriptors:
207
188
  * - `ControlTargetDescriptor` - adds optional `migrations` capability
@@ -229,8 +210,7 @@ export interface TargetDescriptor<TFamilyId extends string, TTargetId extends st
229
210
  }
230
211
 
231
212
  /**
232
- * Base shape for any pack reference.
233
- * Pack refs are pure JSON-friendly objects safe to import in authoring flows.
213
+ * Base shape for any pack reference. Pack refs are pure JSON-friendly objects safe to import in authoring flows.
234
214
  */
235
215
  export interface PackRefBase<Kind extends string, TFamilyId extends string>
236
216
  extends ComponentMetadata {
@@ -274,14 +254,12 @@ export type DriverPackRef<
274
254
  /**
275
255
  * Descriptor for an adapter component.
276
256
  *
277
- * An "adapter" provides the protocol and dialect implementation for a target.
278
- * Adapters handle:
257
+ * An "adapter" provides the protocol and dialect implementation for a target. Adapters handle:
279
258
  * - SQL/query generation (lowering AST to target-specific syntax)
280
259
  * - Codec registration (encoding/decoding between JS and wire types)
281
260
  * - Type mappings and coercions
282
261
  *
283
- * Adapters are bound to a specific family+target combination and work with
284
- * any compatible driver for that target.
262
+ * Adapters are bound to a specific family+target combination and work with any compatible driver for that target.
285
263
  *
286
264
  * Extended by plane-specific descriptors:
287
265
  * - `ControlAdapterDescriptor` - control-plane factory
@@ -311,16 +289,13 @@ export interface AdapterDescriptor<TFamilyId extends string, TTargetId extends s
311
289
  /**
312
290
  * Descriptor for a driver component.
313
291
  *
314
- * A "driver" provides the connection and execution layer for a target.
315
- * Drivers handle:
292
+ * A "driver" provides the connection and execution layer for a target. Drivers handle:
316
293
  * - Connection management (pooling, timeouts, retries)
317
294
  * - Query execution (sending SQL/commands, receiving results)
318
295
  * - Transaction management
319
296
  * - Wire protocol communication
320
297
  *
321
- * Drivers are bound to a specific family+target and work with any compatible
322
- * adapter. Multiple drivers can exist for the same target (e.g., node-postgres
323
- * vs postgres.js for Postgres).
298
+ * Drivers are bound to a specific family+target and work with any compatible adapter. Multiple drivers can exist for the same target (e.g., node-postgres vs postgres.js for Postgres).
324
299
  *
325
300
  * Extended by plane-specific descriptors:
326
301
  * - `ControlDriverDescriptor` - creates driver from connection URL
@@ -355,8 +330,7 @@ export interface DriverDescriptor<TFamilyId extends string, TTargetId extends st
355
330
  * - Custom types and codecs (e.g., vector type)
356
331
  * - Extended query capabilities
357
332
  *
358
- * Extensions are bound to a specific family+target and are registered in the
359
- * config alongside the core components. Multiple extensions can be used together.
333
+ * Extensions are bound to a specific family+target and are registered in the config alongside the core components. Multiple extensions can be used together.
360
334
  *
361
335
  * Extended by plane-specific descriptors:
362
336
  * - `ControlExtensionDescriptor` - control-plane extension factory
@@ -1,4 +1,8 @@
1
- import type { ColumnDefault, ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
1
+ import type {
2
+ ColumnDefault,
3
+ ExecutionMutationDefaultPhases,
4
+ ExecutionMutationDefaultValue,
5
+ } from '@prisma-next/contract/types';
2
6
 
3
7
  interface SourcePosition {
4
8
  readonly offset: number;
@@ -60,7 +64,16 @@ export type DefaultFunctionRegistry = ReadonlyMap<string, DefaultFunctionRegistr
60
64
 
61
65
  export interface MutationDefaultGeneratorDescriptor {
62
66
  readonly id: string;
63
- readonly applicableCodecIds: readonly string[];
67
+ /**
68
+ * Codec ids the generator is compatible with when the codec choice
69
+ * and the generator choice are made independently by the contract
70
+ * author. Set when the registry-coherence check is meaningful
71
+ * (the codec and the generator can be paired arbitrarily by the
72
+ * caller); omitted when the generator is only reachable through a
73
+ * descriptor that co-registers a fixed codec, so coherence is
74
+ * structural and the list would be tautological.
75
+ */
76
+ readonly applicableCodecIds?: readonly string[];
64
77
  readonly resolveGeneratedColumnDescriptor?: (input: {
65
78
  readonly generated: ExecutionMutationDefaultValue;
66
79
  }) =>
@@ -71,6 +84,13 @@ export interface MutationDefaultGeneratorDescriptor {
71
84
  readonly typeParams?: Record<string, unknown>;
72
85
  }
73
86
  | undefined;
87
+ /**
88
+ * Construct the `onCreate`/`onUpdate` phases value owned by this
89
+ * generator. Authoring layers (PSL `temporal.updatedAt()`, TS field presets) call
90
+ * this instead of building the literal inline so PSL/TS-authored
91
+ * contracts stay byte-equivalent for any future params-bearing generator.
92
+ */
93
+ readonly buildPhases?: (args?: Record<string, unknown>) => ExecutionMutationDefaultPhases;
74
94
  }
75
95
 
76
96
  export interface ControlMutationDefaultEntry {
@@ -1 +0,0 @@
1
- {"version":3,"file":"authoring.mjs","names":["resolved: Record<string, unknown>"],"sources":["../src/framework-authoring.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\n\nexport type AuthoringArgRef = {\n readonly kind: 'arg';\n readonly index: number;\n readonly path?: readonly string[];\n readonly default?: AuthoringTemplateValue;\n};\n\nexport type AuthoringTemplateValue =\n | string\n | number\n | boolean\n | null\n | AuthoringArgRef\n | readonly AuthoringTemplateValue[]\n | { readonly [key: string]: AuthoringTemplateValue };\n\ninterface AuthoringArgumentDescriptorCommon {\n readonly name?: string;\n readonly optional?: boolean;\n}\n\nexport type AuthoringArgumentDescriptor = AuthoringArgumentDescriptorCommon &\n (\n | { readonly kind: 'string' }\n | {\n readonly kind: 'number';\n readonly integer?: boolean;\n readonly minimum?: number;\n readonly maximum?: number;\n }\n | { readonly kind: 'stringArray' }\n | {\n readonly kind: 'object';\n readonly properties: Record<string, AuthoringArgumentDescriptor>;\n }\n );\n\nexport interface AuthoringStorageTypeTemplate {\n readonly codecId: string;\n readonly nativeType: AuthoringTemplateValue;\n readonly typeParams?: Record<string, AuthoringTemplateValue>;\n}\n\nexport interface AuthoringTypeConstructorDescriptor {\n readonly kind: 'typeConstructor';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringStorageTypeTemplate;\n}\n\nexport interface AuthoringColumnDefaultTemplateLiteral {\n readonly kind: 'literal';\n readonly value: AuthoringTemplateValue;\n}\n\nexport interface AuthoringColumnDefaultTemplateFunction {\n readonly kind: 'function';\n readonly expression: AuthoringTemplateValue;\n}\n\nexport type AuthoringColumnDefaultTemplate =\n | AuthoringColumnDefaultTemplateLiteral\n | AuthoringColumnDefaultTemplateFunction;\n\nexport interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {\n readonly nullable?: boolean;\n readonly default?: AuthoringColumnDefaultTemplate;\n readonly executionDefault?: AuthoringTemplateValue;\n readonly id?: boolean;\n readonly unique?: boolean;\n}\n\nexport interface AuthoringFieldPresetDescriptor {\n readonly kind: 'fieldPreset';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringFieldPresetOutput;\n}\n\nexport type AuthoringTypeNamespace = {\n readonly [name: string]: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace;\n};\n\nexport type AuthoringFieldNamespace = {\n readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;\n};\n\nexport interface AuthoringContributions {\n readonly type?: AuthoringTypeNamespace;\n readonly field?: AuthoringFieldNamespace;\n}\n\nexport function isAuthoringArgRef(value: unknown): value is AuthoringArgRef {\n if (typeof value !== 'object' || value === null || (value as { kind?: unknown }).kind !== 'arg') {\n return false;\n }\n const { index, path } = value as { index?: unknown; path?: unknown };\n if (typeof index !== 'number' || !Number.isInteger(index) || index < 0) {\n return false;\n }\n if (path !== undefined && (!Array.isArray(path) || path.some((s) => typeof s !== 'string'))) {\n return false;\n }\n return true;\n}\n\nfunction isAuthoringTemplateRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function isAuthoringTypeConstructorDescriptor(\n value: unknown,\n): value is AuthoringTypeConstructorDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'typeConstructor' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function isAuthoringFieldPresetDescriptor(\n value: unknown,\n): value is AuthoringFieldPresetDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'fieldPreset' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function resolveAuthoringTemplateValue(\n template: AuthoringTemplateValue,\n args: readonly unknown[],\n): unknown {\n if (isAuthoringArgRef(template)) {\n let value = args[template.index];\n\n for (const segment of template.path ?? []) {\n if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) {\n value = undefined;\n break;\n }\n value = (value as Record<string, unknown>)[segment];\n }\n\n if (value === undefined && template.default !== undefined) {\n return resolveAuthoringTemplateValue(template.default, args);\n }\n\n return value;\n }\n if (Array.isArray(template)) {\n return template.map((value) => resolveAuthoringTemplateValue(value, args));\n }\n if (typeof template === 'object' && template !== null) {\n const resolved: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(template)) {\n const resolvedValue = resolveAuthoringTemplateValue(value, args);\n if (resolvedValue !== undefined) {\n resolved[key] = resolvedValue;\n }\n }\n return resolved;\n }\n return template;\n}\n\nfunction validateAuthoringArgument(\n descriptor: AuthoringArgumentDescriptor,\n value: unknown,\n path: string,\n): void {\n if (value === undefined) {\n if (descriptor.optional) {\n return;\n }\n throw new Error(`Missing required authoring helper argument at ${path}`);\n }\n\n if (descriptor.kind === 'string') {\n if (typeof value !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be a string`);\n }\n return;\n }\n\n if (descriptor.kind === 'stringArray') {\n if (!Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n }\n return;\n }\n\n if (descriptor.kind === 'object') {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an object`);\n }\n\n const input = value as Record<string, unknown>;\n const expectedKeys = new Set(Object.keys(descriptor.properties));\n\n for (const key of Object.keys(input)) {\n if (!expectedKeys.has(key)) {\n throw new Error(`Authoring helper argument at ${path} contains unknown property \"${key}\"`);\n }\n }\n\n for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) {\n validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);\n }\n\n return;\n }\n\n if (typeof value !== 'number' || Number.isNaN(value)) {\n throw new Error(`Authoring helper argument at ${path} must be a number`);\n }\n\n if (descriptor.integer && !Number.isInteger(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an integer`);\n }\n if (descriptor.minimum !== undefined && value < descriptor.minimum) {\n throw new Error(\n `Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`,\n );\n }\n if (descriptor.maximum !== undefined && value > descriptor.maximum) {\n throw new Error(\n `Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`,\n );\n }\n}\n\nexport function validateAuthoringHelperArguments(\n helperPath: string,\n descriptors: readonly AuthoringArgumentDescriptor[] | undefined,\n args: readonly unknown[],\n): void {\n const expected = descriptors ?? [];\n const minimumArgs = expected.reduce(\n (count, descriptor, index) => (descriptor.optional ? count : index + 1),\n 0,\n );\n if (args.length < minimumArgs || args.length > expected.length) {\n throw new Error(\n `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`,\n );\n }\n\n expected.forEach((descriptor, index) => {\n validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);\n });\n}\n\nfunction resolveAuthoringStorageTypeTemplate(\n template: AuthoringStorageTypeTemplate,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n const nativeType = resolveAuthoringTemplateValue(template.nativeType, args);\n if (typeof nativeType !== 'string') {\n throw new Error(\n `Resolved authoring nativeType must be a string for codec \"${template.codecId}\", received ${String(nativeType)}`,\n );\n }\n const typeParams =\n template.typeParams === undefined\n ? undefined\n : resolveAuthoringTemplateValue(template.typeParams, args);\n if (typeParams !== undefined && !isAuthoringTemplateRecord(typeParams)) {\n throw new Error(\n `Resolved authoring typeParams must be an object for codec \"${template.codecId}\", received ${String(typeParams)}`,\n );\n }\n\n return {\n codecId: template.codecId,\n nativeType,\n ...(typeParams === undefined ? {} : { typeParams }),\n };\n}\n\nfunction resolveAuthoringColumnDefaultTemplate(\n template: AuthoringColumnDefaultTemplate,\n args: readonly unknown[],\n):\n | {\n readonly kind: 'literal';\n readonly value: unknown;\n }\n | {\n readonly kind: 'function';\n readonly expression: string;\n } {\n if (template.kind === 'literal') {\n const value = resolveAuthoringTemplateValue(template.value, args);\n if (value === undefined) {\n throw new Error('Resolved authoring literal default must not be undefined');\n }\n return {\n kind: 'literal',\n value,\n };\n }\n\n const expression = resolveAuthoringTemplateValue(template.expression, args);\n if (expression === undefined || (typeof expression === 'object' && expression !== null)) {\n throw new Error(\n `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`,\n );\n }\n return {\n kind: 'function',\n expression: String(expression),\n };\n}\n\nexport function instantiateAuthoringTypeConstructor(\n descriptor: AuthoringTypeConstructorDescriptor,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n return resolveAuthoringStorageTypeTemplate(descriptor.output, args);\n}\n\nexport function instantiateAuthoringFieldPreset(\n descriptor: AuthoringFieldPresetDescriptor,\n args: readonly unknown[],\n): {\n readonly descriptor: {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n };\n readonly nullable: boolean;\n readonly default?:\n | {\n readonly kind: 'literal';\n readonly value: unknown;\n }\n | {\n readonly kind: 'function';\n readonly expression: string;\n };\n readonly executionDefault?: unknown;\n readonly id: boolean;\n readonly unique: boolean;\n} {\n return {\n descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),\n nullable: descriptor.output.nullable ?? false,\n ...ifDefined(\n 'default',\n descriptor.output.default !== undefined\n ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args)\n : undefined,\n ),\n ...ifDefined(\n 'executionDefault',\n descriptor.output.executionDefault !== undefined\n ? resolveAuthoringTemplateValue(descriptor.output.executionDefault, args)\n : undefined,\n ),\n id: descriptor.output.id ?? false,\n unique: descriptor.output.unique ?? false,\n };\n}\n"],"mappings":";;;AA4FA,SAAgB,kBAAkB,OA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A2D;AAE7E,SAAO;GACL,MAAM;GACN;GACD;;CAGH,MAAM,aAAa,8BAA8B,SAAS,YAAY,KAAK;AAC3E,KAAI,eAAe,UAAc,OAAO,eAAe,YAAY,eAAe,KAChF,OAAM,IAAI,MACR,wFAAwF,OAAO,WAAW,GAC3G;AAEH,QAAO;EACL,MAAM;EACN,YAAY,OAAO,WAAW;EAC/B;;AAGH,SAAgB,oCACd,YACA,MAKA;AACA,QAAO,oCAAoC,WAAW,QAAQ,KAAK;;AAGrE,SAAgB,gCACd,YACA,MAoBA;AACA,QAAO;EACL,YAAY,oCAAoC,WAAW,QAAQ,KAAK;EACxE,UAAU,WAAW,OAAO,YAAY;EACxC,GAAG,UACD,WACA,WAAW,OAAO,YAAY,SAC1B,sCAAsC,WAAW,OAAO,SAAS,KAAK,GACtE,OACL;EACD,GAAG,UACD,oBACA,WAAW,OAAO,qBAAqB,SACnC,8BAA8B,WAAW,OAAO,kBAAkB,KAAK,GACvE,OACL;EACD,IAAI,WAAW,OAAO,MAAM;EAC5B,QAAQ,WAAW,OAAO,UAAU;EACrC"}
@@ -1,58 +0,0 @@
1
- import { JsonValue } from "@prisma-next/contract/types";
2
-
3
- //#region src/codec-types.d.ts
4
- type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
5
- /**
6
- * A codec is the contract between an application value and its on-wire and
7
- * on-contract-disk representations.
8
- *
9
- * The author's mental model is two JS-side types — `TInput` (the
10
- * application JS type) and `TWire` (the database driver wire format) —
11
- * plus `JsonValue` for build-time contract artifacts. The codec translates
12
- * `TInput` to `TWire` on writes and back on reads, and to/from `JsonValue`
13
- * during contract emission and loading.
14
- *
15
- * Three representations participate:
16
- * - **Input** (`TInput`): the JS type at the application boundary.
17
- * - **Wire** (`TWire`): the format exchanged with the database driver.
18
- * - **JSON** (`JsonValue`): a JSON-safe form used in contract artifacts.
19
- *
20
- * Codec methods split into two groups:
21
- *
22
- * - **Query-time** methods (`encode`, `decode`) run per row/parameter at the
23
- * IO boundary; they are required and Promise-returning. The per-family
24
- * codec factory accepts sync or async author functions and lifts sync
25
- * ones to Promise-shaped methods automatically.
26
- * - **Build-time** methods (`encodeJson`, `decodeJson`, `renderOutputType`)
27
- * run when the contract is serialized, loaded, or when client types are
28
- * emitted. They stay synchronous so contract validation and client
29
- * construction are synchronous.
30
- *
31
- * Target-family codec interfaces extend this base with target-shaped
32
- * metadata.
33
- */
34
- interface Codec<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TInput = unknown> {
35
- /** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). */
36
- readonly id: Id;
37
- /** Database-native type names this codec handles (e.g. `['timestamptz']`). */
38
- readonly targetTypes: readonly string[];
39
- /** Semantic traits for operator gating (e.g. equality, order, numeric). */
40
- readonly traits?: TTraits;
41
- /** Converts a JS value to the wire format expected by the database driver. Always Promise-returning at the boundary. */
42
- encode(value: TInput): Promise<TWire>;
43
- /** Converts a wire value from the database driver into the JS application type. Always Promise-returning at the boundary. */
44
- decode(wire: TWire): Promise<TInput>;
45
- /** Converts a JS value to a JSON-safe representation for contract serialization. Synchronous; called during contract emission. */
46
- encodeJson(value: TInput): JsonValue;
47
- /** Converts a JSON representation back to the JS input type. Synchronous; called during contract loading via `validateContract`. */
48
- decodeJson(json: JsonValue): TInput;
49
- /** Produces the TypeScript output type expression for a field given its `typeParams`. Synchronous; used during contract.d.ts emission. */
50
- renderOutputType?(typeParams: Record<string, unknown>): string | undefined;
51
- }
52
- interface CodecLookup {
53
- get(id: string): Codec | undefined;
54
- }
55
- declare const emptyCodecLookup: CodecLookup;
56
- //#endregion
57
- export { emptyCodecLookup as i, CodecLookup as n, CodecTrait as r, Codec as t };
58
- //# sourceMappingURL=codec-types-DQ1Agjom.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types-DQ1Agjom.d.mts","names":[],"sources":["../src/codec-types.ts"],"sourcesContent":[],"mappings":";;;KAEY,UAAA;;AAAZ;AA+BA;;;;;;;;;;;;;;;;;AAwBA;AAIA;;;;;;;;;UA5BiB,2DAEU,wBAAwB;;eAKpC;;;;oBAIK;;gBAEJ,SAAS,QAAQ;;eAElB,QAAQ,QAAQ;;oBAEX,SAAS;;mBAEV,YAAY;;gCAEC;;UAGf,WAAA;mBACE;;cAGN,kBAAkB"}
@@ -1,24 +0,0 @@
1
- import { t as TypesImportSpec } from "./types-import-spec-C4sc7wbb.mjs";
2
- import { Contract, ContractModel } from "@prisma-next/contract/types";
3
-
4
- //#region src/emission-types.d.ts
5
- interface GenerateContractTypesOptions {
6
- readonly queryOperationTypeImports?: ReadonlyArray<TypesImportSpec>;
7
- }
8
- interface ValidationContext {
9
- readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
10
- readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
11
- readonly extensionIds?: ReadonlyArray<string>;
12
- }
13
- interface EmissionSpi {
14
- readonly id: string;
15
- generateStorageType(contract: Contract, storageHashTypeName: string): string;
16
- generateModelStorageType(modelName: string, model: ContractModel): string;
17
- getFamilyImports(): string[];
18
- getFamilyTypeAliases(options?: GenerateContractTypesOptions): string;
19
- getTypeMapsExpression(): string;
20
- getContractWrapper(contractBaseName: string, typeMapsName: string): string;
21
- }
22
- //#endregion
23
- export { GenerateContractTypesOptions as n, ValidationContext as r, EmissionSpi as t };
24
- //# sourceMappingURL=emission-types-BPAALJbF.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emission-types-BPAALJbF.d.mts","names":[],"sources":["../src/emission-types.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,4BAAA;uCACsB,cAAc;AADrD;AAIiB,UAAA,iBAAA,CAAiB;EACU,SAAA,gBAAA,CAAA,EAAd,aAAc,CAAA,eAAA,CAAA;EAAd,SAAA,oBAAA,CAAA,EACI,aADJ,CACkB,eADlB,CAAA;EACkB,SAAA,YAAA,CAAA,EACtB,aADsB,CAAA,MAAA,CAAA;;AACtB,UAGT,WAAA,CAH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