@apimatic/cli 1.1.0-alpha.21 → 1.1.0-alpha.22

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 (299) hide show
  1. package/README.md +112 -90
  2. package/lib/actions/action-result.d.ts +8 -3
  3. package/lib/actions/action-result.js +34 -15
  4. package/lib/actions/action-result.js.map +1 -1
  5. package/lib/actions/api/transform.d.ts +15 -0
  6. package/lib/actions/api/transform.js +48 -0
  7. package/lib/actions/api/transform.js.map +1 -0
  8. package/lib/actions/api/validate.d.ts +12 -0
  9. package/lib/actions/api/validate.js +41 -0
  10. package/lib/actions/api/validate.js.map +1 -0
  11. package/lib/actions/auth/login.d.ts +6 -5
  12. package/lib/actions/auth/login.js +25 -33
  13. package/lib/actions/auth/login.js.map +1 -1
  14. package/lib/actions/auth/logout.d.ts +8 -0
  15. package/lib/actions/auth/logout.js +15 -0
  16. package/lib/actions/auth/logout.js.map +1 -0
  17. package/lib/actions/auth/status.d.ts +11 -0
  18. package/lib/actions/auth/status.js +26 -0
  19. package/lib/actions/auth/status.js.map +1 -0
  20. package/lib/actions/portal/copilot.d.ts +5 -3
  21. package/lib/actions/portal/copilot.js +47 -37
  22. package/lib/actions/portal/copilot.js.map +1 -1
  23. package/lib/actions/portal/generate.d.ts +4 -5
  24. package/lib/actions/portal/generate.js +30 -37
  25. package/lib/actions/portal/generate.js.map +1 -1
  26. package/lib/actions/portal/quickstart.d.ts +16 -0
  27. package/lib/actions/portal/quickstart.js +145 -0
  28. package/lib/actions/portal/quickstart.js.map +1 -0
  29. package/lib/actions/portal/recipe/new-recipe.d.ts +11 -20
  30. package/lib/actions/portal/recipe/new-recipe.js +147 -221
  31. package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
  32. package/lib/actions/portal/serve.d.ts +12 -10
  33. package/lib/actions/portal/serve.js +112 -17
  34. package/lib/actions/portal/serve.js.map +1 -1
  35. package/lib/actions/portal/toc/new-toc.d.ts +16 -15
  36. package/lib/actions/portal/toc/new-toc.js +80 -116
  37. package/lib/actions/portal/toc/new-toc.js.map +1 -1
  38. package/lib/actions/sdk/generate.d.ts +5 -6
  39. package/lib/actions/sdk/generate.js +22 -47
  40. package/lib/actions/sdk/generate.js.map +1 -1
  41. package/lib/application/portal/recipe/portal-recipe.d.ts +2 -2
  42. package/lib/application/portal/recipe/portal-recipe.js +9 -9
  43. package/lib/application/portal/recipe/portal-recipe.js.map +1 -1
  44. package/lib/application/portal/recipe/recipe-generator.d.ts +7 -2
  45. package/lib/application/portal/recipe/recipe-generator.js +21 -22
  46. package/lib/application/portal/recipe/recipe-generator.js.map +1 -1
  47. package/lib/client-utils/auth-manager.d.ts +1 -1
  48. package/lib/client-utils/auth-manager.js +3 -4
  49. package/lib/client-utils/auth-manager.js.map +1 -1
  50. package/lib/commands/api/transform.d.ts +6 -3
  51. package/lib/commands/api/transform.js +43 -94
  52. package/lib/commands/api/transform.js.map +1 -1
  53. package/lib/commands/api/validate.d.ts +6 -3
  54. package/lib/commands/api/validate.js +27 -66
  55. package/lib/commands/api/validate.js.map +1 -1
  56. package/lib/commands/auth/login.d.ts +2 -1
  57. package/lib/commands/auth/login.js +15 -9
  58. package/lib/commands/auth/login.js.map +1 -1
  59. package/lib/commands/auth/logout.d.ts +3 -1
  60. package/lib/commands/auth/logout.js +12 -13
  61. package/lib/commands/auth/logout.js.map +1 -1
  62. package/lib/commands/auth/status.d.ts +1 -0
  63. package/lib/commands/auth/status.js +13 -11
  64. package/lib/commands/auth/status.js.map +1 -1
  65. package/lib/commands/portal/copilot.d.ts +2 -2
  66. package/lib/commands/portal/copilot.js +22 -20
  67. package/lib/commands/portal/copilot.js.map +1 -1
  68. package/lib/commands/portal/generate.d.ts +3 -4
  69. package/lib/commands/portal/generate.js +19 -14
  70. package/lib/commands/portal/generate.js.map +1 -1
  71. package/lib/commands/portal/quickstart.d.ts +3 -4
  72. package/lib/commands/portal/quickstart.js +24 -101
  73. package/lib/commands/portal/quickstart.js.map +1 -1
  74. package/lib/commands/portal/recipe/new.d.ts +3 -1
  75. package/lib/commands/portal/recipe/new.js +31 -23
  76. package/lib/commands/portal/recipe/new.js.map +1 -1
  77. package/lib/commands/portal/serve.d.ts +5 -5
  78. package/lib/commands/portal/serve.js +31 -57
  79. package/lib/commands/portal/serve.js.map +1 -1
  80. package/lib/commands/portal/toc/new.d.ts +2 -2
  81. package/lib/commands/portal/toc/new.js +35 -26
  82. package/lib/commands/portal/toc/new.js.map +1 -1
  83. package/lib/commands/sdk/generate.d.ts +5 -4
  84. package/lib/commands/sdk/generate.js +26 -17
  85. package/lib/commands/sdk/generate.js.map +1 -1
  86. package/lib/hooks/not-found.js +1 -1
  87. package/lib/hooks/not-found.js.map +1 -1
  88. package/lib/infrastructure/api-utils.js +3 -2
  89. package/lib/infrastructure/api-utils.js.map +1 -1
  90. package/lib/{application/portal/serve/watcher-handler.d.ts → infrastructure/debounce-service.d.ts} +3 -3
  91. package/lib/{application/portal/serve/watcher-handler.js → infrastructure/debounce-service.js} +5 -4
  92. package/lib/infrastructure/debounce-service.js.map +1 -0
  93. package/lib/infrastructure/env-info.d.ts +1 -1
  94. package/lib/infrastructure/env-info.js +2 -2
  95. package/lib/infrastructure/env-info.js.map +1 -1
  96. package/lib/infrastructure/file-service.d.ts +7 -2
  97. package/lib/infrastructure/file-service.js +46 -5
  98. package/lib/infrastructure/file-service.js.map +1 -1
  99. package/lib/infrastructure/launcher-service.d.ts +2 -0
  100. package/lib/infrastructure/launcher-service.js +4 -0
  101. package/lib/infrastructure/launcher-service.js.map +1 -1
  102. package/lib/infrastructure/network-service.d.ts +3 -0
  103. package/lib/infrastructure/network-service.js +7 -0
  104. package/lib/infrastructure/network-service.js.map +1 -0
  105. package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
  106. package/lib/infrastructure/services/api-client-factory.js +20 -0
  107. package/lib/infrastructure/services/api-client-factory.js.map +1 -0
  108. package/lib/infrastructure/services/api-service.d.ts +2 -2
  109. package/lib/infrastructure/services/api-service.js +6 -6
  110. package/lib/infrastructure/services/api-service.js.map +1 -1
  111. package/lib/infrastructure/services/auth-service.d.ts +1 -1
  112. package/lib/infrastructure/services/auth-service.js +7 -5
  113. package/lib/infrastructure/services/auth-service.js.map +1 -1
  114. package/lib/infrastructure/services/file-download-service.d.ts +15 -0
  115. package/lib/infrastructure/services/file-download-service.js +104 -0
  116. package/lib/infrastructure/services/file-download-service.js.map +1 -0
  117. package/lib/infrastructure/services/portal-service.d.ts +11 -13
  118. package/lib/infrastructure/services/portal-service.js +73 -102
  119. package/lib/infrastructure/services/portal-service.js.map +1 -1
  120. package/lib/infrastructure/services/telemetry-service.d.ts +3 -2
  121. package/lib/infrastructure/services/telemetry-service.js +4 -6
  122. package/lib/infrastructure/services/telemetry-service.js.map +1 -1
  123. package/lib/infrastructure/services/transformation-service.d.ts +23 -0
  124. package/lib/infrastructure/services/transformation-service.js +56 -0
  125. package/lib/infrastructure/services/transformation-service.js.map +1 -0
  126. package/lib/infrastructure/services/validation-service.d.ts +17 -0
  127. package/lib/infrastructure/services/validation-service.js +49 -0
  128. package/lib/infrastructure/services/validation-service.js.map +1 -0
  129. package/lib/prompts/api/transform.d.ts +11 -0
  130. package/lib/prompts/api/transform.js +30 -0
  131. package/lib/prompts/api/transform.js.map +1 -0
  132. package/lib/prompts/api/validate.d.ts +12 -0
  133. package/lib/prompts/api/validate.js +41 -0
  134. package/lib/prompts/api/validate.js.map +1 -0
  135. package/lib/prompts/auth/login.d.ts +6 -1
  136. package/lib/prompts/auth/login.js +12 -3
  137. package/lib/prompts/auth/login.js.map +1 -1
  138. package/lib/prompts/auth/logout.d.ts +3 -0
  139. package/lib/prompts/auth/logout.js +7 -0
  140. package/lib/prompts/auth/logout.js.map +1 -0
  141. package/lib/prompts/auth/status.d.ts +8 -0
  142. package/lib/prompts/auth/status.js +21 -0
  143. package/lib/prompts/auth/status.js.map +1 -0
  144. package/lib/prompts/format.d.ts +33 -0
  145. package/lib/prompts/format.js +99 -0
  146. package/lib/prompts/format.js.map +1 -0
  147. package/lib/prompts/portal/copilot.d.ts +8 -4
  148. package/lib/prompts/portal/copilot.js +35 -24
  149. package/lib/prompts/portal/copilot.js.map +1 -1
  150. package/lib/prompts/portal/generate.d.ts +9 -7
  151. package/lib/prompts/portal/generate.js +22 -23
  152. package/lib/prompts/portal/generate.js.map +1 -1
  153. package/lib/prompts/portal/quickstart.d.ts +30 -29
  154. package/lib/prompts/portal/quickstart.js +99 -193
  155. package/lib/prompts/portal/quickstart.js.map +1 -1
  156. package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -18
  157. package/lib/prompts/portal/recipe/new-recipe.js +70 -108
  158. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
  159. package/lib/prompts/portal/serve.d.ts +10 -3
  160. package/lib/prompts/portal/serve.js +30 -11
  161. package/lib/prompts/portal/serve.js.map +1 -1
  162. package/lib/prompts/portal/toc/new-toc.d.ts +12 -8
  163. package/lib/prompts/portal/toc/new-toc.js +20 -22
  164. package/lib/prompts/portal/toc/new-toc.js.map +1 -1
  165. package/lib/prompts/sdk/generate.d.ts +7 -7
  166. package/lib/prompts/sdk/generate.js +17 -23
  167. package/lib/prompts/sdk/generate.js.map +1 -1
  168. package/lib/types/api/account.d.ts +1 -1
  169. package/lib/types/api/transform.d.ts +14 -25
  170. package/lib/types/api/transform.js +16 -16
  171. package/lib/types/api/transform.js.map +1 -1
  172. package/lib/types/build/build.d.ts +9 -1
  173. package/lib/types/build/build.js +5 -2
  174. package/lib/types/build/build.js.map +1 -1
  175. package/lib/types/build-context.d.ts +5 -1
  176. package/lib/types/build-context.js +21 -4
  177. package/lib/types/build-context.js.map +1 -1
  178. package/lib/types/common/command-metadata.d.ts +4 -0
  179. package/lib/types/common/command-metadata.js +2 -0
  180. package/lib/types/common/command-metadata.js.map +1 -0
  181. package/lib/types/events/domain-event.d.ts +1 -1
  182. package/lib/types/events/domain-event.js.map +1 -1
  183. package/lib/types/events/quickstart-completed.js +1 -1
  184. package/lib/types/events/quickstart-initiated.js +1 -1
  185. package/lib/types/events/recipe-creation-failed.d.ts +1 -1
  186. package/lib/types/events/recipe-creation-failed.js +1 -1
  187. package/lib/types/events/recipe-creation-failed.js.map +1 -1
  188. package/lib/types/events/toc-creation-failed.d.ts +1 -1
  189. package/lib/types/events/toc-creation-failed.js +1 -1
  190. package/lib/types/events/toc-creation-failed.js.map +1 -1
  191. package/lib/types/file/directory.d.ts +17 -0
  192. package/lib/types/file/directory.js +86 -0
  193. package/lib/types/file/directory.js.map +1 -0
  194. package/lib/types/file/directoryPath.d.ts +3 -1
  195. package/lib/types/file/directoryPath.js +8 -2
  196. package/lib/types/file/directoryPath.js.map +1 -1
  197. package/lib/types/file/fileName.d.ts +2 -0
  198. package/lib/types/file/fileName.js +12 -0
  199. package/lib/types/file/fileName.js.map +1 -1
  200. package/lib/types/file/filePath.d.ts +2 -0
  201. package/lib/types/file/filePath.js +21 -0
  202. package/lib/types/file/filePath.js.map +1 -1
  203. package/lib/types/file/resource-input.d.ts +5 -0
  204. package/lib/types/file/resource-input.js +42 -0
  205. package/lib/types/file/resource-input.js.map +1 -0
  206. package/lib/types/file/urlPath.d.ts +6 -0
  207. package/lib/types/file/urlPath.js +22 -0
  208. package/lib/types/file/urlPath.js.map +1 -0
  209. package/lib/types/portal-context.d.ts +3 -1
  210. package/lib/types/portal-context.js +10 -0
  211. package/lib/types/portal-context.js.map +1 -1
  212. package/lib/types/recipe/recipe.d.ts +2 -17
  213. package/lib/types/recipe-context.d.ts +8 -0
  214. package/lib/types/recipe-context.js +21 -0
  215. package/lib/types/recipe-context.js.map +1 -0
  216. package/lib/types/resource-context.d.ts +12 -0
  217. package/lib/types/resource-context.js +30 -0
  218. package/lib/types/resource-context.js.map +1 -0
  219. package/lib/types/sdk/generate.d.ts +2 -15
  220. package/lib/types/sdk/generate.js +24 -10
  221. package/lib/types/sdk/generate.js.map +1 -1
  222. package/lib/types/sdk-context.d.ts +6 -5
  223. package/lib/types/sdk-context.js +12 -8
  224. package/lib/types/sdk-context.js.map +1 -1
  225. package/lib/types/sdl/sdl.d.ts +9 -0
  226. package/lib/types/sdl/sdl.js +46 -1
  227. package/lib/types/sdl/sdl.js.map +1 -1
  228. package/lib/types/spec-context.d.ts +3 -0
  229. package/lib/types/spec-context.js +7 -2
  230. package/lib/types/spec-context.js.map +1 -1
  231. package/lib/types/temp-context.d.ts +11 -0
  232. package/lib/types/temp-context.js +27 -0
  233. package/lib/types/temp-context.js.map +1 -0
  234. package/lib/types/toc-context.d.ts +12 -0
  235. package/lib/types/toc-context.js +26 -0
  236. package/lib/types/toc-context.js.map +1 -0
  237. package/lib/types/transform-context.d.ts +13 -0
  238. package/lib/types/transform-context.js +30 -0
  239. package/lib/types/transform-context.js.map +1 -0
  240. package/lib/types/utils.d.ts +0 -9
  241. package/lib/utils/string-utils.d.ts +1 -0
  242. package/lib/utils/string-utils.js +10 -0
  243. package/lib/utils/string-utils.js.map +1 -0
  244. package/lib/utils/utils.d.ts +2 -27
  245. package/lib/utils/utils.js +6 -145
  246. package/lib/utils/utils.js.map +1 -1
  247. package/package.json +4 -4
  248. package/lib/application/portal/serve/portal-watcher.d.ts +0 -11
  249. package/lib/application/portal/serve/portal-watcher.js +0 -64
  250. package/lib/application/portal/serve/portal-watcher.js.map +0 -1
  251. package/lib/application/portal/serve/serve-handler.d.ts +0 -16
  252. package/lib/application/portal/serve/serve-handler.js +0 -91
  253. package/lib/application/portal/serve/serve-handler.js.map +0 -1
  254. package/lib/application/portal/serve/watcher-handler.js.map +0 -1
  255. package/lib/application/portal/toc/sdl-parser.d.ts +0 -19
  256. package/lib/application/portal/toc/sdl-parser.js +0 -90
  257. package/lib/application/portal/toc/sdl-parser.js.map +0 -1
  258. package/lib/client-utils/sdk-client.d.ts +0 -18
  259. package/lib/client-utils/sdk-client.js +0 -41
  260. package/lib/client-utils/sdk-client.js.map +0 -1
  261. package/lib/config/env.d.ts +0 -26
  262. package/lib/config/env.js +0 -27
  263. package/lib/config/env.js.map +0 -1
  264. package/lib/controllers/api/transform.d.ts +0 -5
  265. package/lib/controllers/api/transform.js +0 -50
  266. package/lib/controllers/api/transform.js.map +0 -1
  267. package/lib/controllers/api/validate.d.ts +0 -3
  268. package/lib/controllers/api/validate.js +0 -29
  269. package/lib/controllers/api/validate.js.map +0 -1
  270. package/lib/controllers/portal/quickstart.d.ts +0 -13
  271. package/lib/controllers/portal/quickstart.js +0 -214
  272. package/lib/controllers/portal/quickstart.js.map +0 -1
  273. package/lib/infrastructure/api-client-utils.d.ts +0 -6
  274. package/lib/infrastructure/api-client-utils.js +0 -34
  275. package/lib/infrastructure/api-client-utils.js.map +0 -1
  276. package/lib/prompts/portal/common/base-prompts.d.ts +0 -7
  277. package/lib/prompts/portal/common/base-prompts.js +0 -19
  278. package/lib/prompts/portal/common/base-prompts.js.map +0 -1
  279. package/lib/types/api/validate.d.ts +0 -12
  280. package/lib/types/api/validate.js +0 -2
  281. package/lib/types/api/validate.js.map +0 -1
  282. package/lib/types/common/result.d.ts +0 -17
  283. package/lib/types/common/result.js +0 -32
  284. package/lib/types/common/result.js.map +0 -1
  285. package/lib/types/portal/generate.d.ts +0 -13
  286. package/lib/types/portal/generate.js +0 -3
  287. package/lib/types/portal/generate.js.map +0 -1
  288. package/lib/types/portal/quickstart.d.ts +0 -17
  289. package/lib/types/portal/quickstart.js +0 -2
  290. package/lib/types/portal/quickstart.js.map +0 -1
  291. package/lib/types/portal/serve.d.ts +0 -12
  292. package/lib/types/portal/serve.js +0 -2
  293. package/lib/types/portal/serve.js.map +0 -1
  294. package/lib/validators/common/directoryValidator.d.ts +0 -5
  295. package/lib/validators/common/directoryValidator.js +0 -22
  296. package/lib/validators/common/directoryValidator.js.map +0 -1
  297. package/lib/validators/portal/serve-validator.d.ts +0 -6
  298. package/lib/validators/portal/serve-validator.js +0 -15
  299. package/lib/validators/portal/serve-validator.js.map +0 -1
@@ -1,28 +1,34 @@
1
1
  import { Command, Flags } from "@oclif/core";
2
2
  import { DirectoryPath } from "../../types/file/directoryPath.js";
3
- import { LoginPrompts } from "../../prompts/auth/login.js";
4
3
  import { LoginAction } from "../../actions/auth/login.js";
4
+ import { format, intro, outro } from "../../prompts/format.js";
5
5
  class Login extends Command {
6
- constructor() {
7
- super(...arguments);
8
- this.prompts = new LoginPrompts();
9
- }
10
6
  async run() {
11
7
  const { flags: { "auth-key": authKey } } = await this.parse(Login);
12
8
  if (authKey === "") {
13
9
  this.error("Flag --auth-key must not be empty when provided.");
14
10
  }
15
- const loginAction = new LoginAction(new DirectoryPath(this.config.configDir));
11
+ const commandMetadata = {
12
+ commandName: Login.id,
13
+ shell: this.config.shell
14
+ };
15
+ intro("Login");
16
+ const loginAction = new LoginAction(new DirectoryPath(this.config.configDir), commandMetadata);
16
17
  const result = await loginAction.execute(authKey);
17
- result.match((email) => this.prompts.loginSuccessful(email), (error) => this.prompts.logError(error));
18
+ outro(result);
18
19
  }
19
20
  }
21
+ Login.summary = "Login to your APIMatic account";
20
22
  Login.description = "Login using your APIMatic credentials or an API Key";
21
- Login.examples = [`apimatic auth:login`, `apimatic auth:login --auth-key={api-key}`];
23
+ Login.cmdTxt = format.cmd('apimatic', 'auth', 'login');
24
+ Login.examples = [
25
+ Login.cmdTxt,
26
+ `${Login.cmdTxt} ${format.flag('auth-key', '{api-key}')}`
27
+ ];
22
28
  Login.flags = {
23
29
  "auth-key": Flags.string({
24
30
  char: "k",
25
- description: "Sets authentication key for all commands.",
31
+ description: "Sets authentication key for all commands."
26
32
  })
27
33
  };
28
34
  export default Login;
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,6BA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K"}
@@ -1,6 +1,8 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class Login extends Command {
2
+ export default class Logout extends Command {
3
+ static summary: string;
3
4
  static description: string;
5
+ private static cmdTxt;
4
6
  static examples: string[];
5
7
  run(): Promise<void>;
6
8
  }
@@ -1,18 +1,17 @@
1
1
  import { Command } from "@oclif/core";
2
- import { SDKClient } from "../../client-utils/sdk-client.js";
3
- class Login extends Command {
2
+ import { format, intro, outro } from "../../prompts/format.js";
3
+ import { LogoutAction } from "../../actions/auth/logout.js";
4
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
5
+ class Logout extends Command {
4
6
  async run() {
5
- try {
6
- const client = SDKClient.getInstance();
7
- const response = await client.logout(this.config.configDir);
8
- this.log(response);
9
- }
10
- catch (error) {
11
- this.error(error);
12
- }
7
+ intro("Logout");
8
+ const actionResult = await new LogoutAction(new DirectoryPath(this.config.configDir)).execute();
9
+ outro(actionResult);
13
10
  }
14
11
  }
15
- Login.description = "Clears the local login credentials.";
16
- Login.examples = [`apimatic auth:logout`];
17
- export default Login;
12
+ Logout.summary = "Clears the local login credentials.";
13
+ Logout.description = "Clears the local login credentials. This will also clear any cached credentials from the CLI.";
14
+ Logout.cmdTxt = format.cmd('apimatic', 'auth', 'logout');
15
+ Logout.examples = [Logout.cmdTxt];
16
+ export default Logout;
18
17
  //# sourceMappingURL=logout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;IAKxC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAbM,iBAAW,GAAG,qCAAqC,CAAC;AAEpD,cAAQ,GAAG,CAAC,sBAAsB,CAAC,CAAC;eAHxB,KAAK"}
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,MAAqB,MAAO,SAAQ,OAAO;IAQzC,KAAK,CAAC,GAAG;QAEP,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,MAAM,YAAY,GAAG,MAAM,IAAI,YAAY,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAChG,KAAK,CAAC,YAAY,CAAC,CAAA;IACrB,CAAC;;AAZM,cAAO,GAAG,qCAAqC,CAAC;AAEhD,kBAAW,GAAG,+FAA+F,CAAC;AAEtG,aAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC3D,eAAQ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;eANf,MAAM"}
@@ -1,6 +1,7 @@
1
1
  import { Command } from "@oclif/core";
2
2
  export default class Status extends Command {
3
3
  static description: string;
4
+ private static cmdTxt;
4
5
  static examples: string[];
5
6
  run(): Promise<void>;
6
7
  }
@@ -1,19 +1,21 @@
1
1
  import { Command } from "@oclif/core";
2
- import { SDKClient } from "../../client-utils/sdk-client.js";
2
+ import { format, intro, outro } from "../../prompts/format.js";
3
+ import { StatusAction } from "../../actions/auth/status.js";
4
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
5
  class Status extends Command {
4
6
  async run() {
5
- try {
6
- const client = SDKClient.getInstance();
7
- // TODO: Add validation for auth key from the server.
8
- const response = await client.status(this.config.configDir);
9
- this.log(response);
10
- }
11
- catch (error) {
12
- this.error(error);
13
- }
7
+ const commandMetadata = {
8
+ commandName: Status.id,
9
+ shell: this.config.shell
10
+ };
11
+ intro('Status');
12
+ const statusAction = new StatusAction(new DirectoryPath(this.config.configDir), commandMetadata);
13
+ const actionResult = await statusAction.execute(null);
14
+ outro(actionResult);
14
15
  }
15
16
  }
16
17
  Status.description = "View the currently logged in user.";
17
- Status.examples = [`apimatic auth:status`];
18
+ Status.cmdTxt = format.cmd('apimatic', 'auth', 'status');
19
+ Status.examples = [Status.cmdTxt];
18
20
  export default Status;
19
21
  //# sourceMappingURL=status.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,MAAO,SAAQ,OAAO;IAKzC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,qDAAqD;YACrD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAdM,kBAAW,GAAG,oCAAoC,CAAC;AAEnD,eAAQ,GAAG,CAAC,sBAAsB,CAAC,CAAC;eAHxB,MAAM"}
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE,MAAqB,MAAO,SAAQ,OAAO;IAMzC,KAAK,CAAC,GAAG;QAEP,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,MAAM,CAAC,EAAE;YACtB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,QAAQ,CAAC,CAAA;QACf,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC;QACjG,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,KAAK,CAAC,YAAY,CAAC,CAAA;IACrB,CAAC;;AAhBM,kBAAW,GAAG,oCAAoC,CAAC;AAE3C,aAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC3D,eAAQ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;eAJf,MAAM"}
@@ -1,5 +1,5 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class PortalCopilotEnable extends Command {
2
+ export default class PortalCopilot extends Command {
3
3
  static summary: string;
4
4
  static description: string;
5
5
  static flags: {
@@ -7,7 +7,7 @@ export default class PortalCopilotEnable extends Command {
7
7
  force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
8
  disable: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
9
  };
10
+ static cmdTxt: string;
10
11
  static examples: string[];
11
- private readonly prompts;
12
12
  run(): Promise<void>;
13
13
  }
@@ -1,32 +1,34 @@
1
+ var _a;
1
2
  import { Command, Flags } from "@oclif/core";
2
3
  import { DirectoryPath } from "../../types/file/directoryPath.js";
3
- import { PortalCopilotPrompts } from "../../prompts/portal/copilot.js";
4
4
  import { FlagsProvider } from "../../types/flags-provider.js";
5
5
  import { CopilotAction } from "../../actions/portal/copilot.js";
6
- const DEFAULT_WORKING_DIRECTORY = "./";
7
- class PortalCopilotEnable extends Command {
8
- constructor() {
9
- super(...arguments);
10
- this.prompts = new PortalCopilotPrompts();
11
- }
6
+ import { format, intro, outro } from "../../prompts/format.js";
7
+ class PortalCopilot extends Command {
12
8
  async run() {
13
- const { flags: { input, "auth-key": authKey, disable, force } } = await this.parse(PortalCopilotEnable);
14
- const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
15
- const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
16
- const copilotConfigAction = new CopilotAction(new DirectoryPath(this.config.configDir), authKey);
9
+ const { flags: { input, "auth-key": authKey, disable, force } } = await this.parse(_a);
10
+ const commandMetadata = {
11
+ commandName: _a.id,
12
+ shell: this.config.shell
13
+ };
14
+ intro("Configure API Copilot");
15
+ const buildDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : "./", "src");
16
+ const copilotConfigAction = new CopilotAction(new DirectoryPath(this.config.configDir), commandMetadata, authKey);
17
17
  const result = await copilotConfigAction.execute(buildDirectory, force, !disable);
18
- result.map((message) => this.prompts.logError(message));
18
+ outro(result);
19
19
  }
20
20
  }
21
- PortalCopilotEnable.summary = "Configure API Copilot for your API Documentation portal";
22
- PortalCopilotEnable.description = "Displays available API Copilots associated with your account and allows you to select which one to integrate with your portal. Each APIMatic account includes one Copilot by default. The selected Copilot will be added to your APIMATIC-BUILD.json file";
23
- PortalCopilotEnable.flags = Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), { disable: Flags.boolean({
21
+ _a = PortalCopilot;
22
+ PortalCopilot.summary = "Configure API Copilot for your API Documentation portal";
23
+ PortalCopilot.description = `Displays available API Copilots associated with your account and allows you to select which one to integrate with your portal. Each APIMatic account includes one Copilot by default. The selected Copilot will be added to your ${format.var("APIMATIC-BUILD.json")} file`;
24
+ PortalCopilot.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), { disable: Flags.boolean({
24
25
  default: false,
25
26
  description: "marks the API Copilot as disabled in the configuration"
26
- }) }), FlagsProvider.force), FlagsProvider.authKey);
27
- PortalCopilotEnable.examples = [
28
- `apimatic portal:copilot --input="./"`,
29
- `apimatic portal:copilot --input="./" --disable`,
27
+ }) }), FlagsProvider.force), FlagsProvider.force), FlagsProvider.authKey);
28
+ PortalCopilot.cmdTxt = format.cmd("apimatic", "portal", "copilot");
29
+ PortalCopilot.examples = [
30
+ `${_a.cmdTxt} ${format.flag("input", './')}`,
31
+ `${_a.cmdTxt} ${format.flag("input", './')} ${format.flag("disable")}`
30
32
  ];
31
- export default PortalCopilotEnable;
33
+ export default PortalCopilot;
32
34
  //# sourceMappingURL=copilot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/commands/portal/copilot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,MAAM,y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,GAAG,yDAAyD,AAA5D,CAA6D;AAEpE,yBAAW,GAChB,oOAAoO,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,OAAO,AAD5P,CAC6P;AAExQ,mBAAK,6EACP,aAAa,CAAC,KAAK,KACtB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,wDAAwD;KACtE,CAAC,KACC,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,OAAO,CARd,CASV;AAEK,oBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,AAA9C,CAA+C;AACrD,sBAAQ,GAAG;IAChB,GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;IAC9C,GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;CACzE,AAHc,CAGb;eArBiB,aAAa"}
@@ -1,5 +1,6 @@
1
- import { Command, Config } from "@oclif/core";
1
+ import { Command } from "@oclif/core";
2
2
  export declare class PortalGenerate extends Command {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static flags: {
5
6
  "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -7,9 +8,7 @@ export declare class PortalGenerate extends Command {
7
8
  force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
9
  destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
10
  };
11
+ static cmdTxt: string;
10
12
  static examples: string[];
11
- private readonly prompts;
12
- constructor(argv: string[], config: Config);
13
13
  run(): Promise<void>;
14
- private getConfigDir;
15
14
  }
@@ -1,31 +1,36 @@
1
+ var _a;
1
2
  import { Command, Flags } from "@oclif/core";
2
3
  import { DirectoryPath } from "../../types/file/directoryPath.js";
3
4
  import { GenerateAction } from "../../actions/portal/generate.js";
4
- import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
5
5
  import { FlagsProvider } from "../../types/flags-provider.js";
6
+ import { format, intro, outro } from "../../prompts/format.js";
6
7
  const DEFAULT_WORKING_DIRECTORY = "./";
7
8
  export class PortalGenerate extends Command {
8
- constructor(argv, config) {
9
- super(argv, config);
10
- this.getConfigDir = () => {
11
- return new DirectoryPath(this.config.configDir);
12
- };
13
- this.prompts = new PortalGeneratePrompts();
14
- }
15
9
  async run() {
16
- const { flags: { input, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(PortalGenerate);
10
+ const { flags: { input, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(_a);
17
11
  const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
18
12
  const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
19
13
  const portalDirectory = destination ? new DirectoryPath(destination) : workingDirectory.join("portal");
20
- const action = new GenerateAction(this.getConfigDir(), authKey);
21
- const result = await action.execute(buildDirectory, portalDirectory, PortalGenerate.id, force, zipPortal);
22
- result.mapAll(() => this.prompts.displayOutroMessage(portalDirectory.toString()), (message) => this.prompts.logError(message));
14
+ const commandMetadata = {
15
+ commandName: _a.id,
16
+ shell: this.config.shell
17
+ };
18
+ intro("Generate Portal");
19
+ const action = new GenerateAction(new DirectoryPath(this.config.configDir), commandMetadata, authKey);
20
+ const result = await action.execute(buildDirectory, portalDirectory, force, zipPortal);
21
+ outro(result);
23
22
  }
24
23
  }
24
+ _a = PortalGenerate;
25
+ PortalGenerate.summary = "Generate an API Documentation portal";
25
26
  PortalGenerate.description = "Generate an API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)";
26
27
  PortalGenerate.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), FlagsProvider.force), { zip: Flags.boolean({
27
28
  default: false,
28
- description: "download the generated portal as a .zip archive"
29
+ description: "Download the generated portal as a .zip archive"
29
30
  }) }), FlagsProvider.authKey);
30
- PortalGenerate.examples = [`apimatic portal:generate`, `apimatic portal:generate --input="./" --destination="./portal"`];
31
+ PortalGenerate.cmdTxt = format.cmd("apimatic", "portal", "generate");
32
+ PortalGenerate.examples = [
33
+ _a.cmdTxt,
34
+ `${_a.cmdTxt} ${format.flag("input", '"./"')} ${format.flag("destination", '"./portal"')}`
35
+ ];
31
36
  //# sourceMappingURL=generate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,OAAO,cAAe,SAAQ,OAAO;IAmBzC,YAAY,IAAc,EAAE,MAAc;QACxC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAqBd,iBAAY,GAAG,GAAG,EAAE;YAC1B,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC;QAtBA,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,KAAK,EAA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;YAC9B,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QACtG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACvF,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;;;AAvCM,sBAAO,GAAG,sCAAsC,AAAzC,CAA0C;AAEjD,0BAAW,GAChB,mSAAmS,AADnR,CACoR;AAE/R,oBAAK,6EACP,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAC7C,aAAa,CAAC,KAAK,KACtB,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QACjB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC,KACC,aAAa,CAAC,OAAO,CARd,CASV;AAEK,qBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,AAA/C,CAAgD;AACtD,uBAAQ,GAAG;IAChB,EAAI,CAAC,MAAM;IACX,GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE;CAC7F,AAHc,CAGb"}
@@ -1,10 +1,9 @@
1
1
  import { Command } from "@oclif/core";
2
2
  export default class PortalQuickstart extends Command {
3
3
  static description: string;
4
+ static summary: string;
5
+ static cmdTxt: string;
4
6
  static examples: string[];
5
- private getSpecFile;
6
- private getSpecValidationSummary;
7
- private getWorkingDirectory;
8
7
  run(): Promise<void>;
9
- private getServerPort;
8
+ private readonly getConfigDir;
10
9
  }
@@ -1,114 +1,37 @@
1
- import getPort from "get-port";
1
+ var _a;
2
2
  import { Command } from "@oclif/core";
3
- import { ApiValidationExternalApisController } from "@apimatic/sdk";
4
- import { PortalQuickstartPrompts } from "../../prompts/portal/quickstart.js";
5
- import { PortalQuickstartController } from "../../controllers/portal/quickstart.js";
6
- import { getMessageInRedColor } from "../../utils/utils.js";
3
+ import { PortalQuickstartAction } from "../../actions/portal/quickstart.js";
7
4
  import { DirectoryPath } from "../../types/file/directoryPath.js";
8
- import { PortalServeAction } from "../../actions/portal/serve.js";
9
- import { ServeHandler } from "../../application/portal/serve/serve-handler.js";
10
- import { PortalService } from "../../infrastructure/services/portal-service.js";
11
- import { PortalServePrompts } from "../../prompts/portal/serve.js";
12
- import { GenerateAction } from "../../actions/portal/generate.js";
13
- import { LoginAction } from "../../actions/auth/login.js";
14
5
  import { TelemetryService } from "../../infrastructure/services/telemetry-service.js";
15
6
  import { QuickstartInitiatedEvent } from "../../types/events/quickstart-initiated.js";
16
7
  import { QuickstartCompletedEvent } from "../../types/events/quickstart-completed.js";
17
- import { getAuthInfo } from "../../client-utils/auth-manager.js";
18
- import { createApiClient, createAuthorizationHeader } from "../../infrastructure/api-client-utils.js";
8
+ import { format, intro, outro } from "../../prompts/format.js";
19
9
  class PortalQuickstart extends Command {
20
- async getSpecFile(prompts, controller) {
21
- const specPath = await prompts.specPrompt();
22
- const specFile = await controller.getSpecFile(specPath);
23
- prompts.displaySpecValidationMessage();
24
- return specFile;
25
- }
26
- async getSpecValidationSummary(prompts, controller, specFile, apiValidationController) {
27
- const apiValidationSummary = await controller.getSpecValidationSummary(prompts, specFile, apiValidationController);
28
- if (!apiValidationSummary.success) {
29
- prompts.displaySpecValidationFailureMessage();
30
- await prompts.specValidationFailurePrompt();
31
- }
32
- else {
33
- prompts.displaySpecValidationSuccessMessage();
34
- }
35
- return apiValidationSummary;
36
- }
37
- async getWorkingDirectory(prompts, controller, specFile, apiValidationSummary, languages) {
38
- const workingDirectory = await prompts.workingDirectoryPrompt();
39
- prompts.displayBuildDirectoryGenerationMessage();
40
- const buildDirectory = new DirectoryPath(workingDirectory, "src").toString();
41
- await controller.setupBuildDirectory(prompts, buildDirectory, specFile, apiValidationSummary, languages);
42
- prompts.displayBuildDirectoryGenerationSuccessMessage(buildDirectory);
43
- prompts.displayBuildDirectoryAsTree(buildDirectory);
44
- return workingDirectory;
10
+ constructor() {
11
+ super(...arguments);
12
+ this.getConfigDir = () => {
13
+ return new DirectoryPath(this.config.configDir);
14
+ };
45
15
  }
46
16
  async run() {
47
- const prompts = new PortalQuickstartPrompts();
48
- const controller = new PortalQuickstartController();
49
- const telemetryService = new TelemetryService(this.config.configDir);
50
- await telemetryService.trackEvent(new QuickstartInitiatedEvent());
51
- prompts.displayWelcomeMessage();
52
- let loggedIn = await controller.isUserAuthenticated(this.config.configDir);
53
- if (!loggedIn) {
54
- prompts.getLoggedInFirst();
55
- const loginAction = new LoginAction(new DirectoryPath(this.config.configDir));
56
- const loginResult = await loginAction.execute();
57
- loginResult.match((e) => prompts.displayLoggedInMessage(e), (error) => prompts.logError(error));
58
- if (loginResult.isErr())
59
- return;
60
- }
61
- const authInfo = await getAuthInfo(this.config.configDir);
62
- const authorizationHeader = createAuthorizationHeader(authInfo, null);
63
- const client = createApiClient(authorizationHeader, 0);
64
- const apiValidationController = new ApiValidationExternalApisController(client);
65
- try {
66
- const specFile = await this.getSpecFile(prompts, controller);
67
- const apiValidationSummary = await this.getSpecValidationSummary(prompts, controller, specFile, apiValidationController);
68
- const languages = await prompts.sdkLanguagesPrompt();
69
- const workingDirectory = await this.getWorkingDirectory(prompts, controller, specFile, apiValidationSummary, languages);
70
- const portalServePrompts = new PortalServePrompts();
71
- const portalServeAction = new PortalServeAction(portalServePrompts, new ServeHandler(), new PortalService());
72
- //TODO: This needs to be moved within the action. Port should not be initialized again here.
73
- const port = await this.getServerPort(3000);
74
- const buildDirectory = new DirectoryPath(workingDirectory, "src");
75
- const portalDirectory = new DirectoryPath(workingDirectory, "portal");
76
- const generatePortalAction = new GenerateAction(new DirectoryPath(this.config.configDir), null);
77
- const serveFlags = {
78
- folder: buildDirectory.toString(),
79
- destination: portalDirectory.toString(),
80
- port: port,
81
- open: true,
82
- "no-reload": false,
83
- "auth-key": undefined
84
- };
85
- const serverPaths = {
86
- sourceDirectoryPath: buildDirectory.toString(),
87
- destinationDirectoryPath: portalDirectory.toString()
88
- };
89
- const servePortalResult = await portalServeAction.servePortal(serveFlags, serverPaths, PortalQuickstart.id, generatePortalAction.execute);
90
- if (servePortalResult.isFailed()) {
91
- portalServePrompts.logError(getMessageInRedColor(servePortalResult.error));
92
- return;
93
- }
94
- if (servePortalResult.isCancelled()) {
95
- portalServePrompts.logError(getMessageInRedColor(servePortalResult.value));
96
- return;
97
- }
98
- prompts.displayOutroMessage(buildDirectory.toString());
99
- await telemetryService.trackEvent(new QuickstartCompletedEvent());
100
- }
101
- catch (error) {
102
- this.error(getMessageInRedColor(error instanceof Error ? error.message : String(error)));
103
- }
104
- }
105
- async getServerPort(port) {
106
- const defaultPorts = [3000, 3001, 3002];
107
- const preferredPorts = typeof port === "number" ? [port, ...defaultPorts.filter((p) => p !== port)] : defaultPorts;
108
- return await getPort({ port: preferredPorts });
17
+ const telemetryService = new TelemetryService(this.getConfigDir());
18
+ const commandMetadata = {
19
+ commandName: _a.id,
20
+ shell: this.config.shell
21
+ };
22
+ await telemetryService.trackEvent(new QuickstartInitiatedEvent(), commandMetadata.shell);
23
+ intro("Portal Quickstart");
24
+ const action = new PortalQuickstartAction(this.getConfigDir(), commandMetadata);
25
+ const result = await action.execute();
26
+ outro(result);
27
+ // TODO: Remove this, find a solution for tracking.
28
+ await result.mapAll(async () => await telemetryService.trackEvent(new QuickstartCompletedEvent(), commandMetadata.shell), () => new Promise(() => { }), () => new Promise(() => { }));
109
29
  }
110
30
  }
31
+ _a = PortalQuickstart;
111
32
  PortalQuickstart.description = "Create your first API Portal using APIMatic's Docs as Code offering.";
112
- PortalQuickstart.examples = ["apimatic portal:quickstart"];
33
+ PortalQuickstart.summary = "Get started with your first API Portal in four easy steps.";
34
+ PortalQuickstart.cmdTxt = format.cmd("apimatic", "portal", "quickstart");
35
+ PortalQuickstart.examples = [_a.cmdTxt];
113
36
  export default PortalQuickstart;
114
37
  //# sourceMappingURL=quickstart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/commands/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,mCAAmC,EAAgC,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAY,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE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mB,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,eAAe,CAAC,CAAC;QAChF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,mDAAmD;QACnD,MAAM,MAAM,CAAC,MAAM,CACjB,KAAK,IAAI,EAAE,CAAC,MAAM,gBAAgB,CAAC,UAAU,CAAC,IAAI,wBAAwB,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,EACpG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAC5B,CAAC;IACJ,CAAC;;;AA5BM,4BAAW,GAAG,sEAAsE,AAAzE,CAA0E;AAErF,wBAAO,GAAG,4DAA4D,AAA/D,CAAgE;AAEvE,uBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,AAAjD,CAAkD;AAExD,yBAAQ,GAAG,CAAC,EAAI,CAAC,MAAM,CAAC,AAAhB,CAAiB;eAPb,gBAAgB"}
@@ -2,9 +2,11 @@ import { Command } from "@oclif/core";
2
2
  export default class PortalRecipeNew extends Command {
3
3
  static summary: string;
4
4
  static description: string;
5
- static examples: string[];
6
5
  static flags: {
6
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
7
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
8
  };
9
+ static readonly cmdTxt: string;
10
+ static readonly examples: string[];
9
11
  run(): Promise<void>;
10
12
  }
@@ -1,38 +1,46 @@
1
+ var _a;
1
2
  import { Command, Flags } from "@oclif/core";
2
3
  import { PortalRecipeAction } from "../../../actions/portal/recipe/new-recipe.js";
3
- import { PortalRecipePrompts } from "../../../prompts/portal/recipe/new-recipe.js";
4
- import { getMessageInRedColor } from "../../../utils/utils.js";
5
4
  import { TelemetryService } from "../../../infrastructure/services/telemetry-service.js";
6
5
  import { RecipeCreationFailedEvent } from "../../../types/events/recipe-creation-failed.js";
7
6
  import { DirectoryPath } from "../../../types/file/directoryPath.js";
8
7
  import { FlagsProvider } from "../../../types/flags-provider.js";
8
+ import { format, intro, outro } from "../../../prompts/format.js";
9
9
  const DEFAULT_WORKING_DIRECTORY = "./";
10
10
  class PortalRecipeNew extends Command {
11
11
  async run() {
12
- var _a;
13
- const { flags } = await this.parse(PortalRecipeNew);
14
- const telemetryService = new TelemetryService(this.config.configDir);
15
- const portalRecipeAction = new PortalRecipeAction();
16
- const portalRecipePrompts = new PortalRecipePrompts();
17
- const workingDirectory = new DirectoryPath((_a = flags.input) !== null && _a !== void 0 ? _a : DEFAULT_WORKING_DIRECTORY);
18
- const buildDirectory = flags.input ? new DirectoryPath(flags.input, "src") : workingDirectory.join("src");
19
- const createRecipeResult = await portalRecipeAction.createRecipe(buildDirectory, this.config.configDir, PortalRecipeNew.id, flags.name);
20
- //TODO: Add a mapper for automatically mapping events to logger and telemetry service.
21
- if (createRecipeResult.isFailed()) {
22
- await telemetryService.trackEvent(new RecipeCreationFailedEvent(createRecipeResult.error, PortalRecipeNew.id, flags));
23
- portalRecipePrompts.logError(getMessageInRedColor(createRecipeResult.error));
24
- }
25
- if (createRecipeResult.isCancelled()) {
26
- portalRecipePrompts.logError(getMessageInRedColor(createRecipeResult.value));
27
- }
12
+ const { flags: { name, input, force } } = await this.parse(_a);
13
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
14
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
15
+ const commandMetadata = {
16
+ commandName: _a.id,
17
+ shell: this.config.shell
18
+ };
19
+ intro("New Recipe");
20
+ const action = new PortalRecipeAction(new DirectoryPath(this.config.configDir), commandMetadata);
21
+ const result = await action.execute(buildDirectory, name);
22
+ outro(result);
23
+ result.mapAll(() => { }, async () => {
24
+ const telemetryService = new TelemetryService(new DirectoryPath(this.config.configDir));
25
+ await telemetryService.trackEvent(new RecipeCreationFailedEvent("error", _a.id, {
26
+ name,
27
+ input,
28
+ force
29
+ }), commandMetadata.shell);
30
+ }, () => { });
28
31
  }
29
32
  }
30
- PortalRecipeNew.summary = "Add an API Recipe to your API Documentation portal.";
31
- PortalRecipeNew.description = "To learn more about API Recipes, visit: https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes";
33
+ _a = PortalRecipeNew;
34
+ PortalRecipeNew.summary = "Add an API Recipe to your API documentation portal.";
35
+ PortalRecipeNew.description = `This command adds a new API Recipe file to your documentation portal.
36
+
37
+ To learn more about API Recipes, visit:
38
+ ${format.link("https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes")}`;
39
+ PortalRecipeNew.flags = Object.assign(Object.assign({ name: Flags.string({ description: "name for the recipe" }) }, FlagsProvider.input), FlagsProvider.force);
40
+ PortalRecipeNew.cmdTxt = format.cmd("apimatic", "portal", "recipe", "new");
32
41
  PortalRecipeNew.examples = [
33
- `apimatic portal:recipe:new`,
34
- `apimatic portal:recipe:new --name="My API Recipe" --input="./"`
42
+ `${_a.cmdTxt}`,
43
+ `${_a.cmdTxt} ${format.flag("name", '"My API Recipe"')} ${format.flag("input", '"./"')}`
35
44
  ];
36
- PortalRecipeNew.flags = Object.assign({ name: Flags.string({ description: "name for the recipe" }) }, FlagsProvider.input);
37
45
  export default PortalRecipeNew;
38
46
  //# sourceMappingURL=new.js.map