@prisma-next/runtime-executor 0.3.0-dev.1 → 0.3.0-dev.100

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.
@@ -0,0 +1,16 @@
1
+ import type { ExecutionPlan } from '@prisma-next/contract/types';
2
+
3
+ export interface MarkerStatement {
4
+ readonly sql: string;
5
+ readonly params: readonly unknown[];
6
+ }
7
+
8
+ export interface MarkerReader {
9
+ readMarkerStatement(): MarkerStatement;
10
+ }
11
+
12
+ export interface RuntimeFamilyAdapter<TContract = unknown> {
13
+ readonly contract: TContract;
14
+ readonly markerReader: MarkerReader;
15
+ validatePlan(plan: ExecutionPlan, contract: TContract): void;
16
+ }
package/dist/index.d.ts DELETED
@@ -1,157 +0,0 @@
1
- import { ExecutionPlan, ContractMarkerRecord } from '@prisma-next/contract/types';
2
- export { ContractMarkerRecord } from '@prisma-next/contract/types';
3
- import { OperationRegistry } from '@prisma-next/operations';
4
-
5
- /**
6
- * Custom async iterable result that extends AsyncIterable with a toArray() method.
7
- * This provides a convenient way to collect all results from an async iterator.
8
- */
9
- declare class AsyncIterableResult<Row> implements AsyncIterable<Row> {
10
- private readonly generator;
11
- private consumed;
12
- private consumedBy;
13
- constructor(generator: AsyncGenerator<Row, void, unknown>);
14
- [Symbol.asyncIterator](): AsyncIterator<Row>;
15
- /**
16
- * Collects all values from the async iterator into an array.
17
- * Once called, the iterator is consumed and cannot be reused.
18
- */
19
- toArray(): Promise<Row[]>;
20
- }
21
-
22
- interface RuntimeErrorEnvelope extends Error {
23
- readonly code: string;
24
- readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME';
25
- readonly severity: 'error';
26
- readonly details?: Record<string, unknown>;
27
- }
28
- declare function runtimeError(code: string, message: string, details?: Record<string, unknown>): RuntimeErrorEnvelope;
29
-
30
- declare function computeSqlFingerprint(sql: string): string;
31
-
32
- type LintSeverity = 'error' | 'warn';
33
- type BudgetSeverity = 'error' | 'warn';
34
- interface LintFinding {
35
- readonly code: `LINT.${string}`;
36
- readonly severity: LintSeverity;
37
- readonly message: string;
38
- readonly details?: Record<string, unknown>;
39
- }
40
- interface BudgetFinding {
41
- readonly code: `BUDGET.${string}`;
42
- readonly severity: BudgetSeverity;
43
- readonly message: string;
44
- readonly details?: Record<string, unknown>;
45
- }
46
- interface RawGuardrailConfig {
47
- readonly budgets?: {
48
- readonly unboundedSelectSeverity?: BudgetSeverity;
49
- readonly estimatedRows?: number;
50
- };
51
- }
52
- interface RawGuardrailResult {
53
- readonly lints: LintFinding[];
54
- readonly budgets: BudgetFinding[];
55
- readonly statement: 'select' | 'mutation' | 'other';
56
- }
57
- declare function evaluateRawGuardrails(plan: ExecutionPlan, config?: RawGuardrailConfig): RawGuardrailResult;
58
-
59
- declare function parseContractMarkerRow(row: unknown): ContractMarkerRecord;
60
-
61
- type Severity = 'error' | 'warn' | 'info';
62
- interface Log {
63
- info(event: unknown): void;
64
- warn(event: unknown): void;
65
- error(event: unknown): void;
66
- }
67
- interface PluginContext<TContract = unknown, TAdapter = unknown, TDriver = unknown> {
68
- readonly contract: TContract;
69
- readonly adapter: TAdapter;
70
- readonly driver: TDriver;
71
- readonly mode: 'strict' | 'permissive';
72
- readonly now: () => number;
73
- readonly log: Log;
74
- }
75
- interface AfterExecuteResult {
76
- readonly rowCount: number;
77
- readonly latencyMs: number;
78
- readonly completed: boolean;
79
- }
80
- interface Plugin<TContract = unknown, TAdapter = unknown, TDriver = unknown> {
81
- readonly name: string;
82
- beforeExecute?(plan: ExecutionPlan, ctx: PluginContext<TContract, TAdapter, TDriver>): Promise<void>;
83
- onRow?(row: Record<string, unknown>, plan: ExecutionPlan, ctx: PluginContext<TContract, TAdapter, TDriver>): Promise<void>;
84
- afterExecute?(plan: ExecutionPlan, result: AfterExecuteResult, ctx: PluginContext<TContract, TAdapter, TDriver>): Promise<void>;
85
- }
86
-
87
- interface BudgetsOptions {
88
- readonly maxRows?: number;
89
- readonly defaultTableRows?: number;
90
- readonly tableRows?: Record<string, number>;
91
- readonly maxLatencyMs?: number;
92
- readonly severities?: {
93
- readonly rowCount?: 'warn' | 'error';
94
- readonly latency?: 'warn' | 'error';
95
- };
96
- readonly explain?: {
97
- readonly enabled?: boolean;
98
- };
99
- }
100
- declare function budgets<TContract = unknown, TAdapter = unknown, TDriver = unknown>(options?: BudgetsOptions): Plugin<TContract, TAdapter, TDriver>;
101
-
102
- interface LintsOptions {
103
- readonly severities?: {
104
- readonly selectStar?: 'warn' | 'error';
105
- readonly noLimit?: 'warn' | 'error';
106
- readonly readOnlyMutation?: 'warn' | 'error';
107
- readonly unindexedPredicate?: 'warn' | 'error';
108
- };
109
- }
110
- declare function lints<TContract = unknown, TAdapter = unknown, TDriver = unknown>(options?: LintsOptions): Plugin<TContract, TAdapter, TDriver>;
111
-
112
- interface MarkerStatement {
113
- readonly sql: string;
114
- readonly params: readonly unknown[];
115
- }
116
- interface MarkerReader {
117
- readMarkerStatement(): MarkerStatement;
118
- }
119
- interface RuntimeFamilyAdapter<TContract = unknown> {
120
- readonly contract: TContract;
121
- readonly markerReader: MarkerReader;
122
- validatePlan(plan: ExecutionPlan, contract: TContract): void;
123
- }
124
-
125
- interface RuntimeVerifyOptions {
126
- readonly mode: 'onFirstUse' | 'startup' | 'always';
127
- readonly requireMarker: boolean;
128
- }
129
- type TelemetryOutcome = 'success' | 'runtime-error';
130
- interface RuntimeTelemetryEvent {
131
- readonly lane: string;
132
- readonly target: string;
133
- readonly fingerprint: string;
134
- readonly outcome: TelemetryOutcome;
135
- readonly durationMs?: number;
136
- }
137
- interface RuntimeCoreOptions<TContract = unknown, TAdapter = unknown, TDriver = unknown> {
138
- readonly familyAdapter: RuntimeFamilyAdapter<TContract>;
139
- readonly driver: TDriver;
140
- readonly verify: RuntimeVerifyOptions;
141
- readonly plugins?: readonly Plugin<TContract, TAdapter, TDriver>[];
142
- readonly mode?: 'strict' | 'permissive';
143
- readonly log?: Log;
144
- readonly operationRegistry: OperationRegistry;
145
- }
146
- interface RuntimeCore<TContract = unknown, TAdapter = unknown, TDriver = unknown> {
147
- readonly _typeContract?: TContract;
148
- readonly _typeAdapter?: TAdapter;
149
- readonly _typeDriver?: TDriver;
150
- execute<Row = Record<string, unknown>>(plan: ExecutionPlan<Row>): AsyncIterableResult<Row>;
151
- telemetry(): RuntimeTelemetryEvent | null;
152
- close(): Promise<void>;
153
- operations(): OperationRegistry;
154
- }
155
- declare function createRuntimeCore<TContract = unknown, TAdapter = unknown, TDriver = unknown>(options: RuntimeCoreOptions<TContract, TAdapter, TDriver>): RuntimeCore<TContract, TAdapter, TDriver>;
156
-
157
- export { type AfterExecuteResult, AsyncIterableResult, type BudgetFinding, type BudgetsOptions, type LintFinding, type LintsOptions, type Log, type MarkerReader, type MarkerStatement, type Plugin, type PluginContext, type RawGuardrailResult, type RuntimeCore, type RuntimeCoreOptions, type RuntimeErrorEnvelope, type RuntimeFamilyAdapter, type RuntimeTelemetryEvent, type RuntimeVerifyOptions, type Severity, type TelemetryOutcome, budgets, computeSqlFingerprint, createRuntimeCore, evaluateRawGuardrails, lints, parseContractMarkerRow, runtimeError };