effect-qb 0.14.0 → 0.15.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/dist/mysql.js +61270 -4259
- package/dist/postgres/metadata.js +176 -82
- package/dist/postgres.js +5903 -3316
- package/package.json +14 -1
- package/src/internal/aggregation-validation.ts +3 -3
- package/src/internal/case-analysis.d.ts +18 -0
- package/src/internal/case-analysis.ts +4 -4
- package/src/internal/coercion/analysis.d.ts +7 -0
- package/src/internal/{coercion-analysis.ts → coercion/analysis.ts} +3 -3
- package/src/internal/coercion/errors.d.ts +17 -0
- package/src/internal/{coercion-errors.ts → coercion/errors.ts} +1 -1
- package/src/internal/coercion/kind.d.ts +4 -0
- package/src/internal/{coercion-kind.ts → coercion/kind.ts} +2 -2
- package/src/internal/{coercion-normalize.ts → coercion/normalize.ts} +1 -1
- package/src/internal/coercion/rules.d.ts +6 -0
- package/src/internal/{coercion-rules.ts → coercion/rules.ts} +2 -2
- package/src/internal/column-state.d.ts +190 -0
- package/src/internal/column-state.ts +36 -47
- package/src/internal/column.ts +21 -305
- package/src/internal/datatypes/define.d.ts +17 -0
- package/src/internal/datatypes/define.ts +18 -4
- package/src/internal/datatypes/lookup.d.ts +44 -0
- package/src/internal/datatypes/lookup.ts +61 -152
- package/src/internal/datatypes/shape.d.ts +16 -0
- package/src/internal/datatypes/shape.ts +1 -1
- package/src/internal/derived-table.d.ts +4 -0
- package/src/internal/derived-table.ts +21 -16
- package/src/internal/dsl-mutation-runtime.ts +378 -0
- package/src/internal/dsl-plan-runtime.ts +387 -0
- package/src/internal/dsl-query-runtime.ts +160 -0
- package/src/internal/dsl-transaction-ddl-runtime.ts +263 -0
- package/src/internal/executor.ts +132 -31
- package/src/internal/expression-ast.ts +15 -5
- package/src/internal/grouping-key.d.ts +3 -0
- package/src/internal/grouping-key.ts +1 -1
- package/src/internal/implication-runtime.d.ts +15 -0
- package/src/internal/implication-runtime.ts +4 -4
- package/src/internal/json/ast.d.ts +30 -0
- package/src/internal/json/ast.ts +1 -1
- package/src/internal/json/errors.d.ts +8 -0
- package/src/internal/json/path.d.ts +75 -0
- package/src/internal/json/path.ts +1 -1
- package/src/internal/json/types.d.ts +62 -0
- package/src/internal/predicate/analysis.d.ts +20 -0
- package/src/internal/{predicate-analysis.ts → predicate/analysis.ts} +3 -3
- package/src/internal/predicate/atom.d.ts +28 -0
- package/src/internal/{predicate-branches.ts → predicate/branches.ts} +2 -2
- package/src/internal/predicate/context.d.ts +67 -0
- package/src/internal/{predicate-context.ts → predicate/context.ts} +8 -5
- package/src/internal/predicate/formula.d.ts +35 -0
- package/src/internal/{predicate-formula.ts → predicate/formula.ts} +1 -1
- package/src/internal/predicate/key.d.ts +11 -0
- package/src/internal/{predicate-key.ts → predicate/key.ts} +2 -2
- package/src/internal/{predicate-nnf.ts → predicate/nnf.ts} +2 -2
- package/src/internal/predicate/normalize.d.ts +53 -0
- package/src/internal/{predicate-normalize.ts → predicate/normalize.ts} +19 -19
- package/src/internal/predicate/runtime.d.ts +31 -0
- package/src/internal/{predicate-runtime.ts → predicate/runtime.ts} +9 -6
- package/src/internal/projection-alias.d.ts +13 -0
- package/src/internal/projections.d.ts +31 -0
- package/src/internal/projections.ts +1 -1
- package/src/internal/query-ast.d.ts +217 -0
- package/src/internal/query-ast.ts +1 -1
- package/src/internal/query-requirements.d.ts +20 -0
- package/src/internal/query.d.ts +775 -0
- package/src/internal/query.ts +389 -313
- package/src/internal/renderer.ts +7 -21
- package/src/internal/row-set.d.ts +53 -0
- package/src/internal/{plan.ts → row-set.ts} +11 -9
- package/src/internal/{runtime-normalize.ts → runtime/normalize.ts} +9 -31
- package/src/internal/{runtime-schema.ts → runtime/schema.ts} +13 -38
- package/src/internal/runtime/value.d.ts +22 -0
- package/src/internal/{runtime-value.ts → runtime/value.ts} +2 -2
- package/src/internal/scalar.d.ts +107 -0
- package/src/internal/scalar.ts +191 -0
- package/src/internal/schema-derivation.d.ts +105 -0
- package/src/internal/schema-expression.d.ts +18 -0
- package/src/internal/schema-expression.ts +38 -7
- package/src/internal/table-options.d.ts +94 -0
- package/src/internal/table-options.ts +8 -2
- package/src/internal/table.d.ts +173 -0
- package/src/internal/table.ts +32 -14
- package/src/mysql/column.ts +94 -18
- package/src/mysql/datatypes/index.ts +47 -7
- package/src/mysql/errors/generated.ts +57336 -0
- package/src/mysql/errors/index.ts +1 -0
- package/src/mysql/errors/normalize.ts +55 -53
- package/src/mysql/errors/types.ts +74 -0
- package/src/mysql/executor.ts +69 -7
- package/src/mysql/function/aggregate.ts +1 -5
- package/src/mysql/function/core.ts +1 -4
- package/src/mysql/function/index.ts +0 -1
- package/src/mysql/function/string.ts +1 -5
- package/src/mysql/function/temporal.ts +12 -15
- package/src/mysql/function/window.ts +1 -6
- package/src/{internal/mysql-dialect.ts → mysql/internal/dialect.ts} +1 -1
- package/src/{internal/mysql-query.ts → mysql/internal/dsl.ts} +1024 -2082
- package/src/{internal/mysql-renderer.ts → mysql/internal/renderer.ts} +6 -6
- package/src/mysql/internal/sql-expression-renderer.ts +1455 -0
- package/src/mysql/json.ts +2 -0
- package/src/mysql/query.ts +111 -91
- package/src/mysql/renderer.ts +1 -1
- package/src/mysql/table.ts +1 -1
- package/src/mysql.ts +6 -4
- package/src/postgres/cast.ts +11 -12
- package/src/postgres/column.ts +178 -46
- package/src/postgres/datatypes/index.d.ts +515 -0
- package/src/postgres/datatypes/index.ts +22 -13
- package/src/postgres/datatypes/spec.d.ts +412 -0
- package/src/postgres/errors/generated.ts +2636 -0
- package/src/postgres/errors/index.ts +1 -0
- package/src/postgres/errors/normalize.ts +47 -62
- package/src/postgres/errors/types.ts +92 -34
- package/src/postgres/executor.ts +37 -5
- package/src/postgres/function/aggregate.ts +1 -5
- package/src/postgres/function/core.ts +12 -6
- package/src/postgres/function/index.ts +0 -1
- package/src/postgres/function/string.ts +1 -5
- package/src/postgres/function/temporal.ts +12 -15
- package/src/postgres/function/window.ts +1 -6
- package/src/{internal/postgres-dialect.ts → postgres/internal/dialect.ts} +1 -1
- package/src/{internal/postgres-query.ts → postgres/internal/dsl.ts} +1085 -2089
- package/src/{internal/postgres-renderer.ts → postgres/internal/renderer.ts} +6 -6
- package/src/postgres/internal/schema-ddl.ts +108 -0
- package/src/{internal/postgres-schema-model.ts → postgres/internal/schema-model.ts} +12 -6
- package/src/{internal → postgres/internal}/sql-expression-renderer.ts +19 -17
- package/src/postgres/{function/json.ts → json.ts} +77 -85
- package/src/postgres/metadata.ts +2 -2
- package/src/postgres/query.ts +113 -89
- package/src/postgres/renderer.ts +3 -13
- package/src/postgres/schema-expression.ts +2 -1
- package/src/postgres/schema-management.ts +1 -1
- package/src/postgres/table.ts +12 -4
- package/src/postgres/type.ts +29 -2
- package/src/postgres.ts +6 -4
- package/src/internal/expression.ts +0 -327
- package/src/internal/schema-ddl.ts +0 -55
- package/src/mysql/function/json.ts +0 -4
- package/src/mysql/private/query.ts +0 -1
- package/src/postgres/private/query.ts +0 -1
- /package/src/internal/{predicate-atom.ts → predicate/atom.ts} +0 -0
package/src/internal/renderer.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Query from "./query.js"
|
|
2
2
|
import { type Projection, validateProjections } from "./projections.js"
|
|
3
|
-
import { renderPostgresPlan } from "./postgres-renderer.js"
|
|
4
3
|
|
|
5
4
|
/** Symbol used to attach rendered-query phantom row metadata. */
|
|
6
5
|
export const TypeId: unique symbol = Symbol.for("effect-qb/Renderer")
|
|
@@ -41,12 +40,12 @@ export type RowOf<Value extends RenderedQuery<any, any>> = Value[typeof TypeId][
|
|
|
41
40
|
*/
|
|
42
41
|
export interface Renderer<Dialect extends string = string> {
|
|
43
42
|
readonly dialect: Dialect
|
|
44
|
-
render<PlanValue extends Query.
|
|
43
|
+
render<PlanValue extends Query.Plan.Any>(
|
|
45
44
|
plan: Query.DialectCompatiblePlan<PlanValue, Dialect>
|
|
46
45
|
): RenderedQuery<any, Dialect>
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
type CustomRender<Dialect extends string> = <PlanValue extends Query.
|
|
48
|
+
type CustomRender<Dialect extends string> = <PlanValue extends Query.Plan.Any>(
|
|
50
49
|
plan: Query.DialectCompatiblePlan<PlanValue, Dialect>
|
|
51
50
|
) => {
|
|
52
51
|
readonly sql: string
|
|
@@ -55,33 +54,23 @@ type CustomRender<Dialect extends string> = <PlanValue extends Query.QueryPlan<a
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
|
-
* Constructs a renderer from a dialect and
|
|
59
|
-
*
|
|
60
|
-
* When no callback is provided, the library supplies a built-in renderer for
|
|
61
|
-
* `"postgres"` that consumes the query AST directly and produces SQL text plus
|
|
62
|
-
* parameter values.
|
|
57
|
+
* Constructs a renderer from a dialect and implementation callback.
|
|
63
58
|
*/
|
|
64
|
-
export function make(dialect: "postgres"): Renderer<"postgres">
|
|
65
59
|
export function make<Dialect extends string>(
|
|
66
60
|
dialect: Dialect,
|
|
67
61
|
render: CustomRender<Dialect>
|
|
68
62
|
): Renderer<Dialect>
|
|
69
63
|
export function make<Dialect extends string>(
|
|
70
64
|
dialect: Dialect,
|
|
71
|
-
render
|
|
65
|
+
render: CustomRender<Dialect>
|
|
72
66
|
): Renderer<Dialect> {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
: undefined) as CustomRender<Dialect> | undefined)
|
|
76
|
-
|
|
77
|
-
if (!implementation) {
|
|
78
|
-
throw new Error(`No built-in renderer for dialect: ${dialect}`)
|
|
67
|
+
if (typeof render !== "function") {
|
|
68
|
+
throw new Error(`Renderer.make requires an explicit render implementation for dialect: ${dialect}`)
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
return {
|
|
82
71
|
dialect,
|
|
83
72
|
render(plan) {
|
|
84
|
-
const rendered =
|
|
73
|
+
const rendered = render(plan)
|
|
85
74
|
const projections = rendered.projections ?? []
|
|
86
75
|
validateProjections(projections)
|
|
87
76
|
return {
|
|
@@ -97,6 +86,3 @@ export function make<Dialect extends string>(
|
|
|
97
86
|
}
|
|
98
87
|
} as Renderer<Dialect>
|
|
99
88
|
}
|
|
100
|
-
|
|
101
|
-
/** Built-in Postgres renderer backed by the current query AST. */
|
|
102
|
-
export const postgres = make("postgres")
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Pipeable } from "effect/Pipeable";
|
|
2
|
+
import type { PredicateFormula } from "./predicate/formula.js";
|
|
3
|
+
/** Symbol used to attach logical-plan metadata to runtime values. */
|
|
4
|
+
export declare const TypeId: unique symbol;
|
|
5
|
+
export type TypeId = typeof TypeId;
|
|
6
|
+
/**
|
|
7
|
+
* Source availability mode within a query scope.
|
|
8
|
+
*
|
|
9
|
+
* `required` means the source is guaranteed to produce a row at this point in
|
|
10
|
+
* the plan. `optional` means the source may be absent, such as the nullable
|
|
11
|
+
* side of a left join.
|
|
12
|
+
*/
|
|
13
|
+
export type SourceMode = "required" | "optional";
|
|
14
|
+
/** Source made available to a plan. */
|
|
15
|
+
export interface Source<Name extends string = string, Mode extends SourceMode = SourceMode, PresentFormula extends PredicateFormula = PredicateFormula, PresenceWitness extends string = never> {
|
|
16
|
+
readonly name: Name;
|
|
17
|
+
readonly mode: Mode;
|
|
18
|
+
readonly baseName?: string;
|
|
19
|
+
readonly _presentFormula?: PresentFormula;
|
|
20
|
+
readonly _presenceWitnesses?: readonly PresenceWitness[];
|
|
21
|
+
}
|
|
22
|
+
export type AnySource = Source<string, SourceMode, PredicateFormula, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Canonical static metadata stored on a plan.
|
|
25
|
+
*
|
|
26
|
+
* `required` tracks sources that the selection references but which are not yet
|
|
27
|
+
* in scope. `available` tracks sources already in scope for subsequent query
|
|
28
|
+
* operations.
|
|
29
|
+
*/
|
|
30
|
+
export interface State<Columns, Required, Available extends Record<string, AnySource>, Dialect extends string> {
|
|
31
|
+
readonly selection: Columns;
|
|
32
|
+
readonly required: Required;
|
|
33
|
+
readonly available: Available;
|
|
34
|
+
readonly dialect: Dialect;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A composable logical row set.
|
|
38
|
+
*
|
|
39
|
+
* Tables implement this interface as already-complete plans. Future query
|
|
40
|
+
* builders such as `select()` and `from()` should produce and transform values
|
|
41
|
+
* with this same structure.
|
|
42
|
+
*/
|
|
43
|
+
export interface RowSet<Columns, Required = never, Available extends Record<string, AnySource> = {}, Dialect extends string = never> extends Pipeable {
|
|
44
|
+
readonly [TypeId]: State<Columns, Required, Available, Dialect>;
|
|
45
|
+
}
|
|
46
|
+
/** Convenience alias for any plan-like value. */
|
|
47
|
+
export type Any = RowSet<any, any, Record<string, AnySource>, string>;
|
|
48
|
+
/** Extracts a row set's columns shape. */
|
|
49
|
+
export type ColumnsOf<Value extends Any> = Value[typeof TypeId]["selection"];
|
|
50
|
+
/** Extracts a plan's selection shape. */
|
|
51
|
+
export type SelectionOf<Value extends Any> = ColumnsOf<Value>;
|
|
52
|
+
/** Extracts a plan's effective dialect. */
|
|
53
|
+
export type DialectOf<Value extends Any> = Value[typeof TypeId]["dialect"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Pipeable } from "effect/Pipeable"
|
|
2
|
-
import type { PredicateFormula } from "./predicate
|
|
2
|
+
import type { PredicateFormula } from "./predicate/formula.js"
|
|
3
3
|
|
|
4
4
|
/** Symbol used to attach logical-plan metadata to runtime values. */
|
|
5
5
|
export const TypeId: unique symbol = Symbol.for("effect-qb/Plan")
|
|
@@ -39,36 +39,38 @@ export type AnySource = Source<string, SourceMode, PredicateFormula, string>
|
|
|
39
39
|
* operations.
|
|
40
40
|
*/
|
|
41
41
|
export interface State<
|
|
42
|
-
|
|
42
|
+
Columns,
|
|
43
43
|
Required,
|
|
44
44
|
Available extends Record<string, AnySource>,
|
|
45
45
|
Dialect extends string
|
|
46
46
|
> {
|
|
47
|
-
readonly selection:
|
|
47
|
+
readonly selection: Columns
|
|
48
48
|
readonly required: Required
|
|
49
49
|
readonly available: Available
|
|
50
50
|
readonly dialect: Dialect
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* A composable logical
|
|
54
|
+
* A composable logical row set.
|
|
55
55
|
*
|
|
56
56
|
* Tables implement this interface as already-complete plans. Future query
|
|
57
57
|
* builders such as `select()` and `from()` should produce and transform values
|
|
58
58
|
* with this same structure.
|
|
59
59
|
*/
|
|
60
|
-
export interface
|
|
61
|
-
|
|
60
|
+
export interface RowSet<
|
|
61
|
+
Columns,
|
|
62
62
|
Required = never,
|
|
63
63
|
Available extends Record<string, AnySource> = {},
|
|
64
64
|
Dialect extends string = never
|
|
65
65
|
> extends Pipeable {
|
|
66
|
-
readonly [TypeId]: State<
|
|
66
|
+
readonly [TypeId]: State<Columns, Required, Available, Dialect>
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/** Convenience alias for any plan-like value. */
|
|
70
|
-
export type Any =
|
|
70
|
+
export type Any = RowSet<any, any, Record<string, AnySource>, string>
|
|
71
|
+
/** Extracts a row set's columns shape. */
|
|
72
|
+
export type ColumnsOf<Value extends Any> = Value[typeof TypeId]["selection"]
|
|
71
73
|
/** Extracts a plan's selection shape. */
|
|
72
|
-
export type SelectionOf<Value extends Any> = Value
|
|
74
|
+
export type SelectionOf<Value extends Any> = ColumnsOf<Value>
|
|
73
75
|
/** Extracts a plan's effective dialect. */
|
|
74
76
|
export type DialectOf<Value extends Any> = Value[typeof TypeId]["dialect"]
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import type * as Expression from "
|
|
2
|
-
import {
|
|
3
|
-
import { postgresDatatypeKinds } from "../postgres/datatypes/spec.js"
|
|
4
|
-
import type { RuntimeTag } from "./datatypes/shape.js"
|
|
5
|
-
|
|
6
|
-
const stripParameterizedKind = (kind: string): string => {
|
|
7
|
-
const openParen = kind.indexOf("(")
|
|
8
|
-
return openParen === -1 ? kind : kind.slice(0, openParen)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const stripArrayKind = (kind: string): string => {
|
|
12
|
-
let current = kind
|
|
13
|
-
while (current.endsWith("[]")) {
|
|
14
|
-
current = current.slice(0, -2)
|
|
15
|
-
}
|
|
16
|
-
return current
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const baseKind = (kind: string): string => stripArrayKind(stripParameterizedKind(kind))
|
|
1
|
+
import type * as Expression from "../scalar.js"
|
|
2
|
+
import type { RuntimeTag } from "../datatypes/shape.js"
|
|
20
3
|
|
|
21
4
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
22
5
|
typeof value === "object" && value !== null && !Array.isArray(value)
|
|
@@ -39,17 +22,9 @@ const formatLocalDateTime = (value: Date): string => {
|
|
|
39
22
|
}
|
|
40
23
|
|
|
41
24
|
const runtimeTagOfBaseDbType = (
|
|
42
|
-
|
|
43
|
-
kind: string
|
|
25
|
+
dbType: Expression.DbType.Base<string, string>
|
|
44
26
|
): RuntimeTag | undefined => {
|
|
45
|
-
|
|
46
|
-
if (dialect === "postgres") {
|
|
47
|
-
return postgresDatatypeKinds[normalizedKind as keyof typeof postgresDatatypeKinds]?.runtime
|
|
48
|
-
}
|
|
49
|
-
if (dialect === "mysql") {
|
|
50
|
-
return mysqlDatatypeKinds[normalizedKind as keyof typeof mysqlDatatypeKinds]?.runtime
|
|
51
|
-
}
|
|
52
|
-
return undefined
|
|
27
|
+
return dbType.runtime
|
|
53
28
|
}
|
|
54
29
|
|
|
55
30
|
const expectString = (value: unknown, label: string): string => {
|
|
@@ -225,7 +200,10 @@ const normalizeBytes = (value: unknown): Uint8Array => {
|
|
|
225
200
|
if (value instanceof Uint8Array) {
|
|
226
201
|
return new Uint8Array(value)
|
|
227
202
|
}
|
|
228
|
-
|
|
203
|
+
const BufferConstructor = (globalThis as {
|
|
204
|
+
readonly Buffer?: abstract new (...args: never[]) => Uint8Array
|
|
205
|
+
}).Buffer
|
|
206
|
+
if (BufferConstructor !== undefined && value instanceof BufferConstructor) {
|
|
229
207
|
return new Uint8Array(value)
|
|
230
208
|
}
|
|
231
209
|
throw new Error("Expected a byte array value")
|
|
@@ -298,7 +276,7 @@ export const normalizeDbValue = (
|
|
|
298
276
|
if ("variant" in dbType && (dbType.variant === "enum" || dbType.variant === "set")) {
|
|
299
277
|
return expectString(value, "text")
|
|
300
278
|
}
|
|
301
|
-
switch (runtimeTagOfBaseDbType(dbType
|
|
279
|
+
switch (runtimeTagOfBaseDbType(dbType)) {
|
|
302
280
|
case "string":
|
|
303
281
|
return expectString(value, "text")
|
|
304
282
|
case "number":
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema"
|
|
2
2
|
import * as SchemaAST from "effect/SchemaAST"
|
|
3
3
|
|
|
4
|
-
import * as Expression from "
|
|
5
|
-
import * as ExpressionAst from "
|
|
6
|
-
import * as Query from "
|
|
7
|
-
import * as JsonPath from "
|
|
8
|
-
import type { PredicateFormula } from "
|
|
4
|
+
import * as Expression from "../scalar.js"
|
|
5
|
+
import * as ExpressionAst from "../expression-ast.js"
|
|
6
|
+
import * as Query from "../query.js"
|
|
7
|
+
import * as JsonPath from "../json/path.js"
|
|
8
|
+
import type { PredicateFormula } from "../predicate/formula.js"
|
|
9
9
|
import {
|
|
10
10
|
assumeFormulaFalse,
|
|
11
11
|
assumeFormulaTrue,
|
|
12
12
|
contradictsFormula,
|
|
13
13
|
formulaOfExpression as formulaOfExpressionRuntime,
|
|
14
14
|
impliesFormula
|
|
15
|
-
} from "
|
|
16
|
-
import { flattenSelection } from "
|
|
15
|
+
} from "../predicate/runtime.js"
|
|
16
|
+
import { flattenSelection } from "../projections.js"
|
|
17
17
|
import {
|
|
18
18
|
BigIntStringSchema,
|
|
19
19
|
DecimalStringSchema,
|
|
@@ -24,10 +24,8 @@ import {
|
|
|
24
24
|
LocalTimeStringSchema,
|
|
25
25
|
OffsetTimeStringSchema,
|
|
26
26
|
YearStringSchema
|
|
27
|
-
} from "./
|
|
28
|
-
import {
|
|
29
|
-
import { postgresDatatypeKinds } from "../postgres/datatypes/spec.js"
|
|
30
|
-
import type { RuntimeTag } from "./datatypes/shape.js"
|
|
27
|
+
} from "./value.js"
|
|
28
|
+
import type { RuntimeTag } from "../datatypes/shape.js"
|
|
31
29
|
|
|
32
30
|
export type RuntimeSchema = Schema.Schema<any, any, any>
|
|
33
31
|
|
|
@@ -37,21 +35,6 @@ type SchemaContext = {
|
|
|
37
35
|
|
|
38
36
|
const schemaCache = new WeakMap<Expression.Any, RuntimeSchema | undefined>()
|
|
39
37
|
|
|
40
|
-
const stripParameterizedKind = (kind: string): string => {
|
|
41
|
-
const openParen = kind.indexOf("(")
|
|
42
|
-
return openParen === -1 ? kind : kind.slice(0, openParen)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const stripArrayKind = (kind: string): string => {
|
|
46
|
-
let current = kind
|
|
47
|
-
while (current.endsWith("[]")) {
|
|
48
|
-
current = current.slice(0, -2)
|
|
49
|
-
}
|
|
50
|
-
return current
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const baseKind = (kind: string): string => stripArrayKind(stripParameterizedKind(kind))
|
|
54
|
-
|
|
55
38
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
56
39
|
typeof value === "object" && value !== null && !Array.isArray(value)
|
|
57
40
|
|
|
@@ -98,17 +81,9 @@ const runtimeSchemaForTag = (tag: RuntimeTag): RuntimeSchema | undefined => {
|
|
|
98
81
|
}
|
|
99
82
|
|
|
100
83
|
const runtimeTagOfBaseDbType = (
|
|
101
|
-
|
|
102
|
-
kind: string
|
|
84
|
+
dbType: Expression.DbType.Base<string, string>
|
|
103
85
|
): RuntimeTag | undefined => {
|
|
104
|
-
|
|
105
|
-
if (dialect === "postgres") {
|
|
106
|
-
return postgresDatatypeKinds[normalizedKind as keyof typeof postgresDatatypeKinds]?.runtime
|
|
107
|
-
}
|
|
108
|
-
if (dialect === "mysql") {
|
|
109
|
-
return mysqlDatatypeKinds[normalizedKind as keyof typeof mysqlDatatypeKinds]?.runtime
|
|
110
|
-
}
|
|
111
|
-
return undefined
|
|
86
|
+
return dbType.runtime
|
|
112
87
|
}
|
|
113
88
|
|
|
114
89
|
export const runtimeSchemaForDbType = (
|
|
@@ -132,7 +107,7 @@ export const runtimeSchemaForDbType = (
|
|
|
132
107
|
if ("variant" in dbType && (dbType.variant === "enum" || dbType.variant === "set")) {
|
|
133
108
|
return Schema.String
|
|
134
109
|
}
|
|
135
|
-
const runtimeTag = runtimeTagOfBaseDbType(dbType
|
|
110
|
+
const runtimeTag = runtimeTagOfBaseDbType(dbType)
|
|
136
111
|
return runtimeTag === undefined ? undefined : runtimeSchemaForTag(runtimeTag)
|
|
137
112
|
}
|
|
138
113
|
|
|
@@ -257,7 +232,7 @@ const unionSchemas = (schemas: ReadonlyArray<RuntimeSchema | undefined>): Runtim
|
|
|
257
232
|
}
|
|
258
233
|
|
|
259
234
|
const firstSelectedExpression = (
|
|
260
|
-
plan: Query.
|
|
235
|
+
plan: Query.Plan.Any
|
|
261
236
|
): Expression.Any | undefined => {
|
|
262
237
|
const selection = Query.getAst(plan).select
|
|
263
238
|
return flattenSelection(selection as Record<string, unknown>)[0]?.expression
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type * as Brand from "effect/Brand";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import type { JsonPrimitive, JsonValue } from "../json/types.js";
|
|
4
|
+
export type { JsonPrimitive, JsonValue } from "../json/types.js";
|
|
5
|
+
export type LocalDateString = string & Brand.Brand<"LocalDateString">;
|
|
6
|
+
export type LocalTimeString = string & Brand.Brand<"LocalTimeString">;
|
|
7
|
+
export type OffsetTimeString = string & Brand.Brand<"OffsetTimeString">;
|
|
8
|
+
export type LocalDateTimeString = string & Brand.Brand<"LocalDateTimeString">;
|
|
9
|
+
export type InstantString = string & Brand.Brand<"InstantString">;
|
|
10
|
+
export type YearString = string & Brand.Brand<"YearString">;
|
|
11
|
+
export type BigIntString = string & Brand.Brand<"BigIntString">;
|
|
12
|
+
export type DecimalString = string & Brand.Brand<"DecimalString">;
|
|
13
|
+
export declare const LocalDateStringSchema: Schema.Schema<string & Brand.Brand<"LocalDateString">, string & Brand.Brand<"LocalDateString">, never>;
|
|
14
|
+
export declare const LocalTimeStringSchema: Schema.Schema<string & Brand.Brand<"LocalTimeString">, string & Brand.Brand<"LocalTimeString">, never>;
|
|
15
|
+
export declare const OffsetTimeStringSchema: Schema.Schema<string & Brand.Brand<"OffsetTimeString">, string & Brand.Brand<"OffsetTimeString">, never>;
|
|
16
|
+
export declare const LocalDateTimeStringSchema: Schema.Schema<string & Brand.Brand<"LocalDateTimeString">, string & Brand.Brand<"LocalDateTimeString">, never>;
|
|
17
|
+
export declare const InstantStringSchema: Schema.Schema<string & Brand.Brand<"InstantString">, string & Brand.Brand<"InstantString">, never>;
|
|
18
|
+
export declare const YearStringSchema: Schema.Schema<string & Brand.Brand<"YearString">, string & Brand.Brand<"YearString">, never>;
|
|
19
|
+
export declare const BigIntStringSchema: Schema.Schema<string & Brand.Brand<"BigIntString">, string & Brand.Brand<"BigIntString">, never>;
|
|
20
|
+
export declare const DecimalStringSchema: Schema.Schema<string & Brand.Brand<"DecimalString">, string & Brand.Brand<"DecimalString">, never>;
|
|
21
|
+
export declare const JsonValueSchema: Schema.Schema<JsonValue>;
|
|
22
|
+
export declare const JsonPrimitiveSchema: Schema.Schema<JsonPrimitive>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as Brand from "effect/Brand"
|
|
2
2
|
import * as Schema from "effect/Schema"
|
|
3
3
|
|
|
4
|
-
import type { JsonPrimitive, JsonValue } from "
|
|
4
|
+
import type { JsonPrimitive, JsonValue } from "../json/types.js"
|
|
5
5
|
|
|
6
|
-
export type { JsonPrimitive, JsonValue } from "
|
|
6
|
+
export type { JsonPrimitive, JsonValue } from "../json/types.js"
|
|
7
7
|
|
|
8
8
|
export type LocalDateString = string & Brand.Brand<"LocalDateString">
|
|
9
9
|
export type LocalTimeString = string & Brand.Brand<"LocalTimeString">
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Pipeable } from "effect/Pipeable";
|
|
2
|
+
import type * as Schema from "effect/Schema";
|
|
3
|
+
import type { RuntimeOfDbType as RuntimeOfDbTypeLookup } from "./datatypes/lookup.js";
|
|
4
|
+
import type { DatatypeTraits, RuntimeTag } from "./datatypes/shape.js";
|
|
5
|
+
export type { BigIntString, DecimalString, InstantString, JsonPrimitive, JsonValue, LocalDateString, LocalDateTimeString, LocalTimeString, OffsetTimeString, YearString } from "./runtime/value.js";
|
|
6
|
+
/** Symbol used to attach expression metadata to runtime values. */
|
|
7
|
+
export declare const TypeId: unique symbol;
|
|
8
|
+
export type TypeId = typeof TypeId;
|
|
9
|
+
/** Scope-local binding identifier used for dependency tracking. */
|
|
10
|
+
export type BindingId = string;
|
|
11
|
+
/**
|
|
12
|
+
* Three-state nullability lattice.
|
|
13
|
+
*
|
|
14
|
+
* `"never"` means non-null, `"maybe"` means nullable, and `"always"` means the
|
|
15
|
+
* expression is known to be `null`.
|
|
16
|
+
*/
|
|
17
|
+
export type Nullability = "never" | "maybe" | "always";
|
|
18
|
+
/**
|
|
19
|
+
* High-level classification of an expression.
|
|
20
|
+
*
|
|
21
|
+
* - `scalar`: regular per-row expression
|
|
22
|
+
* - `aggregate`: grouped expression such as `count(*)`
|
|
23
|
+
* - `window`: windowed expression such as `row_number() over (...)`
|
|
24
|
+
*/
|
|
25
|
+
export type ScalarKind = "scalar" | "aggregate" | "window";
|
|
26
|
+
/** Database-type descriptors carried alongside decoded runtime types. */
|
|
27
|
+
export declare namespace DbType {
|
|
28
|
+
/** Base SQL type descriptor. */
|
|
29
|
+
interface Base<Dialect extends string, Kind extends string> {
|
|
30
|
+
readonly dialect: Dialect;
|
|
31
|
+
readonly kind: Kind;
|
|
32
|
+
readonly family?: string;
|
|
33
|
+
readonly runtime?: RuntimeTag;
|
|
34
|
+
readonly compareGroup?: string;
|
|
35
|
+
readonly castTargets?: readonly string[];
|
|
36
|
+
readonly traits?: DatatypeTraits;
|
|
37
|
+
}
|
|
38
|
+
/** JSON-like database type. */
|
|
39
|
+
interface Json<Dialect extends string = string, SchemaName extends string = "json"> extends Base<Dialect, SchemaName> {
|
|
40
|
+
readonly variant: SchemaName extends "jsonb" ? "jsonb" : "json";
|
|
41
|
+
}
|
|
42
|
+
/** Array database type. */
|
|
43
|
+
interface Array<Dialect extends string = string, Element extends Any = any, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
44
|
+
readonly element: Element;
|
|
45
|
+
}
|
|
46
|
+
/** Range database type. */
|
|
47
|
+
interface Range<Dialect extends string = string, Subtype extends Any = any, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
48
|
+
readonly subtype: Subtype;
|
|
49
|
+
}
|
|
50
|
+
/** Multirange database type. */
|
|
51
|
+
interface Multirange<Dialect extends string = string, Subtype extends Any = any, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
52
|
+
readonly subtype: Subtype;
|
|
53
|
+
}
|
|
54
|
+
/** Composite/record database type. */
|
|
55
|
+
interface Composite<Dialect extends string = string, Fields extends Record<string, Any> = Record<string, any>, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
56
|
+
readonly fields: Fields;
|
|
57
|
+
}
|
|
58
|
+
/** Named domain database type. */
|
|
59
|
+
interface Domain<Dialect extends string = string, BaseType extends Any = any, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
60
|
+
readonly base: BaseType;
|
|
61
|
+
}
|
|
62
|
+
/** Enumeration database type. */
|
|
63
|
+
interface Enum<Dialect extends string = string, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
64
|
+
readonly variant: "enum";
|
|
65
|
+
}
|
|
66
|
+
/** Set database type. */
|
|
67
|
+
interface Set<Dialect extends string = string, Kind extends string = string> extends Base<Dialect, Kind> {
|
|
68
|
+
readonly variant: "set";
|
|
69
|
+
}
|
|
70
|
+
type Any = Json | Base<string, string> | Array<string, any, string> | Range<string, any, string> | Multirange<string, any, string> | Composite<string, Record<string, any>, string> | Domain<string, any, string> | Enum<string, string> | Set<string, string>;
|
|
71
|
+
}
|
|
72
|
+
/** Canonical static metadata stored on an expression. */
|
|
73
|
+
export interface State<Runtime, Db extends DbType.Any, Nullable extends Nullability, Dialect extends string, Kind extends ScalarKind, Deps extends BindingId = never> {
|
|
74
|
+
readonly runtime: Runtime;
|
|
75
|
+
readonly dbType: Db;
|
|
76
|
+
readonly runtimeSchema?: Schema.Schema.Any;
|
|
77
|
+
readonly nullability: Nullable;
|
|
78
|
+
readonly dialect: Dialect;
|
|
79
|
+
readonly kind: Kind;
|
|
80
|
+
readonly dependencies: Record<string, true>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A typed scalar SQL expression.
|
|
84
|
+
*
|
|
85
|
+
* `Runtime` is the decoded TypeScript type while `Db` captures the SQL-level
|
|
86
|
+
* type identity. Both are needed: multiple SQL types may decode to the same
|
|
87
|
+
* runtime type but still have different comparison/cast semantics.
|
|
88
|
+
*/
|
|
89
|
+
export interface Scalar<Runtime, Db extends DbType.Any, Nullable extends Nullability = "never", Dialect extends string = Db["dialect"], Kind extends ScalarKind = "scalar", Deps extends BindingId = never, GroupKey extends string = string> extends Pipeable {
|
|
90
|
+
readonly [TypeId]: State<Runtime, Db, Nullable, Dialect, Kind, Deps>;
|
|
91
|
+
}
|
|
92
|
+
/** Convenience alias for any expression-like value. */
|
|
93
|
+
export type Any = Scalar<any, DbType.Any, Nullability, string, ScalarKind, BindingId, string>;
|
|
94
|
+
/** Extracts an expression's decoded runtime type. */
|
|
95
|
+
export type RuntimeOf<Value extends Any> = Value[typeof TypeId]["runtime"];
|
|
96
|
+
/** Extracts an expression's database-type descriptor. */
|
|
97
|
+
export type DbTypeOf<Value extends Any> = Value[typeof TypeId]["dbType"];
|
|
98
|
+
/** Extracts an expression's nullability state. */
|
|
99
|
+
export type NullabilityOf<Value extends Any> = Value[typeof TypeId]["nullability"];
|
|
100
|
+
/** Extracts an expression's kind. */
|
|
101
|
+
export type KindOf<Value extends Any> = Value[typeof TypeId]["kind"];
|
|
102
|
+
/** Extracts an expression's source dependency union. */
|
|
103
|
+
export type DependenciesOf<Value extends Any> = Value extends Scalar<any, any, any, any, any, infer Deps> ? Deps : never;
|
|
104
|
+
/** Extracts an expression's grouping identity. */
|
|
105
|
+
export type GroupKeyOf<Value extends Any> = Value extends Scalar<any, any, any, any, any, any, infer GroupKey> ? GroupKey : never;
|
|
106
|
+
/** Maps a database type descriptor back to its decoded runtime type. */
|
|
107
|
+
export type RuntimeOfDbType<Db extends DbType.Any> = RuntimeOfDbTypeLookup<Db>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { Pipeable } from "effect/Pipeable"
|
|
2
|
+
import type * as Schema from "effect/Schema"
|
|
3
|
+
import type { RuntimeOfDbType as RuntimeOfDbTypeLookup } from "./datatypes/lookup.js"
|
|
4
|
+
import type { DatatypeTraits, RuntimeTag } from "./datatypes/shape.js"
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
BigIntString,
|
|
8
|
+
DecimalString,
|
|
9
|
+
InstantString,
|
|
10
|
+
JsonPrimitive,
|
|
11
|
+
JsonValue,
|
|
12
|
+
LocalDateString,
|
|
13
|
+
LocalDateTimeString,
|
|
14
|
+
LocalTimeString,
|
|
15
|
+
OffsetTimeString,
|
|
16
|
+
YearString
|
|
17
|
+
} from "./runtime/value.js"
|
|
18
|
+
|
|
19
|
+
/** Symbol used to attach expression metadata to runtime values. */
|
|
20
|
+
export const TypeId: unique symbol = Symbol.for("effect-qb/Expression")
|
|
21
|
+
|
|
22
|
+
export type TypeId = typeof TypeId
|
|
23
|
+
|
|
24
|
+
/** Scope-local binding identifier used for dependency tracking. */
|
|
25
|
+
export type BindingId = string
|
|
26
|
+
/**
|
|
27
|
+
* Three-state nullability lattice.
|
|
28
|
+
*
|
|
29
|
+
* `"never"` means non-null, `"maybe"` means nullable, and `"always"` means the
|
|
30
|
+
* expression is known to be `null`.
|
|
31
|
+
*/
|
|
32
|
+
export type Nullability = "never" | "maybe" | "always"
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* High-level classification of an expression.
|
|
36
|
+
*
|
|
37
|
+
* - `scalar`: regular per-row expression
|
|
38
|
+
* - `aggregate`: grouped expression such as `count(*)`
|
|
39
|
+
* - `window`: windowed expression such as `row_number() over (...)`
|
|
40
|
+
*/
|
|
41
|
+
export type ScalarKind = "scalar" | "aggregate" | "window"
|
|
42
|
+
|
|
43
|
+
/** Database-type descriptors carried alongside decoded runtime types. */
|
|
44
|
+
export declare namespace DbType {
|
|
45
|
+
/** Base SQL type descriptor. */
|
|
46
|
+
export interface Base<Dialect extends string, Kind extends string> {
|
|
47
|
+
readonly dialect: Dialect
|
|
48
|
+
readonly kind: Kind
|
|
49
|
+
readonly family?: string
|
|
50
|
+
readonly runtime?: RuntimeTag
|
|
51
|
+
readonly compareGroup?: string
|
|
52
|
+
readonly castTargets?: readonly string[]
|
|
53
|
+
readonly traits?: DatatypeTraits
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** JSON-like database type. */
|
|
57
|
+
export interface Json<
|
|
58
|
+
Dialect extends string = string,
|
|
59
|
+
SchemaName extends string = "json"
|
|
60
|
+
> extends Base<Dialect, SchemaName>
|
|
61
|
+
{
|
|
62
|
+
readonly variant: SchemaName extends "jsonb" ? "jsonb" : "json"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Array database type. */
|
|
66
|
+
export interface Array<
|
|
67
|
+
Dialect extends string = string,
|
|
68
|
+
Element extends Any = any,
|
|
69
|
+
Kind extends string = string
|
|
70
|
+
> extends Base<Dialect, Kind> {
|
|
71
|
+
readonly element: Element
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Range database type. */
|
|
75
|
+
export interface Range<
|
|
76
|
+
Dialect extends string = string,
|
|
77
|
+
Subtype extends Any = any,
|
|
78
|
+
Kind extends string = string
|
|
79
|
+
> extends Base<Dialect, Kind> {
|
|
80
|
+
readonly subtype: Subtype
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Multirange database type. */
|
|
84
|
+
export interface Multirange<
|
|
85
|
+
Dialect extends string = string,
|
|
86
|
+
Subtype extends Any = any,
|
|
87
|
+
Kind extends string = string
|
|
88
|
+
> extends Base<Dialect, Kind> {
|
|
89
|
+
readonly subtype: Subtype
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Composite/record database type. */
|
|
93
|
+
export interface Composite<
|
|
94
|
+
Dialect extends string = string,
|
|
95
|
+
Fields extends Record<string, Any> = Record<string, any>,
|
|
96
|
+
Kind extends string = string
|
|
97
|
+
> extends Base<Dialect, Kind> {
|
|
98
|
+
readonly fields: Fields
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Named domain database type. */
|
|
102
|
+
export interface Domain<
|
|
103
|
+
Dialect extends string = string,
|
|
104
|
+
BaseType extends Any = any,
|
|
105
|
+
Kind extends string = string
|
|
106
|
+
> extends Base<Dialect, Kind> {
|
|
107
|
+
readonly base: BaseType
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Enumeration database type. */
|
|
111
|
+
export interface Enum<
|
|
112
|
+
Dialect extends string = string,
|
|
113
|
+
Kind extends string = string
|
|
114
|
+
> extends Base<Dialect, Kind> {
|
|
115
|
+
readonly variant: "enum"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Set database type. */
|
|
119
|
+
export interface Set<
|
|
120
|
+
Dialect extends string = string,
|
|
121
|
+
Kind extends string = string
|
|
122
|
+
> extends Base<Dialect, Kind> {
|
|
123
|
+
readonly variant: "set"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type Any =
|
|
127
|
+
| Json
|
|
128
|
+
| Base<string, string>
|
|
129
|
+
| Array<string, any, string>
|
|
130
|
+
| Range<string, any, string>
|
|
131
|
+
| Multirange<string, any, string>
|
|
132
|
+
| Composite<string, Record<string, any>, string>
|
|
133
|
+
| Domain<string, any, string>
|
|
134
|
+
| Enum<string, string>
|
|
135
|
+
| Set<string, string>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Canonical static metadata stored on an expression. */
|
|
139
|
+
export interface State<
|
|
140
|
+
Runtime,
|
|
141
|
+
Db extends DbType.Any,
|
|
142
|
+
Nullable extends Nullability,
|
|
143
|
+
Dialect extends string,
|
|
144
|
+
Kind extends ScalarKind,
|
|
145
|
+
Deps extends BindingId = never
|
|
146
|
+
> {
|
|
147
|
+
readonly runtime: Runtime
|
|
148
|
+
readonly dbType: Db
|
|
149
|
+
readonly runtimeSchema?: Schema.Schema.Any
|
|
150
|
+
readonly nullability: Nullable
|
|
151
|
+
readonly dialect: Dialect
|
|
152
|
+
readonly kind: Kind
|
|
153
|
+
readonly dependencies: Record<string, true>
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A typed scalar SQL expression.
|
|
158
|
+
*
|
|
159
|
+
* `Runtime` is the decoded TypeScript type while `Db` captures the SQL-level
|
|
160
|
+
* type identity. Both are needed: multiple SQL types may decode to the same
|
|
161
|
+
* runtime type but still have different comparison/cast semantics.
|
|
162
|
+
*/
|
|
163
|
+
export interface Scalar<
|
|
164
|
+
Runtime,
|
|
165
|
+
Db extends DbType.Any,
|
|
166
|
+
Nullable extends Nullability = "never",
|
|
167
|
+
Dialect extends string = Db["dialect"],
|
|
168
|
+
Kind extends ScalarKind = "scalar",
|
|
169
|
+
Deps extends BindingId = never,
|
|
170
|
+
GroupKey extends string = string
|
|
171
|
+
> extends Pipeable {
|
|
172
|
+
readonly [TypeId]: State<Runtime, Db, Nullable, Dialect, Kind, Deps>
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Convenience alias for any expression-like value. */
|
|
176
|
+
export type Any = Scalar<any, DbType.Any, Nullability, string, ScalarKind, BindingId, string>
|
|
177
|
+
/** Extracts an expression's decoded runtime type. */
|
|
178
|
+
export type RuntimeOf<Value extends Any> = Value[typeof TypeId]["runtime"]
|
|
179
|
+
/** Extracts an expression's database-type descriptor. */
|
|
180
|
+
export type DbTypeOf<Value extends Any> = Value[typeof TypeId]["dbType"]
|
|
181
|
+
/** Extracts an expression's nullability state. */
|
|
182
|
+
export type NullabilityOf<Value extends Any> = Value[typeof TypeId]["nullability"]
|
|
183
|
+
/** Extracts an expression's kind. */
|
|
184
|
+
export type KindOf<Value extends Any> = Value[typeof TypeId]["kind"]
|
|
185
|
+
/** Extracts an expression's source dependency union. */
|
|
186
|
+
export type DependenciesOf<Value extends Any> = Value extends Scalar<any, any, any, any, any, infer Deps> ? Deps : never
|
|
187
|
+
/** Extracts an expression's grouping identity. */
|
|
188
|
+
export type GroupKeyOf<Value extends Any> = Value extends Scalar<any, any, any, any, any, any, infer GroupKey> ? GroupKey : never
|
|
189
|
+
|
|
190
|
+
/** Maps a database type descriptor back to its decoded runtime type. */
|
|
191
|
+
export type RuntimeOfDbType<Db extends DbType.Any> = RuntimeOfDbTypeLookup<Db>
|