@fireproof/vendor 0.0.0-smoke → 0.0.2-dev-test
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/merge-package.ts +207 -0
- package/p-limit/index.d.ts +81 -0
- package/p-limit/index.js +104 -0
- package/p-limit/index.test-d.ts +19 -0
- package/p-limit/license +9 -0
- package/p-limit/package.json +59 -0
- package/p-limit/readme.md +128 -0
- package/p-limit/test.js +241 -0
- package/package.json +12 -9
- package/to-esm-transform.ts +42 -0
- package/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
- package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
- package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
- package/patched/@ipld/dag-json/LICENSE +0 -4
- package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
- package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
- package/patched/@ipld/dag-json/README.md +0 -58
- package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
- package/patched/@ipld/dag-json/package.json +0 -173
- package/patched/@ipld/dag-json/src/index.js +0 -291
- package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
- package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
- package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
- package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
- package/patched/@ipld/dag-json/tsconfig.json +0 -14
- package/patched/cborg/.github/dependabot.yml +0 -16
- package/patched/cborg/.github/workflows/test-and-release.yml +0 -52
- package/patched/cborg/CHANGELOG.md +0 -513
- package/patched/cborg/LICENSE +0 -13
- package/patched/cborg/README.md +0 -515
- package/patched/cborg/bench/bench.js +0 -117
- package/patched/cborg/bench/json.js +0 -124
- package/patched/cborg/bench/package.json +0 -8
- package/patched/cborg/cborg-4.2.7.tgz +0 -0
- package/patched/cborg/cborg.js +0 -31
- package/patched/cborg/example-bytestrings.js +0 -180
- package/patched/cborg/example-json.js +0 -6
- package/patched/cborg/example.js +0 -5
- package/patched/cborg/interface.ts +0 -56
- package/patched/cborg/lib/0uint.js +0 -227
- package/patched/cborg/lib/1negint.js +0 -111
- package/patched/cborg/lib/2bytes.js +0 -133
- package/patched/cborg/lib/3string.js +0 -90
- package/patched/cborg/lib/4array.js +0 -113
- package/patched/cborg/lib/5map.js +0 -113
- package/patched/cborg/lib/6tag.js +0 -80
- package/patched/cborg/lib/7float.js +0 -308
- package/patched/cborg/lib/bin.js +0 -189
- package/patched/cborg/lib/bl.js +0 -124
- package/patched/cborg/lib/byte-utils.js +0 -417
- package/patched/cborg/lib/common.js +0 -27
- package/patched/cborg/lib/decode.js +0 -209
- package/patched/cborg/lib/diagnostic.js +0 -156
- package/patched/cborg/lib/diagnostic_test.js +0 -117
- package/patched/cborg/lib/encode.js +0 -464
- package/patched/cborg/lib/is.js +0 -106
- package/patched/cborg/lib/json/decode.js +0 -462
- package/patched/cborg/lib/json/encode.js +0 -299
- package/patched/cborg/lib/json/json.js +0 -4
- package/patched/cborg/lib/jump.js +0 -209
- package/patched/cborg/lib/length.js +0 -61
- package/patched/cborg/lib/token.js +0 -76
- package/patched/cborg/package.json +0 -169
- package/patched/cborg/pnpm-lock.yaml +0 -6096
- package/patched/cborg/taglib.js +0 -73
- package/patched/cborg/test/appendix_a.js +0 -647
- package/patched/cborg/test/common.js +0 -18
- package/patched/cborg/test/node-test-bin.js +0 -402
- package/patched/cborg/test/noop-bin-test.js +0 -3
- package/patched/cborg/test/test-0uint.js +0 -103
- package/patched/cborg/test/test-1negint.js +0 -96
- package/patched/cborg/test/test-2bytes.js +0 -198
- package/patched/cborg/test/test-3string.js +0 -136
- package/patched/cborg/test/test-4array.js +0 -93
- package/patched/cborg/test/test-5map.js +0 -284
- package/patched/cborg/test/test-6tag.js +0 -85
- package/patched/cborg/test/test-7float.js +0 -131
- package/patched/cborg/test/test-bl.js +0 -37
- package/patched/cborg/test/test-cbor-vectors.js +0 -107
- package/patched/cborg/test/test-decode-errors.js +0 -65
- package/patched/cborg/test/test-fuzz.js +0 -42
- package/patched/cborg/test/test-json.js +0 -219
- package/patched/cborg/test/test-length.js +0 -65
- package/patched/cborg/test/test-partial.js +0 -111
- package/patched/cborg/tsconfig.json +0 -45
- package/patched/cborg/types/cborg.d.ts +0 -28
- package/patched/cborg/types/cborg.d.ts.map +0 -1
- package/patched/cborg/types/example.d.ts +0 -2
- package/patched/cborg/types/example.d.ts.map +0 -1
- package/patched/cborg/types/interface.d.ts +0 -47
- package/patched/cborg/types/interface.d.ts.map +0 -1
- package/patched/cborg/types/lib/0uint.d.ts +0 -100
- package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
- package/patched/cborg/types/lib/1negint.d.ts +0 -58
- package/patched/cborg/types/lib/1negint.d.ts.map +0 -1
- package/patched/cborg/types/lib/2bytes.d.ts +0 -68
- package/patched/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/patched/cborg/types/lib/3string.d.ts +0 -46
- package/patched/cborg/types/lib/3string.d.ts.map +0 -1
- package/patched/cborg/types/lib/4array.d.ts +0 -65
- package/patched/cborg/types/lib/4array.d.ts.map +0 -1
- package/patched/cborg/types/lib/5map.d.ts +0 -65
- package/patched/cborg/types/lib/5map.d.ts.map +0 -1
- package/patched/cborg/types/lib/6tag.d.ts +0 -61
- package/patched/cborg/types/lib/6tag.d.ts.map +0 -1
- package/patched/cborg/types/lib/7float.d.ts +0 -60
- package/patched/cborg/types/lib/7float.d.ts.map +0 -1
- package/patched/cborg/types/lib/bin.d.ts +0 -4
- package/patched/cborg/types/lib/bin.d.ts.map +0 -1
- package/patched/cborg/types/lib/bl.d.ts +0 -26
- package/patched/cborg/types/lib/bl.d.ts.map +0 -1
- package/patched/cborg/types/lib/byte-utils.d.ts +0 -53
- package/patched/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/patched/cborg/types/lib/common.d.ts +0 -10
- package/patched/cborg/types/lib/common.d.ts.map +0 -1
- package/patched/cborg/types/lib/decode.d.ts +0 -41
- package/patched/cborg/types/lib/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic.d.ts +0 -12
- package/patched/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/patched/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/patched/cborg/types/lib/encode.d.ts +0 -50
- package/patched/cborg/types/lib/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/is.d.ts +0 -6
- package/patched/cborg/types/lib/is.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/decode.d.ts +0 -67
- package/patched/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/encode.d.ts +0 -11
- package/patched/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/json.d.ts +0 -6
- package/patched/cborg/types/lib/json/json.d.ts.map +0 -1
- package/patched/cborg/types/lib/jump.d.ts +0 -12
- package/patched/cborg/types/lib/jump.d.ts.map +0 -1
- package/patched/cborg/types/lib/length.d.ts +0 -27
- package/patched/cborg/types/lib/length.d.ts.map +0 -1
- package/patched/cborg/types/lib/token.d.ts +0 -59
- package/patched/cborg/types/lib/token.d.ts.map +0 -1
- package/patched/cborg/types/taglib.d.ts +0 -18
- package/patched/cborg/types/taglib.d.ts.map +0 -1
- package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/@ipld/car/car/LICENSE +0 -4
- package/src/@ipld/car/car/README.md +0 -1078
- package/src/@ipld/car/car/dist/index.min.js +0 -5
- package/src/@ipld/car/car/dist/src/api.d.ts +0 -72
- package/src/@ipld/car/car/dist/src/api.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts +0 -67
- package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts +0 -116
- package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-reader.d.ts +0 -31
- package/src/@ipld/car/car/dist/src/buffer-reader.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/buffer-writer.d.ts +0 -86
- package/src/@ipld/car/car/dist/src/buffer-writer.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/coding.d.ts +0 -49
- package/src/@ipld/car/car/dist/src/coding.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/decoder-common.d.ts +0 -43
- package/src/@ipld/car/car/dist/src/decoder-common.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/decoder.d.ts +0 -87
- package/src/@ipld/car/car/dist/src/decoder.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/encoder.d.ts +0 -17
- package/src/@ipld/car/car/dist/src/encoder.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/header-validator.d.ts +0 -5
- package/src/@ipld/car/car/dist/src/header-validator.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/index-browser.d.ts +0 -10
- package/src/@ipld/car/car/dist/src/index-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/index.d.ts +0 -11
- package/src/@ipld/car/car/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts +0 -5
- package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/indexed-reader.d.ts +0 -152
- package/src/@ipld/car/car/dist/src/indexed-reader.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/indexer.d.ts +0 -95
- package/src/@ipld/car/car/dist/src/indexer.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/iterator-channel.d.ts +0 -7
- package/src/@ipld/car/car/dist/src/iterator-channel.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/iterator.d.ts +0 -174
- package/src/@ipld/car/car/dist/src/iterator.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/reader-browser.d.ts +0 -151
- package/src/@ipld/car/car/dist/src/reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/reader.d.ts +0 -35
- package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/writer-browser.d.ts +0 -155
- package/src/@ipld/car/car/dist/src/writer-browser.d.ts.map +0 -1
- package/src/@ipld/car/car/dist/src/writer.d.ts +0 -45
- package/src/@ipld/car/car/dist/src/writer.d.ts.map +0 -1
- package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
- package/src/@ipld/car/car/package.json +0 -235
- package/src/@ipld/car/car/src/api.ts +0 -90
- package/src/@ipld/car/car/src/buffer-decoder.js +0 -213
- package/src/@ipld/car/car/src/buffer-reader-browser.js +0 -144
- package/src/@ipld/car/car/src/buffer-reader.js +0 -51
- package/src/@ipld/car/car/src/buffer-writer.js +0 -286
- package/src/@ipld/car/car/src/coding.ts +0 -68
- package/src/@ipld/car/car/src/decoder-common.js +0 -82
- package/src/@ipld/car/car/src/decoder.js +0 -347
- package/src/@ipld/car/car/src/encoder.js +0 -76
- package/src/@ipld/car/car/src/header-validator.js +0 -214
- package/src/@ipld/car/car/src/header.ipldsch +0 -18
- package/src/@ipld/car/car/src/index-browser.js +0 -18
- package/src/@ipld/car/car/src/index.js +0 -21
- package/src/@ipld/car/car/src/indexed-reader-browser.js +0 -7
- package/src/@ipld/car/car/src/indexed-reader.js +0 -211
- package/src/@ipld/car/car/src/indexer.js +0 -130
- package/src/@ipld/car/car/src/iterator-channel.js +0 -91
- package/src/@ipld/car/car/src/iterator.js +0 -267
- package/src/@ipld/car/car/src/reader-browser.js +0 -194
- package/src/@ipld/car/car/src/reader.js +0 -56
- package/src/@ipld/car/car/src/writer-browser.js +0 -250
- package/src/@ipld/car/car/src/writer.js +0 -84
- package/src/@ipld/dag-cbor/dag-cbor/LICENSE +0 -4
- package/src/@ipld/dag-cbor/dag-cbor/README.md +0 -80
- package/src/@ipld/dag-cbor/dag-cbor/dist/index.min.js +0 -3
- package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts +0 -67
- package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-cbor/dag-cbor/package.json +0 -171
- package/src/@ipld/dag-cbor/dag-cbor/src/index.js +0 -147
- package/src/@ipld/dag-json/dag-json/LICENSE +0 -4
- package/src/@ipld/dag-json/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dag-json/dist/index.min.js +0 -3
- package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts +0 -12
- package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/package.json +0 -173
- package/src/@ipld/dag-json/dag-json/src/index.js +0 -291
- package/src/@web3-storage/pail/pail/LICENSE.md +0 -232
- package/src/@web3-storage/pail/pail/README.md +0 -84
- package/src/@web3-storage/pail/pail/cli.js +0 -218
- package/src/@web3-storage/pail/pail/dist/src/api.d.ts +0 -59
- package/src/@web3-storage/pail/pail/dist/src/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts +0 -31
- package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts +0 -75
- package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts +0 -3
- package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/block.d.ts +0 -35
- package/src/@web3-storage/pail/pail/dist/src/block.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts +0 -10
- package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts +0 -48
- package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts +0 -26
- package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts +0 -11
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts +0 -5
- package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts +0 -9
- package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/diff.d.ts +0 -13
- package/src/@web3-storage/pail/pail/dist/src/diff.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/index.d.ts +0 -10
- package/src/@web3-storage/pail/pail/dist/src/index.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/merge.d.ts +0 -5
- package/src/@web3-storage/pail/pail/dist/src/merge.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/src/shard.d.ts +0 -43
- package/src/@web3-storage/pail/pail/dist/src/shard.d.ts.map +0 -1
- package/src/@web3-storage/pail/pail/dist/tsconfig.tsbuildinfo +0 -1
- package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
- package/src/@web3-storage/pail/pail/package.json +0 -173
- package/src/@web3-storage/pail/pail/src/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/api.ts +0 -90
- package/src/@web3-storage/pail/pail/src/batch/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/batch/api.ts +0 -59
- package/src/@web3-storage/pail/pail/src/batch/index.js +0 -258
- package/src/@web3-storage/pail/pail/src/batch/shard.js +0 -13
- package/src/@web3-storage/pail/pail/src/block.js +0 -75
- package/src/@web3-storage/pail/pail/src/clock/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/clock/api.ts +0 -12
- package/src/@web3-storage/pail/pail/src/clock/index.js +0 -182
- package/src/@web3-storage/pail/pail/src/crdt/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/crdt/api.ts +0 -33
- package/src/@web3-storage/pail/pail/src/crdt/batch/api.js +0 -1
- package/src/@web3-storage/pail/pail/src/crdt/batch/api.ts +0 -30
- package/src/@web3-storage/pail/pail/src/crdt/batch/index.js +0 -155
- package/src/@web3-storage/pail/pail/src/crdt/index.js +0 -354
- package/src/@web3-storage/pail/pail/src/diff.js +0 -151
- package/src/@web3-storage/pail/pail/src/index.js +0 -406
- package/src/@web3-storage/pail/pail/src/merge.js +0 -43
- package/src/@web3-storage/pail/pail/src/shard.js +0 -180
- package/src/cborg/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/cborg/CHANGELOG.md +0 -513
- package/src/cborg/cborg/LICENSE +0 -13
- package/src/cborg/cborg/README.md +0 -515
- package/src/cborg/cborg/bench/bench.js +0 -117
- package/src/cborg/cborg/bench/json.js +0 -124
- package/src/cborg/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/cborg.js +0 -31
- package/src/cborg/cborg/example-bytestrings.js +0 -180
- package/src/cborg/cborg/example-json.js +0 -6
- package/src/cborg/cborg/example.js +0 -5
- package/src/cborg/cborg/interface.ts +0 -56
- package/src/cborg/cborg/lib/0uint.js +0 -227
- package/src/cborg/cborg/lib/1negint.js +0 -111
- package/src/cborg/cborg/lib/2bytes.js +0 -133
- package/src/cborg/cborg/lib/3string.js +0 -90
- package/src/cborg/cborg/lib/4array.js +0 -113
- package/src/cborg/cborg/lib/5map.js +0 -113
- package/src/cborg/cborg/lib/6tag.js +0 -80
- package/src/cborg/cborg/lib/7float.js +0 -308
- package/src/cborg/cborg/lib/bin.js +0 -189
- package/src/cborg/cborg/lib/bl.js +0 -124
- package/src/cborg/cborg/lib/byte-utils.js +0 -417
- package/src/cborg/cborg/lib/common.js +0 -27
- package/src/cborg/cborg/lib/decode.js +0 -209
- package/src/cborg/cborg/lib/diagnostic.js +0 -156
- package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
- package/src/cborg/cborg/lib/encode.js +0 -464
- package/src/cborg/cborg/lib/is.js +0 -106
- package/src/cborg/cborg/lib/json/decode.js +0 -462
- package/src/cborg/cborg/lib/json/encode.js +0 -299
- package/src/cborg/cborg/lib/json/json.js +0 -4
- package/src/cborg/cborg/lib/jump.js +0 -209
- package/src/cborg/cborg/lib/length.js +0 -61
- package/src/cborg/cborg/lib/token.js +0 -76
- package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
- package/src/cborg/cborg/package.json +0 -168
- package/src/cborg/cborg/taglib.js +0 -73
- package/src/cborg/cborg/test/appendix_a.js +0 -647
- package/src/cborg/cborg/test/common.js +0 -18
- package/src/cborg/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/cborg/test/test-0uint.js +0 -103
- package/src/cborg/cborg/test/test-1negint.js +0 -96
- package/src/cborg/cborg/test/test-2bytes.js +0 -198
- package/src/cborg/cborg/test/test-3string.js +0 -136
- package/src/cborg/cborg/test/test-4array.js +0 -93
- package/src/cborg/cborg/test/test-5map.js +0 -284
- package/src/cborg/cborg/test/test-6tag.js +0 -85
- package/src/cborg/cborg/test/test-7float.js +0 -131
- package/src/cborg/cborg/test/test-bl.js +0 -37
- package/src/cborg/cborg/test/test-cbor-vectors.js +0 -107
- package/src/cborg/cborg/test/test-decode-errors.js +0 -65
- package/src/cborg/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/cborg/test/test-json.js +0 -219
- package/src/cborg/cborg/test/test-length.js +0 -65
- package/src/cborg/cborg/test/test-partial.js +0 -111
- package/src/cborg/cborg/tsconfig.json +0 -45
- package/src/cborg/cborg/types/cborg.d.ts +0 -28
- package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/example.d.ts +0 -2
- package/src/cborg/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/cborg/types/interface.d.ts +0 -47
- package/src/cborg/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
- package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
- package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/2bytes.d.ts +0 -68
- package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/3string.d.ts +0 -46
- package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
- package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/5map.d.ts +0 -65
- package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
- package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/7float.d.ts +0 -60
- package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
- package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
- package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
- package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/common.d.ts +0 -10
- package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
- package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
- package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
- package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/is.d.ts +0 -6
- package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
- package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
- package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
- package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/length.d.ts +0 -27
- package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/token.d.ts +0 -59
- package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
- package/src/cborg/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/README.md +0 -105
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/index.min.js +0 -3
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js +0 -197
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/package.json +0 -180
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/errors.ts +0 -87
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/index.ts +0 -498
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as API from './api.js'
|
|
3
|
-
import { ShardFetcher } from './shard.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {string} K
|
|
7
|
-
* @typedef {[before: null, after: API.UnknownLink]} AddV
|
|
8
|
-
* @typedef {[before: API.UnknownLink, after: API.UnknownLink]} UpdateV
|
|
9
|
-
* @typedef {[before: API.UnknownLink, after: null]} DeleteV
|
|
10
|
-
* @typedef {[key: K, value: AddV|UpdateV|DeleteV]} KV
|
|
11
|
-
* @typedef {KV[]} KeysDiff
|
|
12
|
-
* @typedef {{ keys: KeysDiff, shards: API.ShardDiff }} CombinedDiff
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
17
|
-
* @param {API.ShardLink} a Base DAG.
|
|
18
|
-
* @param {API.ShardLink} b Comparison DAG.
|
|
19
|
-
* @returns {Promise<CombinedDiff>}
|
|
20
|
-
*/
|
|
21
|
-
export const difference = async (blocks, a, b) => {
|
|
22
|
-
if (isEqual(a, b)) return { keys: [], shards: { additions: [], removals: [] } }
|
|
23
|
-
|
|
24
|
-
const shards = new ShardFetcher(blocks)
|
|
25
|
-
const [ashard, bshard] = await Promise.all([shards.get(a), shards.get(b)])
|
|
26
|
-
|
|
27
|
-
const aents = new Map(ashard.value.entries)
|
|
28
|
-
const bents = new Map(bshard.value.entries)
|
|
29
|
-
|
|
30
|
-
const keys = /** @type {Map<K, AddV|UpdateV|DeleteV>} */(new Map())
|
|
31
|
-
const additions = new Map([[bshard.cid.toString(), bshard]])
|
|
32
|
-
const removals = new Map([[ashard.cid.toString(), ashard]])
|
|
33
|
-
|
|
34
|
-
// find shards removed in B
|
|
35
|
-
for (const [akey, aval] of ashard.value.entries) {
|
|
36
|
-
const bval = bents.get(akey)
|
|
37
|
-
if (bval) continue
|
|
38
|
-
if (!Array.isArray(aval)) {
|
|
39
|
-
keys.set(`${ashard.value.prefix}${akey}`, [aval, null])
|
|
40
|
-
continue
|
|
41
|
-
}
|
|
42
|
-
// if shard link _with_ value
|
|
43
|
-
if (aval[1] != null) {
|
|
44
|
-
keys.set(`${ashard.value.prefix}${akey}`, [aval[1], null])
|
|
45
|
-
}
|
|
46
|
-
for await (const s of collect(shards, aval[0])) {
|
|
47
|
-
for (const [k, v] of s.value.entries) {
|
|
48
|
-
if (!Array.isArray(v)) {
|
|
49
|
-
keys.set(`${s.value.prefix}${k}`, [v, null])
|
|
50
|
-
} else if (v[1] != null) {
|
|
51
|
-
keys.set(`${s.value.prefix}${k}`, [v[1], null])
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
removals.set(s.cid.toString(), s)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// find shards added or updated in B
|
|
59
|
-
for (const [bkey, bval] of bshard.value.entries) {
|
|
60
|
-
const aval = aents.get(bkey)
|
|
61
|
-
if (!Array.isArray(bval)) {
|
|
62
|
-
if (!aval) {
|
|
63
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [null, bval])
|
|
64
|
-
} else if (Array.isArray(aval)) {
|
|
65
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [aval[1] ?? null, bval])
|
|
66
|
-
} else if (!isEqual(aval, bval)) {
|
|
67
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [aval, bval])
|
|
68
|
-
}
|
|
69
|
-
continue
|
|
70
|
-
}
|
|
71
|
-
if (aval && Array.isArray(aval)) { // updated in B
|
|
72
|
-
if (isEqual(aval[0], bval[0])) {
|
|
73
|
-
if (bval[1] != null && (aval[1] == null || !isEqual(aval[1], bval[1]))) {
|
|
74
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [aval[1] ?? null, bval[1]])
|
|
75
|
-
}
|
|
76
|
-
continue // updated value?
|
|
77
|
-
}
|
|
78
|
-
const res = await difference(blocks, aval[0], bval[0])
|
|
79
|
-
for (const shard of res.shards.additions) {
|
|
80
|
-
additions.set(shard.cid.toString(), shard)
|
|
81
|
-
}
|
|
82
|
-
for (const shard of res.shards.removals) {
|
|
83
|
-
removals.set(shard.cid.toString(), shard)
|
|
84
|
-
}
|
|
85
|
-
for (const [k, v] of res.keys) {
|
|
86
|
-
keys.set(k, v)
|
|
87
|
-
}
|
|
88
|
-
} else if (aval) { // updated in B value => link+value
|
|
89
|
-
if (bval[1] == null) {
|
|
90
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [aval, null])
|
|
91
|
-
} else if (!isEqual(aval, bval[1])) {
|
|
92
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [aval, bval[1]])
|
|
93
|
-
}
|
|
94
|
-
for await (const s of collect(shards, bval[0])) {
|
|
95
|
-
for (const [k, v] of s.value.entries) {
|
|
96
|
-
if (!Array.isArray(v)) {
|
|
97
|
-
keys.set(`${s.value.prefix}${k}`, [null, v])
|
|
98
|
-
} else if (v[1] != null) {
|
|
99
|
-
keys.set(`${s.value.prefix}${k}`, [null, v[1]])
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
additions.set(s.cid.toString(), s)
|
|
103
|
-
}
|
|
104
|
-
} else { // added in B
|
|
105
|
-
keys.set(`${bshard.value.prefix}${bkey}`, [null, bval[0]])
|
|
106
|
-
for await (const s of collect(shards, bval[0])) {
|
|
107
|
-
for (const [k, v] of s.value.entries) {
|
|
108
|
-
if (!Array.isArray(v)) {
|
|
109
|
-
keys.set(`${s.value.prefix}${k}`, [null, v])
|
|
110
|
-
} else if (v[1] != null) {
|
|
111
|
-
keys.set(`${s.value.prefix}${k}`, [null, v[1]])
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
additions.set(s.cid.toString(), s)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// filter blocks that were added _and_ removed from B
|
|
120
|
-
for (const k of removals.keys()) {
|
|
121
|
-
if (additions.has(k)) {
|
|
122
|
-
additions.delete(k)
|
|
123
|
-
removals.delete(k)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
keys: [...keys.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1),
|
|
129
|
-
shards: { additions: [...additions.values()], removals: [...removals.values()] }
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param {API.UnknownLink} a
|
|
135
|
-
* @param {API.UnknownLink} b
|
|
136
|
-
*/
|
|
137
|
-
const isEqual = (a, b) => a.toString() === b.toString()
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* @param {import('./shard.js').ShardFetcher} shards
|
|
141
|
-
* @param {API.ShardLink} root
|
|
142
|
-
* @returns {AsyncIterableIterator<API.ShardBlockView>}
|
|
143
|
-
*/
|
|
144
|
-
async function * collect (shards, root) {
|
|
145
|
-
const shard = await shards.get(root)
|
|
146
|
-
yield shard
|
|
147
|
-
for (const [, v] of shard.value.entries) {
|
|
148
|
-
if (!Array.isArray(v)) continue
|
|
149
|
-
yield * collect(shards, v[0])
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as API from './api.js'
|
|
3
|
-
import { ShardFetcher, isPrintableASCII } from './shard.js'
|
|
4
|
-
import * as Shard from './shard.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Put a value (a CID) for the given key. If the key exists it's value is
|
|
8
|
-
* overwritten.
|
|
9
|
-
*
|
|
10
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
11
|
-
* @param {API.ShardLink} root CID of the root node of the bucket.
|
|
12
|
-
* @param {string} key The key of the value to put.
|
|
13
|
-
* @param {API.UnknownLink} value The value to put.
|
|
14
|
-
* @returns {Promise<{ root: API.ShardLink } & API.ShardDiff>}
|
|
15
|
-
*/
|
|
16
|
-
export const put = async (blocks, root, key, value) => {
|
|
17
|
-
const shards = new ShardFetcher(blocks)
|
|
18
|
-
const rshard = await shards.get(root)
|
|
19
|
-
|
|
20
|
-
if (rshard.value.keyChars !== Shard.KeyCharsASCII) {
|
|
21
|
-
throw new Error(`unsupported key character set: ${rshard.value.keyChars}`)
|
|
22
|
-
}
|
|
23
|
-
if (!isPrintableASCII(key)) {
|
|
24
|
-
throw new Error('key contains non-ASCII characters')
|
|
25
|
-
}
|
|
26
|
-
// ensure utf8 encoded key is smaller than max
|
|
27
|
-
if (new TextEncoder().encode(key).length > rshard.value.maxKeySize) {
|
|
28
|
-
throw new Error(`UTF-8 encoded key exceeds max size of ${rshard.value.maxKeySize} bytes`)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const path = await traverse(shards, rshard, key)
|
|
32
|
-
const target = path[path.length - 1]
|
|
33
|
-
const skey = key.slice(target.value.prefix.length) // key within the shard
|
|
34
|
-
|
|
35
|
-
/** @type {API.ShardEntry} */
|
|
36
|
-
let entry = [skey, value]
|
|
37
|
-
let targetEntries = [...target.value.entries]
|
|
38
|
-
|
|
39
|
-
/** @type {API.ShardBlockView[]} */
|
|
40
|
-
const additions = []
|
|
41
|
-
|
|
42
|
-
for (const [i, e] of targetEntries.entries()) {
|
|
43
|
-
const [k, v] = e
|
|
44
|
-
|
|
45
|
-
// is this just a replace?
|
|
46
|
-
if (k === skey) break
|
|
47
|
-
|
|
48
|
-
// do we need to shard this entry?
|
|
49
|
-
const shortest = k.length < skey.length ? k : skey
|
|
50
|
-
const other = shortest === k ? skey : k
|
|
51
|
-
let common = ''
|
|
52
|
-
for (const char of shortest) {
|
|
53
|
-
const next = common + char
|
|
54
|
-
if (!other.startsWith(next)) break
|
|
55
|
-
common = next
|
|
56
|
-
}
|
|
57
|
-
if (common.length) {
|
|
58
|
-
/** @type {API.ShardEntry[]} */
|
|
59
|
-
let entries = []
|
|
60
|
-
|
|
61
|
-
// if the existing entry key or new key is equal to the common prefix,
|
|
62
|
-
// then the existing value / new value needs to persist in the parent
|
|
63
|
-
// shard. Otherwise they persist in this new shard.
|
|
64
|
-
if (common !== skey) {
|
|
65
|
-
entries = Shard.putEntry(entries, [skey.slice(common.length), value])
|
|
66
|
-
}
|
|
67
|
-
if (common !== k) {
|
|
68
|
-
entries = Shard.putEntry(entries, [k.slice(common.length), v])
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let child = await Shard.encodeBlock(
|
|
72
|
-
Shard.withEntries(entries, { ...target.value, prefix: target.value.prefix + common })
|
|
73
|
-
)
|
|
74
|
-
additions.push(child)
|
|
75
|
-
|
|
76
|
-
// need to spread as access by index does not consider utf-16 surrogates
|
|
77
|
-
const commonChars = [...common]
|
|
78
|
-
|
|
79
|
-
// create parent shards for each character of the common prefix
|
|
80
|
-
for (let i = commonChars.length - 1; i > 0; i--) {
|
|
81
|
-
const parentConfig = { ...target.value, prefix: target.value.prefix + commonChars.slice(0, i).join('') }
|
|
82
|
-
/** @type {API.ShardEntryLinkValue | API.ShardEntryValueValue | API.ShardEntryLinkAndValueValue} */
|
|
83
|
-
let parentValue
|
|
84
|
-
// if the first iteration and the existing entry key is equal to the
|
|
85
|
-
// common prefix, then existing value needs to persist in this parent
|
|
86
|
-
if (i === commonChars.length - 1 && common === k) {
|
|
87
|
-
if (Array.isArray(v)) throw new Error('found a shard link when expecting a value')
|
|
88
|
-
parentValue = [child.cid, v]
|
|
89
|
-
} else if (i === commonChars.length - 1 && common === skey) {
|
|
90
|
-
parentValue = [child.cid, value]
|
|
91
|
-
} else {
|
|
92
|
-
parentValue = [child.cid]
|
|
93
|
-
}
|
|
94
|
-
const parent = await Shard.encodeBlock(Shard.withEntries([[commonChars[i], parentValue]], parentConfig))
|
|
95
|
-
additions.push(parent)
|
|
96
|
-
child = parent
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// remove the sharded entry
|
|
100
|
-
targetEntries.splice(i, 1)
|
|
101
|
-
|
|
102
|
-
// create the entry that will be added to target
|
|
103
|
-
if (commonChars.length === 1 && common === k) {
|
|
104
|
-
if (Array.isArray(v)) throw new Error('found a shard link when expecting a value')
|
|
105
|
-
entry = [commonChars[0], [child.cid, v]]
|
|
106
|
-
} else if (commonChars.length === 1 && common === skey) {
|
|
107
|
-
entry = [commonChars[0], [child.cid, value]]
|
|
108
|
-
} else {
|
|
109
|
-
entry = [commonChars[0], [child.cid]]
|
|
110
|
-
}
|
|
111
|
-
break
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const shard = Shard.withEntries(Shard.putEntry(targetEntries, entry), target.value)
|
|
116
|
-
let child = await Shard.encodeBlock(shard)
|
|
117
|
-
|
|
118
|
-
// if no change in the target then we're done
|
|
119
|
-
if (child.cid.toString() === target.cid.toString()) {
|
|
120
|
-
return { root, additions: [], removals: [] }
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
additions.push(child)
|
|
124
|
-
|
|
125
|
-
// path is root -> target, so work backwards, propagating the new shard CID
|
|
126
|
-
for (let i = path.length - 2; i >= 0; i--) {
|
|
127
|
-
const parent = path[i]
|
|
128
|
-
const key = child.value.prefix.slice(parent.value.prefix.length)
|
|
129
|
-
const value = Shard.withEntries(
|
|
130
|
-
parent.value.entries.map((entry) => {
|
|
131
|
-
const [k, v] = entry
|
|
132
|
-
if (k !== key) return entry
|
|
133
|
-
if (!Array.isArray(v)) throw new Error(`"${key}" is not a shard link in: ${parent.cid}`)
|
|
134
|
-
return /** @type {API.ShardEntry} */(v[1] == null ? [k, [child.cid]] : [k, [child.cid, v[1]]])
|
|
135
|
-
}),
|
|
136
|
-
parent.value
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
child = await Shard.encodeBlock(value)
|
|
140
|
-
additions.push(child)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return { root: additions[additions.length - 1].cid, additions, removals: path }
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Get the stored value for the given key from the bucket. If the key is not
|
|
148
|
-
* found, `undefined` is returned.
|
|
149
|
-
*
|
|
150
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
151
|
-
* @param {API.ShardLink} root CID of the root node of the bucket.
|
|
152
|
-
* @param {string} key The key of the value to get.
|
|
153
|
-
* @returns {Promise<API.UnknownLink | undefined>}
|
|
154
|
-
*/
|
|
155
|
-
export const get = async (blocks, root, key) => {
|
|
156
|
-
const shards = new ShardFetcher(blocks)
|
|
157
|
-
const rshard = await shards.get(root)
|
|
158
|
-
const path = await traverse(shards, rshard, key)
|
|
159
|
-
const target = path[path.length - 1]
|
|
160
|
-
const skey = key.slice(target.value.prefix.length) // key within the shard
|
|
161
|
-
const entry = target.value.entries.find(([k]) => k === skey)
|
|
162
|
-
if (!entry) return
|
|
163
|
-
return Array.isArray(entry[1]) ? entry[1][1] : entry[1]
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Delete the value for the given key from the bucket. If the key is not found
|
|
168
|
-
* no operation occurs.
|
|
169
|
-
*
|
|
170
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
171
|
-
* @param {API.ShardLink} root CID of the root node of the bucket.
|
|
172
|
-
* @param {string} key The key of the value to delete.
|
|
173
|
-
* @returns {Promise<{ root: API.ShardLink } & API.ShardDiff>}
|
|
174
|
-
*/
|
|
175
|
-
export const del = async (blocks, root, key) => {
|
|
176
|
-
const shards = new ShardFetcher(blocks)
|
|
177
|
-
const rshard = await shards.get(root)
|
|
178
|
-
const path = await traverse(shards, rshard, key)
|
|
179
|
-
const target = path[path.length - 1]
|
|
180
|
-
const skey = key.slice(target.value.prefix.length) // key within the shard
|
|
181
|
-
|
|
182
|
-
const entryidx = target.value.entries.findIndex(([k]) => k === skey)
|
|
183
|
-
if (entryidx === -1) return { root, additions: [], removals: [] }
|
|
184
|
-
|
|
185
|
-
const entry = target.value.entries[entryidx]
|
|
186
|
-
// cannot delete a shard (without data)
|
|
187
|
-
if (Array.isArray(entry[1]) && entry[1][1] == null) {
|
|
188
|
-
return { root, additions: [], removals: [] }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/** @type {API.ShardBlockView[]} */
|
|
192
|
-
const additions = []
|
|
193
|
-
/** @type {API.ShardBlockView[]} */
|
|
194
|
-
const removals = [...path]
|
|
195
|
-
|
|
196
|
-
let shard = Shard.withEntries([...target.value.entries], target.value)
|
|
197
|
-
|
|
198
|
-
if (Array.isArray(entry[1])) {
|
|
199
|
-
// remove the value from this link+value
|
|
200
|
-
shard.entries[entryidx] = [entry[0], [entry[1][0]]]
|
|
201
|
-
} else {
|
|
202
|
-
shard.entries.splice(entryidx, 1)
|
|
203
|
-
// if now empty, remove from parent
|
|
204
|
-
while (!shard.entries.length) {
|
|
205
|
-
const child = path[path.length - 1]
|
|
206
|
-
const parent = path[path.length - 2]
|
|
207
|
-
if (!parent) break
|
|
208
|
-
path.pop()
|
|
209
|
-
shard = Shard.withEntries(
|
|
210
|
-
parent.value.entries.filter(e => {
|
|
211
|
-
if (!Array.isArray(e[1])) return true
|
|
212
|
-
return e[1][0].toString() !== child.cid.toString()
|
|
213
|
-
}),
|
|
214
|
-
parent.value
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
let child = await Shard.encodeBlock(shard)
|
|
220
|
-
additions.push(child)
|
|
221
|
-
|
|
222
|
-
// path is root -> shard, so work backwards, propagating the new shard CID
|
|
223
|
-
for (let i = path.length - 2; i >= 0; i--) {
|
|
224
|
-
const parent = path[i]
|
|
225
|
-
const key = child.value.prefix.slice(parent.value.prefix.length)
|
|
226
|
-
const value = Shard.withEntries(
|
|
227
|
-
parent.value.entries.map((entry) => {
|
|
228
|
-
const [k, v] = entry
|
|
229
|
-
if (k !== key) return entry
|
|
230
|
-
if (!Array.isArray(v)) throw new Error(`"${key}" is not a shard link in: ${parent.cid}`)
|
|
231
|
-
return /** @type {API.ShardEntry} */(v[1] == null ? [k, [child.cid]] : [k, [child.cid, v[1]]])
|
|
232
|
-
}),
|
|
233
|
-
parent.value
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
child = await Shard.encodeBlock(value)
|
|
237
|
-
additions.push(child)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return { root: additions[additions.length - 1].cid, additions, removals }
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @param {API.EntriesOptions} [options]
|
|
245
|
-
* @returns {options is API.KeyPrefixOption}
|
|
246
|
-
*/
|
|
247
|
-
const isKeyPrefixOption = options => {
|
|
248
|
-
const opts = options ?? {}
|
|
249
|
-
return 'prefix' in opts && Boolean(opts.prefix)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* @param {API.EntriesOptions} [options]
|
|
254
|
-
* @returns {options is API.KeyRangeOption}
|
|
255
|
-
*/
|
|
256
|
-
const isKeyRangeOption = options => {
|
|
257
|
-
const opts = options ?? {}
|
|
258
|
-
return ('gt' in opts && Boolean(opts.gt)) || ('gte' in opts && Boolean(opts.gte)) || ('lt' in opts && Boolean(opts.lt)) || ('lte' in opts && Boolean(opts.lte))
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @param {API.KeyRangeOption} options
|
|
263
|
-
* @returns {options is API.KeyLowerBoundRangeOption}
|
|
264
|
-
*/
|
|
265
|
-
const isKeyLowerBoundRangeOption = options => ('gt' in options && Boolean(options.gt)) || ('gte' in options && Boolean(options.gte))
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* @param {API.KeyLowerBoundRangeOption} options
|
|
269
|
-
* @returns {options is API.KeyLowerBoundRangeInclusiveOption}
|
|
270
|
-
*/
|
|
271
|
-
const isKeyLowerBoundRangeInclusiveOption = options => 'gte' in options && Boolean(options.gte)
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* @param {API.KeyLowerBoundRangeOption} options
|
|
275
|
-
* @returns {options is API.KeyLowerBoundRangeExclusiveOption}
|
|
276
|
-
*/
|
|
277
|
-
const isKeyLowerBoundRangeExclusiveOption = options => 'gt' in options && Boolean(options.gt)
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* @param {API.KeyRangeOption} options
|
|
281
|
-
* @returns {options is API.KeyUpperBoundRangeOption}
|
|
282
|
-
*/
|
|
283
|
-
const isKeyUpperBoundRangeOption = options => ('lt' in options && Boolean(options.lt)) || ('lte' in options && Boolean(options.lte))
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* @param {API.KeyUpperBoundRangeOption} options
|
|
287
|
-
* @returns {options is API.KeyUpperBoundRangeInclusiveOption}
|
|
288
|
-
*/
|
|
289
|
-
const isKeyUpperBoundRangeInclusiveOption = options => 'lte' in options && Boolean(options.lte)
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* @param {API.KeyUpperBoundRangeOption} options
|
|
293
|
-
* @returns {options is API.KeyUpperBoundRangeExclusiveOption}
|
|
294
|
-
*/
|
|
295
|
-
const isKeyUpperBoundRangeExclusiveOption = options => 'lt' in options && Boolean(options.lt)
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* List entries in the bucket.
|
|
299
|
-
*
|
|
300
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
301
|
-
* @param {API.ShardLink} root CID of the root node of the bucket.
|
|
302
|
-
* @param {API.EntriesOptions} [options]
|
|
303
|
-
* @returns {AsyncIterableIterator<API.ShardValueEntry>}
|
|
304
|
-
*/
|
|
305
|
-
export const entries = async function * (blocks, root, options) {
|
|
306
|
-
const hasKeyPrefix = isKeyPrefixOption(options)
|
|
307
|
-
const hasKeyRange = isKeyRangeOption(options)
|
|
308
|
-
const hasKeyLowerBoundRange = hasKeyRange && isKeyLowerBoundRangeOption(options)
|
|
309
|
-
const hasKeyLowerBoundRangeInclusive = hasKeyLowerBoundRange && isKeyLowerBoundRangeInclusiveOption(options)
|
|
310
|
-
const hasKeyLowerBoundRangeExclusive = hasKeyLowerBoundRange && isKeyLowerBoundRangeExclusiveOption(options)
|
|
311
|
-
const hasKeyUpperBoundRange = hasKeyRange && isKeyUpperBoundRangeOption(options)
|
|
312
|
-
const hasKeyUpperBoundRangeInclusive = hasKeyUpperBoundRange && isKeyUpperBoundRangeInclusiveOption(options)
|
|
313
|
-
const hasKeyUpperBoundRangeExclusive = hasKeyUpperBoundRange && isKeyUpperBoundRangeExclusiveOption(options)
|
|
314
|
-
const hasKeyUpperAndLowerBoundRange = hasKeyLowerBoundRange && hasKeyUpperBoundRange
|
|
315
|
-
|
|
316
|
-
const shards = new ShardFetcher(blocks)
|
|
317
|
-
const rshard = await shards.get(root)
|
|
318
|
-
|
|
319
|
-
yield * (
|
|
320
|
-
/** @returns {AsyncIterableIterator<API.ShardValueEntry>} */
|
|
321
|
-
(async function* ents(shard) {
|
|
322
|
-
for (const entry of shard.value.entries) {
|
|
323
|
-
const key = shard.value.prefix + entry[0]
|
|
324
|
-
|
|
325
|
-
// if array, this is a link to a shard
|
|
326
|
-
if (Array.isArray(entry[1])) {
|
|
327
|
-
if (entry[1][1]) {
|
|
328
|
-
if (
|
|
329
|
-
(hasKeyPrefix && key.startsWith(options.prefix)) ||
|
|
330
|
-
(hasKeyUpperAndLowerBoundRange && (
|
|
331
|
-
((hasKeyLowerBoundRangeExclusive && key > options.gt) || (hasKeyLowerBoundRangeInclusive && key >= options.gte)) &&
|
|
332
|
-
((hasKeyUpperBoundRangeExclusive && key < options.lt) || (hasKeyUpperBoundRangeInclusive && key <= options.lte))
|
|
333
|
-
)) ||
|
|
334
|
-
(hasKeyLowerBoundRangeExclusive && key > options.gt) ||
|
|
335
|
-
(hasKeyLowerBoundRangeInclusive && key >= options.gte) ||
|
|
336
|
-
(hasKeyUpperBoundRangeExclusive && key < options.lt) ||
|
|
337
|
-
(hasKeyUpperBoundRangeInclusive && key <= options.lte) ||
|
|
338
|
-
(!hasKeyPrefix && !hasKeyRange)
|
|
339
|
-
) {
|
|
340
|
-
yield [key, entry[1][1]]
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (hasKeyPrefix) {
|
|
345
|
-
if (options.prefix.length <= key.length && !key.startsWith(options.prefix)) {
|
|
346
|
-
continue
|
|
347
|
-
}
|
|
348
|
-
if (options.prefix.length > key.length && !options.prefix.startsWith(key)) {
|
|
349
|
-
continue
|
|
350
|
-
}
|
|
351
|
-
} else if (
|
|
352
|
-
(hasKeyLowerBoundRangeExclusive && (trunc(key, Math.min(key.length, options.gt.length)) < trunc(options.gt, Math.min(key.length, options.gt.length)))) ||
|
|
353
|
-
(hasKeyLowerBoundRangeInclusive && (trunc(key, Math.min(key.length, options.gte.length)) < trunc(options.gte, Math.min(key.length, options.gte.length)))) ||
|
|
354
|
-
(hasKeyUpperBoundRangeExclusive && (trunc(key, Math.min(key.length, options.lt.length)) > trunc(options.lt, Math.min(key.length, options.lt.length)))) ||
|
|
355
|
-
(hasKeyUpperBoundRangeInclusive && (trunc(key, Math.min(key.length, options.lte.length)) > trunc(options.lte, Math.min(key.length, options.lte.length))))
|
|
356
|
-
) {
|
|
357
|
-
continue
|
|
358
|
-
}
|
|
359
|
-
yield * ents(await shards.get(entry[1][0]))
|
|
360
|
-
} else {
|
|
361
|
-
if (
|
|
362
|
-
(hasKeyPrefix && key.startsWith(options.prefix)) ||
|
|
363
|
-
(hasKeyRange && hasKeyUpperAndLowerBoundRange && (
|
|
364
|
-
((hasKeyLowerBoundRangeExclusive && key > options.gt) || (hasKeyLowerBoundRangeInclusive && key >= options.gte)) &&
|
|
365
|
-
((hasKeyUpperBoundRangeExclusive && key < options.lt) || (hasKeyUpperBoundRangeInclusive && key <= options.lte))
|
|
366
|
-
)) ||
|
|
367
|
-
(hasKeyRange && !hasKeyUpperAndLowerBoundRange && (
|
|
368
|
-
(hasKeyLowerBoundRangeExclusive && key > options.gt) || (hasKeyLowerBoundRangeInclusive && key >= options.gte) ||
|
|
369
|
-
(hasKeyUpperBoundRangeExclusive && key < options.lt) || (hasKeyUpperBoundRangeInclusive && key <= options.lte)
|
|
370
|
-
)) ||
|
|
371
|
-
(!hasKeyPrefix && !hasKeyRange)
|
|
372
|
-
) {
|
|
373
|
-
yield [key, entry[1]]
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
})
|
|
378
|
-
)(rshard)
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* @param {string} str
|
|
383
|
-
* @param {number} len
|
|
384
|
-
*/
|
|
385
|
-
const trunc = (str, len) => str.length <= len ? str : str.slice(0, len)
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Traverse from the passed shard block to the target shard block using the
|
|
389
|
-
* passed key. All traversed shards are returned, starting with the passed
|
|
390
|
-
* shard and ending with the target.
|
|
391
|
-
*
|
|
392
|
-
* @param {ShardFetcher} shards
|
|
393
|
-
* @param {API.ShardBlockView} shard
|
|
394
|
-
* @param {string} key
|
|
395
|
-
* @returns {Promise<[API.ShardBlockView, ...Array<API.ShardBlockView>]>}
|
|
396
|
-
*/
|
|
397
|
-
const traverse = async (shards, shard, key) => {
|
|
398
|
-
for (const [k, v] of shard.value.entries) {
|
|
399
|
-
if (key === k) return [shard]
|
|
400
|
-
if (key.startsWith(k) && Array.isArray(v)) {
|
|
401
|
-
const path = await traverse(shards, await shards.get(v[0]), key.slice(k.length))
|
|
402
|
-
return [shard, ...path]
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return [shard]
|
|
406
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as API from './api.js'
|
|
3
|
-
import { difference } from './diff.js'
|
|
4
|
-
import { put, del } from './index.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {API.BlockFetcher} blocks Bucket block storage.
|
|
8
|
-
* @param {API.ShardLink} base Merge base. Common parent of target DAGs.
|
|
9
|
-
* @param {API.ShardLink[]} targets Target DAGs to merge.
|
|
10
|
-
* @returns {Promise<{ root: API.ShardLink } & API.ShardDiff>}
|
|
11
|
-
*/
|
|
12
|
-
export const merge = async (blocks, base, targets) => {
|
|
13
|
-
const diffs = await Promise.all(targets.map(t => difference(blocks, base, t)))
|
|
14
|
-
const additions = new Map()
|
|
15
|
-
const removals = new Map()
|
|
16
|
-
/** @type {API.BlockFetcher} */
|
|
17
|
-
const fetcher = { get: cid => additions.get(cid.toString()) ?? blocks.get(cid) }
|
|
18
|
-
|
|
19
|
-
let root = base
|
|
20
|
-
for (const { keys } of diffs) {
|
|
21
|
-
for (const [k, v] of keys) {
|
|
22
|
-
let res
|
|
23
|
-
if (v[1] == null) {
|
|
24
|
-
res = await del(fetcher, root, k)
|
|
25
|
-
} else {
|
|
26
|
-
res = await put(fetcher, root, k, v[1])
|
|
27
|
-
}
|
|
28
|
-
for (const blk of res.removals) {
|
|
29
|
-
if (additions.has(blk.cid.toString())) {
|
|
30
|
-
additions.delete(blk.cid.toString())
|
|
31
|
-
} else {
|
|
32
|
-
removals.set(blk.cid.toString(), blk)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
for (const blk of res.additions) {
|
|
36
|
-
additions.set(blk.cid.toString(), blk)
|
|
37
|
-
}
|
|
38
|
-
root = res.root
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return { root, additions: [...additions.values()], removals: [...removals.values()] }
|
|
43
|
-
}
|