@opendatalabs/vana-sdk 0.1.0-alpha.2b6935d → 0.1.0-alpha.2e77fcc

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.
Files changed (171) hide show
  1. package/dist/browser.cjs.map +1 -1
  2. package/dist/browser.d.ts +33 -1
  3. package/dist/browser.js.map +1 -1
  4. package/dist/chains/index.cjs.map +1 -1
  5. package/dist/chains/index.d.ts +30 -1
  6. package/dist/chains/index.js.map +1 -1
  7. package/dist/config/chains.cjs.map +1 -1
  8. package/dist/config/chains.d.ts +99 -0
  9. package/dist/config/chains.js.map +1 -1
  10. package/dist/contracts/contractController.cjs.map +1 -1
  11. package/dist/contracts/contractController.d.ts +66 -10
  12. package/dist/contracts/contractController.js.map +1 -1
  13. package/dist/controllers/base.cjs +33 -0
  14. package/dist/controllers/base.cjs.map +1 -1
  15. package/dist/controllers/base.d.ts +10 -0
  16. package/dist/controllers/base.js +33 -0
  17. package/dist/controllers/base.js.map +1 -1
  18. package/dist/controllers/data.cjs +162 -133
  19. package/dist/controllers/data.cjs.map +1 -1
  20. package/dist/controllers/data.d.ts +222 -184
  21. package/dist/controllers/data.js +162 -133
  22. package/dist/controllers/data.js.map +1 -1
  23. package/dist/controllers/permissions.cjs +208 -60
  24. package/dist/controllers/permissions.cjs.map +1 -1
  25. package/dist/controllers/permissions.d.ts +75 -45
  26. package/dist/controllers/permissions.js +208 -60
  27. package/dist/controllers/permissions.js.map +1 -1
  28. package/dist/controllers/protocol.cjs.map +1 -1
  29. package/dist/controllers/protocol.d.ts +27 -28
  30. package/dist/controllers/protocol.js.map +1 -1
  31. package/dist/controllers/schemas.cjs +23 -21
  32. package/dist/controllers/schemas.cjs.map +1 -1
  33. package/dist/controllers/schemas.d.ts +47 -40
  34. package/dist/controllers/schemas.js +23 -21
  35. package/dist/controllers/schemas.js.map +1 -1
  36. package/dist/controllers/server.cjs +17 -15
  37. package/dist/controllers/server.cjs.map +1 -1
  38. package/dist/controllers/server.d.ts +46 -38
  39. package/dist/controllers/server.js +17 -15
  40. package/dist/controllers/server.js.map +1 -1
  41. package/dist/core/apiClient.cjs +53 -3
  42. package/dist/core/apiClient.cjs.map +1 -1
  43. package/dist/core/apiClient.d.ts +132 -7
  44. package/dist/core/apiClient.js +53 -3
  45. package/dist/core/apiClient.js.map +1 -1
  46. package/dist/core/generics.cjs +30 -3
  47. package/dist/core/generics.cjs.map +1 -1
  48. package/dist/core/generics.d.ts +95 -6
  49. package/dist/core/generics.js +30 -3
  50. package/dist/core/generics.js.map +1 -1
  51. package/dist/core.cjs +4 -1
  52. package/dist/core.cjs.map +1 -1
  53. package/dist/core.d.ts +2 -1
  54. package/dist/core.js +4 -1
  55. package/dist/core.js.map +1 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/index.node.cjs +2 -3
  59. package/dist/index.node.cjs.map +1 -1
  60. package/dist/index.node.d.ts +33 -13
  61. package/dist/index.node.js +2 -2
  62. package/dist/index.node.js.map +1 -1
  63. package/dist/node.cjs.map +1 -1
  64. package/dist/node.d.ts +39 -1
  65. package/dist/node.js.map +1 -1
  66. package/dist/platform/browser.cjs +160 -2
  67. package/dist/platform/browser.cjs.map +1 -1
  68. package/dist/platform/browser.d.ts +232 -12
  69. package/dist/platform/browser.js +160 -2
  70. package/dist/platform/browser.js.map +1 -1
  71. package/dist/platform/interface.cjs.map +1 -1
  72. package/dist/platform/interface.d.ts +283 -90
  73. package/dist/platform/node.cjs +163 -2
  74. package/dist/platform/node.cjs.map +1 -1
  75. package/dist/platform/node.d.ts +69 -6
  76. package/dist/platform/node.js +163 -2
  77. package/dist/platform/node.js.map +1 -1
  78. package/dist/server/relayerHandler.cjs +136 -98
  79. package/dist/server/relayerHandler.cjs.map +1 -1
  80. package/dist/server/relayerHandler.d.ts +3 -2
  81. package/dist/server/relayerHandler.js +135 -96
  82. package/dist/server/relayerHandler.js.map +1 -1
  83. package/dist/storage/manager.cjs +108 -25
  84. package/dist/storage/manager.cjs.map +1 -1
  85. package/dist/storage/manager.d.ts +119 -25
  86. package/dist/storage/manager.js +108 -25
  87. package/dist/storage/manager.js.map +1 -1
  88. package/dist/storage/providers/callback-storage.cjs +86 -15
  89. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  90. package/dist/storage/providers/callback-storage.d.ts +109 -20
  91. package/dist/storage/providers/callback-storage.js +86 -15
  92. package/dist/storage/providers/callback-storage.js.map +1 -1
  93. package/dist/storage/providers/pinata.cjs.map +1 -1
  94. package/dist/storage/providers/pinata.d.ts +12 -14
  95. package/dist/storage/providers/pinata.js.map +1 -1
  96. package/dist/types/blockchain.cjs.map +1 -1
  97. package/dist/types/blockchain.d.ts +39 -11
  98. package/dist/types/chains.cjs.map +1 -1
  99. package/dist/types/chains.d.ts +74 -7
  100. package/dist/types/chains.js.map +1 -1
  101. package/dist/types/config.cjs.map +1 -1
  102. package/dist/types/config.d.ts +38 -4
  103. package/dist/types/config.js.map +1 -1
  104. package/dist/types/contracts.cjs.map +1 -1
  105. package/dist/types/contracts.d.ts +71 -7
  106. package/dist/types/controller-context.cjs.map +1 -1
  107. package/dist/types/controller-context.d.ts +3 -1
  108. package/dist/types/data.cjs.map +1 -1
  109. package/dist/types/data.d.ts +4 -6
  110. package/dist/types/generics.cjs.map +1 -1
  111. package/dist/types/generics.d.ts +81 -10
  112. package/dist/types/index.cjs.map +1 -1
  113. package/dist/types/index.d.ts +28 -2
  114. package/dist/types/index.js.map +1 -1
  115. package/dist/types/operations.cjs.map +1 -1
  116. package/dist/types/operations.d.ts +178 -15
  117. package/dist/types/operations.js.map +1 -1
  118. package/dist/types/permissions.cjs.map +1 -1
  119. package/dist/types/permissions.d.ts +15 -20
  120. package/dist/types/personal.cjs.map +1 -1
  121. package/dist/types/personal.d.ts +131 -14
  122. package/dist/types/relayer.cjs.map +1 -1
  123. package/dist/types/relayer.d.ts +114 -18
  124. package/dist/types/storage.cjs.map +1 -1
  125. package/dist/types/storage.d.ts +9 -21
  126. package/dist/types/storage.js.map +1 -1
  127. package/dist/types/utils.cjs.map +1 -1
  128. package/dist/types/utils.d.ts +5 -1
  129. package/dist/utils/grantFiles.cjs.map +1 -1
  130. package/dist/utils/grantFiles.d.ts +10 -20
  131. package/dist/utils/grantFiles.js.map +1 -1
  132. package/dist/utils/grantValidation.cjs.map +1 -1
  133. package/dist/utils/grantValidation.d.ts +95 -16
  134. package/dist/utils/grantValidation.js.map +1 -1
  135. package/dist/utils/grants.cjs.map +1 -1
  136. package/dist/utils/grants.d.ts +93 -12
  137. package/dist/utils/grants.js.map +1 -1
  138. package/dist/utils/ipfs.cjs +2 -4
  139. package/dist/utils/ipfs.cjs.map +1 -1
  140. package/dist/utils/ipfs.d.ts +1 -1
  141. package/dist/utils/ipfs.js +2 -4
  142. package/dist/utils/ipfs.js.map +1 -1
  143. package/dist/utils/lazy-import.cjs.map +1 -1
  144. package/dist/utils/lazy-import.d.ts +32 -7
  145. package/dist/utils/lazy-import.js.map +1 -1
  146. package/dist/utils/signatureCache.cjs +8 -2
  147. package/dist/utils/signatureCache.cjs.map +1 -1
  148. package/dist/utils/signatureCache.d.ts +49 -8
  149. package/dist/utils/signatureCache.js +8 -2
  150. package/dist/utils/signatureCache.js.map +1 -1
  151. package/dist/utils/transactionHelpers.cjs.map +1 -1
  152. package/dist/utils/transactionHelpers.d.ts +12 -12
  153. package/dist/utils/transactionHelpers.js.map +1 -1
  154. package/dist/utils/typedDataConverter.cjs.map +1 -1
  155. package/dist/utils/typedDataConverter.d.ts +39 -3
  156. package/dist/utils/typedDataConverter.js.map +1 -1
  157. package/dist/utils/urlResolver.cjs +7 -0
  158. package/dist/utils/urlResolver.cjs.map +1 -1
  159. package/dist/utils/urlResolver.d.ts +22 -4
  160. package/dist/utils/urlResolver.js +7 -0
  161. package/dist/utils/urlResolver.js.map +1 -1
  162. package/dist/utils/wallet.cjs.map +1 -1
  163. package/dist/utils/wallet.d.ts +78 -16
  164. package/dist/utils/wallet.js.map +1 -1
  165. package/package.json +3 -1
  166. package/dist/server/handler.cjs +0 -103
  167. package/dist/server/handler.cjs.map +0 -1
  168. package/dist/server/handler.d.ts +0 -95
  169. package/dist/server/handler.js +0 -79
  170. package/dist/server/handler.js.map +0 -1
  171. /package/dist/tests/{server-handler.test.d.ts → permissions-transaction-options.test.d.ts} +0 -0
@@ -1,10 +1,36 @@
1
+ /**
2
+ * Defines types for smart contract interactions.
3
+ *
4
+ * @remarks
5
+ * This module provides comprehensive type definitions for Vana protocol
6
+ * smart contracts including contract names, deployment information, and
7
+ * advanced TypeScript utility types for type-safe contract interactions.
8
+ *
9
+ * @category Types
10
+ * @module types/contracts
11
+ */
1
12
  import type { Abi, Address, Hash, GetContractReturnType } from "viem";
2
13
  /**
3
- * Union type of all canonical Vana contract names
14
+ * Enumerates all supported Vana protocol contract names.
15
+ *
16
+ * @remarks
17
+ * Use these names with `getContractController()` to get typed contract
18
+ * instances. Each name corresponds to a specific protocol contract with
19
+ * its own ABI and functionality.
20
+ *
21
+ * @category Contracts
4
22
  */
5
23
  export type VanaContractName = "DataPortabilityPermissions" | "DataPortabilityServers" | "DataPortabilityGrantees" | "DataRegistry" | "TeePool" | "ComputeEngine" | "TeePoolPhala" | "DataRefinerRegistry" | "QueryEngine" | "ComputeInstructionRegistry" | "TeePoolEphemeralStandard" | "TeePoolPersistentStandard" | "TeePoolPersistentGpu" | "TeePoolDedicatedStandard" | "TeePoolDedicatedGpu" | "VanaEpoch" | "DLPRegistry" | "DLPRegistryTreasury" | "DLPPerformance" | "DLPRewardDeployer" | "DLPRewardDeployerTreasury" | "DLPRewardSwap" | "SwapHelper" | "VanaPoolStaking" | "VanaPoolEntity" | "VanaPoolTreasury" | "DAT" | "DATFactory" | "DATPausable" | "DATVotes" | "DataLiquidityPool" | "DLPRoot";
6
24
  /**
7
- * Contract information with typed address and ABI
25
+ * Provides contract deployment information with typed ABI.
26
+ *
27
+ * @remarks
28
+ * Contains the minimum information needed to interact with a
29
+ * deployed contract: its address and ABI.
30
+ *
31
+ * @typeParam TAbi - The contract's ABI type for full type safety
32
+ *
33
+ * @category Contracts
8
34
  */
9
35
  export interface ContractInfo<TAbi extends Abi = Abi> {
10
36
  /** The contract's deployed address */
@@ -13,7 +39,13 @@ export interface ContractInfo<TAbi extends Abi = Abi> {
13
39
  abi: TAbi;
14
40
  }
15
41
  /**
16
- * Contract deployment information
42
+ * Tracks contract deployment metadata.
43
+ *
44
+ * @remarks
45
+ * Records when and how a contract was deployed to the blockchain,
46
+ * useful for verification and debugging.
47
+ *
48
+ * @category Contracts
17
49
  */
18
50
  export interface ContractDeployment {
19
51
  /** The contract's deployed address */
@@ -24,11 +56,25 @@ export interface ContractDeployment {
24
56
  transactionHash: Hash;
25
57
  }
26
58
  /**
27
- * Typed contract instance
59
+ * Represents a fully typed contract instance.
60
+ *
61
+ * @remarks
62
+ * Alias for viem's GetContractReturnType, providing a contract
63
+ * instance with all methods fully typed based on the ABI.
64
+ *
65
+ * @typeParam TAbi - The contract's ABI type
66
+ *
67
+ * @category Contracts
28
68
  */
29
69
  export type VanaContractInstance<TAbi extends Abi = Abi> = GetContractReturnType<TAbi>;
30
70
  /**
31
- * Contract addresses mapping by chain and contract name
71
+ * Maps contract addresses by chain ID and contract name.
72
+ *
73
+ * @remarks
74
+ * Hierarchical mapping structure for multi-chain contract deployments.
75
+ * Used internally for address resolution across different networks.
76
+ *
77
+ * @category Contracts
32
78
  */
33
79
  export type ContractAddresses = {
34
80
  [chainId: number]: {
@@ -36,7 +82,16 @@ export type ContractAddresses = {
36
82
  };
37
83
  };
38
84
  /**
39
- * Contract method parameters for typed interactions
85
+ * Extracts typed parameters for a contract method from its ABI.
86
+ *
87
+ * @remarks
88
+ * Advanced utility type that provides type-safe parameter extraction
89
+ * from contract ABIs. Maps Solidity types to TypeScript types automatically.
90
+ *
91
+ * @typeParam TAbi - The contract's ABI type
92
+ * @typeParam TFunctionName - The name of the function to extract parameters for
93
+ *
94
+ * @internal
40
95
  */
41
96
  export type ContractMethodParams<TAbi extends Abi, TFunctionName extends string> = TAbi extends readonly unknown[] ? TAbi[number] extends {
42
97
  name: TFunctionName;
@@ -49,7 +104,16 @@ export type ContractMethodParams<TAbi extends Abi, TFunctionName extends string>
49
104
  } ? TName extends string ? TType extends "address" ? Address : TType extends "uint256" ? bigint : TType extends "string" ? string : TType extends "bool" ? boolean : TType extends "bytes32" ? Hash : unknown : never : never;
50
105
  } : never : never : never;
51
106
  /**
52
- * Contract method return type for typed interactions
107
+ * Extracts typed return values for a contract method from its ABI.
108
+ *
109
+ * @remarks
110
+ * Advanced utility type that provides type-safe return type extraction
111
+ * from contract ABIs. Handles single values and tuples appropriately.
112
+ *
113
+ * @typeParam TAbi - The contract's ABI type
114
+ * @typeParam TFunctionName - The name of the function to extract return type for
115
+ *
116
+ * @internal
53
117
  */
54
118
  export type ContractMethodReturnType<TAbi extends Abi, TFunctionName extends string> = TAbi extends readonly unknown[] ? TAbi[number] extends {
55
119
  name: TFunctionName;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/controller-context.ts"],"sourcesContent":["/**\n * Shared type definitions for controller contexts.\n *\n * @remarks\n * These types ensure consistency across all controllers and prevent drift.\n * Single source of truth following Rich Hickey's principles.\n */\n\nimport type { WalletClient, PublicClient, Address } from \"viem\";\nimport type { VanaPlatformAdapter } from \"../platform/interface\";\nimport type { StorageManager } from \"../storage\";\nimport type { DownloadRelayerCallbacks } from \"./config\";\nimport type { UnifiedRelayerRequest, UnifiedRelayerResponse } from \"./relayer\";\nimport type {\n TransactionResult,\n TransactionWaitOptions,\n Operation,\n PollingOptions,\n} from \"./operations\";\nimport type {\n Contract,\n Fn,\n TypedTransactionResult,\n} from \"../generated/event-types\";\n\n/**\n * Type definition for waitForTransactionEvents function.\n *\n * @remarks\n * This is THE single definition used everywhere to prevent drift.\n * If you need to change the signature, change it here.\n */\nexport type WaitForTransactionEventsFn = <C extends Contract, F extends Fn<C>>(\n transaction: TransactionResult<C, F>,\n options?: TransactionWaitOptions,\n) => Promise<TypedTransactionResult<C, F>>;\n\n/**\n * Type definition for waitForOperation function.\n */\nexport type WaitForOperationFn = <T = unknown>(\n opOrId: Operation<T> | string,\n options?: PollingOptions,\n) => Promise<Operation<T>>;\n\n/**\n * Shared controller context interface.\n *\n * @remarks\n * This is the contract that all controllers depend on.\n * Changing this interface is a breaking change.\n */\nexport interface ControllerContext {\n /** Signs transactions and messages using the user's private key. Optional to support read-only mode. */\n walletClient?: WalletClient;\n /** Queries blockchain state and smart contracts without signing. */\n publicClient: PublicClient;\n /** Address of the user for operations requiring user identification in read-only mode. */\n userAddress: Address;\n /** Signs application-specific operations when different from primary wallet. */\n applicationClient?: WalletClient;\n /** Handles gasless transaction submission through relayer services. */\n relayer?: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;\n /** Proxies CORS-restricted downloads through application server. */\n downloadRelayer?: DownloadRelayerCallbacks;\n /** Manages file upload and download operations across storage providers. */\n storageManager?: StorageManager;\n /** Provides subgraph endpoint for querying indexed blockchain data. */\n subgraphUrl?: string;\n /** Adapts SDK functionality to the current runtime environment. */\n platform: VanaPlatformAdapter;\n /** Validates that storage is available for storage-dependent operations. */\n validateStorageRequired?: () => void;\n /** Checks whether storage is configured without throwing an error. */\n hasStorage?: () => boolean;\n /** Default IPFS gateways to use for fetching files. */\n ipfsGateways?: string[];\n /** Default personal server base URL for server operations. */\n defaultPersonalServerUrl?: string;\n /** Waits for transaction confirmation and parses typed events. */\n waitForTransactionEvents?: WaitForTransactionEventsFn;\n /** Waits for an operation to complete with polling. */\n waitForOperation?: WaitForOperationFn;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/controller-context.ts"],"sourcesContent":["/**\n * Shared type definitions for controller contexts.\n *\n * @remarks\n * These types ensure consistency across all controllers and prevent drift.\n * Single source of truth following Rich Hickey's principles.\n */\n\nimport type { WalletClient, PublicClient, Address } from \"viem\";\nimport type { VanaPlatformAdapter } from \"../platform/interface\";\nimport type { StorageManager } from \"../storage\";\nimport type { DownloadRelayerCallbacks } from \"./config\";\nimport type { UnifiedRelayerRequest, UnifiedRelayerResponse } from \"./relayer\";\nimport type {\n TransactionResult,\n TransactionWaitOptions,\n Operation,\n PollingOptions,\n IOperationStore,\n} from \"./operations\";\nimport type {\n Contract,\n Fn,\n TypedTransactionResult,\n} from \"../generated/event-types\";\n\n/**\n * Type definition for waitForTransactionEvents function.\n *\n * @remarks\n * This is THE single definition used everywhere to prevent drift.\n * If you need to change the signature, change it here.\n */\nexport type WaitForTransactionEventsFn = <C extends Contract, F extends Fn<C>>(\n transaction: TransactionResult<C, F>,\n options?: TransactionWaitOptions,\n) => Promise<TypedTransactionResult<C, F>>;\n\n/**\n * Type definition for waitForOperation function.\n */\nexport type WaitForOperationFn = <T = unknown>(\n opOrId: Operation<T> | string,\n options?: PollingOptions,\n) => Promise<Operation<T>>;\n\n/**\n * Shared controller context interface.\n *\n * @remarks\n * This is the contract that all controllers depend on.\n * Changing this interface is a breaking change.\n */\nexport interface ControllerContext {\n /** Signs transactions and messages using the user's private key. Optional to support read-only mode. */\n walletClient?: WalletClient;\n /** Queries blockchain state and smart contracts without signing. */\n publicClient: PublicClient;\n /** Address of the user for operations requiring user identification in read-only mode. */\n userAddress: Address;\n /** Signs application-specific operations when different from primary wallet. */\n applicationClient?: WalletClient;\n /** Handles gasless transaction submission through relayer services. */\n relayer?: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;\n /** Proxies CORS-restricted downloads through application server. */\n downloadRelayer?: DownloadRelayerCallbacks;\n /** Manages file upload and download operations across storage providers. */\n storageManager?: StorageManager;\n /** Provides subgraph endpoint for querying indexed blockchain data. */\n subgraphUrl?: string;\n /** Adapts SDK functionality to the current runtime environment. */\n platform: VanaPlatformAdapter;\n /** Validates that storage is available for storage-dependent operations. */\n validateStorageRequired?: () => void;\n /** Checks whether storage is configured without throwing an error. */\n hasStorage?: () => boolean;\n /** Default IPFS gateways to use for fetching files. */\n ipfsGateways?: string[];\n /** Default personal server base URL for server operations. */\n defaultPersonalServerUrl?: string;\n /** Waits for transaction confirmation and parses typed events. */\n waitForTransactionEvents?: WaitForTransactionEventsFn;\n /** Waits for an operation to complete with polling. */\n waitForOperation?: WaitForOperationFn;\n /** Tracks async relayed transactions for resilient management. */\n operationStore?: IOperationStore;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -10,7 +10,7 @@ import type { VanaPlatformAdapter } from "../platform/interface";
10
10
  import type { StorageManager } from "../storage";
11
11
  import type { DownloadRelayerCallbacks } from "./config";
12
12
  import type { UnifiedRelayerRequest, UnifiedRelayerResponse } from "./relayer";
13
- import type { TransactionResult, TransactionWaitOptions, Operation, PollingOptions } from "./operations";
13
+ import type { TransactionResult, TransactionWaitOptions, Operation, PollingOptions, IOperationStore } from "./operations";
14
14
  import type { Contract, Fn, TypedTransactionResult } from "../generated/event-types";
15
15
  /**
16
16
  * Type definition for waitForTransactionEvents function.
@@ -62,4 +62,6 @@ export interface ControllerContext {
62
62
  waitForTransactionEvents?: WaitForTransactionEventsFn;
63
63
  /** Waits for an operation to complete with polling. */
64
64
  waitForOperation?: WaitForOperationFn;
65
+ /** Tracks async relayed transactions for resilient management. */
66
+ operationStore?: IOperationStore;
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/data.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Represents a registered data file in the Vana network with complete blockchain metadata.\n *\n * @remarks\n * This interface describes files that have been uploaded to storage and registered\n * on the Vana blockchain, including their storage location, ownership, and blockchain\n * tracking information. Each file receives a unique ID and is linked to the owner's\n * address for permission management. Used throughout the SDK for file operations\n * and access control workflows.\n *\n * @category Data Management\n */\nexport interface UserFile {\n /** Unique identifier assigned by the Data Registry contract. */\n id: number;\n /** Storage URL where the encrypted file content is hosted. */\n url: string;\n /** Wallet address of the user who owns this file. */\n ownerAddress: Address;\n /** Block number when this file was registered on-chain. */\n addedAtBlock: bigint;\n /**\n * Schema identifier for data validation and structure definition.\n * Obtain schema IDs from `vana.schemas.list()` or when creating schemas via `vana.schemas.create()`.\n */\n schemaId?: number;\n /** Unix timestamp when the file was registered on-chain. */\n addedAtTimestamp?: bigint;\n /** Transaction hash of the on-chain file registration. */\n transactionHash?: Address;\n /** Additional file properties and custom application data. */\n metadata?: FileMetadata;\n /**\n * Array of DLP IDs that have submitted proofs for this file.\n * Each proof represents verification or processing by a Data Liquidity Pool.\n * Obtain DLP details via `vana.data.getDLP(dlpId)`.\n */\n dlpIds?: number[];\n}\n\n/**\n * Provides optional metadata for uploaded files and content description.\n *\n * @remarks\n * This interface contains descriptive information about uploaded files, including\n * file properties and custom application-specific data that can be used for\n * organization, validation, and display purposes.\n * @category Data Management\n */\nexport interface FileMetadata {\n /** Original filename as provided by the user or application. */\n name?: string;\n /** Total file size in bytes for storage tracking. */\n size?: number;\n /** MIME type identifier for content type recognition. */\n mimeType?: string;\n /** Hash value for file integrity verification. */\n checksum?: string;\n /** ISO 8601 timestamp when the file was uploaded. */\n uploadedAt?: string;\n /** Application-specific metadata for custom use cases. */\n custom?: Record<string, unknown>;\n}\n\n/**\n * High-level parameters for uploading user data with automatic encryption and blockchain registration.\n *\n * @remarks\n * This is the primary interface for uploading user data through the simplified `vana.data.upload()` method.\n * It handles the complete workflow including encryption, storage, and blockchain registration.\n *\n * When using permissions with encryption enabled (default), you must provide the public key\n * for each permission recipient.\n *\n * @example\n * ```typescript\n * // Basic file upload\n * const result = await vana.data.upload({\n * content: \"My personal data\",\n * filename: \"diary.txt\"\n * });\n *\n * // Upload with schema validation\n * const result = await vana.data.upload({\n * content: { name: \"John\", age: 30 },\n * filename: \"profile.json\",\n * schemaId: 1\n * });\n *\n * // Upload with permissions for an app (encrypted - requires publicKey)\n * const result = await vana.data.upload({\n * content: \"Data for AI analysis\",\n * filename: \"analysis.txt\",\n * permissions: [{\n * grantee: \"0x1234...\",\n * operation: \"llm_inference\",\n * parameters: { model: \"gpt-4\" },\n * publicKey: \"0x04...\" // Required when encrypt is true (default)\n * }]\n * });\n *\n * // Upload without encryption (publicKey optional)\n * const result = await vana.data.upload({\n * content: \"Public data\",\n * filename: \"public.txt\",\n * encrypt: false,\n * permissions: [{\n * grantee: \"0x1234...\",\n * operation: \"read\",\n * parameters: {}\n * }]\n * });\n * ```\n * @category Data Management\n */\nexport interface UploadParams {\n /** Raw file data as string, Blob, or Buffer. */\n content: string | Blob | Buffer;\n /** Optional filename for the uploaded file. */\n filename?: string;\n /** Optional schema ID for data validation. */\n schemaId?: number;\n /** Optional file permissions to grant decryption access during upload. */\n permissions?: FilePermissionParams[];\n /** Whether to encrypt the data (defaults to true). */\n encrypt?: boolean;\n /** Optional storage provider name. */\n providerName?: string;\n /** Optional owner address (defaults to current wallet address). */\n owner?: Address;\n}\n\n/**\n * Upload parameters with encryption enabled.\n *\n * @remarks\n * This interface ensures type safety when using encrypted uploads with permissions.\n * When encrypt is true, any permissions must include public keys for encryption.\n * @category Data Management\n */\nexport interface EncryptedUploadParams\n extends Omit<UploadParams, \"permissions\" | \"encrypt\"> {\n /** File permissions with required public keys for encrypted data sharing. */\n permissions?: FilePermissionParams[];\n /** Encryption is enabled. */\n encrypt: true;\n}\n\n/**\n * Upload parameters with encryption disabled.\n *\n * @remarks\n * This interface is used when uploading unencrypted data.\n * @category Data Management\n */\nexport interface UnencryptedUploadParams extends Omit<UploadParams, \"encrypt\"> {\n /** Encryption is disabled. */\n encrypt: false;\n}\n\n/**\n * Parameters for granting file decryption access during upload.\n *\n * @remarks\n * This interface is used to grant decryption access to specific accounts when uploading\n * encrypted files. It only handles encryption key sharing, not operation permissions.\n *\n * For granting operation permissions (like \"llm_inference\"), use the separate\n * `vana.permissions.grant()` method after uploading.\n *\n * @example\n * ```typescript\n * // Upload with decryption permission\n * const result = await vana.data.upload({\n * content: \"data\",\n * permissions: [{\n * account: \"0xServerAddress...\",\n * publicKey: \"0x04...\" // Server's public key\n * }]\n * });\n * ```\n * @category Data Management\n */\nexport interface FilePermissionParams {\n /** The account address that will be able to decrypt this file. */\n account: Address;\n /** The public key to encrypt the file's encryption key with. */\n publicKey: string;\n}\n\n/**\n * Permission parameters for granting data access.\n *\n * @remarks\n * This interface defines parameters for granting permissions to access data.\n * It's used in the permissions system but kept here for compatibility.\n *\n * @category Data Management\n */\nexport interface PermissionParams {\n /** The address of the application to grant permission to. */\n grantee: Address;\n /** The operation type (e.g., \"llm_inference\", \"data_analysis\", \"compute_task\"). */\n operation: string;\n /** Additional parameters for the permission (operation-specific configuration). */\n parameters: Record<string, unknown>;\n /** Optional nonce for the permission (auto-generated if not provided). */\n nonce?: bigint;\n /** Optional expiration timestamp (Unix seconds, no expiration if not provided). */\n expiresAt?: number;\n /**\n * Public key of the recipient to encrypt the data key for (required for upload with permissions).\n * Obtain via `vana.server.getIdentity(recipientAddress).public_key` for personal servers.\n */\n publicKey?: string;\n}\n\n/**\n * Legacy permission parameters that conflated file encryption and data access grants.\n *\n * @remarks\n * This interface was removed because it conflated two different concepts:\n * 1. File encryption permissions (handled during upload)\n * 2. Data access grants (operation permissions)\n *\n * For file uploads, use FilePermissionParams instead.\n * For data access grants, use vana.permissions.grant() after uploading.\n *\n * @deprecated Removed in v2.0.0. Use FilePermissionParams for uploads.\n * @category Data Management\n */\nexport interface LegacyPermissionParams {\n grantee: Address;\n operation: string;\n parameters: Record<string, unknown>;\n nonce?: bigint;\n expiresAt?: number;\n publicKey?: string;\n}\n\n/**\n * Result of the high-level upload operation.\n *\n * @remarks\n * Returned by the `vana.data.upload()` method after successful upload and blockchain registration.\n * @category Data Management\n */\nexport interface UploadResult {\n /** The file ID assigned by the DataRegistry contract. */\n fileId: number;\n /** The storage URL where the file is hosted. */\n url: string;\n /** The transaction hash of the blockchain registration. */\n transactionHash: Hash;\n /** The actual file size in bytes. */\n size: number;\n /** Whether the data passed schema validation (if applicable). */\n isValid?: boolean;\n /** Validation errors if schema validation failed. */\n validationErrors?: string[];\n /** Permission IDs if permissions were granted during upload. */\n permissionIds?: bigint[];\n}\n\n/**\n * Defines parameters for uploading files to storage providers with encryption options.\n *\n * @remarks\n * Used with DataController upload methods and storage operations. Supports multiple\n * content formats, optional encryption, and custom storage provider selection with\n * comprehensive metadata tracking.\n * @deprecated Use UploadParams with vana.data.upload() instead for the high-level API\n * @example\n * ```typescript\n * const uploadParams: UploadFileParams = {\n * content: new TextEncoder().encode(JSON.stringify(userData)),\n * metadata: {\n * name: \"personal-profile.json\",\n * mimeType: \"application/json\",\n * size: 2048,\n * },\n * storageProvider: \"ipfs\",\n * encrypt: true,\n * };\n *\n * const result = await vana.data.uploadFile(uploadParams);\n * ```\n * @category Data Management\n */\nexport interface UploadFileParams {\n /** Raw file data in bytes, buffer, or string format. */\n content: Uint8Array | Buffer | string;\n /** Descriptive metadata for file organization and tracking. */\n metadata?: FileMetadata;\n /** Storage provider name (\"ipfs\" or custom provider, uses configured default if unspecified). */\n storageProvider?: string;\n /** Enables automatic encryption before upload to storage (defaults to false). */\n encrypt?: boolean;\n /** Custom encryption key (auto-generated if encryption enabled and not provided). */\n encryptionKey?: string;\n}\n\n/**\n * Contains the result of a successful file upload operation.\n *\n * @remarks\n * This interface provides the essential information returned after uploading\n * a file to a storage provider, including access URL, size verification,\n * and encryption details when applicable.\n * @category Data Management\n */\nexport interface UploadFileResult {\n /** Public URL where the uploaded file can be accessed. */\n url: string;\n /** Actual file size in bytes after upload processing. */\n size: number;\n /** Hash value for verifying file integrity after upload. */\n checksum?: string;\n /** Encryption metadata when file was encrypted before storage. */\n encryption?: EncryptionInfo;\n}\n\n/**\n * Result of uploading an encrypted file to storage and blockchain\n *\n * @category Data Management\n */\nexport interface UploadEncryptedFileResult extends UploadFileResult {\n /** The new file ID assigned by the DataRegistry */\n fileId: number;\n /** Transaction hash of the file registration */\n transactionHash?: Hash;\n}\n\n/**\n * Encryption information for a file\n *\n * @category Data Management\n */\nexport interface EncryptionInfo {\n /** Encryption algorithm used */\n algorithm: string;\n /** Key derivation function */\n kdf?: string;\n /** Initialization vector */\n iv?: string;\n /** Salt used for key derivation */\n salt?: string;\n /** Key identifier */\n keyId?: string;\n}\n\n/**\n * Parameters for getting user files\n *\n * @category Data Management\n */\nexport interface GetUserFilesParams {\n /** Owner address to filter by */\n owner?: Address;\n /** Starting block number for filtering */\n fromBlock?: bigint;\n /** Ending block number for filtering */\n toBlock?: bigint;\n /** Maximum number of files to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\n/**\n * Parameters for getting a specific file\n *\n * @category Data Management\n */\nexport interface GetFileParams {\n /** File ID to retrieve */\n fileId: number;\n /** Whether to include metadata */\n includeMetadata?: boolean;\n}\n\n/**\n * Parameters for downloading a file\n *\n * @category Data Management\n */\nexport interface DownloadFileParams {\n /** File URL or ID to download */\n file: string | number;\n /** Storage provider to use */\n storageProvider?: string;\n /** Decryption key if file is encrypted */\n decryptionKey?: string;\n}\n\n/**\n * Result of downloading a file\n *\n * @category Data Management\n */\nexport interface DownloadFileResult {\n /** File content */\n content: Uint8Array;\n /** File metadata */\n metadata?: FileMetadata;\n /** Whether the file was encrypted */\n wasEncrypted?: boolean;\n}\n\n/**\n * Parameters for deleting a file\n *\n * @category Data Management\n */\nexport interface DeleteFileParams {\n /** File ID to delete */\n fileId: number;\n /** Whether to also delete from storage */\n deleteFromStorage?: boolean;\n /** Storage provider to delete from */\n storageProvider?: string;\n}\n\n/**\n * Result of deleting a file\n *\n * @category Data Management\n */\nexport interface DeleteFileResult {\n /** Whether the file was successfully deleted from the registry */\n registryDeleted: boolean;\n /** Whether the file was successfully deleted from storage */\n storageDeleted?: boolean;\n /** Transaction hash of the deletion */\n transactionHash?: Hash;\n}\n\n/**\n * Options for encrypting a file\n *\n * @category Data Management\n */\nexport interface EncryptFileOptions {\n /** Encryption seed for key derivation. Defaults to DEFAULT_ENCRYPTION_SEED */\n seed?: string;\n /** MIME type for the encrypted blob if input is not already a Blob */\n mimeType?: string;\n}\n\n/**\n * Result of encrypting a file\n *\n * @category Data Management\n */\nexport interface EncryptFileResult {\n /** The encrypted data as a Blob */\n encryptedData: Blob;\n /** The encryption key used (derived from wallet) */\n encryptionKey: string;\n}\n\n/**\n * Options for decrypting a file\n *\n * @category Data Management\n */\nexport interface DecryptFileOptions {\n /** Encryption seed for key derivation. Defaults to DEFAULT_ENCRYPTION_SEED */\n seed?: string;\n}\n\n/**\n * Parameters for uploading a file with permissions\n *\n * @category Data Management\n */\nexport interface UploadFileWithPermissionsParams {\n /** The file data to encrypt and upload */\n data: Blob;\n /** Array of permissions to grant, each with account address and public key */\n permissions: Array<{ account: Address; publicKey: string }>;\n /** Optional filename for the upload */\n filename?: string;\n /** Optional storage provider to use */\n providerName?: string;\n}\n\n/**\n * Parameters for adding permission to a file\n *\n * @category Data Management\n */\nexport interface AddFilePermissionParams {\n /** The file ID to grant permission for */\n fileId: number;\n /** The account to grant permission to */\n account: Address;\n /** The public key of the account for encryption */\n publicKey: string;\n}\n\n/**\n * Options for decrypting a file with permission\n *\n * @category Data Management\n */\nexport interface DecryptFileWithPermissionOptions {\n /** Optional account address to verify permission against */\n account?: Address;\n}\n\n/**\n * File access permissions\n *\n * @category Data Management\n */\nexport interface FileAccessPermissions {\n /** Whether the file can be read */\n read: boolean;\n /** Whether the file can be written */\n write: boolean;\n /** Whether the file can be deleted */\n delete: boolean;\n /** Whether the file can be shared */\n share: boolean;\n}\n\n/**\n * File sharing configuration\n *\n * @category Data Management\n */\nexport interface FileSharingConfig {\n /** Addresses that can access the file */\n allowedAddresses?: Address[];\n /** Expiration time for shared access */\n expiresAt?: Date;\n /** Required permissions for shared access */\n permissions: FileAccessPermissions;\n}\n\n/**\n * Batch upload parameters\n *\n * @category Data Management\n */\nexport interface BatchUploadParams {\n /** Array of files to upload */\n files: UploadFileParams[];\n /** Storage provider to use for all files */\n storageProvider?: string;\n /** Whether to encrypt all files */\n encrypt?: boolean;\n /** Encryption key for all files */\n encryptionKey?: string;\n}\n\n/**\n * Batch upload result\n *\n * @category Data Management\n */\nexport interface BatchUploadResult {\n /** Results for each uploaded file */\n results: UploadEncryptedFileResult[];\n /** Overall success status */\n success: boolean;\n /** Any errors that occurred */\n errors?: string[];\n}\n\n/**\n * Schema metadata from the blockchain (without fetched definition).\n *\n * This represents the on-chain schema registration data before the\n * definition has been fetched from the storage URL.\n *\n * @category Data Management\n */\nexport interface SchemaMetadata {\n /** Schema ID */\n id: number;\n /** Schema name */\n name: string;\n /** Schema dialect ('json' or 'sqlite') */\n dialect: \"json\" | \"sqlite\";\n /** URL containing the schema definition */\n definitionUrl: string;\n}\n\n/**\n * Complete schema with all definition fields populated.\n * This is what schemas.get() returns - a schema with the definition fetched.\n */\nexport interface CompleteSchema extends SchemaMetadata {\n /** Version of the schema */\n version: string;\n /** Optional description of the schema */\n description?: string;\n /** Optional version of the dialect */\n dialectVersion?: string;\n /** The actual schema - JSON Schema object for 'json' dialect, DDL string for 'sqlite' */\n schema: object | string;\n}\n\n/**\n * Schema with optional definition fields.\n *\n * Schemas define the structure and validation rules for user data processed by refiners.\n * They ensure data quality and consistency across the Vana network by specifying how\n * raw user data should be formatted, validated, and processed.\n *\n * When the definition has been fetched (via schemas.get() or schemas.list() with includeDefinitions),\n * the version and schema fields will be populated. Otherwise, only the metadata fields are present.\n *\n * @category Data Management\n * @example\n * ```typescript\n * // Complete schema from schemas.get()\n * const completeSchema: Schema = {\n * id: 5,\n * name: 'Social Media Profile',\n * dialect: 'json',\n * definitionUrl: 'ipfs://QmSchema...',\n * version: '1.0.0',\n * description: 'Schema for validating social media profile data',\n * schema: { // JSON Schema object\n * type: 'object',\n * properties: {\n * username: { type: 'string' }\n * }\n * }\n * };\n *\n * // Metadata-only schema from schemas.list() without includeDefinitions\n * const metadataSchema: Schema = {\n * id: 5,\n * name: 'Social Media Profile',\n * dialect: 'json',\n * definitionUrl: 'ipfs://QmSchema...'\n * };\n * ```\n */\nexport interface Schema extends SchemaMetadata {\n /** Version of the schema (present when definition is fetched) */\n version?: string;\n /** Optional description of the schema */\n description?: string;\n /** Optional version of the dialect */\n dialectVersion?: string;\n /** The actual schema - JSON Schema object for 'json' dialect, DDL string for 'sqlite' (present when definition is fetched) */\n schema?: object | string;\n}\n\n/**\n * Represents a refiner with schema information\n *\n * @category Data Management\n */\nexport interface Refiner {\n /** Refiner ID */\n id: number;\n /** DLP ID this refiner belongs to */\n dlpId: number;\n /** Owner address */\n owner: Address;\n /** Refiner name */\n name: string;\n /** Schema ID associated with this refiner */\n schemaId: number;\n /** URL containing refinement instructions */\n refinementInstructionUrl: string;\n}\n\n/**\n * Parameters for adding a new schema\n *\n * @category Data Management\n */\nexport interface AddSchemaParams {\n /** Schema name */\n name: string;\n /** Schema dialect */\n dialect: string;\n /** URL containing the schema definition */\n definitionUrl: string;\n}\n\n/**\n * Result of adding a schema\n *\n * @category Data Management\n */\nexport interface AddSchemaResult {\n /** The new schema ID assigned by the contract */\n schemaId: number;\n /** Transaction hash of the schema registration */\n transactionHash: Hash;\n}\n\n/**\n * Parameters for registering a new data refiner in the Vana network.\n *\n * Refiners are processors that transform and validate user data according to specific\n * schemas and instructions. They enable applications to work with structured, verified\n * user data while maintaining privacy and user control.\n *\n * @category Data Management\n * @example\n * ```typescript\n * const refinerParams: AddRefinerParams = {\n * dlpId: 1, // Data Liquidity Pool ID\n * name: 'Social Media Refiner',\n * schemaId: 5, // Pre-defined schema for social media data\n * refinementInstructionUrl: 'ipfs://Qm...' // Instructions for data processing\n * };\n * ```\n */\nexport interface AddRefinerParams {\n /** DLP ID this refiner belongs to */\n dlpId: number;\n /** Refiner name */\n name: string;\n /** Schema ID to associate with this refiner */\n schemaId: number;\n /** URL containing refinement instructions */\n refinementInstructionUrl: string;\n}\n\n/**\n * Result of adding a refiner\n *\n * @category Data Management\n */\nexport interface AddRefinerResult {\n /** The new refiner ID assigned by the contract */\n refinerId: number;\n /** Transaction hash of the refiner registration */\n transactionHash: Hash;\n}\n\n/**\n * Parameters for updating a refiner's schema ID\n *\n * @category Data Management\n */\nexport interface UpdateSchemaIdParams {\n /** Refiner ID to update */\n refinerId: number;\n /** New schema ID to associate with the refiner */\n newSchemaId: number;\n}\n\n/**\n * Result of updating a refiner's schema ID\n *\n * @category Data Management\n */\nexport interface UpdateSchemaIdResult {\n /** Transaction hash of the update */\n transactionHash: Hash;\n}\n\n/**\n * Trusted server data structure\n *\n * @category Data Management\n */\nexport interface TrustedServer {\n /** Unique identifier for the trusted server relationship */\n id: string;\n /** Server address (EVM address) */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Timestamp when server was trusted */\n trustedAt: bigint;\n /** User who trusted the server */\n user: Address;\n /** Index in user's trusted server list (only available in RPC mode) */\n trustIndex?: number;\n}\n\n/**\n * Parameters for getUserTrustedServers method\n *\n * @category Data Management\n */\nexport interface GetUserTrustedServersParams {\n /** User address to query trusted servers for */\n user: Address;\n /** Optional subgraph URL to override default */\n subgraphUrl?: string;\n /** Maximum number of results */\n limit?: number;\n /** Number of results to skip */\n offset?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/data.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Represents a file registered on the Vana blockchain.\n *\n * @remarks\n * Contains complete metadata for files uploaded to storage and registered\n * on-chain. Each file has a unique ID, owner address, and storage URL.\n * Used throughout SDK for file operations and permission management.\n *\n * @category Data Management\n */\nexport interface UserFile {\n /** Unique identifier assigned by the Data Registry contract. */\n id: number;\n /** Storage URL where the encrypted file content is hosted. */\n url: string;\n /** Wallet address of the user who owns this file. */\n ownerAddress: Address;\n /** Block number when this file was registered on-chain. */\n addedAtBlock: bigint;\n /**\n * Schema identifier for data validation and structure definition.\n * Obtain schema IDs from `vana.schemas.list()` or when creating schemas via `vana.schemas.create()`.\n */\n schemaId?: number;\n /** Unix timestamp when the file was registered on-chain. */\n addedAtTimestamp?: bigint;\n /** Transaction hash of the on-chain file registration. */\n transactionHash?: Address;\n /** Additional file properties and custom application data. */\n metadata?: FileMetadata;\n /**\n * Array of DLP IDs that have submitted proofs for this file.\n * Each proof represents verification or processing by a Data Liquidity Pool.\n * Obtain DLP details via `vana.data.getDLP(dlpId)`.\n */\n dlpIds?: number[];\n}\n\n/**\n * Provides optional metadata for uploaded files and content description.\n *\n * @remarks\n * This interface contains descriptive information about uploaded files, including\n * file properties and custom application-specific data that can be used for\n * organization, validation, and display purposes.\n * @category Data Management\n */\nexport interface FileMetadata {\n /** Original filename as provided by the user or application. */\n name?: string;\n /** Total file size in bytes for storage tracking. */\n size?: number;\n /** MIME type identifier for content type recognition. */\n mimeType?: string;\n /** Hash value for file integrity verification. */\n checksum?: string;\n /** ISO 8601 timestamp when the file was uploaded. */\n uploadedAt?: string;\n /** Application-specific metadata for custom use cases. */\n custom?: Record<string, unknown>;\n}\n\n/**\n * High-level parameters for uploading user data with automatic encryption and blockchain registration.\n *\n * @remarks\n * This is the primary interface for uploading user data through the simplified `vana.data.upload()` method.\n * It handles the complete workflow including encryption, storage, and blockchain registration.\n *\n * When using permissions with encryption enabled (default), you must provide the public key\n * for each permission recipient.\n *\n * @example\n * ```typescript\n * // Basic file upload\n * const result = await vana.data.upload({\n * content: \"My personal data\",\n * filename: \"diary.txt\"\n * });\n *\n * // Upload with schema validation\n * const result = await vana.data.upload({\n * content: { name: \"John\", age: 30 },\n * filename: \"profile.json\",\n * schemaId: 1\n * });\n *\n * // Upload with permissions for an app (encrypted - requires publicKey)\n * const result = await vana.data.upload({\n * content: \"Data for AI analysis\",\n * filename: \"analysis.txt\",\n * permissions: [{\n * grantee: \"0x1234...\",\n * operation: \"llm_inference\",\n * parameters: { model: \"gpt-4\" },\n * publicKey: \"0x04...\" // Required when encrypt is true (default)\n * }]\n * });\n *\n * // Upload without encryption (publicKey optional)\n * const result = await vana.data.upload({\n * content: \"Public data\",\n * filename: \"public.txt\",\n * encrypt: false,\n * permissions: [{\n * grantee: \"0x1234...\",\n * operation: \"read\",\n * parameters: {}\n * }]\n * });\n * ```\n * @category Data Management\n */\nexport interface UploadParams {\n /** Raw file data as string, Blob, or Buffer. */\n content: string | Blob | Buffer;\n /** Optional filename for the uploaded file. */\n filename?: string;\n /** Optional schema ID for data validation. */\n schemaId?: number;\n /** Optional file permissions to grant decryption access during upload. */\n permissions?: FilePermissionParams[];\n /** Whether to encrypt the data (defaults to true). */\n encrypt?: boolean;\n /** Optional storage provider name. */\n providerName?: string;\n /** Optional owner address (defaults to current wallet address). */\n owner?: Address;\n}\n\n/**\n * Upload parameters with encryption enabled.\n *\n * @remarks\n * This interface ensures type safety when using encrypted uploads with permissions.\n * When encrypt is true, any permissions must include public keys for encryption.\n * @category Data Management\n */\nexport interface EncryptedUploadParams\n extends Omit<UploadParams, \"permissions\" | \"encrypt\"> {\n /** File permissions with required public keys for encrypted data sharing. */\n permissions?: FilePermissionParams[];\n /** Encryption is enabled. */\n encrypt: true;\n}\n\n/**\n * Upload parameters with encryption disabled.\n *\n * @remarks\n * This interface is used when uploading unencrypted data.\n * @category Data Management\n */\nexport interface UnencryptedUploadParams extends Omit<UploadParams, \"encrypt\"> {\n /** Encryption is disabled. */\n encrypt: false;\n}\n\n/**\n * Parameters for granting file decryption access during upload.\n *\n * @remarks\n * This interface is used to grant decryption access to specific accounts when uploading\n * encrypted files. It only handles encryption key sharing, not operation permissions.\n *\n * For granting operation permissions (like \"llm_inference\"), use the separate\n * `vana.permissions.grant()` method after uploading.\n *\n * @example\n * ```typescript\n * // Upload with decryption permission\n * const result = await vana.data.upload({\n * content: \"data\",\n * permissions: [{\n * account: \"0xServerAddress...\",\n * publicKey: \"0x04...\" // Server's public key\n * }]\n * });\n * ```\n * @category Data Management\n */\nexport interface FilePermissionParams {\n /** The account address that will be able to decrypt this file. */\n account: Address;\n /** The public key to encrypt the file's encryption key with. */\n publicKey: string;\n}\n\n/**\n * Permission parameters for granting data access.\n *\n * @remarks\n * This interface defines parameters for granting permissions to access data.\n * It's used in the permissions system but kept here for compatibility.\n *\n * @category Data Management\n */\nexport interface PermissionParams {\n /** The address of the application to grant permission to. */\n grantee: Address;\n /** The operation type (e.g., \"llm_inference\", \"data_analysis\", \"compute_task\"). */\n operation: string;\n /** Additional parameters for the permission (operation-specific configuration). */\n parameters: Record<string, unknown>;\n /** Optional nonce for the permission (auto-generated if not provided). */\n nonce?: bigint;\n /** Optional expiration timestamp (Unix seconds, no expiration if not provided). */\n expiresAt?: number;\n /**\n * Public key of the recipient to encrypt the data key for (required for upload with permissions).\n * Obtain via `vana.server.getIdentity(recipientAddress).public_key` for personal servers.\n */\n publicKey?: string;\n}\n\n/**\n * Legacy permission parameters that conflated file encryption and data access grants.\n *\n * @remarks\n * This interface was removed because it conflated two different concepts:\n * 1. File encryption permissions (handled during upload)\n * 2. Data access grants (operation permissions)\n *\n * For file uploads, use FilePermissionParams instead.\n * For data access grants, use vana.permissions.grant() after uploading.\n *\n * @deprecated Removed in v2.0.0. Use FilePermissionParams for uploads.\n * @category Data Management\n */\nexport interface LegacyPermissionParams {\n grantee: Address;\n operation: string;\n parameters: Record<string, unknown>;\n nonce?: bigint;\n expiresAt?: number;\n publicKey?: string;\n}\n\n/**\n * Result of the high-level upload operation.\n *\n * @remarks\n * Returned by the `vana.data.upload()` method after successful upload and blockchain registration.\n * @category Data Management\n */\nexport interface UploadResult {\n /** The file ID assigned by the DataRegistry contract. */\n fileId: number;\n /** The storage URL where the file is hosted. */\n url: string;\n /** The transaction hash of the blockchain registration. */\n transactionHash: Hash;\n /** The actual file size in bytes. */\n size: number;\n /** Whether the data passed schema validation (if applicable). */\n isValid?: boolean;\n /** Validation errors if schema validation failed. */\n validationErrors?: string[];\n /** Permission IDs if permissions were granted during upload. */\n permissionIds?: bigint[];\n}\n\n/**\n * Defines parameters for uploading files to storage providers with encryption options.\n *\n * @remarks\n * Used with DataController upload methods and storage operations. Supports multiple\n * content formats, optional encryption, and custom storage provider selection with\n * comprehensive metadata tracking.\n * @deprecated Use UploadParams with vana.data.upload() instead for the high-level API\n * @example\n * ```typescript\n * const uploadParams: UploadFileParams = {\n * content: new TextEncoder().encode(JSON.stringify(userData)),\n * metadata: {\n * name: \"personal-profile.json\",\n * mimeType: \"application/json\",\n * size: 2048,\n * },\n * storageProvider: \"ipfs\",\n * encrypt: true,\n * };\n *\n * const result = await vana.data.uploadFile(uploadParams);\n * ```\n * @category Data Management\n */\nexport interface UploadFileParams {\n /** Raw file data in bytes, buffer, or string format. */\n content: Uint8Array | Buffer | string;\n /** Descriptive metadata for file organization and tracking. */\n metadata?: FileMetadata;\n /** Storage provider name (\"ipfs\" or custom provider, uses configured default if unspecified). */\n storageProvider?: string;\n /** Enables automatic encryption before upload to storage (defaults to false). */\n encrypt?: boolean;\n /** Custom encryption key (auto-generated if encryption enabled and not provided). */\n encryptionKey?: string;\n}\n\n/**\n * Contains the result of a successful file upload operation.\n *\n * @remarks\n * This interface provides the essential information returned after uploading\n * a file to a storage provider, including access URL, size verification,\n * and encryption details when applicable.\n * @category Data Management\n */\nexport interface UploadFileResult {\n /** Public URL where the uploaded file can be accessed. */\n url: string;\n /** Actual file size in bytes after upload processing. */\n size: number;\n /** Hash value for verifying file integrity after upload. */\n checksum?: string;\n /** Encryption metadata when file was encrypted before storage. */\n encryption?: EncryptionInfo;\n}\n\n/**\n * Result of uploading an encrypted file to storage and blockchain\n *\n * @category Data Management\n */\nexport interface UploadEncryptedFileResult extends UploadFileResult {\n /** The new file ID assigned by the DataRegistry */\n fileId: number;\n /** Transaction hash of the file registration */\n transactionHash?: Hash;\n}\n\n/**\n * Encryption information for a file\n *\n * @category Data Management\n */\nexport interface EncryptionInfo {\n /** Encryption algorithm used */\n algorithm: string;\n /** Key derivation function */\n kdf?: string;\n /** Initialization vector */\n iv?: string;\n /** Salt used for key derivation */\n salt?: string;\n /** Key identifier */\n keyId?: string;\n}\n\n/**\n * Parameters for getting user files\n *\n * @category Data Management\n */\nexport interface GetUserFilesParams {\n /** Owner address to filter by */\n owner?: Address;\n /** Starting block number for filtering */\n fromBlock?: bigint;\n /** Ending block number for filtering */\n toBlock?: bigint;\n /** Maximum number of files to return */\n limit?: number;\n /** Offset for pagination */\n offset?: number;\n}\n\n/**\n * Parameters for getting a specific file\n *\n * @category Data Management\n */\nexport interface GetFileParams {\n /** File ID to retrieve */\n fileId: number;\n /** Whether to include metadata */\n includeMetadata?: boolean;\n}\n\n/**\n * Parameters for downloading a file\n *\n * @category Data Management\n */\nexport interface DownloadFileParams {\n /** File URL or ID to download */\n file: string | number;\n /** Storage provider to use */\n storageProvider?: string;\n /** Decryption key if file is encrypted */\n decryptionKey?: string;\n}\n\n/**\n * Result of downloading a file\n *\n * @category Data Management\n */\nexport interface DownloadFileResult {\n /** File content */\n content: Uint8Array;\n /** File metadata */\n metadata?: FileMetadata;\n /** Whether the file was encrypted */\n wasEncrypted?: boolean;\n}\n\n/**\n * Parameters for deleting a file\n *\n * @category Data Management\n */\nexport interface DeleteFileParams {\n /** File ID to delete */\n fileId: number;\n /** Whether to also delete from storage */\n deleteFromStorage?: boolean;\n /** Storage provider to delete from */\n storageProvider?: string;\n}\n\n/**\n * Result of deleting a file\n *\n * @category Data Management\n */\nexport interface DeleteFileResult {\n /** Whether the file was successfully deleted from the registry */\n registryDeleted: boolean;\n /** Whether the file was successfully deleted from storage */\n storageDeleted?: boolean;\n /** Transaction hash of the deletion */\n transactionHash?: Hash;\n}\n\n/**\n * Options for encrypting a file\n *\n * @category Data Management\n */\nexport interface EncryptFileOptions {\n /** Encryption seed for key derivation. Defaults to DEFAULT_ENCRYPTION_SEED */\n seed?: string;\n /** MIME type for the encrypted blob if input is not already a Blob */\n mimeType?: string;\n}\n\n/**\n * Result of encrypting a file\n *\n * @category Data Management\n */\nexport interface EncryptFileResult {\n /** The encrypted data as a Blob */\n encryptedData: Blob;\n /** The encryption key used (derived from wallet) */\n encryptionKey: string;\n}\n\n/**\n * Options for decrypting a file\n *\n * @category Data Management\n */\nexport interface DecryptFileOptions {\n /** Encryption seed for key derivation. Defaults to DEFAULT_ENCRYPTION_SEED */\n seed?: string;\n}\n\n/**\n * Parameters for uploading a file with permissions\n *\n * @category Data Management\n */\nexport interface UploadFileWithPermissionsParams {\n /** The file data to encrypt and upload */\n data: Blob;\n /** Array of permissions to grant, each with account address and public key */\n permissions: Array<{ account: Address; publicKey: string }>;\n /** Optional filename for the upload */\n filename?: string;\n /** Optional storage provider to use */\n providerName?: string;\n}\n\n/**\n * Parameters for adding permission to a file\n *\n * @category Data Management\n */\nexport interface AddFilePermissionParams {\n /** The file ID to grant permission for */\n fileId: number;\n /** The account to grant permission to */\n account: Address;\n /** The public key of the account for encryption */\n publicKey: string;\n}\n\n/**\n * Options for decrypting a file with permission\n *\n * @category Data Management\n */\nexport interface DecryptFileWithPermissionOptions {\n /** Optional account address to verify permission against */\n account?: Address;\n}\n\n/**\n * File access permissions\n *\n * @category Data Management\n */\nexport interface FileAccessPermissions {\n /** Whether the file can be read */\n read: boolean;\n /** Whether the file can be written */\n write: boolean;\n /** Whether the file can be deleted */\n delete: boolean;\n /** Whether the file can be shared */\n share: boolean;\n}\n\n/**\n * File sharing configuration\n *\n * @category Data Management\n */\nexport interface FileSharingConfig {\n /** Addresses that can access the file */\n allowedAddresses?: Address[];\n /** Expiration time for shared access */\n expiresAt?: Date;\n /** Required permissions for shared access */\n permissions: FileAccessPermissions;\n}\n\n/**\n * Batch upload parameters\n *\n * @category Data Management\n */\nexport interface BatchUploadParams {\n /** Array of files to upload */\n files: UploadFileParams[];\n /** Storage provider to use for all files */\n storageProvider?: string;\n /** Whether to encrypt all files */\n encrypt?: boolean;\n /** Encryption key for all files */\n encryptionKey?: string;\n}\n\n/**\n * Batch upload result\n *\n * @category Data Management\n */\nexport interface BatchUploadResult {\n /** Results for each uploaded file */\n results: UploadEncryptedFileResult[];\n /** Overall success status */\n success: boolean;\n /** Any errors that occurred */\n errors?: string[];\n}\n\n/**\n * Schema metadata from the blockchain (without fetched definition).\n *\n * This represents the on-chain schema registration data before the\n * definition has been fetched from the storage URL.\n *\n * @category Data Management\n */\nexport interface SchemaMetadata {\n /** Schema ID */\n id: number;\n /** Schema name */\n name: string;\n /** Schema dialect ('json' or 'sqlite') */\n dialect: \"json\" | \"sqlite\";\n /** URL containing the schema definition */\n definitionUrl: string;\n}\n\n/**\n * Complete schema with all definition fields populated.\n * This is what schemas.get() returns - a schema with the definition fetched.\n */\nexport interface CompleteSchema extends SchemaMetadata {\n /** Version of the schema */\n version: string;\n /** Optional description of the schema */\n description?: string;\n /** Optional version of the dialect */\n dialectVersion?: string;\n /** The actual schema - JSON Schema object for 'json' dialect, DDL string for 'sqlite' */\n schema: object | string;\n}\n\n/**\n * Schema with optional definition fields.\n *\n * Schemas define the structure and validation rules for user data processed by refiners.\n * They ensure data quality and consistency across the Vana network by specifying how\n * raw user data should be formatted, validated, and processed.\n *\n * When the definition has been fetched (via schemas.get() or schemas.list() with includeDefinitions),\n * the version and schema fields will be populated. Otherwise, only the metadata fields are present.\n *\n * @category Data Management\n * @example\n * ```typescript\n * // Complete schema from schemas.get()\n * const completeSchema: Schema = {\n * id: 5,\n * name: 'Social Media Profile',\n * dialect: 'json',\n * definitionUrl: 'ipfs://QmSchema...',\n * version: '1.0.0',\n * description: 'Schema for validating social media profile data',\n * schema: { // JSON Schema object\n * type: 'object',\n * properties: {\n * username: { type: 'string' }\n * }\n * }\n * };\n *\n * // Metadata-only schema from schemas.list() without includeDefinitions\n * const metadataSchema: Schema = {\n * id: 5,\n * name: 'Social Media Profile',\n * dialect: 'json',\n * definitionUrl: 'ipfs://QmSchema...'\n * };\n * ```\n */\nexport interface Schema extends SchemaMetadata {\n /** Version of the schema (present when definition is fetched) */\n version?: string;\n /** Optional description of the schema */\n description?: string;\n /** Optional version of the dialect */\n dialectVersion?: string;\n /** The actual schema - JSON Schema object for 'json' dialect, DDL string for 'sqlite' (present when definition is fetched) */\n schema?: object | string;\n}\n\n/**\n * Represents a refiner with schema information\n *\n * @category Data Management\n */\nexport interface Refiner {\n /** Refiner ID */\n id: number;\n /** DLP ID this refiner belongs to */\n dlpId: number;\n /** Owner address */\n owner: Address;\n /** Refiner name */\n name: string;\n /** Schema ID associated with this refiner */\n schemaId: number;\n /** URL containing refinement instructions */\n refinementInstructionUrl: string;\n}\n\n/**\n * Parameters for adding a new schema\n *\n * @category Data Management\n */\nexport interface AddSchemaParams {\n /** Schema name */\n name: string;\n /** Schema dialect */\n dialect: string;\n /** URL containing the schema definition */\n definitionUrl: string;\n}\n\n/**\n * Result of adding a schema\n *\n * @category Data Management\n */\nexport interface AddSchemaResult {\n /** The new schema ID assigned by the contract */\n schemaId: number;\n /** Transaction hash of the schema registration */\n transactionHash: Hash;\n}\n\n/**\n * Parameters for registering a new data refiner in the Vana network.\n *\n * Refiners are processors that transform and validate user data according to specific\n * schemas and instructions. They enable applications to work with structured, verified\n * user data while maintaining privacy and user control.\n *\n * @category Data Management\n * @example\n * ```typescript\n * const refinerParams: AddRefinerParams = {\n * dlpId: 1, // Data Liquidity Pool ID\n * name: 'Social Media Refiner',\n * schemaId: 5, // Pre-defined schema for social media data\n * refinementInstructionUrl: 'ipfs://Qm...' // Instructions for data processing\n * };\n * ```\n */\nexport interface AddRefinerParams {\n /** DLP ID this refiner belongs to */\n dlpId: number;\n /** Refiner name */\n name: string;\n /** Schema ID to associate with this refiner */\n schemaId: number;\n /** URL containing refinement instructions */\n refinementInstructionUrl: string;\n}\n\n/**\n * Result of adding a refiner\n *\n * @category Data Management\n */\nexport interface AddRefinerResult {\n /** The new refiner ID assigned by the contract */\n refinerId: number;\n /** Transaction hash of the refiner registration */\n transactionHash: Hash;\n}\n\n/**\n * Parameters for updating a refiner's schema ID\n *\n * @category Data Management\n */\nexport interface UpdateSchemaIdParams {\n /** Refiner ID to update */\n refinerId: number;\n /** New schema ID to associate with the refiner */\n newSchemaId: number;\n}\n\n/**\n * Result of updating a refiner's schema ID\n *\n * @category Data Management\n */\nexport interface UpdateSchemaIdResult {\n /** Transaction hash of the update */\n transactionHash: Hash;\n}\n\n/**\n * Trusted server data structure\n *\n * @category Data Management\n */\nexport interface TrustedServer {\n /** Unique identifier for the trusted server relationship */\n id: string;\n /** Server address (EVM address) */\n serverAddress: Address;\n /** Server URL */\n serverUrl: string;\n /** Timestamp when server was trusted */\n trustedAt: bigint;\n /** User who trusted the server */\n user: Address;\n /** Index in user's trusted server list (only available in RPC mode) */\n trustIndex?: number;\n}\n\n/**\n * Parameters for getUserTrustedServers method\n *\n * @category Data Management\n */\nexport interface GetUserTrustedServersParams {\n /** User address to query trusted servers for */\n user: Address;\n /** Optional subgraph URL to override default */\n subgraphUrl?: string;\n /** Maximum number of results */\n limit?: number;\n /** Number of results to skip */\n offset?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,13 +1,11 @@
1
1
  import type { Address, Hash } from "viem";
2
2
  /**
3
- * Represents a registered data file in the Vana network with complete blockchain metadata.
3
+ * Represents a file registered on the Vana blockchain.
4
4
  *
5
5
  * @remarks
6
- * This interface describes files that have been uploaded to storage and registered
7
- * on the Vana blockchain, including their storage location, ownership, and blockchain
8
- * tracking information. Each file receives a unique ID and is linked to the owner's
9
- * address for permission management. Used throughout the SDK for file operations
10
- * and access control workflows.
6
+ * Contains complete metadata for files uploaded to storage and registered
7
+ * on-chain. Each file has a unique ID, owner address, and storage URL.
8
+ * Used throughout SDK for file operations and permission management.
11
9
  *
12
10
  * @category Data Management
13
11
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/generics.ts"],"sourcesContent":["import type { Address, Hash } from \"viem\";\n\n/**\n * Generic request pattern for all SDK operations\n *\n * @category Reference\n */\nexport interface GenericRequest<TParams = unknown, TOptions = unknown> {\n /** Request parameters */\n params: TParams;\n /** Additional request options */\n options?: TOptions;\n}\n\n/**\n * Generic response pattern for all SDK operations\n *\n * @category Reference\n */\nexport interface GenericResponse<TData = unknown, TMeta = unknown> {\n /** Response data */\n data: TData;\n /** Response metadata */\n meta?: TMeta;\n /** Success status */\n success: boolean;\n /** Error information if not successful */\n error?: {\n code: string;\n message: string;\n details?: unknown;\n };\n}\n\n/**\n * Generic async operation result\n *\n * @category Reference\n */\nexport interface AsyncResult<T> {\n /** Operation result */\n result: T;\n /** Transaction hash if applicable */\n transactionHash?: Hash;\n /** Block number if applicable */\n blockNumber?: bigint;\n /** Gas used if applicable */\n gasUsed?: bigint;\n}\n\n/**\n * Generic contract interaction parameters\n *\n * @category Reference\n */\nexport interface ContractCall<\n TArgs extends readonly unknown[] = readonly unknown[],\n> {\n /** Contract method name */\n method: string;\n /** Method arguments */\n args: TArgs;\n /** Call options */\n options?: {\n /** Gas limit */\n gasLimit?: bigint;\n /** Gas price */\n gasPrice?: bigint;\n /** Value to send */\n value?: bigint;\n };\n}\n\n/**\n * Generic contract event filter\n *\n * @category Reference\n */\nexport interface EventFilter<TEventArgs = unknown> {\n /** Event name */\n event: string;\n /** Event arguments filter */\n args?: TEventArgs;\n /** From block */\n fromBlock?: bigint;\n /** To block */\n toBlock?: bigint;\n /** Address filter */\n address?: Address | Address[];\n}\n\n/**\n * Generic event log\n *\n * @category Reference\n */\nexport interface EventLog<TArgs = unknown> {\n /** Event name */\n event: string;\n /** Event arguments */\n args: TArgs;\n /** Block number */\n blockNumber: bigint;\n /** Transaction hash */\n transactionHash: Hash;\n /** Log index */\n logIndex: number;\n /** Transaction index */\n transactionIndex: number;\n /** Contract address */\n address: Address;\n}\n\n/**\n * Generic controller context for dependency injection\n *\n * @category Reference\n */\nexport interface ControllerContext<TClient = unknown, TConfig = unknown> {\n /** Client instance */\n client: TClient;\n /** Configuration */\n config?: TConfig;\n /** Additional context */\n [key: string]: unknown;\n}\n\n/**\n * Generic controller interface\n *\n * @category Reference\n */\nexport interface Controller<TContext = unknown> {\n /** Controller context */\n readonly context: TContext;\n}\n\n/**\n * Generic storage provider interface\n *\n * @category Reference\n */\nexport interface StorageProvider<TConfig = unknown, TOptions = unknown> {\n /** Provider name */\n readonly name: string;\n /** Provider configuration */\n readonly config: TConfig;\n\n /** Upload data */\n upload(\n data: Uint8Array,\n options?: TOptions,\n ): Promise<{\n url: string;\n size: number;\n checksum?: string;\n }>;\n\n /** Download data */\n download(\n url: string,\n options?: TOptions,\n ): Promise<{\n data: Uint8Array;\n size: number;\n checksum?: string;\n }>;\n\n /** Delete data */\n delete?(url: string, options?: TOptions): Promise<boolean>;\n\n /** Check if data exists */\n exists?(url: string, options?: TOptions): Promise<boolean>;\n}\n\n/**\n * Generic cache interface\n *\n * @category Reference\n */\nexport interface Cache<TKey = string, TValue = unknown> {\n /** Get value from cache */\n get(key: TKey): Promise<TValue | undefined>;\n\n /** Set value in cache */\n set(key: TKey, value: TValue, ttl?: number): Promise<void>;\n\n /** Delete value from cache */\n delete(key: TKey): Promise<boolean>;\n\n /** Clear all cache */\n clear(): Promise<void>;\n\n /** Check if key exists */\n has(key: TKey): Promise<boolean>;\n}\n\n/**\n * Generic retry configuration\n *\n * @category Reference\n */\nexport interface RetryConfig<TError = Error> {\n /** Maximum retry attempts */\n maxAttempts: number;\n /** Base delay in milliseconds */\n baseDelay: number;\n /** Backoff multiplier */\n backoffMultiplier?: number;\n /** Maximum delay */\n maxDelay?: number;\n /** Jitter factor */\n jitter?: number;\n /** Retry condition */\n shouldRetry?: (error: TError, attempt: number) => boolean;\n}\n\n/**\n * Generic rate limiter configuration\n *\n * @category Reference\n */\nexport interface RateLimiterConfig {\n /** Requests per time window */\n requestsPerWindow: number;\n /** Time window in milliseconds */\n windowMs: number;\n /** Burst allowance */\n burstLimit?: number;\n}\n\n/**\n * Generic middleware interface\n *\n * @category Reference\n */\nexport interface Middleware<TRequest = unknown, TResponse = unknown> {\n /** Middleware name */\n readonly name: string;\n\n /** Process request */\n request?(req: TRequest): Promise<TRequest>;\n\n /** Process response */\n response?(res: TResponse): Promise<TResponse>;\n\n /** Handle errors */\n error?(error: Error, req: TRequest): Promise<TResponse | void>;\n}\n\n/**\n * Generic plugin interface\n *\n * @category Reference\n */\nexport interface Plugin<TConfig = unknown> {\n /** Plugin name */\n readonly name: string;\n /** Plugin version */\n readonly version: string;\n /** Plugin configuration */\n readonly config: TConfig;\n\n /** Initialize plugin */\n init?(): Promise<void>;\n\n /** Cleanup plugin */\n cleanup?(): Promise<void>;\n}\n\n/**\n * Generic factory interface\n *\n * @category Reference\n */\nexport interface Factory<T, TParams = unknown> {\n /** Create instance */\n create(params: TParams): T;\n\n /** Create multiple instances */\n createMany?(params: TParams[]): T[];\n\n /** Validate parameters */\n validate?(params: TParams): boolean;\n}\n\n/**\n * Generic repository interface for data access\n *\n * @category Reference\n */\nexport interface Repository<TEntity, TKey = string | number> {\n /** Find by ID */\n findById(id: TKey): Promise<TEntity | undefined>;\n\n /** Find all entities */\n findAll(options?: {\n limit?: number;\n offset?: number;\n filter?: Partial<TEntity>;\n sort?: Array<{ field: keyof TEntity; direction: \"asc\" | \"desc\" }>;\n }): Promise<{\n entities: TEntity[];\n total: number;\n hasMore: boolean;\n }>;\n\n /** Create entity */\n create(entity: Omit<TEntity, \"id\">): Promise<TEntity>;\n\n /** Update entity */\n update(id: TKey, updates: Partial<TEntity>): Promise<TEntity>;\n\n /** Delete entity */\n delete(id: TKey): Promise<boolean>;\n\n /** Check if entity exists */\n exists(id: TKey): Promise<boolean>;\n}\n\n/**\n * Generic validator interface\n *\n * @category Reference\n */\nexport interface Validator<T> {\n /** Validate value */\n validate(value: unknown): value is T;\n\n /** Get validation errors */\n getErrors?(value: unknown): string[];\n\n /** Get validation schema */\n getSchema?(): unknown;\n}\n\n/**\n * Generic transformer interface\n *\n * @category Reference\n */\nexport interface Transformer<TInput, TOutput> {\n /** Transform input to output */\n transform(input: TInput): TOutput | Promise<TOutput>;\n\n /** Reverse transform output to input */\n reverse?(output: TOutput): TInput | Promise<TInput>;\n}\n\n/**\n * Generic service interface\n *\n * @category Reference\n */\nexport interface Service<TConfig = unknown> {\n /** Service name */\n readonly name: string;\n /** Service configuration */\n readonly config: TConfig;\n /** Service status */\n readonly status:\n | \"idle\"\n | \"starting\"\n | \"running\"\n | \"stopping\"\n | \"stopped\"\n | \"error\";\n\n /** Start service */\n start(): Promise<void>;\n\n /** Stop service */\n stop(): Promise<void>;\n\n /** Restart service */\n restart?(): Promise<void>;\n\n /** Get health status */\n getHealth?(): Promise<{\n healthy: boolean;\n details?: Record<string, unknown>;\n }>;\n}\n\n/**\n * Generic observer pattern\n *\n * @category Reference\n */\nexport interface Observer<TEvent = unknown> {\n /** Handle event */\n notify(event: TEvent): void | Promise<void>;\n}\n\n/**\n * Generic observable pattern\n *\n * @category Reference\n */\nexport interface Observable<TEvent = unknown> {\n /** Subscribe to events */\n subscribe(observer: Observer<TEvent>): () => void;\n\n /** Unsubscribe from events */\n unsubscribe(observer: Observer<TEvent>): void;\n\n /** Emit event */\n emit(event: TEvent): void;\n}\n\n/**\n * Generic state machine interface\n *\n * @category Reference\n */\nexport interface StateMachine<TState, TEvent> {\n /** Current state */\n readonly currentState: TState;\n\n /** Transition to new state */\n transition(event: TEvent): TState;\n\n /** Check if transition is valid */\n canTransition(event: TEvent): boolean;\n\n /** Get available transitions */\n getAvailableTransitions(): TEvent[];\n}\n\n/**\n * Helper type to make properties optional conditionally\n *\n * @category Reference\n */\nexport type ConditionalOptional<\n T,\n K extends keyof T,\n Condition extends boolean,\n> = Condition extends true ? Omit<T, K> & Partial<Pick<T, K>> : T;\n\n/**\n * Helper type to extract promise result type\n *\n * @category Reference\n */\nexport type PromiseResult<T> = T extends Promise<infer U> ? U : T;\n\n/**\n * Helper type to create a union of all possible keys\n *\n * @category Reference\n */\nexport type AllKeys<T> = T extends unknown ? keyof T : never;\n\n/**\n * Helper type to create a deep partial type\n *\n * @category Reference\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\n/**\n * Helper type to create a deep readonly type\n *\n * @category Reference\n */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];\n};\n\n/**\n * Helper type to create a required type with specific keys\n *\n * @category Reference\n */\nexport type RequireKeys<T, K extends keyof T> = Required<Pick<T, K>> &\n Omit<T, K>;\n\n/**\n * Helper type to create an optional type with specific keys\n *\n * @category Reference\n */\nexport type OptionalKeys<T, K extends keyof T> = Partial<Pick<T, K>> &\n Omit<T, K>;\n\n/**\n * Helper type to exclude null and undefined\n *\n * @category Reference\n */\nexport type NonNullable<T> = T extends null | undefined ? never : T;\n\n/**\n * Helper type to create a type with only specific keys\n *\n * @category Reference\n */\nexport type PickByType<T, U> = {\n [K in keyof T as T[K] extends U ? K : never]: T[K];\n};\n\n/**\n * Helper type to omit keys by type\n *\n * @category Reference\n */\nexport type OmitByType<T, U> = {\n [K in keyof T as T[K] extends U ? never : K]: T[K];\n};\n\n/**\n * Helper type for branded types\n *\n * @category Reference\n */\nexport type Brand<T, B> = T & { readonly __brand: B };\n\n/**\n * Helper type for nominal types\n *\n * @category Reference\n */\nexport type Nominal<T, N extends string> = T & { readonly __nominal: N };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/generics.ts"],"sourcesContent":["/**\n * Defines generic types and interfaces for SDK infrastructure.\n *\n * @remarks\n * This module provides reusable type definitions and interfaces that form\n * the foundation of the SDK's architecture. It includes patterns for requests,\n * responses, caching, middleware, repositories, and other common software\n * engineering abstractions.\n *\n * @category Types\n * @module types/generics\n */\n\nimport type { Address, Hash } from \"viem\";\n\n/**\n * Represents a standardized request structure for SDK operations.\n *\n * @remarks\n * Provides consistent request handling across all SDK methods with\n * typed parameters and optional configuration.\n *\n * @typeParam TParams - Type of request parameters\n * @typeParam TOptions - Type of optional configuration\n *\n * @category Reference\n */\nexport interface GenericRequest<TParams = unknown, TOptions = unknown> {\n /** Request parameters */\n params: TParams;\n /** Additional request options */\n options?: TOptions;\n}\n\n/**\n * Represents a standardized response structure for SDK operations.\n *\n * @remarks\n * Provides consistent response handling with success/error states\n * and optional metadata for additional context.\n *\n * @typeParam TData - Type of response data\n * @typeParam TMeta - Type of response metadata\n *\n * @category Reference\n */\nexport interface GenericResponse<TData = unknown, TMeta = unknown> {\n /** Response data */\n data: TData;\n /** Response metadata */\n meta?: TMeta;\n /** Success status */\n success: boolean;\n /** Error information if not successful */\n error?: {\n code: string;\n message: string;\n details?: unknown;\n };\n}\n\n/**\n * Represents the result of an asynchronous blockchain operation.\n *\n * @remarks\n * Includes transaction details when the operation involves\n * blockchain state changes.\n *\n * @typeParam T - Type of the operation result\n *\n * @category Reference\n */\nexport interface AsyncResult<T> {\n /** Operation result */\n result: T;\n /** Transaction hash if applicable */\n transactionHash?: Hash;\n /** Block number if applicable */\n blockNumber?: bigint;\n /** Gas used if applicable */\n gasUsed?: bigint;\n}\n\n/**\n * Generic contract interaction parameters\n *\n * @category Reference\n */\nexport interface ContractCall<\n TArgs extends readonly unknown[] = readonly unknown[],\n> {\n /** Contract method name */\n method: string;\n /** Method arguments */\n args: TArgs;\n /** Call options */\n options?: {\n /** Gas limit */\n gas?: bigint;\n /** Gas price */\n gasPrice?: bigint;\n /** Value to send */\n value?: bigint;\n };\n}\n\n/**\n * Generic contract event filter\n *\n * @category Reference\n */\nexport interface EventFilter<TEventArgs = unknown> {\n /** Event name */\n event: string;\n /** Event arguments filter */\n args?: TEventArgs;\n /** From block */\n fromBlock?: bigint;\n /** To block */\n toBlock?: bigint;\n /** Address filter */\n address?: Address | Address[];\n}\n\n/**\n * Generic event log\n *\n * @category Reference\n */\nexport interface EventLog<TArgs = unknown> {\n /** Event name */\n event: string;\n /** Event arguments */\n args: TArgs;\n /** Block number */\n blockNumber: bigint;\n /** Transaction hash */\n transactionHash: Hash;\n /** Log index */\n logIndex: number;\n /** Transaction index */\n transactionIndex: number;\n /** Contract address */\n address: Address;\n}\n\n/**\n * Generic controller context for dependency injection\n *\n * @category Reference\n */\nexport interface ControllerContext<TClient = unknown, TConfig = unknown> {\n /** Client instance */\n client: TClient;\n /** Configuration */\n config?: TConfig;\n /** Additional context */\n [key: string]: unknown;\n}\n\n/**\n * Generic controller interface\n *\n * @category Reference\n */\nexport interface Controller<TContext = unknown> {\n /** Controller context */\n readonly context: TContext;\n}\n\n/**\n * Generic storage provider interface\n *\n * @category Reference\n */\nexport interface StorageProvider<TConfig = unknown, TOptions = unknown> {\n /** Provider name */\n readonly name: string;\n /** Provider configuration */\n readonly config: TConfig;\n\n /** Upload data */\n upload(\n data: Uint8Array,\n options?: TOptions,\n ): Promise<{\n url: string;\n size: number;\n checksum?: string;\n }>;\n\n /** Download data */\n download(\n url: string,\n options?: TOptions,\n ): Promise<{\n data: Uint8Array;\n size: number;\n checksum?: string;\n }>;\n\n /** Delete data */\n delete?(url: string, options?: TOptions): Promise<boolean>;\n\n /** Check if data exists */\n exists?(url: string, options?: TOptions): Promise<boolean>;\n}\n\n/**\n * Defines a generic caching interface with TTL support.\n *\n * @remarks\n * Provides standard cache operations for performance optimization\n * and reducing redundant computations or network requests.\n *\n * @typeParam TKey - Type of cache keys\n * @typeParam TValue - Type of cached values\n *\n * @category Reference\n */\nexport interface Cache<TKey = string, TValue = unknown> {\n /** Get value from cache */\n get(key: TKey): Promise<TValue | undefined>;\n\n /** Set value in cache */\n set(key: TKey, value: TValue, ttl?: number): Promise<void>;\n\n /** Delete value from cache */\n delete(key: TKey): Promise<boolean>;\n\n /** Clear all cache */\n clear(): Promise<void>;\n\n /** Check if key exists */\n has(key: TKey): Promise<boolean>;\n}\n\n/**\n * Configures retry behavior for resilient operations.\n *\n * @remarks\n * Supports exponential backoff, jitter, and custom retry conditions\n * for handling transient failures gracefully.\n *\n * @typeParam TError - Type of errors to handle\n *\n * @category Reference\n */\nexport interface RetryConfig<TError = Error> {\n /** Maximum retry attempts */\n maxAttempts: number;\n /** Base delay in milliseconds */\n baseDelay: number;\n /** Backoff multiplier */\n backoffMultiplier?: number;\n /** Maximum delay */\n maxDelay?: number;\n /** Jitter factor */\n jitter?: number;\n /** Retry condition */\n shouldRetry?: (error: TError, attempt: number) => boolean;\n}\n\n/**\n * Generic rate limiter configuration\n *\n * @category Reference\n */\nexport interface RateLimiterConfig {\n /** Requests per time window */\n requestsPerWindow: number;\n /** Time window in milliseconds */\n windowMs: number;\n /** Burst allowance */\n burstLimit?: number;\n}\n\n/**\n * Defines middleware for request/response processing pipelines.\n *\n * @remarks\n * Middleware can transform requests, responses, and handle errors\n * in a composable chain of responsibility pattern.\n *\n * @typeParam TRequest - Type of requests to process\n * @typeParam TResponse - Type of responses to process\n *\n * @category Reference\n */\nexport interface Middleware<TRequest = unknown, TResponse = unknown> {\n /** Middleware name */\n readonly name: string;\n\n /** Process request */\n request?(req: TRequest): Promise<TRequest>;\n\n /** Process response */\n response?(res: TResponse): Promise<TResponse>;\n\n /** Handle errors */\n error?(error: Error, req: TRequest): Promise<TResponse | void>;\n}\n\n/**\n * Generic plugin interface\n *\n * @category Reference\n */\nexport interface Plugin<TConfig = unknown> {\n /** Plugin name */\n readonly name: string;\n /** Plugin version */\n readonly version: string;\n /** Plugin configuration */\n readonly config: TConfig;\n\n /** Initialize plugin */\n init?(): Promise<void>;\n\n /** Cleanup plugin */\n cleanup?(): Promise<void>;\n}\n\n/**\n * Generic factory interface\n *\n * @category Reference\n */\nexport interface Factory<T, TParams = unknown> {\n /** Create instance */\n create(params: TParams): T;\n\n /** Create multiple instances */\n createMany?(params: TParams[]): T[];\n\n /** Validate parameters */\n validate?(params: TParams): boolean;\n}\n\n/**\n * Defines a repository pattern for data access abstraction.\n *\n * @remarks\n * Provides CRUD operations with filtering, sorting, and pagination\n * for consistent data access across different storage backends.\n *\n * @typeParam TEntity - Type of entities managed by the repository\n * @typeParam TKey - Type of entity identifiers\n *\n * @category Reference\n */\nexport interface Repository<TEntity, TKey = string | number> {\n /** Find by ID */\n findById(id: TKey): Promise<TEntity | undefined>;\n\n /** Find all entities */\n findAll(options?: {\n limit?: number;\n offset?: number;\n filter?: Partial<TEntity>;\n sort?: Array<{ field: keyof TEntity; direction: \"asc\" | \"desc\" }>;\n }): Promise<{\n entities: TEntity[];\n total: number;\n hasMore: boolean;\n }>;\n\n /** Create entity */\n create(entity: Omit<TEntity, \"id\">): Promise<TEntity>;\n\n /** Update entity */\n update(id: TKey, updates: Partial<TEntity>): Promise<TEntity>;\n\n /** Delete entity */\n delete(id: TKey): Promise<boolean>;\n\n /** Check if entity exists */\n exists(id: TKey): Promise<boolean>;\n}\n\n/**\n * Generic validator interface\n *\n * @category Reference\n */\nexport interface Validator<T> {\n /** Validate value */\n validate(value: unknown): value is T;\n\n /** Get validation errors */\n getErrors?(value: unknown): string[];\n\n /** Get validation schema */\n getSchema?(): unknown;\n}\n\n/**\n * Generic transformer interface\n *\n * @category Reference\n */\nexport interface Transformer<TInput, TOutput> {\n /** Transform input to output */\n transform(input: TInput): TOutput | Promise<TOutput>;\n\n /** Reverse transform output to input */\n reverse?(output: TOutput): TInput | Promise<TInput>;\n}\n\n/**\n * Generic service interface\n *\n * @category Reference\n */\nexport interface Service<TConfig = unknown> {\n /** Service name */\n readonly name: string;\n /** Service configuration */\n readonly config: TConfig;\n /** Service status */\n readonly status:\n | \"idle\"\n | \"starting\"\n | \"running\"\n | \"stopping\"\n | \"stopped\"\n | \"error\";\n\n /** Start service */\n start(): Promise<void>;\n\n /** Stop service */\n stop(): Promise<void>;\n\n /** Restart service */\n restart?(): Promise<void>;\n\n /** Get health status */\n getHealth?(): Promise<{\n healthy: boolean;\n details?: Record<string, unknown>;\n }>;\n}\n\n/**\n * Implements the observer in the observer pattern.\n *\n * @remarks\n * Receives notifications about events from observable subjects\n * for decoupled event handling.\n *\n * @typeParam TEvent - Type of events to observe\n *\n * @category Reference\n */\nexport interface Observer<TEvent = unknown> {\n /** Handle event */\n notify(event: TEvent): void | Promise<void>;\n}\n\n/**\n * Implements the subject in the observer pattern.\n *\n * @remarks\n * Manages observers and emits events to all subscribed observers\n * for event-driven architectures.\n *\n * @typeParam TEvent - Type of events to emit\n *\n * @category Reference\n */\nexport interface Observable<TEvent = unknown> {\n /** Subscribe to events */\n subscribe(observer: Observer<TEvent>): () => void;\n\n /** Unsubscribe from events */\n unsubscribe(observer: Observer<TEvent>): void;\n\n /** Emit event */\n emit(event: TEvent): void;\n}\n\n/**\n * Generic state machine interface\n *\n * @category Reference\n */\nexport interface StateMachine<TState, TEvent> {\n /** Current state */\n readonly currentState: TState;\n\n /** Transition to new state */\n transition(event: TEvent): TState;\n\n /** Check if transition is valid */\n canTransition(event: TEvent): boolean;\n\n /** Get available transitions */\n getAvailableTransitions(): TEvent[];\n}\n\n/**\n * Helper type to make properties optional conditionally\n *\n * @category Reference\n */\nexport type ConditionalOptional<\n T,\n K extends keyof T,\n Condition extends boolean,\n> = Condition extends true ? Omit<T, K> & Partial<Pick<T, K>> : T;\n\n/**\n * Helper type to extract promise result type\n *\n * @category Reference\n */\nexport type PromiseResult<T> = T extends Promise<infer U> ? U : T;\n\n/**\n * Helper type to create a union of all possible keys\n *\n * @category Reference\n */\nexport type AllKeys<T> = T extends unknown ? keyof T : never;\n\n/**\n * Helper type to create a deep partial type\n *\n * @category Reference\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\n/**\n * Helper type to create a deep readonly type\n *\n * @category Reference\n */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];\n};\n\n/**\n * Helper type to create a required type with specific keys\n *\n * @category Reference\n */\nexport type RequireKeys<T, K extends keyof T> = Required<Pick<T, K>> &\n Omit<T, K>;\n\n/**\n * Helper type to create an optional type with specific keys\n *\n * @category Reference\n */\nexport type OptionalKeys<T, K extends keyof T> = Partial<Pick<T, K>> &\n Omit<T, K>;\n\n/**\n * Helper type to exclude null and undefined\n *\n * @category Reference\n */\nexport type NonNullable<T> = T extends null | undefined ? never : T;\n\n/**\n * Helper type to create a type with only specific keys\n *\n * @category Reference\n */\nexport type PickByType<T, U> = {\n [K in keyof T as T[K] extends U ? K : never]: T[K];\n};\n\n/**\n * Helper type to omit keys by type\n *\n * @category Reference\n */\nexport type OmitByType<T, U> = {\n [K in keyof T as T[K] extends U ? never : K]: T[K];\n};\n\n/**\n * Helper type for branded types\n *\n * @category Reference\n */\nexport type Brand<T, B> = T & { readonly __brand: B };\n\n/**\n * Helper type for nominal types\n *\n * @category Reference\n */\nexport type Nominal<T, N extends string> = T & { readonly __nominal: N };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,6 +1,25 @@
1
+ /**
2
+ * Defines generic types and interfaces for SDK infrastructure.
3
+ *
4
+ * @remarks
5
+ * This module provides reusable type definitions and interfaces that form
6
+ * the foundation of the SDK's architecture. It includes patterns for requests,
7
+ * responses, caching, middleware, repositories, and other common software
8
+ * engineering abstractions.
9
+ *
10
+ * @category Types
11
+ * @module types/generics
12
+ */
1
13
  import type { Address, Hash } from "viem";
2
14
  /**
3
- * Generic request pattern for all SDK operations
15
+ * Represents a standardized request structure for SDK operations.
16
+ *
17
+ * @remarks
18
+ * Provides consistent request handling across all SDK methods with
19
+ * typed parameters and optional configuration.
20
+ *
21
+ * @typeParam TParams - Type of request parameters
22
+ * @typeParam TOptions - Type of optional configuration
4
23
  *
5
24
  * @category Reference
6
25
  */
@@ -11,7 +30,14 @@ export interface GenericRequest<TParams = unknown, TOptions = unknown> {
11
30
  options?: TOptions;
12
31
  }
13
32
  /**
14
- * Generic response pattern for all SDK operations
33
+ * Represents a standardized response structure for SDK operations.
34
+ *
35
+ * @remarks
36
+ * Provides consistent response handling with success/error states
37
+ * and optional metadata for additional context.
38
+ *
39
+ * @typeParam TData - Type of response data
40
+ * @typeParam TMeta - Type of response metadata
15
41
  *
16
42
  * @category Reference
17
43
  */
@@ -30,7 +56,13 @@ export interface GenericResponse<TData = unknown, TMeta = unknown> {
30
56
  };
31
57
  }
32
58
  /**
33
- * Generic async operation result
59
+ * Represents the result of an asynchronous blockchain operation.
60
+ *
61
+ * @remarks
62
+ * Includes transaction details when the operation involves
63
+ * blockchain state changes.
64
+ *
65
+ * @typeParam T - Type of the operation result
34
66
  *
35
67
  * @category Reference
36
68
  */
@@ -57,7 +89,7 @@ export interface ContractCall<TArgs extends readonly unknown[] = readonly unknow
57
89
  /** Call options */
58
90
  options?: {
59
91
  /** Gas limit */
60
- gasLimit?: bigint;
92
+ gas?: bigint;
61
93
  /** Gas price */
62
94
  gasPrice?: bigint;
63
95
  /** Value to send */
@@ -152,7 +184,14 @@ export interface StorageProvider<TConfig = unknown, TOptions = unknown> {
152
184
  exists?(url: string, options?: TOptions): Promise<boolean>;
153
185
  }
154
186
  /**
155
- * Generic cache interface
187
+ * Defines a generic caching interface with TTL support.
188
+ *
189
+ * @remarks
190
+ * Provides standard cache operations for performance optimization
191
+ * and reducing redundant computations or network requests.
192
+ *
193
+ * @typeParam TKey - Type of cache keys
194
+ * @typeParam TValue - Type of cached values
156
195
  *
157
196
  * @category Reference
158
197
  */
@@ -169,7 +208,13 @@ export interface Cache<TKey = string, TValue = unknown> {
169
208
  has(key: TKey): Promise<boolean>;
170
209
  }
171
210
  /**
172
- * Generic retry configuration
211
+ * Configures retry behavior for resilient operations.
212
+ *
213
+ * @remarks
214
+ * Supports exponential backoff, jitter, and custom retry conditions
215
+ * for handling transient failures gracefully.
216
+ *
217
+ * @typeParam TError - Type of errors to handle
173
218
  *
174
219
  * @category Reference
175
220
  */
@@ -201,7 +246,14 @@ export interface RateLimiterConfig {
201
246
  burstLimit?: number;
202
247
  }
203
248
  /**
204
- * Generic middleware interface
249
+ * Defines middleware for request/response processing pipelines.
250
+ *
251
+ * @remarks
252
+ * Middleware can transform requests, responses, and handle errors
253
+ * in a composable chain of responsibility pattern.
254
+ *
255
+ * @typeParam TRequest - Type of requests to process
256
+ * @typeParam TResponse - Type of responses to process
205
257
  *
206
258
  * @category Reference
207
259
  */
@@ -246,7 +298,14 @@ export interface Factory<T, TParams = unknown> {
246
298
  validate?(params: TParams): boolean;
247
299
  }
248
300
  /**
249
- * Generic repository interface for data access
301
+ * Defines a repository pattern for data access abstraction.
302
+ *
303
+ * @remarks
304
+ * Provides CRUD operations with filtering, sorting, and pagination
305
+ * for consistent data access across different storage backends.
306
+ *
307
+ * @typeParam TEntity - Type of entities managed by the repository
308
+ * @typeParam TKey - Type of entity identifiers
250
309
  *
251
310
  * @category Reference
252
311
  */
@@ -325,7 +384,13 @@ export interface Service<TConfig = unknown> {
325
384
  }>;
326
385
  }
327
386
  /**
328
- * Generic observer pattern
387
+ * Implements the observer in the observer pattern.
388
+ *
389
+ * @remarks
390
+ * Receives notifications about events from observable subjects
391
+ * for decoupled event handling.
392
+ *
393
+ * @typeParam TEvent - Type of events to observe
329
394
  *
330
395
  * @category Reference
331
396
  */
@@ -334,7 +399,13 @@ export interface Observer<TEvent = unknown> {
334
399
  notify(event: TEvent): void | Promise<void>;
335
400
  }
336
401
  /**
337
- * Generic observable pattern
402
+ * Implements the subject in the observer pattern.
403
+ *
404
+ * @remarks
405
+ * Manages observers and emits events to all subscribed observers
406
+ * for event-driven architectures.
407
+ *
408
+ * @typeParam TEvent - Type of events to emit
338
409
  *
339
410
  * @category Reference
340
411
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["// Configuration types\nexport type {\n BaseConfig,\n BaseConfigWithStorage,\n WalletConfig,\n WalletConfigWithStorage,\n ChainConfig,\n ChainConfigWithStorage,\n VanaConfig,\n VanaConfigWithStorage,\n VanaConfigWithWallet,\n VanaConfigReadOnly,\n VanaConfigAddressOnly,\n VanaConfigWithWalletWithStorage,\n VanaConfigReadOnlyWithStorage,\n VanaConfigAddressOnlyWithStorage,\n RuntimeConfig,\n StorageConfig,\n ConfigValidationOptions,\n ConfigValidationResult,\n DownloadRelayerCallbacks,\n StorageRequiredMarker,\n} from \"./config\";\n\nexport {\n isWalletConfig,\n isChainConfig,\n isReadOnlyConfig,\n isAddressOnlyConfig,\n hasStorageConfig,\n} from \"./config\";\n\n// Chain types\nexport type { VanaChainId, VanaChain } from \"./chains\";\n\nexport { isVanaChainId, isVanaChain } from \"./chains\";\n\n// Contract types\nexport type {\n VanaContractName,\n ContractInfo,\n ContractDeployment,\n VanaContractInstance,\n ContractAddresses,\n ContractMethodParams,\n ContractMethodReturnType,\n} from \"./contracts\";\n\n// Note: VanaContract and ContractAbis are exported directly from src/index.ts\n// to avoid circular dependencies. Do not re-export them here.\n\n// Storage types\nexport type {\n StorageProvider,\n StorageUploadResult,\n StorageFile,\n StorageListOptions,\n StorageProviderConfig,\n} from \"./storage\";\n\nexport { StorageError } from \"./storage\";\n\n// Data types\nexport type {\n UserFile,\n FileMetadata,\n UploadParams,\n FilePermissionParams,\n LegacyPermissionParams,\n EncryptedUploadParams,\n UnencryptedUploadParams,\n UploadResult,\n UploadFileParams,\n UploadFileResult,\n UploadEncryptedFileResult,\n EncryptionInfo,\n GetUserFilesParams,\n GetFileParams,\n EncryptFileOptions,\n EncryptFileResult,\n DecryptFileOptions,\n UploadFileWithPermissionsParams,\n AddFilePermissionParams,\n DecryptFileWithPermissionOptions,\n DownloadFileParams,\n DownloadFileResult,\n DeleteFileParams,\n DeleteFileResult,\n FileAccessPermissions,\n FileSharingConfig,\n BatchUploadParams,\n BatchUploadResult,\n SchemaMetadata,\n CompleteSchema,\n Schema,\n Refiner,\n AddSchemaParams,\n AddSchemaResult,\n AddRefinerParams,\n AddRefinerResult,\n UpdateSchemaIdParams,\n UpdateSchemaIdResult,\n TrustedServer,\n GetUserTrustedServersParams,\n} from \"./data\";\n\n// Schema types\nexport type {\n CreateSchemaParams,\n CreateSchemaResult,\n} from \"../controllers/schemas\";\n\n// Schema validation types\nexport type { DataSchema } from \"../utils/schemaValidation\";\nexport {\n SchemaValidationError,\n SchemaValidator,\n validateDataSchemaAgainstMetaSchema,\n validateDataAgainstSchema,\n fetchAndValidateSchema,\n} from \"../utils/schemaValidation\";\n\n// Permission types\nexport type {\n OnChainPermissionGrant,\n GetUserPermissionsOptions,\n GrantPermissionParams,\n RevokePermissionParams,\n CheckPermissionParams,\n PermissionCheckResult,\n PermissionGrantDomain,\n PermissionGrantMessage,\n PermissionInputMessage,\n SimplifiedPermissionMessage,\n GrantFile,\n PermissionGrantTypedData,\n RevokePermissionTypedData,\n GenericTypedData,\n TypedDataPrimaryType,\n SpecificTypedData,\n PermissionOperation,\n PermissionStatus,\n QueryPermissionsParams,\n PermissionQueryResult,\n PermissionAnalytics,\n PermissionEvent,\n GrantedPermission,\n Server,\n AddAndTrustServerParams,\n TrustServerParams,\n UntrustServerParams,\n AddAndTrustServerInput,\n TrustServerInput,\n UntrustServerInput,\n AddAndTrustServerTypedData,\n TrustServerTypedData,\n UntrustServerTypedData,\n PermissionInfo,\n RevokePermissionInput,\n TrustedServerInfo,\n PaginatedTrustedServers,\n TrustedServerQueryOptions,\n BatchServerInfoResult,\n ServerTrustStatus,\n ServerInfo,\n Grantee,\n GranteeInfo,\n RegisterGranteeParams,\n RegisterGranteeInput,\n RegisterGranteeTypedData,\n GranteeQueryOptions,\n PaginatedGrantees,\n ServerFilesAndPermissionParams,\n ServerFilesAndPermissionTypedData,\n Permission,\n} from \"./permissions\";\n\n// Personal server types\nexport type {\n PostRequestParams,\n CreateOperationParams,\n InitPersonalServerParams,\n PersonalServerIdentity,\n} from \"./personal\";\n\n// Server API types (auto-generated via fetch-server-types.ts)\nexport type * from \"../generated/server/server-exports\";\n\n// External API types\nexport type {\n ReplicateAPIResponse,\n ReplicateStatus,\n PinataUploadResponse,\n PinataPin,\n PinataListResponse,\n APIResponse,\n} from \"./external-apis\";\n\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./external-apis\";\n\n// Relayer types\nexport type {\n RelayerStorageResponse,\n RelayerTransactionResponse,\n RelayerStoreParams,\n RelayerSubmitParams,\n RelayerStatus,\n RelayerConfig,\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n SignedRelayerRequest,\n DirectRelayerRequest,\n RelayerRequestOptions,\n RelayerErrorResponse,\n RelayerQueueInfo,\n RelayerTransactionStatus,\n RelayerMetrics,\n RelayerWebhookConfig,\n RelayerWebhookPayload,\n} from \"./relayer\";\n\n// Utility types\nexport type {\n PartialExcept,\n RequiredExcept,\n Awaited,\n MaybePromise,\n MaybeArray,\n PaginationParams,\n PaginationResult,\n BlockRange,\n TransactionOptions,\n TransactionReceipt,\n ApiResponse,\n CacheConfig,\n ValidationResult,\n StatusInfo,\n RateLimitInfo,\n UploadProgress,\n NetworkInfo,\n GasEstimate,\n TimeRange,\n} from \"./utils\";\n\n// Generic types for extensibility\nexport type {\n GenericRequest,\n GenericResponse,\n AsyncResult,\n ContractCall,\n EventFilter,\n EventLog,\n ControllerContext,\n Controller,\n Cache,\n RetryConfig,\n RateLimiterConfig,\n Middleware,\n Plugin,\n Factory,\n Repository,\n Validator,\n Transformer,\n Service,\n Observer,\n Observable,\n StateMachine,\n ConditionalOptional,\n PromiseResult,\n AllKeys,\n DeepPartial,\n DeepReadonly,\n RequireKeys,\n OptionalKeys,\n NonNullable,\n PickByType,\n OmitByType,\n Brand,\n Nominal,\n} from \"./generics\";\n\n// Re-export viem types that are commonly used\nexport type {\n Address,\n Hash,\n Abi,\n Chain,\n WalletClient,\n PublicClient,\n Account,\n GetContractReturnType,\n} from \"viem\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBA,oBAMO;AAKP,oBAA2C;AAyB3C,qBAA6B;AAsD7B,8BAMO;AA8EP,2BAKO;","names":[]}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["/**\n * Centralized type exports for the Vana SDK.\n *\n * @remarks\n * This module re-exports all public types from their respective modules,\n * providing a single import point for SDK consumers. Types are organized\n * by category for easy discovery and usage.\n *\n * **Import Strategy:**\n * - Import types from this module for application code\n * - Import from specific modules only for advanced use cases\n * - Avoid importing from internal paths\n *\n * @example\n * ```typescript\n * // Recommended: Import from types module\n * import type { VanaConfig, UserFile, GrantPermissionParams } from '@opendatalabs/vana-sdk';\n *\n * // Alternative: Import from specific category\n * import type { StorageProvider } from '@opendatalabs/vana-sdk';\n * ```\n *\n * @category Types\n * @module types\n */\n\n// Configuration types\nexport type {\n BaseConfig,\n BaseConfigWithStorage,\n WalletConfig,\n WalletConfigWithStorage,\n ChainConfig,\n ChainConfigWithStorage,\n VanaConfig,\n VanaConfigWithStorage,\n VanaConfigWithWallet,\n VanaConfigReadOnly,\n VanaConfigAddressOnly,\n VanaConfigWithWalletWithStorage,\n VanaConfigReadOnlyWithStorage,\n VanaConfigAddressOnlyWithStorage,\n RuntimeConfig,\n StorageConfig,\n ConfigValidationOptions,\n ConfigValidationResult,\n DownloadRelayerCallbacks,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./config\";\n\nexport {\n isWalletConfig,\n isChainConfig,\n isReadOnlyConfig,\n isAddressOnlyConfig,\n hasStorageConfig,\n} from \"./config\";\n\n// Chain types\nexport type { VanaChainId, VanaChain } from \"./chains\";\n\nexport { isVanaChainId, isVanaChain } from \"./chains\";\n\n// Contract types\nexport type {\n VanaContractName,\n ContractInfo,\n ContractDeployment,\n VanaContractInstance,\n ContractAddresses,\n ContractMethodParams,\n ContractMethodReturnType,\n} from \"./contracts\";\n\n// Note: VanaContract and ContractAbis are exported directly from src/index.ts\n// to avoid circular dependencies. Do not re-export them here.\n\n// Storage types\nexport type {\n StorageProvider,\n StorageUploadResult,\n StorageFile,\n StorageListOptions,\n StorageProviderConfig,\n} from \"./storage\";\n\nexport { StorageError } from \"./storage\";\n\n// Data types\nexport type {\n UserFile,\n FileMetadata,\n UploadParams,\n FilePermissionParams,\n LegacyPermissionParams,\n EncryptedUploadParams,\n UnencryptedUploadParams,\n UploadResult,\n UploadFileParams,\n UploadFileResult,\n UploadEncryptedFileResult,\n EncryptionInfo,\n GetUserFilesParams,\n GetFileParams,\n EncryptFileOptions,\n EncryptFileResult,\n DecryptFileOptions,\n UploadFileWithPermissionsParams,\n AddFilePermissionParams,\n DecryptFileWithPermissionOptions,\n DownloadFileParams,\n DownloadFileResult,\n DeleteFileParams,\n DeleteFileResult,\n FileAccessPermissions,\n FileSharingConfig,\n BatchUploadParams,\n BatchUploadResult,\n SchemaMetadata,\n CompleteSchema,\n Schema,\n Refiner,\n AddSchemaParams,\n AddSchemaResult,\n AddRefinerParams,\n AddRefinerResult,\n UpdateSchemaIdParams,\n UpdateSchemaIdResult,\n TrustedServer,\n GetUserTrustedServersParams,\n} from \"./data\";\n\n// Schema types\nexport type {\n CreateSchemaParams,\n CreateSchemaResult,\n} from \"../controllers/schemas\";\n\n// Schema validation types\nexport type { DataSchema } from \"../utils/schemaValidation\";\nexport {\n SchemaValidationError,\n SchemaValidator,\n validateDataSchemaAgainstMetaSchema,\n validateDataAgainstSchema,\n fetchAndValidateSchema,\n} from \"../utils/schemaValidation\";\n\n// Permission types\nexport type {\n OnChainPermissionGrant,\n GetUserPermissionsOptions,\n GrantPermissionParams,\n RevokePermissionParams,\n CheckPermissionParams,\n PermissionCheckResult,\n PermissionGrantDomain,\n PermissionGrantMessage,\n PermissionInputMessage,\n SimplifiedPermissionMessage,\n GrantFile,\n PermissionGrantTypedData,\n RevokePermissionTypedData,\n GenericTypedData,\n TypedDataPrimaryType,\n SpecificTypedData,\n PermissionOperation,\n PermissionStatus,\n QueryPermissionsParams,\n PermissionQueryResult,\n PermissionAnalytics,\n PermissionEvent,\n GrantedPermission,\n Server,\n AddAndTrustServerParams,\n TrustServerParams,\n UntrustServerParams,\n AddAndTrustServerInput,\n TrustServerInput,\n UntrustServerInput,\n AddAndTrustServerTypedData,\n TrustServerTypedData,\n UntrustServerTypedData,\n PermissionInfo,\n RevokePermissionInput,\n TrustedServerInfo,\n PaginatedTrustedServers,\n TrustedServerQueryOptions,\n BatchServerInfoResult,\n ServerTrustStatus,\n ServerInfo,\n Grantee,\n GranteeInfo,\n RegisterGranteeParams,\n RegisterGranteeInput,\n RegisterGranteeTypedData,\n GranteeQueryOptions,\n PaginatedGrantees,\n ServerFilesAndPermissionParams,\n ServerFilesAndPermissionTypedData,\n Permission,\n} from \"./permissions\";\n\n// Personal server types\nexport type {\n PostRequestParams,\n CreateOperationParams,\n InitPersonalServerParams,\n PersonalServerIdentity,\n} from \"./personal\";\n\n// Server API types (auto-generated via fetch-server-types.ts)\nexport type * from \"../generated/server/server-exports\";\n\n// External API types\nexport type {\n ReplicateAPIResponse,\n ReplicateStatus,\n PinataUploadResponse,\n PinataPin,\n PinataListResponse,\n APIResponse,\n} from \"./external-apis\";\n\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./external-apis\";\n\n// Relayer types\nexport type {\n RelayerStorageResponse,\n RelayerTransactionResponse,\n RelayerStoreParams,\n RelayerSubmitParams,\n RelayerStatus,\n RelayerConfig,\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n SignedRelayerRequest,\n DirectRelayerRequest,\n RelayerRequestOptions,\n RelayerErrorResponse,\n RelayerQueueInfo,\n RelayerTransactionStatus,\n RelayerMetrics,\n RelayerWebhookConfig,\n RelayerWebhookPayload,\n} from \"./relayer\";\n\n// Utility types\nexport type {\n PartialExcept,\n RequiredExcept,\n Awaited,\n MaybePromise,\n MaybeArray,\n PaginationParams,\n PaginationResult,\n BlockRange,\n ApiResponse,\n CacheConfig,\n ValidationResult,\n StatusInfo,\n RateLimitInfo,\n UploadProgress,\n NetworkInfo,\n GasEstimate,\n TimeRange,\n} from \"./utils\";\n\n// Operation types\nexport type {\n TransactionOptions,\n TransactionReceipt,\n TransactionResult,\n IOperationStore,\n OperationState,\n} from \"./operations\";\n\n// Generic types for extensibility\nexport type {\n GenericRequest,\n GenericResponse,\n AsyncResult,\n ContractCall,\n EventFilter,\n EventLog,\n ControllerContext,\n Controller,\n Cache,\n RetryConfig,\n RateLimiterConfig,\n Middleware,\n Plugin,\n Factory,\n Repository,\n Validator,\n Transformer,\n Service,\n Observer,\n Observable,\n StateMachine,\n ConditionalOptional,\n PromiseResult,\n AllKeys,\n DeepPartial,\n DeepReadonly,\n RequireKeys,\n OptionalKeys,\n NonNullable,\n PickByType,\n OmitByType,\n Brand,\n Nominal,\n} from \"./generics\";\n\n// Re-export viem types that are commonly used\nexport type {\n Address,\n Hash,\n Abi,\n Chain,\n WalletClient,\n PublicClient,\n Account,\n GetContractReturnType,\n} from \"viem\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDA,oBAMO;AAKP,oBAA2C;AAyB3C,qBAA6B;AAsD7B,8BAMO;AA8EP,2BAKO;","names":[]}
@@ -1,4 +1,29 @@
1
- export type { BaseConfig, BaseConfigWithStorage, WalletConfig, WalletConfigWithStorage, ChainConfig, ChainConfigWithStorage, VanaConfig, VanaConfigWithStorage, VanaConfigWithWallet, VanaConfigReadOnly, VanaConfigAddressOnly, VanaConfigWithWalletWithStorage, VanaConfigReadOnlyWithStorage, VanaConfigAddressOnlyWithStorage, RuntimeConfig, StorageConfig, ConfigValidationOptions, ConfigValidationResult, DownloadRelayerCallbacks, StorageRequiredMarker, } from "./config";
1
+ /**
2
+ * Centralized type exports for the Vana SDK.
3
+ *
4
+ * @remarks
5
+ * This module re-exports all public types from their respective modules,
6
+ * providing a single import point for SDK consumers. Types are organized
7
+ * by category for easy discovery and usage.
8
+ *
9
+ * **Import Strategy:**
10
+ * - Import types from this module for application code
11
+ * - Import from specific modules only for advanced use cases
12
+ * - Avoid importing from internal paths
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Recommended: Import from types module
17
+ * import type { VanaConfig, UserFile, GrantPermissionParams } from '@opendatalabs/vana-sdk';
18
+ *
19
+ * // Alternative: Import from specific category
20
+ * import type { StorageProvider } from '@opendatalabs/vana-sdk';
21
+ * ```
22
+ *
23
+ * @category Types
24
+ * @module types
25
+ */
26
+ export type { BaseConfig, BaseConfigWithStorage, WalletConfig, WalletConfigWithStorage, ChainConfig, ChainConfigWithStorage, VanaConfig, VanaConfigWithStorage, VanaConfigWithWallet, VanaConfigReadOnly, VanaConfigAddressOnly, VanaConfigWithWalletWithStorage, VanaConfigReadOnlyWithStorage, VanaConfigAddressOnlyWithStorage, RuntimeConfig, StorageConfig, ConfigValidationOptions, ConfigValidationResult, DownloadRelayerCallbacks, StorageRequiredMarker, RelayerRequiredMarker, } from "./config";
2
27
  export { isWalletConfig, isChainConfig, isReadOnlyConfig, isAddressOnlyConfig, hasStorageConfig, } from "./config";
3
28
  export type { VanaChainId, VanaChain } from "./chains";
4
29
  export { isVanaChainId, isVanaChain } from "./chains";
@@ -15,6 +40,7 @@ export type * from "../generated/server/server-exports";
15
40
  export type { ReplicateAPIResponse, ReplicateStatus, PinataUploadResponse, PinataPin, PinataListResponse, APIResponse, } from "./external-apis";
16
41
  export { isReplicateAPIResponse, isAPIResponse, safeParseJSON, parseReplicateOutput, } from "./external-apis";
17
42
  export type { RelayerStorageResponse, RelayerTransactionResponse, RelayerStoreParams, RelayerSubmitParams, RelayerStatus, RelayerConfig, UnifiedRelayerRequest, UnifiedRelayerResponse, SignedRelayerRequest, DirectRelayerRequest, RelayerRequestOptions, RelayerErrorResponse, RelayerQueueInfo, RelayerTransactionStatus, RelayerMetrics, RelayerWebhookConfig, RelayerWebhookPayload, } from "./relayer";
18
- export type { PartialExcept, RequiredExcept, Awaited, MaybePromise, MaybeArray, PaginationParams, PaginationResult, BlockRange, TransactionOptions, TransactionReceipt, ApiResponse, CacheConfig, ValidationResult, StatusInfo, RateLimitInfo, UploadProgress, NetworkInfo, GasEstimate, TimeRange, } from "./utils";
43
+ export type { PartialExcept, RequiredExcept, Awaited, MaybePromise, MaybeArray, PaginationParams, PaginationResult, BlockRange, ApiResponse, CacheConfig, ValidationResult, StatusInfo, RateLimitInfo, UploadProgress, NetworkInfo, GasEstimate, TimeRange, } from "./utils";
44
+ export type { TransactionOptions, TransactionReceipt, TransactionResult, IOperationStore, OperationState, } from "./operations";
19
45
  export type { GenericRequest, GenericResponse, AsyncResult, ContractCall, EventFilter, EventLog, ControllerContext, Controller, Cache, RetryConfig, RateLimiterConfig, Middleware, Plugin, Factory, Repository, Validator, Transformer, Service, Observer, Observable, StateMachine, ConditionalOptional, PromiseResult, AllKeys, DeepPartial, DeepReadonly, RequireKeys, OptionalKeys, NonNullable, PickByType, OmitByType, Brand, Nominal, } from "./generics";
20
46
  export type { Address, Hash, Abi, Chain, WalletClient, PublicClient, Account, GetContractReturnType, } from "viem";