@prisma-next/framework-components 0.5.0-dev.2 → 0.5.0-dev.20

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.
@@ -1,5 +1,5 @@
1
- import type { PlanMeta } from '@prisma-next/contract/types';
2
1
  import type { AsyncIterableResult } from './async-iterable-result';
2
+ import type { QueryPlan } from './query-plan';
3
3
  import { runtimeError } from './runtime-error';
4
4
 
5
5
  export interface RuntimeLog {
@@ -22,18 +22,22 @@ export interface AfterExecuteResult {
22
22
  readonly completed: boolean;
23
23
  }
24
24
 
25
- export interface RuntimeMiddleware {
25
+ /**
26
+ * Family-agnostic middleware SPI parameterized over the plan marker.
27
+ *
28
+ * `TPlan` defaults to the framework `QueryPlan` marker so a generic
29
+ * middleware (e.g. cross-family telemetry) can be authored without
30
+ * naming a family. Family-specific middleware (`SqlMiddleware`,
31
+ * `MongoMiddleware`) narrow `TPlan` to their concrete plan type.
32
+ */
33
+ export interface RuntimeMiddleware<TPlan extends QueryPlan = QueryPlan> {
26
34
  readonly name: string;
27
35
  readonly familyId?: string;
28
36
  readonly targetId?: string;
29
- beforeExecute?(plan: { readonly meta: PlanMeta }, ctx: RuntimeMiddlewareContext): Promise<void>;
30
- onRow?(
31
- row: Record<string, unknown>,
32
- plan: { readonly meta: PlanMeta },
33
- ctx: RuntimeMiddlewareContext,
34
- ): Promise<void>;
37
+ beforeExecute?(plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<void>;
38
+ onRow?(row: Record<string, unknown>, plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<void>;
35
39
  afterExecute?(
36
- plan: { readonly meta: PlanMeta },
40
+ plan: TPlan,
37
41
  result: AfterExecuteResult,
38
42
  ctx: RuntimeMiddlewareContext,
39
43
  ): Promise<void>;
@@ -45,9 +49,9 @@ export interface RuntimeMiddleware {
45
49
  * Mongo structurally (due to its phantom Row parameter using a unique symbol).
46
50
  *
47
51
  * The `_row` intersection on `execute` connects the `Row` type parameter to the
48
- * plan, mirroring how `ExecutionPlan<Row>` carries a phantom `_row?: Row`.
52
+ * plan, mirroring how `QueryPlan<Row>` carries a phantom `_row?: Row`.
49
53
  */
50
- export interface RuntimeExecutor<TPlan extends { readonly meta: PlanMeta }> {
54
+ export interface RuntimeExecutor<TPlan extends QueryPlan> {
51
55
  execute<Row>(plan: TPlan & { readonly _row?: Row }): AsyncIterableResult<Row>;
52
56
  close(): Promise<void>;
53
57
  }
@@ -1,40 +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
- * Base codec interface for all target families.
7
- *
8
- * A codec maps between three representations of a value:
9
- * - **JS** (`TJs`): the JavaScript type used in application code
10
- * - **Wire** (`TWire`): the format sent to/from the database driver
11
- * - **JSON** (`JsonValue`): the JSON-safe form stored in contract artifacts
12
- *
13
- * Family-specific codec interfaces (SQL `Codec`, Mongo `MongoCodec`) extend
14
- * this base to add family-specific metadata.
15
- */
16
- interface Codec<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TJs = unknown> {
17
- /** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). */
18
- readonly id: Id;
19
- /** Database-native type names this codec handles (e.g. `['timestamptz']`). */
20
- readonly targetTypes: readonly string[];
21
- /** Semantic traits for operator gating (e.g. equality, order, numeric). */
22
- readonly traits?: TTraits;
23
- /** Converts a JS value to the wire format expected by the database driver. Optional when the driver accepts the JS type directly. */
24
- encode?(value: TJs): TWire;
25
- /** Converts a wire value from the database driver into the JS type. */
26
- decode(wire: TWire): TJs;
27
- /** Converts a JS value to a JSON-safe representation for contract serialization. Called during contract emission. */
28
- encodeJson(value: TJs): JsonValue;
29
- /** Converts a JSON representation back to the JS type. Called during contract loading via `validateContract`. */
30
- decodeJson(json: JsonValue): TJs;
31
- /** Produces the TypeScript output type expression for a field given its `typeParams`. Used during contract.d.ts emission. */
32
- renderOutputType?(typeParams: Record<string, unknown>): string | undefined;
33
- }
34
- interface CodecLookup {
35
- get(id: string): Codec | undefined;
36
- }
37
- declare const emptyCodecLookup: CodecLookup;
38
- //#endregion
39
- export { emptyCodecLookup as i, CodecLookup as n, CodecTrait as r, Codec as t };
40
- //# sourceMappingURL=codec-types-B58nCJiu.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types-B58nCJiu.d.mts","names":[],"sources":["../src/codec-types.ts"],"sourcesContent":[],"mappings":";;;KAEY,UAAA;;AAAZ;AAaA;;;;;;;;;AAiBoB,UAjBH,KAiBG,CAAA,WAAA,MAAA,GAAA,MAAA,EAAA,gBAAA,SAfO,UAeP,EAAA,GAAA,SAf+B,UAe/B,EAAA,EAAA,QAAA,OAAA,EAAA,MAAA,OAAA,CAAA,CAAA;EAAM;EAEP,SAAA,EAAA,EAZJ,EAYI;EAAY;EAEC,SAAA,WAAA,EAAA,SAAA,MAAA,EAAA;EAAM;EAGrB,SAAA,MAAW,CAAA,EAbR,OAcD;EAGN;iBAfI,MAAM;;eAER,QAAQ;;oBAEH,MAAM;;mBAEP,YAAY;;gCAEC;;UAGf,WAAA;mBACE;;cAGN,kBAAkB"}