@elaraai/e3-web 0.0.0-stage → 1.0.86
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.md +54 -0
- package/README.md +395 -2
- package/dist/src/app.d.ts +91 -0
- package/dist/src/app.d.ts.map +1 -0
- package/dist/src/app.js +112 -0
- package/dist/src/app.js.map +1 -0
- package/dist/src/bridge/bridge.spec.d.ts +6 -0
- package/dist/src/bridge/bridge.spec.d.ts.map +1 -0
- package/dist/src/bridge/bridge.spec.js +56 -0
- package/dist/src/bridge/bridge.spec.js.map +1 -0
- package/dist/src/bridge/page.d.ts +149 -0
- package/dist/src/bridge/page.d.ts.map +1 -0
- package/dist/src/bridge/page.js +328 -0
- package/dist/src/bridge/page.js.map +1 -0
- package/dist/src/bridge/protocol.d.ts +181 -0
- package/dist/src/bridge/protocol.d.ts.map +1 -0
- package/dist/src/bridge/protocol.js +113 -0
- package/dist/src/bridge/protocol.js.map +1 -0
- package/dist/src/bridge/worker.d.ts +124 -0
- package/dist/src/bridge/worker.d.ts.map +1 -0
- package/dist/src/bridge/worker.js +185 -0
- package/dist/src/bridge/worker.js.map +1 -0
- package/dist/src/browser/bridge.page.d.ts +12 -0
- package/dist/src/browser/bridge.page.d.ts.map +1 -0
- package/dist/src/browser/bridge.page.js +79 -0
- package/dist/src/browser/bridge.page.js.map +1 -0
- package/dist/src/browser/bridge.spec.d.ts +6 -0
- package/dist/src/browser/bridge.spec.d.ts.map +1 -0
- package/dist/src/browser/bridge.spec.js +105 -0
- package/dist/src/browser/bridge.spec.js.map +1 -0
- package/dist/src/browser/bridge.worker.d.ts +6 -0
- package/dist/src/browser/bridge.worker.d.ts.map +1 -0
- package/dist/src/browser/bridge.worker.js +35 -0
- package/dist/src/browser/bridge.worker.js.map +1 -0
- package/dist/src/browser/compliance.d.ts +68 -0
- package/dist/src/browser/compliance.d.ts.map +1 -0
- package/dist/src/browser/compliance.js +30 -0
- package/dist/src/browser/compliance.js.map +1 -0
- package/dist/src/browser/compliance.page.d.ts +6 -0
- package/dist/src/browser/compliance.page.d.ts.map +1 -0
- package/dist/src/browser/compliance.page.js +204 -0
- package/dist/src/browser/compliance.page.js.map +1 -0
- package/dist/src/browser/compliance.spec.d.ts +6 -0
- package/dist/src/browser/compliance.spec.d.ts.map +1 -0
- package/dist/src/browser/compliance.spec.js +147 -0
- package/dist/src/browser/compliance.spec.js.map +1 -0
- package/dist/src/browser/e3-api-1.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-1.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-1.spec.js +12 -0
- package/dist/src/browser/e3-api-1.spec.js.map +1 -0
- package/dist/src/browser/e3-api-2.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-2.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-2.spec.js +12 -0
- package/dist/src/browser/e3-api-2.spec.js.map +1 -0
- package/dist/src/browser/e3-api-3.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-3.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-3.spec.js +12 -0
- package/dist/src/browser/e3-api-3.spec.js.map +1 -0
- package/dist/src/browser/e3-api-parts.spec.d.ts +6 -0
- package/dist/src/browser/e3-api-parts.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-api-parts.spec.js +45 -0
- package/dist/src/browser/e3-api-parts.spec.js.map +1 -0
- package/dist/src/browser/e3-api.d.ts +28 -0
- package/dist/src/browser/e3-api.d.ts.map +1 -0
- package/dist/src/browser/e3-api.js +144 -0
- package/dist/src/browser/e3-api.js.map +1 -0
- package/dist/src/browser/e3-client.worker.d.ts +6 -0
- package/dist/src/browser/e3-client.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-client.worker.js +19 -0
- package/dist/src/browser/e3-client.worker.js.map +1 -0
- package/dist/src/browser/e3-forward.d.ts +27 -0
- package/dist/src/browser/e3-forward.d.ts.map +1 -0
- package/dist/src/browser/e3-forward.js +81 -0
- package/dist/src/browser/e3-forward.js.map +1 -0
- package/dist/src/browser/e3-forward.spec.d.ts +6 -0
- package/dist/src/browser/e3-forward.spec.d.ts.map +1 -0
- package/dist/src/browser/e3-forward.spec.js +84 -0
- package/dist/src/browser/e3-forward.spec.js.map +1 -0
- package/dist/src/browser/e3-port.worker.d.ts +6 -0
- package/dist/src/browser/e3-port.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-port.worker.js +21 -0
- package/dist/src/browser/e3-port.worker.js.map +1 -0
- package/dist/src/browser/e3-unit.worker.d.ts +6 -0
- package/dist/src/browser/e3-unit.worker.d.ts.map +1 -0
- package/dist/src/browser/e3-unit.worker.js +18 -0
- package/dist/src/browser/e3-unit.worker.js.map +1 -0
- package/dist/src/browser/e3-wire.d.ts +43 -0
- package/dist/src/browser/e3-wire.d.ts.map +1 -0
- package/dist/src/browser/e3-wire.js +32 -0
- package/dist/src/browser/e3-wire.js.map +1 -0
- package/dist/src/browser/e3.page.d.ts +21 -0
- package/dist/src/browser/e3.page.d.ts.map +1 -0
- package/dist/src/browser/e3.page.js +119 -0
- package/dist/src/browser/e3.page.js.map +1 -0
- package/dist/src/browser/e3.spec.d.ts +6 -0
- package/dist/src/browser/e3.spec.d.ts.map +1 -0
- package/dist/src/browser/e3.spec.js +358 -0
- package/dist/src/browser/e3.spec.js.map +1 -0
- package/dist/src/browser/e3.worker.d.ts +6 -0
- package/dist/src/browser/e3.worker.d.ts.map +1 -0
- package/dist/src/browser/e3.worker.js +38 -0
- package/dist/src/browser/e3.worker.js.map +1 -0
- package/dist/src/browser/harness.d.ts +175 -0
- package/dist/src/browser/harness.d.ts.map +1 -0
- package/dist/src/browser/harness.js +375 -0
- package/dist/src/browser/harness.js.map +1 -0
- package/dist/src/browser/page.d.ts +47 -0
- package/dist/src/browser/page.d.ts.map +1 -0
- package/dist/src/browser/page.js +47 -0
- package/dist/src/browser/page.js.map +1 -0
- package/dist/src/browser/repository.page.d.ts +85 -0
- package/dist/src/browser/repository.page.d.ts.map +1 -0
- package/dist/src/browser/repository.page.js +271 -0
- package/dist/src/browser/repository.page.js.map +1 -0
- package/dist/src/browser/runner.page.d.ts +6 -0
- package/dist/src/browser/runner.page.d.ts.map +1 -0
- package/dist/src/browser/runner.page.js +62 -0
- package/dist/src/browser/runner.page.js.map +1 -0
- package/dist/src/browser/runner.spec.d.ts +6 -0
- package/dist/src/browser/runner.spec.d.ts.map +1 -0
- package/dist/src/browser/runner.spec.js +46 -0
- package/dist/src/browser/runner.spec.js.map +1 -0
- package/dist/src/browser/storage.page.d.ts +6 -0
- package/dist/src/browser/storage.page.d.ts.map +1 -0
- package/dist/src/browser/storage.page.js +289 -0
- package/dist/src/browser/storage.page.js.map +1 -0
- package/dist/src/browser/storage.spec.d.ts +6 -0
- package/dist/src/browser/storage.spec.d.ts.map +1 -0
- package/dist/src/browser/storage.spec.js +211 -0
- package/dist/src/browser/storage.spec.js.map +1 -0
- package/dist/src/browser/unit.worker.d.ts +6 -0
- package/dist/src/browser/unit.worker.d.ts.map +1 -0
- package/dist/src/browser/unit.worker.js +17 -0
- package/dist/src/browser/unit.worker.js.map +1 -0
- package/dist/src/execution/WebTaskRunner.d.ts +159 -0
- package/dist/src/execution/WebTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/WebTaskRunner.js +581 -0
- package/dist/src/execution/WebTaskRunner.js.map +1 -0
- package/dist/src/execution/WebTaskRunner.spec.d.ts +6 -0
- package/dist/src/execution/WebTaskRunner.spec.d.ts.map +1 -0
- package/dist/src/execution/WebTaskRunner.spec.js +91 -0
- package/dist/src/execution/WebTaskRunner.spec.js.map +1 -0
- package/dist/src/execution/e3-platform.d.ts +41 -0
- package/dist/src/execution/e3-platform.d.ts.map +1 -0
- package/dist/src/execution/e3-platform.js +52 -0
- package/dist/src/execution/e3-platform.js.map +1 -0
- package/dist/src/execution/in-process.d.ts +32 -0
- package/dist/src/execution/in-process.d.ts.map +1 -0
- package/dist/src/execution/in-process.js +89 -0
- package/dist/src/execution/in-process.js.map +1 -0
- package/dist/src/execution/pool.d.ts +172 -0
- package/dist/src/execution/pool.d.ts.map +1 -0
- package/dist/src/execution/pool.js +352 -0
- package/dist/src/execution/pool.js.map +1 -0
- package/dist/src/execution/pool.spec.d.ts +6 -0
- package/dist/src/execution/pool.spec.d.ts.map +1 -0
- package/dist/src/execution/pool.spec.js +252 -0
- package/dist/src/execution/pool.spec.js.map +1 -0
- package/dist/src/execution/protocol.d.ts +108 -0
- package/dist/src/execution/protocol.d.ts.map +1 -0
- package/dist/src/execution/protocol.js +27 -0
- package/dist/src/execution/protocol.js.map +1 -0
- package/dist/src/execution/unit-server.d.ts +131 -0
- package/dist/src/execution/unit-server.d.ts.map +1 -0
- package/dist/src/execution/unit-server.js +142 -0
- package/dist/src/execution/unit-server.js.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.spec.d.ts +6 -0
- package/dist/src/index.spec.d.ts.map +1 -0
- package/dist/src/index.spec.js +212 -0
- package/dist/src/index.spec.js.map +1 -0
- package/dist/src/node.d.ts +12 -0
- package/dist/src/node.d.ts.map +1 -0
- package/dist/src/node.js +12 -0
- package/dist/src/node.js.map +1 -0
- package/dist/src/storage/WebStateStore.d.ts +64 -0
- package/dist/src/storage/WebStateStore.d.ts.map +1 -0
- package/dist/src/storage/WebStateStore.js +237 -0
- package/dist/src/storage/WebStateStore.js.map +1 -0
- package/dist/src/storage/WebStorage.d.ts +225 -0
- package/dist/src/storage/WebStorage.d.ts.map +1 -0
- package/dist/src/storage/WebStorage.js +1462 -0
- package/dist/src/storage/WebStorage.js.map +1 -0
- package/dist/src/storage/adapters.d.ts +610 -0
- package/dist/src/storage/adapters.d.ts.map +1 -0
- package/dist/src/storage/adapters.js +246 -0
- package/dist/src/storage/adapters.js.map +1 -0
- package/dist/src/storage/indexeddb.d.ts +93 -0
- package/dist/src/storage/indexeddb.d.ts.map +1 -0
- package/dist/src/storage/indexeddb.js +384 -0
- package/dist/src/storage/indexeddb.js.map +1 -0
- package/dist/src/storage/indexeddb.spec.d.ts +6 -0
- package/dist/src/storage/indexeddb.spec.d.ts.map +1 -0
- package/dist/src/storage/indexeddb.spec.js +77 -0
- package/dist/src/storage/indexeddb.spec.js.map +1 -0
- package/dist/src/storage/memory.d.ts +275 -0
- package/dist/src/storage/memory.d.ts.map +1 -0
- package/dist/src/storage/memory.js +724 -0
- package/dist/src/storage/memory.js.map +1 -0
- package/dist/src/storage/memory.spec.d.ts +6 -0
- package/dist/src/storage/memory.spec.d.ts.map +1 -0
- package/dist/src/storage/memory.spec.js +71 -0
- package/dist/src/storage/memory.spec.js.map +1 -0
- package/dist/src/storage/node-files.d.ts +38 -0
- package/dist/src/storage/node-files.d.ts.map +1 -0
- package/dist/src/storage/node-files.js +148 -0
- package/dist/src/storage/node-files.js.map +1 -0
- package/dist/src/storage/node-files.spec.d.ts +6 -0
- package/dist/src/storage/node-files.spec.d.ts.map +1 -0
- package/dist/src/storage/node-files.spec.js +40 -0
- package/dist/src/storage/node-files.spec.js.map +1 -0
- package/dist/src/storage/opfs.d.ts +145 -0
- package/dist/src/storage/opfs.d.ts.map +1 -0
- package/dist/src/storage/opfs.js +514 -0
- package/dist/src/storage/opfs.js.map +1 -0
- package/dist/src/storage/opfs.spec.d.ts +6 -0
- package/dist/src/storage/opfs.spec.d.ts.map +1 -0
- package/dist/src/storage/opfs.spec.js +51 -0
- package/dist/src/storage/opfs.spec.js.map +1 -0
- package/dist/src/storage/record-keys.d.ts +78 -0
- package/dist/src/storage/record-keys.d.ts.map +1 -0
- package/dist/src/storage/record-keys.js +71 -0
- package/dist/src/storage/record-keys.js.map +1 -0
- package/dist/src/storage/stores.spec.d.ts +6 -0
- package/dist/src/storage/stores.spec.d.ts.map +1 -0
- package/dist/src/storage/stores.spec.js +326 -0
- package/dist/src/storage/stores.spec.js.map +1 -0
- package/dist/src/storage/web-locks.d.ts +103 -0
- package/dist/src/storage/web-locks.d.ts.map +1 -0
- package/dist/src/storage/web-locks.js +228 -0
- package/dist/src/storage/web-locks.js.map +1 -0
- package/dist/src/testing/adapter-contract.d.ts +116 -0
- package/dist/src/testing/adapter-contract.d.ts.map +1 -0
- package/dist/src/testing/adapter-contract.js +769 -0
- package/dist/src/testing/adapter-contract.js.map +1 -0
- package/dist/src/testing/assert.d.ts +75 -0
- package/dist/src/testing/assert.d.ts.map +1 -0
- package/dist/src/testing/assert.js +146 -0
- package/dist/src/testing/assert.js.map +1 -0
- package/dist/src/testing/assert.spec.d.ts +6 -0
- package/dist/src/testing/assert.spec.d.ts.map +1 -0
- package/dist/src/testing/assert.spec.js +62 -0
- package/dist/src/testing/assert.spec.js.map +1 -0
- package/dist/src/testing/bridge-contract.d.ts +55 -0
- package/dist/src/testing/bridge-contract.d.ts.map +1 -0
- package/dist/src/testing/bridge-contract.js +376 -0
- package/dist/src/testing/bridge-contract.js.map +1 -0
- package/dist/src/testing/bridge-handler.d.ts +35 -0
- package/dist/src/testing/bridge-handler.d.ts.map +1 -0
- package/dist/src/testing/bridge-handler.js +108 -0
- package/dist/src/testing/bridge-handler.js.map +1 -0
- package/dist/src/testing/callers.d.ts +29 -0
- package/dist/src/testing/callers.d.ts.map +1 -0
- package/dist/src/testing/callers.js +24 -0
- package/dist/src/testing/callers.js.map +1 -0
- package/dist/src/testing/e3-fixtures.d.ts +38 -0
- package/dist/src/testing/e3-fixtures.d.ts.map +1 -0
- package/dist/src/testing/e3-fixtures.js +126 -0
- package/dist/src/testing/e3-fixtures.js.map +1 -0
- package/dist/src/testing/hold-platform.d.ts +33 -0
- package/dist/src/testing/hold-platform.d.ts.map +1 -0
- package/dist/src/testing/hold-platform.js +41 -0
- package/dist/src/testing/hold-platform.js.map +1 -0
- package/dist/src/testing/runner-cases.d.ts +112 -0
- package/dist/src/testing/runner-cases.d.ts.map +1 -0
- package/dist/src/testing/runner-cases.js +959 -0
- package/dist/src/testing/runner-cases.js.map +1 -0
- package/dist/src/testing/runner-fixtures.d.ts +13 -0
- package/dist/src/testing/runner-fixtures.d.ts.map +1 -0
- package/dist/src/testing/runner-fixtures.js +173 -0
- package/dist/src/testing/runner-fixtures.js.map +1 -0
- package/dist/src/testing/test-platform.d.ts +73 -0
- package/dist/src/testing/test-platform.d.ts.map +1 -0
- package/dist/src/testing/test-platform.js +143 -0
- package/dist/src/testing/test-platform.js.map +1 -0
- package/dist/src/transfer/WebTransferBackend.d.ts +780 -0
- package/dist/src/transfer/WebTransferBackend.d.ts.map +1 -0
- package/dist/src/transfer/WebTransferBackend.js +1140 -0
- package/dist/src/transfer/WebTransferBackend.js.map +1 -0
- package/dist/src/transfer/WebTransferBackend.spec.d.ts +6 -0
- package/dist/src/transfer/WebTransferBackend.spec.d.ts.map +1 -0
- package/dist/src/transfer/WebTransferBackend.spec.js +582 -0
- package/dist/src/transfer/WebTransferBackend.spec.js.map +1 -0
- package/dist/src/transfer/endpoints.d.ts +46 -0
- package/dist/src/transfer/endpoints.d.ts.map +1 -0
- package/dist/src/transfer/endpoints.js +157 -0
- package/dist/src/transfer/endpoints.js.map +1 -0
- package/dist/src/units.d.ts +51 -0
- package/dist/src/units.d.ts.map +1 -0
- package/dist/src/units.js +74 -0
- package/dist/src/units.js.map +1 -0
- package/dist/src/worker.d.ts +126 -0
- package/dist/src/worker.d.ts.map +1 -0
- package/dist/src/worker.js +186 -0
- package/dist/src/worker.js.map +1 -0
- package/dist/src/worker.spec.d.ts +6 -0
- package/dist/src/worker.spec.d.ts.map +1 -0
- package/dist/src/worker.spec.js +195 -0
- package/dist/src/worker.spec.js.map +1 -0
- package/package.json +76 -3
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The four adapters e3-web keeps a repository over.
|
|
7
|
+
*
|
|
8
|
+
* A browser keeps e3's records in IndexedDB, its objects as files in the
|
|
9
|
+
* origin private file system (OPFS), and its locks with Web Locks, and names
|
|
10
|
+
* files by OPFS paths. Node, and a page that keeps nothing past a reload, keep
|
|
11
|
+
* the same in memory and name the machine's files. Each is an adapter with two
|
|
12
|
+
* or more implementations that answer alike, so e3-web's stores are written
|
|
13
|
+
* once, over these interfaces, and every contract suite runs in Node as it runs
|
|
14
|
+
* in Chromium.
|
|
15
|
+
*
|
|
16
|
+
* - {@link RecordsAdapter}: records, keyed and ordered, written in
|
|
17
|
+
* transactions — the refs, dataset refs, execution records, lock states and
|
|
18
|
+
* gc notes a store keeps, and the compare-and-swap `writeIf` needs;
|
|
19
|
+
* - {@link BlobsAdapter}: blobs, read whole or by range — the objects;
|
|
20
|
+
* - {@link LocksAdapter}: named locks, exclusive and shared, taken by a
|
|
21
|
+
* session that lives as long as its tab, whose liveness another tab asks;
|
|
22
|
+
* - {@link FilesAdapter}: the files `ObjectStore.adoptFile` and
|
|
23
|
+
* `ObjectStore.materialize` name by path.
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* A record's key: its parts, in order.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Keys order part by part, a part by its UTF-16 code units, and a key before
|
|
32
|
+
* every key it is a prefix of, as IndexedDB orders a key that is an array of
|
|
33
|
+
* strings: `['a'] < ['a', ''] < ['a', 'b'] < ['a', 'b', 'c'] < ['ab'] < ['b']`.
|
|
34
|
+
* A key's parts are strings, the empty string among them; a key may have no
|
|
35
|
+
* parts at all.
|
|
36
|
+
*/
|
|
37
|
+
export type RecordKey = readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* A record: its key and its bytes.
|
|
40
|
+
*/
|
|
41
|
+
export interface RecordEntry {
|
|
42
|
+
/** The record's key */
|
|
43
|
+
readonly key: RecordKey;
|
|
44
|
+
/** The record's bytes: the store's own copy, which the caller may change */
|
|
45
|
+
readonly value: Uint8Array;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Which records under a prefix a scan returns, and in what order.
|
|
49
|
+
*/
|
|
50
|
+
export interface RecordScan {
|
|
51
|
+
/** Only the records whose keys sort after this one */
|
|
52
|
+
readonly after?: RecordKey;
|
|
53
|
+
/** Only the records whose keys sort before this one */
|
|
54
|
+
readonly before?: RecordKey;
|
|
55
|
+
/** At most this many: a whole number greater than zero */
|
|
56
|
+
readonly limit?: number;
|
|
57
|
+
/** The last key first, rather than the first */
|
|
58
|
+
readonly reverse?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* What reads records: an adapter, outside a transaction, or a transaction.
|
|
62
|
+
*/
|
|
63
|
+
export interface RecordsRead {
|
|
64
|
+
/**
|
|
65
|
+
* Reads a record.
|
|
66
|
+
*
|
|
67
|
+
* @param key - The record's key
|
|
68
|
+
* @returns Its bytes, or `null` when there is no record of this key
|
|
69
|
+
* @throws {TypeError} When the key is not a list of strings
|
|
70
|
+
*/
|
|
71
|
+
get(key: RecordKey): Promise<Uint8Array | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Reads the records under a prefix, in key order: every record whose key
|
|
74
|
+
* begins with the prefix's parts, the prefix's own among them.
|
|
75
|
+
*
|
|
76
|
+
* @param prefix - The parts every key returned begins with; `[]` for every
|
|
77
|
+
* record
|
|
78
|
+
* @param options - Where the scan starts and ends, how many it returns, and
|
|
79
|
+
* from which end
|
|
80
|
+
* @returns The records, in the order the options ask
|
|
81
|
+
* @throws {TypeError} When a key is not a list of strings
|
|
82
|
+
* @throws {RangeError} When the limit is not a whole number greater than zero
|
|
83
|
+
*/
|
|
84
|
+
scan(prefix: RecordKey, options?: RecordScan): Promise<RecordEntry[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Reads the keys under a prefix, as {@link scan} reads their records.
|
|
87
|
+
*
|
|
88
|
+
* @param prefix - The parts every key returned begins with
|
|
89
|
+
* @param options - Where the scan starts and ends, how many it returns, and
|
|
90
|
+
* from which end
|
|
91
|
+
* @returns The keys, in the order the options ask
|
|
92
|
+
* @throws {TypeError} When a key is not a list of strings
|
|
93
|
+
* @throws {RangeError} When the limit is not a whole number greater than zero
|
|
94
|
+
*/
|
|
95
|
+
keys(prefix: RecordKey, options?: RecordScan): Promise<RecordKey[]>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A transaction's view of the records: what its reads return and its writes
|
|
99
|
+
* change, all applied together or none of them.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* A transaction's reads see its own writes. A write returns at once and
|
|
103
|
+
* applies with the transaction, so a failed write fails the transaction.
|
|
104
|
+
*
|
|
105
|
+
* A transaction lives only as long as its work keeps it busy. Its work awaits
|
|
106
|
+
* its own operations and nothing else — no timer, no fetch, no digest, no
|
|
107
|
+
* other store — because IndexedDB commits a transaction the moment it has
|
|
108
|
+
* nothing to do, and every adapter holds its transactions to that. An
|
|
109
|
+
* operation on a transaction whose work has gone on to anything else, or has
|
|
110
|
+
* finished, fails with {@link RecordsTransactionError}: a read rejects with
|
|
111
|
+
* it, and a write throws it.
|
|
112
|
+
*/
|
|
113
|
+
export interface RecordsTransaction extends RecordsRead {
|
|
114
|
+
/**
|
|
115
|
+
* Writes a record, replacing any of its key.
|
|
116
|
+
*
|
|
117
|
+
* @param key - The record's key
|
|
118
|
+
* @param value - Its bytes, which the store copies
|
|
119
|
+
* @throws {TypeError} When the key is not a list of strings
|
|
120
|
+
* @throws {RecordsTransactionError} When the transaction has ended
|
|
121
|
+
*/
|
|
122
|
+
put(key: RecordKey, value: Uint8Array): void;
|
|
123
|
+
/**
|
|
124
|
+
* Deletes a record, if there is one.
|
|
125
|
+
*
|
|
126
|
+
* @param key - The record's key
|
|
127
|
+
* @throws {TypeError} When the key is not a list of strings
|
|
128
|
+
* @throws {RecordsTransactionError} When the transaction has ended
|
|
129
|
+
*/
|
|
130
|
+
delete(key: RecordKey): void;
|
|
131
|
+
/**
|
|
132
|
+
* Deletes every record under a prefix, the prefix's own among them.
|
|
133
|
+
*
|
|
134
|
+
* @param prefix - The parts every key deleted begins with
|
|
135
|
+
* @throws {TypeError} When the prefix is not a list of strings
|
|
136
|
+
* @throws {RecordsTransactionError} When the transaction has ended
|
|
137
|
+
*/
|
|
138
|
+
deletePrefix(prefix: RecordKey): void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Records, keyed and ordered, written in transactions.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* Transactions over one store — in one tab or several, through one adapter or
|
|
145
|
+
* several — run one after another wherever they touch the same records, so a
|
|
146
|
+
* transaction that reads a record and writes it back loses no other's write:
|
|
147
|
+
* the compare-and-swap a dataset ref's `writeIf` and a repository's status
|
|
148
|
+
* need. A read outside a transaction sees each transaction whole or not at
|
|
149
|
+
* all.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // Compare-and-swap: write the record only if it holds what was read
|
|
154
|
+
* const swapped = await records.transact(async (tx) => {
|
|
155
|
+
* const current = await tx.get(['refs', 'main']);
|
|
156
|
+
* if (!equalBytes(current, expected)) return false;
|
|
157
|
+
* tx.put(['refs', 'main'], next);
|
|
158
|
+
* return true;
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export interface RecordsAdapter extends RecordsRead {
|
|
163
|
+
/**
|
|
164
|
+
* Runs `work` as one transaction: its writes apply together once it
|
|
165
|
+
* resolves, and none of them when it throws.
|
|
166
|
+
*
|
|
167
|
+
* @param work - The transaction's work, which awaits only the
|
|
168
|
+
* transaction's own operations
|
|
169
|
+
* @returns What `work` resolves to
|
|
170
|
+
* @throws What `work` throws, having applied none of its writes
|
|
171
|
+
* @throws {RecordsTransactionError} When `work` awaited anything but the
|
|
172
|
+
* transaction's own operations: a write after that never applies, and
|
|
173
|
+
* one before it may have, as IndexedDB commits what the transaction had
|
|
174
|
+
* written when it found it with nothing to do
|
|
175
|
+
* @throws {AdapterClosedError} When the adapter is closed
|
|
176
|
+
*/
|
|
177
|
+
transact<T>(work: (tx: RecordsTransaction) => Promise<T>): Promise<T>;
|
|
178
|
+
/**
|
|
179
|
+
* Closes the adapter. The records stay in the store for the next adapter
|
|
180
|
+
* over it; this one refuses every call after.
|
|
181
|
+
*/
|
|
182
|
+
close(): Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A records transaction was used past its life: its work awaited something
|
|
186
|
+
* other than the transaction's own operations, or went on using the
|
|
187
|
+
* transaction once it had finished.
|
|
188
|
+
*/
|
|
189
|
+
export declare class RecordsTransactionError extends Error {
|
|
190
|
+
constructor(reason: string);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* A blob's key: its parts, in order, at least one and none empty.
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* Keys order as record keys do ({@link RecordKey}). A key may be a blob and a
|
|
197
|
+
* prefix of other blobs' keys at once: `['a']` and `['a', 'b']` are two blobs.
|
|
198
|
+
* Keys that differ only in case are different keys.
|
|
199
|
+
*/
|
|
200
|
+
export type BlobKey = readonly string[];
|
|
201
|
+
/**
|
|
202
|
+
* What a blob's size and age are.
|
|
203
|
+
*/
|
|
204
|
+
export interface BlobStat {
|
|
205
|
+
/** Its size in bytes */
|
|
206
|
+
readonly size: number;
|
|
207
|
+
/** When it was last written, in milliseconds since the epoch */
|
|
208
|
+
readonly lastModified: number;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A blob a listing found: its key, size and age.
|
|
212
|
+
*/
|
|
213
|
+
export interface BlobInfo extends BlobStat {
|
|
214
|
+
/** The blob's key */
|
|
215
|
+
readonly key: BlobKey;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* The bytes a write stores: all at once, or a chunk at a time.
|
|
219
|
+
*/
|
|
220
|
+
export type ByteSource = Uint8Array | AsyncIterable<Uint8Array>;
|
|
221
|
+
/**
|
|
222
|
+
* What a sweep of abandoned writes did, or in a dry run would do.
|
|
223
|
+
*/
|
|
224
|
+
export interface BlobSweepResult {
|
|
225
|
+
/** What writes that never finished left, removed */
|
|
226
|
+
readonly deleted: number;
|
|
227
|
+
/** What was left because it is younger than the age gate: a write that may
|
|
228
|
+
* still be in flight */
|
|
229
|
+
readonly skippedYoung: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Blobs, read whole or by range, written whole.
|
|
233
|
+
*
|
|
234
|
+
* @remarks
|
|
235
|
+
* A write replaces a blob whole, and a reader sees the blob before the write
|
|
236
|
+
* or after it, never part of one: a new blob is there only once its write
|
|
237
|
+
* has finished, and a write that fails leaves the blob as it was.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* await blobs.write(['objects', hash], chunks);
|
|
242
|
+
* const head = await blobs.readRange(['objects', hash], 0, 16);
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
export interface BlobsAdapter {
|
|
246
|
+
/**
|
|
247
|
+
* Reads a blob whole.
|
|
248
|
+
*
|
|
249
|
+
* @param key - The blob's key
|
|
250
|
+
* @returns Its bytes, or `null` when there is no blob of this key
|
|
251
|
+
* @throws {TypeError} When the key is not a blob key
|
|
252
|
+
*/
|
|
253
|
+
read(key: BlobKey): Promise<Uint8Array | null>;
|
|
254
|
+
/**
|
|
255
|
+
* Reads a range of a blob without reading the rest of it.
|
|
256
|
+
*
|
|
257
|
+
* @param key - The blob's key
|
|
258
|
+
* @param offset - The byte the range starts at
|
|
259
|
+
* @param length - How many bytes it holds
|
|
260
|
+
* @returns The range's bytes, short only where the blob ends, or `null` when
|
|
261
|
+
* there is no blob of this key
|
|
262
|
+
* @throws {TypeError} When the key is not a blob key
|
|
263
|
+
* @throws {RangeError} When the offset or the length is not a whole number
|
|
264
|
+
* of zero or more
|
|
265
|
+
*/
|
|
266
|
+
readRange(key: BlobKey, offset: number, length: number): Promise<Uint8Array | null>;
|
|
267
|
+
/**
|
|
268
|
+
* Reads a blob's size and age.
|
|
269
|
+
*
|
|
270
|
+
* @param key - The blob's key
|
|
271
|
+
* @returns Its size and age, or `null` when there is no blob of this key
|
|
272
|
+
* @throws {TypeError} When the key is not a blob key
|
|
273
|
+
*/
|
|
274
|
+
stat(key: BlobKey): Promise<BlobStat | null>;
|
|
275
|
+
/**
|
|
276
|
+
* Writes a blob, replacing any of its key.
|
|
277
|
+
*
|
|
278
|
+
* @param key - The blob's key
|
|
279
|
+
* @param data - Its bytes, all at once or a chunk at a time; the store
|
|
280
|
+
* keeps its own copy
|
|
281
|
+
* @returns Its size in bytes
|
|
282
|
+
* @throws {TypeError} When the key is not a blob key
|
|
283
|
+
* @throws What the chunks' source throws, leaving the blob as it was
|
|
284
|
+
*/
|
|
285
|
+
write(key: BlobKey, data: ByteSource): Promise<number>;
|
|
286
|
+
/**
|
|
287
|
+
* Deletes a blob.
|
|
288
|
+
*
|
|
289
|
+
* @param key - The blob's key
|
|
290
|
+
* @returns Whether there was a blob of this key
|
|
291
|
+
* @throws {TypeError} When the key is not a blob key
|
|
292
|
+
*/
|
|
293
|
+
delete(key: BlobKey): Promise<boolean>;
|
|
294
|
+
/**
|
|
295
|
+
* Deletes every blob under a prefix, the prefix's own among them.
|
|
296
|
+
*
|
|
297
|
+
* @param prefix - The parts every key deleted begins with; `[]` for every
|
|
298
|
+
* blob
|
|
299
|
+
* @throws {TypeError} When a part is empty
|
|
300
|
+
*/
|
|
301
|
+
deletePrefix(prefix: BlobKey): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Lists the blobs under a prefix, the prefix's own among them, in key
|
|
304
|
+
* order.
|
|
305
|
+
*
|
|
306
|
+
* @param prefix - The parts every key listed begins with; `[]` for every
|
|
307
|
+
* blob
|
|
308
|
+
* @returns Each blob's key, size and age
|
|
309
|
+
* @throws {TypeError} When a part is empty
|
|
310
|
+
*/
|
|
311
|
+
list(prefix: BlobKey): Promise<BlobInfo[]>;
|
|
312
|
+
/**
|
|
313
|
+
* Removes what writes that never finished left behind — a tab closed mid
|
|
314
|
+
* write, say — older than an age gate; a store whose writes leave nothing
|
|
315
|
+
* behind removes nothing.
|
|
316
|
+
*
|
|
317
|
+
* @param options - `minAge`: the age in milliseconds below which a leftover
|
|
318
|
+
* may be a write still in flight, and is left, `0` for none;
|
|
319
|
+
* `dryRun`: count, and remove nothing
|
|
320
|
+
* @returns What it removed, or in a dry run would, and what it left as too
|
|
321
|
+
* young
|
|
322
|
+
*/
|
|
323
|
+
sweep(options: {
|
|
324
|
+
readonly minAge: number;
|
|
325
|
+
readonly dryRun: boolean;
|
|
326
|
+
}): Promise<BlobSweepResult>;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* How a lock is held: `exclusive`, against every other request, or `shared`
|
|
330
|
+
* with other shared holds.
|
|
331
|
+
*/
|
|
332
|
+
export type LockMode = 'exclusive' | 'shared';
|
|
333
|
+
/**
|
|
334
|
+
* How {@link LocksAdapter.acquire} asks for a lock.
|
|
335
|
+
*/
|
|
336
|
+
export interface LockRequest {
|
|
337
|
+
/** Wait for the lock when it cannot be taken at once, rather than refuse */
|
|
338
|
+
readonly wait?: boolean;
|
|
339
|
+
/** When waiting, how long to wait, in milliseconds: unset, until the lock
|
|
340
|
+
* is free. A lock that can be taken at once is taken whatever this is. */
|
|
341
|
+
readonly timeout?: number;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* A lock held.
|
|
345
|
+
*/
|
|
346
|
+
export interface LockHold {
|
|
347
|
+
/** Releases the lock. Safe to call more than once: the first releases it. */
|
|
348
|
+
release(): Promise<void>;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Named locks, taken by a session: in a browser, the tab.
|
|
352
|
+
*
|
|
353
|
+
* @remarks
|
|
354
|
+
* Every adapter answers as Web Locks do. A name is held by any number of
|
|
355
|
+
* shared holds or one exclusive hold. Requests for a name that wait are
|
|
356
|
+
* granted in the order they were made: a request that cannot be granted yet
|
|
357
|
+
* waits behind the ones before it, and a request that does not wait is
|
|
358
|
+
* refused while any other waits, so a waiting exclusive request is never
|
|
359
|
+
* passed over by shared ones.
|
|
360
|
+
*
|
|
361
|
+
* A session lives until it is closed, or its tab is: then every lock it holds
|
|
362
|
+
* is free, and {@link isAlive} answers `false` for it — which is how a tab
|
|
363
|
+
* judges a lock or an execution another tab recorded, as a process judges
|
|
364
|
+
* another's by its pid.
|
|
365
|
+
*/
|
|
366
|
+
export interface LocksAdapter {
|
|
367
|
+
/** The session every lock of this adapter is held by: a holder's `bootId` */
|
|
368
|
+
readonly session: string;
|
|
369
|
+
/**
|
|
370
|
+
* Takes a lock.
|
|
371
|
+
*
|
|
372
|
+
* @param name - The lock's name
|
|
373
|
+
* @param mode - How to hold it
|
|
374
|
+
* @param options - Whether to wait for it, and how long
|
|
375
|
+
* @returns The hold, or `null` when the lock was not taken: at once, or in
|
|
376
|
+
* the time given, or before the session closed
|
|
377
|
+
* @throws {AdapterClosedError} When the session is closed
|
|
378
|
+
* @throws {TypeError} When the mode is neither `exclusive` nor `shared`
|
|
379
|
+
* @throws {RangeError} When the timeout is not a whole number of
|
|
380
|
+
* milliseconds, zero or more
|
|
381
|
+
*/
|
|
382
|
+
acquire(name: string, mode: LockMode, options?: LockRequest): Promise<LockHold | null>;
|
|
383
|
+
/**
|
|
384
|
+
* Reads how a lock is held, by any session.
|
|
385
|
+
*
|
|
386
|
+
* @param name - The lock's name
|
|
387
|
+
* @returns The mode of each hold on it: none when it is free
|
|
388
|
+
* @throws {AdapterClosedError} When the session is closed
|
|
389
|
+
*/
|
|
390
|
+
held(name: string): Promise<LockMode[]>;
|
|
391
|
+
/**
|
|
392
|
+
* Answers whether a session is alive: open, in a tab that is open.
|
|
393
|
+
*
|
|
394
|
+
* @param session - The session, as a holder's `bootId` names it
|
|
395
|
+
* @returns Whether it is alive; `false` for a session no adapter opened
|
|
396
|
+
* @throws {AdapterClosedError} When this session is closed
|
|
397
|
+
*/
|
|
398
|
+
isAlive(session: string): Promise<boolean>;
|
|
399
|
+
/**
|
|
400
|
+
* Closes the session: every lock it holds is released, and every request of
|
|
401
|
+
* it still waiting is refused.
|
|
402
|
+
*/
|
|
403
|
+
close(): Promise<void>;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* How many bytes a files adapter's read yields at a time, unless the adapter
|
|
407
|
+
* is made with another size: 1 MiB.
|
|
408
|
+
*/
|
|
409
|
+
export declare const FILE_READ_CHUNK: number;
|
|
410
|
+
/**
|
|
411
|
+
* How a files adapter reads.
|
|
412
|
+
*/
|
|
413
|
+
export interface FilesOptions {
|
|
414
|
+
/**
|
|
415
|
+
* How many bytes a read yields at a time: every chunk holds this many but
|
|
416
|
+
* the last, which holds what is left. {@link FILE_READ_CHUNK} unless given.
|
|
417
|
+
*/
|
|
418
|
+
readonly readChunk?: number;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* A files adapter's read size, checked: a whole number of bytes greater than
|
|
422
|
+
* zero.
|
|
423
|
+
*
|
|
424
|
+
* @param options - How the adapter reads
|
|
425
|
+
* @returns The size its reads yield at a time
|
|
426
|
+
* @throws {RangeError} When the size given is not a whole number of bytes
|
|
427
|
+
* greater than zero
|
|
428
|
+
*/
|
|
429
|
+
export declare function readChunkOf(options: FilesOptions): number;
|
|
430
|
+
/**
|
|
431
|
+
* What a file's size and age are.
|
|
432
|
+
*/
|
|
433
|
+
export interface FileStat {
|
|
434
|
+
/** Its size in bytes */
|
|
435
|
+
readonly size: number;
|
|
436
|
+
/** When it was last written, in milliseconds since the epoch */
|
|
437
|
+
readonly lastModified: number;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Files named by path: the machine's in Node, OPFS files in a browser.
|
|
441
|
+
*
|
|
442
|
+
* @remarks
|
|
443
|
+
* A path means what its adapter's files mean: a path on the machine for the
|
|
444
|
+
* machine's files, and an absolute path of `/`-separated names for OPFS and
|
|
445
|
+
* memory files. A write replaces a file whole, and a reader sees the file
|
|
446
|
+
* before the write or after it.
|
|
447
|
+
*/
|
|
448
|
+
export interface FilesAdapter {
|
|
449
|
+
/**
|
|
450
|
+
* Reads a file's size and age.
|
|
451
|
+
*
|
|
452
|
+
* @param path - The file's path
|
|
453
|
+
* @returns Its size and age, or `null` when there is no file at the path
|
|
454
|
+
*/
|
|
455
|
+
stat(path: string): Promise<FileStat | null>;
|
|
456
|
+
/**
|
|
457
|
+
* Reads a file a chunk at a time, never whole: in slices of the adapter's
|
|
458
|
+
* read size ({@link FilesOptions.readChunk}), every one but the last that
|
|
459
|
+
* size, however the file system would hand the file over.
|
|
460
|
+
*
|
|
461
|
+
* @param path - The file's path
|
|
462
|
+
* @returns The file's bytes, in order, a chunk at a time
|
|
463
|
+
* @throws {FileNotFoundError} As it is read, when there is no file at the
|
|
464
|
+
* path
|
|
465
|
+
*/
|
|
466
|
+
read(path: string): AsyncIterable<Uint8Array>;
|
|
467
|
+
/**
|
|
468
|
+
* Writes a file, replacing any at the path.
|
|
469
|
+
*
|
|
470
|
+
* @param path - The file's path, in a directory that exists
|
|
471
|
+
* @param data - Its bytes, all at once or a chunk at a time
|
|
472
|
+
* @returns Its size in bytes
|
|
473
|
+
* @throws {FileNotFoundError} When the file's directory does not exist
|
|
474
|
+
* @throws What the chunks' source throws, leaving the file as it was
|
|
475
|
+
*/
|
|
476
|
+
write(path: string, data: ByteSource): Promise<number>;
|
|
477
|
+
/**
|
|
478
|
+
* Removes a file.
|
|
479
|
+
*
|
|
480
|
+
* @param path - The file's path
|
|
481
|
+
* @returns Whether there was a file at the path; a directory there is left
|
|
482
|
+
*/
|
|
483
|
+
remove(path: string): Promise<boolean>;
|
|
484
|
+
/**
|
|
485
|
+
* Makes a directory, and every directory above it that does not exist.
|
|
486
|
+
* Making one that exists does nothing.
|
|
487
|
+
*
|
|
488
|
+
* @param path - The directory's path
|
|
489
|
+
*/
|
|
490
|
+
mkdir(path: string): Promise<void>;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* A file, or the directory a file is written into, is not there.
|
|
494
|
+
*/
|
|
495
|
+
export declare class FileNotFoundError extends Error {
|
|
496
|
+
readonly path: string;
|
|
497
|
+
/**
|
|
498
|
+
* @param path - The path that names nothing
|
|
499
|
+
*/
|
|
500
|
+
constructor(path: string);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* An adapter was used after it was closed.
|
|
504
|
+
*/
|
|
505
|
+
export declare class AdapterClosedError extends Error {
|
|
506
|
+
readonly adapter: string;
|
|
507
|
+
/**
|
|
508
|
+
* @param adapter - What was closed: `records`, `locks`, …
|
|
509
|
+
*/
|
|
510
|
+
constructor(adapter: string);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Compares two keys in the order records and blobs keep: part by part, a part
|
|
514
|
+
* by its UTF-16 code units, and a key before every key it is a prefix of.
|
|
515
|
+
*
|
|
516
|
+
* @param a - A key
|
|
517
|
+
* @param b - Another key
|
|
518
|
+
* @returns Less than zero when `a` sorts first, more when `b` does, and zero
|
|
519
|
+
* when they are the same key
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```ts
|
|
523
|
+
* [['b'], ['a', 'b'], ['a']].sort(compareKeys); // [['a'], ['a', 'b'], ['b']]
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
export declare function compareKeys(a: readonly string[], b: readonly string[]): number;
|
|
527
|
+
/**
|
|
528
|
+
* Answers whether a key is under a prefix: begins with the prefix's parts, or
|
|
529
|
+
* is the prefix.
|
|
530
|
+
*
|
|
531
|
+
* @param key - The key
|
|
532
|
+
* @param prefix - The prefix
|
|
533
|
+
* @returns Whether the key begins with every part of the prefix
|
|
534
|
+
*/
|
|
535
|
+
export declare function isUnder(key: readonly string[], prefix: readonly string[]): boolean;
|
|
536
|
+
/**
|
|
537
|
+
* Checks a record key is a list of strings.
|
|
538
|
+
*
|
|
539
|
+
* @param key - The key
|
|
540
|
+
* @throws {TypeError} When it is not
|
|
541
|
+
*/
|
|
542
|
+
export declare function checkRecordKey(key: RecordKey): void;
|
|
543
|
+
/**
|
|
544
|
+
* Checks a blob key has a part, and that none of its parts is empty.
|
|
545
|
+
*
|
|
546
|
+
* @param key - The key
|
|
547
|
+
* @throws {TypeError} When it has none, or an empty one
|
|
548
|
+
*/
|
|
549
|
+
export declare function checkBlobKey(key: BlobKey): void;
|
|
550
|
+
/**
|
|
551
|
+
* Checks a blob prefix: a list of strings none of which is empty, or `[]`.
|
|
552
|
+
*
|
|
553
|
+
* @param prefix - The prefix
|
|
554
|
+
* @throws {TypeError} When a part is not a string, or is empty
|
|
555
|
+
*/
|
|
556
|
+
export declare function checkBlobPrefix(prefix: BlobKey): void;
|
|
557
|
+
/**
|
|
558
|
+
* Checks what a scan asks: a limit, when there is one, is a whole number
|
|
559
|
+
* greater than zero.
|
|
560
|
+
*
|
|
561
|
+
* @param options - The scan's options
|
|
562
|
+
* @throws {TypeError} When a bound is not a list of strings
|
|
563
|
+
* @throws {RangeError} When the limit is not a whole number greater than zero
|
|
564
|
+
*/
|
|
565
|
+
export declare function checkScan(options: RecordScan): void;
|
|
566
|
+
/**
|
|
567
|
+
* Checks a byte range: its offset and length are whole numbers of zero or
|
|
568
|
+
* more.
|
|
569
|
+
*
|
|
570
|
+
* @param offset - The byte the range starts at
|
|
571
|
+
* @param length - How many bytes it holds
|
|
572
|
+
* @throws {RangeError} When either is not
|
|
573
|
+
*/
|
|
574
|
+
export declare function checkRange(offset: number, length: number): void;
|
|
575
|
+
/**
|
|
576
|
+
* Checks how a lock is asked for: its mode is `exclusive` or `shared`, and a
|
|
577
|
+
* timeout, when there is one, is a whole number of milliseconds, zero or more.
|
|
578
|
+
*
|
|
579
|
+
* @param mode - How the lock is to be held
|
|
580
|
+
* @param options - Whether to wait for it, and how long
|
|
581
|
+
* @throws {TypeError} When the mode is neither
|
|
582
|
+
* @throws {RangeError} When the timeout is not a whole number of zero or more
|
|
583
|
+
*/
|
|
584
|
+
export declare function checkLockRequest(mode: LockMode, options: LockRequest): void;
|
|
585
|
+
/**
|
|
586
|
+
* A copy of bytes that shares no memory with them, and holds only them: what a
|
|
587
|
+
* store keeps, so a caller that changes its bytes after a write, or those a
|
|
588
|
+
* read returned, changes nothing stored.
|
|
589
|
+
*
|
|
590
|
+
* @param bytes - The bytes
|
|
591
|
+
* @returns A copy of exactly those bytes
|
|
592
|
+
*/
|
|
593
|
+
export declare function copyBytes(bytes: Uint8Array): Uint8Array;
|
|
594
|
+
/**
|
|
595
|
+
* What `answer` returns, as a promise that rejects with what it throws: so a
|
|
596
|
+
* method that answers at once fails as every method does, by rejecting.
|
|
597
|
+
*
|
|
598
|
+
* @param answer - What answers
|
|
599
|
+
* @returns Its answer
|
|
600
|
+
*/
|
|
601
|
+
export declare function attempt<T>(answer: () => T): Promise<T>;
|
|
602
|
+
/**
|
|
603
|
+
* The bytes a source yields, a chunk at a time: the one chunk of bytes given
|
|
604
|
+
* whole, or each chunk of a stream.
|
|
605
|
+
*
|
|
606
|
+
* @param data - The source
|
|
607
|
+
* @returns Its chunks, in order
|
|
608
|
+
*/
|
|
609
|
+
export declare function chunksOf(data: ByteSource): AsyncIterable<Uint8Array>;
|
|
610
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../src/storage/adapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,MAAM,EAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uBAAuB;IACvB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EA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