@apimatic/cli 1.1.0-alpha.1 → 1.1.0-alpha.10

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 (156) hide show
  1. package/README.md +221 -73
  2. package/bin/run.js +5 -0
  3. package/lib/actions/portal/generate.d.ts +7 -0
  4. package/lib/actions/portal/generate.js +54 -0
  5. package/lib/actions/portal/generate.js.map +1 -0
  6. package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
  7. package/lib/actions/portal/recipe/new-recipe.js +258 -0
  8. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  9. package/lib/actions/portal/toc/new-toc.d.ts +17 -0
  10. package/lib/actions/portal/toc/new-toc.js +130 -0
  11. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  12. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  13. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  14. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  15. package/lib/application/portal/recipe/recipe-generator.d.ts +16 -0
  16. package/lib/application/portal/recipe/recipe-generator.js +147 -0
  17. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  18. package/lib/application/portal/toc/sdl-parser.d.ts +16 -0
  19. package/lib/application/portal/toc/sdl-parser.js +74 -0
  20. package/lib/application/portal/toc/sdl-parser.js.map +1 -0
  21. package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
  22. package/lib/application/portal/toc/toc-content-parser.js +44 -0
  23. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  24. package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
  25. package/lib/application/portal/toc/toc-structure-generator.js +84 -0
  26. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  27. package/lib/client-utils/auth-manager.d.ts +1 -1
  28. package/lib/client-utils/auth-manager.js +9 -13
  29. package/lib/client-utils/auth-manager.js.map +1 -0
  30. package/lib/client-utils/sdk-client.js +24 -23
  31. package/lib/client-utils/sdk-client.js.map +1 -0
  32. package/lib/commands/api/transform.d.ts +7 -7
  33. package/lib/commands/api/transform.js +39 -38
  34. package/lib/commands/api/transform.js.map +1 -0
  35. package/lib/commands/api/validate.d.ts +4 -4
  36. package/lib/commands/api/validate.js +24 -23
  37. package/lib/commands/api/validate.js.map +1 -0
  38. package/lib/commands/auth/login.d.ts +2 -2
  39. package/lib/commands/auth/login.js +33 -18
  40. package/lib/commands/auth/login.js.map +1 -0
  41. package/lib/commands/auth/logout.d.ts +1 -1
  42. package/lib/commands/auth/logout.js +6 -7
  43. package/lib/commands/auth/logout.js.map +1 -0
  44. package/lib/commands/auth/status.d.ts +1 -1
  45. package/lib/commands/auth/status.js +6 -7
  46. package/lib/commands/auth/status.js.map +1 -0
  47. package/lib/commands/portal/generate.d.ts +12 -7
  48. package/lib/commands/portal/generate.js +73 -87
  49. package/lib/commands/portal/generate.js.map +1 -0
  50. package/lib/commands/portal/quickstart.d.ts +10 -0
  51. package/lib/commands/portal/quickstart.js +77 -0
  52. package/lib/commands/portal/quickstart.js.map +1 -0
  53. package/lib/commands/portal/recipe/new.d.ts +12 -0
  54. package/lib/commands/portal/recipe/new.js +44 -0
  55. package/lib/commands/portal/recipe/new.js.map +1 -0
  56. package/lib/commands/portal/serve.d.ts +16 -0
  57. package/lib/commands/portal/serve.js +135 -0
  58. package/lib/commands/portal/serve.js.map +1 -0
  59. package/lib/commands/portal/toc/new.d.ts +15 -0
  60. package/lib/commands/portal/toc/new.js +63 -0
  61. package/lib/commands/portal/toc/new.js.map +1 -0
  62. package/lib/commands/sdk/generate.d.ts +8 -8
  63. package/lib/commands/sdk/generate.js +40 -41
  64. package/lib/commands/sdk/generate.js.map +1 -0
  65. package/lib/config/axios-config.d.ts +2 -0
  66. package/lib/config/axios-config.js +10 -0
  67. package/lib/config/axios-config.js.map +1 -0
  68. package/lib/config/env.d.ts +27 -1
  69. package/lib/config/env.js +28 -4
  70. package/lib/config/env.js.map +1 -0
  71. package/lib/controllers/api/transform.d.ts +1 -1
  72. package/lib/controllers/api/transform.js +23 -22
  73. package/lib/controllers/api/transform.js.map +1 -0
  74. package/lib/controllers/api/validate.d.ts +3 -3
  75. package/lib/controllers/api/validate.js +19 -12
  76. package/lib/controllers/api/validate.js.map +1 -0
  77. package/lib/controllers/portal/generate.d.ts +3 -2
  78. package/lib/controllers/portal/generate.js +105 -48
  79. package/lib/controllers/portal/generate.js.map +1 -0
  80. package/lib/controllers/portal/quickstart.d.ts +14 -0
  81. package/lib/controllers/portal/quickstart.js +253 -0
  82. package/lib/controllers/portal/quickstart.js.map +1 -0
  83. package/lib/controllers/portal/serve.d.ts +3 -0
  84. package/lib/controllers/portal/serve.js +133 -0
  85. package/lib/controllers/portal/serve.js.map +1 -0
  86. package/lib/controllers/sdk/generate.d.ts +4 -4
  87. package/lib/controllers/sdk/generate.js +23 -26
  88. package/lib/controllers/sdk/generate.js.map +1 -0
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +2 -4
  91. package/lib/index.js.map +1 -0
  92. package/lib/infrastructure/services/portal-service.d.ts +16 -0
  93. package/lib/infrastructure/services/portal-service.js +129 -0
  94. package/lib/infrastructure/services/portal-service.js.map +1 -0
  95. package/lib/prompts/portal/generate.d.ts +10 -0
  96. package/lib/prompts/portal/generate.js +57 -0
  97. package/lib/prompts/portal/generate.js.map +1 -0
  98. package/lib/prompts/portal/quickstart.d.ts +31 -0
  99. package/lib/prompts/portal/quickstart.js +212 -0
  100. package/lib/prompts/portal/quickstart.js.map +1 -0
  101. package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -0
  102. package/lib/prompts/portal/recipe/new-recipe.js +193 -0
  103. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  104. package/lib/prompts/portal/serve.d.ts +7 -0
  105. package/lib/prompts/portal/serve.js +21 -0
  106. package/lib/prompts/portal/serve.js.map +1 -0
  107. package/lib/prompts/portal/toc/new-toc.d.ts +10 -0
  108. package/lib/prompts/portal/toc/new-toc.js +42 -0
  109. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  110. package/lib/services/portal/server.d.ts +14 -0
  111. package/lib/services/portal/server.js +97 -0
  112. package/lib/services/portal/server.js.map +1 -0
  113. package/lib/types/api/transform.d.ts +19 -4
  114. package/lib/types/api/transform.js +19 -4
  115. package/lib/types/api/transform.js.map +1 -0
  116. package/lib/types/api/validate.d.ts +3 -3
  117. package/lib/types/api/validate.js +2 -2
  118. package/lib/types/api/validate.js.map +1 -0
  119. package/lib/types/common/result.d.ts +17 -0
  120. package/lib/types/common/result.js +32 -0
  121. package/lib/types/common/result.js.map +1 -0
  122. package/lib/types/portal/generate.d.ts +26 -9
  123. package/lib/types/portal/generate.js +3 -2
  124. package/lib/types/portal/generate.js.map +1 -0
  125. package/lib/types/portal/quickstart.d.ts +17 -0
  126. package/lib/types/portal/quickstart.js +2 -0
  127. package/lib/types/portal/quickstart.js.map +1 -0
  128. package/lib/types/recipe/recipe.d.ts +37 -0
  129. package/lib/types/recipe/recipe.js +6 -0
  130. package/lib/types/recipe/recipe.js.map +1 -0
  131. package/lib/types/sdk/generate.d.ts +6 -5
  132. package/lib/types/sdk/generate.js +5 -6
  133. package/lib/types/sdk/generate.js.map +1 -0
  134. package/lib/types/sdl/sdl.d.ts +12 -0
  135. package/lib/types/sdl/sdl.js +2 -0
  136. package/lib/types/sdl/sdl.js.map +1 -0
  137. package/lib/types/toc/toc.d.ts +31 -0
  138. package/lib/types/toc/toc.js +9 -0
  139. package/lib/types/toc/toc.js.map +1 -0
  140. package/lib/types/utils.d.ts +3 -3
  141. package/lib/types/utils.js +2 -2
  142. package/lib/types/utils.js.map +1 -0
  143. package/lib/utils/utils.d.ts +31 -5
  144. package/lib/utils/utils.js +316 -74
  145. package/lib/utils/utils.js.map +1 -0
  146. package/lib/validators/common/directoryValidator.d.ts +9 -0
  147. package/lib/validators/common/directoryValidator.js +49 -0
  148. package/lib/validators/common/directoryValidator.js.map +1 -0
  149. package/lib/validators/common/portValidator.d.ts +5 -0
  150. package/lib/validators/common/portValidator.js +16 -0
  151. package/lib/validators/common/portValidator.js.map +1 -0
  152. package/lib/validators/portal/serveValidator.d.ts +6 -0
  153. package/lib/validators/portal/serveValidator.js +17 -0
  154. package/lib/validators/portal/serveValidator.js.map +1 -0
  155. package/package.json +86 -38
  156. package/bin/run +0 -5
@@ -1,28 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("fs-extra");
4
- const command_1 = require("@oclif/command");
5
- const sdk_1 = require("@apimatic/sdk");
6
- const sdk_client_1 = require("../../client-utils/sdk-client");
7
- const validate_1 = require("../../controllers/api/validate");
8
- const utils_1 = require("../../utils/utils");
9
- class Validate extends command_1.Command {
1
+ import fsExtra from "fs-extra";
2
+ import { ux, Flags, Command } from "@oclif/core";
3
+ import { ApiValidationExternalApIsController } from "@apimatic/sdk";
4
+ import { SDKClient } from "../../client-utils/sdk-client.js";
5
+ import { getValidationSummary } from "../../controllers/api/validate.js";
6
+ import { printValidationMessages, replaceHTML } from "../../utils/utils.js";
7
+ class Validate extends Command {
10
8
  async run() {
11
- const { flags } = this.parse(Validate);
9
+ const { flags } = await this.parse(Validate);
12
10
  try {
13
- if (flags.file && !(await fs.pathExists(flags.file))) {
11
+ if (flags.file && !(await fsExtra.pathExists(flags.file))) {
14
12
  throw new Error(`Validation file: ${flags.file} does not exist`);
15
13
  }
16
14
  const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
17
- const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
18
- const apiValidationController = new sdk_1.APIValidationExternalApisController(client);
19
- const validationSummary = await validate_1.getValidation(flags, apiValidationController);
15
+ const client = await SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
16
+ const apiValidationController = new ApiValidationExternalApIsController(client);
17
+ ux.action.start("Validating specification file");
18
+ const validationSummary = await getValidationSummary(flags, apiValidationController);
19
+ ux.action.stop();
20
20
  const logFunctions = {
21
- log: this.log,
22
- warn: this.warn,
23
- error: this.error
21
+ log: (message) => this.log(message),
22
+ warn: (message) => this.warn(message),
23
+ error: (message) => this.error(message)
24
24
  };
25
- utils_1.printValidationMessages(validationSummary, logFunctions);
25
+ printValidationMessages(validationSummary, logFunctions);
26
26
  validationSummary.success
27
27
  ? this.log("Specification file provided is valid")
28
28
  : this.error("Specification file provided is invalid");
@@ -32,7 +32,7 @@ class Validate extends command_1.Command {
32
32
  const apiError = error;
33
33
  const result = apiError.result;
34
34
  if (result.modelState["exception Error"] && apiError.statusCode === 400) {
35
- this.error(utils_1.replaceHTML(result.modelState["exception Error"][0]));
35
+ this.error(replaceHTML(result.modelState["exception Error"][0]));
36
36
  }
37
37
  else if (error.body && apiError.statusCode === 401) {
38
38
  this.error("You are not authorized to perform this action");
@@ -55,7 +55,6 @@ class Validate extends command_1.Command {
55
55
  }
56
56
  }
57
57
  }
58
- exports.default = Validate;
59
58
  Validate.description = "Validate the syntactic and semantic correctness of an API specification";
60
59
  Validate.examples = [
61
60
  `$ apimatic api:validate --file="./specs/sample.json"
@@ -66,11 +65,13 @@ Specification file provided is valid
66
65
  `
67
66
  ];
68
67
  Validate.flags = {
69
- file: command_1.flags.string({ default: "", description: "Path to the API specification file to validate" }),
70
- url: command_1.flags.string({
68
+ file: Flags.string({ default: "", description: "Path to the API specification file to validate" }),
69
+ url: Flags.string({
71
70
  default: "",
72
71
  description: "URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available."
73
72
  }),
74
73
  // docs: flags.boolean({ default: false, description: "Validate specification for docs generation" }), // Next tier, not included in API spec
75
- "auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
74
+ "auth-key": Flags.string({ description: "override current authentication state with an authentication key" })
76
75
  };
76
+ export default Validate;
77
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC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KAA6B,CAAC,UAAU,KAAK,GAAG;gBAChD,KAA6B,CAAC,IAAI;gBACnC,OAAQ,KAA6B,CAAC,IAAI,KAAK,QAAQ,EACvD,CAAC;gBACD,IAAI,CAAC,KAAK,CAAE,KAA6B,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;;AAxEM,oBAAW,GAAG,yEAAyE,CAAC;AAExF,iBAAQ,GAAG;IAChB;;CAEH;IACG;;CAEH;CACE,CAAC;AAEK,cAAK,GAAG;IACb,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IAClG,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;QAChB,OAAO,EAAE,EAAE;QACX,WAAW,EACT,sIAAsI;KACzI,CAAC;IACF,6IAA6I;IAC7I,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kEAAkE,EAAE,CAAC;CAC9G,CAAC;eArBiB,QAAQ"}
@@ -1,9 +1,9 @@
1
- import { flags, Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Login extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- "auth-key": flags.IOptionFlag<string>;
6
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
7
  };
8
8
  run(): Promise<void>;
9
9
  }
@@ -1,15 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const cli_ux_1 = require("cli-ux");
4
- const command_1 = require("@oclif/command");
5
- const utils_1 = require("../../utils/utils");
6
- const sdk_client_1 = require("../../client-utils/sdk-client");
7
- class Login extends command_1.Command {
1
+ import { Flags, Command } from "@oclif/core";
2
+ import { outro, password, text } from "@clack/prompts";
3
+ import { getMessageInRedColor, replaceHTML } from "../../utils/utils.js";
4
+ import { SDKClient } from "../../client-utils/sdk-client.js";
5
+ class Login extends Command {
8
6
  async run() {
9
- const { flags } = this.parse(Login);
7
+ const { flags } = await this.parse(Login);
10
8
  const configDir = this.config.configDir;
11
9
  try {
12
- const client = sdk_client_1.SDKClient.getInstance();
10
+ const client = SDKClient.getInstance();
13
11
  // If user is setting auth key
14
12
  if (flags["auth-key"]) {
15
13
  const response = client.setAuthKey(flags["auth-key"], configDir);
@@ -17,12 +15,28 @@ class Login extends command_1.Command {
17
15
  }
18
16
  else {
19
17
  // If user logs in with email and password
20
- const email = await cli_ux_1.cli.prompt("Please enter your registered email");
21
- const password = await cli_ux_1.cli.prompt("Please enter your password", {
22
- type: "hide"
18
+ const email = await text({
19
+ message: "Enter your registered email:",
20
+ validate: (input) => {
21
+ if (!input) {
22
+ return getMessageInRedColor("Email is required.");
23
+ }
24
+ const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
25
+ if (!emailRegex.test(input)) {
26
+ return getMessageInRedColor("Please enter a valid email address.");
27
+ }
28
+ }
29
+ });
30
+ const pass = await password({
31
+ message: "Please enter your password:",
32
+ validate: (input) => {
33
+ if (!input) {
34
+ return getMessageInRedColor("Password is required.");
35
+ }
36
+ }
23
37
  });
24
- const response = await client.login(email, password, configDir);
25
- this.log(response);
38
+ const response = await client.login(email, pass, configDir);
39
+ outro(response);
26
40
  }
27
41
  }
28
42
  catch (error) {
@@ -32,7 +46,7 @@ class Login extends command_1.Command {
32
46
  if (apiResponse) {
33
47
  const responseData = apiResponse.data;
34
48
  if (apiResponse.status === 403 && responseData) {
35
- return this.error(utils_1.replaceHTML(responseData));
49
+ return this.error(replaceHTML(JSON.stringify(responseData)));
36
50
  }
37
51
  else {
38
52
  return this.error(apiError.message);
@@ -43,11 +57,10 @@ class Login extends command_1.Command {
43
57
  }
44
58
  }
45
59
  }
46
- exports.default = Login;
47
60
  Login.description = "Login using your APIMatic credentials or an API Key";
48
61
  Login.examples = [
49
62
  `$ apimatic auth:login
50
- Please enter your registered email: apimatic-user@gmail.com
63
+ Enter your registered email: apimatic-user@gmail.com
51
64
  Please enter your password: *********
52
65
 
53
66
  You have successfully logged into APIMatic
@@ -56,5 +69,7 @@ You have successfully logged into APIMatic
56
69
  Authentication key successfully set`
57
70
  ];
58
71
  Login.flags = {
59
- "auth-key": command_1.flags.string({ default: "", description: "Set authentication key for all commands" })
72
+ "auth-key": Flags.string({ default: "", description: "Set authentication key for all commands" })
60
73
  };
74
+ export default Login;
75
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;IAkBxC,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAW,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,MAAM,GAAc,SAAS,CAAC,WAAW,EAAE,CAAC;YAElD,8BAA8B;YAC9B,IAAI,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;gBACtB,MAAM,QAAQ,GAAG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AAC,IAAI,CAAC;oBAEtC,IAAI,WAAW,CAAC,MAAM,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;wBAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;oBAC/D,CAAC;yBAAM,CAAC;wBACN,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBACtC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;;AA3EM,iBAAW,GAAG,qDAAqD,CAAC;AAEpE,cAAQ,GAAG;IAChB;;;;;CAKH;IACG;oCACgC;CACjC,CAAC;AAEK,WAAK,GAAG;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;CAClG,CAAC;eAhBiB,KAAK"}
@@ -1,4 +1,4 @@
1
- import { Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Login extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const sdk_client_1 = require("../../client-utils/sdk-client");
5
- class Login extends command_1.Command {
1
+ import { Command } from "@oclif/core";
2
+ import { SDKClient } from "../../client-utils/sdk-client.js";
3
+ class Login extends Command {
6
4
  async run() {
7
5
  try {
8
- const client = sdk_client_1.SDKClient.getInstance();
6
+ const client = SDKClient.getInstance();
9
7
  const response = await client.logout(this.config.configDir);
10
8
  this.log(response);
11
9
  }
@@ -14,10 +12,11 @@ class Login extends command_1.Command {
14
12
  }
15
13
  }
16
14
  }
17
- exports.default = Login;
18
15
  Login.description = "Clear local login credentials";
19
16
  Login.examples = [
20
17
  `$ apimatic auth:logout
21
18
  Logged out
22
19
  `
23
20
  ];
21
+ export default Login;
22
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,KAAM,SAAQ,OAAO;IASxC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAjBM,iBAAW,GAAG,+BAA+B,CAAC;AAE9C,cAAQ,GAAG;IAChB;;CAEH;CACE,CAAC;eAPiB,KAAK"}
@@ -1,4 +1,4 @@
1
- import { Command } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class Status extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const sdk_client_1 = require("../../client-utils/sdk-client");
5
- class Status extends command_1.Command {
1
+ import { Command } from "@oclif/core";
2
+ import { SDKClient } from "../../client-utils/sdk-client.js";
3
+ class Status extends Command {
6
4
  async run() {
7
5
  try {
8
- const client = sdk_client_1.SDKClient.getInstance();
6
+ const client = SDKClient.getInstance();
9
7
  const response = await client.status(this.config.configDir);
10
8
  this.log(response);
11
9
  }
@@ -14,10 +12,11 @@ class Status extends command_1.Command {
14
12
  }
15
13
  }
16
14
  }
17
- exports.default = Status;
18
15
  Status.description = "View current authentication state";
19
16
  Status.examples = [
20
17
  `$ apimatic auth:status
21
18
  Currently logged in as apimatic-client@gmail.com
22
19
  `
23
20
  ];
21
+ export default Status;
22
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAqB,MAAO,SAAQ,OAAO;IASzC,KAAK,CAAC,GAAG;QACP,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;;AAjBM,kBAAW,GAAG,mCAAmC,CAAC;AAElD,eAAQ,GAAG;IAChB;;CAEH;CACE,CAAC;eAPiB,MAAM"}
@@ -1,13 +1,18 @@
1
- import { Command, flags } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default 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
+ folder: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
+ destination: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
10
  };
11
11
  static examples: string[];
12
- run(): Promise<undefined>;
12
+ private readonly prompts;
13
+ constructor(argv: string[], config: any);
14
+ run(): Promise<void>;
15
+ private getPortalPaths;
16
+ private validatePaths;
17
+ private checkExistingPortal;
13
18
  }
@@ -1,104 +1,88 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const fs = require("fs-extra");
5
- const command_1 = require("@oclif/command");
6
- const sdk_1 = require("@apimatic/sdk");
7
- const sdk_client_1 = require("../../client-utils/sdk-client");
8
- const generate_1 = require("../../controllers/portal/generate");
9
- const utils_1 = require("../../utils/utils");
10
- class PortalGenerate extends command_1.Command {
1
+ var _a;
2
+ import * as path from "path";
3
+ import fsExtra from "fs-extra";
4
+ import { Command, Flags } from "@oclif/core";
5
+ import { getMessageInRedColor } from "../../utils/utils.js";
6
+ import { PortalGeneratePrompts } from "../../prompts/portal/generate.js";
7
+ import { PortalGenerateAction } from "../../actions/portal/generate.js";
8
+ import { Result } from "../../types/common/result.js";
9
+ const DEFAULT_FOLDER = "./";
10
+ const DEFAULT_DESTINATION = path.resolve("./");
11
+ const GENERATED_PORTAL_ARTIFACTS_FOLDER = "generated_portal";
12
+ const GENERATED_PORTAL_ARTIFACTS_ZIP = ".generated_portal.zip";
13
+ class PortalGenerate extends Command {
14
+ constructor(argv, config) {
15
+ super(argv, config);
16
+ this.prompts = new PortalGeneratePrompts();
17
+ }
11
18
  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`);
19
+ const { flags } = await this.parse(_a);
20
+ const paths = await this.getPortalPaths(flags);
21
+ const portalGenerateAction = new PortalGenerateAction();
22
+ const shouldContinueWithExistingPortal = await this.checkExistingPortal(paths, flags);
23
+ if (!shouldContinueWithExistingPortal) {
24
+ process.exit(1);
21
25
  }
22
- else if (fs.existsSync(zippedPortalPath) && !flags.force && zip) {
23
- throw new Error(`Can't download portal to path ${zippedPortalPath}, because it already exists`);
26
+ const validationResult = await this.validatePaths(paths);
27
+ if (validationResult.isFailed()) {
28
+ this.error(validationResult.error);
24
29
  }
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}`);
30
+ await portalGenerateAction.generatePortal(paths, flags, this.config.configDir);
31
+ }
32
+ async getPortalPaths(flags) {
33
+ return {
34
+ sourceFolderPath: flags.folder,
35
+ destinationFolderPath: flags.destination,
36
+ generatedPortalArtifactsFolderPath: path.join(flags.destination, GENERATED_PORTAL_ARTIFACTS_FOLDER),
37
+ generatedPortalArtifactsZipFilePath: path.join(flags.destination, GENERATED_PORTAL_ARTIFACTS_ZIP)
38
+ };
39
+ }
40
+ async validatePaths(paths) {
41
+ if (!(await fsExtra.pathExists(paths.sourceFolderPath))) {
42
+ return Result.failure(getMessageInRedColor(`Portal build input folder ${paths.sourceFolderPath} does not exist.`));
45
43
  }
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);
44
+ if (!(await fsExtra.pathExists(path.dirname(paths.generatedPortalArtifactsFolderPath)))) {
45
+ return Result.failure(getMessageInRedColor(`Destination path ${path.dirname(paths.generatedPortalArtifactsFolderPath)} does not exist.`));
46
+ }
47
+ return Result.success("Paths validated successfully.");
48
+ }
49
+ async checkExistingPortal(paths, flags) {
50
+ if (fsExtra.existsSync(paths.generatedPortalArtifactsFolderPath) && !flags.force && !flags.zip) {
51
+ if (!(await this.prompts.overwriteExistingPortalArtifactsPrompt())) {
52
+ return false;
79
53
  }
80
- else {
81
- this.error(`${error.message}`);
54
+ }
55
+ else if (fsExtra.existsSync(paths.generatedPortalArtifactsZipFilePath) && !flags.force && flags.zip) {
56
+ if (!(await this.prompts.existingDestinationPortalZipPrompt())) {
57
+ return false;
82
58
  }
83
59
  }
60
+ return true;
84
61
  }
85
62
  }
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)";
63
+ _a = PortalGenerate;
64
+ 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://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)";
88
65
  PortalGenerate.flags = {
89
- folder: command_1.flags.string({
90
- parse: (input) => path.resolve(input),
91
- default: "./",
66
+ folder: Flags.string({
67
+ parse: async (input) => path.resolve(input),
68
+ default: DEFAULT_FOLDER,
92
69
  description: "path to the input directory containing API specifications and config files"
93
70
  }),
94
- destination: command_1.flags.string({
95
- parse: (input) => path.resolve(input),
96
- default: path.resolve("./"),
71
+ destination: Flags.string({
72
+ parse: async (input) => path.resolve(input),
73
+ default: DEFAULT_DESTINATION,
97
74
  description: "path to the downloaded portal"
98
75
  }),
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({
76
+ force: Flags.boolean({
77
+ char: "f",
78
+ default: false,
79
+ description: "overwrite if a portal exists in the destination"
80
+ }),
81
+ zip: Flags.boolean({
82
+ default: false,
83
+ description: "download the generated portal as a .zip archive"
84
+ }),
85
+ "auth-key": Flags.string({
102
86
  default: "",
103
87
  description: "override current authentication state with an authentication key"
104
88
  })
@@ -108,3 +92,5 @@ PortalGenerate.examples = [
108
92
  Your portal has been generated at D:/
109
93
  `
110
94
  ];
95
+ export default PortalGenerate;
96
+ //# sourceMappingURL=generate.js.map
@@ -0,0 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AO,CAAC;QACjB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,kEAAkE;KAChF,CAAC;CACH,AAxBW,CAwBV;AAEK,uBAAQ,GAAG;IAChB;;CAEH;CACE,AAJc,CAIb;eAlCiB,cAAc"}
@@ -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 getBuildDirectory;
8
+ private getGeneratedPortalPath;
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,77 @@
1
+ import { Command } from "@oclif/core";
2
+ import { ApiValidationExternalApIsController } from "@apimatic/sdk";
3
+ import { SDKClient } from "../../client-utils/sdk-client.js";
4
+ import { PortalQuickstartPrompts } from "../../prompts/portal/quickstart.js";
5
+ import { PortalQuickstartController } from "../../controllers/portal/quickstart.js";
6
+ import { getMessageInRedColor } from "../../utils/utils.js";
7
+ class PortalQuickstart extends Command {
8
+ async getSpecFile(prompts, controller) {
9
+ const specPath = await prompts.specPrompt();
10
+ const specFile = await controller.getSpecFile(specPath);
11
+ prompts.displaySpecValidationMessage();
12
+ return specFile;
13
+ }
14
+ async getSpecValidationSummary(prompts, controller, specFile, apiValidationController) {
15
+ const apiValidationSummary = await controller.getSpecValidationSummary(prompts, specFile, apiValidationController);
16
+ if (!apiValidationSummary.success) {
17
+ prompts.displaySpecValidationFailureMessage();
18
+ await prompts.specValidationFailurePrompt();
19
+ }
20
+ else {
21
+ prompts.displaySpecValidationSuccessMessage();
22
+ }
23
+ return apiValidationSummary;
24
+ }
25
+ async getBuildDirectory(prompts, controller, specFile, apiValidationSummary, languages) {
26
+ const buildDirectoryPath = await prompts.buildDirectoryPrompt();
27
+ prompts.displayBuildDirectoryGenerationMessage();
28
+ await controller.setupBuildDirectory(prompts, buildDirectoryPath, specFile, apiValidationSummary, languages);
29
+ prompts.displayBuildDirectoryGenerationSuccessMessage(buildDirectoryPath);
30
+ prompts.displayBuildDirectoryAsTree(buildDirectoryPath);
31
+ return buildDirectoryPath;
32
+ }
33
+ async getGeneratedPortalPath(prompts, controller, directory) {
34
+ prompts.displayPortalGenerationMessage();
35
+ const generatedPortalPath = await controller.generatePortalArtifacts(directory, this.config.configDir);
36
+ prompts.displayPortalGenerationSuccessMessage();
37
+ return generatedPortalPath;
38
+ }
39
+ async run() {
40
+ const prompts = new PortalQuickstartPrompts();
41
+ const controller = new PortalQuickstartController();
42
+ prompts.displayWelcomeMessage();
43
+ let loggedIn = await controller.isUserAuthenticated(this.config.configDir);
44
+ while (!loggedIn) {
45
+ const credentials = await prompts.loginPrompt();
46
+ prompts.displayLoggingInMessage();
47
+ try {
48
+ await controller.userLogin(credentials, SDKClient.getInstance(), this.config.configDir);
49
+ loggedIn = true;
50
+ prompts.displayLoggedInMessage();
51
+ }
52
+ catch (error) {
53
+ prompts.displayLoggingInErrorMessage();
54
+ }
55
+ }
56
+ const client = await SDKClient.getInstance().getClient(null, this.config.configDir);
57
+ const apiValidationController = new ApiValidationExternalApIsController(client);
58
+ try {
59
+ const specFile = await this.getSpecFile(prompts, controller);
60
+ const apiValidationSummary = await this.getSpecValidationSummary(prompts, controller, specFile, apiValidationController);
61
+ const languages = await prompts.sdkLanguagesPrompt();
62
+ const directory = await this.getBuildDirectory(prompts, controller, specFile, apiValidationSummary, languages);
63
+ const generatedPortalPath = await this.getGeneratedPortalPath(prompts, controller, directory);
64
+ const serverStarted = await controller.servePortal(generatedPortalPath, directory, this.config.configDir);
65
+ if (serverStarted) {
66
+ prompts.displayOutroMessage(directory);
67
+ }
68
+ }
69
+ catch (error) {
70
+ this.error(getMessageInRedColor(error instanceof Error ? error.message : String(error)));
71
+ }
72
+ }
73
+ }
74
+ PortalQuickstart.description = "Create your first API Portal using APIMatic's Docs as Code offering.";
75
+ PortalQuickstart.examples = ["$ apimatic portal:quickstart"];
76
+ export default PortalQuickstart;
77
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/commands/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,mCAAmC,EAAgC,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAqB,gBAAiB,SAAQ,OAAO;IAK3C,KAAK,CAAC,WAAW,CACvB,OAAgC,EAChC,UAAsC;QAEtC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QAE5C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAExD,OAAO,CAAC,4BAA4B,EAAE,CAAC;QAEvC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,wBAAwB,CACpC,OAAgC,EAChC,UAAsC,EACtC,QAAkB,EAClB,uBAA4D;QAE5D,MAAM,oBAAoB,GAAG,MAAM,UAAU,CAAC,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,uBAAuB,CAAC,CAAC;QAEnH,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;YAClC,OAAO,CAAC,mCAAmC,EAAE,CAAC;YAC9C,MAAM,OAAO,CAAC,2BAA2B,EAAE,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,mCAAmC,EAAE,CAAC;QAChD,CAAC;QAED,OAAO,oBAAoB,CAAC;IAC9B,CAAC;I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AAC,oBAAoB,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;;AAxHM,4BAAW,GAAG,sEAAsE,CAAC;AAErF,yBAAQ,GAAG,CAAC,8BAA8B,CAAC,CAAC;eAHhC,gBAAgB"}
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalNewRecipe 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
+ folder: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ "build-config": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<void>;
12
+ }