@fireproof/core 0.21.0-dev-preview-6 → 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 -70
- 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 -317
- 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 -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 -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 -61
- package/blockstore/loader.d.ts.map +0 -1
- package/blockstore/loader.js +0 -493
- 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 -510
- 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 -26613
- 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 -34
- package/database.d.ts.map +0 -1
- package/database.js +0 -133
- 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 -55
- package/ledger.d.ts.map +0 -1
- package/ledger.js +0 -240
- 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 -296
- package/protocols/cloud/msg-types.d.ts.map +0 -1
- package/protocols/cloud/msg-types.js +0 -296
- 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 -166
- 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 +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 -71
- 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 -6
- package/react/use-attach.d.ts.map +0 -1
- package/react/use-attach.js +0 -75
- 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 -512
- 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 -46
- package/runtime/gateways/cloud/to-cloud.d.ts.map +0 -1
- package/runtime/gateways/cloud/to-cloud.js +0 -159
- 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 -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 -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 -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 -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 -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 -411
- 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 -526
- package/tests/blockstore/loader.test.ts +0 -297
- 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 -174
- package/tests/react/img-file.test.tsx +0 -190
- package/tests/react/use-all-docs.test.tsx +0 -173
- 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/utils.test.ts +0 -192
- 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 -462
- 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 -13
- package/use-fireproof/iframe-strategy.d.ts.map +0 -1
- package/use-fireproof/iframe-strategy.js +0 -83
- package/use-fireproof/iframe-strategy.js.map +0 -1
- package/use-fireproof/index.d.ts +0 -10
- package/use-fireproof/index.d.ts.map +0 -1
- package/use-fireproof/index.js +0 -16
- package/use-fireproof/index.js.map +0 -1
- package/use-fireproof/redirect-strategy.d.ts +0 -8
- package/use-fireproof/redirect-strategy.d.ts.map +0 -1
- package/use-fireproof/redirect-strategy.js +0 -31
- package/use-fireproof/redirect-strategy.js.map +0 -1
- package/utils.d.ts +0 -49
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -454
- 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,254 +0,0 @@
|
|
1
|
-
import { rt, bs } from "@fireproof/core";
|
2
|
-
import { mockSuperThis, simpleCID } from "../helpers.js";
|
3
|
-
import { BuildURI, Result } from "@adviser/cement";
|
4
|
-
import { toJSON } from "multiformats/link";
|
5
|
-
|
6
|
-
describe("storage-content", () => {
|
7
|
-
const sthis = mockSuperThis();
|
8
|
-
it("car", async () => {
|
9
|
-
const raw = new Uint8Array([55, 56, 57]);
|
10
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=car&suffix=.car").URI(), Result.Ok(raw));
|
11
|
-
expect(res.isOk()).toBeTruthy();
|
12
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
13
|
-
expect(res.unwrap().payload).toEqual(raw);
|
14
|
-
});
|
15
|
-
|
16
|
-
it("file", async () => {
|
17
|
-
const raw = new Uint8Array([55, 56, 57]);
|
18
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=file").URI(), Result.Ok(raw));
|
19
|
-
expect(res.isOk()).toBeTruthy();
|
20
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.FILE);
|
21
|
-
expect(res.unwrap().payload).toEqual(raw);
|
22
|
-
});
|
23
|
-
|
24
|
-
it("meta", async () => {
|
25
|
-
const ref = [
|
26
|
-
{
|
27
|
-
cid: "bafyreiaqmtw5jfudn6r6dq7mcmytc2z5z3ggohcj3gco3omjsp3hr73fpy",
|
28
|
-
data: "MomRkYXRhoWZkYk1ldGFYU3siY2FycyI6W3siLyI6ImJhZzR5dnFhYmNpcWNod29zeXQ3dTJqMmxtcHpyM2w3aWRlaTU1YzNmNnJ2Z3U3cXRmYXRoMnl2NnZuaWtjeXEifV19Z3BhcmVudHOA",
|
29
|
-
parents: [(await simpleCID(sthis)).toString(), (await simpleCID(sthis)).toString()],
|
30
|
-
},
|
31
|
-
];
|
32
|
-
const raw = sthis.txt.encode(JSON.stringify(ref));
|
33
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=meta").URI(), Result.Ok(raw));
|
34
|
-
expect(res.isOk()).toBeTruthy();
|
35
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.META);
|
36
|
-
const dbMetas = res.unwrap().payload as bs.DbMetaEvent[];
|
37
|
-
expect(dbMetas.length).toBe(1);
|
38
|
-
const dbMeta = dbMetas[0];
|
39
|
-
expect(dbMeta.parents.map((i) => i.toString())).toStrictEqual(ref[0].parents);
|
40
|
-
expect(dbMeta.eventCid.toString()).toEqual("bafyreiaqmtw5jfudn6r6dq7mcmytc2z5z3ggohcj3gco3omjsp3hr73fpy");
|
41
|
-
expect(dbMeta.dbMeta.cars.map((i) => i.toString())).toEqual([
|
42
|
-
"bag4yvqabciqchwosyt7u2j2lmpzr3l7idei55c3f6rvgu7qtfath2yv6vnikcyq",
|
43
|
-
]);
|
44
|
-
});
|
45
|
-
|
46
|
-
it("wal", async () => {
|
47
|
-
const ref = {
|
48
|
-
fileOperations: [
|
49
|
-
{
|
50
|
-
cid: "bafyreiaqmtw5jfudn6r6dq7mcmytc2z5z3ggohcj3gco3omjsp3hr73fpy",
|
51
|
-
public: false,
|
52
|
-
},
|
53
|
-
],
|
54
|
-
noLoaderOps: [
|
55
|
-
{
|
56
|
-
cars: [
|
57
|
-
{
|
58
|
-
"/": "bag4yvqabciqchwosyt7u2j2lmpzr3l7idei55c3f6rvgu7qtfath2yv6vnikcyq",
|
59
|
-
},
|
60
|
-
],
|
61
|
-
},
|
62
|
-
],
|
63
|
-
operations: [
|
64
|
-
{
|
65
|
-
cars: [{ "/": "bag4yvqabciqchwosyt7u2j2lmpzr3l7idei55c3f6rvgu7qtfath2yv6vnikcyq" }],
|
66
|
-
},
|
67
|
-
],
|
68
|
-
};
|
69
|
-
const raw = sthis.txt.encode(JSON.stringify(ref));
|
70
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=wal").URI(), Result.Ok(raw));
|
71
|
-
expect(res.isOk()).toBeTruthy();
|
72
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.WAL);
|
73
|
-
const walstate = res.unwrap().payload as bs.WALState;
|
74
|
-
expect(
|
75
|
-
walstate.fileOperations.map((i) => ({
|
76
|
-
...i,
|
77
|
-
cid: i.cid.toString(),
|
78
|
-
})),
|
79
|
-
).toEqual(ref.fileOperations);
|
80
|
-
expect(
|
81
|
-
walstate.noLoaderOps.map((i) => ({
|
82
|
-
cars: i.cars.map((i) => toJSON(i)),
|
83
|
-
})),
|
84
|
-
).toEqual(ref.noLoaderOps);
|
85
|
-
expect(
|
86
|
-
walstate.operations.map((i) => ({
|
87
|
-
cars: i.cars.map((i) => toJSON(i)),
|
88
|
-
})),
|
89
|
-
).toEqual(ref.operations);
|
90
|
-
});
|
91
|
-
});
|
92
|
-
|
93
|
-
describe("de-serialize", () => {
|
94
|
-
const sthis = mockSuperThis();
|
95
|
-
it("car", async () => {
|
96
|
-
const msg = {
|
97
|
-
type: bs.FPEnvelopeTypes.CAR,
|
98
|
-
payload: new Uint8Array([55, 56, 57]),
|
99
|
-
} satisfies bs.FPEnvelopeCar;
|
100
|
-
const res = await rt.gw.fpSerialize(sthis, msg);
|
101
|
-
expect(res.Ok()).toEqual(msg.payload);
|
102
|
-
});
|
103
|
-
|
104
|
-
it("file", async () => {
|
105
|
-
const msg = {
|
106
|
-
type: bs.FPEnvelopeTypes.FILE,
|
107
|
-
payload: new Uint8Array([55, 56, 57]),
|
108
|
-
} satisfies bs.FPEnvelopeFile;
|
109
|
-
const res = await rt.gw.fpSerialize(sthis, msg);
|
110
|
-
expect(res.Ok()).toEqual(msg.payload);
|
111
|
-
});
|
112
|
-
|
113
|
-
it("meta", async () => {
|
114
|
-
const msg = {
|
115
|
-
type: bs.FPEnvelopeTypes.META,
|
116
|
-
payload: [
|
117
|
-
await bs.createDbMetaEvent(
|
118
|
-
sthis,
|
119
|
-
{
|
120
|
-
cars: [await simpleCID(sthis)],
|
121
|
-
},
|
122
|
-
[await simpleCID(sthis), await simpleCID(sthis)],
|
123
|
-
),
|
124
|
-
],
|
125
|
-
} satisfies bs.FPEnvelopeMeta;
|
126
|
-
const ser = await rt.gw.fpSerialize(sthis, msg);
|
127
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=meta").URI(), ser);
|
128
|
-
const dbMetas = res.unwrap().payload as bs.DbMetaEvent[];
|
129
|
-
expect(dbMetas.length).toBe(1);
|
130
|
-
const dbMeta = dbMetas[0];
|
131
|
-
expect(dbMeta.parents).toEqual(msg.payload[0].parents);
|
132
|
-
expect(dbMeta.dbMeta).toEqual(msg.payload[0].dbMeta);
|
133
|
-
expect(dbMeta.eventCid).toEqual(msg.payload[0].eventCid);
|
134
|
-
});
|
135
|
-
|
136
|
-
it("wal", async () => {
|
137
|
-
const msg = {
|
138
|
-
type: bs.FPEnvelopeTypes.WAL,
|
139
|
-
payload: {
|
140
|
-
fileOperations: [
|
141
|
-
{
|
142
|
-
cid: await simpleCID(sthis),
|
143
|
-
public: false,
|
144
|
-
},
|
145
|
-
],
|
146
|
-
noLoaderOps: [
|
147
|
-
{
|
148
|
-
cars: [await simpleCID(sthis)],
|
149
|
-
},
|
150
|
-
],
|
151
|
-
operations: [
|
152
|
-
{
|
153
|
-
cars: [await simpleCID(sthis)],
|
154
|
-
},
|
155
|
-
],
|
156
|
-
},
|
157
|
-
} satisfies bs.FPEnvelopeWAL;
|
158
|
-
const ser = await rt.gw.fpSerialize(sthis, msg);
|
159
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=wal").URI(), ser);
|
160
|
-
expect(res.isOk()).toBeTruthy();
|
161
|
-
expect(res.unwrap().type).toEqual("wal");
|
162
|
-
const walstate = res.unwrap().payload as bs.WALState;
|
163
|
-
expect(walstate.fileOperations).toEqual(msg.payload.fileOperations);
|
164
|
-
expect(walstate.noLoaderOps).toEqual(msg.payload.noLoaderOps);
|
165
|
-
expect(walstate.operations).toEqual(msg.payload.operations);
|
166
|
-
});
|
167
|
-
|
168
|
-
it("coerce into fpDeserialize Result", async () => {
|
169
|
-
const raw = new Uint8Array([55, 56, 57]);
|
170
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=car&suffix=.car").URI(), Result.Ok(raw));
|
171
|
-
expect(res.isOk()).toBeTruthy();
|
172
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
173
|
-
expect(res.unwrap().payload).toEqual(raw);
|
174
|
-
});
|
175
|
-
|
176
|
-
it("coerce into fpDeserialize Promise", async () => {
|
177
|
-
const raw = new Uint8Array([55, 56, 57]);
|
178
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=car&suffix=.car").URI(), Promise.resolve(raw));
|
179
|
-
expect(res.isOk()).toBeTruthy();
|
180
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
181
|
-
expect(res.unwrap().payload).toEqual(raw);
|
182
|
-
});
|
183
|
-
|
184
|
-
it("coerce into fpDeserialize Promise Result", async () => {
|
185
|
-
const raw = new Uint8Array([55, 56, 57]);
|
186
|
-
const res = await rt.gw.fpDeserialize(
|
187
|
-
sthis,
|
188
|
-
BuildURI.from("http://x.com?store=car&suffix=.car").URI(),
|
189
|
-
Promise.resolve(Result.Ok(raw)),
|
190
|
-
);
|
191
|
-
expect(res.isOk()).toBeTruthy();
|
192
|
-
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
193
|
-
expect(res.unwrap().payload).toEqual(raw);
|
194
|
-
});
|
195
|
-
|
196
|
-
it("coerce into fpDeserialize Promise Result.Err", async () => {
|
197
|
-
const raw = Promise.resolve(Result.Err<Uint8Array>("error"));
|
198
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=car&suffix=.car").URI(), raw);
|
199
|
-
expect(res.isErr()).toBeTruthy();
|
200
|
-
expect(res.unwrap_err().message).toEqual("error");
|
201
|
-
});
|
202
|
-
|
203
|
-
it("coerce into fpDeserialize Promise.reject", async () => {
|
204
|
-
const raw = Promise.reject(new Error("error"));
|
205
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=car&suffix=.car").URI(), raw);
|
206
|
-
expect(res.isErr()).toBeTruthy();
|
207
|
-
expect(res.unwrap_err().message).toEqual("error");
|
208
|
-
});
|
209
|
-
|
210
|
-
it("coerce into fpDeserialize Result.Err", async () => {
|
211
|
-
const raw = Result.Err<Uint8Array>("error");
|
212
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=car&suffix=.car").URI(), raw);
|
213
|
-
expect(res.isErr()).toBeTruthy();
|
214
|
-
expect(res.unwrap_err().message).toEqual("error");
|
215
|
-
});
|
216
|
-
|
217
|
-
it("attach Key to Meta", async () => {
|
218
|
-
const msg = {
|
219
|
-
type: bs.FPEnvelopeTypes.META,
|
220
|
-
payload: [
|
221
|
-
await bs.createDbMetaEvent(
|
222
|
-
sthis,
|
223
|
-
{
|
224
|
-
cars: [await simpleCID(sthis)],
|
225
|
-
},
|
226
|
-
[await simpleCID(sthis), await simpleCID(sthis)],
|
227
|
-
),
|
228
|
-
],
|
229
|
-
} satisfies bs.FPEnvelopeMeta;
|
230
|
-
const ser = await rt.gw.fpSerialize(sthis, msg, {
|
231
|
-
meta: async (sthis, payload) => {
|
232
|
-
return Result.Ok(sthis.txt.encode(JSON.stringify(payload.map((i) => ({ ...i, key: "key" })))));
|
233
|
-
},
|
234
|
-
});
|
235
|
-
let key = "";
|
236
|
-
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=meta").URI(), ser, {
|
237
|
-
meta: async (sthis, payload) => {
|
238
|
-
const json = JSON.parse(sthis.txt.decode(payload));
|
239
|
-
key = json[0].key;
|
240
|
-
return Result.Ok(
|
241
|
-
json.map((i: { key?: string }) => {
|
242
|
-
delete i.key;
|
243
|
-
return i;
|
244
|
-
}) as rt.gw.SerializedMeta[],
|
245
|
-
);
|
246
|
-
},
|
247
|
-
});
|
248
|
-
expect(res.isOk()).toBeTruthy();
|
249
|
-
const meta = res.unwrap() as bs.FPEnvelopeMeta;
|
250
|
-
expect(meta.type).toEqual("meta");
|
251
|
-
expect(Object.keys(meta.payload).includes("key")).toBeFalsy();
|
252
|
-
expect(key).toEqual("key");
|
253
|
-
});
|
254
|
-
});
|
@@ -1,95 +0,0 @@
|
|
1
|
-
import { BuildURI, URI } from "@adviser/cement";
|
2
|
-
import { rt, bs, fireproof, PARAM, ensureSuperThis, Database } from "@fireproof/core";
|
3
|
-
|
4
|
-
describe("MetaKeyHack", () => {
|
5
|
-
const storageMap = new Map();
|
6
|
-
|
7
|
-
const sthis = ensureSuperThis();
|
8
|
-
const memGw = new rt.gw.memory.MemoryGateway(sthis, storageMap);
|
9
|
-
bs.registerStoreProtocol({
|
10
|
-
protocol: "hack:",
|
11
|
-
defaultURI: () => URI.from(`hack://localhost?version=hack`),
|
12
|
-
serdegateway: async () => {
|
13
|
-
return new rt.AddKeyToDbMetaGateway(memGw, "v2");
|
14
|
-
},
|
15
|
-
});
|
16
|
-
|
17
|
-
let db: Database;
|
18
|
-
let ctx: { loader: bs.Loadable };
|
19
|
-
beforeAll(async () => {
|
20
|
-
db = fireproof("test", {
|
21
|
-
storeUrls: {
|
22
|
-
base: BuildURI.from("hack://localhost").setParam(PARAM.SELF_REFLECT, "x"),
|
23
|
-
},
|
24
|
-
keyBag: {
|
25
|
-
url: "memory://./dist/kb-dir-partykit?extractKey=_deprecated_internal_api",
|
26
|
-
},
|
27
|
-
});
|
28
|
-
await db.ready();
|
29
|
-
ctx = { loader: db.ledger.crdt.blockstore.loader };
|
30
|
-
});
|
31
|
-
|
32
|
-
it("inject key into meta", async () => {
|
33
|
-
const loader = db.ledger.crdt.blockstore.loader;
|
34
|
-
const metaStore = loader.attachedStores.local().active.meta;
|
35
|
-
const subscribeFn = vitest.fn();
|
36
|
-
const unreg = await metaStore.realGateway.subscribe(
|
37
|
-
ctx,
|
38
|
-
metaStore.url(),
|
39
|
-
// metaStore.url().build().setParam(PARAM.SELF_REFLECT, "x").URI(),
|
40
|
-
subscribeFn,
|
41
|
-
);
|
42
|
-
expect(unreg.isOk()).toBeTruthy();
|
43
|
-
await db.put({ val: "test" });
|
44
|
-
|
45
|
-
const dataStore = loader.attachedStores.local().active.car;
|
46
|
-
const kb = new rt.KeyBag(db.ledger.opts.keyBag);
|
47
|
-
const rDataStoreKeyItem = await kb.getNamedKey(dataStore.url().getParam(PARAM.STORE_KEY) ?? "");
|
48
|
-
|
49
|
-
await rDataStoreKeyItem.Ok().upsert("zBUFMmu5c3VdCa4r2DZTzhR", false);
|
50
|
-
await rDataStoreKeyItem.Ok().upsert("zH1fyizirAiYVxoaQ2XZ3Xj", false);
|
51
|
-
|
52
|
-
expect(rDataStoreKeyItem.isOk()).toBeTruthy();
|
53
|
-
const rUrl = await memGw.buildUrl(metaStore.url(), "main");
|
54
|
-
// console.log(">>>>", rUrl.Ok().toString())
|
55
|
-
const rGet = await memGw.get(rUrl.Ok(), sthis);
|
56
|
-
const metas = JSON.parse(ctx.loader.sthis.txt.decode(rGet.Ok())) as rt.V2SerializedMetaKey;
|
57
|
-
const keyMaterials = metas.keys;
|
58
|
-
const dataStoreKeyMaterial = await rDataStoreKeyItem.Ok().asKeysItem();
|
59
|
-
expect(keyMaterials.length).toBeGreaterThan(0);
|
60
|
-
expect(dataStoreKeyMaterial).toEqual({
|
61
|
-
keys: {
|
62
|
-
...(await rDataStoreKeyItem
|
63
|
-
.Ok()
|
64
|
-
.get()
|
65
|
-
.then(async (r) => ({
|
66
|
-
[r?.fingerPrint as string]: {
|
67
|
-
default: true,
|
68
|
-
fingerPrint: r?.fingerPrint,
|
69
|
-
key: await r?.extract().then((i) => i.keyStr),
|
70
|
-
},
|
71
|
-
}))),
|
72
|
-
z3boMcLEQxjZAMrVo2j3k9bZJzmSqXkQmh6q7bLZ2nRuo: {
|
73
|
-
default: false,
|
74
|
-
fingerPrint: "z3boMcLEQxjZAMrVo2j3k9bZJzmSqXkQmh6q7bLZ2nRuo",
|
75
|
-
key: "zH1fyizirAiYVxoaQ2XZ3Xj",
|
76
|
-
},
|
77
|
-
zG5F2VWVAs3uAFyLE5rty5WWo7zJ1oBmYTdnraxfhaHG5: {
|
78
|
-
default: false,
|
79
|
-
fingerPrint: "zG5F2VWVAs3uAFyLE5rty5WWo7zJ1oBmYTdnraxfhaHG5",
|
80
|
-
key: "zBUFMmu5c3VdCa4r2DZTzhR",
|
81
|
-
},
|
82
|
-
},
|
83
|
-
name: "@test-data@",
|
84
|
-
});
|
85
|
-
|
86
|
-
// expect(keyMaterials.every((k) => k === dataStoreKeyMaterial.keyStr)).toBeTruthy()
|
87
|
-
// expect(subscribeFn.mock.calls).toEqual([]);
|
88
|
-
expect(subscribeFn).toHaveBeenCalledTimes(2);
|
89
|
-
const addKeyToDbMetaGateway = metaStore.realGateway as rt.AddKeyToDbMetaGateway;
|
90
|
-
expect(
|
91
|
-
subscribeFn.mock.calls.map((i) => i.map((i) => i.payload.map((i: bs.DbMetaEvent) => i.eventCid.toString()))).flat(2),
|
92
|
-
).toEqual(Array.from(new Set(addKeyToDbMetaGateway.lastDecodedMetas.map((i) => i.metas.map((i) => i.cid)).flat(2))));
|
93
|
-
unreg.Ok()();
|
94
|
-
});
|
95
|
-
});
|
package/tests/setup.file.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
process.env.FP_STORAGE_URL = "./dist/fp-dir-file";
|
package/tests/setup.indexeddb.ts
DELETED
File without changes
|
package/tests/setup.memory.ts
DELETED
package/tests/utils.test.ts
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
2
|
-
import { ensureURIDefaults } from "../src/utils.js";
|
3
|
-
import { BuildURI, Logger } from "@adviser/cement";
|
4
|
-
import { PARAM, StoreType, SuperThis } from "@fireproof/core"; // Assuming types are here
|
5
|
-
// import { mockSuperThis } from './helpers'; // We'll need a mock for SuperThis
|
6
|
-
|
7
|
-
// A minimal mock for SuperThis, to be expanded as needed
|
8
|
-
const mockSuperThisMinimal = (): Partial<SuperThis> => {
|
9
|
-
// Helper to create a LogBuilder mock part
|
10
|
-
// The LogBuilder interface is complex, so we mock only what's used by ensureURIDefaults
|
11
|
-
const createLogBuilder = (level: string) => ({
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
13
|
-
Msg: (_message: string) => ({
|
14
|
-
// Using _message for potentially unused parameter
|
15
|
-
AsError: () => new Error(`Mock Error from ${level}`),
|
16
|
-
// Log: () => { /* no-op */ }
|
17
|
-
}),
|
18
|
-
With: function () {
|
19
|
-
return this;
|
20
|
-
}, // Fluent interface
|
21
|
-
Stv: function () {
|
22
|
-
return this;
|
23
|
-
}, // Fluent interface
|
24
|
-
});
|
25
|
-
|
26
|
-
const loggerInstance = {
|
27
|
-
Error: () => createLogBuilder("Error"),
|
28
|
-
Info: () => createLogBuilder("Info"),
|
29
|
-
Warn: () => createLogBuilder("Warn"),
|
30
|
-
Debug: () => createLogBuilder("Debug"),
|
31
|
-
// Add stubs for other Logger methods/properties if ensureURIDefaults uses them
|
32
|
-
// For now, these are the ones that might be expected by the Logger type itself
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
34
|
-
Msg: (_message: string) => createLogBuilder("DefaultMsgLevel"), // Top-level Msg
|
35
|
-
Flush: async () => {
|
36
|
-
/* no-op */
|
37
|
-
},
|
38
|
-
levelHandler: {
|
39
|
-
/* minimal stub or actual mock if needed */
|
40
|
-
},
|
41
|
-
TxtEnDe: { encode: (s: string) => new Uint8Array(s.length), decode: (b: Uint8Array) => b.toString() },
|
42
|
-
Child: function () {
|
43
|
-
return this as unknown as Logger;
|
44
|
-
},
|
45
|
-
With: function () {
|
46
|
-
return this as unknown as Logger;
|
47
|
-
},
|
48
|
-
Stv: function () {
|
49
|
-
return this as unknown as Logger;
|
50
|
-
},
|
51
|
-
// ... and potentially other properties from the Logger interface if TS still complains
|
52
|
-
};
|
53
|
-
|
54
|
-
return {
|
55
|
-
logger: loggerInstance as unknown as Logger, // Using unknown as Logger for partial mock
|
56
|
-
// Add other SuperThis properties if ensureURIDefaults accesses them
|
57
|
-
};
|
58
|
-
};
|
59
|
-
|
60
|
-
describe("ensureURIDefaults", () => {
|
61
|
-
const baseUri = BuildURI.from("fireproof://mydatabase").URI();
|
62
|
-
const defaultName = "testDb";
|
63
|
-
|
64
|
-
it("should set STORE_KEY to insecure and apply store type when opts.public is true", () => {
|
65
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
66
|
-
const names = { name: defaultName };
|
67
|
-
const opts = { public: true };
|
68
|
-
const store: StoreType = "car";
|
69
|
-
|
70
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store);
|
71
|
-
|
72
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("insecure");
|
73
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe("car");
|
74
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
75
|
-
});
|
76
|
-
|
77
|
-
it("should use opts.storeKey when public is false and storeKey is provided", () => {
|
78
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
79
|
-
const names = { name: defaultName };
|
80
|
-
const opts = { public: false, storeKey: "customKey123" };
|
81
|
-
const store: StoreType = "car";
|
82
|
-
|
83
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store);
|
84
|
-
|
85
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("customKey123");
|
86
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe("car");
|
87
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
88
|
-
});
|
89
|
-
|
90
|
-
it("should use STORE_KEY from names.localURI when public is false and opts.storeKey is not set", () => {
|
91
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
92
|
-
const localStoreKey = "keyFromLocalURI";
|
93
|
-
const localUriWithKey = BuildURI.from("file:///another?storekey=" + localStoreKey).URI();
|
94
|
-
const names = { name: defaultName, localURI: localUriWithKey };
|
95
|
-
const opts = { public: false }; // storeKey is undefined
|
96
|
-
const store: StoreType = "wal";
|
97
|
-
|
98
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store);
|
99
|
-
|
100
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe(localStoreKey);
|
101
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe("wal");
|
102
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
103
|
-
});
|
104
|
-
|
105
|
-
it("should generate a new STORE_KEY when public is false and no key is provided", () => {
|
106
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
107
|
-
const names = { name: defaultName, localURI: BuildURI.from("file:///clean").URI() }; // No store_key in localURI
|
108
|
-
const opts = { public: false }; // No storeKey in opts
|
109
|
-
const store: StoreType = "wal";
|
110
|
-
const initialUri = baseUri.clone();
|
111
|
-
|
112
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, initialUri, store);
|
113
|
-
|
114
|
-
const storeKey = resultUri.getParam(PARAM.STORE_KEY);
|
115
|
-
expect(storeKey).toBeDefined();
|
116
|
-
expect(storeKey).not.toBeNull();
|
117
|
-
expect(storeKey).not.toBe("insecure");
|
118
|
-
expect(typeof storeKey).toBe("string");
|
119
|
-
// Add a direct check to satisfy TypeScript's null/undefined check for storeKey
|
120
|
-
if (storeKey) {
|
121
|
-
expect(storeKey.length).toBeGreaterThan(0); // Ensure it's not an empty string
|
122
|
-
} else {
|
123
|
-
// This case should not be reached if the above expects pass, but it satisfies TS
|
124
|
-
expect(storeKey).toBe("actually a string"); // This will fail if storeKey is not a string, or null/undefined
|
125
|
-
}
|
126
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe(store);
|
127
|
-
});
|
128
|
-
|
129
|
-
it('should preserve suffix if opts.public is true (and store is not "car")', () => {
|
130
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
131
|
-
const names = { name: defaultName };
|
132
|
-
const opts = { public: true };
|
133
|
-
const store: StoreType = "wal";
|
134
|
-
const suffixValue = "somesuffix";
|
135
|
-
const initialUriWithSuffix = BuildURI.from(baseUri).setParam(PARAM.SUFFIX, suffixValue).URI();
|
136
|
-
|
137
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, initialUriWithSuffix, store);
|
138
|
-
|
139
|
-
expect(resultUri.hasParam(PARAM.SUFFIX)).toBe(true);
|
140
|
-
expect(resultUri.getParam(PARAM.SUFFIX)).toBe(suffixValue);
|
141
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("insecure");
|
142
|
-
});
|
143
|
-
|
144
|
-
it("should preserve suffix if opts.public is false", () => {
|
145
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
146
|
-
const names = { name: defaultName };
|
147
|
-
const opts = { public: false, storeKey: "somekey" }; // Provide a storeKey for private
|
148
|
-
const store: StoreType = "wal";
|
149
|
-
const suffixValue = "keepsuffix";
|
150
|
-
const initialUriWithSuffix = BuildURI.from(baseUri).setParam(PARAM.SUFFIX, suffixValue).URI();
|
151
|
-
|
152
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, initialUriWithSuffix, store);
|
153
|
-
|
154
|
-
expect(resultUri.hasParam(PARAM.SUFFIX)).toBe(true);
|
155
|
-
expect(resultUri.getParam(PARAM.SUFFIX)).toBe(suffixValue);
|
156
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("somekey");
|
157
|
-
});
|
158
|
-
|
159
|
-
it("should generate STORE_KEY with -idx and set PARAM.INDEX when ctx.idx is true and public is false", () => {
|
160
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
161
|
-
const names = { name: defaultName }; // No localURI with storeKey
|
162
|
-
const opts = { public: false }; // No explicit storeKey
|
163
|
-
const store: StoreType = "wal";
|
164
|
-
const ctx = { idx: true };
|
165
|
-
|
166
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store, ctx);
|
167
|
-
|
168
|
-
expect(resultUri.hasParam(PARAM.INDEX)).toBe(true);
|
169
|
-
expect(resultUri.getParam(PARAM.INDEX)).toBe("idx");
|
170
|
-
// Assuming storeType2DataMetaWal('wal') results in 'wal' for the key name
|
171
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe(`@${defaultName}-wal-idx@`);
|
172
|
-
});
|
173
|
-
|
174
|
-
it("should use opts.uri as base and correctly apply other params (e.g., public affects STORE_KEY)", () => {
|
175
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
176
|
-
const customUriString = "fireproof://custombase/path";
|
177
|
-
const optsUri = BuildURI.from(customUriString).URI();
|
178
|
-
const names = { name: defaultName };
|
179
|
-
// Set public to true to check interaction: STORE_KEY should be 'insecure'
|
180
|
-
const opts = { uri: optsUri, public: true };
|
181
|
-
const store: StoreType = "file"; // Changed 'data' to 'file' (a valid StoreType)
|
182
|
-
// This baseUri should be overridden by opts.uri
|
183
|
-
const originalUri = BuildURI.from("fireproof://original/ignored").URI();
|
184
|
-
|
185
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, originalUri, store);
|
186
|
-
|
187
|
-
expect(resultUri.pathname.startsWith(optsUri.pathname)).toBe(true);
|
188
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("insecure");
|
189
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe(store);
|
190
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
191
|
-
});
|
192
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
2
|
-
|
3
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
4
|
-
|
5
|
-
export default defineConfig({
|
6
|
-
plugins: [tsconfigPaths()],
|
7
|
-
test: {
|
8
|
-
name: "file",
|
9
|
-
exclude: ["tests/react/**", "examples/**", "tests/gateway/indexeddb"],
|
10
|
-
include: ["tests/**/*test.?(c|m)[jt]s?(x)"],
|
11
|
-
globals: true,
|
12
|
-
setupFiles: "./tests/setup.file.ts",
|
13
|
-
},
|
14
|
-
});
|
@@ -1,37 +0,0 @@
|
|
1
|
-
/// <reference types="@vitest/browser/providers/playwright" />
|
2
|
-
/// <reference types="@vitest/browser/providers/webdriverio" />
|
3
|
-
|
4
|
-
import { defineConfig } from "vitest/config";
|
5
|
-
|
6
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
7
|
-
|
8
|
-
export default defineConfig({
|
9
|
-
plugins: [tsconfigPaths()],
|
10
|
-
test: {
|
11
|
-
name: "indexeddb",
|
12
|
-
exclude: ["examples/**", "tests/gateway/file"],
|
13
|
-
include: ["tests/**/*test.?(c|m)[jt]s?(x)"],
|
14
|
-
browser: {
|
15
|
-
enabled: true,
|
16
|
-
headless: true,
|
17
|
-
provider: "playwright",
|
18
|
-
// provider: "webdriverio",
|
19
|
-
// name: "chrome",
|
20
|
-
instances: [
|
21
|
-
{
|
22
|
-
browser: "chromium",
|
23
|
-
//setupFile: './chromium-setup.js',
|
24
|
-
},
|
25
|
-
],
|
26
|
-
|
27
|
-
// name: process.env.FP_BROWSER || "chrome", // browser name is required
|
28
|
-
// instances: [
|
29
|
-
// {
|
30
|
-
// browser: process.env.FP_BROWSER || "chrome", // browser name is required
|
31
|
-
// },
|
32
|
-
// ],
|
33
|
-
},
|
34
|
-
globals: true,
|
35
|
-
setupFiles: "./tests/setup.indexeddb.ts",
|
36
|
-
},
|
37
|
-
});
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
2
|
-
|
3
|
-
import tsconfigPaths from "vite-tsconfig-paths";
|
4
|
-
|
5
|
-
export default defineConfig({
|
6
|
-
plugins: [tsconfigPaths()],
|
7
|
-
test: {
|
8
|
-
name: "memory",
|
9
|
-
exclude: [
|
10
|
-
"tests/react/**",
|
11
|
-
"**/smoke/**",
|
12
|
-
"**/scripts/**",
|
13
|
-
"**/examples/**",
|
14
|
-
"tests/gateway/indexeddb",
|
15
|
-
"tests/gateway/file",
|
16
|
-
"tests/blockstore/keyed-crypto-indexeddb-file.test.ts",
|
17
|
-
],
|
18
|
-
include: ["tests/**/*test.?(c|m)[jt]s?(x)"],
|
19
|
-
coverage: {
|
20
|
-
exclude: ["**/smoke/**", "**/scripts/**", "**/examples/**"],
|
21
|
-
},
|
22
|
-
globals: true,
|
23
|
-
setupFiles: "./tests/setup.memory.ts",
|
24
|
-
},
|
25
|
-
});
|