@aztec-labs/foundation 6.0.0-nightly.20260829
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/README.md +1 -0
- package/dest/array/array.d.ts +68 -0
- package/dest/array/array.d.ts.map +1 -0
- package/dest/array/array.js +100 -0
- package/dest/array/index.d.ts +3 -0
- package/dest/array/index.d.ts.map +1 -0
- package/dest/array/index.js +2 -0
- package/dest/array/sorted_array.d.ts +15 -0
- package/dest/array/sorted_array.d.ts.map +1 -0
- package/dest/array/sorted_array.js +109 -0
- package/dest/async-map/index.d.ts +13 -0
- package/dest/async-map/index.d.ts.map +1 -0
- package/dest/async-map/index.js +17 -0
- package/dest/async-pool/index.d.ts +3 -0
- package/dest/async-pool/index.d.ts.map +1 -0
- package/dest/async-pool/index.js +48 -0
- package/dest/bigint/index.d.ts +7 -0
- package/dest/bigint/index.d.ts.map +1 -0
- package/dest/bigint/index.js +15 -0
- package/dest/bigint-buffer/index.d.ts +40 -0
- package/dest/bigint-buffer/index.d.ts.map +1 -0
- package/dest/bigint-buffer/index.js +81 -0
- package/dest/branded-types/block_number.d.ts +56 -0
- package/dest/branded-types/block_number.d.ts.map +1 -0
- package/dest/branded-types/block_number.js +89 -0
- package/dest/branded-types/buffer32_hash.d.ts +27 -0
- package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
- package/dest/branded-types/buffer32_hash.js +12 -0
- package/dest/branded-types/checkpoint_number.d.ts +60 -0
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -0
- package/dest/branded-types/checkpoint_number.js +88 -0
- package/dest/branded-types/epoch.d.ts +42 -0
- package/dest/branded-types/epoch.d.ts.map +1 -0
- package/dest/branded-types/epoch.js +59 -0
- package/dest/branded-types/index.d.ts +8 -0
- package/dest/branded-types/index.d.ts.map +1 -0
- package/dest/branded-types/index.js +6 -0
- package/dest/branded-types/index_within_checkpoint.d.ts +42 -0
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -0
- package/dest/branded-types/index_within_checkpoint.js +59 -0
- package/dest/branded-types/slot.d.ts +45 -0
- package/dest/branded-types/slot.d.ts.map +1 -0
- package/dest/branded-types/slot.js +62 -0
- package/dest/branded-types/types.d.ts +5 -0
- package/dest/branded-types/types.d.ts.map +1 -0
- package/dest/branded-types/types.js +1 -0
- package/dest/buffer/buffer16.d.ts +82 -0
- package/dest/buffer/buffer16.d.ts.map +1 -0
- package/dest/buffer/buffer16.js +102 -0
- package/dest/buffer/buffer32.d.ts +54 -0
- package/dest/buffer/buffer32.d.ts.map +1 -0
- package/dest/buffer/buffer32.js +83 -0
- package/dest/buffer/index.d.ts +4 -0
- package/dest/buffer/index.d.ts.map +1 -0
- package/dest/buffer/index.js +3 -0
- package/dest/buffer/utils.d.ts +3 -0
- package/dest/buffer/utils.d.ts.map +1 -0
- package/dest/buffer/utils.js +7 -0
- package/dest/collection/array.d.ts +135 -0
- package/dest/collection/array.d.ts.map +1 -0
- package/dest/collection/array.js +302 -0
- package/dest/collection/index.d.ts +5 -0
- package/dest/collection/index.d.ts.map +1 -0
- package/dest/collection/index.js +4 -0
- package/dest/collection/lru_map.d.ts +41 -0
- package/dest/collection/lru_map.d.ts.map +1 -0
- package/dest/collection/lru_map.js +119 -0
- package/dest/collection/lru_set.d.ts +35 -0
- package/dest/collection/lru_set.d.ts.map +1 -0
- package/dest/collection/lru_set.js +95 -0
- package/dest/collection/object.d.ts +30 -0
- package/dest/collection/object.d.ts.map +1 -0
- package/dest/collection/object.js +57 -0
- package/dest/committable/committable.d.ts +28 -0
- package/dest/committable/committable.d.ts.map +1 -0
- package/dest/committable/committable.js +36 -0
- package/dest/committable/index.d.ts +2 -0
- package/dest/committable/index.d.ts.map +1 -0
- package/dest/committable/index.js +1 -0
- package/dest/config/env_var.d.ts +2 -0
- package/dest/config/env_var.d.ts.map +1 -0
- package/dest/config/env_var.js +1 -0
- package/dest/config/index.d.ts +154 -0
- package/dest/config/index.d.ts.map +1 -0
- package/dest/config/index.js +272 -0
- package/dest/config/network_config.d.ts +28 -0
- package/dest/config/network_config.d.ts.map +1 -0
- package/dest/config/network_config.js +14 -0
- package/dest/config/network_name.d.ts +3 -0
- package/dest/config/network_name.d.ts.map +1 -0
- package/dest/config/network_name.js +19 -0
- package/dest/config/parse-env.d.ts +3 -0
- package/dest/config/parse-env.d.ts.map +1 -0
- package/dest/config/parse-env.js +7 -0
- package/dest/config/secret_value.d.ts +28 -0
- package/dest/config/secret_value.d.ts.map +1 -0
- package/dest/config/secret_value.js +36 -0
- package/dest/crypto/aes128/index.d.ts +33 -0
- package/dest/crypto/aes128/index.d.ts.map +1 -0
- package/dest/crypto/aes128/index.js +71 -0
- package/dest/crypto/bls/bn254_keystore.d.ts +129 -0
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -0
- package/dest/crypto/bls/bn254_keystore.js +206 -0
- package/dest/crypto/bls/index.d.ts +13 -0
- package/dest/crypto/bls/index.d.ts.map +1 -0
- package/dest/crypto/bls/index.js +87 -0
- package/dest/crypto/bn254/index.d.ts +39 -0
- package/dest/crypto/bn254/index.d.ts.map +1 -0
- package/dest/crypto/bn254/index.js +56 -0
- package/dest/crypto/ecdsa/index.d.ts +39 -0
- package/dest/crypto/ecdsa/index.d.ts.map +1 -0
- package/dest/crypto/ecdsa/index.js +102 -0
- package/dest/crypto/ecdsa/signature.d.ts +69 -0
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -0
- package/dest/crypto/ecdsa/signature.js +92 -0
- package/dest/crypto/grumpkin/index.d.ts +42 -0
- package/dest/crypto/grumpkin/index.d.ts.map +1 -0
- package/dest/crypto/grumpkin/index.js +160 -0
- package/dest/crypto/keccak/index.d.ts +26 -0
- package/dest/crypto/keccak/index.d.ts.map +1 -0
- package/dest/crypto/keccak/index.js +248 -0
- package/dest/crypto/keys/index.d.ts +4 -0
- package/dest/crypto/keys/index.d.ts.map +1 -0
- package/dest/crypto/keys/index.js +34 -0
- package/dest/crypto/pedersen/index.d.ts +2 -0
- package/dest/crypto/pedersen/index.d.ts.map +1 -0
- package/dest/crypto/pedersen/index.js +1 -0
- package/dest/crypto/pedersen/pedersen.noble.d.ts +9 -0
- package/dest/crypto/pedersen/pedersen.noble.d.ts.map +1 -0
- package/dest/crypto/pedersen/pedersen.noble.js +558 -0
- package/dest/crypto/pedersen/pedersen.wasm.d.ts +19 -0
- package/dest/crypto/pedersen/pedersen.wasm.d.ts.map +1 -0
- package/dest/crypto/pedersen/pedersen.wasm.js +51 -0
- package/dest/crypto/poseidon/index.d.ts +23 -0
- package/dest/crypto/poseidon/index.d.ts.map +1 -0
- package/dest/crypto/poseidon/index.js +71 -0
- package/dest/crypto/random/index.d.ts +23 -0
- package/dest/crypto/random/index.d.ts.map +1 -0
- package/dest/crypto/random/index.js +38 -0
- package/dest/crypto/random/randomness_singleton.d.ts +24 -0
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -0
- package/dest/crypto/random/randomness_singleton.js +55 -0
- package/dest/crypto/schnorr/index.d.ts +32 -0
- package/dest/crypto/schnorr/index.d.ts.map +1 -0
- package/dest/crypto/schnorr/index.js +60 -0
- package/dest/crypto/schnorr/signature.d.ts +48 -0
- package/dest/crypto/schnorr/signature.d.ts.map +1 -0
- package/dest/crypto/schnorr/signature.js +77 -0
- package/dest/crypto/secp256k1/index.d.ts +30 -0
- package/dest/crypto/secp256k1/index.d.ts.map +1 -0
- package/dest/crypto/secp256k1/index.js +121 -0
- package/dest/crypto/secp256k1-signer/index.d.ts +3 -0
- package/dest/crypto/secp256k1-signer/index.d.ts.map +1 -0
- package/dest/crypto/secp256k1-signer/index.js +2 -0
- package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts +24 -0
- package/dest/crypto/secp256k1-signer/secp256k1_signer.d.ts.map +1 -0
- package/dest/crypto/secp256k1-signer/secp256k1_signer.js +30 -0
- package/dest/crypto/secp256k1-signer/utils.d.ts +102 -0
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -0
- package/dest/crypto/secp256k1-signer/utils.js +196 -0
- package/dest/crypto/sha256/index.d.ts +37 -0
- package/dest/crypto/sha256/index.d.ts.map +1 -0
- package/dest/crypto/sha256/index.js +208 -0
- package/dest/crypto/sha512/index.d.ts +9 -0
- package/dest/crypto/sha512/index.d.ts.map +1 -0
- package/dest/crypto/sha512/index.js +12 -0
- package/dest/crypto/signature/index.d.ts +17 -0
- package/dest/crypto/signature/index.d.ts.map +1 -0
- package/dest/crypto/signature/index.js +3 -0
- package/dest/crypto/sync/index.d.ts +3 -0
- package/dest/crypto/sync/index.d.ts.map +1 -0
- package/dest/crypto/sync/index.js +4 -0
- package/dest/crypto/sync/pedersen/index.d.ts +19 -0
- package/dest/crypto/sync/pedersen/index.d.ts.map +1 -0
- package/dest/crypto/sync/pedersen/index.js +45 -0
- package/dest/crypto/sync/poseidon/index.d.ts +23 -0
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -0
- package/dest/crypto/sync/poseidon/index.js +60 -0
- package/dest/curves/bls12/field.d.ts +148 -0
- package/dest/curves/bls12/field.d.ts.map +1 -0
- package/dest/curves/bls12/field.js +357 -0
- package/dest/curves/bls12/index.d.ts +3 -0
- package/dest/curves/bls12/index.d.ts.map +1 -0
- package/dest/curves/bls12/index.js +2 -0
- package/dest/curves/bls12/point.d.ts +229 -0
- package/dest/curves/bls12/point.d.ts.map +1 -0
- package/dest/curves/bls12/point.js +400 -0
- package/dest/curves/bn254/field.d.ts +185 -0
- package/dest/curves/bn254/field.d.ts.map +1 -0
- package/dest/curves/bn254/field.js +420 -0
- package/dest/curves/bn254/index.d.ts +3 -0
- package/dest/curves/bn254/index.d.ts.map +1 -0
- package/dest/curves/bn254/index.js +2 -0
- package/dest/curves/bn254/point.d.ts +54 -0
- package/dest/curves/bn254/point.d.ts.map +1 -0
- package/dest/curves/bn254/point.js +143 -0
- package/dest/curves/grumpkin/index.d.ts +10 -0
- package/dest/curves/grumpkin/index.d.ts.map +1 -0
- package/dest/curves/grumpkin/index.js +3 -0
- package/dest/curves/grumpkin/point.d.ts +168 -0
- package/dest/curves/grumpkin/point.d.ts.map +1 -0
- package/dest/curves/grumpkin/point.js +263 -0
- package/dest/decorators/index.d.ts +2 -0
- package/dest/decorators/index.d.ts.map +1 -0
- package/dest/decorators/index.js +1 -0
- package/dest/decorators/memoize.d.ts +2 -0
- package/dest/decorators/memoize.d.ts.map +1 -0
- package/dest/decorators/memoize.js +11 -0
- package/dest/error/index.d.ts +21 -0
- package/dest/error/index.d.ts.map +1 -0
- package/dest/error/index.js +17 -0
- package/dest/eth-address/index.d.ts +143 -0
- package/dest/eth-address/index.d.ts.map +1 -0
- package/dest/eth-address/index.js +224 -0
- package/dest/eth-signature/eth_signature.d.ts +65 -0
- package/dest/eth-signature/eth_signature.d.ts.map +1 -0
- package/dest/eth-signature/eth_signature.js +110 -0
- package/dest/eth-signature/index.d.ts +2 -0
- package/dest/eth-signature/index.d.ts.map +1 -0
- package/dest/eth-signature/index.js +1 -0
- package/dest/fifo/fifo_frame_reader.d.ts +41 -0
- package/dest/fifo/fifo_frame_reader.d.ts.map +1 -0
- package/dest/fifo/fifo_frame_reader.js +91 -0
- package/dest/fifo/index.d.ts +2 -0
- package/dest/fifo/index.d.ts.map +1 -0
- package/dest/fifo/index.js +1 -0
- package/dest/fifo_set/fifo_set.d.ts +15 -0
- package/dest/fifo_set/fifo_set.d.ts.map +1 -0
- package/dest/fifo_set/fifo_set.js +39 -0
- package/dest/fifo_set/index.d.ts +2 -0
- package/dest/fifo_set/index.d.ts.map +1 -0
- package/dest/fifo_set/index.js +1 -0
- package/dest/fs/index.d.ts +3 -0
- package/dest/fs/index.d.ts.map +1 -0
- package/dest/fs/index.js +2 -0
- package/dest/fs/run_in_dir.d.ts +2 -0
- package/dest/fs/run_in_dir.d.ts.map +1 -0
- package/dest/fs/run_in_dir.js +31 -0
- package/dest/fs/try_rm_dir.d.ts +3 -0
- package/dest/fs/try_rm_dir.d.ts.map +1 -0
- package/dest/fs/try_rm_dir.js +16 -0
- package/dest/iterable/all.d.ts +9 -0
- package/dest/iterable/all.d.ts.map +1 -0
- package/dest/iterable/all.js +18 -0
- package/dest/iterable/filter.d.ts +10 -0
- package/dest/iterable/filter.d.ts.map +1 -0
- package/dest/iterable/filter.js +48 -0
- package/dest/iterable/first.d.ts +8 -0
- package/dest/iterable/first.d.ts.map +1 -0
- package/dest/iterable/first.js +11 -0
- package/dest/iterable/index.d.ts +9 -0
- package/dest/iterable/index.d.ts.map +1 -0
- package/dest/iterable/index.js +8 -0
- package/dest/iterable/isAsyncIt.d.ts +7 -0
- package/dest/iterable/isAsyncIt.d.ts.map +1 -0
- package/dest/iterable/isAsyncIt.js +7 -0
- package/dest/iterable/map.d.ts +12 -0
- package/dest/iterable/map.d.ts.map +1 -0
- package/dest/iterable/map.js +36 -0
- package/dest/iterable/peek.d.ts +19 -0
- package/dest/iterable/peek.d.ts.map +1 -0
- package/dest/iterable/peek.js +33 -0
- package/dest/iterable/sort.d.ts +14 -0
- package/dest/iterable/sort.d.ts.map +1 -0
- package/dest/iterable/sort.js +15 -0
- package/dest/iterable/take.d.ts +10 -0
- package/dest/iterable/take.d.ts.map +1 -0
- package/dest/iterable/take.js +32 -0
- package/dest/iterable/toArray.d.ts +2 -0
- package/dest/iterable/toArray.d.ts.map +1 -0
- package/dest/iterable/toArray.js +7 -0
- package/dest/iterator/filter.d.ts +3 -0
- package/dest/iterator/filter.d.ts.map +1 -0
- package/dest/iterator/filter.js +7 -0
- package/dest/iterator/index.d.ts +2 -0
- package/dest/iterator/index.d.ts.map +1 -0
- package/dest/iterator/index.js +1 -0
- package/dest/jest/env.js +48 -0
- package/dest/jest/setup.js +34 -0
- package/dest/jest/setupAfterEnv.js +3 -0
- package/dest/json-rpc/client/fetch.d.ts +37 -0
- package/dest/json-rpc/client/fetch.d.ts.map +1 -0
- package/dest/json-rpc/client/fetch.js +67 -0
- package/dest/json-rpc/client/index.d.ts +3 -0
- package/dest/json-rpc/client/index.d.ts.map +1 -0
- package/dest/json-rpc/client/index.js +2 -0
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +33 -0
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -0
- package/dest/json-rpc/client/safe_json_rpc_client.js +218 -0
- package/dest/json-rpc/client/undici.d.ts +16 -0
- package/dest/json-rpc/client/undici.d.ts.map +1 -0
- package/dest/json-rpc/client/undici.js +112 -0
- package/dest/json-rpc/convert.d.ts +20 -0
- package/dest/json-rpc/convert.d.ts.map +1 -0
- package/dest/json-rpc/convert.js +40 -0
- package/dest/json-rpc/errors.d.ts +4 -0
- package/dest/json-rpc/errors.d.ts.map +1 -0
- package/dest/json-rpc/errors.js +6 -0
- package/dest/json-rpc/fixtures/class_a.d.ts +13 -0
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -0
- package/dest/json-rpc/fixtures/class_a.js +20 -0
- package/dest/json-rpc/fixtures/class_b.d.ts +13 -0
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -0
- package/dest/json-rpc/fixtures/class_b.js +20 -0
- package/dest/json-rpc/fixtures/test_state.d.ts +85 -0
- package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -0
- package/dest/json-rpc/fixtures/test_state.js +171 -0
- package/dest/json-rpc/index.d.ts +3 -0
- package/dest/json-rpc/index.d.ts.map +1 -0
- package/dest/json-rpc/index.js +2 -0
- package/dest/json-rpc/js_utils.d.ts +13 -0
- package/dest/json-rpc/js_utils.d.ts.map +1 -0
- package/dest/json-rpc/js_utils.js +16 -0
- package/dest/json-rpc/server/api_key_auth.d.ts +19 -0
- package/dest/json-rpc/server/api_key_auth.d.ts.map +1 -0
- package/dest/json-rpc/server/api_key_auth.js +57 -0
- package/dest/json-rpc/server/index.d.ts +3 -0
- package/dest/json-rpc/server/index.d.ts.map +1 -0
- package/dest/json-rpc/server/index.js +2 -0
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts +177 -0
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -0
- package/dest/json-rpc/server/safe_json_rpc_server.js +570 -0
- package/dest/json-rpc/test/index.d.ts +2 -0
- package/dest/json-rpc/test/index.d.ts.map +1 -0
- package/dest/json-rpc/test/index.js +1 -0
- package/dest/json-rpc/test/integration.d.ts +14 -0
- package/dest/json-rpc/test/integration.d.ts.map +1 -0
- package/dest/json-rpc/test/integration.js +21 -0
- package/dest/log/aws-logger-config.d.ts +8 -0
- package/dest/log/aws-logger-config.d.ts.map +1 -0
- package/dest/log/aws-logger-config.js +55 -0
- package/dest/log/bigint-utils.d.ts +5 -0
- package/dest/log/bigint-utils.d.ts.map +1 -0
- package/dest/log/bigint-utils.js +21 -0
- package/dest/log/console.d.ts +11 -0
- package/dest/log/console.d.ts.map +1 -0
- package/dest/log/console.js +36 -0
- package/dest/log/gcloud-logger-config.d.ts +13 -0
- package/dest/log/gcloud-logger-config.d.ts.map +1 -0
- package/dest/log/gcloud-logger-config.js +61 -0
- package/dest/log/index.d.ts +7 -0
- package/dest/log/index.d.ts.map +1 -0
- package/dest/log/index.js +6 -0
- package/dest/log/libp2p_logger.d.ts +10 -0
- package/dest/log/libp2p_logger.d.ts.map +1 -0
- package/dest/log/libp2p_logger.js +76 -0
- package/dest/log/log-filters.d.ts +20 -0
- package/dest/log/log-filters.d.ts.map +1 -0
- package/dest/log/log-filters.js +73 -0
- package/dest/log/log-levels.d.ts +3 -0
- package/dest/log/log-levels.d.ts.map +1 -0
- package/dest/log/log-levels.js +10 -0
- package/dest/log/log_fn.d.ts +7 -0
- package/dest/log/log_fn.d.ts.map +1 -0
- package/dest/log/log_fn.js +1 -0
- package/dest/log/noir_debug_log_util.d.ts +14 -0
- package/dest/log/noir_debug_log_util.d.ts.map +1 -0
- package/dest/log/noir_debug_log_util.js +14 -0
- package/dest/log/pino-logger-server.d.ts +9 -0
- package/dest/log/pino-logger-server.d.ts.map +1 -0
- package/dest/log/pino-logger-server.js +18 -0
- package/dest/log/pino-logger.d.ts +86 -0
- package/dest/log/pino-logger.d.ts.map +1 -0
- package/dest/log/pino-logger.js +347 -0
- package/dest/message/index.d.ts +32 -0
- package/dest/message/index.d.ts.map +1 -0
- package/dest/message/index.js +27 -0
- package/dest/mutex/index.d.ts +53 -0
- package/dest/mutex/index.d.ts.map +1 -0
- package/dest/mutex/index.js +78 -0
- package/dest/mutex/mutex_database.d.ts +10 -0
- package/dest/mutex/mutex_database.d.ts.map +1 -0
- package/dest/mutex/mutex_database.js +4 -0
- package/dest/noir/index.d.ts +2 -0
- package/dest/noir/index.d.ts.map +1 -0
- package/dest/noir/index.js +1 -0
- package/dest/noir/noir_package_config.d.ts +44 -0
- package/dest/noir/noir_package_config.d.ts.map +1 -0
- package/dest/noir/noir_package_config.js +36 -0
- package/dest/number/index.d.ts +3 -0
- package/dest/number/index.d.ts.map +1 -0
- package/dest/number/index.js +12 -0
- package/dest/profiler/index.d.ts +2 -0
- package/dest/profiler/index.d.ts.map +1 -0
- package/dest/profiler/index.js +1 -0
- package/dest/profiler/profiler.d.ts +8 -0
- package/dest/profiler/profiler.d.ts.map +1 -0
- package/dest/profiler/profiler.js +97 -0
- package/dest/promise/index.d.ts +3 -0
- package/dest/promise/index.d.ts.map +1 -0
- package/dest/promise/index.js +2 -0
- package/dest/promise/running-promise.d.ts +53 -0
- package/dest/promise/running-promise.d.ts.map +1 -0
- package/dest/promise/running-promise.js +122 -0
- package/dest/promise/utils.d.ts +25 -0
- package/dest/promise/utils.d.ts.map +1 -0
- package/dest/promise/utils.js +40 -0
- package/dest/queue/base_memory_queue.d.ts +65 -0
- package/dest/queue/base_memory_queue.d.ts.map +1 -0
- package/dest/queue/base_memory_queue.js +116 -0
- package/dest/queue/batch_queue.d.ts +47 -0
- package/dest/queue/batch_queue.d.ts.map +1 -0
- package/dest/queue/batch_queue.js +106 -0
- package/dest/queue/bounded_serial_queue.d.ts +56 -0
- package/dest/queue/bounded_serial_queue.d.ts.map +1 -0
- package/dest/queue/bounded_serial_queue.js +84 -0
- package/dest/queue/fifo_memory_queue.d.ts +21 -0
- package/dest/queue/fifo_memory_queue.d.ts.map +1 -0
- package/dest/queue/fifo_memory_queue.js +29 -0
- package/dest/queue/index.d.ts +7 -0
- package/dest/queue/index.d.ts.map +1 -0
- package/dest/queue/index.js +6 -0
- package/dest/queue/priority_memory_queue.d.ts +13 -0
- package/dest/queue/priority_memory_queue.d.ts.map +1 -0
- package/dest/queue/priority_memory_queue.js +16 -0
- package/dest/queue/priority_queue.d.ts +14 -0
- package/dest/queue/priority_queue.d.ts.map +1 -0
- package/dest/queue/priority_queue.js +29 -0
- package/dest/queue/semaphore.d.ts +27 -0
- package/dest/queue/semaphore.d.ts.map +1 -0
- package/dest/queue/semaphore.js +26 -0
- package/dest/queue/serial_queue.d.ts +49 -0
- package/dest/queue/serial_queue.d.ts.map +1 -0
- package/dest/queue/serial_queue.js +74 -0
- package/dest/retry/index.d.ts +83 -0
- package/dest/retry/index.d.ts.map +1 -0
- package/dest/retry/index.js +146 -0
- package/dest/running-promise/index.d.ts +2 -0
- package/dest/running-promise/index.d.ts.map +1 -0
- package/dest/running-promise/index.js +1 -0
- package/dest/schemas/api.d.ts +23 -0
- package/dest/schemas/api.d.ts.map +1 -0
- package/dest/schemas/api.js +9 -0
- package/dest/schemas/index.d.ts +6 -0
- package/dest/schemas/index.d.ts.map +1 -0
- package/dest/schemas/index.js +5 -0
- package/dest/schemas/parse.d.ts +9 -0
- package/dest/schemas/parse.d.ts.map +1 -0
- package/dest/schemas/parse.js +23 -0
- package/dest/schemas/schemas.d.ts +46 -0
- package/dest/schemas/schemas.d.ts.map +1 -0
- package/dest/schemas/schemas.js +56 -0
- package/dest/schemas/types.d.ts +33 -0
- package/dest/schemas/types.d.ts.map +1 -0
- package/dest/schemas/types.js +25 -0
- package/dest/schemas/utils.d.ts +47 -0
- package/dest/schemas/utils.d.ts.map +1 -0
- package/dest/schemas/utils.js +54 -0
- package/dest/serialize/buffer_reader.d.ts +274 -0
- package/dest/serialize/buffer_reader.d.ts.map +1 -0
- package/dest/serialize/buffer_reader.js +359 -0
- package/dest/serialize/buffer_sink.d.ts +134 -0
- package/dest/serialize/buffer_sink.d.ts.map +1 -0
- package/dest/serialize/buffer_sink.js +297 -0
- package/dest/serialize/field_reader.d.ts +121 -0
- package/dest/serialize/field_reader.d.ts.map +1 -0
- package/dest/serialize/field_reader.js +164 -0
- package/dest/serialize/free_funcs.d.ts +107 -0
- package/dest/serialize/free_funcs.d.ts.map +1 -0
- package/dest/serialize/free_funcs.js +183 -0
- package/dest/serialize/index.d.ts +8 -0
- package/dest/serialize/index.d.ts.map +1 -0
- package/dest/serialize/index.js +7 -0
- package/dest/serialize/serialize.d.ts +168 -0
- package/dest/serialize/serialize.d.ts.map +1 -0
- package/dest/serialize/serialize.js +258 -0
- package/dest/serialize/type_registry.d.ts +23 -0
- package/dest/serialize/type_registry.d.ts.map +1 -0
- package/dest/serialize/type_registry.js +61 -0
- package/dest/serialize/types.d.ts +33 -0
- package/dest/serialize/types.d.ts.map +1 -0
- package/dest/serialize/types.js +21 -0
- package/dest/sleep/index.d.ts +54 -0
- package/dest/sleep/index.d.ts.map +1 -0
- package/dest/sleep/index.js +80 -0
- package/dest/string/index.d.ts +18 -0
- package/dest/string/index.d.ts.map +1 -0
- package/dest/string/index.js +62 -0
- package/dest/testing/files/index.d.ts +20 -0
- package/dest/testing/files/index.d.ts.map +1 -0
- package/dest/testing/files/index.js +59 -0
- package/dest/testing/formatting.d.ts +4 -0
- package/dest/testing/formatting.d.ts.map +1 -0
- package/dest/testing/formatting.js +3 -0
- package/dest/testing/index.d.ts +5 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +4 -0
- package/dest/testing/port_allocator.d.ts +10 -0
- package/dest/testing/port_allocator.d.ts.map +1 -0
- package/dest/testing/port_allocator.js +29 -0
- package/dest/testing/snapshot_serializer.d.ts +5 -0
- package/dest/testing/snapshot_serializer.d.ts.map +1 -0
- package/dest/testing/snapshot_serializer.js +32 -0
- package/dest/testing/test_data.d.ts +7 -0
- package/dest/testing/test_data.d.ts.map +1 -0
- package/dest/testing/test_data.js +29 -0
- package/dest/timer/date.d.ts +39 -0
- package/dest/timer/date.d.ts.map +1 -0
- package/dest/timer/date.js +62 -0
- package/dest/timer/elapsed.d.ts +13 -0
- package/dest/timer/elapsed.d.ts.map +1 -0
- package/dest/timer/elapsed.js +25 -0
- package/dest/timer/index.d.ts +5 -0
- package/dest/timer/index.d.ts.map +1 -0
- package/dest/timer/index.js +4 -0
- package/dest/timer/timeout.d.ts +56 -0
- package/dest/timer/timeout.d.ts.map +1 -0
- package/dest/timer/timeout.js +113 -0
- package/dest/timer/timer.d.ts +37 -0
- package/dest/timer/timer.d.ts.map +1 -0
- package/dest/timer/timer.js +40 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +111 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -0
- package/dest/transport/dispatch/create_dispatch_proxy.js +59 -0
- package/dest/transport/dispatch/messages.d.ts +52 -0
- package/dest/transport/dispatch/messages.d.ts.map +1 -0
- package/dest/transport/dispatch/messages.js +13 -0
- package/dest/transport/index.d.ts +10 -0
- package/dest/transport/index.d.ts.map +1 -0
- package/dest/transport/index.js +9 -0
- package/dest/transport/interface/connector.d.ts +8 -0
- package/dest/transport/interface/connector.d.ts.map +1 -0
- package/dest/transport/interface/connector.js +3 -0
- package/dest/transport/interface/listener.d.ts +12 -0
- package/dest/transport/interface/listener.d.ts.map +1 -0
- package/dest/transport/interface/listener.js +4 -0
- package/dest/transport/interface/socket.d.ts +13 -0
- package/dest/transport/interface/socket.d.ts.map +1 -0
- package/dest/transport/interface/socket.js +7 -0
- package/dest/transport/interface/transferable.d.ts +68 -0
- package/dest/transport/interface/transferable.d.ts.map +1 -0
- package/dest/transport/interface/transferable.js +63 -0
- package/dest/transport/node/index.d.ts +3 -0
- package/dest/transport/node/index.d.ts.map +1 -0
- package/dest/transport/node/index.js +2 -0
- package/dest/transport/node/node_connector.d.ts +27 -0
- package/dest/transport/node/node_connector.d.ts.map +1 -0
- package/dest/transport/node/node_connector.js +26 -0
- package/dest/transport/node/node_connector_socket.d.ts +41 -0
- package/dest/transport/node/node_connector_socket.d.ts.map +1 -0
- package/dest/transport/node/node_connector_socket.js +44 -0
- package/dest/transport/node/node_listener.d.ts +25 -0
- package/dest/transport/node/node_listener.d.ts.map +1 -0
- package/dest/transport/node/node_listener.js +26 -0
- package/dest/transport/node/node_listener_socket.d.ts +36 -0
- package/dest/transport/node/node_listener_socket.d.ts.map +1 -0
- package/dest/transport/node/node_listener_socket.js +40 -0
- package/dest/transport/transport_client.d.ts +60 -0
- package/dest/transport/transport_client.d.ts.map +1 -0
- package/dest/transport/transport_client.js +96 -0
- package/dest/transport/transport_server.d.ts +47 -0
- package/dest/transport/transport_server.d.ts.map +1 -0
- package/dest/transport/transport_server.js +114 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts +16 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/balanced_merkle_tree_root.js +50 -0
- package/dest/trees/hasher.d.ts +40 -0
- package/dest/trees/hasher.d.ts.map +1 -0
- package/dest/trees/hasher.js +10 -0
- package/dest/trees/index.d.ts +13 -0
- package/dest/trees/index.d.ts.map +1 -0
- package/dest/trees/index.js +12 -0
- package/dest/trees/indexed_merkle_tree.d.ts +11 -0
- package/dest/trees/indexed_merkle_tree.d.ts.map +1 -0
- package/dest/trees/indexed_merkle_tree.js +27 -0
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +21 -0
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -0
- package/dest/trees/indexed_merkle_tree_calculator.js +87 -0
- package/dest/trees/indexed_tree_leaf.d.ts +55 -0
- package/dest/trees/indexed_tree_leaf.d.ts.map +1 -0
- package/dest/trees/indexed_tree_leaf.js +5 -0
- package/dest/trees/membership_witness.d.ts +63 -0
- package/dest/trees/membership_witness.d.ts.map +1 -0
- package/dest/trees/membership_witness.js +83 -0
- package/dest/trees/merkle_tree.d.ts +16 -0
- package/dest/trees/merkle_tree.d.ts.map +1 -0
- package/dest/trees/merkle_tree.js +58 -0
- package/dest/trees/merkle_tree_calculator.d.ts +16 -0
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -0
- package/dest/trees/merkle_tree_calculator.js +57 -0
- package/dest/trees/sibling_path.d.ts +96 -0
- package/dest/trees/sibling_path.d.ts.map +1 -0
- package/dest/trees/sibling_path.js +139 -0
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +48 -0
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -0
- package/dest/trees/unbalanced_merkle_tree_calculator.js +154 -0
- package/dest/trees/unbalanced_merkle_tree_root.d.ts +27 -0
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/unbalanced_merkle_tree_root.js +83 -0
- package/dest/trees/unbalanced_tree_store.d.ts +24 -0
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -0
- package/dest/trees/unbalanced_tree_store.js +148 -0
- package/dest/types/index.d.ts +68 -0
- package/dest/types/index.d.ts.map +1 -0
- package/dest/types/index.js +24 -0
- package/dest/url/index.d.ts +9 -0
- package/dest/url/index.d.ts.map +1 -0
- package/dest/url/index.js +62 -0
- package/dest/validation/index.d.ts +9 -0
- package/dest/validation/index.d.ts.map +1 -0
- package/dest/validation/index.js +15 -0
- package/package.json +213 -0
- package/src/array/array.ts +147 -0
- package/src/array/index.ts +2 -0
- package/src/array/sorted_array.ts +138 -0
- package/src/async-map/index.ts +18 -0
- package/src/async-pool/index.ts +51 -0
- package/src/bigint/index.ts +20 -0
- package/src/bigint-buffer/index.ts +92 -0
- package/src/branded-types/block_number.ts +135 -0
- package/src/branded-types/buffer32_hash.ts +38 -0
- package/src/branded-types/checkpoint_number.ts +130 -0
- package/src/branded-types/epoch.ts +88 -0
- package/src/branded-types/index.ts +8 -0
- package/src/branded-types/index_within_checkpoint.ts +88 -0
- package/src/branded-types/slot.ts +93 -0
- package/src/branded-types/types.ts +2 -0
- package/src/buffer/buffer16.ts +135 -0
- package/src/buffer/buffer32.ts +116 -0
- package/src/buffer/index.ts +3 -0
- package/src/buffer/utils.ts +8 -0
- package/src/collection/array.ts +351 -0
- package/src/collection/index.ts +4 -0
- package/src/collection/lru_map.ts +143 -0
- package/src/collection/lru_set.ts +115 -0
- package/src/collection/object.ts +89 -0
- package/src/committable/committable.ts +46 -0
- package/src/committable/index.ts +1 -0
- package/src/config/env_var.ts +412 -0
- package/src/config/index.ts +419 -0
- package/src/config/network_config.ts +21 -0
- package/src/config/network_name.ts +28 -0
- package/src/config/parse-env.ts +4 -0
- package/src/config/secret_value.ts +49 -0
- package/src/crypto/aes128/index.ts +77 -0
- package/src/crypto/bls/bn254_keystore.ts +276 -0
- package/src/crypto/bls/index.ts +76 -0
- package/src/crypto/bn254/index.ts +64 -0
- package/src/crypto/ecdsa/index.ts +88 -0
- package/src/crypto/ecdsa/signature.ts +100 -0
- package/src/crypto/grumpkin/index.ts +90 -0
- package/src/crypto/keccak/index.ts +283 -0
- package/src/crypto/keys/index.ts +26 -0
- package/src/crypto/pedersen/index.ts +1 -0
- package/src/crypto/pedersen/pedersen.noble.ts +573 -0
- package/src/crypto/pedersen/pedersen.wasm.ts +52 -0
- package/src/crypto/poseidon/index.ts +83 -0
- package/src/crypto/random/index.ts +47 -0
- package/src/crypto/random/randomness_singleton.ts +64 -0
- package/src/crypto/schnorr/index.ts +61 -0
- package/src/crypto/schnorr/signature.ts +87 -0
- package/src/crypto/secp256k1/index.ts +61 -0
- package/src/crypto/secp256k1-signer/index.ts +2 -0
- package/src/crypto/secp256k1-signer/secp256k1_signer.ts +38 -0
- package/src/crypto/secp256k1-signer/utils.ts +244 -0
- package/src/crypto/sha256/index.ts +194 -0
- package/src/crypto/sha512/index.ts +16 -0
- package/src/crypto/signature/index.ts +17 -0
- package/src/crypto/sync/index.ts +6 -0
- package/src/crypto/sync/pedersen/index.ts +46 -0
- package/src/crypto/sync/poseidon/index.ts +72 -0
- package/src/curves/bls12/field.ts +456 -0
- package/src/curves/bls12/index.ts +2 -0
- package/src/curves/bls12/point.ts +450 -0
- package/src/curves/bn254/field.ts +531 -0
- package/src/curves/bn254/index.ts +2 -0
- package/src/curves/bn254/point.ts +170 -0
- package/src/curves/grumpkin/index.ts +11 -0
- package/src/curves/grumpkin/point.ts +300 -0
- package/src/decorators/index.ts +1 -0
- package/src/decorators/memoize.ts +11 -0
- package/src/error/index.ts +22 -0
- package/src/eth-address/index.ts +269 -0
- package/src/eth-signature/eth_signature.ts +155 -0
- package/src/eth-signature/index.ts +1 -0
- package/src/fifo/fifo_frame_reader.ts +113 -0
- package/src/fifo/index.ts +1 -0
- package/src/fifo_set/fifo_set.ts +52 -0
- package/src/fifo_set/index.ts +1 -0
- package/src/fs/index.ts +2 -0
- package/src/fs/run_in_dir.ts +33 -0
- package/src/fs/try_rm_dir.ts +15 -0
- package/src/iterable/all.ts +32 -0
- package/src/iterable/filter.ts +77 -0
- package/src/iterable/first.ts +14 -0
- package/src/iterable/index.ts +8 -0
- package/src/iterable/isAsyncIt.ts +8 -0
- package/src/iterable/map.ts +66 -0
- package/src/iterable/peek.ts +58 -0
- package/src/iterable/sort.ts +39 -0
- package/src/iterable/take.ts +54 -0
- package/src/iterable/toArray.ts +9 -0
- package/src/iterator/filter.ts +11 -0
- package/src/iterator/index.ts +1 -0
- package/src/jest/env.mjs +52 -0
- package/src/jest/setup.mjs +38 -0
- package/src/jest/setupAfterEnv.mjs +3 -0
- package/src/json-rpc/README.md +55 -0
- package/src/json-rpc/client/fetch.ts +98 -0
- package/src/json-rpc/client/index.ts +2 -0
- package/src/json-rpc/client/safe_json_rpc_client.ts +283 -0
- package/src/json-rpc/client/undici.ts +128 -0
- package/src/json-rpc/convert.ts +52 -0
- package/src/json-rpc/errors.ts +6 -0
- package/src/json-rpc/fixtures/class_a.ts +18 -0
- package/src/json-rpc/fixtures/class_b.ts +18 -0
- package/src/json-rpc/fixtures/test_state.ts +143 -0
- package/src/json-rpc/index.ts +2 -0
- package/src/json-rpc/js_utils.ts +21 -0
- package/src/json-rpc/server/api_key_auth.ts +63 -0
- package/src/json-rpc/server/index.ts +2 -0
- package/src/json-rpc/server/safe_json_rpc_server.ts +626 -0
- package/src/json-rpc/test/index.ts +1 -0
- package/src/json-rpc/test/integration.ts +35 -0
- package/src/log/aws-logger-config.ts +32 -0
- package/src/log/bigint-utils.ts +25 -0
- package/src/log/console.ts +42 -0
- package/src/log/gcloud-logger-config.ts +72 -0
- package/src/log/index.ts +6 -0
- package/src/log/libp2p_logger.ts +93 -0
- package/src/log/log-filters.ts +81 -0
- package/src/log/log-levels.ts +3 -0
- package/src/log/log_fn.ts +5 -0
- package/src/log/noir_debug_log_util.ts +21 -0
- package/src/log/pino-logger-server.ts +25 -0
- package/src/log/pino-logger.ts +406 -0
- package/src/message/index.ts +47 -0
- package/src/mutex/index.ts +84 -0
- package/src/mutex/mutex_database.ts +11 -0
- package/src/noir/index.ts +1 -0
- package/src/noir/noir_package_config.ts +66 -0
- package/src/number/index.ts +14 -0
- package/src/profiler/index.ts +1 -0
- package/src/profiler/profiler.ts +125 -0
- package/src/promise/index.ts +2 -0
- package/src/promise/running-promise.ts +138 -0
- package/src/promise/utils.ts +60 -0
- package/src/queue/base_memory_queue.ts +138 -0
- package/src/queue/batch_queue.ts +121 -0
- package/src/queue/bounded_serial_queue.ts +103 -0
- package/src/queue/fifo_memory_queue.ts +39 -0
- package/src/queue/index.ts +6 -0
- package/src/queue/priority_memory_queue.ts +20 -0
- package/src/queue/priority_queue.ts +34 -0
- package/src/queue/semaphore.ts +38 -0
- package/src/queue/serial_queue.ts +86 -0
- package/src/retry/index.ts +185 -0
- package/src/running-promise/index.ts +1 -0
- package/src/schemas/api.ts +47 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/parse.ts +32 -0
- package/src/schemas/schemas.ts +93 -0
- package/src/schemas/types.ts +36 -0
- package/src/schemas/utils.ts +91 -0
- package/src/serialize/buffer_reader.ts +472 -0
- package/src/serialize/buffer_sink.ts +350 -0
- package/src/serialize/field_reader.ts +208 -0
- package/src/serialize/free_funcs.ts +198 -0
- package/src/serialize/index.ts +7 -0
- package/src/serialize/serialize.ts +320 -0
- package/src/serialize/type_registry.ts +75 -0
- package/src/serialize/types.ts +40 -0
- package/src/sleep/index.ts +90 -0
- package/src/string/index.ts +80 -0
- package/src/testing/files/index.ts +74 -0
- package/src/testing/formatting.ts +3 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/port_allocator.ts +31 -0
- package/src/testing/snapshot_serializer.ts +33 -0
- package/src/testing/test_data.ts +36 -0
- package/src/timer/date.ts +82 -0
- package/src/timer/elapsed.ts +23 -0
- package/src/timer/index.ts +4 -0
- package/src/timer/timeout.ts +136 -0
- package/src/timer/timer.ts +48 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +151 -0
- package/src/transport/dispatch/messages.ts +58 -0
- package/src/transport/index.ts +9 -0
- package/src/transport/interface/connector.ts +8 -0
- package/src/transport/interface/listener.ts +15 -0
- package/src/transport/interface/socket.ts +14 -0
- package/src/transport/interface/transferable.ts +125 -0
- package/src/transport/node/index.ts +2 -0
- package/src/transport/node/node_connector.ts +30 -0
- package/src/transport/node/node_connector_socket.ts +52 -0
- package/src/transport/node/node_listener.ts +34 -0
- package/src/transport/node/node_listener_socket.ts +48 -0
- package/src/transport/transport_client.ts +130 -0
- package/src/transport/transport_server.ts +111 -0
- package/src/trees/balanced_merkle_tree_root.ts +65 -0
- package/src/trees/hasher.ts +51 -0
- package/src/trees/index.ts +12 -0
- package/src/trees/indexed_merkle_tree.ts +40 -0
- package/src/trees/indexed_merkle_tree_calculator.ts +98 -0
- package/src/trees/indexed_tree_leaf.ts +56 -0
- package/src/trees/membership_witness.ts +112 -0
- package/src/trees/merkle_tree.ts +75 -0
- package/src/trees/merkle_tree_calculator.ts +66 -0
- package/src/trees/sibling_path.ts +177 -0
- package/src/trees/unbalanced_merkle_tree_calculator.ts +176 -0
- package/src/trees/unbalanced_merkle_tree_root.ts +112 -0
- package/src/trees/unbalanced_tree_store.ts +161 -0
- package/src/types/index.ts +103 -0
- package/src/url/index.ts +72 -0
- package/src/validation/index.ts +18 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FifoMemoryQueue } from './fifo_memory_queue.js';
|
|
2
|
+
/**
|
|
3
|
+
* A more specialized fifo queue that enqueues functions to execute. Enqueued functions are executed in serial.
|
|
4
|
+
*/ export class SerialQueue {
|
|
5
|
+
queue = new FifoMemoryQueue();
|
|
6
|
+
runningPromises = [];
|
|
7
|
+
started = false;
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the execution of enqueued functions in the serial queue.
|
|
10
|
+
* Functions are executed in the order they were added to the queue, with each function
|
|
11
|
+
* waiting for the completion of the previous one before starting its execution.
|
|
12
|
+
* This method should be called once to start processing the queue.
|
|
13
|
+
*/ start(numWorkers = 1) {
|
|
14
|
+
if (this.started) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.runningPromises = Array.from({
|
|
18
|
+
length: numWorkers
|
|
19
|
+
}, ()=>this.queue.process((fn)=>fn()));
|
|
20
|
+
this.started = true;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the current number of enqueued functions in the serial queue.
|
|
24
|
+
* This provides a way to check the size of the queue and monitor its progress.
|
|
25
|
+
*
|
|
26
|
+
* @returns The length of the serial queue as a number.
|
|
27
|
+
*/ length() {
|
|
28
|
+
return this.queue.length();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Cancels the processing of the remaining functions in the serial queue and resolves the running promise.
|
|
32
|
+
* Any enqueued functions that have not yet been executed will be discarded. The queue can still accept new
|
|
33
|
+
* functions after cancellation, but the previously enqueued functions will not be re-processed.
|
|
34
|
+
*
|
|
35
|
+
* @returns The running promise which resolves when the current executing function (if any) completes.
|
|
36
|
+
*/ cancel() {
|
|
37
|
+
this.queue.cancel();
|
|
38
|
+
return Promise.all(this.runningPromises).then(()=>{});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Signals the SerialQueue that it should finish processing its current task and stop accepting new tasks.
|
|
42
|
+
* The returned Promise resolves when all enqueued tasks have completed execution.
|
|
43
|
+
*
|
|
44
|
+
* @returns A Promise that resolves when the queue is completely emptied and no new tasks are allowed.
|
|
45
|
+
*/ end() {
|
|
46
|
+
this.queue.end();
|
|
47
|
+
return Promise.all(this.runningPromises).then(()=>{});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Enqueues fn for execution on the serial queue.
|
|
51
|
+
* Returns the result of the function after execution.
|
|
52
|
+
* @param fn - The function to enqueue.
|
|
53
|
+
* @returns A resolution promise. Rejects if the function does, or if the function could not be enqueued.
|
|
54
|
+
*/ put(fn) {
|
|
55
|
+
return new Promise((resolve, reject)=>{
|
|
56
|
+
const accepted = this.queue.put(async ()=>{
|
|
57
|
+
try {
|
|
58
|
+
const res = await fn();
|
|
59
|
+
resolve(res);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
reject(e);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (!accepted) {
|
|
65
|
+
reject(new Error('Could not enqueue function'));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Awaiting this ensures the queue is empty before resuming.
|
|
71
|
+
*/ async syncPoint() {
|
|
72
|
+
await this.put(async ()=>{});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type Logger } from '../log/index.js';
|
|
2
|
+
import { type DateProvider } from '../timer/index.js';
|
|
3
|
+
/** An error that indicates that the operation should not be retried. */
|
|
4
|
+
export declare class NoRetryError extends Error {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generates a backoff sequence for retrying operations with an increasing delay.
|
|
8
|
+
* The backoff sequence follows this pattern: 1, 1, 1, 2, 4, 8, 16, 32, 64, ...
|
|
9
|
+
* This generator can be used in combination with the `retry` function to perform
|
|
10
|
+
* retries with exponential backoff and capped at 64 seconds between attempts.
|
|
11
|
+
*
|
|
12
|
+
* @returns A generator that yields the next backoff value in seconds as an integer.
|
|
13
|
+
*/
|
|
14
|
+
export declare function backoffGenerator(): Generator<number, void, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a backoff sequence based on the array of retry intervals to use with the `retry` function.
|
|
17
|
+
* @param retries - Intervals to retry (in seconds).
|
|
18
|
+
* @returns A generator sequence.
|
|
19
|
+
*/
|
|
20
|
+
export declare function makeBackoff(retries: number[]): Generator<number, void, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Retry a given asynchronous function with a specific backoff strategy, until it succeeds or backoff generator ends.
|
|
23
|
+
* It logs the error and retry interval in case an error is caught. The function can be named for better log output.
|
|
24
|
+
*
|
|
25
|
+
* @param fn - The asynchronous function to be retried.
|
|
26
|
+
* @param name - The optional name of the operation, used for logging purposes.
|
|
27
|
+
* @param backoff - The optional backoff generator providing the intervals in seconds between retries. Defaults to a predefined series.
|
|
28
|
+
* @param log - Logger to use for logging.
|
|
29
|
+
* @param failSilently - Do not log errors while retrying.
|
|
30
|
+
* @returns A Promise that resolves with the successful result of the provided function, or rejects if backoff generator ends.
|
|
31
|
+
* @throws If `NoRetryError` is thrown by the `fn`, it is rethrown.
|
|
32
|
+
*/
|
|
33
|
+
export declare function retry<Result>(fn: () => Promise<Result>, name?: string, backoff?: Generator<number, void, unknown>, log?: Logger, failSilently?: boolean): Promise<Result>;
|
|
34
|
+
/**
|
|
35
|
+
* Timeout specification accepted by {@link retryUntil}. Either a plain number of seconds, an explicit
|
|
36
|
+
* `{ timeout }` in seconds, or an absolute `{ deadline }` with an optional {@link DateProvider} used to
|
|
37
|
+
* read the current time. A deadline is converted to the remaining seconds at call time; a deadline that
|
|
38
|
+
* has already passed yields a zero remaining budget, matching the immediate-timeout semantics of a
|
|
39
|
+
* non-positive numeric timeout.
|
|
40
|
+
*/
|
|
41
|
+
export type RetryUntilTimeout = number | {
|
|
42
|
+
timeout: number;
|
|
43
|
+
} | {
|
|
44
|
+
deadline: Date;
|
|
45
|
+
dateProvider?: DateProvider;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Retry an asynchronous function until it returns a truthy value or the specified timeout is exceeded.
|
|
49
|
+
* The function is retried periodically with a fixed interval between attempts. The operation can be named for better error messages.
|
|
50
|
+
* Will never timeout if the value is 0.
|
|
51
|
+
*
|
|
52
|
+
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
53
|
+
* @param name - The optional name of the operation, used for generating timeout error message.
|
|
54
|
+
* @param timeout - The maximum time to keep retrying before throwing a timeout error. Accepts a number of
|
|
55
|
+
* seconds (0 = never time out), an explicit `{ timeout }` in seconds, or an absolute `{ deadline }` with an
|
|
56
|
+
* optional `dateProvider`. A deadline already in the past times out on the first interval, the same as a
|
|
57
|
+
* zero/negative numeric timeout. Defaults to 0 (never timeout).
|
|
58
|
+
* @param interval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
59
|
+
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if timeout is exceeded.
|
|
60
|
+
*/
|
|
61
|
+
export declare function retryUntil<T>(fn: () => (T | undefined) | Promise<T | undefined>, name?: string, timeout?: RetryUntilTimeout, interval?: number): Promise<NonNullable<Awaited<T>>>;
|
|
62
|
+
/**
|
|
63
|
+
* Retry an asynchronous function until it returns a truthy value or the maximum number of retries is exceeded.
|
|
64
|
+
* The function is retried periodically with a fixed interval between attempts.
|
|
65
|
+
*
|
|
66
|
+
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
67
|
+
* @param name - The optional name of the operation, used for generating error messages.
|
|
68
|
+
* @param maxRetries - The maximum number of retry attempts before throwing an error.
|
|
69
|
+
* @param retryInterval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
70
|
+
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if retries are exhausted.
|
|
71
|
+
*/
|
|
72
|
+
export declare function retryTimes<T>(fn: () => (T | undefined) | Promise<T | undefined>, name: string | undefined, maxRetries: number, retryInterval?: number): Promise<NonNullable<Awaited<T>>>;
|
|
73
|
+
/**
|
|
74
|
+
* Convenience wrapper around retryUntil with fast polling for tests.
|
|
75
|
+
* Uses 10s timeout and 100ms polling interval by default.
|
|
76
|
+
*
|
|
77
|
+
* @param fn - The function to retry until it returns a truthy value.
|
|
78
|
+
* @param name - Description of what we're waiting for (for error messages).
|
|
79
|
+
* @param timeout - Optional timeout in seconds. Defaults to 10s.
|
|
80
|
+
* @param interval - Optional interval in seconds. Defaults to 0.1s (100ms).
|
|
81
|
+
*/
|
|
82
|
+
export declare function retryFastUntil<T>(fn: () => (T | undefined) | Promise<T | undefined>, name?: string, timeout?: number, interval?: number): Promise<NonNullable<Awaited<T>>>;
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9yZXRyeS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0saUJBQWlCLENBQUM7QUFFNUQsT0FBTyxFQUFFLEtBQUssWUFBWSxFQUFTLE1BQU0sbUJBQW1CLENBQUM7QUFFN0Qsd0VBQXdFO0FBQ3hFLHFCQUFhLFlBQWEsU0FBUSxLQUFLO0NBQUc7QUFFMUM7Ozs7Ozs7R0FPRztBQUNILHdCQUFpQixnQkFBZ0IscUNBTWhDO0FBRUQ7Ozs7R0FJRztBQUNILHdCQUFpQixXQUFXLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxvQ0FJN0M7QUFFRDs7Ozs7Ozs7Ozs7R0FXRztBQUNILHdCQUFzQixLQUFLLENBQUMsTUFBTSxFQUNoQyxFQUFFLEVBQUUsTUFBTSxPQUFPLENBQUMsT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ClB,aAAa,SAAI,oCAclB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,EAClD,IAAI,SAAK,EACT,OAAO,SAAK,EACZ,QAAQ,SAAM,oCAGf"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { TimeoutError } from '../error/index.js';
|
|
2
|
+
import { createLogger } from '../log/index.js';
|
|
3
|
+
import { sleep } from '../sleep/index.js';
|
|
4
|
+
import { Timer } from '../timer/index.js';
|
|
5
|
+
/** An error that indicates that the operation should not be retried. */ export class NoRetryError extends Error {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates a backoff sequence for retrying operations with an increasing delay.
|
|
9
|
+
* The backoff sequence follows this pattern: 1, 1, 1, 2, 4, 8, 16, 32, 64, ...
|
|
10
|
+
* This generator can be used in combination with the `retry` function to perform
|
|
11
|
+
* retries with exponential backoff and capped at 64 seconds between attempts.
|
|
12
|
+
*
|
|
13
|
+
* @returns A generator that yields the next backoff value in seconds as an integer.
|
|
14
|
+
*/ export function* backoffGenerator() {
|
|
15
|
+
const v = [
|
|
16
|
+
1,
|
|
17
|
+
1,
|
|
18
|
+
1,
|
|
19
|
+
2,
|
|
20
|
+
4,
|
|
21
|
+
8,
|
|
22
|
+
16,
|
|
23
|
+
32,
|
|
24
|
+
64
|
|
25
|
+
];
|
|
26
|
+
let i = 0;
|
|
27
|
+
while(true){
|
|
28
|
+
yield v[Math.min(i++, v.length - 1)];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generates a backoff sequence based on the array of retry intervals to use with the `retry` function.
|
|
33
|
+
* @param retries - Intervals to retry (in seconds).
|
|
34
|
+
* @returns A generator sequence.
|
|
35
|
+
*/ export function* makeBackoff(retries) {
|
|
36
|
+
for (const retry of retries){
|
|
37
|
+
yield retry;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Retry a given asynchronous function with a specific backoff strategy, until it succeeds or backoff generator ends.
|
|
42
|
+
* It logs the error and retry interval in case an error is caught. The function can be named for better log output.
|
|
43
|
+
*
|
|
44
|
+
* @param fn - The asynchronous function to be retried.
|
|
45
|
+
* @param name - The optional name of the operation, used for logging purposes.
|
|
46
|
+
* @param backoff - The optional backoff generator providing the intervals in seconds between retries. Defaults to a predefined series.
|
|
47
|
+
* @param log - Logger to use for logging.
|
|
48
|
+
* @param failSilently - Do not log errors while retrying.
|
|
49
|
+
* @returns A Promise that resolves with the successful result of the provided function, or rejects if backoff generator ends.
|
|
50
|
+
* @throws If `NoRetryError` is thrown by the `fn`, it is rethrown.
|
|
51
|
+
*/ export async function retry(fn, name = 'Operation', backoff = backoffGenerator(), log = createLogger('foundation:retry'), failSilently = false) {
|
|
52
|
+
while(true){
|
|
53
|
+
try {
|
|
54
|
+
return await fn();
|
|
55
|
+
} catch (err) {
|
|
56
|
+
if (err instanceof NoRetryError) {
|
|
57
|
+
// A special error that indicates that the operation should not be retried. Rethrow it.
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
const s = backoff.next().value;
|
|
61
|
+
if (s === undefined) {
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
log?.debug(`${name} failed. Will retry in ${s}s...`);
|
|
65
|
+
!failSilently && log?.error(`Error while retrying ${name}`, err);
|
|
66
|
+
await sleep(s * 1000);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolves a {@link RetryUntilTimeout} to a numeric timeout in seconds for the legacy timer-based loop.
|
|
73
|
+
* A numeric/`{ timeout }` value passes through unchanged (0 means never time out, negative times out on the
|
|
74
|
+
* first interval). A `{ deadline }` is the remaining seconds until the deadline; when the deadline is already
|
|
75
|
+
* at or past `now` it resolves to a negative value so the loop times out immediately instead of being read as
|
|
76
|
+
* the never-timeout sentinel 0.
|
|
77
|
+
*/ function resolveRetryUntilTimeoutSeconds(timeout) {
|
|
78
|
+
if (typeof timeout === 'number') {
|
|
79
|
+
return timeout;
|
|
80
|
+
}
|
|
81
|
+
if ('deadline' in timeout) {
|
|
82
|
+
const now = timeout.dateProvider?.now() ?? Date.now();
|
|
83
|
+
const remainingSeconds = (timeout.deadline.getTime() - now) / 1000;
|
|
84
|
+
return remainingSeconds > 0 ? remainingSeconds : -1;
|
|
85
|
+
}
|
|
86
|
+
return timeout.timeout;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Retry an asynchronous function until it returns a truthy value or the specified timeout is exceeded.
|
|
90
|
+
* The function is retried periodically with a fixed interval between attempts. The operation can be named for better error messages.
|
|
91
|
+
* Will never timeout if the value is 0.
|
|
92
|
+
*
|
|
93
|
+
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
94
|
+
* @param name - The optional name of the operation, used for generating timeout error message.
|
|
95
|
+
* @param timeout - The maximum time to keep retrying before throwing a timeout error. Accepts a number of
|
|
96
|
+
* seconds (0 = never time out), an explicit `{ timeout }` in seconds, or an absolute `{ deadline }` with an
|
|
97
|
+
* optional `dateProvider`. A deadline already in the past times out on the first interval, the same as a
|
|
98
|
+
* zero/negative numeric timeout. Defaults to 0 (never timeout).
|
|
99
|
+
* @param interval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
100
|
+
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if timeout is exceeded.
|
|
101
|
+
*/ export async function retryUntil(fn, name = '', timeout = 0, interval = 1) {
|
|
102
|
+
const timeoutSeconds = resolveRetryUntilTimeoutSeconds(timeout);
|
|
103
|
+
const timer = new Timer();
|
|
104
|
+
while(true){
|
|
105
|
+
const result = await fn();
|
|
106
|
+
if (result) {
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
await sleep(interval * 1000);
|
|
110
|
+
if (timeoutSeconds && timer.s() > timeoutSeconds) {
|
|
111
|
+
throw new TimeoutError(name ? `Timeout awaiting ${name}` : 'Timeout');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Retry an asynchronous function until it returns a truthy value or the maximum number of retries is exceeded.
|
|
117
|
+
* The function is retried periodically with a fixed interval between attempts.
|
|
118
|
+
*
|
|
119
|
+
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
120
|
+
* @param name - The optional name of the operation, used for generating error messages.
|
|
121
|
+
* @param maxRetries - The maximum number of retry attempts before throwing an error.
|
|
122
|
+
* @param retryInterval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
123
|
+
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if retries are exhausted.
|
|
124
|
+
*/ export async function retryTimes(fn, name = '', maxRetries, retryInterval = 1) {
|
|
125
|
+
for(let attempt = 0; attempt <= maxRetries; attempt++){
|
|
126
|
+
const result = await fn();
|
|
127
|
+
if (result) {
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
if (attempt < maxRetries) {
|
|
131
|
+
await sleep(retryInterval * 1000);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
throw new Error(name ? `Retries exhausted awaiting ${name}` : 'Retries exhausted');
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Convenience wrapper around retryUntil with fast polling for tests.
|
|
138
|
+
* Uses 10s timeout and 100ms polling interval by default.
|
|
139
|
+
*
|
|
140
|
+
* @param fn - The function to retry until it returns a truthy value.
|
|
141
|
+
* @param name - Description of what we're waiting for (for error messages).
|
|
142
|
+
* @param timeout - Optional timeout in seconds. Defaults to 10s.
|
|
143
|
+
* @param interval - Optional interval in seconds. Defaults to 0.1s (100ms).
|
|
144
|
+
*/ export function retryFastUntil(fn, name = '', timeout = 10, interval = 0.1) {
|
|
145
|
+
return retryUntil(fn, name, timeout, interval);
|
|
146
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from '../promise/running-promise.js';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydW5uaW5nLXByb21pc2UvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYywrQkFBK0IsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/running-promise/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../promise/running-promise.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { ZodNullableOptional } from './utils.js';
|
|
3
|
+
type ZodParameterTypeFor<T> = undefined extends T ? ZodNullableOptional<z.ZodType<T, any>> : z.ZodType<T, any>;
|
|
4
|
+
type ZodReturnTypeFor<T> = z.ZodType<T, any>;
|
|
5
|
+
type ZodMapParameterTypes<T extends readonly unknown[]> = {
|
|
6
|
+
[K in keyof T]-?: ZodParameterTypeFor<T[K]>;
|
|
7
|
+
};
|
|
8
|
+
/** Maps all functions in an interface to their schema representation. */
|
|
9
|
+
export type ApiSchemaFor<T> = {
|
|
10
|
+
[K in keyof T]: T[K] extends (...args: infer Args) => Promise<infer Ret> ? z.ZodFunction<z.ZodTuple<ZodMapParameterTypes<Args>, null>, ZodReturnTypeFor<Ret>> : never;
|
|
11
|
+
};
|
|
12
|
+
/** Generic Api schema not bounded to a specific implementation. */
|
|
13
|
+
export type ApiSchema = {
|
|
14
|
+
[key: string]: z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>;
|
|
15
|
+
};
|
|
16
|
+
/** Return whether an API schema defines a valid function schema for a given method name. */
|
|
17
|
+
export declare function schemaHasMethod<T extends ApiSchema>(schema: T, methodName: string): methodName is Extract<keyof T, string>;
|
|
18
|
+
/** Returns the parameter tuple schema for an API method schema. */
|
|
19
|
+
export declare function getSchemaParameters<T extends z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>(schema: T): z.ZodTuple<any, any>;
|
|
20
|
+
/** Returns the return value schema for an API method schema. */
|
|
21
|
+
export declare function getSchemaReturnType<T extends z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>(schema: T): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2NoZW1hcy9hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRTdCLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sWUFBWSxDQUFDO0FBR3RELEtBQUssbUJBQW1CLENBQUMsQ0FBQyxJQUFJLFNBQVMsU0FBUyxDQUFDLEdBQUcsbUJBQW1CLENBQUMsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsR0FBRyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FBQztBQUUvRyxLQUFLLGdCQUFnQixDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FBQztBQUU3QyxLQUFLLG9CQUFvQixDQUFDLENBQUMsU0FBUyxTQUFTLE9BQU8sRUFBRSxJQUFJO0tBQ3ZELENBQU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,GAAG,CAAC,GACpE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAClF,KAAK;CACV,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;CAClE,CAAC;AAEF,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EACjD,MAAM,EAAE,CAAC,EACT,UAAU,EAAE,MAAM,GACjB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAOxC;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,wBAEzG;AAED,gEAAgE;AAChE,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,2EAEzG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Return whether an API schema defines a valid function schema for a given method name. */ export function schemaHasMethod(schema, methodName) {
|
|
2
|
+
return typeof methodName === 'string' && Object.hasOwn(schema, methodName) && schema[methodName].def.input !== undefined && schema[methodName].def.output !== undefined;
|
|
3
|
+
}
|
|
4
|
+
/** Returns the parameter tuple schema for an API method schema. */ export function getSchemaParameters(schema) {
|
|
5
|
+
return schema.def.input;
|
|
6
|
+
}
|
|
7
|
+
/** Returns the return value schema for an API method schema. */ export function getSchemaReturnType(schema) {
|
|
8
|
+
return schema.def.output;
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export * from './parse.js';
|
|
3
|
+
export * from './utils.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './schemas.js';
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWFzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsVUFBVSxDQUFDO0FBQ3pCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMsY0FBYyxDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Parses the given arguments using a tuple from the provided schemas. */
|
|
3
|
+
export declare function parse<T extends [] | [z.ZodTypeAny, ...z.ZodTypeAny[]]>(args: IArguments, ...schemas: T): [];
|
|
4
|
+
/**
|
|
5
|
+
* Parses the given arguments against a tuple, allowing empty for optional items.
|
|
6
|
+
* @dev Zod doesn't like tuples with optional items. See https://github.com/colinhacks/zod/discussions/949.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseWithOptionals<T extends z.ZodTuple<any, any>>(args: any[], schema: T): Promise<z.output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AC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAO/G"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { times } from '../collection/array.js';
|
|
3
|
+
/** Parses the given arguments using a tuple from the provided schemas. */ export function parse(args, ...schemas) {
|
|
4
|
+
return schemas.length === 0 ? z.tuple([]).parse(args) : z.tuple(schemas).parse(args);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Parses the given arguments against a tuple, allowing empty for optional items.
|
|
8
|
+
* @dev Zod doesn't like tuples with optional items. See https://github.com/colinhacks/zod/discussions/949.
|
|
9
|
+
*/ export function parseWithOptionals(args, schema) {
|
|
10
|
+
const items = schema.def.items;
|
|
11
|
+
const missingCount = items.length - args.length;
|
|
12
|
+
const optionalCount = items.filter(isOptional).length;
|
|
13
|
+
const toParse = missingCount > 0 && missingCount <= optionalCount ? args.concat(times(missingCount, ()=>undefined)) : args;
|
|
14
|
+
return schema.parseAsync(toParse);
|
|
15
|
+
}
|
|
16
|
+
function isOptional(schema) {
|
|
17
|
+
try {
|
|
18
|
+
return schema.isOptional();
|
|
19
|
+
} catch {
|
|
20
|
+
// See https://github.com/colinhacks/zod/issues/1911
|
|
21
|
+
return schema.def.type === 'optional';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EpochNumber } from '../branded-types/epoch.js';
|
|
3
|
+
import { SlotNumber } from '../branded-types/slot.js';
|
|
4
|
+
import { Buffer32 } from '../buffer/buffer32.js';
|
|
5
|
+
import { SecretValue } from '../config/secret_value.js';
|
|
6
|
+
import { Fq, Fr } from '../curves/bn254/field.js';
|
|
7
|
+
import { Point } from '../curves/grumpkin/point.js';
|
|
8
|
+
import { EthAddress } from '../eth-address/index.js';
|
|
9
|
+
export declare const schemas: {
|
|
10
|
+
/** Accepts a number, bigint, or string as an EpochNumber. */
|
|
11
|
+
EpochNumber: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodBigInt, z.ZodString]>, z.ZodCoercedNumber<string | number | bigint>>, z.ZodTransform<EpochNumber, number>>;
|
|
12
|
+
/** Accepts a number, bigint, or string as a SlotNumber. */
|
|
13
|
+
SlotNumber: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodBigInt, z.ZodString]>, z.ZodCoercedNumber<string | number | bigint>>, z.ZodTransform<SlotNumber, number>>;
|
|
14
|
+
/** Accepts a hex string. */
|
|
15
|
+
EthAddress: z.ZodType<EthAddress, string, z.core.$ZodTypeInternals<EthAddress, string>>;
|
|
16
|
+
/** Accepts a hex string. */
|
|
17
|
+
Fr: z.ZodType<Fr, string, z.core.$ZodTypeInternals<Fr, string>>;
|
|
18
|
+
/** Accepts a hex string. */
|
|
19
|
+
Fq: z.ZodType<Fq, string, z.core.$ZodTypeInternals<Fq, string>>;
|
|
20
|
+
/** Point. Serialized as a hex string. */
|
|
21
|
+
Point: z.ZodType<Point, string, z.core.$ZodTypeInternals<Point, string>>;
|
|
22
|
+
/** Coerces truthy-like string values to boolean. */
|
|
23
|
+
Boolean: z.ZodUnion<readonly [z.ZodBoolean, z.ZodPipe<z.ZodNumber & z.ZodType<0 | 1, number, z.core.$ZodTypeInternals<0 | 1, number>>, z.ZodTransform<boolean, 0 | 1>>, z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<boolean, string>>]>;
|
|
24
|
+
/** Coerces any input to bigint. */
|
|
25
|
+
BigInt: z.ZodPipe<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodCoercedBigInt<string | number | bigint>>;
|
|
26
|
+
/** Coerces any input to integer number. */
|
|
27
|
+
Integer: z.ZodPipe<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodCoercedNumber<string | number | bigint>>;
|
|
28
|
+
/** Coerces input to UInt32. */
|
|
29
|
+
UInt32: z.ZodPipe<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodCoercedNumber<string | number | bigint>>;
|
|
30
|
+
/** Coerces input to UInt64. */
|
|
31
|
+
UInt64: z.ZodPipe<z.ZodUnion<readonly [z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodCoercedBigInt<string | number | bigint>>;
|
|
32
|
+
/** Accepts a hex string as a Buffer32 type. */
|
|
33
|
+
Buffer32: z.ZodPipe<z.ZodString, z.ZodTransform<Buffer32, string>>;
|
|
34
|
+
/** Accepts a base64 string or an object `{ type: 'Buffer', data: [byte, byte...] }` as a buffer. */
|
|
35
|
+
Buffer: import("./types.js").ZodFor<Buffer<ArrayBufferLike>>;
|
|
36
|
+
/** Accepts a hex string as a buffer. */
|
|
37
|
+
BufferHex: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<Buffer<ArrayBuffer>, string>>;
|
|
38
|
+
/** Hex string with an optional 0x prefix which gets removed as part of the parsing. */
|
|
39
|
+
HexString: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
40
|
+
/** Hex string with an optional 0x prefix which gets enforced as part of the parsing. */
|
|
41
|
+
HexStringWith0x: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
42
|
+
/** A secret config value */
|
|
43
|
+
SecretValue: typeof SecretValue.schema;
|
|
44
|
+
};
|
|
45
|
+
export type { EpochNumber, EthAddress, Fq, Fr, Point, SlotNumber };
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4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3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAqB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD,eAAO,MAAM,OAAO;IAClB,6DAA6D;;IAG7D,2DAA2D;;IAG3D,4BAA4B;;IAG5B,4BAA4B;;IAG5B,4BAA4B;;IAG5B,yCAAyC;;IAGzC,oDAAoD;;IAcpD,mCAAmC;;IAGnC,2CAA2C;;IAG3C,+BAA+B;;IAS/B,+BAA+B;;IAQ/B,+CAA+C;;IAG/C,oGAAoG;;IAGpG,wCAAwC;;IAOxC,uFAAuF;;IAGvF,wFAAwF;;IAGxF,4BAA4B;;CAE7B,CAAC;AAGF,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EpochNumberSchema } from '../branded-types/epoch.js';
|
|
3
|
+
import { SlotNumberSchema } from '../branded-types/slot.js';
|
|
4
|
+
import { Buffer32 } from '../buffer/buffer32.js';
|
|
5
|
+
import { SecretValue } from '../config/secret_value.js';
|
|
6
|
+
import { Fq, Fr } from '../curves/bn254/field.js';
|
|
7
|
+
import { Point } from '../curves/grumpkin/point.js';
|
|
8
|
+
import { EthAddress } from '../eth-address/index.js';
|
|
9
|
+
import { isHex, withHexPrefix, withoutHexPrefix } from '../string/index.js';
|
|
10
|
+
import { bufferSchema, hexSchema } from './utils.js';
|
|
11
|
+
export const schemas = {
|
|
12
|
+
/** Accepts a number, bigint, or string as an EpochNumber. */ EpochNumber: EpochNumberSchema,
|
|
13
|
+
/** Accepts a number, bigint, or string as a SlotNumber. */ SlotNumber: SlotNumberSchema,
|
|
14
|
+
/** Accepts a hex string. */ EthAddress: EthAddress.schema,
|
|
15
|
+
/** Accepts a hex string. */ Fr: Fr.schema,
|
|
16
|
+
/** Accepts a hex string. */ Fq: Fq.schema,
|
|
17
|
+
/** Point. Serialized as a hex string. */ Point: Point.schema,
|
|
18
|
+
/** Coerces truthy-like string values to boolean. */ Boolean: z.union([
|
|
19
|
+
z.boolean(),
|
|
20
|
+
z.number().refine((arg)=>arg === 0 || arg === 1, {
|
|
21
|
+
message: `Numeric value for a boolean variable must be 0 or 1`
|
|
22
|
+
}).transform((arg)=>arg === 1),
|
|
23
|
+
z.string().transform((arg)=>arg.trim().toLowerCase()).refine((arg)=>[
|
|
24
|
+
'true',
|
|
25
|
+
'false',
|
|
26
|
+
'1',
|
|
27
|
+
'0'
|
|
28
|
+
].includes(arg)).transform((arg)=>arg === '1' || arg === 'true')
|
|
29
|
+
]),
|
|
30
|
+
/** Coerces any input to bigint. */ BigInt: z.union([
|
|
31
|
+
z.bigint(),
|
|
32
|
+
z.number(),
|
|
33
|
+
z.string()
|
|
34
|
+
]).pipe(z.coerce.bigint()),
|
|
35
|
+
/** Coerces any input to integer number. */ Integer: z.union([
|
|
36
|
+
z.bigint(),
|
|
37
|
+
z.number(),
|
|
38
|
+
z.string()
|
|
39
|
+
]).pipe(z.coerce.number().int()),
|
|
40
|
+
/** Coerces input to UInt32. */ UInt32: z.union([
|
|
41
|
+
z.bigint(),
|
|
42
|
+
z.number(),
|
|
43
|
+
z.string()
|
|
44
|
+
]).pipe(z.coerce.number().int().min(0).max(2 ** 32 - 1)),
|
|
45
|
+
/** Coerces input to UInt64. */ UInt64: z.union([
|
|
46
|
+
z.bigint(),
|
|
47
|
+
z.number(),
|
|
48
|
+
z.string()
|
|
49
|
+
]).pipe(z.coerce.bigint().min(0n).max(2n ** 64n - 1n)),
|
|
50
|
+
/** Accepts a hex string as a Buffer32 type. */ Buffer32: z.string().refine(isHex, 'Not a valid hex string').transform(Buffer32.fromString),
|
|
51
|
+
/** Accepts a base64 string or an object `{ type: 'Buffer', data: [byte, byte...] }` as a buffer. */ Buffer: bufferSchema,
|
|
52
|
+
/** Accepts a hex string as a buffer. */ BufferHex: z.string().refine(isHex, 'Not a valid hex string').transform(withoutHexPrefix).transform((data)=>Buffer.from(data, 'hex')),
|
|
53
|
+
/** Hex string with an optional 0x prefix which gets removed as part of the parsing. */ HexString: hexSchema,
|
|
54
|
+
/** Hex string with an optional 0x prefix which gets enforced as part of the parsing. */ HexStringWith0x: z.string().refine(isHex, 'Not a valid hex string').transform(withHexPrefix),
|
|
55
|
+
/** A secret config value */ SecretValue: SecretValue.schema
|
|
56
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
export type ZodFor<T> = ZodType<T, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a schema validator that enforces all properties of type T are present in the schema.
|
|
5
|
+
* This provides compile-time safety to ensure schemas don't miss optional properties.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* interface MyConfig {
|
|
10
|
+
* foo: string;
|
|
11
|
+
* bar?: number;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* // ✅ This will work - all keys present
|
|
15
|
+
* const schema1 = zodFor<MyConfig>()(z.object({
|
|
16
|
+
* foo: z.string(),
|
|
17
|
+
* bar: z.number().optional(),
|
|
18
|
+
* }));
|
|
19
|
+
*
|
|
20
|
+
* // ❌ This will error - 'bar' is missing
|
|
21
|
+
* const schema2 = zodFor<MyConfig>()(z.object({
|
|
22
|
+
* foo: z.string(),
|
|
23
|
+
* }));
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function zodFor<T>(): <S extends ZodType<any, any, import("zod/v4/core").$ZodTypeInternals<any, any>>>(schema: keyof T extends keyof S["_output"] ? keyof S["_output"] extends keyof T ? S : S & {
|
|
27
|
+
__error__: "Schema has extra keys not in type";
|
|
28
|
+
__extra__: Exclude<keyof S["_output"], keyof T>;
|
|
29
|
+
} : S & {
|
|
30
|
+
__error__: "Schema is missing keys from type";
|
|
31
|
+
__missing__: Exclude<keyof T, keyof S["_output"]>;
|
|
32
|
+
}) => S;
|
|
33
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWFzL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLEtBQUssQ0FBQztBQUVuQyxNQUFNLE1BQU0sTUFBTSxDQUFDLENBQUMsSUFBSSxPQUFPLENBQUMsQ0FBQyxFQUFFLEdBQUcsQ0FBQyxDQUFDO0FBRXhDOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBc0JHO0FBQ0gsd0JBQWdCLE1BQU0sQ0FBQyxDQUFDLE1BQ1EsQ0FBQzs7Ozs7O1FBT2hDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/schemas/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CAAC,CAAC,MACQ,CAAC;;;;;;QAOhC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a schema validator that enforces all properties of type T are present in the schema.
|
|
3
|
+
* This provides compile-time safety to ensure schemas don't miss optional properties.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* interface MyConfig {
|
|
8
|
+
* foo: string;
|
|
9
|
+
* bar?: number;
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* // ✅ This will work - all keys present
|
|
13
|
+
* const schema1 = zodFor<MyConfig>()(z.object({
|
|
14
|
+
* foo: z.string(),
|
|
15
|
+
* bar: z.number().optional(),
|
|
16
|
+
* }));
|
|
17
|
+
*
|
|
18
|
+
* // ❌ This will error - 'bar' is missing
|
|
19
|
+
* const schema2 = zodFor<MyConfig>()(z.object({
|
|
20
|
+
* foo: z.string(),
|
|
21
|
+
* }));
|
|
22
|
+
* ```
|
|
23
|
+
*/ export function zodFor() {
|
|
24
|
+
return (schema)=>schema;
|
|
25
|
+
}
|