@bjornpagen/bumbledb 0.2.0 → 0.4.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/COOKBOOK.md +503 -427
- package/README.md +84 -36
- package/dist/closed.d.ts +111 -38
- package/dist/closed.d.ts.map +1 -1
- package/dist/closed.js +94 -99
- package/dist/closed.js.map +1 -1
- package/dist/db.d.ts +16 -2
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +46 -8
- package/dist/db.js.map +1 -1
- package/dist/face.d.ts +114 -69
- package/dist/face.d.ts.map +1 -1
- package/dist/face.js +38 -21
- package/dist/face.js.map +1 -1
- package/dist/fields.d.ts +72 -87
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +35 -67
- package/dist/fields.js.map +1 -1
- package/dist/index.d.ts +18 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/law.d.ts +224 -0
- package/dist/law.d.ts.map +1 -0
- package/dist/law.js +224 -0
- package/dist/law.js.map +1 -0
- package/dist/lower.d.ts +17 -10
- package/dist/lower.d.ts.map +1 -1
- package/dist/lower.js +34 -23
- package/dist/lower.js.map +1 -1
- package/dist/marshal.d.ts +33 -6
- package/dist/marshal.d.ts.map +1 -1
- package/dist/marshal.js +67 -6
- package/dist/marshal.js.map +1 -1
- package/dist/native.d.ts +6 -2
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/query/atom.d.ts +139 -56
- package/dist/query/atom.d.ts.map +1 -1
- package/dist/query/atom.js +7 -1
- package/dist/query/atom.js.map +1 -1
- package/dist/query/lower.d.ts +71 -56
- package/dist/query/lower.d.ts.map +1 -1
- package/dist/query/lower.js +341 -69
- package/dist/query/lower.js.map +1 -1
- package/dist/query/predicate.d.ts +10 -9
- package/dist/query/predicate.d.ts.map +1 -1
- package/dist/query/predicate.js +2 -2
- package/dist/query/predicate.js.map +1 -1
- package/dist/query/run.d.ts +15 -5
- package/dist/query/run.d.ts.map +1 -1
- package/dist/query/run.js +26 -6
- package/dist/query/run.js.map +1 -1
- package/dist/query/scope.d.ts +100 -43
- package/dist/query/scope.d.ts.map +1 -1
- package/dist/query/scope.js +89 -30
- package/dist/query/scope.js.map +1 -1
- package/dist/query/select.d.ts +5 -5
- package/dist/query/select.d.ts.map +1 -1
- package/dist/relation.d.ts +29 -15
- package/dist/relation.d.ts.map +1 -1
- package/dist/relation.js +45 -17
- package/dist/relation.js.map +1 -1
- package/dist/schema.d.ts +41 -3
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +16 -2
- package/dist/schema.js.map +1 -1
- package/dist/spec.d.ts +10 -8
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/statements.d.ts +67 -31
- package/dist/statements.d.ts.map +1 -1
- package/dist/statements.js +97 -20
- package/dist/statements.js.map +1 -1
- package/package.json +2 -2
- package/src/closed.ts +214 -146
- package/src/db.ts +65 -10
- package/src/face.ts +169 -102
- package/src/fields.ts +97 -164
- package/src/index.ts +43 -18
- package/src/law.ts +519 -0
- package/src/lower.ts +36 -23
- package/src/marshal.ts +74 -7
- package/src/native.ts +6 -2
- package/src/query/atom.ts +155 -65
- package/src/query/lower.ts +572 -167
- package/src/query/predicate.ts +43 -33
- package/src/query/run.ts +26 -6
- package/src/query/scope.ts +161 -51
- package/src/query/select.ts +5 -5
- package/src/relation.ts +60 -26
- package/src/schema.ts +48 -7
- package/src/spec.ts +10 -8
- package/src/statements.ts +165 -46
package/dist/query/scope.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Query scope terms,
|
|
2
|
+
* Query scope terms, LAW-TYPED edition: string-named variables and
|
|
3
3
|
* parameters as plain frozen values. A `Var` is a NAME — it is typed by the
|
|
4
|
-
* field it first binds (
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* and
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
4
|
+
* field slot it first binds (the descriptor AND the slot's law-computed
|
|
5
|
+
* CLASS, read off the schema's class map through the rule builder's
|
|
6
|
+
* environment), reuse of the name within one rule IS the join, and a
|
|
7
|
+
* class-mismatched reuse is a compile error: a var joins only class-equal
|
|
8
|
+
* slots, and BARE PAIRS ONLY WITH BARE (ruling 3 — a slot in no law has no
|
|
9
|
+
* class and never joins a classed slot; the deliberate sum-domain pointer
|
|
10
|
+
* stays legal against other bare slots). Params are query-global by name
|
|
11
|
+
* and typed BY USE: the field position or comparison sibling that anchors
|
|
12
|
+
* a param types it, the query's inferred `Params` object is exactly the
|
|
13
|
+
* params the rules use, and a param value that no rule uses simply never
|
|
14
|
+
* registers — the query executes under its own inferred type (the
|
|
15
|
+
* bug-hunt law). This module also owns the environment/typing utilities
|
|
16
|
+
* the whole surface shares: the env shape (var name → classed slot), the
|
|
17
|
+
* class-equality judgment {@link JoinOk} with its runtime twin
|
|
18
|
+
* {@link fieldJoins}, and the record-folding helpers `Params` and `Row`
|
|
19
|
+
* inference ride.
|
|
17
20
|
*/
|
|
18
21
|
import type { AnyField, Infer } from "#fields.ts";
|
|
19
22
|
/**
|
|
@@ -89,6 +92,20 @@ type AnyTerm = Var | Param | SetParam | MaskParam | Duration;
|
|
|
89
92
|
declare function isTerm(value: unknown): value is AnyTerm;
|
|
90
93
|
/** Builds one variable term. */
|
|
91
94
|
declare function makeVar<const Name extends string>(name: Name): Var<Name>;
|
|
95
|
+
/** The record `makeVars` mints: one own frozen `Var<Name>` per requested name, each typed exactly. */
|
|
96
|
+
type VarsRecord<Names extends string> = {
|
|
97
|
+
readonly [N in Names]: Var<N>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Mints several variables at once — `const { service, w } = r.vars("service",
|
|
101
|
+
* "w")`: tuple-to-object, each name typed exactly (`Var<"service">`),
|
|
102
|
+
* inference identical to the one-at-a-time `r.var` spelling (one lowering,
|
|
103
|
+
* two entry flavors). Each key is defined as an OWN property (a name like
|
|
104
|
+
* `"__proto__"` is a record key like any other, never a prototype write),
|
|
105
|
+
* and a duplicate name in one call is a construction error: each name mints
|
|
106
|
+
* one variable — write it once and reuse the binding.
|
|
107
|
+
*/
|
|
108
|
+
declare function makeVars<const Names extends readonly string[]>(...names: Names): VarsRecord<Names[number]>;
|
|
92
109
|
/** Builds one scalar-parameter term. */
|
|
93
110
|
declare function makeParam<const Name extends string>(name: Name): Param<Name>;
|
|
94
111
|
/** Builds one set-parameter term. */
|
|
@@ -98,11 +115,23 @@ declare function makeMaskParam<const Name extends string>(name: Name): MaskParam
|
|
|
98
115
|
/** Builds one measure term over an interval-typed variable's name. */
|
|
99
116
|
declare function makeDuration<const Name extends string>(name: Name): Duration<Name>;
|
|
100
117
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
118
|
+
* One bound field slot: the field's descriptor plus the slot's
|
|
119
|
+
* law-computed CLASS (`undefined` = bare — the slot is in no law). The one
|
|
120
|
+
* shape the rule environment carries per variable, at the TYPE level (env
|
|
121
|
+
* entries hold the schema type's class-map lookups) and at RUNTIME alike
|
|
122
|
+
* (the rule's `varFields` record holds exactly this shape, read off the
|
|
123
|
+
* schema value's frozen class map) — one shape, two tiers, one walk.
|
|
124
|
+
*/
|
|
125
|
+
interface ClassedField {
|
|
126
|
+
readonly field: AnyField;
|
|
127
|
+
readonly class: string | undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A rule's typing environment: variable name → the classed slot it first
|
|
131
|
+
* bound. Purely a TYPE — the runtime twin is the rule's `varFields`
|
|
103
132
|
* record, and the two are built by the same walk.
|
|
104
133
|
*/
|
|
105
|
-
type EnvShape = Record<string,
|
|
134
|
+
type EnvShape = Record<string, ClassedField>;
|
|
106
135
|
/** A params object type — what `execute` takes and inference carries. */
|
|
107
136
|
type ParamsRecord = Readonly<Record<string, unknown>>;
|
|
108
137
|
/** Flattens an intersection into one displayed object type (hover legibility). */
|
|
@@ -116,8 +145,6 @@ type UnionToIntersection<U> = (U extends unknown ? (member: U) => void : never)
|
|
|
116
145
|
* (the machinery both `Params` and `Row` inference ride).
|
|
117
146
|
*/
|
|
118
147
|
type ShapeOf<U> = [U] extends [never] ? Record<never, never> : Flatten<UnionToIntersection<U>>;
|
|
119
|
-
/** Reads a field descriptor's domain label (S1: the label IS the domain check). */
|
|
120
|
-
type DomainOf<F extends AnyField> = F["domain"];
|
|
121
148
|
/** Reads a field descriptor's width label (`bytes<N>`, `interval<E, W>`); `undefined` when the kind carries none. */
|
|
122
149
|
type WidthOf<F extends AnyField> = F extends {
|
|
123
150
|
readonly width: infer W;
|
|
@@ -126,35 +153,61 @@ type WidthOf<F extends AnyField> = F extends {
|
|
|
126
153
|
type ElementOf<F extends AnyField> = F extends {
|
|
127
154
|
readonly element: infer E;
|
|
128
155
|
} ? E : undefined;
|
|
156
|
+
/** Reads a closed reference's handle union; `undefined` on every non-closed kind (the roster IS descriptor structure). */
|
|
157
|
+
type RosterOf<F extends AnyField> = F extends {
|
|
158
|
+
readonly closed: {
|
|
159
|
+
readonly handles: readonly (infer H extends string)[];
|
|
160
|
+
};
|
|
161
|
+
} ? H : undefined;
|
|
129
162
|
/**
|
|
130
|
-
* The
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
163
|
+
* The join judgment: two bound slots join iff their descriptors' structure
|
|
164
|
+
* agrees (kind, width label, interval element, and the closed ROSTER — a
|
|
165
|
+
* closed reference pairs only with the same vocabulary, never with a bare
|
|
166
|
+
* u64: the roster keys every closed judgment downstream, so a join across
|
|
167
|
+
* it would decode/order/translate incoherently by binding order) AND their
|
|
168
|
+
* law-computed classes agree — same class name joins, and bare
|
|
169
|
+
* (`undefined`) pairs only with bare (ruling 3: a field in no law has no
|
|
170
|
+
* class; a bare↔classed pairing refuses). The class names come off the
|
|
171
|
+
* SCHEMA type's class map — the statements are the typing; no descriptor
|
|
172
|
+
* label beyond the roster exists to compare.
|
|
134
173
|
*/
|
|
135
|
-
type JoinOk<A extends
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
WidthOf<
|
|
139
|
-
ElementOf<
|
|
140
|
-
|
|
174
|
+
type JoinOk<A extends ClassedField, B extends ClassedField> = [
|
|
175
|
+
A["field"]["kind"],
|
|
176
|
+
A["class"],
|
|
177
|
+
WidthOf<A["field"]>,
|
|
178
|
+
ElementOf<A["field"]>,
|
|
179
|
+
RosterOf<A["field"]>
|
|
180
|
+
] extends [B["field"]["kind"], B["class"], WidthOf<B["field"]>, ElementOf<B["field"]>, RosterOf<B["field"]>] ? [B["field"]["kind"], B["class"], WidthOf<B["field"]>, ElementOf<B["field"]>, RosterOf<B["field"]>] extends [
|
|
181
|
+
A["field"]["kind"],
|
|
182
|
+
A["class"],
|
|
183
|
+
WidthOf<A["field"]>,
|
|
184
|
+
ElementOf<A["field"]>,
|
|
185
|
+
RosterOf<A["field"]>
|
|
186
|
+
] ? true : false : false;
|
|
141
187
|
/**
|
|
142
|
-
* The runtime twin of {@link JoinOk}: two
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
188
|
+
* The runtime twin of {@link JoinOk}: two bound slots join iff descriptor
|
|
189
|
+
* structure and class agree — the same comparison the type tier makes,
|
|
190
|
+
* judged on the honest runtime values (the descriptor, the roster by VALUE
|
|
191
|
+
* IDENTITY — vocabulary identity is value identity — and the schema
|
|
192
|
+
* value's frozen class map). The rule builders throw through this on a
|
|
193
|
+
* class-unequal variable reuse, so the wall holds for untyped callers too,
|
|
194
|
+
* not only where the compiler can see.
|
|
148
195
|
*/
|
|
149
|
-
declare function fieldJoins(a:
|
|
196
|
+
declare function fieldJoins(a: ClassedField, b: ClassedField): boolean;
|
|
150
197
|
/**
|
|
151
|
-
* Renders one
|
|
152
|
-
* grammar's
|
|
198
|
+
* Renders one bound slot for join-mismatch diagnostics — the structural
|
|
199
|
+
* kind in the schema grammar's spelling (a closed reference names its
|
|
200
|
+
* vocabulary: the roster is part of the structure being compared) plus the
|
|
201
|
+
* slot's law-computed class (`u64 in class Holder.id`; a lawless slot
|
|
202
|
+
* renders `bare`).
|
|
153
203
|
*/
|
|
154
|
-
declare function renderFieldKind(
|
|
204
|
+
declare function renderFieldKind(slot: ClassedField): string;
|
|
155
205
|
/**
|
|
156
206
|
* What a PARAM anchored at field `F` accepts at execution: the field's
|
|
157
|
-
* bare value type, exactly
|
|
207
|
+
* bare value type, exactly — at a CLOSED-reference field that is the
|
|
208
|
+
* handle-name union (`"DirectPass" | "Failed"`), translated name → row id
|
|
209
|
+
* at execute through the one roster-verification point
|
|
210
|
+
* (`taggedHandleId`). At an interval field the engine resolves the
|
|
158
211
|
* bivalent anchor to the INTERVAL reading (value equality) — the point
|
|
159
212
|
* reading of a param is spelled `pointIn(r.param(...), w)`, whose sibling
|
|
160
213
|
* anchors it element-typed.
|
|
@@ -171,14 +224,18 @@ type InferredOf<T> = T extends {
|
|
|
171
224
|
* positions) — the op keeps literal tagging op-aware at `pointIn`
|
|
172
225
|
* (the bug-hunt fix, preserved). `anchor` is `undefined` only on a query
|
|
173
226
|
* built but not yet anchored by any rule; lowering and the wire both refuse
|
|
174
|
-
* that state typed.
|
|
227
|
+
* that state typed. `members` is present exactly on a MEMBERSHIP-ARRAY
|
|
228
|
+
* entry (a literal set at a closed field, folded into the program): the
|
|
229
|
+
* SDK itself translates and supplies the set at every execute — the entry
|
|
230
|
+
* is never read from, and never demanded of, the host's params object.
|
|
175
231
|
*/
|
|
176
232
|
interface ParamEntry {
|
|
177
233
|
readonly name: string;
|
|
178
234
|
readonly shape: "value" | "set" | "mask";
|
|
179
235
|
readonly anchor: AnyField | "measure" | undefined;
|
|
180
236
|
readonly op: "binding" | "eq" | "ne" | "lt" | "le" | "gt" | "ge" | "pointIn" | "allen";
|
|
237
|
+
readonly members: readonly string[] | undefined;
|
|
181
238
|
}
|
|
182
|
-
export type { AnyTerm,
|
|
183
|
-
export { fieldJoins, inferred, isTerm, makeDuration, makeMaskParam, makeParam, makeSetParam, makeVar, renderFieldKind, term };
|
|
239
|
+
export type { AnyTerm, ClassedField, Duration, EnvShape, Flatten, InferredOf, JoinOk, MaskParam, Param, ParamEntry, ParamsRecord, ParamValueAt, SetParam, ShapeOf, UnionToIntersection, Var, VarsRecord };
|
|
240
|
+
export { fieldJoins, inferred, isTerm, makeDuration, makeMaskParam, makeParam, makeSetParam, makeVar, makeVars, renderFieldKind, term };
|
|
184
241
|
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/query/scope.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/query/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;GAIG;AACH,QAAA,MAAM,IAAI,EAAE,OAAO,MAAsC,CAAA;AAEzD;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,EAAE,OAAO,MAA0C,CAAA;AAEjE;;;;;;GAMG;AACH,UAAU,GAAG,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IACzC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CACnB;AAED;;;;;GAKG;AACH,UAAU,KAAK,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IAC3C,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CACnB;AAED;;;;;;GAMG;AACH,UAAU,QAAQ,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;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AG,SAAS,GAAG,OAAO,CAAA;IACtF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAC/C;AAED,YAAY,EACX,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,GAAG,EACH,UAAU,EACV,CAAA;AACD,OAAO,EACN,UAAU,EACV,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,CAAA"}
|
package/dist/query/scope.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Query scope terms,
|
|
2
|
+
* Query scope terms, LAW-TYPED edition: string-named variables and
|
|
3
3
|
* parameters as plain frozen values. A `Var` is a NAME — it is typed by the
|
|
4
|
-
* field it first binds (
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* and
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
4
|
+
* field slot it first binds (the descriptor AND the slot's law-computed
|
|
5
|
+
* CLASS, read off the schema's class map through the rule builder's
|
|
6
|
+
* environment), reuse of the name within one rule IS the join, and a
|
|
7
|
+
* class-mismatched reuse is a compile error: a var joins only class-equal
|
|
8
|
+
* slots, and BARE PAIRS ONLY WITH BARE (ruling 3 — a slot in no law has no
|
|
9
|
+
* class and never joins a classed slot; the deliberate sum-domain pointer
|
|
10
|
+
* stays legal against other bare slots). Params are query-global by name
|
|
11
|
+
* and typed BY USE: the field position or comparison sibling that anchors
|
|
12
|
+
* a param types it, the query's inferred `Params` object is exactly the
|
|
13
|
+
* params the rules use, and a param value that no rule uses simply never
|
|
14
|
+
* registers — the query executes under its own inferred type (the
|
|
15
|
+
* bug-hunt law). This module also owns the environment/typing utilities
|
|
16
|
+
* the whole surface shares: the env shape (var name → classed slot), the
|
|
17
|
+
* class-equality judgment {@link JoinOk} with its runtime twin
|
|
18
|
+
* {@link fieldJoins}, and the record-folding helpers `Params` and `Row`
|
|
19
|
+
* inference ride.
|
|
17
20
|
*/
|
|
21
|
+
import * as errors from "@superbuilders/errors";
|
|
18
22
|
/**
|
|
19
23
|
* The runtime discriminant of query term values. Host literals (bigints,
|
|
20
24
|
* strings, interval objects) never carry it, so "is this position a term
|
|
@@ -37,6 +41,47 @@ function makeVar(name) {
|
|
|
37
41
|
const value = { [term]: "var", name };
|
|
38
42
|
return Object.freeze(value);
|
|
39
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The trusted seam of the vars mint: every requested name reads back as an
|
|
46
|
+
* own var term of exactly that name — verified before the record is
|
|
47
|
+
* admitted at the {@link VarsRecord} type (a name riding the
|
|
48
|
+
* object-protocol accessor instead of an own definition would fail exactly
|
|
49
|
+
* this check).
|
|
50
|
+
*/
|
|
51
|
+
function varsMinted(record, names) {
|
|
52
|
+
return names.every(function varMinted(name) {
|
|
53
|
+
if (!Object.hasOwn(record, name)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const value = record[name];
|
|
57
|
+
return isTerm(value) && value[term] === "var" && value.name === name;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Mints several variables at once — `const { service, w } = r.vars("service",
|
|
62
|
+
* "w")`: tuple-to-object, each name typed exactly (`Var<"service">`),
|
|
63
|
+
* inference identical to the one-at-a-time `r.var` spelling (one lowering,
|
|
64
|
+
* two entry flavors). Each key is defined as an OWN property (a name like
|
|
65
|
+
* `"__proto__"` is a record key like any other, never a prototype write),
|
|
66
|
+
* and a duplicate name in one call is a construction error: each name mints
|
|
67
|
+
* one variable — write it once and reuse the binding.
|
|
68
|
+
*/
|
|
69
|
+
function makeVars(...names) {
|
|
70
|
+
const out = {};
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
for (const name of names) {
|
|
73
|
+
if (seen.has(name)) {
|
|
74
|
+
throw errors.new(`vars: duplicate name ${name} — each name mints one variable; write it once and reuse the binding`);
|
|
75
|
+
}
|
|
76
|
+
seen.add(name);
|
|
77
|
+
Object.defineProperty(out, name, { value: makeVar(name), enumerable: true });
|
|
78
|
+
}
|
|
79
|
+
Object.freeze(out);
|
|
80
|
+
if (!varsMinted(out, names)) {
|
|
81
|
+
throw errors.new("vars: variable minting incomplete");
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
40
85
|
/** Builds one scalar-parameter term. */
|
|
41
86
|
function makeParam(name) {
|
|
42
87
|
const value = { [term]: "param", name };
|
|
@@ -58,33 +103,47 @@ function makeDuration(name) {
|
|
|
58
103
|
return Object.freeze(value);
|
|
59
104
|
}
|
|
60
105
|
/**
|
|
61
|
-
* The runtime twin of {@link JoinOk}: two
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
106
|
+
* The runtime twin of {@link JoinOk}: two bound slots join iff descriptor
|
|
107
|
+
* structure and class agree — the same comparison the type tier makes,
|
|
108
|
+
* judged on the honest runtime values (the descriptor, the roster by VALUE
|
|
109
|
+
* IDENTITY — vocabulary identity is value identity — and the schema
|
|
110
|
+
* value's frozen class map). The rule builders throw through this on a
|
|
111
|
+
* class-unequal variable reuse, so the wall holds for untyped callers too,
|
|
112
|
+
* not only where the compiler can see.
|
|
67
113
|
*/
|
|
68
114
|
function fieldJoins(a, b) {
|
|
69
|
-
const widthA = "width" in a ? a.width : undefined;
|
|
70
|
-
const widthB = "width" in b ? b.width : undefined;
|
|
71
|
-
const elementA = "element" in a ? a.element : undefined;
|
|
72
|
-
const elementB = "element" in b ? b.element : undefined;
|
|
73
|
-
|
|
115
|
+
const widthA = "width" in a.field ? a.field.width : undefined;
|
|
116
|
+
const widthB = "width" in b.field ? b.field.width : undefined;
|
|
117
|
+
const elementA = "element" in a.field ? a.field.element : undefined;
|
|
118
|
+
const elementB = "element" in b.field ? b.field.element : undefined;
|
|
119
|
+
const rosterA = "closed" in a.field ? a.field.closed : undefined;
|
|
120
|
+
const rosterB = "closed" in b.field ? b.field.closed : undefined;
|
|
121
|
+
return (a.field.kind === b.field.kind &&
|
|
122
|
+
a.class === b.class &&
|
|
123
|
+
widthA === widthB &&
|
|
124
|
+
elementA === elementB &&
|
|
125
|
+
rosterA === rosterB);
|
|
74
126
|
}
|
|
75
127
|
/**
|
|
76
|
-
* Renders one
|
|
77
|
-
* grammar's
|
|
128
|
+
* Renders one bound slot for join-mismatch diagnostics — the structural
|
|
129
|
+
* kind in the schema grammar's spelling (a closed reference names its
|
|
130
|
+
* vocabulary: the roster is part of the structure being compared) plus the
|
|
131
|
+
* slot's law-computed class (`u64 in class Holder.id`; a lawless slot
|
|
132
|
+
* renders `bare`).
|
|
78
133
|
*/
|
|
79
|
-
function renderFieldKind(
|
|
134
|
+
function renderFieldKind(slot) {
|
|
135
|
+
const field = slot.field;
|
|
80
136
|
let base = field.kind;
|
|
137
|
+
if ("closed" in field) {
|
|
138
|
+
base = `u64 referencing ${field.closed.name}`;
|
|
139
|
+
}
|
|
81
140
|
if (field.kind === "bytes") {
|
|
82
141
|
base = `bytes<${field.width}>`;
|
|
83
142
|
}
|
|
84
143
|
if (field.kind === "interval") {
|
|
85
144
|
base = field.width === undefined ? `interval<${field.element}>` : `interval<${field.element}, ${field.width}>`;
|
|
86
145
|
}
|
|
87
|
-
return
|
|
146
|
+
return slot.class === undefined ? `${base} (bare)` : `${base} in class ${slot.class}`;
|
|
88
147
|
}
|
|
89
|
-
export { fieldJoins, inferred, isTerm, makeDuration, makeMaskParam, makeParam, makeSetParam, makeVar, renderFieldKind, term };
|
|
148
|
+
export { fieldJoins, inferred, isTerm, makeDuration, makeMaskParam, makeParam, makeSetParam, makeVar, makeVars, renderFieldKind, term };
|
|
90
149
|
//# sourceMappingURL=scope.js.map
|
package/dist/query/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/query/scope.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/query/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA;AAG/C;;;;GAIG;AACH,MAAM,IAAI,GAAkB,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,QAAQ,GAAkB,MAAM,CAAC,yBAAyB,CAAC,CAAA;AAgEjE,6EAA6E;AAC7E,SAAS,MAAM,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,KAAK,CAAA;AACpE,CAAC;AAED,gCAAgC;AAChC,SAAS,OAAO,CAA4B,IAAU;IACrD,MAAM,KAAK,GAAc,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IAChD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC5B,CAAC;AAKD;;;;;;GAMG;AACH,SAAS,UAAU,CAClB,MAAyC,EACzC,KAAuB;IAEvB,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,SAAS,CAAC,IAAI;QACzC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;YAClC,OAAO,KAAK,CAAA;QACb,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAC1B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,KAA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type CheckNameSelect<Env extends EnvShape, S> = {
|
|
|
95
95
|
* type.
|
|
96
96
|
*/
|
|
97
97
|
type SelectEntryRow<Env extends EnvShape, E> = E extends string ? {
|
|
98
|
-
readonly [K in E]: Infer<Env[E & keyof Env]>;
|
|
98
|
+
readonly [K in E]: Infer<Env[E & keyof Env]["field"]>;
|
|
99
99
|
} : E extends Duration<infer N extends string> ? {
|
|
100
100
|
readonly [K in N]: bigint;
|
|
101
101
|
} : E extends Agg<"count", undefined> ? {
|
|
@@ -103,13 +103,13 @@ type SelectEntryRow<Env extends EnvShape, E> = E extends string ? {
|
|
|
103
103
|
} : E extends Agg<"countDistinct", infer O extends string> ? {
|
|
104
104
|
readonly [K in O]: bigint;
|
|
105
105
|
} : E extends Agg<"sum" | "min" | "max", infer O> ? O extends string ? {
|
|
106
|
-
readonly [K in O]: Infer<Env[O & keyof Env]>;
|
|
106
|
+
readonly [K in O]: Infer<Env[O & keyof Env]["field"]>;
|
|
107
107
|
} : O extends Duration<infer N extends string> ? {
|
|
108
108
|
readonly [K in N]: bigint;
|
|
109
109
|
} : never : E extends Agg<"argMax" | "argMin", infer O extends string, string> ? {
|
|
110
|
-
readonly [K in O]: Infer<Env[O & keyof Env]>;
|
|
110
|
+
readonly [K in O]: Infer<Env[O & keyof Env]["field"]>;
|
|
111
111
|
} : E extends Agg<"pack", infer O extends string> ? {
|
|
112
|
-
readonly [K in O]: Infer<Env[O & keyof Env]>;
|
|
112
|
+
readonly [K in O]: Infer<Env[O & keyof Env]["field"]>;
|
|
113
113
|
} : never;
|
|
114
114
|
/** The inferred answer-row object type of a select tuple. */
|
|
115
115
|
type RowOfSelect<Env extends EnvShape, S extends readonly SelectEntry[]> = ShapeOf<SelectEntryRow<Env, S[number]>>;
|
|
@@ -119,7 +119,7 @@ type RowOfSelect<Env extends EnvShape, S extends readonly SelectEntry[]> = Shape
|
|
|
119
119
|
* smears into one column's type), mirroring {@link SelectEntryRow}.
|
|
120
120
|
*/
|
|
121
121
|
type NameSelectRow<Env extends EnvShape, N> = N extends string ? {
|
|
122
|
-
readonly [K in N]: Infer<Env[K & keyof Env]>;
|
|
122
|
+
readonly [K in N]: Infer<Env[K & keyof Env]["field"]>;
|
|
123
123
|
} : never;
|
|
124
124
|
/** The inferred answer-row object type of a names-only (recursive-rule) select tuple. */
|
|
125
125
|
type RowOfNameSelect<Env extends EnvShape, S extends readonly string[]> = ShapeOf<NameSelectRow<Env, S[number]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/query/select.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAElE,4DAA4D;AAC5D,KAAK,SAAS,GAAG,OAAO,GAAG,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEjG;;;;;GAKG;AACH,UAAU,GAAG,CACZ,EAAE,SAAS,SAAS,EACpB,IAAI,SAAS,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,EAClD,GAAG,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS;IAE1C,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAA;IAChB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CACjB;AAED,kCAAkC;AAClC,KAAK,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAEvF,4EAA4E;AAC5E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AE,MAAM,CAAC,SAAS,MAAM,CAAC,GAC5C;IAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;CAAE,GACzD,KAAK,CAAA;AAEd,6DAA6D;AAC7D,KAAK,WAAW,CAAC,GAAG,SAAS,QAAQ,EAAE,CAAC,SAAS,SAAS,WAAW,EAAE,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAElH;;;;GAIG;AACH,KAAK,aAAa,CAAC,GAAG,SAAS,QAAQ,EAAE,CAAC,IAAI,CAAC,SAAS,MAAM,GAC3D;IAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;CAAE,GACzD,KAAK,CAAA;AAER,yFAAyF;AACzF,KAAK,eAAe,CAAC,GAAG,SAAS,QAAQ,EAAE,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAEhH,YAAY,EACX,GAAG,EACH,SAAS,EACT,MAAM,EACN,eAAe,EACf,WAAW,EACX,eAAe,EACf,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,CAAA;AACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA"}
|
package/dist/relation.d.ts
CHANGED
|
@@ -10,20 +10,29 @@
|
|
|
10
10
|
* optional on insert input (omit-to-mint) and present on read
|
|
11
11
|
* (resupply-to-preserve-identity), typed exactly.
|
|
12
12
|
*/
|
|
13
|
-
import type { OneOf } from "#face.ts";
|
|
14
13
|
import { type AnyField, type Infer } from "#fields.ts";
|
|
15
|
-
import type
|
|
14
|
+
import { type LiteralSetSpec } from "#spec.ts";
|
|
16
15
|
/** Flattens an intersection into one displayed object type (hover legibility). */
|
|
17
16
|
type Flatten<T> = {
|
|
18
17
|
[K in keyof T]: T[K];
|
|
19
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a whole `where()` selection against the declared fields, in the
|
|
21
|
+
* selection's written order (macro parity: σ is spelled, not sorted). An
|
|
22
|
+
* empty selection is the bare relation respelled and rejected (the
|
|
23
|
+
* canonical-utterance law). THE one selection resolver — `closed()`'s
|
|
24
|
+
* `where()` resolves its payload columns through this same machine (a
|
|
25
|
+
* `ClosedColumn` is structurally a {@link RelationField}), so both surfaces
|
|
26
|
+
* share one vocabulary and one error voice.
|
|
27
|
+
*/
|
|
28
|
+
declare function resolveSelection(name: string, ordered: readonly RelationField[], entries: ReadonlyArray<readonly [string, unknown]>): readonly SelectionBinding[];
|
|
20
29
|
/** The field block of a relation: field name to field descriptor. */
|
|
21
30
|
type FieldsShape = Record<string, AnyField>;
|
|
22
31
|
/**
|
|
23
32
|
* A typed field reference (`Account.fields.holder`) — the value statements,
|
|
24
33
|
* selections, and queries address a field through. Purely positional
|
|
25
|
-
* (relation name + field name); the field's descriptor
|
|
26
|
-
*
|
|
34
|
+
* (relation name + field name); the field's descriptor is read off the
|
|
35
|
+
* relation's schema type structurally.
|
|
27
36
|
*/
|
|
28
37
|
interface FieldRef<Rel extends string, Name extends string> {
|
|
29
38
|
readonly relation: Rel;
|
|
@@ -54,13 +63,15 @@ interface SelectionBinding {
|
|
|
54
63
|
}
|
|
55
64
|
/**
|
|
56
65
|
* The `where()` argument: per field, a bare structural literal of that
|
|
57
|
-
* field's value type (a closed
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
66
|
+
* field's value type (a closed reference's literal IS its handle name —
|
|
67
|
+
* `"Savings"`, verified against the roster at construction), a plain
|
|
68
|
+
* ARRAY of such literals read disjunctively — `kind: ["Checking",
|
|
69
|
+
* "Savings"]` — or a `span(start, end)` interval literal. Membership is
|
|
70
|
+
* an array, never an operator (the drizzle law); equality-only by
|
|
71
|
+
* construction: no operator parameter exists anywhere.
|
|
61
72
|
*/
|
|
62
73
|
type SelectionInput<Fields extends FieldsShape> = {
|
|
63
|
-
readonly [K in keyof Fields]?: Infer<Fields[K]> |
|
|
74
|
+
readonly [K in keyof Fields]?: Infer<Fields[K]> | readonly Infer<Fields[K]>[];
|
|
64
75
|
};
|
|
65
76
|
/** A relation with a selection applied — what `on()` consumes as a σ-carrying source. */
|
|
66
77
|
interface Selected<Name extends string, Fields extends FieldsShape> {
|
|
@@ -105,13 +116,16 @@ type FreshKeys<R extends AnyRelation> = {
|
|
|
105
116
|
*/
|
|
106
117
|
type InsertFact<R extends AnyRelation> = Flatten<Omit<Fact<R>, FreshKeys<R>> & Partial<Pick<Fact<R>, FreshKeys<R>>>>;
|
|
107
118
|
/**
|
|
108
|
-
* Declares one relation: `relation("Account", { id:
|
|
109
|
-
* holder:
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
119
|
+
* Declares one relation: `relation("Account", { id: u64.fresh,
|
|
120
|
+
* holder: u64, kind: Kind.id, ... })` — every field is a pure-structure
|
|
121
|
+
* descriptor (the constructor values themselves; domains are never
|
|
122
|
+
* declared: `schema()` computes them from the statements). Field
|
|
123
|
+
* declaration order is ordinal-id order (macro parity), carried at BOTH
|
|
124
|
+
* levels: the type level by the fields object, the value level by the
|
|
125
|
+
* frozen `data.fields` list — the law the schema-level class naming leans
|
|
126
|
+
* on. The returned value is frozen and side-effect free.
|
|
113
127
|
*/
|
|
114
128
|
declare function relation<const Name extends string, Fields extends FieldsShape>(name: Name, fields: Fields): Relation<Name, Fields>;
|
|
115
129
|
export type { AnyRelation, AnySelected, Fact, FieldRef, FieldRefs, FieldsShape, FreshKeys, InsertFact, Relation, RelationData, RelationField, RelationFields, Selected, SelectionBinding, SelectionInput };
|
|
116
|
-
export { relation };
|
|
130
|
+
export { relation, resolveSelection };
|
|
117
131
|
//# sourceMappingURL=relation.d.ts.map
|
package/dist/relation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../src/relation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../src/relation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,KAAK,QAAQ,EAA6B,KAAK,KAAK,EAAa,MAAM,YAAY,CAAA;AAC5F,OAAO,EAAE,KAAK,cAAc,EAAmC,MAAM,UAAU,CAAA;AAE/E,kFAAkF;AAClF,KAAK,OAAO,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AA6D1C;;;;;;;;GAQG;AACH,iBAAS,gBAAgB,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAChD,SAAS,gBAAgB,EAAE,CAsB7B;AAED,qEAAqE;AACrE,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAE3C;;;;;GAKG;AACH,UAAU,QAAQ,CAAC,GAAG,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM;IACzD,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CACpB;AAED,sDAAsD;AACtD,KAAK,SAAS,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,WAAW,IAAI;IAClE,QAAQ,EAAE,CAAC,IAAI,MAAM,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE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