@apimatic/cli 1.1.0-alpha.9 → 1.1.0-beta.2

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 (337) 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 +17 -13
  37. package/lib/actions/portal/toc/new-toc.js +85 -122
  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/toc/toc-content-parser.d.ts +1 -1
  55. package/lib/application/portal/toc/toc-content-parser.js +9 -11
  56. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  57. package/lib/application/portal/toc/toc-structure-generator.d.ts +1 -1
  58. package/lib/application/portal/toc/toc-structure-generator.js +4 -8
  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 +5 -6
  91. package/lib/commands/portal/toc/new.js +45 -50
  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 +13 -8
  191. package/lib/prompts/portal/toc/new-toc.js +28 -36
  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/application/portal/toc/sdl-parser.d.ts +0 -13
  303. package/lib/application/portal/toc/sdl-parser.js +0 -53
  304. package/lib/client-utils/sdk-client.d.ts +0 -23
  305. package/lib/client-utils/sdk-client.js +0 -124
  306. package/lib/commands/portal/quickstart.d.ts +0 -10
  307. package/lib/commands/portal/quickstart.js +0 -79
  308. package/lib/config/env.d.ts +0 -27
  309. package/lib/config/env.js +0 -31
  310. package/lib/controllers/api/transform.d.ts +0 -5
  311. package/lib/controllers/api/transform.js +0 -56
  312. package/lib/controllers/api/validate.d.ts +0 -3
  313. package/lib/controllers/api/validate.js +0 -33
  314. package/lib/controllers/portal/generate.d.ts +0 -3
  315. package/lib/controllers/portal/generate.js +0 -110
  316. package/lib/controllers/portal/quickstart.d.ts +0 -14
  317. package/lib/controllers/portal/quickstart.js +0 -258
  318. package/lib/controllers/portal/serve.d.ts +0 -3
  319. package/lib/controllers/portal/serve.js +0 -138
  320. package/lib/controllers/sdk/generate.d.ts +0 -4
  321. package/lib/controllers/sdk/generate.js +0 -66
  322. package/lib/services/portal/server.d.ts +0 -14
  323. package/lib/services/portal/server.js +0 -101
  324. package/lib/types/api/validate.d.ts +0 -12
  325. package/lib/types/api/validate.js +0 -3
  326. package/lib/types/common/result.d.ts +0 -17
  327. package/lib/types/common/result.js +0 -36
  328. package/lib/types/portal/generate.d.ts +0 -26
  329. package/lib/types/portal/generate.js +0 -4
  330. package/lib/types/portal/quickstart.d.ts +0 -17
  331. package/lib/types/portal/quickstart.js +0 -3
  332. package/lib/validators/common/directoryValidator.d.ts +0 -9
  333. package/lib/validators/common/directoryValidator.js +0 -53
  334. package/lib/validators/common/portValidator.d.ts +0 -5
  335. package/lib/validators/common/portValidator.js +0 -20
  336. package/lib/validators/portal/serveValidator.d.ts +0 -6
  337. package/lib/validators/portal/serveValidator.js +0 -21
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1,13 @@
1
+ export declare class ActionResult {
2
+ private readonly message;
3
+ private readonly resultType;
4
+ private constructor();
5
+ static success(): ActionResult;
6
+ static failed(): ActionResult;
7
+ static cancelled(): ActionResult;
8
+ static stopped(): ActionResult;
9
+ getMessage(): string;
10
+ getExitCode(): number;
11
+ isFailed(): boolean;
12
+ mapAll<T>(onSuccess: () => T, onFailure: () => T, onCancel: () => T): T;
13
+ }
@@ -0,0 +1,44 @@
1
+ var ResultType;
2
+ (function (ResultType) {
3
+ ResultType[ResultType["Success"] = 0] = "Success";
4
+ ResultType[ResultType["Cancel"] = 130] = "Cancel";
5
+ ResultType[ResultType["Failure"] = 1] = "Failure";
6
+ })(ResultType || (ResultType = {}));
7
+ export class ActionResult {
8
+ constructor(resultType, message) {
9
+ this.resultType = resultType;
10
+ this.message = message;
11
+ }
12
+ static success() {
13
+ return new ActionResult(ResultType.Success, " Succeeded ");
14
+ }
15
+ static failed() {
16
+ return new ActionResult(ResultType.Failure, " Failed ");
17
+ }
18
+ static cancelled() {
19
+ return new ActionResult(ResultType.Cancel, " Cancelled ");
20
+ }
21
+ static stopped() {
22
+ return new ActionResult(ResultType.Cancel, " Stopped ");
23
+ }
24
+ getMessage() {
25
+ return this.message;
26
+ }
27
+ getExitCode() {
28
+ return this.resultType.valueOf();
29
+ }
30
+ isFailed() {
31
+ return this.resultType === ResultType.Failure;
32
+ }
33
+ mapAll(onSuccess, onFailure, onCancel) {
34
+ switch (this.resultType) {
35
+ case ResultType.Success:
36
+ return onSuccess();
37
+ case ResultType.Failure:
38
+ return onFailure();
39
+ case ResultType.Cancel:
40
+ return onCancel();
41
+ }
42
+ }
43
+ }
44
+ //# sourceMappingURL=action-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-result.js","sourceRoot":"","sources":["../../src/actions/action-result.ts"],"names":[],"mappings":"AAAA,IAAK,UAIJ;AAJD,WAAK,UAAU;IACb,iDAAU,CAAA;IACV,iDAAY,CAAA;IACZ,iDAAU,CAAA;AACZ,CAAC,EAJI,UAAU,KAAV,UAAU,QAId;AAED,MAAM,OAAO,YAAY;IAIvB,YAAoB,UAAsB,EAAE,OAAe;QACzD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,SAAS;QACd,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,WAAW;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,UAAU,KAAK,UAAU,CAAC,OAAO,CAAC;IAChD,CAAC;IAEM,MAAM,CAAI,SAAkB,EAAE,SAAkB,EAAE,QAAiB;QACxE,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;YACxB,KAAK,UAAU,CAAC,OAAO;gBACrB,OAAO,SAAS,EAAE,CAAC;YACrB,KAAK,UAAU,CAAC,OAAO;gBACrB,OAAO,SAAS,EAAE,CAAC;YACrB,KAAK,UAAU,CAAC,MAAM;gBACpB,OAAO,QAAQ,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { ActionResult } from "../action-result.js";
3
+ import { ExportFormats } from "@apimatic/sdk";
4
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
5
+ import { ResourceInput } from "../../types/file/resource-input.js";
6
+ export declare class TransformAction {
7
+ private readonly prompts;
8
+ private readonly validatePrompts;
9
+ private readonly transformationService;
10
+ private readonly configDir;
11
+ private readonly commandMetadata;
12
+ private readonly authKey;
13
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
14
+ readonly execute: (resourcePath: ResourceInput, format: ExportFormats, destination: DirectoryPath, force: boolean) => Promise<ActionResult>;
15
+ }
@@ -0,0 +1,48 @@
1
+ import { ActionResult } from "../action-result.js";
2
+ import { ApiTransformPrompts } from "../../prompts/api/transform.js";
3
+ import { withDirPath } from "../../infrastructure/tmp-extensions.js";
4
+ import { TransformationService } from "../../infrastructure/services/transformation-service.js";
5
+ import { ApiValidatePrompts } from "../../prompts/api/validate.js";
6
+ import { TransformContext } from "../../types/transform-context.js";
7
+ import { ResourceContext } from "../../types/resource-context.js";
8
+ export class TransformAction {
9
+ constructor(configDir, commandMetadata, authKey = null) {
10
+ this.prompts = new ApiTransformPrompts();
11
+ this.validatePrompts = new ApiValidatePrompts();
12
+ this.transformationService = new TransformationService();
13
+ this.execute = async (resourcePath, format, destination, force) => {
14
+ return await withDirPath(async (tempDirectory) => {
15
+ const resourceContext = new ResourceContext(tempDirectory);
16
+ const specFileDirResult = await resourceContext.resolveTo(resourcePath);
17
+ if (specFileDirResult.isErr()) {
18
+ this.prompts.networkError(specFileDirResult.error);
19
+ return ActionResult.failed();
20
+ }
21
+ const transformContext = new TransformContext(specFileDirResult.value, format, destination);
22
+ if (!force && (await transformContext.exists()) && !(await this.prompts.overwriteApi(destination))) {
23
+ this.prompts.transformedApiAlreadyExists();
24
+ return ActionResult.cancelled();
25
+ }
26
+ const result = await this.prompts.transformApi(this.transformationService.transformViaFile({
27
+ file: specFileDirResult.value,
28
+ format: format,
29
+ configDir: this.configDir,
30
+ commandMetadata: this.commandMetadata,
31
+ authKey: this.authKey
32
+ }));
33
+ if (result.isErr()) {
34
+ this.prompts.logTransformationError(result.error);
35
+ return ActionResult.failed();
36
+ }
37
+ const transformedFilePath = await transformContext.save(result.value.stream);
38
+ this.validatePrompts.displayValidationMessages(result.value.apiValidationSummary);
39
+ this.validatePrompts.transformedApiSaved(transformedFilePath);
40
+ return ActionResult.success();
41
+ });
42
+ };
43
+ this.configDir = configDir;
44
+ this.commandMetadata = commandMetadata;
45
+ this.authKey = authKey;
46
+ }
47
+ }
48
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/actions/api/transform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,OAAO,eAAe;IAQ1B,YAAY,SAAwB,EAAE,eAAgC,EAAE,UAAyB,IAAI;QAPpF,YAAO,GAAwB,IAAI,mBAAmB,EAAE,CAAC;QACzD,oBAAe,GAAuB,IAAI,kBAAkB,EAAE,CAAC;QAC/D,0BAAqB,GAA0B,IAAI,qBAAqB,EAAE,CAAC;QAW5E,YAAO,GAAG,KAAK,EAC7B,YAA2B,EAC3B,MAAqB,EACrB,WAA0B,EAC1B,KAAc,EACS,EAAE;YACzB,OAAO,MAAM,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAC/C,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;gBAC3D,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACxE,IAAI,iBAAiB,CA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ElF,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;gBAE9D,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QA9CA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CA4CF"}
@@ -0,0 +1,12 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { ActionResult } from "../action-result.js";
3
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
4
+ import { ResourceInput } from "../../types/file/resource-input.js";
5
+ export declare class ValidateAction {
6
+ private readonly prompts;
7
+ private readonly validationService;
8
+ private readonly authKey;
9
+ private readonly commandMetadata;
10
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
11
+ readonly execute: (resourcePath: ResourceInput, displayValidationSummary?: boolean) => Promise<ActionResult>;
12
+ }
@@ -0,0 +1,41 @@
1
+ import { ActionResult } from "../action-result.js";
2
+ import { ApiValidatePrompts } from "../../prompts/api/validate.js";
3
+ import { ValidationService } from "../../infrastructure/services/validation-service.js";
4
+ import { withDirPath } from "../../infrastructure/tmp-extensions.js";
5
+ import { ResourceContext } from "../../types/resource-context.js";
6
+ export class ValidateAction {
7
+ constructor(configDir, commandMetadata, authKey = null) {
8
+ this.prompts = new ApiValidatePrompts();
9
+ this.execute = async (resourcePath, displayValidationSummary = true) => {
10
+ return await withDirPath(async (tempDirectory) => {
11
+ const resourceContext = new ResourceContext(tempDirectory);
12
+ const specFileDirResult = await resourceContext.resolveTo(resourcePath);
13
+ if (specFileDirResult.isErr()) {
14
+ this.prompts.networkError(specFileDirResult.error);
15
+ return ActionResult.failed();
16
+ }
17
+ const validationSummaryResult = await this.prompts.validateApi(this.validationService.validateViaFile({
18
+ file: specFileDirResult.value,
19
+ commandMetadata: this.commandMetadata,
20
+ authKey: this.authKey
21
+ }));
22
+ if (validationSummaryResult.isErr()) {
23
+ this.prompts.logValidationError(validationSummaryResult.error);
24
+ return ActionResult.failed();
25
+ }
26
+ const validationSummary = validationSummaryResult.value;
27
+ if (displayValidationSummary) {
28
+ this.prompts.displayValidationMessages(validationSummary);
29
+ }
30
+ if (!validationSummary.success) {
31
+ return ActionResult.failed();
32
+ }
33
+ return ActionResult.success();
34
+ });
35
+ };
36
+ this.authKey = authKey;
37
+ this.validationService = new ValidationService(configDir);
38
+ this.commandMetadata = commandMetadata;
39
+ }
40
+ }
41
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/actions/api/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGxF,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,OAAO,cAAc;IAMzB,YAAY,SAAwB,EAAE,eAAgC,EAAE,UAAyB,IAAI;QALpF,YAAO,GAAuB,IAAI,kBAAkB,EAAE,CAAC;QAWxD,YAAO,GAAG,KAAK,EAC7B,YAA2B,EAC3B,wBAAwB,GAAG,IAAI,EACR,EAAE;YACzB,OAAO,MAAM,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAC/C,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;gBAC3D,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACxE,IAAI,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC;oBAC9B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBACnD,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBACD,MAAM,uBAAuB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAC5D,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC;oBACrC,IAAI,EAAE,iBAAiB,CAAC,KAAK;oBAC7B,eAAe,EAAE,IAAI,CAAC,eAAe;oBACrC,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CAAC,CACH,CAAC;gBAEF,IAAI,uBAAuB,CAAC,KAAK,EAAE,EAAE,CAAC;oBACpC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;oBAC/D,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBACD,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,KAAK,CAAC;gBACxD,IAAI,wBAAwB,EAAE,CAAC;oBAC7B,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;gBAC5D,CAAC;gBACD,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;oBAC/B,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBAED,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAtCA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;CAoCF"}
@@ -0,0 +1,13 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
3
+ import { ActionResult } from "../action-result.js";
4
+ export declare class LoginAction {
5
+ private readonly configDir;
6
+ private readonly commandMetadata;
7
+ private readonly authService;
8
+ private readonly apiService;
9
+ private readonly prompts;
10
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata);
11
+ execute(apiKey?: string | undefined): Promise<ActionResult>;
12
+ private pollDeviceToken;
13
+ }
@@ -0,0 +1,55 @@
1
+ import { AuthService } from "../../infrastructure/services/auth-service.js";
2
+ import { ApiService } from "../../infrastructure/services/api-service.js";
3
+ import { v4 as uuid } from "uuid";
4
+ import open from "open";
5
+ import { setAuthInfo } from "../../client-utils/auth-manager.js";
6
+ import { LoginPrompts } from "../../prompts/auth/login.js";
7
+ import { ActionResult } from "../action-result.js";
8
+ import { err, ok } from "neverthrow";
9
+ export class LoginAction {
10
+ constructor(configDir, commandMetadata) {
11
+ this.configDir = configDir;
12
+ this.commandMetadata = commandMetadata;
13
+ this.authService = new AuthService();
14
+ this.apiService = new ApiService();
15
+ this.prompts = new LoginPrompts();
16
+ }
17
+ async execute(apiKey = undefined) {
18
+ const apiKeyResult = await this.pollDeviceToken(apiKey, this.commandMetadata.shell);
19
+ if (apiKeyResult.isErr()) {
20
+ this.prompts.loginTimeout();
21
+ return ActionResult.failed();
22
+ }
23
+ // TODO: Use status endpoint here
24
+ // Problem, we don't have email info here, just the key and required for setAuthInfo
25
+ const accountInfoResult = await this.prompts.accountInfoSpinner(this.apiService.getAccountInfo(this.configDir, this.commandMetadata.shell, apiKeyResult.value));
26
+ if (accountInfoResult.isErr()) {
27
+ this.prompts.invalidKeyProvided(accountInfoResult.error);
28
+ return ActionResult.failed();
29
+ }
30
+ await setAuthInfo(accountInfoResult.value.Email, apiKeyResult.value, false, this.configDir);
31
+ this.prompts.loginSuccessful(accountInfoResult.value.Email);
32
+ return ActionResult.success();
33
+ }
34
+ async pollDeviceToken(apiKey, shell) {
35
+ if (apiKey)
36
+ return ok(apiKey);
37
+ const state = uuid();
38
+ this.prompts.openBrowser();
39
+ await open(this.authService.getDeviceLoginUrl(state));
40
+ const timeoutDuration = 5 * 60 * 1000; // 5 minutes in milliseconds
41
+ const startTime = Date.now();
42
+ const delayMs = 3 * 1000;
43
+ while (true) {
44
+ if (Date.now() - startTime > timeoutDuration) {
45
+ return err("TIMEOUT");
46
+ }
47
+ const result = await this.authService.getDeviceLoginToken(state, shell);
48
+ if (result.isOk()) {
49
+ return ok(result.value.apiKey);
50
+ }
51
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/actions/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAE1E,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAI7C,MAAM,OAAO,WAAW;IAKtB,YAA6B,SAAwB,EAAmB,eAAgC;QAA3E,cAAS,GAAT,SAAS,CAAe;QAAmB,oBAAe,GAAf,eAAe,CAAiB;QAJvF,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAChC,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAC9B,YAAO,GAAG,IAAI,YAAY,EAAE,CAAC;IAE6D,CAAC;IAErG,KAAK,CAAC,OAAO,CAAC,SAA6B,SAAS;QACzD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACpF,IA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GAAG,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC;QAEzB,OAAO,IAAI,EAAE,CAAC;YACZ,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,eAAe,EAAE,CAAC;gBAC7C,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC;YACxB,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACxE,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAClB,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;YACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { ActionResult } from "../action-result.js";
3
+ export declare class LogoutAction {
4
+ private readonly configDir;
5
+ private readonly prompts;
6
+ constructor(configDir: DirectoryPath);
7
+ execute(): Promise<ActionResult>;
8
+ }
@@ -0,0 +1,15 @@
1
+ import { ActionResult } from "../action-result.js";
2
+ import { removeAuthInfo } from "../../client-utils/auth-manager.js";
3
+ import { LogoutPrompts } from "../../prompts/auth/logout.js";
4
+ export class LogoutAction {
5
+ constructor(configDir) {
6
+ this.configDir = configDir;
7
+ this.prompts = new LogoutPrompts();
8
+ }
9
+ async execute() {
10
+ await removeAuthInfo(this.configDir);
11
+ this.prompts.removeAuthInfo();
12
+ return ActionResult.success();
13
+ }
14
+ }
15
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/actions/auth/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,MAAM,OAAO,YAAY;IAGvB,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;QAFpC,YAAO,GAAG,IAAI,aAAa,EAAE,CAAC;IAES,CAAC;IAElD,KAAK,CAAC,OAAO;QAClB,MAAM,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC9B,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { ActionResult } from "../action-result.js";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
4
+ export declare class StatusAction {
5
+ private readonly configDir;
6
+ private readonly commandMetadata;
7
+ private readonly prompts;
8
+ private readonly apiService;
9
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata);
10
+ execute(authKey: string | null): Promise<ActionResult>;
11
+ }
@@ -0,0 +1,26 @@
1
+ import { ActionResult } from "../action-result.js";
2
+ import { getAuthInfo } from "../../client-utils/auth-manager.js";
3
+ import { StatusPrompts } from "../../prompts/auth/status.js";
4
+ import { ApiService } from "../../infrastructure/services/api-service.js";
5
+ export class StatusAction {
6
+ constructor(configDir, commandMetadata) {
7
+ this.configDir = configDir;
8
+ this.commandMetadata = commandMetadata;
9
+ this.prompts = new StatusPrompts();
10
+ this.apiService = new ApiService();
11
+ }
12
+ async execute(authKey) {
13
+ const accountInfo = await getAuthInfo(this.configDir.toString());
14
+ if (accountInfo === null) {
15
+ return ActionResult.failed();
16
+ }
17
+ const result = await this.prompts.accountInfoSpinner(this.apiService.getAccountInfo(this.configDir, this.commandMetadata.shell, authKey));
18
+ if (result.isErr()) {
19
+ this.prompts.invalidKeyProvided(result.error);
20
+ return ActionResult.failed();
21
+ }
22
+ this.prompts.showAccountInfo(result.value);
23
+ return ActionResult.success();
24
+ }
25
+ }
26
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/actions/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAE1E,MAAM,OAAO,YAAY;IAIvB,YAA6B,SAAwB,EAAmB,eAAgC;QAA3E,cAAS,GAAT,SAAS,CAAe;QAAmB,oBAAe,GAAf,eAAe,CAAiB;QAHvF,YAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QAC9B,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAE4D,CAAC;IAErG,KAAK,CAAC,OAAO,CAAC,OAAsB;QACzC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjE,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;QAC/B,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAClD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CACpF,CAAC;QACF,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { ActionResult } from "../action-result.js";
3
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
4
+ export declare class CopilotAction {
5
+ private readonly apiService;
6
+ private readonly fileService;
7
+ private readonly launcherService;
8
+ private readonly prompts;
9
+ private readonly configDir;
10
+ private readonly commandMetadata;
11
+ private readonly authKey;
12
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
13
+ readonly execute: (buildDirectory: DirectoryPath, force: boolean, enable: boolean) => Promise<ActionResult>;
14
+ private selectCopilotKey;
15
+ private prepareWelcomeMessage;
16
+ }
@@ -0,0 +1,89 @@
1
+ import { ApiService } from "../../infrastructure/services/api-service.js";
2
+ import { PortalCopilotPrompts } from "../../prompts/portal/copilot.js";
3
+ import { ActionResult } from "../action-result.js";
4
+ import { BuildContext } from "../../types/build-context.js";
5
+ import { withDirPath } from "../../infrastructure/tmp-extensions.js";
6
+ import { FilePath } from "../../types/file/filePath.js";
7
+ import { FileName } from "../../types/file/fileName.js";
8
+ import { FileService } from "../../infrastructure/file-service.js";
9
+ import { LauncherService } from "../../infrastructure/launcher-service.js";
10
+ import { err, ok } from "neverthrow";
11
+ export class CopilotAction {
12
+ constructor(configDir, commandMetadata, authKey = null) {
13
+ this.apiService = new ApiService();
14
+ this.fileService = new FileService();
15
+ this.launcherService = new LauncherService();
16
+ this.prompts = new PortalCopilotPrompts();
17
+ this.execute = async (buildDirectory, force, enable) => {
18
+ const buildContext = new BuildContext(buildDirectory);
19
+ if (!(await buildContext.validate())) {
20
+ this.prompts.srcDirectoryEmpty(buildDirectory);
21
+ return ActionResult.failed();
22
+ }
23
+ const buildJson = await buildContext.getBuildFileContents();
24
+ if (!force && buildJson.apiCopilotConfig != null && !(await this.prompts.confirmOverwrite())) {
25
+ this.prompts.cancelled();
26
+ return ActionResult.cancelled();
27
+ }
28
+ const response = await this.prompts.spinnerAccountInfo(this.apiService.getAccountInfo(this.configDir, this.commandMetadata.shell, this.authKey));
29
+ if (response.isErr()) {
30
+ this.prompts.serviceError(response.error);
31
+ return ActionResult.failed();
32
+ }
33
+ const apiCopilotKeyResult = await this.selectCopilotKey(response.value, force);
34
+ if (apiCopilotKeyResult.isErr()) {
35
+ if (apiCopilotKeyResult.error === "cancelled")
36
+ return ActionResult.cancelled();
37
+ return ActionResult.failed();
38
+ }
39
+ const welcomeMessage = await this.prepareWelcomeMessage();
40
+ buildJson.apiCopilotConfig = {
41
+ isEnabled: enable,
42
+ key: apiCopilotKeyResult.value,
43
+ welcomeMessage: welcomeMessage
44
+ };
45
+ await buildContext.updateBuildFileContents(buildJson);
46
+ this.prompts.copilotConfigured(enable, apiCopilotKeyResult.value);
47
+ return ActionResult.success();
48
+ };
49
+ this.configDir = configDir;
50
+ this.commandMetadata = commandMetadata;
51
+ this.authKey = authKey;
52
+ }
53
+ async selectCopilotKey(subscription, force) {
54
+ if (subscription.ApiCopilotKeys === undefined || subscription.ApiCopilotKeys.length === 0) {
55
+ this.prompts.noCopilotKeyFound();
56
+ return err("failed");
57
+ }
58
+ if (subscription.ApiCopilotKeys.length === 1) {
59
+ if (force || (await this.prompts.confirmSingleKeyUsage(subscription.ApiCopilotKeys[0])))
60
+ return ok(subscription.ApiCopilotKeys[0]);
61
+ this.prompts.noCopilotKeySelected();
62
+ return err("cancelled");
63
+ }
64
+ const key = await this.prompts.selectCopilotKey(subscription.ApiCopilotKeys);
65
+ if (key === null) {
66
+ this.prompts.noCopilotKeySelected();
67
+ return err("cancelled");
68
+ }
69
+ await this.prompts.displayApiCopilotKeyUsageWarning();
70
+ return ok(key);
71
+ }
72
+ async prepareWelcomeMessage() {
73
+ return await withDirPath(async (tempDir) => {
74
+ const tempFile = new FilePath(tempDir, new FileName("welcome-message.md"));
75
+ const defaultContent = "Hi there! I'm your API Integration Assistant, here to help you learn and integrate with this API.\n" +
76
+ "\n" +
77
+ "Ask me anything about this API or try one of these example prompts:\n" +
78
+ "\n" +
79
+ "`- What authentication methods does this API support?`\n" +
80
+ "`- [Enter another prompt here]`";
81
+ await this.fileService.writeContents(tempFile, defaultContent);
82
+ this.prompts.openWelcomeMessageEditor();
83
+ await this.launcherService.openInEditor(tempFile);
84
+ const welcomeMessage = await this.fileService.getContents(tempFile);
85
+ return welcomeMessage.replace(/\r\n|\r/g, "\n");
86
+ });
87
+ }
88
+ }
89
+ //# sourceMappingURL=copilot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/actions/portal/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAK7C,MAAM,OAAO,aAAa;IASxB,YAAY,SAAwB,EAAE,eAAgC,EAAE,UAAyB,IAAI;QARpF,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAC9B,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAChC,oBAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QACxC,YA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C,oBAAoB,EAAE,CAAC;YACpC,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;QAC7E,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;YACpC,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,CAAC;QACtD,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,qBAAqB;QACjC,OAAO,MAAM,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACzC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC3E,MAAM,cAAc,GAClB,qGAAqG;gBACrG,IAAI;gBACJ,uEAAuE;gBACvE,IAAI;gBACJ,0DAA0D;gBAC1D,iCAAiC,CAAC;YACpC,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAC/D,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAClD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACpE,OAAO,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,7 +1,13 @@
1
- import { PortalPaths, GenerateFlags } from "../../types/portal/generate";
2
- export declare class PortalGenerateAction {
1
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
2
+ import { ActionResult } from "../action-result.js";
3
+ import { CommandMetadata } from "../../types/common/command-metadata.js";
4
+ export declare class GenerateAction {
3
5
  private readonly prompts;
4
- constructor();
5
- generatePortal(paths: PortalPaths, flags: GenerateFlags, configDir: string): Promise<void>;
6
- private saveGeneratedPortalStreamToZipFile;
6
+ private readonly launcherService;
7
+ private readonly portalService;
8
+ private readonly configDir;
9
+ private readonly commandMetadata;
10
+ private readonly authKey;
11
+ constructor(configDir: DirectoryPath, commandMetadata: CommandMetadata, authKey?: string | null);
12
+ readonly execute: (buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, force: boolean, zipPortal: boolean, displayMessages?: boolean) => Promise<ActionResult>;
7
13
  }
@@ -1,58 +1,63 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PortalGenerateAction = void 0;
4
- const path = require("path");
5
- const fs = require("fs-extra");
6
- const portal_service_1 = require("../../infrastructure/services/portal-service");
7
- const result_1 = require("../../types/common/result");
8
- const utils_1 = require("../../utils/utils");
9
- const generate_1 = require("../../prompts/portal/generate");
10
- class PortalGenerateAction {
11
- constructor() {
12
- this.prompts = new generate_1.PortalGeneratePrompts();
13
- }
14
- async generatePortal(paths, flags, configDir) {
15
- var _a;
16
- this.prompts.displayPortalGenerationMessage();
17
- const pathsToIgnore = (0, utils_1.getGeneratedFilesPaths)(paths.sourceFolderPath, paths.generatedPortalArtifactsFolderPath);
18
- //TODO: Refactor this method, carries dual responsibility.
19
- const sourceBuildInputZipFilePath = await (0, utils_1.validateAndZipPortalSource)(paths.sourceFolderPath, path.join(paths.sourceFolderPath, ".portal_source.zip"), pathsToIgnore);
20
- const generatePortalParams = {
21
- sourceBuildInputZipFilePath: sourceBuildInputZipFilePath,
22
- generatedPortalArtifactsFolderPath: paths.generatedPortalArtifactsFolderPath,
23
- generatedPortalArtifactsZipFilePath: paths.generatedPortalArtifactsZipFilePath,
24
- overrideAuthKey: (_a = flags["auth-key"]) !== null && _a !== void 0 ? _a : null,
25
- generateZipFile: flags.zip
26
- };
27
- const docsPortalService = new portal_service_1.PortalService();
28
- const portalGenerationResult = await docsPortalService.generateOnPremPortal(generatePortalParams, configDir);
29
- await (0, utils_1.deleteFile)(sourceBuildInputZipFilePath);
30
- if (portalGenerationResult.isSuccess()) {
31
- await this.saveGeneratedPortalStreamToZipFile(portalGenerationResult.value, paths.generatedPortalArtifactsZipFilePath);
32
- if (flags.zip) {
33
- this.prompts.displayPortalGenerationSuccessMessage();
34
- this.prompts.displayOutroMessage(paths.generatedPortalArtifactsZipFilePath);
35
- return;
1
+ import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
2
+ import { PortalService } from "../../infrastructure/services/portal-service.js";
3
+ import { ActionResult } from "../action-result.js";
4
+ import { BuildContext } from "../../types/build-context.js";
5
+ import { PortalContext } from "../../types/portal-context.js";
6
+ import { withDirPath } from "../../infrastructure/tmp-extensions.js";
7
+ import { LauncherService } from "../../infrastructure/launcher-service.js";
8
+ import { TempContext } from "../../types/temp-context.js";
9
+ import { ServiceError } from "../../infrastructure/service-error.js";
10
+ export class GenerateAction {
11
+ constructor(configDir, commandMetadata, authKey = null) {
12
+ this.prompts = new PortalGeneratePrompts();
13
+ this.launcherService = new LauncherService();
14
+ this.portalService = new PortalService();
15
+ this.execute = async (buildDirectory, portalDirectory, force, zipPortal, displayMessages = true) => {
16
+ if (buildDirectory.isEqual(portalDirectory)) {
17
+ this.prompts.directoryCannotBeSame(portalDirectory);
18
+ return ActionResult.failed();
36
19
  }
37
- await (0, utils_1.extractZipFile)(paths.generatedPortalArtifactsZipFilePath, paths.generatedPortalArtifactsFolderPath);
38
- await (0, utils_1.deleteFile)(paths.generatedPortalArtifactsZipFilePath);
39
- this.prompts.displayPortalGenerationSuccessMessage();
40
- this.prompts.displayOutroMessage(paths.generatedPortalArtifactsFolderPath);
41
- }
42
- else {
43
- this.prompts.displayPortalGenerationErrorMessage();
44
- this.prompts.logError((0, utils_1.getMessageInRedColor)(`${portalGenerationResult.error}`));
45
- }
46
- }
47
- async saveGeneratedPortalStreamToZipFile(data, generatedPortalArtifactsZipFilePath) {
48
- const writeStream = fs.createWriteStream(generatedPortalArtifactsZipFilePath);
49
- await new Promise((resolve, reject) => {
50
- data
51
- .pipe(writeStream)
52
- .on("finish", () => resolve())
53
- .on("error", (error) => reject(result_1.Result.failure(`Failed to save downloaded portal to file: ${error.message}`)));
54
- });
20
+ const buildContext = new BuildContext(buildDirectory);
21
+ if (!(await buildContext.validate())) {
22
+ this.prompts.srcDirectoryEmpty(buildDirectory);
23
+ return ActionResult.failed();
24
+ }
25
+ const portalContext = new PortalContext(portalDirectory);
26
+ if (!force && (await portalContext.exists()) && !(await this.prompts.overwritePortal(portalDirectory))) {
27
+ this.prompts.portalDirectoryNotEmpty();
28
+ return ActionResult.cancelled();
29
+ }
30
+ return await withDirPath(async (tempDirectory) => {
31
+ const tempContext = new TempContext(tempDirectory);
32
+ const buildZipPath = await tempContext.zip(buildDirectory);
33
+ const response = await this.prompts.generatePortal(this.portalService.generatePortal(buildZipPath, this.configDir, this.commandMetadata, this.authKey));
34
+ if (response.isErr()) {
35
+ const error = response.error;
36
+ if (error instanceof ServiceError) {
37
+ this.prompts.portalGenerationServiceError(error);
38
+ }
39
+ else if (typeof error === "string") {
40
+ this.prompts.portalGenerationError(error);
41
+ }
42
+ else {
43
+ const errorZipPath = await tempContext.save(error);
44
+ const reportPath = await portalContext.saveError(errorZipPath);
45
+ await this.launcherService.openFile(reportPath);
46
+ this.prompts.portalGenerationErrorWithReport(reportPath);
47
+ }
48
+ return ActionResult.failed();
49
+ }
50
+ const tempPortalZipPath = await tempContext.save(response.value);
51
+ await portalContext.save(tempPortalZipPath, zipPortal);
52
+ if (displayMessages) {
53
+ this.prompts.portalGenerated(portalDirectory);
54
+ }
55
+ return ActionResult.success();
56
+ });
57
+ };
58
+ this.configDir = configDir;
59
+ this.commandMetadata = commandMetadata;
60
+ this.authKey = authKey;
55
61
  }
56
62
  }
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