@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.
Files changed (295) hide show
  1. package/LICENSE +31 -0
  2. package/README.md +253 -0
  3. package/dist/analytics/index.d.ts +7 -0
  4. package/dist/analytics/index.d.ts.map +1 -0
  5. package/dist/analytics/index.js +6 -0
  6. package/dist/analytics/tracker.d.ts +128 -0
  7. package/dist/analytics/tracker.d.ts.map +1 -0
  8. package/dist/analytics/tracker.js +203 -0
  9. package/dist/blockchain/BlockchainService.d.ts +100 -0
  10. package/dist/blockchain/BlockchainService.d.ts.map +1 -0
  11. package/dist/blockchain/BlockchainService.js +188 -0
  12. package/dist/blockchain/NFTLicensingService.d.ts +69 -0
  13. package/dist/blockchain/NFTLicensingService.d.ts.map +1 -0
  14. package/dist/blockchain/NFTLicensingService.js +136 -0
  15. package/dist/blockchain/RevenueSplitService.d.ts +71 -0
  16. package/dist/blockchain/RevenueSplitService.d.ts.map +1 -0
  17. package/dist/blockchain/RevenueSplitService.js +111 -0
  18. package/dist/blockchain/index.d.ts +48 -0
  19. package/dist/blockchain/index.d.ts.map +1 -0
  20. package/dist/blockchain/index.js +46 -0
  21. package/dist/blockchain/types.d.ts +63 -0
  22. package/dist/blockchain/types.d.ts.map +1 -0
  23. package/dist/blockchain/types.js +6 -0
  24. package/dist/chains/arbitrum.d.ts +89 -0
  25. package/dist/chains/arbitrum.d.ts.map +1 -0
  26. package/dist/chains/arbitrum.js +134 -0
  27. package/dist/chains/base.d.ts +84 -0
  28. package/dist/chains/base.d.ts.map +1 -0
  29. package/dist/chains/base.js +131 -0
  30. package/dist/chains/index.d.ts +36 -0
  31. package/dist/chains/index.d.ts.map +1 -0
  32. package/dist/chains/index.js +32 -0
  33. package/dist/chains/registry.d.ts +113 -0
  34. package/dist/chains/registry.d.ts.map +1 -0
  35. package/dist/chains/registry.js +201 -0
  36. package/dist/chains/varityL3.d.ts +81 -0
  37. package/dist/chains/varityL3.d.ts.map +1 -0
  38. package/dist/chains/varityL3.js +125 -0
  39. package/dist/cli/commands/clone.d.ts +8 -0
  40. package/dist/cli/commands/clone.d.ts.map +1 -0
  41. package/dist/cli/commands/clone.js +391 -0
  42. package/dist/cli/commands/dev.d.ts +8 -0
  43. package/dist/cli/commands/dev.d.ts.map +1 -0
  44. package/dist/cli/commands/dev.js +40 -0
  45. package/dist/cli/commands/generate.d.ts +8 -0
  46. package/dist/cli/commands/generate.d.ts.map +1 -0
  47. package/dist/cli/commands/generate.js +303 -0
  48. package/dist/cli/commands/init.d.ts +8 -0
  49. package/dist/cli/commands/init.d.ts.map +1 -0
  50. package/dist/cli/commands/init.js +317 -0
  51. package/dist/cli/commands/validate.d.ts +8 -0
  52. package/dist/cli/commands/validate.d.ts.map +1 -0
  53. package/dist/cli/commands/validate.js +69 -0
  54. package/dist/cli/index.d.ts +8 -0
  55. package/dist/cli/index.d.ts.map +1 -0
  56. package/dist/cli/index.js +33 -0
  57. package/dist/cli/utils/logger.d.ts +17 -0
  58. package/dist/cli/utils/logger.d.ts.map +1 -0
  59. package/dist/cli/utils/logger.js +35 -0
  60. package/dist/cli/utils/prompts.d.ts +21 -0
  61. package/dist/cli/utils/prompts.d.ts.map +1 -0
  62. package/dist/cli/utils/prompts.js +103 -0
  63. package/dist/contracts/abis/iso/AccessControlRegistry.json +1468 -0
  64. package/dist/contracts/abis/iso/DataProofRegistry.json +797 -0
  65. package/dist/contracts/abis/iso/MerchantRegistry.json +1237 -0
  66. package/dist/contracts/abis/iso/RepPerformance.json +1351 -0
  67. package/dist/contracts/abis/iso/ResidualCalculator.json +1118 -0
  68. package/dist/contracts/abis/iso/TransactionVault.json +1588 -0
  69. package/dist/contracts/abis/iso/VarityWalletFactory.json +475 -0
  70. package/dist/contracts/addresses.d.ts +88 -0
  71. package/dist/contracts/addresses.d.ts.map +1 -0
  72. package/dist/contracts/addresses.js +94 -0
  73. package/dist/contracts/index.d.ts +7 -0
  74. package/dist/contracts/index.d.ts.map +1 -0
  75. package/dist/contracts/index.js +6 -0
  76. package/dist/core/VaritySDK.d.ts +177 -0
  77. package/dist/core/VaritySDK.d.ts.map +1 -0
  78. package/dist/core/VaritySDK.js +325 -0
  79. package/dist/core/config.d.ts +120 -0
  80. package/dist/core/config.d.ts.map +1 -0
  81. package/dist/core/config.js +187 -0
  82. package/dist/core/credentials-proxy.d.ts +157 -0
  83. package/dist/core/credentials-proxy.d.ts.map +1 -0
  84. package/dist/core/credentials-proxy.js +345 -0
  85. package/dist/core/credentials.d.ts +219 -0
  86. package/dist/core/credentials.d.ts.map +1 -0
  87. package/dist/core/credentials.js +345 -0
  88. package/dist/core/template-loader.d.ts +15 -0
  89. package/dist/core/template-loader.d.ts.map +1 -0
  90. package/dist/core/template-loader.js +380 -0
  91. package/dist/core/template.d.ts +321 -0
  92. package/dist/core/template.d.ts.map +1 -0
  93. package/dist/core/template.js +189 -0
  94. package/dist/core/types.d.ts +572 -0
  95. package/dist/core/types.d.ts.map +1 -0
  96. package/dist/core/types.js +52 -0
  97. package/dist/dev/dev-server.d.ts +16 -0
  98. package/dist/dev/dev-server.d.ts.map +1 -0
  99. package/dist/dev/dev-server.js +119 -0
  100. package/dist/generators/contracts/generator.d.ts +21 -0
  101. package/dist/generators/contracts/generator.d.ts.map +1 -0
  102. package/dist/generators/contracts/generator.js +252 -0
  103. package/dist/generators/tests/generator.d.ts +20 -0
  104. package/dist/generators/tests/generator.d.ts.map +1 -0
  105. package/dist/generators/tests/generator.js +375 -0
  106. package/dist/generators/types/generator.d.ts +19 -0
  107. package/dist/generators/types/generator.d.ts.map +1 -0
  108. package/dist/generators/types/generator.js +165 -0
  109. package/dist/generators/ui/component-generator.d.ts +20 -0
  110. package/dist/generators/ui/component-generator.d.ts.map +1 -0
  111. package/dist/generators/ui/component-generator.js +749 -0
  112. package/dist/generators/ui/dashboard-generator.d.ts +20 -0
  113. package/dist/generators/ui/dashboard-generator.d.ts.map +1 -0
  114. package/dist/generators/ui/dashboard-generator.js +349 -0
  115. package/dist/index.d.ts +61 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +74 -0
  118. package/dist/modules/analytics/AnalyticsModule.d.ts +349 -0
  119. package/dist/modules/analytics/AnalyticsModule.d.ts.map +1 -0
  120. package/dist/modules/analytics/AnalyticsModule.js +274 -0
  121. package/dist/modules/analytics/index.d.ts +3 -0
  122. package/dist/modules/analytics/index.d.ts.map +1 -0
  123. package/dist/modules/analytics/index.js +1 -0
  124. package/dist/modules/auth/AccessKeyModule.d.ts +189 -0
  125. package/dist/modules/auth/AccessKeyModule.d.ts.map +1 -0
  126. package/dist/modules/auth/AccessKeyModule.js +322 -0
  127. package/dist/modules/auth/AuthModule.d.ts +133 -0
  128. package/dist/modules/auth/AuthModule.d.ts.map +1 -0
  129. package/dist/modules/auth/AuthModule.js +214 -0
  130. package/dist/modules/auth/index.d.ts +8 -0
  131. package/dist/modules/auth/index.d.ts.map +1 -0
  132. package/dist/modules/auth/index.js +6 -0
  133. package/dist/modules/cache/CacheModule.d.ts +279 -0
  134. package/dist/modules/cache/CacheModule.d.ts.map +1 -0
  135. package/dist/modules/cache/CacheModule.js +493 -0
  136. package/dist/modules/cache/index.d.ts +3 -0
  137. package/dist/modules/cache/index.d.ts.map +1 -0
  138. package/dist/modules/cache/index.js +1 -0
  139. package/dist/modules/compute/ComputeModule.d.ts +226 -0
  140. package/dist/modules/compute/ComputeModule.d.ts.map +1 -0
  141. package/dist/modules/compute/ComputeModule.js +379 -0
  142. package/dist/modules/compute/index.d.ts +6 -0
  143. package/dist/modules/compute/index.d.ts.map +1 -0
  144. package/dist/modules/compute/index.js +4 -0
  145. package/dist/modules/contracts/ContractsModule.d.ts +164 -0
  146. package/dist/modules/contracts/ContractsModule.d.ts.map +1 -0
  147. package/dist/modules/contracts/ContractsModule.js +242 -0
  148. package/dist/modules/contracts/index.d.ts +6 -0
  149. package/dist/modules/contracts/index.d.ts.map +1 -0
  150. package/dist/modules/contracts/index.js +4 -0
  151. package/dist/modules/export/ExportModule.d.ts +346 -0
  152. package/dist/modules/export/ExportModule.d.ts.map +1 -0
  153. package/dist/modules/export/ExportModule.js +432 -0
  154. package/dist/modules/export/index.d.ts +3 -0
  155. package/dist/modules/export/index.d.ts.map +1 -0
  156. package/dist/modules/export/index.js +1 -0
  157. package/dist/modules/forecasting/ForecastingModule.d.ts +579 -0
  158. package/dist/modules/forecasting/ForecastingModule.d.ts.map +1 -0
  159. package/dist/modules/forecasting/ForecastingModule.js +310 -0
  160. package/dist/modules/forecasting/index.d.ts +3 -0
  161. package/dist/modules/forecasting/index.d.ts.map +1 -0
  162. package/dist/modules/forecasting/index.js +1 -0
  163. package/dist/modules/monitoring/MonitoringModule.d.ts +359 -0
  164. package/dist/modules/monitoring/MonitoringModule.d.ts.map +1 -0
  165. package/dist/modules/monitoring/MonitoringModule.js +483 -0
  166. package/dist/modules/monitoring/index.d.ts +3 -0
  167. package/dist/modules/monitoring/index.d.ts.map +1 -0
  168. package/dist/modules/monitoring/index.js +1 -0
  169. package/dist/modules/notifications/NotificationsModule.d.ts +336 -0
  170. package/dist/modules/notifications/NotificationsModule.d.ts.map +1 -0
  171. package/dist/modules/notifications/NotificationsModule.js +418 -0
  172. package/dist/modules/notifications/index.d.ts +3 -0
  173. package/dist/modules/notifications/index.d.ts.map +1 -0
  174. package/dist/modules/notifications/index.js +1 -0
  175. package/dist/modules/oracle/OracleModule.d.ts +110 -0
  176. package/dist/modules/oracle/OracleModule.d.ts.map +1 -0
  177. package/dist/modules/oracle/OracleModule.js +151 -0
  178. package/dist/modules/oracle/index.d.ts +6 -0
  179. package/dist/modules/oracle/index.d.ts.map +1 -0
  180. package/dist/modules/oracle/index.js +4 -0
  181. package/dist/modules/storage/S3Module.d.ts +377 -0
  182. package/dist/modules/storage/S3Module.d.ts.map +1 -0
  183. package/dist/modules/storage/S3Module.js +680 -0
  184. package/dist/modules/storage/StorageModule.d.ts +157 -0
  185. package/dist/modules/storage/StorageModule.d.ts.map +1 -0
  186. package/dist/modules/storage/StorageModule.js +302 -0
  187. package/dist/modules/storage/adapters/AdapterFactory.d.ts +100 -0
  188. package/dist/modules/storage/adapters/AdapterFactory.d.ts.map +1 -0
  189. package/dist/modules/storage/adapters/AdapterFactory.js +209 -0
  190. package/dist/modules/storage/adapters/FilecoinAdapter.d.ts +94 -0
  191. package/dist/modules/storage/adapters/FilecoinAdapter.d.ts.map +1 -0
  192. package/dist/modules/storage/adapters/FilecoinAdapter.js +263 -0
  193. package/dist/modules/storage/adapters/IStorageAdapter.d.ts +287 -0
  194. package/dist/modules/storage/adapters/IStorageAdapter.d.ts.map +1 -0
  195. package/dist/modules/storage/adapters/IStorageAdapter.js +81 -0
  196. package/dist/modules/storage/adapters/MultiTierAdapter.d.ts +187 -0
  197. package/dist/modules/storage/adapters/MultiTierAdapter.d.ts.map +1 -0
  198. package/dist/modules/storage/adapters/MultiTierAdapter.js +430 -0
  199. package/dist/modules/storage/adapters/index.d.ts +12 -0
  200. package/dist/modules/storage/adapters/index.d.ts.map +1 -0
  201. package/dist/modules/storage/adapters/index.js +12 -0
  202. package/dist/modules/storage/index.d.ts +16 -0
  203. package/dist/modules/storage/index.d.ts.map +1 -0
  204. package/dist/modules/storage/index.js +15 -0
  205. package/dist/modules/storage/tiering/AccessAnalyzer.d.ts +227 -0
  206. package/dist/modules/storage/tiering/AccessAnalyzer.d.ts.map +1 -0
  207. package/dist/modules/storage/tiering/AccessAnalyzer.js +367 -0
  208. package/dist/modules/storage/tiering/CostOptimizer.d.ts +248 -0
  209. package/dist/modules/storage/tiering/CostOptimizer.d.ts.map +1 -0
  210. package/dist/modules/storage/tiering/CostOptimizer.js +356 -0
  211. package/dist/modules/storage/tiering/MetadataStore.d.ts +287 -0
  212. package/dist/modules/storage/tiering/MetadataStore.d.ts.map +1 -0
  213. package/dist/modules/storage/tiering/MetadataStore.js +535 -0
  214. package/dist/modules/storage/tiering/TieringEngine.d.ts +237 -0
  215. package/dist/modules/storage/tiering/TieringEngine.d.ts.map +1 -0
  216. package/dist/modules/storage/tiering/TieringEngine.js +419 -0
  217. package/dist/modules/storage/tiering/example.d.ts +8 -0
  218. package/dist/modules/storage/tiering/example.d.ts.map +1 -0
  219. package/dist/modules/storage/tiering/example.js +250 -0
  220. package/dist/modules/storage/tiering/index.d.ts +17 -0
  221. package/dist/modules/storage/tiering/index.d.ts.map +1 -0
  222. package/dist/modules/storage/tiering/index.js +13 -0
  223. package/dist/modules/webhooks/WebhooksModule.d.ts +476 -0
  224. package/dist/modules/webhooks/WebhooksModule.d.ts.map +1 -0
  225. package/dist/modules/webhooks/WebhooksModule.js +359 -0
  226. package/dist/modules/webhooks/index.d.ts +3 -0
  227. package/dist/modules/webhooks/index.d.ts.map +1 -0
  228. package/dist/modules/webhooks/index.js +1 -0
  229. package/dist/modules/zk/ZKModule.d.ts +153 -0
  230. package/dist/modules/zk/ZKModule.d.ts.map +1 -0
  231. package/dist/modules/zk/ZKModule.js +262 -0
  232. package/dist/modules/zk/index.d.ts +7 -0
  233. package/dist/modules/zk/index.d.ts.map +1 -0
  234. package/dist/modules/zk/index.js +4 -0
  235. package/dist/thirdweb/BridgeClient.d.ts +228 -0
  236. package/dist/thirdweb/BridgeClient.d.ts.map +1 -0
  237. package/dist/thirdweb/BridgeClient.js +160 -0
  238. package/dist/thirdweb/EngineClient.d.ts +396 -0
  239. package/dist/thirdweb/EngineClient.d.ts.map +1 -0
  240. package/dist/thirdweb/EngineClient.js +386 -0
  241. package/dist/thirdweb/GatewayClient.d.ts +190 -0
  242. package/dist/thirdweb/GatewayClient.d.ts.map +1 -0
  243. package/dist/thirdweb/GatewayClient.js +257 -0
  244. package/dist/thirdweb/NebulaClient.d.ts +292 -0
  245. package/dist/thirdweb/NebulaClient.d.ts.map +1 -0
  246. package/dist/thirdweb/NebulaClient.js +180 -0
  247. package/dist/thirdweb/StorageClient.d.ts +445 -0
  248. package/dist/thirdweb/StorageClient.d.ts.map +1 -0
  249. package/dist/thirdweb/StorageClient.js +405 -0
  250. package/dist/thirdweb/ThirdwebWrapper.d.ts +236 -0
  251. package/dist/thirdweb/ThirdwebWrapper.d.ts.map +1 -0
  252. package/dist/thirdweb/ThirdwebWrapper.js +332 -0
  253. package/dist/thirdweb/index.d.ts +21 -0
  254. package/dist/thirdweb/index.d.ts.map +1 -0
  255. package/dist/thirdweb/index.js +28 -0
  256. package/dist/thirdweb/varity-chain.d.ts +48 -0
  257. package/dist/thirdweb/varity-chain.d.ts.map +1 -0
  258. package/dist/thirdweb/varity-chain.js +64 -0
  259. package/dist/thirdweb/x402Client.d.ts +319 -0
  260. package/dist/thirdweb/x402Client.d.ts.map +1 -0
  261. package/dist/thirdweb/x402Client.js +223 -0
  262. package/dist/tracking/gasTracker.d.ts +158 -0
  263. package/dist/tracking/gasTracker.d.ts.map +1 -0
  264. package/dist/tracking/gasTracker.js +227 -0
  265. package/dist/tracking/index.d.ts +10 -0
  266. package/dist/tracking/index.d.ts.map +1 -0
  267. package/dist/tracking/index.js +8 -0
  268. package/dist/tracking/types.d.ts +327 -0
  269. package/dist/tracking/types.d.ts.map +1 -0
  270. package/dist/tracking/types.js +8 -0
  271. package/dist/ui/components/ChartWidget.d.ts +36 -0
  272. package/dist/ui/components/ChartWidget.d.ts.map +1 -0
  273. package/dist/ui/components/ChartWidget.js +82 -0
  274. package/dist/ui/components/DashboardLayout.d.ts +41 -0
  275. package/dist/ui/components/DashboardLayout.d.ts.map +1 -0
  276. package/dist/ui/components/DashboardLayout.js +102 -0
  277. package/dist/ui/components/DataTable.d.ts +49 -0
  278. package/dist/ui/components/DataTable.d.ts.map +1 -0
  279. package/dist/ui/components/DataTable.js +96 -0
  280. package/dist/ui/components/EntityForm.d.ts +60 -0
  281. package/dist/ui/components/EntityForm.d.ts.map +1 -0
  282. package/dist/ui/components/EntityForm.js +182 -0
  283. package/dist/ui/components/KPICard.d.ts +29 -0
  284. package/dist/ui/components/KPICard.d.ts.map +1 -0
  285. package/dist/ui/components/KPICard.js +61 -0
  286. package/dist/ui/components/Modal.d.ts +34 -0
  287. package/dist/ui/components/Modal.d.ts.map +1 -0
  288. package/dist/ui/components/Modal.js +30 -0
  289. package/dist/ui/components/index.d.ts +18 -0
  290. package/dist/ui/components/index.d.ts.map +1 -0
  291. package/dist/ui/components/index.js +11 -0
  292. package/dist/validation/template-validator.d.ts +25 -0
  293. package/dist/validation/template-validator.d.ts.map +1 -0
  294. package/dist/validation/template-validator.js +305 -0
  295. package/package.json +102 -0
@@ -0,0 +1,483 @@
1
+ /**
2
+ * MonitoringModule - Universal monitoring and observability
3
+ *
4
+ * Provides comprehensive monitoring capabilities including health checks,
5
+ * metrics collection, distributed tracing, and error tracking.
6
+ * Works across all templates for production observability.
7
+ */
8
+ export class MonitoringModule {
9
+ constructor(sdk) {
10
+ this.sdk = sdk;
11
+ }
12
+ /**
13
+ * Get system health status
14
+ *
15
+ * Universal method - checks health of all system components.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const health = await sdk.monitoring.getHealthStatus()
20
+ * if (health.status !== 'healthy') {
21
+ * console.error('System unhealthy:', health.checks)
22
+ * }
23
+ * ```
24
+ */
25
+ async getHealthStatus() {
26
+ const apiEndpoint = this.sdk.getAPIEndpoint();
27
+ const apiKey = this.sdk.getAPIKey();
28
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/health`, {
29
+ method: 'GET',
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
33
+ }
34
+ });
35
+ if (!response.ok) {
36
+ throw new Error(`Failed to get health status: ${response.statusText}`);
37
+ }
38
+ return await response.json();
39
+ }
40
+ /**
41
+ * Record metric
42
+ *
43
+ * Universal method - records a metric value for monitoring.
44
+ *
45
+ * @example ISO Dashboard
46
+ * ```typescript
47
+ * await sdk.monitoring.recordMetric({
48
+ * name: 'merchant.registration.duration',
49
+ * value: 245,
50
+ * type: 'histogram',
51
+ * unit: 'ms',
52
+ * tags: { status: 'success' }
53
+ * })
54
+ * ```
55
+ *
56
+ * @example Healthcare Dashboard
57
+ * ```typescript
58
+ * await sdk.monitoring.recordMetric({
59
+ * name: 'appointment.booking.duration',
60
+ * value: 320,
61
+ * type: 'histogram',
62
+ * unit: 'ms',
63
+ * tags: { department: 'cardiology' }
64
+ * })
65
+ * ```
66
+ */
67
+ async recordMetric(options) {
68
+ const apiEndpoint = this.sdk.getAPIEndpoint();
69
+ const apiKey = this.sdk.getAPIKey();
70
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/metrics`, {
71
+ method: 'POST',
72
+ headers: {
73
+ 'Content-Type': 'application/json',
74
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
75
+ },
76
+ body: JSON.stringify(options)
77
+ });
78
+ if (!response.ok) {
79
+ throw new Error(`Failed to record metric: ${response.statusText}`);
80
+ }
81
+ }
82
+ /**
83
+ * Query metrics
84
+ *
85
+ * Universal method - retrieves metric data with aggregation.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const latency = await sdk.monitoring.queryMetrics({
90
+ * name: 'api.latency',
91
+ * startTime: '2025-01-01T00:00:00Z',
92
+ * endTime: '2025-01-31T23:59:59Z',
93
+ * aggregation: 'p95',
94
+ * interval: '1h'
95
+ * })
96
+ * ```
97
+ */
98
+ async queryMetrics(options) {
99
+ const apiEndpoint = this.sdk.getAPIEndpoint();
100
+ const apiKey = this.sdk.getAPIKey();
101
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/metrics/query`, {
102
+ method: 'POST',
103
+ headers: {
104
+ 'Content-Type': 'application/json',
105
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
106
+ },
107
+ body: JSON.stringify(options)
108
+ });
109
+ if (!response.ok) {
110
+ throw new Error(`Failed to query metrics: ${response.statusText}`);
111
+ }
112
+ return await response.json();
113
+ }
114
+ /**
115
+ * Start distributed trace
116
+ *
117
+ * Universal method - begins a new distributed trace.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const trace = await sdk.monitoring.startTrace('merchant.registration', {
122
+ * userId: '123',
123
+ * merchantId: 'M456'
124
+ * })
125
+ *
126
+ * try {
127
+ * // ... perform operations ...
128
+ * await trace.end()
129
+ * } catch (error) {
130
+ * await trace.error(error)
131
+ * }
132
+ * ```
133
+ */
134
+ async startTrace(name, tags) {
135
+ const apiEndpoint = this.sdk.getAPIEndpoint();
136
+ const apiKey = this.sdk.getAPIKey();
137
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/traces`, {
138
+ method: 'POST',
139
+ headers: {
140
+ 'Content-Type': 'application/json',
141
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
142
+ },
143
+ body: JSON.stringify({ name, tags, startTime: new Date().toISOString() })
144
+ });
145
+ if (!response.ok) {
146
+ throw new Error(`Failed to start trace: ${response.statusText}`);
147
+ }
148
+ const trace = await response.json();
149
+ return new TraceContext(trace.id, name, this.sdk, apiEndpoint, apiKey);
150
+ }
151
+ /**
152
+ * Get trace by ID
153
+ *
154
+ * Universal method - retrieves trace details.
155
+ */
156
+ async getTrace(traceId) {
157
+ const apiEndpoint = this.sdk.getAPIEndpoint();
158
+ const apiKey = this.sdk.getAPIKey();
159
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/traces/${traceId}`, {
160
+ method: 'GET',
161
+ headers: {
162
+ 'Content-Type': 'application/json',
163
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
164
+ }
165
+ });
166
+ if (!response.ok) {
167
+ throw new Error(`Failed to get trace: ${response.statusText}`);
168
+ }
169
+ return await response.json();
170
+ }
171
+ /**
172
+ * Report error
173
+ *
174
+ * Universal method - reports an error for tracking.
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * try {
179
+ * await somethingRisky()
180
+ * } catch (error) {
181
+ * await sdk.monitoring.reportError(error, {
182
+ * context: { userId: '123', action: 'registration' },
183
+ * tags: { severity: 'high' }
184
+ * })
185
+ * }
186
+ * ```
187
+ */
188
+ async reportError(error, options) {
189
+ const apiEndpoint = this.sdk.getAPIEndpoint();
190
+ const apiKey = this.sdk.getAPIKey();
191
+ const errorMessage = typeof error === 'string' ? error : error.message;
192
+ const stackTrace = error instanceof Error ? error.stack : undefined;
193
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/errors`, {
194
+ method: 'POST',
195
+ headers: {
196
+ 'Content-Type': 'application/json',
197
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
198
+ },
199
+ body: JSON.stringify({
200
+ error: errorMessage,
201
+ stackTrace,
202
+ context: options?.context,
203
+ tags: options?.tags,
204
+ timestamp: new Date().toISOString()
205
+ })
206
+ });
207
+ if (!response.ok) {
208
+ throw new Error(`Failed to report error: ${response.statusText}`);
209
+ }
210
+ return await response.json();
211
+ }
212
+ /**
213
+ * Get error reports
214
+ *
215
+ * Universal method - retrieves error tracking data.
216
+ */
217
+ async getErrors(options = {}) {
218
+ const apiEndpoint = this.sdk.getAPIEndpoint();
219
+ const apiKey = this.sdk.getAPIKey();
220
+ const queryParams = new URLSearchParams();
221
+ if (options.startTime)
222
+ queryParams.append('startTime', options.startTime);
223
+ if (options.endTime)
224
+ queryParams.append('endTime', options.endTime);
225
+ if (options.limit)
226
+ queryParams.append('limit', options.limit.toString());
227
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/errors?${queryParams}`, {
228
+ method: 'POST',
229
+ headers: {
230
+ 'Content-Type': 'application/json',
231
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
232
+ },
233
+ body: JSON.stringify({ tags: options.tags })
234
+ });
235
+ if (!response.ok) {
236
+ throw new Error(`Failed to get errors: ${response.statusText}`);
237
+ }
238
+ return await response.json();
239
+ }
240
+ /**
241
+ * Get performance metrics
242
+ *
243
+ * Universal method - retrieves system performance metrics.
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const perf = await sdk.monitoring.getPerformanceMetrics()
248
+ * console.log(`API p95 latency: ${perf.apiLatency.p95}ms`)
249
+ * console.log(`Error rate: ${perf.errorRate}%`)
250
+ * ```
251
+ */
252
+ async getPerformanceMetrics() {
253
+ const apiEndpoint = this.sdk.getAPIEndpoint();
254
+ const apiKey = this.sdk.getAPIKey();
255
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/performance`, {
256
+ method: 'GET',
257
+ headers: {
258
+ 'Content-Type': 'application/json',
259
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
260
+ }
261
+ });
262
+ if (!response.ok) {
263
+ throw new Error(`Failed to get performance metrics: ${response.statusText}`);
264
+ }
265
+ return await response.json();
266
+ }
267
+ /**
268
+ * Get active alerts
269
+ *
270
+ * Universal method - retrieves currently active alerts.
271
+ */
272
+ async getActiveAlerts() {
273
+ const apiEndpoint = this.sdk.getAPIEndpoint();
274
+ const apiKey = this.sdk.getAPIKey();
275
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/alerts?status=active`, {
276
+ method: 'GET',
277
+ headers: {
278
+ 'Content-Type': 'application/json',
279
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
280
+ }
281
+ });
282
+ if (!response.ok) {
283
+ throw new Error(`Failed to get active alerts: ${response.statusText}`);
284
+ }
285
+ return await response.json();
286
+ }
287
+ /**
288
+ * Get system uptime
289
+ *
290
+ * Universal method - retrieves system uptime in seconds.
291
+ */
292
+ async getUptime() {
293
+ const health = await this.getHealthStatus();
294
+ return health.uptime;
295
+ }
296
+ /**
297
+ * Record custom event
298
+ *
299
+ * Universal method - records a custom event for tracking.
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * await sdk.monitoring.recordEvent('merchant.tier.upgraded', {
304
+ * merchantId: 'M123',
305
+ * oldTier: 'silver',
306
+ * newTier: 'gold'
307
+ * })
308
+ * ```
309
+ */
310
+ async recordEvent(name, data) {
311
+ const apiEndpoint = this.sdk.getAPIEndpoint();
312
+ const apiKey = this.sdk.getAPIKey();
313
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/events`, {
314
+ method: 'POST',
315
+ headers: {
316
+ 'Content-Type': 'application/json',
317
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
318
+ },
319
+ body: JSON.stringify({
320
+ name,
321
+ data,
322
+ timestamp: new Date().toISOString()
323
+ })
324
+ });
325
+ if (!response.ok) {
326
+ throw new Error(`Failed to record event: ${response.statusText}`);
327
+ }
328
+ }
329
+ /**
330
+ * Create custom dashboard
331
+ *
332
+ * Universal method - creates a custom monitoring dashboard.
333
+ */
334
+ async createDashboard(dashboard) {
335
+ const apiEndpoint = this.sdk.getAPIEndpoint();
336
+ const apiKey = this.sdk.getAPIKey();
337
+ const response = await fetch(`${apiEndpoint}/api/v1/monitoring/dashboards`, {
338
+ method: 'POST',
339
+ headers: {
340
+ 'Content-Type': 'application/json',
341
+ ...(apiKey && { 'Authorization': `Bearer ${apiKey}` })
342
+ },
343
+ body: JSON.stringify(dashboard)
344
+ });
345
+ if (!response.ok) {
346
+ throw new Error(`Failed to create dashboard: ${response.statusText}`);
347
+ }
348
+ return await response.json();
349
+ }
350
+ }
351
+ /**
352
+ * TraceContext - Helper class for managing distributed traces
353
+ */
354
+ export class TraceContext {
355
+ constructor(id, name, sdk, apiEndpoint, apiKey) {
356
+ this.id = id;
357
+ this.name = name;
358
+ this.sdk = sdk;
359
+ this.apiEndpoint = apiEndpoint;
360
+ this.apiKey = apiKey;
361
+ this.spans = [];
362
+ }
363
+ /**
364
+ * Start a new span within this trace
365
+ */
366
+ async startSpan(name, tags) {
367
+ const response = await fetch(`${this.apiEndpoint}/api/v1/monitoring/traces/${this.id}/spans`, {
368
+ method: 'POST',
369
+ headers: {
370
+ 'Content-Type': 'application/json',
371
+ ...(this.apiKey && { 'Authorization': `Bearer ${this.apiKey}` })
372
+ },
373
+ body: JSON.stringify({
374
+ name,
375
+ tags,
376
+ startTime: new Date().toISOString()
377
+ })
378
+ });
379
+ if (!response.ok) {
380
+ throw new Error(`Failed to start span: ${response.statusText}`);
381
+ }
382
+ const span = await response.json();
383
+ return new SpanContext(span.id, this.id, name, this.apiEndpoint, this.apiKey);
384
+ }
385
+ /**
386
+ * End the trace successfully
387
+ */
388
+ async end() {
389
+ await fetch(`${this.apiEndpoint}/api/v1/monitoring/traces/${this.id}`, {
390
+ method: 'PUT',
391
+ headers: {
392
+ 'Content-Type': 'application/json',
393
+ ...(this.apiKey && { 'Authorization': `Bearer ${this.apiKey}` })
394
+ },
395
+ body: JSON.stringify({
396
+ endTime: new Date().toISOString(),
397
+ status: 'completed'
398
+ })
399
+ });
400
+ }
401
+ /**
402
+ * End the trace with an error
403
+ */
404
+ async error(error) {
405
+ const errorMessage = typeof error === 'string' ? error : error.message;
406
+ await fetch(`${this.apiEndpoint}/api/v1/monitoring/traces/${this.id}`, {
407
+ method: 'PUT',
408
+ headers: {
409
+ 'Content-Type': 'application/json',
410
+ ...(this.apiKey && { 'Authorization': `Bearer ${this.apiKey}` })
411
+ },
412
+ body: JSON.stringify({
413
+ endTime: new Date().toISOString(),
414
+ status: 'error',
415
+ error: errorMessage
416
+ })
417
+ });
418
+ }
419
+ }
420
+ /**
421
+ * SpanContext - Helper class for managing trace spans
422
+ */
423
+ export class SpanContext {
424
+ constructor(id, traceId, name, apiEndpoint, apiKey) {
425
+ this.id = id;
426
+ this.traceId = traceId;
427
+ this.name = name;
428
+ this.apiEndpoint = apiEndpoint;
429
+ this.apiKey = apiKey;
430
+ }
431
+ /**
432
+ * Add log entry to span
433
+ */
434
+ async log(level, message, metadata) {
435
+ await fetch(`${this.apiEndpoint}/api/v1/monitoring/spans/${this.id}/logs`, {
436
+ method: 'POST',
437
+ headers: {
438
+ 'Content-Type': 'application/json',
439
+ ...(this.apiKey && { 'Authorization': `Bearer ${this.apiKey}` })
440
+ },
441
+ body: JSON.stringify({
442
+ level,
443
+ message,
444
+ metadata,
445
+ timestamp: new Date().toISOString()
446
+ })
447
+ });
448
+ }
449
+ /**
450
+ * End the span successfully
451
+ */
452
+ async end() {
453
+ await fetch(`${this.apiEndpoint}/api/v1/monitoring/spans/${this.id}`, {
454
+ method: 'PUT',
455
+ headers: {
456
+ 'Content-Type': 'application/json',
457
+ ...(this.apiKey && { 'Authorization': `Bearer ${this.apiKey}` })
458
+ },
459
+ body: JSON.stringify({
460
+ endTime: new Date().toISOString(),
461
+ status: 'completed'
462
+ })
463
+ });
464
+ }
465
+ /**
466
+ * End the span with an error
467
+ */
468
+ async error(error) {
469
+ const errorMessage = typeof error === 'string' ? error : error.message;
470
+ await fetch(`${this.apiEndpoint}/api/v1/monitoring/spans/${this.id}`, {
471
+ method: 'PUT',
472
+ headers: {
473
+ 'Content-Type': 'application/json',
474
+ ...(this.apiKey && { 'Authorization': `Bearer ${this.apiKey}` })
475
+ },
476
+ body: JSON.stringify({
477
+ endTime: new Date().toISOString(),
478
+ status: 'error',
479
+ error: errorMessage
480
+ })
481
+ });
482
+ }
483
+ }
@@ -0,0 +1,3 @@
1
+ export { MonitoringModule, TraceContext, SpanContext } from './MonitoringModule';
2
+ export type { HealthStatus, MetricType, HealthCheckResult, Metric, RecordMetricOptions, QueryMetricsOptions, MetricSeries, Trace, Span, LogEntry, ErrorReport, PerformanceMetrics, Alert } from './MonitoringModule';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/monitoring/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChF,YAAY,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,KAAK,EACN,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1 @@
1
+ export { MonitoringModule, TraceContext, SpanContext } from './MonitoringModule';