@fireproof/core 0.21.0-dev-preview-7 → 0.22.0-keybag
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 +12 -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 -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,116 +0,0 @@
|
|
1
|
-
import { Database, DocWithId, fireproof } from "@fireproof/core";
|
2
|
-
|
3
|
-
interface TestDoc {
|
4
|
-
text: string;
|
5
|
-
category: string;
|
6
|
-
active: boolean;
|
7
|
-
}
|
8
|
-
|
9
|
-
describe("query return value consistency", function () {
|
10
|
-
let db: Database;
|
11
|
-
|
12
|
-
beforeEach(async () => {
|
13
|
-
db = fireproof("test-query-docs");
|
14
|
-
|
15
|
-
// Add test documents
|
16
|
-
await db.put({ _id: "doc1", text: "hello world", category: "greeting", active: true });
|
17
|
-
await db.put({ _id: "doc2", text: "goodbye world", category: "farewell", active: true });
|
18
|
-
await db.put({ _id: "doc3", text: "hello again", category: "greeting", active: false });
|
19
|
-
});
|
20
|
-
|
21
|
-
afterEach(async () => {
|
22
|
-
await db.close();
|
23
|
-
await db.destroy();
|
24
|
-
});
|
25
|
-
|
26
|
-
it("database query should return docs property like useLiveQuery", async function () {
|
27
|
-
// This test should initially fail because the query method doesn't return docs yet
|
28
|
-
const result = await db.query<TestDoc>("category");
|
29
|
-
|
30
|
-
// Check that rows property exists (this should pass)
|
31
|
-
expect(result).toHaveProperty("rows");
|
32
|
-
expect(result.rows.length).toBe(3);
|
33
|
-
|
34
|
-
// Check that docs property exists (this should fail until we implement the feature)
|
35
|
-
expect(result).toHaveProperty("docs");
|
36
|
-
expect(Array.isArray(result.docs)).toBe(true);
|
37
|
-
expect(result.docs.length).toBe(3);
|
38
|
-
|
39
|
-
// Verify docs contain the correct document data
|
40
|
-
const docIds = result.docs.map((doc) => doc._id).sort();
|
41
|
-
expect(docIds).toEqual(["doc1", "doc2", "doc3"]);
|
42
|
-
});
|
43
|
-
|
44
|
-
it("should return docs with the same order as rows", async function () {
|
45
|
-
const result = await db.query<TestDoc>("category");
|
46
|
-
|
47
|
-
// Ensure docs array exists
|
48
|
-
expect(result).toHaveProperty("docs");
|
49
|
-
|
50
|
-
// Verify the order matches between rows and docs
|
51
|
-
for (let i = 0; i < result.rows.length; i++) {
|
52
|
-
const row = result.rows[i];
|
53
|
-
const doc = result.docs[i];
|
54
|
-
expect(doc._id).toBe(row.id);
|
55
|
-
}
|
56
|
-
});
|
57
|
-
|
58
|
-
it("should work with complex map functions and query options", async function () {
|
59
|
-
// Test with a map function and query options
|
60
|
-
const result = await db.query<TestDoc, boolean>((doc) => doc.active, {
|
61
|
-
key: true,
|
62
|
-
includeDocs: true,
|
63
|
-
});
|
64
|
-
|
65
|
-
// Check rows (this should pass)
|
66
|
-
expect(result.rows.length).toBeGreaterThan(0);
|
67
|
-
|
68
|
-
// Check docs property (this should fail until we implement the feature)
|
69
|
-
expect(result).toHaveProperty("docs");
|
70
|
-
expect(result.docs.length).toBe(result.rows.length);
|
71
|
-
|
72
|
-
// Verify all returned docs are active
|
73
|
-
result.docs.forEach((doc) => {
|
74
|
-
// Since we know these are TestDoc documents
|
75
|
-
expect((doc as DocWithId<TestDoc>).active).toBe(true);
|
76
|
-
});
|
77
|
-
});
|
78
|
-
|
79
|
-
it("should only return docs with false value when queried with {key: false}", async function () {
|
80
|
-
// Test with a map function and query options for false value
|
81
|
-
const result = await db.query<TestDoc, boolean>((doc) => doc.active, {
|
82
|
-
key: false,
|
83
|
-
includeDocs: true,
|
84
|
-
});
|
85
|
-
|
86
|
-
// Should only return documents where active is false
|
87
|
-
expect(result.rows.length).toBe(1); // We only have one document with active: false
|
88
|
-
|
89
|
-
// Check docs property exists and matches rows length
|
90
|
-
expect(result).toHaveProperty("docs");
|
91
|
-
expect(result.docs.length).toBe(result.rows.length);
|
92
|
-
|
93
|
-
// Verify all returned docs have active set to false
|
94
|
-
result.docs.forEach((doc) => {
|
95
|
-
expect((doc as DocWithId<TestDoc>).active).toBe(false);
|
96
|
-
});
|
97
|
-
|
98
|
-
// Make sure no documents with active: true are included
|
99
|
-
const activeTrue = result.docs.filter((doc) => (doc as DocWithId<TestDoc>).active === true);
|
100
|
-
expect(activeTrue.length).toBe(0); // No active: true docs should be included
|
101
|
-
|
102
|
-
// Now run a query with key: true for comparison
|
103
|
-
const trueResult = await db.query<TestDoc, boolean>((doc) => doc.active, {
|
104
|
-
key: true,
|
105
|
-
includeDocs: true,
|
106
|
-
});
|
107
|
-
|
108
|
-
// This correctly returns only active: true documents
|
109
|
-
expect(trueResult.rows.length).toBe(2);
|
110
|
-
|
111
|
-
// All returned docs have active set to true
|
112
|
-
trueResult.docs.forEach((doc) => {
|
113
|
-
expect((doc as DocWithId<TestDoc>).active).toBe(true);
|
114
|
-
});
|
115
|
-
});
|
116
|
-
});
|
@@ -1,147 +0,0 @@
|
|
1
|
-
import { describe, it, beforeEach, afterEach, expect } from "vitest";
|
2
|
-
import { Database, fireproof } from "@fireproof/core";
|
3
|
-
|
4
|
-
interface TodoDoc {
|
5
|
-
task: string;
|
6
|
-
completed: boolean;
|
7
|
-
priority?: number;
|
8
|
-
}
|
9
|
-
|
10
|
-
describe("query limit handling", () => {
|
11
|
-
let db: Database;
|
12
|
-
|
13
|
-
beforeEach(async () => {
|
14
|
-
db = await fireproof("test-query-limit");
|
15
|
-
|
16
|
-
// Create multiple documents with different completed values and priorities
|
17
|
-
await db.put({ _id: "task1", task: "Task 1", completed: true, priority: 1 });
|
18
|
-
await db.put({ _id: "task2", task: "Task 2", completed: true, priority: 2 });
|
19
|
-
await db.put({ _id: "task3", task: "Task 3", completed: false, priority: 3 });
|
20
|
-
await db.put({ _id: "task4", task: "Task 4", completed: false, priority: 4 });
|
21
|
-
await db.put({ _id: "task5", task: "Task 5", completed: true, priority: 5 });
|
22
|
-
});
|
23
|
-
|
24
|
-
afterEach(async () => {
|
25
|
-
await db.destroy();
|
26
|
-
});
|
27
|
-
|
28
|
-
// PASSING CASES - These should work correctly with the current implementation
|
29
|
-
|
30
|
-
it("should correctly limit results for regular queries", async () => {
|
31
|
-
// Regular query with limit (no key/keys specified)
|
32
|
-
const queryResult = await db.query("completed", {
|
33
|
-
includeDocs: false,
|
34
|
-
limit: 2,
|
35
|
-
});
|
36
|
-
|
37
|
-
// This should pass - limit should work for regular queries
|
38
|
-
expect(queryResult.rows.length).toBe(2);
|
39
|
-
});
|
40
|
-
|
41
|
-
it("should correctly limit results for 'key' parameter queries", async () => {
|
42
|
-
// Query with a single key and limit
|
43
|
-
const queryResult = await db.query("completed", {
|
44
|
-
key: true,
|
45
|
-
includeDocs: false,
|
46
|
-
limit: 2,
|
47
|
-
});
|
48
|
-
|
49
|
-
// This should pass - limit should work for queries with 'key' option
|
50
|
-
expect(queryResult.rows.length).toBe(2);
|
51
|
-
|
52
|
-
// All results should have completed=true
|
53
|
-
queryResult.rows.forEach((row) => {
|
54
|
-
expect(row.key).toBe(true);
|
55
|
-
});
|
56
|
-
});
|
57
|
-
|
58
|
-
it("should correctly limit range query results", async () => {
|
59
|
-
// Query with range and limit
|
60
|
-
const queryResult = await db.query("priority", {
|
61
|
-
range: [2, 4],
|
62
|
-
includeDocs: false,
|
63
|
-
limit: 2,
|
64
|
-
});
|
65
|
-
|
66
|
-
// This should pass - limit should work for range queries
|
67
|
-
expect(queryResult.rows.length).toBe(2);
|
68
|
-
|
69
|
-
// All results should have priority between 2 and 4
|
70
|
-
queryResult.rows.forEach((row) => {
|
71
|
-
expect(row.key).toBeGreaterThanOrEqual(2);
|
72
|
-
expect(row.key).toBeLessThanOrEqual(4);
|
73
|
-
});
|
74
|
-
});
|
75
|
-
|
76
|
-
// FAILING CASES - These demonstrate the current bug
|
77
|
-
|
78
|
-
it("should respect the limit option with 'keys' parameter (currently failing)", async () => {
|
79
|
-
// Query with multiple keys and limit=1
|
80
|
-
// This should return only 1 result total, but currently returns 1 per key
|
81
|
-
const queryResult = await db.query("completed", {
|
82
|
-
keys: [true, false],
|
83
|
-
includeDocs: false,
|
84
|
-
limit: 1,
|
85
|
-
});
|
86
|
-
|
87
|
-
// This assertion will fail with the current implementation
|
88
|
-
// Current behavior: Returns limit=1 for EACH key, so 2 results total
|
89
|
-
// Expected behavior: Returns limit=1 across ALL keys combined
|
90
|
-
expect(queryResult.rows.length).toBe(1);
|
91
|
-
});
|
92
|
-
|
93
|
-
it("should apply limit correctly to combined results from multiple keys", async () => {
|
94
|
-
// Query with multiple keys and limit=3
|
95
|
-
// Should return exactly 3 results total
|
96
|
-
const queryResult = await db.query<TodoDoc, boolean>("completed", {
|
97
|
-
keys: [true, false],
|
98
|
-
includeDocs: false,
|
99
|
-
limit: 3,
|
100
|
-
});
|
101
|
-
|
102
|
-
// This assertion verifies that limit is applied to the combined result
|
103
|
-
expect(queryResult.rows.length).toBe(3);
|
104
|
-
});
|
105
|
-
|
106
|
-
it("demonstrates the limit+1 issue with the 'keys' parameter", async () => {
|
107
|
-
// Create a controlled test case with exact document counts
|
108
|
-
await db.destroy();
|
109
|
-
db = await fireproof("test-exact-limit");
|
110
|
-
|
111
|
-
// Create exactly 2 documents with completed=true and 2 with completed=false
|
112
|
-
await db.put({ _id: "doc1", task: "Doc 1", completed: true });
|
113
|
-
await db.put({ _id: "doc2", task: "Doc 2", completed: true });
|
114
|
-
await db.put({ _id: "doc3", task: "Doc 3", completed: false });
|
115
|
-
await db.put({ _id: "doc4", task: "Doc 4", completed: false });
|
116
|
-
|
117
|
-
// Query with limit=1 - should return exactly 1 result total
|
118
|
-
const result1 = await db.query("completed", {
|
119
|
-
keys: [true, false],
|
120
|
-
limit: 1,
|
121
|
-
includeDocs: false,
|
122
|
-
});
|
123
|
-
|
124
|
-
// Will fail - returns 2 instead of 1
|
125
|
-
expect(result1.rows.length).toBe(1);
|
126
|
-
|
127
|
-
// Query with limit=2 - should return exactly 2 results total
|
128
|
-
const result2 = await db.query("completed", {
|
129
|
-
keys: [true, false],
|
130
|
-
limit: 2,
|
131
|
-
includeDocs: false,
|
132
|
-
});
|
133
|
-
|
134
|
-
// Will fail - returns 4 instead of 2
|
135
|
-
expect(result2.rows.length).toBe(2);
|
136
|
-
|
137
|
-
// Query with limit=3 - should return exactly 3 results total
|
138
|
-
const result3 = await db.query("completed", {
|
139
|
-
keys: [true, false],
|
140
|
-
limit: 3,
|
141
|
-
includeDocs: false,
|
142
|
-
});
|
143
|
-
|
144
|
-
// Will fail - returns 4 instead of 3
|
145
|
-
expect(result3.rows.length).toBe(3);
|
146
|
-
});
|
147
|
-
});
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import { Database, fireproof } from "@fireproof/core";
|
2
|
-
|
3
|
-
interface TestDoc {
|
4
|
-
text: string;
|
5
|
-
category: string;
|
6
|
-
count: number;
|
7
|
-
}
|
8
|
-
|
9
|
-
describe("query property inconsistency issue", function () {
|
10
|
-
let db: Database;
|
11
|
-
|
12
|
-
beforeEach(async () => {
|
13
|
-
db = fireproof("test-query-property-inconsistency");
|
14
|
-
|
15
|
-
// Add test documents
|
16
|
-
await db.put({ _id: "doc1", text: "hello world", category: "greeting", count: 1 });
|
17
|
-
await db.put({ _id: "doc2", text: "goodbye world", category: "farewell", count: 2 });
|
18
|
-
await db.put({ _id: "doc3", text: "hello again", category: "greeting", count: 3 });
|
19
|
-
});
|
20
|
-
|
21
|
-
afterEach(async () => {
|
22
|
-
await db.close();
|
23
|
-
await db.destroy();
|
24
|
-
});
|
25
|
-
|
26
|
-
it("demonstrates property inconsistency in query results", async function () {
|
27
|
-
// Case 1: Query without key option - should have 'value' property
|
28
|
-
const queryNoKey = await db.query<TestDoc>((doc) => doc.category);
|
29
|
-
|
30
|
-
// Verify it has 'value' property
|
31
|
-
expect(queryNoKey.rows[0]).toHaveProperty("value");
|
32
|
-
|
33
|
-
// Case 2: Query with key option - currently has 'row' property instead of 'value'
|
34
|
-
const queryWithKey = await db.query<TestDoc>((doc) => doc.category, {
|
35
|
-
key: "greeting",
|
36
|
-
});
|
37
|
-
|
38
|
-
// THIS WILL FAIL - Demonstrating the inconsistency
|
39
|
-
// After standardizing on 'value', this assertion should pass
|
40
|
-
expect(queryWithKey.rows[0]).toHaveProperty("value");
|
41
|
-
|
42
|
-
// This assertion will pass after standardizing on 'value' and removing 'row'
|
43
|
-
expect(queryWithKey.rows[0]).not.toHaveProperty("row");
|
44
|
-
});
|
45
|
-
|
46
|
-
it("should use consistent property names regardless of query type", async function () {
|
47
|
-
// Multiple query variations to test different code paths
|
48
|
-
|
49
|
-
// 1. Regular query (no options)
|
50
|
-
const regularQuery = await db.query<TestDoc>((doc) => doc.category);
|
51
|
-
|
52
|
-
// 2. Query with key option
|
53
|
-
const keyQuery = await db.query<TestDoc>((doc) => doc.category, {
|
54
|
-
key: "greeting",
|
55
|
-
});
|
56
|
-
|
57
|
-
// 3. Query with range option
|
58
|
-
const rangeQuery = await db.query<TestDoc>((doc) => doc.count, {
|
59
|
-
range: [1, 3],
|
60
|
-
});
|
61
|
-
|
62
|
-
// 4. Query with prefix option
|
63
|
-
const prefixQuery = await db.query<TestDoc>((doc) => [doc.category, doc.count], {
|
64
|
-
prefix: ["greeting"],
|
65
|
-
});
|
66
|
-
|
67
|
-
// Check each query type has the 'value' property
|
68
|
-
expect(regularQuery.rows[0]).toHaveProperty("value");
|
69
|
-
expect(keyQuery.rows[0]).toHaveProperty("value");
|
70
|
-
expect(rangeQuery.rows[0]).toHaveProperty("value");
|
71
|
-
expect(prefixQuery.rows[0]).toHaveProperty("value");
|
72
|
-
|
73
|
-
// Ensure no query has the 'row' property
|
74
|
-
expect(regularQuery.rows[0]).not.toHaveProperty("row");
|
75
|
-
expect(keyQuery.rows[0]).not.toHaveProperty("row");
|
76
|
-
expect(rangeQuery.rows[0]).not.toHaveProperty("row");
|
77
|
-
expect(prefixQuery.rows[0]).not.toHaveProperty("row");
|
78
|
-
|
79
|
-
// Ensure all queries have the same set of properties
|
80
|
-
const regularProps = Object.keys(regularQuery.rows[0]).sort();
|
81
|
-
const keyProps = Object.keys(keyQuery.rows[0]).sort();
|
82
|
-
const rangeProps = Object.keys(rangeQuery.rows[0]).sort();
|
83
|
-
const prefixProps = Object.keys(prefixQuery.rows[0]).sort();
|
84
|
-
|
85
|
-
expect(keyProps).toEqual(regularProps);
|
86
|
-
expect(rangeProps).toEqual(regularProps);
|
87
|
-
expect(prefixProps).toEqual(regularProps);
|
88
|
-
});
|
89
|
-
});
|
@@ -1,42 +0,0 @@
|
|
1
|
-
import { Database, fireproof } from "@fireproof/core";
|
2
|
-
|
3
|
-
interface TestDoc {
|
4
|
-
text: string;
|
5
|
-
category: string;
|
6
|
-
count: number;
|
7
|
-
}
|
8
|
-
|
9
|
-
describe("query result property consistency", function () {
|
10
|
-
let db: Database;
|
11
|
-
|
12
|
-
beforeEach(async () => {
|
13
|
-
db = fireproof("test-query-result-properties");
|
14
|
-
|
15
|
-
// Add test documents
|
16
|
-
await db.put({ _id: "doc1", text: "hello world", category: "greeting", count: 1 });
|
17
|
-
await db.put({ _id: "doc2", text: "goodbye world", category: "farewell", count: 2 });
|
18
|
-
await db.put({ _id: "doc3", text: "hello again", category: "greeting", count: 3 });
|
19
|
-
});
|
20
|
-
|
21
|
-
afterEach(async () => {
|
22
|
-
await db.close();
|
23
|
-
await db.destroy();
|
24
|
-
});
|
25
|
-
|
26
|
-
it("should have consistent result properties regardless of query options", async function () {
|
27
|
-
// Query without using the key option
|
28
|
-
const resultWithoutKey = await db.query<TestDoc>((doc) => doc.category);
|
29
|
-
|
30
|
-
// Query with the key option
|
31
|
-
const resultWithKey = await db.query<TestDoc>((doc) => doc.category, {
|
32
|
-
key: "greeting",
|
33
|
-
});
|
34
|
-
|
35
|
-
// Add assertions to check property existence
|
36
|
-
const withoutKeyProps = Object.keys(resultWithoutKey.rows[0]);
|
37
|
-
const withKeyProps = Object.keys(resultWithKey.rows[0]);
|
38
|
-
|
39
|
-
// Test if the properties are the same in both cases
|
40
|
-
expect(withoutKeyProps).toEqual(withKeyProps);
|
41
|
-
});
|
42
|
-
});
|
@@ -1,69 +0,0 @@
|
|
1
|
-
import { sha256 } from "multiformats/hashes/sha2";
|
2
|
-
import { ensureSuperThis, rt, bs } from "@fireproof/core";
|
3
|
-
import { base58btc } from "multiformats/bases/base58";
|
4
|
-
import { URI, toCryptoRuntime } from "@adviser/cement";
|
5
|
-
import * as cborg from "cborg";
|
6
|
-
|
7
|
-
const sthis = ensureSuperThis();
|
8
|
-
describe.each([
|
9
|
-
async () => {
|
10
|
-
const kb = await rt.kb.getKeyBag(sthis, {});
|
11
|
-
const keyStr = base58btc.encode(toCryptoRuntime().randomBytes(kb.rt.keyLength));
|
12
|
-
return await rt.kc.keyedCryptoFactory(URI.from(`test://bla?storekey=${keyStr}`), kb, sthis);
|
13
|
-
},
|
14
|
-
async () => {
|
15
|
-
const kb = await rt.kb.getKeyBag(sthis, {});
|
16
|
-
return await rt.kc.keyedCryptoFactory(URI.from(`test://bla?storekey=insecure`), kb, sthis);
|
17
|
-
},
|
18
|
-
])("regression of stable cid encoding", (factory) => {
|
19
|
-
let kycr: bs.CryptoAction;
|
20
|
-
beforeEach(async () => {
|
21
|
-
// let url: URI;
|
22
|
-
// if (runtimeFn().isBrowser) {
|
23
|
-
// url = URI.from("indexeddb://fp-keybag");
|
24
|
-
// } else {
|
25
|
-
// url = URI.merge(`file://./dist/tests/key.bag`, sthis.env.get("FP_KEYBAG_URL"));
|
26
|
-
// }
|
27
|
-
kycr = await factory();
|
28
|
-
});
|
29
|
-
|
30
|
-
it("should encode and decode a stable cid", async () => {
|
31
|
-
const x1 = await rt.mf.block.encode({
|
32
|
-
value: cborg.encode({ hello: "world" }),
|
33
|
-
// hashBytes: {
|
34
|
-
// as: (x: Uint8Array<ArrayBufferLike>): Promise<ByteView<Uint8Array>> => Promise.resolve(x),
|
35
|
-
// },
|
36
|
-
hasher: sha256,
|
37
|
-
codec: kycr.codec(toCryptoRuntime().randomBytes(12)),
|
38
|
-
});
|
39
|
-
const x2 = await rt.mf.block.encode({
|
40
|
-
value: cborg.encode({ hello: "world" }),
|
41
|
-
// hashBytes: {
|
42
|
-
// as: (x: Uint8Array<ArrayBufferLike>): Promise<ByteView<Uint8Array>> => Promise.resolve(x),
|
43
|
-
// },
|
44
|
-
hasher: sha256,
|
45
|
-
codec: kycr.codec(toCryptoRuntime().randomBytes(12)),
|
46
|
-
});
|
47
|
-
expect(x1.cid).toEqual(x2.cid);
|
48
|
-
});
|
49
|
-
it("decode stable cid", async () => {
|
50
|
-
const x1 = await rt.mf.block.encode({
|
51
|
-
value: cborg.encode({ hello: "world" }),
|
52
|
-
// hashBytes: {
|
53
|
-
// as: (x: Uint8Array<ArrayBufferLike>): Promise<ByteView<Uint8Array>> => Promise.resolve(x),
|
54
|
-
// },
|
55
|
-
hasher: sha256,
|
56
|
-
codec: kycr.codec(),
|
57
|
-
});
|
58
|
-
const x = await rt.mf.block.decode<bs.IvKeyIdData, 24, 18>({
|
59
|
-
bytes: x1.bytes,
|
60
|
-
// hashBytes: {
|
61
|
-
// get: (x: bs.IvKeyIdData): Promise<ByteView<Uint8Array>> => Promise.resolve(x.data as ByteView<Uint8Array<ArrayBufferLike>>),
|
62
|
-
// },
|
63
|
-
codec: kycr.codec(),
|
64
|
-
hasher: sha256,
|
65
|
-
});
|
66
|
-
expect(x.cid.toString()).toEqual(x1.cid.toString());
|
67
|
-
expect(cborg.decode(x.value.data)).toEqual({ hello: "world" });
|
68
|
-
}, 1000000);
|
69
|
-
});
|
@@ -1,135 +0,0 @@
|
|
1
|
-
import { runtimeFn, URI } from "@adviser/cement";
|
2
|
-
import { rt, getStore, inplaceFilter, ensureSuperThis, ensureSuperLog } from "@fireproof/core";
|
3
|
-
import { UUID } from "uuidv7";
|
4
|
-
|
5
|
-
describe("utils", () => {
|
6
|
-
const sthis = ensureSuperThis();
|
7
|
-
const logger = ensureSuperLog(sthis, "getfilename");
|
8
|
-
|
9
|
-
beforeAll(async () => {
|
10
|
-
await sthis.start();
|
11
|
-
});
|
12
|
-
|
13
|
-
it("sorts search params", () => {
|
14
|
-
const url = URI.from("http://example.com?z=1&y=2&x=3");
|
15
|
-
expect(url.toString()).toEqual("http://example.com/?x=3&y=2&z=1");
|
16
|
-
});
|
17
|
-
|
18
|
-
const storeOpts = [
|
19
|
-
{
|
20
|
-
type: "car",
|
21
|
-
pathPart: "data",
|
22
|
-
suffix: ".car",
|
23
|
-
},
|
24
|
-
{
|
25
|
-
type: "file",
|
26
|
-
pathPart: "data",
|
27
|
-
suffix: "",
|
28
|
-
},
|
29
|
-
{
|
30
|
-
type: "wal",
|
31
|
-
pathPart: "wal",
|
32
|
-
suffix: ".json",
|
33
|
-
},
|
34
|
-
{
|
35
|
-
type: "meta",
|
36
|
-
pathPart: "meta",
|
37
|
-
suffix: ".json",
|
38
|
-
},
|
39
|
-
];
|
40
|
-
it("getfilename plain", () => {
|
41
|
-
for (const store of storeOpts) {
|
42
|
-
const url = URI.from(`file://./x/path?store=${store.type}&name=name&key=key&version=version&suffix=${store.suffix}`);
|
43
|
-
expect(rt.getFileName(url, logger)).toEqual(`${store.pathPart}/key${store.suffix}`);
|
44
|
-
}
|
45
|
-
});
|
46
|
-
|
47
|
-
it("getfilename index", () => {
|
48
|
-
for (const store of storeOpts) {
|
49
|
-
const url = URI.from(
|
50
|
-
`file://./x/path?index=idx&store=${store.type}&name=name&key=key&version=version&suffix=${store.suffix}`,
|
51
|
-
);
|
52
|
-
expect(rt.getFileName(url, logger)).toEqual(`idx-${store.pathPart}/key${store.suffix}`);
|
53
|
-
}
|
54
|
-
});
|
55
|
-
|
56
|
-
it("getstore", () => {
|
57
|
-
for (const store of storeOpts) {
|
58
|
-
const url = URI.from(`file://./x/path?store=${store.type}&name=name&key=key&version=version`);
|
59
|
-
expect(getStore(url, logger, (...toJoin) => toJoin.join("+"))).toEqual({
|
60
|
-
fromUrl: store.type,
|
61
|
-
name: store.pathPart,
|
62
|
-
pathPart: store.pathPart,
|
63
|
-
});
|
64
|
-
}
|
65
|
-
});
|
66
|
-
|
67
|
-
it("getstore idx", () => {
|
68
|
-
for (const store of storeOpts) {
|
69
|
-
const url = URI.from(`file://./x/path?index=ix&store=${store.type}&name=name&key=key&version=version`);
|
70
|
-
expect(getStore(url, logger, (...toJoin) => toJoin.join("+"))).toEqual({
|
71
|
-
fromUrl: store.type,
|
72
|
-
pathPart: store.pathPart,
|
73
|
-
name: `ix+${store.pathPart}`,
|
74
|
-
});
|
75
|
-
}
|
76
|
-
});
|
77
|
-
|
78
|
-
it("order timeorderednextid", () => {
|
79
|
-
let last = sthis.timeOrderedNextId().str;
|
80
|
-
for (let i = 0; i < 10; i++) {
|
81
|
-
const id = sthis.timeOrderedNextId().str;
|
82
|
-
const x = UUID.parse(id);
|
83
|
-
expect(x.getVariant()).toBe("VAR_10");
|
84
|
-
assert(id !== last, "id should be greater than last");
|
85
|
-
assert(id.slice(0, 13) >= last.slice(0, 13), `id should be greater than last ${id.slice(0, 13)} ${last.slice(0, 13)}`);
|
86
|
-
last = id;
|
87
|
-
}
|
88
|
-
});
|
89
|
-
it("timeorderednextid is uuidv7", () => {
|
90
|
-
const id = sthis.timeOrderedNextId(0xcafebabebeef).str;
|
91
|
-
expect(id.slice(0, 15)).toBe("cafebabe-beef-7");
|
92
|
-
});
|
93
|
-
|
94
|
-
it("inplaceFilter empty", () => {
|
95
|
-
const s: string[] = [];
|
96
|
-
expect(inplaceFilter(s, () => false)).toEqual([]);
|
97
|
-
expect(inplaceFilter(s, () => true)).toEqual([]);
|
98
|
-
});
|
99
|
-
|
100
|
-
it("inplaceFilter sized filtered", () => {
|
101
|
-
const s = new Array(100).fill("a").map((a, i) => `${a}${i.toString()}`);
|
102
|
-
expect(inplaceFilter(s, () => false)).toEqual([]);
|
103
|
-
});
|
104
|
-
it("inplaceFilter sized unfiltered", () => {
|
105
|
-
const s = new Array(100).fill("a").map((a, i) => `${a}${i.toString()}`);
|
106
|
-
const ref = [...s];
|
107
|
-
expect(inplaceFilter(s, () => true)).toEqual(ref);
|
108
|
-
});
|
109
|
-
|
110
|
-
it("inplaceFilter sized mod 7", () => {
|
111
|
-
const s = new Array(100).fill("a").map((a, i) => `${a}${i.toString()}`);
|
112
|
-
const ref = [...s];
|
113
|
-
for (let i = 99; i >= 0; i--) {
|
114
|
-
if (!(i % 7)) {
|
115
|
-
ref.splice(i, 1);
|
116
|
-
}
|
117
|
-
}
|
118
|
-
expect(inplaceFilter(s, (_, j) => !!(j % 7))).toEqual(ref);
|
119
|
-
expect(s.length).toBe(85);
|
120
|
-
});
|
121
|
-
});
|
122
|
-
|
123
|
-
describe("runtime", () => {
|
124
|
-
it("runtime", () => {
|
125
|
-
const isDeno = !!(typeof process === "object" && process.versions?.deno);
|
126
|
-
const isNode = !isDeno && !!(typeof process === "object" && process.versions?.node);
|
127
|
-
expect(runtimeFn()).toEqual({
|
128
|
-
isBrowser: !(isNode || isDeno),
|
129
|
-
isCFWorker: false,
|
130
|
-
isDeno: isDeno,
|
131
|
-
isNodeIsh: isNode,
|
132
|
-
isReactNative: false,
|
133
|
-
});
|
134
|
-
});
|
135
|
-
});
|