@fireproof/core 0.20.0-dev-preview-63 → 0.20.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/deno/index.d.ts +7 -0
- package/deno/index.js +66 -0
- package/deno/index.js.map +1 -0
- package/deno/metafile-esm.json +1 -0
- package/deno.json +2 -2
- package/index.cjs +7268 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +2742 -0
- package/index.d.ts +2742 -15
- package/index.js +7267 -14
- package/index.js.map +1 -1
- package/indexeddb/index.cjs +218 -0
- package/indexeddb/index.cjs.map +1 -0
- package/indexeddb/index.d.cts +30 -0
- package/indexeddb/index.d.ts +30 -0
- package/indexeddb/index.js +195 -0
- package/indexeddb/index.js.map +1 -0
- package/indexeddb/metafile-cjs.json +1 -0
- package/indexeddb/metafile-esm.json +1 -0
- package/metafile-cjs.json +1 -0
- package/metafile-esm.json +1 -0
- package/node/index.cjs +97 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +7 -0
- package/node/index.d.ts +7 -0
- package/node/index.js +64 -0
- package/node/index.js.map +1 -0
- package/node/metafile-cjs.json +1 -0
- package/node/metafile-esm.json +1 -0
- package/package.json +17 -20
- package/react/index.cjs +296 -0
- package/react/index.cjs.map +1 -0
- package/react/{img-file.d.ts → index.d.cts} +53 -6
- package/react/index.d.ts +336 -4
- package/react/index.js +262 -3
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -0
- package/react/metafile-esm.json +1 -0
- package/tests/blockstore/loader.test.ts +1 -1
- package/tests/blockstore/store.test.ts +4 -9
- package/tests/fireproof/attachable.test.ts +3 -3
- package/tests/react/use-fireproof-db-switch.test.tsx +91 -0
- package/tests/www/gallery.html +132 -0
- package/tests/www/iife.html +42 -0
- package/tests/www/todo-aws.html +232 -0
- package/tests/www/todo-ipfs.html +213 -0
- package/tests/www/todo-local.html +214 -0
- package/tests/www/todo-netlify.html +227 -0
- package/tests/www/todo.html +254 -0
- package/apply-head-queue.d.ts +0 -18
- package/apply-head-queue.d.ts.map +0 -1
- package/apply-head-queue.js +0 -47
- package/apply-head-queue.js.map +0 -1
- package/blockstore/attachable-store.d.ts +0 -17
- package/blockstore/attachable-store.d.ts.map +0 -1
- package/blockstore/attachable-store.js +0 -295
- package/blockstore/attachable-store.js.map +0 -1
- package/blockstore/commit-queue.d.ts +0 -12
- package/blockstore/commit-queue.d.ts.map +0 -1
- package/blockstore/commit-queue.js +0 -52
- package/blockstore/commit-queue.js.map +0 -1
- package/blockstore/commitor.d.ts +0 -21
- package/blockstore/commitor.d.ts.map +0 -1
- package/blockstore/commitor.js +0 -104
- package/blockstore/commitor.js.map +0 -1
- package/blockstore/connect-raw.d.ts +0 -2
- package/blockstore/connect-raw.d.ts.map +0 -1
- package/blockstore/connect-raw.js +0 -2
- package/blockstore/connect-raw.js.map +0 -1
- package/blockstore/connection-base.d.ts +0 -2
- package/blockstore/connection-base.d.ts.map +0 -1
- package/blockstore/connection-base.js +0 -2
- package/blockstore/connection-base.js.map +0 -1
- package/blockstore/encrypt-helpers.d.ts +0 -2
- package/blockstore/encrypt-helpers.d.ts.map +0 -1
- package/blockstore/encrypt-helpers.js +0 -2
- package/blockstore/encrypt-helpers.js.map +0 -1
- package/blockstore/fp-envelope.d.ts +0 -32
- package/blockstore/fp-envelope.d.ts.map +0 -1
- package/blockstore/fp-envelope.js +0 -14
- package/blockstore/fp-envelope.js.map +0 -1
- package/blockstore/gateway.d.ts +0 -20
- package/blockstore/gateway.d.ts.map +0 -1
- package/blockstore/gateway.js +0 -2
- package/blockstore/gateway.js.map +0 -1
- package/blockstore/index.d.ts +0 -16
- package/blockstore/index.d.ts.map +0 -1
- package/blockstore/index.js +0 -16
- package/blockstore/index.js.map +0 -1
- package/blockstore/interceptor-gateway.d.ts +0 -29
- package/blockstore/interceptor-gateway.d.ts.map +0 -1
- package/blockstore/interceptor-gateway.js +0 -137
- package/blockstore/interceptor-gateway.js.map +0 -1
- package/blockstore/loader-helpers.d.ts +0 -4
- package/blockstore/loader-helpers.d.ts.map +0 -1
- package/blockstore/loader-helpers.js +0 -16
- package/blockstore/loader-helpers.js.map +0 -1
- package/blockstore/loader.d.ts +0 -45
- package/blockstore/loader.d.ts.map +0 -1
- package/blockstore/loader.js +0 -352
- package/blockstore/loader.js.map +0 -1
- package/blockstore/register-store-protocol.d.ts +0 -22
- package/blockstore/register-store-protocol.d.ts.map +0 -1
- package/blockstore/register-store-protocol.js +0 -114
- package/blockstore/register-store-protocol.js.map +0 -1
- package/blockstore/serde-gateway.d.ts +0 -78
- package/blockstore/serde-gateway.d.ts.map +0 -1
- package/blockstore/serde-gateway.js +0 -2
- package/blockstore/serde-gateway.js.map +0 -1
- package/blockstore/store-factory.d.ts +0 -11
- package/blockstore/store-factory.d.ts.map +0 -1
- package/blockstore/store-factory.js +0 -105
- package/blockstore/store-factory.js.map +0 -1
- package/blockstore/store-remote.d.ts +0 -2
- package/blockstore/store-remote.d.ts.map +0 -1
- package/blockstore/store-remote.js +0 -2
- package/blockstore/store-remote.js.map +0 -1
- package/blockstore/store.d.ts +0 -82
- package/blockstore/store.d.ts.map +0 -1
- package/blockstore/store.js +0 -438
- package/blockstore/store.js.map +0 -1
- package/blockstore/task-manager.d.ts +0 -19
- package/blockstore/task-manager.d.ts.map +0 -1
- package/blockstore/task-manager.js +0 -50
- package/blockstore/task-manager.js.map +0 -1
- package/blockstore/transaction.d.ts +0 -64
- package/blockstore/transaction.d.ts.map +0 -1
- package/blockstore/transaction.js +0 -249
- package/blockstore/transaction.js.map +0 -1
- package/blockstore/types.d.ts +0 -400
- package/blockstore/types.d.ts.map +0 -1
- package/blockstore/types.js +0 -55
- package/blockstore/types.js.map +0 -1
- package/blockstore/uri-interceptor.d.ts +0 -19
- package/blockstore/uri-interceptor.d.ts.map +0 -1
- package/blockstore/uri-interceptor.js +0 -61
- package/blockstore/uri-interceptor.js.map +0 -1
- package/bundle-not-impl.d.ts +0 -2
- package/bundle-not-impl.d.ts.map +0 -1
- package/bundle-not-impl.js +0 -4
- package/bundle-not-impl.js.map +0 -1
- package/cli/main.js +0 -26114
- package/context.d.ts +0 -7
- package/context.d.ts.map +0 -1
- package/context.js +0 -15
- package/context.js.map +0 -1
- package/crdt-clock.d.ts +0 -27
- package/crdt-clock.d.ts.map +0 -1
- package/crdt-clock.js +0 -140
- package/crdt-clock.js.map +0 -1
- package/crdt-helpers.d.ts +0 -16
- package/crdt-helpers.d.ts.map +0 -1
- package/crdt-helpers.js +0 -316
- package/crdt-helpers.js.map +0 -1
- package/crdt.d.ts +0 -34
- package/crdt.d.ts.map +0 -1
- package/crdt.js +0 -131
- package/crdt.js.map +0 -1
- package/database.d.ts +0 -34
- package/database.d.ts.map +0 -1
- package/database.js +0 -121
- package/database.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-helpers.d.ts +0 -69
- package/indexer-helpers.d.ts.map +0 -1
- package/indexer-helpers.js +0 -135
- package/indexer-helpers.js.map +0 -1
- package/indexer.d.ts +0 -25
- package/indexer.d.ts.map +0 -1
- package/indexer.js +0 -231
- package/indexer.js.map +0 -1
- package/ledger.d.ts +0 -56
- package/ledger.d.ts.map +0 -1
- package/ledger.js +0 -224
- package/ledger.js.map +0 -1
- package/protocols/cloud/http-connection.d.ts +0 -25
- package/protocols/cloud/http-connection.d.ts.map +0 -1
- package/protocols/cloud/http-connection.js +0 -153
- package/protocols/cloud/http-connection.js.map +0 -1
- package/protocols/cloud/index.d.ts +0 -10
- package/protocols/cloud/index.d.ts.map +0 -1
- package/protocols/cloud/index.js +0 -10
- package/protocols/cloud/index.js.map +0 -1
- package/protocols/cloud/msg-raw-connection-base.d.ts +0 -16
- package/protocols/cloud/msg-raw-connection-base.d.ts.map +0 -1
- package/protocols/cloud/msg-raw-connection-base.js +0 -22
- package/protocols/cloud/msg-raw-connection-base.js.map +0 -1
- package/protocols/cloud/msg-types-data.d.ts +0 -36
- package/protocols/cloud/msg-types-data.d.ts.map +0 -1
- package/protocols/cloud/msg-types-data.js +0 -38
- package/protocols/cloud/msg-types-data.js.map +0 -1
- package/protocols/cloud/msg-types-meta.d.ts +0 -41
- package/protocols/cloud/msg-types-meta.d.ts.map +0 -1
- package/protocols/cloud/msg-types-meta.js +0 -98
- package/protocols/cloud/msg-types-meta.js.map +0 -1
- package/protocols/cloud/msg-types-wal.d.ts +0 -33
- package/protocols/cloud/msg-types-wal.d.ts.map +0 -1
- package/protocols/cloud/msg-types-wal.js +0 -38
- package/protocols/cloud/msg-types-wal.js.map +0 -1
- package/protocols/cloud/msg-types.d.ts +0 -279
- package/protocols/cloud/msg-types.d.ts.map +0 -1
- package/protocols/cloud/msg-types.js +0 -278
- package/protocols/cloud/msg-types.js.map +0 -1
- package/protocols/cloud/msger.d.ts +0 -79
- package/protocols/cloud/msger.d.ts.map +0 -1
- package/protocols/cloud/msger.js +0 -198
- package/protocols/cloud/msger.js.map +0 -1
- package/protocols/cloud/ws-connection.d.ts +0 -29
- package/protocols/cloud/ws-connection.d.ts.map +0 -1
- package/protocols/cloud/ws-connection.js +0 -163
- package/protocols/cloud/ws-connection.js.map +0 -1
- package/protocols/index.d.ts +0 -2
- package/protocols/index.d.ts.map +0 -1
- package/protocols/index.js +0 -2
- package/protocols/index.js.map +0 -1
- package/react/img-file.d.ts.map +0 -1
- package/react/img-file.js +0 -58
- package/react/img-file.js.map +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/types.d.ts +0 -43
- package/react/types.d.ts.map +0 -1
- package/react/types.js +0 -2
- package/react/types.js.map +0 -1
- package/react/use-all-docs.d.ts +0 -4
- package/react/use-all-docs.d.ts.map +0 -1
- package/react/use-all-docs.js +0 -19
- package/react/use-all-docs.js.map +0 -1
- package/react/use-changes.d.ts +0 -4
- package/react/use-changes.d.ts.map +0 -1
- package/react/use-changes.js +0 -19
- package/react/use-changes.js.map +0 -1
- package/react/use-document.d.ts +0 -4
- package/react/use-document.d.ts.map +0 -1
- package/react/use-document.js +0 -99
- package/react/use-document.js.map +0 -1
- package/react/use-fireproof.d.ts +0 -6
- package/react/use-fireproof.d.ts.map +0 -1
- package/react/use-fireproof.js +0 -15
- package/react/use-fireproof.js.map +0 -1
- package/react/use-live-query.d.ts +0 -4
- package/react/use-live-query.d.ts.map +0 -1
- package/react/use-live-query.js +0 -38
- package/react/use-live-query.js.map +0 -1
- package/react/utils.d.ts +0 -2
- package/react/utils.d.ts.map +0 -1
- package/react/utils.js +0 -4
- package/react/utils.js.map +0 -1
- package/runtime/files.d.ts +0 -12
- package/runtime/files.d.ts.map +0 -1
- package/runtime/files.js +0 -29
- package/runtime/files.js.map +0 -1
- package/runtime/gateways/cloud/gateway.d.ts +0 -44
- package/runtime/gateways/cloud/gateway.d.ts.map +0 -1
- package/runtime/gateways/cloud/gateway.js +0 -496
- package/runtime/gateways/cloud/gateway.js.map +0 -1
- package/runtime/gateways/def-serde-gateway.d.ts +0 -19
- package/runtime/gateways/def-serde-gateway.d.ts.map +0 -1
- package/runtime/gateways/def-serde-gateway.js +0 -73
- package/runtime/gateways/def-serde-gateway.js.map +0 -1
- package/runtime/gateways/file/deno/deno-filesystem.d.ts +0 -27
- package/runtime/gateways/file/deno/deno-filesystem.d.ts.map +0 -1
- package/runtime/gateways/file/deno/deno-filesystem.js +0 -51
- package/runtime/gateways/file/deno/deno-filesystem.js.map +0 -1
- package/runtime/gateways/file/deno/get-sys-file-system.d.ts +0 -4
- package/runtime/gateways/file/deno/get-sys-file-system.d.ts.map +0 -1
- package/runtime/gateways/file/deno/get-sys-file-system.js +0 -11
- package/runtime/gateways/file/deno/get-sys-file-system.js.map +0 -1
- package/runtime/gateways/file/deno/index.d.ts +0 -2
- package/runtime/gateways/file/deno/index.d.ts.map +0 -1
- package/runtime/gateways/file/deno/index.js +0 -2
- package/runtime/gateways/file/deno/index.js.map +0 -1
- package/runtime/gateways/file/gateway-impl.d.ts +0 -18
- package/runtime/gateways/file/gateway-impl.d.ts.map +0 -1
- package/runtime/gateways/file/gateway-impl.js +0 -121
- package/runtime/gateways/file/gateway-impl.js.map +0 -1
- package/runtime/gateways/file/index.d.ts +0 -3
- package/runtime/gateways/file/index.d.ts.map +0 -1
- package/runtime/gateways/file/index.js +0 -3
- package/runtime/gateways/file/index.js.map +0 -1
- package/runtime/gateways/file/key-bag-file.d.ts +0 -19
- package/runtime/gateways/file/key-bag-file.d.ts.map +0 -1
- package/runtime/gateways/file/key-bag-file.js +0 -40
- package/runtime/gateways/file/key-bag-file.js.map +0 -1
- package/runtime/gateways/file/node/get-sys-file-system.d.ts +0 -4
- package/runtime/gateways/file/node/get-sys-file-system.d.ts.map +0 -1
- package/runtime/gateways/file/node/get-sys-file-system.js +0 -11
- package/runtime/gateways/file/node/get-sys-file-system.js.map +0 -1
- package/runtime/gateways/file/node/index.d.ts +0 -2
- package/runtime/gateways/file/node/index.d.ts.map +0 -1
- package/runtime/gateways/file/node/index.js +0 -2
- package/runtime/gateways/file/node/index.js.map +0 -1
- package/runtime/gateways/file/node/node-filesystem.d.ts +0 -32
- package/runtime/gateways/file/node/node-filesystem.d.ts.map +0 -1
- package/runtime/gateways/file/node/node-filesystem.js +0 -37
- package/runtime/gateways/file/node/node-filesystem.js.map +0 -1
- package/runtime/gateways/file/node/to-array-buffer.d.ts +0 -2
- package/runtime/gateways/file/node/to-array-buffer.d.ts.map +0 -1
- package/runtime/gateways/file/node/to-array-buffer.js +0 -12
- package/runtime/gateways/file/node/to-array-buffer.js.map +0 -1
- package/runtime/gateways/file/sys-file-system-factory.d.ts +0 -4
- package/runtime/gateways/file/sys-file-system-factory.d.ts.map +0 -1
- package/runtime/gateways/file/sys-file-system-factory.js +0 -13
- package/runtime/gateways/file/sys-file-system-factory.js.map +0 -1
- package/runtime/gateways/file/utils.d.ts +0 -5
- package/runtime/gateways/file/utils.d.ts.map +0 -1
- package/runtime/gateways/file/utils.js +0 -27
- package/runtime/gateways/file/utils.js.map +0 -1
- package/runtime/gateways/file/version.d.ts +0 -2
- package/runtime/gateways/file/version.d.ts.map +0 -1
- package/runtime/gateways/file/version.js +0 -2
- package/runtime/gateways/file/version.js.map +0 -1
- package/runtime/gateways/fp-envelope-serialize.d.ts +0 -50
- package/runtime/gateways/fp-envelope-serialize.d.ts.map +0 -1
- package/runtime/gateways/fp-envelope-serialize.js +0 -141
- package/runtime/gateways/fp-envelope-serialize.js.map +0 -1
- package/runtime/gateways/index.d.ts +0 -6
- package/runtime/gateways/index.d.ts.map +0 -1
- package/runtime/gateways/index.js +0 -6
- package/runtime/gateways/index.js.map +0 -1
- package/runtime/gateways/indexeddb/gateway-impl.d.ts +0 -22
- package/runtime/gateways/indexeddb/gateway-impl.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/gateway-impl.js +0 -147
- package/runtime/gateways/indexeddb/gateway-impl.js.map +0 -1
- package/runtime/gateways/indexeddb/index.d.ts +0 -6
- package/runtime/gateways/indexeddb/index.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/index.js +0 -6
- package/runtime/gateways/indexeddb/index.js.map +0 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts +0 -15
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js +0 -42
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js.map +0 -1
- package/runtime/gateways/indexeddb-version.d.ts +0 -2
- package/runtime/gateways/indexeddb-version.d.ts.map +0 -1
- package/runtime/gateways/indexeddb-version.js +0 -2
- package/runtime/gateways/indexeddb-version.js.map +0 -1
- package/runtime/gateways/memory/gateway.d.ts +0 -18
- package/runtime/gateways/memory/gateway.d.ts.map +0 -1
- package/runtime/gateways/memory/gateway.js +0 -58
- package/runtime/gateways/memory/gateway.js.map +0 -1
- package/runtime/gateways/memory/version.d.ts +0 -2
- package/runtime/gateways/memory/version.d.ts.map +0 -1
- package/runtime/gateways/memory/version.js +0 -2
- package/runtime/gateways/memory/version.js.map +0 -1
- package/runtime/index.d.ts +0 -13
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -13
- package/runtime/index.js.map +0 -1
- package/runtime/key-bag-memory.d.ts +0 -12
- package/runtime/key-bag-memory.d.ts.map +0 -1
- package/runtime/key-bag-memory.js +0 -23
- package/runtime/key-bag-memory.js.map +0 -1
- package/runtime/key-bag.d.ts +0 -85
- package/runtime/key-bag.d.ts.map +0 -1
- package/runtime/key-bag.js +0 -415
- package/runtime/key-bag.js.map +0 -1
- package/runtime/keyed-crypto.d.ts +0 -19
- package/runtime/keyed-crypto.d.ts.map +0 -1
- package/runtime/keyed-crypto.js +0 -192
- package/runtime/keyed-crypto.js.map +0 -1
- package/runtime/memory-sys-container.d.ts +0 -2
- package/runtime/memory-sys-container.d.ts.map +0 -1
- package/runtime/memory-sys-container.js +0 -2
- package/runtime/memory-sys-container.js.map +0 -1
- package/runtime/meta-key-hack.d.ts +0 -42
- package/runtime/meta-key-hack.d.ts.map +0 -1
- package/runtime/meta-key-hack.js +0 -201
- package/runtime/meta-key-hack.js.map +0 -1
- package/runtime/sts-service/index.d.ts +0 -40
- package/runtime/sts-service/index.d.ts.map +0 -1
- package/runtime/sts-service/index.js +0 -102
- package/runtime/sts-service/index.js.map +0 -1
- package/runtime/sys-container.d.ts +0 -2
- package/runtime/sys-container.d.ts.map +0 -1
- package/runtime/sys-container.js +0 -2
- package/runtime/sys-container.js.map +0 -1
- package/runtime/wait-pr-multiformats/block.d.ts +0 -47
- package/runtime/wait-pr-multiformats/block.d.ts.map +0 -1
- package/runtime/wait-pr-multiformats/block.js +0 -64
- package/runtime/wait-pr-multiformats/block.js.map +0 -1
- package/runtime/wait-pr-multiformats/codec-interface.d.ts +0 -29
- package/runtime/wait-pr-multiformats/codec-interface.d.ts.map +0 -1
- package/runtime/wait-pr-multiformats/codec-interface.js +0 -2
- package/runtime/wait-pr-multiformats/codec-interface.js.map +0 -1
- package/runtime/wait-pr-multiformats/index.d.ts +0 -3
- package/runtime/wait-pr-multiformats/index.d.ts.map +0 -1
- package/runtime/wait-pr-multiformats/index.js +0 -3
- package/runtime/wait-pr-multiformats/index.js.map +0 -1
- package/types.d.ts +0 -427
- package/types.d.ts.map +0 -1
- package/types.js +0 -54
- package/types.js.map +0 -1
- package/use-fireproof/index.d.ts +0 -3
- package/use-fireproof/index.d.ts.map +0 -1
- package/use-fireproof/index.js +0 -3
- package/use-fireproof/index.js.map +0 -1
- package/utils.d.ts +0 -36
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -379
- package/utils.js.map +0 -1
- package/version.d.ts +0 -2
- package/version.d.ts.map +0 -1
- package/version.js +0 -4
- package/version.js.map +0 -1
- package/write-queue.d.ts +0 -9
- package/write-queue.d.ts.map +0 -1
- package/write-queue.js +0 -70
- package/write-queue.js.map +0 -1
@@ -1,249 +0,0 @@
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
5
|
-
};
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
11
|
-
};
|
12
|
-
var _CarTransactionImpl_memblock, _CarTransactionImpl_hackUnshift;
|
13
|
-
import { MemoryBlockstore } from "@fireproof/vendor/@web3-storage/pail/block";
|
14
|
-
import { Loader } from "./loader.js";
|
15
|
-
import { falsyToUndef } from "../types.js";
|
16
|
-
import { ensureStoreEnDeFile, toStoreRuntime } from "./store-factory.js";
|
17
|
-
import { toCryptoRuntime } from "@adviser/cement";
|
18
|
-
import { ensureLogger, ensureSuperThis } from "../utils.js";
|
19
|
-
export class CarTransactionImpl {
|
20
|
-
constructor(parent, opts = { add: true, noLoader: false }) {
|
21
|
-
_CarTransactionImpl_memblock.set(this, new MemoryBlockstore());
|
22
|
-
_CarTransactionImpl_hackUnshift.set(this, void 0);
|
23
|
-
if (opts.add) {
|
24
|
-
parent.transactions.add(this);
|
25
|
-
}
|
26
|
-
this.parent = parent;
|
27
|
-
}
|
28
|
-
async get(cid) {
|
29
|
-
return ((await this.superGet(cid)) ?? falsyToUndef(await this.parent.get(cid)));
|
30
|
-
}
|
31
|
-
async superGet(cid) {
|
32
|
-
return __classPrivateFieldGet(this, _CarTransactionImpl_memblock, "f").get(cid);
|
33
|
-
}
|
34
|
-
async put(cid, block) {
|
35
|
-
await __classPrivateFieldGet(this, _CarTransactionImpl_memblock, "f").put(cid, block);
|
36
|
-
}
|
37
|
-
putSync(cid, bytes) {
|
38
|
-
__classPrivateFieldGet(this, _CarTransactionImpl_memblock, "f").putSync(cid, bytes);
|
39
|
-
}
|
40
|
-
unshift(cid, bytes) {
|
41
|
-
if (__classPrivateFieldGet(this, _CarTransactionImpl_hackUnshift, "f")) {
|
42
|
-
throw new Error("unshift already called");
|
43
|
-
}
|
44
|
-
__classPrivateFieldSet(this, _CarTransactionImpl_hackUnshift, { cid, bytes }, "f");
|
45
|
-
}
|
46
|
-
async *entries() {
|
47
|
-
if (__classPrivateFieldGet(this, _CarTransactionImpl_hackUnshift, "f")) {
|
48
|
-
yield __classPrivateFieldGet(this, _CarTransactionImpl_hackUnshift, "f");
|
49
|
-
}
|
50
|
-
for await (const blk of __classPrivateFieldGet(this, _CarTransactionImpl_memblock, "f").entries()) {
|
51
|
-
yield blk;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
_CarTransactionImpl_memblock = new WeakMap(), _CarTransactionImpl_hackUnshift = new WeakMap();
|
56
|
-
export function defaultedBlockstoreRuntime(sthis, opts, component, ctx) {
|
57
|
-
const logger = ensureLogger(sthis, component, ctx);
|
58
|
-
return {
|
59
|
-
applyMeta: (meta, snap) => {
|
60
|
-
return Promise.resolve();
|
61
|
-
},
|
62
|
-
compact: async (blocks) => {
|
63
|
-
return {};
|
64
|
-
},
|
65
|
-
autoCompact: 100,
|
66
|
-
public: false,
|
67
|
-
threshold: 1000 * 1000,
|
68
|
-
...opts,
|
69
|
-
logger,
|
70
|
-
keyBag: opts.keyBag || {},
|
71
|
-
crypto: toCryptoRuntime(opts.crypto),
|
72
|
-
storeUrls: opts.storeUrls,
|
73
|
-
taskManager: {
|
74
|
-
removeAfter: 3,
|
75
|
-
retryTimeout: 50,
|
76
|
-
...opts.taskManager,
|
77
|
-
},
|
78
|
-
storeRuntime: toStoreRuntime(sthis, ensureStoreEnDeFile(opts.storeEnDeFile)),
|
79
|
-
};
|
80
|
-
}
|
81
|
-
export class BaseBlockstoreImpl {
|
82
|
-
ready() {
|
83
|
-
return Promise.resolve();
|
84
|
-
}
|
85
|
-
async close() {
|
86
|
-
}
|
87
|
-
async destroy() {
|
88
|
-
}
|
89
|
-
async compact() {
|
90
|
-
}
|
91
|
-
constructor(ebOpts) {
|
92
|
-
this.transactions = new Set();
|
93
|
-
this.sthis = ensureSuperThis(ebOpts);
|
94
|
-
this.ebOpts = defaultedBlockstoreRuntime(this.sthis, ebOpts, "BaseBlockstore");
|
95
|
-
this.logger = this.ebOpts.logger;
|
96
|
-
this.loader = new Loader(this.sthis, ebOpts);
|
97
|
-
}
|
98
|
-
async get(cid) {
|
99
|
-
if (!cid)
|
100
|
-
throw this.logger.Error().Msg("required cid").AsError();
|
101
|
-
for (const f of this.transactions) {
|
102
|
-
const v = await f.superGet(cid);
|
103
|
-
if (v)
|
104
|
-
return v;
|
105
|
-
}
|
106
|
-
}
|
107
|
-
async put(cid, block) {
|
108
|
-
throw this.logger.Error().Msg("use a transaction to put").AsError();
|
109
|
-
}
|
110
|
-
async transaction(fn, _opts) {
|
111
|
-
this.logger.Debug().Msg("enter transaction");
|
112
|
-
const t = new CarTransactionImpl(this, _opts);
|
113
|
-
this.logger.Debug().Msg("post CarTransaction");
|
114
|
-
const done = await fn(t);
|
115
|
-
this.logger.Debug().Msg("post fn");
|
116
|
-
this.lastTxMeta = done;
|
117
|
-
return { t, meta: done };
|
118
|
-
}
|
119
|
-
openTransaction(opts = { add: true, noLoader: false }) {
|
120
|
-
return new CarTransactionImpl(this, opts);
|
121
|
-
}
|
122
|
-
async commitTransaction(t, done, opts) {
|
123
|
-
if (!this.loader)
|
124
|
-
throw this.logger.Error().Msg("loader required to commit").AsError();
|
125
|
-
const cars = await this.loader.commit(t, done, opts);
|
126
|
-
if (this.ebOpts.autoCompact && this.loader.carLog.length > this.ebOpts.autoCompact) {
|
127
|
-
setTimeout(() => void this.compact(), 10);
|
128
|
-
}
|
129
|
-
if (cars) {
|
130
|
-
this.transactions.delete(t);
|
131
|
-
return { meta: done, cars, t };
|
132
|
-
}
|
133
|
-
throw this.logger.Error().Msg("failed to commit car files").AsError();
|
134
|
-
}
|
135
|
-
async *entries() {
|
136
|
-
const seen = new Set();
|
137
|
-
for (const t of this.transactions) {
|
138
|
-
for await (const blk of t.entries()) {
|
139
|
-
if (seen.has(blk.cid.toString()))
|
140
|
-
continue;
|
141
|
-
seen.add(blk.cid.toString());
|
142
|
-
yield blk;
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
}
|
147
|
-
export class EncryptedBlockstore extends BaseBlockstoreImpl {
|
148
|
-
ready() {
|
149
|
-
return this.loader.ready();
|
150
|
-
}
|
151
|
-
close() {
|
152
|
-
return this.loader.close();
|
153
|
-
}
|
154
|
-
destroy() {
|
155
|
-
return this.loader.destroy();
|
156
|
-
}
|
157
|
-
constructor(sthis, ebOpts) {
|
158
|
-
super(ebOpts);
|
159
|
-
this.compacting = false;
|
160
|
-
this.logger = ensureLogger(this.sthis, "EncryptedBlockstore", {
|
161
|
-
this: 1,
|
162
|
-
});
|
163
|
-
}
|
164
|
-
async get(cid) {
|
165
|
-
const got = await super.get(cid);
|
166
|
-
if (got)
|
167
|
-
return got;
|
168
|
-
const ret = falsyToUndef(await this.loader.getBlock(cid, this.loader.attachedStores.local()));
|
169
|
-
return ret;
|
170
|
-
}
|
171
|
-
async transaction(fn, opts = { noLoader: false }) {
|
172
|
-
this.logger.Debug().Msg("enter transaction");
|
173
|
-
const { t, meta: done } = await super.transaction(fn);
|
174
|
-
this.logger.Debug().Msg("post super.transaction");
|
175
|
-
const cars = await this.loader.commit(t, done, opts);
|
176
|
-
this.logger.Debug().Msg("post this.loader.commit");
|
177
|
-
if (this.ebOpts.autoCompact && this.loader.carLog.length > this.ebOpts.autoCompact) {
|
178
|
-
setTimeout(() => void this.compact(), 10);
|
179
|
-
}
|
180
|
-
if (cars) {
|
181
|
-
this.transactions.delete(t);
|
182
|
-
return { meta: done, cars, t };
|
183
|
-
}
|
184
|
-
throw this.logger.Error().Msg("failed to commit car files").AsError();
|
185
|
-
}
|
186
|
-
async getFile(car, cid) {
|
187
|
-
await this.ready();
|
188
|
-
if (!this.loader)
|
189
|
-
throw this.logger.Error().Msg("loader required to get file, ledger must be named").AsError();
|
190
|
-
const reader = await this.loader.loadFileCar(car, this.loader.attachedStores.local());
|
191
|
-
const block = await reader.blocks.find((i) => i.cid.equals(cid));
|
192
|
-
if (!block)
|
193
|
-
throw this.logger.Error().Str("cid", cid.toString()).Msg(`Missing block`).AsError();
|
194
|
-
return block.bytes;
|
195
|
-
}
|
196
|
-
async compact() {
|
197
|
-
await this.ready();
|
198
|
-
if (!this.loader)
|
199
|
-
throw this.logger.Error().Msg("loader required to compact").AsError();
|
200
|
-
if (this.loader.carLog.length < 2)
|
201
|
-
return;
|
202
|
-
const compactFn = this.ebOpts.compact || ((blocks) => this.defaultCompact(blocks, this.logger));
|
203
|
-
if (!compactFn || this.compacting)
|
204
|
-
return;
|
205
|
-
const blockLog = new CompactionFetcher(this);
|
206
|
-
this.compacting = true;
|
207
|
-
const meta = await compactFn(blockLog);
|
208
|
-
await this.loader.commit(blockLog.loggedBlocks, meta, {
|
209
|
-
compact: true,
|
210
|
-
noLoader: true,
|
211
|
-
});
|
212
|
-
this.compacting = false;
|
213
|
-
}
|
214
|
-
async defaultCompact(blocks, logger) {
|
215
|
-
if (!this.loader) {
|
216
|
-
throw logger.Error().Msg("no loader").AsError();
|
217
|
-
}
|
218
|
-
if (!this.lastTxMeta) {
|
219
|
-
throw logger.Error().Msg("no lastTxMeta").AsError();
|
220
|
-
}
|
221
|
-
for await (const blk of this.loader.entries(false)) {
|
222
|
-
blocks.loggedBlocks.putSync(blk.cid, blk.bytes);
|
223
|
-
}
|
224
|
-
for (const t of this.transactions) {
|
225
|
-
for await (const blk of t.entries()) {
|
226
|
-
blocks.loggedBlocks.putSync(blk.cid, blk.bytes);
|
227
|
-
}
|
228
|
-
}
|
229
|
-
return this.lastTxMeta;
|
230
|
-
}
|
231
|
-
async *entries() {
|
232
|
-
for await (const blk of this.loader.entries()) {
|
233
|
-
yield blk;
|
234
|
-
}
|
235
|
-
}
|
236
|
-
}
|
237
|
-
export class CompactionFetcher {
|
238
|
-
constructor(blocks) {
|
239
|
-
this.blockstore = blocks;
|
240
|
-
this.loggedBlocks = new CarTransactionImpl(blocks);
|
241
|
-
}
|
242
|
-
async get(cid) {
|
243
|
-
const block = await this.blockstore.get(cid);
|
244
|
-
if (block)
|
245
|
-
this.loggedBlocks.putSync(cid, block.bytes);
|
246
|
-
return falsyToUndef(block);
|
247
|
-
}
|
248
|
-
}
|
249
|
-
//# sourceMappingURL=transaction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../../src/blockstore/transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAe9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CA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,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;gBACpC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,CAAC,OAAO;QAEZ,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAG9C,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,iBAAiB;IAK5B,YAAY,MAA2B;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QAEzB,IAAI,CAAC,YAAY,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,GAAG,CAA2D,GAAY;QAC9E,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,KAAK;YAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,YAAY,CAAC,KAAK,CAAsB,CAAC;IAClD,CAAC;CACF"}
|
package/blockstore/types.d.ts
DELETED
@@ -1,400 +0,0 @@
|
|
1
|
-
import type { CID, Link, Version } from "multiformats";
|
2
|
-
import { Attachable, Attached, CarTransaction, DocFileMeta, Falsy, GatewayUrls, StoreType, SuperThis } from "../types.js";
|
3
|
-
import { BlockFetcher } from "./transaction.js";
|
4
|
-
import { CommitQueue } from "./commit-queue.js";
|
5
|
-
import { KeyBag, KeyBagRuntime, KeysItem } from "../runtime/key-bag.js";
|
6
|
-
import { CoerceURI, CryptoRuntime, CTCryptoKey, Future, Logger, Result, URI } from "@adviser/cement";
|
7
|
-
import { EventBlock } from "@fireproof/vendor/@web3-storage/pail/clock";
|
8
|
-
import { TaskManager, TaskManagerParams } from "./task-manager.js";
|
9
|
-
import { SerdeGateway, SerdeGatewayInterceptor } from "./serde-gateway.js";
|
10
|
-
import { Context } from "../context.js";
|
11
|
-
import { AsyncBlockCodec } from "../runtime/wait-pr-multiformats/codec-interface.js";
|
12
|
-
export type AnyLink = Link<unknown, number, number, Version>;
|
13
|
-
export type CarGroup = AnyLink[];
|
14
|
-
export type FroozenCarLog = CarGroup[];
|
15
|
-
export declare class CarLog {
|
16
|
-
readonly _logs: CarGroup[];
|
17
|
-
get length(): number;
|
18
|
-
last(): AnyLink[];
|
19
|
-
xunshift(logs: CarGroup): void;
|
20
|
-
update(logs: FroozenCarLog): void;
|
21
|
-
asArray(): FroozenCarLog;
|
22
|
-
}
|
23
|
-
export type AnyAnyLink = Link<unknown, number, number, Version>;
|
24
|
-
export type AnyLinkFn = (cid: AnyLink) => Promise<AnyBlock | undefined>;
|
25
|
-
export interface AnyBlock {
|
26
|
-
readonly cid: Link<unknown, number, number, Version>;
|
27
|
-
readonly bytes: Uint8Array;
|
28
|
-
}
|
29
|
-
export interface CIDBlock {
|
30
|
-
readonly cid: CID<unknown, number, number, Version>;
|
31
|
-
readonly bytes: Uint8Array;
|
32
|
-
}
|
33
|
-
export declare function toCIDBlock(block: AnyBlock): CIDBlock;
|
34
|
-
export interface AnyAnyBlock {
|
35
|
-
readonly cid: AnyAnyLink;
|
36
|
-
readonly bytes: Uint8Array;
|
37
|
-
}
|
38
|
-
export interface IvKeyIdData {
|
39
|
-
readonly iv: Uint8Array;
|
40
|
-
readonly keyId: Uint8Array;
|
41
|
-
readonly data: Uint8Array;
|
42
|
-
}
|
43
|
-
export interface IvAndKeyAndBytes {
|
44
|
-
readonly bytes: Uint8Array;
|
45
|
-
readonly key: CTCryptoKey;
|
46
|
-
readonly iv: Uint8Array;
|
47
|
-
}
|
48
|
-
export interface BytesAndKeyWithIv {
|
49
|
-
readonly bytes: Uint8Array;
|
50
|
-
readonly key: CTCryptoKey;
|
51
|
-
readonly iv?: Uint8Array;
|
52
|
-
}
|
53
|
-
export interface AnyDecodedBlock {
|
54
|
-
readonly cid: AnyLink;
|
55
|
-
readonly bytes: Uint8Array;
|
56
|
-
readonly value: Uint8Array;
|
57
|
-
}
|
58
|
-
export interface CarMakeable {
|
59
|
-
entries(): AsyncIterable<AnyBlock>;
|
60
|
-
get(cid: AnyLink): Promise<AnyBlock | undefined>;
|
61
|
-
}
|
62
|
-
export interface CarHeader<T> {
|
63
|
-
readonly cars: FroozenCarLog;
|
64
|
-
readonly compact: FroozenCarLog;
|
65
|
-
readonly meta: T;
|
66
|
-
}
|
67
|
-
export interface TransactionWrapper<M extends TransactionMeta> {
|
68
|
-
meta: M;
|
69
|
-
cars?: CarGroup;
|
70
|
-
t: CarTransaction;
|
71
|
-
}
|
72
|
-
export type TransactionMeta = unknown;
|
73
|
-
export interface EncryptedBlock {
|
74
|
-
readonly value: IvAndKeyAndBytes;
|
75
|
-
}
|
76
|
-
export interface KeyMaterial {
|
77
|
-
readonly key: Uint8Array;
|
78
|
-
readonly keyStr: string;
|
79
|
-
}
|
80
|
-
export interface KeyWithFingerPrint {
|
81
|
-
readonly fingerPrint: string;
|
82
|
-
readonly key: CTCryptoKey;
|
83
|
-
extract(): Promise<KeyMaterial>;
|
84
|
-
}
|
85
|
-
export interface CodecOpts {
|
86
|
-
readonly ivCalc: "random" | "hash";
|
87
|
-
readonly noIVVerify: boolean;
|
88
|
-
}
|
89
|
-
export interface KeyUpsertResult {
|
90
|
-
readonly modified: boolean;
|
91
|
-
readonly kfp: KeyWithFingerPrint;
|
92
|
-
}
|
93
|
-
export interface KeysByFingerprint {
|
94
|
-
readonly id: string;
|
95
|
-
readonly name: string;
|
96
|
-
get(fingerPrint?: Uint8Array | string): Promise<KeyWithFingerPrint | undefined>;
|
97
|
-
upsert(key: string | Uint8Array, def?: boolean): Promise<Result<KeyUpsertResult>>;
|
98
|
-
asKeysItem(): Promise<KeysItem>;
|
99
|
-
}
|
100
|
-
export interface CryptoAction {
|
101
|
-
readonly ivLength: number;
|
102
|
-
readonly logger: Logger;
|
103
|
-
readonly crypto: CryptoRuntime;
|
104
|
-
readonly url: URI;
|
105
|
-
readonly key: KeysByFingerprint;
|
106
|
-
algo(iv?: Uint8Array): {
|
107
|
-
name: string;
|
108
|
-
iv: Uint8Array;
|
109
|
-
tagLength: number;
|
110
|
-
};
|
111
|
-
codec(iv?: Uint8Array, codecOpts?: Partial<CodecOpts>): AsyncBlockCodec<24, Uint8Array, IvKeyIdData>;
|
112
|
-
_decrypt(data: IvAndKeyAndBytes): Promise<Uint8Array>;
|
113
|
-
_encrypt(data: BytesAndKeyWithIv): Promise<Uint8Array>;
|
114
|
-
}
|
115
|
-
export interface StoreFactory {
|
116
|
-
encodeFile?: (blob: Blob) => Promise<{
|
117
|
-
cid: AnyLink;
|
118
|
-
blocks: AnyBlock[];
|
119
|
-
}>;
|
120
|
-
decodeFile?: (blocks: unknown, cid: AnyLink, meta: DocFileMeta) => Promise<File>;
|
121
|
-
}
|
122
|
-
export interface StoreUrls {
|
123
|
-
readonly meta: CoerceURI;
|
124
|
-
readonly car: CoerceURI;
|
125
|
-
readonly file: CoerceURI;
|
126
|
-
readonly wal: CoerceURI;
|
127
|
-
}
|
128
|
-
export interface StoreEnDeFile {
|
129
|
-
readonly encodeFile: (blob: Blob) => Promise<{
|
130
|
-
cid: AnyLink;
|
131
|
-
blocks: AnyBlock[];
|
132
|
-
}>;
|
133
|
-
readonly decodeFile: (blocks: unknown, cid: AnyLink, meta: DocFileMeta) => Promise<Result<File>>;
|
134
|
-
}
|
135
|
-
export interface StoreUrlsOpts {
|
136
|
-
readonly base?: CoerceURI;
|
137
|
-
readonly data?: Partial<StoreUrls>;
|
138
|
-
readonly idx?: Partial<StoreUrls>;
|
139
|
-
}
|
140
|
-
export interface StoreURIs {
|
141
|
-
readonly meta: URI;
|
142
|
-
readonly car: URI;
|
143
|
-
readonly file: URI;
|
144
|
-
readonly wal: URI;
|
145
|
-
}
|
146
|
-
export interface StoreURIRuntime {
|
147
|
-
readonly data: StoreURIs;
|
148
|
-
readonly idx: StoreURIs;
|
149
|
-
}
|
150
|
-
export interface UrlAndInterceptor {
|
151
|
-
readonly url: URI;
|
152
|
-
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
153
|
-
}
|
154
|
-
export interface StoreFactoryItem {
|
155
|
-
readonly byStore: GatewayUrls;
|
156
|
-
readonly loader: Loadable;
|
157
|
-
}
|
158
|
-
export interface StoreRuntime {
|
159
|
-
makeStores(sfi: StoreFactoryItem): Promise<DataAndMetaAndWalStore>;
|
160
|
-
encodeFile(blob: Blob): Promise<{
|
161
|
-
cid: AnyLink;
|
162
|
-
blocks: AnyBlock[];
|
163
|
-
}>;
|
164
|
-
decodeFile(blocks: unknown, cid: AnyLink, meta: DocFileMeta): Promise<Result<File>>;
|
165
|
-
}
|
166
|
-
export interface CommitOpts {
|
167
|
-
readonly noLoader?: boolean;
|
168
|
-
readonly compact?: boolean;
|
169
|
-
}
|
170
|
-
export interface WriteableDataAndMetaStore {
|
171
|
-
file: FileStore;
|
172
|
-
car: CarStore;
|
173
|
-
meta: MetaStore;
|
174
|
-
}
|
175
|
-
export type DataAndMetaStore = Readonly<WriteableDataAndMetaStore>;
|
176
|
-
export interface WriteableDataAndMetaAndWalStore extends WriteableDataAndMetaStore {
|
177
|
-
wal?: WALStore;
|
178
|
-
}
|
179
|
-
export type DataAndMetaAndWalStore = Readonly<WriteableDataAndMetaAndWalStore>;
|
180
|
-
export type LocalDataAndMetaAndWalStore = Readonly<Omit<WriteableDataAndMetaAndWalStore, "wal">> & {
|
181
|
-
readonly wal: WALStore;
|
182
|
-
};
|
183
|
-
export interface DbMeta {
|
184
|
-
readonly cars: CarGroup;
|
185
|
-
}
|
186
|
-
export type LoadHandler = (dbMetas: DbMeta[]) => Promise<void>;
|
187
|
-
export interface RefLoadable {
|
188
|
-
readonly loader: Loadable;
|
189
|
-
}
|
190
|
-
export interface RefBlockstore {
|
191
|
-
readonly blockstore: RefLoadable;
|
192
|
-
}
|
193
|
-
export interface Connection {
|
194
|
-
loaded(): Future<void>;
|
195
|
-
readonly context: Context;
|
196
|
-
connectStorage(ref: RefLoadable | RefBlockstore): void;
|
197
|
-
}
|
198
|
-
export interface BaseStore {
|
199
|
-
readonly storeType: StoreType;
|
200
|
-
readonly realGateway: SerdeGateway;
|
201
|
-
readonly logger: Logger;
|
202
|
-
url(): URI;
|
203
|
-
keyedCrypto(): Promise<CryptoAction>;
|
204
|
-
close(): Promise<Result<void>>;
|
205
|
-
destroy(): Promise<Result<void>>;
|
206
|
-
readonly ready?: () => Promise<void>;
|
207
|
-
start(dam: DataAndMetaStore): Promise<Result<URI>>;
|
208
|
-
}
|
209
|
-
export interface DbMetaEvent {
|
210
|
-
readonly eventCid: CarClockLink;
|
211
|
-
readonly parents: CarClockHead;
|
212
|
-
readonly dbMeta: DbMeta;
|
213
|
-
}
|
214
|
-
export declare function DbMetaEventEqual(a: DbMetaEvent, b: DbMetaEvent): boolean;
|
215
|
-
export declare function DbMetaEventsEqual(a: DbMetaEvent[], b: DbMetaEvent[]): boolean;
|
216
|
-
export interface MetaStore extends BaseStore {
|
217
|
-
readonly storeType: "meta";
|
218
|
-
load(branch?: string): Promise<DbMeta[] | Falsy>;
|
219
|
-
save(meta: DbMeta, branch?: string): Promise<Result<void>>;
|
220
|
-
}
|
221
|
-
export interface DataSaveOpts {
|
222
|
-
readonly public: boolean;
|
223
|
-
}
|
224
|
-
export interface CarStore extends BaseStore {
|
225
|
-
readonly storeType: "car";
|
226
|
-
load(cid: AnyLink): Promise<AnyBlock>;
|
227
|
-
save(car: AnyBlock, opts?: DataSaveOpts): Promise<void>;
|
228
|
-
remove(cid: AnyLink): Promise<Result<void>>;
|
229
|
-
}
|
230
|
-
export interface FileStore extends BaseStore {
|
231
|
-
readonly storeType: "file";
|
232
|
-
load(cid: AnyLink): Promise<AnyBlock>;
|
233
|
-
save(car: AnyBlock, opts?: DataSaveOpts): Promise<void>;
|
234
|
-
remove(cid: AnyLink): Promise<Result<void>>;
|
235
|
-
}
|
236
|
-
export interface WALState {
|
237
|
-
readonly operations: DbMeta[];
|
238
|
-
readonly noLoaderOps: DbMeta[];
|
239
|
-
readonly fileOperations: {
|
240
|
-
readonly cid: AnyLink;
|
241
|
-
readonly public: boolean;
|
242
|
-
}[];
|
243
|
-
}
|
244
|
-
export interface WALStore extends BaseStore {
|
245
|
-
readonly storeType: "wal";
|
246
|
-
ready(): Promise<void>;
|
247
|
-
readonly processing?: Promise<void> | undefined;
|
248
|
-
readonly processQueue: CommitQueue<void>;
|
249
|
-
process(): Promise<void>;
|
250
|
-
enqueue(dbMeta: DbMeta, opts: CommitOpts): Promise<void>;
|
251
|
-
enqueueFile(fileCid: AnyLink): Promise<void>;
|
252
|
-
load(): Promise<WALState | Falsy>;
|
253
|
-
save(state: WALState): Promise<void>;
|
254
|
-
}
|
255
|
-
export type CompactFetcher = BlockFetcher & {
|
256
|
-
readonly loggedBlocks: CarTransaction;
|
257
|
-
};
|
258
|
-
export type CompactFn = (blocks: CompactFetcher) => Promise<TransactionMeta>;
|
259
|
-
export interface StoreRuntimeUrls {
|
260
|
-
readonly meta: URI;
|
261
|
-
readonly data: URI;
|
262
|
-
readonly wal: URI;
|
263
|
-
}
|
264
|
-
export interface BlockstoreParams {
|
265
|
-
readonly logger: Logger;
|
266
|
-
readonly applyMeta: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
267
|
-
readonly compact: CompactFn;
|
268
|
-
readonly autoCompact: number;
|
269
|
-
readonly crypto: CryptoRuntime;
|
270
|
-
readonly public: boolean;
|
271
|
-
readonly meta: DbMeta;
|
272
|
-
readonly threshold: number;
|
273
|
-
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
274
|
-
readonly storeEnDeFile: Partial<StoreEnDeFile>;
|
275
|
-
readonly keyBag: KeyBagRuntime;
|
276
|
-
readonly storeUrls: StoreURIs;
|
277
|
-
readonly storeRuntime: StoreRuntime;
|
278
|
-
readonly taskManager: TaskManagerParams;
|
279
|
-
}
|
280
|
-
export type BlockstoreOpts = Partial<BlockstoreParams> & {
|
281
|
-
readonly keyBag: KeyBagRuntime;
|
282
|
-
readonly storeUrls: StoreURIs;
|
283
|
-
readonly storeRuntime: StoreRuntime;
|
284
|
-
};
|
285
|
-
export interface BlockstoreRuntime {
|
286
|
-
readonly logger: Logger;
|
287
|
-
readonly applyMeta: (meta: TransactionMeta, snap?: boolean) => Promise<void>;
|
288
|
-
readonly compact: CompactFn;
|
289
|
-
readonly autoCompact: number;
|
290
|
-
readonly crypto: CryptoRuntime;
|
291
|
-
readonly storeRuntime: StoreRuntime;
|
292
|
-
readonly keyBag: KeyBagRuntime;
|
293
|
-
readonly storeUrls: StoreURIs;
|
294
|
-
readonly gatewayInterceptor?: SerdeGatewayInterceptor;
|
295
|
-
readonly taskManager: TaskManagerParams;
|
296
|
-
readonly meta?: DbMeta;
|
297
|
-
readonly threshold: number;
|
298
|
-
}
|
299
|
-
export type LocalActiveStore = Omit<ActiveStore, "active"> & {
|
300
|
-
readonly active: LocalDataAndMetaAndWalStore;
|
301
|
-
};
|
302
|
-
export interface AttachedStores {
|
303
|
-
local(): LocalActiveStore;
|
304
|
-
forRemotes(actionFn: (store: ActiveStore) => Promise<unknown>): Promise<void>;
|
305
|
-
remotes(): ActiveStore[];
|
306
|
-
activate(store: DataAndMetaStore | CoerceURI): ActiveStore;
|
307
|
-
attach(attached: Attachable): Promise<Attached>;
|
308
|
-
detach(): Promise<void>;
|
309
|
-
}
|
310
|
-
export interface BaseAttachedStores {
|
311
|
-
local(): BaseStore;
|
312
|
-
remotes(): BaseStore[];
|
313
|
-
}
|
314
|
-
export interface CarAttachedStores extends BaseAttachedStores {
|
315
|
-
local(): CarStore;
|
316
|
-
remotes(): CarStore[];
|
317
|
-
}
|
318
|
-
export declare abstract class BaseActiveStore {
|
319
|
-
abstract readonly ref: ActiveStore;
|
320
|
-
abstract readonly active: BaseStore;
|
321
|
-
abstract local(): BaseStore;
|
322
|
-
abstract remotes(): BaseStore[];
|
323
|
-
protected abstract readonly xattached: BaseAttachedStores;
|
324
|
-
}
|
325
|
-
export interface FileAttachedStores extends BaseAttachedStores {
|
326
|
-
local(): FileStore;
|
327
|
-
remotes(): FileStore[];
|
328
|
-
}
|
329
|
-
export declare abstract class CarActiveStore extends BaseActiveStore {
|
330
|
-
protected abstract readonly xattached: CarAttachedStores;
|
331
|
-
abstract local(): CarStore;
|
332
|
-
abstract remotes(): CarStore[];
|
333
|
-
}
|
334
|
-
export declare abstract class FileActiveStore extends BaseActiveStore {
|
335
|
-
protected abstract readonly xattached: FileAttachedStores;
|
336
|
-
abstract local(): FileStore;
|
337
|
-
abstract remotes(): FileStore[];
|
338
|
-
}
|
339
|
-
export type CIDActiveStore = CarActiveStore | FileActiveStore;
|
340
|
-
export interface MetaAttachedStores extends BaseAttachedStores {
|
341
|
-
local(): MetaStore;
|
342
|
-
remotes(): MetaStore[];
|
343
|
-
}
|
344
|
-
export declare abstract class MetaActiveStore extends BaseActiveStore {
|
345
|
-
protected abstract readonly xattached: MetaAttachedStores;
|
346
|
-
abstract local(): MetaStore;
|
347
|
-
abstract remotes(): MetaStore[];
|
348
|
-
}
|
349
|
-
export interface WALAttachedStores extends BaseAttachedStores {
|
350
|
-
local(): WALStore;
|
351
|
-
remotes(): WALStore[];
|
352
|
-
}
|
353
|
-
export declare abstract class WALActiveStore extends BaseActiveStore {
|
354
|
-
protected abstract readonly xattached: WALAttachedStores;
|
355
|
-
abstract local(): WALStore;
|
356
|
-
abstract remotes(): WALStore[];
|
357
|
-
}
|
358
|
-
export interface ActiveStore {
|
359
|
-
readonly active: DataAndMetaAndWalStore;
|
360
|
-
baseStores(): BaseStore[];
|
361
|
-
carStore(): CarActiveStore;
|
362
|
-
fileStore(): FileActiveStore;
|
363
|
-
metaStore(): MetaActiveStore;
|
364
|
-
walStore(): WALActiveStore;
|
365
|
-
local(): LocalActiveStore;
|
366
|
-
remotes(): ActiveStore[];
|
367
|
-
readonly xattached: AttachedStores;
|
368
|
-
}
|
369
|
-
export interface CarCacheItem {
|
370
|
-
readonly type: "car" | "block";
|
371
|
-
readonly cid: AnyLink;
|
372
|
-
readonly blocks: AnyBlock[];
|
373
|
-
readonly roots: CID[];
|
374
|
-
}
|
375
|
-
export interface Loadable {
|
376
|
-
readonly sthis: SuperThis;
|
377
|
-
readonly ebOpts: BlockstoreRuntime;
|
378
|
-
readonly carLog: CarLog;
|
379
|
-
readonly attachedStores: AttachedStores;
|
380
|
-
attach(attached: Attachable): Promise<Attached>;
|
381
|
-
readonly taskManager: TaskManager;
|
382
|
-
ready(): Promise<void>;
|
383
|
-
close(): Promise<void>;
|
384
|
-
keyBag(): Promise<KeyBag>;
|
385
|
-
handleDbMetasFromStore(metas: DbMeta[], store: ActiveStore): Promise<void>;
|
386
|
-
commit<T = TransactionMeta>(t: CarTransaction, done: T, opts: CommitOpts): Promise<CarGroup>;
|
387
|
-
destroy(): Promise<void>;
|
388
|
-
getBlock(cid: AnyLink, store: ActiveStore): Promise<AnyBlock | Falsy>;
|
389
|
-
loadFileCar(cid: AnyLink, store: ActiveStore): Promise<CarCacheItem>;
|
390
|
-
loadCar(cid: AnyLink, store: ActiveStore): Promise<CarCacheItem>;
|
391
|
-
commitFiles(t: CarTransaction, done: TransactionMeta): Promise<CarGroup>;
|
392
|
-
entries(cache?: boolean): AsyncIterableIterator<AnyBlock>;
|
393
|
-
}
|
394
|
-
export interface DbMetaBinary {
|
395
|
-
readonly dbMeta: Uint8Array;
|
396
|
-
}
|
397
|
-
export type DbMetaEventBlock = EventBlock<DbMetaBinary>;
|
398
|
-
export type CarClockLink = Link<DbMetaEventBlock, number, number, Version>;
|
399
|
-
export type CarClockHead = CarClockLink[];
|
400
|
-
//# sourceMappingURL=types.d.ts.map
|