@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,44 @@
1
+ var _a;
2
+ import * as path from "path";
3
+ import { Command, Flags } from "@oclif/core";
4
+ import { PortalRecipeAction } from "../../../actions/portal/recipe/new-recipe.js";
5
+ import { PortalRecipePrompts } from "../../../prompts/portal/recipe/new-recipe.js";
6
+ import { getMessageInRedColor } from "../../../utils/utils.js";
7
+ const DEFAULT_FOLDER = process.cwd();
8
+ class PortalNewRecipe extends Command {
9
+ async run() {
10
+ const { flags } = await this.parse(_a);
11
+ const portalRecipeAction = new PortalRecipeAction();
12
+ const portalRecipePrompts = new PortalRecipePrompts();
13
+ const createRecipeResult = await portalRecipeAction.createRecipe(flags.folder, this.config.configDir, flags["build-config"], flags.name);
14
+ if (createRecipeResult.isFailed()) {
15
+ portalRecipePrompts.logError(getMessageInRedColor(createRecipeResult.error));
16
+ }
17
+ if (createRecipeResult.isCancelled()) {
18
+ portalRecipePrompts.logError(getMessageInRedColor(createRecipeResult.value));
19
+ }
20
+ }
21
+ }
22
+ _a = PortalNewRecipe;
23
+ PortalNewRecipe.summary = "Generate an API Recipe for a static API Documentation portal.";
24
+ PortalNewRecipe.description = "To learn more about API Recipes, visit: https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes";
25
+ PortalNewRecipe.examples = [
26
+ `$ apimatic portal:recipe:new --name="My API Recipe" --folder="./build-folder" --build-config-file="./build-folder/APIMATIC-BUILD.json"
27
+ Generated recipe has been added to build directory at: C:/build-folder/`,
28
+ `$ apimatic portal:recipe:new
29
+ Generated recipe has been added to build directory at: C:/`
30
+ ];
31
+ PortalNewRecipe.flags = {
32
+ name: Flags.string({ description: "name for the recipe" }),
33
+ folder: Flags.string({
34
+ parse: async (input) => path.resolve(input),
35
+ description: "path to the build directory containing the specs folder, content folder, and the build config file. Defaults to the current working directory if not provided.",
36
+ default: DEFAULT_FOLDER
37
+ }),
38
+ "build-config": Flags.string({
39
+ parse: async (input) => path.resolve(input),
40
+ description: "path to the APIMATIC-BUILD.json file. Defaults to the APIMATIC-BUILD.json file in the build directory if not provided."
41
+ })
42
+ };
43
+ export default PortalNewRecipe;
44
+ //# 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,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AACrC,MAAqB,eAAgB,SAAQ,OAAO;IA0B3C,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAe,CAAC,CAAC;QACpD,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACpD,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAEtD,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,CAAC,YAAY,CAC9D,KAAK,CAAC,MAAM,EACZ,IAAI,CAAC,MAAM,CAAC,SAAS,EACrB,KAAK,CAAC,cAAc,CAAC,EACrB,KAAK,CAAC,IAAI,CACX,CAAC;QACF,IAAI,kBAAkB,CAAC,QAAQ,EAAE,EAAE,CAAC;YAClC,mBAAmB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,KAAM,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,kBAAkB,CAAC,WAAW,EAAE,EAAE,CAAC;YACrC,mBAAmB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,KAAM,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;;;AA1Ce,uBAAO,GAAG,+DAA+D,AAAlE,CAAmE;AAE1E,2BAAW,GAAG,uIAAuI,AAA1I,CAA2I;AAEtJ,wBAAQ,GAAG;IACzB;wEACoE;IACpE;2DACuD;CACxD,AALuB,CAKtB;AACc,qBAAK,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAC1D,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,KAAK,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnD,WAAW,EACT,gKAAgK;QAClK,OAAO,EAAE,cAAc;KACxB,CAAC;IACF,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC;QAC3B,KAAK,EAAE,KAAK,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnD,WAAW,EACT,wHAAwH;KAC3H,CAAC;CACH,AAboB,CAanB;eAxBiB,eAAe"}
@@ -0,0 +1,16 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class PortalServe extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
6
+ destination: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ source: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ "no-reload": import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ ignore: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ static examples: string[];
14
+ run(): Promise<void>;
15
+ private handleError;
16
+ }
@@ -0,0 +1,135 @@
1
+ var _a;
2
+ import * as path from "path";
3
+ import axios from "axios";
4
+ import { Command, Flags } from "@oclif/core";
5
+ import { generatePortal } from "../../controllers/portal/serve.js";
6
+ import { PortalServerService } from "../../services/portal/server.js";
7
+ import { PortalServePrompts } from "../../prompts/portal/serve.js";
8
+ import { cleanUpGeneratedPortalFiles, getGeneratedFilesPaths, getMessageInRedColor } from "../../utils/utils.js";
9
+ import { PortalServeValidator } from "../../validators/portal/serveValidator.js";
10
+ class PortalServe extends Command {
11
+ async run() {
12
+ var _b;
13
+ const { flags } = await this.parse(_a);
14
+ const ignoredPaths = flags.ignore.split(",").map((path) => path.trim());
15
+ const portalDir = path.resolve(flags.destination);
16
+ const sourceDir = path.resolve(flags.source);
17
+ const port = flags.port;
18
+ const overrideAuthKey = (_b = flags["auth-key"]) !== null && _b !== void 0 ? _b : null;
19
+ const serverService = new PortalServerService();
20
+ const prompts = new PortalServePrompts();
21
+ const validator = new PortalServeValidator(this.error);
22
+ const allIgnoredPaths = [...ignoredPaths, ...getGeneratedFilesPaths(sourceDir, portalDir)];
23
+ await validator.validate(port, flags.destination, sourceDir, portalDir);
24
+ try {
25
+ prompts.displayGeneratingPortalMessage();
26
+ await generatePortal(sourceDir, portalDir, this.config.configDir, allIgnoredPaths, overrideAuthKey);
27
+ prompts.displayGeneratedPortalMessage(portalDir);
28
+ await cleanUpGeneratedPortalFiles(sourceDir);
29
+ }
30
+ catch (error) {
31
+ prompts.displayGeneratingPortalErrorMessage();
32
+ await cleanUpGeneratedPortalFiles(sourceDir);
33
+ this.handleError(error);
34
+ }
35
+ serverService.setupServer(portalDir);
36
+ serverService.startServer({
37
+ generatedPortalPath: portalDir,
38
+ targetFolder: sourceDir,
39
+ configDir: this.config.configDir,
40
+ authKey: overrideAuthKey,
41
+ ignoredPaths: allIgnoredPaths,
42
+ port,
43
+ openInBrowser: flags.open
44
+ }, flags["no-reload"]);
45
+ prompts.displayOutroMessage(port);
46
+ }
47
+ handleError(error) {
48
+ if (axios.isAxiosError(error)) {
49
+ const axiosError = error;
50
+ if (axiosError.response) {
51
+ if (axiosError.response.status === 400) {
52
+ this.error(getMessageInRedColor(`Failed to generate the portal. Please ensure that the provided build directory follows the correct structure and contains valid API definition and build files.`));
53
+ }
54
+ else if (axiosError.response.status === 401) {
55
+ this.error(getMessageInRedColor(`Failed to generate the portal. Please ensure that you are logged in or have provided a valid Auth key.`));
56
+ }
57
+ else if (axiosError.response.status === 403) {
58
+ this.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.`));
59
+ }
60
+ else if (axiosError.response.status === 422) {
61
+ this.error(getMessageInRedColor(`Failed to generate the portal. Please ensure that the provided build directory follows the correct structure and contains valid API definition and build files.`));
62
+ }
63
+ else if (axiosError.response.status === 500) {
64
+ this.error(getMessageInRedColor(`Failed to generate 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`));
65
+ }
66
+ else {
67
+ this.error(getMessageInRedColor(`Failed to generate 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`));
68
+ }
69
+ }
70
+ else if (axiosError.request) {
71
+ if (axiosError.code === "ECONNABORTED") {
72
+ this.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.`));
73
+ }
74
+ else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
75
+ this.error(getMessageInRedColor(`Network error. Please check your internet connection and try again.`));
76
+ }
77
+ else {
78
+ this.error(getMessageInRedColor(`No response received from the server. Please try again later.`));
79
+ }
80
+ }
81
+ else {
82
+ this.error(getMessageInRedColor(`Failed to generate the portal: ${axiosError.message}`));
83
+ }
84
+ }
85
+ else if (error instanceof Error) {
86
+ this.error(getMessageInRedColor(`Failed to generate the portal: ${error.message}`));
87
+ }
88
+ else {
89
+ this.error(getMessageInRedColor(`Something went wrong while generating the portal, please try again later. If the issue persists, contact our team at support@apimatic.io`));
90
+ }
91
+ }
92
+ }
93
+ _a = PortalServe;
94
+ PortalServe.description = "Generate and deploy a Docs as Code portal with hot reload.";
95
+ PortalServe.flags = {
96
+ port: Flags.integer({
97
+ char: "p",
98
+ description: "Port to serve the portal.",
99
+ default: 3000
100
+ }),
101
+ destination: Flags.string({
102
+ char: "d",
103
+ description: "Directory to store and serve the generated portal.",
104
+ default: "./generated_portal",
105
+ parse: async (input) => path.resolve(input)
106
+ }),
107
+ source: Flags.string({
108
+ char: "s",
109
+ description: "Source directory containing specs, content, and build file. By default, the current directory is used.",
110
+ default: "./",
111
+ parse: async (input) => path.resolve(input)
112
+ }),
113
+ open: Flags.boolean({
114
+ char: "o",
115
+ description: "Open the portal in the default browser.",
116
+ default: false
117
+ }),
118
+ "no-reload": Flags.boolean({
119
+ description: "Disable hot reload.",
120
+ default: false
121
+ }),
122
+ ignore: Flags.string({
123
+ char: "i",
124
+ description: "Comma-separated list of files/directories to ignore.",
125
+ default: ""
126
+ }),
127
+ "auth-key": Flags.string({
128
+ description: "Override current authentication state with an authentication key."
129
+ })
130
+ };
131
+ PortalServe.examples = [
132
+ '$ apimatic portal:serve --source="./" --destination="./generated_portal" --port=3000 --open --no-reload'
133
+ ];
134
+ export default PortalServe;
135
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/portal/serve.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA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CAAC;QACnB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,sDAAsD;QACnE,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,WAAW,EAAE,mEAAmE;KACjF,CAAC;CACH,AApCW,CAoCV;AAEK,oBAAQ,GAAG;IAChB,yGAAyG;CAC1G,AAFc,CAEb;eA3CiB,WAAW"}
@@ -0,0 +1,15 @@
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
+ destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ folder: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ "expand-endpoints": import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ "expand-models": import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static examples: string[];
13
+ constructor(argv: string[], config: any);
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,63 @@
1
+ var _a;
2
+ import * as path from "path";
3
+ import { Command, Flags } from "@oclif/core";
4
+ import { PortalNewTocAction } from "../../../actions/portal/toc/new-toc.js";
5
+ const DEFAULT_FOLDER = process.cwd();
6
+ class PortalTocNew extends Command {
7
+ constructor(argv, config) {
8
+ super(argv, config);
9
+ }
10
+ async run() {
11
+ const { flags } = await this.parse(_a);
12
+ const portalNewTocAction = new PortalNewTocAction();
13
+ const result = await portalNewTocAction.createToc(flags.folder, this.config.configDir, flags.destination, flags.force, flags["expand-endpoints"], flags["expand-models"]);
14
+ if (result.isFailed()) {
15
+ this.error(result.error);
16
+ }
17
+ }
18
+ }
19
+ _a = PortalTocNew;
20
+ PortalTocNew.summary = 'Generates a TOC file based on the content directory and spec folder provided in your working directory';
21
+ PortalTocNew.description = `This command generates a new Table of Contents (TOC) file used in the
22
+ generation of your API documentation portal.
23
+
24
+ The output is a YAML file with the .yml extension.
25
+
26
+ To learn more about the TOC file and APIMatic build directory structure, visit:
27
+ https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/overview-generating-api-portal`;
28
+ PortalTocNew.flags = {
29
+ destination: Flags.string({
30
+ parse: async (input) => path.resolve(input),
31
+ description: "optional path where the generated TOC file will be saved. Defaults to the current working directory if not provided.",
32
+ }),
33
+ folder: Flags.string({
34
+ parse: async (input) => path.resolve(input),
35
+ description: "path to the working directory containing the API project files. Defaults to the current working directory if not specified.",
36
+ default: DEFAULT_FOLDER
37
+ }),
38
+ force: Flags.boolean({
39
+ default: false,
40
+ description: "overwrite the TOC file if one already exists at the destination.",
41
+ }),
42
+ "expand-endpoints": Flags.boolean({
43
+ default: false,
44
+ description: "include individual entries for each endpoint in the generated TOC. Requires a valid API specification in the working directory."
45
+ }),
46
+ "expand-models": Flags.boolean({
47
+ default: false,
48
+ description: "include individual entries for each model in the generated TOC. Requires a valid API specification in the working directory."
49
+ })
50
+ };
51
+ PortalTocNew.examples = [
52
+ `$ apimatic portal:toc:new --destination="./portal/content/"
53
+ A new toc file has been created at ./portal/content/toc.yml
54
+ `,
55
+ `$ apimatic portal:toc:new --folder="./my-project"
56
+ A new toc file has been created at ./my-project/content/toc.yml
57
+ `,
58
+ `$ apimatic portal:toc:new --folder="./my-project" --destination="./portal/content/"
59
+ A new toc file has been created at ./portal/content/toc.yml
60
+ `
61
+ ];
62
+ export default PortalTocNew;
63
+ //# 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,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,MAAM,cA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AK;QACd,WAAW,EAAE,kEAAkE;KAChF,CAAC;IACF,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC;QAChC,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iIAAiI;KAC/I,CAAC;IACF,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC;QAC7B,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,8HAA8H;KAC5I,CAAC;CACH,AAtBW,CAsBV;AAEK,qBAAQ,GAAG;IAChB;;CAEH;IACG;;CAEH;IACG;;CAEH;CACE,AAVc,CAUb;eA7CiB,YAAY"}
@@ -1,14 +1,14 @@
1
- import { Command, flags } from "@oclif/command";
1
+ import { Command } from "@oclif/core";
2
2
  export default class SdkGenerate extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
- platform: flags.IOptionFlag<string>;
6
- file: flags.IOptionFlag<string>;
7
- url: flags.IOptionFlag<string>;
8
- destination: flags.IOptionFlag<string>;
9
- force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
- zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
11
- "auth-key": flags.IOptionFlag<string>;
5
+ platform: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
+ file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ url: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ destination: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ "auth-key": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
12
  };
13
13
  static examples: string[];
14
14
  run(): Promise<void>;
@@ -1,38 +1,37 @@
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
+ var _a;
2
+ import * as path from "path";
3
+ import fsExtra from "fs-extra";
4
+ import { Command, Flags } from "@oclif/core";
5
+ import { SDKClient } from "../../client-utils/sdk-client.js";
6
+ import { CodeGenerationExternalApIsController } from "@apimatic/sdk";
7
+ import { replaceHTML, isJSONParsable, getFileNameFromPath } from "../../utils/utils.js";
8
+ import { getSDKGenerationId, downloadGeneratedSDK } from "../../controllers/sdk/generate.js";
9
+ class SdkGenerate extends Command {
11
10
  async run() {
12
- const { flags } = this.parse(SdkGenerate);
11
+ const { flags } = await this.parse(_a);
13
12
  const zip = flags.zip;
14
- const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
13
+ const fileName = flags.file ? getFileNameFromPath(flags.file) : getFileNameFromPath(flags.url);
15
14
  const sdkFolderPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}`.toLowerCase());
16
15
  const zippedSDKPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}.zip`.toLowerCase());
17
16
  // 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) {
17
+ if (fsExtra.existsSync(sdkFolderPath) && !flags.force && !zip) {
19
18
  throw new Error(`Can't download SDK to path ${sdkFolderPath}, because it already exists`);
20
19
  }
21
- else if (fs.existsSync(zippedSDKPath) && !flags.force && zip) {
20
+ else if (fsExtra.existsSync(zippedSDKPath) && !flags.force && zip) {
22
21
  throw new Error(`Can't download SDK to path ${zippedSDKPath}, because it already exists`);
23
22
  }
24
23
  try {
25
- if (!(await fs.pathExists(path.resolve(flags.destination)))) {
24
+ if (!(await fsExtra.pathExists(path.resolve(flags.destination)))) {
26
25
  throw new Error(`Destination path ${flags.destination} does not exist`);
27
26
  }
28
- else if (!(await fs.pathExists(path.resolve(flags.file)))) {
27
+ else if (!(await fsExtra.pathExists(path.resolve(flags.file)))) {
29
28
  throw new Error(`Specification file ${flags.file} does not exist`);
30
29
  }
31
30
  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);
31
+ const client = await SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
32
+ const sdkGenerationController = new CodeGenerationExternalApIsController(client);
34
33
  // Get generation id for the specification and platform
35
- const codeGenId = await generate_1.getSDKGenerationId(flags, sdkGenerationController);
34
+ const codeGenId = await getSDKGenerationId(flags, sdkGenerationController);
36
35
  // If user wanted to download the SDK as well
37
36
  const sdkDownloadParams = {
38
37
  codeGenId,
@@ -40,17 +39,17 @@ class SdkGenerate extends command_1.Command {
40
39
  sdkFolderPath,
41
40
  zip
42
41
  };
43
- const sdkPath = await generate_1.downloadGeneratedSDK(sdkDownloadParams, sdkGenerationController);
42
+ const sdkPath = await downloadGeneratedSDK(sdkDownloadParams, sdkGenerationController);
44
43
  this.log(`Success! Your SDK is located at ${sdkPath}`);
45
44
  }
46
45
  catch (error) {
47
46
  if (error.result) {
48
47
  const apiError = error;
49
48
  const result = apiError.result;
50
- if (apiError.statusCode === 400 && utils_1.isJSONParsable(result.message)) {
49
+ if (apiError.statusCode === 400 && isJSONParsable(result.message)) {
51
50
  const errors = JSON.parse(result.message);
52
51
  if (Array.isArray(errors.Errors) && apiError.statusCode === 400) {
53
- this.error(utils_1.replaceHTML(`${JSON.parse(result.message).Errors[0]}`));
52
+ this.error(replaceHTML(`${JSON.parse(result.message).Errors[0]}`));
54
53
  }
55
54
  }
56
55
  else if (apiError.statusCode === 401 && apiError.body && typeof apiError.body === "string") {
@@ -59,17 +58,17 @@ class SdkGenerate extends command_1.Command {
59
58
  else if (apiError.statusCode === 500 &&
60
59
  apiError.body &&
61
60
  typeof apiError.body === "string" &&
62
- utils_1.isJSONParsable(apiError.body)) {
61
+ isJSONParsable(apiError.body)) {
63
62
  this.error(JSON.parse(apiError.body).message);
64
63
  }
65
64
  else if (apiError.statusCode === 422 &&
66
65
  apiError.body &&
67
66
  typeof apiError.body === "string" &&
68
- utils_1.isJSONParsable(apiError.body)) {
67
+ isJSONParsable(apiError.body)) {
69
68
  this.error(JSON.parse(apiError.body)["dto.Url"][0]);
70
69
  }
71
70
  else {
72
- this.error(utils_1.replaceHTML(result.message));
71
+ this.error(replaceHTML(result.message));
73
72
  }
74
73
  }
75
74
  else if (error.statusCode === 401) {
@@ -78,7 +77,7 @@ class SdkGenerate extends command_1.Command {
78
77
  else if (error.statusCode === 402 &&
79
78
  error.body &&
80
79
  typeof error.body === "string") {
81
- this.error(utils_1.replaceHTML(error.body));
80
+ this.error(replaceHTML(error.body));
82
81
  }
83
82
  else {
84
83
  this.error(`${error.message}`);
@@ -86,39 +85,37 @@ class SdkGenerate extends command_1.Command {
86
85
  }
87
86
  }
88
87
  }
89
- exports.default = SdkGenerate;
88
+ _a = SdkGenerate;
90
89
  SdkGenerate.description = "Generate SDK for your APIs";
91
90
  SdkGenerate.flags = {
92
- platform: command_1.flags.string({
93
- parse: (input) => input.toUpperCase(),
91
+ platform: Flags.string({
92
+ parse: async (input) => input.toUpperCase(),
94
93
  required: true,
95
94
  description: `language platform for sdk
96
- Simple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT
97
- Legacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LIB|
98
- JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|
99
- TS_GENERIC_LIB`
95
+ Simple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT|GO
96
+ Legacy: CS_NET_STANDARD_LIB|JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB_V2|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|TS_GENERIC_LIB|GO_GENERIC_LIB`
100
97
  }),
101
- file: command_1.flags.string({
102
- parse: (input) => path.resolve(input),
98
+ file: Flags.string({
99
+ parse: async (input) => path.resolve(input),
103
100
  default: "",
104
101
  description: "path to the API specification to generate SDKs for"
105
102
  }),
106
- url: command_1.flags.string({
103
+ url: Flags.string({
107
104
  default: "",
108
105
  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."
109
106
  }),
110
- destination: command_1.flags.string({
111
- parse: (input) => path.resolve(input),
107
+ destination: Flags.string({
108
+ parse: async (input) => path.resolve(input),
112
109
  default: path.resolve("./"),
113
110
  description: "directory to download the generated SDK to"
114
111
  }),
115
- force: command_1.flags.boolean({
112
+ force: Flags.boolean({
116
113
  char: "f",
117
114
  default: false,
118
115
  description: "overwrite if an SDK already exists in the destination"
119
116
  }),
120
- zip: command_1.flags.boolean({ default: false, description: "download the generated SDK as a .zip archive" }),
121
- "auth-key": command_1.flags.string({
117
+ zip: Flags.boolean({ default: false, description: "download the generated SDK as a .zip archive" }),
118
+ "auth-key": Flags.string({
122
119
  default: "",
123
120
  description: "override current authentication state with an authentication key"
124
121
  })
@@ -135,3 +132,5 @@ Downloading SDK... done
135
132
  Success! Your SDK is located at swagger_sdk_csharp
136
133
  `
137
134
  ];
135
+ export default SdkGenerate;
136
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/sdk/generate.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AA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CAAC,MAAM,CAAC;QACxB,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3B,WAAW,EAAE,4CAA4C;KAC1D,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,uDAAuD;KACrE,CAAC;IACF,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IACnG,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,kEAAkE;KAChF,CAAC;CACH,AAjCW,CAiCV;AAEK,oBAAQ,GAAG;IAChB;;;mDAG+C;IAC/C;;;;;CAKH;CACE,AAXc,CAWb;eAhDiB,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"}
@@ -1 +1,27 @@
1
- export declare const baseURL = "https://www.apimatic.io/api";
1
+ export declare const baseURL = "https://api.apimatic.io";
2
+ export declare const staticPortalRepoUrl = "https://github.com/apimatic/static-portal-workflow.git";
3
+ export declare const metadataFileContent: {
4
+ ImportSettings: {
5
+ AutoGenerateTestCases: boolean;
6
+ ImportAdditionalHeader: boolean;
7
+ ImportAdditionalTypeCombinatorModels: boolean;
8
+ ImportTypeCombinatorsWithOnlyOneType: boolean;
9
+ };
10
+ CodeGenSettings: {
11
+ Timeout: number;
12
+ ValidateRequiredParameters: boolean;
13
+ AddSingleAuthDeprecatedCode: boolean;
14
+ EnableGlobalUserAgent: boolean;
15
+ UserAgent: string;
16
+ EnableLogging: boolean;
17
+ EnableModelKeywordArgsInRuby: boolean;
18
+ SymbolizeHashKeysInRuby: boolean;
19
+ ReturnCompleteHttpResponse: boolean;
20
+ UserConfigurableRetries: boolean;
21
+ UseEnumPrefix: boolean;
22
+ ExtendedAdditionalPropertiesSupport: boolean;
23
+ EnforceStandardizedCasing: boolean;
24
+ ControllerPostfix: string;
25
+ DoNotSplitWords: string[];
26
+ };
27
+ };
package/lib/config/env.js CHANGED
@@ -1,4 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.baseURL = void 0;
4
- exports.baseURL = "https://www.apimatic.io/api";
1
+ export const baseURL = "https://api.apimatic.io";
2
+ export const staticPortalRepoUrl = "https://github.com/apimatic/static-portal-workflow.git";
3
+ export const metadataFileContent = {
4
+ ImportSettings: {
5
+ AutoGenerateTestCases: false,
6
+ ImportAdditionalHeader: false,
7
+ ImportAdditionalTypeCombinatorModels: false,
8
+ ImportTypeCombinatorsWithOnlyOneType: false
9
+ },
10
+ CodeGenSettings: {
11
+ Timeout: 30,
12
+ ValidateRequiredParameters: true,
13
+ AddSingleAuthDeprecatedCode: false,
14
+ EnableGlobalUserAgent: true,
15
+ UserAgent: "{language}-SDK/{version} [OS: {os-info}, Engine: {engine}/{engine-version}]",
16
+ EnableLogging: true,
17
+ EnableModelKeywordArgsInRuby: true,
18
+ SymbolizeHashKeysInRuby: true,
19
+ ReturnCompleteHttpResponse: true,
20
+ UserConfigurableRetries: true,
21
+ UseEnumPrefix: false,
22
+ ExtendedAdditionalPropertiesSupport: true,
23
+ EnforceStandardizedCasing: true,
24
+ ControllerPostfix: "Api",
25
+ DoNotSplitWords: ["oauth"]
26
+ }
27
+ };
28
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,wDAAwD,CAAC;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,cAAc,EAAE;QACd,qBAAqB,EAAE,KAAK;QAC5B,sBAAsB,EAAE,KAAK;QAC7B,oCAAoC,EAAE,KAAK;QAC3C,oCAAoC,EAAE,KAAK;KAC5C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,EAAE;QACX,0BAA0B,EAAE,IAAI;QAChC,2BAA2B,EAAE,KAAK;QAClC,qBAAqB,EAAE,IAAI;QAC3B,SAAS,EAAE,6EAA6E;QACxF,aAAa,EAAE,IAAI;QACnB,4BAA4B,EAAE,IAAI;QAClC,uBAAuB,EAAE,IAAI;QAC7B,0BAA0B,EAAE,IAAI;QAChC,uBAAuB,EAAE,IAAI;QAC7B,aAAa,EAAE,KAAK;QACpB,mCAAmC,EAAE,IAAI;QACzC,yBAAyB,EAAE,IAAI;QAC/B,iBAAiB,EAAE,KAAK;QACxB,eAAe,EAAE,CAAC,OAAO,CAAC;KAC3B;CACF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform";
1
+ import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform.js";
2
2
  import { ExportFormats, Transformation, TransformationController } from "@apimatic/sdk";
3
3
  export declare const getTransformationId: ({ file, url, format }: TransformationIdParams, transformationController: TransformationController) => Promise<Transformation>;
4
4
  export declare const downloadTransformationFile: ({ id, destinationFilePath, transformationController }: DownloadTransformationParams) => Promise<string>;