@apimatic/cli 0.0.0-alpha.3 → 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 (306) 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 -46
  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
  306. package/oclif.manifest.json +0 -1
@@ -0,0 +1,46 @@
1
+ var _a;
2
+ import { Command, Flags } from "@oclif/core";
3
+ import { PortalRecipeAction } from "../../../actions/portal/recipe/new-recipe.js";
4
+ import { TelemetryService } from "../../../infrastructure/services/telemetry-service.js";
5
+ import { RecipeCreationFailedEvent } from "../../../types/events/recipe-creation-failed.js";
6
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
7
+ import { FlagsProvider } from "../../../types/flags-provider.js";
8
+ import { format, intro, outro } from "../../../prompts/format.js";
9
+ const DEFAULT_WORKING_DIRECTORY = "./";
10
+ class PortalRecipeNew extends Command {
11
+ async run() {
12
+ const { flags: { name, input, force } } = await this.parse(_a);
13
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
14
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
15
+ const commandMetadata = {
16
+ commandName: _a.id,
17
+ shell: this.config.shell
18
+ };
19
+ intro("New Recipe");
20
+ const action = new PortalRecipeAction(new DirectoryPath(this.config.configDir), commandMetadata);
21
+ const result = await action.execute(buildDirectory, name);
22
+ outro(result);
23
+ result.mapAll(() => { }, async () => {
24
+ const telemetryService = new TelemetryService(new DirectoryPath(this.config.configDir));
25
+ await telemetryService.trackEvent(new RecipeCreationFailedEvent("error", _a.id, {
26
+ name,
27
+ input,
28
+ force
29
+ }), commandMetadata.shell);
30
+ }, () => { });
31
+ }
32
+ }
33
+ _a = PortalRecipeNew;
34
+ PortalRecipeNew.summary = "Add an API Recipe to your API documentation portal.";
35
+ PortalRecipeNew.description = `This command adds a new API Recipe file to your documentation portal.
36
+
37
+ To learn more about API Recipes, visit:
38
+ ${format.link("https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes")}`;
39
+ PortalRecipeNew.flags = Object.assign(Object.assign({ name: Flags.string({ description: "name for the recipe" }) }, FlagsProvider.input), FlagsProvider.force);
40
+ PortalRecipeNew.cmdTxt = format.cmd("apimatic", "portal", "recipe", "new");
41
+ PortalRecipeNew.examples = [
42
+ `${_a.cmdTxt}`,
43
+ `${_a.cmdTxt} ${format.flag("name", '"My API Recipe"')} ${format.flag("input", '"./"')}`
44
+ ];
45
+ export default PortalRecipeNew;
46
+ //# 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,gBAAgB,EAAE,MAAM,uDAAuD,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAqB,eAAgB,SAAQ,OAAO;IAsBlD,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAC9B,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAe,CAAC,CAAC;QAEtC,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;QAE9F,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,EAAe,CAAC,EAAE;YAC/B,KAAK,EAAE,IAAI,C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AI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;CAC3F,AAHuB,CAGtB;eApBiB,eAAe"}
@@ -0,0 +1,16 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalServe 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
+ open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ "no-reload": import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ static cmdTxt: string;
13
+ static examples: string[];
14
+ run(): Promise<void>;
15
+ private getConfigDir;
16
+ }
@@ -0,0 +1,54 @@
1
+ var _a;
2
+ import { Command, Flags } from "@oclif/core";
3
+ import { PortalServeAction } from "../../actions/portal/serve.js";
4
+ import { DirectoryPath } from "../../types/file/directoryPath.js";
5
+ import { FlagsProvider } from "../../types/flags-provider.js";
6
+ import { format, intro, outro } from "../../prompts/format.js";
7
+ const DEFAULT_WORKING_DIRECTORY = "./";
8
+ class PortalServe extends Command {
9
+ async run() {
10
+ const { flags: { input, destination, port, open, "no-reload": noReload, "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("Portal Serve");
19
+ const portalServeAction = new PortalServeAction(this.getConfigDir(), commandMetadata, authKey);
20
+ const result = await portalServeAction.execute(buildDirectory, portalDirectory, port, open, !noReload);
21
+ outro(result);
22
+ }
23
+ getConfigDir() {
24
+ return new DirectoryPath(this.config.configDir);
25
+ }
26
+ }
27
+ _a = PortalServe;
28
+ PortalServe.summary = "Generate and serve an API Documentation Portal with hot reload.";
29
+ PortalServe.description = "Requires an input directory with API specifications, a config file, and optionally markdown guides. Supports disabling hot reload and opening the portal in the default browser.";
30
+ PortalServe.flags = Object.assign(Object.assign(Object.assign(Object.assign({ port: Flags.integer({
31
+ char: "p",
32
+ description: "port to serve the portal.",
33
+ default: 3000,
34
+ helpValue: "3000"
35
+ }) }, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), { open: Flags.boolean({
36
+ char: "o",
37
+ description: "open the portal in the default browser.",
38
+ default: false
39
+ }), "no-reload": Flags.boolean({
40
+ description: "disable hot reload.",
41
+ default: false
42
+ }) }), FlagsProvider.authKey);
43
+ PortalServe.cmdTxt = format.cmd("apimatic", "portal", "serve");
44
+ PortalServe.examples = [
45
+ _a.cmdTxt,
46
+ `${_a.cmdTxt} ` +
47
+ `${format.flag("input", './')} ` +
48
+ `${format.flag("destination", './portal')} ` +
49
+ `${format.flag("port", "3000")} ` +
50
+ `${format.flag("open")} ` +
51
+ `${format.flag("no-reload")}`
52
+ ];
53
+ export default PortalServe;
54
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/portal/serve.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBA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AClD,CAAC;;;AA1DM,mBAAO,GAAG,iEAAiE,AAApE,CAAqE;AAE5E,uBAAW,GAChB,kLAAkL,AADlK,CACmK;AAE9K,iBAAK,6DACV,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;QAClB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,2BAA2B;QACxC,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,MAAM;KAClB,CAAC,IACC,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAChD,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;QAClB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,yCAAyC;QACtD,OAAO,EAAE,KAAK;KACf,CAAC,EACF,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC;QACzB,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,KAAK;KACf,CAAC,KACC,aAAa,CAAC,OAAO,CAlBd,CAmBV;AAEK,kBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,AAA5C,CAA6C;AACnD,oBAAQ,GAAG;IAChB,EAAI,CAAC,MAAM;IACX,GAAG,EAAI,CAAC,MAAM,GAAG;QACf,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG;QAChC,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG;QAC5C,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QACjC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;QACzB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;CAChC,AARc,CAQb;eApCiB,WAAW"}
@@ -0,0 +1,14 @@
1
+ import { Command } 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 cmdTxt: string;
12
+ static examples: string[];
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,61 @@
1
+ var _a;
2
+ import { Command, Flags } from "@oclif/core";
3
+ import { PortalNewTocAction } from "../../../actions/portal/toc/new-toc.js";
4
+ import { TelemetryService } from "../../../infrastructure/services/telemetry-service.js";
5
+ import { TocCreationFailedEvent } from "../../../types/events/toc-creation-failed.js";
6
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
7
+ import { FlagsProvider } from "../../../types/flags-provider.js";
8
+ import { format, intro, outro } from "../../../prompts/format.js";
9
+ const DEFAULT_WORKING_DIRECTORY = "./";
10
+ class PortalTocNew extends Command {
11
+ async run() {
12
+ const { flags: { input, destination, force, "expand-endpoints": expandEndpoints, "expand-models": expandModels } } = await this.parse(_a);
13
+ const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
14
+ const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
15
+ const tocDirectory = destination ? new DirectoryPath(destination) : undefined;
16
+ const commandMetadata = {
17
+ commandName: _a.id,
18
+ shell: this.config.shell
19
+ };
20
+ intro("New TOC");
21
+ const action = new PortalNewTocAction(new DirectoryPath(this.config.configDir), commandMetadata);
22
+ const result = await action.execute(buildDirectory, tocDirectory, force, expandEndpoints, expandModels);
23
+ outro(result);
24
+ result.mapAll(() => { }, async () => {
25
+ const telemetryService = new TelemetryService(new DirectoryPath(this.config.configDir));
26
+ await telemetryService.trackEvent(
27
+ // TODO: fix Toc error message
28
+ new TocCreationFailedEvent("error", _a.id, {
29
+ input,
30
+ destination,
31
+ force,
32
+ "expand-endpoints": expandEndpoints,
33
+ "expand-models": expandModels
34
+ }), commandMetadata.shell);
35
+ }, () => { });
36
+ }
37
+ }
38
+ _a = PortalTocNew;
39
+ PortalTocNew.summary = "Generate a Table of Contents (TOC) file for your API documentation portal";
40
+ PortalTocNew.description = `This command generates a new Table of Contents (TOC) file used in the
41
+ generation of your API documentation portal.
42
+
43
+ The output is a YAML file with the .yml extension.
44
+
45
+ To learn more about the TOC file and APIMatic build directory structure, visit:
46
+ ${format.link("https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal")}`;
47
+ PortalTocNew.flags = Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.destination("src/content", `toc.yml`)), FlagsProvider.input), FlagsProvider.force), { "expand-endpoints": Flags.boolean({
48
+ default: false,
49
+ description: `include individual entries for each endpoint in the generated ${format.var("toc.yml")}. Requires a valid API specification in the working directory.`
50
+ }), "expand-models": Flags.boolean({
51
+ default: false,
52
+ description: `include individual entries for each model in the generated ${format.var("toc.yml")}. Requires a valid API specification in the working directory.`
53
+ }) });
54
+ PortalTocNew.cmdTxt = format.cmd("apimatic", "portal", "toc", "new");
55
+ PortalTocNew.examples = [
56
+ `${_a.cmdTxt} ${format.flag("destination", './src/content/')}`,
57
+ `${_a.cmdTxt} ${format.flag("input", './')}`,
58
+ `${_a.cmdTxt} ${format.flag("input", './')} ${format.flag("destination", './src/content/')}`
59
+ ];
60
+ export default PortalTocNew;
61
+ //# 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,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,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GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE;IAChE,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,aAAa,EAAE,gBAAgB,CAAC,EAAE;CAC/F,AAJc,CAIb;eApCiB,YAAY"}
@@ -1,15 +1,17 @@
1
- import { Command, flags } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class SdkGenerate extends Command {
3
- static description: string;
3
+ static readonly summary = "Generate an SDK for your API";
4
+ static readonly description = "Generate Software Development Kits (SDKs) from API specifications.\nSupports multiple programming languages including Java, C#, Python, JavaScript, and more.";
5
+ static readonly cmdTxt: string;
4
6
  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>;
7
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ language: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ spec: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
13
  };
13
14
  static examples: string[];
14
15
  run(): Promise<void>;
16
+ private readonly getConfigDir;
15
17
  }
@@ -1,129 +1,55 @@
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_client_1 = require("../../client-utils/sdk-client");
7
- const sdk_1 = require("@apimatic/sdk");
8
- const utils_1 = require("../../utils/utils");
9
- const generate_1 = require("../../controllers/sdk/generate");
10
- class SdkGenerate 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 { GenerateAction } from "../../actions/sdk/generate.js";
5
+ import { Language } from "../../types/sdk/generate.js";
6
+ import { format, intro, outro } from "../../prompts/format.js";
7
+ const DEFAULT_WORKING_DIRECTORY = "./";
8
+ class SdkGenerate extends Command {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.getConfigDir = () => {
12
+ return new DirectoryPath(this.config.configDir);
13
+ };
14
+ }
11
15
  async run() {
12
- const { flags } = this.parse(SdkGenerate);
13
- const zip = flags.zip;
14
- const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
15
- const sdkFolderPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}`.toLowerCase());
16
- const zippedSDKPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}.zip`.toLowerCase());
17
- // Check if at destination, SDK already exists and throw error if force flag is not set for both zip and extracted
18
- if (fs.existsSync(sdkFolderPath) && !flags.force && !zip) {
19
- throw new Error(`Can't download SDK to path ${sdkFolderPath}, because it already exists`);
20
- }
21
- else if (fs.existsSync(zippedSDKPath) && !flags.force && zip) {
22
- throw new Error(`Can't download SDK to path ${zippedSDKPath}, because it already exists`);
23
- }
24
- try {
25
- if (!(await fs.pathExists(path.resolve(flags.destination)))) {
26
- throw new Error(`Destination path ${flags.destination} does not exist`);
27
- }
28
- else if (!(await fs.pathExists(path.resolve(flags.file)))) {
29
- throw new Error(`Specification file ${flags.file} does not exist`);
30
- }
31
- const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
32
- const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
33
- const sdkGenerationController = new sdk_1.CodeGenerationExternalApisController(client);
34
- // Get generation id for the specification and platform
35
- const codeGenId = await generate_1.getSDKGenerationId(flags, sdkGenerationController);
36
- // If user wanted to download the SDK as well
37
- const sdkDownloadParams = {
38
- codeGenId,
39
- zippedSDKPath,
40
- sdkFolderPath,
41
- zip
42
- };
43
- const sdkPath = await generate_1.downloadGeneratedSDK(sdkDownloadParams, sdkGenerationController);
44
- this.log(`Success! Your SDK is located at ${sdkPath}`);
45
- }
46
- catch (error) {
47
- if (error.result) {
48
- const apiError = error;
49
- const result = apiError.result;
50
- if (apiError.statusCode === 400 && utils_1.isJSONParsable(result.message)) {
51
- const errors = JSON.parse(result.message);
52
- if (Array.isArray(errors.Errors) && apiError.statusCode === 400) {
53
- this.error(utils_1.replaceHTML(`${JSON.parse(result.message).Errors[0]}`));
54
- }
55
- }
56
- else if (apiError.statusCode === 401 && apiError.body && typeof apiError.body === "string") {
57
- this.error(apiError.body);
58
- }
59
- else if (apiError.statusCode === 500 &&
60
- apiError.body &&
61
- typeof apiError.body === "string" &&
62
- utils_1.isJSONParsable(apiError.body)) {
63
- this.error(JSON.parse(apiError.body).message);
64
- }
65
- else if (apiError.statusCode === 422 &&
66
- apiError.body &&
67
- typeof apiError.body === "string" &&
68
- utils_1.isJSONParsable(apiError.body)) {
69
- this.error(JSON.parse(apiError.body)["dto.Url"][0]);
70
- }
71
- else {
72
- this.error(utils_1.replaceHTML(result.message));
73
- }
74
- }
75
- else {
76
- this.error(`${error.message}`);
77
- }
78
- }
16
+ const { flags: { language, spec, destination, force, zip: zipSdk, "auth-key": authKey } } = await this.parse(SdkGenerate);
17
+ const workingDirectory = new DirectoryPath(DEFAULT_WORKING_DIRECTORY);
18
+ const specDirectory = new DirectoryPath(spec);
19
+ const sdkDirectory = destination ? new DirectoryPath(destination) : workingDirectory.join("sdk");
20
+ const commandMetadata = {
21
+ commandName: SdkGenerate.id,
22
+ shell: this.config.shell
23
+ };
24
+ intro("Generate SDK");
25
+ const action = new GenerateAction(this.getConfigDir(), commandMetadata, authKey);
26
+ const result = await action.execute(specDirectory, sdkDirectory, language, force, zipSdk);
27
+ outro(result);
79
28
  }
80
29
  }
81
- exports.default = SdkGenerate;
82
- SdkGenerate.description = "Generate SDK for your APIs";
83
- SdkGenerate.flags = {
84
- platform: command_1.flags.string({
85
- parse: (input) => input.toUpperCase(),
30
+ SdkGenerate.summary = "Generate an SDK for your API";
31
+ SdkGenerate.description = `Generate Software Development Kits (SDKs) from API specifications.
32
+ Supports multiple programming languages including Java, C#, Python, JavaScript, and more.`;
33
+ SdkGenerate.cmdTxt = format.cmd("apimatic", "sdk", "generate");
34
+ SdkGenerate.flags = Object.assign(Object.assign(Object.assign({ language: Flags.string({
35
+ char: "l",
86
36
  required: true,
87
- description: `language platform for sdk
88
- Simple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT
89
- Legacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LIB|
90
- JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|
91
- TS_GENERIC_LIB`
92
- }),
93
- file: command_1.flags.string({
94
- parse: (input) => path.resolve(input),
95
- default: "",
96
- description: "path to the API specification to generate SDKs for"
97
- }),
98
- url: command_1.flags.string({
99
- default: "",
100
- description: "URL to the API specification to generate SDKs for. Can be used in place of the --file option if the API specification is publicly available."
101
- }),
102
- destination: command_1.flags.string({
103
- parse: (input) => path.resolve(input),
104
- default: path.resolve("./"),
105
- description: "directory to download the generated SDK to"
106
- }),
107
- force: command_1.flags.boolean({
108
- char: "f",
37
+ description: "Programming language for SDK generation",
38
+ options: Object.values(Language).map((p) => p.valueOf()),
39
+ }), spec: Flags.string({
40
+ description: "Path to the folder containing the API specification file",
41
+ default: "./src/spec"
42
+ }), destination: Flags.string({
43
+ char: "d",
44
+ description: "Directory where the SDK will be generated"
45
+ }) }, FlagsProvider.force), { zip: Flags.boolean({
109
46
  default: false,
110
- description: "overwrite if an SDK already exists in the destination"
111
- }),
112
- zip: command_1.flags.boolean({ default: false, description: "download the generated SDK as a .zip archive" }),
113
- "auth-key": command_1.flags.string({
114
- default: "",
115
- description: "override current authentication state with an authentication key"
116
- })
117
- };
47
+ description: "Download the generated SDK as a .zip archive"
48
+ }) }), FlagsProvider.authKey);
118
49
  SdkGenerate.examples = [
119
- `$ apimatic sdk:generate --platform="CSHARP" --file="./specs/sample.json"
120
- Generating SDK... done
121
- Downloading SDK... done
122
- Success! Your SDK is located at swagger_sdk_csharp`,
123
- `
124
- $ apimatic sdk:generate --platform="CSHARP" --url=https://petstore.swagger.io/v2/swagger.json
125
- Generating SDK... done
126
- Downloading SDK... done
127
- Success! Your SDK is located at swagger_sdk_csharp
128
- `
50
+ `${SdkGenerate.cmdTxt} ${format.flag("language", "java")}`,
51
+ `${SdkGenerate.cmdTxt} ${format.flag("language", "csharp")} ${format.flag("spec", "./src/spec")}`,
52
+ `${SdkGenerate.cmdTxt} ${format.flag("language", "python")} ${format.flag("destination", "./sdk")} ${format.flag("zip")}`
129
53
  ];
54
+ export default SdkGenerate;
55
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/sdk/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,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE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MAAM,CAAC,IAAI,CAC9G,KAAK,CACN,EAAE;CACJ,AANc,CAMb;eArCiB,WAAW"}
@@ -0,0 +1,2 @@
1
+ declare const axiosInstance: import("axios").AxiosInstance;
2
+ export default axiosInstance;
@@ -0,0 +1,10 @@
1
+ import axios from "axios";
2
+ const fiftyMBsInBytes = 50 * 1024 * 1024;
3
+ const fiveMinutesInMilliseconds = 5 * 60 * 1000;
4
+ const axiosInstance = axios.create({
5
+ maxContentLength: fiftyMBsInBytes,
6
+ maxBodyLength: fiftyMBsInBytes,
7
+ timeout: fiveMinutesInMilliseconds
8
+ });
9
+ export default axiosInstance;
10
+ //# sourceMappingURL=axios-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-config.js","sourceRoot":"","sources":["../../src/config/axios-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACzC,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;IACjC,gBAAgB,EAAE,eAAe;IACjC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,yBAAyB;CACnC,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Hook } from "@oclif/core";
2
+ declare const hook: Hook.CommandNotFound;
3
+ export default hook;
@@ -0,0 +1,52 @@
1
+ // This code was originally forked from https://github.com/oclif/plugin-not-found/blob/main/src/index.ts
2
+ import { toConfiguredId } from "@oclif/core";
3
+ import { cyan, yellow } from "ansis";
4
+ import utils from "./utils.js";
5
+ const hook = async function (opts) {
6
+ var _a;
7
+ const hiddenCommandIds = new Set(opts.config.commands.filter((c) => c.hidden).map((c) => c.id));
8
+ const commandIDs = [...opts.config.commandIDs, ...opts.config.commands.flatMap((c) => c.aliases)].filter((c) => !hiddenCommandIds.has(c));
9
+ if (commandIDs.length === 0)
10
+ return;
11
+ let binHelp = `${opts.config.bin} help`;
12
+ const idSplit = opts.id.split(":");
13
+ if (opts.config.findTopic(idSplit[0])) {
14
+ binHelp = `${binHelp} ${idSplit[0]}`;
15
+ }
16
+ let suggestion;
17
+ if (/:?help:?/.test(opts.id)) {
18
+ suggestion = ["help", ...opts.id.split(":").filter((cmd) => cmd !== "help")].join(":");
19
+ }
20
+ else {
21
+ suggestion = utils.closest(opts.id, commandIDs);
22
+ }
23
+ const readableSuggestion = suggestion ? toConfiguredId(suggestion, this.config) : null;
24
+ const originalCmd = toConfiguredId(opts.id, this.config);
25
+ this.warn(`${yellow(originalCmd)} is not a ${opts.config.bin} command.`);
26
+ if (!process.stdin.isTTY || !suggestion) {
27
+ this.error(`Run ${cyan.bold(binHelp)} for a list of available commands.`, {
28
+ exit: 127
29
+ });
30
+ }
31
+ let response;
32
+ try {
33
+ response = await utils.getConfirmation(readableSuggestion);
34
+ }
35
+ catch (_b) {
36
+ response = false;
37
+ }
38
+ if (response) {
39
+ const confirmedSuggestion = suggestion;
40
+ let argv = ((_a = opts.argv) === null || _a === void 0 ? void 0 : _a.length) ? opts.argv : opts.id.split(":").slice(confirmedSuggestion.split(":").length);
41
+ if (confirmedSuggestion.startsWith("help:")) {
42
+ argv = confirmedSuggestion.split(":").slice(1);
43
+ suggestion = "help";
44
+ }
45
+ return this.config.runCommand(confirmedSuggestion, argv);
46
+ }
47
+ this.error(`Run ${cyan.bold(binHelp)} for a list of available commands.`, {
48
+ exit: 127
49
+ });
50
+ };
51
+ export default hook;
52
+ //# sourceMappingURL=not-found.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-found.js","sourceRoot":"","sources":["../../src/hooks/not-found.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,EAAQ,cAAc,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErC,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IAAI,mBAAmB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,IAAI,GAAG,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/C,UAAU,GAAG,MAAM,CAAC;QACtB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oCAAoC,EAAE;QACxE,IAAI,EAAE,GAAG;KACV,CAAC,CAAC;AAEL,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ closest: (target: string, possibilities: string[]) => string | null;
3
+ getConfirmation: (suggestion: string) => Promise<boolean>;
4
+ };
5
+ export default _default;
@@ -0,0 +1,51 @@
1
+ // This code was originally forked from https://github.com/oclif/plugin-not-found/blob/main/src/utils.ts
2
+ import readline from 'node:readline';
3
+ import { blueBright, reset } from 'ansis';
4
+ import levenshtein from 'fast-levenshtein';
5
+ const getConfirmation = async (suggestion) => {
6
+ if (!process.stdin.isTTY)
7
+ return false;
8
+ const question = `${reset('Did you mean ' + blueBright(suggestion) + '?')} (Y/n) `;
9
+ return new Promise((resolve) => {
10
+ const rl = readline.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout,
13
+ });
14
+ let settled = false;
15
+ const cleanup = () => {
16
+ rl.close();
17
+ clearTimeout(timeout);
18
+ };
19
+ const finish = (result) => {
20
+ if (!settled) {
21
+ settled = true;
22
+ cleanup();
23
+ resolve(result);
24
+ }
25
+ };
26
+ const timeout = setTimeout(() => {
27
+ finish(false);
28
+ }, 10000);
29
+ rl.question(question, (answer) => {
30
+ const a = (answer !== null && answer !== void 0 ? answer : '').trim().toLowerCase();
31
+ finish(a === '' || a === 'y' || a === 'yes');
32
+ });
33
+ });
34
+ };
35
+ const closest = (target, possibilities) => {
36
+ let best = null;
37
+ let bestDistance = Infinity;
38
+ for (const id of possibilities) {
39
+ const distance = levenshtein.get(target, id, { useCollator: true });
40
+ if (distance < bestDistance) {
41
+ bestDistance = distance;
42
+ best = id;
43
+ }
44
+ }
45
+ return best;
46
+ };
47
+ export default {
48
+ closest,
49
+ getConfirmation,
50
+ };
51
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/hooks/utils.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,MAAM,eAAe,GAAG,KAAK,EAAE,UAAkB,EAAoB,EAAE;IACrE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEvC,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,eAAe,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC;IAEnF,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,CAAC,MAAe,EAAE,EAAE;YACjC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,EAAE,KAAM,CAAC,CAAC;QAEX,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,MAAM,CAAC,GAAG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAC9C,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,aAAuB,EAAiB,EAAE;IACzE,IAAI,IAAI,GAAkB,IAAI,CAAC;IAC/B,IAAI,YAAY,GAAG,QAAQ,CAAC;IAE5B,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACpE,IAAI,QAAQ,GAAG,YAAY,EAAE,CAAC;YAC5B,YAAY,GAAG,QAAQ,CAAC;YACxB,IAAI,GAAG,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,eAAe;IACb,OAAO;IACP,eAAe;CAChB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { run } from "@oclif/command";
1
+ export { run } from "@oclif/core";
package/lib/index.js CHANGED
@@ -1,4 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var command_1 = require("@oclif/command");
4
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_1.run; } });
1
+ export { run } from "@oclif/core";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const enum ServiceError {
2
+ NotFound = "NOT_FOUND",
3
+ ServerError = "SERVER_ERROR",
4
+ NetworkError = "NETWORK_ERROR",
5
+ InvalidResponse = "INVALID_RESPONSE",
6
+ UnAuthorized = "UNAUTHORIZED"
7
+ }
8
+ export declare function getErrorMessage(error: ServiceError): string;
9
+ export declare function handleServiceError(error: unknown): ServiceError;