@bjornpagen/bumbledb 1.2.1 → 1.3.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/COOKBOOK.md +240 -9
- package/README.md +9 -6
- package/dist/alternatives.d.ts +25 -0
- package/dist/alternatives.d.ts.map +1 -0
- package/dist/alternatives.js +59 -0
- package/dist/alternatives.js.map +1 -0
- package/dist/changes.d.ts +0 -1
- package/dist/changes.d.ts.map +1 -1
- package/dist/changes.js +2 -8
- package/dist/changes.js.map +1 -1
- package/dist/codec.d.ts +8 -1
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +29 -2
- package/dist/codec.js.map +1 -1
- package/dist/db-native.d.ts +2 -9
- package/dist/db-native.d.ts.map +1 -1
- package/dist/db-native.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/log.d.ts +4 -4
- package/dist/internal/log.d.ts.map +1 -1
- package/dist/internal/log.js +2 -2
- package/dist/internal/log.js.map +1 -1
- package/dist/native.d.ts +23 -9
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/query/atom.d.ts +2 -1
- package/dist/query/atom.d.ts.map +1 -1
- package/dist/query/atom.js.map +1 -1
- package/dist/query/compute.d.ts +19 -4
- package/dist/query/compute.d.ts.map +1 -1
- package/dist/query/compute.js +17 -13
- package/dist/query/compute.js.map +1 -1
- package/dist/query/description.d.ts +10 -2
- package/dist/query/description.d.ts.map +1 -1
- package/dist/query/description.js +14 -5
- package/dist/query/description.js.map +1 -1
- package/dist/query/find.d.ts +13 -6
- package/dist/query/find.d.ts.map +1 -1
- package/dist/query/find.js +1 -1
- package/dist/query/find.js.map +1 -1
- package/dist/query/lower.d.ts +14 -2
- package/dist/query/lower.d.ts.map +1 -1
- package/dist/query/lower.js +64 -50
- package/dist/query/lower.js.map +1 -1
- package/dist/query/parse-ir.d.ts.map +1 -1
- package/dist/query/parse-ir.js +26 -3
- package/dist/query/parse-ir.js.map +1 -1
- package/dist/query/scope.d.ts.map +1 -1
- package/dist/query/scope.js +6 -1
- package/dist/query/scope.js.map +1 -1
- package/dist/query/segments.d.ts +20 -0
- package/dist/query/segments.d.ts.map +1 -0
- package/dist/query/segments.js +35 -0
- package/dist/query/segments.js.map +1 -0
- package/dist/runtime-codes.d.ts +1 -1
- package/dist/runtime-codes.d.ts.map +1 -1
- package/dist/runtime-codes.js +1 -0
- package/dist/runtime-codes.js.map +1 -1
- package/dist/runtime-errors.d.ts +23 -3
- package/dist/runtime-errors.d.ts.map +1 -1
- package/dist/runtime-errors.js +16 -3
- package/dist/runtime-errors.js.map +1 -1
- package/dist/runtime-native.d.ts +3 -8
- package/dist/runtime-native.d.ts.map +1 -1
- package/dist/runtime-native.js.map +1 -1
- package/dist/runtime.d.ts +0 -23
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +0 -36
- package/dist/runtime.js.map +1 -1
- package/dist/scalar.d.ts +46 -94
- package/dist/scalar.d.ts.map +1 -1
- package/dist/scalar.js +69 -156
- package/dist/scalar.js.map +1 -1
- package/dist/schema-file.d.ts +7 -0
- package/dist/schema-file.d.ts.map +1 -0
- package/dist/schema-file.js +24 -0
- package/dist/schema-file.js.map +1 -0
- package/pack-provenance.json +4 -4
- package/package.json +4 -4
- package/src/alternatives.ts +95 -0
- package/src/changes.ts +2 -8
- package/src/codec.ts +43 -3
- package/src/db-native.ts +2 -10
- package/src/index.ts +23 -6
- package/src/internal/log.ts +2 -4
- package/src/native.ts +21 -7
- package/src/query/atom.ts +2 -0
- package/src/query/compute.ts +46 -16
- package/src/query/description.ts +38 -8
- package/src/query/find.ts +37 -26
- package/src/query/lower.ts +89 -52
- package/src/query/parse-ir.ts +27 -3
- package/src/query/scope.ts +8 -1
- package/src/query/segments.ts +61 -0
- package/src/runtime-codes.ts +1 -0
- package/src/runtime-errors.ts +16 -3
- package/src/runtime-native.ts +1 -9
- package/src/runtime.ts +1 -70
- package/src/scalar.ts +138 -285
- package/src/schema-file.ts +38 -0
- package/dist/migration.d.ts +0 -31
- package/dist/migration.d.ts.map +0 -1
- package/dist/migration.js +0 -47
- package/dist/migration.js.map +0 -1
- package/src/migration.ts +0 -61
package/dist/scalar.d.ts
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
+
import type { ScalarExprIr } from "./native.js";
|
|
1
2
|
import type { ValueSpec } from "./spec.js";
|
|
2
|
-
/** F0: leaf scope for the shared AST (C1). Query vars are typed; source fields stay unresolved. */
|
|
3
|
-
export type ScalarLeafScope = "query-var" | "source-field";
|
|
4
3
|
/** The engine's scalar result vocabulary — distinct at the type level. */
|
|
5
4
|
type ScalarKind = "u64" | "i64" | "f64" | "bool";
|
|
6
5
|
/** Cached result kind: known only when derivable; otherwise honestly unresolved. */
|
|
7
|
-
type
|
|
6
|
+
type IntervalKind = "intervalU64" | "intervalI64" | "intervalF64";
|
|
7
|
+
type ScalarInputKind = ScalarKind | IntervalKind;
|
|
8
|
+
type ScalarResultKind = ScalarInputKind;
|
|
9
|
+
type Rounding = "towardZero" | "nearestTiesAwayFromZero" | "nearestTiesToEven";
|
|
8
10
|
/** Host value for a derived scalar kind. */
|
|
9
11
|
type ScalarValue<K extends ScalarKind> = K extends "f64" ? number : K extends "bool" ? boolean : bigint;
|
|
10
12
|
type NumericCast = "toF64" | "toF64Exact" | "toI64Exact" | "toU64Exact";
|
|
11
13
|
type NumericKind = "u64" | "i64" | "f64";
|
|
12
|
-
type NumericOrUnresolved = NumericKind | "unresolved";
|
|
13
|
-
/**
|
|
14
|
-
* Combine known numeric kinds, or stay unresolved when a source-field leaf
|
|
15
|
-
* still needs native binding. Distinct known kinds collapse to `never`
|
|
16
|
-
* (static refusal) and throw at the constructor.
|
|
17
|
-
*/
|
|
18
|
-
type CombineNumeric<L, R> = L extends "unresolved" ? R extends "bool" ? never : "unresolved" : R extends "unresolved" ? L extends "bool" ? never : "unresolved" : L extends R ? L : never;
|
|
19
|
-
/** The tagged literal subset shared by every leaf scope. */
|
|
20
14
|
type ScalarLiteral = {
|
|
21
15
|
readonly bool: boolean;
|
|
22
16
|
} | {
|
|
@@ -26,7 +20,7 @@ type ScalarLiteral = {
|
|
|
26
20
|
} | {
|
|
27
21
|
readonly f64: number;
|
|
28
22
|
};
|
|
29
|
-
type ScalarOpKind = "literal" | "negate" | "isNaN" | "isFinite" | "add" | "subtract" | "multiply" | "divide" | "cast";
|
|
23
|
+
type ScalarOpKind = "literal" | "negate" | "isNaN" | "isFinite" | "add" | "subtract" | "multiply" | "divide" | "cast" | "mulDiv" | "measure";
|
|
30
24
|
/**
|
|
31
25
|
* Structural query-variable leaf. The query layer supplies a bound variable
|
|
32
26
|
* whose field kind is already a schema kind; this module does not import
|
|
@@ -42,62 +36,53 @@ type QueryVarLeaf = {
|
|
|
42
36
|
readonly kind: "var";
|
|
43
37
|
readonly ref: ScalarQueryVar;
|
|
44
38
|
};
|
|
45
|
-
type
|
|
46
|
-
readonly kind: "
|
|
47
|
-
readonly
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
type ScalarNodeBody = {
|
|
40
|
+
readonly kind: "measure";
|
|
41
|
+
readonly expr: ScalarNode;
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "mulDiv";
|
|
44
|
+
readonly a: ScalarNode;
|
|
45
|
+
readonly b: ScalarNode;
|
|
46
|
+
readonly divisor: ScalarNode;
|
|
47
|
+
readonly rounding: Rounding;
|
|
48
|
+
} | QueryVarLeaf | {
|
|
51
49
|
readonly kind: "literal";
|
|
52
50
|
readonly value: ScalarLiteral;
|
|
53
51
|
} | {
|
|
54
52
|
readonly kind: "negate";
|
|
55
|
-
readonly expr: ScalarNode
|
|
53
|
+
readonly expr: ScalarNode;
|
|
56
54
|
} | {
|
|
57
55
|
readonly kind: "isNaN";
|
|
58
|
-
readonly expr: ScalarNode
|
|
56
|
+
readonly expr: ScalarNode;
|
|
59
57
|
} | {
|
|
60
58
|
readonly kind: "isFinite";
|
|
61
|
-
readonly expr: ScalarNode
|
|
59
|
+
readonly expr: ScalarNode;
|
|
62
60
|
} | {
|
|
63
61
|
readonly kind: "add";
|
|
64
|
-
readonly left: ScalarNode
|
|
65
|
-
readonly right: ScalarNode
|
|
62
|
+
readonly left: ScalarNode;
|
|
63
|
+
readonly right: ScalarNode;
|
|
66
64
|
} | {
|
|
67
65
|
readonly kind: "subtract";
|
|
68
|
-
readonly left: ScalarNode
|
|
69
|
-
readonly right: ScalarNode
|
|
66
|
+
readonly left: ScalarNode;
|
|
67
|
+
readonly right: ScalarNode;
|
|
70
68
|
} | {
|
|
71
69
|
readonly kind: "multiply";
|
|
72
|
-
readonly left: ScalarNode
|
|
73
|
-
readonly right: ScalarNode
|
|
70
|
+
readonly left: ScalarNode;
|
|
71
|
+
readonly right: ScalarNode;
|
|
74
72
|
} | {
|
|
75
73
|
readonly kind: "divide";
|
|
76
|
-
readonly left: ScalarNode
|
|
77
|
-
readonly right: ScalarNode
|
|
74
|
+
readonly left: ScalarNode;
|
|
75
|
+
readonly right: ScalarNode;
|
|
78
76
|
} | {
|
|
79
77
|
readonly kind: "cast";
|
|
80
78
|
readonly cast: NumericCast;
|
|
81
|
-
readonly expr: ScalarNode
|
|
79
|
+
readonly expr: ScalarNode;
|
|
82
80
|
};
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
* Summaries are construction metadata; lowering and L17 serialization read
|
|
86
|
-
* the grammar arms and ignore the summaries.
|
|
87
|
-
*/
|
|
88
|
-
type ScalarNode<S extends ScalarLeafScope = ScalarLeafScope, K extends ScalarResultKind = ScalarResultKind> = ScalarNodeBody<S> & {
|
|
89
|
-
readonly scope: S;
|
|
81
|
+
/** Cached summaries never replace the expression grammar. */
|
|
82
|
+
type ScalarNode<K extends ScalarResultKind = ScalarResultKind> = ScalarNodeBody & {
|
|
90
83
|
readonly result: K;
|
|
91
84
|
readonly depth: number;
|
|
92
85
|
};
|
|
93
|
-
/**
|
|
94
|
-
* Migration authoring expression (source-field scope). `K` is the cached
|
|
95
|
-
* result kind, not a host value type: I64 and U64 remain distinct even
|
|
96
|
-
* though both use bigint in JavaScript.
|
|
97
|
-
*/
|
|
98
|
-
type ScalarExpr<K extends ScalarResultKind = ScalarResultKind> = ScalarNode<"source-field", K>;
|
|
99
|
-
/** A migration field read: unresolved until native snapshot binding. */
|
|
100
|
-
type ScalarFieldRef = ScalarNode<"source-field", "unresolved"> & SourceFieldLeaf;
|
|
101
86
|
declare const MAX_SCALAR_DEPTH = 128;
|
|
102
87
|
declare function scalarAuthoringWork(): number;
|
|
103
88
|
declare function checkU64(value: bigint, where: string): void;
|
|
@@ -109,57 +94,24 @@ declare function literalValue(value: ScalarLiteral): ScalarLiteral;
|
|
|
109
94
|
declare function literalWireOf(value: ScalarLiteral): ValueSpec;
|
|
110
95
|
declare function literalKindOf(value: ScalarLiteral): ScalarKind;
|
|
111
96
|
declare function assertDepth(where: string, depth: number): void;
|
|
112
|
-
declare function assertNumeric(where: string, kind:
|
|
113
|
-
declare function assertSameKind(where: string, left:
|
|
97
|
+
declare function assertNumeric(where: string, kind: ScalarInputKind): asserts kind is NumericKind;
|
|
98
|
+
declare function assertSameKind(where: string, left: ScalarInputKind, right: ScalarInputKind): ScalarInputKind;
|
|
114
99
|
declare function isScalarNode(value: unknown): value is ScalarNode;
|
|
115
|
-
declare function isUnresolvedScalar(node: ScalarNode): boolean;
|
|
116
100
|
/** Query-var leaf — kind is the variable's schema kind, already known. */
|
|
117
|
-
declare function queryVarLeaf<K extends
|
|
118
|
-
declare function scalarLiteral
|
|
101
|
+
declare function queryVarLeaf<K extends ScalarInputKind>(ref: ScalarQueryVar, kind: K): ScalarNode<K>;
|
|
102
|
+
declare function scalarLiteral(value: ScalarLiteral): ScalarNode<ScalarKind>;
|
|
119
103
|
type BinaryOp = "add" | "subtract" | "multiply" | "divide";
|
|
120
|
-
declare function scalarBinary
|
|
121
|
-
declare function
|
|
122
|
-
declare function
|
|
123
|
-
declare function
|
|
104
|
+
declare function scalarBinary(where: string, op: BinaryOp, left: ScalarNode, right: ScalarNode): ScalarNode;
|
|
105
|
+
declare function roundingMode(value: unknown): Rounding;
|
|
106
|
+
declare function scalarMulDiv(where: string, a: ScalarNode, b: ScalarNode, divisor: ScalarNode, rounding: Rounding): ScalarNode;
|
|
107
|
+
declare function scalarMeasure(where: string, expr: ScalarNode): ScalarNode;
|
|
108
|
+
declare function scalarNegate(where: string, expr: ScalarNode): ScalarNode;
|
|
109
|
+
declare function scalarCast(where: string, cast: NumericCast, result: ScalarKind, expr: ScalarNode): ScalarNode<ScalarKind>;
|
|
110
|
+
declare function scalarFloatPredicate(where: string, op: "isNaN" | "isFinite", expr: ScalarNode): ScalarNode<"bool">;
|
|
124
111
|
/** Query-var leaves collected once at find-binding time — not during construction. */
|
|
125
|
-
declare function queryVarsOf(node: ScalarNode
|
|
126
|
-
|
|
127
|
-
declare function
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
declare function f64(value: number): ScalarExpr<"f64">;
|
|
131
|
-
declare function bool(value: boolean): ScalarExpr<"bool">;
|
|
132
|
-
declare function negate<K extends "i64" | "f64" | "unresolved">(expr: ScalarExpr<K>): ScalarExpr<K>;
|
|
133
|
-
declare function add<L extends NumericOrUnresolved, R extends CombineNumeric<L, R> extends never ? never : NumericOrUnresolved>(left: ScalarExpr<L>, right: ScalarExpr<R>): ScalarExpr<CombineNumeric<L, R>>;
|
|
134
|
-
declare function subtract<L extends NumericOrUnresolved, R extends CombineNumeric<L, R> extends never ? never : NumericOrUnresolved>(left: ScalarExpr<L>, right: ScalarExpr<R>): ScalarExpr<CombineNumeric<L, R>>;
|
|
135
|
-
declare function multiply<L extends NumericOrUnresolved, R extends CombineNumeric<L, R> extends never ? never : NumericOrUnresolved>(left: ScalarExpr<L>, right: ScalarExpr<R>): ScalarExpr<CombineNumeric<L, R>>;
|
|
136
|
-
declare function divide<L extends NumericOrUnresolved, R extends CombineNumeric<L, R> extends never ? never : NumericOrUnresolved>(left: ScalarExpr<L>, right: ScalarExpr<R>): ScalarExpr<CombineNumeric<L, R>>;
|
|
137
|
-
declare function toF64(expr: ScalarExpr<NumericOrUnresolved>): ScalarExpr<"f64">;
|
|
138
|
-
declare function toF64Exact(expr: ScalarExpr<NumericOrUnresolved>): ScalarExpr<"f64">;
|
|
139
|
-
declare function toI64Exact(expr: ScalarExpr<NumericOrUnresolved>): ScalarExpr<"i64">;
|
|
140
|
-
declare function toU64Exact(expr: ScalarExpr<NumericOrUnresolved>): ScalarExpr<"u64">;
|
|
141
|
-
declare function isNaNExpr(expr: ScalarExpr<"f64" | "unresolved">): ScalarExpr<"bool">;
|
|
142
|
-
declare function isFiniteExpr(expr: ScalarExpr<"f64" | "unresolved">): ScalarExpr<"bool">;
|
|
143
|
-
/** The authoring namespace: `Scalar.field("units")`, `Scalar.add(...)`. */
|
|
144
|
-
declare const Scalar: Readonly<{
|
|
145
|
-
field: typeof field;
|
|
146
|
-
literal: typeof literal;
|
|
147
|
-
u64: typeof u64;
|
|
148
|
-
i64: typeof i64;
|
|
149
|
-
f64: typeof f64;
|
|
150
|
-
bool: typeof bool;
|
|
151
|
-
negate: typeof negate;
|
|
152
|
-
add: typeof add;
|
|
153
|
-
subtract: typeof subtract;
|
|
154
|
-
multiply: typeof multiply;
|
|
155
|
-
divide: typeof divide;
|
|
156
|
-
toF64: typeof toF64;
|
|
157
|
-
toF64Exact: typeof toF64Exact;
|
|
158
|
-
toI64Exact: typeof toI64Exact;
|
|
159
|
-
toU64Exact: typeof toU64Exact;
|
|
160
|
-
isNaN: typeof isNaNExpr;
|
|
161
|
-
isFinite: typeof isFiniteExpr;
|
|
162
|
-
}>;
|
|
163
|
-
export type { CombineNumeric, NumericCast, NumericKind, NumericOrUnresolved, QueryVarLeaf, ScalarExpr, ScalarFieldRef, ScalarKind, ScalarLiteral, ScalarNode, ScalarOpKind, ScalarQueryVar, ScalarResultKind, ScalarValue, SourceFieldLeaf };
|
|
164
|
-
export { assertDepth, assertNumeric, assertSameKind, checkBool, checkF64, checkI64, checkU64, isScalarNode, isUnresolvedScalar, literalKindOf, literalValue, literalWireOf, MAX_SCALAR_DEPTH, queryVarLeaf, queryVarsOf, Scalar, scalarAuthoringWork, scalarBinary, scalarCast, scalarFloatPredicate, scalarLiteral, scalarNegate };
|
|
112
|
+
declare function queryVarsOf(node: ScalarNode): readonly ScalarQueryVar[];
|
|
113
|
+
/** Lower each query variable through its existing binding. */
|
|
114
|
+
declare function scalarWire(node: ScalarNode, leaf: (node: QueryVarLeaf) => number): ScalarExprIr;
|
|
115
|
+
export type { IntervalKind, NumericCast, NumericKind, QueryVarLeaf, Rounding, ScalarInputKind, ScalarKind, ScalarLiteral, ScalarNode, ScalarOpKind, ScalarQueryVar, ScalarResultKind, ScalarValue };
|
|
116
|
+
export { assertDepth, assertNumeric, assertSameKind, checkBool, checkF64, checkI64, checkU64, isScalarNode, literalKindOf, literalValue, literalWireOf, MAX_SCALAR_DEPTH, queryVarLeaf, queryVarsOf, roundingMode, scalarAuthoringWork, scalarBinary, scalarCast, scalarFloatPredicate, scalarLiteral, scalarMeasure, scalarMulDiv, scalarNegate, scalarWire };
|
|
165
117
|
//# sourceMappingURL=scalar.d.ts.map
|
package/dist/scalar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../src/scalar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../src/scalar.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,0EAA0E;AAC1E,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;AAEhD,oFAAoF;AACpF,KAAK,YAAY,GAAG,aAAa,GAAG,aAAa,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G;AAED,sFAAsF;AACtF,iBAAS,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,cAAc,EAAE,CAiChE;AAED,8DAA8D;AAC9D,iBAAS,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,GAAG,YAAY,CAsBxF;AAED,YAAY,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,CAAA;AACD,OAAO,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,CAAA"}
|
package/dist/scalar.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* operator roster, parameterized by {@link ScalarLeafScope}. TypeScript never
|
|
4
|
-
* evaluates — the native compiler binds source fields and the engine
|
|
5
|
-
* `ScalarEvaluator` executes. Construction is constant work against cached
|
|
6
|
-
* depth/kind summaries; it does not re-walk the tree.
|
|
7
|
-
*
|
|
8
|
-
* Query-var leaves carry a known schema kind. Source-field leaves stay
|
|
9
|
-
* `unresolved` until native snapshot binding. A result kind is recorded only
|
|
10
|
-
* when it is derivable from known operands; otherwise it stays unresolved.
|
|
11
|
-
* Known incompatible kinds refuse here. Unresolved trees are inert metadata,
|
|
12
|
-
* not typechecked programs.
|
|
13
|
-
*
|
|
14
|
-
* Wire spellings (the grammar arms, not a second flattened interpretation):
|
|
15
|
-
* migration plan JSON — field/literal/operator nodes; one-arm literals (`{ u64: n }`)
|
|
16
|
-
* query IR — `{ kind: "literal", value: ValueSpec }` via `literalWireOf`
|
|
17
|
-
*/
|
|
1
|
+
/** Query scalar nodes, with cached kind and depth. Construction is constant
|
|
2
|
+
* work; native preparation binds variables and evaluates the expressions. */
|
|
18
3
|
import { AuthoringError } from "#errors.ts";
|
|
19
4
|
const MAX_SCALAR_DEPTH = 128;
|
|
20
5
|
const U64_MAX = (1n << 64n) - 1n;
|
|
@@ -86,44 +71,24 @@ function assertDepth(where, depth) {
|
|
|
86
71
|
}
|
|
87
72
|
}
|
|
88
73
|
function assertNumeric(where, kind) {
|
|
89
|
-
if (kind
|
|
74
|
+
if (kind !== "u64" && kind !== "i64" && kind !== "f64") {
|
|
90
75
|
throw new AuthoringError({ message: `${where}: the operand is bool, not numeric (u64/i64/f64)` });
|
|
91
76
|
}
|
|
92
77
|
}
|
|
93
78
|
function assertSameKind(where, left, right) {
|
|
94
79
|
if (left !== right) {
|
|
95
80
|
throw new AuthoringError({
|
|
96
|
-
message: `${where}: operand kinds differ (${left} vs ${right}) — the engine has no mixed promotion; cast explicitly (
|
|
81
|
+
message: `${where}: operand kinds differ (${left} vs ${right}) — the engine has no mixed promotion; cast explicitly (Compute.toF64/ toF64Exact/ toI64Exact/ toU64Exact)`
|
|
97
82
|
});
|
|
98
83
|
}
|
|
99
84
|
return left;
|
|
100
85
|
}
|
|
101
|
-
function assertScope(where, left, right) {
|
|
102
|
-
if (left.scope !== right.scope) {
|
|
103
|
-
throw new AuthoringError({
|
|
104
|
-
message: `${where}: leaf scopes differ (${left.scope} vs ${right.scope}) — query-var and source-field trees do not mix`
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return left.scope;
|
|
108
|
-
}
|
|
109
86
|
function combineNumeric(where, left, right) {
|
|
110
|
-
if (left === "unresolved" || right === "unresolved") {
|
|
111
|
-
if (left !== "unresolved") {
|
|
112
|
-
assertNumeric(where, left);
|
|
113
|
-
}
|
|
114
|
-
if (right !== "unresolved") {
|
|
115
|
-
assertNumeric(where, right);
|
|
116
|
-
}
|
|
117
|
-
return "unresolved";
|
|
118
|
-
}
|
|
119
87
|
assertNumeric(where, left);
|
|
120
88
|
assertNumeric(where, right);
|
|
121
89
|
return assertSameKind(where, left, right);
|
|
122
90
|
}
|
|
123
91
|
function negateKind(where, inner) {
|
|
124
|
-
if (inner === "unresolved") {
|
|
125
|
-
return "unresolved";
|
|
126
|
-
}
|
|
127
92
|
if (inner !== "i64" && inner !== "f64") {
|
|
128
93
|
throw new AuthoringError({
|
|
129
94
|
message: `${where}: the operand is ${inner} — negation is defined over i64 and f64 only`
|
|
@@ -132,79 +97,80 @@ function negateKind(where, inner) {
|
|
|
132
97
|
return inner;
|
|
133
98
|
}
|
|
134
99
|
function assertCastOperand(where, inner) {
|
|
135
|
-
if (inner === "unresolved") {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
100
|
assertNumeric(where, inner);
|
|
139
101
|
}
|
|
140
102
|
function assertFloatOperand(where, inner) {
|
|
141
|
-
if (inner === "unresolved") {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
103
|
if (inner !== "f64") {
|
|
145
104
|
throw new AuthoringError({ message: `${where}: the operand is ${inner} — the float predicates read f64` });
|
|
146
105
|
}
|
|
147
106
|
}
|
|
148
107
|
function isScalarNode(value) {
|
|
149
|
-
return
|
|
150
|
-
value !== null &&
|
|
151
|
-
"kind" in value &&
|
|
152
|
-
"scope" in value &&
|
|
153
|
-
"result" in value &&
|
|
154
|
-
"depth" in value);
|
|
155
|
-
}
|
|
156
|
-
function isUnresolvedScalar(node) {
|
|
157
|
-
return node.result === "unresolved";
|
|
158
|
-
}
|
|
159
|
-
/** Source-field leaf — unresolved until L14 binds it against the verified snapshot. */
|
|
160
|
-
function sourceField(name) {
|
|
161
|
-
if (typeof name !== "string" || name.length === 0) {
|
|
162
|
-
throw new AuthoringError({ message: "scalar field(...) names a nonempty source field" });
|
|
163
|
-
}
|
|
164
|
-
return admit("Scalar.field", {
|
|
165
|
-
kind: "field",
|
|
166
|
-
name,
|
|
167
|
-
scope: "source-field",
|
|
168
|
-
result: "unresolved",
|
|
169
|
-
depth: 1
|
|
170
|
-
});
|
|
108
|
+
return typeof value === "object" && value !== null && "kind" in value && "result" in value && "depth" in value;
|
|
171
109
|
}
|
|
172
110
|
/** Query-var leaf — kind is the variable's schema kind, already known. */
|
|
173
111
|
function queryVarLeaf(ref, kind) {
|
|
174
|
-
return admit("
|
|
112
|
+
return admit("Compute.variable", {
|
|
175
113
|
kind: "var",
|
|
176
114
|
ref,
|
|
177
|
-
scope: "query-var",
|
|
178
115
|
result: kind,
|
|
179
116
|
depth: 1
|
|
180
117
|
});
|
|
181
118
|
}
|
|
182
|
-
function scalarLiteral(
|
|
119
|
+
function scalarLiteral(value) {
|
|
183
120
|
const kind = literalKindOf(value);
|
|
184
|
-
return admit("
|
|
121
|
+
return admit("Compute.literal", {
|
|
185
122
|
kind: "literal",
|
|
186
123
|
value: literalValue(value),
|
|
187
|
-
scope,
|
|
188
124
|
result: kind,
|
|
189
125
|
depth: 1
|
|
190
126
|
});
|
|
191
127
|
}
|
|
192
128
|
function scalarBinary(where, op, left, right) {
|
|
193
|
-
const scope = assertScope(where, left, right);
|
|
194
129
|
return admit(where, {
|
|
195
130
|
kind: op,
|
|
196
131
|
left,
|
|
197
132
|
right,
|
|
198
|
-
scope,
|
|
199
133
|
result: combineNumeric(where, left.result, right.result),
|
|
200
134
|
depth: Math.max(left.depth, right.depth) + 1
|
|
201
135
|
});
|
|
202
136
|
}
|
|
137
|
+
function roundingMode(value) {
|
|
138
|
+
if (value !== "towardZero" && value !== "nearestTiesAwayFromZero" && value !== "nearestTiesToEven")
|
|
139
|
+
throw new AuthoringError({ message: "unknown integer rounding mode" });
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
function scalarMulDiv(where, a, b, divisor, rounding) {
|
|
143
|
+
let known;
|
|
144
|
+
for (const operand of [a, b, divisor]) {
|
|
145
|
+
if ((operand.result !== "i64" && operand.result !== "u64") || (known !== undefined && known !== operand.result))
|
|
146
|
+
throw new AuthoringError({ message: `${where}: operands must have one matching integer kind` });
|
|
147
|
+
known = operand.result;
|
|
148
|
+
}
|
|
149
|
+
return admit(where, {
|
|
150
|
+
kind: "mulDiv",
|
|
151
|
+
a,
|
|
152
|
+
b,
|
|
153
|
+
divisor,
|
|
154
|
+
rounding: roundingMode(rounding),
|
|
155
|
+
result: a.result,
|
|
156
|
+
depth: Math.max(a.depth, b.depth, divisor.depth) + 1
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function scalarMeasure(where, expr) {
|
|
160
|
+
const kind = expr.result;
|
|
161
|
+
if (kind !== "intervalU64" && kind !== "intervalI64" && kind !== "intervalF64")
|
|
162
|
+
throw new AuthoringError({ message: `${where}: measure requires an interval` });
|
|
163
|
+
return admit(where, {
|
|
164
|
+
kind: "measure",
|
|
165
|
+
expr,
|
|
166
|
+
result: { intervalF64: "f64", intervalI64: "u64", intervalU64: "u64" }[kind],
|
|
167
|
+
depth: expr.depth + 1
|
|
168
|
+
});
|
|
169
|
+
}
|
|
203
170
|
function scalarNegate(where, expr) {
|
|
204
171
|
return admit(where, {
|
|
205
172
|
kind: "negate",
|
|
206
173
|
expr,
|
|
207
|
-
scope: expr.scope,
|
|
208
174
|
result: negateKind(where, expr.result),
|
|
209
175
|
depth: expr.depth + 1
|
|
210
176
|
});
|
|
@@ -215,7 +181,6 @@ function scalarCast(where, cast, result, expr) {
|
|
|
215
181
|
kind: "cast",
|
|
216
182
|
cast,
|
|
217
183
|
expr,
|
|
218
|
-
scope: expr.scope,
|
|
219
184
|
result,
|
|
220
185
|
depth: expr.depth + 1
|
|
221
186
|
});
|
|
@@ -225,7 +190,6 @@ function scalarFloatPredicate(where, op, expr) {
|
|
|
225
190
|
return admit(where, {
|
|
226
191
|
kind: op,
|
|
227
192
|
expr,
|
|
228
|
-
scope: expr.scope,
|
|
229
193
|
result: "bool",
|
|
230
194
|
depth: expr.depth + 1
|
|
231
195
|
});
|
|
@@ -245,100 +209,49 @@ function queryVarsOf(node) {
|
|
|
245
209
|
break;
|
|
246
210
|
case "literal":
|
|
247
211
|
break;
|
|
212
|
+
case "measure":
|
|
248
213
|
case "negate":
|
|
249
214
|
case "isNaN":
|
|
250
215
|
case "isFinite":
|
|
251
216
|
case "cast":
|
|
252
217
|
pending.push(next.expr);
|
|
253
218
|
break;
|
|
219
|
+
case "mulDiv":
|
|
220
|
+
pending.push(next.a, next.b, next.divisor);
|
|
221
|
+
break;
|
|
254
222
|
case "add":
|
|
255
223
|
case "subtract":
|
|
256
224
|
case "multiply":
|
|
257
225
|
case "divide":
|
|
258
226
|
pending.push(next.left, next.right);
|
|
259
227
|
break;
|
|
260
|
-
default:
|
|
261
|
-
throw new AuthoringError({
|
|
262
|
-
message: "queryVarsOf: a query-var tree cannot carry a source-field leaf"
|
|
263
|
-
});
|
|
264
228
|
}
|
|
265
229
|
}
|
|
266
230
|
return vars;
|
|
267
231
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return scalarNegate("Scalar.negate", expr);
|
|
292
|
-
}
|
|
293
|
-
function add(left, right) {
|
|
294
|
-
return scalarBinary("Scalar.add", "add", left, right);
|
|
295
|
-
}
|
|
296
|
-
function subtract(left, right) {
|
|
297
|
-
return scalarBinary("Scalar.subtract", "subtract", left, right);
|
|
298
|
-
}
|
|
299
|
-
function multiply(left, right) {
|
|
300
|
-
return scalarBinary("Scalar.multiply", "multiply", left, right);
|
|
301
|
-
}
|
|
302
|
-
function divide(left, right) {
|
|
303
|
-
return scalarBinary("Scalar.divide", "divide", left, right);
|
|
304
|
-
}
|
|
305
|
-
function toF64(expr) {
|
|
306
|
-
return scalarCast("Scalar.toF64", "toF64", "f64", expr);
|
|
307
|
-
}
|
|
308
|
-
function toF64Exact(expr) {
|
|
309
|
-
return scalarCast("Scalar.toF64Exact", "toF64Exact", "f64", expr);
|
|
310
|
-
}
|
|
311
|
-
function toI64Exact(expr) {
|
|
312
|
-
return scalarCast("Scalar.toI64Exact", "toI64Exact", "i64", expr);
|
|
313
|
-
}
|
|
314
|
-
function toU64Exact(expr) {
|
|
315
|
-
return scalarCast("Scalar.toU64Exact", "toU64Exact", "u64", expr);
|
|
316
|
-
}
|
|
317
|
-
function isNaNExpr(expr) {
|
|
318
|
-
return scalarFloatPredicate("Scalar.isNaN", "isNaN", expr);
|
|
319
|
-
}
|
|
320
|
-
function isFiniteExpr(expr) {
|
|
321
|
-
return scalarFloatPredicate("Scalar.isFinite", "isFinite", expr);
|
|
232
|
+
/** Lower each query variable through its existing binding. */
|
|
233
|
+
function scalarWire(node, leaf) {
|
|
234
|
+
const walk = (expr) => scalarWire(expr, leaf);
|
|
235
|
+
switch (node.kind) {
|
|
236
|
+
case "var":
|
|
237
|
+
return { kind: "var", var: leaf(node) };
|
|
238
|
+
case "literal":
|
|
239
|
+
return { kind: "literal", value: literalWireOf(node.value) };
|
|
240
|
+
case "measure":
|
|
241
|
+
case "negate":
|
|
242
|
+
case "isNaN":
|
|
243
|
+
case "isFinite":
|
|
244
|
+
return { kind: node.kind, expr: walk(node.expr) };
|
|
245
|
+
case "cast":
|
|
246
|
+
return { kind: node.kind, cast: node.cast, expr: walk(node.expr) };
|
|
247
|
+
case "mulDiv":
|
|
248
|
+
return { kind: node.kind, a: walk(node.a), b: walk(node.b), divisor: walk(node.divisor), rounding: node.rounding };
|
|
249
|
+
case "add":
|
|
250
|
+
case "subtract":
|
|
251
|
+
case "multiply":
|
|
252
|
+
case "divide":
|
|
253
|
+
return { kind: node.kind, left: walk(node.left), right: walk(node.right) };
|
|
254
|
+
}
|
|
322
255
|
}
|
|
323
|
-
|
|
324
|
-
const Scalar = Object.freeze({
|
|
325
|
-
field,
|
|
326
|
-
literal,
|
|
327
|
-
u64,
|
|
328
|
-
i64,
|
|
329
|
-
f64,
|
|
330
|
-
bool,
|
|
331
|
-
negate,
|
|
332
|
-
add,
|
|
333
|
-
subtract,
|
|
334
|
-
multiply,
|
|
335
|
-
divide,
|
|
336
|
-
toF64,
|
|
337
|
-
toF64Exact,
|
|
338
|
-
toI64Exact,
|
|
339
|
-
toU64Exact,
|
|
340
|
-
isNaN: isNaNExpr,
|
|
341
|
-
isFinite: isFiniteExpr
|
|
342
|
-
});
|
|
343
|
-
export { assertDepth, assertNumeric, assertSameKind, checkBool, checkF64, checkI64, checkU64, isScalarNode, isUnresolvedScalar, literalKindOf, literalValue, literalWireOf, MAX_SCALAR_DEPTH, queryVarLeaf, queryVarsOf, Scalar, scalarAuthoringWork, scalarBinary, scalarCast, scalarFloatPredicate, scalarLiteral, scalarNegate };
|
|
256
|
+
export { assertDepth, assertNumeric, assertSameKind, checkBool, checkF64, checkI64, checkU64, isScalarNode, literalKindOf, literalValue, literalWireOf, MAX_SCALAR_DEPTH, queryVarLeaf, queryVarsOf, roundingMode, scalarAuthoringWork, scalarBinary, scalarCast, scalarFloatPredicate, scalarLiteral, scalarMeasure, scalarMulDiv, scalarNegate, scalarWire };
|
|
344
257
|
//# sourceMappingURL=scalar.js.map
|
package/dist/scalar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar.js","sourceRoot":"","sources":["../src/scalar.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scalar.js","sourceRoot":"","sources":["../src/scalar.ts"],"names":[],"mappings":"AAAA;6EAC6E;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AA6E3C,MAAM,gBAAgB,GAAG,GA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EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { DbError } from "./runtime-errors.js";
|
|
3
|
+
import type { SchemaSpec } from "./spec.js";
|
|
4
|
+
declare const internalSchemaSnapshot: (spec: SchemaSpec) => Effect.Effect<string, DbError, import("./runtime.js").NativeRuntime>;
|
|
5
|
+
declare const internalSchemaBindings: (snapshot: string) => Effect.Effect<string, DbError, import("./runtime.js").NativeRuntime>;
|
|
6
|
+
export { internalSchemaBindings, internalSchemaSnapshot };
|
|
7
|
+
//# sourceMappingURL=schema-file.d.ts.map
|