@opendatalabs/vana-sdk 0.1.0-alpha.f2de4f7 → 0.1.0-alpha.f35bb9c

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 (165) 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/data.cjs +173 -141
  14. package/dist/controllers/data.cjs.map +1 -1
  15. package/dist/controllers/data.d.ts +213 -175
  16. package/dist/controllers/data.js +173 -141
  17. package/dist/controllers/data.js.map +1 -1
  18. package/dist/controllers/permissions.cjs +185 -191
  19. package/dist/controllers/permissions.cjs.map +1 -1
  20. package/dist/controllers/permissions.d.ts +29 -73
  21. package/dist/controllers/permissions.js +185 -191
  22. package/dist/controllers/permissions.js.map +1 -1
  23. package/dist/controllers/protocol.cjs.map +1 -1
  24. package/dist/controllers/protocol.d.ts +27 -28
  25. package/dist/controllers/protocol.js.map +1 -1
  26. package/dist/controllers/schemas.cjs +23 -21
  27. package/dist/controllers/schemas.cjs.map +1 -1
  28. package/dist/controllers/schemas.d.ts +47 -40
  29. package/dist/controllers/schemas.js +23 -21
  30. package/dist/controllers/schemas.js.map +1 -1
  31. package/dist/controllers/server.cjs +17 -15
  32. package/dist/controllers/server.cjs.map +1 -1
  33. package/dist/controllers/server.d.ts +46 -38
  34. package/dist/controllers/server.js +17 -15
  35. package/dist/controllers/server.js.map +1 -1
  36. package/dist/core/apiClient.cjs +53 -3
  37. package/dist/core/apiClient.cjs.map +1 -1
  38. package/dist/core/apiClient.d.ts +132 -7
  39. package/dist/core/apiClient.js +53 -3
  40. package/dist/core/apiClient.js.map +1 -1
  41. package/dist/core/generics.cjs +30 -3
  42. package/dist/core/generics.cjs.map +1 -1
  43. package/dist/core/generics.d.ts +95 -6
  44. package/dist/core/generics.js +30 -3
  45. package/dist/core/generics.js.map +1 -1
  46. package/dist/core.cjs +29 -12
  47. package/dist/core.cjs.map +1 -1
  48. package/dist/core.d.ts +2 -1
  49. package/dist/core.js +29 -12
  50. package/dist/core.js.map +1 -1
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/index.node.cjs +3 -3
  54. package/dist/index.node.cjs.map +1 -1
  55. package/dist/index.node.d.ts +8 -9
  56. package/dist/index.node.js +2 -2
  57. package/dist/index.node.js.map +1 -1
  58. package/dist/node.cjs.map +1 -1
  59. package/dist/node.d.ts +39 -1
  60. package/dist/node.js.map +1 -1
  61. package/dist/platform/browser.cjs +160 -2
  62. package/dist/platform/browser.cjs.map +1 -1
  63. package/dist/platform/browser.d.ts +232 -12
  64. package/dist/platform/browser.js +160 -2
  65. package/dist/platform/browser.js.map +1 -1
  66. package/dist/platform/interface.cjs.map +1 -1
  67. package/dist/platform/interface.d.ts +283 -90
  68. package/dist/platform/node.cjs +163 -2
  69. package/dist/platform/node.cjs.map +1 -1
  70. package/dist/platform/node.d.ts +69 -6
  71. package/dist/platform/node.js +163 -2
  72. package/dist/platform/node.js.map +1 -1
  73. package/dist/server/relayerHandler.cjs +214 -0
  74. package/dist/server/relayerHandler.cjs.map +1 -0
  75. package/dist/server/relayerHandler.d.ts +36 -0
  76. package/dist/server/relayerHandler.js +190 -0
  77. package/dist/server/relayerHandler.js.map +1 -0
  78. package/dist/storage/manager.cjs +108 -25
  79. package/dist/storage/manager.cjs.map +1 -1
  80. package/dist/storage/manager.d.ts +119 -25
  81. package/dist/storage/manager.js +108 -25
  82. package/dist/storage/manager.js.map +1 -1
  83. package/dist/storage/providers/callback-storage.cjs +86 -15
  84. package/dist/storage/providers/callback-storage.cjs.map +1 -1
  85. package/dist/storage/providers/callback-storage.d.ts +109 -20
  86. package/dist/storage/providers/callback-storage.js +86 -15
  87. package/dist/storage/providers/callback-storage.js.map +1 -1
  88. package/dist/storage/providers/pinata.cjs.map +1 -1
  89. package/dist/storage/providers/pinata.d.ts +12 -14
  90. package/dist/storage/providers/pinata.js.map +1 -1
  91. package/dist/tests/factories/mockFactory.d.ts +2 -2
  92. package/dist/tests/relayer-integration.test.d.ts +1 -0
  93. package/dist/tests/relayer-unified.test.d.ts +1 -0
  94. package/dist/tests/server-relayer-handler.test.d.ts +1 -0
  95. package/dist/types/blockchain.cjs.map +1 -1
  96. package/dist/types/blockchain.d.ts +39 -11
  97. package/dist/types/chains.cjs.map +1 -1
  98. package/dist/types/chains.d.ts +74 -7
  99. package/dist/types/chains.js.map +1 -1
  100. package/dist/types/config.cjs.map +1 -1
  101. package/dist/types/config.d.ts +46 -191
  102. package/dist/types/config.js.map +1 -1
  103. package/dist/types/contracts.cjs.map +1 -1
  104. package/dist/types/contracts.d.ts +71 -7
  105. package/dist/types/controller-context.cjs.map +1 -1
  106. package/dist/types/controller-context.d.ts +3 -2
  107. package/dist/types/data.cjs.map +1 -1
  108. package/dist/types/data.d.ts +4 -6
  109. package/dist/types/generics.cjs.map +1 -1
  110. package/dist/types/generics.d.ts +80 -9
  111. package/dist/types/index.cjs.map +1 -1
  112. package/dist/types/index.d.ts +27 -2
  113. package/dist/types/index.js.map +1 -1
  114. package/dist/types/operations.cjs.map +1 -1
  115. package/dist/types/operations.d.ts +132 -15
  116. package/dist/types/operations.js.map +1 -1
  117. package/dist/types/permissions.cjs.map +1 -1
  118. package/dist/types/permissions.d.ts +15 -20
  119. package/dist/types/personal.cjs.map +1 -1
  120. package/dist/types/personal.d.ts +131 -14
  121. package/dist/types/relayer.cjs.map +1 -1
  122. package/dist/types/relayer.d.ts +262 -35
  123. package/dist/types/storage.cjs.map +1 -1
  124. package/dist/types/storage.d.ts +9 -21
  125. package/dist/types/storage.js.map +1 -1
  126. package/dist/utils/grantFiles.cjs.map +1 -1
  127. package/dist/utils/grantFiles.d.ts +10 -20
  128. package/dist/utils/grantFiles.js.map +1 -1
  129. package/dist/utils/grantValidation.cjs.map +1 -1
  130. package/dist/utils/grantValidation.d.ts +95 -16
  131. package/dist/utils/grantValidation.js.map +1 -1
  132. package/dist/utils/grants.cjs.map +1 -1
  133. package/dist/utils/grants.d.ts +93 -12
  134. package/dist/utils/grants.js.map +1 -1
  135. package/dist/utils/lazy-import.cjs.map +1 -1
  136. package/dist/utils/lazy-import.d.ts +32 -7
  137. package/dist/utils/lazy-import.js.map +1 -1
  138. package/dist/utils/signatureCache.cjs +8 -2
  139. package/dist/utils/signatureCache.cjs.map +1 -1
  140. package/dist/utils/signatureCache.d.ts +49 -8
  141. package/dist/utils/signatureCache.js +8 -2
  142. package/dist/utils/signatureCache.js.map +1 -1
  143. package/dist/utils/transactionHelpers.cjs.map +1 -1
  144. package/dist/utils/transactionHelpers.d.ts +12 -12
  145. package/dist/utils/transactionHelpers.js.map +1 -1
  146. package/dist/utils/typedDataConverter.cjs.map +1 -1
  147. package/dist/utils/typedDataConverter.d.ts +39 -3
  148. package/dist/utils/typedDataConverter.js.map +1 -1
  149. package/dist/utils/urlResolver.cjs +7 -0
  150. package/dist/utils/urlResolver.cjs.map +1 -1
  151. package/dist/utils/urlResolver.d.ts +22 -4
  152. package/dist/utils/urlResolver.js +7 -0
  153. package/dist/utils/urlResolver.js.map +1 -1
  154. package/dist/utils/wallet.cjs +2 -1
  155. package/dist/utils/wallet.cjs.map +1 -1
  156. package/dist/utils/wallet.d.ts +78 -16
  157. package/dist/utils/wallet.js +2 -1
  158. package/dist/utils/wallet.js.map +1 -1
  159. package/package.json +1 -1
  160. package/dist/server/handler.cjs +0 -101
  161. package/dist/server/handler.cjs.map +0 -1
  162. package/dist/server/handler.d.ts +0 -87
  163. package/dist/server/handler.js +0 -77
  164. package/dist/server/handler.js.map +0 -1
  165. /package/dist/tests/{server-handler.test.d.ts → permissions-revoke-relayer.test.d.ts} +0 -0
@@ -6,90 +6,106 @@ import type { ControllerContext } from "./permissions";
6
6
  import { BaseController } from "./base";
7
7
  import { type DataSchema } from "../utils/schemaValidation";
8
8
  /**
9
- * Manages encrypted user data files and their blockchain registration on the Vana network.
9
+ * Manages encrypted user data files and blockchain registration on the Vana network.
10
10
  *
11
11
  * @remarks
12
- * This controller handles the complete file lifecycle from encrypted upload to
13
- * blockchain registration and decryption. It provides methods for querying user files,
14
- * uploading new encrypted content, managing file schemas, and handling permissions for
15
- * secure data sharing. All operations respect the user's privacy through client-side
16
- * encryption before any data leaves the user's device.
12
+ * The DataController provides comprehensive file lifecycle management from encrypted upload
13
+ * through blockchain registration to decryption. Client-side encryption ensures data privacy
14
+ * before transmission. The controller integrates with multiple storage providers (IPFS, Pinata,
15
+ * Google Drive) and supports both gasless transactions via relayers and direct blockchain interaction.
17
16
  *
18
- * The controller integrates with multiple storage providers (IPFS, Pinata, Google Drive)
19
- * and supports both gasless transactions via relayers and direct blockchain interaction.
20
- * File metadata and access permissions are stored on the Vana blockchain while encrypted
21
- * file content is stored on decentralized storage networks.
17
+ * **Architecture:**
18
+ * Files use dual storage: encrypted content on decentralized storage (IPFS/Pinata/Google Drive),
19
+ * metadata and permissions on blockchain. This design minimizes on-chain data while maintaining
20
+ * decentralization and access control.
22
21
  *
23
22
  * **Method Selection:**
24
- * - `upload()` handles encryption, storage, and blockchain registration automatically
25
- * - `getUserFiles()` queries existing file metadata from blockchain and subgraph
26
- * - `decryptFile()` decrypts files for which you have access permissions
27
- * - `getFileById()` retrieves specific file metadata when you have the file ID
23
+ * - `upload()` - Complete workflow: encryption, storage, blockchain registration
24
+ * - `getUserFiles()` - Query file metadata from blockchain/subgraph
25
+ * - `decryptFile()` - Decrypt files you have permission to access
26
+ * - `getFileById()` - Retrieve specific file metadata by ID
28
27
  *
29
28
  * **Storage Requirements:**
30
- * Methods requiring storage configuration: `upload()`
31
- * Methods working without storage: `getUserFiles()`, `decryptFile()`, `getFileById()`
29
+ * - Methods requiring storage: `upload()`, `encryptFile()`
30
+ * - Methods working without storage: `getUserFiles()`, `decryptFile()`, `getFileById()`
31
+ *
32
+ * **Permission Model:**
33
+ * - File permissions (decryption access) are handled during upload
34
+ * - Operation permissions (what can be done with data) use `vana.permissions.grant()`
35
+ *
32
36
  * @example
33
37
  * ```typescript
34
- * // Upload an encrypted file with automatic schema validation
38
+ * // Upload encrypted file with schema validation
35
39
  * const result = await vana.data.upload({
36
- * content: "My personal data",
37
- * filename: "personal-data.json"
40
+ * content: { name: "Alice", age: 30 },
41
+ * filename: "profile.json",
42
+ * schemaId: 1
38
43
  * });
44
+ * console.log(`File uploaded: ID ${result.fileId}, URL ${result.url}`);
39
45
  *
40
- * // Query files owned by a user
46
+ * // Query user's files
41
47
  * const files = await vana.data.getUserFiles({
42
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
48
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
43
49
  * });
50
+ * files.forEach(file => console.log(`File ${file.id}: ${file.url}`));
44
51
  *
45
- * // Decrypt accessible file content
52
+ * // Decrypt accessible file
46
53
  * const decryptedData = await vana.data.decryptFile(files[0]);
54
+ * console.log("Decrypted content:", decryptedData);
47
55
  * ```
56
+ *
48
57
  * @category Data Management
49
- * @see {@link https://docs.vana.com/developer/data-registry | Vana Data Registry Documentation} for conceptual overview
58
+ * @see For conceptual overview, visit {@link https://docs.vana.org/docs/data-registry}
50
59
  */
51
60
  export declare class DataController extends BaseController {
52
61
  constructor(context: ControllerContext);
53
62
  /**
54
- * Uploads user data with automatic encryption and blockchain registration.
63
+ * Uploads data with automatic encryption and blockchain registration.
55
64
  *
56
65
  * @remarks
57
- * This is the primary method for uploading user data to the Vana network. It handles
58
- * the complete workflow including content normalization, schema validation, encryption,
59
- * storage upload, file permission granting, and blockchain registration.
60
- *
61
- * The method automatically:
62
- * - Normalizes input content to a Blob
63
- * - Validates data against schema if provided
64
- * - Generates encryption keys and encrypts the data
65
- * - Uploads to the configured storage provider
66
- * - Grants file decryption permissions to specified accounts
67
- * - Registers the file on the blockchain
66
+ * Primary method for uploading data to Vana. Handles complete workflow:
67
+ * content normalization, schema validation, encryption, storage upload,
68
+ * permission granting, and blockchain registration.
69
+ *
70
+ * **Automatic Processing:**
71
+ * - Normalizes content to Blob format
72
+ * - Validates against schema if provided
73
+ * - Generates encryption keys
74
+ * - Uploads to configured storage
75
+ * - Grants decryption permissions
76
+ * - Registers on blockchain
68
77
  *
69
78
  * **TypeScript Overloads:**
70
- * This method has three overloads to ensure type safety:
71
- * 1. `EncryptedUploadParams` - When `encrypt: true` (default), permissions require publicKey
72
- * 2. `UnencryptedUploadParams` - When `encrypt: false`, permissions are optional
73
- * 3. `UploadParams` - General signature for runtime determination
74
- *
75
- * IMPORTANT: The permissions parameter only grants decryption access to the file.
76
- * To grant operation permissions (like "llm_inference"), use vana.permissions.grant()
77
- * after uploading. This separation ensures clear distinction between:
78
- * - File permissions: Who can decrypt and read the encrypted file (handled here)
79
- * - Operation permissions: What operations can be performed on the data (handled separately)
80
- *
81
- * @param params - Upload parameters including content, filename, schema, and permissions
82
- * @param params.permissions - Optional array of file permissions for granting decryption access
83
- * @param params.schemaId - Optional schema ID for data validation. Get available schemas from `vana.schemas.list()`.
84
- * @param params.owner - Optional owner address if uploading on behalf of another user (requires delegation).
85
- * @returns Promise resolving to upload results with file ID and transaction hash
86
- * @throws {Error} When storage manager is not configured - "Storage manager not configured. Please provide storage providers in VanaConfig."
87
- * @throws {Error} When no wallet addresses available - "No addresses available in wallet client"
88
- * @throws {Error} When chain ID is not available - "Chain ID not available"
89
- * @throws {Error} When relay callback doesn't support required features - "The configured relay callback does not support schemas or permissions"
90
- * @throws {Error} When schema fetch fails - "Failed to fetch schema definition: {status}"
91
- * @throws {SchemaValidationError} When data doesn't match schema - includes specific validation errors
92
- * @throws {Error} General upload failures - "Upload failed: {specific error message}"
79
+ * - `EncryptedUploadParams`: When `encrypt: true` (default), permissions require `publicKey`
80
+ * - `UnencryptedUploadParams`: When `encrypt: false`, permissions optional
81
+ * - `UploadParams`: General signature for runtime determination
82
+ *
83
+ * **Permission Separation:**
84
+ * - File permissions (here): Decryption access only
85
+ * - Operation permissions: Use `vana.permissions.grant()` separately
86
+ *
87
+ * @param params - Upload configuration object
88
+ * @param params.content - Data to upload (string, object, or Blob)
89
+ * @param params.filename - Name for the uploaded file
90
+ * @param params.permissions - Decryption access grants.
91
+ * Each requires `account` and `publicKey` for encryption.
92
+ * @param params.schemaId - Schema for validation.
93
+ * Obtain via `vana.schemas.list()`.
94
+ * @param params.owner - Owner address for delegation scenarios.
95
+ * Defaults to connected wallet address.
96
+ * @param params.encrypt - Enable encryption (default: `true`)
97
+ * @param params.providerName - Storage provider override
98
+ *
99
+ * @returns Upload result with file ID, URL, and transaction hash
100
+ *
101
+ * @throws {Error} Storage not configured.
102
+ * Configure storage providers in `VanaConfig`.
103
+ * @throws {Error} No wallet addresses available.
104
+ * Ensure wallet is connected.
105
+ * @throws {SchemaValidationError} Data doesn't match schema.
106
+ * Verify data structure matches schema from `vana.schemas.get(schemaId)`.
107
+ * @throws {Error} Upload failed with specific error message.
108
+ *
93
109
  * @example
94
110
  * ```typescript
95
111
  * // Basic file upload
@@ -192,35 +208,33 @@ export declare class DataController extends BaseController {
192
208
  */
193
209
  encryptFile(data: Blob | string | object, options?: EncryptFileOptions): Promise<EncryptFileResult>;
194
210
  /**
195
- * Decrypts a file owned by the user using their wallet signature.
211
+ * Decrypts a file using wallet-derived decryption key.
196
212
  *
197
213
  * @remarks
198
- * This is the high-level convenience method for decrypting user files, serving as the
199
- * symmetrical counterpart to the `upload` method. It handles the complete decryption
200
- * workflow including key generation, URL protocol detection, content fetching, and
201
- * decryption.
214
+ * Counterpart to `upload()` for decrypting user files. Automatically
215
+ * generates decryption key from wallet, fetches encrypted content,
216
+ * and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
217
+ *
218
+ * @param file - UserFile object from `getUserFiles()`
219
+ * @param options - Decryption options
220
+ * @param options.seed - Custom encryption seed.
221
+ * Defaults to standard Vana seed.
222
+ *
223
+ * @returns Decrypted content as Blob
224
+ *
225
+ * @throws {Error} No wallet connected.
226
+ * Connect wallet before decrypting.
227
+ * @throws {Error} Network error accessing file.
228
+ * Check CORS settings or server availability.
229
+ * @throws {Error} File not found (404).
230
+ * File no longer available at stored URL.
231
+ * @throws {Error} Access denied (403).
232
+ * No permission to access file.
233
+ * @throws {Error} Invalid file format.
234
+ * File not encrypted with Vana protocol.
235
+ * @throws {Error} Wrong encryption key.
236
+ * Verify seed matches upload or use default.
202
237
  *
203
- * The method automatically:
204
- * - Generates the decryption key from the user's wallet signature
205
- * - Determines the appropriate fetch method based on the file URL protocol
206
- * - Fetches the encrypted content from IPFS or standard HTTP URLs
207
- * - Decrypts the content using the generated key
208
- *
209
- * For IPFS URLs, the method uses gateway fallback for improved reliability. For
210
- * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
211
- * headers or specific gateway configurations, use the low-level primitives directly.
212
- *
213
- * @param file - The user file to decrypt (typically from getUserFiles)
214
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
215
- * @returns Promise resolving to the decrypted file content as a Blob
216
- * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
217
- * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
218
- * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
219
- * @throws {Error} "Access denied" - When file returns 403 (no permission)
220
- * @throws {Error} "File is empty or could not be retrieved" - When file has no content
221
- * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
222
- * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
223
- * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
224
238
  * @example
225
239
  * ```typescript
226
240
  * // Basic file decryption
@@ -248,35 +262,38 @@ export declare class DataController extends BaseController {
248
262
  */
249
263
  decryptFile(file: UserFile, options?: DecryptFileOptions): Promise<Blob>;
250
264
  /**
251
- * Retrieves all data files owned by a specific user address.
265
+ * Retrieves all files owned by a specific user address.
252
266
  *
253
267
  * @remarks
254
- * This method queries the Vana subgraph to find files directly owned by the user.
255
- * It efficiently handles large datasets by using the File entity's owner field
256
- * and returns complete file metadata without additional contract calls.
257
- *
258
- * **Deduplication Behavior:**
259
- * The method automatically deduplicates files by ID, keeping only the latest version
260
- * (highest timestamp) when duplicate file IDs are found. This handles cases where
261
- * the subgraph may contain multiple entries for the same file due to re-indexing
262
- * or blockchain reorganizations.
263
- * @param params - The query parameters object
264
- * @param params.owner - The wallet address of the file owner to query
265
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
266
- * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
267
- * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
268
- * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
269
- * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
270
- * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
268
+ * Queries the Vana subgraph for files owned by the specified address.
269
+ * Automatically deduplicates by file ID, keeping the latest version
270
+ * when duplicates exist from re-indexing or chain reorganizations.
271
+ * Enriches results with DLP proof data when available.
272
+ *
273
+ * @param params - Query configuration
274
+ * @param params.owner - Wallet address of the file owner
275
+ * @param params.subgraphUrl - Subgraph endpoint override.
276
+ * Defaults to context configuration.
277
+ *
278
+ * @returns Array of UserFile objects sorted by timestamp (newest first)
279
+ *
280
+ * @throws {Error} Subgraph URL not configured.
281
+ * Provide `subgraphUrl` parameter or configure in Vana constructor.
282
+ * @throws {Error} Subgraph request failed.
283
+ * Check network connectivity and subgraph availability.
284
+ * @throws {Error} Subgraph returned errors.
285
+ * Review query parameters and subgraph logs.
286
+ *
271
287
  * @example
272
288
  * ```typescript
273
- * // Query files for a specific user
274
289
  * const files = await vana.data.getUserFiles({
275
- * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
290
+ * owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
276
291
  * });
277
292
  *
278
293
  * files.forEach(file => {
279
- * console.log(`File ${file.id}: ${file.url} (Schema: ${file.schemaId})`);
294
+ * console.log(`File ${file.id}: ${file.url}`);
295
+ * console.log(` Schema: ${file.schemaId}`);
296
+ * console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
280
297
  * });
281
298
  * ```
282
299
  */
@@ -468,48 +485,56 @@ export declare class DataController extends BaseController {
468
485
  */
469
486
  private _getUserTrustedServersViaRpc;
470
487
  /**
471
- * Gets the total number of files in the registry from the contract.
488
+ * Retrieves total file count from Data Registry.
489
+ *
490
+ * @remarks
491
+ * Queries blockchain for complete file count across all users.
492
+ * Useful for pagination and network statistics.
493
+ *
494
+ * @returns Total number of registered files
495
+ *
496
+ * @throws {Error} Chain ID not available.
497
+ * Ensure network connection.
498
+ * @throws {Error} Contract read failed.
499
+ * Check RPC availability.
472
500
  *
473
- * @returns Promise resolving to the total file count
474
501
  * @example
475
502
  * ```typescript
476
- * const totalFiles = await vana.data.getTotalFilesCount();
477
- * console.log(`Total files in registry: ${totalFiles}`);
503
+ * const total = await vana.data.getTotalFilesCount();
504
+ * console.log(`Total files: ${total}`);
478
505
  *
479
- * // Use for pagination calculations
480
- * const filesPerPage = 20;
481
- * const totalPages = Math.ceil(totalFiles / filesPerPage);
482
- * console.log(`Total pages: ${totalPages}`);
506
+ * // Calculate pagination
507
+ * const pages = Math.ceil(total / 20);
483
508
  * ```
484
509
  */
485
510
  getTotalFilesCount(): Promise<number>;
486
511
  /**
487
- * Retrieves details for a specific file by its ID.
512
+ * Retrieves file metadata by ID from the blockchain.
513
+ *
514
+ * @remarks
515
+ * Queries DataRegistry contract directly for file details.
516
+ * Works for any file ID regardless of ownership, enabling
517
+ * cross-user file discovery and verification.
518
+ *
519
+ * @param fileId - Numeric file ID to retrieve
520
+ *
521
+ * @returns UserFile object with metadata
522
+ *
523
+ * @throws {Error} Chain ID not available.
524
+ * Ensure proper network connection.
525
+ * @throws {Error} File not found.
526
+ * Verify file ID exists on-chain.
527
+ * @throws {Error} Contract call failed.
528
+ * Check network and RPC availability.
488
529
  *
489
- * @param fileId - The file ID to look up
490
- * @returns Promise resolving to UserFile object
491
- * @throws {Error} "Chain ID not available" - When wallet chain is not configured
492
- * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
493
- * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
494
530
  * @example
495
531
  * ```typescript
496
- * try {
497
- * const file = await vana.data.getFileById(123);
498
- * console.log('File details:', {
499
- * id: file.id,
500
- * url: file.url,
501
- * owner: file.ownerAddress,
502
- * addedAt: file.addedAtBlock
503
- * });
504
- * } catch (error) {
505
- * console.error('File not found or error retrieving file:', error);
506
- * }
532
+ * const file = await vana.data.getFileById(123);
533
+ * console.log(`File ${file.id}:`);
534
+ * console.log(` URL: ${file.url}`);
535
+ * console.log(` Owner: ${file.ownerAddress}`);
536
+ * console.log(` Block: ${file.addedAtBlock}`);
507
537
  * ```
508
- *
509
- * This method queries the DataRegistry contract directly
510
- * to get file details for any file ID, regardless of user ownership.
511
- * This is useful for file lookup functionality where users can search
512
- * for specific files by ID.
513
538
  */
514
539
  getFileById(fileId: number): Promise<UserFile>;
515
540
  /**
@@ -648,74 +673,87 @@ export declare class DataController extends BaseController {
648
673
  key: string;
649
674
  }>, schemaId?: number): Promise<TransactionResult<"DataRegistry", "addFileWithPermissionsAndSchema">>;
650
675
  /**
651
- * Adds a new refiner to the DataRefinerRegistry.
676
+ * Registers a data refiner for processing templates.
652
677
  *
653
678
  * @remarks
654
- * Refiners are data processing templates that define how raw data should be
655
- * transformed into structured formats. Each refiner is associated with a DLP
656
- * (Data Liquidity Pool), has a specific schema for output, and includes
657
- * instructions for the refinement process.
658
- *
659
- * @param params - Refiner configuration parameters
660
- * @param params.dlpId - The Data Liquidity Pool ID this refiner belongs to
661
- * @param params.name - Human-readable name for the refiner
662
- * @param params.schemaId - Schema ID that defines the output format
663
- * @param params.refinementInstructionUrl - URL containing processing instructions
664
- * @returns Promise resolving to the new refiner ID and transaction hash
665
- * @throws {Error} When chain ID is not available - "Chain ID not available"
666
- * @throws {Error} When transaction fails - "Failed to add refiner: {error}"
679
+ * Refiners define data transformation rules for DLPs.
680
+ * Associates schema, instructions, and processing logic.
681
+ *
682
+ * @param params - Refiner configuration
683
+ * @param params.dlpId - Data Liquidity Pool ID
684
+ * @param params.name - Refiner display name
685
+ * @param params.schemaId - Output schema ID.
686
+ * Obtain via `vana.schemas.list()`.
687
+ * @param params.refinementInstructionUrl - Processing instructions URL
688
+ *
689
+ * @returns Refiner ID and transaction hash
690
+ *
691
+ * @throws {Error} Chain ID not available.
692
+ * Ensure network connection.
693
+ * @throws {Error} Transaction failed.
694
+ * Check wallet balance and network status.
695
+ *
667
696
  * @example
668
697
  * ```typescript
669
698
  * const result = await vana.data.addRefiner({
670
699
  * dlpId: 1,
671
- * name: "Social Media Sentiment Analyzer",
700
+ * name: "Sentiment Analyzer",
672
701
  * schemaId: 42,
673
702
  * refinementInstructionUrl: "ipfs://QmXxx..."
674
703
  * });
675
- * console.log(`Created refiner ${result.refinerId} in tx ${result.transactionHash}`);
704
+ * console.log(`Refiner ${result.refinerId} created`);
676
705
  * ```
677
706
  */
678
707
  addRefiner(params: AddRefinerParams): Promise<AddRefinerResult>;
679
708
  /**
680
- * Retrieves a refiner by its ID.
709
+ * Retrieves refiner configuration by ID.
681
710
  *
682
711
  * @remarks
683
- * Queries the DataRefinerRegistry contract to get complete information about
684
- * a specific refiner including its DLP association, schema, and instructions.
712
+ * Queries DataRefinerRegistry for refiner details.
713
+ * Returns DLP association, schema, and processing instructions.
714
+ *
715
+ * @param refinerId - Numeric refiner ID
716
+ *
717
+ * @returns Refiner configuration object
718
+ *
719
+ * @throws {Error} Chain ID not available.
720
+ * Ensure network connection.
721
+ * @throws {Error} Refiner not found.
722
+ * Verify refiner ID exists.
723
+ * @throws {Error} Contract read failed.
724
+ * Check network and RPC status.
685
725
  *
686
- * @param refinerId - The numeric refiner ID to retrieve
687
- * @returns Promise resolving to the refiner information object
688
- * @throws {Error} When chain ID is not available - "Chain ID not available"
689
- * @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
690
- * @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
691
726
  * @example
692
727
  * ```typescript
693
728
  * const refiner = await vana.data.getRefiner(1);
694
- * console.log({
695
- * name: refiner.name,
696
- * dlp: refiner.dlpId,
697
- * schema: refiner.schemaId,
698
- * instructions: refiner.refinementInstructionUrl
699
- * });
729
+ * console.log(`Refiner: ${refiner.name}`);
730
+ * console.log(`DLP: ${refiner.dlpId}`);
731
+ * console.log(`Schema: ${refiner.schemaId}`);
700
732
  * ```
701
733
  */
702
734
  getRefiner(refinerId: number): Promise<Refiner>;
703
735
  /**
704
- * Validates if a schema ID exists in the registry.
736
+ * Validates schema ID existence.
705
737
  *
706
738
  * @remarks
707
- * Checks the DataRefinerRegistry contract to determine if a given schema ID
708
- * has been registered and is available for use.
739
+ * Verifies schema registration in DataRegistry.
740
+ * Check before using schemas for uploads.
741
+ *
742
+ * @param schemaId - Numeric schema ID to validate
743
+ *
744
+ * @returns True if schema exists, false otherwise
745
+ *
746
+ * @throws {Error} Chain ID not available.
747
+ * Ensure network connection.
748
+ * @throws {Error} Contract read failed.
749
+ * Check RPC availability.
709
750
  *
710
- * @param schemaId - The numeric schema ID to validate
711
- * @returns Promise resolving to true if schema exists, false otherwise
712
751
  * @example
713
752
  * ```typescript
714
- * const isValid = await vana.data.isValidSchemaId(42);
715
- * if (isValid) {
716
- * console.log('Schema 42 is available for use');
717
- * } else {
718
- * console.log('Schema 42 does not exist');
753
+ * const valid = await vana.data.isValidSchemaId(42);
754
+ * if (valid) {
755
+ * // Safe to use schema 42
756
+ * await vana.data.upload({ schemaId: 42, ... });
719
757
  * }
720
758
  * ```
721
759
  */