@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 +20 -0
- package/LICENSE-MIT +21 -0
- package/README.md +24 -3
- package/browser/dreamdb.d.ts +185 -2
- package/browser/dreamdb.js +1 -1
- package/browser/dreamdb_bg.js +723 -5
- package/browser/dreamdb_bg.wasm +0 -0
- package/browser/dreamdb_bg.wasm.d.ts +35 -2
- package/browser-extras.mjs +82 -7
- package/browser.mjs +7 -0
- package/index.d.ts +328 -8
- package/node/dreamdb.cjs +858 -9
- package/node/dreamdb.d.cts +250 -6
- package/node/dreamdb_bg.wasm +0 -0
- package/node/dreamdb_bg.wasm.d.ts +42 -3
- package/node.mjs +5 -4
- package/package.json +4 -2
- package/web/dreamdb.d.ts +220 -4
- package/web/dreamdb.js +730 -5
- package/web/dreamdb_bg.wasm +0 -0
- package/web/dreamdb_bg.wasm.d.ts +35 -2
- package/web.mjs +5 -0
package/browser/dreamdb_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_geometryreader_free: (a: number, b: number) => void;
|
|
4
5
|
export const __wbg_s3backend_free: (a: number, b: number) => void;
|
|
5
6
|
export const __wbg_space_free: (a: number, b: number) => void;
|
|
6
7
|
export const __wbg_writer_free: (a: number, b: number) => void;
|
|
@@ -9,38 +10,70 @@ export const addressVariant: (a: number, b: number) => [number, number, number,
|
|
|
9
10
|
export const bytesToBase32: (a: number, b: number) => [number, number];
|
|
10
11
|
export const decodeCbor: (a: number, b: number) => [number, number, number];
|
|
11
12
|
export const encodeCbor: (a: any) => [number, number, number, number];
|
|
13
|
+
export const geometryreader_extendCellPrefix: (a: number, b: any, c: any) => any;
|
|
14
|
+
export const geometryreader_metadata: (a: number) => [number, number, number];
|
|
15
|
+
export const geometryreader_readMeshLod: (a: number, b: any) => any;
|
|
16
|
+
export const geometryreader_selectCells: (a: number, b: any, c: any) => [number, number, number];
|
|
12
17
|
export const modalityParse: (a: number, b: number) => [number, number, number];
|
|
13
18
|
export const multihashBase32: (a: number, b: number) => [number, number];
|
|
14
19
|
export const multihashHex: (a: number, b: number) => [number, number];
|
|
15
20
|
export const rangeHeader: (a: bigint, b: bigint) => [number, number, number, number];
|
|
16
21
|
export const s3backend_get: (a: number, b: number, c: number, d: any) => any;
|
|
22
|
+
export const s3backend_getStream: (a: number, b: number, c: number) => any;
|
|
17
23
|
export const s3backend_list: (a: number, b: number, c: number) => any;
|
|
18
24
|
export const s3backend_new: (a: number, b: number) => number;
|
|
25
|
+
export const space_auditArrayField: (a: number, b: number, c: number) => any;
|
|
26
|
+
export const space_auditGraphIndex: (a: number, b: number, c: number) => any;
|
|
19
27
|
export const space_connectorBase: (a: number) => [number, number];
|
|
28
|
+
export const space_description: (a: number) => any;
|
|
20
29
|
export const space_fromUri: (a: number, b: number, c: any) => any;
|
|
30
|
+
export const space_getEntity: (a: number, b: any) => any;
|
|
21
31
|
export const space_history: (a: number, b: number) => any;
|
|
22
32
|
export const space_manifestHash: (a: number) => [number, number];
|
|
33
|
+
export const space_openGeometryItem: (a: number, b: number, c: number, d: any) => any;
|
|
23
34
|
export const space_queryHybrid: (a: number, b: number, c: number, d: any) => any;
|
|
35
|
+
export const space_queryHybridPlanned: (a: number, b: number, c: number, d: any) => any;
|
|
24
36
|
export const space_queryScalar: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
|
|
25
37
|
export const space_queryText: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
26
38
|
export const space_queryVector: (a: number, b: number, c: number, d: number, e: number, f: any) => any;
|
|
39
|
+
export const space_readArrayColumn: (a: number, b: number, c: number) => any;
|
|
40
|
+
export const space_readArrayConstant: (a: number, b: number, c: number) => any;
|
|
41
|
+
export const space_readArrayItem: (a: number, b: number, c: number, d: any) => any;
|
|
27
42
|
export const space_readScalarColumn: (a: number, b: any, c: any) => any;
|
|
43
|
+
export const space_readVideoItemRange: (a: number, b: number, c: number, d: any, e: any, f: any) => any;
|
|
28
44
|
export const space_resolveObjectIndex: (a: number, b: any) => any;
|
|
45
|
+
export const space_semanticCacheCapacity: (a: number) => any;
|
|
46
|
+
export const space_semanticCacheStats: (a: number) => any;
|
|
47
|
+
export const space_setSemanticCacheCapacity: (a: number, b: number) => any;
|
|
29
48
|
export const space_timelineId: (a: number) => [number, number, number, number];
|
|
30
|
-
export const space_trackFor: (a: number, b: number, c: number) =>
|
|
31
|
-
export const space_tracks: (a: number) =>
|
|
49
|
+
export const space_trackFor: (a: number, b: number, c: number) => [number, number, number];
|
|
50
|
+
export const space_tracks: (a: number) => [number, number, number];
|
|
51
|
+
export const space_videoItemAt: (a: number, b: number, c: number, d: any) => any;
|
|
52
|
+
export const space_videoItemByKey: (a: number, b: number, c: number, d: any) => any;
|
|
32
53
|
export const spatialKeyRoundTrip: (a: number, b: number) => [number, number, number, number];
|
|
33
54
|
export const timeAnchorFromHex: (a: number, b: number) => [bigint, number, number];
|
|
34
55
|
export const timeAnchorHex: (a: bigint) => [number, number];
|
|
35
56
|
export const timeBucket: (a: bigint, b: number, c: number) => [bigint, number, number];
|
|
57
|
+
export const typedArrayDecode: (a: any, b: number, c: number) => [number, number, number];
|
|
36
58
|
export const version: () => [number, number];
|
|
59
|
+
export const writer_appendHot: (a: number, b: any, c: number) => any;
|
|
37
60
|
export const writer_appendMany: (a: number, b: any) => any;
|
|
61
|
+
export const writer_appendManyWithSpecs: (a: number, b: any, c: any) => any;
|
|
38
62
|
export const writer_commit: (a: number) => any;
|
|
63
|
+
export const writer_configureHotShard: (a: number, b: number, c: number) => [number, number];
|
|
64
|
+
export const writer_createEntity: (a: number, b: any, c: any, d: number) => any;
|
|
65
|
+
export const writer_deleteEntity: (a: number, b: any, c: any) => any;
|
|
39
66
|
export const writer_deleteRecords: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
67
|
+
export const writer_enableEntityKeys: (a: number, b: number, c: number) => any;
|
|
68
|
+
export const writer_flushHot: (a: number) => any;
|
|
40
69
|
export const writer_manifestHash: (a: number) => [number, number, number, number];
|
|
41
70
|
export const writer_open: (a: number, b: number, c: any) => any;
|
|
71
|
+
export const writer_publishGeometryCells: (a: number, b: number, c: number, d: any, e: any, f: any, g: any) => any;
|
|
72
|
+
export const writer_publishGeometryMesh: (a: number, b: number, c: number, d: any, e: any, f: any) => any;
|
|
42
73
|
export const writer_refName: (a: number) => [number, number];
|
|
43
74
|
export const writer_snapshot: (a: number, b: number, c: number) => any;
|
|
75
|
+
export const writer_supersedeEntity: (a: number, b: any, c: any, d: any, e: number) => any;
|
|
76
|
+
export const writer_upsertEntity: (a: number, b: any, c: any, d: number, e: number) => any;
|
|
44
77
|
export const zeroSpatialKey: () => [number, number];
|
|
45
78
|
export const __wasm_init: () => void;
|
|
46
79
|
export const wasm_bindgen_f7c54996eb9137d9___convert__closures_____invoke___wasm_bindgen_f7c54996eb9137d9___JsValue__core_7d5f0a2ba6a62c33___result__Result_____wasm_bindgen_f7c54996eb9137d9___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
package/browser-extras.mjs
CHANGED
|
@@ -37,6 +37,42 @@ class AuthoringUnavailable {
|
|
|
37
37
|
|
|
38
38
|
export { AuthoringUnavailable as Authoring }
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* `Writer.ingestCmaf` is Node-only, for the same reason `Authoring` is: it is
|
|
42
|
+
* gated behind the `write-full` feature, and the browser build is compiled
|
|
43
|
+
* with `write`.
|
|
44
|
+
*
|
|
45
|
+
* The shared declarations describe it on both ends (see build.sh, "types"), so
|
|
46
|
+
* a browser caller type-checks and would otherwise reach
|
|
47
|
+
* `writer.ingestCmaf is not a function` at runtime — a message that names
|
|
48
|
+
* neither the cause nor the fix. This replaces it with one that does.
|
|
49
|
+
*
|
|
50
|
+
* Applied to the prototype rather than declared as a method because `Writer`
|
|
51
|
+
* comes from the wasm module; there is no class here to extend.
|
|
52
|
+
*/
|
|
53
|
+
function installIngestCmafStub(Writer) {
|
|
54
|
+
if (!Writer || typeof Writer !== 'function') return Writer
|
|
55
|
+
if (typeof Writer.prototype.ingestCmaf === 'function') return Writer // full build
|
|
56
|
+
Object.defineProperty(Writer.prototype, 'ingestCmaf', {
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: async function ingestCmaf() {
|
|
60
|
+
throw new Error(
|
|
61
|
+
'Writer.ingestCmaf is not available in the browser build of ' +
|
|
62
|
+
'@dreamlake/dreamdb. CMAF ingest takes the whole clip as one ' +
|
|
63
|
+
'argument, so peak memory is the entire source — and fragmenting a ' +
|
|
64
|
+
'multi-GB file inside a tab\'s 32-bit address space is not a ' +
|
|
65
|
+
'workflow this package pretends to support. Run it under Node (the ' +
|
|
66
|
+
'"node" export condition resolves to the full build), or fragment ' +
|
|
67
|
+
'ahead of time and append the fragments.',
|
|
68
|
+
)
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
return Writer
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { installIngestCmafStub }
|
|
75
|
+
|
|
40
76
|
/**
|
|
41
77
|
* A Backend (contract v2) that gets bytes over plain `fetch` and writes through
|
|
42
78
|
* short-lived presigned URLs minted by *your* server.
|
|
@@ -86,7 +122,7 @@ export class PresignedBackend {
|
|
|
86
122
|
* @param {object} o
|
|
87
123
|
* @param {string} o.readBase Base URL for reads.
|
|
88
124
|
* @param {(paths: string[], opts?: {ifMatch?: string}) => Promise<Record<string, {url: string, headers?: Record<string,string>}>>} o.mintPut
|
|
89
|
-
* @param {(path: string, opts: {ifMatch?: string, ifNoneMatchStar?: boolean}, bytes: Uint8Array) => Promise<{status
|
|
125
|
+
* @param {(path: string, opts: {ifMatch?: string, ifNoneMatchStar?: boolean}, bytes: Uint8Array) => Promise<{outcome?: string, status?: string, etag?: string}>} [o.commitRef]
|
|
90
126
|
* Server-side ref commit. Used when `refStrategy` is `'proxy'`.
|
|
91
127
|
* @param {'proxy'|'presign'} [o.refStrategy='proxy']
|
|
92
128
|
* How the 33-byte ref object is written. `'proxy'` posts it to your
|
|
@@ -119,15 +155,27 @@ export class PresignedBackend {
|
|
|
119
155
|
return this._readUrl ? this._readUrl(path) : `${this.readBase}/${path}`
|
|
120
156
|
}
|
|
121
157
|
|
|
122
|
-
/** v2 get: returns `{bytes, etag}`. Range is
|
|
158
|
+
/** v2 get: returns `{bytes, etag, totalLength}`. Range is half-open `[start, end)`. */
|
|
123
159
|
async get(path, range) {
|
|
124
160
|
const headers = {}
|
|
125
|
-
if (range)
|
|
161
|
+
if (range) {
|
|
162
|
+
if (!Number.isSafeInteger(range.start) || !Number.isSafeInteger(range.end) ||
|
|
163
|
+
range.start < 0 || range.end <= range.start) {
|
|
164
|
+
throw new Error(`GET ${path}: invalid half-open range [${range.start}, ${range.end})`)
|
|
165
|
+
}
|
|
166
|
+
// HTTP uses an inclusive end; the Backend contract uses an exclusive one.
|
|
167
|
+
headers.range = `bytes=${range.start}-${range.end - 1}`
|
|
168
|
+
}
|
|
126
169
|
const r = await fetch(this.#url(path), { headers })
|
|
127
170
|
if (!r.ok) throw new Error(`GET ${path}: ${r.status} ${r.statusText}`)
|
|
171
|
+
const contentRange = r.headers.get('content-range')
|
|
172
|
+
const rangeTotal = contentRange && /^bytes \d+-\d+\/(\d+)$/.exec(contentRange)?.[1]
|
|
173
|
+
const lengthText = range ? rangeTotal : r.headers.get('content-length')
|
|
174
|
+
const totalLength = lengthText == null ? undefined : Number(lengthText)
|
|
128
175
|
return {
|
|
129
176
|
bytes: new Uint8Array(await r.arrayBuffer()),
|
|
130
177
|
etag: normalizeEtag(r.headers.get('etag')),
|
|
178
|
+
totalLength: Number.isSafeInteger(totalLength) && totalLength >= 0 ? totalLength : undefined,
|
|
131
179
|
}
|
|
132
180
|
}
|
|
133
181
|
|
|
@@ -148,7 +196,12 @@ export class PresignedBackend {
|
|
|
148
196
|
// semantics differ per provider — so they get their own path.
|
|
149
197
|
const isRef = path.startsWith('refs/')
|
|
150
198
|
if (isRef && this.refStrategy === 'proxy') {
|
|
151
|
-
|
|
199
|
+
// `commitRef` is the CALLER's callback and its documented contract is the
|
|
200
|
+
// `{status}` string form, so it is normalised here rather than being
|
|
201
|
+
// broken. This is the ref path — the one where mistaking a refused CAS
|
|
202
|
+
// for a successful one loses a write — so it does not rely on the
|
|
203
|
+
// adapter's compatibility handling.
|
|
204
|
+
return normalizePutResult(await this.commitRef(path, opts, bytes), path)
|
|
152
205
|
}
|
|
153
206
|
|
|
154
207
|
const minted = await this.mintPut([path], opts.ifMatch ? { ifMatch: opts.ifMatch } : undefined)
|
|
@@ -167,11 +220,11 @@ export class PresignedBackend {
|
|
|
167
220
|
// someone else moved it, which is a conflict the caller must resolve.
|
|
168
221
|
if (r.status === 412 || r.status === 409) {
|
|
169
222
|
return opts.ifNoneMatchStar
|
|
170
|
-
? {
|
|
171
|
-
: {
|
|
223
|
+
? { outcome: 'alreadyExists' }
|
|
224
|
+
: { outcome: 'casFailed', etag: normalizeEtag(r.headers.get('etag')) }
|
|
172
225
|
}
|
|
173
226
|
if (!r.ok) throw new Error(`PUT ${path}: ${r.status} ${r.statusText}`)
|
|
174
|
-
return {
|
|
227
|
+
return { outcome: 'created', etag: normalizeEtag(r.headers.get('etag')) }
|
|
175
228
|
}
|
|
176
229
|
|
|
177
230
|
// No `delete`. It would need a signed DELETE URL, and the sign endpoint only
|
|
@@ -181,6 +234,28 @@ export class PresignedBackend {
|
|
|
181
234
|
// dropping a ref is an `Authoring` operation, which is Node-only.
|
|
182
235
|
}
|
|
183
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Normalise a caller-supplied put result into the tagged form.
|
|
239
|
+
*
|
|
240
|
+
* Accepts the documented `{status: 'created'|'exists'|'casFailed'}` and the
|
|
241
|
+
* tagged `{outcome}`; anything else is refused by name rather than silently
|
|
242
|
+
* treated as success, because the one thing a ref write must never do is report
|
|
243
|
+
* a refused CAS as a completed one.
|
|
244
|
+
*/
|
|
245
|
+
function normalizePutResult(r, path) {
|
|
246
|
+
if (r && typeof r.outcome === 'string') return r
|
|
247
|
+
const s = r && r.status
|
|
248
|
+
if (s === 'created') return { outcome: 'created', etag: r.etag }
|
|
249
|
+
if (s === 'exists' || s === 'alreadyExists') return { outcome: 'alreadyExists', etag: r.etag }
|
|
250
|
+
if (s === 'casFailed') return { outcome: 'casFailed', etag: r.etag }
|
|
251
|
+
if (s === 'notFound') return { outcome: 'notFound' }
|
|
252
|
+
if (typeof s === 'number') return r
|
|
253
|
+
throw new Error(
|
|
254
|
+
`commitRef(${path}) resolved an unrecognised result; expected ` +
|
|
255
|
+
`{outcome} or {status: 'created'|'exists'|'casFailed'}, got ${JSON.stringify(r)}`,
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
184
259
|
/**
|
|
185
260
|
* S3 quotes ETags and sometimes suffixes them (`W/"…"`, `"…-3"` for multipart).
|
|
186
261
|
* The conditional-write comparison is byte-exact, so a stray quote turns every
|
package/browser.mjs
CHANGED
|
@@ -2,3 +2,10 @@
|
|
|
2
2
|
// module and instantiated by the bundler; there is nothing to await.
|
|
3
3
|
export * from './browser/dreamdb.js'
|
|
4
4
|
export { ZERO_SPATIAL_KEY, PresignedBackend, Authoring } from './browser-extras.mjs'
|
|
5
|
+
|
|
6
|
+
// `ingestCmaf` is behind `write-full`, so it is absent here while the shared
|
|
7
|
+
// declarations describe it. Replace the bare `is not a function` with a
|
|
8
|
+
// message that names the reason and the fix.
|
|
9
|
+
import { Writer as _W } from './browser/dreamdb.js'
|
|
10
|
+
import { installIngestCmafStub as _stub } from './browser-extras.mjs'
|
|
11
|
+
_stub(_W)
|