@dreamlake/dreamdb 0.5.1 → 0.5.3

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/LICENSE-APACHE ADDED
@@ -0,0 +1,20 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright (c) 2026 DreamLake AI
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ The full text of the Apache License, Version 2.0 is available at the URL
20
+ above and is incorporated here by reference.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DreamLake AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @dreamlake/dreamdb
2
2
 
3
+ Documentation scope: the public npm release is 0.5.2 as checked on 2026-09-10.
4
+ New APIs merged on main (entity keys, progressive geometry and structured arrays)
5
+ require a source build until a corresponding package is published. See the
6
+ [main/unreleased guide](https://dreamdb.dreamlake.ai/main-features) separately
7
+ from the [released SDK reference](https://dreamdb.dreamlake.ai/typescript-sdk-api).
8
+
3
9
  The DreamDB SDK — read and write, in the browser and on the server, compiled to
4
10
  WebAssembly from the same Rust core the CLI and Python SDK use.
5
11
 
@@ -114,13 +120,21 @@ trained index as a layer, or build it with the CLI.
114
120
  ## Implementing a Backend
115
121
 
116
122
  Only `get` is required; a `get`-only backend is the read-only v1 shape and
117
- still works for reading. Write entry points check for `put` up front and refuse
118
- with a message naming what is missing.
123
+ still works for reading. Implement `getStream` to keep full-object reads bounded
124
+ when DreamDB must scan a historical oversized inline Track. Write entry points
125
+ check for `put` up front and refuse with a message naming what is missing.
119
126
 
120
127
  ```ts
121
128
  interface Backend {
129
+ // `range` is half-open: start is included, end is excluded.
122
130
  get(path: string, range?: { start: number; end: number })
123
- : Promise<Uint8Array | { bytes: Uint8Array; etag?: string }>
131
+ : Promise<Uint8Array | { bytes: Uint8Array; etag?: string; totalLength?: number }>
132
+ getStream?(path: string)
133
+ : Promise<ReadableStream<Uint8Array> | {
134
+ stream: ReadableStream<Uint8Array>
135
+ etag?: string
136
+ totalLength?: number
137
+ }>
124
138
  head?(path: string): Promise<{ exists?: boolean; etag?: string; size?: number }>
125
139
  put?(path: string, bytes: Uint8Array,
126
140
  opts?: { ifMatch?: string; ifNoneMatchStar?: boolean })
@@ -130,6 +144,13 @@ interface Backend {
130
144
  }
131
145
  ```
132
146
 
147
+ `getStream` chunks must themselves be bounded; returning one object-sized
148
+ `Uint8Array` is functionally valid but does not provide the bounded-memory
149
+ profile. The SDK hashes every chunk and exposes no decoded result until the
150
+ complete response matches its content address. Existing backends without
151
+ `getStream` continue through `get` and are intentionally classified as the
152
+ unbounded compatibility profile.
153
+
133
154
  ### Two things that will bite you
134
155
 
135
156
  **Your bucket's CORS rule must include `ExposeHeaders: ["ETag"]`.**
@@ -1,6 +1,22 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ export class GeometryReader {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ /**
9
+ * Returns only the new suffix at this total logical byte budget.
10
+ */
11
+ extendCellPrefix(key: any, budget: any): Promise<Uint8Array>;
12
+ /**
13
+ * Declaration plus cells/LODs; no payload transfer. u64 values are BigInt.
14
+ */
15
+ metadata(): any;
16
+ readMeshLod(level: any): Promise<Uint8Array>;
17
+ selectCells(min: any, max: any): Array<any>;
18
+ }
19
+
4
20
  /**
5
21
  * A `fetch`-backed backend rooted at a base URL.
6
22
  */
@@ -13,6 +29,15 @@ export class S3Backend {
13
29
  * content is hash-addressed; refs are read fresh each page load anyway).
14
30
  */
15
31
  get(path: string, _opts: any): Promise<Uint8Array>;
32
+ /**
33
+ * Stream `path` without first aggregating the response in wasm memory.
34
+ *
35
+ * Returning the length beside the browser stream satisfies the optional
36
+ * `Backend.getStream` contract. Older injected backends that implement
37
+ * only [`Self::get`] remain compatible, but cannot claim bounded memory
38
+ * for historical oversized inline Track reads.
39
+ */
40
+ getStream(path: string): Promise<any>;
16
41
  /**
17
42
  * List object paths under `prefix`. Stub (returns empty); the current
18
43
  * consumer read paths don't require listing.
@@ -28,6 +53,41 @@ export class Space {
28
53
  private constructor();
29
54
  free(): void;
30
55
  [Symbol.dispose](): void;
56
+ /**
57
+ * Validate all referenced Items, including tombstoned payloads.
58
+ */
59
+ auditArrayField(field: string): Promise<bigint>;
60
+ /**
61
+ * Validate all graph pages and, when declared, exact-source correspondence.
62
+ * The returned count is exactly representable (GraphIndex node_count is u32).
63
+ */
64
+ auditGraphIndex(field: string): Promise<number>;
65
+ /**
66
+ * The Space's human-readable description, or `undefined` when none is set.
67
+ *
68
+ * The read half of `Authoring.setDescription` (#129). It lives here rather
69
+ * than on `Authoring` because that type is `write-full` and so exists only
70
+ * in the Node build — a description is metadata a READER wants, and
71
+ * `Space` is the surface all three build targets share.
72
+ *
73
+ * `async` although `Dataset::description` is not: the value comes from the
74
+ * Dataset this Space opens lazily at the Manifest hash already pinned by
75
+ * this Space, so the first call may perform that open without re-resolving
76
+ * a source Ref.
77
+ *
78
+ * Deliberately routed through `Dataset::description` rather than read out
79
+ * of `self.manifest`'s registry, which would be shorter and would also
80
+ * serve the cached decoded Manifest. `Dataset::recover_meta` is not a prefix
81
+ * filter: it accepts the legacy `vortex.*` namespace as well as
82
+ * `dreamdb.*`, canonicalises, and drops structural keys. Matching
83
+ * `dreamdb.description` here would silently return nothing for a legacy
84
+ * Space whose description is on disk and readable from Rust — the exact
85
+ * defect `recover_meta`'s own comment records.
86
+ *
87
+ * `Option<String>` marshals to `string | undefined`, NOT to `""`. An unset
88
+ * description and an empty one stay distinguishable across the boundary.
89
+ */
90
+ description(): Promise<string | undefined>;
31
91
  /**
32
92
  * Open a Space from a `.../refs/<name>` or `.../manifests/<hash>` URI,
33
93
  * resolving the ref (if any) and loading the manifest. If `backend` is
@@ -36,11 +96,21 @@ export class Space {
36
96
  * no-backend path).
37
97
  */
38
98
  static fromUri(uri: string, backend: any): Promise<Space>;
99
+ /**
100
+ * Read at this pinned Manifest. Returns null for never-created keys;
101
+ * deleted keys retain metadata with sample=null. Integer keys and anchors
102
+ * are BigInt; sample values use the Writer's tagged field shapes.
103
+ */
104
+ getEntity(key: any): Promise<any>;
39
105
  /**
40
106
  * Walk the manifest DAG from HEAD, up to `max_depth` entries. Each entry:
41
107
  * `{ manifestHash, ts, writer, tracks: [{modality, address}] }`.
42
108
  */
43
109
  history(max_depth?: number | null): Promise<Array<any>>;
110
+ /**
111
+ * Open one pinned geometry Item. Missing/deleted anchors return undefined.
112
+ */
113
+ openGeometryItem(field: string, anchor: any): Promise<GeometryReader | undefined>;
44
114
  /**
45
115
  * Hybrid search fusing a lexical (BM25) sub-query and a dense (vector)
46
116
  * sub-query per spec/0015 §5/§6. Returns the fused `[{ anchor, score }]`
@@ -63,10 +133,17 @@ export class Space {
63
133
  * ```
64
134
  *
65
135
  * Delegates to the real (tested) `dreamdb-dataset::Dataset::query_hybrid`.
66
- * (v0 does not expose the optional scalar pre/post-filter; it runs with no
67
- * scalar gate.)
136
+ * Optional `scalarField` / `scalarOp` / `scalarValue` properties select
137
+ * the same scalar pre/post-filter planner used by the native API.
68
138
  */
69
139
  queryHybrid(vector: Float32Array, opts: any): Promise<Array<any>>;
140
+ /**
141
+ * Hybrid query with an observable `{hits, trace}` result. `opts` accepts
142
+ * `maxLatencyMs`, `costModel`, and the optional scalar triple
143
+ * `scalarField`/`scalarOp`/`scalarValue` in addition to `queryHybrid`'s
144
+ * existing properties.
145
+ */
146
+ queryHybridPlanned(vector: Float32Array, opts: any): Promise<any>;
70
147
  /**
71
148
  * Scalar-index lookup: every anchor whose `field` satisfies `op value`
72
149
  * (spec/0011). Returns a `BigUint64Array`-style `Array` of anchors,
@@ -107,18 +184,60 @@ export class Space {
107
184
  * two-pass rerank + HotShard merge + tombstone suppression.
108
185
  */
109
186
  queryVector(field: string, query: Float32Array, opts: any): Promise<Array<any>>;
187
+ /**
188
+ * Read an Event/Unbucketed or Continuous/TimeBatch typed-array field as
189
+ * `Map<anchorString, {values, shape, ...}>`.
190
+ */
191
+ readArrayColumn(field: string): Promise<Map<any, any>>;
192
+ /**
193
+ * Read a typed-array Constant and decode it to a JS TypedArray plus its
194
+ * authoritative shape and semantic metadata.
195
+ */
196
+ readArrayConstant(field: string): Promise<any>;
197
+ /**
198
+ * Point read; full-u64 BigInt anchors are supported. Returned components
199
+ * are owned typed arrays (one Item's bytes), never unaligned aliases.
200
+ */
201
+ readArrayItem(field: string, anchor: any): Promise<any>;
110
202
  /**
111
203
  * Read a scalar track as a `Map<anchorString, value>`. Single-anchor
112
204
  * entries resolve from the track index; multi-anchor entries fetch (and
113
205
  * de-dupe) their bucket and roaring-decode the anchor set.
114
206
  */
115
207
  readScalarColumn(track: any, _opts: any): Promise<Map<any, any>>;
208
+ /**
209
+ * Fetch verified initialization and complete Fragments overlapping one
210
+ * item-relative half-open range. This materializes the selected bytes; it
211
+ * is not a streaming API.
212
+ */
213
+ readVideoItemRange(field: string, item_key: Uint8Array, relative_start_ns: any, relative_end_ns: any): Promise<any>;
116
214
  /**
117
215
  * Fetch a track object and return its `object_index` (array of CBOR
118
216
  * entries). Inline indexes only — paged indexes are not resolved (matching
119
217
  * dreamdb-ts, which also doesn't support them on this path).
120
218
  */
121
219
  resolveObjectIndex(track: any): Promise<Array<any>>;
220
+ /**
221
+ * Semantic-cache capacity in bytes (spec/0006 §3.6). Default 1 GiB.
222
+ */
223
+ semanticCacheCapacity(): Promise<number>;
224
+ /**
225
+ * Semantic-cache occupancy as `{ entries, bytesUsed, maxBytes }`.
226
+ */
227
+ semanticCacheStats(): Promise<object>;
228
+ /**
229
+ * Set the semantic-cache capacity in bytes, evicting down to it before
230
+ * returning. Returns the bytes evicted. `0` disables the cache.
231
+ *
232
+ * An index whose accounted size exceeds the cap is not cached and is
233
+ * re-fetched on every query, reported honestly as a miss. The default is
234
+ * not raised globally to suit one corpus.
235
+ *
236
+ * Sizing is workload- and architecture-dependent, and figures measured on
237
+ * a 64-bit host do NOT carry over here: `usize` is 32 bits on `wasm32`, so
238
+ * every offset and length inside a decoded index accounts differently.
239
+ */
240
+ setSemanticCacheCapacity(n_bytes: number): Promise<number>;
122
241
  /**
123
242
  * Base32 hash of the manifest's first timeline.
124
243
  */
@@ -131,6 +250,16 @@ export class Space {
131
250
  * List resolved tracks from this manifest.
132
251
  */
133
252
  tracks(): Array<any>;
253
+ /**
254
+ * Look up the logical VideoItem containing one absolute Timeline anchor
255
+ * without fetching media. Exact nanosecond values are returned as bigint.
256
+ */
257
+ videoItemAt(field: string, anchor_ns: any): Promise<any>;
258
+ /**
259
+ * Look up one logical VideoItem by its stable opaque key without fetching
260
+ * initialization or Fragment bytes.
261
+ */
262
+ videoItemByKey(field: string, item_key: Uint8Array): Promise<any>;
134
263
  /**
135
264
  * The base URL objects are fetched relative to (consumers build their own
136
265
  * object URLs from this — e.g. `dreamdb-demo`'s track readers).
@@ -149,6 +278,11 @@ export class Writer {
149
278
  private constructor();
150
279
  free(): void;
151
280
  [Symbol.dispose](): void;
281
+ /**
282
+ * Atomically hot-append a complete Sample batch. Embeddings retain v1;
283
+ * scalar/text values use v2. Identified embeddings require embeddingSpecs.
284
+ */
285
+ appendHot(samples: Array<any>, embedding_specs?: object | null): Promise<number>;
152
286
  /**
153
287
  * Append records and commit in one call.
154
288
  *
@@ -162,6 +296,11 @@ export class Writer {
162
296
  * lifetime is under the caller's control.
163
297
  */
164
298
  appendMany(samples: Array<any>): Promise<number>;
299
+ /**
300
+ * Append records with a field-to-`spec_id` map for identified embeddings.
301
+ * Values are full canonical base32 multihashes.
302
+ */
303
+ appendManyWithSpecs(samples: Array<any>, embedding_specs: object): Promise<number>;
165
304
  /**
166
305
  * Flush staged entries and publish a new manifest.
167
306
  *
@@ -171,10 +310,30 @@ export class Writer {
171
310
  * its records on top of the new head is correct.
172
311
  */
173
312
  commit(): Promise<string>;
313
+ /**
314
+ * Producer policy only: TTL is evaluated on append, not by a timer.
315
+ */
316
+ configureHotShard(flush_threshold: number, ttl_seconds: number): void;
317
+ /**
318
+ * Create a never-used key. Sample uses appendMany's tagged fields, no anchor.
319
+ */
320
+ createEntity(key: any, sample: object, embedding_specs?: object | null): Promise<object>;
321
+ /**
322
+ * Delete exactly a live revision, retaining its key and stable identity.
323
+ */
324
+ deleteEntity(key: any, expected: Uint8Array): Promise<object>;
174
325
  /**
175
326
  * Tombstone records by anchor. Returns the new manifest hash.
176
327
  */
177
328
  deleteRecords(anchors: BigUint64Array, reason?: string | null): Promise<string>;
329
+ /**
330
+ * Enable one exact typed entity namespace: string, bytes or int.
331
+ */
332
+ enableEntityKeys(key_kind: string): Promise<void>;
333
+ /**
334
+ * Explicitly fold every pending hot field into cold Tracks in one publish.
335
+ */
336
+ flushHot(): Promise<void>;
178
337
  /**
179
338
  * Open a ref for writing.
180
339
  *
@@ -189,10 +348,27 @@ export class Writer {
189
348
  * until it calls it.
190
349
  */
191
350
  static open(uri: string, backend: any): Promise<Writer>;
351
+ /**
352
+ * Publish prequantized fixed-stride records. Coordinates is
353
+ * {origin:[x,y,z],step:[x,y,z],units:string}; depth is 0..16.
354
+ */
355
+ publishGeometryCells(field: string, anchor: any, coordinates: any, depth: any, records: Uint8Array): Promise<string>;
356
+ /**
357
+ * Each level is {errorGrid,vertices,triangles,bytes:Uint8Array}.
358
+ */
359
+ publishGeometryMesh(field: string, anchor: any, coordinates: any, levels: Array<any>): Promise<string>;
192
360
  /**
193
361
  * Tag the current manifest with an immutable label (`refs/<ref>@<label>`).
194
362
  */
195
363
  snapshot(label: string): Promise<string>;
364
+ /**
365
+ * Replace only a live revision, atomically hiding its old physical row.
366
+ */
367
+ supersedeEntity(key: any, sample: object, expected: Uint8Array, embedding_specs?: object | null): Promise<object>;
368
+ /**
369
+ * Create with no expected token, or replace/restore exactly that revision.
370
+ */
371
+ upsertEntity(key: any, sample: object, expected?: Uint8Array | null, embedding_specs?: object | null): Promise<object>;
196
372
  /**
197
373
  * Current manifest hash, base32.
198
374
  */
@@ -314,6 +490,13 @@ export function timeAnchorHex(value: bigint): string;
314
490
  */
315
491
  export function timeBucket(t_start: bigint, duration: string): bigint;
316
492
 
493
+ /**
494
+ * Decode one spec/0025 item using the same declaration and payload path as
495
+ * `Space.readArrayColumn`, without requiring storage IO. This is the SDK's
496
+ * pure conformance entry point for language-neutral vectors.
497
+ */
498
+ export function typedArrayDecode(item_type: any, payload: Uint8Array): any;
499
+
317
500
  /**
318
501
  * Package version — useful for consumers to confirm which build is loaded.
319
502
  */
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./dreamdb_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- S3Backend, Space, Writer, __wasm_init, addressRoundTrip, addressVariant, bytesToBase32, decodeCbor, encodeCbor, modalityParse, multihashBase32, multihashHex, rangeHeader, spatialKeyRoundTrip, timeAnchorFromHex, timeAnchorHex, timeBucket, version, zeroSpatialKey
8
+ GeometryReader, S3Backend, Space, Writer, __wasm_init, addressRoundTrip, addressVariant, bytesToBase32, decodeCbor, encodeCbor, modalityParse, multihashBase32, multihashHex, rangeHeader, spatialKeyRoundTrip, timeAnchorFromHex, timeAnchorHex, timeBucket, typedArrayDecode, version, zeroSpatialKey
9
9
  } from "./dreamdb_bg.js";