@prisma-next/framework-components 0.13.0-dev.27 → 0.13.0-dev.29

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.
@@ -133,30 +133,6 @@ export interface PslModel {
133
133
  readonly comment?: string;
134
134
  }
135
135
 
136
- export interface PslEnumValue {
137
- readonly kind: 'enumValue';
138
- readonly name: string;
139
- /**
140
- * Optional storage label for the enum member, captured from a trailing
141
- * `@map("...")` attribute on the member line. The parser populates this
142
- * when the source PSL carries an explicit `@map`. Producers (e.g.
143
- * `sqlSchemaIrToPslAst`) leave it unset; the printer emits `@map(...)`
144
- * automatically when normalisation would change the printed member name
145
- * (so an enum value `'in-progress'` becomes `inProgress @map("in-progress")`
146
- * in PSL, preserving the round-trip).
147
- */
148
- readonly mapName?: string;
149
- readonly span: PslSpan;
150
- }
151
-
152
- export interface PslEnum {
153
- readonly kind: 'enum';
154
- readonly name: string;
155
- readonly values: readonly PslEnumValue[];
156
- readonly attributes: readonly PslAttribute[];
157
- readonly span: PslSpan;
158
- }
159
-
160
136
  /**
161
137
  * A reusable group of fields embedded in a model (a `type Name { … }` block) —
162
138
  * e.g. a MongoDB embedded document or a Postgres composite type. Unlike
@@ -205,7 +181,7 @@ export interface PslTypesBlock {
205
181
  export const UNSPECIFIED_PSL_NAMESPACE_ID = '__unspecified__';
206
182
 
207
183
  /** A value in {@link PslNamespace.entries}: a built-in entity node or an extension-contributed {@link PslExtensionBlock}. */
208
- export type PslNamespaceEntry = PslModel | PslEnum | PslCompositeType | PslExtensionBlock;
184
+ export type PslNamespaceEntry = PslModel | PslCompositeType | PslExtensionBlock;
209
185
 
210
186
  /**
211
187
  * A namespace block, or the parser's synthesised `__unspecified__` bucket for
@@ -223,8 +199,6 @@ export interface PslNamespace {
223
199
  readonly entries: Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>>;
224
200
  /** Built-in models, from `entries['model']`. Extension kinds: {@link namespacePslExtensionBlocks}. */
225
201
  readonly models: readonly PslModel[];
226
- /** Built-in enums, from `entries['enum']`. */
227
- readonly enums: readonly PslEnum[];
228
202
  /** Built-in composite types, from `entries['compositeType']`. */
229
203
  readonly compositeTypes: readonly PslCompositeType[];
230
204
  readonly span: PslSpan;
@@ -258,12 +232,6 @@ class PslNamespaceNode implements PslNamespace {
258
232
  );
259
233
  }
260
234
 
261
- get enums(): readonly PslEnum[] {
262
- return blindCast<readonly PslEnum[], 'entries[enum] holds only PslEnum by construction'>(
263
- Object.values(this.entries['enum'] ?? {}),
264
- );
265
- }
266
-
267
235
  get compositeTypes(): readonly PslCompositeType[] {
268
236
  return blindCast<
269
237
  readonly PslCompositeType[],
@@ -289,7 +257,6 @@ export function makePslNamespace(init: {
289
257
  */
290
258
  export function makePslNamespaceEntries(
291
259
  models: readonly PslModel[],
292
- enums: readonly PslEnum[],
293
260
  compositeTypes: readonly PslCompositeType[],
294
261
  extensionBlocks: readonly PslExtensionBlock[],
295
262
  ): Readonly<Record<string, Readonly<Record<string, PslNamespaceEntry>>>> {
@@ -303,14 +270,6 @@ export function makePslNamespaceEntries(
303
270
  container['model'] = Object.freeze(map);
304
271
  }
305
272
 
306
- if (enums.length > 0) {
307
- const map: Record<string, PslEnum> = {};
308
- for (const e of enums) {
309
- map[e.name] = e;
310
- }
311
- container['enum'] = Object.freeze(map);
312
- }
313
-
314
273
  if (compositeTypes.length > 0) {
315
274
  const map: Record<string, PslCompositeType> = {};
316
275
  for (const ct of compositeTypes) {
@@ -353,17 +312,6 @@ export function flatPslModels(ast: PslDocumentAst): readonly PslModel[] {
353
312
  );
354
313
  }
355
314
 
356
- /**
357
- * Returns all enums from every namespace in document order.
358
- */
359
- export function flatPslEnums(ast: PslDocumentAst): readonly PslEnum[] {
360
- return ast.namespaces.flatMap((ns) =>
361
- blindCast<PslEnum[], 'enum kind map contains only PslEnum by construction'>(
362
- Object.values(ns.entries['enum'] ?? {}),
363
- ),
364
- );
365
- }
366
-
367
315
  /**
368
316
  * Returns all composite types from every namespace in document order.
369
317
  */
@@ -382,20 +330,18 @@ export function flatPslCompositeTypes(ast: PslDocumentAst): readonly PslComposit
382
330
  * that is **not** in this set was contributed by an extension-block descriptor.
383
331
  *
384
332
  * Built-in keys match the PSL keyword used on each block type:
385
- * `'model'`, `'enum'`, `'compositeType'`.
333
+ * `'model'`, `'compositeType'`. The `'enum'` keyword is claimed by the
334
+ * extension-block grammar via a registered descriptor, so `entries['enum']`
335
+ * holds `PslExtensionBlock` nodes and is returned by `namespacePslExtensionBlocks`.
386
336
  */
387
- export const BUILTIN_PSL_KIND_KEYS: ReadonlySet<string> = new Set([
388
- 'model',
389
- 'enum',
390
- 'compositeType',
391
- ]);
337
+ export const BUILTIN_PSL_KIND_KEYS: ReadonlySet<string> = new Set(['model', 'compositeType']);
392
338
 
393
339
  /**
394
340
  * Returns all extension-contributed blocks in the given namespace, in
395
341
  * insertion order (the order the parser encountered them in the source).
396
342
  *
397
343
  * Reads from `namespace.entries`, skipping the built-in kind keys
398
- * (`'model'`, `'enum'`, `'compositeType'`). All remaining kind maps contain
344
+ * (`'model'`, `'compositeType'`). All remaining kind maps contain
399
345
  * only `PslExtensionBlock` nodes by construction (see `makePslNamespaceEntries`).
400
346
  */
401
347
  export function namespacePslExtensionBlocks(ns: PslNamespace): readonly PslExtensionBlock[] {
@@ -43,6 +43,8 @@ export interface CodecDescriptor<P = void> {
43
43
  readonly isParameterized: boolean;
44
44
  /** Emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for given params (e.g. `Vector<1536>`). Optional; absent renderers cause the emitter to fall back to the codec's base output type. Non-parameterized codecs typically omit it. */
45
45
  readonly renderOutputType?: (params: P) => string | undefined;
46
+ /** Emit-path string renderer for the `contract.d.ts` *input* position (create/update values). Returns the TypeScript input type expression for given params. Optional; absent renderers fall back to the codec's base input type. A codec supplies this when its write type is narrower than the generic codec input — e.g. an enum whose input should be the literal member union, not `string`. */
47
+ readonly renderInputType?: (params: P) => string | undefined;
46
48
  /** The curried higher-order codec. For non-parameterized codecs, the factory is constant — every call returns the same shared codec instance. For parameterized codecs, the factory is called once per `storage.types` instance (or once per inline-`typeParams` column), with `ctx` carrying the column set the resulting codec serves. */
47
49
  readonly factory: (params: P) => (ctx: CodecInstanceContext) => Codec;
48
50
  }
@@ -78,6 +80,9 @@ export abstract class CodecDescriptorImpl<TParams = void> implements CodecDescri
78
80
  /** Optional emit-path string renderer for `contract.d.ts`. Returns the TypeScript output type expression for the given params (e.g. `Vector<1536>`). Non-parameterized codecs typically omit it. */
79
81
  renderOutputType?(params: TParams): string | undefined;
80
82
 
83
+ /** Optional emit-path string renderer for the `contract.d.ts` input position. Returns the TypeScript input type expression for the given params; supplied when the write type is narrower than the generic codec input (e.g. an enum's literal member union). */
84
+ renderInputType?(params: TParams): string | undefined;
85
+
81
86
  /**
82
87
  * Materialize a curried codec factory for the given params. Concrete subclasses override with a typed return type (e.g. `factory<N>(params: { length: N }): (ctx) => VectorCodec<N>`); per-codec helpers read the typed return at the *direct* call site, which is what preserves method-level generics. Type extraction (e.g. `ReturnType<D['factory']>`) widens method generics to their constraint — that's why the column-helper surface is per-codec, not polymorphic.
83
88
  */
@@ -46,6 +46,8 @@ export interface CodecLookup {
46
46
  targetTypesFor(id: string): readonly string[] | undefined;
47
47
  metaFor(id: string): CodecMeta | undefined;
48
48
  renderOutputTypeFor(id: string, params: Record<string, unknown>): string | undefined;
49
+ /** Codec-id-keyed `renderInputType` renderer for the `contract.d.ts` input position. Optional so existing lookups need not provide it; returns `undefined` when the codec renders no custom input type or the id is unknown. */
50
+ renderInputTypeFor?(id: string, params: Record<string, unknown>): string | undefined;
49
51
  }
50
52
 
51
53
  /**
@@ -160,7 +160,7 @@ export interface PslBlockParamList {
160
160
  * - `option` → `PslExtensionBlockParamOption` — the chosen token.
161
161
  * - `list` → `PslExtensionBlockParamList` — ordered list of the above.
162
162
  * - `bare` → `PslExtensionBlockParamBare` — a bare identifier line with no
163
- * `= value` (e.g. `Low` in an enum2 block). The name is the key in
163
+ * `= value` (e.g. `Low` in an enum block). The name is the key in
164
164
  * `parameters`; the interpreting consumer decides the default value.
165
165
  *
166
166
  * These shapes are intentionally minimal. The validator and lowering refine
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types-29q8imKF.d.mts","names":[],"sources":["../src/shared/codec-descriptor.ts","../src/shared/codec.ts","../src/shared/codec-types.ts"],"mappings":";;;;;;;;;;;;;;;UA8BiB,eAAA;EAUN;EAAA,SARA,OAAA;EAQ+B;EAAA,SAN/B,MAAA,WAAiB,UAAA;EAUjB;EAAA,SARA,WAAA;EAQoB;EAAA,SANpB,IAAA,GAAO,SAAA;EAQW;EAAA,SANlB,YAAA,EAAc,gBAAA,CAAiB,CAAA;EAMD;EAAA,SAJ9B,eAAA;EAIuD;EAAA,SAFvD,gBAAA,IAAoB,MAAA,EAAQ,CAAA;EAEgC;EAAA,SAA5D,OAAA,GAAU,MAAA,EAAQ,CAAA,MAAO,GAAA,EAAK,oBAAA,KAAyB,KAAA;AAAA;;;AASlB;AAShD;;KATY,kBAAA,GAAqB,eAAe;;;;;;;;uBAS1B,mBAAA,4BAA+C,eAAA,CAAgB,OAAA;EAAA,kBACjE,OAAA;EAAA,kBACA,MAAA,WAAiB,UAAA;EAAA,kBACjB,WAAA;EAAA,SACT,IAAA,GAAO,SAAA;EAAA,kBAEE,YAAA,EAAc,gBAAA,CAAiB,OAAA;EANT;EAAA,IASpC,eAAA;EAT+E;EAcnF,gBAAA,EAAkB,MAAA,EAAQ,OAAA;EAZR;;;EAAA,SAiBT,OAAA,CACP,MAAA,EAAQ,OAAA,IACN,GAAA,EAAK,oBAAA,KAAyB,KAAA,kBAAuB,UAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;UCpD1C,KAAA,sDAEU,UAAA,cAAwB,UAAA;EDWtB;EAAA,SCNlB,EAAA,EAAI,EAAA;EDM0B;EAAA,SCJ9B,aAAA,GAAgB,OAAA;EDIuC;ECFhE,MAAA,CAAO,KAAA,EAAO,MAAA,EAAQ,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