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

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 (269) hide show
  1. package/README.md +257 -101
  2. package/bin/run.js +5 -0
  3. package/lib/actions/action-result.d.ts +8 -0
  4. package/lib/actions/action-result.js +25 -0
  5. package/lib/actions/action-result.js.map +1 -0
  6. package/lib/actions/auth/login.d.ts +12 -0
  7. package/lib/actions/auth/login.js +63 -0
  8. package/lib/actions/auth/login.js.map +1 -0
  9. package/lib/actions/portal/copilot.d.ts +14 -0
  10. package/lib/actions/portal/copilot.js +79 -0
  11. package/lib/actions/portal/copilot.js.map +1 -0
  12. package/lib/actions/portal/generate.d.ts +14 -0
  13. package/lib/actions/portal/generate.js +66 -0
  14. package/lib/actions/portal/generate.js.map +1 -0
  15. package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
  16. package/lib/actions/portal/recipe/new-recipe.js +250 -0
  17. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  18. package/lib/actions/portal/serve.d.ts +14 -0
  19. package/lib/actions/portal/serve.js +24 -0
  20. package/lib/actions/portal/serve.js.map +1 -0
  21. package/lib/actions/portal/toc/new-toc.d.ts +20 -0
  22. package/lib/actions/portal/toc/new-toc.js +133 -0
  23. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  24. package/lib/actions/sdk/generate.d.ts +14 -0
  25. package/lib/actions/sdk/generate.js +72 -0
  26. package/lib/actions/sdk/generate.js.map +1 -0
  27. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  28. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  29. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  30. package/lib/application/portal/recipe/recipe-generator.d.ts +16 -0
  31. package/lib/application/portal/recipe/recipe-generator.js +147 -0
  32. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  33. package/lib/application/portal/serve/portal-watcher.d.ts +11 -0
  34. package/lib/application/portal/serve/portal-watcher.js +64 -0
  35. package/lib/application/portal/serve/portal-watcher.js.map +1 -0
  36. package/lib/application/portal/serve/serve-handler.d.ts +16 -0
  37. package/lib/application/portal/serve/serve-handler.js +91 -0
  38. package/lib/application/portal/serve/serve-handler.js.map +1 -0
  39. package/lib/application/portal/serve/watcher-handler.d.ts +10 -0
  40. package/lib/application/portal/serve/watcher-handler.js +51 -0
  41. package/lib/application/portal/serve/watcher-handler.js.map +1 -0
  42. package/lib/application/portal/toc/sdl-parser.d.ts +19 -0
  43. package/lib/application/portal/toc/sdl-parser.js +90 -0
  44. package/lib/application/portal/toc/sdl-parser.js.map +1 -0
  45. package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
  46. package/lib/application/portal/toc/toc-content-parser.js +44 -0
  47. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  48. package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
  49. package/lib/application/portal/toc/toc-structure-generator.js +84 -0
  50. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  51. package/lib/client-utils/auth-manager.d.ts +8 -3
  52. package/lib/client-utils/auth-manager.js +23 -10
  53. package/lib/client-utils/auth-manager.js.map +1 -0
  54. package/lib/client-utils/sdk-client.d.ts +4 -9
  55. package/lib/client-utils/sdk-client.js +9 -87
  56. package/lib/client-utils/sdk-client.js.map +1 -0
  57. package/lib/commands/api/transform.d.ts +7 -7
  58. package/lib/commands/api/transform.js +46 -51
  59. package/lib/commands/api/transform.js.map +1 -0
  60. package/lib/commands/api/validate.d.ts +4 -4
  61. package/lib/commands/api/validate.js +35 -36
  62. package/lib/commands/api/validate.js.map +1 -0
  63. package/lib/commands/auth/login.d.ts +3 -2
  64. package/lib/commands/auth/login.js +22 -53
  65. package/lib/commands/auth/login.js.map +1 -0
  66. package/lib/commands/auth/logout.d.ts +1 -1
  67. package/lib/commands/auth/logout.js +8 -13
  68. package/lib/commands/auth/logout.js.map +1 -0
  69. package/lib/commands/auth/status.d.ts +1 -1
  70. package/lib/commands/auth/status.js +9 -13
  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 +32 -0
  74. package/lib/commands/portal/copilot.js.map +1 -0
  75. package/lib/commands/portal/generate.d.ts +10 -8
  76. package/lib/commands/portal/generate.js +28 -107
  77. package/lib/commands/portal/generate.js.map +1 -0
  78. package/lib/commands/portal/quickstart.d.ts +10 -0
  79. package/lib/commands/portal/quickstart.js +114 -0
  80. package/lib/commands/portal/quickstart.js.map +1 -0
  81. package/lib/commands/portal/recipe/new.d.ts +10 -0
  82. package/lib/commands/portal/recipe/new.js +38 -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 +80 -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 +52 -0
  89. package/lib/commands/portal/toc/new.js.map +1 -0
  90. package/lib/commands/sdk/generate.d.ts +9 -8
  91. package/lib/commands/sdk/generate.js +39 -128
  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/config/env.d.ts +26 -1
  97. package/lib/config/env.js +27 -4
  98. package/lib/config/env.js.map +1 -0
  99. package/lib/controllers/api/transform.d.ts +1 -1
  100. package/lib/controllers/api/transform.js +23 -22
  101. package/lib/controllers/api/transform.js.map +1 -0
  102. package/lib/controllers/api/validate.d.ts +3 -3
  103. package/lib/controllers/api/validate.js +19 -12
  104. package/lib/controllers/api/validate.js.map +1 -0
  105. package/lib/controllers/portal/quickstart.d.ts +13 -0
  106. package/lib/controllers/portal/quickstart.js +214 -0
  107. package/lib/controllers/portal/quickstart.js.map +1 -0
  108. package/lib/hooks/not-found.d.ts +3 -0
  109. package/lib/hooks/not-found.js +52 -0
  110. package/lib/hooks/not-found.js.map +1 -0
  111. package/lib/hooks/utils.d.ts +5 -0
  112. package/lib/hooks/utils.js +51 -0
  113. package/lib/hooks/utils.js.map +1 -0
  114. package/lib/index.d.ts +1 -1
  115. package/lib/index.js +2 -4
  116. package/lib/index.js.map +1 -0
  117. package/lib/infrastructure/api-client-utils.d.ts +6 -0
  118. package/lib/infrastructure/api-client-utils.js +34 -0
  119. package/lib/infrastructure/api-client-utils.js.map +1 -0
  120. package/lib/infrastructure/api-utils.d.ts +9 -0
  121. package/lib/infrastructure/api-utils.js +33 -0
  122. package/lib/infrastructure/api-utils.js.map +1 -0
  123. package/lib/infrastructure/env-info.d.ts +12 -0
  124. package/lib/infrastructure/env-info.js +58 -0
  125. package/lib/infrastructure/env-info.js.map +1 -0
  126. package/lib/infrastructure/file-service.d.ts +18 -0
  127. package/lib/infrastructure/file-service.js +76 -0
  128. package/lib/infrastructure/file-service.js.map +1 -0
  129. package/lib/infrastructure/launcher-service.d.ts +5 -0
  130. package/lib/infrastructure/launcher-service.js +47 -0
  131. package/lib/infrastructure/launcher-service.js.map +1 -0
  132. package/lib/infrastructure/services/api-service.d.ts +10 -0
  133. package/lib/infrastructure/services/api-service.js +55 -0
  134. package/lib/infrastructure/services/api-service.js.map +1 -0
  135. package/lib/infrastructure/services/auth-service.d.ts +11 -0
  136. package/lib/infrastructure/services/auth-service.js +35 -0
  137. package/lib/infrastructure/services/auth-service.js.map +1 -0
  138. package/lib/infrastructure/services/portal-service.d.ts +23 -0
  139. package/lib/infrastructure/services/portal-service.js +186 -0
  140. package/lib/infrastructure/services/portal-service.js.map +1 -0
  141. package/lib/infrastructure/services/telemetry-service.d.ts +8 -0
  142. package/lib/infrastructure/services/telemetry-service.js +40 -0
  143. package/lib/infrastructure/services/telemetry-service.js.map +1 -0
  144. package/lib/infrastructure/tmp-extensions.d.ts +2 -0
  145. package/lib/infrastructure/tmp-extensions.js +6 -0
  146. package/lib/infrastructure/tmp-extensions.js.map +1 -0
  147. package/lib/infrastructure/zip-service.d.ts +6 -0
  148. package/lib/infrastructure/zip-service.js +39 -0
  149. package/lib/infrastructure/zip-service.js.map +1 -0
  150. package/lib/prompts/auth/login.d.ts +5 -0
  151. package/lib/prompts/auth/login.js +13 -0
  152. package/lib/prompts/auth/login.js.map +1 -0
  153. package/lib/prompts/portal/common/base-prompts.d.ts +7 -0
  154. package/lib/prompts/portal/common/base-prompts.js +19 -0
  155. package/lib/prompts/portal/common/base-prompts.js.map +1 -0
  156. package/lib/prompts/portal/copilot.d.ts +14 -0
  157. package/lib/prompts/portal/copilot.js +71 -0
  158. package/lib/prompts/portal/copilot.js.map +1 -0
  159. package/lib/prompts/portal/generate.d.ts +11 -0
  160. package/lib/prompts/portal/generate.js +42 -0
  161. package/lib/prompts/portal/generate.js.map +1 -0
  162. package/lib/prompts/portal/quickstart.d.ts +30 -0
  163. package/lib/prompts/portal/quickstart.js +240 -0
  164. package/lib/prompts/portal/quickstart.js.map +1 -0
  165. package/lib/prompts/portal/recipe/new-recipe.d.ts +24 -0
  166. package/lib/prompts/portal/recipe/new-recipe.js +203 -0
  167. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  168. package/lib/prompts/portal/serve.d.ts +4 -0
  169. package/lib/prompts/portal/serve.js +14 -0
  170. package/lib/prompts/portal/serve.js.map +1 -0
  171. package/lib/prompts/portal/toc/new-toc.d.ts +11 -0
  172. package/lib/prompts/portal/toc/new-toc.js +39 -0
  173. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  174. package/lib/prompts/sdk/generate.d.ts +11 -0
  175. package/lib/prompts/sdk/generate.js +42 -0
  176. package/lib/prompts/sdk/generate.js.map +1 -0
  177. package/lib/types/api/account.d.ts +10 -0
  178. package/lib/types/api/account.js +2 -0
  179. package/lib/types/api/account.js.map +1 -0
  180. package/lib/types/api/transform.d.ts +19 -4
  181. package/lib/types/api/transform.js +19 -4
  182. package/lib/types/api/transform.js.map +1 -0
  183. package/lib/types/api/validate.d.ts +3 -3
  184. package/lib/types/api/validate.js +2 -2
  185. package/lib/types/api/validate.js.map +1 -0
  186. package/lib/types/build/build.d.ts +14 -0
  187. package/lib/types/build/build.js +4 -0
  188. package/lib/types/build/build.js.map +1 -0
  189. package/lib/types/build-context.d.ts +13 -0
  190. package/lib/types/build-context.js +30 -0
  191. package/lib/types/build-context.js.map +1 -0
  192. package/lib/types/common/result.d.ts +17 -0
  193. package/lib/types/common/result.js +32 -0
  194. package/lib/types/common/result.js.map +1 -0
  195. package/lib/types/events/domain-event.d.ts +8 -0
  196. package/lib/types/events/domain-event.js +11 -0
  197. package/lib/types/events/domain-event.js.map +1 -0
  198. package/lib/types/events/quickstart-completed.d.ts +7 -0
  199. package/lib/types/events/quickstart-completed.js +10 -0
  200. package/lib/types/events/quickstart-completed.js.map +1 -0
  201. package/lib/types/events/quickstart-initiated.d.ts +7 -0
  202. package/lib/types/events/quickstart-initiated.js +10 -0
  203. package/lib/types/events/quickstart-initiated.js.map +1 -0
  204. package/lib/types/events/recipe-creation-failed.d.ts +5 -0
  205. package/lib/types/events/recipe-creation-failed.js +8 -0
  206. package/lib/types/events/recipe-creation-failed.js.map +1 -0
  207. package/lib/types/events/toc-creation-failed.d.ts +5 -0
  208. package/lib/types/events/toc-creation-failed.js +8 -0
  209. package/lib/types/events/toc-creation-failed.js.map +1 -0
  210. package/lib/types/file/directoryPath.d.ts +7 -0
  211. package/lib/types/file/directoryPath.js +16 -0
  212. package/lib/types/file/directoryPath.js.map +1 -0
  213. package/lib/types/file/fileName.d.ts +5 -0
  214. package/lib/types/file/fileName.js +9 -0
  215. package/lib/types/file/fileName.js.map +1 -0
  216. package/lib/types/file/filePath.d.ts +8 -0
  217. package/lib/types/file/filePath.js +11 -0
  218. package/lib/types/file/filePath.js.map +1 -0
  219. package/lib/types/flags-provider.d.ts +15 -0
  220. package/lib/types/flags-provider.js +34 -0
  221. package/lib/types/flags-provider.js.map +1 -0
  222. package/lib/types/portal/generate.d.ts +13 -9
  223. package/lib/types/portal/generate.js +3 -2
  224. package/lib/types/portal/generate.js.map +1 -0
  225. package/lib/types/portal/quickstart.d.ts +17 -0
  226. package/lib/types/portal/quickstart.js +2 -0
  227. package/lib/types/portal/quickstart.js.map +1 -0
  228. package/lib/types/portal/serve.d.ts +12 -0
  229. package/lib/types/portal/serve.js +2 -0
  230. package/lib/types/portal/serve.js.map +1 -0
  231. package/lib/types/portal-context.d.ts +11 -0
  232. package/lib/types/portal-context.js +28 -0
  233. package/lib/types/portal-context.js.map +1 -0
  234. package/lib/types/recipe/recipe.d.ts +37 -0
  235. package/lib/types/recipe/recipe.js +6 -0
  236. package/lib/types/recipe/recipe.js.map +1 -0
  237. package/lib/types/sdk/generate.d.ts +11 -10
  238. package/lib/types/sdk/generate.js +11 -12
  239. package/lib/types/sdk/generate.js.map +1 -0
  240. package/lib/types/sdk-context.d.ts +13 -0
  241. package/lib/types/sdk-context.js +28 -0
  242. package/lib/types/sdk-context.js.map +1 -0
  243. package/lib/types/sdl/sdl.d.ts +12 -0
  244. package/lib/types/sdl/sdl.js +2 -0
  245. package/lib/types/sdl/sdl.js.map +1 -0
  246. package/lib/types/spec-context.d.ts +7 -0
  247. package/lib/types/spec-context.js +12 -0
  248. package/lib/types/spec-context.js.map +1 -0
  249. package/lib/types/toc/toc.d.ts +31 -0
  250. package/lib/types/toc/toc.js +9 -0
  251. package/lib/types/toc/toc.js.map +1 -0
  252. package/lib/types/utils.d.ts +3 -3
  253. package/lib/types/utils.js +2 -2
  254. package/lib/types/utils.js.map +1 -0
  255. package/lib/utils/utils.d.ts +16 -7
  256. package/lib/utils/utils.js +142 -86
  257. package/lib/utils/utils.js.map +1 -0
  258. package/lib/validators/common/directoryValidator.d.ts +5 -0
  259. package/lib/validators/common/directoryValidator.js +22 -0
  260. package/lib/validators/common/directoryValidator.js.map +1 -0
  261. package/lib/validators/portal/serve-validator.d.ts +6 -0
  262. package/lib/validators/portal/serve-validator.js +15 -0
  263. package/lib/validators/portal/serve-validator.js.map +1 -0
  264. package/package.json +100 -43
  265. package/bin/run +0 -5
  266. package/lib/controllers/portal/generate.d.ts +0 -2
  267. package/lib/controllers/portal/generate.js +0 -49
  268. package/lib/controllers/sdk/generate.d.ts +0 -4
  269. package/lib/controllers/sdk/generate.js +0 -64
@@ -0,0 +1,32 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { PortalCopilotPrompts } from "../../prompts/portal/copilot.js";
4
+ import { FlagsProvider } from "../../types/flags-provider.js";
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
+ }
12
+ 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);
17
+ const result = await copilotConfigAction.execute(buildDirectory, force, !disable);
18
+ result.map((message) => this.prompts.logError(message));
19
+ }
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({
24
+ default: false,
25
+ 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`,
30
+ ];
31
+ export default PortalCopilotEnable;
32
+ //# 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,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAqB,mBAAoB,SAAQ,OAAO;IAAxD;;QAqBmB,YAAO,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAaxD,CAAC;IAXC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAC,EACrD,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE1C,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,mBAAmB,GAAG,IAAI,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;QACjG,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;QAClF,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;;AA/BM,2BAAO,GAAG,yDAAyD,AAA5D,CAA6D;AAEpE,+BAAW,GAAG,2PAA2P,AAA9P,CAA+P;AAE1Q,yBAAK,+DACP,aAAa,CAAC,KAAK,KACtB,OAAO,EAAG,KAAK,CAAC,OAAO,CAAC;QACtB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,wDAAwD;KACtE,CAAC,KACC,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,OAAO,CAPd,CAQV;AAEK,4BAAQ,GAAG;IAChB,sCAAsC;IACtC,gDAAgD;CACjD,AAHc,CAGb;eAnBiB,mBAAmB"}
@@ -1,13 +1,15 @@
1
- import { Command, flags } from "@oclif/command";
2
- export default class PortalGenerate extends Command {
1
+ import { Command, Config } from "@oclif/core";
2
+ export declare class PortalGenerate extends Command {
3
3
  static description: string;
4
4
  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>;
5
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
9
  };
11
10
  static examples: string[];
12
- run(): Promise<undefined>;
11
+ private readonly prompts;
12
+ constructor(argv: string[], config: Config);
13
+ run(): Promise<void>;
14
+ private getConfigDir;
13
15
  }
@@ -1,110 +1,31 @@
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
+ import { Command, Flags } from "@oclif/core";
2
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
3
+ import { GenerateAction } from "../../actions/portal/generate.js";
4
+ import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
5
+ import { FlagsProvider } from "../../types/flags-provider.js";
6
+ const DEFAULT_WORKING_DIRECTORY = "./";
7
+ 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
+ }
11
15
  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("You are not authorized to perform this action");
63
- }
64
- else if (apiResponse.status === 403 && apiResponse.statusText) {
65
- return this.error("Your subscription does not allow on premise portal generation");
66
- }
67
- else {
68
- return this.error(apiError.message);
69
- }
70
- }
71
- }
72
- else if (error.statusCode === 401) {
73
- this.error("You are not authorized to perform this action");
74
- }
75
- else if (error.statusCode === 402 &&
76
- error.body &&
77
- typeof error.body === "string") {
78
- this.error(error.body);
79
- }
80
- else {
81
- this.error(`${error.message}`);
82
- }
83
- }
16
+ const { flags: { input, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(PortalGenerate);
17
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
18
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
19
+ 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));
84
23
  }
85
24
  }
86
- exports.default = PortalGenerate;
87
- 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)";
88
- PortalGenerate.flags = {
89
- folder: command_1.flags.string({
90
- parse: (input) => path.resolve(input),
91
- default: "./",
92
- description: "path to the input directory containing API specifications and config files"
93
- }),
94
- destination: command_1.flags.string({
95
- parse: (input) => path.resolve(input),
96
- default: path.resolve("./"),
97
- description: "path to the downloaded portal"
98
- }),
99
- force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if a portal exists in the destination" }),
100
- zip: command_1.flags.boolean({ default: false, description: "download the generated portal as a .zip archive" }),
101
- "auth-key": command_1.flags.string({
102
- default: "",
103
- description: "override current authentication state with an authentication key"
104
- })
105
- };
106
- PortalGenerate.examples = [
107
- `$ apimatic portal:generate --folder="./portal/" --destination="D:/"
108
- Your portal has been generated at D:/
109
- `
110
- ];
25
+ 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
+ PortalGenerate.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), FlagsProvider.force), { zip: Flags.boolean({
27
+ default: false,
28
+ description: "download the generated portal as a .zip archive"
29
+ }) }), FlagsProvider.authKey);
30
+ PortalGenerate.examples = [`apimatic portal:generate`, `apimatic portal:generate --input="./" --destination="./portal"`];
31
+ //# 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,OA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AAc,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAC1G,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,EAClE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAC5C,CAAC;IACJ,CAAC;;AAtCM,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,uBAAQ,GAAG,CAAC,0BAA0B,EAAE,gEAAgE,CAAC,AAAjG,CAAkG"}
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalQuickstart extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ private getSpecFile;
6
+ private getSpecValidationSummary;
7
+ private getWorkingDirectory;
8
+ run(): Promise<void>;
9
+ private getServerPort;
10
+ }
@@ -0,0 +1,114 @@
1
+ import getPort from "get-port";
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";
7
+ 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
+ import { TelemetryService } from "../../infrastructure/services/telemetry-service.js";
15
+ import { QuickstartInitiatedEvent } from "../../types/events/quickstart-initiated.js";
16
+ 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";
19
+ 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;
45
+ }
46
+ 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 });
109
+ }
110
+ }
111
+ PortalQuickstart.description = "Create your first API Portal using APIMatic's Docs as Code offering.";
112
+ PortalQuickstart.examples = ["apimatic portal:quickstart"];
113
+ export default PortalQuickstart;
114
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +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,EAA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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,IAAwB;QAClD,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAExC,MAAM,cAAc,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAEnH,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;;AAlKM,4BAAW,GAAG,sEAAsE,CAAC;AAErF,yBAAQ,GAAG,CAAC,4BAA4B,CAAC,CAAC;eAH9B,gBAAgB"}
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalRecipeNew extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,38 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ 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
+ import { TelemetryService } from "../../../infrastructure/services/telemetry-service.js";
6
+ import { RecipeCreationFailedEvent } from "../../../types/events/recipe-creation-failed.js";
7
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
8
+ import { FlagsProvider } from "../../../types/flags-provider.js";
9
+ const DEFAULT_WORKING_DIRECTORY = "./";
10
+ class PortalRecipeNew extends Command {
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
+ }
28
+ }
29
+ }
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";
32
+ PortalRecipeNew.examples = [
33
+ `apimatic portal:recipe:new`,
34
+ `apimatic portal:recipe:new --name="My API Recipe" --input="./"`
35
+ ];
36
+ PortalRecipeNew.flags = Object.assign({ name: Flags.string({ description: "name for the recipe" }) }, FlagsProvider.input);
37
+ export default PortalRecipeNew;
38
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../../../src/commands/portal/recipe/new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,mBAAmB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BAAkB,CAAC,KAAM,EAAE,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;YACvH,mBAAmB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,KAAM,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,kBAAkB,CAAC,WAAW,EAAE,EAAE,CAAC;YACrC,mBAAmB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,KAAM,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;;AAjCe,uBAAO,GAAG,qDAAqD,CAAC;AAEhE,2BAAW,GACzB,uIAAuI,CAAC;AAE1H,wBAAQ,GAAG;IACzB,4BAA4B;IAC5B,gEAAgE;CACjE,CAAC;AACc,qBAAK,mBACnB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC,IACvD,aAAa,CAAC,KAAK,EACtB;eAbiB,eAAe"}
@@ -0,0 +1,16 @@
1
+ import { Command, Config } from "@oclif/core";
2
+ export default class PortalServe extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ "no-reload": import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ private readonly prompts;
12
+ constructor(argv: string[], config: Config);
13
+ static examples: string[];
14
+ run(): Promise<void>;
15
+ private getServerPort;
16
+ }
@@ -0,0 +1,80 @@
1
+ import getPort from "get-port";
2
+ import { Command, Flags } from "@oclif/core";
3
+ import { PortalServePrompts } from "../../prompts/portal/serve.js";
4
+ import { PortalServeAction } from "../../actions/portal/serve.js";
5
+ import { getMessageInRedColor } from "../../utils/utils.js";
6
+ import { ServeHandler } from "../../application/portal/serve/serve-handler.js";
7
+ import { PortalService } from "../../infrastructure/services/portal-service.js";
8
+ import { GenerateAction } from "../../actions/portal/generate.js";
9
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
10
+ import { FlagsProvider } from "../../types/flags-provider.js";
11
+ const DEFAULT_WORKING_DIRECTORY = "./";
12
+ class PortalServe extends Command {
13
+ constructor(argv, config) {
14
+ super(argv, config);
15
+ this.prompts = new PortalServePrompts();
16
+ }
17
+ async run() {
18
+ var _a;
19
+ const { flags } = await this.parse(PortalServe);
20
+ const portalServePrompts = new PortalServePrompts();
21
+ const portalServeAction = new PortalServeAction(portalServePrompts, new ServeHandler(), new PortalService());
22
+ //TODO: This needs to be moved within the action. Port should not be initialized again here.
23
+ const port = await this.getServerPort(flags.port);
24
+ const workingDirectory = new DirectoryPath((_a = flags.input) !== null && _a !== void 0 ? _a : DEFAULT_WORKING_DIRECTORY);
25
+ const buildDirectory = flags.input ? new DirectoryPath(flags.input, "src") : workingDirectory.join("src");
26
+ const portalDirectory = flags.destination ? new DirectoryPath(flags.destination) : workingDirectory.join("portal");
27
+ const generatePortalAction = new GenerateAction(new DirectoryPath(this.config.configDir), flags["auth-key"]);
28
+ const serveFlags = {
29
+ folder: buildDirectory.toString(),
30
+ destination: portalDirectory.toString(),
31
+ "auth-key": flags["auth-key"],
32
+ port: port,
33
+ open: flags.open,
34
+ "no-reload": flags["no-reload"]
35
+ };
36
+ const servePaths = {
37
+ sourceDirectoryPath: buildDirectory.toString(),
38
+ destinationDirectoryPath: portalDirectory.toString()
39
+ };
40
+ const servePortalResult = await portalServeAction.servePortal(serveFlags, servePaths, PortalServe.id, generatePortalAction.execute);
41
+ //TODO: Convert below statements to result.mapAll after changing servePortalResult to ActionResult.
42
+ if (servePortalResult.isFailed()) {
43
+ portalServePrompts.logError(getMessageInRedColor(servePortalResult.error));
44
+ }
45
+ if (servePortalResult.isCancelled()) {
46
+ portalServePrompts.logError(getMessageInRedColor(servePortalResult.value));
47
+ }
48
+ if (servePortalResult.isSuccess()) {
49
+ this.prompts.displayOutroMessage(buildDirectory.toString(), portalDirectory.toString(), port, flags["no-reload"]);
50
+ }
51
+ }
52
+ async getServerPort(port) {
53
+ const defaultPorts = [3000, 3001, 3002];
54
+ const preferredPorts = typeof port === "number" ? [port, ...defaultPorts.filter((p) => p !== port)] : defaultPorts;
55
+ const availablePort = await getPort({ port: preferredPorts });
56
+ // Show warning only if user provided --port and it is not available
57
+ if (typeof port === "number" && availablePort !== port) {
58
+ this.prompts.displayInfo(`⚠️ Port ${port} is already in use. Available port ${availablePort} will be used.`);
59
+ }
60
+ return availablePort;
61
+ }
62
+ }
63
+ PortalServe.description = "Generate and deploy a Docs as Code portal with hot reload.";
64
+ PortalServe.flags = Object.assign(Object.assign(Object.assign(Object.assign({ port: Flags.integer({
65
+ char: "p",
66
+ description: "[default: 3000] port to serve the portal."
67
+ }) }, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), { open: Flags.boolean({
68
+ char: "o",
69
+ description: "Open the portal in the default browser.",
70
+ default: false
71
+ }), "no-reload": Flags.boolean({
72
+ description: "Disable hot reload.",
73
+ default: false
74
+ }) }), FlagsProvider.authKey);
75
+ PortalServe.examples = [
76
+ "apimatic portal:serve",
77
+ 'apimatic portal:serve --input="./" --destination="./portal" --port=3000 --open --no-reload'
78
+ ];
79
+ export default PortalServe;
80
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAA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AChB,uBAAuB;IACvB,4FAA4F;CAC7F,CAAC;eAhCiB,WAAW"}
@@ -0,0 +1,14 @@
1
+ import { Command, Config } from "@oclif/core";
2
+ export default class PortalTocNew extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static flags: {
6
+ "expand-endpoints": import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ "expand-models": 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
+ };
11
+ static examples: string[];
12
+ constructor(argv: string[], config: Config);
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,52 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { PortalNewTocAction } from "../../../actions/portal/toc/new-toc.js";
3
+ import { TelemetryService } from "../../../infrastructure/services/telemetry-service.js";
4
+ import { TocCreationFailedEvent } from "../../../types/events/toc-creation-failed.js";
5
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
6
+ import { FlagsProvider } from "../../../types/flags-provider.js";
7
+ const DEFAULT_WORKING_DIRECTORY = "./";
8
+ class PortalTocNew extends Command {
9
+ constructor(argv, config) {
10
+ super(argv, config);
11
+ }
12
+ async run() {
13
+ var _a;
14
+ const { flags } = await this.parse(PortalTocNew);
15
+ const telemetryService = new TelemetryService(this.config.configDir);
16
+ const portalNewTocAction = new PortalNewTocAction();
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
+ let tocDirectory;
20
+ if (flags.destination) {
21
+ tocDirectory = new DirectoryPath(flags.destination);
22
+ }
23
+ const result = await portalNewTocAction.createToc(buildDirectory, this.config.configDir, PortalTocNew.id, tocDirectory, flags.force, flags["expand-endpoints"], flags["expand-models"]);
24
+ //TODO: Add a mapper for automatically mapping events to logger and telemetry service.
25
+ if (result.isFailed()) {
26
+ await telemetryService.trackEvent(new TocCreationFailedEvent(result.error, PortalTocNew.id, flags));
27
+ this.error(result.error);
28
+ }
29
+ }
30
+ }
31
+ PortalTocNew.summary = "Generate a Table of Contents (TOC) file for your API documentation portal";
32
+ PortalTocNew.description = `This command generates a new Table of Contents (TOC) file used in the
33
+ generation of your API documentation portal.
34
+
35
+ The output is a YAML file with the .yml extension.
36
+
37
+ To learn more about the TOC file and APIMatic build directory structure, visit:
38
+ https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal`;
39
+ PortalTocNew.flags = Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.destination("src/content", `'toc.yml'`)), FlagsProvider.input), FlagsProvider.force), { "expand-endpoints": Flags.boolean({
40
+ default: false,
41
+ description: "include individual entries for each endpoint in the generated 'toc.yml'. Requires a valid API specification in the working directory."
42
+ }), "expand-models": Flags.boolean({
43
+ default: false,
44
+ description: "include individual entries for each model in the generated 'toc.yml'. Requires a valid API specification in the working directory."
45
+ }) });
46
+ PortalTocNew.examples = [
47
+ `apimatic portal:toc:new --destination="./src/content/"`,
48
+ `apimatic portal:toc:new --input="./"`,
49
+ `apimatic portal:toc:new --input="./" --destination="./src/content/"`
50
+ ];
51
+ export default PortalTocNew;
52
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../../../src/commands/portal/toc/new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,O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,MAAM,CAAC,KAAM,EAAE,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;YACrG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAM,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;;AAlEM,oBAAO,GACZ,2EAA2E,CAAC;AAEvE,wBAAW,GAAG;;;;;;iHAM0F,CAAC;AAEzG,kBAAK,+DACP,aAAa,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,GACrD,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,KAAK,KACtB,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC;QAChC,OAAO,EAAE,KAAK;QACd,WAAW,EACT,uIAAuI;KAC1I,CAAC,EACF,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC;QAC7B,OAAO,EAAE,KAAK;QACd,WAAW,EACT,oIAAoI;KACvI,CAAC,IACF;AAEK,qBAAQ,GAAG;IAChB,wDAAwD;IACxD,sCAAsC;IACtC,qEAAqE;CACtE,CAAC;eAhCiB,YAAY"}
@@ -1,15 +1,16 @@
1
- import { Command, flags } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class SdkGenerate extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- platform: flags.IOptionFlag<string>;
6
- file: flags.IOptionFlag<string>;
7
- url: flags.IOptionFlag<string>;
8
- destination: flags.IOptionFlag<string>;
9
- force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
- zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
11
- "auth-key": flags.IOptionFlag<string>;
5
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ platform: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ spec: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
11
  };
13
12
  static examples: string[];
13
+ private readonly prompts;
14
14
  run(): Promise<void>;
15
+ private getConfigDir;
15
16
  }