@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,391 @@
1
+ /**
2
+ * varity clone - Clone existing template
3
+ *
4
+ * Quickly create new template from existing one
5
+ */
6
+ import { Command } from 'commander';
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { Logger } from '../utils/logger';
10
+ import inquirer from 'inquirer';
11
+ export const cloneCommand = new Command('clone')
12
+ .description('Clone an existing template to create a new one')
13
+ .option('--from <template>', 'Source template name')
14
+ .option('--to <name>', 'New template name')
15
+ .option('-d, --dir <directory>', 'Output directory', '.')
16
+ .action(async (options) => {
17
+ try {
18
+ Logger.header('📋 Clone Template');
19
+ // Get source and destination if not provided
20
+ let sourceTemplate = options.from;
21
+ let newTemplateName = options.to;
22
+ if (!sourceTemplate || !newTemplateName) {
23
+ const answers = await inquirer.prompt([
24
+ {
25
+ type: 'input',
26
+ name: 'sourceTemplate',
27
+ message: 'Source template to clone from (e.g., iso, healthcare):',
28
+ when: !sourceTemplate,
29
+ validate: (input) => {
30
+ if (!input || input.trim().length === 0) {
31
+ return 'Source template is required';
32
+ }
33
+ return true;
34
+ }
35
+ },
36
+ {
37
+ type: 'input',
38
+ name: 'newTemplateName',
39
+ message: 'New template name:',
40
+ when: !newTemplateName,
41
+ validate: (input) => {
42
+ if (!input || input.trim().length === 0) {
43
+ return 'New template name is required';
44
+ }
45
+ if (!/^[a-z][a-z0-9-]*$/.test(input)) {
46
+ return 'Template name must be lowercase letters, numbers, and hyphens only';
47
+ }
48
+ return true;
49
+ }
50
+ }
51
+ ]);
52
+ sourceTemplate = sourceTemplate || answers.sourceTemplate;
53
+ newTemplateName = newTemplateName || answers.newTemplateName;
54
+ }
55
+ const outputDir = path.join(options.dir, newTemplateName);
56
+ // Check if output directory already exists
57
+ if (fs.existsSync(outputDir)) {
58
+ Logger.error(`Directory ${outputDir} already exists`);
59
+ process.exit(1);
60
+ }
61
+ Logger.step(1, 5, `Locating source template: ${sourceTemplate}...`);
62
+ // Find source template
63
+ const sourceTemplatePath = findSourceTemplate(sourceTemplate);
64
+ if (!sourceTemplatePath) {
65
+ Logger.error(`Source template "${sourceTemplate}" not found`);
66
+ Logger.info('Available templates in SDK:');
67
+ Logger.code(' - iso');
68
+ Logger.newline();
69
+ process.exit(1);
70
+ }
71
+ Logger.step(2, 5, 'Copying template structure...');
72
+ // Create output directory
73
+ fs.mkdirSync(outputDir, { recursive: true });
74
+ // Copy and transform template JSON
75
+ const templateJson = loadAndTransformTemplate(path.join(sourceTemplatePath, `${sourceTemplate}.template.json`), sourceTemplate, newTemplateName);
76
+ // Create project structure
77
+ createProjectStructure(outputDir);
78
+ // Write transformed template
79
+ const templatesDir = path.join(outputDir, 'templates');
80
+ fs.mkdirSync(templatesDir, { recursive: true });
81
+ fs.writeFileSync(path.join(templatesDir, `${newTemplateName}.template.json`), JSON.stringify(templateJson, null, 2));
82
+ Logger.step(3, 5, 'Generating environment configuration...');
83
+ generateEnvFile(outputDir, newTemplateName, templateJson.api?.basePath);
84
+ Logger.step(4, 5, 'Creating package.json...');
85
+ generatePackageJson(outputDir, newTemplateName, templateJson.description);
86
+ Logger.step(5, 5, 'Creating README.md...');
87
+ generateReadme(outputDir, newTemplateName, templateJson);
88
+ Logger.newline();
89
+ Logger.success(`Template cloned successfully from "${sourceTemplate}" to "${newTemplateName}"!`);
90
+ Logger.newline();
91
+ Logger.info('Next steps:');
92
+ Logger.code(` cd ${newTemplateName}`);
93
+ Logger.code(` npm install`);
94
+ Logger.code(` # Edit templates/${newTemplateName}.template.json to customize entities`);
95
+ Logger.code(` varity generate contracts`);
96
+ Logger.code(` varity generate ui`);
97
+ Logger.code(` varity generate dashboard`);
98
+ Logger.code(` varity dev --watch`);
99
+ Logger.newline();
100
+ }
101
+ catch (error) {
102
+ Logger.error(`Failed to clone template: ${error instanceof Error ? error.message : 'Unknown error'}`);
103
+ process.exit(1);
104
+ }
105
+ });
106
+ /**
107
+ * Find source template in SDK
108
+ */
109
+ function findSourceTemplate(templateName) {
110
+ // Check in SDK templates directory
111
+ const sdkTemplatesPath = path.join(__dirname, '..', '..', '..', 'templates');
112
+ const templatePath = path.join(sdkTemplatesPath, `${templateName}.template.json`);
113
+ if (fs.existsSync(templatePath)) {
114
+ return sdkTemplatesPath;
115
+ }
116
+ return null;
117
+ }
118
+ /**
119
+ * Load and transform template JSON
120
+ */
121
+ function loadAndTransformTemplate(sourcePath, sourceTemplate, newTemplate) {
122
+ const content = fs.readFileSync(sourcePath, 'utf-8');
123
+ const template = JSON.parse(content);
124
+ // Transform template
125
+ template.type = newTemplate;
126
+ template.name = `${capitalize(newTemplate)} Business Template`;
127
+ template.description = `${capitalize(newTemplate)} business template (cloned from ${sourceTemplate})`;
128
+ // Update storage namespaces
129
+ if (template.storage) {
130
+ if (template.storage.varityNamespace) {
131
+ template.storage.varityNamespace = template.storage.varityNamespace.replace(sourceTemplate, newTemplate);
132
+ }
133
+ if (template.storage.industryNamespace) {
134
+ template.storage.industryNamespace = template.storage.industryNamespace.replace(sourceTemplate, newTemplate);
135
+ }
136
+ if (template.storage.customerNamespacePattern) {
137
+ template.storage.customerNamespacePattern = template.storage.customerNamespacePattern.replace(sourceTemplate, newTemplate);
138
+ }
139
+ }
140
+ // Update API base path
141
+ if (template.api) {
142
+ template.api.basePath = `/api/v1/${newTemplate}`;
143
+ }
144
+ // Update contract ABIs paths (only if they're strings)
145
+ if (template.contracts) {
146
+ template.contracts = template.contracts.map(contract => ({
147
+ ...contract,
148
+ abi: typeof contract.abi === 'string'
149
+ ? contract.abi.replace(sourceTemplate, newTemplate)
150
+ : contract.abi
151
+ }));
152
+ }
153
+ return template;
154
+ }
155
+ /**
156
+ * Create project structure
157
+ */
158
+ function createProjectStructure(baseDir) {
159
+ const dirs = [
160
+ path.join(baseDir, 'contracts'),
161
+ path.join(baseDir, 'contracts', 'abis'),
162
+ path.join(baseDir, 'templates'),
163
+ path.join(baseDir, 'scripts'),
164
+ path.join(baseDir, 'test'),
165
+ path.join(baseDir, 'src'),
166
+ path.join(baseDir, 'src', 'components'),
167
+ path.join(baseDir, 'src', 'hooks'),
168
+ path.join(baseDir, 'src', 'services')
169
+ ];
170
+ dirs.forEach(dir => {
171
+ if (!fs.existsSync(dir)) {
172
+ fs.mkdirSync(dir, { recursive: true });
173
+ }
174
+ });
175
+ // Create .gitignore
176
+ const gitignore = `
177
+ node_modules
178
+ .env
179
+ .env.local
180
+ dist
181
+ build
182
+ *.log
183
+ .DS_Store
184
+ deployments
185
+ cache
186
+ artifacts
187
+ typechain-types
188
+ `.trim();
189
+ fs.writeFileSync(path.join(baseDir, '.gitignore'), gitignore);
190
+ }
191
+ /**
192
+ * Generate .env.example file
193
+ */
194
+ function generateEnvFile(baseDir, templateName, basePath) {
195
+ const envContent = `# Varity SDK Configuration
196
+
197
+ # Network
198
+ VARITY_NETWORK=arbitrum-sepolia
199
+
200
+ # API Configuration
201
+ VARITY_API_KEY=
202
+ VARITY_API_ENDPOINT=https://api.varity.io${basePath || `/api/v1/${templateName}`}
203
+
204
+ # RPC URLs
205
+ ARBITRUM_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
206
+ ARBITRUM_L3_TESTNET_RPC=
207
+ ARBITRUM_L3_MAINNET_RPC=
208
+
209
+ # Contract Addresses (populated after deployment)
210
+ # Arbitrum Sepolia contracts
211
+ # Add your contract addresses here after deployment
212
+
213
+ # Storage Configuration
214
+ PINATA_API_KEY=
215
+ CELESTIA_TESTNET_RPC=https://rpc-mocha.pops.one
216
+
217
+ # Private Key (NEVER commit this!)
218
+ PRIVATE_KEY=
219
+ `;
220
+ fs.writeFileSync(path.join(baseDir, '.env.example'), envContent);
221
+ }
222
+ /**
223
+ * Generate package.json
224
+ */
225
+ function generatePackageJson(baseDir, templateName, description) {
226
+ const packageJson = {
227
+ name: `varity-${templateName}-template`,
228
+ version: '1.0.0',
229
+ description: description || `Varity ${capitalize(templateName)} template`,
230
+ scripts: {
231
+ 'generate:contracts': 'varity generate contracts',
232
+ 'generate:ui': 'varity generate ui',
233
+ 'generate:dashboard': 'varity generate dashboard',
234
+ 'generate:types': 'varity generate types',
235
+ 'generate:tests': 'varity generate tests',
236
+ 'generate:all': 'npm run generate:contracts && npm run generate:ui && npm run generate:dashboard && npm run generate:types',
237
+ 'dev': 'varity dev --watch',
238
+ 'validate': 'varity validate',
239
+ 'test': 'hardhat test',
240
+ 'deploy:sepolia': 'varity deploy --network arbitrum-sepolia',
241
+ 'deploy:testnet': 'varity deploy --network arbitrum-l3-testnet',
242
+ 'deploy:mainnet': 'varity deploy --network arbitrum-l3-mainnet',
243
+ 'start': 'react-scripts start',
244
+ 'build': 'react-scripts build'
245
+ },
246
+ dependencies: {
247
+ '@varity-labs/sdk': '^2.0.0-beta.1',
248
+ 'react': '^18.2.0',
249
+ 'react-dom': '^18.2.0',
250
+ 'react-scripts': '^5.0.1',
251
+ 'ethers': '^6.9.0',
252
+ '@mui/material': '^5.15.0',
253
+ '@mui/icons-material': '^5.15.0',
254
+ '@emotion/react': '^11.11.0',
255
+ '@emotion/styled': '^11.11.0'
256
+ },
257
+ devDependencies: {
258
+ '@nomicfoundation/hardhat-toolbox': '^4.0.0',
259
+ 'hardhat': '^2.19.0',
260
+ 'typescript': '^5.0.0',
261
+ '@types/react': '^18.2.0',
262
+ '@types/react-dom': '^18.2.0'
263
+ }
264
+ };
265
+ fs.writeFileSync(path.join(baseDir, 'package.json'), JSON.stringify(packageJson, null, 2));
266
+ }
267
+ /**
268
+ * Generate README.md
269
+ */
270
+ function generateReadme(baseDir, templateName, template) {
271
+ const entityNames = template.entities?.map(e => e.displayName || capitalize(e.name)).join(', ') || 'entities';
272
+ const readme = `# ${capitalize(templateName)} Template
273
+
274
+ ${template.description || `Business template for ${capitalize(templateName)}`}
275
+
276
+ **Business Entities**: ${entityNames}
277
+
278
+ ## Quick Start
279
+
280
+ \`\`\`bash
281
+ # Install dependencies
282
+ npm install
283
+
284
+ # Generate all code
285
+ npm run generate:all
286
+
287
+ # Start development mode (hot-reload)
288
+ npm run dev
289
+
290
+ # Validate template configuration
291
+ npm run validate
292
+ \`\`\`
293
+
294
+ ## Development Workflow
295
+
296
+ ### 1. Customize Template
297
+
298
+ Edit \`templates/${templateName}.template.json\` to define your business entities:
299
+
300
+ \`\`\`json
301
+ {
302
+ "entities": [
303
+ {
304
+ "name": "customer",
305
+ "fields": [
306
+ { "name": "customerId", "type": "string", "required": true },
307
+ { "name": "email", "type": "string", "required": true }
308
+ ]
309
+ }
310
+ ]
311
+ }
312
+ \`\`\`
313
+
314
+ ### 2. Generate Code
315
+
316
+ \`\`\`bash
317
+ # Generate smart contracts
318
+ npm run generate:contracts
319
+
320
+ # Generate UI components (CRUD interfaces)
321
+ npm run generate:ui
322
+
323
+ # Generate dashboard layouts
324
+ npm run generate:dashboard
325
+
326
+ # Generate TypeScript types
327
+ npm run generate:types
328
+
329
+ # Or generate everything at once
330
+ npm run generate:all
331
+ \`\`\`
332
+
333
+ ### 3. Test & Deploy
334
+
335
+ \`\`\`bash
336
+ # Test on Arbitrum Sepolia
337
+ npm run deploy:sepolia
338
+
339
+ # Run tests
340
+ npm test
341
+
342
+ # Deploy to mainnet
343
+ npm run deploy:mainnet
344
+ \`\`\`
345
+
346
+ ## Generated Structure
347
+
348
+ After running \`npm run generate:all\`:
349
+
350
+ \`\`\`
351
+ ${templateName}/
352
+ ├── contracts/ # Generated Solidity contracts
353
+ ├── src/
354
+ │ ├── components/
355
+ │ │ ├── entities/ # Generated CRUD components
356
+ │ │ └── dashboards/ # Generated dashboard layouts
357
+ │ ├── hooks/ # React hooks for SDK
358
+ │ └── services/ # API service layer
359
+ ├── test/ # Generated test suites
360
+ └── templates/ # Template configuration
361
+ \`\`\`
362
+
363
+ ## Features
364
+
365
+ - ✅ Automated smart contract generation
366
+ - ✅ Complete CRUD UI components
367
+ - ✅ Dashboard layouts with KPIs and charts
368
+ - ✅ TypeScript type safety
369
+ - ✅ Comprehensive test coverage
370
+ - ✅ Hot-reload development mode
371
+ - ✅ One-command deployment
372
+
373
+ ## Documentation
374
+
375
+ - [Varity SDK Documentation](https://docs.varity.com)
376
+ - [CLI Guide](https://docs.varity.com/cli)
377
+ - [Template Guide](https://docs.varity.com/templates)
378
+
379
+ ## Support
380
+
381
+ - Discord: https://discord.gg/varity
382
+ - Email: support@varity.com
383
+ `;
384
+ fs.writeFileSync(path.join(baseDir, 'README.md'), readme);
385
+ }
386
+ /**
387
+ * Capitalize first letter
388
+ */
389
+ function capitalize(str) {
390
+ return str.charAt(0).toUpperCase() + str.slice(1);
391
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * varity dev - Development mode with hot-reload
3
+ *
4
+ * Watches for changes and automatically regenerates code
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const devCommand: Command;
8
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,eAAO,MAAM,UAAU,SAiCnB,CAAA"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * varity dev - Development mode with hot-reload
3
+ *
4
+ * Watches for changes and automatically regenerates code
5
+ */
6
+ import { Command } from 'commander';
7
+ import * as path from 'path';
8
+ import { Logger } from '../utils/logger';
9
+ import { startDevServer } from '../../dev/dev-server';
10
+ export const devCommand = new Command('dev')
11
+ .description('Start development mode with hot-reload')
12
+ .option('-t, --template <path>', 'Path to template JSON file', './templates/template.json')
13
+ .option('-c, --contracts <path>', 'Contracts output directory', './contracts')
14
+ .option('-w, --watch', 'Enable file watching (default: true)', true)
15
+ .option('-p, --port <number>', 'Development server port', '3001')
16
+ .action(async (options) => {
17
+ try {
18
+ Logger.header('🔥 Varity Development Mode');
19
+ const templatePath = path.resolve(options.template);
20
+ const contractsPath = path.resolve(options.contracts);
21
+ const port = parseInt(options.port, 10);
22
+ Logger.info('Configuration:');
23
+ Logger.code(` Template: ${templatePath}`);
24
+ Logger.code(` Contracts: ${contractsPath}`);
25
+ Logger.code(` Watch mode: ${options.watch ? 'enabled' : 'disabled'}`);
26
+ Logger.code(` Port: ${port}`);
27
+ Logger.newline();
28
+ // Start dev server
29
+ await startDevServer({
30
+ templatePath,
31
+ contractsPath,
32
+ watch: options.watch,
33
+ port
34
+ });
35
+ }
36
+ catch (error) {
37
+ Logger.error(`Failed to start dev server: ${error instanceof Error ? error.message : 'Unknown error'}`);
38
+ process.exit(1);
39
+ }
40
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * varity generate - Code generation commands
3
+ *
4
+ * Generate contracts, types, tests, and deployment scripts
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const generateCommand: Command;
8
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAuUnC,eAAO,MAAM,eAAe,SAMW,CAAA"}