@apimatic/cli 0.0.0-alpha.4 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/README.md +308 -130
  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 +13 -0
  25. package/lib/actions/portal/generate.js +59 -0
  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 +145 -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 +176 -0
  32. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  33. package/lib/actions/portal/serve.d.ts +16 -0
  34. package/lib/actions/portal/serve.js +119 -0
  35. package/lib/actions/portal/serve.js.map +1 -0
  36. package/lib/actions/portal/toc/new-toc.d.ts +21 -0
  37. package/lib/actions/portal/toc/new-toc.js +97 -0
  38. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  39. package/lib/actions/sdk/generate.d.ts +13 -0
  40. package/lib/actions/sdk/generate.js +47 -0
  41. package/lib/actions/sdk/generate.js.map +1 -0
  42. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  43. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  44. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  45. package/lib/application/portal/recipe/recipe-generator.d.ts +21 -0
  46. package/lib/application/portal/recipe/recipe-generator.js +146 -0
  47. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  48. package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
  49. package/lib/application/portal/toc/toc-content-parser.js +44 -0
  50. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  51. package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
  52. package/lib/application/portal/toc/toc-structure-generator.js +84 -0
  53. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  54. package/lib/client-utils/auth-manager.d.ts +8 -3
  55. package/lib/client-utils/auth-manager.js +26 -14
  56. package/lib/client-utils/auth-manager.js.map +1 -0
  57. package/lib/commands/api/transform.d.ts +11 -8
  58. package/lib/commands/api/transform.js +52 -105
  59. package/lib/commands/api/transform.js.map +1 -0
  60. package/lib/commands/api/validate.d.ts +8 -5
  61. package/lib/commands/api/validate.js +31 -63
  62. package/lib/commands/api/validate.js.map +1 -0
  63. package/lib/commands/auth/login.d.ts +4 -2
  64. package/lib/commands/auth/login.js +26 -51
  65. package/lib/commands/auth/login.js.map +1 -0
  66. package/lib/commands/auth/logout.d.ts +4 -2
  67. package/lib/commands/auth/logout.js +14 -20
  68. package/lib/commands/auth/logout.js.map +1 -0
  69. package/lib/commands/auth/status.d.ts +2 -1
  70. package/lib/commands/auth/status.js +18 -20
  71. package/lib/commands/auth/status.js.map +1 -0
  72. package/lib/commands/portal/copilot.d.ts +13 -0
  73. package/lib/commands/portal/copilot.js +34 -0
  74. package/lib/commands/portal/copilot.js.map +1 -0
  75. package/lib/commands/portal/generate.d.ts +9 -8
  76. package/lib/commands/portal/generate.js +31 -97
  77. package/lib/commands/portal/generate.js.map +1 -0
  78. package/lib/commands/portal/quickstart.d.ts +9 -0
  79. package/lib/commands/portal/quickstart.js +37 -0
  80. package/lib/commands/portal/quickstart.js.map +1 -0
  81. package/lib/commands/portal/recipe/new.d.ts +12 -0
  82. package/lib/commands/portal/recipe/new.js +46 -0
  83. package/lib/commands/portal/recipe/new.js.map +1 -0
  84. package/lib/commands/portal/serve.d.ts +16 -0
  85. package/lib/commands/portal/serve.js +54 -0
  86. package/lib/commands/portal/serve.js.map +1 -0
  87. package/lib/commands/portal/toc/new.d.ts +14 -0
  88. package/lib/commands/portal/toc/new.js +61 -0
  89. package/lib/commands/portal/toc/new.js.map +1 -0
  90. package/lib/commands/sdk/generate.d.ts +11 -9
  91. package/lib/commands/sdk/generate.js +48 -122
  92. package/lib/commands/sdk/generate.js.map +1 -0
  93. package/lib/config/axios-config.d.ts +2 -0
  94. package/lib/config/axios-config.js +10 -0
  95. package/lib/config/axios-config.js.map +1 -0
  96. package/lib/hooks/not-found.d.ts +3 -0
  97. package/lib/hooks/not-found.js +52 -0
  98. package/lib/hooks/not-found.js.map +1 -0
  99. package/lib/hooks/utils.d.ts +5 -0
  100. package/lib/hooks/utils.js +51 -0
  101. package/lib/hooks/utils.js.map +1 -0
  102. package/lib/index.d.ts +1 -1
  103. package/lib/index.js +2 -4
  104. package/lib/index.js.map +1 -0
  105. package/lib/infrastructure/api-utils.d.ts +9 -0
  106. package/lib/infrastructure/api-utils.js +34 -0
  107. package/lib/infrastructure/api-utils.js.map +1 -0
  108. package/lib/infrastructure/debounce-service.d.ts +10 -0
  109. package/lib/infrastructure/debounce-service.js +52 -0
  110. package/lib/infrastructure/debounce-service.js.map +1 -0
  111. package/lib/infrastructure/env-info.d.ts +12 -0
  112. package/lib/infrastructure/env-info.js +58 -0
  113. package/lib/infrastructure/env-info.js.map +1 -0
  114. package/lib/infrastructure/file-service.d.ts +23 -0
  115. package/lib/infrastructure/file-service.js +117 -0
  116. package/lib/infrastructure/file-service.js.map +1 -0
  117. package/lib/infrastructure/launcher-service.d.ts +7 -0
  118. package/lib/infrastructure/launcher-service.js +51 -0
  119. package/lib/infrastructure/launcher-service.js.map +1 -0
  120. package/lib/infrastructure/network-service.d.ts +3 -0
  121. package/lib/infrastructure/network-service.js +7 -0
  122. package/lib/infrastructure/network-service.js.map +1 -0
  123. package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
  124. package/lib/infrastructure/services/api-client-factory.js +20 -0
  125. package/lib/infrastructure/services/api-client-factory.js.map +1 -0
  126. package/lib/infrastructure/services/api-service.d.ts +10 -0
  127. package/lib/infrastructure/services/api-service.js +55 -0
  128. package/lib/infrastructure/services/api-service.js.map +1 -0
  129. package/lib/infrastructure/services/auth-service.d.ts +11 -0
  130. package/lib/infrastructure/services/auth-service.js +37 -0
  131. package/lib/infrastructure/services/auth-service.js.map +1 -0
  132. package/lib/infrastructure/services/file-download-service.d.ts +15 -0
  133. package/lib/infrastructure/services/file-download-service.js +104 -0
  134. package/lib/infrastructure/services/file-download-service.js.map +1 -0
  135. package/lib/infrastructure/services/portal-service.d.ts +21 -0
  136. package/lib/infrastructure/services/portal-service.js +157 -0
  137. package/lib/infrastructure/services/portal-service.js.map +1 -0
  138. package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
  139. package/lib/infrastructure/services/telemetry-service.js +38 -0
  140. package/lib/infrastructure/services/telemetry-service.js.map +1 -0
  141. package/lib/infrastructure/services/transformation-service.d.ts +23 -0
  142. package/lib/infrastructure/services/transformation-service.js +56 -0
  143. package/lib/infrastructure/services/transformation-service.js.map +1 -0
  144. package/lib/infrastructure/services/validation-service.d.ts +17 -0
  145. package/lib/infrastructure/services/validation-service.js +49 -0
  146. package/lib/infrastructure/services/validation-service.js.map +1 -0
  147. package/lib/infrastructure/tmp-extensions.d.ts +2 -0
  148. package/lib/infrastructure/tmp-extensions.js +6 -0
  149. package/lib/infrastructure/tmp-extensions.js.map +1 -0
  150. package/lib/infrastructure/zip-service.d.ts +6 -0
  151. package/lib/infrastructure/zip-service.js +39 -0
  152. package/lib/infrastructure/zip-service.js.map +1 -0
  153. package/lib/prompts/api/transform.d.ts +11 -0
  154. package/lib/prompts/api/transform.js +30 -0
  155. package/lib/prompts/api/transform.js.map +1 -0
  156. package/lib/prompts/api/validate.d.ts +12 -0
  157. package/lib/prompts/api/validate.js +41 -0
  158. package/lib/prompts/api/validate.js.map +1 -0
  159. package/lib/prompts/auth/login.d.ts +10 -0
  160. package/lib/prompts/auth/login.js +22 -0
  161. package/lib/prompts/auth/login.js.map +1 -0
  162. package/lib/prompts/auth/logout.d.ts +3 -0
  163. package/lib/prompts/auth/logout.js +7 -0
  164. package/lib/prompts/auth/logout.js.map +1 -0
  165. package/lib/prompts/auth/status.d.ts +8 -0
  166. package/lib/prompts/auth/status.js +21 -0
  167. package/lib/prompts/auth/status.js.map +1 -0
  168. package/lib/prompts/format.d.ts +33 -0
  169. package/lib/prompts/format.js +99 -0
  170. package/lib/prompts/format.js.map +1 -0
  171. package/lib/prompts/portal/copilot.d.ts +18 -0
  172. package/lib/prompts/portal/copilot.js +82 -0
  173. package/lib/prompts/portal/copilot.js.map +1 -0
  174. package/lib/prompts/portal/generate.d.ts +13 -0
  175. package/lib/prompts/portal/generate.js +41 -0
  176. package/lib/prompts/portal/generate.js.map +1 -0
  177. package/lib/prompts/portal/quickstart.d.ts +31 -0
  178. package/lib/prompts/portal/quickstart.js +146 -0
  179. package/lib/prompts/portal/quickstart.js.map +1 -0
  180. package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
  181. package/lib/prompts/portal/recipe/new-recipe.js +165 -0
  182. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  183. package/lib/prompts/portal/serve.d.ts +11 -0
  184. package/lib/prompts/portal/serve.js +33 -0
  185. package/lib/prompts/portal/serve.js.map +1 -0
  186. package/lib/prompts/portal/toc/new-toc.d.ts +15 -0
  187. package/lib/prompts/portal/toc/new-toc.js +37 -0
  188. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  189. package/lib/prompts/sdk/generate.d.ts +11 -0
  190. package/lib/prompts/sdk/generate.js +36 -0
  191. package/lib/prompts/sdk/generate.js.map +1 -0
  192. package/lib/types/api/account.d.ts +10 -0
  193. package/lib/types/api/account.js +2 -0
  194. package/lib/types/api/account.js.map +1 -0
  195. package/lib/types/api/transform.d.ts +17 -17
  196. package/lib/types/api/transform.js +21 -6
  197. package/lib/types/api/transform.js.map +1 -0
  198. package/lib/types/build/build.d.ts +22 -0
  199. package/lib/types/build/build.js +7 -0
  200. package/lib/types/build/build.js.map +1 -0
  201. package/lib/types/build-context.d.ts +17 -0
  202. package/lib/types/build-context.js +47 -0
  203. package/lib/types/build-context.js.map +1 -0
  204. package/lib/types/common/command-metadata.d.ts +4 -0
  205. package/lib/types/common/command-metadata.js +2 -0
  206. package/lib/types/common/command-metadata.js.map +1 -0
  207. package/lib/types/events/domain-event.d.ts +8 -0
  208. package/lib/types/events/domain-event.js +11 -0
  209. package/lib/types/events/domain-event.js.map +1 -0
  210. package/lib/types/events/quickstart-completed.d.ts +7 -0
  211. package/lib/types/events/quickstart-completed.js +10 -0
  212. package/lib/types/events/quickstart-completed.js.map +1 -0
  213. package/lib/types/events/quickstart-initiated.d.ts +7 -0
  214. package/lib/types/events/quickstart-initiated.js +10 -0
  215. package/lib/types/events/quickstart-initiated.js.map +1 -0
  216. package/lib/types/events/recipe-creation-failed.d.ts +5 -0
  217. package/lib/types/events/recipe-creation-failed.js +8 -0
  218. package/lib/types/events/recipe-creation-failed.js.map +1 -0
  219. package/lib/types/events/toc-creation-failed.d.ts +5 -0
  220. package/lib/types/events/toc-creation-failed.js +8 -0
  221. package/lib/types/events/toc-creation-failed.js.map +1 -0
  222. package/lib/types/file/directory.d.ts +17 -0
  223. package/lib/types/file/directory.js +86 -0
  224. package/lib/types/file/directory.js.map +1 -0
  225. package/lib/types/file/directoryPath.d.ts +9 -0
  226. package/lib/types/file/directoryPath.js +22 -0
  227. package/lib/types/file/directoryPath.js.map +1 -0
  228. package/lib/types/file/fileName.d.ts +7 -0
  229. package/lib/types/file/fileName.js +21 -0
  230. package/lib/types/file/fileName.js.map +1 -0
  231. package/lib/types/file/filePath.d.ts +10 -0
  232. package/lib/types/file/filePath.js +32 -0
  233. package/lib/types/file/filePath.js.map +1 -0
  234. package/lib/types/file/resource-input.d.ts +5 -0
  235. package/lib/types/file/resource-input.js +42 -0
  236. package/lib/types/file/resource-input.js.map +1 -0
  237. package/lib/types/file/urlPath.d.ts +6 -0
  238. package/lib/types/file/urlPath.js +22 -0
  239. package/lib/types/file/urlPath.js.map +1 -0
  240. package/lib/types/flags-provider.d.ts +15 -0
  241. package/lib/types/flags-provider.js +34 -0
  242. package/lib/types/flags-provider.js.map +1 -0
  243. package/lib/types/portal-context.d.ts +13 -0
  244. package/lib/types/portal-context.js +38 -0
  245. package/lib/types/portal-context.js.map +1 -0
  246. package/lib/types/recipe/recipe.d.ts +22 -0
  247. package/lib/types/recipe/recipe.js +6 -0
  248. package/lib/types/recipe/recipe.js.map +1 -0
  249. package/lib/types/recipe-context.d.ts +8 -0
  250. package/lib/types/recipe-context.js +21 -0
  251. package/lib/types/recipe-context.js.map +1 -0
  252. package/lib/types/resource-context.d.ts +12 -0
  253. package/lib/types/resource-context.js +30 -0
  254. package/lib/types/resource-context.js.map +1 -0
  255. package/lib/types/sdk/generate.d.ts +9 -21
  256. package/lib/types/sdk/generate.js +25 -12
  257. package/lib/types/sdk/generate.js.map +1 -0
  258. package/lib/types/sdk-context.d.ts +14 -0
  259. package/lib/types/sdk-context.js +32 -0
  260. package/lib/types/sdk-context.js.map +1 -0
  261. package/lib/types/sdl/sdl.d.ts +21 -0
  262. package/lib/types/sdl/sdl.js +47 -0
  263. package/lib/types/sdl/sdl.js.map +1 -0
  264. package/lib/types/spec-context.d.ts +10 -0
  265. package/lib/types/spec-context.js +17 -0
  266. package/lib/types/spec-context.js.map +1 -0
  267. package/lib/types/temp-context.d.ts +11 -0
  268. package/lib/types/temp-context.js +27 -0
  269. package/lib/types/temp-context.js.map +1 -0
  270. package/lib/types/toc/toc.d.ts +31 -0
  271. package/lib/types/toc/toc.js +9 -0
  272. package/lib/types/toc/toc.js.map +1 -0
  273. package/lib/types/toc-context.d.ts +12 -0
  274. package/lib/types/toc-context.js +26 -0
  275. package/lib/types/toc-context.js.map +1 -0
  276. package/lib/types/transform-context.d.ts +13 -0
  277. package/lib/types/transform-context.js +30 -0
  278. package/lib/types/transform-context.js.map +1 -0
  279. package/lib/types/utils.d.ts +1 -6
  280. package/lib/types/utils.js +2 -2
  281. package/lib/types/utils.js.map +1 -0
  282. package/lib/utils/string-utils.d.ts +1 -0
  283. package/lib/utils/string-utils.js +10 -0
  284. package/lib/utils/string-utils.js.map +1 -0
  285. package/lib/utils/utils.d.ts +2 -18
  286. package/lib/utils/utils.js +33 -116
  287. package/lib/utils/utils.js.map +1 -0
  288. package/package.json +101 -44
  289. package/bin/run +0 -5
  290. package/lib/client-utils/sdk-client.d.ts +0 -23
  291. package/lib/client-utils/sdk-client.js +0 -119
  292. package/lib/config/env.d.ts +0 -1
  293. package/lib/config/env.js +0 -4
  294. package/lib/controllers/api/transform.d.ts +0 -5
  295. package/lib/controllers/api/transform.js +0 -49
  296. package/lib/controllers/api/validate.d.ts +0 -3
  297. package/lib/controllers/api/validate.js +0 -22
  298. package/lib/controllers/portal/generate.d.ts +0 -2
  299. package/lib/controllers/portal/generate.js +0 -49
  300. package/lib/controllers/sdk/generate.d.ts +0 -4
  301. package/lib/controllers/sdk/generate.js +0 -64
  302. package/lib/types/api/validate.d.ts +0 -12
  303. package/lib/types/api/validate.js +0 -2
  304. package/lib/types/portal/generate.d.ts +0 -9
  305. package/lib/types/portal/generate.js +0 -2
@@ -1,68 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs-extra");
4
- const command_1 = require("@oclif/command");
5
- const sdk_1 = require("@apimatic/sdk");
6
- const sdk_client_1 = require("../../client-utils/sdk-client");
7
- const validate_1 = require("../../controllers/api/validate");
8
- const utils_1 = require("../../utils/utils");
9
- class Validate extends command_1.Command {
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { FlagsProvider } from "../../types/flags-provider.js";
4
+ import { ValidateAction } from "../../actions/api/validate.js";
5
+ import { format, intro, outro } from "../../prompts/format.js";
6
+ import { createResourceInput } from "../../types/file/resource-input.js";
7
+ class Validate extends Command {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.getConfigDir = () => {
11
+ return new DirectoryPath(this.config.configDir);
12
+ };
13
+ }
10
14
  async run() {
11
- const { flags } = this.parse(Validate);
12
- try {
13
- if (flags.file && !(await fs.pathExists(flags.file))) {
14
- throw new Error(`Validation file: ${flags.file} does not exist`);
15
- }
16
- const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
17
- const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
18
- const apiValidationController = new sdk_1.APIValidationExternalApisController(client);
19
- const validationSummary = await validate_1.getValidation(flags, apiValidationController);
20
- const logFunctions = {
21
- log: this.log,
22
- warn: this.warn,
23
- error: this.error
24
- };
25
- utils_1.printValidationMessages(validationSummary, logFunctions);
26
- validationSummary.success
27
- ? this.log("Specification file provided is valid")
28
- : this.error("Specification file provided is invalid");
29
- }
30
- catch (error) {
31
- if (error.result) {
32
- const apiError = error;
33
- const result = apiError.result;
34
- if (result.modelState["exception Error"] && apiError.statusCode === 400) {
35
- this.error(utils_1.replaceHTML(result.modelState["exception Error"][0]));
36
- }
37
- else if (error.body && apiError.statusCode === 401) {
38
- this.error(error.body);
39
- }
40
- else {
41
- this.error(error.message);
42
- }
43
- }
44
- else {
45
- this.error(`${error.message}`);
46
- }
47
- }
15
+ const { flags: { file, url, "auth-key": authKey } } = await this.parse(Validate);
16
+ const commandMetadata = {
17
+ commandName: Validate.id,
18
+ shell: this.config.shell
19
+ };
20
+ const action = new ValidateAction(this.getConfigDir(), commandMetadata, authKey);
21
+ const resourceInput = createResourceInput(file, url);
22
+ intro("Validate API");
23
+ const result = await action.execute(resourceInput);
24
+ outro(result);
48
25
  }
49
26
  }
50
- exports.default = Validate;
51
- Validate.description = "Validate the syntactic and semantic correctness of an API specification";
27
+ Validate.summary = "Validate API specification for syntactic and semantic correctness";
28
+ Validate.description = `Validate your API specification to ensure it adheres to syntactic and semantic standards.`;
29
+ Validate.cmdTxt = format.cmd("apimatic", "api", "validate");
52
30
  Validate.examples = [
53
- `$ apimatic api:validate --file="./specs/sample.json"
54
- Specification file provided is valid
55
- `,
56
- `$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
57
- Specification file provided is valid
58
- `
31
+ `${Validate.cmdTxt} ${format.flag("file", "./specs/sample.json")}`,
32
+ `${Validate.cmdTxt} ${format.flag("url", '"https://petstore.swagger.io/v2/swagger.json"')}`
59
33
  ];
60
- Validate.flags = {
61
- file: command_1.flags.string({ default: "", description: "Path to the API specification file to validate" }),
62
- url: command_1.flags.string({
63
- default: "",
64
- description: "URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available."
65
- }),
66
- // docs: flags.boolean({ default: false, description: "Validate specification for docs generation" }), // Next tier, not included in API spec
67
- "auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
68
- };
34
+ Validate.flags = Object.assign({ file: Flags.string({ description: "Path to the API specification file to validate" }), url: Flags.string({ description: "URL to the API specification file to validate (publicly accessible)" }) }, FlagsProvider.authKey);
35
+ export default Validate;
36
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAqB,QAAS,SAAQ,OAAO;IAA7C;;QAoCmB,iBAAY,GAAG,GAAG,EAAE;YACnC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IArBC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,EAC1C,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/B,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,QAAQ,CAAC,EAAE;YACxB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QACjF,MAAM,aAAa,GAAG,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAErD,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACnD,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;;AAjCe,gBAAO,GAAG,mEAAmE,AAAtE,CAAuE;AAE9E,oBAAW,GAAG,2FAA2F,AAA9F,CAA+F;AAE1G,eAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC,AAA5C,CAA6C;AAE5D,iBAAQ,GAAG;IAChB,GAAG,QAAQ,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAAE;IAClE,GAAG,QAAQ,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,+CAA+C,CAAC,EAAE;CAC5F,AAHc,CAGb;AAEK,cAAK,mBACV,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,EACrF,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qEAAqE,EAAE,CAAC,IACtG,aAAa,CAAC,OAAO,CAHd,CAIV;eAhBiB,QAAQ"}
@@ -1,9 +1,11 @@
1
- import { flags, Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Login extends Command {
3
+ static summary: string;
3
4
  static description: string;
5
+ private static cmdTxt;
4
6
  static examples: string[];
5
7
  static flags: {
6
- "auth-key": flags.IOptionFlag<string>;
8
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
9
  };
8
10
  run(): Promise<void>;
9
11
  }
@@ -1,60 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_ux_1 = require("cli-ux");
4
- const command_1 = require("@oclif/command");
5
- const utils_1 = require("../../utils/utils");
6
- const sdk_client_1 = require("../../client-utils/sdk-client");
7
- class Login extends command_1.Command {
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { LoginAction } from "../../actions/auth/login.js";
4
+ import { format, intro, outro } from "../../prompts/format.js";
5
+ class Login extends Command {
8
6
  async run() {
9
- const { flags } = this.parse(Login);
10
- const configDir = this.config.configDir;
11
- try {
12
- const client = sdk_client_1.SDKClient.getInstance();
13
- // If user is setting auth key
14
- if (flags["auth-key"]) {
15
- const response = client.setAuthKey(flags["auth-key"], configDir);
16
- return this.log(response);
17
- }
18
- else {
19
- // If user logs in with email and password
20
- const email = await cli_ux_1.cli.prompt("Please enter your registered email");
21
- const password = await cli_ux_1.cli.prompt("Please enter your password", {
22
- type: "hide"
23
- });
24
- const response = await client.login(email, password, configDir);
25
- this.log(response);
26
- }
27
- }
28
- catch (error) {
29
- if (error && error.response) {
30
- const apiError = error;
31
- const apiResponse = apiError.response;
32
- if (apiResponse) {
33
- const responseData = apiResponse.data;
34
- if (apiResponse.status === 403 && responseData) {
35
- return this.error(utils_1.replaceHTML(responseData));
36
- }
37
- else {
38
- return this.error(apiError.message);
39
- }
40
- }
41
- }
42
- this.error(error.message);
7
+ const { flags: { "auth-key": authKey } } = await this.parse(Login);
8
+ if (authKey === "") {
9
+ this.error("Flag --auth-key must not be empty when provided.");
43
10
  }
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);
17
+ const result = await loginAction.execute(authKey);
18
+ outro(result);
44
19
  }
45
20
  }
46
- exports.default = Login;
21
+ Login.summary = "Login to your APIMatic account";
47
22
  Login.description = "Login using your APIMatic credentials or an API Key";
23
+ Login.cmdTxt = format.cmd('apimatic', 'auth', 'login');
48
24
  Login.examples = [
49
- `$ apimatic auth:login
50
- Please enter your registered email: apimatic-user@gmail.com
51
- Please enter your password: *********
52
-
53
- You have successfully logged into APIMatic
54
- `,
55
- `$ apimatic auth:login --auth-key=xxxxxx
56
- Authentication key successfully set`
25
+ Login.cmdTxt,
26
+ `${Login.cmdTxt} ${format.flag('auth-key', '{api-key}')}`
57
27
  ];
58
28
  Login.flags = {
59
- "auth-key": command_1.flags.string({ default: "", description: "Set authentication key for all commands" })
29
+ "auth-key": Flags.string({
30
+ char: "k",
31
+ description: "Sets authentication key for all commands."
32
+ })
60
33
  };
34
+ export default Login;
35
+ //# sourceMappingURL=login.js.map
@@ -0,0 +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,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAqB,KAAM,SAAQ,OAAO;IAkBxC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAC/B,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE5B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,KAAK,CAAC,EAAE;YACrB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC;QAC/F,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;;AAnCM,aAAO,GAAG,gCAAgC,CAAC;AAE3C,iBAAW,GAAG,qDAAqD,CAAC;AAE5D,YAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAG,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1D,cAAQ,GAAG;IAChB,KAAK,CAAC,MAAM;IACZ,GAAG,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE;CAAC,CAAC;AAEtD,WAAK,GAAG;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,2CAA2C;KACzD,CAAC;CACH,CAAC;eAfiB,KAAK"}
@@ -1,6 +1,8 @@
1
- import { Command } from "@oclif/command";
2
- export default class Login extends Command {
1
+ import { Command } from "@oclif/core";
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,23 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const sdk_client_1 = require("../../client-utils/sdk-client");
5
- class Login extends command_1.Command {
1
+ import { Command } from "@oclif/core";
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 {
6
6
  async run() {
7
- try {
8
- const client = sdk_client_1.SDKClient.getInstance();
9
- const response = await client.logout(this.config.configDir);
10
- this.log(response);
11
- }
12
- catch (error) {
13
- this.error(error);
14
- }
7
+ intro("Logout");
8
+ const actionResult = await new LogoutAction(new DirectoryPath(this.config.configDir)).execute();
9
+ outro(actionResult);
15
10
  }
16
11
  }
17
- exports.default = Login;
18
- Login.description = "Clear local login credentials";
19
- Login.examples = [
20
- `$ apimatic auth:logout
21
- Logged out
22
- `
23
- ];
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;
17
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
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
- import { Command } from "@oclif/command";
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,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const sdk_client_1 = require("../../client-utils/sdk-client");
5
- class Status extends command_1.Command {
1
+ import { Command } from "@oclif/core";
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";
5
+ class Status extends Command {
6
6
  async run() {
7
- try {
8
- const client = sdk_client_1.SDKClient.getInstance();
9
- const response = await client.status(this.config.configDir);
10
- this.log(response);
11
- }
12
- catch (error) {
13
- this.error(error);
14
- }
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);
15
15
  }
16
16
  }
17
- exports.default = Status;
18
- Status.description = "View current authentication state";
19
- Status.examples = [
20
- `$ apimatic auth:status
21
- Currently logged in as apimatic-client@gmail.com
22
- `
23
- ];
17
+ Status.description = "View the currently logged in user.";
18
+ Status.cmdTxt = format.cmd('apimatic', 'auth', 'status');
19
+ Status.examples = [Status.cmdTxt];
20
+ export default Status;
21
+ //# sourceMappingURL=status.js.map
@@ -0,0 +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,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"}
@@ -0,0 +1,13 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalCopilot extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static flags: {
6
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ disable: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ static cmdTxt: string;
11
+ static examples: string[];
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,34 @@
1
+ var _a;
2
+ import { Command, Flags } from "@oclif/core";
3
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
4
+ import { FlagsProvider } from "../../types/flags-provider.js";
5
+ import { CopilotAction } from "../../actions/portal/copilot.js";
6
+ import { format, intro, outro } from "../../prompts/format.js";
7
+ class PortalCopilot extends Command {
8
+ async run() {
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
+ const result = await copilotConfigAction.execute(buildDirectory, force, !disable);
18
+ outro(result);
19
+ }
20
+ }
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({
25
+ default: false,
26
+ description: "marks the API Copilot as disabled in the configuration"
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")}`
32
+ ];
33
+ export default PortalCopilot;
34
+ //# sourceMappingURL=copilot.js.map
@@ -0,0 +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,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAqB,aAAc,SAAQ,OAAO;IAuBhD,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EACtD,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAa,CAAC,CAAC;QAEpC,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,EAAa,CAAC,EAAE;YAC7B,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC/B,MAAM,cAAc,GAAG,IAAI,aAAa,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/D,MAAM,mBAAmB,GAAG,IAAI,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAClH,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;QAClF,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;;;AArCM,qBAAO,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,13 +1,14 @@
1
- import { Command, flags } from "@oclif/command";
2
- export default class PortalGenerate extends Command {
1
+ import { Command } from "@oclif/core";
2
+ export declare class PortalGenerate extends Command {
3
+ static summary: string;
3
4
  static description: string;
4
5
  static flags: {
5
- folder: flags.IOptionFlag<string>;
6
- destination: flags.IOptionFlag<string>;
7
- force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
- zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- "auth-key": flags.IOptionFlag<string>;
6
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  };
11
+ static cmdTxt: string;
11
12
  static examples: string[];
12
- run(): Promise<undefined>;
13
+ run(): Promise<void>;
13
14
  }
@@ -1,102 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const fs = require("fs-extra");
5
- const command_1 = require("@oclif/command");
6
- const sdk_1 = require("@apimatic/sdk");
7
- const sdk_client_1 = require("../../client-utils/sdk-client");
8
- const generate_1 = require("../../controllers/portal/generate");
9
- const utils_1 = require("../../utils/utils");
10
- class PortalGenerate extends command_1.Command {
1
+ var _a;
2
+ import { Command, Flags } from "@oclif/core";
3
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
4
+ import { GenerateAction } from "../../actions/portal/generate.js";
5
+ import { FlagsProvider } from "../../types/flags-provider.js";
6
+ import { format, intro, outro } from "../../prompts/format.js";
7
+ const DEFAULT_WORKING_DIRECTORY = "./";
8
+ export class PortalGenerate extends Command {
11
9
  async run() {
12
- const { flags } = this.parse(PortalGenerate);
13
- const zip = flags.zip;
14
- const sourceFolderPath = flags.folder;
15
- const portalFolderPath = path.join(flags.destination, "generated_portal");
16
- const zippedPortalPath = path.join(flags.destination, "generated_portal.zip");
17
- const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
18
- // Check if at destination, portal already exists and throw error if force flag is not set for both zip and extracted
19
- if (fs.existsSync(portalFolderPath) && !flags.force && !zip) {
20
- throw new Error(`Can't download portal to path ${portalFolderPath}, because it already exists`);
21
- }
22
- else if (fs.existsSync(zippedPortalPath) && !flags.force && zip) {
23
- throw new Error(`Can't download portal to path ${zippedPortalPath}, because it already exists`);
24
- }
25
- try {
26
- if (!(await fs.pathExists(flags.destination))) {
27
- throw new Error(`Destination path ${flags.destination} does not exist`);
28
- }
29
- else if (!(await fs.pathExists(flags.folder))) {
30
- throw new Error(`Portal build folder ${flags.folder} does not exist`);
31
- }
32
- const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
33
- const docsPortalController = new sdk_1.DocsPortalManagementController(client);
34
- const zippedBuildFilePath = await utils_1.zipDirectory(sourceFolderPath, flags.destination);
35
- const generatePortalParams = {
36
- zippedBuildFilePath,
37
- portalFolderPath,
38
- zippedPortalPath,
39
- docsPortalController,
40
- overrideAuthKey,
41
- zip
42
- };
43
- const generatedPortalPath = await generate_1.downloadDocsPortal(generatePortalParams, this.config.configDir);
44
- this.log(`Your portal has been generated at ${generatedPortalPath}`);
45
- }
46
- catch (error) {
47
- if (error && error.response) {
48
- const apiError = error;
49
- const apiResponse = apiError.response;
50
- if (apiResponse) {
51
- const responseData = apiResponse.data.toString();
52
- if (apiResponse.status === 422 && responseData.length > 0 && utils_1.isJSONParsable(responseData)) {
53
- const nestedErrors = JSON.parse(responseData);
54
- if (nestedErrors.error) {
55
- return this.error(utils_1.replaceHTML(nestedErrors.error));
56
- }
57
- else if (nestedErrors.message) {
58
- return this.error(utils_1.replaceHTML(nestedErrors.message));
59
- }
60
- }
61
- else if (apiResponse.status === 401 && responseData.length > 0) {
62
- this.error(utils_1.replaceHTML(responseData));
63
- }
64
- else if (apiResponse.status === 403 && apiResponse.statusText) {
65
- return this.error(utils_1.replaceHTML(apiResponse.statusText));
66
- }
67
- else {
68
- return this.error(apiError.message);
69
- }
70
- }
71
- }
72
- else {
73
- this.error(`${error.message}`);
74
- }
75
- }
10
+ const { flags: { input, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(_a);
11
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
12
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
13
+ const portalDirectory = destination ? new DirectoryPath(destination) : workingDirectory.join("portal");
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);
76
22
  }
77
23
  }
78
- exports.default = PortalGenerate;
79
- PortalGenerate.description = "Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)";
80
- PortalGenerate.flags = {
81
- folder: command_1.flags.string({
82
- parse: (input) => path.resolve(input),
83
- default: "./",
84
- description: "path to the input directory containing API specifications and config files"
85
- }),
86
- destination: command_1.flags.string({
87
- parse: (input) => path.resolve(input),
88
- default: path.resolve("./"),
89
- description: "path to the downloaded portal"
90
- }),
91
- force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if a portal exists in the destination" }),
92
- zip: command_1.flags.boolean({ default: false, description: "download the generated portal as a .zip archive" }),
93
- "auth-key": command_1.flags.string({
94
- default: "",
95
- description: "override current authentication state with an authentication key"
96
- })
97
- };
24
+ _a = PortalGenerate;
25
+ PortalGenerate.summary = "Generate an API Documentation portal";
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)";
27
+ PortalGenerate.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), FlagsProvider.force), { zip: Flags.boolean({
28
+ default: false,
29
+ description: "Download the generated portal as a .zip archive"
30
+ }) }), FlagsProvider.authKey);
31
+ PortalGenerate.cmdTxt = format.cmd("apimatic", "portal", "generate");
98
32
  PortalGenerate.examples = [
99
- `$ apimatic portal:generate --folder="./portal/" --destination="D:/"
100
- Your portal has been generated at D:/
101
- `
33
+ _a.cmdTxt,
34
+ `${_a.cmdTxt} ${format.flag("input", '"./"')} ${format.flag("destination", '"./portal"')}`
102
35
  ];
36
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/portal/generate.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAG/D,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,OAAO,cAAe,SAAQ,OAAO;IAuBzC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAC1E,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAc,CAAC,CAAC;QAErC,MAAM,gBAAgB,GAAG,IAAI,aAAa,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,yBAAyB,CAAC,CAAC;QAC/E,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9F,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvG,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,EAAc,CAAC,EAAE;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"}
@@ -0,0 +1,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalQuickstart extends Command {
3
+ static description: string;
4
+ static summary: string;
5
+ static cmdTxt: string;
6
+ static examples: string[];
7
+ run(): Promise<void>;
8
+ private readonly getConfigDir;
9
+ }
@@ -0,0 +1,37 @@
1
+ var _a;
2
+ import { Command } from "@oclif/core";
3
+ import { PortalQuickstartAction } from "../../actions/portal/quickstart.js";
4
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
5
+ import { TelemetryService } from "../../infrastructure/services/telemetry-service.js";
6
+ import { QuickstartInitiatedEvent } from "../../types/events/quickstart-initiated.js";
7
+ import { QuickstartCompletedEvent } from "../../types/events/quickstart-completed.js";
8
+ import { format, intro, outro } from "../../prompts/format.js";
9
+ class PortalQuickstart extends Command {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.getConfigDir = () => {
13
+ return new DirectoryPath(this.config.configDir);
14
+ };
15
+ }
16
+ async run() {
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(() => { }));
29
+ }
30
+ }
31
+ _a = PortalQuickstart;
32
+ PortalQuickstart.description = "Create your first API Portal using APIMatic's Docs as Code offering.";
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];
36
+ export default PortalQuickstart;
37
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/commands/portal/quickstart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAqB,gBAAiB,SAAQ,OAAO;IAArD;;QA+BmB,iBAAY,GAAG,GAAG,EAAE;YACnC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IAzBC,KAAK,CAAC,GAAG;QACP,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACnE,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,EAAgB,CAAC,EAAE;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,MAAM,gBAAgB,CAAC,UAAU,CAAC,IAAI,wBAAwB,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;QAEzF,KAAK,CAAC,mBAAmB,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"}
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalRecipeNew extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static flags: {
6
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ static readonly cmdTxt: string;
10
+ static readonly examples: string[];
11
+ run(): Promise<void>;
12
+ }