@opendatalabs/vana-sdk 2.3.0 → 3.0.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 +76 -92
- package/dist/auth/errors.cjs +54 -0
- package/dist/auth/errors.cjs.map +1 -0
- package/dist/auth/errors.d.ts +26 -0
- package/dist/auth/errors.js +28 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/pkce.cjs +100 -0
- package/dist/auth/pkce.cjs.map +1 -0
- package/dist/auth/pkce.d.ts +55 -0
- package/dist/auth/pkce.js +71 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/token-store.cjs +59 -0
- package/dist/auth/token-store.cjs.map +1 -0
- package/dist/auth/token-store.d.ts +61 -0
- package/dist/auth/token-store.js +35 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/auth/web3-signed-builder.cjs +70 -0
- package/dist/auth/web3-signed-builder.cjs.map +1 -0
- package/dist/auth/web3-signed-builder.d.ts +47 -0
- package/dist/auth/web3-signed-builder.js +45 -0
- package/dist/auth/web3-signed-builder.js.map +1 -0
- package/dist/auth/web3-signed.cjs +125 -0
- package/dist/auth/web3-signed.cjs.map +1 -0
- package/dist/auth/web3-signed.d.ts +59 -0
- package/dist/auth/web3-signed.js +104 -0
- package/dist/auth/web3-signed.js.map +1 -0
- package/dist/chains/definitions.cjs +2 -6
- package/dist/chains/definitions.cjs.map +1 -1
- package/dist/chains/definitions.d.ts +1 -7
- package/dist/chains/definitions.js +2 -6
- package/dist/chains/definitions.js.map +1 -1
- package/dist/config/chains.d.ts +18 -0
- package/dist/config/contracts.config.cjs +7 -95
- package/dist/config/contracts.config.cjs.map +1 -1
- package/dist/config/contracts.config.d.ts +0 -54
- package/dist/config/contracts.config.js +6 -93
- package/dist/config/contracts.config.js.map +1 -1
- package/dist/config/default-services.cjs +0 -10
- package/dist/config/default-services.cjs.map +1 -1
- package/dist/config/default-services.d.ts +1 -20
- package/dist/config/default-services.js +0 -9
- package/dist/config/default-services.js.map +1 -1
- package/dist/crypto/ecies/interface.cjs +2 -0
- package/dist/crypto/ecies/interface.cjs.map +1 -1
- package/dist/crypto/ecies/interface.js +2 -0
- package/dist/crypto/ecies/interface.js.map +1 -1
- package/dist/crypto/envelope/openpgp.cjs +59 -0
- package/dist/crypto/envelope/openpgp.cjs.map +1 -0
- package/dist/crypto/envelope/openpgp.d.ts +28 -0
- package/dist/crypto/envelope/openpgp.js +24 -0
- package/dist/crypto/envelope/openpgp.js.map +1 -0
- package/dist/crypto/keys/derive.cjs +65 -0
- package/dist/crypto/keys/derive.cjs.map +1 -0
- package/dist/crypto/keys/derive.d.ts +45 -0
- package/dist/crypto/keys/derive.js +38 -0
- package/dist/crypto/keys/derive.js.map +1 -0
- package/dist/errors.cjs +10 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/index.cjs +2 -37
- package/dist/generated/abi/index.cjs.map +1 -1
- package/dist/generated/abi/index.d.ts +2683 -9296
- package/dist/generated/abi/index.js +2 -29
- package/dist/generated/abi/index.js.map +1 -1
- package/dist/generated/addresses.cjs +5 -107
- package/dist/generated/addresses.cjs.map +1 -1
- package/dist/generated/addresses.d.ts +5 -99
- package/dist/generated/addresses.js +5 -105
- package/dist/generated/addresses.js.map +1 -1
- package/dist/index.browser.d.ts +23 -140
- package/dist/index.browser.js +32090 -114
- package/dist/index.browser.js.map +7 -1
- package/dist/index.node.cjs +32809 -160
- package/dist/index.node.cjs.map +7 -1
- package/dist/index.node.d.ts +22 -210
- package/dist/index.node.js +32716 -133
- package/dist/index.node.js.map +7 -1
- package/dist/protocol/data-file.cjs +56 -0
- package/dist/protocol/data-file.cjs.map +1 -0
- package/dist/protocol/data-file.d.ts +20 -0
- package/dist/protocol/data-file.js +30 -0
- package/dist/protocol/data-file.js.map +1 -0
- package/dist/protocol/eip712.cjs +123 -0
- package/dist/protocol/eip712.cjs.map +1 -0
- package/dist/protocol/eip712.d.ts +117 -0
- package/dist/protocol/eip712.js +90 -0
- package/dist/protocol/eip712.js.map +1 -0
- package/dist/protocol/gateway.cjs +226 -0
- package/dist/protocol/gateway.cjs.map +1 -0
- package/dist/protocol/gateway.d.ts +120 -0
- package/dist/protocol/gateway.js +202 -0
- package/dist/protocol/gateway.js.map +1 -0
- package/dist/protocol/scopes.cjs +78 -0
- package/dist/protocol/scopes.cjs.map +1 -0
- package/dist/protocol/scopes.d.ts +13 -0
- package/dist/protocol/scopes.js +50 -0
- package/dist/protocol/scopes.js.map +1 -0
- package/dist/{types/atomicStore.cjs → storage/default.cjs} +9 -8
- package/dist/storage/default.cjs.map +1 -0
- package/dist/storage/default.d.ts +4 -0
- package/dist/storage/default.js +8 -0
- package/dist/storage/default.js.map +1 -0
- package/dist/storage/index.cjs +11 -2
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.ts +9 -0
- package/dist/storage/index.js +7 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +1 -0
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.js +1 -0
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/dropbox.cjs +1 -0
- package/dist/storage/providers/dropbox.cjs.map +1 -1
- package/dist/storage/providers/dropbox.js +1 -0
- package/dist/storage/providers/dropbox.js.map +1 -1
- package/dist/storage/providers/google-drive.cjs +1 -0
- package/dist/storage/providers/google-drive.cjs.map +1 -1
- package/dist/storage/providers/google-drive.js +1 -0
- package/dist/storage/providers/google-drive.js.map +1 -1
- package/dist/storage/providers/ipfs.cjs +1 -0
- package/dist/storage/providers/ipfs.cjs.map +1 -1
- package/dist/storage/providers/ipfs.js +1 -0
- package/dist/storage/providers/ipfs.js.map +1 -1
- package/dist/storage/providers/pinata.cjs +1 -0
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.js +1 -0
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/storage/providers/r2.cjs +376 -0
- package/dist/storage/providers/r2.cjs.map +1 -0
- package/dist/storage/providers/r2.d.ts +91 -0
- package/dist/storage/providers/r2.js +354 -0
- package/dist/storage/providers/r2.js.map +1 -0
- package/dist/storage/providers/vana-storage.cjs +251 -0
- package/dist/storage/providers/vana-storage.cjs.map +1 -0
- package/dist/storage/providers/vana-storage.d.ts +100 -0
- package/dist/storage/providers/vana-storage.js +231 -0
- package/dist/storage/providers/vana-storage.js.map +1 -0
- package/dist/types/config.cjs +0 -34
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +1 -607
- package/dist/types/config.js +0 -22
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +1 -1
- package/dist/types/index.cjs +2 -33
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +2 -33
- package/dist/types/index.js +1 -35
- package/dist/types/index.js.map +1 -1
- package/dist/types/ps-errors.cjs +66 -0
- package/dist/types/ps-errors.cjs.map +1 -0
- package/dist/types/ps-errors.d.ts +25 -0
- package/dist/types/ps-errors.js +41 -0
- package/dist/types/ps-errors.js.map +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +0 -29
- package/dist/types.js.map +1 -1
- package/package.json +7 -25
- package/dist/client/enhancedResponse.cjs +0 -164
- package/dist/client/enhancedResponse.cjs.map +0 -1
- package/dist/client/enhancedResponse.d.ts +0 -120
- package/dist/client/enhancedResponse.js +0 -138
- package/dist/client/enhancedResponse.js.map +0 -1
- package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +0 -7
- package/dist/controllers/base.cjs +0 -116
- package/dist/controllers/base.cjs.map +0 -1
- package/dist/controllers/base.d.ts +0 -94
- package/dist/controllers/base.js +0 -92
- package/dist/controllers/base.js.map +0 -1
- package/dist/controllers/data.cjs +0 -2633
- package/dist/controllers/data.cjs.map +0 -1
- package/dist/controllers/data.d.ts +0 -1067
- package/dist/controllers/data.js +0 -2626
- package/dist/controllers/data.js.map +0 -1
- package/dist/controllers/operations.cjs +0 -430
- package/dist/controllers/operations.cjs.map +0 -1
- package/dist/controllers/operations.d.ts +0 -229
- package/dist/controllers/operations.js +0 -406
- package/dist/controllers/operations.js.map +0 -1
- package/dist/controllers/permissions.cjs +0 -4368
- package/dist/controllers/permissions.cjs.map +0 -1
- package/dist/controllers/permissions.d.ts +0 -1411
- package/dist/controllers/permissions.js +0 -4344
- package/dist/controllers/permissions.js.map +0 -1
- package/dist/controllers/protocol.cjs +0 -183
- package/dist/controllers/protocol.cjs.map +0 -1
- package/dist/controllers/protocol.d.ts +0 -138
- package/dist/controllers/protocol.js +0 -163
- package/dist/controllers/protocol.js.map +0 -1
- package/dist/controllers/schemas.cjs +0 -678
- package/dist/controllers/schemas.cjs.map +0 -1
- package/dist/controllers/schemas.d.ts +0 -293
- package/dist/controllers/schemas.js +0 -654
- package/dist/controllers/schemas.js.map +0 -1
- package/dist/controllers/server.cjs +0 -643
- package/dist/controllers/server.cjs.map +0 -1
- package/dist/controllers/server.d.ts +0 -322
- package/dist/controllers/server.js +0 -624
- package/dist/controllers/server.js.map +0 -1
- package/dist/controllers/staking.cjs +0 -626
- package/dist/controllers/staking.cjs.map +0 -1
- package/dist/controllers/staking.d.ts +0 -457
- package/dist/controllers/staking.js +0 -602
- package/dist/controllers/staking.js.map +0 -1
- package/dist/core/__tests__/pollingManager.test.d.ts +0 -4
- package/dist/core/apiClient.cjs +0 -378
- package/dist/core/apiClient.cjs.map +0 -1
- package/dist/core/apiClient.d.ts +0 -286
- package/dist/core/apiClient.js +0 -359
- package/dist/core/apiClient.js.map +0 -1
- package/dist/core/generics.cjs +0 -417
- package/dist/core/generics.cjs.map +0 -1
- package/dist/core/generics.d.ts +0 -205
- package/dist/core/generics.js +0 -386
- package/dist/core/generics.js.map +0 -1
- package/dist/core/health.cjs +0 -289
- package/dist/core/health.cjs.map +0 -1
- package/dist/core/health.d.ts +0 -143
- package/dist/core/health.js +0 -265
- package/dist/core/health.js.map +0 -1
- package/dist/core/inMemoryNonceManager.cjs +0 -138
- package/dist/core/inMemoryNonceManager.cjs.map +0 -1
- package/dist/core/inMemoryNonceManager.d.ts +0 -69
- package/dist/core/inMemoryNonceManager.js +0 -114
- package/dist/core/inMemoryNonceManager.js.map +0 -1
- package/dist/core/nonceManager.cjs +0 -304
- package/dist/core/nonceManager.cjs.map +0 -1
- package/dist/core/nonceManager.d.ts +0 -116
- package/dist/core/nonceManager.js +0 -280
- package/dist/core/nonceManager.js.map +0 -1
- package/dist/core/pollingManager.cjs +0 -292
- package/dist/core/pollingManager.cjs.map +0 -1
- package/dist/core/pollingManager.d.ts +0 -120
- package/dist/core/pollingManager.js +0 -268
- package/dist/core/pollingManager.js.map +0 -1
- package/dist/core.cjs +0 -781
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -496
- package/dist/core.js +0 -756
- package/dist/core.js.map +0 -1
- package/dist/diagnostics.cjs +0 -37
- package/dist/diagnostics.cjs.map +0 -1
- package/dist/diagnostics.d.ts +0 -24
- package/dist/diagnostics.js +0 -13
- package/dist/diagnostics.js.map +0 -1
- package/dist/diagnostics.test.d.ts +0 -1
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +0 -1202
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +0 -1
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +0 -914
- package/dist/generated/abi/DLPPerformanceImplementation.js +0 -1178
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +0 -1
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +0 -1112
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +0 -1
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +0 -840
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +0 -1088
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +0 -1
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs +0 -612
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs.map +0 -1
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +0 -451
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js +0 -588
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js.map +0 -1
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs +0 -939
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +0 -1
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +0 -705
- package/dist/generated/abi/DLPRewardSwapImplementation.js +0 -915
- package/dist/generated/abi/DLPRewardSwapImplementation.js.map +0 -1
- package/dist/generated/abi/DLPRootImplementation.cjs +0 -1644
- package/dist/generated/abi/DLPRootImplementation.cjs.map +0 -1
- package/dist/generated/abi/DLPRootImplementation.d.ts +0 -1246
- package/dist/generated/abi/DLPRootImplementation.js +0 -1620
- package/dist/generated/abi/DLPRootImplementation.js.map +0 -1
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +0 -985
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +0 -1
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +0 -735
- package/dist/generated/abi/DataLiquidityPoolImplementation.js +0 -961
- package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +0 -1
- package/dist/generated/abi/SwapHelperImplementation.cjs +0 -976
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +0 -1
- package/dist/generated/abi/SwapHelperImplementation.d.ts +0 -728
- package/dist/generated/abi/SwapHelperImplementation.js +0 -952
- package/dist/generated/abi/SwapHelperImplementation.js.map +0 -1
- package/dist/generated/abi/TeePoolImplementation.cjs +0 -1313
- package/dist/generated/abi/TeePoolImplementation.cjs.map +0 -1
- package/dist/generated/abi/TeePoolImplementation.d.ts +0 -992
- package/dist/generated/abi/TeePoolImplementation.js +0 -1289
- package/dist/generated/abi/TeePoolImplementation.js.map +0 -1
- package/dist/generated/event-types.cjs +0 -17
- package/dist/generated/event-types.cjs.map +0 -1
- package/dist/generated/event-types.d.ts +0 -816
- package/dist/generated/event-types.js +0 -1
- package/dist/generated/event-types.js.map +0 -1
- package/dist/generated/eventRegistry.cjs +0 -4512
- package/dist/generated/eventRegistry.cjs.map +0 -1
- package/dist/generated/eventRegistry.d.ts +0 -14
- package/dist/generated/eventRegistry.js +0 -4487
- package/dist/generated/eventRegistry.js.map +0 -1
- package/dist/generated/server/server-exports.cjs +0 -45
- package/dist/generated/server/server-exports.cjs.map +0 -1
- package/dist/generated/server/server-exports.d.ts +0 -36
- package/dist/generated/server/server-exports.js +0 -19
- package/dist/generated/server/server-exports.js.map +0 -1
- package/dist/generated/server/server.cjs +0 -17
- package/dist/generated/server/server.cjs.map +0 -1
- package/dist/generated/server/server.d.ts +0 -907
- package/dist/generated/server/server.js +0 -1
- package/dist/generated/server/server.js.map +0 -1
- package/dist/generated/subgraph.cjs +0 -1440
- package/dist/generated/subgraph.cjs.map +0 -1
- package/dist/generated/subgraph.d.ts +0 -6113
- package/dist/generated/subgraph.js +0 -1404
- package/dist/generated/subgraph.js.map +0 -1
- package/dist/lib/__tests__/redisAtomicStore.test.d.ts +0 -1
- package/dist/lib/redisAtomicStore.cjs +0 -201
- package/dist/lib/redisAtomicStore.cjs.map +0 -1
- package/dist/lib/redisAtomicStore.d.ts +0 -120
- package/dist/lib/redisAtomicStore.js +0 -177
- package/dist/lib/redisAtomicStore.js.map +0 -1
- package/dist/server/relayerHandler.cjs +0 -452
- package/dist/server/relayerHandler.cjs.map +0 -1
- package/dist/server/relayerHandler.d.ts +0 -69
- package/dist/server/relayerHandler.js +0 -428
- package/dist/server/relayerHandler.js.map +0 -1
- package/dist/tests/abi.test.d.ts +0 -1
- package/dist/tests/chains-definitions.test.d.ts +0 -1
- package/dist/tests/core-encryption.test.d.ts +0 -1
- package/dist/tests/core-extended.test.d.ts +0 -1
- package/dist/tests/core-generics-coverage.test.d.ts +0 -1
- package/dist/tests/coverage-boost.test.d.ts +0 -1
- package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +0 -1
- package/dist/tests/data-addfile-permissions-schema.test.d.ts +0 -1
- package/dist/tests/data-additional-methods.test.d.ts +0 -1
- package/dist/tests/data-controller-edge-cases.test.d.ts +0 -1
- package/dist/tests/data-ipfs-gateways.test.d.ts +0 -1
- package/dist/tests/data-relayer.test.d.ts +0 -1
- package/dist/tests/data-schema-validation.test.d.ts +0 -1
- package/dist/tests/data-simple-methods.test.d.ts +0 -1
- package/dist/tests/data-upload-owner-validation.test.d.ts +0 -1
- package/dist/tests/data.test.d.ts +0 -1
- package/dist/tests/demo-integration.test.d.ts +0 -1
- package/dist/tests/demo-trusted-server-integration.test.d.ts +0 -1
- package/dist/tests/download-relayer.test.d.ts +0 -1
- package/dist/tests/dual-mode-permissions.test.d.ts +0 -1
- package/dist/tests/dual-mode-trusted-servers.test.d.ts +0 -1
- package/dist/tests/encryption-correct-implementation.test.d.ts +0 -1
- package/dist/tests/encryption-coverage.test.d.ts +0 -1
- package/dist/tests/encryption-edge-cases.test.d.ts +0 -1
- package/dist/tests/encryption-utils-updated.test.d.ts +0 -1
- package/dist/tests/errors-coverage.test.d.ts +0 -1
- package/dist/tests/factories/mockFactory.d.ts +0 -316
- package/dist/tests/fakes/FakeStorageManager.d.ts +0 -200
- package/dist/tests/fakes/FakeStorageManager.test.d.ts +0 -1
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +0 -170
- package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +0 -1
- package/dist/tests/fakes/fake-pgp-port.d.ts +0 -13
- package/dist/tests/grantValidation-edge-cases.test.d.ts +0 -1
- package/dist/tests/grantValidation-unreachable-branch.test.d.ts +0 -1
- package/dist/tests/helper-methods.test.d.ts +0 -1
- package/dist/tests/helpers/typedMocks.d.ts +0 -64
- package/dist/tests/index-browser.test.d.ts +0 -1
- package/dist/tests/index-node.test.d.ts +0 -1
- package/dist/tests/index.test.d.ts +0 -1
- package/dist/tests/mocks/platformAdapter.d.ts +0 -12
- package/dist/tests/new-permissions-methods.test.d.ts +0 -1
- package/dist/tests/no-buffer-browser.test.d.ts +0 -1
- package/dist/tests/permissions-grantee.test.d.ts +0 -1
- package/dist/tests/permissions-revoke-relayer.test.d.ts +0 -1
- package/dist/tests/permissions-schema-validation.test.d.ts +0 -1
- package/dist/tests/permissions-server-files.test.d.ts +0 -1
- package/dist/tests/permissions-transaction-options.test.d.ts +0 -1
- package/dist/tests/permissions-trust-servers.test.d.ts +0 -1
- package/dist/tests/permissions.test.d.ts +0 -1
- package/dist/tests/personal.test.d.ts +0 -1
- package/dist/tests/platform-browser.test.d.ts +0 -1
- package/dist/tests/platform-crypto-expanded.test.d.ts +0 -1
- package/dist/tests/platform-crypto.test.d.ts +0 -1
- package/dist/tests/platform-index.test.d.ts +0 -1
- package/dist/tests/platform-node.test.d.ts +0 -1
- package/dist/tests/platform-shared-utils.test.d.ts +0 -1
- package/dist/tests/platform-updated.test.d.ts +0 -1
- package/dist/tests/protocol-additional-methods.test.d.ts +0 -1
- package/dist/tests/protocol.test.d.ts +0 -1
- package/dist/tests/read-only-mode.test.d.ts +0 -1
- package/dist/tests/relayer-integration.test.d.ts +0 -1
- package/dist/tests/relayer-unified.test.d.ts +0 -1
- package/dist/tests/schemas.test.d.ts +0 -1
- package/dist/tests/server-relayer-handler.test.d.ts +0 -1
- package/dist/tests/signatureFormatter.test.d.ts +0 -1
- package/dist/tests/staking.test.d.ts +0 -1
- package/dist/tests/trusted-server-queries.test.d.ts +0 -1
- package/dist/tests/typedDataConverter.test.d.ts +0 -1
- package/dist/tests/types-contracts.test.d.ts +0 -1
- package/dist/tests/types-data.test.d.ts +0 -1
- package/dist/tests/types-external-apis.test.d.ts +0 -1
- package/dist/tests/types-generics.test.d.ts +0 -1
- package/dist/tests/types-permissions.test.d.ts +0 -1
- package/dist/tests/types-upload-params.test.d.ts +0 -1
- package/dist/tests/types.test.d.ts +0 -1
- package/dist/tests/utils-formatters.test.d.ts +0 -1
- package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +0 -1
- package/dist/tests/utils-grantFiles-validation.test.d.ts +0 -1
- package/dist/tests/utils-grantFiles.test.d.ts +0 -1
- package/dist/tests/utils-grantValidation-consolidated.test.d.ts +0 -1
- package/dist/tests/utils-grants.test.d.ts +0 -1
- package/dist/tests/utils-ipfs-additional.test.d.ts +0 -1
- package/dist/tests/utils-ipfs.test.d.ts +0 -4
- package/dist/tests/utils-schemaValidation.test.d.ts +0 -1
- package/dist/tests/vana.test.d.ts +0 -1
- package/dist/tests/wallet-crypto-compatibility.test.d.ts +0 -1
- package/dist/types/atomicStore.cjs.map +0 -1
- package/dist/types/atomicStore.d.ts +0 -236
- package/dist/types/atomicStore.js +0 -7
- package/dist/types/atomicStore.js.map +0 -1
- package/dist/types/blockchain.cjs +0 -17
- package/dist/types/blockchain.cjs.map +0 -1
- package/dist/types/blockchain.d.ts +0 -85
- package/dist/types/blockchain.js +0 -1
- package/dist/types/blockchain.js.map +0 -1
- package/dist/types/controller-context.cjs +0 -17
- package/dist/types/controller-context.cjs.map +0 -1
- package/dist/types/controller-context.d.ts +0 -68
- package/dist/types/controller-context.js +0 -1
- package/dist/types/controller-context.js.map +0 -1
- package/dist/types/data.cjs +0 -17
- package/dist/types/data.cjs.map +0 -1
- package/dist/types/data.d.ts +0 -763
- package/dist/types/data.js +0 -1
- package/dist/types/data.js.map +0 -1
- package/dist/types/external-apis.cjs +0 -61
- package/dist/types/external-apis.cjs.map +0 -1
- package/dist/types/external-apis.d.ts +0 -184
- package/dist/types/external-apis.js +0 -34
- package/dist/types/external-apis.js.map +0 -1
- package/dist/types/generics.cjs +0 -17
- package/dist/types/generics.cjs.map +0 -1
- package/dist/types/generics.d.ts +0 -518
- package/dist/types/generics.js +0 -1
- package/dist/types/generics.js.map +0 -1
- package/dist/types/operationStore.cjs +0 -17
- package/dist/types/operationStore.cjs.map +0 -1
- package/dist/types/operationStore.d.ts +0 -171
- package/dist/types/operationStore.js +0 -1
- package/dist/types/operationStore.js.map +0 -1
- package/dist/types/operations.cjs +0 -53
- package/dist/types/operations.cjs.map +0 -1
- package/dist/types/operations.d.ts +0 -204
- package/dist/types/operations.js +0 -26
- package/dist/types/operations.js.map +0 -1
- package/dist/types/options.cjs +0 -17
- package/dist/types/options.cjs.map +0 -1
- package/dist/types/options.d.ts +0 -308
- package/dist/types/options.js +0 -1
- package/dist/types/options.js.map +0 -1
- package/dist/types/permissions.cjs +0 -17
- package/dist/types/permissions.cjs.map +0 -1
- package/dist/types/permissions.d.ts +0 -955
- package/dist/types/permissions.js +0 -1
- package/dist/types/permissions.js.map +0 -1
- package/dist/types/personal.cjs +0 -17
- package/dist/types/personal.cjs.map +0 -1
- package/dist/types/personal.d.ts +0 -174
- package/dist/types/personal.js +0 -1
- package/dist/types/personal.js.map +0 -1
- package/dist/types/relayer.cjs +0 -17
- package/dist/types/relayer.cjs.map +0 -1
- package/dist/types/relayer.d.ts +0 -552
- package/dist/types/relayer.js +0 -1
- package/dist/types/relayer.js.map +0 -1
- package/dist/types/transactionResults.cjs +0 -17
- package/dist/types/transactionResults.cjs.map +0 -1
- package/dist/types/transactionResults.d.ts +0 -193
- package/dist/types/transactionResults.js +0 -1
- package/dist/types/transactionResults.js.map +0 -1
- package/dist/types/utils.cjs +0 -17
- package/dist/types/utils.cjs.map +0 -1
- package/dist/types/utils.d.ts +0 -771
- package/dist/types/utils.js +0 -1
- package/dist/types/utils.js.map +0 -1
- package/dist/utils/__tests__/chainQuery.test.d.ts +0 -1
- package/dist/utils/__tests__/parseTransaction.test.d.ts +0 -1
- package/dist/utils/__tests__/pojo-serialization.test.d.ts +0 -1
- package/dist/utils/__tests__/signatureCache.test.d.ts +0 -1
- package/dist/utils/__tests__/subgraphConsistency.test.d.ts +0 -4
- package/dist/utils/__tests__/subgraphPagination.test.d.ts +0 -4
- package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +0 -1
- package/dist/utils/__tests__/transactionHelpers.test.d.ts +0 -1
- package/dist/utils/__tests__/urlResolver.test.d.ts +0 -4
- package/dist/utils/blockchain/registry.cjs +0 -81
- package/dist/utils/blockchain/registry.cjs.map +0 -1
- package/dist/utils/blockchain/registry.d.ts +0 -32
- package/dist/utils/blockchain/registry.js +0 -56
- package/dist/utils/blockchain/registry.js.map +0 -1
- package/dist/utils/blockchain/registry.test.d.ts +0 -1
- package/dist/utils/chainQuery.cjs +0 -107
- package/dist/utils/chainQuery.cjs.map +0 -1
- package/dist/utils/chainQuery.d.ts +0 -31
- package/dist/utils/chainQuery.js +0 -82
- package/dist/utils/chainQuery.js.map +0 -1
- package/dist/utils/download.cjs +0 -69
- package/dist/utils/download.cjs.map +0 -1
- package/dist/utils/download.d.ts +0 -40
- package/dist/utils/download.js +0 -45
- package/dist/utils/download.js.map +0 -1
- package/dist/utils/encryption.cjs +0 -176
- package/dist/utils/encryption.cjs.map +0 -1
- package/dist/utils/encryption.d.ts +0 -271
- package/dist/utils/encryption.js +0 -142
- package/dist/utils/encryption.js.map +0 -1
- package/dist/utils/formatters.cjs +0 -55
- package/dist/utils/formatters.cjs.map +0 -1
- package/dist/utils/formatters.d.ts +0 -118
- package/dist/utils/formatters.js +0 -28
- package/dist/utils/formatters.js.map +0 -1
- package/dist/utils/grantFiles.cjs +0 -181
- package/dist/utils/grantFiles.cjs.map +0 -1
- package/dist/utils/grantFiles.d.ts +0 -172
- package/dist/utils/grantFiles.js +0 -143
- package/dist/utils/grantFiles.js.map +0 -1
- package/dist/utils/grantValidation.cjs +0 -243
- package/dist/utils/grantValidation.cjs.map +0 -1
- package/dist/utils/grantValidation.d.ts +0 -226
- package/dist/utils/grantValidation.js +0 -201
- package/dist/utils/grantValidation.js.map +0 -1
- package/dist/utils/grants.cjs +0 -108
- package/dist/utils/grants.cjs.map +0 -1
- package/dist/utils/grants.d.ts +0 -148
- package/dist/utils/grants.js +0 -82
- package/dist/utils/grants.js.map +0 -1
- package/dist/utils/ipfs.cjs +0 -128
- package/dist/utils/ipfs.cjs.map +0 -1
- package/dist/utils/ipfs.d.ts +0 -88
- package/dist/utils/ipfs.js +0 -97
- package/dist/utils/ipfs.js.map +0 -1
- package/dist/utils/multicall.cjs +0 -233
- package/dist/utils/multicall.cjs.map +0 -1
- package/dist/utils/multicall.d.ts +0 -126
- package/dist/utils/multicall.js +0 -208
- package/dist/utils/multicall.js.map +0 -1
- package/dist/utils/parseTransactionPojo.cjs +0 -87
- package/dist/utils/parseTransactionPojo.cjs.map +0 -1
- package/dist/utils/parseTransactionPojo.d.ts +0 -31
- package/dist/utils/parseTransactionPojo.js +0 -63
- package/dist/utils/parseTransactionPojo.js.map +0 -1
- package/dist/utils/schemaValidation.cjs +0 -258
- package/dist/utils/schemaValidation.cjs.map +0 -1
- package/dist/utils/schemaValidation.d.ts +0 -168
- package/dist/utils/schemaValidation.js +0 -219
- package/dist/utils/schemaValidation.js.map +0 -1
- package/dist/utils/signatureCache.cjs +0 -192
- package/dist/utils/signatureCache.cjs.map +0 -1
- package/dist/utils/signatureCache.d.ts +0 -172
- package/dist/utils/signatureCache.js +0 -167
- package/dist/utils/signatureCache.js.map +0 -1
- package/dist/utils/signatureFormatter.cjs +0 -42
- package/dist/utils/signatureFormatter.cjs.map +0 -1
- package/dist/utils/signatureFormatter.d.ts +0 -36
- package/dist/utils/signatureFormatter.js +0 -18
- package/dist/utils/signatureFormatter.js.map +0 -1
- package/dist/utils/subgraphConsistency.cjs +0 -184
- package/dist/utils/subgraphConsistency.cjs.map +0 -1
- package/dist/utils/subgraphConsistency.d.ts +0 -65
- package/dist/utils/subgraphConsistency.js +0 -155
- package/dist/utils/subgraphConsistency.js.map +0 -1
- package/dist/utils/subgraphMetaCache.cjs +0 -101
- package/dist/utils/subgraphMetaCache.cjs.map +0 -1
- package/dist/utils/subgraphMetaCache.d.ts +0 -56
- package/dist/utils/subgraphMetaCache.js +0 -76
- package/dist/utils/subgraphMetaCache.js.map +0 -1
- package/dist/utils/subgraphPagination.cjs +0 -104
- package/dist/utils/subgraphPagination.cjs.map +0 -1
- package/dist/utils/subgraphPagination.d.ts +0 -78
- package/dist/utils/subgraphPagination.js +0 -78
- package/dist/utils/subgraphPagination.js.map +0 -1
- package/dist/utils/tests/multicall.test.d.ts +0 -1
- package/dist/utils/transactionHelpers.cjs +0 -54
- package/dist/utils/transactionHelpers.cjs.map +0 -1
- package/dist/utils/transactionHelpers.d.ts +0 -80
- package/dist/utils/transactionHelpers.js +0 -29
- package/dist/utils/transactionHelpers.js.map +0 -1
- package/dist/utils/typeGuards.cjs +0 -109
- package/dist/utils/typeGuards.cjs.map +0 -1
- package/dist/utils/typeGuards.d.ts +0 -138
- package/dist/utils/typeGuards.js +0 -74
- package/dist/utils/typeGuards.js.map +0 -1
- package/dist/utils/typedDataConverter.cjs +0 -43
- package/dist/utils/typedDataConverter.cjs.map +0 -1
- package/dist/utils/typedDataConverter.d.ts +0 -46
- package/dist/utils/typedDataConverter.js +0 -19
- package/dist/utils/typedDataConverter.js.map +0 -1
- package/dist/utils/urlResolver.cjs +0 -62
- package/dist/utils/urlResolver.cjs.map +0 -1
- package/dist/utils/urlResolver.d.ts +0 -56
- package/dist/utils/urlResolver.js +0 -37
- package/dist/utils/urlResolver.js.map +0 -1
- package/dist/utils/wallet.cjs +0 -63
- package/dist/utils/wallet.cjs.map +0 -1
- package/dist/utils/wallet.d.ts +0 -94
- package/dist/utils/wallet.js +0 -37
- package/dist/utils/wallet.js.map +0 -1
- package/dist/utils/withEvents.cjs +0 -44
- package/dist/utils/withEvents.cjs.map +0 -1
- package/dist/utils/withEvents.d.ts +0 -56
- package/dist/utils/withEvents.js +0 -18
- package/dist/utils/withEvents.js.map +0 -1
- /package/dist/{__tests__/waitForTransactionEvents.test.d.ts → auth/pkce.test.d.ts} +0 -0
- /package/dist/{client/__tests__/enhancedResponse.test.d.ts → auth/token-store.test.d.ts} +0 -0
- /package/dist/{controllers/__tests__/operations.processQueue.test.d.ts → auth/web3-signed.test.d.ts} +0 -0
- /package/dist/{controllers/__tests__/schemas-edge-cases.test.d.ts → crypto/envelope/openpgp.test.d.ts} +0 -0
- /package/dist/{controllers/data-error-handling.test.d.ts → crypto/keys/derive.test.d.ts} +0 -0
- /package/dist/{tests/errors.test.d.ts → errors.test.d.ts} +0 -0
- /package/dist/{controllers/server-additional.test.d.ts → protocol/data-file.test.d.ts} +0 -0
- /package/dist/{core/__tests__/health.test.d.ts → protocol/eip712.test.d.ts} +0 -0
- /package/dist/{core/__tests__/inMemoryNonceManager.test.d.ts → protocol/gateway.test.d.ts} +0 -0
- /package/dist/{core/__tests__/nonceManager.test.d.ts → protocol/scopes.test.d.ts} +0 -0
- /package/dist/{core/core.test.d.ts → storage/tests/defaultStorage.test.d.ts} +0 -0
- /package/dist/{core/tests/apiClient.test.d.ts → storage/tests/r2Storage.test.d.ts} +0 -0
- /package/dist/{core/tests/client.test.d.ts → storage/tests/vanaStorage.test.d.ts} +0 -0
- /package/dist/{core/tests/generics.test.d.ts → types/ps-errors.test.d.ts} +0 -0
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var parseTransactionPojo_exports = {};
|
|
20
|
-
__export(parseTransactionPojo_exports, {
|
|
21
|
-
parseTransaction: () => parseTransaction
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(parseTransactionPojo_exports);
|
|
24
|
-
var import_viem = require("viem");
|
|
25
|
-
var import_eventRegistry = require("../generated/eventRegistry");
|
|
26
|
-
function parseTransaction(transactionResult, receipt) {
|
|
27
|
-
const { contract: contractName, fn: functionName } = transactionResult;
|
|
28
|
-
const registryKey = `${contractName}.${functionName}`;
|
|
29
|
-
const registry = import_eventRegistry.EVENT_REGISTRY[registryKey];
|
|
30
|
-
const expectedEvents = {};
|
|
31
|
-
const allEvents = [];
|
|
32
|
-
let hasExpectedEvents = false;
|
|
33
|
-
if (receipt.logs) {
|
|
34
|
-
for (const log of receipt.logs) {
|
|
35
|
-
if (!log.topics || log.topics.length === 0) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const eventTopic = log.topics[0];
|
|
39
|
-
const abiCandidates = import_eventRegistry.TOPIC_TO_ABIS.get(eventTopic);
|
|
40
|
-
if (abiCandidates && abiCandidates.length > 0) {
|
|
41
|
-
for (const abiEvent of abiCandidates) {
|
|
42
|
-
try {
|
|
43
|
-
const decoded = (0, import_viem.decodeEventLog)({
|
|
44
|
-
abi: [abiEvent],
|
|
45
|
-
data: log.data,
|
|
46
|
-
topics: log.topics
|
|
47
|
-
});
|
|
48
|
-
allEvents.push({
|
|
49
|
-
contractAddress: log.address || "",
|
|
50
|
-
eventName: decoded.eventName,
|
|
51
|
-
args: decoded.args,
|
|
52
|
-
logIndex: log.logIndex ?? 0
|
|
53
|
-
});
|
|
54
|
-
if (registry && registry.eventNames.includes(decoded.eventName)) {
|
|
55
|
-
expectedEvents[decoded.eventName] = decoded.args;
|
|
56
|
-
hasExpectedEvents = true;
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
} catch {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
allEvents.push({
|
|
65
|
-
contractAddress: log.address || "",
|
|
66
|
-
eventName: "Unknown",
|
|
67
|
-
args: { topic0: eventTopic, data: log.data },
|
|
68
|
-
logIndex: log.logIndex ?? 0
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
hash: transactionResult.hash,
|
|
75
|
-
from: transactionResult.from,
|
|
76
|
-
contract: contractName,
|
|
77
|
-
fn: functionName,
|
|
78
|
-
expectedEvents,
|
|
79
|
-
allEvents,
|
|
80
|
-
hasExpectedEvents
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
-
0 && (module.exports = {
|
|
85
|
-
parseTransaction
|
|
86
|
-
});
|
|
87
|
-
//# sourceMappingURL=parseTransactionPojo.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/parseTransactionPojo.ts"],"sourcesContent":["/**\n * Transaction parsing with POJO support and NO heuristics.\n *\n * @remarks\n * This is the new POJO-based parser that works with TransactionResult objects.\n * Principle: Explicit over implicit, guarantees over guesses.\n */\n\nimport { decodeEventLog, type TransactionReceipt } from \"viem\";\nimport type { TransactionResult } from \"../types/operations\";\nimport type {\n TypedTransactionResult,\n Contract,\n Fn,\n ExpectedEvents,\n} from \"../generated/event-types\";\nimport { EVENT_REGISTRY, TOPIC_TO_ABIS } from \"../generated/eventRegistry\";\n\n/**\n * Parses a transaction using TransactionResult POJO with ZERO heuristics.\n *\n * @remarks\n * - Uses function-scoped event registry for O(1) lookups\n * - Only expects events explicitly mapped for this contract.function\n * - Returns typed events matching the exact TypedTransactionResult interface\n *\n * @param transactionResult - The TransactionResult POJO with context\n * @param transactionResult.hash - Transaction hash\n * @param transactionResult.from - Transaction sender address\n * @param transactionResult.contract - Contract name\n * @param transactionResult.fn - Function name\n * @param transactionResult.chainId - Optional chain ID\n * @param transactionResult.value - Optional transaction value\n * @param transactionResult.nonce - Optional nonce\n * @param transactionResult.to - Optional recipient address\n * @param receipt - The transaction receipt from the blockchain\n * @returns Typed transaction result with parsed events\n */\nexport function parseTransaction<C extends Contract, F extends Fn<C>>(\n transactionResult: TransactionResult<C, F>,\n receipt: TransactionReceipt,\n): TypedTransactionResult<C, F> {\n const { contract: contractName, fn: functionName } = transactionResult;\n\n // Look up expected events from the function-specific registry\n const registryKey = `${contractName}.${functionName}`;\n const registry = EVENT_REGISTRY[registryKey];\n\n // Initialize the expected events object with proper types\n const expectedEvents: Record<string, unknown> = {};\n const allEvents: Array<{\n contractAddress: string;\n eventName: string;\n args: Record<string, unknown>;\n logIndex: number;\n }> = [];\n\n let hasExpectedEvents = false;\n\n if (receipt.logs) {\n // Parse logs using the function-scoped registry\n for (const log of receipt.logs) {\n if (!log.topics || log.topics.length === 0) {\n // Skip malformed logs\n continue;\n }\n\n const eventTopic = log.topics[0] as `0x${string}`;\n\n // Try to decode using TOPIC_TO_ABIS for O(1) lookup\n const abiCandidates = TOPIC_TO_ABIS.get(eventTopic);\n\n if (abiCandidates && abiCandidates.length > 0) {\n // Try each ABI variant (handles collisions)\n for (const abiEvent of abiCandidates) {\n try {\n const decoded = decodeEventLog({\n abi: [abiEvent],\n data: log.data,\n topics: log.topics as [`0x${string}`, ...`0x${string}`[]],\n });\n\n // Add to allEvents\n allEvents.push({\n contractAddress: log.address || \"\",\n eventName: decoded.eventName,\n args: decoded.args as Record<string, unknown>,\n logIndex: log.logIndex ?? 0,\n });\n\n // If this event is expected for this function, add to expectedEvents\n if (registry && registry.eventNames.includes(decoded.eventName)) {\n expectedEvents[decoded.eventName] = decoded.args;\n hasExpectedEvents = true;\n }\n\n break; // Successfully decoded, don't try other variants\n } catch {\n // Try next ABI variant\n continue;\n }\n }\n } else {\n // Event not decodable, add as unknown\n allEvents.push({\n contractAddress: log.address || \"\",\n eventName: \"Unknown\",\n args: { topic0: eventTopic, data: log.data },\n logIndex: log.logIndex ?? 0,\n });\n }\n }\n }\n\n // Return a properly typed TypedTransactionResult\n return {\n hash: transactionResult.hash,\n from: transactionResult.from,\n contract: contractName,\n fn: functionName,\n expectedEvents: expectedEvents as ExpectedEvents<C, F>,\n allEvents,\n hasExpectedEvents,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,kBAAwD;AAQxD,2BAA8C;AAsBvC,SAAS,iBACd,mBACA,SAC8B;AAC9B,QAAM,EAAE,UAAU,cAAc,IAAI,aAAa,IAAI;AAGrD,QAAM,cAAc,GAAG,YAAY,IAAI,YAAY;AACnD,QAAM,WAAW,oCAAe,WAAW;AAG3C,QAAM,iBAA0C,CAAC;AACjD,QAAM,YAKD,CAAC;AAEN,MAAI,oBAAoB;AAExB,MAAI,QAAQ,MAAM;AAEhB,eAAW,OAAO,QAAQ,MAAM;AAC9B,UAAI,CAAC,IAAI,UAAU,IAAI,OAAO,WAAW,GAAG;AAE1C;AAAA,MACF;AAEA,YAAM,aAAa,IAAI,OAAO,CAAC;AAG/B,YAAM,gBAAgB,mCAAc,IAAI,UAAU;AAElD,UAAI,iBAAiB,cAAc,SAAS,GAAG;AAE7C,mBAAW,YAAY,eAAe;AACpC,cAAI;AACF,kBAAM,cAAU,4BAAe;AAAA,cAC7B,KAAK,CAAC,QAAQ;AAAA,cACd,MAAM,IAAI;AAAA,cACV,QAAQ,IAAI;AAAA,YACd,CAAC;AAGD,sBAAU,KAAK;AAAA,cACb,iBAAiB,IAAI,WAAW;AAAA,cAChC,WAAW,QAAQ;AAAA,cACnB,MAAM,QAAQ;AAAA,cACd,UAAU,IAAI,YAAY;AAAA,YAC5B,CAAC;AAGD,gBAAI,YAAY,SAAS,WAAW,SAAS,QAAQ,SAAS,GAAG;AAC/D,6BAAe,QAAQ,SAAS,IAAI,QAAQ;AAC5C,kCAAoB;AAAA,YACtB;AAEA;AAAA,UACF,QAAQ;AAEN;AAAA,UACF;AAAA,QACF;AAAA,MACF,OAAO;AAEL,kBAAU,KAAK;AAAA,UACb,iBAAiB,IAAI,WAAW;AAAA,UAChC,WAAW;AAAA,UACX,MAAM,EAAE,QAAQ,YAAY,MAAM,IAAI,KAAK;AAAA,UAC3C,UAAU,IAAI,YAAY;AAAA,QAC5B,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,MAAM,kBAAkB;AAAA,IACxB,UAAU;AAAA,IACV,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transaction parsing with POJO support and NO heuristics.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* This is the new POJO-based parser that works with TransactionResult objects.
|
|
6
|
-
* Principle: Explicit over implicit, guarantees over guesses.
|
|
7
|
-
*/
|
|
8
|
-
import { type TransactionReceipt } from "viem";
|
|
9
|
-
import type { TransactionResult } from "../types/operations";
|
|
10
|
-
import type { TypedTransactionResult, Contract, Fn } from "../generated/event-types";
|
|
11
|
-
/**
|
|
12
|
-
* Parses a transaction using TransactionResult POJO with ZERO heuristics.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* - Uses function-scoped event registry for O(1) lookups
|
|
16
|
-
* - Only expects events explicitly mapped for this contract.function
|
|
17
|
-
* - Returns typed events matching the exact TypedTransactionResult interface
|
|
18
|
-
*
|
|
19
|
-
* @param transactionResult - The TransactionResult POJO with context
|
|
20
|
-
* @param transactionResult.hash - Transaction hash
|
|
21
|
-
* @param transactionResult.from - Transaction sender address
|
|
22
|
-
* @param transactionResult.contract - Contract name
|
|
23
|
-
* @param transactionResult.fn - Function name
|
|
24
|
-
* @param transactionResult.chainId - Optional chain ID
|
|
25
|
-
* @param transactionResult.value - Optional transaction value
|
|
26
|
-
* @param transactionResult.nonce - Optional nonce
|
|
27
|
-
* @param transactionResult.to - Optional recipient address
|
|
28
|
-
* @param receipt - The transaction receipt from the blockchain
|
|
29
|
-
* @returns Typed transaction result with parsed events
|
|
30
|
-
*/
|
|
31
|
-
export declare function parseTransaction<C extends Contract, F extends Fn<C>>(transactionResult: TransactionResult<C, F>, receipt: TransactionReceipt): TypedTransactionResult<C, F>;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { decodeEventLog } from "viem";
|
|
2
|
-
import { EVENT_REGISTRY, TOPIC_TO_ABIS } from "../generated/eventRegistry";
|
|
3
|
-
function parseTransaction(transactionResult, receipt) {
|
|
4
|
-
const { contract: contractName, fn: functionName } = transactionResult;
|
|
5
|
-
const registryKey = `${contractName}.${functionName}`;
|
|
6
|
-
const registry = EVENT_REGISTRY[registryKey];
|
|
7
|
-
const expectedEvents = {};
|
|
8
|
-
const allEvents = [];
|
|
9
|
-
let hasExpectedEvents = false;
|
|
10
|
-
if (receipt.logs) {
|
|
11
|
-
for (const log of receipt.logs) {
|
|
12
|
-
if (!log.topics || log.topics.length === 0) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const eventTopic = log.topics[0];
|
|
16
|
-
const abiCandidates = TOPIC_TO_ABIS.get(eventTopic);
|
|
17
|
-
if (abiCandidates && abiCandidates.length > 0) {
|
|
18
|
-
for (const abiEvent of abiCandidates) {
|
|
19
|
-
try {
|
|
20
|
-
const decoded = decodeEventLog({
|
|
21
|
-
abi: [abiEvent],
|
|
22
|
-
data: log.data,
|
|
23
|
-
topics: log.topics
|
|
24
|
-
});
|
|
25
|
-
allEvents.push({
|
|
26
|
-
contractAddress: log.address || "",
|
|
27
|
-
eventName: decoded.eventName,
|
|
28
|
-
args: decoded.args,
|
|
29
|
-
logIndex: log.logIndex ?? 0
|
|
30
|
-
});
|
|
31
|
-
if (registry && registry.eventNames.includes(decoded.eventName)) {
|
|
32
|
-
expectedEvents[decoded.eventName] = decoded.args;
|
|
33
|
-
hasExpectedEvents = true;
|
|
34
|
-
}
|
|
35
|
-
break;
|
|
36
|
-
} catch {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
allEvents.push({
|
|
42
|
-
contractAddress: log.address || "",
|
|
43
|
-
eventName: "Unknown",
|
|
44
|
-
args: { topic0: eventTopic, data: log.data },
|
|
45
|
-
logIndex: log.logIndex ?? 0
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
hash: transactionResult.hash,
|
|
52
|
-
from: transactionResult.from,
|
|
53
|
-
contract: contractName,
|
|
54
|
-
fn: functionName,
|
|
55
|
-
expectedEvents,
|
|
56
|
-
allEvents,
|
|
57
|
-
hasExpectedEvents
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export {
|
|
61
|
-
parseTransaction
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=parseTransactionPojo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/parseTransactionPojo.ts"],"sourcesContent":["/**\n * Transaction parsing with POJO support and NO heuristics.\n *\n * @remarks\n * This is the new POJO-based parser that works with TransactionResult objects.\n * Principle: Explicit over implicit, guarantees over guesses.\n */\n\nimport { decodeEventLog, type TransactionReceipt } from \"viem\";\nimport type { TransactionResult } from \"../types/operations\";\nimport type {\n TypedTransactionResult,\n Contract,\n Fn,\n ExpectedEvents,\n} from \"../generated/event-types\";\nimport { EVENT_REGISTRY, TOPIC_TO_ABIS } from \"../generated/eventRegistry\";\n\n/**\n * Parses a transaction using TransactionResult POJO with ZERO heuristics.\n *\n * @remarks\n * - Uses function-scoped event registry for O(1) lookups\n * - Only expects events explicitly mapped for this contract.function\n * - Returns typed events matching the exact TypedTransactionResult interface\n *\n * @param transactionResult - The TransactionResult POJO with context\n * @param transactionResult.hash - Transaction hash\n * @param transactionResult.from - Transaction sender address\n * @param transactionResult.contract - Contract name\n * @param transactionResult.fn - Function name\n * @param transactionResult.chainId - Optional chain ID\n * @param transactionResult.value - Optional transaction value\n * @param transactionResult.nonce - Optional nonce\n * @param transactionResult.to - Optional recipient address\n * @param receipt - The transaction receipt from the blockchain\n * @returns Typed transaction result with parsed events\n */\nexport function parseTransaction<C extends Contract, F extends Fn<C>>(\n transactionResult: TransactionResult<C, F>,\n receipt: TransactionReceipt,\n): TypedTransactionResult<C, F> {\n const { contract: contractName, fn: functionName } = transactionResult;\n\n // Look up expected events from the function-specific registry\n const registryKey = `${contractName}.${functionName}`;\n const registry = EVENT_REGISTRY[registryKey];\n\n // Initialize the expected events object with proper types\n const expectedEvents: Record<string, unknown> = {};\n const allEvents: Array<{\n contractAddress: string;\n eventName: string;\n args: Record<string, unknown>;\n logIndex: number;\n }> = [];\n\n let hasExpectedEvents = false;\n\n if (receipt.logs) {\n // Parse logs using the function-scoped registry\n for (const log of receipt.logs) {\n if (!log.topics || log.topics.length === 0) {\n // Skip malformed logs\n continue;\n }\n\n const eventTopic = log.topics[0] as `0x${string}`;\n\n // Try to decode using TOPIC_TO_ABIS for O(1) lookup\n const abiCandidates = TOPIC_TO_ABIS.get(eventTopic);\n\n if (abiCandidates && abiCandidates.length > 0) {\n // Try each ABI variant (handles collisions)\n for (const abiEvent of abiCandidates) {\n try {\n const decoded = decodeEventLog({\n abi: [abiEvent],\n data: log.data,\n topics: log.topics as [`0x${string}`, ...`0x${string}`[]],\n });\n\n // Add to allEvents\n allEvents.push({\n contractAddress: log.address || \"\",\n eventName: decoded.eventName,\n args: decoded.args as Record<string, unknown>,\n logIndex: log.logIndex ?? 0,\n });\n\n // If this event is expected for this function, add to expectedEvents\n if (registry && registry.eventNames.includes(decoded.eventName)) {\n expectedEvents[decoded.eventName] = decoded.args;\n hasExpectedEvents = true;\n }\n\n break; // Successfully decoded, don't try other variants\n } catch {\n // Try next ABI variant\n continue;\n }\n }\n } else {\n // Event not decodable, add as unknown\n allEvents.push({\n contractAddress: log.address || \"\",\n eventName: \"Unknown\",\n args: { topic0: eventTopic, data: log.data },\n logIndex: log.logIndex ?? 0,\n });\n }\n }\n }\n\n // Return a properly typed TypedTransactionResult\n return {\n hash: transactionResult.hash,\n from: transactionResult.from,\n contract: contractName,\n fn: functionName,\n expectedEvents: expectedEvents as ExpectedEvents<C, F>,\n allEvents,\n hasExpectedEvents,\n };\n}\n"],"mappings":"AAQA,SAAS,sBAA+C;AAQxD,SAAS,gBAAgB,qBAAqB;AAsBvC,SAAS,iBACd,mBACA,SAC8B;AAC9B,QAAM,EAAE,UAAU,cAAc,IAAI,aAAa,IAAI;AAGrD,QAAM,cAAc,GAAG,YAAY,IAAI,YAAY;AACnD,QAAM,WAAW,eAAe,WAAW;AAG3C,QAAM,iBAA0C,CAAC;AACjD,QAAM,YAKD,CAAC;AAEN,MAAI,oBAAoB;AAExB,MAAI,QAAQ,MAAM;AAEhB,eAAW,OAAO,QAAQ,MAAM;AAC9B,UAAI,CAAC,IAAI,UAAU,IAAI,OAAO,WAAW,GAAG;AAE1C;AAAA,MACF;AAEA,YAAM,aAAa,IAAI,OAAO,CAAC;AAG/B,YAAM,gBAAgB,cAAc,IAAI,UAAU;AAElD,UAAI,iBAAiB,cAAc,SAAS,GAAG;AAE7C,mBAAW,YAAY,eAAe;AACpC,cAAI;AACF,kBAAM,UAAU,eAAe;AAAA,cAC7B,KAAK,CAAC,QAAQ;AAAA,cACd,MAAM,IAAI;AAAA,cACV,QAAQ,IAAI;AAAA,YACd,CAAC;AAGD,sBAAU,KAAK;AAAA,cACb,iBAAiB,IAAI,WAAW;AAAA,cAChC,WAAW,QAAQ;AAAA,cACnB,MAAM,QAAQ;AAAA,cACd,UAAU,IAAI,YAAY;AAAA,YAC5B,CAAC;AAGD,gBAAI,YAAY,SAAS,WAAW,SAAS,QAAQ,SAAS,GAAG;AAC/D,6BAAe,QAAQ,SAAS,IAAI,QAAQ;AAC5C,kCAAoB;AAAA,YACtB;AAEA;AAAA,UACF,QAAQ;AAEN;AAAA,UACF;AAAA,QACF;AAAA,MACF,OAAO;AAEL,kBAAU,KAAK;AAAA,UACb,iBAAiB,IAAI,WAAW;AAAA,UAChC,WAAW;AAAA,UACX,MAAM,EAAE,QAAQ,YAAY,MAAM,IAAI,KAAK;AAAA,UAC3C,UAAU,IAAI,YAAY;AAAA,QAC5B,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,MAAM,kBAAkB;AAAA,IACxB,UAAU;AAAA,IACV,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var schemaValidation_exports = {};
|
|
30
|
-
__export(schemaValidation_exports, {
|
|
31
|
-
SchemaValidationError: () => SchemaValidationError,
|
|
32
|
-
SchemaValidator: () => SchemaValidator,
|
|
33
|
-
fetchAndValidateSchema: () => fetchAndValidateSchema,
|
|
34
|
-
schemaValidator: () => schemaValidator,
|
|
35
|
-
validateDataAgainstSchema: () => validateDataAgainstSchema,
|
|
36
|
-
validateDataSchemaAgainstMetaSchema: () => validateDataSchemaAgainstMetaSchema
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(schemaValidation_exports);
|
|
39
|
-
var import_ajv = __toESM(require("ajv"), 1);
|
|
40
|
-
var import_ajv_formats = __toESM(require("ajv-formats"), 1);
|
|
41
|
-
var import_dataSchema_schema = __toESM(require("../schemas/dataSchema.schema.json"), 1);
|
|
42
|
-
class SchemaValidationError extends Error {
|
|
43
|
-
constructor(message, errors) {
|
|
44
|
-
super(message);
|
|
45
|
-
this.errors = errors;
|
|
46
|
-
this.name = "SchemaValidationError";
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class SchemaValidator {
|
|
50
|
-
ajv;
|
|
51
|
-
dataSchemaValidator;
|
|
52
|
-
constructor() {
|
|
53
|
-
this.ajv = new import_ajv.default({
|
|
54
|
-
allErrors: true,
|
|
55
|
-
verbose: true,
|
|
56
|
-
strict: false
|
|
57
|
-
});
|
|
58
|
-
(0, import_ajv_formats.default)(this.ajv);
|
|
59
|
-
this.dataSchemaValidator = this.ajv.compile(import_dataSchema_schema.default);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Validates a data schema definition against the Vana meta-schema
|
|
63
|
-
*
|
|
64
|
-
* @param schema - The data schema definition to validate
|
|
65
|
-
* @throws SchemaValidationError if invalid
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const validator = new SchemaValidator();
|
|
69
|
-
*
|
|
70
|
-
* const schema = {
|
|
71
|
-
* name: "User Profile",
|
|
72
|
-
* version: "1.0.0",
|
|
73
|
-
* dialect: "json",
|
|
74
|
-
* schema: {
|
|
75
|
-
* type: "object",
|
|
76
|
-
* properties: {
|
|
77
|
-
* name: { type: "string" },
|
|
78
|
-
* age: { type: "number" }
|
|
79
|
-
* }
|
|
80
|
-
* }
|
|
81
|
-
* };
|
|
82
|
-
*
|
|
83
|
-
* validator.validateDataSchemaAgainstMetaSchema(schema); // throws if invalid
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
validateDataSchemaAgainstMetaSchema(schema) {
|
|
87
|
-
const isValid = this.dataSchemaValidator(schema);
|
|
88
|
-
if (!isValid) {
|
|
89
|
-
const errors = this.dataSchemaValidator.errors ?? [];
|
|
90
|
-
const errorMessage = `Data schema validation failed: ${errors.map((e) => `${e.instancePath} ${e.message}`).join(", ")}`;
|
|
91
|
-
throw new SchemaValidationError(errorMessage, errors);
|
|
92
|
-
}
|
|
93
|
-
const typedSchema = schema;
|
|
94
|
-
if (typedSchema.dialect === "json" && typeof typedSchema.schema === "object") {
|
|
95
|
-
try {
|
|
96
|
-
this.ajv.compile(typedSchema.schema);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
const errorMessage = `Invalid JSON Schema in data schema: ${error instanceof Error ? error.message : "Unknown schema compilation error"}`;
|
|
99
|
-
throw new SchemaValidationError(errorMessage, []);
|
|
100
|
-
}
|
|
101
|
-
} else if (typedSchema.dialect === "sqlite" && typeof typedSchema.schema === "string") {
|
|
102
|
-
this.validateSQLiteDDL(typedSchema.schema, typedSchema.dialectVersion);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Validates data against a JSON Schema
|
|
107
|
-
*
|
|
108
|
-
* @param data - The data to validate
|
|
109
|
-
* @param schema - The schema containing the validation rules (must have been validated or fetched from chain)
|
|
110
|
-
* @throws SchemaValidationError if invalid
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* const validator = new SchemaValidator();
|
|
114
|
-
*
|
|
115
|
-
* // Works with Schema from schemas.get()
|
|
116
|
-
* const schema = await vana.schemas.get(1);
|
|
117
|
-
* validator.validateDataAgainstSchema(userData, schema);
|
|
118
|
-
*
|
|
119
|
-
* // Also works with pre-validated DataSchema object
|
|
120
|
-
* const dataSchema = validator.validateDataSchemaAgainstMetaSchema({
|
|
121
|
-
* name: "User Profile",
|
|
122
|
-
* version: "1.0.0",
|
|
123
|
-
* dialect: "json",
|
|
124
|
-
* schema: { type: "object", properties: { name: { type: "string" } } }
|
|
125
|
-
* });
|
|
126
|
-
* validator.validateDataAgainstSchema(userData, dataSchema);
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
validateDataAgainstSchema(data, schema) {
|
|
130
|
-
if (schema.dialect !== "json") {
|
|
131
|
-
console.warn(
|
|
132
|
-
`[SchemaValidator] Data validation skipped: dialect '${schema.dialect}' does not support data validation. Only JSON schemas can validate data structure.`
|
|
133
|
-
);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (typeof schema.schema !== "object") {
|
|
137
|
-
throw new SchemaValidationError(
|
|
138
|
-
"JSON dialect schemas must have an object schema",
|
|
139
|
-
[]
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
const dataValidator = this.ajv.compile(schema.schema);
|
|
143
|
-
const isValid = dataValidator(data);
|
|
144
|
-
if (!isValid) {
|
|
145
|
-
const errors = dataValidator.errors ?? [];
|
|
146
|
-
const errorMessage = `Data validation failed: ${errors.map((e) => `${e.instancePath} ${e.message}`).join(", ")}`;
|
|
147
|
-
throw new SchemaValidationError(errorMessage, errors);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Validates a SQLite DDL string for basic syntax
|
|
152
|
-
* Note: This is a basic validation, full SQL parsing would require a proper SQL parser
|
|
153
|
-
*
|
|
154
|
-
* @param ddl - The DDL string to validate
|
|
155
|
-
* @param dialectVersion - Optional SQLite version (e.g., "3" for SQLite v3)
|
|
156
|
-
* @throws SchemaValidationError if invalid
|
|
157
|
-
*/
|
|
158
|
-
validateSQLiteDDL(ddl, dialectVersion) {
|
|
159
|
-
if (typeof ddl !== "string" || ddl.trim().length === 0) {
|
|
160
|
-
throw new SchemaValidationError(
|
|
161
|
-
"SQLite DDL must be a non-empty string",
|
|
162
|
-
[]
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
if (dialectVersion !== void 0) {
|
|
166
|
-
const supportedVersions = ["3"];
|
|
167
|
-
if (!supportedVersions.includes(dialectVersion)) {
|
|
168
|
-
throw new SchemaValidationError(
|
|
169
|
-
`Unsupported SQLite dialect version: ${dialectVersion}. Supported versions: ${supportedVersions.join(", ")}`,
|
|
170
|
-
[]
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const normalizedDDL = ddl.trim().toUpperCase();
|
|
175
|
-
if (!normalizedDDL.includes("CREATE TABLE")) {
|
|
176
|
-
throw new SchemaValidationError(
|
|
177
|
-
"SQLite DDL must contain at least one CREATE TABLE statement",
|
|
178
|
-
[]
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
let parenCount = 0;
|
|
182
|
-
for (const char of ddl) {
|
|
183
|
-
if (char === "(") parenCount++;
|
|
184
|
-
if (char === ")") parenCount--;
|
|
185
|
-
if (parenCount < 0) {
|
|
186
|
-
throw new SchemaValidationError(
|
|
187
|
-
"SQLite DDL has unbalanced parentheses",
|
|
188
|
-
[]
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (parenCount !== 0) {
|
|
193
|
-
throw new SchemaValidationError(
|
|
194
|
-
"SQLite DDL has unbalanced parentheses",
|
|
195
|
-
[]
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Fetches and validates a data schema from a URL
|
|
201
|
-
*
|
|
202
|
-
* @param url - The URL to fetch the data schema from
|
|
203
|
-
* @param downloadRelayer - Optional download relayer for CORS bypass
|
|
204
|
-
* @param downloadRelayer.proxyDownload - Function to proxy downloads through application server
|
|
205
|
-
* @returns The validated data schema
|
|
206
|
-
* @throws SchemaValidationError if invalid or fetch fails
|
|
207
|
-
* @example
|
|
208
|
-
* ```typescript
|
|
209
|
-
* const validator = new SchemaValidator();
|
|
210
|
-
* const schema = await validator.fetchAndValidateSchema("https://example.com/schema.json");
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
async fetchAndValidateSchema(url, downloadRelayer) {
|
|
214
|
-
try {
|
|
215
|
-
const { universalFetch } = await import("./download");
|
|
216
|
-
const response = await universalFetch(url, downloadRelayer);
|
|
217
|
-
if (!response.ok) {
|
|
218
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
219
|
-
}
|
|
220
|
-
const schema = await response.json();
|
|
221
|
-
this.validateDataSchemaAgainstMetaSchema(schema);
|
|
222
|
-
if (schema.dialect === "sqlite" && typeof schema.schema === "string") {
|
|
223
|
-
this.validateSQLiteDDL(schema.schema, schema.dialectVersion);
|
|
224
|
-
}
|
|
225
|
-
return schema;
|
|
226
|
-
} catch (error) {
|
|
227
|
-
if (error instanceof SchemaValidationError) {
|
|
228
|
-
throw error;
|
|
229
|
-
}
|
|
230
|
-
throw new SchemaValidationError(
|
|
231
|
-
`Failed to fetch and validate schema from ${url}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
232
|
-
[]
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
const schemaValidator = new SchemaValidator();
|
|
238
|
-
function validateDataSchemaAgainstMetaSchema(schema) {
|
|
239
|
-
const validator = schemaValidator;
|
|
240
|
-
validator.validateDataSchemaAgainstMetaSchema(schema);
|
|
241
|
-
return schema;
|
|
242
|
-
}
|
|
243
|
-
function validateDataAgainstSchema(data, schema) {
|
|
244
|
-
schemaValidator.validateDataAgainstSchema(data, schema);
|
|
245
|
-
}
|
|
246
|
-
function fetchAndValidateSchema(url, downloadRelayer) {
|
|
247
|
-
return schemaValidator.fetchAndValidateSchema(url, downloadRelayer);
|
|
248
|
-
}
|
|
249
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
250
|
-
0 && (module.exports = {
|
|
251
|
-
SchemaValidationError,
|
|
252
|
-
SchemaValidator,
|
|
253
|
-
fetchAndValidateSchema,
|
|
254
|
-
schemaValidator,
|
|
255
|
-
validateDataAgainstSchema,
|
|
256
|
-
validateDataSchemaAgainstMetaSchema
|
|
257
|
-
});
|
|
258
|
-
//# sourceMappingURL=schemaValidation.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/schemaValidation.ts"],"sourcesContent":["import Ajv, { type ValidateFunction } from \"ajv\";\nimport addFormats from \"ajv-formats\";\nimport dataSchemaSchema from \"../schemas/dataSchema.schema.json\";\nimport type { Schema } from \"../types/data\";\n\n/**\n * Data schema interface following the Vana schema specification\n *\n * @category Configuration\n */\nexport interface DataSchema {\n /** The name of the data schema */\n name: string;\n /** The version of the data schema */\n version: string;\n /** Optional description of the data schema */\n description?: string;\n /** The dialect type - either SQLite or JSON */\n dialect: \"sqlite\" | \"json\";\n /** Optional version of the dialect */\n dialectVersion?: string;\n /** The actual schema definition as string or object */\n schema: string | object;\n}\n\n/**\n * Error thrown when schema validation fails\n */\nexport class SchemaValidationError extends Error {\n constructor(\n message: string,\n public errors: Array<{\n instancePath: string;\n schemaPath: string;\n keyword: string;\n params: Record<string, unknown>;\n message?: string;\n }>,\n ) {\n super(message);\n this.name = \"SchemaValidationError\";\n }\n}\n\n/**\n * Data schema validation utility class\n */\nexport class SchemaValidator {\n private ajv: Ajv;\n private dataSchemaValidator: ValidateFunction;\n\n constructor() {\n this.ajv = new Ajv({\n allErrors: true,\n verbose: true,\n strict: false,\n });\n\n // Add format validation (e.g., date, email, uri)\n addFormats(this.ajv);\n\n // Compile the data schema meta-schema validator\n this.dataSchemaValidator = this.ajv.compile(dataSchemaSchema);\n }\n\n /**\n * Validates a data schema definition against the Vana meta-schema\n *\n * @param schema - The data schema definition to validate\n * @throws SchemaValidationError if invalid\n * @example\n * ```typescript\n * const validator = new SchemaValidator();\n *\n * const schema = {\n * name: \"User Profile\",\n * version: \"1.0.0\",\n * dialect: \"json\",\n * schema: {\n * type: \"object\",\n * properties: {\n * name: { type: \"string\" },\n * age: { type: \"number\" }\n * }\n * }\n * };\n *\n * validator.validateDataSchemaAgainstMetaSchema(schema); // throws if invalid\n * ```\n */\n validateDataSchemaAgainstMetaSchema(\n schema: unknown,\n ): asserts schema is DataSchema {\n const isValid = this.dataSchemaValidator(schema);\n\n if (!isValid) {\n const errors = this.dataSchemaValidator.errors ?? [];\n const errorMessage = `Data schema validation failed: ${errors.map((e) => `${e.instancePath} ${e.message}`).join(\", \")}`;\n throw new SchemaValidationError(errorMessage, errors);\n }\n\n // Additional validation based on dialect\n const typedSchema = schema as DataSchema;\n if (\n typedSchema.dialect === \"json\" &&\n typeof typedSchema.schema === \"object\"\n ) {\n // Validate that the embedded JSON Schema is actually valid\n try {\n this.ajv.compile(typedSchema.schema);\n } catch (error) {\n const errorMessage = `Invalid JSON Schema in data schema: ${error instanceof Error ? error.message : \"Unknown schema compilation error\"}`;\n throw new SchemaValidationError(errorMessage, []);\n }\n } else if (\n typedSchema.dialect === \"sqlite\" &&\n typeof typedSchema.schema === \"string\"\n ) {\n // Validate SQLite DDL syntax\n this.validateSQLiteDDL(typedSchema.schema, typedSchema.dialectVersion);\n }\n }\n\n /**\n * Validates data against a JSON Schema\n *\n * @param data - The data to validate\n * @param schema - The schema containing the validation rules (must have been validated or fetched from chain)\n * @throws SchemaValidationError if invalid\n * @example\n * ```typescript\n * const validator = new SchemaValidator();\n *\n * // Works with Schema from schemas.get()\n * const schema = await vana.schemas.get(1);\n * validator.validateDataAgainstSchema(userData, schema);\n *\n * // Also works with pre-validated DataSchema object\n * const dataSchema = validator.validateDataSchemaAgainstMetaSchema({\n * name: \"User Profile\",\n * version: \"1.0.0\",\n * dialect: \"json\",\n * schema: { type: \"object\", properties: { name: { type: \"string\" } } }\n * });\n * validator.validateDataAgainstSchema(userData, dataSchema);\n * ```\n */\n validateDataAgainstSchema(data: unknown, schema: DataSchema | Schema): void {\n if (schema.dialect !== \"json\") {\n console.warn(\n `[SchemaValidator] Data validation skipped: dialect '${schema.dialect}' does not support data validation. ` +\n `Only JSON schemas can validate data structure.`,\n );\n return;\n }\n\n if (typeof schema.schema !== \"object\") {\n throw new SchemaValidationError(\n \"JSON dialect schemas must have an object schema\",\n [],\n );\n }\n\n // Compile and validate against the data schema\n const dataValidator = this.ajv.compile(schema.schema);\n const isValid = dataValidator(data);\n\n if (!isValid) {\n const errors = dataValidator.errors ?? [];\n const errorMessage = `Data validation failed: ${errors.map((e) => `${e.instancePath} ${e.message}`).join(\", \")}`;\n throw new SchemaValidationError(errorMessage, errors);\n }\n }\n\n /**\n * Validates a SQLite DDL string for basic syntax\n * Note: This is a basic validation, full SQL parsing would require a proper SQL parser\n *\n * @param ddl - The DDL string to validate\n * @param dialectVersion - Optional SQLite version (e.g., \"3\" for SQLite v3)\n * @throws SchemaValidationError if invalid\n */\n validateSQLiteDDL(ddl: string, dialectVersion?: string): void {\n if (typeof ddl !== \"string\" || ddl.trim().length === 0) {\n throw new SchemaValidationError(\n \"SQLite DDL must be a non-empty string\",\n [],\n );\n }\n\n // Validate dialectVersion if provided\n if (dialectVersion !== undefined) {\n const supportedVersions = [\"3\"];\n if (!supportedVersions.includes(dialectVersion)) {\n throw new SchemaValidationError(\n `Unsupported SQLite dialect version: ${dialectVersion}. Supported versions: ${supportedVersions.join(\", \")}`,\n [],\n );\n }\n }\n\n // Basic validation - check for CREATE TABLE statements\n const normalizedDDL = ddl.trim().toUpperCase();\n if (!normalizedDDL.includes(\"CREATE TABLE\")) {\n throw new SchemaValidationError(\n \"SQLite DDL must contain at least one CREATE TABLE statement\",\n [],\n );\n }\n\n // Check for balanced parentheses\n let parenCount = 0;\n for (const char of ddl) {\n if (char === \"(\") parenCount++;\n if (char === \")\") parenCount--;\n if (parenCount < 0) {\n throw new SchemaValidationError(\n \"SQLite DDL has unbalanced parentheses\",\n [],\n );\n }\n }\n\n if (parenCount !== 0) {\n throw new SchemaValidationError(\n \"SQLite DDL has unbalanced parentheses\",\n [],\n );\n }\n }\n\n /**\n * Fetches and validates a data schema from a URL\n *\n * @param url - The URL to fetch the data schema from\n * @param downloadRelayer - Optional download relayer for CORS bypass\n * @param downloadRelayer.proxyDownload - Function to proxy downloads through application server\n * @returns The validated data schema\n * @throws SchemaValidationError if invalid or fetch fails\n * @example\n * ```typescript\n * const validator = new SchemaValidator();\n * const schema = await validator.fetchAndValidateSchema(\"https://example.com/schema.json\");\n * ```\n */\n async fetchAndValidateSchema(\n url: string,\n downloadRelayer?: { proxyDownload: (url: string) => Promise<Blob> },\n ): Promise<DataSchema> {\n try {\n const { universalFetch } = await import(\"./download\");\n const response = await universalFetch(url, downloadRelayer);\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n }\n\n const schema = await response.json();\n this.validateDataSchemaAgainstMetaSchema(schema);\n\n // Additional validation based on dialect\n if (schema.dialect === \"sqlite\" && typeof schema.schema === \"string\") {\n this.validateSQLiteDDL(schema.schema, schema.dialectVersion);\n }\n\n return schema;\n } catch (error) {\n if (error instanceof SchemaValidationError) {\n throw error;\n }\n\n throw new SchemaValidationError(\n `Failed to fetch and validate schema from ${url}: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n [],\n );\n }\n }\n}\n\n/**\n * Global schema validator instance\n */\nexport const schemaValidator = new SchemaValidator();\n\n/**\n * Convenience function to validate a data schema definition against the Vana meta-schema\n *\n * @param schema - The data schema definition to validate\n * @returns The validated DataSchema\n * @throws SchemaValidationError if invalid\n * @example\n * ```typescript\n * const schemaDefinition = {\n * name: \"User Profile\",\n * version: \"1.0.0\",\n * dialect: \"json\",\n * schema: { type: \"object\", properties: { name: { type: \"string\" } } }\n * };\n *\n * const validatedSchema = validateDataSchemaAgainstMetaSchema(schemaDefinition);\n * ```\n */\nexport function validateDataSchemaAgainstMetaSchema(\n schema: unknown,\n): DataSchema {\n const validator: SchemaValidator = schemaValidator;\n validator.validateDataSchemaAgainstMetaSchema(schema);\n // If we get here, schema is valid and typed as DataSchema\n return schema;\n}\n\n/**\n * Convenience function to validate data against a schema\n *\n * @param data - The data to validate\n * @param schema - The data schema containing the schema\n * @returns void - Function doesn't return a value\n * @throws SchemaValidationError if invalid\n */\nexport function validateDataAgainstSchema(\n data: unknown,\n schema: DataSchema | Schema,\n): void {\n schemaValidator.validateDataAgainstSchema(data, schema);\n}\n\n/**\n * Convenience function to fetch and validate a data schema from a URL\n *\n * @param url - The URL to fetch the data schema from\n * @param downloadRelayer - Optional download relayer for CORS bypass\n * @param downloadRelayer.proxyDownload - Function to proxy downloads through application server\n * @returns The validated data schema\n * @throws SchemaValidationError if invalid or fetch fails\n */\nexport function fetchAndValidateSchema(\n url: string,\n downloadRelayer?: { proxyDownload: (url: string) => Promise<Blob> },\n): Promise<DataSchema> {\n return schemaValidator.fetchAndValidateSchema(url, downloadRelayer);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA2C;AAC3C,yBAAuB;AACvB,+BAA6B;AA0BtB,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YACE,SACO,QAOP;AACA,UAAM,OAAO;AARN;AASP,SAAK,OAAO;AAAA,EACd;AACF;AAKO,MAAM,gBAAgB;AAAA,EACnB;AAAA,EACA;AAAA,EAER,cAAc;AACZ,SAAK,MAAM,IAAI,WAAAA,QAAI;AAAA,MACjB,WAAW;AAAA,MACX,SAAS;AAAA,MACT,QAAQ;AAAA,IACV,CAAC;AAGD,2BAAAC,SAAW,KAAK,GAAG;AAGnB,SAAK,sBAAsB,KAAK,IAAI,QAAQ,yBAAAC,OAAgB;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BA,oCACE,QAC8B;AAC9B,UAAM,UAAU,KAAK,oBAAoB,MAAM;AAE/C,QAAI,CAAC,SAAS;AACZ,YAAM,SAAS,KAAK,oBAAoB,UAAU,CAAC;AACnD,YAAM,eAAe,kCAAkC,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,YAAY,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,IAAI,CAAC;AACrH,YAAM,IAAI,sBAAsB,cAAc,MAAM;AAAA,IACtD;AAGA,UAAM,cAAc;AACpB,QACE,YAAY,YAAY,UACxB,OAAO,YAAY,WAAW,UAC9B;AAEA,UAAI;AACF,aAAK,IAAI,QAAQ,YAAY,MAAM;AAAA,MACrC,SAAS,OAAO;AACd,cAAM,eAAe,uCAAuC,iBAAiB,QAAQ,MAAM,UAAU,kCAAkC;AACvI,cAAM,IAAI,sBAAsB,cAAc,CAAC,CAAC;AAAA,MAClD;AAAA,IACF,WACE,YAAY,YAAY,YACxB,OAAO,YAAY,WAAW,UAC9B;AAEA,WAAK,kBAAkB,YAAY,QAAQ,YAAY,cAAc;AAAA,IACvE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BA,0BAA0B,MAAe,QAAmC;AAC1E,QAAI,OAAO,YAAY,QAAQ;AAC7B,cAAQ;AAAA,QACN,uDAAuD,OAAO,OAAO;AAAA,MAEvE;AACA;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,WAAW,UAAU;AACrC,YAAM,IAAI;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAGA,UAAM,gBAAgB,KAAK,IAAI,QAAQ,OAAO,MAAM;AACpD,UAAM,UAAU,cAAc,IAAI;AAElC,QAAI,CAAC,SAAS;AACZ,YAAM,SAAS,cAAc,UAAU,CAAC;AACxC,YAAM,eAAe,2BAA2B,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,YAAY,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,IAAI,CAAC;AAC9G,YAAM,IAAI,sBAAsB,cAAc,MAAM;AAAA,IACtD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,kBAAkB,KAAa,gBAA+B;AAC5D,QAAI,OAAO,QAAQ,YAAY,IAAI,KAAK,EAAE,WAAW,GAAG;AACtD,YAAM,IAAI;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAGA,QAAI,mBAAmB,QAAW;AAChC,YAAM,oBAAoB,CAAC,GAAG;AAC9B,UAAI,CAAC,kBAAkB,SAAS,cAAc,GAAG;AAC/C,cAAM,IAAI;AAAA,UACR,uCAAuC,cAAc,yBAAyB,kBAAkB,KAAK,IAAI,CAAC;AAAA,UAC1G,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAGA,UAAM,gBAAgB,IAAI,KAAK,EAAE,YAAY;AAC7C,QAAI,CAAC,cAAc,SAAS,cAAc,GAAG;AAC3C,YAAM,IAAI;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAGA,QAAI,aAAa;AACjB,eAAW,QAAQ,KAAK;AACtB,UAAI,SAAS,IAAK;AAClB,UAAI,SAAS,IAAK;AAClB,UAAI,aAAa,GAAG;AAClB,cAAM,IAAI;AAAA,UACR;AAAA,UACA,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAEA,QAAI,eAAe,GAAG;AACpB,YAAM,IAAI;AAAA,QACR;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,uBACJ,KACA,iBACqB;AACrB,QAAI;AACF,YAAM,EAAE,eAAe,IAAI,MAAM,OAAO,YAAY;AACpD,YAAM,WAAW,MAAM,eAAe,KAAK,eAAe;AAC1D,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,QAAQ,SAAS,MAAM,KAAK,SAAS,UAAU,EAAE;AAAA,MACnE;AAEA,YAAM,SAAS,MAAM,SAAS,KAAK;AACnC,WAAK,oCAAoC,MAAM;AAG/C,UAAI,OAAO,YAAY,YAAY,OAAO,OAAO,WAAW,UAAU;AACpE,aAAK,kBAAkB,OAAO,QAAQ,OAAO,cAAc;AAAA,MAC7D;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,iBAAiB,uBAAuB;AAC1C,cAAM;AAAA,MACR;AAEA,YAAM,IAAI;AAAA,QACR,4CAA4C,GAAG,KAAK,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAAA,QAC5G,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAKO,MAAM,kBAAkB,IAAI,gBAAgB;AAoB5C,SAAS,oCACd,QACY;AACZ,QAAM,YAA6B;AACnC,YAAU,oCAAoC,MAAM;AAEpD,SAAO;AACT;AAUO,SAAS,0BACd,MACA,QACM;AACN,kBAAgB,0BAA0B,MAAM,MAAM;AACxD;AAWO,SAAS,uBACd,KACA,iBACqB;AACrB,SAAO,gBAAgB,uBAAuB,KAAK,eAAe;AACpE;","names":["Ajv","addFormats","dataSchemaSchema"]}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import type { Schema } from "../types/data";
|
|
2
|
-
/**
|
|
3
|
-
* Data schema interface following the Vana schema specification
|
|
4
|
-
*
|
|
5
|
-
* @category Configuration
|
|
6
|
-
*/
|
|
7
|
-
export interface DataSchema {
|
|
8
|
-
/** The name of the data schema */
|
|
9
|
-
name: string;
|
|
10
|
-
/** The version of the data schema */
|
|
11
|
-
version: string;
|
|
12
|
-
/** Optional description of the data schema */
|
|
13
|
-
description?: string;
|
|
14
|
-
/** The dialect type - either SQLite or JSON */
|
|
15
|
-
dialect: "sqlite" | "json";
|
|
16
|
-
/** Optional version of the dialect */
|
|
17
|
-
dialectVersion?: string;
|
|
18
|
-
/** The actual schema definition as string or object */
|
|
19
|
-
schema: string | object;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Error thrown when schema validation fails
|
|
23
|
-
*/
|
|
24
|
-
export declare class SchemaValidationError extends Error {
|
|
25
|
-
errors: Array<{
|
|
26
|
-
instancePath: string;
|
|
27
|
-
schemaPath: string;
|
|
28
|
-
keyword: string;
|
|
29
|
-
params: Record<string, unknown>;
|
|
30
|
-
message?: string;
|
|
31
|
-
}>;
|
|
32
|
-
constructor(message: string, errors: Array<{
|
|
33
|
-
instancePath: string;
|
|
34
|
-
schemaPath: string;
|
|
35
|
-
keyword: string;
|
|
36
|
-
params: Record<string, unknown>;
|
|
37
|
-
message?: string;
|
|
38
|
-
}>);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Data schema validation utility class
|
|
42
|
-
*/
|
|
43
|
-
export declare class SchemaValidator {
|
|
44
|
-
private ajv;
|
|
45
|
-
private dataSchemaValidator;
|
|
46
|
-
constructor();
|
|
47
|
-
/**
|
|
48
|
-
* Validates a data schema definition against the Vana meta-schema
|
|
49
|
-
*
|
|
50
|
-
* @param schema - The data schema definition to validate
|
|
51
|
-
* @throws SchemaValidationError if invalid
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const validator = new SchemaValidator();
|
|
55
|
-
*
|
|
56
|
-
* const schema = {
|
|
57
|
-
* name: "User Profile",
|
|
58
|
-
* version: "1.0.0",
|
|
59
|
-
* dialect: "json",
|
|
60
|
-
* schema: {
|
|
61
|
-
* type: "object",
|
|
62
|
-
* properties: {
|
|
63
|
-
* name: { type: "string" },
|
|
64
|
-
* age: { type: "number" }
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* };
|
|
68
|
-
*
|
|
69
|
-
* validator.validateDataSchemaAgainstMetaSchema(schema); // throws if invalid
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
validateDataSchemaAgainstMetaSchema(schema: unknown): asserts schema is DataSchema;
|
|
73
|
-
/**
|
|
74
|
-
* Validates data against a JSON Schema
|
|
75
|
-
*
|
|
76
|
-
* @param data - The data to validate
|
|
77
|
-
* @param schema - The schema containing the validation rules (must have been validated or fetched from chain)
|
|
78
|
-
* @throws SchemaValidationError if invalid
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* const validator = new SchemaValidator();
|
|
82
|
-
*
|
|
83
|
-
* // Works with Schema from schemas.get()
|
|
84
|
-
* const schema = await vana.schemas.get(1);
|
|
85
|
-
* validator.validateDataAgainstSchema(userData, schema);
|
|
86
|
-
*
|
|
87
|
-
* // Also works with pre-validated DataSchema object
|
|
88
|
-
* const dataSchema = validator.validateDataSchemaAgainstMetaSchema({
|
|
89
|
-
* name: "User Profile",
|
|
90
|
-
* version: "1.0.0",
|
|
91
|
-
* dialect: "json",
|
|
92
|
-
* schema: { type: "object", properties: { name: { type: "string" } } }
|
|
93
|
-
* });
|
|
94
|
-
* validator.validateDataAgainstSchema(userData, dataSchema);
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
validateDataAgainstSchema(data: unknown, schema: DataSchema | Schema): void;
|
|
98
|
-
/**
|
|
99
|
-
* Validates a SQLite DDL string for basic syntax
|
|
100
|
-
* Note: This is a basic validation, full SQL parsing would require a proper SQL parser
|
|
101
|
-
*
|
|
102
|
-
* @param ddl - The DDL string to validate
|
|
103
|
-
* @param dialectVersion - Optional SQLite version (e.g., "3" for SQLite v3)
|
|
104
|
-
* @throws SchemaValidationError if invalid
|
|
105
|
-
*/
|
|
106
|
-
validateSQLiteDDL(ddl: string, dialectVersion?: string): void;
|
|
107
|
-
/**
|
|
108
|
-
* Fetches and validates a data schema from a URL
|
|
109
|
-
*
|
|
110
|
-
* @param url - The URL to fetch the data schema from
|
|
111
|
-
* @param downloadRelayer - Optional download relayer for CORS bypass
|
|
112
|
-
* @param downloadRelayer.proxyDownload - Function to proxy downloads through application server
|
|
113
|
-
* @returns The validated data schema
|
|
114
|
-
* @throws SchemaValidationError if invalid or fetch fails
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* const validator = new SchemaValidator();
|
|
118
|
-
* const schema = await validator.fetchAndValidateSchema("https://example.com/schema.json");
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
fetchAndValidateSchema(url: string, downloadRelayer?: {
|
|
122
|
-
proxyDownload: (url: string) => Promise<Blob>;
|
|
123
|
-
}): Promise<DataSchema>;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Global schema validator instance
|
|
127
|
-
*/
|
|
128
|
-
export declare const schemaValidator: SchemaValidator;
|
|
129
|
-
/**
|
|
130
|
-
* Convenience function to validate a data schema definition against the Vana meta-schema
|
|
131
|
-
*
|
|
132
|
-
* @param schema - The data schema definition to validate
|
|
133
|
-
* @returns The validated DataSchema
|
|
134
|
-
* @throws SchemaValidationError if invalid
|
|
135
|
-
* @example
|
|
136
|
-
* ```typescript
|
|
137
|
-
* const schemaDefinition = {
|
|
138
|
-
* name: "User Profile",
|
|
139
|
-
* version: "1.0.0",
|
|
140
|
-
* dialect: "json",
|
|
141
|
-
* schema: { type: "object", properties: { name: { type: "string" } } }
|
|
142
|
-
* };
|
|
143
|
-
*
|
|
144
|
-
* const validatedSchema = validateDataSchemaAgainstMetaSchema(schemaDefinition);
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
export declare function validateDataSchemaAgainstMetaSchema(schema: unknown): DataSchema;
|
|
148
|
-
/**
|
|
149
|
-
* Convenience function to validate data against a schema
|
|
150
|
-
*
|
|
151
|
-
* @param data - The data to validate
|
|
152
|
-
* @param schema - The data schema containing the schema
|
|
153
|
-
* @returns void - Function doesn't return a value
|
|
154
|
-
* @throws SchemaValidationError if invalid
|
|
155
|
-
*/
|
|
156
|
-
export declare function validateDataAgainstSchema(data: unknown, schema: DataSchema | Schema): void;
|
|
157
|
-
/**
|
|
158
|
-
* Convenience function to fetch and validate a data schema from a URL
|
|
159
|
-
*
|
|
160
|
-
* @param url - The URL to fetch the data schema from
|
|
161
|
-
* @param downloadRelayer - Optional download relayer for CORS bypass
|
|
162
|
-
* @param downloadRelayer.proxyDownload - Function to proxy downloads through application server
|
|
163
|
-
* @returns The validated data schema
|
|
164
|
-
* @throws SchemaValidationError if invalid or fetch fails
|
|
165
|
-
*/
|
|
166
|
-
export declare function fetchAndValidateSchema(url: string, downloadRelayer?: {
|
|
167
|
-
proxyDownload: (url: string) => Promise<Blob>;
|
|
168
|
-
}): Promise<DataSchema>;
|