@fireproof/core 0.21.0-dev-preview-7 → 0.22.0-dev-preview
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/index.d.ts +2 -16
- package/index.js +2 -15
- package/index.js.map +1 -1
- package/index.ts +2 -0
- package/package.json +11 -69
- package/tsconfig.json +18 -0
- package/README.md +0 -269
- 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 -19
- package/blockstore/attachable-store.d.ts.map +0 -1
- package/blockstore/attachable-store.js +0 -316
- package/blockstore/attachable-store.js.map +0 -1
- package/blockstore/commit-queue.d.ts +0 -17
- package/blockstore/commit-queue.d.ts.map +0 -1
- package/blockstore/commit-queue.js +0 -60
- 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 -95
- 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 -17
- package/blockstore/index.d.ts.map +0 -1
- package/blockstore/index.js +0 -17
- 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 -10
- package/blockstore/loader-helpers.d.ts.map +0 -1
- package/blockstore/loader-helpers.js +0 -115
- package/blockstore/loader-helpers.js.map +0 -1
- package/blockstore/loader.d.ts +0 -62
- package/blockstore/loader.d.ts.map +0 -1
- package/blockstore/loader.js +0 -523
- 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 -125
- 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 -104
- 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 -86
- package/blockstore/store.d.ts.map +0 -1
- package/blockstore/store.js +0 -437
- 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 -62
- package/blockstore/transaction.d.ts.map +0 -1
- package/blockstore/transaction.js +0 -256
- package/blockstore/transaction.js.map +0 -1
- package/blockstore/types.d.ts +0 -508
- package/blockstore/types.d.ts.map +0 -1
- package/blockstore/types.js +0 -83
- 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 -26645
- package/crdt-clock.d.ts +0 -26
- package/crdt-clock.d.ts.map +0 -1
- package/crdt-clock.js +0 -133
- package/crdt-clock.js.map +0 -1
- package/crdt-helpers.d.ts +0 -19
- package/crdt-helpers.d.ts.map +0 -1
- package/crdt-helpers.js +0 -332
- package/crdt-helpers.js.map +0 -1
- package/crdt.d.ts +0 -41
- package/crdt.d.ts.map +0 -1
- package/crdt.js +0 -164
- package/crdt.js.map +0 -1
- package/database.d.ts +0 -33
- package/database.d.ts.map +0 -1
- package/database.js +0 -132
- package/database.js.map +0 -1
- package/deno.json +0 -20
- package/index.d.ts.map +0 -1
- package/indexer-helpers.d.ts +0 -68
- package/indexer-helpers.d.ts.map +0 -1
- package/indexer-helpers.js +0 -157
- package/indexer-helpers.js.map +0 -1
- package/indexer.d.ts +0 -24
- package/indexer.d.ts.map +0 -1
- package/indexer.js +0 -239
- package/indexer.js.map +0 -1
- package/ledger.d.ts +0 -56
- package/ledger.d.ts.map +0 -1
- package/ledger.js +0 -237
- package/ledger.js.map +0 -1
- package/protocols/cloud/http-connection.d.ts +0 -26
- package/protocols/cloud/http-connection.d.ts.map +0 -1
- package/protocols/cloud/http-connection.js +0 -154
- 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 -310
- package/protocols/cloud/msg-types.d.ts.map +0 -1
- package/protocols/cloud/msg-types.js +0 -299
- package/protocols/cloud/msg-types.js.map +0 -1
- package/protocols/cloud/msger.d.ts +0 -94
- package/protocols/cloud/msger.d.ts.map +0 -1
- package/protocols/cloud/msger.js +0 -319
- package/protocols/cloud/msger.js.map +0 -1
- package/protocols/cloud/ws-connection.d.ts +0 -40
- package/protocols/cloud/ws-connection.d.ts.map +0 -1
- package/protocols/cloud/ws-connection.js +0 -205
- package/protocols/cloud/ws-connection.js.map +0 -1
- package/protocols/dashboard/index.d.ts +0 -4
- package/protocols/dashboard/index.d.ts.map +0 -1
- package/protocols/dashboard/index.js +0 -4
- package/protocols/dashboard/index.js.map +0 -1
- package/protocols/dashboard/msg-api.d.ts +0 -11
- package/protocols/dashboard/msg-api.d.ts.map +0 -1
- package/protocols/dashboard/msg-api.js +0 -55
- package/protocols/dashboard/msg-api.js.map +0 -1
- package/protocols/dashboard/msg-is.d.ts +0 -45
- package/protocols/dashboard/msg-is.d.ts.map +0 -1
- package/protocols/dashboard/msg-is.js +0 -63
- package/protocols/dashboard/msg-is.js.map +0 -1
- package/protocols/dashboard/msg-types.d.ts +0 -397
- package/protocols/dashboard/msg-types.d.ts.map +0 -1
- package/protocols/dashboard/msg-types.js +0 -4
- package/protocols/dashboard/msg-types.js.map +0 -1
- package/protocols/index.d.ts +0 -3
- package/protocols/index.d.ts.map +0 -1
- package/protocols/index.js +0 -3
- package/protocols/index.js.map +0 -1
- package/react/img-file.d.ts +0 -303
- package/react/img-file.d.ts.map +0 -1
- package/react/img-file.js +0 -92
- package/react/img-file.js.map +0 -1
- package/react/index.d.ts +0 -5
- package/react/index.d.ts.map +0 -1
- package/react/index.js +0 -5
- package/react/index.js.map +0 -1
- package/react/types.d.ts +0 -91
- 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 -25
- package/react/use-all-docs.js.map +0 -1
- package/react/use-attach.d.ts +0 -11
- package/react/use-attach.d.ts.map +0 -1
- package/react/use-attach.js +0 -169
- package/react/use-attach.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 -109
- 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 -20
- 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 -24
- package/react/use-live-query.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 -41
- package/runtime/gateways/cloud/gateway.d.ts.map +0 -1
- package/runtime/gateways/cloud/gateway.js +0 -514
- package/runtime/gateways/cloud/gateway.js.map +0 -1
- package/runtime/gateways/cloud/index.d.ts +0 -3
- package/runtime/gateways/cloud/index.d.ts.map +0 -1
- package/runtime/gateways/cloud/index.js +0 -3
- package/runtime/gateways/cloud/index.js.map +0 -1
- package/runtime/gateways/cloud/to-cloud.d.ts +0 -59
- package/runtime/gateways/cloud/to-cloud.d.ts.map +0 -1
- package/runtime/gateways/cloud/to-cloud.js +0 -175
- package/runtime/gateways/cloud/to-cloud.js.map +0 -1
- package/runtime/gateways/def-serde-gateway.d.ts +0 -18
- package/runtime/gateways/def-serde-gateway.d.ts.map +0 -1
- package/runtime/gateways/def-serde-gateway.js +0 -92
- 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 -52
- 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 -20
- package/runtime/gateways/file/key-bag-file.d.ts.map +0 -1
- package/runtime/gateways/file/key-bag-file.js +0 -52
- 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 -33
- 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 -16
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts.map +0 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js +0 -48
- 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 -73
- 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 -13
- package/runtime/key-bag-memory.d.ts.map +0 -1
- package/runtime/key-bag-memory.js +0 -30
- package/runtime/key-bag-memory.js.map +0 -1
- package/runtime/key-bag.d.ts +0 -88
- package/runtime/key-bag.d.ts.map +0 -1
- package/runtime/key-bag.js +0 -417
- 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 -108
- 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/tests/blockstore/fp-envelope.test.ts-off +0 -65
- package/tests/blockstore/fragment-gateway.test.ts-off +0 -106
- package/tests/blockstore/interceptor-gateway.test.ts +0 -254
- package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +0 -128
- package/tests/blockstore/keyed-crypto.test.ts +0 -376
- package/tests/blockstore/loader.test.ts +0 -298
- package/tests/blockstore/standalone.test.ts +0 -152
- package/tests/blockstore/store.test.ts +0 -192
- package/tests/blockstore/transaction.test.ts +0 -130
- package/tests/fireproof/all-gateway.test.ts +0 -461
- package/tests/fireproof/attachable.test.ts +0 -686
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +0 -324
- package/tests/fireproof/charwise-boolean.test.ts +0 -66
- package/tests/fireproof/crdt.test.ts +0 -570
- package/tests/fireproof/database.test.ts +0 -779
- package/tests/fireproof/deleted-docs-handling.test.ts +0 -111
- package/tests/fireproof/fireproof.test.fixture.ts +0 -133
- package/tests/fireproof/fireproof.test.ts +0 -777
- package/tests/fireproof/hello.test.ts +0 -74
- package/tests/fireproof/indexer.test.ts +0 -458
- package/tests/fireproof/multiple-ledger.test.ts +0 -65
- package/tests/fireproof/query-docs.test.ts +0 -116
- package/tests/fireproof/query-limit-issue.test.ts +0 -147
- package/tests/fireproof/query-property-inconsistency.test.ts +0 -89
- package/tests/fireproof/query-result-properties.test.ts +0 -42
- package/tests/fireproof/stable-cid.test.ts +0 -69
- package/tests/fireproof/utils.test.ts +0 -135
- package/tests/gateway/file/loader-config.test.ts +0 -307
- package/tests/gateway/indexeddb/loader-config.test.ts +0 -79
- package/tests/helpers.ts +0 -172
- package/tests/protocols/cloud/msger.test.ts +0 -548
- package/tests/react/img-file.test.tsx +0 -190
- package/tests/react/use-all-docs.test.tsx +0 -172
- package/tests/react/use-document-with-nonexistent-id.test.tsx +0 -96
- package/tests/react/use-fireproof-db-switch.test.tsx +0 -91
- package/tests/react/use-fireproof-stability.test.tsx +0 -145
- package/tests/react/use-fireproof.test.tsx +0 -645
- package/tests/runtime/fp-envelope-serialize.test.ts +0 -254
- package/tests/runtime/meta-key-hack.test.ts +0 -95
- package/tests/setup.file.ts +0 -1
- package/tests/setup.indexeddb.ts +0 -0
- package/tests/setup.memory.ts +0 -2
- package/tests/vitest.file.config.ts +0 -14
- package/tests/vitest.indexeddb.config.ts +0 -37
- package/tests/vitest.memory.config.ts +0 -25
- package/types.d.ts +0 -461
- package/types.d.ts.map +0 -1
- package/types.js +0 -60
- package/types.js.map +0 -1
- package/use-fireproof/iframe-strategy.d.ts +0 -14
- package/use-fireproof/iframe-strategy.d.ts.map +0 -1
- package/use-fireproof/iframe-strategy.js +0 -79
- package/use-fireproof/iframe-strategy.js.map +0 -1
- package/use-fireproof/index.d.ts +0 -14
- package/use-fireproof/index.d.ts.map +0 -1
- package/use-fireproof/index.js +0 -36
- package/use-fireproof/index.js.map +0 -1
- package/use-fireproof/redirect-strategy.d.ts +0 -15
- package/use-fireproof/redirect-strategy.d.ts.map +0 -1
- package/use-fireproof/redirect-strategy.js +0 -153
- package/use-fireproof/redirect-strategy.js.map +0 -1
- package/utils.d.ts +0 -48
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -406
- 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,779 +0,0 @@
|
|
1
|
-
import { URI } from "@adviser/cement";
|
2
|
-
import { buildBlobFiles, FileWithCid, mockSuperThis } from "../helpers.js";
|
3
|
-
import {
|
4
|
-
bs,
|
5
|
-
DocResponse,
|
6
|
-
DocFileMeta,
|
7
|
-
DocWithId,
|
8
|
-
DocFiles,
|
9
|
-
toStoreURIRuntime,
|
10
|
-
keyConfigOpts,
|
11
|
-
ensureSuperThis,
|
12
|
-
Database,
|
13
|
-
fireproof,
|
14
|
-
LedgerShell,
|
15
|
-
} from "@fireproof/core";
|
16
|
-
|
17
|
-
describe("basic Ledger", () => {
|
18
|
-
let db: Database;
|
19
|
-
const sthis = mockSuperThis();
|
20
|
-
afterEach(async () => {
|
21
|
-
await db.close();
|
22
|
-
await db.destroy();
|
23
|
-
});
|
24
|
-
beforeEach(async () => {
|
25
|
-
await sthis.start();
|
26
|
-
db = fireproof(undefined as unknown as string, {
|
27
|
-
logger: sthis.logger,
|
28
|
-
});
|
29
|
-
});
|
30
|
-
it("should put", async () => {
|
31
|
-
/** @type {Doc} */
|
32
|
-
const doc = { _id: "hello", value: "world" };
|
33
|
-
const ok = await db.put(doc);
|
34
|
-
expect(ok.id).toBe("hello");
|
35
|
-
});
|
36
|
-
it("get missing should throw", async () => {
|
37
|
-
const e = await db.get("missing").catch((e) => e);
|
38
|
-
expect(e.message).toMatch(/Not found/);
|
39
|
-
});
|
40
|
-
it("del missing should result in deleted state", async () => {
|
41
|
-
await db.del("missing");
|
42
|
-
|
43
|
-
const e = await db.get("missing").catch((e) => e);
|
44
|
-
expect(e.message).toMatch(/Not found/);
|
45
|
-
});
|
46
|
-
it("has no changes", async () => {
|
47
|
-
const { rows } = await db.changes([]);
|
48
|
-
expect(rows.length).toBe(0);
|
49
|
-
});
|
50
|
-
});
|
51
|
-
|
52
|
-
describe("basic Ledger with record", function () {
|
53
|
-
interface Doc {
|
54
|
-
readonly value: string;
|
55
|
-
}
|
56
|
-
let db: Database;
|
57
|
-
const sthis = ensureSuperThis();
|
58
|
-
afterEach(async () => {
|
59
|
-
await db.close();
|
60
|
-
await db.destroy();
|
61
|
-
});
|
62
|
-
beforeEach(async () => {
|
63
|
-
await sthis.start();
|
64
|
-
db = fireproof("factory-name");
|
65
|
-
const ok = await db.put<Doc>({ _id: "hello", value: "world" });
|
66
|
-
expect(ok.id).toBe("hello");
|
67
|
-
});
|
68
|
-
it("should get", async () => {
|
69
|
-
const doc = await db.get<Doc>("hello");
|
70
|
-
expect(doc).toBeTruthy();
|
71
|
-
expect(doc._id).toBe("hello");
|
72
|
-
expect(doc.value).toBe("world");
|
73
|
-
});
|
74
|
-
it("should update", async () => {
|
75
|
-
const ok = await db.put({ _id: "hello", value: "universe" });
|
76
|
-
expect(ok.id).toBe("hello");
|
77
|
-
const doc = await db.get<Doc>("hello");
|
78
|
-
expect(doc).toBeTruthy();
|
79
|
-
expect(doc._id).toBe("hello");
|
80
|
-
expect(doc.value).toBe("universe");
|
81
|
-
});
|
82
|
-
it("should del last record", async () => {
|
83
|
-
const ok = await db.del("hello");
|
84
|
-
expect(ok.id).toBe("hello");
|
85
|
-
|
86
|
-
const e = await db.get("hello").catch((e) => e);
|
87
|
-
expect(e.message).toMatch(/Not found/);
|
88
|
-
});
|
89
|
-
it("should remove as an alias for del", async () => {
|
90
|
-
const ok = await db.remove("hello");
|
91
|
-
expect(ok.id).toBe("hello");
|
92
|
-
|
93
|
-
const e = await db.get("hello").catch((e) => e);
|
94
|
-
expect(e.message).toMatch(/Not found/);
|
95
|
-
});
|
96
|
-
it("has changes", async () => {
|
97
|
-
const { rows } = await db.changes([]);
|
98
|
-
expect(rows.length).toBe(1);
|
99
|
-
expect(rows[0].key).toBe("hello");
|
100
|
-
expect(rows[0].value._id).toBe("hello");
|
101
|
-
});
|
102
|
-
it("is not persisted", async () => {
|
103
|
-
const db2 = fireproof("factory-name");
|
104
|
-
const { rows } = await db2.changes([]);
|
105
|
-
expect(rows.length).toBe(1);
|
106
|
-
// assert((db.ledger.ref === db2.ledger.ref, "should be the same ledger");
|
107
|
-
expect((db.ledger as LedgerShell).ref).toBe((db2.ledger as LedgerShell).ref);
|
108
|
-
const doc = await db2.get<Doc>("hello").catch((e) => e);
|
109
|
-
expect(doc.value).toBe("world");
|
110
|
-
await db2.close();
|
111
|
-
});
|
112
|
-
});
|
113
|
-
|
114
|
-
describe("named Ledger with record", function () {
|
115
|
-
interface Doc {
|
116
|
-
readonly value: string;
|
117
|
-
}
|
118
|
-
let db: Database;
|
119
|
-
const sthis = ensureSuperThis();
|
120
|
-
afterEach(async () => {
|
121
|
-
await db.close();
|
122
|
-
await db.destroy();
|
123
|
-
});
|
124
|
-
beforeEach(async () => {
|
125
|
-
await sthis.start();
|
126
|
-
db = fireproof("test-db-name");
|
127
|
-
/** @type {Doc} */
|
128
|
-
const doc = { _id: "hello", value: "world" };
|
129
|
-
const ok = await db.put(doc);
|
130
|
-
expect(ok.id).toBe("hello");
|
131
|
-
});
|
132
|
-
it("should get", async () => {
|
133
|
-
const doc = await db.get<Doc>("hello");
|
134
|
-
expect(doc).toBeTruthy();
|
135
|
-
expect(doc._id).toBe("hello");
|
136
|
-
expect(doc.value).toBe("world");
|
137
|
-
});
|
138
|
-
it("should update", async () => {
|
139
|
-
const ok = await db.put({ _id: "hello", value: "universe" });
|
140
|
-
expect(ok.id).toBe("hello");
|
141
|
-
const doc = await db.get<Doc>("hello");
|
142
|
-
expect(doc).toBeTruthy();
|
143
|
-
expect(doc._id).toBe("hello");
|
144
|
-
expect(doc.value).toBe("universe");
|
145
|
-
});
|
146
|
-
it("should update with Date value", async function () {
|
147
|
-
const date = new Date();
|
148
|
-
const dateStr = date.toISOString();
|
149
|
-
const ok = await db.put({ _id: "hello", value: date });
|
150
|
-
expect(ok.id).toBe("hello");
|
151
|
-
const doc = await db.get<Doc>("hello");
|
152
|
-
expect(doc).toBeTruthy();
|
153
|
-
expect(doc._id).toBe("hello");
|
154
|
-
expect(doc.value).toBe(dateStr);
|
155
|
-
expect(typeof doc.value).toBe("string");
|
156
|
-
const parsed = new Date(doc.value);
|
157
|
-
expect(parsed).toStrictEqual(date);
|
158
|
-
});
|
159
|
-
it("should update with null value", async function () {
|
160
|
-
const ok = await db.put({ _id: "hello", value: null });
|
161
|
-
expect(ok.id).toBe("hello");
|
162
|
-
const doc = await db.get<Doc>("hello");
|
163
|
-
expect(doc).toBeTruthy();
|
164
|
-
expect(doc._id).toBe("hello");
|
165
|
-
expect(doc.value).toBeNull();
|
166
|
-
expect(Object.keys(doc).includes("value")).toBeTruthy();
|
167
|
-
});
|
168
|
-
it("should update with undefined value", async function () {
|
169
|
-
const ok = await db.put({ _id: "hello", value: undefined });
|
170
|
-
expect(ok.id).toBe("hello");
|
171
|
-
const doc = await db.get<Doc>("hello");
|
172
|
-
expect(doc).toBeTruthy();
|
173
|
-
expect(doc._id).toBe("hello");
|
174
|
-
|
175
|
-
// expect 'value' not to be in keys
|
176
|
-
expect(Object.keys(doc).includes("value")).toBeFalsy();
|
177
|
-
});
|
178
|
-
it("should update with NaN value", async function () {
|
179
|
-
const ok = await db.put({ _id: "hello", value: NaN });
|
180
|
-
expect(ok.id).toBe("hello");
|
181
|
-
const doc = await db.get<Doc>("hello");
|
182
|
-
expect(doc).toBeTruthy();
|
183
|
-
expect(doc._id).toBe("hello");
|
184
|
-
|
185
|
-
// expect 'value' not to be in keys
|
186
|
-
expect(Object.keys(doc).includes("value")).toBeFalsy();
|
187
|
-
});
|
188
|
-
it("should not update with Infinity value", async function () {
|
189
|
-
const ok = await db.put({ _id: "hello", value: Infinity }).catch((e) => e);
|
190
|
-
expect(ok.message).toMatch(/IPLD/);
|
191
|
-
});
|
192
|
-
it("should not update with undefined array value", async function () {
|
193
|
-
const ok = await db.put({ _id: "hello", value: [undefined] }).catch((e) => e);
|
194
|
-
expect(ok.message).toMatch(/IPLD/);
|
195
|
-
});
|
196
|
-
it("should not update with NaN array value", async function () {
|
197
|
-
const ok = await db.put({ _id: "hello", value: [NaN] }).catch((e) => e);
|
198
|
-
expect(ok.message).toMatch(/IPLD/);
|
199
|
-
});
|
200
|
-
it("should del last record", async () => {
|
201
|
-
const ok = await db.del("hello");
|
202
|
-
expect(ok.id).toBe("hello");
|
203
|
-
|
204
|
-
const e = await db.get("hello").catch((e) => e);
|
205
|
-
expect(e.message).toMatch(/Not found/);
|
206
|
-
});
|
207
|
-
it("should remove as an alias for del", async () => {
|
208
|
-
const ok = await db.remove("hello");
|
209
|
-
expect(ok.id).toBe("hello");
|
210
|
-
|
211
|
-
const e = await db.get("hello").catch((e) => e);
|
212
|
-
expect(e.message).toMatch(/Not found/);
|
213
|
-
});
|
214
|
-
it("has changes", async () => {
|
215
|
-
const { rows } = await db.changes([]);
|
216
|
-
expect(rows.length).toBe(1);
|
217
|
-
expect(rows[0].key).toBe("hello");
|
218
|
-
expect(rows[0].value._id).toBe("hello");
|
219
|
-
});
|
220
|
-
it("should have a key", async () => {
|
221
|
-
const { rows } = await db.changes([]);
|
222
|
-
expect(rows.length).toBe(1);
|
223
|
-
const blocks = db.ledger.crdt.blockstore as bs.EncryptedBlockstore;
|
224
|
-
const loader = blocks.loader;
|
225
|
-
expect(loader).toBeTruthy();
|
226
|
-
await loader.ready();
|
227
|
-
|
228
|
-
// expect(loader.key?.length).toBe(64);
|
229
|
-
// expect(loader.keyId?.length).toBe(64);
|
230
|
-
// expect(loader.key).not.toBe(loader.keyId);
|
231
|
-
});
|
232
|
-
it("should work right with a sequence of changes", async () => {
|
233
|
-
const numDocs = 10;
|
234
|
-
for (let i = 0; i < numDocs; i++) {
|
235
|
-
const doc = { _id: `id-${i}`, hello: "world" };
|
236
|
-
const ok = await db.put(doc);
|
237
|
-
expect(ok.id).toBe(`id-${i}`);
|
238
|
-
}
|
239
|
-
const { rows } = await db.changes([]);
|
240
|
-
expect(rows.length).toBe(numDocs + 1);
|
241
|
-
|
242
|
-
const ok6 = await db.put({ _id: `id-${6}`, hello: "block" });
|
243
|
-
expect(ok6.id).toBe(`id-${6}`);
|
244
|
-
|
245
|
-
for (let i = 0; i < numDocs; i++) {
|
246
|
-
const id = `id-${i}`;
|
247
|
-
const doc = await db.get<{ hello: string }>(id);
|
248
|
-
expect(doc).toBeTruthy();
|
249
|
-
expect(doc._id).toBe(id);
|
250
|
-
expect(doc.hello.length).toBe(5);
|
251
|
-
}
|
252
|
-
|
253
|
-
const { rows: rows2 } = await db.changes([]);
|
254
|
-
expect(rows2.length).toBe(numDocs + 1);
|
255
|
-
|
256
|
-
const ok7 = await db.del(`id-${7}`);
|
257
|
-
expect(ok7.id).toBe(`id-${7}`);
|
258
|
-
|
259
|
-
const { rows: rows3 } = await db.changes([]);
|
260
|
-
expect(rows3.length).toBe(numDocs + 1);
|
261
|
-
expect(rows3[numDocs].key).toBe(`id-${7}`);
|
262
|
-
expect(rows3[numDocs].value._deleted).toBe(true);
|
263
|
-
|
264
|
-
// test limit
|
265
|
-
const { rows: rows4 } = await db.changes([], { limit: 5 });
|
266
|
-
expect(rows4.length).toBe(5);
|
267
|
-
});
|
268
|
-
|
269
|
-
it("should work right after compaction", async () => {
|
270
|
-
const numDocs = 10;
|
271
|
-
for (let i = 0; i < numDocs; i++) {
|
272
|
-
const doc = { _id: `id-${i}`, hello: "world" };
|
273
|
-
const ok = await db.put(doc);
|
274
|
-
expect(ok.id).toBe(`id-${i}`);
|
275
|
-
}
|
276
|
-
const { rows } = await db.changes([]);
|
277
|
-
expect(rows.length).toBe(numDocs + 1);
|
278
|
-
|
279
|
-
await db.compact();
|
280
|
-
|
281
|
-
const { rows: rows3 } = await db.changes([], { dirty: true });
|
282
|
-
expect(rows3.length).toBe(numDocs + 1);
|
283
|
-
|
284
|
-
const { rows: rows4 } = await db.changes([], { dirty: false });
|
285
|
-
expect(rows4.length).toBe(numDocs + 1);
|
286
|
-
});
|
287
|
-
});
|
288
|
-
|
289
|
-
// describe('basic Ledger parallel writes / public', function () {
|
290
|
-
// /** @type {Ledger} */
|
291
|
-
// let db
|
292
|
-
// const writes = []
|
293
|
-
// beforeEach(async () =>{
|
294
|
-
// await resetDirectory(dataDir, 'test-parallel-writes')
|
295
|
-
// db = new Ledger('test-parallel-writes', { public: true })
|
296
|
-
// /** @type {Doc} */
|
297
|
-
// for (let i = 0; i < 10; i++) {
|
298
|
-
// const doc = { _id: `id-${i}`, hello: 'world' }
|
299
|
-
// writes.push(db.put(doc))
|
300
|
-
// }
|
301
|
-
// await Promise.all(writes)
|
302
|
-
// })
|
303
|
-
|
304
|
-
describe("basic Ledger parallel writes / public ordered", () => {
|
305
|
-
let db: Database;
|
306
|
-
const writes: Promise<DocResponse>[] = [];
|
307
|
-
const sthis = mockSuperThis();
|
308
|
-
afterEach(async () => {
|
309
|
-
await db.close();
|
310
|
-
await db.destroy();
|
311
|
-
});
|
312
|
-
beforeEach(async () => {
|
313
|
-
await sthis.start();
|
314
|
-
db = fireproof("test-parallel-writes-ordered", { writeQueue: { chunkSize: 1 } });
|
315
|
-
for (let i = 0; i < 10; i++) {
|
316
|
-
const doc = { _id: `id-${i}`, hello: "world" };
|
317
|
-
writes.push(db.put(doc));
|
318
|
-
}
|
319
|
-
await Promise.all(writes);
|
320
|
-
});
|
321
|
-
|
322
|
-
it("should have one head", () => {
|
323
|
-
const crdt = db.ledger.crdt;
|
324
|
-
expect(crdt.clock.head.length).toBe(1);
|
325
|
-
});
|
326
|
-
|
327
|
-
it("has changes ordered", async () => {
|
328
|
-
const { rows, clock } = await db.changes([]);
|
329
|
-
expect(clock[0]).toBe(db.ledger.crdt.clock.head[0]);
|
330
|
-
expect(rows.length).toBe(10);
|
331
|
-
for (let i = 0; i < 10; i++) {
|
332
|
-
expect(rows[i].key).toBe("id-" + i);
|
333
|
-
expect(rows[i].clock).toBeTruthy();
|
334
|
-
}
|
335
|
-
});
|
336
|
-
});
|
337
|
-
|
338
|
-
describe("basic Ledger parallel writes / public", () => {
|
339
|
-
let db: Database;
|
340
|
-
const writes: Promise<DocResponse>[] = [];
|
341
|
-
const sthis = ensureSuperThis();
|
342
|
-
afterEach(async () => {
|
343
|
-
await db.close();
|
344
|
-
await db.destroy();
|
345
|
-
});
|
346
|
-
beforeEach(async () => {
|
347
|
-
await sthis.start();
|
348
|
-
db = fireproof("test-parallel-writes", { writeQueue: { chunkSize: 32 } });
|
349
|
-
for (let i = 0; i < 10; i++) {
|
350
|
-
const doc = { _id: `id-${i}`, hello: "world" };
|
351
|
-
writes.push(db.put(doc));
|
352
|
-
}
|
353
|
-
await Promise.all(writes);
|
354
|
-
});
|
355
|
-
it("should resolve to one head", async () => {
|
356
|
-
const crdt = db.ledger.crdt;
|
357
|
-
expect(crdt.clock.head.length).toBe(9);
|
358
|
-
await db.put({ _id: "id-10", hello: "world" });
|
359
|
-
expect(crdt.clock.head.length).toBe(1);
|
360
|
-
});
|
361
|
-
it("should write all", async () => {
|
362
|
-
for (let i = 0; i < 10; i++) {
|
363
|
-
const id = `id-${i}`;
|
364
|
-
const doc = await db.get<{ hello: string }>(id);
|
365
|
-
expect(doc).toBeTruthy();
|
366
|
-
expect(doc._id).toBe(id);
|
367
|
-
expect(doc.hello).toBe("world");
|
368
|
-
}
|
369
|
-
});
|
370
|
-
it("should del all", async () => {
|
371
|
-
for (let i = 0; i < 10; i++) {
|
372
|
-
const id = `id-${i}`;
|
373
|
-
const ok = await db.del(id);
|
374
|
-
expect(ok.id).toBe(id);
|
375
|
-
|
376
|
-
const e = await db.get(id).catch((e) => e);
|
377
|
-
expect(e.message).toMatch(/Not found/);
|
378
|
-
}
|
379
|
-
});
|
380
|
-
it("should delete all in parallel", async () => {
|
381
|
-
const deletes: Promise<DocResponse>[] = [];
|
382
|
-
for (let i = 0; i < 10; i++) {
|
383
|
-
const id = `id-${i}`;
|
384
|
-
deletes.push(db.del(id));
|
385
|
-
}
|
386
|
-
await Promise.all(deletes);
|
387
|
-
for (let i = 0; i < 10; i++) {
|
388
|
-
const id = `id-${i}`;
|
389
|
-
const e = await db.get(id).catch((e) => e);
|
390
|
-
expect(e.message).toMatch(/Not found/);
|
391
|
-
}
|
392
|
-
});
|
393
|
-
it("has changes not ordered", async () => {
|
394
|
-
const { rows, clock } = await db.changes([]);
|
395
|
-
expect(clock[0]).toBe(db.ledger.crdt.clock.head[0]);
|
396
|
-
expect(rows.length).toBe(10);
|
397
|
-
rows.sort((a, b) => a.key.localeCompare(b.key));
|
398
|
-
// console.log(rows);
|
399
|
-
for (let i = 0; i < 10; i++) {
|
400
|
-
expect(rows[i].key).toBe("id-" + i);
|
401
|
-
expect(rows[i].clock).toBeTruthy();
|
402
|
-
}
|
403
|
-
});
|
404
|
-
it("should not have a key", async () => {
|
405
|
-
const { rows } = await db.changes([]);
|
406
|
-
expect(rows.length).toBe(10);
|
407
|
-
// expect(db.opts.public).toBeTruthy();
|
408
|
-
// expect(db._crdt.opts.public).toBeTruthy();
|
409
|
-
const blocks = db.ledger.crdt.blockstore as bs.EncryptedBlockstore;
|
410
|
-
const loader = blocks.loader;
|
411
|
-
expect(loader).toBeTruthy();
|
412
|
-
await loader.ready();
|
413
|
-
// expect(loader.key).toBeUndefined();
|
414
|
-
// expect(loader.keyId).toBeUndefined();
|
415
|
-
});
|
416
|
-
});
|
417
|
-
|
418
|
-
describe("basic Ledger with subscription", function () {
|
419
|
-
let db: Database;
|
420
|
-
let didRun: number;
|
421
|
-
let unsubscribe: () => void;
|
422
|
-
let lastDoc: DocWithId<NonNullable<unknown>>;
|
423
|
-
let waitForSub: Promise<void>;
|
424
|
-
const sthis = ensureSuperThis();
|
425
|
-
afterEach(async () => {
|
426
|
-
await db.close();
|
427
|
-
await db.destroy();
|
428
|
-
});
|
429
|
-
beforeEach(async () => {
|
430
|
-
await sthis.start();
|
431
|
-
db = fireproof("factory-name");
|
432
|
-
didRun = 0;
|
433
|
-
waitForSub = new Promise((resolve) => {
|
434
|
-
unsubscribe = db.subscribe((docs) => {
|
435
|
-
lastDoc = docs[0];
|
436
|
-
// lastDoc = {_id: "ok"};
|
437
|
-
didRun++;
|
438
|
-
resolve();
|
439
|
-
}, true);
|
440
|
-
});
|
441
|
-
});
|
442
|
-
it("should run on put", async () => {
|
443
|
-
const all = await db.allDocs();
|
444
|
-
expect(all.rows.length).toBe(0);
|
445
|
-
const doc = { _id: "hello", message: "world" };
|
446
|
-
expect(didRun).toBe(0);
|
447
|
-
const ok = await db.put(doc);
|
448
|
-
await waitForSub;
|
449
|
-
expect(didRun).toBeTruthy();
|
450
|
-
expect(lastDoc).toBeTruthy();
|
451
|
-
expect(lastDoc._id).toBe("hello");
|
452
|
-
expect(ok.id).toBe("hello");
|
453
|
-
expect(didRun).toBe(1);
|
454
|
-
});
|
455
|
-
it("should unsubscribe", async () => {
|
456
|
-
unsubscribe();
|
457
|
-
const doc = { _id: "hello", message: "again" };
|
458
|
-
const ok = await db.put(doc);
|
459
|
-
expect(ok.id).toBe("hello");
|
460
|
-
expect(didRun).toBe(0);
|
461
|
-
});
|
462
|
-
});
|
463
|
-
|
464
|
-
describe("basic Ledger with no update subscription", function () {
|
465
|
-
let db: Database;
|
466
|
-
let didRun: number;
|
467
|
-
let unsubscribe: () => void;
|
468
|
-
// const sthis = ensureSuperThis();
|
469
|
-
afterEach(async () => {
|
470
|
-
await db.close();
|
471
|
-
await db.destroy();
|
472
|
-
});
|
473
|
-
beforeEach(async () => {
|
474
|
-
db = fireproof("factory-name");
|
475
|
-
didRun = 0;
|
476
|
-
unsubscribe = db.subscribe(() => {
|
477
|
-
didRun++;
|
478
|
-
});
|
479
|
-
});
|
480
|
-
it("xshould run on put", async function () {
|
481
|
-
const all = await db.allDocs();
|
482
|
-
expect(all.rows.length).toBe(0);
|
483
|
-
/** @type {Doc} */
|
484
|
-
const doc = { _id: "hello", message: "world" };
|
485
|
-
expect(didRun).toBe(0);
|
486
|
-
const ok = await db.put(doc);
|
487
|
-
expect(ok.id).toBe("hello");
|
488
|
-
expect(didRun).toBe(1);
|
489
|
-
}, 10000);
|
490
|
-
it("should unsubscribe", async () => {
|
491
|
-
unsubscribe();
|
492
|
-
const doc = { _id: "hello", message: "again" };
|
493
|
-
const ok = await db.put(doc);
|
494
|
-
expect(ok.id).toBe("hello");
|
495
|
-
expect(didRun).toBe(0);
|
496
|
-
});
|
497
|
-
});
|
498
|
-
|
499
|
-
describe("ledger with files input", () => {
|
500
|
-
let db: Database;
|
501
|
-
let imagefiles: FileWithCid[] = [];
|
502
|
-
let result: DocResponse;
|
503
|
-
const sthis = ensureSuperThis();
|
504
|
-
|
505
|
-
afterEach(async () => {
|
506
|
-
await db.close();
|
507
|
-
await db.destroy();
|
508
|
-
});
|
509
|
-
beforeEach(async () => {
|
510
|
-
await sthis.start();
|
511
|
-
imagefiles = await buildBlobFiles();
|
512
|
-
db = fireproof("fireproof-with-images");
|
513
|
-
const doc = {
|
514
|
-
_id: "images-main",
|
515
|
-
type: "files",
|
516
|
-
_files: {
|
517
|
-
one: imagefiles[0].file,
|
518
|
-
two: imagefiles[1].file,
|
519
|
-
},
|
520
|
-
};
|
521
|
-
result = await db.put(doc);
|
522
|
-
});
|
523
|
-
|
524
|
-
it("Should upload images", async () => {
|
525
|
-
expect(result.id).toBe("images-main");
|
526
|
-
});
|
527
|
-
|
528
|
-
it("Should fetch the images", async () => {
|
529
|
-
const doc = await db.get(result.id);
|
530
|
-
const files = doc._files as DocFiles;
|
531
|
-
expect(files).toBeTruthy();
|
532
|
-
const keys = Object.keys(files);
|
533
|
-
let fileMeta = files[keys[0]] as DocFileMeta;
|
534
|
-
expect(fileMeta).toBeTruthy();
|
535
|
-
expect(imagefiles[0].file.type).toBeTruthy();
|
536
|
-
expect(fileMeta.type).toBeTruthy();
|
537
|
-
expect(fileMeta.type).toBe(imagefiles[0].file.type);
|
538
|
-
expect(fileMeta.size).toBe(imagefiles[0].file.size);
|
539
|
-
expect(fileMeta.cid.toString()).toBe(imagefiles[0].cid);
|
540
|
-
expect(typeof fileMeta.file).toBe("function");
|
541
|
-
let file = (await fileMeta.file?.()) as File;
|
542
|
-
|
543
|
-
expect(file.type).toBe(imagefiles[0].file.type);
|
544
|
-
expect(file.size).toBe(imagefiles[0].file.size);
|
545
|
-
// expect(file.name).toBe('image.jpg') // see https://github.com/fireproof-storage/fireproof/issues/70
|
546
|
-
|
547
|
-
fileMeta = files[keys[1]] as DocFileMeta;
|
548
|
-
expect(fileMeta.type).toBe(imagefiles[1].file.type);
|
549
|
-
expect(fileMeta.size).toBe(imagefiles[1].file.size);
|
550
|
-
expect(fileMeta.cid.toString()).toBe(imagefiles[1].cid);
|
551
|
-
expect(typeof fileMeta.file).toBe("function");
|
552
|
-
file = (await fileMeta.file?.()) as File;
|
553
|
-
|
554
|
-
expect(file.type).toBe(imagefiles[1].file.type);
|
555
|
-
expect(file.size).toBe(imagefiles[1].file.size);
|
556
|
-
// expect(file.name).toBe('fireproof.png') // see https://github.com/fireproof-storage/fireproof/issues/70
|
557
|
-
});
|
558
|
-
|
559
|
-
it("should preserve lastModified timestamp", async () => {
|
560
|
-
// Create a custom timestamp
|
561
|
-
const customTimestamp = Date.now() - 86400000; // 1 day ago
|
562
|
-
|
563
|
-
// Create a new file with the custom timestamp
|
564
|
-
const blob = new Blob(["test content"], { type: "text/plain" });
|
565
|
-
const file = new File([blob], "test.txt", {
|
566
|
-
type: "text/plain",
|
567
|
-
lastModified: customTimestamp,
|
568
|
-
});
|
569
|
-
|
570
|
-
// Store the file in the database
|
571
|
-
const newDoc = {
|
572
|
-
_id: "test-timestamp",
|
573
|
-
type: "files",
|
574
|
-
_files: {
|
575
|
-
test: file,
|
576
|
-
},
|
577
|
-
};
|
578
|
-
|
579
|
-
await db.put(newDoc);
|
580
|
-
|
581
|
-
// Retrieve the file from the database
|
582
|
-
const retrievedDoc = await db.get("test-timestamp");
|
583
|
-
const files = retrievedDoc._files as DocFiles;
|
584
|
-
const fileMeta = files.test as DocFileMeta;
|
585
|
-
|
586
|
-
// Verify the file has the correct metadata
|
587
|
-
expect(fileMeta).toBeTruthy();
|
588
|
-
expect(fileMeta.type).toBe("text/plain");
|
589
|
-
expect(typeof fileMeta.file).toBe("function");
|
590
|
-
|
591
|
-
// Get the actual file
|
592
|
-
const retrievedFile = (await fileMeta.file?.()) as File;
|
593
|
-
|
594
|
-
// Check if lastModified is preserved
|
595
|
-
expect(retrievedFile.lastModified).toBe(customTimestamp);
|
596
|
-
});
|
597
|
-
|
598
|
-
it("should update the file document data without changing the files", async () => {
|
599
|
-
interface Doc {
|
600
|
-
type: string;
|
601
|
-
}
|
602
|
-
const doc = await db.get<Doc>(result.id);
|
603
|
-
let files = doc._files || {};
|
604
|
-
let keys = Object.keys(files);
|
605
|
-
let fileMeta = files[keys[0]] as DocFileMeta;
|
606
|
-
expect(fileMeta.type).toBe(imagefiles[0].file.type);
|
607
|
-
expect(fileMeta.size).toBe(imagefiles[0].file.size);
|
608
|
-
expect(fileMeta.cid.toString()).toBe(imagefiles[0].cid);
|
609
|
-
expect(typeof fileMeta.file).toBe("function");
|
610
|
-
let file = (await fileMeta.file?.()) as File;
|
611
|
-
|
612
|
-
expect(file.type).toBe(imagefiles[0].file.type);
|
613
|
-
expect(file.size).toBe(imagefiles[0].file.size);
|
614
|
-
|
615
|
-
doc.type = "images";
|
616
|
-
const r2 = await db.put(doc);
|
617
|
-
expect(r2.id).toBe("images-main");
|
618
|
-
const readDoc = await db.get<Doc>(r2.id);
|
619
|
-
expect(readDoc.type).toBe("images");
|
620
|
-
files = readDoc._files || {};
|
621
|
-
keys = Object.keys(files);
|
622
|
-
fileMeta = files[keys[0]] as DocFileMeta;
|
623
|
-
expect(fileMeta.type).toBe(imagefiles[0].file.type);
|
624
|
-
expect(fileMeta.size).toBe(imagefiles[0].file.size);
|
625
|
-
expect(fileMeta.cid.toString()).toBe(imagefiles[0].cid);
|
626
|
-
expect(typeof fileMeta.file).toBe("function");
|
627
|
-
file = (await fileMeta.file?.()) as File;
|
628
|
-
|
629
|
-
expect(file.type).toBe(imagefiles[0].file.type);
|
630
|
-
expect(file.size).toBe(imagefiles[0].file.size);
|
631
|
-
}, 1000000);
|
632
|
-
});
|
633
|
-
|
634
|
-
describe("StoreURIRuntime", () => {
|
635
|
-
const sthis = mockSuperThis();
|
636
|
-
let safeEnv: string | undefined;
|
637
|
-
let unreg: () => void;
|
638
|
-
beforeEach(async () => {
|
639
|
-
await sthis.start();
|
640
|
-
safeEnv = sthis.env.get("FP_STORAGE_URL");
|
641
|
-
sthis.env.set("FP_STORAGE_URL", "my://bla/storage");
|
642
|
-
// console.log(">>>>>>>>>>", bs, bs.registerStoreProtocol)
|
643
|
-
unreg = bs.registerStoreProtocol({
|
644
|
-
protocol: "murks",
|
645
|
-
isDefault: true,
|
646
|
-
defaultURI: function (): URI {
|
647
|
-
return URI.from("murks://fp");
|
648
|
-
},
|
649
|
-
gateway: function (): Promise<bs.Gateway> {
|
650
|
-
throw new Error("Function not implemented.");
|
651
|
-
},
|
652
|
-
});
|
653
|
-
});
|
654
|
-
afterEach(() => {
|
655
|
-
sthis.env.set("FP_STORAGE_URL", safeEnv);
|
656
|
-
unreg();
|
657
|
-
});
|
658
|
-
it("default toStoreURIRuntime", () => {
|
659
|
-
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis, "test")))).toEqual({
|
660
|
-
data: {
|
661
|
-
car: "my://bla/storage?name=test&store=car&storekey=%40test-data%40&suffix=.car&urlGen=fromEnv",
|
662
|
-
file: "my://bla/storage?name=test&store=file&storekey=%40test-data%40&urlGen=fromEnv",
|
663
|
-
meta: "my://bla/storage?name=test&store=meta&storekey=%40test-meta%40&urlGen=fromEnv",
|
664
|
-
wal: "my://bla/storage?name=test&store=wal&storekey=%40test-wal%40&urlGen=fromEnv",
|
665
|
-
},
|
666
|
-
idx: {
|
667
|
-
car: "my://bla/storage?index=idx&name=test&store=car&storekey=%40test-data-idx%40&suffix=.car&urlGen=fromEnv",
|
668
|
-
file: "my://bla/storage?index=idx&name=test&store=file&storekey=%40test-data-idx%40&urlGen=fromEnv",
|
669
|
-
meta: "my://bla/storage?index=idx&name=test&store=meta&storekey=%40test-meta-idx%40&urlGen=fromEnv",
|
670
|
-
wal: "my://bla/storage?index=idx&name=test&store=wal&storekey=%40test-wal-idx%40&urlGen=fromEnv",
|
671
|
-
},
|
672
|
-
});
|
673
|
-
// keyConfigOpts(sthis: SuperThis, name: string, opts?: ConfigOpts): string {
|
674
|
-
});
|
675
|
-
it("no name toStoreURIRuntime(not more)", () => {
|
676
|
-
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis, "gogo")))).toEqual({
|
677
|
-
data: {
|
678
|
-
car: "my://bla/storage?name=gogo&store=car&storekey=%40gogo-data%40&suffix=.car&urlGen=fromEnv",
|
679
|
-
file: "my://bla/storage?name=gogo&store=file&storekey=%40gogo-data%40&urlGen=fromEnv",
|
680
|
-
meta: "my://bla/storage?name=gogo&store=meta&storekey=%40gogo-meta%40&urlGen=fromEnv",
|
681
|
-
wal: "my://bla/storage?name=gogo&store=wal&storekey=%40gogo-wal%40&urlGen=fromEnv",
|
682
|
-
},
|
683
|
-
idx: {
|
684
|
-
car: "my://bla/storage?index=idx&name=gogo&store=car&storekey=%40gogo-data-idx%40&suffix=.car&urlGen=fromEnv",
|
685
|
-
file: "my://bla/storage?index=idx&name=gogo&store=file&storekey=%40gogo-data-idx%40&urlGen=fromEnv",
|
686
|
-
meta: "my://bla/storage?index=idx&name=gogo&store=meta&storekey=%40gogo-meta-idx%40&urlGen=fromEnv",
|
687
|
-
wal: "my://bla/storage?index=idx&name=gogo&store=wal&storekey=%40gogo-wal-idx%40&urlGen=fromEnv",
|
688
|
-
},
|
689
|
-
});
|
690
|
-
});
|
691
|
-
|
692
|
-
it("set toStoreURIRuntime", () => {
|
693
|
-
expect(
|
694
|
-
JSON.parse(
|
695
|
-
JSON.stringify(
|
696
|
-
toStoreURIRuntime(sthis, "xxx", {
|
697
|
-
base: "my://storage-base",
|
698
|
-
data: {
|
699
|
-
car: "my://storage-data?name=yyy",
|
700
|
-
meta: "my://storage-meta",
|
701
|
-
},
|
702
|
-
idx: {
|
703
|
-
car: "my://storage-idx-data?name=yyy&index=bla",
|
704
|
-
meta: "my://storage-idx-meta",
|
705
|
-
},
|
706
|
-
}),
|
707
|
-
),
|
708
|
-
),
|
709
|
-
).toEqual({
|
710
|
-
data: {
|
711
|
-
car: "my://storage-data?name=yyy&store=car&storekey=%40yyy-data%40&suffix=.car",
|
712
|
-
file: "my://storage-data?name=yyy&store=file&storekey=%40yyy-data%40",
|
713
|
-
meta: "my://storage-meta?name=xxx&store=meta&storekey=%40xxx-meta%40",
|
714
|
-
wal: "my://storage-base?name=xxx&store=wal&storekey=%40xxx-wal%40",
|
715
|
-
},
|
716
|
-
idx: {
|
717
|
-
car: "my://storage-idx-data?index=bla&name=yyy&store=car&storekey=%40yyy-data-idx%40&suffix=.car",
|
718
|
-
file: "my://storage-idx-data?index=bla&name=yyy&store=file&storekey=%40yyy-data-idx%40",
|
719
|
-
meta: "my://storage-idx-meta?index=idx&name=xxx&store=meta&storekey=%40xxx-meta-idx%40",
|
720
|
-
wal: "my://storage-base?index=idx&name=xxx&store=wal&storekey=%40xxx-wal-idx%40",
|
721
|
-
},
|
722
|
-
});
|
723
|
-
});
|
724
|
-
|
725
|
-
it("default-reg toStoreURIRuntime", () => {
|
726
|
-
sthis.env.delete("FP_STORAGE_URL");
|
727
|
-
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis, "maxi")))).toEqual({
|
728
|
-
data: {
|
729
|
-
car: "murks://fp?name=maxi&store=car&storekey=%40maxi-data%40&suffix=.car&urlGen=default",
|
730
|
-
file: "murks://fp?name=maxi&store=file&storekey=%40maxi-data%40&urlGen=default",
|
731
|
-
meta: "murks://fp?name=maxi&store=meta&storekey=%40maxi-meta%40&urlGen=default",
|
732
|
-
wal: "murks://fp?name=maxi&store=wal&storekey=%40maxi-wal%40&urlGen=default",
|
733
|
-
},
|
734
|
-
idx: {
|
735
|
-
car: "murks://fp?index=idx&name=maxi&store=car&storekey=%40maxi-data-idx%40&suffix=.car&urlGen=default",
|
736
|
-
file: "murks://fp?index=idx&name=maxi&store=file&storekey=%40maxi-data-idx%40&urlGen=default",
|
737
|
-
meta: "murks://fp?index=idx&name=maxi&store=meta&storekey=%40maxi-meta-idx%40&urlGen=default",
|
738
|
-
wal: "murks://fp?index=idx&name=maxi&store=wal&storekey=%40maxi-wal-idx%40&urlGen=default",
|
739
|
-
},
|
740
|
-
});
|
741
|
-
});
|
742
|
-
|
743
|
-
it("keyConfigOpts", () => {
|
744
|
-
expect(JSON.parse(keyConfigOpts(sthis, "test"))).toEqual([
|
745
|
-
["name", "test"],
|
746
|
-
[
|
747
|
-
"stores",
|
748
|
-
[
|
749
|
-
[
|
750
|
-
"data",
|
751
|
-
{
|
752
|
-
car: "my://bla/storage?name=test&store=car&storekey=%40test-data%40&suffix=.car&urlGen=fromEnv",
|
753
|
-
file: "my://bla/storage?name=test&store=file&storekey=%40test-data%40&urlGen=fromEnv",
|
754
|
-
meta: "my://bla/storage?name=test&store=meta&storekey=%40test-meta%40&urlGen=fromEnv",
|
755
|
-
wal: "my://bla/storage?name=test&store=wal&storekey=%40test-wal%40&urlGen=fromEnv",
|
756
|
-
},
|
757
|
-
],
|
758
|
-
[
|
759
|
-
"idx",
|
760
|
-
{
|
761
|
-
car: "my://bla/storage?index=idx&name=test&store=car&storekey=%40test-data-idx%40&suffix=.car&urlGen=fromEnv",
|
762
|
-
file: "my://bla/storage?index=idx&name=test&store=file&storekey=%40test-data-idx%40&urlGen=fromEnv",
|
763
|
-
meta: "my://bla/storage?index=idx&name=test&store=meta&storekey=%40test-meta-idx%40&urlGen=fromEnv",
|
764
|
-
wal: "my://bla/storage?index=idx&name=test&store=wal&storekey=%40test-wal-idx%40&urlGen=fromEnv",
|
765
|
-
},
|
766
|
-
],
|
767
|
-
],
|
768
|
-
],
|
769
|
-
]);
|
770
|
-
});
|
771
|
-
|
772
|
-
it("check file protocol defaultURI", () => {
|
773
|
-
const gw = bs.defaultGatewayFactoryItem();
|
774
|
-
expect(gw.defaultURI(sthis).toString()).toBe(
|
775
|
-
"murks://fp",
|
776
|
-
// `file://${sthis.env.get("HOME")}/.fireproof/${FILESTORE_VERSION.replace(/-.*$/, "")}`,
|
777
|
-
);
|
778
|
-
});
|
779
|
-
});
|