@bjornpagen/bumbledb 0.15.0 → 0.17.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 +33 -49
- package/README.md +3 -3
- package/dist/capacity.d.ts +24 -136
- package/dist/capacity.d.ts.map +1 -1
- package/dist/capacity.js +18 -40
- package/dist/capacity.js.map +1 -1
- package/dist/closed.d.ts +0 -156
- package/dist/closed.d.ts.map +1 -1
- package/dist/closed.js +0 -104
- package/dist/closed.js.map +1 -1
- package/dist/db.d.ts +7 -223
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +147 -396
- package/dist/db.js.map +1 -1
- package/dist/face.d.ts +0 -133
- package/dist/face.d.ts.map +1 -1
- package/dist/face.js +0 -33
- package/dist/face.js.map +1 -1
- package/dist/fields.d.ts +1 -145
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -91
- package/dist/fields.js.map +1 -1
- package/dist/index.d.ts +11 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -13
- package/dist/index.js.map +1 -1
- package/dist/law.d.ts +111 -93
- package/dist/law.d.ts.map +1 -1
- package/dist/law.js +23 -27
- package/dist/law.js.map +1 -1
- package/dist/lower.d.ts +9 -35
- package/dist/lower.d.ts.map +1 -1
- package/dist/lower.js +8 -53
- package/dist/lower.js.map +1 -1
- package/dist/marshal.d.ts +0 -65
- package/dist/marshal.d.ts.map +1 -1
- package/dist/marshal.js +0 -72
- package/dist/marshal.js.map +1 -1
- package/dist/native.d.ts +25 -290
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +6 -66
- package/dist/native.js.map +1 -1
- package/dist/query/atom.d.ts +10 -276
- package/dist/query/atom.d.ts.map +1 -1
- package/dist/query/atom.js +1 -96
- package/dist/query/atom.js.map +1 -1
- package/dist/query/find.d.ts +10 -76
- package/dist/query/find.d.ts.map +1 -1
- package/dist/query/find.js +0 -30
- package/dist/query/find.js.map +1 -1
- package/dist/query/lower.d.ts +64 -146
- package/dist/query/lower.d.ts.map +1 -1
- package/dist/query/lower.js +19 -256
- package/dist/query/lower.js.map +1 -1
- package/dist/query/parse-ir.d.ts +0 -7
- package/dist/query/parse-ir.d.ts.map +1 -1
- package/dist/query/parse-ir.js +1 -13
- package/dist/query/parse-ir.js.map +1 -1
- package/dist/query/run.d.ts +0 -36
- package/dist/query/run.d.ts.map +1 -1
- package/dist/query/run.js +0 -44
- package/dist/query/run.js.map +1 -1
- package/dist/query/scope.d.ts +24 -180
- package/dist/query/scope.d.ts.map +1 -1
- package/dist/query/scope.js +2 -66
- package/dist/query/scope.js.map +1 -1
- package/dist/relation.d.ts +2 -50
- package/dist/relation.d.ts.map +1 -1
- package/dist/relation.js +2 -37
- package/dist/relation.js.map +1 -1
- package/dist/schema.d.ts +13 -63
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +118 -92
- package/dist/schema.js.map +1 -1
- package/dist/spec.d.ts +1 -140
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js +1 -68
- package/dist/spec.js.map +1 -1
- package/dist/statements.d.ts +6 -137
- package/dist/statements.d.ts.map +1 -1
- package/dist/statements.js +16 -119
- package/dist/statements.js.map +1 -1
- package/package.json +2 -2
- package/src/capacity.ts +26 -140
- package/src/closed.ts +5 -206
- package/src/db.ts +203 -692
- package/src/face.ts +0 -142
- package/src/fields.ts +4 -172
- package/src/index.ts +9 -15
- package/src/law.ts +201 -129
- package/src/lower.ts +8 -53
- package/src/marshal.ts +1 -85
- package/src/native.ts +47 -323
- package/src/query/atom.ts +26 -313
- package/src/query/find.ts +24 -110
- package/src/query/lower.ts +132 -377
- package/src/query/parse-ir.ts +1 -14
- package/src/query/run.ts +0 -45
- package/src/query/scope.ts +25 -186
- package/src/relation.ts +2 -66
- package/src/schema.ts +143 -122
- package/src/spec.ts +1 -160
- package/src/statements.ts +22 -174
package/dist/spec.d.ts
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The lowered wire shapes — a 1:1 TypeScript mirror of bumbledb's
|
|
3
|
-
* `SchemaSpec` bindings contract (PRD-01;
|
|
4
|
-
* `bumbledb/crates/bumbledb/src/schema/spec.rs`): a schema as named plain
|
|
5
|
-
* data, relations and dependency statements each in declaration order (the
|
|
6
|
-
* declaration-order law that mints every id). The SDK's `lower()` emits
|
|
7
|
-
* these values; the napi bridge (PRD-04) marshals them into the Rust
|
|
8
|
-
* `SchemaSpec` verbatim, and the engine's own judge (`SchemaSpec::descriptor`
|
|
9
|
-
* name resolution + `SchemaDescriptor::validate` at `Db.create`/`Db.open`)
|
|
10
|
-
* stays the single semantic authority — the SDK lowers, it never re-judges.
|
|
11
|
-
*
|
|
12
|
-
* Every u64 crosses as `bigint`, never `number` (PRD-04's marshaling law: no
|
|
13
|
-
* 53-bit hazards, no branch). Object keys are always written in one fixed
|
|
14
|
-
* literal order per shape, so serialization of a lowered schema is
|
|
15
|
-
* deterministic (byte-stable) by construction.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* A structural value type — the one type vocabulary of the `schema!` field
|
|
19
|
-
* grammar (`ValueType` in Rust): `bool`, `u64`, `i64`, `str` (`string`
|
|
20
|
-
* here), `bytes<N>` (`fixedBytes`), and the interval family (`width:
|
|
21
|
-
* undefined` is the general 16-byte encoding with rays representable;
|
|
22
|
-
* `width: w` is the fixed-width `interval<E, w>` whose encoding stores only
|
|
23
|
-
* the start).
|
|
24
|
-
*/
|
|
25
1
|
type ValueTypeSpec = {
|
|
26
2
|
readonly kind: "bool";
|
|
27
3
|
} | {
|
|
@@ -38,12 +14,6 @@ type ValueTypeSpec = {
|
|
|
38
14
|
readonly element: "u64" | "i64";
|
|
39
15
|
readonly width: bigint | undefined;
|
|
40
16
|
};
|
|
41
|
-
/**
|
|
42
|
-
* One plain engine value as carried by a lowered literal — the mirror of
|
|
43
|
-
* `bumbledb::Value` restricted to the schema-literal vocabulary (Allen masks
|
|
44
|
-
* are query-side values, never schema literals). Intervals are half-open
|
|
45
|
-
* `[start, end)`.
|
|
46
|
-
*/
|
|
47
17
|
type ValueSpec = {
|
|
48
18
|
readonly kind: "bool";
|
|
49
19
|
readonly value: boolean;
|
|
@@ -68,12 +38,6 @@ type ValueSpec = {
|
|
|
68
38
|
readonly start: bigint;
|
|
69
39
|
readonly end: bigint;
|
|
70
40
|
};
|
|
71
|
-
/**
|
|
72
|
-
* One literal as spelled: a plain value, or a closed relation's handle by
|
|
73
|
-
* name (the `| status == Frozen` spelling) — resolved by the engine through
|
|
74
|
-
* the selected field's newtype to the handle's declaration-order row id,
|
|
75
|
-
* exactly as the macro resolves it at expansion.
|
|
76
|
-
*/
|
|
77
41
|
type LiteralSpec = {
|
|
78
42
|
readonly kind: "value";
|
|
79
43
|
readonly value: ValueSpec;
|
|
@@ -81,13 +45,6 @@ type LiteralSpec = {
|
|
|
81
45
|
readonly kind: "handle";
|
|
82
46
|
readonly handle: string;
|
|
83
47
|
};
|
|
84
|
-
/**
|
|
85
|
-
* One σ binding's right side: a single literal or a literal set (read
|
|
86
|
-
* disjunctively). The SDK's selection resolver refuses the degenerate sets
|
|
87
|
-
* (a membership array needs two members — the empty set selects nothing,
|
|
88
|
-
* the one-element set is the bare literal respelled), so a lowered `many`
|
|
89
|
-
* always carries ≥ 2 literals.
|
|
90
|
-
*/
|
|
91
48
|
type LiteralSetSpec = {
|
|
92
49
|
readonly kind: "one";
|
|
93
50
|
readonly literal: LiteralSpec;
|
|
@@ -95,24 +52,11 @@ type LiteralSetSpec = {
|
|
|
95
52
|
readonly kind: "many";
|
|
96
53
|
readonly literals: readonly LiteralSpec[];
|
|
97
54
|
};
|
|
98
|
-
/**
|
|
99
|
-
* One side of a containment or capacity statement:
|
|
100
|
-
* `R(fields… | field == literal…)`, all names. `projection` is π in the
|
|
101
|
-
* statement's written order (positional pairing with the other side);
|
|
102
|
-
* `selection` is σ as (field, literal-or-set) pairs, read conjunctively.
|
|
103
|
-
*/
|
|
104
55
|
interface SideSpec {
|
|
105
56
|
readonly relation: string;
|
|
106
57
|
readonly projection: readonly string[];
|
|
107
58
|
readonly selection: ReadonlyArray<readonly [string, LiteralSetSpec]>;
|
|
108
59
|
}
|
|
109
|
-
/**
|
|
110
|
-
* One capacity bound: a non-negative literal, a u64 field of the TARGET
|
|
111
|
-
* row (the dependent bound — per-group capacity read at judge time), or
|
|
112
|
-
* the interval-measure of a TARGET-row field (`Duration(span)`). Names,
|
|
113
|
-
* not ids — the spec is the name-level wire; the engine resolves bound
|
|
114
|
-
* names against the target's FULL roster (C1), never the projection.
|
|
115
|
-
*/
|
|
116
60
|
type CapacityBoundSpec = {
|
|
117
61
|
readonly kind: "lit";
|
|
118
62
|
readonly value: bigint;
|
|
@@ -123,13 +67,6 @@ type CapacityBoundSpec = {
|
|
|
123
67
|
readonly kind: "durationField";
|
|
124
68
|
readonly field: string;
|
|
125
69
|
};
|
|
126
|
-
/**
|
|
127
|
-
* A capacity statement's weight — a TOTAL sum (C4: `unit` is a case, not
|
|
128
|
-
* an absence): the count instance (`unit`), a u64 field of the SOURCE row
|
|
129
|
-
* (`field`), or a SOURCE-row interval's measure (`durationField`). The
|
|
130
|
-
* wire always carries it — a unit statement crosses as `{ kind: "unit" }`,
|
|
131
|
-
* never by omission.
|
|
132
|
-
*/
|
|
133
70
|
type WeightSpec = {
|
|
134
71
|
readonly kind: "unit";
|
|
135
72
|
} | {
|
|
@@ -139,16 +76,6 @@ type WeightSpec = {
|
|
|
139
76
|
readonly kind: "durationField";
|
|
140
77
|
readonly field: string;
|
|
141
78
|
};
|
|
142
|
-
/**
|
|
143
|
-
* A capacity statement's window — the canonical-utterance law's surviving
|
|
144
|
-
* spellings, per-aggregate where weight-sensitive (design § 6), since the
|
|
145
|
-
* SDK's `within()` mint makes every banned spelling unwritable or a
|
|
146
|
-
* construction error: `exact` is `{n}` (`{0}` the exclusion on the unit
|
|
147
|
-
* instance, "total is zero" on a weighted one), `range` is `{lo..hi}` with
|
|
148
|
-
* lo < hi (`{0..hi}` the canonical ceiling; the hi slot admits a dependent
|
|
149
|
-
* bound — C6: hi only), `floor` is `{lo..*}` (`{1..*}` legal on weighted
|
|
150
|
-
* statements only).
|
|
151
|
-
*/
|
|
152
79
|
type CapacityWindowSpec = {
|
|
153
80
|
readonly kind: "exact";
|
|
154
81
|
readonly n: CapacityBoundSpec;
|
|
@@ -160,22 +87,12 @@ type CapacityWindowSpec = {
|
|
|
160
87
|
readonly kind: "floor";
|
|
161
88
|
readonly lo: CapacityBoundSpec;
|
|
162
89
|
};
|
|
163
|
-
/**
|
|
164
|
-
* One field: name, structural type, host newtype name — the field's
|
|
165
|
-
* DOMAIN (the macro's declared `as NewType`; the SDK's law-computed class
|
|
166
|
-
* name), carried for handle resolution only, dropped by the engine at
|
|
167
|
-
* descriptor lowering and never fingerprinted — and the `fresh` mint mark.
|
|
168
|
-
*/
|
|
169
90
|
interface FieldSpec {
|
|
170
91
|
readonly name: string;
|
|
171
92
|
readonly valueType: ValueTypeSpec;
|
|
172
93
|
readonly newtype: string | undefined;
|
|
173
94
|
readonly fresh: boolean;
|
|
174
95
|
}
|
|
175
|
-
/**
|
|
176
|
-
* One ground axiom of a closed relation: the handle plus one literal per
|
|
177
|
-
* declared intrinsic column, in field-declaration order (row id = index).
|
|
178
|
-
*/
|
|
179
96
|
interface RowSpec {
|
|
180
97
|
readonly handle: string;
|
|
181
98
|
readonly values: readonly LiteralSpec[];
|
|
@@ -194,26 +111,11 @@ interface ClosedSpec {
|
|
|
194
111
|
readonly newtype: string;
|
|
195
112
|
readonly rows: readonly RowSpec[];
|
|
196
113
|
}
|
|
197
|
-
/**
|
|
198
|
-
* One relation. A present `closed` declares it closed (the option is the
|
|
199
|
-
* kind, one sum — R7); a closed relation's `fields` are its declared
|
|
200
|
-
* intrinsic columns only — the synthetic (`id`, u64) handle field is
|
|
201
|
-
* materialized by the engine's schema validation.
|
|
202
|
-
*/
|
|
203
114
|
interface RelationSpec {
|
|
204
115
|
readonly name: string;
|
|
205
116
|
readonly fields: readonly FieldSpec[];
|
|
206
117
|
readonly closed: ClosedSpec | undefined;
|
|
207
118
|
}
|
|
208
|
-
/**
|
|
209
|
-
* One dependency statement, tagged by form. `==` is not a variant: a
|
|
210
|
-
* bidirectional containment is `containment` with `bidirectional: true`,
|
|
211
|
-
* lowered by the engine to the two adjacent containments (`source <=
|
|
212
|
-
* target` first). `capacity` reads as the operator does (C2 — target,
|
|
213
|
-
* weight, window, source): the target is the per-group parent, the source
|
|
214
|
-
* is the weighed side, and the weight is ALWAYS present (`unit` the count
|
|
215
|
-
* instance).
|
|
216
|
-
*/
|
|
217
119
|
type StatementSpec = {
|
|
218
120
|
readonly kind: "fd";
|
|
219
121
|
readonly relation: string;
|
|
@@ -230,55 +132,14 @@ type StatementSpec = {
|
|
|
230
132
|
readonly window: CapacityWindowSpec;
|
|
231
133
|
readonly source: SideSpec;
|
|
232
134
|
};
|
|
233
|
-
/**
|
|
234
|
-
* The whole theory as named plain data — what `lower()` produces and what
|
|
235
|
-
* the bridge's `dbCreate`/`dbOpen` take. Both lists are in declaration
|
|
236
|
-
* order. Only DECLARED statements appear: the engine materializes the
|
|
237
|
-
* fresh-implied and closed auto-keys itself
|
|
238
|
-
* (`SchemaDescriptor::materialized_statements` — fresh keys first, closed
|
|
239
|
-
* auto-keys second, declared statements last), so re-stating them here
|
|
240
|
-
* would double them and change the fingerprint.
|
|
241
|
-
*/
|
|
242
135
|
interface SchemaSpec {
|
|
243
136
|
readonly relations: readonly RelationSpec[];
|
|
244
137
|
readonly statements: readonly StatementSpec[];
|
|
245
138
|
}
|
|
246
|
-
/**
|
|
247
|
-
* Renders one lowered literal in the exact macro spelling the engine's own
|
|
248
|
-
* renderer uses (`schema/render.rs` `literal`): handles bare by name,
|
|
249
|
-
* integers as digits, `true`/`false`, intervals as `start..end`, strings
|
|
250
|
-
* char-escaped through the `char::escape_debug` mirror, bytes as `b"…"`
|
|
251
|
-
* byte-escaped through the `u8::escape_ascii` mirror — byte-for-byte the
|
|
252
|
-
* engine's violation canonicals, so TS-side construction errors and
|
|
253
|
-
* engine-side violations read identically and `renderStatement` equals the
|
|
254
|
-
* violation's `canonical`.
|
|
255
|
-
*/
|
|
256
139
|
declare function renderLiteral(literal: LiteralSpec): string;
|
|
257
|
-
/**
|
|
258
|
-
* Renders one σ binding's right side: a bare literal, or a disjunctive
|
|
259
|
-
* literal set in braces (`{A, B}`).
|
|
260
|
-
*/
|
|
261
140
|
declare function renderLiteralSet(set: LiteralSetSpec): string;
|
|
262
|
-
/**
|
|
263
|
-
* Renders one capacity bound in its one canonical spelling: a literal as
|
|
264
|
-
* digits, a dependent bound bare by field name, an interval-measure bound
|
|
265
|
-
* as `Duration(field)` — the spellings the engine's renderer emits.
|
|
266
|
-
*/
|
|
267
|
-
declare function renderCapacityBound(bound: CapacityBoundSpec): string;
|
|
268
|
-
/**
|
|
269
|
-
* Renders a capacity window in its one canonical spelling: `{n}` exact
|
|
270
|
-
* (`{0}` the exclusion), `{lo..hi}`, `{lo..*}` — the spelling set the
|
|
271
|
-
* engine's renderer emits for sealed statements, bounds through
|
|
272
|
-
* {@link renderCapacityBound}.
|
|
273
|
-
*/
|
|
274
141
|
declare function renderCapacityWindow(window: CapacityWindowSpec): string;
|
|
275
|
-
/**
|
|
276
|
-
* Renders a capacity weight as the operator's bracket: the unit weight
|
|
277
|
-
* renders NOTHING — the count utterance `<={lo..hi}` falls out of the one
|
|
278
|
-
* printer, never a second "legacy" arm — a field weight as `[field]`, an
|
|
279
|
-
* interval measure as `[Duration(field)]`.
|
|
280
|
-
*/
|
|
281
142
|
declare function renderWeight(weight: WeightSpec): string;
|
|
282
143
|
export type { CapacityBoundSpec, CapacityWindowSpec, ClosedSpec, FieldSpec, LiteralSetSpec, LiteralSpec, RelationSpec, RowSpec, SchemaSpec, SideSpec, StatementSpec, ValueSpec, ValueTypeSpec, WeightSpec };
|
|
283
|
-
export {
|
|
144
|
+
export { renderCapacityWindow, renderLiteral, renderLiteralSet, renderWeight };
|
|
284
145
|
//# sourceMappingURL=spec.d.ts.map
|
package/dist/spec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACrD;IACA,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,KAAK,GAAG,KAAK,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC,CAAA;AAEJ,KAAK,SAAS,GACX;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE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AAY,EACZ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,aAAa,EACb,SAAS,EACT,aAAa,EACb,UAAU,EACV,CAAA;AACD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/spec.js
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The lowered wire shapes — a 1:1 TypeScript mirror of bumbledb's
|
|
3
|
-
* `SchemaSpec` bindings contract (PRD-01;
|
|
4
|
-
* `bumbledb/crates/bumbledb/src/schema/spec.rs`): a schema as named plain
|
|
5
|
-
* data, relations and dependency statements each in declaration order (the
|
|
6
|
-
* declaration-order law that mints every id). The SDK's `lower()` emits
|
|
7
|
-
* these values; the napi bridge (PRD-04) marshals them into the Rust
|
|
8
|
-
* `SchemaSpec` verbatim, and the engine's own judge (`SchemaSpec::descriptor`
|
|
9
|
-
* name resolution + `SchemaDescriptor::validate` at `Db.create`/`Db.open`)
|
|
10
|
-
* stays the single semantic authority — the SDK lowers, it never re-judges.
|
|
11
|
-
*
|
|
12
|
-
* Every u64 crosses as `bigint`, never `number` (PRD-04's marshaling law: no
|
|
13
|
-
* 53-bit hazards, no branch). Object keys are always written in one fixed
|
|
14
|
-
* literal order per shape, so serialization of a lowered schema is
|
|
15
|
-
* deterministic (byte-stable) by construction.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* The characters Rust's `char::escape_debug` (the engine renderer's string
|
|
19
|
-
* formatter, `schema/render.rs` `literal`) escapes as `\u{…}`: everything
|
|
20
|
-
* non-printable per rustc's generated tables — the C categories (Cc, Cf,
|
|
21
|
-
* Cs, Co, Cn) and the Z separators (Zs, Zl, Zp) except U+0020 itself
|
|
22
|
-
* (`library/core/src/unicode/printable.py`).
|
|
23
|
-
*/
|
|
24
1
|
const NON_PRINTABLE = /[\p{C}\p{Z}]/u;
|
|
25
|
-
/** Grapheme-extending characters, which `char::escape_debug` always escapes even when printable. */
|
|
26
2
|
const GRAPHEME_EXTEND = /\p{Grapheme_Extend}/u;
|
|
27
|
-
/**
|
|
28
|
-
* One char exactly as Rust's `char::escape_debug` spells it (the engine
|
|
29
|
-
* renders strings char by char through it): `\0`, `\t`, `\r`, `\n`,
|
|
30
|
-
* backslash-escaped `\\`/`\'`/`\"`, `\u{hex}` (lowercase, unpadded) for
|
|
31
|
-
* grapheme-extending and non-printable chars, the char itself otherwise.
|
|
32
|
-
*/
|
|
33
3
|
function escapeDebugChar(ch) {
|
|
34
4
|
if (ch === "\0") {
|
|
35
5
|
return "\\0";
|
|
@@ -55,12 +25,6 @@ function escapeDebugChar(ch) {
|
|
|
55
25
|
}
|
|
56
26
|
return ch;
|
|
57
27
|
}
|
|
58
|
-
/**
|
|
59
|
-
* One byte exactly as Rust's `u8::escape_ascii` spells it (the engine
|
|
60
|
-
* renders `bytes<N>` literals byte by byte through it): `\t`, `\r`, `\n`,
|
|
61
|
-
* `\\`, `\'`, `\"` as two-char escapes, printable ASCII (0x20–0x7e)
|
|
62
|
-
* verbatim, everything else `\xNN` lowercase.
|
|
63
|
-
*/
|
|
64
28
|
function escapeAsciiByte(byte) {
|
|
65
29
|
if (byte === 0x09) {
|
|
66
30
|
return "\\t";
|
|
@@ -85,16 +49,6 @@ function escapeAsciiByte(byte) {
|
|
|
85
49
|
}
|
|
86
50
|
return `\\x${byte.toString(16).padStart(2, "0")}`;
|
|
87
51
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Renders one lowered literal in the exact macro spelling the engine's own
|
|
90
|
-
* renderer uses (`schema/render.rs` `literal`): handles bare by name,
|
|
91
|
-
* integers as digits, `true`/`false`, intervals as `start..end`, strings
|
|
92
|
-
* char-escaped through the `char::escape_debug` mirror, bytes as `b"…"`
|
|
93
|
-
* byte-escaped through the `u8::escape_ascii` mirror — byte-for-byte the
|
|
94
|
-
* engine's violation canonicals, so TS-side construction errors and
|
|
95
|
-
* engine-side violations read identically and `renderStatement` equals the
|
|
96
|
-
* violation's `canonical`.
|
|
97
|
-
*/
|
|
98
52
|
function renderLiteral(literal) {
|
|
99
53
|
if (literal.kind === "handle") {
|
|
100
54
|
return literal.handle;
|
|
@@ -125,21 +79,12 @@ function renderLiteral(literal) {
|
|
|
125
79
|
return `${value.start}..${value.end}`;
|
|
126
80
|
}
|
|
127
81
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Renders one σ binding's right side: a bare literal, or a disjunctive
|
|
130
|
-
* literal set in braces (`{A, B}`).
|
|
131
|
-
*/
|
|
132
82
|
function renderLiteralSet(set) {
|
|
133
83
|
if (set.kind === "one") {
|
|
134
84
|
return renderLiteral(set.literal);
|
|
135
85
|
}
|
|
136
86
|
return `{${set.literals.map(renderLiteral).join(", ")}}`;
|
|
137
87
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Renders one capacity bound in its one canonical spelling: a literal as
|
|
140
|
-
* digits, a dependent bound bare by field name, an interval-measure bound
|
|
141
|
-
* as `Duration(field)` — the spellings the engine's renderer emits.
|
|
142
|
-
*/
|
|
143
88
|
function renderCapacityBound(bound) {
|
|
144
89
|
switch (bound.kind) {
|
|
145
90
|
case "lit":
|
|
@@ -150,12 +95,6 @@ function renderCapacityBound(bound) {
|
|
|
150
95
|
return `Duration(${bound.field})`;
|
|
151
96
|
}
|
|
152
97
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Renders a capacity window in its one canonical spelling: `{n}` exact
|
|
155
|
-
* (`{0}` the exclusion), `{lo..hi}`, `{lo..*}` — the spelling set the
|
|
156
|
-
* engine's renderer emits for sealed statements, bounds through
|
|
157
|
-
* {@link renderCapacityBound}.
|
|
158
|
-
*/
|
|
159
98
|
function renderCapacityWindow(window) {
|
|
160
99
|
switch (window.kind) {
|
|
161
100
|
case "exact":
|
|
@@ -166,12 +105,6 @@ function renderCapacityWindow(window) {
|
|
|
166
105
|
return `{${renderCapacityBound(window.lo)}..*}`;
|
|
167
106
|
}
|
|
168
107
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Renders a capacity weight as the operator's bracket: the unit weight
|
|
171
|
-
* renders NOTHING — the count utterance `<={lo..hi}` falls out of the one
|
|
172
|
-
* printer, never a second "legacy" arm — a field weight as `[field]`, an
|
|
173
|
-
* interval measure as `[Duration(field)]`.
|
|
174
|
-
*/
|
|
175
108
|
function renderWeight(weight) {
|
|
176
109
|
switch (weight.kind) {
|
|
177
110
|
case "unit":
|
|
@@ -182,5 +115,5 @@ function renderWeight(weight) {
|
|
|
182
115
|
return `[Duration(${weight.field})]`;
|
|
183
116
|
}
|
|
184
117
|
}
|
|
185
|
-
export {
|
|
118
|
+
export { renderCapacityWindow, renderLiteral, renderLiteralSet, renderWeight };
|
|
186
119
|
//# sourceMappingURL=spec.js.map
|
package/dist/spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":"AAwGA,MAAM,aAAa,GAAG,eAAe,CAAA;AAErC,MAAM,eAAe,GAAG,sBAAsB,CAAA;AAE9C,SAAS,eAAe,CAAC,EAAU;IAClC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAA;IACb,CAAC;IACD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAA;IACb,CAAC;IACD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAA;IACb,CAAC;IACD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAA;IACb,CAAC;IACD,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;QAC7C,OAAO,KAAK,EAAE,EAAE,CAAA;IACjB,CAAC;IACD,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAA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C;QACpB,KAAK,KAAK;YACT,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;QAC9B,KAAK,OAAO;YACX,OAAO,KAAK,CAAC,KAAK,CAAA;QACnB,KAAK,eAAe;YACnB,OAAO,YAAY,KAAK,CAAC,KAAK,GAAG,CAAA;IACnC,CAAC;AACF,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA0B;IACvD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,OAAO;YACX,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAA;QAC5C,KAAK,OAAO;YACX,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAA;QAChF,KAAK,OAAO;YACX,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAA;IACjD,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,MAAkB;IACvC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,MAAM;YACV,OAAO,EAAE,CAAA;QACV,KAAK,OAAO;YACX,OAAO,IAAI,MAAM,CAAC,KAAK,GAAG,CAAA;QAC3B,KAAK,eAAe;YACnB,OAAO,aAAa,MAAM,CAAC,KAAK,IAAI,CAAA;IACtC,CAAC;AACF,CAAC;AAkBD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/statements.d.ts
CHANGED
|
@@ -1,55 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dependency statements as typed values (`docs/architecture/30-dependencies.md`
|
|
3
|
-
* owns the semantics; `docs/architecture/70-api.md` the surface): the FD key
|
|
4
|
-
* form, conditional containment, the bidirectional `==` abbreviation, and
|
|
5
|
-
* the capacity statement. A statement value is opaque and inert — no
|
|
6
|
-
* methods, no fluent continuation: a fact about the theory, not a builder.
|
|
7
|
-
*
|
|
8
|
-
* Every field reference is checked against the relation it names in the
|
|
9
|
-
* TYPE — existence through {@link FaceFields} (`on(R, "nope")` does not
|
|
10
|
-
* compile) and STRUCTURAL compatibility through {@link SameShapes}: the two
|
|
11
|
-
* faces' projected kind/width/element/roster quadruples are read off the
|
|
12
|
-
* schema type (the minimal kernel — descriptors are pure structure) and
|
|
13
|
-
* constrained positionwise equal, so a u64 face against a str face, a
|
|
14
|
-
* bytes width mismatch, an interval element mismatch, or a bare column
|
|
15
|
-
* against a closed reference is a compile error. TWO of those walls carry
|
|
16
|
-
* construction-time runtime twins here for untyped callers: ARITY
|
|
17
|
-
* ({@link assertArityAgreement} — cleanup-0.5.0 ruling 9: an
|
|
18
|
-
* arity-mismatched pairing fails at the statement, never by silent
|
|
19
|
-
* truncation) and the ROSTER slot ({@link assertRosterAgreement} —
|
|
20
|
-
* roster IDENTITY, positionwise: a closed vocabulary's referencing column
|
|
21
|
-
* is spelled with the vocabulary's own id descriptor, the ONE spelling, so
|
|
22
|
-
* a plain u64 column can never alias a vocabulary through a declared law
|
|
23
|
-
* and the SDK's descriptor-keyed closed judgments stay sound). Domains are
|
|
24
|
-
* NOT compared here — there is no domain to compare at construction: the
|
|
25
|
-
* statements themselves are what define the equivalence classes, and the
|
|
26
|
-
* domain wall lives where they aggregate — `schema()` (the
|
|
27
|
-
* one-generator-per-class law) and query joins (class names off the schema
|
|
28
|
-
* type). What is only a SEMANTIC property — the target side of a
|
|
29
|
-
* containment resolving a declared key of its relation — is DELIBERATELY
|
|
30
|
-
* not (and cannot be) stated here: whether `B(y)` is a key of `B` depends
|
|
31
|
-
* on which `key()` statements the surrounding `schema()` collects, a set no
|
|
32
|
-
* face type can see; it stays the engine's typed `SchemaError` judgment at
|
|
33
|
-
* `Db.create`/`Db.open` (the two-boundary split, engine as final
|
|
34
|
-
* authority).
|
|
35
|
-
*/
|
|
36
1
|
import { type BoundsOnTarget, type CapacityWeight, type CapacityWindow, type UnitDimensionBan, type UnitWindowBan, type WeightOnSource } from "./capacity.js";
|
|
37
2
|
import { type AnyFace, type FaceData, type SameArity, type SameShapes } from "./face.js";
|
|
38
3
|
import type { AnyRelation, RelationFields } from "./relation.js";
|
|
39
4
|
import { type CapacityWindowSpec, type WeightSpec } from "./spec.js";
|
|
40
|
-
/** A `key()` statement's runtime description — owner and projection carried at exact types. */
|
|
41
5
|
interface KeyData<R extends AnyRelation, Projection extends readonly string[]> {
|
|
42
6
|
readonly kind: "key";
|
|
43
7
|
readonly owner: R;
|
|
44
8
|
readonly projection: Projection;
|
|
45
9
|
}
|
|
46
|
-
/**
|
|
47
|
-
* A containment statement's runtime description — the two faces carried at
|
|
48
|
-
* their EXACT types (owner names and projection tuples are honest runtime
|
|
49
|
-
* properties, and they are the type-level carrier `schema()`'s law-typing
|
|
50
|
-
* pairs slots through). The defaults are the wide shape renderers and the
|
|
51
|
-
* wire lowering consume.
|
|
52
|
-
*/
|
|
53
10
|
interface ContainmentData<Src extends FaceData = FaceData, Tgt extends FaceData = FaceData> {
|
|
54
11
|
readonly kind: "containment";
|
|
55
12
|
readonly source: Src;
|
|
@@ -60,12 +17,6 @@ interface MirrorsData<Src extends FaceData = FaceData, Tgt extends FaceData = Fa
|
|
|
60
17
|
readonly source: Src;
|
|
61
18
|
readonly target: Tgt;
|
|
62
19
|
}
|
|
63
|
-
/**
|
|
64
|
-
* A capacity statement's runtime description — target-left, in the
|
|
65
|
-
* operator's own order (C2: target, weight, window, source), faces at
|
|
66
|
-
* exact types like {@link ContainmentData}. The weight is ALWAYS present
|
|
67
|
-
* (C4 — `unit` is a case, not an absence).
|
|
68
|
-
*/
|
|
69
20
|
interface CapacityData<Tgt extends FaceData = FaceData, Src extends FaceData = FaceData> {
|
|
70
21
|
readonly kind: "capacity";
|
|
71
22
|
readonly target: Tgt;
|
|
@@ -73,56 +24,19 @@ interface CapacityData<Tgt extends FaceData = FaceData, Src extends FaceData = F
|
|
|
73
24
|
readonly window: CapacityWindowSpec;
|
|
74
25
|
readonly source: Src;
|
|
75
26
|
}
|
|
76
|
-
/** One statement's runtime description, tagged by form. */
|
|
77
27
|
type StatementData = KeyData<AnyRelation, readonly string[]> | ContainmentData | MirrorsData | CapacityData;
|
|
78
|
-
/**
|
|
79
|
-
* The admission brand — a module-private symbol, deliberately unexported
|
|
80
|
-
* (the `capacity.ts` pattern): `Statement` is a public structural type, so
|
|
81
|
-
* without this brand a forged plain object of the right shape would walk
|
|
82
|
-
* past the construction-time arity and roster walls into `schema()` — and
|
|
83
|
-
* the roster wall is the one the engine cannot backstop (the wire carries
|
|
84
|
-
* plain u64s, no rosters). The symbol makes the four constructors the ONLY
|
|
85
|
-
* mints, so a statement that skipped the walls is unspellable.
|
|
86
|
-
*/
|
|
87
28
|
declare const admitted: unique symbol;
|
|
88
|
-
/** An opaque statement value — what `schema()` assembles into a theory. Only the four constructors produce one. */
|
|
89
29
|
interface Statement {
|
|
90
30
|
readonly data: StatementData;
|
|
91
31
|
readonly [admitted]: true;
|
|
92
32
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Narrows any value to an admitted statement — the probe is the
|
|
95
|
-
* module-private {@link admitted} brand only the four constructors set, so
|
|
96
|
-
* no host-built value (fact cells are structurally OPEN — an interval with
|
|
97
|
-
* an excess `kind` property is a legal cell) can ever be misread as one.
|
|
98
|
-
* The keyed-get selector dispatch and `schema()`'s admission both judge
|
|
99
|
-
* through here.
|
|
100
|
-
*/
|
|
101
33
|
declare function isStatement(value: unknown): value is Statement;
|
|
102
|
-
/**
|
|
103
|
-
* A containment (or `==` bijection) statement as a TYPED value: `data`
|
|
104
|
-
* carries both faces at their exact types, so the schema-level class laws
|
|
105
|
-
* can read every paired (relation, field) slot off the statement type —
|
|
106
|
-
* spell the statement list inline in `schema()` and the equivalence
|
|
107
|
-
* classes compute at the type level too. Structurally still a plain
|
|
108
|
-
* {@link Statement}.
|
|
109
|
-
*/
|
|
110
34
|
interface ContainedStatement<Src extends FaceData, Tgt extends FaceData> extends Statement {
|
|
111
35
|
readonly data: ContainmentData<Src, Tgt> | MirrorsData<Src, Tgt>;
|
|
112
36
|
}
|
|
113
|
-
/** A capacity statement as a TYPED value — the {@link ContainedStatement} of the capacity form. */
|
|
114
37
|
interface CapacityStatement<Tgt extends FaceData, Src extends FaceData> extends Statement {
|
|
115
38
|
readonly data: CapacityData<Tgt, Src>;
|
|
116
39
|
}
|
|
117
|
-
/**
|
|
118
|
-
* A `key()` statement as a TYPED value: its `data` carries the owner
|
|
119
|
-
* relation and the projection tuple at their EXACT types (honest runtime
|
|
120
|
-
* properties — no phantom), which is what the key-statement-selected
|
|
121
|
-
* `get(relation, keyStatement, key)` overload types its key object by
|
|
122
|
-
* (`docs/architecture/70-api.md` § the freeze, the multi-key typed get) and
|
|
123
|
-
* what resolves each projected field's descriptor through the owner's
|
|
124
|
-
* schema type. Structurally still a plain {@link Statement}.
|
|
125
|
-
*/
|
|
126
40
|
interface KeyStatement<R extends AnyRelation, Projection extends readonly string[]> extends Statement {
|
|
127
41
|
readonly data: KeyData<R, Projection>;
|
|
128
42
|
}
|
|
@@ -135,63 +49,18 @@ interface KeyStatement<R extends AnyRelation, Projection extends readonly string
|
|
|
135
49
|
* checked against `R`'s field block in the type, and the tuple is carried
|
|
136
50
|
* in the returned value's type ({@link KeyStatement}) — keyed point reads
|
|
137
51
|
* through THIS statement are typed field-for-field, descriptors resolvable
|
|
138
|
-
* through the owner's schema type.
|
|
52
|
+
* through the owner's schema type. A DUPLICATE field in the projection is
|
|
53
|
+
* refused here, at the mint (the engine's `FieldSet` refuses the same
|
|
54
|
+
* duplicate at `Db.create`; canonical utterance says the twice-spelled
|
|
55
|
+
* field is the once-spelled projection respelled) — without this wall a
|
|
56
|
+
* `new Set`-collapsed duplicate could set-match a shorter target
|
|
57
|
+
* projection the engine refuses.
|
|
139
58
|
*/
|
|
140
59
|
declare function key<R extends AnyRelation, const Projection extends readonly [keyof RelationFields<R> & string, ...(keyof RelationFields<R> & string)[]]>(relation: R, fields: Projection): KeyStatement<R, Projection>;
|
|
141
|
-
/**
|
|
142
|
-
* `A(X|φ) <= B(Y|ψ)` — conditional inclusion, source left. Arity mismatch
|
|
143
|
-
* between the two faces is a type error ({@link SameArity}); a structurally
|
|
144
|
-
* mismatched pair is a type error ({@link SameShapes} — positionwise
|
|
145
|
-
* equality of the projected kind/width/element triples). The target side
|
|
146
|
-
* must resolve a declared key of B — a SEMANTIC property of the whole
|
|
147
|
-
* statement set that no face type can state, DELIBERATELY judged by the
|
|
148
|
-
* engine at `Db.create`/`Db.open` (`SchemaError`), never re-checked here.
|
|
149
|
-
*/
|
|
150
60
|
declare function contained<A extends AnyFace, B extends AnyFace>(source: A, target: B & SameArity<A, B> & SameShapes<A, B>): ContainedStatement<A["data"], B["data"]>;
|
|
151
|
-
/**
|
|
152
|
-
* `A(X|φ) == B(Y|ψ)` — the bidirectional abbreviation, one utterance: the
|
|
153
|
-
* selected `==` bijection, a keyed one-to-one correspondence between the
|
|
154
|
-
* two faces (each side contains the other). It lowers to the two adjacent
|
|
155
|
-
* containments in the `A <= B` first order (macro parity — the engine
|
|
156
|
-
* performs the split, source-first) and renders as `==` once, in the
|
|
157
|
-
* written orientation. Faces pair by arity AND structural shape, exactly
|
|
158
|
-
* as {@link contained}.
|
|
159
|
-
*/
|
|
160
61
|
declare function mirrors<A extends AnyFace, B extends AnyFace>(source: A, target: B & SameArity<A, B> & SameShapes<A, B>): ContainedStatement<A["data"], B["data"]>;
|
|
161
|
-
/**
|
|
162
|
-
* `B(Y|ψ) <=[w]{window} A(X|φ)` — the capacity statement, the one
|
|
163
|
-
* extension form: per ψ-selected target fact, the group of φ-selected
|
|
164
|
-
* source facts sharing its key tuple must have its MEASURE (Σ weight; the
|
|
165
|
-
* unit weight IS the count instance) inside the window. READ CAREFULLY:
|
|
166
|
-
* the LEFT face is the TARGET, the per-group parent (B-family, target-left
|
|
167
|
-
* — macro parity), and the RIGHT face is the weighed source. Two
|
|
168
|
-
* overloads mirror the operator positionally (target, weight?, window,
|
|
169
|
-
* source): `capacity(on(Holder, "id"), within(0n, 3n), on(Account,
|
|
170
|
-
* "holder"))` says each Holder id groups at most three Account rows;
|
|
171
|
-
* `capacity(on(Pool, "id"), weigh("watts"), within(0n, ref("supply")),
|
|
172
|
-
* on(Device, "pool"))` bounds each pool's summed draw by the pool's own
|
|
173
|
-
* row. The two faces pair by arity AND structural shape
|
|
174
|
-
* ({@link SameShapes}), exactly as containment — the grouping join reads
|
|
175
|
-
* the same positionwise field pairing. The weight-sensitive bans ride the
|
|
176
|
-
* UNIT overload only: `{1..*}` ({@link UnitWindowBan} — on a weighted
|
|
177
|
-
* statement "positive total" is a different, weaker law than containment)
|
|
178
|
-
* and the `duration()` bound ({@link UnitDimensionBan} — a count of facts
|
|
179
|
-
* bounded by a span of time mixes dimensions, C18).
|
|
180
|
-
*/
|
|
181
62
|
declare function capacity<B extends AnyFace, W extends CapacityWindow, A extends AnyFace>(target: B, window: W & UnitWindowBan<W> & UnitDimensionBan<W> & BoundsOnTarget<W, B>, source: A & SameArity<B, A> & SameShapes<B, A>): CapacityStatement<B["data"], A["data"]>;
|
|
182
63
|
declare function capacity<B extends AnyFace, M extends CapacityWeight, W extends CapacityWindow, A extends AnyFace>(target: B, weight: M & WeightOnSource<M, A>, window: W & BoundsOnTarget<W, B>, source: A & SameArity<B, A> & SameShapes<B, A>): CapacityStatement<B["data"], A["data"]>;
|
|
183
|
-
/**
|
|
184
|
-
* Renders one statement in the CANONICAL macro spelling
|
|
185
|
-
* (`docs/architecture/70-api.md`; the engine's `schema/render.rs` emits the
|
|
186
|
-
* same shapes for violations) — `Account(id) -> Account`,
|
|
187
|
-
* `Account(holder) <= Holder(id)`,
|
|
188
|
-
* `Account(id | kind == Savings) == SavingsTerms(account)`,
|
|
189
|
-
* `Holder(id) <={0..3} Account(holder)`,
|
|
190
|
-
* `Pool(id) <=[watts]{0..supply} Device(pool)` — so TS-side errors and
|
|
191
|
-
* engine-side diagnostics read identically. A renderer, never a parser:
|
|
192
|
-
* strings are output-only. The unit weight renders nothing — the count
|
|
193
|
-
* utterance falls out of the one printer.
|
|
194
|
-
*/
|
|
195
64
|
declare function renderStatement(statement: Statement): string;
|
|
196
65
|
export type { CapacityData, CapacityStatement, ContainedStatement, ContainmentData, KeyData, KeyStatement, MirrorsData, Statement, StatementData };
|
|
197
66
|
export { capacity, contained, isStatement, key, mirrors, renderStatement };
|
package/dist/statements.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statements.d.ts","sourceRoot":"","sources":["../src/statements.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statements.d.ts","sourceRoot":"","sources":["../src/statements.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EAGnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAEnG,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,KAAK,kBAAkB,EAAsC,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAEvG,UAAU,OAAO,CAAC,CAAC,SAAS,WAAW,EAAE,UAAU,SAAS,SAAS,MAAM,EAAE;IAC5E,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;IACjB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;CAC/B;AAED,UAAU,eAAe,CAAC,GAAG,SAAS,QAAQ,GAAG,QAAQ,EAAE,GAAG,SAAS,QAAQ,GAAG,QAAQ;IACzF,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAA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