@prisma-next/family-sql 0.1.0-pr.32.8 → 0.1.0-pr.34.1
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.
- package/README.md +1 -0
- package/dist/exports/chunk-3HYKCN35.js +89 -0
- package/dist/exports/chunk-3HYKCN35.js.map +1 -0
- package/dist/exports/control.d.ts +102 -15
- package/dist/exports/control.js +6 -104
- package/dist/exports/control.js.map +1 -1
- package/dist/exports/runtime.d.ts +2 -238
- package/dist/exports/verify.d.ts +28 -0
- package/dist/exports/verify.js +11 -0
- package/dist/exports/verify.js.map +1 -0
- package/package.json +21 -14
- package/dist/exports/index-Bi3Sr19r.d.ts +0 -28
|
@@ -1,246 +1,10 @@
|
|
|
1
1
|
import { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';
|
|
2
2
|
import { RuntimeFamilyInstance, RuntimeFamilyDescriptor, RuntimeTargetDescriptor, RuntimeAdapterDescriptor, RuntimeDriverDescriptor, RuntimeExtensionDescriptor } from '@prisma-next/core-execution-plane/types';
|
|
3
|
-
import {
|
|
3
|
+
import { RuntimeVerifyOptions, Plugin, Log } from '@prisma-next/runtime-executor';
|
|
4
4
|
import { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
5
|
-
import {
|
|
6
|
-
import { SqlLoweringSpec } from '@prisma-next/sql-operations';
|
|
5
|
+
import { Adapter, SelectAst, LoweredStatement, SqlDriver } from '@prisma-next/sql-relational-core/ast';
|
|
7
6
|
import { Extension, Runtime } from '@prisma-next/sql-runtime';
|
|
8
7
|
|
|
9
|
-
interface Log {
|
|
10
|
-
info(event: unknown): void;
|
|
11
|
-
warn(event: unknown): void;
|
|
12
|
-
error(event: unknown): void;
|
|
13
|
-
}
|
|
14
|
-
interface PluginContext<TContract = unknown, TAdapter = unknown, TDriver = unknown> {
|
|
15
|
-
readonly contract: TContract;
|
|
16
|
-
readonly adapter: TAdapter;
|
|
17
|
-
readonly driver: TDriver;
|
|
18
|
-
readonly mode: 'strict' | 'permissive';
|
|
19
|
-
readonly now: () => number;
|
|
20
|
-
readonly log: Log;
|
|
21
|
-
}
|
|
22
|
-
interface AfterExecuteResult {
|
|
23
|
-
readonly rowCount: number;
|
|
24
|
-
readonly latencyMs: number;
|
|
25
|
-
readonly completed: boolean;
|
|
26
|
-
}
|
|
27
|
-
interface Plugin<TContract = unknown, TAdapter = unknown, TDriver = unknown> {
|
|
28
|
-
readonly name: string;
|
|
29
|
-
beforeExecute?(plan: ExecutionPlan, ctx: PluginContext<TContract, TAdapter, TDriver>): Promise<void>;
|
|
30
|
-
onRow?(row: Record<string, unknown>, plan: ExecutionPlan, ctx: PluginContext<TContract, TAdapter, TDriver>): Promise<void>;
|
|
31
|
-
afterExecute?(plan: ExecutionPlan, result: AfterExecuteResult, ctx: PluginContext<TContract, TAdapter, TDriver>): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface RuntimeVerifyOptions {
|
|
35
|
-
readonly mode: 'onFirstUse' | 'startup' | 'always';
|
|
36
|
-
readonly requireMarker: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Codec metadata for database-specific type information.
|
|
41
|
-
* Used for schema introspection and verification.
|
|
42
|
-
*/
|
|
43
|
-
interface CodecMeta {
|
|
44
|
-
readonly db?: {
|
|
45
|
-
readonly sql?: {
|
|
46
|
-
readonly postgres?: {
|
|
47
|
-
readonly nativeType: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Codec interface for encoding/decoding values between wire format and JavaScript types.
|
|
54
|
-
*
|
|
55
|
-
* Codecs are pure, synchronous functions with no side effects or IO.
|
|
56
|
-
* They provide deterministic conversion between database wire types and JS values.
|
|
57
|
-
*/
|
|
58
|
-
interface Codec<Id extends string = string, TWire = unknown, TJs = unknown> {
|
|
59
|
-
/**
|
|
60
|
-
* Namespaced codec identifier in format 'namespace/name@version'
|
|
61
|
-
* Examples: 'pg/text@1', 'pg/uuid@1', 'pg/timestamptz@1'
|
|
62
|
-
*/
|
|
63
|
-
readonly id: Id;
|
|
64
|
-
/**
|
|
65
|
-
* Contract scalar type IDs that this codec can handle.
|
|
66
|
-
* Examples: ['text'], ['int4', 'float8'], ['timestamp', 'timestamptz']
|
|
67
|
-
*/
|
|
68
|
-
readonly targetTypes: readonly string[];
|
|
69
|
-
/**
|
|
70
|
-
* Optional metadata for database-specific type information.
|
|
71
|
-
* Used for schema introspection and verification.
|
|
72
|
-
*/
|
|
73
|
-
readonly meta?: CodecMeta;
|
|
74
|
-
/**
|
|
75
|
-
* Decode a wire value (from database) to JavaScript type.
|
|
76
|
-
* Must be synchronous and pure (no side effects).
|
|
77
|
-
*/
|
|
78
|
-
decode(wire: TWire): TJs;
|
|
79
|
-
/**
|
|
80
|
-
* Encode a JavaScript value to wire format (for database).
|
|
81
|
-
* Optional - if not provided, values pass through unchanged.
|
|
82
|
-
* Must be synchronous and pure (no side effects).
|
|
83
|
-
*/
|
|
84
|
-
encode?(value: TJs): TWire;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Registry interface for codecs organized by ID and by contract scalar type.
|
|
88
|
-
*
|
|
89
|
-
* The registry allows looking up codecs by their namespaced ID or by the
|
|
90
|
-
* contract scalar types they handle. Multiple codecs may handle the same
|
|
91
|
-
* scalar type; ordering in byScalar reflects preference (adapter first,
|
|
92
|
-
* then packs, then app overrides).
|
|
93
|
-
*/
|
|
94
|
-
interface CodecRegistry {
|
|
95
|
-
get(id: string): Codec<string> | undefined;
|
|
96
|
-
has(id: string): boolean;
|
|
97
|
-
getByScalar(scalar: string): readonly Codec<string>[];
|
|
98
|
-
getDefaultCodec(scalar: string): Codec<string> | undefined;
|
|
99
|
-
register(codec: Codec<string>): void;
|
|
100
|
-
[Symbol.iterator](): Iterator<Codec<string>>;
|
|
101
|
-
values(): IterableIterator<Codec<string>>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
type AdapterTarget = string;
|
|
105
|
-
interface AdapterProfile<TTarget extends AdapterTarget = AdapterTarget> {
|
|
106
|
-
readonly id: string;
|
|
107
|
-
readonly target: TTarget;
|
|
108
|
-
readonly capabilities: Record<string, unknown>;
|
|
109
|
-
/**
|
|
110
|
-
* Returns the adapter's default codec registry.
|
|
111
|
-
* The registry contains codecs provided by the adapter for converting
|
|
112
|
-
* between wire types and JavaScript types.
|
|
113
|
-
*/
|
|
114
|
-
codecs(): CodecRegistry;
|
|
115
|
-
}
|
|
116
|
-
interface LoweredPayload<TBody = unknown> {
|
|
117
|
-
readonly profileId?: string;
|
|
118
|
-
readonly body: TBody;
|
|
119
|
-
readonly annotations?: Record<string, unknown>;
|
|
120
|
-
}
|
|
121
|
-
interface LowererContext<TContract = unknown> {
|
|
122
|
-
readonly contract: TContract;
|
|
123
|
-
readonly params?: readonly unknown[];
|
|
124
|
-
}
|
|
125
|
-
interface Adapter<Ast = unknown, TContract = unknown, TBody = unknown> {
|
|
126
|
-
readonly profile: AdapterProfile;
|
|
127
|
-
lower(ast: Ast, context: LowererContext<TContract>): LoweredPayload<TBody>;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
type Direction = 'asc' | 'desc';
|
|
131
|
-
interface TableRef {
|
|
132
|
-
readonly kind: 'table';
|
|
133
|
-
readonly name: string;
|
|
134
|
-
}
|
|
135
|
-
interface ColumnRef {
|
|
136
|
-
readonly kind: 'col';
|
|
137
|
-
readonly table: string;
|
|
138
|
-
readonly column: string;
|
|
139
|
-
}
|
|
140
|
-
interface ParamRef {
|
|
141
|
-
readonly kind: 'param';
|
|
142
|
-
readonly index: number;
|
|
143
|
-
readonly name?: string;
|
|
144
|
-
}
|
|
145
|
-
interface LiteralExpr {
|
|
146
|
-
readonly kind: 'literal';
|
|
147
|
-
readonly value: unknown;
|
|
148
|
-
}
|
|
149
|
-
interface OperationExpr {
|
|
150
|
-
readonly kind: 'operation';
|
|
151
|
-
readonly method: string;
|
|
152
|
-
readonly forTypeId: string;
|
|
153
|
-
readonly self: ColumnRef | OperationExpr;
|
|
154
|
-
readonly args: ReadonlyArray<ColumnRef | ParamRef | LiteralExpr | OperationExpr>;
|
|
155
|
-
readonly returns: ReturnSpec;
|
|
156
|
-
readonly lowering: SqlLoweringSpec;
|
|
157
|
-
}
|
|
158
|
-
interface BinaryExpr {
|
|
159
|
-
readonly kind: 'bin';
|
|
160
|
-
readonly op: 'eq';
|
|
161
|
-
readonly left: ColumnRef | OperationExpr;
|
|
162
|
-
readonly right: ParamRef;
|
|
163
|
-
}
|
|
164
|
-
interface ExistsExpr {
|
|
165
|
-
readonly kind: 'exists';
|
|
166
|
-
readonly not: boolean;
|
|
167
|
-
readonly subquery: SelectAst;
|
|
168
|
-
}
|
|
169
|
-
type JoinOnExpr = {
|
|
170
|
-
readonly kind: 'eqCol';
|
|
171
|
-
readonly left: ColumnRef;
|
|
172
|
-
readonly right: ColumnRef;
|
|
173
|
-
};
|
|
174
|
-
interface JoinAst {
|
|
175
|
-
readonly kind: 'join';
|
|
176
|
-
readonly joinType: 'inner' | 'left' | 'right' | 'full';
|
|
177
|
-
readonly table: TableRef;
|
|
178
|
-
readonly on: JoinOnExpr;
|
|
179
|
-
}
|
|
180
|
-
interface IncludeRef {
|
|
181
|
-
readonly kind: 'includeRef';
|
|
182
|
-
readonly alias: string;
|
|
183
|
-
}
|
|
184
|
-
interface IncludeAst {
|
|
185
|
-
readonly kind: 'includeMany';
|
|
186
|
-
readonly alias: string;
|
|
187
|
-
readonly child: {
|
|
188
|
-
readonly table: TableRef;
|
|
189
|
-
readonly on: JoinOnExpr;
|
|
190
|
-
readonly where?: BinaryExpr | ExistsExpr;
|
|
191
|
-
readonly orderBy?: ReadonlyArray<{
|
|
192
|
-
expr: ColumnRef | OperationExpr;
|
|
193
|
-
dir: Direction;
|
|
194
|
-
}>;
|
|
195
|
-
readonly limit?: number;
|
|
196
|
-
readonly project: ReadonlyArray<{
|
|
197
|
-
alias: string;
|
|
198
|
-
expr: ColumnRef | OperationExpr;
|
|
199
|
-
}>;
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
interface SelectAst {
|
|
203
|
-
readonly kind: 'select';
|
|
204
|
-
readonly from: TableRef;
|
|
205
|
-
readonly joins?: ReadonlyArray<JoinAst>;
|
|
206
|
-
readonly includes?: ReadonlyArray<IncludeAst>;
|
|
207
|
-
readonly project: ReadonlyArray<{
|
|
208
|
-
alias: string;
|
|
209
|
-
expr: ColumnRef | IncludeRef | OperationExpr | LiteralExpr;
|
|
210
|
-
}>;
|
|
211
|
-
readonly where?: BinaryExpr | ExistsExpr;
|
|
212
|
-
readonly orderBy?: ReadonlyArray<{
|
|
213
|
-
expr: ColumnRef | OperationExpr;
|
|
214
|
-
dir: Direction;
|
|
215
|
-
}>;
|
|
216
|
-
readonly limit?: number;
|
|
217
|
-
}
|
|
218
|
-
interface LoweredStatement {
|
|
219
|
-
readonly sql: string;
|
|
220
|
-
readonly params: readonly unknown[];
|
|
221
|
-
readonly annotations?: Record<string, unknown>;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
interface SqlExecuteRequest {
|
|
225
|
-
readonly sql: string;
|
|
226
|
-
readonly params?: readonly unknown[];
|
|
227
|
-
}
|
|
228
|
-
interface SqlQueryResult<Row = Record<string, unknown>> {
|
|
229
|
-
readonly rows: ReadonlyArray<Row>;
|
|
230
|
-
readonly rowCount?: number | null;
|
|
231
|
-
readonly [key: string]: unknown;
|
|
232
|
-
}
|
|
233
|
-
interface SqlExplainResult<Row = Record<string, unknown>> {
|
|
234
|
-
readonly rows: ReadonlyArray<Row>;
|
|
235
|
-
}
|
|
236
|
-
interface SqlDriver {
|
|
237
|
-
connect(): Promise<void>;
|
|
238
|
-
execute<Row = Record<string, unknown>>(request: SqlExecuteRequest): AsyncIterable<Row>;
|
|
239
|
-
explain?(request: SqlExecuteRequest): Promise<SqlExplainResult>;
|
|
240
|
-
query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<SqlQueryResult<Row>>;
|
|
241
|
-
close(): Promise<void>;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
8
|
/**
|
|
245
9
|
* SQL runtime family instance interface.
|
|
246
10
|
* Extends base RuntimeFamilyInstance with SQL-specific runtime creation method.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ContractMarkerRecord } from '@prisma-next/contract/types';
|
|
2
|
+
import { ControlDriverInstance } from '@prisma-next/core-control-plane/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parses a contract marker row from database query result.
|
|
6
|
+
* This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).
|
|
7
|
+
*/
|
|
8
|
+
declare function parseContractMarkerRow(row: unknown): ContractMarkerRecord;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the SQL statement to read the contract marker.
|
|
11
|
+
* This is a migration-plane helper (no runtime imports).
|
|
12
|
+
* @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
|
|
13
|
+
*/
|
|
14
|
+
declare function readMarkerSql(): {
|
|
15
|
+
readonly sql: string;
|
|
16
|
+
readonly params: readonly unknown[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Reads the contract marker from the database using the provided driver.
|
|
20
|
+
* Returns the parsed marker record or null if no marker is found.
|
|
21
|
+
* This abstracts SQL-specific details from the Control Plane.
|
|
22
|
+
*
|
|
23
|
+
* @param driver - ControlDriverInstance instance for executing queries
|
|
24
|
+
* @returns Promise resolving to ContractMarkerRecord or null if marker not found
|
|
25
|
+
*/
|
|
26
|
+
declare function readMarker(driver: ControlDriverInstance): Promise<ContractMarkerRecord | null>;
|
|
27
|
+
|
|
28
|
+
export { parseContractMarkerRow, readMarker, readMarkerSql };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/family-sql",
|
|
3
|
-
"version": "0.1.0-pr.
|
|
3
|
+
"version": "0.1.0-pr.34.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "SQL family descriptor for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.0.0",
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/core-control-plane": "0.1.0-pr.
|
|
12
|
-
"@prisma-next/core-execution-plane": "0.1.0-pr.
|
|
13
|
-
"@prisma-next/
|
|
14
|
-
"@prisma-next/
|
|
15
|
-
"@prisma-next/sql-contract": "0.1.0-pr.
|
|
16
|
-
"@prisma-next/sql-
|
|
17
|
-
"@prisma-next/sql-
|
|
18
|
-
"@prisma-next/sql-
|
|
9
|
+
"@prisma-next/contract": "0.1.0-pr.34.1",
|
|
10
|
+
"@prisma-next/cli": "0.1.0-pr.34.1",
|
|
11
|
+
"@prisma-next/core-control-plane": "0.1.0-pr.34.1",
|
|
12
|
+
"@prisma-next/core-execution-plane": "0.1.0-pr.34.1",
|
|
13
|
+
"@prisma-next/operations": "0.1.0-pr.34.1",
|
|
14
|
+
"@prisma-next/runtime-executor": "0.1.0-pr.34.1",
|
|
15
|
+
"@prisma-next/sql-contract-emitter": "0.1.0-pr.34.1",
|
|
16
|
+
"@prisma-next/sql-contract-ts": "0.1.0-pr.34.1",
|
|
17
|
+
"@prisma-next/sql-contract": "0.1.0-pr.34.1",
|
|
18
|
+
"@prisma-next/sql-operations": "0.1.0-pr.34.1",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.1.0-pr.34.1",
|
|
20
|
+
"@prisma-next/sql-runtime": "0.1.0-pr.34.1",
|
|
21
|
+
"@prisma-next/sql-schema-ir": "0.1.0-pr.34.1"
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
24
|
"tsup": "^8.3.0",
|
|
22
25
|
"typescript": "^5.9.3",
|
|
23
26
|
"vite-tsconfig-paths": "^5.1.4",
|
|
24
27
|
"vitest": "^2.1.1",
|
|
25
|
-
"@prisma-next/
|
|
26
|
-
"@prisma-next/
|
|
27
|
-
"@prisma-next/
|
|
28
|
+
"@prisma-next/targets-postgres": "0.1.0-pr.34.1",
|
|
29
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
30
|
+
"@prisma-next/driver-postgres": "0.1.0-pr.34.1"
|
|
28
31
|
},
|
|
29
32
|
"files": [
|
|
30
33
|
"dist"
|
|
@@ -41,6 +44,10 @@
|
|
|
41
44
|
"./runtime": {
|
|
42
45
|
"types": "./dist/exports/runtime.d.ts",
|
|
43
46
|
"import": "./dist/exports/runtime.js"
|
|
47
|
+
},
|
|
48
|
+
"./verify": {
|
|
49
|
+
"types": "./dist/exports/verify.d.ts",
|
|
50
|
+
"import": "./dist/exports/verify.js"
|
|
44
51
|
}
|
|
45
52
|
},
|
|
46
53
|
"scripts": {
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
type ArgSpec = {
|
|
2
|
-
readonly kind: 'typeId';
|
|
3
|
-
readonly type: string;
|
|
4
|
-
} | {
|
|
5
|
-
readonly kind: 'param';
|
|
6
|
-
} | {
|
|
7
|
-
readonly kind: 'literal';
|
|
8
|
-
};
|
|
9
|
-
type ReturnSpec = {
|
|
10
|
-
readonly kind: 'typeId';
|
|
11
|
-
readonly type: string;
|
|
12
|
-
} | {
|
|
13
|
-
readonly kind: 'builtin';
|
|
14
|
-
readonly type: 'number' | 'boolean' | 'string';
|
|
15
|
-
};
|
|
16
|
-
interface OperationSignature {
|
|
17
|
-
readonly forTypeId: string;
|
|
18
|
-
readonly method: string;
|
|
19
|
-
readonly args: ReadonlyArray<ArgSpec>;
|
|
20
|
-
readonly returns: ReturnSpec;
|
|
21
|
-
readonly capabilities?: ReadonlyArray<string>;
|
|
22
|
-
}
|
|
23
|
-
interface OperationRegistry {
|
|
24
|
-
register(op: OperationSignature): void;
|
|
25
|
-
byType(typeId: string): ReadonlyArray<OperationSignature>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type { OperationRegistry as O, ReturnSpec as R };
|