@opendatalabs/vana-sdk 0.1.0-alpha.ffe4659 → 2.1.0
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 +67 -342
- package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
- package/dist/browser.cjs +29 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +36 -1
- package/dist/browser.js +1 -305
- package/dist/browser.js.map +1 -1
- package/dist/{chains.browser.cjs → chains/definitions.cjs} +16 -17
- package/dist/chains/definitions.cjs.map +1 -0
- package/dist/{chains.browser.d.cts → chains/definitions.d.ts} +9 -11
- package/dist/chains/definitions.js +67 -0
- package/dist/chains/definitions.js.map +1 -0
- package/dist/chains/index.cjs +37 -0
- package/dist/chains/index.cjs.map +1 -0
- package/dist/chains/index.d.ts +34 -0
- package/dist/chains/index.js +15 -0
- package/dist/chains/index.js.map +1 -0
- package/dist/chains.browser.d.ts +5 -50
- package/dist/chains.browser.js +7 -57
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +6 -65
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.d.ts +8 -2
- package/dist/chains.js +7 -57
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +6 -65
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.d.ts +8 -2
- package/dist/chains.node.js +7 -57
- package/dist/chains.node.js.map +1 -1
- package/dist/client/__tests__/enhancedResponse.test.d.ts +1 -0
- package/dist/client/enhancedResponse.cjs +164 -0
- package/dist/client/enhancedResponse.cjs.map +1 -0
- package/dist/client/enhancedResponse.d.ts +120 -0
- package/dist/client/enhancedResponse.js +138 -0
- package/dist/client/enhancedResponse.js.map +1 -0
- package/dist/config/addresses.cjs +325 -0
- package/dist/config/addresses.cjs.map +1 -0
- package/dist/config/addresses.d.ts +364 -0
- package/dist/config/addresses.js +295 -0
- package/dist/config/addresses.js.map +1 -0
- package/dist/config/chains.cjs +93 -0
- package/dist/config/chains.cjs.map +1 -0
- package/dist/config/chains.d.ts +180 -0
- package/dist/config/chains.js +67 -0
- package/dist/config/chains.js.map +1 -0
- package/dist/config/default-services.cjs +60 -0
- package/dist/config/default-services.cjs.map +1 -0
- package/dist/config/default-services.d.ts +46 -0
- package/dist/config/default-services.js +33 -0
- package/dist/config/default-services.js.map +1 -0
- package/dist/config/default-services.test.d.ts +1 -0
- package/dist/config/features.cjs +52 -0
- package/dist/config/features.cjs.map +1 -0
- package/dist/config/features.d.ts +62 -0
- package/dist/config/features.js +28 -0
- package/dist/config/features.js.map +1 -0
- package/dist/config/tests/addresses.test.d.ts +1 -0
- package/dist/contracts/contractController.cjs +126 -0
- package/dist/contracts/contractController.cjs.map +1 -0
- package/dist/contracts/contractController.d.ts +135 -0
- package/dist/contracts/contractController.js +100 -0
- package/dist/contracts/contractController.js.map +1 -0
- package/dist/contracts/tests/contractController.test.d.ts +1 -0
- package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
- package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
- package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
- package/dist/controllers/base.cjs +116 -0
- package/dist/controllers/base.cjs.map +1 -0
- package/dist/controllers/base.d.ts +94 -0
- package/dist/controllers/base.js +92 -0
- package/dist/controllers/base.js.map +1 -0
- package/dist/controllers/data-error-handling.test.d.ts +1 -0
- package/dist/controllers/data.cjs +2633 -0
- package/dist/controllers/data.cjs.map +1 -0
- package/dist/controllers/data.d.ts +1067 -0
- package/dist/controllers/data.js +2626 -0
- package/dist/controllers/data.js.map +1 -0
- package/dist/controllers/operations.cjs +430 -0
- package/dist/controllers/operations.cjs.map +1 -0
- package/dist/controllers/operations.d.ts +229 -0
- package/dist/controllers/operations.js +406 -0
- package/dist/controllers/operations.js.map +1 -0
- package/dist/controllers/permissions.cjs +4363 -0
- package/dist/controllers/permissions.cjs.map +1 -0
- package/dist/controllers/permissions.d.ts +1411 -0
- package/dist/controllers/permissions.js +4339 -0
- package/dist/controllers/permissions.js.map +1 -0
- package/dist/controllers/protocol.cjs +183 -0
- package/dist/controllers/protocol.cjs.map +1 -0
- package/dist/controllers/protocol.d.ts +138 -0
- package/dist/controllers/protocol.js +163 -0
- package/dist/controllers/protocol.js.map +1 -0
- package/dist/controllers/schemas.cjs +678 -0
- package/dist/controllers/schemas.cjs.map +1 -0
- package/dist/controllers/schemas.d.ts +293 -0
- package/dist/controllers/schemas.js +654 -0
- package/dist/controllers/schemas.js.map +1 -0
- package/dist/controllers/server-additional.test.d.ts +1 -0
- package/dist/controllers/server.cjs +643 -0
- package/dist/controllers/server.cjs.map +1 -0
- package/dist/controllers/server.d.ts +322 -0
- package/dist/controllers/server.js +624 -0
- package/dist/controllers/server.js.map +1 -0
- package/dist/core/__tests__/health.test.d.ts +1 -0
- package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
- package/dist/core/apiClient.cjs +378 -0
- package/dist/core/apiClient.cjs.map +1 -0
- package/dist/core/apiClient.d.ts +286 -0
- package/dist/core/apiClient.js +359 -0
- package/dist/core/apiClient.js.map +1 -0
- package/dist/core/client.cjs +70 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.ts +89 -0
- package/dist/core/client.js +47 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/core.test.d.ts +1 -0
- package/dist/core/generics.cjs +417 -0
- package/dist/core/generics.cjs.map +1 -0
- package/dist/core/generics.d.ts +205 -0
- package/dist/core/generics.js +386 -0
- package/dist/core/generics.js.map +1 -0
- package/dist/core/health.cjs +289 -0
- package/dist/core/health.cjs.map +1 -0
- package/dist/core/health.d.ts +143 -0
- package/dist/core/health.js +265 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/inMemoryNonceManager.cjs +138 -0
- package/dist/core/inMemoryNonceManager.cjs.map +1 -0
- package/dist/core/inMemoryNonceManager.d.ts +69 -0
- package/dist/core/inMemoryNonceManager.js +114 -0
- package/dist/core/inMemoryNonceManager.js.map +1 -0
- package/dist/core/nonceManager.cjs +304 -0
- package/dist/core/nonceManager.cjs.map +1 -0
- package/dist/core/nonceManager.d.ts +116 -0
- package/dist/core/nonceManager.js +280 -0
- package/dist/core/nonceManager.js.map +1 -0
- package/dist/core/pollingManager.cjs +292 -0
- package/dist/core/pollingManager.cjs.map +1 -0
- package/dist/core/pollingManager.d.ts +120 -0
- package/dist/core/pollingManager.js +268 -0
- package/dist/core/pollingManager.js.map +1 -0
- package/dist/core/tests/apiClient.test.d.ts +1 -0
- package/dist/core/tests/client.test.d.ts +1 -0
- package/dist/core/tests/generics.test.d.ts +1 -0
- package/dist/core.cjs +777 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.ts +493 -0
- package/dist/core.js +752 -0
- package/dist/core.js.map +1 -0
- package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
- package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
- package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs +102 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs.map +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.ts +38 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js +77 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js.map +1 -0
- package/dist/crypto/ecies/base.cjs +245 -0
- package/dist/crypto/ecies/base.cjs.map +1 -0
- package/dist/crypto/ecies/base.d.ts +140 -0
- package/dist/crypto/ecies/base.js +221 -0
- package/dist/crypto/ecies/base.js.map +1 -0
- package/dist/crypto/ecies/browser.cjs +165 -0
- package/dist/crypto/ecies/browser.cjs.map +1 -0
- package/dist/crypto/ecies/browser.d.ts +43 -0
- package/dist/crypto/ecies/browser.js +131 -0
- package/dist/crypto/ecies/browser.js.map +1 -0
- package/dist/crypto/ecies/constants.cjs +131 -0
- package/dist/crypto/ecies/constants.cjs.map +1 -0
- package/dist/crypto/ecies/constants.d.ts +120 -0
- package/dist/crypto/ecies/constants.js +101 -0
- package/dist/crypto/ecies/constants.js.map +1 -0
- package/dist/crypto/ecies/index.cjs +35 -0
- package/dist/crypto/ecies/index.cjs.map +1 -0
- package/dist/crypto/ecies/index.d.ts +8 -0
- package/dist/crypto/ecies/index.js +13 -0
- package/dist/crypto/ecies/index.js.map +1 -0
- package/dist/crypto/ecies/interface.cjs +87 -0
- package/dist/crypto/ecies/interface.cjs.map +1 -0
- package/dist/crypto/ecies/interface.d.ts +174 -0
- package/dist/crypto/ecies/interface.js +60 -0
- package/dist/crypto/ecies/interface.js.map +1 -0
- package/dist/crypto/ecies/node.cjs +167 -0
- package/dist/crypto/ecies/node.cjs.map +1 -0
- package/dist/crypto/ecies/node.d.ts +45 -0
- package/dist/crypto/ecies/node.js +139 -0
- package/dist/crypto/ecies/node.js.map +1 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +52 -0
- package/dist/crypto/ecies/utils.cjs.map +1 -0
- package/dist/crypto/ecies/utils.d.ts +30 -0
- package/dist/crypto/ecies/utils.js +26 -0
- package/dist/crypto/ecies/utils.js.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +128 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +88 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js +108 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
- package/dist/diagnostics.cjs +37 -0
- package/dist/diagnostics.cjs.map +1 -0
- package/dist/diagnostics.d.ts +24 -0
- package/dist/diagnostics.js +13 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/diagnostics.test.d.ts +1 -0
- package/dist/errors.cjs +186 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +452 -0
- package/dist/errors.js +148 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs +1313 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +995 -0
- package/dist/generated/abi/ComputeEngineImplementation.js +1289 -0
- package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs +734 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +544 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js +710 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs +882 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.d.ts +660 -0
- package/dist/generated/abi/DATFactoryImplementation.js +858 -0
- package/dist/generated/abi/DATFactoryImplementation.js.map +1 -0
- package/dist/generated/abi/DATImplementation.cjs +934 -0
- package/dist/generated/abi/DATImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATImplementation.d.ts +692 -0
- package/dist/generated/abi/DATImplementation.js +910 -0
- package/dist/generated/abi/DATImplementation.js.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.cjs +1523 -0
- package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.d.ts +1144 -0
- package/dist/generated/abi/DATPausableImplementation.js +1499 -0
- package/dist/generated/abi/DATPausableImplementation.js.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.cjs +1460 -0
- package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.d.ts +1094 -0
- package/dist/generated/abi/DATVotesImplementation.js +1436 -0
- package/dist/generated/abi/DATVotesImplementation.js.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +1202 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +914 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js +1178 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs +1469 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +1122 -0
- package/dist/generated/abi/DLPRegistryImplementation.js +1445 -0
- package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +451 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +1112 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +840 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +1088 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +451 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs +939 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +705 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js +915 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.cjs +1644 -0
- package/dist/generated/abi/DLPRootImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.d.ts +1246 -0
- package/dist/generated/abi/DLPRootImplementation.js +1620 -0
- package/dist/generated/abi/DLPRootImplementation.js.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.d.ts +451 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +985 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +735 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js +961 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +1036 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +773 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js +1012 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +1298 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +974 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +1274 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs +1419 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +1071 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js +1395 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs +984 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +736 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js +960 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs +1328 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.d.ts +1003 -0
- package/dist/generated/abi/DataRegistryImplementation.js +1304 -0
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs +1319 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.d.ts +1000 -0
- package/dist/generated/abi/QueryEngineImplementation.js +1295 -0
- package/dist/generated/abi/QueryEngineImplementation.js.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs +976 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.d.ts +728 -0
- package/dist/generated/abi/SwapHelperImplementation.js +952 -0
- package/dist/generated/abi/SwapHelperImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.d.ts +992 -0
- package/dist/generated/abi/TeePoolImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +992 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs +1383 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.d.ts +1050 -0
- package/dist/generated/abi/VanaEpochImplementation.js +1359 -0
- package/dist/generated/abi/VanaEpochImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +1191 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +899 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js +1167 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +1033 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +776 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js +1009 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs +538 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +393 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js +514 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/index.cjs +177 -0
- package/dist/generated/abi/index.cjs.map +1 -0
- package/dist/{index.node.d.cts → generated/abi/index.d.ts} +26941 -37486
- package/dist/generated/abi/index.js +120 -0
- package/dist/generated/abi/index.js.map +1 -0
- package/dist/generated/event-types.cjs +17 -0
- package/dist/generated/event-types.cjs.map +1 -0
- package/dist/generated/event-types.d.ts +860 -0
- package/dist/generated/event-types.js +1 -0
- package/dist/generated/event-types.js.map +1 -0
- package/dist/generated/eventRegistry.cjs +3375 -0
- package/dist/generated/eventRegistry.cjs.map +1 -0
- package/dist/generated/eventRegistry.d.ts +14 -0
- package/dist/generated/eventRegistry.js +3350 -0
- package/dist/generated/eventRegistry.js.map +1 -0
- package/dist/generated/server/server-exports.cjs +45 -0
- package/dist/generated/server/server-exports.cjs.map +1 -0
- package/dist/generated/server/server-exports.d.ts +36 -0
- package/dist/generated/server/server-exports.js +19 -0
- package/dist/generated/server/server-exports.js.map +1 -0
- package/dist/generated/server/server.cjs +17 -0
- package/dist/generated/server/server.cjs.map +1 -0
- package/dist/generated/server/server.d.ts +907 -0
- package/dist/generated/server/server.js +1 -0
- package/dist/generated/server/server.js.map +1 -0
- package/dist/generated/subgraph.cjs +1440 -0
- package/dist/generated/subgraph.cjs.map +1 -0
- package/dist/generated/subgraph.d.ts +6113 -0
- package/dist/generated/subgraph.js +1404 -0
- package/dist/generated/subgraph.js.map +1 -0
- package/dist/index.browser.d.ts +48 -37223
- package/dist/index.browser.js +86 -46352
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.cjs +123 -46839
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +92 -37358
- package/dist/index.node.js +103 -46726
- package/dist/index.node.js.map +1 -1
- package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
- package/dist/lib/redisAtomicStore.cjs +201 -0
- package/dist/lib/redisAtomicStore.cjs.map +1 -0
- package/dist/lib/redisAtomicStore.d.ts +120 -0
- package/dist/lib/redisAtomicStore.js +177 -0
- package/dist/lib/redisAtomicStore.js.map +1 -0
- package/dist/node.cjs +2 -321
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +42 -1
- package/dist/node.js +1 -307
- package/dist/node.js.map +1 -1
- package/dist/platform/browser-only.cjs +37 -0
- package/dist/platform/browser-only.cjs.map +1 -0
- package/dist/platform/browser-only.d.ts +22 -0
- package/dist/platform/browser-only.js +12 -0
- package/dist/platform/browser-only.js.map +1 -0
- package/dist/platform/browser-only.test.d.ts +1 -0
- package/dist/platform/browser-safe.cjs +57 -0
- package/dist/platform/browser-safe.cjs.map +1 -0
- package/dist/platform/browser-safe.d.ts +29 -0
- package/dist/platform/browser-safe.js +31 -0
- package/dist/platform/browser-safe.js.map +1 -0
- package/dist/platform/browser-safe.test.d.ts +1 -0
- package/dist/platform/browser.cjs +488 -0
- package/dist/platform/browser.cjs.map +1 -0
- package/dist/platform/browser.d.ts +291 -0
- package/dist/platform/browser.js +454 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/browser.test.d.ts +1 -0
- package/dist/platform/index.cjs +50 -0
- package/dist/platform/index.cjs.map +1 -0
- package/dist/platform/index.d.ts +11 -0
- package/dist/platform/index.js +27 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/interface.cjs +17 -0
- package/dist/platform/interface.cjs.map +1 -0
- package/dist/platform/interface.d.ts +409 -0
- package/dist/platform/interface.js +1 -0
- package/dist/platform/interface.js.map +1 -0
- package/dist/platform/node.cjs +512 -0
- package/dist/platform/node.cjs.map +1 -0
- package/dist/platform/node.d.ts +86 -0
- package/dist/platform/node.js +481 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/ports/openpgp-port.cjs +74 -0
- package/dist/platform/ports/openpgp-port.cjs.map +1 -0
- package/dist/platform/ports/openpgp-port.d.ts +13 -0
- package/dist/platform/ports/openpgp-port.js +59 -0
- package/dist/platform/ports/openpgp-port.js.map +1 -0
- package/dist/platform/ports/pgp-port.cjs +17 -0
- package/dist/platform/ports/pgp-port.cjs.map +1 -0
- package/dist/platform/ports/pgp-port.d.ts +35 -0
- package/dist/platform/ports/pgp-port.js +1 -0
- package/dist/platform/ports/pgp-port.js.map +1 -0
- package/dist/platform/shared/error-utils.cjs +43 -0
- package/dist/platform/shared/error-utils.cjs.map +1 -0
- package/dist/platform/shared/error-utils.d.ts +23 -0
- package/dist/platform/shared/error-utils.js +18 -0
- package/dist/platform/shared/error-utils.js.map +1 -0
- package/dist/platform/shared/pgp-utils.cjs +55 -0
- package/dist/platform/shared/pgp-utils.cjs.map +1 -0
- package/dist/platform/shared/pgp-utils.d.ts +59 -0
- package/dist/platform/shared/pgp-utils.js +29 -0
- package/dist/platform/shared/pgp-utils.js.map +1 -0
- package/dist/platform/shared/stream-utils.cjs +49 -0
- package/dist/platform/shared/stream-utils.cjs.map +1 -0
- package/dist/platform/shared/stream-utils.d.ts +14 -0
- package/dist/platform/shared/stream-utils.js +25 -0
- package/dist/platform/shared/stream-utils.js.map +1 -0
- package/dist/platform/utils.cjs +114 -0
- package/dist/platform/utils.cjs.map +1 -0
- package/dist/platform/utils.d.ts +49 -0
- package/dist/platform/utils.js +76 -0
- package/dist/platform/utils.js.map +1 -0
- package/dist/platform/utils.test.d.ts +1 -0
- package/dist/platform.browser.d.ts +6 -57
- package/dist/platform.browser.js +10 -379
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +14 -708
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.d.ts +11 -2
- package/dist/platform.js +14 -694
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +14 -708
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.d.ts +7 -102
- package/dist/platform.node.js +14 -694
- package/dist/platform.node.js.map +1 -1
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/relayerHandler.cjs +452 -0
- package/dist/server/relayerHandler.cjs.map +1 -0
- package/dist/server/relayerHandler.d.ts +69 -0
- package/dist/server/relayerHandler.js +428 -0
- package/dist/server/relayerHandler.js.map +1 -0
- package/dist/storage/index.cjs +47 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.ts +57 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/manager.cjs +272 -0
- package/dist/storage/manager.cjs.map +1 -0
- package/dist/storage/manager.d.ts +241 -0
- package/dist/storage/manager.js +248 -0
- package/dist/storage/manager.js.map +1 -0
- package/dist/storage/providers/callback-storage.cjs +248 -0
- package/dist/storage/providers/callback-storage.cjs.map +1 -0
- package/dist/storage/providers/callback-storage.d.ts +183 -0
- package/dist/storage/providers/callback-storage.js +226 -0
- package/dist/storage/providers/callback-storage.js.map +1 -0
- package/dist/storage/providers/dropbox.cjs +237 -0
- package/dist/storage/providers/dropbox.cjs.map +1 -0
- package/dist/storage/providers/dropbox.d.ts +39 -0
- package/dist/storage/providers/dropbox.js +215 -0
- package/dist/storage/providers/dropbox.js.map +1 -0
- package/dist/storage/providers/dropbox.test.d.ts +1 -0
- package/dist/storage/providers/google-drive.cjs +516 -0
- package/dist/storage/providers/google-drive.cjs.map +1 -0
- package/dist/storage/providers/google-drive.d.ts +152 -0
- package/dist/storage/providers/google-drive.js +494 -0
- package/dist/storage/providers/google-drive.js.map +1 -0
- package/dist/storage/providers/google-drive.test.d.ts +1 -0
- package/dist/storage/providers/ipfs.cjs +283 -0
- package/dist/storage/providers/ipfs.cjs.map +1 -0
- package/dist/storage/providers/ipfs.d.ts +160 -0
- package/dist/storage/providers/ipfs.js +261 -0
- package/dist/storage/providers/ipfs.js.map +1 -0
- package/dist/storage/providers/pinata.cjs +339 -0
- package/dist/storage/providers/pinata.cjs.map +1 -0
- package/dist/storage/providers/pinata.d.ts +168 -0
- package/dist/storage/providers/pinata.js +317 -0
- package/dist/storage/providers/pinata.js.map +1 -0
- package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
- package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
- package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
- package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
- package/dist/storage/tests/storageManager.test.d.ts +1 -0
- package/dist/tests/abi.test.d.ts +1 -0
- package/dist/tests/chains-definitions.test.d.ts +1 -0
- package/dist/tests/core-encryption.test.d.ts +1 -0
- package/dist/tests/core-extended.test.d.ts +1 -0
- package/dist/tests/core-generics-coverage.test.d.ts +1 -0
- package/dist/tests/coverage-boost.test.d.ts +1 -0
- package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
- package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
- package/dist/tests/data-additional-methods.test.d.ts +1 -0
- package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
- package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
- package/dist/tests/data-relayer.test.d.ts +1 -0
- package/dist/tests/data-schema-validation.test.d.ts +1 -0
- package/dist/tests/data-simple-methods.test.d.ts +1 -0
- package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
- package/dist/tests/data.test.d.ts +1 -0
- package/dist/tests/demo-integration.test.d.ts +1 -0
- package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
- package/dist/tests/download-relayer.test.d.ts +1 -0
- package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
- package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
- package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
- package/dist/tests/encryption-coverage.test.d.ts +1 -0
- package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
- package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
- package/dist/tests/errors-coverage.test.d.ts +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/factories/mockFactory.d.ts +316 -0
- package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
- package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
- package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
- package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
- package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
- package/dist/tests/helper-methods.test.d.ts +1 -0
- package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
- package/dist/tests/helpers/typedMocks.d.ts +64 -0
- package/dist/tests/index-browser.test.d.ts +1 -0
- package/dist/tests/index-node.test.d.ts +1 -0
- package/dist/tests/index.test.d.ts +1 -0
- package/dist/tests/mocks/platformAdapter.d.ts +12 -0
- package/dist/tests/new-permissions-methods.test.d.ts +1 -0
- package/dist/tests/no-buffer-browser.test.d.ts +1 -0
- package/dist/tests/permissions-grantee.test.d.ts +1 -0
- package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
- package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
- package/dist/tests/permissions-server-files.test.d.ts +1 -0
- package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
- package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
- package/dist/tests/permissions.test.d.ts +1 -0
- package/dist/tests/personal.test.d.ts +1 -0
- package/dist/tests/platform-browser.test.d.ts +1 -0
- package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
- package/dist/tests/platform-crypto.test.d.ts +1 -0
- package/dist/tests/platform-index.test.d.ts +1 -0
- package/dist/tests/platform-node.test.d.ts +1 -0
- package/dist/tests/platform-shared-utils.test.d.ts +1 -0
- package/dist/tests/platform-updated.test.d.ts +1 -0
- package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
- package/dist/tests/protocol.test.d.ts +1 -0
- package/dist/tests/read-only-mode.test.d.ts +1 -0
- package/dist/tests/relayer-integration.test.d.ts +1 -0
- package/dist/tests/relayer-unified.test.d.ts +1 -0
- package/dist/tests/schemas.test.d.ts +1 -0
- package/dist/tests/server-relayer-handler.test.d.ts +1 -0
- package/dist/tests/setup.d.ts +7 -0
- package/dist/tests/signatureFormatter.test.d.ts +1 -0
- package/dist/tests/trusted-server-queries.test.d.ts +1 -0
- package/dist/tests/typedDataConverter.test.d.ts +1 -0
- package/dist/tests/types-contracts.test.d.ts +1 -0
- package/dist/tests/types-data.test.d.ts +1 -0
- package/dist/tests/types-external-apis.test.d.ts +1 -0
- package/dist/tests/types-generics.test.d.ts +1 -0
- package/dist/tests/types-permissions.test.d.ts +1 -0
- package/dist/tests/types-upload-params.test.d.ts +1 -0
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/tests/utils-formatters.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles.test.d.ts +1 -0
- package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
- package/dist/tests/utils-grants.test.d.ts +1 -0
- package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
- package/dist/tests/utils-ipfs.test.d.ts +4 -0
- package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
- package/dist/tests/vana.test.d.ts +1 -0
- package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
- package/dist/types/atomicStore.cjs +31 -0
- package/dist/types/atomicStore.cjs.map +1 -0
- package/dist/types/atomicStore.d.ts +236 -0
- package/dist/types/atomicStore.js +7 -0
- package/dist/types/atomicStore.js.map +1 -0
- package/dist/types/blockchain.cjs +17 -0
- package/dist/types/blockchain.cjs.map +1 -0
- package/dist/types/blockchain.d.ts +85 -0
- package/dist/types/blockchain.js +1 -0
- package/dist/types/blockchain.js.map +1 -0
- package/dist/types/chains-additional.test.d.ts +1 -0
- package/dist/types/chains.cjs +36 -0
- package/dist/types/chains.cjs.map +1 -0
- package/dist/types/chains.d.ts +98 -0
- package/dist/types/chains.js +11 -0
- package/dist/types/chains.js.map +1 -0
- package/dist/types/config.cjs +51 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.ts +720 -0
- package/dist/types/config.js +23 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/contracts.cjs +17 -0
- package/dist/types/contracts.cjs.map +1 -0
- package/dist/types/contracts.d.ts +129 -0
- package/dist/types/contracts.js +1 -0
- package/dist/types/contracts.js.map +1 -0
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.ts +68 -0
- package/dist/types/controller-context.js +1 -0
- package/dist/types/controller-context.js.map +1 -0
- package/dist/types/data.cjs +17 -0
- package/dist/types/data.cjs.map +1 -0
- package/dist/types/data.d.ts +763 -0
- package/dist/types/data.js +1 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/eccrypto-js.d.cjs +2 -0
- package/dist/types/eccrypto-js.d.cjs.map +1 -0
- package/dist/types/eccrypto-js.d.js +1 -0
- package/dist/types/eccrypto-js.d.js.map +1 -0
- package/dist/types/external-apis.cjs +61 -0
- package/dist/types/external-apis.cjs.map +1 -0
- package/dist/types/external-apis.d.ts +184 -0
- package/dist/types/external-apis.js +34 -0
- package/dist/types/external-apis.js.map +1 -0
- package/dist/types/generics.cjs +17 -0
- package/dist/types/generics.cjs.map +1 -0
- package/dist/types/generics.d.ts +518 -0
- package/dist/types/generics.js +1 -0
- package/dist/types/generics.js.map +1 -0
- package/dist/types/index.cjs +65 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.ts +48 -0
- package/dist/types/index.js +42 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/operationStore.cjs +17 -0
- package/dist/types/operationStore.cjs.map +1 -0
- package/dist/types/operationStore.d.ts +171 -0
- package/dist/types/operationStore.js +1 -0
- package/dist/types/operationStore.js.map +1 -0
- package/dist/types/operations.cjs +53 -0
- package/dist/types/operations.cjs.map +1 -0
- package/dist/types/operations.d.ts +204 -0
- package/dist/types/operations.js +26 -0
- package/dist/types/operations.js.map +1 -0
- package/dist/types/options.cjs +17 -0
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.d.ts +308 -0
- package/dist/types/options.js +1 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/permissions.cjs +17 -0
- package/dist/types/permissions.cjs.map +1 -0
- package/dist/types/permissions.d.ts +953 -0
- package/dist/types/permissions.js +1 -0
- package/dist/types/permissions.js.map +1 -0
- package/dist/types/personal.cjs +17 -0
- package/dist/types/personal.cjs.map +1 -0
- package/dist/types/personal.d.ts +174 -0
- package/dist/types/personal.js +1 -0
- package/dist/types/personal.js.map +1 -0
- package/dist/types/relayer.cjs +17 -0
- package/dist/types/relayer.cjs.map +1 -0
- package/dist/types/relayer.d.ts +552 -0
- package/dist/types/relayer.js +1 -0
- package/dist/types/relayer.js.map +1 -0
- package/dist/types/storage.cjs +39 -0
- package/dist/types/storage.cjs.map +1 -0
- package/dist/types/storage.d.ts +117 -0
- package/dist/types/storage.js +15 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/types/transactionResults.cjs +17 -0
- package/dist/types/transactionResults.cjs.map +1 -0
- package/dist/types/transactionResults.d.ts +193 -0
- package/dist/types/transactionResults.js +1 -0
- package/dist/types/transactionResults.js.map +1 -0
- package/dist/types/utils.cjs +17 -0
- package/dist/types/utils.cjs.map +1 -0
- package/dist/types/utils.d.ts +771 -0
- package/dist/types/utils.js +1 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types.cjs +23 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
- package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
- package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
- package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
- package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
- package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
- package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
- package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
- package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
- package/dist/utils/blockchain/registry.cjs +81 -0
- package/dist/utils/blockchain/registry.cjs.map +1 -0
- package/dist/utils/blockchain/registry.d.ts +32 -0
- package/dist/utils/blockchain/registry.js +56 -0
- package/dist/utils/blockchain/registry.js.map +1 -0
- package/dist/utils/blockchain/registry.test.d.ts +1 -0
- package/dist/utils/chainQuery.cjs +107 -0
- package/dist/utils/chainQuery.cjs.map +1 -0
- package/dist/utils/chainQuery.d.ts +31 -0
- package/dist/utils/chainQuery.js +82 -0
- package/dist/utils/chainQuery.js.map +1 -0
- package/dist/utils/crypto-utils.cjs +108 -0
- package/dist/utils/crypto-utils.cjs.map +1 -0
- package/dist/utils/crypto-utils.d.ts +100 -0
- package/dist/utils/crypto-utils.js +76 -0
- package/dist/utils/crypto-utils.js.map +1 -0
- package/dist/utils/crypto-utils.test.d.ts +1 -0
- package/dist/utils/download.cjs +69 -0
- package/dist/utils/download.cjs.map +1 -0
- package/dist/utils/download.d.ts +40 -0
- package/dist/utils/download.js +45 -0
- package/dist/utils/download.js.map +1 -0
- package/dist/utils/encoding.cjs +66 -0
- package/dist/utils/encoding.cjs.map +1 -0
- package/dist/utils/encoding.d.ts +52 -0
- package/dist/utils/encoding.js +39 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/encoding.test.d.ts +1 -0
- package/dist/utils/encryption.cjs +176 -0
- package/dist/utils/encryption.cjs.map +1 -0
- package/dist/utils/encryption.d.ts +271 -0
- package/dist/utils/encryption.js +142 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/formatters.cjs +55 -0
- package/dist/utils/formatters.cjs.map +1 -0
- package/dist/utils/formatters.d.ts +118 -0
- package/dist/utils/formatters.js +28 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/grantFiles.cjs +181 -0
- package/dist/utils/grantFiles.cjs.map +1 -0
- package/dist/utils/grantFiles.d.ts +172 -0
- package/dist/utils/grantFiles.js +143 -0
- package/dist/utils/grantFiles.js.map +1 -0
- package/dist/utils/grantValidation.cjs +243 -0
- package/dist/utils/grantValidation.cjs.map +1 -0
- package/dist/utils/grantValidation.d.ts +226 -0
- package/dist/utils/grantValidation.js +201 -0
- package/dist/utils/grantValidation.js.map +1 -0
- package/dist/utils/grants.cjs +108 -0
- package/dist/utils/grants.cjs.map +1 -0
- package/dist/utils/grants.d.ts +148 -0
- package/dist/utils/grants.js +82 -0
- package/dist/utils/grants.js.map +1 -0
- package/dist/utils/ipfs.cjs +128 -0
- package/dist/utils/ipfs.cjs.map +1 -0
- package/dist/utils/ipfs.d.ts +88 -0
- package/dist/utils/ipfs.js +97 -0
- package/dist/utils/ipfs.js.map +1 -0
- package/dist/utils/lazy-import.cjs +38 -0
- package/dist/utils/lazy-import.cjs.map +1 -0
- package/dist/utils/lazy-import.d.ts +43 -0
- package/dist/utils/lazy-import.js +14 -0
- package/dist/utils/lazy-import.js.map +1 -0
- package/dist/utils/multicall.cjs +233 -0
- package/dist/utils/multicall.cjs.map +1 -0
- package/dist/utils/multicall.d.ts +126 -0
- package/dist/utils/multicall.js +208 -0
- package/dist/utils/multicall.js.map +1 -0
- package/dist/utils/parseTransactionPojo.cjs +87 -0
- package/dist/utils/parseTransactionPojo.cjs.map +1 -0
- package/dist/utils/parseTransactionPojo.d.ts +31 -0
- package/dist/utils/parseTransactionPojo.js +63 -0
- package/dist/utils/parseTransactionPojo.js.map +1 -0
- package/dist/utils/schemaValidation.cjs +258 -0
- package/dist/utils/schemaValidation.cjs.map +1 -0
- package/dist/utils/schemaValidation.d.ts +168 -0
- package/dist/utils/schemaValidation.js +219 -0
- package/dist/utils/schemaValidation.js.map +1 -0
- package/dist/utils/signatureCache.cjs +192 -0
- package/dist/utils/signatureCache.cjs.map +1 -0
- package/dist/utils/signatureCache.d.ts +172 -0
- package/dist/utils/signatureCache.js +167 -0
- package/dist/utils/signatureCache.js.map +1 -0
- package/dist/utils/signatureFormatter.cjs +42 -0
- package/dist/utils/signatureFormatter.cjs.map +1 -0
- package/dist/utils/signatureFormatter.d.ts +36 -0
- package/dist/utils/signatureFormatter.js +18 -0
- package/dist/utils/signatureFormatter.js.map +1 -0
- package/dist/utils/subgraphConsistency.cjs +184 -0
- package/dist/utils/subgraphConsistency.cjs.map +1 -0
- package/dist/utils/subgraphConsistency.d.ts +65 -0
- package/dist/utils/subgraphConsistency.js +155 -0
- package/dist/utils/subgraphConsistency.js.map +1 -0
- package/dist/utils/subgraphMetaCache.cjs +101 -0
- package/dist/utils/subgraphMetaCache.cjs.map +1 -0
- package/dist/utils/subgraphMetaCache.d.ts +56 -0
- package/dist/utils/subgraphMetaCache.js +76 -0
- package/dist/utils/subgraphMetaCache.js.map +1 -0
- package/dist/utils/subgraphPagination.cjs +104 -0
- package/dist/utils/subgraphPagination.cjs.map +1 -0
- package/dist/utils/subgraphPagination.d.ts +78 -0
- package/dist/utils/subgraphPagination.js +78 -0
- package/dist/utils/subgraphPagination.js.map +1 -0
- package/dist/utils/tests/multicall.test.d.ts +1 -0
- package/dist/utils/transactionHelpers.cjs +54 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -0
- package/dist/utils/transactionHelpers.d.ts +80 -0
- package/dist/utils/transactionHelpers.js +29 -0
- package/dist/utils/transactionHelpers.js.map +1 -0
- package/dist/utils/typeGuards.cjs +109 -0
- package/dist/utils/typeGuards.cjs.map +1 -0
- package/dist/utils/typeGuards.d.ts +138 -0
- package/dist/utils/typeGuards.js +74 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/dist/utils/typedDataConverter.cjs +43 -0
- package/dist/utils/typedDataConverter.cjs.map +1 -0
- package/dist/utils/typedDataConverter.d.ts +46 -0
- package/dist/utils/typedDataConverter.js +19 -0
- package/dist/utils/typedDataConverter.js.map +1 -0
- package/dist/utils/urlResolver.cjs +62 -0
- package/dist/utils/urlResolver.cjs.map +1 -0
- package/dist/utils/urlResolver.d.ts +56 -0
- package/dist/utils/urlResolver.js +37 -0
- package/dist/utils/urlResolver.js.map +1 -0
- package/dist/utils/wallet.cjs +63 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +94 -0
- package/dist/utils/wallet.js +37 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/utils/withEvents.cjs +44 -0
- package/dist/utils/withEvents.cjs.map +1 -0
- package/dist/utils/withEvents.d.ts +56 -0
- package/dist/utils/withEvents.js +18 -0
- package/dist/utils/withEvents.js.map +1 -0
- package/package.json +63 -29
- package/dist/browser-DY8XDblx.d.ts +0 -241
- package/dist/chains.browser.cjs.map +0 -1
- package/dist/chains.d.cts +0 -2
- package/dist/chains.node.d.cts +0 -2
- package/dist/index.d.cts +0 -2
- package/dist/node-D9-F9uEP.d.cts +0 -238
- package/dist/node-D9-F9uEP.d.ts +0 -238
- package/dist/node.d.cts +0 -1
- package/dist/platform.d.cts +0 -2
- package/dist/platform.node.d.cts +0 -105
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides a generic HTTP client with enterprise-grade resilience features.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module implements a robust API client with automatic retry, rate limiting,
|
|
6
|
+
* circuit breaker pattern, and middleware support. It's used internally by the SDK
|
|
7
|
+
* for all HTTP operations and can be extended for custom API integrations.
|
|
8
|
+
*
|
|
9
|
+
* **Architecture:**
|
|
10
|
+
* - Middleware pipeline for request/response transformation
|
|
11
|
+
* - Exponential backoff retry with configurable policies
|
|
12
|
+
* - Token bucket rate limiting to prevent API throttling
|
|
13
|
+
* - Circuit breaker to fail fast when services are down
|
|
14
|
+
*
|
|
15
|
+
* @category Networking
|
|
16
|
+
* @module apiClient
|
|
17
|
+
*/
|
|
18
|
+
import type { GenericResponse, RetryConfig, RateLimiterConfig, Middleware } from "../types/generics";
|
|
19
|
+
/**
|
|
20
|
+
* Configures the API client's behavior and resilience features.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Provides fine-grained control over HTTP client behavior including
|
|
24
|
+
* retry strategies, rate limiting, and circuit breaker thresholds.
|
|
25
|
+
*
|
|
26
|
+
* @category Networking
|
|
27
|
+
*/
|
|
28
|
+
export interface ApiClientConfig {
|
|
29
|
+
/** Base URL for all requests */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Default headers */
|
|
32
|
+
headers?: Record<string, string>;
|
|
33
|
+
/** Request timeout in milliseconds */
|
|
34
|
+
timeout?: number;
|
|
35
|
+
/** Retry configuration */
|
|
36
|
+
retry?: RetryConfig;
|
|
37
|
+
/** Rate limiting configuration */
|
|
38
|
+
rateLimit?: RateLimiterConfig;
|
|
39
|
+
/** Circuit breaker configuration */
|
|
40
|
+
circuitBreaker?: {
|
|
41
|
+
failureThreshold: number;
|
|
42
|
+
recoveryTimeout: number;
|
|
43
|
+
halfOpenMaxAttempts?: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Represents supported HTTP methods for API operations.
|
|
48
|
+
*
|
|
49
|
+
* @category Networking
|
|
50
|
+
*/
|
|
51
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
52
|
+
/**
|
|
53
|
+
* Configures individual HTTP request behavior.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Allows per-request overrides of client defaults including headers,
|
|
57
|
+
* timeout, and resilience features. Use to customize specific requests
|
|
58
|
+
* without affecting global configuration.
|
|
59
|
+
*
|
|
60
|
+
* @category Networking
|
|
61
|
+
*/
|
|
62
|
+
export interface RequestOptions {
|
|
63
|
+
/** HTTP method */
|
|
64
|
+
method?: HttpMethod;
|
|
65
|
+
/** Request headers */
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
/** Query parameters */
|
|
68
|
+
params?: Record<string, unknown>;
|
|
69
|
+
/** Request timeout */
|
|
70
|
+
timeout?: number;
|
|
71
|
+
/** Skip retry for this request */
|
|
72
|
+
skipRetry?: boolean;
|
|
73
|
+
/** Skip rate limiting for this request */
|
|
74
|
+
skipRateLimit?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Provides resilient HTTP client functionality with enterprise features.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* This client implements multiple resilience patterns to ensure reliable
|
|
81
|
+
* API communication even under adverse conditions. It automatically handles
|
|
82
|
+
* transient failures, rate limits, and service outages while providing
|
|
83
|
+
* hooks for custom behavior through middleware.
|
|
84
|
+
*
|
|
85
|
+
* **Features:**
|
|
86
|
+
* - Automatic retry with exponential backoff
|
|
87
|
+
* - Rate limiting to prevent API throttling
|
|
88
|
+
* - Circuit breaker for fast failure detection
|
|
89
|
+
* - Middleware pipeline for request/response transformation
|
|
90
|
+
* - Configurable timeouts and headers
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Create client with custom configuration
|
|
95
|
+
* const client = new ApiClient({
|
|
96
|
+
* baseUrl: 'https://api.example.com',
|
|
97
|
+
* headers: { 'API-Key': 'secret' },
|
|
98
|
+
* retry: {
|
|
99
|
+
* maxAttempts: 5,
|
|
100
|
+
* baseDelay: 2000
|
|
101
|
+
* },
|
|
102
|
+
* rateLimit: {
|
|
103
|
+
* requestsPerWindow: 50,
|
|
104
|
+
* windowMs: 60000
|
|
105
|
+
* }
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* // Add logging middleware
|
|
109
|
+
* client.use(async (req, next) => {
|
|
110
|
+
* console.log(`Request: ${req.params.url}`);
|
|
111
|
+
* const res = await next(req);
|
|
112
|
+
* console.log(`Response: ${res.status}`);
|
|
113
|
+
* return res;
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // Make resilient API calls
|
|
117
|
+
* const data = await client.get('/users');
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @category Networking
|
|
121
|
+
*/
|
|
122
|
+
export declare class ApiClient {
|
|
123
|
+
private readonly config;
|
|
124
|
+
private readonly middleware;
|
|
125
|
+
private readonly rateLimiter?;
|
|
126
|
+
private readonly circuitBreaker?;
|
|
127
|
+
constructor(config?: ApiClientConfig);
|
|
128
|
+
/**
|
|
129
|
+
* Adds middleware to the request processing pipeline.
|
|
130
|
+
*
|
|
131
|
+
* @remarks
|
|
132
|
+
* Middleware functions execute in order of registration and can transform
|
|
133
|
+
* requests, responses, or implement cross-cutting concerns like logging,
|
|
134
|
+
* authentication, or caching.
|
|
135
|
+
*
|
|
136
|
+
* @param middleware - The middleware function to add to the pipeline
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* // Add authentication middleware
|
|
141
|
+
* client.use(async (req, next) => {
|
|
142
|
+
* req.options.headers = {
|
|
143
|
+
* ...req.options.headers,
|
|
144
|
+
* 'Authorization': `Bearer ${getToken()}`
|
|
145
|
+
* };
|
|
146
|
+
* return next(req);
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // Add response caching
|
|
150
|
+
* client.use(async (req, next) => {
|
|
151
|
+
* const cached = cache.get(req.params.url);
|
|
152
|
+
* if (cached) return cached;
|
|
153
|
+
*
|
|
154
|
+
* const res = await next(req);
|
|
155
|
+
* if (res.status === 'success') {
|
|
156
|
+
* cache.set(req.params.url, res);
|
|
157
|
+
* }
|
|
158
|
+
* return res;
|
|
159
|
+
* });
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
use(middleware: Middleware): void;
|
|
163
|
+
/**
|
|
164
|
+
* Executes an HTTP request with full resilience features.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* This is the core request method that applies all configured resilience
|
|
168
|
+
* patterns including retry, rate limiting, and circuit breaking. It processes
|
|
169
|
+
* the request through the middleware pipeline before execution.
|
|
170
|
+
*
|
|
171
|
+
* @param url - The URL to make the request to.
|
|
172
|
+
* Can be relative (uses baseUrl) or absolute.
|
|
173
|
+
* @param options - Request options including method, headers, body, etc.
|
|
174
|
+
* @returns Promise resolving to the response data
|
|
175
|
+
*
|
|
176
|
+
* @throws {Error} When request fails after all retry attempts.
|
|
177
|
+
* Check error message for details.
|
|
178
|
+
* @throws {Error} When circuit breaker is open.
|
|
179
|
+
* Wait for recovery timeout before retrying.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const response = await client.request('/api/data', {
|
|
184
|
+
* method: 'POST',
|
|
185
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
186
|
+
* params: { name: 'John', age: 30 },
|
|
187
|
+
* timeout: 5000
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
request<TData = unknown>(url: string, options?: RequestOptions): Promise<GenericResponse<TData>>;
|
|
192
|
+
/**
|
|
193
|
+
* Make a GET request
|
|
194
|
+
*
|
|
195
|
+
* @param url - The URL to make the GET request to
|
|
196
|
+
* @param options - Request options (excluding method)
|
|
197
|
+
* @returns Promise resolving to the response data
|
|
198
|
+
*/
|
|
199
|
+
get<TData = unknown>(url: string, options?: Omit<RequestOptions, "method">): Promise<GenericResponse<TData>>;
|
|
200
|
+
/**
|
|
201
|
+
* Make a POST request
|
|
202
|
+
*
|
|
203
|
+
* @param url - The URL to make the POST request to
|
|
204
|
+
* @param data - The data to send in the request body
|
|
205
|
+
* @param options - Request options (excluding method)
|
|
206
|
+
* @returns Promise resolving to the response data
|
|
207
|
+
*/
|
|
208
|
+
post<TData = unknown>(url: string, data?: unknown, options?: Omit<RequestOptions, "method">): Promise<GenericResponse<TData>>;
|
|
209
|
+
/**
|
|
210
|
+
* Make a PUT request
|
|
211
|
+
*
|
|
212
|
+
* @param url - The URL to make the PUT request to
|
|
213
|
+
* @param data - The data to send in the request body
|
|
214
|
+
* @param options - Request options (excluding method)
|
|
215
|
+
* @returns Promise resolving to the response data
|
|
216
|
+
*/
|
|
217
|
+
put<TData = unknown>(url: string, data?: unknown, options?: Omit<RequestOptions, "method">): Promise<GenericResponse<TData>>;
|
|
218
|
+
/**
|
|
219
|
+
* Make a DELETE request
|
|
220
|
+
*
|
|
221
|
+
* @param url - The URL to make the DELETE request to
|
|
222
|
+
* @param options - Request options (excluding method)
|
|
223
|
+
* @returns Promise resolving to the response data
|
|
224
|
+
*/
|
|
225
|
+
delete<TData = unknown>(url: string, options?: Omit<RequestOptions, "method">): Promise<GenericResponse<TData>>;
|
|
226
|
+
/**
|
|
227
|
+
* Make a PATCH request
|
|
228
|
+
*
|
|
229
|
+
* @param url - The URL to make the PATCH request to
|
|
230
|
+
* @param data - The data to send in the request body
|
|
231
|
+
* @param options - Request options (excluding method)
|
|
232
|
+
* @returns Promise resolving to the response data
|
|
233
|
+
*/
|
|
234
|
+
patch<TData = unknown>(url: string, data?: unknown, options?: Omit<RequestOptions, "method">): Promise<GenericResponse<TData>>;
|
|
235
|
+
/**
|
|
236
|
+
* Execute the actual HTTP request with middleware and retry
|
|
237
|
+
*
|
|
238
|
+
* @param request - The generic request object containing URL and options
|
|
239
|
+
* @returns Promise resolving to the generic response with data
|
|
240
|
+
*/
|
|
241
|
+
private executeRequest;
|
|
242
|
+
/**
|
|
243
|
+
* Make the actual HTTP request using fetch API
|
|
244
|
+
*
|
|
245
|
+
* @param url - The URL to make the request to
|
|
246
|
+
* @param options - The request options including method, headers, body, etc.
|
|
247
|
+
* @returns Promise resolving to the generic response with data
|
|
248
|
+
*/
|
|
249
|
+
private makeHttpRequest;
|
|
250
|
+
/**
|
|
251
|
+
* Build the full URL
|
|
252
|
+
*
|
|
253
|
+
* @param url - The URL or path to build the full URL from
|
|
254
|
+
* @returns The complete URL string
|
|
255
|
+
*/
|
|
256
|
+
private buildUrl;
|
|
257
|
+
/**
|
|
258
|
+
* Build request options with defaults
|
|
259
|
+
*
|
|
260
|
+
* @param options - The request options to merge with defaults
|
|
261
|
+
* @returns The merged request options with defaults applied
|
|
262
|
+
*/
|
|
263
|
+
private buildRequestOptions;
|
|
264
|
+
/**
|
|
265
|
+
* Get client statistics
|
|
266
|
+
*
|
|
267
|
+
* @returns Object containing client statistics and performance metrics
|
|
268
|
+
*/
|
|
269
|
+
getStats(): {
|
|
270
|
+
rateLimiter: {
|
|
271
|
+
remaining: number;
|
|
272
|
+
resetTime: number;
|
|
273
|
+
} | null;
|
|
274
|
+
circuitBreaker: {
|
|
275
|
+
state: string;
|
|
276
|
+
failures: number;
|
|
277
|
+
} | null;
|
|
278
|
+
middleware: {
|
|
279
|
+
count: number;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Reset client state
|
|
284
|
+
*/
|
|
285
|
+
reset(): void;
|
|
286
|
+
}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RetryUtility,
|
|
3
|
+
RateLimiter,
|
|
4
|
+
MiddlewarePipeline,
|
|
5
|
+
CircuitBreaker
|
|
6
|
+
} from "./generics";
|
|
7
|
+
class ApiClient {
|
|
8
|
+
config;
|
|
9
|
+
middleware;
|
|
10
|
+
rateLimiter;
|
|
11
|
+
circuitBreaker;
|
|
12
|
+
constructor(config = {}) {
|
|
13
|
+
this.config = {
|
|
14
|
+
baseUrl: config.baseUrl ?? "",
|
|
15
|
+
headers: config.headers ?? {},
|
|
16
|
+
timeout: config.timeout ?? 3e4,
|
|
17
|
+
retry: config.retry ?? {
|
|
18
|
+
maxAttempts: 3,
|
|
19
|
+
baseDelay: 1e3,
|
|
20
|
+
backoffMultiplier: 2,
|
|
21
|
+
shouldRetry: (error) => error.message.includes("network")
|
|
22
|
+
},
|
|
23
|
+
rateLimit: config.rateLimit ?? {
|
|
24
|
+
requestsPerWindow: 100,
|
|
25
|
+
windowMs: 6e4
|
|
26
|
+
},
|
|
27
|
+
circuitBreaker: config.circuitBreaker ?? {
|
|
28
|
+
failureThreshold: 5,
|
|
29
|
+
recoveryTimeout: 6e4,
|
|
30
|
+
halfOpenMaxAttempts: 3
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.middleware = new MiddlewarePipeline();
|
|
34
|
+
this.rateLimiter = new RateLimiter(this.config.rateLimit);
|
|
35
|
+
this.circuitBreaker = new CircuitBreaker(this.config.circuitBreaker);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Adds middleware to the request processing pipeline.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Middleware functions execute in order of registration and can transform
|
|
42
|
+
* requests, responses, or implement cross-cutting concerns like logging,
|
|
43
|
+
* authentication, or caching.
|
|
44
|
+
*
|
|
45
|
+
* @param middleware - The middleware function to add to the pipeline
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Add authentication middleware
|
|
50
|
+
* client.use(async (req, next) => {
|
|
51
|
+
* req.options.headers = {
|
|
52
|
+
* ...req.options.headers,
|
|
53
|
+
* 'Authorization': `Bearer ${getToken()}`
|
|
54
|
+
* };
|
|
55
|
+
* return next(req);
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* // Add response caching
|
|
59
|
+
* client.use(async (req, next) => {
|
|
60
|
+
* const cached = cache.get(req.params.url);
|
|
61
|
+
* if (cached) return cached;
|
|
62
|
+
*
|
|
63
|
+
* const res = await next(req);
|
|
64
|
+
* if (res.status === 'success') {
|
|
65
|
+
* cache.set(req.params.url, res);
|
|
66
|
+
* }
|
|
67
|
+
* return res;
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
use(middleware) {
|
|
72
|
+
this.middleware.use(middleware);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Executes an HTTP request with full resilience features.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This is the core request method that applies all configured resilience
|
|
79
|
+
* patterns including retry, rate limiting, and circuit breaking. It processes
|
|
80
|
+
* the request through the middleware pipeline before execution.
|
|
81
|
+
*
|
|
82
|
+
* @param url - The URL to make the request to.
|
|
83
|
+
* Can be relative (uses baseUrl) or absolute.
|
|
84
|
+
* @param options - Request options including method, headers, body, etc.
|
|
85
|
+
* @returns Promise resolving to the response data
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} When request fails after all retry attempts.
|
|
88
|
+
* Check error message for details.
|
|
89
|
+
* @throws {Error} When circuit breaker is open.
|
|
90
|
+
* Wait for recovery timeout before retrying.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const response = await client.request('/api/data', {
|
|
95
|
+
* method: 'POST',
|
|
96
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
97
|
+
* params: { name: 'John', age: 30 },
|
|
98
|
+
* timeout: 5000
|
|
99
|
+
* });
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async request(url, options = {}) {
|
|
103
|
+
const fullUrl = this.buildUrl(url);
|
|
104
|
+
const requestOptions = this.buildRequestOptions(options);
|
|
105
|
+
const request = {
|
|
106
|
+
params: {
|
|
107
|
+
url: fullUrl,
|
|
108
|
+
options: requestOptions
|
|
109
|
+
},
|
|
110
|
+
options: requestOptions
|
|
111
|
+
};
|
|
112
|
+
if (!options.skipRateLimit && this.rateLimiter) {
|
|
113
|
+
await this.rateLimiter.waitForSlot();
|
|
114
|
+
}
|
|
115
|
+
if (this.circuitBreaker) {
|
|
116
|
+
return this.circuitBreaker.execute(
|
|
117
|
+
() => this.executeRequest(request)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return this.executeRequest(request);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Make a GET request
|
|
124
|
+
*
|
|
125
|
+
* @param url - The URL to make the GET request to
|
|
126
|
+
* @param options - Request options (excluding method)
|
|
127
|
+
* @returns Promise resolving to the response data
|
|
128
|
+
*/
|
|
129
|
+
async get(url, options = {}) {
|
|
130
|
+
return this.request(url, { ...options, method: "GET" });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Make a POST request
|
|
134
|
+
*
|
|
135
|
+
* @param url - The URL to make the POST request to
|
|
136
|
+
* @param data - The data to send in the request body
|
|
137
|
+
* @param options - Request options (excluding method)
|
|
138
|
+
* @returns Promise resolving to the response data
|
|
139
|
+
*/
|
|
140
|
+
async post(url, data, options = {}) {
|
|
141
|
+
return this.request(url, {
|
|
142
|
+
...options,
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: {
|
|
145
|
+
"Content-Type": "application/json",
|
|
146
|
+
...options.headers
|
|
147
|
+
},
|
|
148
|
+
params: data
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Make a PUT request
|
|
153
|
+
*
|
|
154
|
+
* @param url - The URL to make the PUT request to
|
|
155
|
+
* @param data - The data to send in the request body
|
|
156
|
+
* @param options - Request options (excluding method)
|
|
157
|
+
* @returns Promise resolving to the response data
|
|
158
|
+
*/
|
|
159
|
+
async put(url, data, options = {}) {
|
|
160
|
+
return this.request(url, {
|
|
161
|
+
...options,
|
|
162
|
+
method: "PUT",
|
|
163
|
+
headers: {
|
|
164
|
+
"Content-Type": "application/json",
|
|
165
|
+
...options.headers
|
|
166
|
+
},
|
|
167
|
+
params: data
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Make a DELETE request
|
|
172
|
+
*
|
|
173
|
+
* @param url - The URL to make the DELETE request to
|
|
174
|
+
* @param options - Request options (excluding method)
|
|
175
|
+
* @returns Promise resolving to the response data
|
|
176
|
+
*/
|
|
177
|
+
async delete(url, options = {}) {
|
|
178
|
+
return this.request(url, { ...options, method: "DELETE" });
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Make a PATCH request
|
|
182
|
+
*
|
|
183
|
+
* @param url - The URL to make the PATCH request to
|
|
184
|
+
* @param data - The data to send in the request body
|
|
185
|
+
* @param options - Request options (excluding method)
|
|
186
|
+
* @returns Promise resolving to the response data
|
|
187
|
+
*/
|
|
188
|
+
async patch(url, data, options = {}) {
|
|
189
|
+
return this.request(url, {
|
|
190
|
+
...options,
|
|
191
|
+
method: "PATCH",
|
|
192
|
+
headers: {
|
|
193
|
+
"Content-Type": "application/json",
|
|
194
|
+
...options.headers
|
|
195
|
+
},
|
|
196
|
+
params: data
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Execute the actual HTTP request with middleware and retry
|
|
201
|
+
*
|
|
202
|
+
* @param request - The generic request object containing URL and options
|
|
203
|
+
* @returns Promise resolving to the generic response with data
|
|
204
|
+
*/
|
|
205
|
+
async executeRequest(request) {
|
|
206
|
+
const executeWithRetry = async () => {
|
|
207
|
+
try {
|
|
208
|
+
const processedRequest = await this.middleware.processRequest(request);
|
|
209
|
+
const response = await this.makeHttpRequest(
|
|
210
|
+
processedRequest.params.url,
|
|
211
|
+
processedRequest.params.options
|
|
212
|
+
);
|
|
213
|
+
const processedResponse = await this.middleware.processResponse(response);
|
|
214
|
+
return processedResponse;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
const handledResponse = await this.middleware.handleError(error, request);
|
|
217
|
+
if (handledResponse) {
|
|
218
|
+
return handledResponse;
|
|
219
|
+
}
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
if (!request.params.options.skipRetry) {
|
|
224
|
+
return RetryUtility.withRetry(executeWithRetry, this.config.retry);
|
|
225
|
+
}
|
|
226
|
+
return executeWithRetry();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Make the actual HTTP request using fetch API
|
|
230
|
+
*
|
|
231
|
+
* @param url - The URL to make the request to
|
|
232
|
+
* @param options - The request options including method, headers, body, etc.
|
|
233
|
+
* @returns Promise resolving to the generic response with data
|
|
234
|
+
*/
|
|
235
|
+
async makeHttpRequest(url, options) {
|
|
236
|
+
const controller = new AbortController();
|
|
237
|
+
const timeoutId = setTimeout(() => {
|
|
238
|
+
controller.abort();
|
|
239
|
+
}, options.timeout ?? this.config.timeout);
|
|
240
|
+
try {
|
|
241
|
+
const response = await fetch(url, {
|
|
242
|
+
method: options.method ?? "GET",
|
|
243
|
+
headers: {
|
|
244
|
+
...this.config.headers,
|
|
245
|
+
...options.headers
|
|
246
|
+
},
|
|
247
|
+
signal: controller.signal,
|
|
248
|
+
// Add body for POST/PUT/PATCH requests
|
|
249
|
+
...options.method && ["POST", "PUT", "PATCH"].includes(options.method) && {
|
|
250
|
+
body: JSON.stringify(options.params)
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
clearTimeout(timeoutId);
|
|
254
|
+
const responseData = await response.json();
|
|
255
|
+
const data = responseData;
|
|
256
|
+
if (!response.ok) {
|
|
257
|
+
return {
|
|
258
|
+
data: null,
|
|
259
|
+
success: false,
|
|
260
|
+
error: {
|
|
261
|
+
code: response.status.toString(),
|
|
262
|
+
message: data.message ?? response.statusText,
|
|
263
|
+
details: data
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
data: responseData,
|
|
269
|
+
success: true,
|
|
270
|
+
meta: {
|
|
271
|
+
status: response.status,
|
|
272
|
+
statusText: response.statusText,
|
|
273
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
} catch (error) {
|
|
277
|
+
clearTimeout(timeoutId);
|
|
278
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
279
|
+
return {
|
|
280
|
+
data: null,
|
|
281
|
+
success: false,
|
|
282
|
+
error: {
|
|
283
|
+
code: "TIMEOUT",
|
|
284
|
+
message: "Request timeout",
|
|
285
|
+
details: error
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
data: null,
|
|
291
|
+
success: false,
|
|
292
|
+
error: {
|
|
293
|
+
code: "NETWORK_ERROR",
|
|
294
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
295
|
+
details: error
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Build the full URL
|
|
302
|
+
*
|
|
303
|
+
* @param url - The URL or path to build the full URL from
|
|
304
|
+
* @returns The complete URL string
|
|
305
|
+
*/
|
|
306
|
+
buildUrl(url) {
|
|
307
|
+
if (url.startsWith("http")) {
|
|
308
|
+
return url;
|
|
309
|
+
}
|
|
310
|
+
const baseUrl = this.config.baseUrl.endsWith("/") ? this.config.baseUrl.slice(0, -1) : this.config.baseUrl;
|
|
311
|
+
const path = url.startsWith("/") ? url : `/${url}`;
|
|
312
|
+
return `${baseUrl}${path}`;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Build request options with defaults
|
|
316
|
+
*
|
|
317
|
+
* @param options - The request options to merge with defaults
|
|
318
|
+
* @returns The merged request options with defaults applied
|
|
319
|
+
*/
|
|
320
|
+
buildRequestOptions(options) {
|
|
321
|
+
return {
|
|
322
|
+
method: "GET",
|
|
323
|
+
headers: {},
|
|
324
|
+
timeout: this.config.timeout,
|
|
325
|
+
...options
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get client statistics
|
|
330
|
+
*
|
|
331
|
+
* @returns Object containing client statistics and performance metrics
|
|
332
|
+
*/
|
|
333
|
+
getStats() {
|
|
334
|
+
return {
|
|
335
|
+
rateLimiter: this.rateLimiter ? {
|
|
336
|
+
remaining: this.rateLimiter.getRemainingRequests(),
|
|
337
|
+
resetTime: this.rateLimiter.getResetTime()
|
|
338
|
+
} : null,
|
|
339
|
+
circuitBreaker: this.circuitBreaker ? {
|
|
340
|
+
state: this.circuitBreaker.getState(),
|
|
341
|
+
failures: this.circuitBreaker.getFailures()
|
|
342
|
+
} : null,
|
|
343
|
+
middleware: {
|
|
344
|
+
count: this.middleware.getMiddleware().length
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Reset client state
|
|
350
|
+
*/
|
|
351
|
+
reset() {
|
|
352
|
+
this.circuitBreaker?.reset();
|
|
353
|
+
this.middleware.clear();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
export {
|
|
357
|
+
ApiClient
|
|
358
|
+
};
|
|
359
|
+
//# sourceMappingURL=apiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/apiClient.ts"],"sourcesContent":["/**\n * Provides a generic HTTP client with enterprise-grade resilience features.\n *\n * @remarks\n * This module implements a robust API client with automatic retry, rate limiting,\n * circuit breaker pattern, and middleware support. It's used internally by the SDK\n * for all HTTP operations and can be extended for custom API integrations.\n *\n * **Architecture:**\n * - Middleware pipeline for request/response transformation\n * - Exponential backoff retry with configurable policies\n * - Token bucket rate limiting to prevent API throttling\n * - Circuit breaker to fail fast when services are down\n *\n * @category Networking\n * @module apiClient\n */\n\nimport type {\n GenericRequest,\n GenericResponse,\n RetryConfig,\n RateLimiterConfig,\n Middleware,\n} from \"../types/generics\";\nimport {\n RetryUtility,\n RateLimiter,\n MiddlewarePipeline,\n CircuitBreaker,\n} from \"./generics\";\n\n/**\n * Configures the API client's behavior and resilience features.\n *\n * @remarks\n * Provides fine-grained control over HTTP client behavior including\n * retry strategies, rate limiting, and circuit breaker thresholds.\n *\n * @category Networking\n */\nexport interface ApiClientConfig {\n /** Base URL for all requests */\n baseUrl?: string;\n /** Default headers */\n headers?: Record<string, string>;\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Retry configuration */\n retry?: RetryConfig;\n /** Rate limiting configuration */\n rateLimit?: RateLimiterConfig;\n /** Circuit breaker configuration */\n circuitBreaker?: {\n failureThreshold: number;\n recoveryTimeout: number;\n halfOpenMaxAttempts?: number;\n };\n}\n\n/**\n * Represents supported HTTP methods for API operations.\n *\n * @category Networking\n */\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\n\n/**\n * Configures individual HTTP request behavior.\n *\n * @remarks\n * Allows per-request overrides of client defaults including headers,\n * timeout, and resilience features. Use to customize specific requests\n * without affecting global configuration.\n *\n * @category Networking\n */\nexport interface RequestOptions {\n /** HTTP method */\n method?: HttpMethod;\n /** Request headers */\n headers?: Record<string, string>;\n /** Query parameters */\n params?: Record<string, unknown>;\n /** Request timeout */\n timeout?: number;\n /** Skip retry for this request */\n skipRetry?: boolean;\n /** Skip rate limiting for this request */\n skipRateLimit?: boolean;\n}\n\n/**\n * Provides resilient HTTP client functionality with enterprise features.\n *\n * @remarks\n * This client implements multiple resilience patterns to ensure reliable\n * API communication even under adverse conditions. It automatically handles\n * transient failures, rate limits, and service outages while providing\n * hooks for custom behavior through middleware.\n *\n * **Features:**\n * - Automatic retry with exponential backoff\n * - Rate limiting to prevent API throttling\n * - Circuit breaker for fast failure detection\n * - Middleware pipeline for request/response transformation\n * - Configurable timeouts and headers\n *\n * @example\n * ```typescript\n * // Create client with custom configuration\n * const client = new ApiClient({\n * baseUrl: 'https://api.example.com',\n * headers: { 'API-Key': 'secret' },\n * retry: {\n * maxAttempts: 5,\n * baseDelay: 2000\n * },\n * rateLimit: {\n * requestsPerWindow: 50,\n * windowMs: 60000\n * }\n * });\n *\n * // Add logging middleware\n * client.use(async (req, next) => {\n * console.log(`Request: ${req.params.url}`);\n * const res = await next(req);\n * console.log(`Response: ${res.status}`);\n * return res;\n * });\n *\n * // Make resilient API calls\n * const data = await client.get('/users');\n * ```\n *\n * @category Networking\n */\nexport class ApiClient {\n private readonly config: Required<ApiClientConfig>;\n private readonly middleware: MiddlewarePipeline;\n private readonly rateLimiter?: RateLimiter;\n private readonly circuitBreaker?: CircuitBreaker;\n\n constructor(config: ApiClientConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl ?? \"\",\n headers: config.headers ?? {},\n timeout: config.timeout ?? 30000,\n retry: config.retry ?? {\n maxAttempts: 3,\n baseDelay: 1000,\n backoffMultiplier: 2,\n shouldRetry: (error) => error.message.includes(\"network\"),\n },\n rateLimit: config.rateLimit ?? {\n requestsPerWindow: 100,\n windowMs: 60000,\n },\n circuitBreaker: config.circuitBreaker ?? {\n failureThreshold: 5,\n recoveryTimeout: 60000,\n halfOpenMaxAttempts: 3,\n },\n };\n\n this.middleware = new MiddlewarePipeline();\n this.rateLimiter = new RateLimiter(this.config.rateLimit);\n this.circuitBreaker = new CircuitBreaker(this.config.circuitBreaker);\n }\n\n /**\n * Adds middleware to the request processing pipeline.\n *\n * @remarks\n * Middleware functions execute in order of registration and can transform\n * requests, responses, or implement cross-cutting concerns like logging,\n * authentication, or caching.\n *\n * @param middleware - The middleware function to add to the pipeline\n *\n * @example\n * ```typescript\n * // Add authentication middleware\n * client.use(async (req, next) => {\n * req.options.headers = {\n * ...req.options.headers,\n * 'Authorization': `Bearer ${getToken()}`\n * };\n * return next(req);\n * });\n *\n * // Add response caching\n * client.use(async (req, next) => {\n * const cached = cache.get(req.params.url);\n * if (cached) return cached;\n *\n * const res = await next(req);\n * if (res.status === 'success') {\n * cache.set(req.params.url, res);\n * }\n * return res;\n * });\n * ```\n */\n use(middleware: Middleware): void {\n this.middleware.use(middleware);\n }\n\n /**\n * Executes an HTTP request with full resilience features.\n *\n * @remarks\n * This is the core request method that applies all configured resilience\n * patterns including retry, rate limiting, and circuit breaking. It processes\n * the request through the middleware pipeline before execution.\n *\n * @param url - The URL to make the request to.\n * Can be relative (uses baseUrl) or absolute.\n * @param options - Request options including method, headers, body, etc.\n * @returns Promise resolving to the response data\n *\n * @throws {Error} When request fails after all retry attempts.\n * Check error message for details.\n * @throws {Error} When circuit breaker is open.\n * Wait for recovery timeout before retrying.\n *\n * @example\n * ```typescript\n * const response = await client.request('/api/data', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * params: { name: 'John', age: 30 },\n * timeout: 5000\n * });\n * ```\n */\n async request<TData = unknown>(\n url: string,\n options: RequestOptions = {},\n ): Promise<GenericResponse<TData>> {\n const fullUrl = this.buildUrl(url);\n const requestOptions = this.buildRequestOptions(options);\n\n const request: GenericRequest<{\n url: string;\n options: RequestOptions;\n }> = {\n params: {\n url: fullUrl,\n options: requestOptions,\n },\n options: requestOptions,\n };\n\n // Apply rate limiting\n if (!options.skipRateLimit && this.rateLimiter) {\n await this.rateLimiter.waitForSlot();\n }\n\n // Execute with circuit breaker\n if (this.circuitBreaker) {\n return this.circuitBreaker.execute(() =>\n this.executeRequest<TData>(request),\n );\n }\n\n return this.executeRequest<TData>(request);\n }\n\n /**\n * Make a GET request\n *\n * @param url - The URL to make the GET request to\n * @param options - Request options (excluding method)\n * @returns Promise resolving to the response data\n */\n async get<TData = unknown>(\n url: string,\n options: Omit<RequestOptions, \"method\"> = {},\n ): Promise<GenericResponse<TData>> {\n return this.request<TData>(url, { ...options, method: \"GET\" });\n }\n\n /**\n * Make a POST request\n *\n * @param url - The URL to make the POST request to\n * @param data - The data to send in the request body\n * @param options - Request options (excluding method)\n * @returns Promise resolving to the response data\n */\n async post<TData = unknown>(\n url: string,\n data?: unknown,\n options: Omit<RequestOptions, \"method\"> = {},\n ): Promise<GenericResponse<TData>> {\n return this.request<TData>(url, {\n ...options,\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...options.headers,\n },\n params: data as Record<string, unknown>,\n });\n }\n\n /**\n * Make a PUT request\n *\n * @param url - The URL to make the PUT request to\n * @param data - The data to send in the request body\n * @param options - Request options (excluding method)\n * @returns Promise resolving to the response data\n */\n async put<TData = unknown>(\n url: string,\n data?: unknown,\n options: Omit<RequestOptions, \"method\"> = {},\n ): Promise<GenericResponse<TData>> {\n return this.request<TData>(url, {\n ...options,\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...options.headers,\n },\n params: data as Record<string, unknown>,\n });\n }\n\n /**\n * Make a DELETE request\n *\n * @param url - The URL to make the DELETE request to\n * @param options - Request options (excluding method)\n * @returns Promise resolving to the response data\n */\n async delete<TData = unknown>(\n url: string,\n options: Omit<RequestOptions, \"method\"> = {},\n ): Promise<GenericResponse<TData>> {\n return this.request<TData>(url, { ...options, method: \"DELETE\" });\n }\n\n /**\n * Make a PATCH request\n *\n * @param url - The URL to make the PATCH request to\n * @param data - The data to send in the request body\n * @param options - Request options (excluding method)\n * @returns Promise resolving to the response data\n */\n async patch<TData = unknown>(\n url: string,\n data?: unknown,\n options: Omit<RequestOptions, \"method\"> = {},\n ): Promise<GenericResponse<TData>> {\n return this.request<TData>(url, {\n ...options,\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...options.headers,\n },\n params: data as Record<string, unknown>,\n });\n }\n\n /**\n * Execute the actual HTTP request with middleware and retry\n *\n * @param request - The generic request object containing URL and options\n * @returns Promise resolving to the generic response with data\n */\n private async executeRequest<TData>(\n request: GenericRequest<{ url: string; options: RequestOptions }>,\n ): Promise<GenericResponse<TData>> {\n const executeWithRetry = async (): Promise<GenericResponse<TData>> => {\n try {\n // Process request through middleware\n const processedRequest = await this.middleware.processRequest(request);\n\n // Make the actual HTTP request\n const response = await this.makeHttpRequest<TData>(\n (\n processedRequest as GenericRequest<{\n url: string;\n options: RequestOptions;\n }>\n ).params.url,\n (\n processedRequest as GenericRequest<{\n url: string;\n options: RequestOptions;\n }>\n ).params.options,\n );\n\n // Process response through middleware\n const processedResponse =\n await this.middleware.processResponse(response);\n\n return processedResponse;\n } catch (error) {\n // Try to handle error with middleware\n const handledResponse = await this.middleware.handleError<\n typeof request,\n GenericResponse<TData>\n >(error as Error, request);\n\n if (handledResponse) {\n return handledResponse;\n }\n\n throw error;\n }\n };\n\n // Apply retry logic if not skipped\n if (!request.params.options.skipRetry) {\n return RetryUtility.withRetry(executeWithRetry, this.config.retry);\n }\n\n return executeWithRetry();\n }\n\n /**\n * Make the actual HTTP request using fetch API\n *\n * @param url - The URL to make the request to\n * @param options - The request options including method, headers, body, etc.\n * @returns Promise resolving to the generic response with data\n */\n private async makeHttpRequest<TData>(\n url: string,\n options: RequestOptions,\n ): Promise<GenericResponse<TData>> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => {\n controller.abort();\n }, options.timeout ?? this.config.timeout);\n\n try {\n const response = await fetch(url, {\n method: options.method ?? \"GET\",\n headers: {\n ...this.config.headers,\n ...options.headers,\n },\n signal: controller.signal,\n // Add body for POST/PUT/PATCH requests\n ...(options.method &&\n [\"POST\", \"PUT\", \"PATCH\"].includes(options.method) && {\n body: JSON.stringify(options.params),\n }),\n });\n\n clearTimeout(timeoutId);\n\n const responseData: unknown = await response.json();\n const data = responseData as { message?: string; [key: string]: unknown };\n\n if (!response.ok) {\n return {\n data: null as unknown as TData,\n success: false,\n error: {\n code: response.status.toString(),\n message: data.message ?? response.statusText,\n details: data,\n },\n };\n }\n\n return {\n data: responseData as TData,\n success: true,\n meta: {\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers.entries()),\n },\n };\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error && error.name === \"AbortError\") {\n return {\n data: null as unknown as TData,\n success: false,\n error: {\n code: \"TIMEOUT\",\n message: \"Request timeout\",\n details: error,\n },\n };\n }\n\n return {\n data: null as unknown as TData,\n success: false,\n error: {\n code: \"NETWORK_ERROR\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n details: error,\n },\n };\n }\n }\n\n /**\n * Build the full URL\n *\n * @param url - The URL or path to build the full URL from\n * @returns The complete URL string\n */\n private buildUrl(url: string): string {\n if (url.startsWith(\"http\")) {\n return url;\n }\n\n const baseUrl = this.config.baseUrl.endsWith(\"/\")\n ? this.config.baseUrl.slice(0, -1)\n : this.config.baseUrl;\n const path = url.startsWith(\"/\") ? url : `/${url}`;\n\n return `${baseUrl}${path}`;\n }\n\n /**\n * Build request options with defaults\n *\n * @param options - The request options to merge with defaults\n * @returns The merged request options with defaults applied\n */\n private buildRequestOptions(options: RequestOptions): RequestOptions {\n return {\n method: \"GET\",\n headers: {},\n timeout: this.config.timeout,\n ...options,\n };\n }\n\n /**\n * Get client statistics\n *\n * @returns Object containing client statistics and performance metrics\n */\n getStats() {\n return {\n rateLimiter: this.rateLimiter\n ? {\n remaining: this.rateLimiter.getRemainingRequests(),\n resetTime: this.rateLimiter.getResetTime(),\n }\n : null,\n circuitBreaker: this.circuitBreaker\n ? {\n state: this.circuitBreaker.getState(),\n failures: this.circuitBreaker.getFailures(),\n }\n : null,\n middleware: {\n count: this.middleware.getMiddleware().length,\n },\n };\n }\n\n /**\n * Reset client state\n */\n reset(): void {\n this.circuitBreaker?.reset();\n this.middleware.clear();\n }\n}\n"],"mappings":"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","names":[]}
|