@paimaexample/wallets 0.3.117
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/esm/chain-types/src/hash.d.ts +28 -0
- package/esm/chain-types/src/hash.d.ts.map +1 -0
- package/esm/chain-types/src/hash.js +29 -0
- package/esm/chain-types/src/mod.d.ts +3 -0
- package/esm/chain-types/src/mod.d.ts.map +1 -0
- package/esm/chain-types/src/mod.js +2 -0
- package/esm/chain-types/src/types.d.ts +70 -0
- package/esm/chain-types/src/types.d.ts.map +1 -0
- package/esm/chain-types/src/types.js +1 -0
- package/esm/concise/src/batcher.d.ts +40 -0
- package/esm/concise/src/batcher.d.ts.map +1 -0
- package/esm/concise/src/batcher.js +117 -0
- package/esm/concise/src/delegate.d.ts +18 -0
- package/esm/concise/src/delegate.d.ts.map +1 -0
- package/esm/concise/src/delegate.js +118 -0
- package/esm/concise/src/mod.d.ts +5 -0
- package/esm/concise/src/mod.d.ts.map +1 -0
- package/esm/concise/src/mod.js +3 -0
- package/esm/concise/src/v2/builtins/batcher.d.ts +27 -0
- package/esm/concise/src/v2/builtins/batcher.d.ts.map +1 -0
- package/esm/concise/src/v2/builtins/batcher.js +51 -0
- package/esm/concise/src/v2/builtins/grammar.d.ts +25 -0
- package/esm/concise/src/v2/builtins/grammar.d.ts.map +1 -0
- package/esm/concise/src/v2/builtins/grammar.js +40 -0
- package/esm/concise/src/v2/builtins/index.d.ts +3 -0
- package/esm/concise/src/v2/builtins/index.d.ts.map +1 -0
- package/esm/concise/src/v2/builtins/index.js +3 -0
- package/esm/concise/src/v2/grammar.d.ts +8 -0
- package/esm/concise/src/v2/grammar.d.ts.map +1 -0
- package/esm/concise/src/v2/grammar.js +19 -0
- package/esm/concise/src/v2/inputs.d.ts +7 -0
- package/esm/concise/src/v2/inputs.d.ts.map +1 -0
- package/esm/concise/src/v2/inputs.js +37 -0
- package/esm/concise/src/v2/mod.d.ts +5 -0
- package/esm/concise/src/v2/mod.d.ts.map +1 -0
- package/esm/concise/src/v2/mod.js +4 -0
- package/esm/concise/src/v2/types.d.ts +23 -0
- package/esm/concise/src/v2/types.d.ts.map +1 -0
- package/esm/concise/src/v2/types.js +1 -0
- package/esm/config/src/config/builder.d.ts +33 -0
- package/esm/config/src/config/builder.d.ts.map +1 -0
- package/esm/config/src/config/builder.js +82 -0
- package/esm/config/src/config/configCheck.d.ts +32 -0
- package/esm/config/src/config/configCheck.d.ts.map +1 -0
- package/esm/config/src/config/configCheck.js +67 -0
- package/esm/config/src/config/context.d.ts +23 -0
- package/esm/config/src/config/context.d.ts.map +1 -0
- package/esm/config/src/config/context.js +25 -0
- package/esm/config/src/config/mod.d.ts +7 -0
- package/esm/config/src/config/mod.d.ts.map +1 -0
- package/esm/config/src/config/mod.js +4 -0
- package/esm/config/src/config/parts/deployedAddresses.d.ts +17 -0
- package/esm/config/src/config/parts/deployedAddresses.d.ts.map +1 -0
- package/esm/config/src/config/parts/deployedAddresses.js +24 -0
- package/esm/config/src/config/parts/network.d.ts +19 -0
- package/esm/config/src/config/parts/network.d.ts.map +1 -0
- package/esm/config/src/config/parts/network.js +29 -0
- package/esm/config/src/config/parts/primitive.d.ts +31 -0
- package/esm/config/src/config/parts/primitive.d.ts.map +1 -0
- package/esm/config/src/config/parts/primitive.js +28 -0
- package/esm/config/src/config/parts/securityNamespace.d.ts +14 -0
- package/esm/config/src/config/parts/securityNamespace.d.ts.map +1 -0
- package/esm/config/src/config/parts/securityNamespace.js +26 -0
- package/esm/config/src/config/parts/syncProtocols.d.ts +43 -0
- package/esm/config/src/config/parts/syncProtocols.d.ts.map +1 -0
- package/esm/config/src/config/parts/syncProtocols.js +66 -0
- package/esm/config/src/config/utils.d.ts +40 -0
- package/esm/config/src/config/utils.d.ts.map +1 -0
- package/esm/config/src/config/utils.js +55 -0
- package/esm/config/src/mod.d.ts +3 -0
- package/esm/config/src/mod.d.ts.map +1 -0
- package/esm/config/src/mod.js +2 -0
- package/esm/config/src/schema/common.d.ts +26 -0
- package/esm/config/src/schema/common.d.ts.map +1 -0
- package/esm/config/src/schema/common.js +51 -0
- package/esm/config/src/schema/mod.d.ts +7 -0
- package/esm/config/src/schema/mod.d.ts.map +1 -0
- package/esm/config/src/schema/mod.js +6 -0
- package/esm/config/src/schema/namespace.d.ts +39 -0
- package/esm/config/src/schema/namespace.d.ts.map +1 -0
- package/esm/config/src/schema/namespace.js +34 -0
- package/esm/config/src/schema/network/algorand.d.ts +12 -0
- package/esm/config/src/schema/network/algorand.d.ts.map +1 -0
- package/esm/config/src/schema/network/algorand.js +23 -0
- package/esm/config/src/schema/network/all.d.ts +175 -0
- package/esm/config/src/schema/network/all.d.ts.map +1 -0
- package/esm/config/src/schema/network/all.js +24 -0
- package/esm/config/src/schema/network/bitcoin.d.ts +19 -0
- package/esm/config/src/schema/network/bitcoin.d.ts.map +1 -0
- package/esm/config/src/schema/network/bitcoin.js +21 -0
- package/esm/config/src/schema/network/cardano.d.ts +12 -0
- package/esm/config/src/schema/network/cardano.d.ts.map +1 -0
- package/esm/config/src/schema/network/cardano.js +27 -0
- package/esm/config/src/schema/network/evm.d.ts +68 -0
- package/esm/config/src/schema/network/evm.d.ts.map +1 -0
- package/esm/config/src/schema/network/evm.js +70 -0
- package/esm/config/src/schema/network/mina.d.ts +14 -0
- package/esm/config/src/schema/network/mina.d.ts.map +1 -0
- package/esm/config/src/schema/network/mina.js +25 -0
- package/esm/config/src/schema/network/mod.d.ts +9 -0
- package/esm/config/src/schema/network/mod.d.ts.map +1 -0
- package/esm/config/src/schema/network/mod.js +8 -0
- package/esm/config/src/schema/network/ntp.d.ts +32 -0
- package/esm/config/src/schema/network/ntp.d.ts.map +1 -0
- package/esm/config/src/schema/network/ntp.js +39 -0
- package/esm/config/src/schema/network/substrate/avail.d.ts +14 -0
- package/esm/config/src/schema/network/substrate/avail.d.ts.map +1 -0
- package/esm/config/src/schema/network/substrate/avail.js +26 -0
- package/esm/config/src/schema/network/substrate/common.d.ts +18 -0
- package/esm/config/src/schema/network/substrate/common.d.ts.map +1 -0
- package/esm/config/src/schema/network/substrate/common.js +32 -0
- package/esm/config/src/schema/network/substrate/midnight.d.ts +20 -0
- package/esm/config/src/schema/network/substrate/midnight.d.ts.map +1 -0
- package/esm/config/src/schema/network/substrate/midnight.js +32 -0
- package/esm/config/src/schema/network/substrate/mod.d.ts +4 -0
- package/esm/config/src/schema/network/substrate/mod.d.ts.map +1 -0
- package/esm/config/src/schema/network/substrate/mod.js +3 -0
- package/esm/config/src/schema/network/types.d.ts +13 -0
- package/esm/config/src/schema/network/types.d.ts.map +1 -0
- package/esm/config/src/schema/network/types.js +13 -0
- package/esm/config/src/schema/network/utils.d.ts +5 -0
- package/esm/config/src/schema/network/utils.d.ts.map +1 -0
- package/esm/config/src/schema/network/utils.js +73 -0
- package/esm/config/src/schema/primitive/mod.d.ts +2 -0
- package/esm/config/src/schema/primitive/mod.d.ts.map +1 -0
- package/esm/config/src/schema/primitive/mod.js +1 -0
- package/esm/config/src/schema/primitive/types.d.ts +58 -0
- package/esm/config/src/schema/primitive/types.d.ts.map +1 -0
- package/esm/config/src/schema/primitive/types.js +1 -0
- package/esm/config/src/schema/sync-protocols/all.d.ts +583 -0
- package/esm/config/src/schema/sync-protocols/all.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/all.js +55 -0
- package/esm/config/src/schema/sync-protocols/avail/rpc.d.ts +76 -0
- package/esm/config/src/schema/sync-protocols/avail/rpc.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/avail/rpc.js +56 -0
- package/esm/config/src/schema/sync-protocols/bitcoin/rpc.d.ts +76 -0
- package/esm/config/src/schema/sync-protocols/bitcoin/rpc.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/bitcoin/rpc.js +47 -0
- package/esm/config/src/schema/sync-protocols/cardano/carp.d.ts +80 -0
- package/esm/config/src/schema/sync-protocols/cardano/carp.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/cardano/carp.js +62 -0
- package/esm/config/src/schema/sync-protocols/cardano/mod.d.ts +2 -0
- package/esm/config/src/schema/sync-protocols/cardano/mod.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/cardano/mod.js +1 -0
- package/esm/config/src/schema/sync-protocols/cardano/utxorpc.d.ts +56 -0
- package/esm/config/src/schema/sync-protocols/cardano/utxorpc.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/cardano/utxorpc.js +56 -0
- package/esm/config/src/schema/sync-protocols/common.d.ts +60 -0
- package/esm/config/src/schema/sync-protocols/common.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/common.js +54 -0
- package/esm/config/src/schema/sync-protocols/decorators/all.d.ts +17 -0
- package/esm/config/src/schema/sync-protocols/decorators/all.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/decorators/all.js +8 -0
- package/esm/config/src/schema/sync-protocols/decorators/emulated.d.ts +8 -0
- package/esm/config/src/schema/sync-protocols/decorators/emulated.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/decorators/emulated.js +12 -0
- package/esm/config/src/schema/sync-protocols/decorators/mod.d.ts +4 -0
- package/esm/config/src/schema/sync-protocols/decorators/mod.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/decorators/mod.js +3 -0
- package/esm/config/src/schema/sync-protocols/decorators/types.d.ts +4 -0
- package/esm/config/src/schema/sync-protocols/decorators/types.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/decorators/types.js +4 -0
- package/esm/config/src/schema/sync-protocols/evm/rpc.d.ts +68 -0
- package/esm/config/src/schema/sync-protocols/evm/rpc.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/evm/rpc.js +44 -0
- package/esm/config/src/schema/sync-protocols/midnight/graphql.d.ts +66 -0
- package/esm/config/src/schema/sync-protocols/midnight/graphql.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/midnight/graphql.js +50 -0
- package/esm/config/src/schema/sync-protocols/mina/graphql.d.ts +73 -0
- package/esm/config/src/schema/sync-protocols/mina/graphql.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/mina/graphql.js +59 -0
- package/esm/config/src/schema/sync-protocols/mod.d.ts +10 -0
- package/esm/config/src/schema/sync-protocols/mod.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/mod.js +9 -0
- package/esm/config/src/schema/sync-protocols/ntp/rpc.d.ts +45 -0
- package/esm/config/src/schema/sync-protocols/ntp/rpc.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/ntp/rpc.js +33 -0
- package/esm/config/src/schema/sync-protocols/types.d.ts +125 -0
- package/esm/config/src/schema/sync-protocols/types.d.ts.map +1 -0
- package/esm/config/src/schema/sync-protocols/types.js +22 -0
- package/esm/config/src/schema/utils.d.ts +53 -0
- package/esm/config/src/schema/utils.d.ts.map +1 -0
- package/esm/config/src/schema/utils.js +58 -0
- package/esm/events/src/app-events.d.ts +65 -0
- package/esm/events/src/app-events.d.ts.map +1 -0
- package/esm/events/src/app-events.js +51 -0
- package/esm/events/src/asyncapi.d.ts +1173 -0
- package/esm/events/src/asyncapi.d.ts.map +1 -0
- package/esm/events/src/asyncapi.js +7 -0
- package/esm/events/src/builtin-event-utils.d.ts +5 -0
- package/esm/events/src/builtin-event-utils.d.ts.map +1 -0
- package/esm/events/src/builtin-event-utils.js +58 -0
- package/esm/events/src/builtin-events.d.ts +106 -0
- package/esm/events/src/builtin-events.d.ts.map +1 -0
- package/esm/events/src/builtin-events.js +198 -0
- package/esm/events/src/event-connect.d.ts +15 -0
- package/esm/events/src/event-connect.d.ts.map +1 -0
- package/esm/events/src/event-connect.js +75 -0
- package/esm/events/src/event-manager.d.ts +54 -0
- package/esm/events/src/event-manager.d.ts.map +1 -0
- package/esm/events/src/event-manager.js +129 -0
- package/esm/events/src/evm.d.ts +6 -0
- package/esm/events/src/evm.d.ts.map +1 -0
- package/esm/events/src/evm.js +55 -0
- package/esm/events/src/mod.d.ts +10 -0
- package/esm/events/src/mod.d.ts.map +1 -0
- package/esm/events/src/mod.js +9 -0
- package/esm/events/src/types.d.ts +255 -0
- package/esm/events/src/types.d.ts.map +1 -0
- package/esm/events/src/types.js +103 -0
- package/esm/events/src/utils.d.ts +16 -0
- package/esm/events/src/utils.d.ts.map +1 -0
- package/esm/events/src/utils.js +93 -0
- package/esm/package.json +3 -0
- package/esm/utils/src/binary-search.d.ts +7 -0
- package/esm/utils/src/binary-search.d.ts.map +1 -0
- package/esm/utils/src/binary-search.js +38 -0
- package/esm/utils/src/captcha.d.ts +9 -0
- package/esm/utils/src/captcha.d.ts.map +1 -0
- package/esm/utils/src/captcha.js +19 -0
- package/esm/utils/src/concurrency/condVar.d.ts +25 -0
- package/esm/utils/src/concurrency/condVar.d.ts.map +1 -0
- package/esm/utils/src/concurrency/condVar.js +39 -0
- package/esm/utils/src/concurrency/latch.d.ts +25 -0
- package/esm/utils/src/concurrency/latch.d.ts.map +1 -0
- package/esm/utils/src/concurrency/latch.js +51 -0
- package/esm/utils/src/concurrency/mod.d.ts +5 -0
- package/esm/utils/src/concurrency/mod.d.ts.map +1 -0
- package/esm/utils/src/concurrency/mod.js +4 -0
- package/esm/utils/src/concurrency/retry.d.ts +14 -0
- package/esm/utils/src/concurrency/retry.d.ts.map +1 -0
- package/esm/utils/src/concurrency/retry.js +26 -0
- package/esm/utils/src/concurrency/utils.d.ts +27 -0
- package/esm/utils/src/concurrency/utils.d.ts.map +1 -0
- package/esm/utils/src/concurrency/utils.js +27 -0
- package/esm/utils/src/constants.d.ts +4 -0
- package/esm/utils/src/constants.d.ts.map +1 -0
- package/esm/utils/src/constants.js +7 -0
- package/esm/utils/src/decorators/bound.d.ts +10 -0
- package/esm/utils/src/decorators/bound.d.ts.map +1 -0
- package/esm/utils/src/decorators/bound.js +17 -0
- package/esm/utils/src/decorators/mod.d.ts +2 -0
- package/esm/utils/src/decorators/mod.d.ts.map +1 -0
- package/esm/utils/src/decorators/mod.js +1 -0
- package/esm/utils/src/mod.d.ts +8 -0
- package/esm/utils/src/mod.d.ts.map +1 -0
- package/esm/utils/src/mod.js +7 -0
- package/esm/utils/src/types/json-query.d.ts +30 -0
- package/esm/utils/src/types/json-query.d.ts.map +1 -0
- package/esm/utils/src/types/json-query.js +1 -0
- package/esm/utils/src/types/misc.d.ts +109 -0
- package/esm/utils/src/types/misc.d.ts.map +1 -0
- package/esm/utils/src/types/misc.js +2 -0
- package/esm/utils/src/types/mod.d.ts +7 -0
- package/esm/utils/src/types/mod.d.ts.map +1 -0
- package/esm/utils/src/types/mod.js +3 -0
- package/esm/utils/src/types/nominal.d.ts +87 -0
- package/esm/utils/src/types/nominal.d.ts.map +1 -0
- package/esm/utils/src/types/nominal.js +1 -0
- package/esm/utils/src/types/typebox-helpers.d.ts +183 -0
- package/esm/utils/src/types/typebox-helpers.d.ts.map +1 -0
- package/esm/utils/src/types/typebox-helpers.js +235 -0
- package/esm/utils/src/types/utils.d.ts +37 -0
- package/esm/utils/src/types/utils.d.ts.map +1 -0
- package/esm/utils/src/types/utils.js +46 -0
- package/esm/utils/src/types/validators/algorand.d.ts +31 -0
- package/esm/utils/src/types/validators/algorand.d.ts.map +1 -0
- package/esm/utils/src/types/validators/algorand.js +90 -0
- package/esm/utils/src/types/validators/cardano.d.ts +26 -0
- package/esm/utils/src/types/validators/cardano.d.ts.map +1 -0
- package/esm/utils/src/types/validators/cardano.js +113 -0
- package/esm/utils/src/types/validators/mina.d.ts +15 -0
- package/esm/utils/src/types/validators/mina.d.ts.map +1 -0
- package/esm/utils/src/types/validators/mina.js +43 -0
- package/esm/utils/src/types/validators/minicbor.d.ts +98 -0
- package/esm/utils/src/types/validators/minicbor.d.ts.map +1 -0
- package/esm/utils/src/types/validators/minicbor.js +332 -0
- package/esm/utils/src/types/validators/mod.d.ts +3 -0
- package/esm/utils/src/types/validators/mod.d.ts.map +1 -0
- package/esm/utils/src/types/validators/mod.js +2 -0
- package/esm/utils/src/types/validators/utils.d.ts +6 -0
- package/esm/utils/src/types/validators/utils.d.ts.map +1 -0
- package/esm/utils/src/types/validators/utils.js +24 -0
- package/esm/utils/src/viem.d.ts +6 -0
- package/esm/utils/src/viem.d.ts.map +1 -0
- package/esm/utils/src/viem.js +15 -0
- package/esm/wallets/src/IProvider.d.ts +48 -0
- package/esm/wallets/src/IProvider.d.ts.map +1 -0
- package/esm/wallets/src/IProvider.js +7 -0
- package/esm/wallets/src/avail/avail.d.ts +28 -0
- package/esm/wallets/src/avail/avail.d.ts.map +1 -0
- package/esm/wallets/src/avail/avail.js +65 -0
- package/esm/wallets/src/avail/wrapper.d.ts +6 -0
- package/esm/wallets/src/avail/wrapper.d.ts.map +1 -0
- package/esm/wallets/src/avail/wrapper.js +31 -0
- package/esm/wallets/src/cardano/cardano.d.ts +30 -0
- package/esm/wallets/src/cardano/cardano.d.ts.map +1 -0
- package/esm/wallets/src/cardano/cardano.js +158 -0
- package/esm/wallets/src/cardano/wrapper.d.ts +7 -0
- package/esm/wallets/src/cardano/wrapper.d.ts.map +1 -0
- package/esm/wallets/src/cardano/wrapper.js +22 -0
- package/esm/wallets/src/evm/ethers.d.ts +28 -0
- package/esm/wallets/src/evm/ethers.d.ts.map +1 -0
- package/esm/wallets/src/evm/ethers.js +79 -0
- package/esm/wallets/src/evm/injected.d.ts +74 -0
- package/esm/wallets/src/evm/injected.d.ts.map +1 -0
- package/esm/wallets/src/evm/injected.js +322 -0
- package/esm/wallets/src/evm/types.d.ts +3 -0
- package/esm/wallets/src/evm/types.d.ts.map +1 -0
- package/esm/wallets/src/evm/types.js +1 -0
- package/esm/wallets/src/evm/wrapper-ethers.d.ts +6 -0
- package/esm/wallets/src/evm/wrapper-ethers.d.ts.map +1 -0
- package/esm/wallets/src/evm/wrapper-ethers.js +38 -0
- package/esm/wallets/src/evm/wrapper-injected.d.ts +7 -0
- package/esm/wallets/src/evm/wrapper-injected.d.ts.map +1 -0
- package/esm/wallets/src/evm/wrapper-injected.js +80 -0
- package/esm/wallets/src/midnight/midnight.d.ts +26 -0
- package/esm/wallets/src/midnight/midnight.d.ts.map +1 -0
- package/esm/wallets/src/midnight/midnight.js +112 -0
- package/esm/wallets/src/midnight/wrapper.d.ts +7 -0
- package/esm/wallets/src/midnight/wrapper.d.ts.map +1 -0
- package/esm/wallets/src/midnight/wrapper.js +22 -0
- package/esm/wallets/src/mina/mina.d.ts +28 -0
- package/esm/wallets/src/mina/mina.d.ts.map +1 -0
- package/esm/wallets/src/mina/mina.js +133 -0
- package/esm/wallets/src/mina/wrapper.d.ts +6 -0
- package/esm/wallets/src/mina/wrapper.d.ts.map +1 -0
- package/esm/wallets/src/mina/wrapper.js +12 -0
- package/esm/wallets/src/mod.d.ts +8 -0
- package/esm/wallets/src/mod.d.ts.map +1 -0
- package/esm/wallets/src/mod.js +5 -0
- package/esm/wallets/src/paima.d.ts +104 -0
- package/esm/wallets/src/paima.d.ts.map +1 -0
- package/esm/wallets/src/paima.js +244 -0
- package/esm/wallets/src/types.d.ts +49 -0
- package/esm/wallets/src/types.d.ts.map +1 -0
- package/esm/wallets/src/types.js +1 -0
- package/esm/wallets/src/utils.d.ts +41 -0
- package/esm/wallets/src/utils.d.ts.map +1 -0
- package/esm/wallets/src/utils.js +75 -0
- package/esm/wallets/src/wallet-modes.d.ts +49 -0
- package/esm/wallets/src/wallet-modes.d.ts.map +1 -0
- package/esm/wallets/src/wallet-modes.js +26 -0
- package/esm/wallets/src/wallets.d.ts +5 -0
- package/esm/wallets/src/wallets.d.ts.map +1 -0
- package/esm/wallets/src/wallets.js +55 -0
- package/esm/wallets/src/windows.d.ts +5 -0
- package/esm/wallets/src/windows.d.ts.map +1 -0
- package/esm/wallets/src/windows.js +9 -0
- package/package.json +51 -0
- package/script/chain-types/src/hash.d.ts +28 -0
- package/script/chain-types/src/hash.d.ts.map +1 -0
- package/script/chain-types/src/hash.js +36 -0
- package/script/chain-types/src/mod.d.ts +3 -0
- package/script/chain-types/src/mod.d.ts.map +1 -0
- package/script/chain-types/src/mod.js +18 -0
- package/script/chain-types/src/types.d.ts +70 -0
- package/script/chain-types/src/types.d.ts.map +1 -0
- package/script/chain-types/src/types.js +2 -0
- package/script/concise/src/batcher.d.ts +40 -0
- package/script/concise/src/batcher.d.ts.map +1 -0
- package/script/concise/src/batcher.js +122 -0
- package/script/concise/src/delegate.d.ts +18 -0
- package/script/concise/src/delegate.d.ts.map +1 -0
- package/script/concise/src/delegate.js +123 -0
- package/script/concise/src/mod.d.ts +5 -0
- package/script/concise/src/mod.d.ts.map +1 -0
- package/script/concise/src/mod.js +19 -0
- package/script/concise/src/v2/builtins/batcher.d.ts +27 -0
- package/script/concise/src/v2/builtins/batcher.d.ts.map +1 -0
- package/script/concise/src/v2/builtins/batcher.js +54 -0
- package/script/concise/src/v2/builtins/grammar.d.ts +25 -0
- package/script/concise/src/v2/builtins/grammar.d.ts.map +1 -0
- package/script/concise/src/v2/builtins/grammar.js +43 -0
- package/script/concise/src/v2/builtins/index.d.ts +3 -0
- package/script/concise/src/v2/builtins/index.d.ts.map +1 -0
- package/script/concise/src/v2/builtins/index.js +19 -0
- package/script/concise/src/v2/grammar.d.ts +8 -0
- package/script/concise/src/v2/grammar.d.ts.map +1 -0
- package/script/concise/src/v2/grammar.js +24 -0
- package/script/concise/src/v2/inputs.d.ts +7 -0
- package/script/concise/src/v2/inputs.d.ts.map +1 -0
- package/script/concise/src/v2/inputs.js +43 -0
- package/script/concise/src/v2/mod.d.ts +5 -0
- package/script/concise/src/v2/mod.d.ts.map +1 -0
- package/script/concise/src/v2/mod.js +20 -0
- package/script/concise/src/v2/types.d.ts +23 -0
- package/script/concise/src/v2/types.d.ts.map +1 -0
- package/script/concise/src/v2/types.js +2 -0
- package/script/config/src/config/builder.d.ts +33 -0
- package/script/config/src/config/builder.d.ts.map +1 -0
- package/script/config/src/config/builder.js +86 -0
- package/script/config/src/config/configCheck.d.ts +32 -0
- package/script/config/src/config/configCheck.d.ts.map +1 -0
- package/script/config/src/config/configCheck.js +70 -0
- package/script/config/src/config/context.d.ts +23 -0
- package/script/config/src/config/context.d.ts.map +1 -0
- package/script/config/src/config/context.js +31 -0
- package/script/config/src/config/mod.d.ts +7 -0
- package/script/config/src/config/mod.d.ts.map +1 -0
- package/script/config/src/config/mod.js +22 -0
- package/script/config/src/config/parts/deployedAddresses.d.ts +17 -0
- package/script/config/src/config/parts/deployedAddresses.d.ts.map +1 -0
- package/script/config/src/config/parts/deployedAddresses.js +28 -0
- package/script/config/src/config/parts/network.d.ts +19 -0
- package/script/config/src/config/parts/network.d.ts.map +1 -0
- package/script/config/src/config/parts/network.js +33 -0
- package/script/config/src/config/parts/primitive.d.ts +31 -0
- package/script/config/src/config/parts/primitive.d.ts.map +1 -0
- package/script/config/src/config/parts/primitive.js +32 -0
- package/script/config/src/config/parts/securityNamespace.d.ts +14 -0
- package/script/config/src/config/parts/securityNamespace.d.ts.map +1 -0
- package/script/config/src/config/parts/securityNamespace.js +30 -0
- package/script/config/src/config/parts/syncProtocols.d.ts +43 -0
- package/script/config/src/config/parts/syncProtocols.d.ts.map +1 -0
- package/script/config/src/config/parts/syncProtocols.js +70 -0
- package/script/config/src/config/utils.d.ts +40 -0
- package/script/config/src/config/utils.d.ts.map +1 -0
- package/script/config/src/config/utils.js +62 -0
- package/script/config/src/mod.d.ts +3 -0
- package/script/config/src/mod.d.ts.map +1 -0
- package/script/config/src/mod.js +18 -0
- package/script/config/src/schema/common.d.ts +26 -0
- package/script/config/src/schema/common.d.ts.map +1 -0
- package/script/config/src/schema/common.js +54 -0
- package/script/config/src/schema/mod.d.ts +7 -0
- package/script/config/src/schema/mod.d.ts.map +1 -0
- package/script/config/src/schema/mod.js +22 -0
- package/script/config/src/schema/namespace.d.ts +39 -0
- package/script/config/src/schema/namespace.d.ts.map +1 -0
- package/script/config/src/schema/namespace.js +38 -0
- package/script/config/src/schema/network/algorand.d.ts +12 -0
- package/script/config/src/schema/network/algorand.d.ts.map +1 -0
- package/script/config/src/schema/network/algorand.js +26 -0
- package/script/config/src/schema/network/all.d.ts +175 -0
- package/script/config/src/schema/network/all.d.ts.map +1 -0
- package/script/config/src/schema/network/all.js +28 -0
- package/script/config/src/schema/network/bitcoin.d.ts +19 -0
- package/script/config/src/schema/network/bitcoin.d.ts.map +1 -0
- package/script/config/src/schema/network/bitcoin.js +24 -0
- package/script/config/src/schema/network/cardano.d.ts +12 -0
- package/script/config/src/schema/network/cardano.d.ts.map +1 -0
- package/script/config/src/schema/network/cardano.js +30 -0
- package/script/config/src/schema/network/evm.d.ts +68 -0
- package/script/config/src/schema/network/evm.d.ts.map +1 -0
- package/script/config/src/schema/network/evm.js +75 -0
- package/script/config/src/schema/network/mina.d.ts +14 -0
- package/script/config/src/schema/network/mina.d.ts.map +1 -0
- package/script/config/src/schema/network/mina.js +28 -0
- package/script/config/src/schema/network/mod.d.ts +9 -0
- package/script/config/src/schema/network/mod.d.ts.map +1 -0
- package/script/config/src/schema/network/mod.js +24 -0
- package/script/config/src/schema/network/ntp.d.ts +32 -0
- package/script/config/src/schema/network/ntp.d.ts.map +1 -0
- package/script/config/src/schema/network/ntp.js +42 -0
- package/script/config/src/schema/network/substrate/avail.d.ts +14 -0
- package/script/config/src/schema/network/substrate/avail.d.ts.map +1 -0
- package/script/config/src/schema/network/substrate/avail.js +29 -0
- package/script/config/src/schema/network/substrate/common.d.ts +18 -0
- package/script/config/src/schema/network/substrate/common.d.ts.map +1 -0
- package/script/config/src/schema/network/substrate/common.js +35 -0
- package/script/config/src/schema/network/substrate/midnight.d.ts +20 -0
- package/script/config/src/schema/network/substrate/midnight.d.ts.map +1 -0
- package/script/config/src/schema/network/substrate/midnight.js +35 -0
- package/script/config/src/schema/network/substrate/mod.d.ts +4 -0
- package/script/config/src/schema/network/substrate/mod.d.ts.map +1 -0
- package/script/config/src/schema/network/substrate/mod.js +19 -0
- package/script/config/src/schema/network/types.d.ts +13 -0
- package/script/config/src/schema/network/types.d.ts.map +1 -0
- package/script/config/src/schema/network/types.js +16 -0
- package/script/config/src/schema/network/utils.d.ts +5 -0
- package/script/config/src/schema/network/utils.d.ts.map +1 -0
- package/script/config/src/schema/network/utils.js +76 -0
- package/script/config/src/schema/primitive/mod.d.ts +2 -0
- package/script/config/src/schema/primitive/mod.d.ts.map +1 -0
- package/script/config/src/schema/primitive/mod.js +17 -0
- package/script/config/src/schema/primitive/types.d.ts +58 -0
- package/script/config/src/schema/primitive/types.d.ts.map +1 -0
- package/script/config/src/schema/primitive/types.js +2 -0
- package/script/config/src/schema/sync-protocols/all.d.ts +583 -0
- package/script/config/src/schema/sync-protocols/all.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/all.js +62 -0
- package/script/config/src/schema/sync-protocols/avail/rpc.d.ts +76 -0
- package/script/config/src/schema/sync-protocols/avail/rpc.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/avail/rpc.js +59 -0
- package/script/config/src/schema/sync-protocols/bitcoin/rpc.d.ts +76 -0
- package/script/config/src/schema/sync-protocols/bitcoin/rpc.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/bitcoin/rpc.js +50 -0
- package/script/config/src/schema/sync-protocols/cardano/carp.d.ts +80 -0
- package/script/config/src/schema/sync-protocols/cardano/carp.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/cardano/carp.js +65 -0
- package/script/config/src/schema/sync-protocols/cardano/mod.d.ts +2 -0
- package/script/config/src/schema/sync-protocols/cardano/mod.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/cardano/mod.js +17 -0
- package/script/config/src/schema/sync-protocols/cardano/utxorpc.d.ts +56 -0
- package/script/config/src/schema/sync-protocols/cardano/utxorpc.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/cardano/utxorpc.js +59 -0
- package/script/config/src/schema/sync-protocols/common.d.ts +60 -0
- package/script/config/src/schema/sync-protocols/common.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/common.js +61 -0
- package/script/config/src/schema/sync-protocols/decorators/all.d.ts +17 -0
- package/script/config/src/schema/sync-protocols/decorators/all.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/decorators/all.js +12 -0
- package/script/config/src/schema/sync-protocols/decorators/emulated.d.ts +8 -0
- package/script/config/src/schema/sync-protocols/decorators/emulated.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/decorators/emulated.js +15 -0
- package/script/config/src/schema/sync-protocols/decorators/mod.d.ts +4 -0
- package/script/config/src/schema/sync-protocols/decorators/mod.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/decorators/mod.js +19 -0
- package/script/config/src/schema/sync-protocols/decorators/types.d.ts +4 -0
- package/script/config/src/schema/sync-protocols/decorators/types.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/decorators/types.js +7 -0
- package/script/config/src/schema/sync-protocols/evm/rpc.d.ts +68 -0
- package/script/config/src/schema/sync-protocols/evm/rpc.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/evm/rpc.js +47 -0
- package/script/config/src/schema/sync-protocols/midnight/graphql.d.ts +66 -0
- package/script/config/src/schema/sync-protocols/midnight/graphql.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/midnight/graphql.js +53 -0
- package/script/config/src/schema/sync-protocols/mina/graphql.d.ts +73 -0
- package/script/config/src/schema/sync-protocols/mina/graphql.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/mina/graphql.js +62 -0
- package/script/config/src/schema/sync-protocols/mod.d.ts +10 -0
- package/script/config/src/schema/sync-protocols/mod.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/mod.js +25 -0
- package/script/config/src/schema/sync-protocols/ntp/rpc.d.ts +45 -0
- package/script/config/src/schema/sync-protocols/ntp/rpc.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/ntp/rpc.js +36 -0
- package/script/config/src/schema/sync-protocols/types.d.ts +125 -0
- package/script/config/src/schema/sync-protocols/types.d.ts.map +1 -0
- package/script/config/src/schema/sync-protocols/types.js +25 -0
- package/script/config/src/schema/utils.d.ts +53 -0
- package/script/config/src/schema/utils.d.ts.map +1 -0
- package/script/config/src/schema/utils.js +62 -0
- package/script/events/src/app-events.d.ts +65 -0
- package/script/events/src/app-events.d.ts.map +1 -0
- package/script/events/src/app-events.js +62 -0
- package/script/events/src/asyncapi.d.ts +1173 -0
- package/script/events/src/asyncapi.d.ts.map +1 -0
- package/script/events/src/asyncapi.js +8 -0
- package/script/events/src/builtin-event-utils.d.ts +5 -0
- package/script/events/src/builtin-event-utils.d.ts.map +1 -0
- package/script/events/src/builtin-event-utils.js +63 -0
- package/script/events/src/builtin-events.d.ts +106 -0
- package/script/events/src/builtin-events.d.ts.map +1 -0
- package/script/events/src/builtin-events.js +204 -0
- package/script/events/src/event-connect.d.ts +15 -0
- package/script/events/src/event-connect.d.ts.map +1 -0
- package/script/events/src/event-connect.js +82 -0
- package/script/events/src/event-manager.d.ts +54 -0
- package/script/events/src/event-manager.d.ts.map +1 -0
- package/script/events/src/event-manager.js +133 -0
- package/script/events/src/evm.d.ts +6 -0
- package/script/events/src/evm.d.ts.map +1 -0
- package/script/events/src/evm.js +59 -0
- package/script/events/src/mod.d.ts +10 -0
- package/script/events/src/mod.d.ts.map +1 -0
- package/script/events/src/mod.js +25 -0
- package/script/events/src/types.d.ts +255 -0
- package/script/events/src/types.d.ts.map +1 -0
- package/script/events/src/types.js +111 -0
- package/script/events/src/utils.d.ts +16 -0
- package/script/events/src/utils.d.ts.map +1 -0
- package/script/events/src/utils.js +98 -0
- package/script/package.json +3 -0
- package/script/utils/src/binary-search.d.ts +7 -0
- package/script/utils/src/binary-search.d.ts.map +1 -0
- package/script/utils/src/binary-search.js +41 -0
- package/script/utils/src/captcha.d.ts +9 -0
- package/script/utils/src/captcha.d.ts.map +1 -0
- package/script/utils/src/captcha.js +22 -0
- package/script/utils/src/concurrency/condVar.d.ts +25 -0
- package/script/utils/src/concurrency/condVar.d.ts.map +1 -0
- package/script/utils/src/concurrency/condVar.js +42 -0
- package/script/utils/src/concurrency/latch.d.ts +25 -0
- package/script/utils/src/concurrency/latch.d.ts.map +1 -0
- package/script/utils/src/concurrency/latch.js +54 -0
- package/script/utils/src/concurrency/mod.d.ts +5 -0
- package/script/utils/src/concurrency/mod.d.ts.map +1 -0
- package/script/utils/src/concurrency/mod.js +20 -0
- package/script/utils/src/concurrency/retry.d.ts +14 -0
- package/script/utils/src/concurrency/retry.d.ts.map +1 -0
- package/script/utils/src/concurrency/retry.js +30 -0
- package/script/utils/src/concurrency/utils.d.ts +27 -0
- package/script/utils/src/concurrency/utils.d.ts.map +1 -0
- package/script/utils/src/concurrency/utils.js +30 -0
- package/script/utils/src/constants.d.ts +4 -0
- package/script/utils/src/constants.d.ts.map +1 -0
- package/script/utils/src/constants.js +12 -0
- package/script/utils/src/decorators/bound.d.ts +10 -0
- package/script/utils/src/decorators/bound.d.ts.map +1 -0
- package/script/utils/src/decorators/bound.js +20 -0
- package/script/utils/src/decorators/mod.d.ts +2 -0
- package/script/utils/src/decorators/mod.d.ts.map +1 -0
- package/script/utils/src/decorators/mod.js +17 -0
- package/script/utils/src/mod.d.ts +8 -0
- package/script/utils/src/mod.d.ts.map +1 -0
- package/script/utils/src/mod.js +23 -0
- package/script/utils/src/types/json-query.d.ts +30 -0
- package/script/utils/src/types/json-query.d.ts.map +1 -0
- package/script/utils/src/types/json-query.js +2 -0
- package/script/utils/src/types/misc.d.ts +109 -0
- package/script/utils/src/types/misc.d.ts.map +1 -0
- package/script/utils/src/types/misc.js +3 -0
- package/script/utils/src/types/mod.d.ts +7 -0
- package/script/utils/src/types/mod.d.ts.map +1 -0
- package/script/utils/src/types/mod.js +19 -0
- package/script/utils/src/types/nominal.d.ts +87 -0
- package/script/utils/src/types/nominal.d.ts.map +1 -0
- package/script/utils/src/types/nominal.js +2 -0
- package/script/utils/src/types/typebox-helpers.d.ts +183 -0
- package/script/utils/src/types/typebox-helpers.d.ts.map +1 -0
- package/script/utils/src/types/typebox-helpers.js +277 -0
- package/script/utils/src/types/utils.d.ts +37 -0
- package/script/utils/src/types/utils.d.ts.map +1 -0
- package/script/utils/src/types/utils.js +52 -0
- package/script/utils/src/types/validators/algorand.d.ts +31 -0
- package/script/utils/src/types/validators/algorand.d.ts.map +1 -0
- package/script/utils/src/types/validators/algorand.js +98 -0
- package/script/utils/src/types/validators/cardano.d.ts +26 -0
- package/script/utils/src/types/validators/cardano.d.ts.map +1 -0
- package/script/utils/src/types/validators/cardano.js +121 -0
- package/script/utils/src/types/validators/mina.d.ts +15 -0
- package/script/utils/src/types/validators/mina.d.ts.map +1 -0
- package/script/utils/src/types/validators/mina.js +51 -0
- package/script/utils/src/types/validators/minicbor.d.ts +98 -0
- package/script/utils/src/types/validators/minicbor.d.ts.map +1 -0
- package/script/utils/src/types/validators/minicbor.js +337 -0
- package/script/utils/src/types/validators/mod.d.ts +3 -0
- package/script/utils/src/types/validators/mod.d.ts.map +1 -0
- package/script/utils/src/types/validators/mod.js +18 -0
- package/script/utils/src/types/validators/utils.d.ts +6 -0
- package/script/utils/src/types/validators/utils.d.ts.map +1 -0
- package/script/utils/src/types/validators/utils.js +31 -0
- package/script/utils/src/viem.d.ts +6 -0
- package/script/utils/src/viem.d.ts.map +1 -0
- package/script/utils/src/viem.js +19 -0
- package/script/wallets/src/IProvider.d.ts +48 -0
- package/script/wallets/src/IProvider.d.ts.map +1 -0
- package/script/wallets/src/IProvider.js +10 -0
- package/script/wallets/src/avail/avail.d.ts +28 -0
- package/script/wallets/src/avail/avail.d.ts.map +1 -0
- package/script/wallets/src/avail/avail.js +70 -0
- package/script/wallets/src/avail/wrapper.d.ts +6 -0
- package/script/wallets/src/avail/wrapper.d.ts.map +1 -0
- package/script/wallets/src/avail/wrapper.js +34 -0
- package/script/wallets/src/cardano/cardano.d.ts +30 -0
- package/script/wallets/src/cardano/cardano.d.ts.map +1 -0
- package/script/wallets/src/cardano/cardano.js +163 -0
- package/script/wallets/src/cardano/wrapper.d.ts +7 -0
- package/script/wallets/src/cardano/wrapper.d.ts.map +1 -0
- package/script/wallets/src/cardano/wrapper.js +26 -0
- package/script/wallets/src/evm/ethers.d.ts +28 -0
- package/script/wallets/src/evm/ethers.d.ts.map +1 -0
- package/script/wallets/src/evm/ethers.js +84 -0
- package/script/wallets/src/evm/injected.d.ts +74 -0
- package/script/wallets/src/evm/injected.d.ts.map +1 -0
- package/script/wallets/src/evm/injected.js +360 -0
- package/script/wallets/src/evm/types.d.ts +3 -0
- package/script/wallets/src/evm/types.d.ts.map +1 -0
- package/script/wallets/src/evm/types.js +4 -0
- package/script/wallets/src/evm/wrapper-ethers.d.ts +6 -0
- package/script/wallets/src/evm/wrapper-ethers.d.ts.map +1 -0
- package/script/wallets/src/evm/wrapper-ethers.js +41 -0
- package/script/wallets/src/evm/wrapper-injected.d.ts +7 -0
- package/script/wallets/src/evm/wrapper-injected.d.ts.map +1 -0
- package/script/wallets/src/evm/wrapper-injected.js +84 -0
- package/script/wallets/src/midnight/midnight.d.ts +26 -0
- package/script/wallets/src/midnight/midnight.d.ts.map +1 -0
- package/script/wallets/src/midnight/midnight.js +117 -0
- package/script/wallets/src/midnight/wrapper.d.ts +7 -0
- package/script/wallets/src/midnight/wrapper.d.ts.map +1 -0
- package/script/wallets/src/midnight/wrapper.js +26 -0
- package/script/wallets/src/mina/mina.d.ts +28 -0
- package/script/wallets/src/mina/mina.d.ts.map +1 -0
- package/script/wallets/src/mina/mina.js +138 -0
- package/script/wallets/src/mina/wrapper.d.ts +6 -0
- package/script/wallets/src/mina/wrapper.d.ts.map +1 -0
- package/script/wallets/src/mina/wrapper.js +15 -0
- package/script/wallets/src/mod.d.ts +8 -0
- package/script/wallets/src/mod.d.ts.map +1 -0
- package/script/wallets/src/mod.js +26 -0
- package/script/wallets/src/paima.d.ts +104 -0
- package/script/wallets/src/paima.d.ts.map +1 -0
- package/script/wallets/src/paima.js +253 -0
- package/script/wallets/src/types.d.ts +49 -0
- package/script/wallets/src/types.d.ts.map +1 -0
- package/script/wallets/src/types.js +2 -0
- package/script/wallets/src/utils.d.ts +41 -0
- package/script/wallets/src/utils.d.ts.map +1 -0
- package/script/wallets/src/utils.js +81 -0
- package/script/wallets/src/wallet-modes.d.ts +49 -0
- package/script/wallets/src/wallet-modes.d.ts.map +1 -0
- package/script/wallets/src/wallet-modes.js +29 -0
- package/script/wallets/src/wallets.d.ts +5 -0
- package/script/wallets/src/wallets.d.ts.map +1 -0
- package/script/wallets/src/wallets.js +58 -0
- package/script/wallets/src/windows.d.ts +5 -0
- package/script/wallets/src/windows.d.ts.map +1 -0
- package/script/wallets/src/windows.js +12 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaimaEventManager = void 0;
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const event_connect_js_1 = require("./event-connect.js");
|
|
7
|
+
const types_js_1 = require("./types.js");
|
|
8
|
+
/*
|
|
9
|
+
* This class subscribes to specific topics, and stores the callbacks for event processing.
|
|
10
|
+
*/
|
|
11
|
+
class PaimaEventManager {
|
|
12
|
+
callbacksForTopic = {
|
|
13
|
+
[types_js_1.PaimaEventBrokerNames.PaimaEngine]: {},
|
|
14
|
+
[types_js_1.PaimaEventBrokerNames.Batcher]: {},
|
|
15
|
+
};
|
|
16
|
+
symbolToSubscription = {};
|
|
17
|
+
static Instance = new PaimaEventManager();
|
|
18
|
+
constructor() {
|
|
19
|
+
// TODO: replace once TS5 decorators are better supported
|
|
20
|
+
this.subscribe.bind(this);
|
|
21
|
+
this.subscribeExplicit.bind(this);
|
|
22
|
+
this.unsubscribe.bind(this);
|
|
23
|
+
this.sendMessage.bind(this);
|
|
24
|
+
this.sendMessageExplicit.bind(this);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Subscribe to events for a topic filtered by a set of indexed variables
|
|
28
|
+
* @param broker
|
|
29
|
+
* @param filter a filter to generate the MQTT topic syntax to monitor for new events
|
|
30
|
+
* @param callback a callback to call when a message matching this topic is encountered
|
|
31
|
+
* @returns a unique symbol to use to unsubscribe the specific callback
|
|
32
|
+
*/
|
|
33
|
+
async subscribe(args, callback) {
|
|
34
|
+
return await this.subscribeExplicit({
|
|
35
|
+
topic: args.topic,
|
|
36
|
+
filter: args.filter,
|
|
37
|
+
}, ({ val, resolvedPath }) => callback({ ...val, ...resolvedPath }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Subscribe to events for a topic filtered by a set of indexed variables
|
|
41
|
+
*
|
|
42
|
+
* This is an explicit version of the `subscribe` function
|
|
43
|
+
* by explicit, it means MQTT topic vars and content are treated differently
|
|
44
|
+
* this is worse devx, but supports cases where topic & content have vars with overlapping names
|
|
45
|
+
* @param broker
|
|
46
|
+
* @param filter a filter to generate the MQTT topic syntax to monitor for new events
|
|
47
|
+
* @param callback a callback to call when a message matching this topic is encountered
|
|
48
|
+
* @returns a unique symbol to use to unsubscribe the specific callback
|
|
49
|
+
*/
|
|
50
|
+
async subscribeExplicit(args, callback) {
|
|
51
|
+
const client = await new event_connect_js_1.PaimaEventConnect().getClient(args.topic.broker);
|
|
52
|
+
const topic = (0, utils_js_1.fillPath)(args.topic.path, args.filter);
|
|
53
|
+
const clientSubscribe = async () => {
|
|
54
|
+
try {
|
|
55
|
+
await client.subscribeAsync(topic, { qos: 2 });
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.log(`MQTT[${args.topic.broker}] ERROR`, err);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
if (client.connected)
|
|
62
|
+
await clientSubscribe();
|
|
63
|
+
else
|
|
64
|
+
await new Promise(resolve => {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
66
|
+
client.on('connect', async () => {
|
|
67
|
+
await clientSubscribe();
|
|
68
|
+
resolve();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
// keep track of a unique symbol for the subscription that can be used to unsubscribe later
|
|
72
|
+
const symbol = Symbol(topic);
|
|
73
|
+
this.symbolToSubscription[symbol] = {
|
|
74
|
+
broker: args.topic.broker,
|
|
75
|
+
topic,
|
|
76
|
+
};
|
|
77
|
+
const callbacksForTopic = this.callbacksForTopic[args.topic.broker][topic] ?? {};
|
|
78
|
+
callbacksForTopic[symbol] = {
|
|
79
|
+
// in practice, casting to any shouldn't be problem
|
|
80
|
+
// since callbacks are only called for specific topics where we know the type matches
|
|
81
|
+
callback: callback, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
82
|
+
event: args.topic,
|
|
83
|
+
};
|
|
84
|
+
this.callbacksForTopic[args.topic.broker][topic] = callbacksForTopic;
|
|
85
|
+
return symbol;
|
|
86
|
+
}
|
|
87
|
+
async unsubscribe(event) {
|
|
88
|
+
const { topic, broker } = this.symbolToSubscription[event];
|
|
89
|
+
if (topic == null) {
|
|
90
|
+
console.error('Subscription not found', event.description);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
delete this.symbolToSubscription[event];
|
|
94
|
+
const callbacks = this.callbacksForTopic[broker][topic];
|
|
95
|
+
delete callbacks[event];
|
|
96
|
+
const numCallbacks = Object.keys(callbacks).length - 1; // objs are small, so this is fast enough in practice
|
|
97
|
+
// if there are no references left to this topic, we can unsubscribe from it
|
|
98
|
+
if (numCallbacks === 0) {
|
|
99
|
+
const client = await new event_connect_js_1.PaimaEventConnect().getClient(broker);
|
|
100
|
+
delete this.callbacksForTopic[broker][topic];
|
|
101
|
+
const clientUnsubscribe = async () => {
|
|
102
|
+
try {
|
|
103
|
+
await client.unsubscribeAsync(topic);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
console.log(`MQTT[${broker}] ERROR`, err);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
if (client.connected)
|
|
110
|
+
await clientUnsubscribe();
|
|
111
|
+
else
|
|
112
|
+
await new Promise(resolve => {
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
114
|
+
client.on('connect', async () => {
|
|
115
|
+
await clientUnsubscribe();
|
|
116
|
+
resolve();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async sendMessage(topic, event) {
|
|
122
|
+
const filterKeys = new Set((0, utils_js_1.keysForPath)(topic.path));
|
|
123
|
+
const filter = Object.fromEntries(Object.entries(event).filter(([key, _]) => filterKeys.has(key))); // typescript can't know this filter actually matches the static type
|
|
124
|
+
const message = Object.fromEntries(Object.entries(event).filter(([key, _]) => !filterKeys.has(key))); // typescript can't know this filter actually matches the static type
|
|
125
|
+
return await this.sendMessageExplicit({ topic, filter }, message);
|
|
126
|
+
}
|
|
127
|
+
async sendMessageExplicit(args, message) {
|
|
128
|
+
const client = await new event_connect_js_1.PaimaEventConnect().getClient(args.topic.broker);
|
|
129
|
+
const topicPath = (0, utils_js_1.fillPath)(args.topic.path, args.filter);
|
|
130
|
+
await client.publishAsync(topicPath, JSON.stringify(message), { qos: 2 });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.PaimaEventManager = PaimaEventManager;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TSchema } from '@sinclair/typebox';
|
|
2
|
+
import type { LogEvent, LogEventFields } from './types.js';
|
|
3
|
+
import type { AbiParameter } from 'abitype';
|
|
4
|
+
export declare function fieldToAbi<Type extends TSchema>(type: Type): AbiParameter | undefined;
|
|
5
|
+
export declare function toEvmAbi<const T extends LogEvent<LogEventFields<TSchema>[]>>(log: T): undefined | AbiParameter[];
|
|
6
|
+
//# sourceMappingURL=evm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../src/events/src/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,OAAO,EAAU,MAAM,mBAAmB,CAAC;AAE1E,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,UAAU,CAAC,IAAI,SAAS,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,YAAY,GAAG,SAAS,CA2CrF;AACD,wBAAgB,QAAQ,CAAC,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,EAC1E,GAAG,EAAE,CAAC,GACL,SAAS,GAAG,YAAY,EAAE,CAW5B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fieldToAbi = fieldToAbi;
|
|
4
|
+
exports.toEvmAbi = toEvmAbi;
|
|
5
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
6
|
+
function fieldToAbi(type) {
|
|
7
|
+
const isString = typebox_1.Type.Extends(type, typebox_1.Type.String(), typebox_1.Type.Literal(true), typebox_1.Type.Literal(false)).const;
|
|
8
|
+
if (isString) {
|
|
9
|
+
return { type: 'string' };
|
|
10
|
+
}
|
|
11
|
+
const isNumber = typebox_1.Type.Extends(type, typebox_1.Type.Number(), typebox_1.Type.Literal(true), typebox_1.Type.Literal(false)).const;
|
|
12
|
+
if (isNumber) {
|
|
13
|
+
const minimum = type.minimum;
|
|
14
|
+
const maximum = type.maximum;
|
|
15
|
+
const isSigned = minimum != null && minimum < 0;
|
|
16
|
+
const bits = maximum == null ? null : Math.log2(isSigned ? maximum + 1 : maximum);
|
|
17
|
+
const suffix = bits == null || !Number.isInteger(bits) ? '' : isSigned ? bits + 1 : bits;
|
|
18
|
+
return { type: `${isSigned ? 'int' : 'uint'}${suffix}` };
|
|
19
|
+
}
|
|
20
|
+
const isBoolean = typebox_1.Type.Extends(type, typebox_1.Type.Boolean(), typebox_1.Type.Literal(true), typebox_1.Type.Literal(false)).const;
|
|
21
|
+
if (isBoolean) {
|
|
22
|
+
return { type: 'bool' };
|
|
23
|
+
}
|
|
24
|
+
if (type[typebox_1.Kind] === 'Tuple') {
|
|
25
|
+
const components = [];
|
|
26
|
+
for (const subtype of type.items?.map(t => fieldToAbi(t)) ?? []) {
|
|
27
|
+
if (subtype == null)
|
|
28
|
+
return undefined;
|
|
29
|
+
components.push(subtype);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
type: 'tuple',
|
|
33
|
+
components,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (type[typebox_1.Kind] === 'Array') {
|
|
37
|
+
const innerType = fieldToAbi(type.items);
|
|
38
|
+
if (innerType == null)
|
|
39
|
+
return undefined;
|
|
40
|
+
return { type: `${innerType.type}[]` };
|
|
41
|
+
}
|
|
42
|
+
// TODO: address
|
|
43
|
+
// TODO: bytes
|
|
44
|
+
// TODO: support refining to numbers larger than max JS Number size (ex: uint256)
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
function toEvmAbi(log) {
|
|
48
|
+
const params = [];
|
|
49
|
+
for (const field of log.fields) {
|
|
50
|
+
const parsedField = fieldToAbi(field.type);
|
|
51
|
+
if (parsedField == null)
|
|
52
|
+
return undefined;
|
|
53
|
+
params.push({
|
|
54
|
+
...parsedField,
|
|
55
|
+
name: field.name,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return params;
|
|
59
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './app-events.js';
|
|
2
|
+
export * from './event-manager.js';
|
|
3
|
+
export * from './builtin-events.js';
|
|
4
|
+
export * from './builtin-event-utils.js';
|
|
5
|
+
export * from './utils.js';
|
|
6
|
+
export * from './event-connect.js';
|
|
7
|
+
export * from './builtin-event-utils.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
export * from './evm.js';
|
|
10
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/events/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./app-events.js"), exports);
|
|
18
|
+
__exportStar(require("./event-manager.js"), exports);
|
|
19
|
+
__exportStar(require("./builtin-events.js"), exports);
|
|
20
|
+
__exportStar(require("./builtin-event-utils.js"), exports);
|
|
21
|
+
__exportStar(require("./utils.js"), exports);
|
|
22
|
+
__exportStar(require("./event-connect.js"), exports);
|
|
23
|
+
__exportStar(require("./builtin-event-utils.js"), exports);
|
|
24
|
+
__exportStar(require("./types.js"), exports);
|
|
25
|
+
__exportStar(require("./evm.js"), exports);
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type { TString, TInteger, TExtends, Kind, TTuple, TLiteral, TObject, Static, TSchema } from '@sinclair/typebox';
|
|
2
|
+
export declare enum PaimaEventBrokerNames {
|
|
3
|
+
PaimaEngine = "effectstream-engine",
|
|
4
|
+
Batcher = "batcher"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Name inspired from https://docs.aws.amazon.com/whitepapers/latest/designing-mqtt-topics-aws-iot-core/mqtt-design-best-practices.html#:~:text=Since%20MQTT%20topics%20are%20case,when%20creating%20each%20topic%20level
|
|
8
|
+
*/
|
|
9
|
+
export declare enum TopicPrefix {
|
|
10
|
+
Batcher = "batcher",
|
|
11
|
+
Node = "node",
|
|
12
|
+
App = "app"
|
|
13
|
+
}
|
|
14
|
+
export declare function topicToBroker(topic: TopicPrefix): PaimaEventBrokerNames;
|
|
15
|
+
/**
|
|
16
|
+
* ============================
|
|
17
|
+
* Define paths for MQTT topics
|
|
18
|
+
* ============================
|
|
19
|
+
*/
|
|
20
|
+
export type SimplePath = string;
|
|
21
|
+
export type ArgPath = {
|
|
22
|
+
name: string;
|
|
23
|
+
type: TSchema;
|
|
24
|
+
};
|
|
25
|
+
export type EventPath = (SimplePath | ArgPath)[];
|
|
26
|
+
/**
|
|
27
|
+
* ===================================================
|
|
28
|
+
* Define the dev-friendly event log definition format
|
|
29
|
+
* ===================================================
|
|
30
|
+
*/
|
|
31
|
+
type EnsureExtendsString<A extends TSchema> = TExtends<A, TString, TLiteral<true>, TLiteral<false>> extends TLiteral<true> ? A : never;
|
|
32
|
+
type EnsureExtendsNumber<A extends TSchema> = TExtends<A, TInteger, TLiteral<true>, TLiteral<false>> extends TLiteral<true> ? A : never;
|
|
33
|
+
type ValidMqttParameter<A extends TSchema> = EnsureExtendsString<A> | EnsureExtendsNumber<A>;
|
|
34
|
+
export type LogEventFields<Schema extends TSchema> = {
|
|
35
|
+
indexed: boolean;
|
|
36
|
+
/** keeps track if this indexed field is the string version of a complex data type (ex: if it's an object type) */
|
|
37
|
+
hashed?: boolean;
|
|
38
|
+
name: string;
|
|
39
|
+
type: Schema;
|
|
40
|
+
};
|
|
41
|
+
export type LogEvent<Fields extends LogEventFields<any>[]> = {
|
|
42
|
+
name: string;
|
|
43
|
+
fields: Fields;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* ==============================================
|
|
47
|
+
* Define the MQTT topic path + event type format
|
|
48
|
+
* ==============================================
|
|
49
|
+
*/
|
|
50
|
+
export type EventPathAndDef = {
|
|
51
|
+
path: EventPath;
|
|
52
|
+
broker: PaimaEventBrokerNames;
|
|
53
|
+
type: TObject;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* ============================================================
|
|
57
|
+
* Transform paths into TS objects that can be partially filled
|
|
58
|
+
* ============================================================
|
|
59
|
+
*/
|
|
60
|
+
type FilterSimple<T> = T extends SimplePath ? never : T;
|
|
61
|
+
type RemoveAllSimple<T extends EventPath> = T extends (infer U)[] ? FilterSimple<U>[] : never;
|
|
62
|
+
type KeypairToObj<T extends {
|
|
63
|
+
name: string;
|
|
64
|
+
type: any;
|
|
65
|
+
}[]> = {
|
|
66
|
+
[K in T[number] as K['name']]: Static<K['type']>;
|
|
67
|
+
};
|
|
68
|
+
export type ResolvedPath<Path extends EventPath> = KeypairToObj<RemoveAllSimple<Path>>;
|
|
69
|
+
export type Undefined<T extends Record<string, any>> = {
|
|
70
|
+
[P in keyof T]: T[P] | undefined;
|
|
71
|
+
};
|
|
72
|
+
export type UserFilledPath<Path extends EventPath> = Partial<Undefined<ResolvedPath<Path>>>;
|
|
73
|
+
/**
|
|
74
|
+
* ======================================================================
|
|
75
|
+
* Transform dev-friendly event type to typebox Schema for easy exporting
|
|
76
|
+
* ======================================================================
|
|
77
|
+
*/
|
|
78
|
+
type ToTObject<T extends Record<string, LogEventFields<any>>> = {
|
|
79
|
+
-readonly [P in keyof T]: TObject<{
|
|
80
|
+
indexed: TLiteral<T[P]['indexed']>;
|
|
81
|
+
name: TLiteral<T[P]['name']>;
|
|
82
|
+
type: T[P]['type'];
|
|
83
|
+
hashed: TLiteral<DefaultToFalse<T[P]['hashed']>>;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Typebox doesn't provide the right interface for convert into a Tuple
|
|
88
|
+
* So we provide our own wrapper here, then convert it to a proper Tuple later
|
|
89
|
+
*/
|
|
90
|
+
export type CustomTuple<T> = T extends TSchema[] ? TSchema & {
|
|
91
|
+
[Kind]: 'Tuple';
|
|
92
|
+
static: {
|
|
93
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K], TSchema['params']> : T[K];
|
|
94
|
+
};
|
|
95
|
+
type: 'array';
|
|
96
|
+
items?: T;
|
|
97
|
+
additionalItems?: false;
|
|
98
|
+
minItems: number;
|
|
99
|
+
maxItems: number;
|
|
100
|
+
} : never;
|
|
101
|
+
type AsTuple<T extends TSchema> = T extends TTuple<infer U> ? TTuple<U> : never;
|
|
102
|
+
export declare function toSchema<T extends LogEvent<any>>(event: T): TObject<{
|
|
103
|
+
name: TLiteral<T['name']>;
|
|
104
|
+
fields: AsTuple<CustomTuple<ToTObject<T['fields']>>>;
|
|
105
|
+
}>;
|
|
106
|
+
/**
|
|
107
|
+
* =======================================================
|
|
108
|
+
* Transform dev-friendly event type to MQTT-friendly type
|
|
109
|
+
* =======================================================
|
|
110
|
+
*/
|
|
111
|
+
type FilterIndexed<T> = T extends {
|
|
112
|
+
indexed: true;
|
|
113
|
+
} ? T : never;
|
|
114
|
+
type RemoveAllUnindexed<T extends LogEventFields<TSchema>[]> = {
|
|
115
|
+
[P in keyof T]: FilterIndexed<T[P]>;
|
|
116
|
+
};
|
|
117
|
+
type TransformEventInput<T> = T extends {
|
|
118
|
+
readonly hashed?: infer Hashed;
|
|
119
|
+
readonly name: infer N;
|
|
120
|
+
readonly type: infer U;
|
|
121
|
+
} ? {
|
|
122
|
+
hashed?: Hashed;
|
|
123
|
+
name: N;
|
|
124
|
+
type: U;
|
|
125
|
+
} : never;
|
|
126
|
+
export type TransformAllEventInput<T extends LogEventFields<TSchema>[]> = {
|
|
127
|
+
[P in keyof T]: TransformEventInput<T[P]>;
|
|
128
|
+
};
|
|
129
|
+
export type ExcludeFromTuple<T extends readonly any[], E> = T extends [infer F, ...infer R] ? [F] extends [E] ? ExcludeFromTuple<R, E> : [F, ...ExcludeFromTuple<R, E>] : [];
|
|
130
|
+
type RemoveHashSuffix<T extends string> = T extends `${infer Prefix}Hash` ? Prefix : T;
|
|
131
|
+
type AddStringPath<T extends any[]> = T extends [
|
|
132
|
+
{
|
|
133
|
+
hashed?: infer Hashed;
|
|
134
|
+
name: infer Name extends string;
|
|
135
|
+
type: infer Type;
|
|
136
|
+
},
|
|
137
|
+
...infer Rest
|
|
138
|
+
] ? [
|
|
139
|
+
Hashed extends true ? RemoveHashSuffix<Name> : Name,
|
|
140
|
+
{
|
|
141
|
+
name: Name;
|
|
142
|
+
type: Type;
|
|
143
|
+
},
|
|
144
|
+
...AddStringPath<Rest>
|
|
145
|
+
] : [];
|
|
146
|
+
type FilterNonIndexed<T> = T extends {
|
|
147
|
+
indexed: false;
|
|
148
|
+
} ? T : never;
|
|
149
|
+
export type RemoveAllIndexed<T extends LogEventFields<TSchema>[]> = {
|
|
150
|
+
[P in keyof T]: FilterNonIndexed<T[P]>;
|
|
151
|
+
};
|
|
152
|
+
export type OutputKeypairToObj<T> = T extends {
|
|
153
|
+
name: string;
|
|
154
|
+
type: any;
|
|
155
|
+
}[] ? {
|
|
156
|
+
[K in T[number] as K['name']]: K['type'];
|
|
157
|
+
} : never;
|
|
158
|
+
export type BrokerName<T extends TopicPrefix> = T extends TopicPrefix.Batcher ? PaimaEventBrokerNames.Batcher : PaimaEventBrokerNames.PaimaEngine;
|
|
159
|
+
type IndexedFields<T extends LogEventFields<TSchema>[]> = ExcludeFromTuple<TransformAllEventInput<RemoveAllUnindexed<T>>, never>;
|
|
160
|
+
export declare function toPath<T extends LogEvent<LogEventFields<TSchema>[]>, Prefix extends TopicPrefix>(prefix: Prefix, event: T, signatureHash?: string): {
|
|
161
|
+
path: AddStringPath<IndexedFields<T['fields']>>;
|
|
162
|
+
broker: BrokerName<Prefix>;
|
|
163
|
+
type: TObject<OutputKeypairToObj<ExcludeFromTuple<TransformAllEventInput<RemoveAllIndexed<T['fields']>>, never>>>;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* ================================================================
|
|
167
|
+
* Wrap interface to make it more dev-friendly and less error-prone
|
|
168
|
+
* ================================================================
|
|
169
|
+
*/
|
|
170
|
+
export type MaybeIndexedLogEventFields<Schema extends TSchema> = {
|
|
171
|
+
indexed?: boolean;
|
|
172
|
+
hashed?: boolean;
|
|
173
|
+
name: string;
|
|
174
|
+
type: Schema;
|
|
175
|
+
};
|
|
176
|
+
export type MaybeIndexedLogEvent<Fields extends MaybeIndexedLogEventFields<any>[]> = {
|
|
177
|
+
name: string;
|
|
178
|
+
fields: Fields;
|
|
179
|
+
};
|
|
180
|
+
type DefaultToFalse<T> = T extends true ? true : false;
|
|
181
|
+
type ToDefinitelyIndexedObject<T extends MaybeIndexedLogEventFields<any>[]> = {
|
|
182
|
+
-readonly [P in keyof T]: {
|
|
183
|
+
indexed: DefaultToFalse<T[P]['indexed']>;
|
|
184
|
+
hashed: DefaultToFalse<T[P]['hashed']>;
|
|
185
|
+
name: T[P]['name'];
|
|
186
|
+
type: T[P]['type'];
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
export type ToLog<T extends MaybeIndexedLogEvent<MaybeIndexedLogEventFields<TSchema>[]>> = {
|
|
190
|
+
name: T['name'];
|
|
191
|
+
fields: ToDefinitelyIndexedObject<T['fields']>;
|
|
192
|
+
};
|
|
193
|
+
type Ensure<T extends MaybeIndexedLogEvent<MaybeIndexedLogEventFields<TSchema>[]>, U> = MaybeIndexedLogEvent<MaybeIndexedLogEventFields<TSchema>[]> extends U ? T : never;
|
|
194
|
+
export declare function genEvent<const T extends MaybeIndexedLogEvent<MaybeIndexedLogEventFields<TSchema>[]>>(event: DisallowComplexEventFields<T> & Ensure<T, MaybeIndexedLogEvent<any>>): ToLog<T>;
|
|
195
|
+
/**
|
|
196
|
+
* ======================================================================
|
|
197
|
+
* Replace indexed objects with hashes so they can be used as MQTT topics
|
|
198
|
+
* ======================================================================
|
|
199
|
+
*/
|
|
200
|
+
type AddHashFields<T extends any[]> = T extends [
|
|
201
|
+
{
|
|
202
|
+
indexed: infer Indexed;
|
|
203
|
+
name: infer Name extends string;
|
|
204
|
+
type: infer Type extends TSchema;
|
|
205
|
+
},
|
|
206
|
+
...infer Rest
|
|
207
|
+
] ? Indexed extends true ? ValidMqttParameter<Type> extends never ? [
|
|
208
|
+
{
|
|
209
|
+
hashed: true;
|
|
210
|
+
indexed: true;
|
|
211
|
+
name: `${Name}Hash`;
|
|
212
|
+
type: TString;
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
indexed: false;
|
|
216
|
+
name: Name;
|
|
217
|
+
type: Type;
|
|
218
|
+
},
|
|
219
|
+
...AddHashFields<Rest>
|
|
220
|
+
] : [{
|
|
221
|
+
indexed: Indexed;
|
|
222
|
+
name: Name;
|
|
223
|
+
type: Type;
|
|
224
|
+
}, ...AddHashFields<Rest>] : [{
|
|
225
|
+
indexed: Indexed;
|
|
226
|
+
name: Name;
|
|
227
|
+
type: Type;
|
|
228
|
+
}, ...AddHashFields<Rest>] : [];
|
|
229
|
+
export type EventAddHashFields<T extends {
|
|
230
|
+
name: string;
|
|
231
|
+
fields: MaybeIndexedLogEventFields<TSchema>[];
|
|
232
|
+
}> = {
|
|
233
|
+
name: T['name'];
|
|
234
|
+
fields: AddHashFields<T['fields']>;
|
|
235
|
+
};
|
|
236
|
+
export declare function addHashes<T extends LogEvent<LogEventFields<TSchema>[]>>(event: T): EventAddHashFields<T>;
|
|
237
|
+
/**
|
|
238
|
+
* ===================================================
|
|
239
|
+
* Disable complex fields until we support these later
|
|
240
|
+
* ===================================================
|
|
241
|
+
*/
|
|
242
|
+
type DisallowComplexFields<T extends MaybeIndexedLogEventFields<TSchema>[]> = {
|
|
243
|
+
[P in keyof T]: T[P]['indexed'] extends false ? T[P] : ValidMqttParameter<T[P]['type']> extends never ? {
|
|
244
|
+
indexed: T[P]['indexed'];
|
|
245
|
+
name: T[P]['name'];
|
|
246
|
+
type: never;
|
|
247
|
+
} : T[P];
|
|
248
|
+
};
|
|
249
|
+
type DisallowComplexEventFields<T extends {
|
|
250
|
+
fields: MaybeIndexedLogEventFields<TSchema>[];
|
|
251
|
+
}> = {
|
|
252
|
+
fields: DisallowComplexFields<T['fields']>;
|
|
253
|
+
};
|
|
254
|
+
export {};
|
|
255
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/events/src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,MAAM,EACN,OAAO,EACR,MAAM,mBAAmB,CAAC;AAG3B,oBAAY,qBAAqB;IAC/B,WAAW,wBAAwB;IACnC,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,qBAAqB,CAWvE;AAED;;;;GAIG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AACtD,MAAM,MAAM,SAAS,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;AAEjD;;;;GAIG;AAGH,KAAK,mBAAmB,CAAC,CAAC,SAAS,OAAO,IACxC,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,IAA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C,SAAS;IAAE,MAAM,EAAE,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAA;CAAE,IAAI;IAC7F,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;CAC5C,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TopicPrefix = exports.PaimaEventBrokerNames = void 0;
|
|
4
|
+
exports.topicToBroker = topicToBroker;
|
|
5
|
+
exports.toSchema = toSchema;
|
|
6
|
+
exports.toPath = toPath;
|
|
7
|
+
exports.genEvent = genEvent;
|
|
8
|
+
exports.addHashes = addHashes;
|
|
9
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
10
|
+
const assert_never_1 = require("assert-never");
|
|
11
|
+
var PaimaEventBrokerNames;
|
|
12
|
+
(function (PaimaEventBrokerNames) {
|
|
13
|
+
PaimaEventBrokerNames["PaimaEngine"] = "effectstream-engine";
|
|
14
|
+
PaimaEventBrokerNames["Batcher"] = "batcher";
|
|
15
|
+
})(PaimaEventBrokerNames || (exports.PaimaEventBrokerNames = PaimaEventBrokerNames = {}));
|
|
16
|
+
/**
|
|
17
|
+
* Name inspired from https://docs.aws.amazon.com/whitepapers/latest/designing-mqtt-topics-aws-iot-core/mqtt-design-best-practices.html#:~:text=Since%20MQTT%20topics%20are%20case,when%20creating%20each%20topic%20level
|
|
18
|
+
*/
|
|
19
|
+
var TopicPrefix;
|
|
20
|
+
(function (TopicPrefix) {
|
|
21
|
+
TopicPrefix["Batcher"] = "batcher";
|
|
22
|
+
TopicPrefix["Node"] = "node";
|
|
23
|
+
TopicPrefix["App"] = "app";
|
|
24
|
+
})(TopicPrefix || (exports.TopicPrefix = TopicPrefix = {}));
|
|
25
|
+
function topicToBroker(topic) {
|
|
26
|
+
switch (topic) {
|
|
27
|
+
case TopicPrefix.Batcher:
|
|
28
|
+
return PaimaEventBrokerNames.Batcher;
|
|
29
|
+
case TopicPrefix.Node:
|
|
30
|
+
return PaimaEventBrokerNames.PaimaEngine;
|
|
31
|
+
case TopicPrefix.App:
|
|
32
|
+
return PaimaEventBrokerNames.PaimaEngine;
|
|
33
|
+
default:
|
|
34
|
+
(0, assert_never_1.assertNever)(topic);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function toSchema(event) {
|
|
38
|
+
return typebox_1.Type.Object({
|
|
39
|
+
name: typebox_1.Type.Literal(event.name),
|
|
40
|
+
fields: typebox_1.Type.Tuple(event.fields.map((input) => typebox_1.Type.Object({
|
|
41
|
+
indexed: typebox_1.Type.Literal(input.indexed),
|
|
42
|
+
name: typebox_1.Type.Literal(input.name),
|
|
43
|
+
type: input.type,
|
|
44
|
+
hashed: typebox_1.Type.Literal(input.hashed ?? false),
|
|
45
|
+
})) // map(..) converts it to an array, but we need to consider it a tuple
|
|
46
|
+
),
|
|
47
|
+
}); // typescript can't really know this dynamic object matches our static type
|
|
48
|
+
}
|
|
49
|
+
function toPath(prefix, event, signatureHash) {
|
|
50
|
+
return {
|
|
51
|
+
path: [
|
|
52
|
+
prefix,
|
|
53
|
+
...[signatureHash].filter(x => x),
|
|
54
|
+
...event.fields
|
|
55
|
+
.filter(input => input.indexed)
|
|
56
|
+
.flatMap(input => [
|
|
57
|
+
input.hashed === true
|
|
58
|
+
? input.name.substring(0, input.name.length - 'Hash'.length)
|
|
59
|
+
: input.name,
|
|
60
|
+
{
|
|
61
|
+
name: input.name,
|
|
62
|
+
type: input.type,
|
|
63
|
+
},
|
|
64
|
+
]),
|
|
65
|
+
],
|
|
66
|
+
broker: topicToBroker(prefix),
|
|
67
|
+
type: typebox_1.Type.Object(event.fields
|
|
68
|
+
.filter(input => !input.indexed)
|
|
69
|
+
.reduce((acc, curr) => {
|
|
70
|
+
acc[curr.name] = curr.type;
|
|
71
|
+
return acc;
|
|
72
|
+
}, {})),
|
|
73
|
+
}; // typescript can't really know this dynamic object matches our static type
|
|
74
|
+
}
|
|
75
|
+
function genEvent(event) {
|
|
76
|
+
for (const { name } of event.fields) {
|
|
77
|
+
const invalidCharacters = ['$', '/', '+', '#'];
|
|
78
|
+
for (const invalid of invalidCharacters) {
|
|
79
|
+
if (name.includes(invalid)) {
|
|
80
|
+
throw new Error(`Event ${event.name} has field ${name} with invalid character ${invalid}.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return event;
|
|
85
|
+
}
|
|
86
|
+
function addHashes(event) {
|
|
87
|
+
return {
|
|
88
|
+
name: event.name,
|
|
89
|
+
fields: event.fields.flatMap(field => {
|
|
90
|
+
if (field.indexed === false)
|
|
91
|
+
return field;
|
|
92
|
+
const isString = typebox_1.Type.Extends(field.type, typebox_1.Type.String(), typebox_1.Type.Literal(true), typebox_1.Type.Literal(false)).const;
|
|
93
|
+
const isNumber = typebox_1.Type.Extends(field.type, typebox_1.Type.Number(), typebox_1.Type.Literal(true), typebox_1.Type.Literal(false)).const;
|
|
94
|
+
if (isString || isNumber) {
|
|
95
|
+
return field;
|
|
96
|
+
}
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
indexed: true,
|
|
100
|
+
type: typebox_1.Type.String(),
|
|
101
|
+
name: `${field.name}Hash`,
|
|
102
|
+
hashed: true,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
...field,
|
|
106
|
+
indexed: false,
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EventPath, UserFilledPath } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an MQTT path filling in specified variables in the path
|
|
4
|
+
* @param path the base MQTT path to use
|
|
5
|
+
* @param args the args to fill the path.
|
|
6
|
+
* - `undefined` (explicitly or omitted) variables will be treated as `+`
|
|
7
|
+
* - if all trailing variables are `undefined`, it will be replaced by `#`
|
|
8
|
+
*/
|
|
9
|
+
export declare function fillPath<Path extends EventPath>(path: Path, args: UserFilledPath<Path>): string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert our internal definition of an event path to an mqtt-pattern compatible path
|
|
12
|
+
* This is useful to later deconstruct topics for pattern matching
|
|
13
|
+
*/
|
|
14
|
+
export declare function toPattern(path: EventPath): string;
|
|
15
|
+
export declare function keysForPath(path: EventPath): string[];
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/events/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,MAAM,CAsE/F;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAajD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,CAErD"}
|