@varity-labs/sdk 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +31 -0
- package/README.md +253 -0
- package/dist/analytics/index.d.ts +7 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +6 -0
- package/dist/analytics/tracker.d.ts +128 -0
- package/dist/analytics/tracker.d.ts.map +1 -0
- package/dist/analytics/tracker.js +203 -0
- package/dist/blockchain/BlockchainService.d.ts +100 -0
- package/dist/blockchain/BlockchainService.d.ts.map +1 -0
- package/dist/blockchain/BlockchainService.js +188 -0
- package/dist/blockchain/NFTLicensingService.d.ts +69 -0
- package/dist/blockchain/NFTLicensingService.d.ts.map +1 -0
- package/dist/blockchain/NFTLicensingService.js +136 -0
- package/dist/blockchain/RevenueSplitService.d.ts +71 -0
- package/dist/blockchain/RevenueSplitService.d.ts.map +1 -0
- package/dist/blockchain/RevenueSplitService.js +111 -0
- package/dist/blockchain/index.d.ts +48 -0
- package/dist/blockchain/index.d.ts.map +1 -0
- package/dist/blockchain/index.js +46 -0
- package/dist/blockchain/types.d.ts +63 -0
- package/dist/blockchain/types.d.ts.map +1 -0
- package/dist/blockchain/types.js +6 -0
- package/dist/chains/arbitrum.d.ts +89 -0
- package/dist/chains/arbitrum.d.ts.map +1 -0
- package/dist/chains/arbitrum.js +134 -0
- package/dist/chains/base.d.ts +84 -0
- package/dist/chains/base.d.ts.map +1 -0
- package/dist/chains/base.js +131 -0
- package/dist/chains/index.d.ts +36 -0
- package/dist/chains/index.d.ts.map +1 -0
- package/dist/chains/index.js +32 -0
- package/dist/chains/registry.d.ts +113 -0
- package/dist/chains/registry.d.ts.map +1 -0
- package/dist/chains/registry.js +201 -0
- package/dist/chains/varityL3.d.ts +81 -0
- package/dist/chains/varityL3.d.ts.map +1 -0
- package/dist/chains/varityL3.js +125 -0
- package/dist/cli/commands/clone.d.ts +8 -0
- package/dist/cli/commands/clone.d.ts.map +1 -0
- package/dist/cli/commands/clone.js +391 -0
- package/dist/cli/commands/dev.d.ts +8 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +40 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +303 -0
- package/dist/cli/commands/init.d.ts +8 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +317 -0
- package/dist/cli/commands/validate.d.ts +8 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +69 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +33 -0
- package/dist/cli/utils/logger.d.ts +17 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +35 -0
- package/dist/cli/utils/prompts.d.ts +21 -0
- package/dist/cli/utils/prompts.d.ts.map +1 -0
- package/dist/cli/utils/prompts.js +103 -0
- package/dist/contracts/abis/iso/AccessControlRegistry.json +1468 -0
- package/dist/contracts/abis/iso/DataProofRegistry.json +797 -0
- package/dist/contracts/abis/iso/MerchantRegistry.json +1237 -0
- package/dist/contracts/abis/iso/RepPerformance.json +1351 -0
- package/dist/contracts/abis/iso/ResidualCalculator.json +1118 -0
- package/dist/contracts/abis/iso/TransactionVault.json +1588 -0
- package/dist/contracts/abis/iso/VarityWalletFactory.json +475 -0
- package/dist/contracts/addresses.d.ts +88 -0
- package/dist/contracts/addresses.d.ts.map +1 -0
- package/dist/contracts/addresses.js +94 -0
- package/dist/contracts/index.d.ts +7 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +6 -0
- package/dist/core/VaritySDK.d.ts +177 -0
- package/dist/core/VaritySDK.d.ts.map +1 -0
- package/dist/core/VaritySDK.js +325 -0
- package/dist/core/config.d.ts +120 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +187 -0
- package/dist/core/credentials-proxy.d.ts +157 -0
- package/dist/core/credentials-proxy.d.ts.map +1 -0
- package/dist/core/credentials-proxy.js +345 -0
- package/dist/core/credentials.d.ts +219 -0
- package/dist/core/credentials.d.ts.map +1 -0
- package/dist/core/credentials.js +345 -0
- package/dist/core/template-loader.d.ts +15 -0
- package/dist/core/template-loader.d.ts.map +1 -0
- package/dist/core/template-loader.js +380 -0
- package/dist/core/template.d.ts +321 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/template.js +189 -0
- package/dist/core/types.d.ts +572 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +52 -0
- package/dist/dev/dev-server.d.ts +16 -0
- package/dist/dev/dev-server.d.ts.map +1 -0
- package/dist/dev/dev-server.js +119 -0
- package/dist/generators/contracts/generator.d.ts +21 -0
- package/dist/generators/contracts/generator.d.ts.map +1 -0
- package/dist/generators/contracts/generator.js +252 -0
- package/dist/generators/tests/generator.d.ts +20 -0
- package/dist/generators/tests/generator.d.ts.map +1 -0
- package/dist/generators/tests/generator.js +375 -0
- package/dist/generators/types/generator.d.ts +19 -0
- package/dist/generators/types/generator.d.ts.map +1 -0
- package/dist/generators/types/generator.js +165 -0
- package/dist/generators/ui/component-generator.d.ts +20 -0
- package/dist/generators/ui/component-generator.d.ts.map +1 -0
- package/dist/generators/ui/component-generator.js +749 -0
- package/dist/generators/ui/dashboard-generator.d.ts +20 -0
- package/dist/generators/ui/dashboard-generator.d.ts.map +1 -0
- package/dist/generators/ui/dashboard-generator.js +349 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/modules/analytics/AnalyticsModule.d.ts +349 -0
- package/dist/modules/analytics/AnalyticsModule.d.ts.map +1 -0
- package/dist/modules/analytics/AnalyticsModule.js +274 -0
- package/dist/modules/analytics/index.d.ts +3 -0
- package/dist/modules/analytics/index.d.ts.map +1 -0
- package/dist/modules/analytics/index.js +1 -0
- package/dist/modules/auth/AccessKeyModule.d.ts +189 -0
- package/dist/modules/auth/AccessKeyModule.d.ts.map +1 -0
- package/dist/modules/auth/AccessKeyModule.js +322 -0
- package/dist/modules/auth/AuthModule.d.ts +133 -0
- package/dist/modules/auth/AuthModule.d.ts.map +1 -0
- package/dist/modules/auth/AuthModule.js +214 -0
- package/dist/modules/auth/index.d.ts +8 -0
- package/dist/modules/auth/index.d.ts.map +1 -0
- package/dist/modules/auth/index.js +6 -0
- package/dist/modules/cache/CacheModule.d.ts +279 -0
- package/dist/modules/cache/CacheModule.d.ts.map +1 -0
- package/dist/modules/cache/CacheModule.js +493 -0
- package/dist/modules/cache/index.d.ts +3 -0
- package/dist/modules/cache/index.d.ts.map +1 -0
- package/dist/modules/cache/index.js +1 -0
- package/dist/modules/compute/ComputeModule.d.ts +226 -0
- package/dist/modules/compute/ComputeModule.d.ts.map +1 -0
- package/dist/modules/compute/ComputeModule.js +379 -0
- package/dist/modules/compute/index.d.ts +6 -0
- package/dist/modules/compute/index.d.ts.map +1 -0
- package/dist/modules/compute/index.js +4 -0
- package/dist/modules/contracts/ContractsModule.d.ts +164 -0
- package/dist/modules/contracts/ContractsModule.d.ts.map +1 -0
- package/dist/modules/contracts/ContractsModule.js +242 -0
- package/dist/modules/contracts/index.d.ts +6 -0
- package/dist/modules/contracts/index.d.ts.map +1 -0
- package/dist/modules/contracts/index.js +4 -0
- package/dist/modules/export/ExportModule.d.ts +346 -0
- package/dist/modules/export/ExportModule.d.ts.map +1 -0
- package/dist/modules/export/ExportModule.js +432 -0
- package/dist/modules/export/index.d.ts +3 -0
- package/dist/modules/export/index.d.ts.map +1 -0
- package/dist/modules/export/index.js +1 -0
- package/dist/modules/forecasting/ForecastingModule.d.ts +579 -0
- package/dist/modules/forecasting/ForecastingModule.d.ts.map +1 -0
- package/dist/modules/forecasting/ForecastingModule.js +310 -0
- package/dist/modules/forecasting/index.d.ts +3 -0
- package/dist/modules/forecasting/index.d.ts.map +1 -0
- package/dist/modules/forecasting/index.js +1 -0
- package/dist/modules/monitoring/MonitoringModule.d.ts +359 -0
- package/dist/modules/monitoring/MonitoringModule.d.ts.map +1 -0
- package/dist/modules/monitoring/MonitoringModule.js +483 -0
- package/dist/modules/monitoring/index.d.ts +3 -0
- package/dist/modules/monitoring/index.d.ts.map +1 -0
- package/dist/modules/monitoring/index.js +1 -0
- package/dist/modules/notifications/NotificationsModule.d.ts +336 -0
- package/dist/modules/notifications/NotificationsModule.d.ts.map +1 -0
- package/dist/modules/notifications/NotificationsModule.js +418 -0
- package/dist/modules/notifications/index.d.ts +3 -0
- package/dist/modules/notifications/index.d.ts.map +1 -0
- package/dist/modules/notifications/index.js +1 -0
- package/dist/modules/oracle/OracleModule.d.ts +110 -0
- package/dist/modules/oracle/OracleModule.d.ts.map +1 -0
- package/dist/modules/oracle/OracleModule.js +151 -0
- package/dist/modules/oracle/index.d.ts +6 -0
- package/dist/modules/oracle/index.d.ts.map +1 -0
- package/dist/modules/oracle/index.js +4 -0
- package/dist/modules/storage/S3Module.d.ts +377 -0
- package/dist/modules/storage/S3Module.d.ts.map +1 -0
- package/dist/modules/storage/S3Module.js +680 -0
- package/dist/modules/storage/StorageModule.d.ts +157 -0
- package/dist/modules/storage/StorageModule.d.ts.map +1 -0
- package/dist/modules/storage/StorageModule.js +302 -0
- package/dist/modules/storage/adapters/AdapterFactory.d.ts +100 -0
- package/dist/modules/storage/adapters/AdapterFactory.d.ts.map +1 -0
- package/dist/modules/storage/adapters/AdapterFactory.js +209 -0
- package/dist/modules/storage/adapters/FilecoinAdapter.d.ts +94 -0
- package/dist/modules/storage/adapters/FilecoinAdapter.d.ts.map +1 -0
- package/dist/modules/storage/adapters/FilecoinAdapter.js +263 -0
- package/dist/modules/storage/adapters/IStorageAdapter.d.ts +287 -0
- package/dist/modules/storage/adapters/IStorageAdapter.d.ts.map +1 -0
- package/dist/modules/storage/adapters/IStorageAdapter.js +81 -0
- package/dist/modules/storage/adapters/MultiTierAdapter.d.ts +187 -0
- package/dist/modules/storage/adapters/MultiTierAdapter.d.ts.map +1 -0
- package/dist/modules/storage/adapters/MultiTierAdapter.js +430 -0
- package/dist/modules/storage/adapters/index.d.ts +12 -0
- package/dist/modules/storage/adapters/index.d.ts.map +1 -0
- package/dist/modules/storage/adapters/index.js +12 -0
- package/dist/modules/storage/index.d.ts +16 -0
- package/dist/modules/storage/index.d.ts.map +1 -0
- package/dist/modules/storage/index.js +15 -0
- package/dist/modules/storage/tiering/AccessAnalyzer.d.ts +227 -0
- package/dist/modules/storage/tiering/AccessAnalyzer.d.ts.map +1 -0
- package/dist/modules/storage/tiering/AccessAnalyzer.js +367 -0
- package/dist/modules/storage/tiering/CostOptimizer.d.ts +248 -0
- package/dist/modules/storage/tiering/CostOptimizer.d.ts.map +1 -0
- package/dist/modules/storage/tiering/CostOptimizer.js +356 -0
- package/dist/modules/storage/tiering/MetadataStore.d.ts +287 -0
- package/dist/modules/storage/tiering/MetadataStore.d.ts.map +1 -0
- package/dist/modules/storage/tiering/MetadataStore.js +535 -0
- package/dist/modules/storage/tiering/TieringEngine.d.ts +237 -0
- package/dist/modules/storage/tiering/TieringEngine.d.ts.map +1 -0
- package/dist/modules/storage/tiering/TieringEngine.js +419 -0
- package/dist/modules/storage/tiering/example.d.ts +8 -0
- package/dist/modules/storage/tiering/example.d.ts.map +1 -0
- package/dist/modules/storage/tiering/example.js +250 -0
- package/dist/modules/storage/tiering/index.d.ts +17 -0
- package/dist/modules/storage/tiering/index.d.ts.map +1 -0
- package/dist/modules/storage/tiering/index.js +13 -0
- package/dist/modules/webhooks/WebhooksModule.d.ts +476 -0
- package/dist/modules/webhooks/WebhooksModule.d.ts.map +1 -0
- package/dist/modules/webhooks/WebhooksModule.js +359 -0
- package/dist/modules/webhooks/index.d.ts +3 -0
- package/dist/modules/webhooks/index.d.ts.map +1 -0
- package/dist/modules/webhooks/index.js +1 -0
- package/dist/modules/zk/ZKModule.d.ts +153 -0
- package/dist/modules/zk/ZKModule.d.ts.map +1 -0
- package/dist/modules/zk/ZKModule.js +262 -0
- package/dist/modules/zk/index.d.ts +7 -0
- package/dist/modules/zk/index.d.ts.map +1 -0
- package/dist/modules/zk/index.js +4 -0
- package/dist/thirdweb/BridgeClient.d.ts +228 -0
- package/dist/thirdweb/BridgeClient.d.ts.map +1 -0
- package/dist/thirdweb/BridgeClient.js +160 -0
- package/dist/thirdweb/EngineClient.d.ts +396 -0
- package/dist/thirdweb/EngineClient.d.ts.map +1 -0
- package/dist/thirdweb/EngineClient.js +386 -0
- package/dist/thirdweb/GatewayClient.d.ts +190 -0
- package/dist/thirdweb/GatewayClient.d.ts.map +1 -0
- package/dist/thirdweb/GatewayClient.js +257 -0
- package/dist/thirdweb/NebulaClient.d.ts +292 -0
- package/dist/thirdweb/NebulaClient.d.ts.map +1 -0
- package/dist/thirdweb/NebulaClient.js +180 -0
- package/dist/thirdweb/StorageClient.d.ts +445 -0
- package/dist/thirdweb/StorageClient.d.ts.map +1 -0
- package/dist/thirdweb/StorageClient.js +405 -0
- package/dist/thirdweb/ThirdwebWrapper.d.ts +236 -0
- package/dist/thirdweb/ThirdwebWrapper.d.ts.map +1 -0
- package/dist/thirdweb/ThirdwebWrapper.js +332 -0
- package/dist/thirdweb/index.d.ts +21 -0
- package/dist/thirdweb/index.d.ts.map +1 -0
- package/dist/thirdweb/index.js +28 -0
- package/dist/thirdweb/varity-chain.d.ts +48 -0
- package/dist/thirdweb/varity-chain.d.ts.map +1 -0
- package/dist/thirdweb/varity-chain.js +64 -0
- package/dist/thirdweb/x402Client.d.ts +319 -0
- package/dist/thirdweb/x402Client.d.ts.map +1 -0
- package/dist/thirdweb/x402Client.js +223 -0
- package/dist/tracking/gasTracker.d.ts +158 -0
- package/dist/tracking/gasTracker.d.ts.map +1 -0
- package/dist/tracking/gasTracker.js +227 -0
- package/dist/tracking/index.d.ts +10 -0
- package/dist/tracking/index.d.ts.map +1 -0
- package/dist/tracking/index.js +8 -0
- package/dist/tracking/types.d.ts +327 -0
- package/dist/tracking/types.d.ts.map +1 -0
- package/dist/tracking/types.js +8 -0
- package/dist/ui/components/ChartWidget.d.ts +36 -0
- package/dist/ui/components/ChartWidget.d.ts.map +1 -0
- package/dist/ui/components/ChartWidget.js +82 -0
- package/dist/ui/components/DashboardLayout.d.ts +41 -0
- package/dist/ui/components/DashboardLayout.d.ts.map +1 -0
- package/dist/ui/components/DashboardLayout.js +102 -0
- package/dist/ui/components/DataTable.d.ts +49 -0
- package/dist/ui/components/DataTable.d.ts.map +1 -0
- package/dist/ui/components/DataTable.js +96 -0
- package/dist/ui/components/EntityForm.d.ts +60 -0
- package/dist/ui/components/EntityForm.d.ts.map +1 -0
- package/dist/ui/components/EntityForm.js +182 -0
- package/dist/ui/components/KPICard.d.ts +29 -0
- package/dist/ui/components/KPICard.d.ts.map +1 -0
- package/dist/ui/components/KPICard.js +61 -0
- package/dist/ui/components/Modal.d.ts +34 -0
- package/dist/ui/components/Modal.d.ts.map +1 -0
- package/dist/ui/components/Modal.js +30 -0
- package/dist/ui/components/index.d.ts +18 -0
- package/dist/ui/components/index.d.ts.map +1 -0
- package/dist/ui/components/index.js +11 -0
- package/dist/validation/template-validator.d.ts +25 -0
- package/dist/validation/template-validator.d.ts.map +1 -0
- package/dist/validation/template-validator.js +305 -0
- package/package.json +102 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Varity SDK - Storage Module
|
|
3
|
+
*
|
|
4
|
+
* Universal decentralized storage on IPFS/Filecoin/Celestia.
|
|
5
|
+
* Works across all templates (ISO, Healthcare, Retail, etc.)
|
|
6
|
+
*
|
|
7
|
+
* REFACTORED: Now uses adapter pattern for multi-backend support
|
|
8
|
+
*/
|
|
9
|
+
import type { VaritySDK } from '../../core/VaritySDK';
|
|
10
|
+
import type { StorageResult, StorageOptions } from '../../core/types';
|
|
11
|
+
export interface UploadResult extends StorageResult {
|
|
12
|
+
}
|
|
13
|
+
export interface DataPointer {
|
|
14
|
+
pointerId: string;
|
|
15
|
+
cid: string;
|
|
16
|
+
owner: string;
|
|
17
|
+
metadata: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Pin {
|
|
21
|
+
cid: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
size: number;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PinFilters {
|
|
27
|
+
status?: 'pinned' | 'unpinned';
|
|
28
|
+
limit?: number;
|
|
29
|
+
offset?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface CelestiaReceipt {
|
|
32
|
+
height: number;
|
|
33
|
+
commitment: string;
|
|
34
|
+
namespace: string;
|
|
35
|
+
blobId: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* StorageModule - Universal decentralized storage
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Upload encrypted data
|
|
43
|
+
* const result = await sdk.storage.uploadEncrypted({
|
|
44
|
+
* businessName: 'Acme Corp',
|
|
45
|
+
* data: {...}
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* // Retrieve encrypted data
|
|
49
|
+
* const data = await sdk.storage.retrieveEncrypted(result.cid)
|
|
50
|
+
*
|
|
51
|
+
* // Submit to Celestia for data availability
|
|
52
|
+
* const receipt = await sdk.storage.submitToCelestia(data, 'iso-merchants')
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare class StorageModule {
|
|
56
|
+
private sdk;
|
|
57
|
+
private adapter;
|
|
58
|
+
private dataProofContract;
|
|
59
|
+
constructor(sdk: VaritySDK);
|
|
60
|
+
/**
|
|
61
|
+
* Initialize DataProofRegistry contract
|
|
62
|
+
*/
|
|
63
|
+
private getDataProofContract;
|
|
64
|
+
/**
|
|
65
|
+
* Derive encryption key from wallet address
|
|
66
|
+
*/
|
|
67
|
+
private deriveKey;
|
|
68
|
+
/**
|
|
69
|
+
* Encrypt data with AES-256-GCM
|
|
70
|
+
*/
|
|
71
|
+
private encrypt;
|
|
72
|
+
/**
|
|
73
|
+
* Decrypt data
|
|
74
|
+
*/
|
|
75
|
+
private decrypt;
|
|
76
|
+
/**
|
|
77
|
+
* Upload encrypted data to IPFS/Filecoin
|
|
78
|
+
*
|
|
79
|
+
* @param data - Data to upload
|
|
80
|
+
* @param options - Storage options
|
|
81
|
+
* @returns Upload result with CID
|
|
82
|
+
*/
|
|
83
|
+
uploadEncrypted(data: any, options?: StorageOptions): Promise<UploadResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieve and decrypt data from IPFS
|
|
86
|
+
*
|
|
87
|
+
* @param cid - Content identifier
|
|
88
|
+
* @returns Decrypted data
|
|
89
|
+
*/
|
|
90
|
+
retrieveEncrypted(cid: string): Promise<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Upload file to IPFS
|
|
93
|
+
*
|
|
94
|
+
* @param file - File blob
|
|
95
|
+
* @param options - Storage options
|
|
96
|
+
* @returns Upload result
|
|
97
|
+
*/
|
|
98
|
+
uploadFile(file: Blob, options?: StorageOptions): Promise<UploadResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieve file from IPFS
|
|
101
|
+
*
|
|
102
|
+
* @param cid - Content identifier
|
|
103
|
+
* @returns File blob
|
|
104
|
+
*/
|
|
105
|
+
retrieveFile(cid: string): Promise<Blob>;
|
|
106
|
+
/**
|
|
107
|
+
* Record data pointer on-chain
|
|
108
|
+
*
|
|
109
|
+
* @param cid - Content identifier
|
|
110
|
+
* @param metadata - Data metadata
|
|
111
|
+
* @returns Transaction hash
|
|
112
|
+
*/
|
|
113
|
+
recordDataPointer(cid: string, metadata: any): Promise<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Get data pointer from on-chain registry
|
|
116
|
+
*
|
|
117
|
+
* @param cid - Content identifier
|
|
118
|
+
* @returns Data pointer
|
|
119
|
+
*/
|
|
120
|
+
getDataPointer(cid: string): Promise<DataPointer>;
|
|
121
|
+
/**
|
|
122
|
+
* Pin content to ensure persistence
|
|
123
|
+
*
|
|
124
|
+
* @param cid - Content identifier
|
|
125
|
+
*/
|
|
126
|
+
pin(cid: string): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Unpin content
|
|
129
|
+
*
|
|
130
|
+
* @param cid - Content identifier
|
|
131
|
+
*/
|
|
132
|
+
unpin(cid: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* List pinned content
|
|
135
|
+
*
|
|
136
|
+
* @param filters - Pin filters
|
|
137
|
+
* @returns Array of pins
|
|
138
|
+
*/
|
|
139
|
+
listPins(filters?: PinFilters): Promise<Pin[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Submit data to Celestia for data availability
|
|
142
|
+
*
|
|
143
|
+
* @param data - Data to submit
|
|
144
|
+
* @param namespace - Celestia namespace
|
|
145
|
+
* @returns Celestia receipt
|
|
146
|
+
*/
|
|
147
|
+
submitToCelestia(data: any, namespace: string): Promise<CelestiaReceipt>;
|
|
148
|
+
/**
|
|
149
|
+
* Retrieve data from Celestia
|
|
150
|
+
*
|
|
151
|
+
* @param height - Block height
|
|
152
|
+
* @param blobId - Blob identifier
|
|
153
|
+
* @returns Decrypted data
|
|
154
|
+
*/
|
|
155
|
+
retrieveFromCelestia(height: number, blobId: string): Promise<any>;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=StorageModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageModule.d.ts","sourceRoot":"","sources":["../../../src/modules/storage/StorageModule.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAa,MAAM,kBAAkB,CAAA;AAMhF,MAAM,WAAW,YAAa,SAAQ,aAAa;CAAG;AAEtD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAW;IACtB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,iBAAiB,CAA+B;gBAE5C,GAAG,EAAE,SAAS;IAO1B;;OAEG;YACW,oBAAoB;IAalC;;OAEG;YACW,SAAS;IAUvB;;OAEG;IACH,OAAO,CAAC,OAAO;IAKf;;OAEG;IACH,OAAO,CAAC,OAAO;IAMf;;;;;;OAMG;IACG,eAAe,CACnB,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC;IAgDxB;;;;;OAKG;IACG,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAYlD;;;;;;OAMG;IACG,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAoB7E;;;;;OAKG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM9C;;;;;;OAMG;IACG,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBpE;;;;;OAKG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAavD;;;;OAIG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrC;;;;OAIG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvC;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAgBpD;;;;;;OAMG;IACG,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4B9E;;;;;;OAMG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAsBzE"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Varity SDK - Storage Module
|
|
3
|
+
*
|
|
4
|
+
* Universal decentralized storage on IPFS/Filecoin/Celestia.
|
|
5
|
+
* Works across all templates (ISO, Healthcare, Retail, etc.)
|
|
6
|
+
*
|
|
7
|
+
* REFACTORED: Now uses adapter pattern for multi-backend support
|
|
8
|
+
*/
|
|
9
|
+
import { ethers } from 'ethers';
|
|
10
|
+
import CryptoJS from 'crypto-js';
|
|
11
|
+
import { StorageLayer, StorageTier } from '@varity-labs/types';
|
|
12
|
+
import DataProofRegistryABI from '../../contracts/abis/iso/DataProofRegistry.json';
|
|
13
|
+
import { AdapterFactory } from './adapters/AdapterFactory';
|
|
14
|
+
/**
|
|
15
|
+
* StorageModule - Universal decentralized storage
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Upload encrypted data
|
|
20
|
+
* const result = await sdk.storage.uploadEncrypted({
|
|
21
|
+
* businessName: 'Acme Corp',
|
|
22
|
+
* data: {...}
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* // Retrieve encrypted data
|
|
26
|
+
* const data = await sdk.storage.retrieveEncrypted(result.cid)
|
|
27
|
+
*
|
|
28
|
+
* // Submit to Celestia for data availability
|
|
29
|
+
* const receipt = await sdk.storage.submitToCelestia(data, 'iso-merchants')
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class StorageModule {
|
|
33
|
+
constructor(sdk) {
|
|
34
|
+
this.dataProofContract = null;
|
|
35
|
+
this.sdk = sdk;
|
|
36
|
+
// NEW: Initialize adapter based on SDK configuration
|
|
37
|
+
this.adapter = AdapterFactory.createFromSDKConfig(sdk);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Initialize DataProofRegistry contract
|
|
41
|
+
*/
|
|
42
|
+
async getDataProofContract() {
|
|
43
|
+
if (!this.dataProofContract) {
|
|
44
|
+
const address = this.sdk.getContractAddress('DataProofRegistry');
|
|
45
|
+
const provider = this.sdk.getProvider();
|
|
46
|
+
this.dataProofContract = new ethers.Contract(address, DataProofRegistryABI.abi, provider);
|
|
47
|
+
}
|
|
48
|
+
return this.dataProofContract;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Derive encryption key from wallet address
|
|
52
|
+
*/
|
|
53
|
+
async deriveKey(walletAddress) {
|
|
54
|
+
// Use PBKDF2 with wallet address as password
|
|
55
|
+
const salt = 'varity-sdk-v1';
|
|
56
|
+
const iterations = 100000;
|
|
57
|
+
return CryptoJS.PBKDF2(walletAddress.toLowerCase(), salt, {
|
|
58
|
+
keySize: 256 / 32,
|
|
59
|
+
iterations
|
|
60
|
+
}).toString();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Encrypt data with AES-256-GCM
|
|
64
|
+
*/
|
|
65
|
+
encrypt(data, key) {
|
|
66
|
+
const jsonString = JSON.stringify(data);
|
|
67
|
+
return CryptoJS.AES.encrypt(jsonString, key).toString();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Decrypt data
|
|
71
|
+
*/
|
|
72
|
+
decrypt(encryptedData, key) {
|
|
73
|
+
const decrypted = CryptoJS.AES.decrypt(encryptedData, key);
|
|
74
|
+
const jsonString = decrypted.toString(CryptoJS.enc.Utf8);
|
|
75
|
+
return JSON.parse(jsonString);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Upload encrypted data to IPFS/Filecoin
|
|
79
|
+
*
|
|
80
|
+
* @param data - Data to upload
|
|
81
|
+
* @param options - Storage options
|
|
82
|
+
* @returns Upload result with CID
|
|
83
|
+
*/
|
|
84
|
+
async uploadEncrypted(data, options) {
|
|
85
|
+
const walletAddress = await this.sdk.getAddress();
|
|
86
|
+
// 1. Derive encryption key from wallet
|
|
87
|
+
const key = await this.deriveKey(walletAddress);
|
|
88
|
+
// 2. Encrypt data
|
|
89
|
+
const encrypted = this.encrypt(data, key);
|
|
90
|
+
// 3. Upload via adapter (NEW: delegates to adapter)
|
|
91
|
+
const adapterOptions = {
|
|
92
|
+
layer: options?.layer || StorageLayer.CUSTOMER_DATA,
|
|
93
|
+
tier: StorageTier.HOT, // Default to hot tier
|
|
94
|
+
metadata: {
|
|
95
|
+
walletAddress,
|
|
96
|
+
encrypted: true,
|
|
97
|
+
...options?.metadata
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const result = await this.adapter.upload(encrypted, adapterOptions);
|
|
101
|
+
// 4. Record data proof on-chain (optional)
|
|
102
|
+
if (options?.pin !== false) {
|
|
103
|
+
const hash = CryptoJS.SHA256(encrypted).toString();
|
|
104
|
+
await this.recordDataPointer(result.identifier, {
|
|
105
|
+
hash,
|
|
106
|
+
owner: walletAddress,
|
|
107
|
+
layer: options?.layer || StorageLayer.CUSTOMER_DATA,
|
|
108
|
+
...options?.metadata
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// Convert adapter result to legacy format for backward compatibility
|
|
112
|
+
return {
|
|
113
|
+
cid: result.identifier,
|
|
114
|
+
gatewayUrl: result.gatewayUrl,
|
|
115
|
+
size: result.size,
|
|
116
|
+
hash: result.hash,
|
|
117
|
+
timestamp: result.timestamp,
|
|
118
|
+
encryptionMetadata: {
|
|
119
|
+
encrypted: true,
|
|
120
|
+
walletAddress,
|
|
121
|
+
layer: options?.layer || StorageLayer.CUSTOMER_DATA
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Retrieve and decrypt data from IPFS
|
|
127
|
+
*
|
|
128
|
+
* @param cid - Content identifier
|
|
129
|
+
* @returns Decrypted data
|
|
130
|
+
*/
|
|
131
|
+
async retrieveEncrypted(cid) {
|
|
132
|
+
const walletAddress = await this.sdk.getAddress();
|
|
133
|
+
// 1. Download via adapter (NEW: delegates to adapter)
|
|
134
|
+
const buffer = await this.adapter.download(cid);
|
|
135
|
+
const encrypted = buffer.toString();
|
|
136
|
+
// 2. Derive key and decrypt
|
|
137
|
+
const key = await this.deriveKey(walletAddress);
|
|
138
|
+
return this.decrypt(encrypted, key);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Upload file to IPFS
|
|
142
|
+
*
|
|
143
|
+
* @param file - File blob
|
|
144
|
+
* @param options - Storage options
|
|
145
|
+
* @returns Upload result
|
|
146
|
+
*/
|
|
147
|
+
async uploadFile(file, options) {
|
|
148
|
+
// NEW: Upload via adapter
|
|
149
|
+
const adapterOptions = {
|
|
150
|
+
layer: options?.layer || StorageLayer.CUSTOMER_DATA,
|
|
151
|
+
tier: StorageTier.HOT,
|
|
152
|
+
metadata: options?.metadata
|
|
153
|
+
};
|
|
154
|
+
const result = await this.adapter.upload(file, adapterOptions);
|
|
155
|
+
// Convert to legacy format for backward compatibility
|
|
156
|
+
return {
|
|
157
|
+
cid: result.identifier,
|
|
158
|
+
gatewayUrl: result.gatewayUrl,
|
|
159
|
+
size: result.size,
|
|
160
|
+
hash: result.hash,
|
|
161
|
+
timestamp: result.timestamp
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Retrieve file from IPFS
|
|
166
|
+
*
|
|
167
|
+
* @param cid - Content identifier
|
|
168
|
+
* @returns File blob
|
|
169
|
+
*/
|
|
170
|
+
async retrieveFile(cid) {
|
|
171
|
+
// NEW: Download via adapter
|
|
172
|
+
const buffer = await this.adapter.download(cid);
|
|
173
|
+
return new Blob([new Uint8Array(buffer)]);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Record data pointer on-chain
|
|
177
|
+
*
|
|
178
|
+
* @param cid - Content identifier
|
|
179
|
+
* @param metadata - Data metadata
|
|
180
|
+
* @returns Transaction hash
|
|
181
|
+
*/
|
|
182
|
+
async recordDataPointer(cid, metadata) {
|
|
183
|
+
const contract = await this.getDataProofContract();
|
|
184
|
+
const signer = this.sdk.getSigner();
|
|
185
|
+
const contractWithSigner = contract.connect(signer);
|
|
186
|
+
const storeDataProofFunc = contractWithSigner.getFunction('storeDataProof');
|
|
187
|
+
const tx = await storeDataProofFunc(cid, metadata.hash || ethers.ZeroHash, JSON.stringify(metadata));
|
|
188
|
+
const receipt = await tx.wait();
|
|
189
|
+
return receipt.hash;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get data pointer from on-chain registry
|
|
193
|
+
*
|
|
194
|
+
* @param cid - Content identifier
|
|
195
|
+
* @returns Data pointer
|
|
196
|
+
*/
|
|
197
|
+
async getDataPointer(cid) {
|
|
198
|
+
const contract = await this.getDataProofContract();
|
|
199
|
+
const proof = await contract.getDataProof(cid);
|
|
200
|
+
return {
|
|
201
|
+
pointerId: cid,
|
|
202
|
+
cid,
|
|
203
|
+
owner: proof.owner,
|
|
204
|
+
metadata: proof.metadata,
|
|
205
|
+
timestamp: Number(proof.timestamp)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Pin content to ensure persistence
|
|
210
|
+
*
|
|
211
|
+
* @param cid - Content identifier
|
|
212
|
+
*/
|
|
213
|
+
async pin(cid) {
|
|
214
|
+
// NEW: Pin is now a no-op for backward compatibility
|
|
215
|
+
// Content is automatically pinned during upload
|
|
216
|
+
// This method is kept for API compatibility
|
|
217
|
+
console.log(`✅ Content already pinned during upload: ${cid}`);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Unpin content
|
|
221
|
+
*
|
|
222
|
+
* @param cid - Content identifier
|
|
223
|
+
*/
|
|
224
|
+
async unpin(cid) {
|
|
225
|
+
// NEW: Delegate to adapter delete
|
|
226
|
+
await this.adapter.delete(cid);
|
|
227
|
+
console.log(`✅ Content unpinned: ${cid}`);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* List pinned content
|
|
231
|
+
*
|
|
232
|
+
* @param filters - Pin filters
|
|
233
|
+
* @returns Array of pins
|
|
234
|
+
*/
|
|
235
|
+
async listPins(filters) {
|
|
236
|
+
// NEW: Delegate to adapter list
|
|
237
|
+
const items = await this.adapter.list({
|
|
238
|
+
maxResults: filters?.limit,
|
|
239
|
+
startAfter: filters?.offset?.toString()
|
|
240
|
+
});
|
|
241
|
+
// Convert to legacy Pin format
|
|
242
|
+
return items.map(item => ({
|
|
243
|
+
cid: item.key,
|
|
244
|
+
name: item.metadata?.name,
|
|
245
|
+
size: item.size,
|
|
246
|
+
timestamp: item.lastModified.getTime()
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Submit data to Celestia for data availability
|
|
251
|
+
*
|
|
252
|
+
* @param data - Data to submit
|
|
253
|
+
* @param namespace - Celestia namespace
|
|
254
|
+
* @returns Celestia receipt
|
|
255
|
+
*/
|
|
256
|
+
async submitToCelestia(data, namespace) {
|
|
257
|
+
const walletAddress = await this.sdk.getAddress();
|
|
258
|
+
const key = await this.deriveKey(walletAddress);
|
|
259
|
+
const encrypted = this.encrypt(data, key);
|
|
260
|
+
const apiEndpoint = this.sdk.getAPIEndpoint();
|
|
261
|
+
const apiKey = this.sdk.getAPIKey();
|
|
262
|
+
const response = await fetch(`${apiEndpoint}/api/v1/celestia/submit`, {
|
|
263
|
+
method: 'POST',
|
|
264
|
+
headers: {
|
|
265
|
+
'Content-Type': 'application/json',
|
|
266
|
+
...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
|
|
267
|
+
},
|
|
268
|
+
body: JSON.stringify({
|
|
269
|
+
data: encrypted,
|
|
270
|
+
namespace,
|
|
271
|
+
walletAddress
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
if (!response.ok) {
|
|
275
|
+
throw new Error(`Celestia submit failed: ${response.statusText}`);
|
|
276
|
+
}
|
|
277
|
+
return await response.json();
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Retrieve data from Celestia
|
|
281
|
+
*
|
|
282
|
+
* @param height - Block height
|
|
283
|
+
* @param blobId - Blob identifier
|
|
284
|
+
* @returns Decrypted data
|
|
285
|
+
*/
|
|
286
|
+
async retrieveFromCelestia(height, blobId) {
|
|
287
|
+
const walletAddress = await this.sdk.getAddress();
|
|
288
|
+
const apiEndpoint = this.sdk.getAPIEndpoint();
|
|
289
|
+
const apiKey = this.sdk.getAPIKey();
|
|
290
|
+
const response = await fetch(`${apiEndpoint}/api/v1/celestia/retrieve/${height}/${blobId}`, {
|
|
291
|
+
headers: {
|
|
292
|
+
...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
if (!response.ok) {
|
|
296
|
+
throw new Error(`Celestia retrieve failed: ${response.statusText}`);
|
|
297
|
+
}
|
|
298
|
+
const encrypted = await response.text();
|
|
299
|
+
const key = await this.deriveKey(walletAddress);
|
|
300
|
+
return this.decrypt(encrypted, key);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Varity SDK - Storage Adapter Factory
|
|
3
|
+
*
|
|
4
|
+
* Factory pattern for creating storage adapters based on backend configuration.
|
|
5
|
+
* Supports Filecoin/IPFS, multi-tier, and future S3/GCS backends.
|
|
6
|
+
*/
|
|
7
|
+
import type { VaritySDK } from '../../../core/VaritySDK';
|
|
8
|
+
import type { StorageBackend, MultiTierStorageConfig, S3CompatibleConfig, GCSCompatibleConfig } from '@varity-labs/types';
|
|
9
|
+
import { IStorageAdapter } from './IStorageAdapter';
|
|
10
|
+
/**
|
|
11
|
+
* Adapter factory configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface AdapterFactoryConfig {
|
|
14
|
+
backend: StorageBackend;
|
|
15
|
+
multiTierConfig?: MultiTierStorageConfig;
|
|
16
|
+
s3Config?: S3CompatibleConfig;
|
|
17
|
+
gcsConfig?: GCSCompatibleConfig;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Factory for creating storage adapters
|
|
21
|
+
*
|
|
22
|
+
* Provides a unified interface for creating different storage backend adapters
|
|
23
|
+
* based on configuration. Handles validation and adapter initialization.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Create Filecoin adapter
|
|
28
|
+
* const adapter = AdapterFactory.createAdapter(sdk, {
|
|
29
|
+
* backend: StorageBackend.FILECOIN_IPFS
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* // Create multi-tier adapter
|
|
33
|
+
* const multiTierAdapter = AdapterFactory.createAdapter(sdk, {
|
|
34
|
+
* backend: StorageBackend.MULTI_TIER,
|
|
35
|
+
* multiTierConfig: {
|
|
36
|
+
* hotTier: { backend: StorageBackend.FILECOIN_IPFS, replication: 3 },
|
|
37
|
+
* coldTier: { backend: StorageBackend.FILECOIN_IPFS, replication: 2 },
|
|
38
|
+
* autoTiering: { enabled: true, policy: TieringPolicy.ACCESS_BASED, checkInterval: 24 }
|
|
39
|
+
* }
|
|
40
|
+
* })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class AdapterFactory {
|
|
44
|
+
/**
|
|
45
|
+
* Create a storage adapter based on backend type and configuration
|
|
46
|
+
*
|
|
47
|
+
* @param sdk - Varity SDK instance
|
|
48
|
+
* @param config - Adapter configuration
|
|
49
|
+
* @returns Storage adapter instance
|
|
50
|
+
* @throws {Error} If backend is unsupported or configuration is invalid
|
|
51
|
+
*/
|
|
52
|
+
static createAdapter(sdk: VaritySDK, config: AdapterFactoryConfig): IStorageAdapter;
|
|
53
|
+
/**
|
|
54
|
+
* Create adapter from SDK configuration
|
|
55
|
+
*
|
|
56
|
+
* Convenience method that extracts storage configuration from SDK config
|
|
57
|
+
* and creates the appropriate adapter.
|
|
58
|
+
*
|
|
59
|
+
* @param sdk - Varity SDK instance
|
|
60
|
+
* @returns Storage adapter instance
|
|
61
|
+
*/
|
|
62
|
+
static createFromSDKConfig(sdk: VaritySDK): IStorageAdapter;
|
|
63
|
+
/**
|
|
64
|
+
* Validate adapter configuration
|
|
65
|
+
*
|
|
66
|
+
* @param config - Adapter configuration
|
|
67
|
+
* @returns True if valid
|
|
68
|
+
* @throws {Error} If configuration is invalid
|
|
69
|
+
*/
|
|
70
|
+
static validateConfig(config: AdapterFactoryConfig): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get supported backends
|
|
73
|
+
*
|
|
74
|
+
* @returns Array of supported storage backends
|
|
75
|
+
*/
|
|
76
|
+
static getSupportedBackends(): StorageBackend[];
|
|
77
|
+
/**
|
|
78
|
+
* Check if a backend is supported
|
|
79
|
+
*
|
|
80
|
+
* @param backend - Backend to check
|
|
81
|
+
* @returns True if supported
|
|
82
|
+
*/
|
|
83
|
+
static isBackendSupported(backend: StorageBackend): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Get backend capabilities
|
|
86
|
+
*
|
|
87
|
+
* @param backend - Storage backend
|
|
88
|
+
* @returns Capabilities object
|
|
89
|
+
*/
|
|
90
|
+
static getBackendCapabilities(backend: StorageBackend): {
|
|
91
|
+
supportsEncryption: boolean;
|
|
92
|
+
supportsVersioning: boolean;
|
|
93
|
+
supportsMetadata: boolean;
|
|
94
|
+
supportsCopy: boolean;
|
|
95
|
+
supportsMove: boolean;
|
|
96
|
+
supportsPresignedUrls: boolean;
|
|
97
|
+
costTier: 'low' | 'medium' | 'high';
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=AdapterFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdapterFactory.d.ts","sourceRoot":"","sources":["../../../../src/modules/storage/adapters/AdapterFactory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAInD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,cAAc,CAAA;IACvB,eAAe,CAAC,EAAE,sBAAsB,CAAA;IACxC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,SAAS,CAAC,EAAE,mBAAmB,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,cAAc;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,GAAG,eAAe;IAyBnF;;;;;;;;OAQG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,eAAe;IAgB3D;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO;IAgD5D;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,IAAI,cAAc,EAAE;IAQ/C;;;;;OAKG;IACH,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAI3D;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG;QACtD,kBAAkB,EAAE,OAAO,CAAA;QAC3B,kBAAkB,EAAE,OAAO,CAAA;QAC3B,gBAAgB,EAAE,OAAO,CAAA;QACzB,YAAY,EAAE,OAAO,CAAA;QACrB,YAAY,EAAE,OAAO,CAAA;QACrB,qBAAqB,EAAE,OAAO,CAAA;QAC9B,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;KACpC;CA0DF"}
|