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