@prisma-next/sql-relational-core 0.3.0-pr.99.5 → 0.3.0
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/LICENSE +201 -0
- package/README.md +20 -6
- package/dist/codec-types-DcEITed4.d.mts +144 -0
- package/dist/codec-types-DcEITed4.d.mts.map +1 -0
- package/dist/errors-Cs52upp3.d.mts +8 -0
- package/dist/errors-Cs52upp3.d.mts.map +1 -0
- package/dist/errors-D3xmG4h-.mjs +35 -0
- package/dist/errors-D3xmG4h-.mjs.map +1 -0
- package/dist/exports/ast.d.mts +158 -0
- package/dist/exports/ast.d.mts.map +1 -0
- package/dist/exports/ast.mjs +1358 -0
- package/dist/exports/ast.mjs.map +1 -0
- package/dist/exports/errors.d.mts +5 -0
- package/dist/exports/errors.mjs +3 -0
- package/dist/exports/plan.d.mts +2 -0
- package/dist/exports/plan.mjs +17 -0
- package/dist/exports/plan.mjs.map +1 -0
- package/dist/exports/query-lane-context.d.mts +3 -0
- package/dist/exports/query-lane-context.mjs +1 -0
- package/dist/exports/types.d.mts +4 -0
- package/dist/exports/types.mjs +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.mjs +7 -0
- package/dist/plan-5qUWdlJM.d.mts +28 -0
- package/dist/plan-5qUWdlJM.d.mts.map +1 -0
- package/dist/query-lane-context-UlR8vOkd.d.mts +89 -0
- package/dist/query-lane-context-UlR8vOkd.d.mts.map +1 -0
- package/dist/types-CLCtwVWx.d.mts +485 -0
- package/dist/types-CLCtwVWx.d.mts.map +1 -0
- package/dist/types-V1qiC5DO.d.mts +200 -0
- package/dist/types-V1qiC5DO.d.mts.map +1 -0
- package/package.json +29 -51
- package/src/ast/adapter-types.ts +11 -0
- package/src/ast/codec-types.ts +101 -53
- package/src/ast/driver-types.ts +20 -3
- package/src/ast/sql-codecs.ts +142 -0
- package/src/ast/types.ts +1678 -88
- package/src/errors.ts +47 -1
- package/src/exports/ast.ts +1 -8
- package/src/index.ts +0 -3
- package/src/plan.ts +4 -4
- package/src/query-lane-context.ts +74 -11
- package/src/types.ts +102 -404
- package/dist/ast/adapter-types.d.ts +0 -28
- package/dist/ast/adapter-types.d.ts.map +0 -1
- package/dist/ast/codec-types.d.ts +0 -141
- package/dist/ast/codec-types.d.ts.map +0 -1
- package/dist/ast/common.d.ts +0 -7
- package/dist/ast/common.d.ts.map +0 -1
- package/dist/ast/delete.d.ts +0 -8
- package/dist/ast/delete.d.ts.map +0 -1
- package/dist/ast/driver-types.d.ts +0 -20
- package/dist/ast/driver-types.d.ts.map +0 -1
- package/dist/ast/insert.d.ts +0 -8
- package/dist/ast/insert.d.ts.map +0 -1
- package/dist/ast/join.d.ts +0 -6
- package/dist/ast/join.d.ts.map +0 -1
- package/dist/ast/order.d.ts +0 -6
- package/dist/ast/order.d.ts.map +0 -1
- package/dist/ast/predicate.d.ts +0 -4
- package/dist/ast/predicate.d.ts.map +0 -1
- package/dist/ast/select.d.ts +0 -18
- package/dist/ast/select.d.ts.map +0 -1
- package/dist/ast/types.d.ts +0 -130
- package/dist/ast/types.d.ts.map +0 -1
- package/dist/ast/update.d.ts +0 -9
- package/dist/ast/update.d.ts.map +0 -1
- package/dist/ast/util.d.ts +0 -2
- package/dist/ast/util.d.ts.map +0 -1
- package/dist/chunk-2BWK6XEY.js +0 -13
- package/dist/chunk-2BWK6XEY.js.map +0 -1
- package/dist/chunk-2F7DSEOU.js +0 -8
- package/dist/chunk-2F7DSEOU.js.map +0 -1
- package/dist/chunk-2MAKNVCP.js +0 -86
- package/dist/chunk-2MAKNVCP.js.map +0 -1
- package/dist/chunk-36WJWNHT.js +0 -1
- package/dist/chunk-36WJWNHT.js.map +0 -1
- package/dist/chunk-3F4RFQIB.js +0 -169
- package/dist/chunk-3F4RFQIB.js.map +0 -1
- package/dist/chunk-7I3EMQID.js +0 -16
- package/dist/chunk-7I3EMQID.js.map +0 -1
- package/dist/chunk-G52ENULI.js +0 -1
- package/dist/chunk-G52ENULI.js.map +0 -1
- package/dist/chunk-HV334QHG.js +0 -320
- package/dist/chunk-HV334QHG.js.map +0 -1
- package/dist/chunk-KYSP7L5C.js +0 -16
- package/dist/chunk-KYSP7L5C.js.map +0 -1
- package/dist/chunk-U7AXAUJA.js +0 -1
- package/dist/chunk-U7AXAUJA.js.map +0 -1
- package/dist/chunk-YXD25S5I.js +0 -171
- package/dist/chunk-YXD25S5I.js.map +0 -1
- package/dist/errors.d.ts +0 -2
- package/dist/errors.d.ts.map +0 -1
- package/dist/exports/ast.d.ts +0 -14
- package/dist/exports/ast.d.ts.map +0 -1
- package/dist/exports/ast.js +0 -46
- package/dist/exports/ast.js.map +0 -1
- package/dist/exports/errors.d.ts +0 -2
- package/dist/exports/errors.d.ts.map +0 -1
- package/dist/exports/errors.js +0 -9
- package/dist/exports/errors.js.map +0 -1
- package/dist/exports/guards.d.ts +0 -2
- package/dist/exports/guards.d.ts.map +0 -1
- package/dist/exports/guards.js +0 -31
- package/dist/exports/guards.js.map +0 -1
- package/dist/exports/operations-registry.d.ts +0 -2
- package/dist/exports/operations-registry.d.ts.map +0 -1
- package/dist/exports/operations-registry.js +0 -9
- package/dist/exports/operations-registry.js.map +0 -1
- package/dist/exports/param.d.ts +0 -3
- package/dist/exports/param.d.ts.map +0 -1
- package/dist/exports/param.js +0 -7
- package/dist/exports/param.js.map +0 -1
- package/dist/exports/plan.d.ts +0 -2
- package/dist/exports/plan.d.ts.map +0 -1
- package/dist/exports/plan.js +0 -7
- package/dist/exports/plan.js.map +0 -1
- package/dist/exports/query-lane-context.d.ts +0 -2
- package/dist/exports/query-lane-context.d.ts.map +0 -1
- package/dist/exports/query-lane-context.js +0 -2
- package/dist/exports/query-lane-context.js.map +0 -1
- package/dist/exports/schema.d.ts +0 -3
- package/dist/exports/schema.d.ts.map +0 -1
- package/dist/exports/schema.js +0 -13
- package/dist/exports/schema.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -10
- package/dist/exports/types.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -81
- package/dist/index.js.map +0 -1
- package/dist/operations-registry.d.ts +0 -5
- package/dist/operations-registry.d.ts.map +0 -1
- package/dist/param.d.ts +0 -4
- package/dist/param.d.ts.map +0 -1
- package/dist/plan.d.ts +0 -23
- package/dist/plan.d.ts.map +0 -1
- package/dist/query-lane-context.d.ts +0 -27
- package/dist/query-lane-context.d.ts.map +0 -1
- package/dist/schema.d.ts +0 -83
- package/dist/schema.d.ts.map +0 -1
- package/dist/types.d.ts +0 -371
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/guards.d.ts +0 -82
- package/dist/utils/guards.d.ts.map +0 -1
- package/src/ast/common.ts +0 -36
- package/src/ast/delete.ts +0 -17
- package/src/ast/insert.ts +0 -17
- package/src/ast/join.ts +0 -54
- package/src/ast/order.ts +0 -11
- package/src/ast/predicate.ts +0 -22
- package/src/ast/select.ts +0 -39
- package/src/ast/update.ts +0 -19
- package/src/exports/guards.ts +0 -15
- package/src/exports/operations-registry.ts +0 -1
- package/src/exports/param.ts +0 -2
- package/src/exports/schema.ts +0 -6
- package/src/operations-registry.ts +0 -276
- package/src/param.ts +0 -15
- package/src/schema.ts +0 -406
- package/src/utils/guards.ts +0 -193
package/src/errors.ts
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RuntimeError } from './types';
|
|
2
|
+
|
|
3
|
+
export function planInvalid(
|
|
4
|
+
message: string,
|
|
5
|
+
details?: Record<string, unknown>,
|
|
6
|
+
hints?: readonly string[],
|
|
7
|
+
docs?: readonly string[],
|
|
8
|
+
): RuntimeError {
|
|
9
|
+
const error = new Error(message) as RuntimeError;
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(error, 'name', {
|
|
12
|
+
value: 'RuntimeError',
|
|
13
|
+
configurable: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return Object.assign(error, {
|
|
17
|
+
code: 'PLAN.INVALID',
|
|
18
|
+
category: 'PLAN' as const,
|
|
19
|
+
severity: 'error' as const,
|
|
20
|
+
details,
|
|
21
|
+
hints,
|
|
22
|
+
docs,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function planUnsupported(
|
|
27
|
+
message: string,
|
|
28
|
+
details?: Record<string, unknown>,
|
|
29
|
+
hints?: readonly string[],
|
|
30
|
+
docs?: readonly string[],
|
|
31
|
+
): RuntimeError {
|
|
32
|
+
const error = new Error(message) as RuntimeError;
|
|
33
|
+
|
|
34
|
+
Object.defineProperty(error, 'name', {
|
|
35
|
+
value: 'RuntimeError',
|
|
36
|
+
configurable: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return Object.assign(error, {
|
|
40
|
+
code: 'PLAN.UNSUPPORTED',
|
|
41
|
+
category: 'PLAN' as const,
|
|
42
|
+
severity: 'error' as const,
|
|
43
|
+
details,
|
|
44
|
+
hints,
|
|
45
|
+
docs,
|
|
46
|
+
});
|
|
47
|
+
}
|
package/src/exports/ast.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
export * from '../ast/adapter-types';
|
|
2
2
|
export * from '../ast/codec-types';
|
|
3
|
-
export * from '../ast/common';
|
|
4
|
-
export * from '../ast/delete';
|
|
5
3
|
export * from '../ast/driver-types';
|
|
6
|
-
export * from '../ast/
|
|
7
|
-
export * from '../ast/join';
|
|
8
|
-
export * from '../ast/order';
|
|
9
|
-
export * from '../ast/predicate';
|
|
10
|
-
export * from '../ast/select';
|
|
4
|
+
export * from '../ast/sql-codecs';
|
|
11
5
|
export * from '../ast/types';
|
|
12
|
-
export * from '../ast/update';
|
|
13
6
|
export * from '../ast/util';
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export * from './exports/ast';
|
|
2
2
|
export * from './exports/errors';
|
|
3
|
-
export * from './exports/operations-registry';
|
|
4
|
-
export * from './exports/param';
|
|
5
3
|
export * from './exports/plan';
|
|
6
4
|
export * from './exports/query-lane-context';
|
|
7
|
-
export * from './exports/schema';
|
|
8
5
|
export * from './exports/types';
|
package/src/plan.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExecutionPlan, ParamDescriptor } from '@prisma-next/contract/types';
|
|
2
2
|
import type { StorageColumn } from '@prisma-next/sql-contract/types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AnyQueryAst } from './ast/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* SQL query plan produced by lanes before lowering.
|
|
@@ -8,13 +8,13 @@ import type { QueryAst } from './ast/types';
|
|
|
8
8
|
* Lanes build ASTs and metadata but do not perform SQL lowering.
|
|
9
9
|
* The `sql` field is absent - lowering happens in the runtime executor.
|
|
10
10
|
*
|
|
11
|
-
* Structurally aligns with ExecutionPlan<Row,
|
|
11
|
+
* Structurally aligns with ExecutionPlan<Row, AnyQueryAst> (without sql field) to maintain
|
|
12
12
|
* compatibility with ExecutionPlan/Plan-based utilities.
|
|
13
13
|
* The generic parameter `_Row` is preserved for type extraction via ResultType.
|
|
14
14
|
*/
|
|
15
15
|
export interface SqlQueryPlan<_Row = unknown>
|
|
16
|
-
extends Pick<ExecutionPlan<_Row,
|
|
17
|
-
readonly ast:
|
|
16
|
+
extends Pick<ExecutionPlan<_Row, AnyQueryAst>, 'params' | 'meta'> {
|
|
17
|
+
readonly ast: AnyQueryAst;
|
|
18
18
|
// Phantom property to preserve generic parameter for type extraction
|
|
19
19
|
// This allows ResultType to extract _Row for SqlQueryPlan values.
|
|
20
20
|
readonly _Row?: _Row;
|
|
@@ -1,14 +1,69 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Contract } from '@prisma-next/contract/types';
|
|
2
|
+
import type { SqlStorage } from '@prisma-next/sql-contract/types';
|
|
3
|
+
import type { SqlOperationRegistry } from '@prisma-next/sql-operations';
|
|
3
4
|
import type { CodecRegistry } from './ast/codec-types';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Registry of initialized type helpers from storage.types.
|
|
7
|
-
* Each key is a type name from storage.types, and the value is
|
|
8
|
-
*
|
|
8
|
+
* Each key is a type name from storage.types, and the value is:
|
|
9
|
+
* - The result of the codec's init hook (if provided), or
|
|
10
|
+
* - The full StorageTypeInstance metadata (codecId, nativeType, typeParams) if no init hook
|
|
9
11
|
*/
|
|
10
12
|
export type TypeHelperRegistry = Record<string, unknown>;
|
|
11
13
|
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// JSON Schema Validation Types
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A single validation error from JSON Schema validation.
|
|
20
|
+
*/
|
|
21
|
+
export interface JsonSchemaValidationError {
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly keyword: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Result of a JSON Schema validation.
|
|
29
|
+
*/
|
|
30
|
+
export type JsonSchemaValidationResult =
|
|
31
|
+
| { readonly valid: true }
|
|
32
|
+
| { readonly valid: false; readonly errors: ReadonlyArray<JsonSchemaValidationError> };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A compiled JSON Schema validate function.
|
|
36
|
+
* Returns a structured result indicating whether the value conforms to the schema.
|
|
37
|
+
*/
|
|
38
|
+
export type JsonSchemaValidateFn = (value: unknown) => JsonSchemaValidationResult;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Registry of compiled JSON Schema validators for columns with typed JSON/JSONB.
|
|
42
|
+
*
|
|
43
|
+
* Built during context creation by scanning the contract for columns whose codec
|
|
44
|
+
* descriptor provides an `init` hook that returns a `{ validate }` helper.
|
|
45
|
+
* Keys are `"table.column"` (e.g., `"user.metadata"`).
|
|
46
|
+
*/
|
|
47
|
+
export interface JsonSchemaValidatorRegistry {
|
|
48
|
+
/** Get the compiled validator for a column. Key format: "table.column". */
|
|
49
|
+
get(key: string): JsonSchemaValidateFn | undefined;
|
|
50
|
+
/** Number of registered validators. */
|
|
51
|
+
readonly size: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type MutationDefaultsOp = 'create' | 'update';
|
|
55
|
+
|
|
56
|
+
export type AppliedMutationDefault = {
|
|
57
|
+
readonly column: string;
|
|
58
|
+
readonly value: unknown;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type MutationDefaultsOptions = {
|
|
62
|
+
readonly op: MutationDefaultsOp;
|
|
63
|
+
readonly table: string;
|
|
64
|
+
readonly values: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
|
|
12
67
|
/**
|
|
13
68
|
* Minimal context interface for SQL query lanes.
|
|
14
69
|
*
|
|
@@ -16,15 +71,23 @@ export type TypeHelperRegistry = Record<string, unknown>;
|
|
|
16
71
|
* operation builders. This interface explicitly excludes runtime concerns like
|
|
17
72
|
* adapters, connection management, and transaction state.
|
|
18
73
|
*/
|
|
19
|
-
export interface
|
|
20
|
-
TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,
|
|
21
|
-
> {
|
|
74
|
+
export interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
|
|
22
75
|
readonly contract: TContract;
|
|
23
|
-
readonly operations: OperationRegistry;
|
|
24
76
|
readonly codecs: CodecRegistry;
|
|
77
|
+
readonly queryOperations: SqlOperationRegistry;
|
|
78
|
+
/**
|
|
79
|
+
* Type helper registry for parameterized types.
|
|
80
|
+
* Schema builders expose these helpers via schema.types.
|
|
81
|
+
*/
|
|
82
|
+
readonly types: TypeHelperRegistry;
|
|
83
|
+
/**
|
|
84
|
+
* Compiled JSON Schema validators for typed JSON/JSONB columns.
|
|
85
|
+
* Present only when the contract declares columns with JSON Schema typeParams.
|
|
86
|
+
*/
|
|
87
|
+
readonly jsonSchemaValidators?: JsonSchemaValidatorRegistry;
|
|
25
88
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
89
|
+
* Applies execution-time mutation defaults for the given table.
|
|
90
|
+
* Returns the applied defaults (caller-provided values always win).
|
|
28
91
|
*/
|
|
29
|
-
|
|
92
|
+
applyMutationDefaults(options: MutationDefaultsOptions): ReadonlyArray<AppliedMutationDefault>;
|
|
30
93
|
}
|