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

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
@@ -0,0 +1,133 @@
1
+ import * as path from "path";
2
+ import axios from "axios";
3
+ import chokidar from "chokidar";
4
+ import { cleanUpGeneratedPortalFiles, getGeneratedFilesPaths, getMessageInMagentaColor, getMessageInRedColor, validateAndZipPortalSource } from "../../utils/utils.js";
5
+ import { downloadDocsPortal } from "./generate.js";
6
+ const progressSpinner = {
7
+ frames: ["◒", "◐", "◓", "◑"].map((frame) => getMessageInMagentaColor(frame)),
8
+ isRunning: false,
9
+ interval: null,
10
+ frameIndex: 0,
11
+ text: "Regenerating portal... ",
12
+ start() {
13
+ if (this.interval) {
14
+ return;
15
+ }
16
+ this.interval = setInterval(() => {
17
+ this.frameIndex = (this.frameIndex + 1) % this.frames.length;
18
+ process.stdout.write(`\r\u001b[K${this.format()}`);
19
+ }, 200);
20
+ },
21
+ stop() {
22
+ if (this.interval !== null) {
23
+ clearInterval(this.interval);
24
+ this.interval = null;
25
+ }
26
+ process.stdout.write("\r\u001b[K ✅ Portal regenerated successfully. ");
27
+ },
28
+ error() {
29
+ if (this.interval !== null) {
30
+ clearInterval(this.interval);
31
+ this.interval = null;
32
+ }
33
+ process.stdout.write("\r\u001b[K ❌ Portal regeneration unsuccessful. ");
34
+ },
35
+ format() {
36
+ return ` ${this.frames[this.frameIndex]} ${this.text}`;
37
+ }
38
+ };
39
+ export const watchAndRegeneratePortal = async (sourceDir, portalDir, configDir, overrideAuthKey, ignoredPaths = []) => {
40
+ // Convert ignoredPaths to absolute paths for consistent comparison
41
+ const generatedFilesPaths = getGeneratedFilesPaths(sourceDir, portalDir);
42
+ const absoluteIgnoredPaths = [
43
+ ...ignoredPaths.filter((ignoredPath) => ignoredPath.trim() !== ""),
44
+ ...generatedFilesPaths
45
+ ].map((ignoredPath) => path.resolve(sourceDir, ignoredPath));
46
+ const watcher = chokidar.watch(sourceDir, {
47
+ ignored: [...absoluteIgnoredPaths, /(^|[/\\])\..+/],
48
+ ignoreInitial: true,
49
+ persistent: true
50
+ });
51
+ const deletedDirectories = new Set();
52
+ watcher
53
+ .on("all", async (event, path) => {
54
+ if (event == "unlinkDir") {
55
+ deletedDirectories.add(path);
56
+ }
57
+ if (event == "unlink") {
58
+ for (const dir of deletedDirectories) {
59
+ if (path.startsWith(dir)) {
60
+ return;
61
+ }
62
+ }
63
+ }
64
+ await handleFileChange(sourceDir, portalDir, configDir, overrideAuthKey, absoluteIgnoredPaths);
65
+ })
66
+ .on("error", (error) => {
67
+ console.error("Watcher error:", error);
68
+ });
69
+ return watcher;
70
+ };
71
+ export const generatePortal = async (sourceDir, portalDir, configDir, ignoredPaths = [], overrideAuthKey = null) => {
72
+ const zippedBuildFilePath = await validateAndZipPortalSource(sourceDir, path.join(sourceDir, ".portal_source.zip"), ignoredPaths);
73
+ const generatePortalParams = {
74
+ sourceBuildInputZipFilePath: zippedBuildFilePath,
75
+ generatedPortalArtifactsFolderPath: portalDir,
76
+ generatedPortalArtifactsZipFilePath: path.join(sourceDir, ".generated_portal.zip"),
77
+ overrideAuthKey,
78
+ generateZipFile: false
79
+ };
80
+ await downloadDocsPortal(generatePortalParams, configDir);
81
+ };
82
+ async function handleFileChange(sourceDir, portalDir, configDir, overrideAuthKey, absoluteIgnoredPaths) {
83
+ progressSpinner.start();
84
+ try {
85
+ await generatePortal(sourceDir, portalDir, configDir, absoluteIgnoredPaths, overrideAuthKey);
86
+ progressSpinner.stop();
87
+ await cleanUpGeneratedPortalFiles(sourceDir);
88
+ }
89
+ catch (error) {
90
+ if (axios.isCancel(error)) {
91
+ return;
92
+ }
93
+ progressSpinner.error();
94
+ await cleanUpGeneratedPortalFiles(sourceDir);
95
+ if (axios.isAxiosError(error)) {
96
+ if (error.response) {
97
+ if (error.response.status === 400) {
98
+ console.error(getMessageInRedColor(`Failed to regenerate the portal. Please ensure that the provided build directory follows the correct structure and contains valid API definition and build files.`));
99
+ }
100
+ else if (error.response.status === 403) {
101
+ console.error(getMessageInRedColor(`Access denied. It looks like you don't have access to APIMatic's Docs as Code offering. Check your subscription details and contact our team at support@apimatic.io if you believe this is a mistake.`));
102
+ }
103
+ else if (error.response.status === 422) {
104
+ console.error(getMessageInRedColor(`Failed to regenerate the portal. Please ensure that the provided build directory follows the correct structure and contains valid API definition and build files.`));
105
+ }
106
+ else if (error.response.status === 500) {
107
+ console.error(getMessageInRedColor(`Failed to regenerate the portal. Please ensure that the provided build directory follows the correct structure and contains valid API definition and build files. If the issue persists, reach out to our team at support@apimatic.io`));
108
+ }
109
+ else {
110
+ console.error(getMessageInRedColor(`Failed to regenerate the portal. Please ensure that the provided build directory follows the correct structure and contains valid API definition and build files. If the issue persists, reach out to our team at support@apimatic.io`));
111
+ }
112
+ }
113
+ else if (error.request) {
114
+ if (error.code === "ECONNABORTED") {
115
+ console.error(getMessageInRedColor(`Your request timed out. Please try again or reach out to our team at support@apimatic.io for help if your problem persists.`));
116
+ }
117
+ else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
118
+ throw new Error(getMessageInRedColor(`Network error. Please check your internet connection and try again.`));
119
+ }
120
+ else {
121
+ console.error(getMessageInRedColor(`No response received from the server. Please try again later.`));
122
+ }
123
+ }
124
+ else {
125
+ console.error(getMessageInRedColor(`Failed to regenerate portal: ${error.message}`));
126
+ }
127
+ }
128
+ else {
129
+ console.error(getMessageInRedColor(`Failed to regenerate portal: ${error instanceof Error ? error.message : "Unknown error"}`));
130
+ }
131
+ }
132
+ }
133
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/controllers/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,M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oBAClC,OAAO,CAAC,KAAK,CACX,oBAAoB,CAClB,8HAA8H,CAC/H,CACF,CAAC;gBACJ,CAAC;qBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;oBACtE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,qEAAqE,CAAC,CAAC,CAAC;gBAC/G,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CACX,oBAAoB,CAClB,+DAA+D,CAChE,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,gCAAgC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,oBAAoB,CAAC,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CACjH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import { CodeGenerationExternalApisController } from "@apimatic/sdk";
2
- import { GenerationIdParams, DownloadSDKParams } from "../../types/sdk/generate";
3
- export declare const getSDKGenerationId: ({ file, url, platform }: GenerationIdParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
4
- export declare const downloadGeneratedSDK: ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }: DownloadSDKParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
1
+ import { CodeGenerationExternalApIsController } from "@apimatic/sdk";
2
+ import { GenerationIdParams, DownloadSDKParams } from "../../types/sdk/generate.js";
3
+ export declare const getSDKGenerationId: ({ file, url, platform }: GenerationIdParams, sdkGenerationController: CodeGenerationExternalApIsController) => Promise<string>;
4
+ export declare const downloadGeneratedSDK: ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }: DownloadSDKParams, sdkGenerationController: CodeGenerationExternalApIsController) => Promise<string>;
@@ -1,19 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadGeneratedSDK = exports.getSDKGenerationId = void 0;
4
- const fs = require("fs-extra");
5
- const cli_ux_1 = require("cli-ux");
6
- const sdk_1 = require("@apimatic/sdk");
7
- const core_1 = require("@apimatic/core");
8
- const generate_1 = require("../../types/sdk/generate");
9
- const utils_1 = require("../../utils/utils");
10
- exports.getSDKGenerationId = async ({ file, url, platform }, sdkGenerationController) => {
11
- cli_ux_1.default.action.start("Generating SDK");
1
+ import fsExtra from "fs-extra";
2
+ import { ux } from "@oclif/core";
3
+ import { Platforms, FileWrapper } from "@apimatic/sdk";
4
+ import { SimplePlatforms } from "../../types/sdk/generate.js";
5
+ import { unzipFile, writeFileUsingReadableStream } from "../../utils/utils.js";
6
+ export const getSDKGenerationId = async ({ file, url, platform }, sdkGenerationController) => {
7
+ ux.action.start("Generating SDK");
12
8
  let generation;
13
9
  const sdkPlatform = getSDKPlatform(platform);
14
10
  if (file) {
15
- const fileDescriptor = new core_1.FileWrapper(fs.createReadStream(file));
16
- generation = await sdkGenerationController.generateSDKViaFile(fileDescriptor, sdkPlatform);
11
+ const fileDescriptor = new FileWrapper(fsExtra.createReadStream(file));
12
+ generation = await sdkGenerationController.generateSdkViaFile(fileDescriptor, sdkPlatform);
17
13
  }
18
14
  else if (url) {
19
15
  // If url to spec file is provided
@@ -21,40 +17,40 @@ exports.getSDKGenerationId = async ({ file, url, platform }, sdkGenerationContro
21
17
  url: url,
22
18
  template: sdkPlatform
23
19
  };
24
- generation = await sdkGenerationController.generateSDKViaURL(body);
20
+ generation = await sdkGenerationController.generateSdkViaUrl(body);
25
21
  }
26
22
  else {
27
23
  throw new Error("Please provide a specification file");
28
24
  }
29
- cli_ux_1.default.action.stop();
25
+ ux.action.stop();
30
26
  return generation.result.id;
31
27
  };
32
28
  // Get valid platform from user's input, convert simple platform to valid Platforms enum value
33
29
  const getSDKPlatform = (platform) => {
34
- if (Object.keys(generate_1.SimplePlatforms).includes(platform)) {
35
- return generate_1.SimplePlatforms[platform];
30
+ if (Object.keys(SimplePlatforms).includes(platform)) {
31
+ return SimplePlatforms[platform];
36
32
  }
37
- else if (Object.values(sdk_1.Platforms).includes(platform)) {
33
+ else if (Object.values(Platforms).includes(platform)) {
38
34
  return platform;
39
35
  }
40
36
  else {
41
- const platforms = Object.keys(generate_1.SimplePlatforms).concat(Object.values(sdk_1.Platforms)).join("|");
37
+ const platforms = Object.keys(SimplePlatforms).concat(Object.values(Platforms)).join("|");
42
38
  throw new Error(`Please provide a valid platform i.e. ${platforms}`);
43
39
  }
44
40
  };
45
41
  // Download Platform
46
- exports.downloadGeneratedSDK = async ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }, sdkGenerationController) => {
47
- cli_ux_1.default.action.start("Downloading SDK");
48
- const { result } = await sdkGenerationController.downloadSDK(codeGenId);
42
+ export const downloadGeneratedSDK = async ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }, sdkGenerationController) => {
43
+ ux.action.start("Downloading SDK");
44
+ const { result } = await sdkGenerationController.downloadSdk(codeGenId);
49
45
  if (result.readable) {
50
46
  if (!zip) {
51
- await utils_1.unzipFile(result, sdkFolderPath);
52
- cli_ux_1.default.action.stop();
47
+ await unzipFile(result, sdkFolderPath);
48
+ ux.action.stop();
53
49
  return sdkFolderPath;
54
50
  }
55
51
  else {
56
- await utils_1.writeFileUsingReadableStream(result, zippedSDKPath);
57
- cli_ux_1.default.action.stop();
52
+ await writeFileUsingReadableStream(result, zippedSDKPath);
53
+ ux.action.stop();
58
54
  return zippedSDKPath;
59
55
  }
60
56
  }
@@ -62,3 +58,4 @@ exports.downloadGeneratedSDK = async ({ codeGenId, zippedSDKPath, sdkFolderPath,
62
58
  throw new Error("Couldn't download the SDK");
63
59
  }
64
60
  };
61
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"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AAO,aAAa,CAAC;QACvB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC,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,16 @@
1
+ import { GeneratePortalParams } from "../../types/portal/generate.js";
2
+ import { Result } from "../../types/common/result.js";
3
+ import { Sdl } from "../../types/sdl/sdl.js";
4
+ export declare class PortalService {
5
+ private readonly CONTENT_TYPE;
6
+ private readonly TIMEOUT;
7
+ generateOnPremPortal(params: GeneratePortalParams, configDir: string): Promise<Result<NodeJS.ReadableStream, string>>;
8
+ generateSdl(specPath: string, configDir: string): Promise<Result<Sdl, string>>;
9
+ private createGenericErrorResult;
10
+ private createAuthorizationHeader;
11
+ private createApiClient;
12
+ private generatePortalFromSyncEndpoint;
13
+ private handlePortalGenerationErrors;
14
+ private parseErrorResponse;
15
+ private saveAndExtractErrorZipFile;
16
+ }
@@ -0,0 +1,129 @@
1
+ import fsExtra from "fs-extra";
2
+ import fs from "fs";
3
+ import * as path from "path";
4
+ import { ContentType, DocsPortalManagementController, Client, UnauthorizedResponseError, ProblemDetailsError, FileWrapper, ApiError, TransformationController, ExportFormats, InternalServerErrorResponseError } from "@apimatic/sdk";
5
+ import { getAuthInfo } from "../../client-utils/auth-manager.js";
6
+ import { Result } from "../../types/common/result.js";
7
+ import { getMessageInRedColor, parseStreamBodyToJson, extractZipFile, deleteFile } from "../../utils/utils.js";
8
+ export class PortalService {
9
+ constructor() {
10
+ this.CONTENT_TYPE = ContentType.EnumMultipartformdata;
11
+ this.TIMEOUT = 0;
12
+ this.createAuthorizationHeader = (authInfo, overrideAuthKey) => {
13
+ const key = overrideAuthKey || (authInfo === null || authInfo === void 0 ? void 0 : authInfo.authKey);
14
+ return `X-Auth-Key ${key !== null && key !== void 0 ? key : ""}`;
15
+ };
16
+ this.createApiClient = (authorizationHeader) => {
17
+ return new Client({
18
+ customHeaderAuthenticationCredentials: {
19
+ Authorization: authorizationHeader
20
+ },
21
+ timeout: this.TIMEOUT
22
+ });
23
+ };
24
+ this.generatePortalFromSyncEndpoint = async (docsPortalManagementController, zippedBuildFilePath) => {
25
+ const file = new FileWrapper(fs.createReadStream(zippedBuildFilePath));
26
+ const response = await docsPortalManagementController.generateOnPremPortalViaBuildInput(this.CONTENT_TYPE, file);
27
+ return response.result;
28
+ };
29
+ this.handlePortalGenerationErrors = async (error, params) => {
30
+ var _a;
31
+ if (error instanceof UnauthorizedResponseError) {
32
+ //401
33
+ const body = await this.parseErrorResponse(error);
34
+ return getMessageInRedColor((_a = body.message) !== null && _a !== void 0 ? _a : "Unauthorized access.");
35
+ }
36
+ else if (error instanceof ProblemDetailsError) {
37
+ //400 & 403
38
+ const body = await this.parseErrorResponse(error);
39
+ const message = body.errors[Object.keys(body.errors)[0]][0];
40
+ return getMessageInRedColor(body.title + "\n- " + message);
41
+ }
42
+ else if (error instanceof ApiError && error.statusCode === 422) {
43
+ //422
44
+ return await this.saveAndExtractErrorZipFile(error, params);
45
+ }
46
+ else if (error instanceof InternalServerErrorResponseError) {
47
+ //500
48
+ const body = await this.parseErrorResponse(error);
49
+ return getMessageInRedColor(`${body.message} Please try again or reach out to our team at support@apimatic.io for help if your problem persists.`);
50
+ }
51
+ else {
52
+ return getMessageInRedColor(error instanceof Error ? error.message : String(error));
53
+ }
54
+ };
55
+ this.parseErrorResponse = async (error) => {
56
+ if (error instanceof Error && "body" in error) {
57
+ const stream = error.body;
58
+ return await parseStreamBodyToJson(stream);
59
+ }
60
+ throw error;
61
+ };
62
+ this.saveAndExtractErrorZipFile = async (error, params) => {
63
+ const data = error.body;
64
+ const writeStream = fs.createWriteStream(params.generatedPortalArtifactsZipFilePath);
65
+ //TODO: Extract zip to temp folder and only copy the the debug report.
66
+ return await new Promise((resolve, reject) => {
67
+ data
68
+ .pipe(writeStream)
69
+ .on("finish", async () => {
70
+ await extractZipFile(params.generatedPortalArtifactsZipFilePath, params.generatedPortalArtifactsFolderPath);
71
+ await deleteFile(params.generatedPortalArtifactsZipFilePath);
72
+ await deleteFile(path.join(params.generatedPortalArtifactsFolderPath, "static"));
73
+ resolve(getMessageInRedColor("An error occurred during portal generation due to an issue with the input. An error report has been written at the destination path: " +
74
+ path.join(params.generatedPortalArtifactsFolderPath, "apimatic-debug")));
75
+ })
76
+ .on("error", async () => {
77
+ reject(getMessageInRedColor("An error occurred during portal generation due to an issue with the input. The error report could not be generated. Please try again later."));
78
+ });
79
+ });
80
+ };
81
+ }
82
+ async generateOnPremPortal(params, configDir) {
83
+ if (!(await fsExtra.pathExists(params.sourceBuildInputZipFilePath))) {
84
+ return Result.failure("Build file doesn't exist");
85
+ }
86
+ const authInfo = await getAuthInfo(configDir);
87
+ const authorizationHeader = this.createAuthorizationHeader(authInfo, params.overrideAuthKey);
88
+ const client = this.createApiClient(authorizationHeader);
89
+ const docsPortalManagementController = new DocsPortalManagementController(client);
90
+ try {
91
+ const stream = await this.generatePortalFromSyncEndpoint(docsPortalManagementController, params.sourceBuildInputZipFilePath);
92
+ return Result.success(stream);
93
+ }
94
+ catch (error) {
95
+ return Result.failure(await this.handlePortalGenerationErrors(error, params));
96
+ }
97
+ }
98
+ async generateSdl(specPath, configDir) {
99
+ if (!(await fsExtra.pathExists(specPath))) {
100
+ return Result.failure("Spec file doesn't exist");
101
+ }
102
+ const authInfo = await getAuthInfo(configDir);
103
+ const authorizationHeader = this.createAuthorizationHeader(authInfo, null);
104
+ const client = this.createApiClient(authorizationHeader);
105
+ const transformationController = new TransformationController(client);
106
+ try {
107
+ const file = new FileWrapper(fs.createReadStream(specPath));
108
+ const generation = await transformationController.transformViaFile(ContentType.EnumMultipartformdata, file, ExportFormats.Apimatic);
109
+ if (!generation.result.success) {
110
+ return this.createGenericErrorResult();
111
+ }
112
+ const transformationId = generation.result.id;
113
+ const { result } = await transformationController.downloadTransformedFile(transformationId);
114
+ if (result.readable) {
115
+ return Result.success((await parseStreamBodyToJson(result)));
116
+ }
117
+ else {
118
+ return this.createGenericErrorResult();
119
+ }
120
+ }
121
+ catch (_a) {
122
+ return this.createGenericErrorResult();
123
+ }
124
+ }
125
+ createGenericErrorResult() {
126
+ return Result.failure("An unexpected error occurred");
127
+ }
128
+ }
129
+ //# sourceMappingURL=portal-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-service.js","sourceRoot":"","sources":["../../../src/infrastructure/services/portal-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,MAAM,EACN,yBAAyB,EACzB,mBAAmB,EACnB,WAAW,EAEX,QAAQ,EACR,wBAAwB,EAExB,aAAa,EACb,gCAAgC,EACjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAY,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAI/G,MAAM,OAAO,aAAa;IAA1B;QACmB,iBAAY,GAAG,WAAW,CAAC,qBAAqB,CAAC;QACjD,YAAO,GAAG,C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IAAI,CAAC,wBAAwB,EAAE,CAAC;YACzC,CAAC;YAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9C,MAAM,EAAE,MAAM,EAAE,GAAuB,MAAM,wBAAwB,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;YAChH,IAAK,MAAgC,CAAC,QAAQ,EAAE,CAAC;gBAC/C,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,qBAAqB,CAAC,MAA+B,CAAC,CAAQ,CAAC,CAAC;YAC/F,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACzC,CAAC;QACH,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACzC,CAAC;IACH,CAAC;IAEO,wBAAwB;QAC9B,OAAO,MAAM,CAAC,OAAO,CAAc,8BAA8B,CAAC,CAAC;IACrE,CAAC;CAuFF"}
@@ -0,0 +1,10 @@
1
+ export declare class PortalGeneratePrompts {
2
+ private readonly spin;
3
+ overwriteExistingPortalArtifactsPrompt(): Promise<boolean>;
4
+ existingDestinationPortalZipPrompt(): Promise<boolean>;
5
+ displayPortalGenerationMessage(): void;
6
+ displayPortalGenerationSuccessMessage(): void;
7
+ displayPortalGenerationErrorMessage(): void;
8
+ displayOutroMessage(generatedPortalPath: string): void;
9
+ logError(error: string): void;
10
+ }
@@ -0,0 +1,57 @@
1
+ import { cancel, outro, select, spinner, isCancel } from "@clack/prompts";
2
+ import { getMessageInRedColor } from "../../utils/utils.js";
3
+ export class PortalGeneratePrompts {
4
+ constructor() {
5
+ this.spin = spinner();
6
+ }
7
+ async overwriteExistingPortalArtifactsPrompt() {
8
+ const useExistingFolder = await select({
9
+ message: `The destination folder is not empty, do you want to overwrite the existing files?`,
10
+ options: [
11
+ { value: "yes", label: "Yes" },
12
+ { value: "no", label: "No" }
13
+ ]
14
+ });
15
+ if (isCancel(useExistingFolder)) {
16
+ cancel("Operation cancelled.");
17
+ return process.exit(1);
18
+ }
19
+ if (useExistingFolder === "no") {
20
+ outro("Please enter a different destination folder or remove the existing files and try again.");
21
+ }
22
+ return useExistingFolder === "yes";
23
+ }
24
+ async existingDestinationPortalZipPrompt() {
25
+ const useExistingZip = await select({
26
+ message: `A zip file already exists at the specified destination path, do you want to overwrite it?`,
27
+ options: [
28
+ { value: "yes", label: "Yes" },
29
+ { value: "no", label: "No" }
30
+ ]
31
+ });
32
+ if (isCancel(useExistingZip)) {
33
+ cancel("Operation cancelled.");
34
+ return process.exit(1);
35
+ }
36
+ if (useExistingZip === "no") {
37
+ outro("Please enter a different destination path or delete the existing zip file and try again.");
38
+ }
39
+ return useExistingZip === "yes";
40
+ }
41
+ displayPortalGenerationMessage() {
42
+ this.spin.start("Generating portal...");
43
+ }
44
+ displayPortalGenerationSuccessMessage() {
45
+ this.spin.stop("✅ Portal generated successfully.");
46
+ }
47
+ displayPortalGenerationErrorMessage() {
48
+ this.spin.stop(getMessageInRedColor(`Portal Generation failed.`));
49
+ }
50
+ displayOutroMessage(generatedPortalPath) {
51
+ outro(`The generated portal can be found at ${generatedPortalPath}`);
52
+ }
53
+ logError(error) {
54
+ outro(error);
55
+ }
56
+ }
57
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/prompts/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,OAAO,qBAAqB;IAAlC;QACmB,SAAI,GAAG,OAAO,EAAE,CAAC;IA+DpC,CAAC;IA7DC,KAAK,CAAC,sCAAsC;QAC1C,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC;YACrC,OAAO,EAAE,mFAAmF;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IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,mBAAmB,CAAC,mBAA2B;QAC7C,KAAK,CAAC,wCAAwC,mBAAmB,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,QAAQ,CAAC,KAAa;QACpB,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ export declare class PortalQuickstartPrompts {
2
+ private readonly spin;
3
+ private readonly vscodeExtensionUrl;
4
+ private readonly serverUrl;
5
+ private readonly referenceDocumentationUrl;
6
+ private readonly customizeTheSdksUrl;
7
+ private readonly defaultPortalDirectoryPath;
8
+ displayWelcomeMessage(): void;
9
+ loginPrompt(): Promise<{
10
+ email: string;
11
+ password: string;
12
+ }>;
13
+ displayLoggingInMessage(): void;
14
+ displayLoggingInErrorMessage(): void;
15
+ displayLoggedInMessage(): void;
16
+ specPrompt(): Promise<string>;
17
+ displaySpecValidationMessage(): void;
18
+ displaySpecValidationSuccessMessage(): void;
19
+ displaySpecValidationErrorMessage(): void;
20
+ displaySpecValidationFailureMessage(): void;
21
+ specValidationFailurePrompt(): Promise<void>;
22
+ sdkLanguagesPrompt(): Promise<string[]>;
23
+ buildDirectoryPrompt(): Promise<string>;
24
+ displayBuildDirectoryGenerationMessage(): void;
25
+ displayBuildDirectoryGenerationErrorMessage(): void;
26
+ displayBuildDirectoryGenerationSuccessMessage(targetFolder: string): void;
27
+ displayBuildDirectoryAsTree(targetFolder: string): void;
28
+ displayPortalGenerationMessage(): void;
29
+ displayPortalGenerationSuccessMessage(): void;
30
+ displayOutroMessage(directory: string): void;
31
+ }