@bjornpagen/bumbledb 0.19.1 → 0.20.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 +2 -0
- package/README.md +1 -0
- package/dist/closed.d.ts +9 -9
- package/dist/closed.d.ts.map +1 -1
- package/dist/closed.js +27 -18
- package/dist/closed.js.map +1 -1
- package/dist/db.d.ts +8 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +6 -0
- package/dist/db.js.map +1 -1
- package/dist/face.d.ts +18 -23
- package/dist/face.d.ts.map +1 -1
- package/dist/face.js.map +1 -1
- package/dist/fields.d.ts +54 -8
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +28 -1
- package/dist/fields.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/judgment.d.ts +13 -0
- package/dist/judgment.d.ts.map +1 -0
- package/dist/judgment.js +11 -0
- package/dist/judgment.js.map +1 -0
- package/dist/law.d.ts +2 -1
- package/dist/law.d.ts.map +1 -1
- package/dist/law.js.map +1 -1
- package/dist/marshal.d.ts +2 -2
- package/dist/marshal.d.ts.map +1 -1
- package/dist/marshal.js.map +1 -1
- package/dist/native.d.ts +168 -3
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +86 -2
- package/dist/native.js.map +1 -1
- package/dist/query/atom.d.ts +10 -7
- package/dist/query/atom.d.ts.map +1 -1
- package/dist/query/atom.js +1 -1
- package/dist/query/atom.js.map +1 -1
- package/dist/query/find.d.ts +1 -2
- package/dist/query/find.d.ts.map +1 -1
- package/dist/query/find.js.map +1 -1
- package/dist/query/lower.d.ts +3 -39
- package/dist/query/lower.d.ts.map +1 -1
- package/dist/query/lower.js +48 -19
- package/dist/query/lower.js.map +1 -1
- package/dist/query/scope.d.ts +43 -38
- package/dist/query/scope.d.ts.map +1 -1
- package/dist/query/scope.js +24 -15
- package/dist/query/scope.js.map +1 -1
- package/dist/spec.d.ts +1 -1
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/statements.d.ts +1 -1
- package/dist/statements.d.ts.map +1 -1
- package/dist/statements.js +2 -2
- package/dist/statements.js.map +1 -1
- package/package.json +5 -4
- package/src/closed.ts +85 -51
- package/src/db.ts +15 -0
- package/src/face.ts +18 -24
- package/src/fields.ts +85 -7
- package/src/index.ts +43 -1
- package/src/judgment.ts +25 -0
- package/src/law.ts +2 -1
- package/src/marshal.ts +3 -3
- package/src/native.ts +320 -12
- package/src/query/atom.ts +6 -19
- package/src/query/find.ts +1 -16
- package/src/query/lower.ts +51 -32
- package/src/query/scope.ts +84 -65
- package/src/spec.ts +0 -1
- package/src/statements.ts +3 -4
package/src/law.ts
CHANGED
|
@@ -58,6 +58,7 @@ import * as errors from "@superbuilders/errors"
|
|
|
58
58
|
import type { AnyClosed } from "#closed.ts"
|
|
59
59
|
import { isClosedMember, sealedFieldsOf } from "#closed.ts"
|
|
60
60
|
import type { FaceData } from "#face.ts"
|
|
61
|
+
import type { Same } from "#judgment.ts"
|
|
61
62
|
import type { AnyRelation, RelationFields } from "#relation.ts"
|
|
62
63
|
import type { SchemaRelation, SchemaRelations } from "#schema.ts"
|
|
63
64
|
import { renderStatement, type Statement } from "#statements.ts"
|
|
@@ -196,7 +197,7 @@ type WallScan<Comps extends readonly string[], Gens extends string, Pairs extend
|
|
|
196
197
|
: WallScan<T, Gens, Pairs>
|
|
197
198
|
: unknown
|
|
198
199
|
|
|
199
|
-
type SetEq<A extends string, B extends string> =
|
|
200
|
+
type SetEq<A extends string, B extends string> = Same<A, B>
|
|
200
201
|
|
|
201
202
|
type KeyEntry = readonly [string, string]
|
|
202
203
|
|
package/src/marshal.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
import * as errors from "@superbuilders/errors"
|
|
31
|
-
import type {
|
|
31
|
+
import type { AnyClosedRoster, AnyField } from "#fields.ts"
|
|
32
32
|
import { isIntervalValue, literalShapeError, rosterOf } from "#fields.ts"
|
|
33
33
|
import type { FactValue } from "#native.ts"
|
|
34
34
|
import type { AnyRelation, Fact, FreshKeys, RelationData } from "#relation.ts"
|
|
@@ -61,7 +61,7 @@ function isStringIndexed(value: object): value is Readonly<Record<string, unknow
|
|
|
61
61
|
* violation. `indexOf` is the whole machine (the roster is ≤ 256 rows,
|
|
62
62
|
* engine law — no map is warranted).
|
|
63
63
|
*/
|
|
64
|
-
function closedCellOf(context: string, closed:
|
|
64
|
+
function closedCellOf(context: string, closed: AnyClosedRoster, name: string): FactValue {
|
|
65
65
|
const id = closed.handles.indexOf(name)
|
|
66
66
|
if (id === -1) {
|
|
67
67
|
throw errors.new(
|
|
@@ -71,7 +71,7 @@ function closedCellOf(context: string, closed: ClosedRoster, name: string): Fact
|
|
|
71
71
|
return BigInt(id)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function handleOf(context: string, closed:
|
|
74
|
+
function handleOf(context: string, closed: AnyClosedRoster, cell: FactValue): string {
|
|
75
75
|
if (typeof cell !== "bigint") {
|
|
76
76
|
throw literalShapeError(context, `a ${closed.name} handle id (bigint)`, cell)
|
|
77
77
|
}
|
package/src/native.ts
CHANGED
|
@@ -17,6 +17,13 @@ type TxHandle = { readonly __brand: "bumbledb.tx" }
|
|
|
17
17
|
|
|
18
18
|
type PreparedHandle = { readonly __brand: "bumbledb.prepared" }
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The sealed per-theory log codec (`crates/bumbledb-log`): descriptor
|
|
22
|
+
* parsed once — vocabulary + braid map — beside the fingerprint the wire
|
|
23
|
+
* pins. Immutable plain data; no lifecycle verbs.
|
|
24
|
+
*/
|
|
25
|
+
type LogCodecHandle = { readonly __brand: "bumbledb.logCodec" }
|
|
26
|
+
|
|
20
27
|
interface WireMutationReport {
|
|
21
28
|
readonly submitted: bigint
|
|
22
29
|
readonly changed: bigint
|
|
@@ -131,10 +138,152 @@ type ConditionTreeIr =
|
|
|
131
138
|
|
|
132
139
|
type StatementKindTag = "functionality" | "containment" | "capacity"
|
|
133
140
|
|
|
141
|
+
/**
|
|
142
|
+
* A log grammar lane's domain outcome: the payload, or a refusal row
|
|
143
|
+
* whose `kind` is an identity string spelled exactly as
|
|
144
|
+
* `crates/bumbledb-log` spells it (the `log-identities.json` mint table).
|
|
145
|
+
*/
|
|
146
|
+
type LogResult<T, K extends string> =
|
|
147
|
+
| { readonly ok: true; readonly value: T }
|
|
148
|
+
| { readonly ok: false; readonly kind: K; readonly message: string }
|
|
149
|
+
|
|
150
|
+
/** `DecodeError::identity` — the batch decode refusal identities. */
|
|
151
|
+
type LogBatchDecodeKind =
|
|
152
|
+
| "Truncated"
|
|
153
|
+
| "BadMagic"
|
|
154
|
+
| "Version"
|
|
155
|
+
| "Flags"
|
|
156
|
+
| "FingerprintMismatch"
|
|
157
|
+
| "UnknownBraid"
|
|
158
|
+
| "UnknownOpKind"
|
|
159
|
+
| "UnknownRelation"
|
|
160
|
+
| "ClosedRelation"
|
|
161
|
+
| "OpRelationOutsideBraid"
|
|
162
|
+
| "TagMismatch"
|
|
163
|
+
| "BoolByte"
|
|
164
|
+
| "InvalidUtf8"
|
|
165
|
+
| "EmptyInterval"
|
|
166
|
+
| "IntervalOverflow"
|
|
167
|
+
| "TrailingBytes"
|
|
168
|
+
|
|
169
|
+
/** The batch encode refusal identities (`EncodeError`, bridge-spelled). */
|
|
170
|
+
type LogBatchEncodeKind =
|
|
171
|
+
| "FingerprintMismatch"
|
|
172
|
+
| "UnknownBraid"
|
|
173
|
+
| "UnknownRelation"
|
|
174
|
+
| "ClosedRelation"
|
|
175
|
+
| "OpRelationOutsideBraid"
|
|
176
|
+
| "Arity"
|
|
177
|
+
| "Value"
|
|
178
|
+
| "TooManyOps"
|
|
179
|
+
| "TooManyRows"
|
|
180
|
+
|
|
181
|
+
/** `ManifestError::identity`. */
|
|
182
|
+
type LogManifestKind = "Malformed" | "Version"
|
|
183
|
+
|
|
184
|
+
/** `CheckpointError::identity`. */
|
|
185
|
+
type LogCheckpointKind = "Malformed" | "Version" | "Overflow" | "UnknownBraid" | "BraidSet"
|
|
186
|
+
|
|
187
|
+
/** `SidecarError::identity`. */
|
|
188
|
+
type LogSidecarKind = "Malformed" | "Version" | "UnknownBraid" | "Overflow"
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The batch header both directions. The codec handle is the fingerprint
|
|
192
|
+
* authority — the wire never carries one. `braid` is the raw braid id
|
|
193
|
+
* (the smallest relation id in its component).
|
|
194
|
+
*/
|
|
195
|
+
interface LogBatchHeader {
|
|
196
|
+
readonly braid: number
|
|
197
|
+
readonly braidGen: bigint
|
|
198
|
+
readonly prev: Uint8Array
|
|
199
|
+
readonly writer: bigint
|
|
200
|
+
readonly timestamp: bigint
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
type LogOpKind = "insert" | "delete"
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* One op inbound to `logEncodeBatch`: rows carry TAGGED values (the
|
|
207
|
+
* query-literal lane's inbound spelling) so the bridge stays layout-blind
|
|
208
|
+
* and the codec core is the one judge of every cell.
|
|
209
|
+
*/
|
|
210
|
+
interface LogOpIn {
|
|
211
|
+
readonly kind: LogOpKind
|
|
212
|
+
readonly relation: number
|
|
213
|
+
readonly rows: ReadonlyArray<readonly TaggedValue[]>
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** One decoded op: rows cross exactly as the engine's `ValueOut` walk. */
|
|
217
|
+
interface LogOpOut {
|
|
218
|
+
readonly kind: LogOpKind
|
|
219
|
+
readonly relation: number
|
|
220
|
+
readonly rows: FactValue[][]
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface LogBatch {
|
|
224
|
+
readonly header: LogBatchHeader
|
|
225
|
+
readonly ops: readonly LogOpOut[]
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
interface LogBraidComponent {
|
|
229
|
+
readonly braid: number
|
|
230
|
+
readonly relations: readonly number[]
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The braid decomposition + serial-at statement ids of one theory. */
|
|
234
|
+
interface LogBraids {
|
|
235
|
+
readonly components: readonly LogBraidComponent[]
|
|
236
|
+
readonly serialAt: readonly number[]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** The manifest document: an absent `checkpoint` is the store-birth null arm. */
|
|
240
|
+
interface LogManifestDoc {
|
|
241
|
+
readonly fingerprint: Uint8Array
|
|
242
|
+
readonly checkpoint?: Uint8Array
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
interface LogCheckpointHead {
|
|
246
|
+
readonly braid: number
|
|
247
|
+
readonly g: bigint
|
|
248
|
+
readonly hash: Uint8Array
|
|
249
|
+
readonly ts: bigint
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** The `ckpt/{digest}` document. Derived facts (digest, vector sum) stay derived. */
|
|
253
|
+
interface LogCheckpointDoc {
|
|
254
|
+
readonly braids: readonly LogCheckpointHead[]
|
|
255
|
+
readonly catalog: Uint8Array
|
|
256
|
+
readonly writer: bigint
|
|
257
|
+
readonly prev?: Uint8Array
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
interface LogChainEntry {
|
|
261
|
+
readonly braid: number
|
|
262
|
+
readonly g: bigint
|
|
263
|
+
readonly prev: Uint8Array
|
|
264
|
+
readonly ts: bigint
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
interface LogPendingBatch {
|
|
268
|
+
readonly braid: number
|
|
269
|
+
readonly slot: bigint
|
|
270
|
+
readonly bytes: Uint8Array
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The chain sidecar document: an absent `pending` is the `Settled` arm. */
|
|
274
|
+
interface LogChain {
|
|
275
|
+
readonly entries: readonly LogChainEntry[]
|
|
276
|
+
readonly pending?: LogPendingBatch
|
|
277
|
+
}
|
|
278
|
+
|
|
134
279
|
interface ManifestField {
|
|
135
280
|
readonly name: string
|
|
136
281
|
readonly id: number
|
|
137
282
|
readonly valueType: ValueTypeSpec
|
|
283
|
+
/** The field's fresh attribute, straight off the declared spec; a closed relation's synthetic `id` slot is never fresh. */
|
|
284
|
+
readonly fresh: boolean
|
|
285
|
+
/** The field's host newtype name off the declared spec; a closed relation's synthetic `id` slot carries the handle newtype. Absent on a bare column. */
|
|
286
|
+
readonly newtype?: string
|
|
138
287
|
}
|
|
139
288
|
|
|
140
289
|
interface ManifestRow {
|
|
@@ -317,6 +466,13 @@ interface Native {
|
|
|
317
466
|
|
|
318
467
|
dbGeneration(db: DbHandle): bigint
|
|
319
468
|
|
|
469
|
+
/**
|
|
470
|
+
* blake3 over the canonical catalog enumeration — the replication
|
|
471
|
+
* equality oracle: equal digests imply identical judged content
|
|
472
|
+
* regardless of page layout or allocation history.
|
|
473
|
+
*/
|
|
474
|
+
dbCatalogDigest(db: DbHandle): Uint8Array
|
|
475
|
+
|
|
320
476
|
dbFromInstance(path: string, instance: OwnedHandle): Promise<DbHandle>
|
|
321
477
|
|
|
322
478
|
/**
|
|
@@ -408,9 +564,37 @@ interface Native {
|
|
|
408
564
|
): FactValue[] | null
|
|
409
565
|
ownedPrepare(instance: OwnedHandle, query: ParsedQuery): PrepareResult
|
|
410
566
|
ownedExecute(prepared: PreparedHandle, instance: OwnedHandle, params: readonly QueryParam[]): FactValue[][]
|
|
567
|
+
|
|
568
|
+
logCodec(descriptor: SealedDescriptor): LogCodecHandle
|
|
569
|
+
|
|
570
|
+
logBraidsOf(descriptor: SealedDescriptor): LogBraids
|
|
571
|
+
|
|
572
|
+
logEncodeBatch(
|
|
573
|
+
handle: LogCodecHandle,
|
|
574
|
+
header: LogBatchHeader,
|
|
575
|
+
ops: readonly LogOpIn[]
|
|
576
|
+
): LogResult<Uint8Array, LogBatchEncodeKind>
|
|
577
|
+
|
|
578
|
+
logDecodeBatch(handle: LogCodecHandle, bytes: Uint8Array): LogResult<LogBatch, LogBatchDecodeKind>
|
|
579
|
+
|
|
580
|
+
logParseManifest(bytes: Uint8Array): LogResult<LogManifestDoc, LogManifestKind>
|
|
581
|
+
|
|
582
|
+
logRenderManifest(doc: LogManifestDoc): Uint8Array
|
|
583
|
+
|
|
584
|
+
logParseCheckpoint(handle: LogCodecHandle, bytes: Uint8Array): LogResult<LogCheckpointDoc, LogCheckpointKind>
|
|
585
|
+
|
|
586
|
+
logRenderCheckpoint(handle: LogCodecHandle, doc: LogCheckpointDoc): Uint8Array
|
|
587
|
+
|
|
588
|
+
logParseSidecar(handle: LogCodecHandle, bytes: Uint8Array): LogResult<LogChain, LogSidecarKind>
|
|
589
|
+
|
|
590
|
+
logRenderSidecar(handle: LogCodecHandle, chain: LogChain): Uint8Array
|
|
591
|
+
|
|
592
|
+
logParseCkptScratch(bytes: Uint8Array): Uint8Array | null
|
|
593
|
+
|
|
594
|
+
logRenderCkptScratch(digest: Uint8Array): Uint8Array
|
|
411
595
|
}
|
|
412
596
|
|
|
413
|
-
const SHIPPED_PLATFORMS = ["darwin-arm64", "linux-arm64"] as const
|
|
597
|
+
const SHIPPED_PLATFORMS = ["darwin-arm64", "linux-arm64", "linux-x64"] as const
|
|
414
598
|
|
|
415
599
|
const requireNative = createRequire(import.meta.url)
|
|
416
600
|
|
|
@@ -468,6 +652,109 @@ function internalDescriptor(spec: SchemaSpec): SealedDescriptor {
|
|
|
468
652
|
})
|
|
469
653
|
}
|
|
470
654
|
|
|
655
|
+
/**
|
|
656
|
+
* @internal the sealed per-theory log codec off the `DescriptorWire` —
|
|
657
|
+
* one implementation of the protocol grammar (`crates/bumbledb-log`),
|
|
658
|
+
* lent to the replication driver (`@bjornpagen/bumbledb-log`). Not SDK
|
|
659
|
+
* API; the export is deliberately undocumented in the package surface.
|
|
660
|
+
*/
|
|
661
|
+
function internalLogCodec(descriptor: SealedDescriptor): LogCodecHandle {
|
|
662
|
+
return bridged("bumbledb-log codec", function sealCodec() {
|
|
663
|
+
return binding.logCodec(descriptor)
|
|
664
|
+
})
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* @internal the braid decomposition + serial-at statement ids, riding
|
|
669
|
+
* the same `DescriptorWire`; the driver caches the result per theory
|
|
670
|
+
* beside the codec handle. Not SDK API.
|
|
671
|
+
*/
|
|
672
|
+
function internalLogBraidsOf(descriptor: SealedDescriptor): LogBraids {
|
|
673
|
+
return bridged("bumbledb-log braids", function deriveBraids() {
|
|
674
|
+
return binding.logBraidsOf(descriptor)
|
|
675
|
+
})
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** @internal batch encode through the sealed codec. Not SDK API. */
|
|
679
|
+
function internalLogEncodeBatch(
|
|
680
|
+
handle: LogCodecHandle,
|
|
681
|
+
header: LogBatchHeader,
|
|
682
|
+
ops: readonly LogOpIn[]
|
|
683
|
+
): LogResult<Uint8Array, LogBatchEncodeKind> {
|
|
684
|
+
return bridged("bumbledb-log encode", function encodeBatch() {
|
|
685
|
+
return binding.logEncodeBatch(handle, header, ops)
|
|
686
|
+
})
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/** @internal batch decode through the sealed codec. Not SDK API. */
|
|
690
|
+
function internalLogDecodeBatch(handle: LogCodecHandle, bytes: Uint8Array): LogResult<LogBatch, LogBatchDecodeKind> {
|
|
691
|
+
return bridged("bumbledb-log decode", function decodeBatch() {
|
|
692
|
+
return binding.logDecodeBatch(handle, bytes)
|
|
693
|
+
})
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** @internal manifest document parse — grammar only, no IO. Not SDK API. */
|
|
697
|
+
function internalLogParseManifest(bytes: Uint8Array): LogResult<LogManifestDoc, LogManifestKind> {
|
|
698
|
+
return bridged("bumbledb-log manifest parse", function parseManifest() {
|
|
699
|
+
return binding.logParseManifest(bytes)
|
|
700
|
+
})
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/** @internal the manifest's one encoding, byte-exact for CAS bodies. Not SDK API. */
|
|
704
|
+
function internalLogRenderManifest(doc: LogManifestDoc): Uint8Array {
|
|
705
|
+
return bridged("bumbledb-log manifest render", function renderManifest() {
|
|
706
|
+
return binding.logRenderManifest(doc)
|
|
707
|
+
})
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/** @internal checkpoint document parse against the theory's braids. Not SDK API. */
|
|
711
|
+
function internalLogParseCheckpoint(
|
|
712
|
+
handle: LogCodecHandle,
|
|
713
|
+
bytes: Uint8Array
|
|
714
|
+
): LogResult<LogCheckpointDoc, LogCheckpointKind> {
|
|
715
|
+
return bridged("bumbledb-log checkpoint parse", function parseCheckpoint() {
|
|
716
|
+
return binding.logParseCheckpoint(handle, bytes)
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** @internal checkpoint document render. Not SDK API. */
|
|
721
|
+
function internalLogRenderCheckpoint(handle: LogCodecHandle, doc: LogCheckpointDoc): Uint8Array {
|
|
722
|
+
return bridged("bumbledb-log checkpoint render", function renderCheckpoint() {
|
|
723
|
+
return binding.logRenderCheckpoint(handle, doc)
|
|
724
|
+
})
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/** @internal chain sidecar parse — the fs half stays in the driver. Not SDK API. */
|
|
728
|
+
function internalLogParseSidecar(handle: LogCodecHandle, bytes: Uint8Array): LogResult<LogChain, LogSidecarKind> {
|
|
729
|
+
return bridged("bumbledb-log sidecar parse", function parseSidecar() {
|
|
730
|
+
return binding.logParseSidecar(handle, bytes)
|
|
731
|
+
})
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** @internal chain sidecar render. Not SDK API. */
|
|
735
|
+
function internalLogRenderSidecar(handle: LogCodecHandle, chain: LogChain): Uint8Array {
|
|
736
|
+
return bridged("bumbledb-log sidecar render", function renderSidecar() {
|
|
737
|
+
return binding.logRenderSidecar(handle, chain)
|
|
738
|
+
})
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* @internal the digest a scratch-lease body names, or null — the refusal
|
|
743
|
+
* is undifferentiated by law. Not SDK API.
|
|
744
|
+
*/
|
|
745
|
+
function internalLogParseCkptScratch(bytes: Uint8Array): Uint8Array | null {
|
|
746
|
+
return bridged("bumbledb-log scratch parse", function parseScratch() {
|
|
747
|
+
return binding.logParseCkptScratch(bytes)
|
|
748
|
+
})
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/** @internal the scratch-lease body: version byte + 32-byte digest. Not SDK API. */
|
|
752
|
+
function internalLogRenderCkptScratch(digest: Uint8Array): Uint8Array {
|
|
753
|
+
return bridged("bumbledb-log scratch render", function renderScratch() {
|
|
754
|
+
return binding.logRenderCkptScratch(digest)
|
|
755
|
+
})
|
|
756
|
+
}
|
|
757
|
+
|
|
471
758
|
function isEngineThrow(value: unknown): value is { kind: ErrorFamilyKind; message: string } {
|
|
472
759
|
if (typeof value !== "object" || value === null) {
|
|
473
760
|
return false
|
|
@@ -516,34 +803,43 @@ export type {
|
|
|
516
803
|
CmpOpIr,
|
|
517
804
|
ComparisonIr,
|
|
518
805
|
ConditionTreeIr,
|
|
519
|
-
CreateResult,
|
|
520
806
|
DbHandle,
|
|
521
|
-
DbOpenResult,
|
|
522
807
|
ErrorFamilyKind,
|
|
523
808
|
FactValue,
|
|
524
809
|
FindTermIr,
|
|
525
|
-
FoldOpIr,
|
|
526
810
|
HeadOpIr,
|
|
527
811
|
HeadTermIr,
|
|
528
812
|
InstanceHandle,
|
|
529
|
-
InteriorIr,
|
|
530
813
|
IntervalValue,
|
|
814
|
+
LogBatch,
|
|
815
|
+
LogBatchDecodeKind,
|
|
816
|
+
LogBatchEncodeKind,
|
|
817
|
+
LogBatchHeader,
|
|
818
|
+
LogBraidComponent,
|
|
819
|
+
LogBraids,
|
|
820
|
+
LogChain,
|
|
821
|
+
LogChainEntry,
|
|
822
|
+
LogCheckpointDoc,
|
|
823
|
+
LogCheckpointHead,
|
|
824
|
+
LogCheckpointKind,
|
|
825
|
+
LogCodecHandle,
|
|
826
|
+
LogManifestDoc,
|
|
827
|
+
LogManifestKind,
|
|
828
|
+
LogOpIn,
|
|
829
|
+
LogOpKind,
|
|
830
|
+
LogOpOut,
|
|
831
|
+
LogPendingBatch,
|
|
832
|
+
LogResult,
|
|
833
|
+
LogSidecarKind,
|
|
531
834
|
Manifest,
|
|
532
|
-
ManifestField,
|
|
533
|
-
ManifestRelation,
|
|
534
|
-
ManifestRow,
|
|
535
|
-
ManifestStatement,
|
|
536
|
-
Native,
|
|
537
835
|
NativeWriteOutcome,
|
|
538
836
|
OpenKind,
|
|
539
837
|
OwnedHandle,
|
|
540
838
|
ParsedQuery,
|
|
541
839
|
PreparedHandle,
|
|
542
840
|
PrepareKind,
|
|
543
|
-
PrepareResult,
|
|
544
841
|
QueryIr,
|
|
545
842
|
QueryParam,
|
|
546
|
-
RecIr,
|
|
547
843
|
RuleIr,
|
|
548
844
|
SealedDescriptor,
|
|
549
845
|
SealedHi,
|
|
@@ -568,6 +864,18 @@ export {
|
|
|
568
864
|
errorFromThrow,
|
|
569
865
|
internalBlake3,
|
|
570
866
|
internalDescriptor,
|
|
867
|
+
internalLogBraidsOf,
|
|
868
|
+
internalLogCodec,
|
|
869
|
+
internalLogDecodeBatch,
|
|
870
|
+
internalLogEncodeBatch,
|
|
871
|
+
internalLogParseCheckpoint,
|
|
872
|
+
internalLogParseCkptScratch,
|
|
873
|
+
internalLogParseManifest,
|
|
874
|
+
internalLogParseSidecar,
|
|
875
|
+
internalLogRenderCheckpoint,
|
|
876
|
+
internalLogRenderCkptScratch,
|
|
877
|
+
internalLogRenderManifest,
|
|
878
|
+
internalLogRenderSidecar,
|
|
571
879
|
loadNativeBinding,
|
|
572
880
|
native,
|
|
573
881
|
SHIPPED_PLATFORMS
|
package/src/query/atom.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as errors from "@superbuilders/errors"
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyClosedRoster, AnyField, Infer, IntervalValue } from "#fields.ts"
|
|
3
3
|
import type { ClassLookup, ClassRecordOf, SchemaClasses } from "#law.ts"
|
|
4
4
|
import type {
|
|
5
5
|
AntiJoinOk,
|
|
@@ -77,7 +77,7 @@ type FindEntryData =
|
|
|
77
77
|
interface FindColumn {
|
|
78
78
|
readonly name: string
|
|
79
79
|
readonly entry: FindEntryData
|
|
80
|
-
readonly closed:
|
|
80
|
+
readonly closed: AnyClosedRoster | undefined
|
|
81
81
|
readonly slot: ClassedField | undefined
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -140,7 +140,7 @@ type DerivedTable = InteriorData | RecHead
|
|
|
140
140
|
|
|
141
141
|
type BindingInput<F extends AnyField> =
|
|
142
142
|
| Infer<F>
|
|
143
|
-
| (F extends
|
|
143
|
+
| (F extends { readonly closed: { readonly handles: readonly string[] } } ? readonly Infer<F>[] : never)
|
|
144
144
|
| (F extends { readonly kind: "interval" } ? bigint : never)
|
|
145
145
|
| AnyVar
|
|
146
146
|
| Param<string>
|
|
@@ -364,7 +364,7 @@ function not(
|
|
|
364
364
|
* closed-bound terms — the construction-time validations in
|
|
365
365
|
* `#query/lower.ts` are that ban's runtime twin.
|
|
366
366
|
*/
|
|
367
|
-
type NumericVarOk<V extends AnyVar> = V["field"] extends { readonly closed:
|
|
367
|
+
type NumericVarOk<V extends AnyVar> = V["field"] extends { readonly closed: AnyClosedRoster }
|
|
368
368
|
? false
|
|
369
369
|
: V["field"]["kind"] extends "u64" | "i64"
|
|
370
370
|
? true
|
|
@@ -545,15 +545,10 @@ type CondParamsShape<C> = ShapeOf<CondParams<C>>
|
|
|
545
545
|
|
|
546
546
|
export type {
|
|
547
547
|
AggData,
|
|
548
|
-
AnyCmp,
|
|
549
548
|
AnyCond,
|
|
550
|
-
AnyNotAtom,
|
|
551
|
-
AnyTreeChild,
|
|
552
549
|
AtomData,
|
|
553
550
|
BindingEntry,
|
|
554
551
|
BindingInput,
|
|
555
|
-
BindingTermData,
|
|
556
|
-
BindParams,
|
|
557
552
|
BindParamsShape,
|
|
558
553
|
CheckBindings,
|
|
559
554
|
CheckCond,
|
|
@@ -562,31 +557,23 @@ export type {
|
|
|
562
557
|
CmpKind,
|
|
563
558
|
CmpTermData,
|
|
564
559
|
CondData,
|
|
565
|
-
CondOkBool,
|
|
566
|
-
CondParams,
|
|
567
560
|
CondParamsShape,
|
|
568
561
|
DerivedTable,
|
|
569
562
|
FindColumn,
|
|
570
563
|
FindEntryData,
|
|
571
564
|
InteriorData,
|
|
572
|
-
IntervalSide,
|
|
573
565
|
IntervalVarOk,
|
|
574
566
|
MatchFields,
|
|
575
567
|
MatchOwner,
|
|
576
568
|
MatchShape,
|
|
577
569
|
NotAtom,
|
|
578
|
-
NotInteriorAtom,
|
|
579
570
|
NumericVarOk,
|
|
580
|
-
OrderSide,
|
|
581
571
|
ParamUse,
|
|
582
|
-
PointSide,
|
|
583
572
|
RecData,
|
|
584
573
|
RecHandle,
|
|
585
574
|
RecHead,
|
|
586
575
|
RuleData,
|
|
587
576
|
RuleItem,
|
|
588
|
-
|
|
589
|
-
Tree,
|
|
590
|
-
TreeData
|
|
577
|
+
Tree
|
|
591
578
|
}
|
|
592
|
-
export { ALLEN,
|
|
579
|
+
export { ALLEN, allen, and, comparison, eq, ge, gt, le, lt, ne, not, or, pointIn }
|
package/src/query/find.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type { IntervalVarOk, NumericVarOk } from "#query/atom.ts"
|
|
|
4
4
|
import type { AnyVar, MintSlotOf } from "#query/scope.ts"
|
|
5
5
|
|
|
6
6
|
type FoldOpName = "sum" | "min" | "max" | "pack"
|
|
7
|
-
type AggOpName = "count" | FoldOpName
|
|
8
7
|
|
|
9
8
|
interface CountAgg {
|
|
10
9
|
readonly agg: "count"
|
|
@@ -90,19 +89,5 @@ type HeadRecordOf<Classes extends SchemaClasses, F extends FindShape> = {
|
|
|
90
89
|
readonly [K in keyof F]: F[K] extends AnyVar ? MintSlotOf<Classes, F[K]> : never
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
export type {
|
|
94
|
-
Agg,
|
|
95
|
-
AggOpName,
|
|
96
|
-
AnyAgg,
|
|
97
|
-
CheckFind,
|
|
98
|
-
CheckRecFind,
|
|
99
|
-
CountAgg,
|
|
100
|
-
FindEntry,
|
|
101
|
-
FindEntryOk,
|
|
102
|
-
FindShape,
|
|
103
|
-
FindValue,
|
|
104
|
-
FoldOpName,
|
|
105
|
-
HeadRecordOf,
|
|
106
|
-
RowOfFind
|
|
107
|
-
}
|
|
92
|
+
export type { Agg, CheckFind, CheckRecFind, FindEntry, FindShape, HeadRecordOf, RowOfFind }
|
|
108
93
|
export { count, max, min, pack, sum }
|