@apimatic/cli 1.1.0-alpha.8 → 1.1.0-beta.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 (345) hide show
  1. package/README.md +436 -374
  2. package/bin/run.js +5 -0
  3. package/lib/actions/action-result.d.ts +13 -0
  4. package/lib/actions/action-result.js +44 -0
  5. package/lib/actions/action-result.js.map +1 -0
  6. package/lib/actions/api/transform.d.ts +15 -0
  7. package/lib/actions/api/transform.js +48 -0
  8. package/lib/actions/api/transform.js.map +1 -0
  9. package/lib/actions/api/validate.d.ts +12 -0
  10. package/lib/actions/api/validate.js +41 -0
  11. package/lib/actions/api/validate.js.map +1 -0
  12. package/lib/actions/auth/login.d.ts +13 -0
  13. package/lib/actions/auth/login.js +55 -0
  14. package/lib/actions/auth/login.js.map +1 -0
  15. package/lib/actions/auth/logout.d.ts +8 -0
  16. package/lib/actions/auth/logout.js +15 -0
  17. package/lib/actions/auth/logout.js.map +1 -0
  18. package/lib/actions/auth/status.d.ts +11 -0
  19. package/lib/actions/auth/status.js +26 -0
  20. package/lib/actions/auth/status.js.map +1 -0
  21. package/lib/actions/portal/copilot.d.ts +16 -0
  22. package/lib/actions/portal/copilot.js +89 -0
  23. package/lib/actions/portal/copilot.js.map +1 -0
  24. package/lib/actions/portal/generate.d.ts +11 -5
  25. package/lib/actions/portal/generate.js +60 -55
  26. package/lib/actions/portal/generate.js.map +1 -0
  27. package/lib/actions/portal/quickstart.d.ts +16 -0
  28. package/lib/actions/portal/quickstart.js +146 -0
  29. package/lib/actions/portal/quickstart.js.map +1 -0
  30. package/lib/actions/portal/recipe/new-recipe.d.ts +15 -0
  31. package/lib/actions/portal/recipe/new-recipe.js +177 -0
  32. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  33. package/lib/actions/portal/serve.d.ts +15 -0
  34. package/lib/actions/portal/serve.js +118 -0
  35. package/lib/actions/portal/serve.js.map +1 -0
  36. package/lib/actions/portal/toc/new-toc.d.ts +21 -0
  37. package/lib/actions/portal/toc/new-toc.js +97 -0
  38. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  39. package/lib/actions/quickstart.d.ts +10 -0
  40. package/lib/actions/quickstart.js +30 -0
  41. package/lib/actions/quickstart.js.map +1 -0
  42. package/lib/actions/sdk/generate.d.ts +13 -0
  43. package/lib/actions/sdk/generate.js +47 -0
  44. package/lib/actions/sdk/generate.js.map +1 -0
  45. package/lib/actions/sdk/quickstart.d.ts +14 -0
  46. package/lib/actions/sdk/quickstart.js +149 -0
  47. package/lib/actions/sdk/quickstart.js.map +1 -0
  48. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  49. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  50. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  51. package/lib/application/portal/recipe/recipe-generator.d.ts +21 -0
  52. package/lib/application/portal/recipe/recipe-generator.js +145 -0
  53. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  54. package/lib/application/portal/{new/toc → toc}/toc-content-parser.d.ts +1 -1
  55. package/lib/application/portal/toc/toc-content-parser.js +44 -0
  56. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  57. package/lib/application/portal/{new/toc → toc}/toc-structure-generator.d.ts +1 -1
  58. package/lib/application/portal/toc/toc-structure-generator.js +84 -0
  59. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  60. package/lib/client-utils/auth-manager.d.ts +7 -2
  61. package/lib/client-utils/auth-manager.js +26 -14
  62. package/lib/client-utils/auth-manager.js.map +1 -0
  63. package/lib/commands/api/transform.d.ts +10 -7
  64. package/lib/commands/api/transform.js +51 -111
  65. package/lib/commands/api/transform.js.map +1 -0
  66. package/lib/commands/api/validate.d.ts +7 -4
  67. package/lib/commands/api/validate.js +31 -74
  68. package/lib/commands/api/validate.js.map +1 -0
  69. package/lib/commands/auth/login.d.ts +3 -1
  70. package/lib/commands/auth/login.js +26 -68
  71. package/lib/commands/auth/login.js.map +1 -0
  72. package/lib/commands/auth/logout.d.ts +3 -1
  73. package/lib/commands/auth/logout.js +14 -21
  74. package/lib/commands/auth/logout.js.map +1 -0
  75. package/lib/commands/auth/status.d.ts +1 -0
  76. package/lib/commands/auth/status.js +18 -21
  77. package/lib/commands/auth/status.js.map +1 -0
  78. package/lib/commands/portal/copilot.d.ts +13 -0
  79. package/lib/commands/portal/copilot.js +34 -0
  80. package/lib/commands/portal/copilot.js.map +1 -0
  81. package/lib/commands/portal/generate.d.ts +7 -11
  82. package/lib/commands/portal/generate.js +26 -89
  83. package/lib/commands/portal/generate.js.map +1 -0
  84. package/lib/commands/portal/recipe/new.d.ts +12 -0
  85. package/lib/commands/portal/recipe/new.js +45 -0
  86. package/lib/commands/portal/recipe/new.js.map +1 -0
  87. package/lib/commands/portal/serve.d.ts +8 -8
  88. package/lib/commands/portal/serve.js +41 -125
  89. package/lib/commands/portal/serve.js.map +1 -0
  90. package/lib/commands/portal/toc/new.d.ts +14 -0
  91. package/lib/commands/portal/toc/new.js +60 -0
  92. package/lib/commands/portal/toc/new.js.map +1 -0
  93. package/lib/commands/quickstart.d.ts +9 -0
  94. package/lib/commands/quickstart.js +37 -0
  95. package/lib/commands/quickstart.js.map +1 -0
  96. package/lib/commands/sdk/generate.d.ts +10 -8
  97. package/lib/commands/sdk/generate.js +46 -131
  98. package/lib/commands/sdk/generate.js.map +1 -0
  99. package/lib/config/axios-config.js +4 -6
  100. package/lib/config/axios-config.js.map +1 -0
  101. package/lib/hooks/not-found.d.ts +3 -0
  102. package/lib/hooks/not-found.js +52 -0
  103. package/lib/hooks/not-found.js.map +1 -0
  104. package/lib/hooks/utils.d.ts +5 -0
  105. package/lib/hooks/utils.js +51 -0
  106. package/lib/hooks/utils.js.map +1 -0
  107. package/lib/index.js +2 -5
  108. package/lib/index.js.map +1 -0
  109. package/lib/infrastructure/debounce-service.d.ts +10 -0
  110. package/lib/infrastructure/debounce-service.js +52 -0
  111. package/lib/infrastructure/debounce-service.js.map +1 -0
  112. package/lib/infrastructure/env-info.d.ts +12 -0
  113. package/lib/infrastructure/env-info.js +58 -0
  114. package/lib/infrastructure/env-info.js.map +1 -0
  115. package/lib/infrastructure/file-service.d.ts +24 -0
  116. package/lib/infrastructure/file-service.js +120 -0
  117. package/lib/infrastructure/file-service.js.map +1 -0
  118. package/lib/infrastructure/launcher-service.d.ts +9 -0
  119. package/lib/infrastructure/launcher-service.js +72 -0
  120. package/lib/infrastructure/launcher-service.js.map +1 -0
  121. package/lib/infrastructure/network-service.d.ts +3 -0
  122. package/lib/infrastructure/network-service.js +7 -0
  123. package/lib/infrastructure/network-service.js.map +1 -0
  124. package/lib/infrastructure/service-error.d.ts +16 -0
  125. package/lib/infrastructure/service-error.js +49 -0
  126. package/lib/infrastructure/service-error.js.map +1 -0
  127. package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
  128. package/lib/infrastructure/services/api-client-factory.js +20 -0
  129. package/lib/infrastructure/services/api-client-factory.js.map +1 -0
  130. package/lib/infrastructure/services/api-service.d.ts +12 -0
  131. package/lib/infrastructure/services/api-service.js +79 -0
  132. package/lib/infrastructure/services/api-service.js.map +1 -0
  133. package/lib/infrastructure/services/auth-service.d.ts +11 -0
  134. package/lib/infrastructure/services/auth-service.js +37 -0
  135. package/lib/infrastructure/services/auth-service.js.map +1 -0
  136. package/lib/infrastructure/services/file-download-service.d.ts +15 -0
  137. package/lib/infrastructure/services/file-download-service.js +104 -0
  138. package/lib/infrastructure/services/file-download-service.js.map +1 -0
  139. package/lib/infrastructure/services/portal-service.d.ts +17 -12
  140. package/lib/infrastructure/services/portal-service.js +134 -99
  141. package/lib/infrastructure/services/portal-service.js.map +1 -0
  142. package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
  143. package/lib/infrastructure/services/telemetry-service.js +38 -0
  144. package/lib/infrastructure/services/telemetry-service.js.map +1 -0
  145. package/lib/infrastructure/services/transformation-service.d.ts +23 -0
  146. package/lib/infrastructure/services/transformation-service.js +56 -0
  147. package/lib/infrastructure/services/transformation-service.js.map +1 -0
  148. package/lib/infrastructure/services/validation-service.d.ts +17 -0
  149. package/lib/infrastructure/services/validation-service.js +49 -0
  150. package/lib/infrastructure/services/validation-service.js.map +1 -0
  151. package/lib/infrastructure/tmp-extensions.d.ts +2 -0
  152. package/lib/infrastructure/tmp-extensions.js +6 -0
  153. package/lib/infrastructure/tmp-extensions.js.map +1 -0
  154. package/lib/infrastructure/zip-service.d.ts +6 -0
  155. package/lib/infrastructure/zip-service.js +39 -0
  156. package/lib/infrastructure/zip-service.js.map +1 -0
  157. package/lib/prompts/api/transform.d.ts +11 -0
  158. package/lib/prompts/api/transform.js +29 -0
  159. package/lib/prompts/api/transform.js.map +1 -0
  160. package/lib/prompts/api/validate.d.ts +12 -0
  161. package/lib/prompts/api/validate.js +40 -0
  162. package/lib/prompts/api/validate.js.map +1 -0
  163. package/lib/prompts/auth/login.d.ts +10 -0
  164. package/lib/prompts/auth/login.js +22 -0
  165. package/lib/prompts/auth/login.js.map +1 -0
  166. package/lib/prompts/auth/logout.d.ts +3 -0
  167. package/lib/prompts/auth/logout.js +7 -0
  168. package/lib/prompts/auth/logout.js.map +1 -0
  169. package/lib/prompts/auth/status.d.ts +8 -0
  170. package/lib/prompts/auth/status.js +22 -0
  171. package/lib/prompts/auth/status.js.map +1 -0
  172. package/lib/prompts/format.d.ts +31 -0
  173. package/lib/prompts/format.js +89 -0
  174. package/lib/prompts/format.js.map +1 -0
  175. package/lib/prompts/portal/copilot.d.ts +18 -0
  176. package/lib/prompts/portal/copilot.js +82 -0
  177. package/lib/prompts/portal/copilot.js.map +1 -0
  178. package/lib/prompts/portal/generate.d.ts +13 -8
  179. package/lib/prompts/portal/generate.js +36 -53
  180. package/lib/prompts/portal/generate.js.map +1 -0
  181. package/lib/prompts/portal/quickstart.d.ts +28 -29
  182. package/lib/prompts/portal/quickstart.js +102 -185
  183. package/lib/prompts/portal/quickstart.js.map +1 -0
  184. package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
  185. package/lib/prompts/portal/recipe/new-recipe.js +165 -0
  186. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  187. package/lib/prompts/portal/serve.d.ts +9 -5
  188. package/lib/prompts/portal/serve.js +29 -19
  189. package/lib/prompts/portal/serve.js.map +1 -0
  190. package/lib/prompts/portal/toc/new-toc.d.ts +15 -0
  191. package/lib/prompts/portal/toc/new-toc.js +38 -0
  192. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  193. package/lib/prompts/prompt.d.ts +3 -0
  194. package/lib/prompts/prompt.js +37 -0
  195. package/lib/prompts/prompt.js.map +1 -0
  196. package/lib/prompts/quickstart.d.ts +6 -0
  197. package/lib/prompts/quickstart.js +25 -0
  198. package/lib/prompts/quickstart.js.map +1 -0
  199. package/lib/prompts/sdk/generate.d.ts +11 -0
  200. package/lib/prompts/sdk/generate.js +37 -0
  201. package/lib/prompts/sdk/generate.js.map +1 -0
  202. package/lib/prompts/sdk/quickstart.d.ts +32 -0
  203. package/lib/prompts/sdk/quickstart.js +140 -0
  204. package/lib/prompts/sdk/quickstart.js.map +1 -0
  205. package/lib/types/api/account.d.ts +10 -0
  206. package/lib/types/api/account.js +2 -0
  207. package/lib/types/api/account.js.map +1 -0
  208. package/lib/types/api/transform.d.ts +14 -25
  209. package/lib/types/api/transform.js +20 -23
  210. package/lib/types/api/transform.js.map +1 -0
  211. package/lib/types/build/build.d.ts +22 -0
  212. package/lib/types/build/build.js +7 -0
  213. package/lib/types/build/build.js.map +1 -0
  214. package/lib/types/build-context.d.ts +13 -0
  215. package/lib/types/build-context.js +33 -0
  216. package/lib/types/build-context.js.map +1 -0
  217. package/lib/types/common/command-metadata.d.ts +4 -0
  218. package/lib/types/common/command-metadata.js +2 -0
  219. package/lib/types/common/command-metadata.js.map +1 -0
  220. package/lib/types/events/domain-event.d.ts +8 -0
  221. package/lib/types/events/domain-event.js +11 -0
  222. package/lib/types/events/domain-event.js.map +1 -0
  223. package/lib/types/events/quickstart-completed.d.ts +7 -0
  224. package/lib/types/events/quickstart-completed.js +10 -0
  225. package/lib/types/events/quickstart-completed.js.map +1 -0
  226. package/lib/types/events/quickstart-initiated.d.ts +7 -0
  227. package/lib/types/events/quickstart-initiated.js +10 -0
  228. package/lib/types/events/quickstart-initiated.js.map +1 -0
  229. package/lib/types/events/recipe-creation-failed.d.ts +5 -0
  230. package/lib/types/events/recipe-creation-failed.js +8 -0
  231. package/lib/types/events/recipe-creation-failed.js.map +1 -0
  232. package/lib/types/events/toc-creation-failed.d.ts +5 -0
  233. package/lib/types/events/toc-creation-failed.js +8 -0
  234. package/lib/types/events/toc-creation-failed.js.map +1 -0
  235. package/lib/types/file/directory.d.ts +17 -0
  236. package/lib/types/file/directory.js +87 -0
  237. package/lib/types/file/directory.js.map +1 -0
  238. package/lib/types/file/directoryPath.d.ts +10 -0
  239. package/lib/types/file/directoryPath.js +26 -0
  240. package/lib/types/file/directoryPath.js.map +1 -0
  241. package/lib/types/file/fileName.d.ts +7 -0
  242. package/lib/types/file/fileName.js +21 -0
  243. package/lib/types/file/fileName.js.map +1 -0
  244. package/lib/types/file/filePath.d.ts +10 -0
  245. package/lib/types/file/filePath.js +32 -0
  246. package/lib/types/file/filePath.js.map +1 -0
  247. package/lib/types/file/resource-input.d.ts +5 -0
  248. package/lib/types/file/resource-input.js +42 -0
  249. package/lib/types/file/resource-input.js.map +1 -0
  250. package/lib/types/file/urlPath.d.ts +6 -0
  251. package/lib/types/file/urlPath.js +22 -0
  252. package/lib/types/file/urlPath.js.map +1 -0
  253. package/lib/types/flags-provider.d.ts +15 -0
  254. package/lib/types/flags-provider.js +34 -0
  255. package/lib/types/flags-provider.js.map +1 -0
  256. package/lib/types/portal-context.d.ts +13 -0
  257. package/lib/types/portal-context.js +38 -0
  258. package/lib/types/portal-context.js.map +1 -0
  259. package/lib/types/recipe/recipe.d.ts +22 -0
  260. package/lib/types/recipe/recipe.js +6 -0
  261. package/lib/types/recipe/recipe.js.map +1 -0
  262. package/lib/types/recipe-context.d.ts +9 -0
  263. package/lib/types/recipe-context.js +26 -0
  264. package/lib/types/recipe-context.js.map +1 -0
  265. package/lib/types/resource-context.d.ts +12 -0
  266. package/lib/types/resource-context.js +30 -0
  267. package/lib/types/resource-context.js.map +1 -0
  268. package/lib/types/sdk/generate.d.ts +9 -22
  269. package/lib/types/sdk/generate.js +25 -14
  270. package/lib/types/sdk/generate.js.map +1 -0
  271. package/lib/types/sdk-context.d.ts +14 -0
  272. package/lib/types/sdk-context.js +32 -0
  273. package/lib/types/sdk-context.js.map +1 -0
  274. package/lib/types/sdl/sdl.d.ts +10 -0
  275. package/lib/types/sdl/sdl.js +47 -3
  276. package/lib/types/sdl/sdl.js.map +1 -0
  277. package/lib/types/spec-context.d.ts +12 -0
  278. package/lib/types/spec-context.js +29 -0
  279. package/lib/types/spec-context.js.map +1 -0
  280. package/lib/types/temp-context.d.ts +11 -0
  281. package/lib/types/temp-context.js +27 -0
  282. package/lib/types/temp-context.js.map +1 -0
  283. package/lib/types/toc/toc.js +2 -10
  284. package/lib/types/toc/toc.js.map +1 -0
  285. package/lib/types/toc-context.d.ts +12 -0
  286. package/lib/types/toc-context.js +26 -0
  287. package/lib/types/toc-context.js.map +1 -0
  288. package/lib/types/transform-context.d.ts +13 -0
  289. package/lib/types/transform-context.js +30 -0
  290. package/lib/types/transform-context.js.map +1 -0
  291. package/lib/types/utils.d.ts +0 -9
  292. package/lib/types/utils.js +2 -3
  293. package/lib/types/utils.js.map +1 -0
  294. package/lib/utils/string-utils.d.ts +2 -0
  295. package/lib/utils/string-utils.js +37 -0
  296. package/lib/utils/string-utils.js.map +1 -0
  297. package/lib/utils/utils.d.ts +2 -44
  298. package/lib/utils/utils.js +14 -366
  299. package/lib/utils/utils.js.map +1 -0
  300. package/package.json +50 -31
  301. package/bin/run +0 -9
  302. package/lib/actions/portal/new/toc.d.ts +0 -17
  303. package/lib/actions/portal/new/toc.js +0 -134
  304. package/lib/application/portal/new/toc/sdl-parser.d.ts +0 -13
  305. package/lib/application/portal/new/toc/sdl-parser.js +0 -53
  306. package/lib/application/portal/new/toc/toc-content-parser.js +0 -46
  307. package/lib/application/portal/new/toc/toc-structure-generator.js +0 -88
  308. package/lib/client-utils/sdk-client.d.ts +0 -23
  309. package/lib/client-utils/sdk-client.js +0 -124
  310. package/lib/commands/portal/new/toc.d.ts +0 -15
  311. package/lib/commands/portal/new/toc.js +0 -65
  312. package/lib/commands/portal/quickstart.d.ts +0 -10
  313. package/lib/commands/portal/quickstart.js +0 -79
  314. package/lib/config/env.d.ts +0 -27
  315. package/lib/config/env.js +0 -31
  316. package/lib/controllers/api/transform.d.ts +0 -5
  317. package/lib/controllers/api/transform.js +0 -56
  318. package/lib/controllers/api/validate.d.ts +0 -3
  319. package/lib/controllers/api/validate.js +0 -33
  320. package/lib/controllers/portal/generate.d.ts +0 -3
  321. package/lib/controllers/portal/generate.js +0 -110
  322. package/lib/controllers/portal/quickstart.d.ts +0 -14
  323. package/lib/controllers/portal/quickstart.js +0 -258
  324. package/lib/controllers/portal/serve.d.ts +0 -3
  325. package/lib/controllers/portal/serve.js +0 -138
  326. package/lib/controllers/sdk/generate.d.ts +0 -4
  327. package/lib/controllers/sdk/generate.js +0 -66
  328. package/lib/prompts/portal/new/toc.d.ts +0 -10
  329. package/lib/prompts/portal/new/toc.js +0 -46
  330. package/lib/services/portal/server.d.ts +0 -14
  331. package/lib/services/portal/server.js +0 -101
  332. package/lib/types/api/validate.d.ts +0 -12
  333. package/lib/types/api/validate.js +0 -3
  334. package/lib/types/common/result.d.ts +0 -17
  335. package/lib/types/common/result.js +0 -36
  336. package/lib/types/portal/generate.d.ts +0 -26
  337. package/lib/types/portal/generate.js +0 -4
  338. package/lib/types/portal/quickstart.d.ts +0 -17
  339. package/lib/types/portal/quickstart.js +0 -3
  340. package/lib/validators/common/directoryValidator.d.ts +0 -9
  341. package/lib/validators/common/directoryValidator.js +0 -53
  342. package/lib/validators/common/portValidator.d.ts +0 -5
  343. package/lib/validators/common/portValidator.js +0 -20
  344. package/lib/validators/portal/serveValidator.d.ts +0 -6
  345. package/lib/validators/portal/serveValidator.js +0 -21
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-service.js","sourceRoot":"","sources":["../../../src/infrastructure/services/portal-service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EACN,QAAQ,EAER,0BAA0B,EAC1B,oCAAoC,EACpC,WAAW,EACX,mCAAmC,EACnC,yBAAyB,EACzB,mBAAmB,EACnB,WAAW,EACX,wBAAwB,EAExB,aAAa,EACb,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAY,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAK7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,aAAa;IAA1B;QACmB,iBAAY,GAAG,WAAW,CAAC,qBAAqB,CAAC;QACjD,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAChC,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAuIvC,8BAAyB,GAAG,CAAC,QAAyB,EAAE,eAA8B,EAAU,EAAE;YACxG,MAAM,GAAG,GAAG,eAAe,KAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAA,CAAC;YACjD,OAAO,cAAc,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,EAAE,CAAC;QACnC,CAAC,CAAC;QAEM,+BAA0B,GAAG,CAAC,WA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C;YAC3C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,GAAG,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IA8BO,uBAAuB,CAAC,YAAgC;QAC9D,kEAAkE;QAClE,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,cAAc,CAAC;QACxB,CAAC;QACD,wBAAwB;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAE9C,qDAAqD;QACrD,IAAI,YAAY,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChG,sCAAsC;YACtC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YAClD,yEAAyE;YACzE,iEAAiE;QACnE,CAAC;aAAM,IAAI,YAAY,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YAC1C,OAAO,wCAAwC,CAAC;QAClD,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;CAWF"}
@@ -0,0 +1,9 @@
1
+ import { DomainEvent } from "../../types/events/domain-event.js";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ export declare class TelemetryService {
4
+ private readonly configDirectory;
5
+ private readonly apiService;
6
+ constructor(configDirectory: DirectoryPath);
7
+ trackEvent<T extends DomainEvent>(event: T, shell: string): Promise<void>;
8
+ private getAuthInfo;
9
+ }
@@ -0,0 +1,38 @@
1
+ import process from "process";
2
+ import os from "os";
3
+ import fs from "fs-extra";
4
+ import { envInfo } from "../env-info.js";
5
+ import path from "path";
6
+ import { ApiService } from "./api-service.js";
7
+ export class TelemetryService {
8
+ constructor(configDirectory) {
9
+ this.configDirectory = configDirectory;
10
+ this.apiService = new ApiService();
11
+ }
12
+ async trackEvent(event, shell) {
13
+ const authInfo = await this.getAuthInfo(this.configDirectory.toString());
14
+ const telemetryOptedOut = process.env.APIMATIC_CLI_TELEMETRY_OPTOUT === "1";
15
+ const authKey = authInfo === null || authInfo === void 0 ? void 0 : authInfo.authKey;
16
+ if (telemetryOptedOut || (authInfo === null || authInfo === void 0 ? void 0 : authInfo.APIMATIC_CLI_TELEMETRY_OPTOUT) === "1" || !authKey) {
17
+ return;
18
+ }
19
+ const payload = {
20
+ payload: event,
21
+ timestamp: new Date().toISOString(),
22
+ cliVersion: envInfo.getCLIVersion(),
23
+ platform: os.platform(),
24
+ releaseVersion: os.release(),
25
+ nodeVersion: process.version
26
+ };
27
+ await this.apiService.sendTelemetry(JSON.stringify(payload), authKey, shell);
28
+ }
29
+ async getAuthInfo(configDirectory) {
30
+ try {
31
+ return JSON.parse(await fs.readFile(path.join(configDirectory, "config.json"), "utf8"));
32
+ }
33
+ catch (_a) {
34
+ return null;
35
+ }
36
+ }
37
+ }
38
+ //# sourceMappingURL=telemetry-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-service.js","sourceRoot":"","sources":["../../../src/infrastructure/services/telemetry-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9C,MAAM,OAAO,gBAAgB;IAG3B,YAA6B,eAA8B;QAA9B,oBAAe,GAAf,eAAe,CAAe;QAF1C,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAEe,CAAC;IAExD,KAAK,CAAC,UAAU,CAAwB,KAAQ,EAAE,KAAa;QACpE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,GAAG,CAAC;QAC5E,MAAM,OAAO,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAC;QAElC,IAAI,iBAAiB,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,6BAA6B,MAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YACrF,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAqB;YAChC,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE;YACnC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE;YACvB,cAAc,EAAE,EAAE,CAAC,OAAO,EAAE;YAC5B,WAAW,EAAE,OAAO,CAAC,OAAO;SAC7B,CAAC;QAEF,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/E,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,eAAuB;QAC/C,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1F,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import { ExportFormats, ApiValidationSummary } from "@apimatic/sdk";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { FilePath } from "../../types/file/filePath.js";
4
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
5
+ import { Result } from "neverthrow";
6
+ export interface TransformViaFileParams {
7
+ file: FilePath;
8
+ format: ExportFormats;
9
+ configDir: DirectoryPath;
10
+ commandMetadata: CommandMetadata;
11
+ authKey?: string | null;
12
+ }
13
+ export interface TransformationResultData {
14
+ stream: NodeJS.ReadableStream;
15
+ apiValidationSummary: ApiValidationSummary;
16
+ }
17
+ export declare class TransformationService {
18
+ private readonly CONTENT_TYPE;
19
+ transformViaFile({ file, format, configDir, commandMetadata, authKey }: TransformViaFileParams): Promise<Result<TransformationResultData, string>>;
20
+ private createAuthorizationHeader;
21
+ private readonly createOriginQueryParameter;
22
+ private readonly handleTransformationErrors;
23
+ }
@@ -0,0 +1,56 @@
1
+ import fsExtra from "fs-extra";
2
+ import { ContentType, FileWrapper, TransformationController, ApiError } from "@apimatic/sdk";
3
+ import { getAuthInfo } from "../../client-utils/auth-manager.js";
4
+ import { apiClientFactory } from "./api-client-factory.js";
5
+ import { err, ok } from "neverthrow";
6
+ export class TransformationService {
7
+ constructor() {
8
+ this.CONTENT_TYPE = ContentType.EnumMultipartformdata;
9
+ this.createOriginQueryParameter = (commandName) => {
10
+ return {
11
+ origin: `APIMATIC CLI ${commandName}`
12
+ };
13
+ };
14
+ this.handleTransformationErrors = async (error) => {
15
+ if (error instanceof ApiError) {
16
+ const apiError = error;
17
+ if (apiError.statusCode === 400) {
18
+ return "Your API Definition is invalid. Please use the APIMatic VS Code Extension to fix the errors and try again.";
19
+ }
20
+ else if (apiError.statusCode === 401) {
21
+ const message = JSON.parse(apiError.body).message;
22
+ return `${message} You are not authorized to perform this action. Please run 'auth:login' or provide a valid auth key.`;
23
+ }
24
+ return `Error ${apiError.statusCode}: An error occurred during the transformation. Please try again or contact support@apimatic.io for assistance.`;
25
+ }
26
+ else {
27
+ return "An unexpected error occurred while validating your API Definition. Please try again later. If the problem persists, please reach out to our team at support@apimatic.io";
28
+ }
29
+ };
30
+ }
31
+ async transformViaFile({ file, format, configDir, commandMetadata, authKey }) {
32
+ const authInfo = await getAuthInfo(configDir.toString());
33
+ const authorizationHeader = this.createAuthorizationHeader(authInfo, authKey !== null && authKey !== void 0 ? authKey : null);
34
+ const client = apiClientFactory.createApiClient(authorizationHeader, commandMetadata.shell);
35
+ const transformationController = new TransformationController(client);
36
+ try {
37
+ const fileStream = fsExtra.createReadStream(file.toString());
38
+ const fileWrapper = new FileWrapper(fileStream);
39
+ const generation = await transformationController.transformViaFile(this.CONTENT_TYPE, fileWrapper, format, this.createOriginQueryParameter(commandMetadata.commandName));
40
+ const { id, apiValidationSummary } = generation.result;
41
+ const { result } = await transformationController.downloadTransformedFile(id);
42
+ return ok({
43
+ stream: result,
44
+ apiValidationSummary
45
+ });
46
+ }
47
+ catch (error) {
48
+ return err(await this.handleTransformationErrors(error));
49
+ }
50
+ }
51
+ createAuthorizationHeader(authInfo, overrideAuthKey) {
52
+ const key = overrideAuthKey || (authInfo === null || authInfo === void 0 ? void 0 : authInfo.authKey);
53
+ return `X-Auth-Key ${key !== null && key !== void 0 ? key : ""}`;
54
+ }
55
+ }
56
+ //# sourceMappingURL=transformation-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformation-service.js","sourceRoot":"","sources":["../../../src/infrastructure/services/transformation-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAEL,WAAW,EAEX,WAAW,EACX,wBAAwB,EAExB,QAAQ,EAET,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAY,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,GAAG,EAAE,EAAE,EAAS,MAAM,YAAY,CAAC;AAe5C,MAAM,OAAO,qBAAqB;IAAlC;QACmB,iBAAY,GAAG,WAAW,CAAC,qBAAqB,CAAC;QAyCjD,+BAA0B,GAAG,CAAC,WAAmB,EAA0B,EAAE;YAC5F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7D,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;YAChD,MAAM,UAAU,GAAgC,MAAM,wBAAwB,CAAC,gBAAgB,CAC7F,IAAI,CAAC,YAAY,EACjB,WAAW,EACX,MAAuB,EACvB,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAAC,WAAW,CAAC,CAC7D,CAAC;YAEF,MAAM,EAAE,EAAE,EAAE,oBAAoB,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC;YACvD,MAAM,EAAE,MAAM,EAAE,GAAuB,MAAM,wBAAwB,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;YAElG,OAAO,EAAE,CAAC;gBACR,MAAM,EAAE,MAA+B;gBACvC,oBAAoB;aACrB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAEO,yBAAyB,CAAC,QAAyB,EAAE,eAA8B;QACzF,MAAM,GAAG,GAAG,eAAe,KAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAA,CAAC;QACjD,OAAO,cAAc,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,EAAE,CAAC;IACnC,CAAC;CAsBF"}
@@ -0,0 +1,17 @@
1
+ import { ApiValidationSummary } from "@apimatic/sdk";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { Result } from "neverthrow";
4
+ import { FilePath } from "../../types/file/filePath.js";
5
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
6
+ export interface ValidateViaFileParams {
7
+ file: FilePath;
8
+ commandMetadata: CommandMetadata;
9
+ authKey?: string | null;
10
+ }
11
+ export declare class ValidationService {
12
+ private readonly configDir;
13
+ constructor(configDir: DirectoryPath);
14
+ validateViaFile({ file, commandMetadata, authKey }: ValidateViaFileParams): Promise<Result<ApiValidationSummary, string>>;
15
+ private createAuthorizationHeader;
16
+ private handleValidationErrors;
17
+ }
@@ -0,0 +1,49 @@
1
+ import fsExtra from "fs-extra";
2
+ import { ApiValidationExternalApisController, ContentType, FileWrapper, ApiError } from "@apimatic/sdk";
3
+ import { getAuthInfo } from "../../client-utils/auth-manager.js";
4
+ import { apiClientFactory } from "./api-client-factory.js";
5
+ import { err, ok } from "neverthrow";
6
+ export class ValidationService {
7
+ constructor(configDir) {
8
+ this.configDir = configDir;
9
+ }
10
+ async validateViaFile({ file, commandMetadata, authKey }) {
11
+ const authInfo = await getAuthInfo(this.configDir.toString());
12
+ const authorizationHeader = this.createAuthorizationHeader(authInfo, authKey !== null && authKey !== void 0 ? authKey : null);
13
+ const client = apiClientFactory.createApiClient(authorizationHeader, commandMetadata.shell);
14
+ const controller = new ApiValidationExternalApisController(client);
15
+ try {
16
+ const fileDescriptor = new FileWrapper(fsExtra.createReadStream(file.toString()));
17
+ //TODO: Update spec to include origin query parameter.
18
+ const validation = await controller.validateApiViaFile(ContentType.EnumMultipartformdata, fileDescriptor);
19
+ return ok(validation.result);
20
+ }
21
+ catch (error) {
22
+ return err(await this.handleValidationErrors(error));
23
+ }
24
+ }
25
+ createAuthorizationHeader(authInfo, overrideAuthKey) {
26
+ const key = overrideAuthKey || (authInfo === null || authInfo === void 0 ? void 0 : authInfo.authKey);
27
+ return `X-Auth-Key ${key !== null && key !== void 0 ? key : ""}`;
28
+ }
29
+ async handleValidationErrors(error) {
30
+ if (error instanceof ApiError) {
31
+ const apiError = error;
32
+ if (apiError.statusCode === 400) {
33
+ return "Your API Definition is invalid. Please fix the issues and try again.";
34
+ }
35
+ else if (apiError.statusCode === 401) {
36
+ return "You are not authorized to perform this action. Please run 'auth:login' or provide a valid auth key.";
37
+ }
38
+ else if (apiError.statusCode === 403) {
39
+ return "You do not have permission to perform this action.";
40
+ }
41
+ else if (apiError.statusCode === 500) {
42
+ return "An unexpected error occurred validating the API specification, please try again later. If the problem persists, please reach out to our team at support@apimatic.io";
43
+ }
44
+ return `Error ${apiError.statusCode}: An error occurred during validation.`;
45
+ }
46
+ return "Unexpected error occurred while validating API specification.";
47
+ }
48
+ }
49
+ //# sourceMappingURL=validation-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-service.js","sourceRoot":"","sources":["../../../src/infrastructure/services/validation-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAEL,mCAAmC,EAEnC,WAAW,EACX,WAAW,EACX,QAAQ,EACT,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAY,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAU7C,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;IAAG,CAAC;IAEzD,KAAK,CAAC,eAAe,CAAC,EACpB,IAAI,EACJ,eAAe,EACf,OAAO,EACe;QACtB,MAAM,QAAQ,GAAoB,MAAM,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/E,MAAM,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,CAAC;QACtF,MAAM,MAAM,GAAG,gBAAgB,CAAC,eAAe,CAAC,mBAAmB,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5F,MAAM,UAAU,GAAG,IAAI,mCAAmC,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAClF,sDAAsD;YACtD,MAAM,UAAU,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
@@ -0,0 +1,6 @@
1
+ import { DirectoryPath } from "../types/file/directoryPath.js";
2
+ import { withDir } from "tmp-promise";
3
+ export function withDirPath(fn) {
4
+ return withDir(results => fn(new DirectoryPath(results.path)), { unsafeCleanup: true });
5
+ }
6
+ //# sourceMappingURL=tmp-extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tmp-extensions.js","sourceRoot":"","sources":["../../src/infrastructure/tmp-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,EAA0C;IAE1C,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { DirectoryPath } from "../types/file/directoryPath.js";
2
+ import { FilePath } from "../types/file/filePath.js";
3
+ export declare class ZipService {
4
+ archive(sourceDir: DirectoryPath, outputZipPath: FilePath): Promise<void>;
5
+ unArchive(sourceFile: FilePath, destinationDirectory: DirectoryPath): Promise<void>;
6
+ }
@@ -0,0 +1,39 @@
1
+ import fs from "fs";
2
+ import archiver from "archiver";
3
+ import extract from "extract-zip";
4
+ export class ZipService {
5
+ async archive(sourceDir, outputZipPath) {
6
+ return new Promise((resolve, reject) => {
7
+ const output = fs.createWriteStream(outputZipPath.toString());
8
+ const archive = archiver("zip");
9
+ output.on("close", () => resolve());
10
+ archive.on("error", (err) => reject(err));
11
+ archive.pipe(output);
12
+ archive.directory(sourceDir.toString(), false); // false: don't nest under folder
13
+ archive.finalize();
14
+ });
15
+ }
16
+ async unArchive(sourceFile, destinationDirectory) {
17
+ const MAX_FILES = 100000;
18
+ const MAX_SIZE = 1000000000; // 1 GB
19
+ let fileCount = 0;
20
+ let totalSize = 0;
21
+ await extract(sourceFile.toString(), {
22
+ dir: destinationDirectory.toString(),
23
+ onEntry: function (entry) {
24
+ fileCount++;
25
+ if (fileCount > MAX_FILES) {
26
+ throw new Error("Reached max. file count");
27
+ }
28
+ // The uncompressedSize comes from the zip headers, so it might not be trustworthy.
29
+ // Alternatively, calculate the size from the readStream.
30
+ let entrySize = entry.uncompressedSize;
31
+ totalSize += entrySize;
32
+ if (totalSize > MAX_SIZE) {
33
+ throw new Error("Reached max. size");
34
+ }
35
+ }
36
+ });
37
+ }
38
+ }
39
+ //# sourceMappingURL=zip-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip-service.js","sourceRoot":"","sources":["../../src/infrastructure/zip-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,OAAO,MAAM,aAAa,CAAC;AAIlC,MAAM,OAAO,UAAU;IACd,KAAK,CAAC,OAAO,CAAC,SAAwB,EAAE,aAAuB;QACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YAEhC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YACpC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAE1C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,iCAAiC;YACjF,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAAoB,EAAE,oBAAmC;QAC9E,MAAM,SAAS,GAAG,MAAO,CAAC;QAC1B,MAAM,QAAQ,GAAG,UAAa,CAAC,CAAC,OAAO;QACvC,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE;YACnC,GAAG,EAAE,oBAAoB,CAAC,QAAQ,EAAE;YACpC,OAAO,EAAE,UAAU,KAAK;gBACtB,SAAS,EAAE,CAAC;gBACZ,IAAI,SAAS,GAAG,SAAS,EAAE,CAAC;oBAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;gBAC7C,CAAC;gBACD,mFAAmF;gBACnF,yDAAyD;gBACzD,IAAI,SAAS,GAAG,KAAK,CAAC,gBAAgB,CAAC;gBACvC,SAAS,IAAI,SAAS,CAAC;gBACvB,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;oBACzB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { Result } from "neverthrow";
3
+ import { TransformationResultData } from "../../infrastructure/services/transformation-service.js";
4
+ import { ServiceError } from "../../infrastructure/service-error.js";
5
+ export declare class ApiTransformPrompts {
6
+ overwriteApi(directory: DirectoryPath): Promise<boolean>;
7
+ transformedApiAlreadyExists(): void;
8
+ transformApi(fn: Promise<Result<TransformationResultData, string>>): Promise<Result<TransformationResultData, string>>;
9
+ logTransformationError(error: string): void;
10
+ networkError(serviceError: ServiceError): void;
11
+ }
@@ -0,0 +1,29 @@
1
+ import { log, isCancel, confirm } from "@clack/prompts";
2
+ import { format as f } from "../format.js";
3
+ import { withSpinner } from "../prompt.js";
4
+ export class ApiTransformPrompts {
5
+ async overwriteApi(directory) {
6
+ const overwrite = await confirm({
7
+ message: `A specification file already exists at ${f.path(directory)}. Do you want to overwrite the existing file?`,
8
+ initialValue: false
9
+ });
10
+ if (isCancel(overwrite)) {
11
+ return false;
12
+ }
13
+ return overwrite;
14
+ }
15
+ transformedApiAlreadyExists() {
16
+ const message = `Specification already exists.`;
17
+ log.error(message);
18
+ }
19
+ async transformApi(fn) {
20
+ return withSpinner("Transforming API", "API transformed successfully.", "API transformation failed.", fn);
21
+ }
22
+ logTransformationError(error) {
23
+ log.error(error);
24
+ }
25
+ networkError(serviceError) {
26
+ log.error(serviceError.errorMessage);
27
+ }
28
+ }
29
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/prompts/api/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,mBAAmB;IACvB,KAAK,CAAC,YAAY,CAAC,SAAwB;QAChD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAC9B,OAAO,EAAE,0CAA0C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,+CAA+C;YACnH,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,2BAA2B;QAChC,MAAM,OAAO,GAAG,+BAA+B,CAAC;QAChD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,EAAqD;QAC7E,OAAO,WAAW,CAAC,kBAAkB,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED,sBAAsB,CAAC,KAAa;QAClC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,YAAY,CAAC,YAA0B;QAC5C,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { ValidationMessages } from "../../types/utils.js";
2
+ import { Result } from "neverthrow";
3
+ import { ApiValidationSummary } from "@apimatic/sdk";
4
+ import { ServiceError } from "../../infrastructure/service-error.js";
5
+ import { FilePath } from "../../types/file/filePath.js";
6
+ export declare class ApiValidatePrompts {
7
+ validateApi(fn: Promise<Result<ApiValidationSummary, string>>): Promise<Result<ApiValidationSummary, string>>;
8
+ displayValidationMessages({ warnings, errors, messages }: ValidationMessages): void;
9
+ logValidationError(error: string): void;
10
+ networkError(serviceError: ServiceError): void;
11
+ transformedApiSaved(filePath: FilePath): void;
12
+ }
@@ -0,0 +1,40 @@
1
+ import { log } from "@clack/prompts";
2
+ import { replaceHTML } from "../../utils/utils.js";
3
+ import { format as f } from "../format.js";
4
+ import { withSpinner } from "../prompt.js";
5
+ export class ApiValidatePrompts {
6
+ async validateApi(fn) {
7
+ return withSpinner("Validating API", "API validation completed", "API validation failed", fn);
8
+ }
9
+ displayValidationMessages({ warnings, errors, messages }) {
10
+ if (messages.length > 0) {
11
+ log.info("Messages");
12
+ messages.forEach((msg) => {
13
+ log.message(`${replaceHTML(msg)}`);
14
+ });
15
+ }
16
+ if (warnings.length > 0) {
17
+ log.warning("Warnings");
18
+ warnings.forEach((war) => {
19
+ log.message(`${replaceHTML(war)}`);
20
+ });
21
+ }
22
+ if (errors.length > 0) {
23
+ log.error("Errors");
24
+ errors.forEach((err) => {
25
+ log.message(`${replaceHTML(err)}`);
26
+ });
27
+ }
28
+ }
29
+ logValidationError(error) {
30
+ log.error(error);
31
+ }
32
+ networkError(serviceError) {
33
+ const message = serviceError.errorMessage;
34
+ log.error(message);
35
+ }
36
+ transformedApiSaved(filePath) {
37
+ log.info(`Transformed API has been saved to ${f.path(filePath)}.`);
38
+ }
39
+ }
40
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/prompts/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,kBAAkB;IACtB,KAAK,CAAC,WAAW,CAAC,EAAiD;QACxE,OAAO,WAAW,CAAC,gBAAgB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,yBAAyB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAsB;QAC1E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACvB,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACxB,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACvB,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACrB,GAAG,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,kBAAkB,CAAC,KAAa;QAC9B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,YAAY,CAAC,YAA0B;QAC5C,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,CAAC;QAC1C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,mBAAmB,CAAC,QAAkB;QAC3C,GAAG,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { ServiceError } from "../../infrastructure/service-error.js";
2
+ import { SubscriptionInfo } from "../../types/api/account.js";
3
+ import { Result } from "neverthrow";
4
+ export declare class LoginPrompts {
5
+ loginSuccessful(email: string): void;
6
+ openBrowser(): void;
7
+ invalidKeyProvided(serviceError: ServiceError): void;
8
+ loginTimeout(): void;
9
+ accountInfoSpinner(fn: Promise<Result<SubscriptionInfo, ServiceError>>): Promise<Result<SubscriptionInfo, ServiceError>>;
10
+ }
@@ -0,0 +1,22 @@
1
+ import { log } from "@clack/prompts";
2
+ import { ServiceError } from "../../infrastructure/service-error.js";
3
+ import { withSpinner } from "../prompt.js";
4
+ export class LoginPrompts {
5
+ loginSuccessful(email) {
6
+ log.success(`Successfully logged in as ${email}`);
7
+ }
8
+ openBrowser() {
9
+ log.info("Please continue with authentication in the opened browser window.");
10
+ }
11
+ invalidKeyProvided(serviceError) {
12
+ const message = serviceError === ServiceError.NetworkError ? "Invalid API key provided." : serviceError.errorMessage;
13
+ log.error(message);
14
+ }
15
+ loginTimeout() {
16
+ log.error("Authentication timed out. Please try again.");
17
+ }
18
+ accountInfoSpinner(fn) {
19
+ return withSpinner("Retrieving your subscription info", "Retrieved subscription info", "Error retrieving subscription info", fn);
20
+ }
21
+ }
22
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/prompts/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,YAAY;IAChB,eAAe,CAAC,KAAa;QAClC,GAAG,CAAC,OAAO,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IAEM,WAAW;QAChB,GAAG,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;IAChF,CAAC;IAEM,kBAAkB,CAAC,YAA0B;QAClD,MAAM,OAAO,GACX,YAAY,KAAK,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QACvG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,YAAY;QACjB,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC3D,CAAC;IAEM,kBAAkB,CAAC,EAAmD;QAC3E,OAAO,WAAW,CAChB,mCAAmC,EACnC,6BAA6B,EAC7B,oCAAoC,EACpC,EAAE,CACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export declare class LogoutPrompts {
2
+ removeAuthInfo(): void;
3
+ }
@@ -0,0 +1,7 @@
1
+ import { log } from "@clack/prompts";
2
+ export class LogoutPrompts {
3
+ removeAuthInfo() {
4
+ log.info("Logged out successfully.");
5
+ }
6
+ }
7
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/prompts/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,MAAM,OAAO,aAAa;IAEjB,cAAc;QACnB,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { Result } from "neverthrow";
2
+ import { SubscriptionInfo } from "../../types/api/account.js";
3
+ import { ServiceError } from "../../infrastructure/service-error.js";
4
+ export declare class StatusPrompts {
5
+ accountInfoSpinner(fn: Promise<Result<SubscriptionInfo, ServiceError>>): Promise<Result<SubscriptionInfo, ServiceError>>;
6
+ invalidKeyProvided(serviceError: ServiceError): void;
7
+ showAccountInfo(info: SubscriptionInfo): void;
8
+ }
@@ -0,0 +1,22 @@
1
+ import { ServiceError } from "../../infrastructure/service-error.js";
2
+ import { format } from "../format.js";
3
+ import { log } from "@clack/prompts";
4
+ import { mapLanguages } from "../../types/sdk/generate.js";
5
+ import { withSpinner } from "../prompt.js";
6
+ export class StatusPrompts {
7
+ accountInfoSpinner(fn) {
8
+ return withSpinner("Retrieving your subscription info", "Retrieved subscription info", "Error retrieving subscription info", fn);
9
+ }
10
+ invalidKeyProvided(serviceError) {
11
+ const message = serviceError === ServiceError.UnAuthorized ? "Invalid API key provided." : serviceError.errorMessage;
12
+ log.error(message);
13
+ }
14
+ showAccountInfo(info) {
15
+ const languages = mapLanguages(info.allowedLanguages);
16
+ const message = `Account Information:
17
+ Email: ${format.var(info.Email)}
18
+ Allowed Languages: ${languages.map((language) => format.var(language)).join(", ")}`;
19
+ log.info(`${message}`);
20
+ }
21
+ }
22
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/prompts/auth/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,aAAa;IACjB,kBAAkB,CAAC,EAAmD;QAC3E,OAAO,WAAW,CAChB,mCAAmC,EACnC,6BAA6B,EAC7B,oCAAoC,EACpC,EAAE,CACH,CAAC;IACJ,CAAC;IAEM,kBAAkB,CAAC,YAA0B;QAClD,MAAM,OAAO,GACX,YAAY,KAAK,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;QACvG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,eAAe,CAAC,IAAsB;QAC3C,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG;WACT,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;uBACV,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ import { ActionResult } from "../actions/action-result.js";
2
+ import { Directory } from "../types/file/directory.js";
3
+ import { DirectoryPath } from "../types/file/directoryPath.js";
4
+ import { FilePath } from "../types/file/filePath.js";
5
+ export declare const format: {
6
+ var: (text: string) => string;
7
+ path: (text: DirectoryPath | FilePath) => string;
8
+ cmd: (cmd: string, ...args: string[]) => string;
9
+ cmdAlt: (cmd: string, ...args: string[]) => string;
10
+ link: (text: string) => string;
11
+ description: (text: string) => string;
12
+ flag: (name: string, value?: string | undefined) => string;
13
+ success: (text: string) => string;
14
+ error: (text: string) => string;
15
+ info: (text: string) => string;
16
+ intro: (text: string) => string;
17
+ outroSuccess: (text: string) => string;
18
+ outroFailure: (text: string) => string;
19
+ outroCancelled: (text: string) => string;
20
+ };
21
+ export declare function intro(text: string): void;
22
+ export declare function outro(result: ActionResult): void;
23
+ export declare function getDirectoryTree(dir: Directory, prefix?: string, isLast?: boolean): string;
24
+ export interface LeafNode {
25
+ name: string;
26
+ description?: string;
27
+ }
28
+ export interface TreeNode extends LeafNode {
29
+ items: Array<TreeNode | LeafNode>;
30
+ }
31
+ export declare function getTree(dir: TreeNode, prefix?: string, isLast?: boolean): string;
@@ -0,0 +1,89 @@
1
+ import pc from "picocolors";
2
+ import { intro as i, outro as o } from '@clack/prompts';
3
+ import { Directory } from "../types/file/directory.js";
4
+ export const format = {
5
+ // Core element types
6
+ var: (text) => pc.magenta(`'${text}'`),
7
+ path: (text) => pc.cyan(`'${text}'`),
8
+ cmd: (cmd, ...args) => `${pc.blueBright(cmd)} ${args.map(arg => pc.dim(arg)).join(" ")}`,
9
+ cmdAlt: (cmd, ...args) => `${pc.dim(pc.blueBright(cmd))} ${args.map(arg => pc.blueBright(arg)).join(" ")}`,
10
+ link: (text) => pc.underline(pc.blueBright(text)),
11
+ description: (text) => pc.greenBright(`${text}`),
12
+ flag: (name, value = undefined) => {
13
+ if (value) {
14
+ const sanitizedValue = value.includes(" ") ? `'${value}'` : value;
15
+ return `${pc.green(`--${name}`)}=${pc.dim(sanitizedValue)}`;
16
+ }
17
+ return `${pc.green(`--${name}`)}`;
18
+ },
19
+ // Common message styles
20
+ success: (text) => pc.green(text),
21
+ error: (text) => pc.red(text),
22
+ info: (text) => pc.cyan(text),
23
+ intro: (text) => pc.bgCyan(text),
24
+ outroSuccess: (text) => pc.bgGreen(text),
25
+ outroFailure: (text) => pc.bgRed(text),
26
+ outroCancelled: (text) => pc.bgWhite(pc.blackBright(text)),
27
+ };
28
+ export function intro(text) {
29
+ i(format.intro(` ${text} `));
30
+ }
31
+ export function outro(result) {
32
+ const exitCode = result.getExitCode();
33
+ const message = result.getMessage();
34
+ const outroMessage = result.mapAll(() => format.outroSuccess(message), () => format.outroFailure(message), () => format.outroCancelled(message));
35
+ o(outroMessage);
36
+ process.exitCode = exitCode;
37
+ }
38
+ export function getDirectoryTree(dir, prefix = "", isLast = true) {
39
+ const folderDescription = {
40
+ spec: "# Contains all API definition files",
41
+ content: "# Includes custom documentation pages in Markdown",
42
+ static: "# Includes all static files, such as images, GIFs, and PDFs"
43
+ };
44
+ const fileDescriptions = {
45
+ "toc.yml": "# Controls the structure of the side navigation bar in the API portal",
46
+ "APIMATIC-BUILD.json": "# Defines all configurations for the API portal, including programming languages and themes"
47
+ };
48
+ const pointer = isLast ? "└─ " : "├─ ";
49
+ const folderName = dir.directoryPath.leafName();
50
+ const description = folderDescription[folderName] ? format.description(folderDescription[folderName]) : "";
51
+ let output = `${prefix}${pointer}${folderName}${description ? " " + description : ""}\n`;
52
+ const items = dir.items;
53
+ const newPrefix = prefix + (isLast ? " " : "| ");
54
+ items.forEach((item, index) => {
55
+ const last = index === items.length - 1;
56
+ if (item instanceof Directory) {
57
+ output += getDirectoryTree(item, newPrefix, last);
58
+ }
59
+ else {
60
+ const filePointer = last ? "└─ " : "├─ ";
61
+ const fileName = item.toString();
62
+ const fileDescription = fileDescriptions[fileName] ? format.description(fileDescriptions[fileName]) : "";
63
+ output += `${newPrefix}${filePointer}${fileName}${fileDescription ? " " + fileDescription : ""}\n`;
64
+ }
65
+ });
66
+ return output;
67
+ }
68
+ export function getTree(dir, prefix = "", isLast = true) {
69
+ const pointer = isLast ? "└─ " : "├─ ";
70
+ const folderName = dir.name;
71
+ const description = dir.description ? format.description(dir.description) : "";
72
+ let output = `${prefix}${pointer}${folderName}${description ? " " + description : ""}\n`;
73
+ const items = dir.items;
74
+ const newPrefix = prefix + (isLast ? " " : "| ");
75
+ items.forEach((item, index) => {
76
+ const last = index === items.length - 1;
77
+ if ('items' in item) {
78
+ output += getTree(item, newPrefix, last);
79
+ }
80
+ else {
81
+ const filePointer = last ? "└─ " : "├─ ";
82
+ const fileName = item.name;
83
+ const fileDescription = item.description ? format.description(item.description) : "";
84
+ output += `${newPrefix}${filePointer}${fileName}${fileDescription ? " " + fileDescription : ""}\n`;
85
+ }
86
+ });
87
+ return output;
88
+ }
89
+ //# sourceMappingURL=format.js.map