@bjornpagen/bumbledb 1.0.0 → 1.1.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 +64 -27
- package/README.md +21 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/changes.d.ts +4 -5
- package/dist/changes.d.ts.map +1 -1
- package/dist/changes.js +37 -34
- package/dist/changes.js.map +1 -1
- package/dist/close.d.ts +2 -2
- package/dist/codec.d.ts +5 -6
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +6 -6
- package/dist/codec.js.map +1 -1
- package/dist/compile.d.ts +4 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +6 -6
- package/dist/compile.js.map +1 -1
- package/dist/db-native.d.ts +43 -56
- package/dist/db-native.d.ts.map +1 -1
- package/dist/db-native.js.map +1 -1
- package/dist/db.d.ts +43 -28
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +77 -63
- package/dist/db.js.map +1 -1
- package/dist/errors.d.ts +4 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -8
- package/dist/errors.js.map +1 -1
- package/dist/fields.d.ts +4 -5
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/log.d.ts +4 -4
- package/dist/internal/log.d.ts.map +1 -1
- package/dist/internal/log.js +1 -1
- package/dist/internal/log.js.map +1 -1
- package/dist/law.d.ts +1 -1
- package/dist/migration.d.ts +5 -7
- package/dist/migration.d.ts.map +1 -1
- package/dist/migration.js +8 -9
- package/dist/migration.js.map +1 -1
- package/dist/native.d.ts +2 -2
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/query/lower.d.ts +1 -1
- package/dist/result.d.ts +10 -25
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -12
- package/dist/result.js.map +1 -1
- package/dist/rows.d.ts +10 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +8 -45
- package/dist/rows.js.map +1 -1
- package/dist/runtime-codes.d.ts +1 -1
- package/dist/runtime-codes.d.ts.map +1 -1
- package/dist/runtime-codes.js +1 -2
- package/dist/runtime-codes.js.map +1 -1
- package/dist/runtime-errors.d.ts +3 -15
- package/dist/runtime-errors.d.ts.map +1 -1
- package/dist/runtime-errors.js +1 -5
- package/dist/runtime-errors.js.map +1 -1
- package/dist/runtime-native.d.ts +18 -48
- package/dist/runtime-native.d.ts.map +1 -1
- package/dist/runtime-native.js.map +1 -1
- package/dist/runtime.d.ts +12 -29
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +16 -57
- package/dist/runtime.js.map +1 -1
- package/dist/shape.d.ts +3 -4
- package/dist/shape.d.ts.map +1 -1
- package/dist/spec.d.ts +2 -2
- package/dist/spec.js +1 -1
- package/dist/statements.js +2 -2
- package/dist/statements.js.map +1 -1
- package/pack-provenance.json +3 -3
- package/package.json +4 -4
- package/src/capacity.ts +1 -1
- package/src/changes.ts +50 -48
- package/src/close.ts +2 -2
- package/src/codec.ts +8 -24
- package/src/compile.ts +8 -10
- package/src/db-native.ts +37 -83
- package/src/db.ts +156 -135
- package/src/errors.ts +4 -8
- package/src/fields.ts +4 -5
- package/src/index.ts +6 -5
- package/src/internal/log.ts +2 -7
- package/src/law.ts +1 -1
- package/src/migration.ts +8 -16
- package/src/native.ts +2 -3
- package/src/query/lower.ts +1 -1
- package/src/result.ts +16 -45
- package/src/rows.ts +12 -65
- package/src/runtime-codes.ts +1 -2
- package/src/runtime-errors.ts +1 -5
- package/src/runtime-native.ts +15 -68
- package/src/runtime.ts +53 -122
- package/src/shape.ts +3 -4
- package/src/spec.ts +2 -2
- package/src/statements.ts +2 -2
package/src/db-native.ts
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Private
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* OWNERSHIP NOTE (recorded in implementation/packets/P07.md): the addon
|
|
7
|
-
* implementation of every verb below is P06R's lane (`ts/crate/src/`,
|
|
8
|
-
* worker-affine sessions per P06.md's reactor design) on top of P02's C04
|
|
9
|
-
* owned snapshots and P03's C05 completed results. This file declares the
|
|
10
|
-
* exact shapes P07 codes against, exactly as `#runtime-native.ts` pins the
|
|
11
|
-
* landed runtime/directory/fs handshake. Every verb runs on the ONE bounded
|
|
12
|
-
* executor (no AsyncTask/libuv bypass), registers under the runtime's
|
|
13
|
-
* operation accounting, takes a `PolicyWire` converted once at admission,
|
|
14
|
-
* and completes through the registered callback; `runtimeCancel` cancels
|
|
2
|
+
* Private database bridge over worker-owned core snapshots and results.
|
|
3
|
+
* The implementation lives in `ts/crate/src/`; this is not a public API.
|
|
4
|
+
* Every verb runs on the shared bounded executor, registers under its
|
|
5
|
+
* operation ownership and completes through the registered callback; `runtimeCancel` cancels
|
|
15
6
|
* and joins any of them. Close verbs report the real drain outcome through
|
|
16
7
|
* `CloseWire`.
|
|
17
8
|
*/
|
|
18
9
|
import type { DbHandle, ParsedQuery, QueryParam, SealedDescriptor, Violation } from "#native.ts"
|
|
19
10
|
import { native } from "#native.ts"
|
|
20
11
|
import type { CellValue } from "#rows.ts"
|
|
21
|
-
import type { CloseWire, OperationHandle,
|
|
12
|
+
import type { CloseWire, OperationHandle, RuntimeHandle } from "#runtime-native.ts"
|
|
22
13
|
import type { SchemaSpec } from "#spec.ts"
|
|
23
14
|
|
|
24
15
|
export interface SnapshotHandle {
|
|
25
16
|
readonly __snapshot: unique symbol
|
|
26
17
|
}
|
|
27
|
-
export interface
|
|
28
|
-
readonly
|
|
18
|
+
export interface PreparedHandle {
|
|
19
|
+
readonly __prepared: unique symbol
|
|
29
20
|
}
|
|
30
21
|
export interface ResultHandle {
|
|
31
22
|
readonly __result: unique symbol
|
|
@@ -59,10 +50,7 @@ export type ApplyOutcomeWire =
|
|
|
59
50
|
/** Bounded database diagnostics: measurements, never retained row payloads. */
|
|
60
51
|
export interface DbInspectionWire {
|
|
61
52
|
readonly generation: bigint
|
|
62
|
-
readonly
|
|
63
|
-
readonly populatedBytes: bigint
|
|
64
|
-
readonly diskBytes: bigint
|
|
65
|
-
readonly residentEstimateBytes: bigint
|
|
53
|
+
readonly storage: import("#db.ts").StorageInspection
|
|
66
54
|
readonly retainedOperations: bigint
|
|
67
55
|
}
|
|
68
56
|
|
|
@@ -82,29 +70,24 @@ export interface MutationReportWire {
|
|
|
82
70
|
}
|
|
83
71
|
|
|
84
72
|
interface DbBridge {
|
|
85
|
-
/**
|
|
86
|
-
runtimeSchemaCompile(
|
|
87
|
-
runtime: RuntimeHandle,
|
|
88
|
-
policy: PolicyWire,
|
|
89
|
-
spec: SchemaSpec,
|
|
90
|
-
callback: () => void
|
|
91
|
-
): OperationHandle
|
|
73
|
+
/** Schema admission/compilation; take yields detached descriptor data. */
|
|
74
|
+
runtimeSchemaCompile(runtime: RuntimeHandle, spec: SchemaSpec, callback: () => void): OperationHandle
|
|
92
75
|
runtimeSchemaTake(operation: OperationHandle): SealedDescriptor
|
|
93
76
|
|
|
94
77
|
/** Coherent owned snapshot acquisition off a managed database. */
|
|
95
|
-
runtimeDbSnapshot(db: DbHandle,
|
|
78
|
+
runtimeDbSnapshot(db: DbHandle, callback: () => void): OperationHandle
|
|
96
79
|
runtimeSnapshotTake(operation: OperationHandle): SnapshotWire
|
|
97
80
|
runtimeSnapshotClose(snapshot: SnapshotHandle, callback: (report: CloseWire) => void): void
|
|
98
81
|
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
/** One compiled query, with an independent share of the snapshot pin. */
|
|
83
|
+
runtimeSnapshotPrepare(snapshot: SnapshotHandle, query: ParsedQuery, callback: () => void): OperationHandle
|
|
84
|
+
runtimePreparedTake(operation: OperationHandle): PreparedHandle
|
|
85
|
+
runtimePreparedClose(prepared: PreparedHandle, callback: (report: CloseWire) => void): void
|
|
86
|
+
runtimePreparedReleaseMemory(prepared: PreparedHandle, callback: () => void): OperationHandle
|
|
103
87
|
|
|
104
88
|
/** Exact-key point read; take yields one owned row or null (absent). */
|
|
105
89
|
runtimeSnapshotGet(
|
|
106
90
|
snapshot: SnapshotHandle,
|
|
107
|
-
policy: PolicyWire,
|
|
108
91
|
relationId: number,
|
|
109
92
|
keyStatementId: number,
|
|
110
93
|
keyCells: readonly CellValue[],
|
|
@@ -113,34 +96,25 @@ interface DbBridge {
|
|
|
113
96
|
runtimeRowTake(operation: OperationHandle): readonly CellValue[] | null
|
|
114
97
|
|
|
115
98
|
/**
|
|
116
|
-
* Complete
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* sealed and independent only after ALL evaluation succeeded (C05).
|
|
99
|
+
* Complete execution. One-shot preparation drops before publication;
|
|
100
|
+
* explicit preparation reuses its compiled plan and scratch. The result is
|
|
101
|
+
* sealed and independent only after ALL evaluation succeeded.
|
|
120
102
|
*/
|
|
121
103
|
runtimeSnapshotExecute(
|
|
122
104
|
snapshot: SnapshotHandle,
|
|
123
|
-
policy: PolicyWire,
|
|
124
|
-
query: ParsedQuery,
|
|
125
|
-
params: readonly QueryParam[],
|
|
126
|
-
callback: () => void
|
|
127
|
-
): OperationHandle
|
|
128
|
-
runtimeSessionExecute(
|
|
129
|
-
session: SessionHandle,
|
|
130
|
-
policy: PolicyWire,
|
|
131
105
|
query: ParsedQuery,
|
|
132
106
|
params: readonly QueryParam[],
|
|
133
107
|
callback: () => void
|
|
134
108
|
): OperationHandle
|
|
109
|
+
runtimePreparedExecute(prepared: PreparedHandle, params: readonly QueryParam[], callback: () => void): OperationHandle
|
|
135
110
|
runtimeResultTake(operation: OperationHandle): ResultHandle
|
|
136
111
|
runtimeResultClose(result: ResultHandle, callback: (report: CloseWire) => void): void
|
|
137
112
|
|
|
138
113
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* backing available. Take yields owned row arrays.
|
|
114
|
+
* Explicit full materialization into final native row arrays.
|
|
115
|
+
* Failure leaves the sealed backing available.
|
|
142
116
|
*/
|
|
143
|
-
runtimeResultCollect(result: ResultHandle,
|
|
117
|
+
runtimeResultCollect(result: ResultHandle, callback: () => void): OperationHandle
|
|
144
118
|
runtimeRowsTake(operation: OperationHandle): readonly (readonly CellValue[])[]
|
|
145
119
|
|
|
146
120
|
/**
|
|
@@ -148,25 +122,24 @@ interface DbBridge {
|
|
|
148
122
|
* private cursor. A second transfer, or transfer racing collect,
|
|
149
123
|
* refuses (SpentHandle) before touching the backing.
|
|
150
124
|
*/
|
|
151
|
-
runtimeResultCursor(result: ResultHandle,
|
|
125
|
+
runtimeResultCursor(result: ResultHandle, callback: () => void): OperationHandle
|
|
152
126
|
runtimeCursorTake(operation: OperationHandle): CursorHandle
|
|
153
|
-
/** One
|
|
154
|
-
runtimeCursorNext(cursor: CursorHandle,
|
|
127
|
+
/** One bounded delivery batch; null is EOF. Execution is already complete. */
|
|
128
|
+
runtimeCursorNext(cursor: CursorHandle, callback: () => void): OperationHandle
|
|
155
129
|
runtimePageTake(operation: OperationHandle): readonly (readonly CellValue[])[] | null
|
|
156
130
|
runtimeCursorClose(cursor: CursorHandle, callback: (report: CloseWire) => void): void
|
|
157
131
|
|
|
158
132
|
/** Database-free draft acquisition (schema compiled/checked on the executor). */
|
|
159
|
-
runtimeDraftOpen(runtime: RuntimeHandle,
|
|
133
|
+
runtimeDraftOpen(runtime: RuntimeHandle, spec: SchemaSpec, callback: () => void): OperationHandle
|
|
160
134
|
runtimeDraftTake(operation: OperationHandle): DraftHandle
|
|
161
135
|
/**
|
|
162
136
|
* One bounded ingestion chunk (rows × arity cells, row-major, sealed
|
|
163
|
-
* field order).
|
|
164
|
-
*
|
|
137
|
+
* field order). Rows are owned by the draft until finish. Failure spends
|
|
138
|
+
* the draft and starts tracked
|
|
165
139
|
* drain natively.
|
|
166
140
|
*/
|
|
167
141
|
runtimeDraftInsert(
|
|
168
142
|
draft: DraftHandle,
|
|
169
|
-
policy: PolicyWire,
|
|
170
143
|
relationId: number,
|
|
171
144
|
rows: bigint,
|
|
172
145
|
cells: readonly CellValue[],
|
|
@@ -174,7 +147,6 @@ interface DbBridge {
|
|
|
174
147
|
): OperationHandle
|
|
175
148
|
runtimeDraftDelete(
|
|
176
149
|
draft: DraftHandle,
|
|
177
|
-
policy: PolicyWire,
|
|
178
150
|
relationId: number,
|
|
179
151
|
rows: bigint,
|
|
180
152
|
cells: readonly CellValue[],
|
|
@@ -182,28 +154,22 @@ interface DbBridge {
|
|
|
182
154
|
): OperationHandle
|
|
183
155
|
runtimeReportTake(operation: OperationHandle): MutationReportWire
|
|
184
156
|
/** Consumes the draft into an immutable schema-bound ChangeSet (one command, add-wins normalization). */
|
|
185
|
-
runtimeDraftFinish(draft: DraftHandle,
|
|
157
|
+
runtimeDraftFinish(draft: DraftHandle, callback: () => void): OperationHandle
|
|
186
158
|
runtimeChangesTake(operation: OperationHandle): ChangesWire
|
|
187
159
|
runtimeDraftClose(draft: DraftHandle, callback: (report: CloseWire) => void): void
|
|
188
160
|
runtimeChangesClose(changes: ChangesHandle, callback: (report: CloseWire) => void): void
|
|
189
161
|
|
|
190
162
|
/** One immutable final-state admission/commit under the managed owner. */
|
|
191
|
-
runtimeDbApply(
|
|
192
|
-
db: DbHandle,
|
|
193
|
-
policy: PolicyWire,
|
|
194
|
-
changes: ChangesHandle,
|
|
195
|
-
expected: ExpectedWire,
|
|
196
|
-
callback: () => void
|
|
197
|
-
): OperationHandle
|
|
163
|
+
runtimeDbApply(db: DbHandle, changes: ChangesHandle, expected: ExpectedWire, callback: () => void): OperationHandle
|
|
198
164
|
runtimeApplyTake(operation: OperationHandle): ApplyOutcomeWire
|
|
199
165
|
|
|
200
|
-
runtimeDbInspect(db: DbHandle,
|
|
166
|
+
runtimeDbInspect(db: DbHandle, callback: () => void): OperationHandle
|
|
167
|
+
runtimeDbClearCache(db: DbHandle, callback: () => void): OperationHandle
|
|
201
168
|
runtimeDbInspectTake(operation: OperationHandle): DbInspectionWire
|
|
202
169
|
|
|
203
170
|
/** Shared canonical row codec (also the log/migration encoding). */
|
|
204
171
|
runtimeEncodeRows(
|
|
205
172
|
runtime: RuntimeHandle,
|
|
206
|
-
policy: PolicyWire,
|
|
207
173
|
spec: SchemaSpec,
|
|
208
174
|
relationId: number,
|
|
209
175
|
rows: bigint,
|
|
@@ -213,7 +179,6 @@ interface DbBridge {
|
|
|
213
179
|
runtimeBytesTake(operation: OperationHandle): Uint8Array
|
|
214
180
|
runtimeDecodeRows(
|
|
215
181
|
runtime: RuntimeHandle,
|
|
216
|
-
policy: PolicyWire,
|
|
217
182
|
spec: SchemaSpec,
|
|
218
183
|
relationId: number,
|
|
219
184
|
bytes: Uint8Array,
|
|
@@ -221,25 +186,14 @@ interface DbBridge {
|
|
|
221
186
|
): OperationHandle
|
|
222
187
|
|
|
223
188
|
/**
|
|
224
|
-
* Read-only migration-codec integration
|
|
225
|
-
* `
|
|
226
|
-
* lanes reached through the P06 executor). `hashChunk`-shaped: bounded
|
|
189
|
+
* Read-only migration-codec integration over native `schema_file` and
|
|
190
|
+
* `migration::{plan, manifest}` through the shared executor: bounded
|
|
227
191
|
* owned input, bounded owned JSON response bytes, one registered
|
|
228
192
|
* cancellable operation. Neither verb opens, initializes, freezes or
|
|
229
193
|
* migrates a database.
|
|
230
194
|
*/
|
|
231
|
-
runtimeMigrationSchema(
|
|
232
|
-
|
|
233
|
-
policy: PolicyWire,
|
|
234
|
-
spec: SchemaSpec,
|
|
235
|
-
callback: () => void
|
|
236
|
-
): OperationHandle
|
|
237
|
-
runtimeMigrationRead(
|
|
238
|
-
runtime: RuntimeHandle,
|
|
239
|
-
policy: PolicyWire,
|
|
240
|
-
request: Uint8Array,
|
|
241
|
-
callback: () => void
|
|
242
|
-
): OperationHandle
|
|
195
|
+
runtimeMigrationSchema(runtime: RuntimeHandle, spec: SchemaSpec, callback: () => void): OperationHandle
|
|
196
|
+
runtimeMigrationRead(runtime: RuntimeHandle, request: Uint8Array, callback: () => void): OperationHandle
|
|
243
197
|
}
|
|
244
198
|
|
|
245
199
|
// The fresh-addon roster test pins this private declaration exactly as it
|