@apimatic/cli 1.1.0-alpha.21 → 1.1.0-alpha.22
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.
- package/README.md +112 -90
- package/lib/actions/action-result.d.ts +8 -3
- package/lib/actions/action-result.js +34 -15
- package/lib/actions/action-result.js.map +1 -1
- package/lib/actions/api/transform.d.ts +15 -0
- package/lib/actions/api/transform.js +48 -0
- package/lib/actions/api/transform.js.map +1 -0
- package/lib/actions/api/validate.d.ts +12 -0
- package/lib/actions/api/validate.js +41 -0
- package/lib/actions/api/validate.js.map +1 -0
- package/lib/actions/auth/login.d.ts +6 -5
- package/lib/actions/auth/login.js +25 -33
- package/lib/actions/auth/login.js.map +1 -1
- package/lib/actions/auth/logout.d.ts +8 -0
- package/lib/actions/auth/logout.js +15 -0
- package/lib/actions/auth/logout.js.map +1 -0
- package/lib/actions/auth/status.d.ts +11 -0
- package/lib/actions/auth/status.js +26 -0
- package/lib/actions/auth/status.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +5 -3
- package/lib/actions/portal/copilot.js +47 -37
- package/lib/actions/portal/copilot.js.map +1 -1
- package/lib/actions/portal/generate.d.ts +4 -5
- package/lib/actions/portal/generate.js +30 -37
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/quickstart.d.ts +16 -0
- package/lib/actions/portal/quickstart.js +145 -0
- package/lib/actions/portal/quickstart.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +11 -20
- package/lib/actions/portal/recipe/new-recipe.js +147 -221
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
- package/lib/actions/portal/serve.d.ts +12 -10
- package/lib/actions/portal/serve.js +112 -17
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/portal/toc/new-toc.d.ts +16 -15
- package/lib/actions/portal/toc/new-toc.js +80 -116
- package/lib/actions/portal/toc/new-toc.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +5 -6
- package/lib/actions/sdk/generate.js +22 -47
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/application/portal/recipe/portal-recipe.d.ts +2 -2
- package/lib/application/portal/recipe/portal-recipe.js +9 -9
- package/lib/application/portal/recipe/portal-recipe.js.map +1 -1
- package/lib/application/portal/recipe/recipe-generator.d.ts +7 -2
- package/lib/application/portal/recipe/recipe-generator.js +21 -22
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -1
- package/lib/client-utils/auth-manager.d.ts +1 -1
- package/lib/client-utils/auth-manager.js +3 -4
- package/lib/client-utils/auth-manager.js.map +1 -1
- package/lib/commands/api/transform.d.ts +6 -3
- package/lib/commands/api/transform.js +43 -94
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.d.ts +6 -3
- package/lib/commands/api/validate.js +27 -66
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.d.ts +2 -1
- package/lib/commands/auth/login.js +15 -9
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.d.ts +3 -1
- package/lib/commands/auth/logout.js +12 -13
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.d.ts +1 -0
- package/lib/commands/auth/status.js +13 -11
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/portal/copilot.d.ts +2 -2
- package/lib/commands/portal/copilot.js +22 -20
- package/lib/commands/portal/copilot.js.map +1 -1
- package/lib/commands/portal/generate.d.ts +3 -4
- package/lib/commands/portal/generate.js +19 -14
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/quickstart.d.ts +3 -4
- package/lib/commands/portal/quickstart.js +24 -101
- package/lib/commands/portal/quickstart.js.map +1 -1
- package/lib/commands/portal/recipe/new.d.ts +3 -1
- package/lib/commands/portal/recipe/new.js +31 -23
- package/lib/commands/portal/recipe/new.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +5 -5
- package/lib/commands/portal/serve.js +31 -57
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/portal/toc/new.d.ts +2 -2
- package/lib/commands/portal/toc/new.js +35 -26
- package/lib/commands/portal/toc/new.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +5 -4
- package/lib/commands/sdk/generate.js +26 -17
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/hooks/not-found.js +1 -1
- package/lib/hooks/not-found.js.map +1 -1
- package/lib/infrastructure/api-utils.js +3 -2
- package/lib/infrastructure/api-utils.js.map +1 -1
- package/lib/{application/portal/serve/watcher-handler.d.ts → infrastructure/debounce-service.d.ts} +3 -3
- package/lib/{application/portal/serve/watcher-handler.js → infrastructure/debounce-service.js} +5 -4
- package/lib/infrastructure/debounce-service.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +1 -1
- package/lib/infrastructure/env-info.js +2 -2
- package/lib/infrastructure/env-info.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +7 -2
- package/lib/infrastructure/file-service.js +46 -5
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/launcher-service.d.ts +2 -0
- package/lib/infrastructure/launcher-service.js +4 -0
- package/lib/infrastructure/launcher-service.js.map +1 -1
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +7 -0
- package/lib/infrastructure/network-service.js.map +1 -0
- package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
- package/lib/infrastructure/services/api-client-factory.js +20 -0
- package/lib/infrastructure/services/api-client-factory.js.map +1 -0
- package/lib/infrastructure/services/api-service.d.ts +2 -2
- package/lib/infrastructure/services/api-service.js +6 -6
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/auth-service.d.ts +1 -1
- package/lib/infrastructure/services/auth-service.js +7 -5
- package/lib/infrastructure/services/auth-service.js.map +1 -1
- package/lib/infrastructure/services/file-download-service.d.ts +15 -0
- package/lib/infrastructure/services/file-download-service.js +104 -0
- package/lib/infrastructure/services/file-download-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +11 -13
- package/lib/infrastructure/services/portal-service.js +73 -102
- package/lib/infrastructure/services/portal-service.js.map +1 -1
- package/lib/infrastructure/services/telemetry-service.d.ts +3 -2
- package/lib/infrastructure/services/telemetry-service.js +4 -6
- package/lib/infrastructure/services/telemetry-service.js.map +1 -1
- package/lib/infrastructure/services/transformation-service.d.ts +23 -0
- package/lib/infrastructure/services/transformation-service.js +56 -0
- package/lib/infrastructure/services/transformation-service.js.map +1 -0
- package/lib/infrastructure/services/validation-service.d.ts +17 -0
- package/lib/infrastructure/services/validation-service.js +49 -0
- package/lib/infrastructure/services/validation-service.js.map +1 -0
- package/lib/prompts/api/transform.d.ts +11 -0
- package/lib/prompts/api/transform.js +30 -0
- package/lib/prompts/api/transform.js.map +1 -0
- package/lib/prompts/api/validate.d.ts +12 -0
- package/lib/prompts/api/validate.js +41 -0
- package/lib/prompts/api/validate.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +6 -1
- package/lib/prompts/auth/login.js +12 -3
- package/lib/prompts/auth/login.js.map +1 -1
- package/lib/prompts/auth/logout.d.ts +3 -0
- package/lib/prompts/auth/logout.js +7 -0
- package/lib/prompts/auth/logout.js.map +1 -0
- package/lib/prompts/auth/status.d.ts +8 -0
- package/lib/prompts/auth/status.js +21 -0
- package/lib/prompts/auth/status.js.map +1 -0
- package/lib/prompts/format.d.ts +33 -0
- package/lib/prompts/format.js +99 -0
- package/lib/prompts/format.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +8 -4
- package/lib/prompts/portal/copilot.js +35 -24
- package/lib/prompts/portal/copilot.js.map +1 -1
- package/lib/prompts/portal/generate.d.ts +9 -7
- package/lib/prompts/portal/generate.js +22 -23
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +30 -29
- package/lib/prompts/portal/quickstart.js +99 -193
- package/lib/prompts/portal/quickstart.js.map +1 -1
- package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -18
- package/lib/prompts/portal/recipe/new-recipe.js +70 -108
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
- package/lib/prompts/portal/serve.d.ts +10 -3
- package/lib/prompts/portal/serve.js +30 -11
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +12 -8
- package/lib/prompts/portal/toc/new-toc.js +20 -22
- package/lib/prompts/portal/toc/new-toc.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +7 -7
- package/lib/prompts/sdk/generate.js +17 -23
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/types/api/account.d.ts +1 -1
- package/lib/types/api/transform.d.ts +14 -25
- package/lib/types/api/transform.js +16 -16
- package/lib/types/api/transform.js.map +1 -1
- package/lib/types/build/build.d.ts +9 -1
- package/lib/types/build/build.js +5 -2
- package/lib/types/build/build.js.map +1 -1
- package/lib/types/build-context.d.ts +5 -1
- package/lib/types/build-context.js +21 -4
- package/lib/types/build-context.js.map +1 -1
- package/lib/types/common/command-metadata.d.ts +4 -0
- package/lib/types/common/command-metadata.js +2 -0
- package/lib/types/common/command-metadata.js.map +1 -0
- package/lib/types/events/domain-event.d.ts +1 -1
- package/lib/types/events/domain-event.js.map +1 -1
- package/lib/types/events/quickstart-completed.js +1 -1
- package/lib/types/events/quickstart-initiated.js +1 -1
- package/lib/types/events/recipe-creation-failed.d.ts +1 -1
- package/lib/types/events/recipe-creation-failed.js +1 -1
- package/lib/types/events/recipe-creation-failed.js.map +1 -1
- package/lib/types/events/toc-creation-failed.d.ts +1 -1
- package/lib/types/events/toc-creation-failed.js +1 -1
- package/lib/types/events/toc-creation-failed.js.map +1 -1
- package/lib/types/file/directory.d.ts +17 -0
- package/lib/types/file/directory.js +86 -0
- package/lib/types/file/directory.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +3 -1
- package/lib/types/file/directoryPath.js +8 -2
- package/lib/types/file/directoryPath.js.map +1 -1
- package/lib/types/file/fileName.d.ts +2 -0
- package/lib/types/file/fileName.js +12 -0
- package/lib/types/file/fileName.js.map +1 -1
- package/lib/types/file/filePath.d.ts +2 -0
- package/lib/types/file/filePath.js +21 -0
- package/lib/types/file/filePath.js.map +1 -1
- package/lib/types/file/resource-input.d.ts +5 -0
- package/lib/types/file/resource-input.js +42 -0
- package/lib/types/file/resource-input.js.map +1 -0
- package/lib/types/file/urlPath.d.ts +6 -0
- package/lib/types/file/urlPath.js +22 -0
- package/lib/types/file/urlPath.js.map +1 -0
- package/lib/types/portal-context.d.ts +3 -1
- package/lib/types/portal-context.js +10 -0
- package/lib/types/portal-context.js.map +1 -1
- package/lib/types/recipe/recipe.d.ts +2 -17
- package/lib/types/recipe-context.d.ts +8 -0
- package/lib/types/recipe-context.js +21 -0
- package/lib/types/recipe-context.js.map +1 -0
- package/lib/types/resource-context.d.ts +12 -0
- package/lib/types/resource-context.js +30 -0
- package/lib/types/resource-context.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +2 -15
- package/lib/types/sdk/generate.js +24 -10
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk-context.d.ts +6 -5
- package/lib/types/sdk-context.js +12 -8
- package/lib/types/sdk-context.js.map +1 -1
- package/lib/types/sdl/sdl.d.ts +9 -0
- package/lib/types/sdl/sdl.js +46 -1
- package/lib/types/sdl/sdl.js.map +1 -1
- package/lib/types/spec-context.d.ts +3 -0
- package/lib/types/spec-context.js +7 -2
- package/lib/types/spec-context.js.map +1 -1
- package/lib/types/temp-context.d.ts +11 -0
- package/lib/types/temp-context.js +27 -0
- package/lib/types/temp-context.js.map +1 -0
- package/lib/types/toc-context.d.ts +12 -0
- package/lib/types/toc-context.js +26 -0
- package/lib/types/toc-context.js.map +1 -0
- package/lib/types/transform-context.d.ts +13 -0
- package/lib/types/transform-context.js +30 -0
- package/lib/types/transform-context.js.map +1 -0
- package/lib/types/utils.d.ts +0 -9
- package/lib/utils/string-utils.d.ts +1 -0
- package/lib/utils/string-utils.js +10 -0
- package/lib/utils/string-utils.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -27
- package/lib/utils/utils.js +6 -145
- package/lib/utils/utils.js.map +1 -1
- package/package.json +4 -4
- package/lib/application/portal/serve/portal-watcher.d.ts +0 -11
- package/lib/application/portal/serve/portal-watcher.js +0 -64
- package/lib/application/portal/serve/portal-watcher.js.map +0 -1
- package/lib/application/portal/serve/serve-handler.d.ts +0 -16
- package/lib/application/portal/serve/serve-handler.js +0 -91
- package/lib/application/portal/serve/serve-handler.js.map +0 -1
- package/lib/application/portal/serve/watcher-handler.js.map +0 -1
- package/lib/application/portal/toc/sdl-parser.d.ts +0 -19
- package/lib/application/portal/toc/sdl-parser.js +0 -90
- package/lib/application/portal/toc/sdl-parser.js.map +0 -1
- package/lib/client-utils/sdk-client.d.ts +0 -18
- package/lib/client-utils/sdk-client.js +0 -41
- package/lib/client-utils/sdk-client.js.map +0 -1
- package/lib/config/env.d.ts +0 -26
- package/lib/config/env.js +0 -27
- package/lib/config/env.js.map +0 -1
- package/lib/controllers/api/transform.d.ts +0 -5
- package/lib/controllers/api/transform.js +0 -50
- package/lib/controllers/api/transform.js.map +0 -1
- package/lib/controllers/api/validate.d.ts +0 -3
- package/lib/controllers/api/validate.js +0 -29
- package/lib/controllers/api/validate.js.map +0 -1
- package/lib/controllers/portal/quickstart.d.ts +0 -13
- package/lib/controllers/portal/quickstart.js +0 -214
- package/lib/controllers/portal/quickstart.js.map +0 -1
- package/lib/infrastructure/api-client-utils.d.ts +0 -6
- package/lib/infrastructure/api-client-utils.js +0 -34
- package/lib/infrastructure/api-client-utils.js.map +0 -1
- package/lib/prompts/portal/common/base-prompts.d.ts +0 -7
- package/lib/prompts/portal/common/base-prompts.js +0 -19
- package/lib/prompts/portal/common/base-prompts.js.map +0 -1
- package/lib/types/api/validate.d.ts +0 -12
- package/lib/types/api/validate.js +0 -2
- package/lib/types/api/validate.js.map +0 -1
- package/lib/types/common/result.d.ts +0 -17
- package/lib/types/common/result.js +0 -32
- package/lib/types/common/result.js.map +0 -1
- package/lib/types/portal/generate.d.ts +0 -13
- package/lib/types/portal/generate.js +0 -3
- package/lib/types/portal/generate.js.map +0 -1
- package/lib/types/portal/quickstart.d.ts +0 -17
- package/lib/types/portal/quickstart.js +0 -2
- package/lib/types/portal/quickstart.js.map +0 -1
- package/lib/types/portal/serve.d.ts +0 -12
- package/lib/types/portal/serve.js +0 -2
- package/lib/types/portal/serve.js.map +0 -1
- package/lib/validators/common/directoryValidator.d.ts +0 -5
- package/lib/validators/common/directoryValidator.js +0 -22
- package/lib/validators/common/directoryValidator.js.map +0 -1
- package/lib/validators/portal/serve-validator.d.ts +0 -6
- package/lib/validators/portal/serve-validator.js +0 -15
- package/lib/validators/portal/serve-validator.js.map +0 -1
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { intro, spinner, select, text, cancel, isCancel, outro, log, autocomplete } from "@clack/prompts";
|
|
5
|
-
import { getMessageInGreenColor } from "../../../utils/utils.js";
|
|
1
|
+
import { select, text, isCancel, log, autocomplete, confirm, note } from "@clack/prompts";
|
|
2
|
+
import { format as f, getTree, withSpinner } from "../../format.js";
|
|
3
|
+
import { getErrorMessage } from "../../../infrastructure/api-utils.js";
|
|
6
4
|
export class PortalRecipePrompts {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.spin = spinner();
|
|
9
|
-
}
|
|
10
5
|
displayWelcomeMessage() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
log.step(`Welcome to the API Recipe Generation Wizard.`);
|
|
7
|
+
const message = `This wizard will guide you through the process of creating an API Recipe.
|
|
8
|
+
|
|
9
|
+
An API Recipe is a collection of steps that allows you to define a single use case for your API Documentation portal.
|
|
10
|
+
Learn more: ${f.link("https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/api-recipes")}
|
|
11
|
+
|
|
12
|
+
Let's get started!`;
|
|
13
|
+
log.info(message);
|
|
14
|
+
}
|
|
15
|
+
recipeNameEmpty() {
|
|
16
|
+
const message = "No recipe name provided";
|
|
17
|
+
log.error(message);
|
|
18
|
+
}
|
|
19
|
+
contentFolderNotFound() {
|
|
20
|
+
const message = "Content folder not found.";
|
|
21
|
+
log.error(message);
|
|
22
|
+
}
|
|
23
|
+
specFileEmptyInvalid() {
|
|
24
|
+
const message = "Spec file is empty or invalid.";
|
|
25
|
+
log.error(message);
|
|
16
26
|
}
|
|
17
27
|
async recipeNamePrompt() {
|
|
18
28
|
const recipeName = await text({
|
|
19
|
-
message:
|
|
29
|
+
message: `Enter a name for your API Recipe:`,
|
|
20
30
|
placeholder: "This name will be displayed in your API Documentation portal sidebar.",
|
|
21
31
|
validate: (name) => {
|
|
22
32
|
if (!name) {
|
|
@@ -25,45 +35,10 @@ export class PortalRecipePrompts {
|
|
|
25
35
|
}
|
|
26
36
|
});
|
|
27
37
|
if (isCancel(recipeName)) {
|
|
28
|
-
|
|
29
|
-
return process.exit(0);
|
|
38
|
+
return undefined;
|
|
30
39
|
}
|
|
31
40
|
return recipeName.trim();
|
|
32
41
|
}
|
|
33
|
-
//Todo: Find a better place for this function
|
|
34
|
-
removeQuotes(str) {
|
|
35
|
-
const quotes = ['"', "'"];
|
|
36
|
-
for (const quote of quotes) {
|
|
37
|
-
if (str.startsWith(quote) && str.endsWith(quote) && str.length > 1) {
|
|
38
|
-
return this.removeQuotes(str.slice(1, -1)); // Recursive call
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return str;
|
|
42
|
-
}
|
|
43
|
-
async buildConfigFilePathPrompt(buildDirectoryPath) {
|
|
44
|
-
const buildConfigFilePath = await text({
|
|
45
|
-
message: `⚠️ APIMATIC-BUILD.json is required and was not found in "${buildDirectoryPath}".\nPlease enter the path to your build config file (relative to this directory):`,
|
|
46
|
-
validate: (filePath) => {
|
|
47
|
-
if (!filePath) {
|
|
48
|
-
return "Build config file path cannot be empty. Please provide a valid file path.";
|
|
49
|
-
}
|
|
50
|
-
const cleanedPath = this.removeQuotes(filePath.trim());
|
|
51
|
-
const resolvedPath = path.resolve(buildDirectoryPath, cleanedPath);
|
|
52
|
-
if (!resolvedPath.endsWith(".json")) {
|
|
53
|
-
return "The content file must be a JSON (.json) file. Please provide a valid file path.";
|
|
54
|
-
}
|
|
55
|
-
if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
return "The specified path is either not a valid relative file path or it doesn't exist. Please provide a valid relative file path.";
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
if (isCancel(buildConfigFilePath)) {
|
|
62
|
-
cancel("Operation cancelled.");
|
|
63
|
-
return process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
return path.resolve(buildDirectoryPath, this.removeQuotes(buildConfigFilePath.trim()));
|
|
66
|
-
}
|
|
67
42
|
async stepNamePrompt(defaultStepName) {
|
|
68
43
|
const stepName = await text({
|
|
69
44
|
message: `Enter a name for the step:`,
|
|
@@ -71,36 +46,32 @@ export class PortalRecipePrompts {
|
|
|
71
46
|
placeholder: `Press enter to use the default, i.e. ${defaultStepName}`
|
|
72
47
|
});
|
|
73
48
|
if (isCancel(stepName)) {
|
|
74
|
-
|
|
75
|
-
return process.exit(0);
|
|
49
|
+
return undefined;
|
|
76
50
|
}
|
|
77
51
|
return stepName.trim();
|
|
78
52
|
}
|
|
79
53
|
displayStepsInformation() {
|
|
80
|
-
log.step(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
54
|
+
log.step(`Add Steps to your API Recipe:`);
|
|
55
|
+
const message = `You can add:
|
|
56
|
+
1. Content Step: Display custom content, such as instructions or information related to your API.
|
|
57
|
+
2. Endpoint Step: Display an API endpoint, its playground and other relevant details.
|
|
58
|
+
Steps appear in the order you add them.
|
|
59
|
+
Let's proceed to adding steps to your API Recipe.`;
|
|
60
|
+
log.message(message);
|
|
86
61
|
}
|
|
87
62
|
async stepTypeSelectionPrompt() {
|
|
88
63
|
const stepType = await select({
|
|
89
|
-
message:
|
|
64
|
+
message: `Select the type of step you want to add:`,
|
|
90
65
|
options: [
|
|
91
66
|
{ value: "content", label: "Content Step", hint: "For displaying custom content" },
|
|
92
67
|
{ value: "endpoint", label: "Endpoint Step", hint: "For displaying an API endpoint with its details" }
|
|
93
68
|
]
|
|
94
69
|
});
|
|
95
70
|
if (isCancel(stepType)) {
|
|
96
|
-
|
|
97
|
-
return process.exit(0);
|
|
71
|
+
return undefined;
|
|
98
72
|
}
|
|
99
73
|
return stepType;
|
|
100
74
|
}
|
|
101
|
-
displayContentStepInfo() {
|
|
102
|
-
log.step("📝 Opening markdown editor for you to add content in...");
|
|
103
|
-
}
|
|
104
75
|
async endpointGroupNamePrompt(endpointGroups) {
|
|
105
76
|
const groupNames = Array.from(endpointGroups.keys()).map((name) => ({
|
|
106
77
|
value: name,
|
|
@@ -112,8 +83,7 @@ export class PortalRecipePrompts {
|
|
|
112
83
|
options: groupNames
|
|
113
84
|
});
|
|
114
85
|
if (isCancel(endpointGroupName)) {
|
|
115
|
-
|
|
116
|
-
return process.exit(0);
|
|
86
|
+
return undefined;
|
|
117
87
|
}
|
|
118
88
|
return endpointGroupName.trim();
|
|
119
89
|
}
|
|
@@ -128,76 +98,68 @@ export class PortalRecipePrompts {
|
|
|
128
98
|
}))
|
|
129
99
|
});
|
|
130
100
|
if (isCancel(endpointName)) {
|
|
131
|
-
|
|
132
|
-
return process.exit(0);
|
|
101
|
+
return undefined;
|
|
133
102
|
}
|
|
134
103
|
return endpointName.trim();
|
|
135
104
|
}
|
|
136
|
-
async endpointDescriptionPrompt(
|
|
137
|
-
const defaultDescription = endpointGroups.get(endpointGroupName).find((e) => e.Name === endpointName).Description;
|
|
105
|
+
async endpointDescriptionPrompt(defaultDescription) {
|
|
138
106
|
const endpointDescription = await text({
|
|
139
107
|
message: `Enter a description for the endpoint:`,
|
|
140
108
|
placeholder: `Optional. Leave this empty to use the endpoint description defined in the API Specification`,
|
|
141
109
|
defaultValue: defaultDescription
|
|
142
110
|
});
|
|
143
111
|
if (isCancel(endpointDescription)) {
|
|
144
|
-
|
|
145
|
-
return process.exit(0);
|
|
112
|
+
return undefined;
|
|
146
113
|
}
|
|
147
114
|
return endpointDescription.trim();
|
|
148
115
|
}
|
|
149
116
|
async addAnotherStepSelectionPrompt() {
|
|
150
|
-
const addAnotherStep = await
|
|
117
|
+
const addAnotherStep = await confirm({
|
|
151
118
|
message: `Do you want to add another step?`,
|
|
152
|
-
|
|
153
|
-
{ value: "yes", label: "Yes" },
|
|
154
|
-
{ value: "no", label: "No" }
|
|
155
|
-
],
|
|
156
|
-
initialValue: "yes"
|
|
119
|
+
initialValue: true
|
|
157
120
|
});
|
|
158
121
|
if (isCancel(addAnotherStep)) {
|
|
159
|
-
|
|
160
|
-
return process.exit(0);
|
|
122
|
+
return false;
|
|
161
123
|
}
|
|
162
|
-
return addAnotherStep
|
|
124
|
+
return addAnotherStep;
|
|
163
125
|
}
|
|
164
|
-
async overwriteApiRecipeInTocPrompt() {
|
|
165
|
-
const
|
|
166
|
-
message:
|
|
167
|
-
|
|
168
|
-
{ value: "yes", label: "Yes" },
|
|
169
|
-
{ value: "no", label: "No" }
|
|
170
|
-
]
|
|
126
|
+
async overwriteApiRecipeInTocPrompt(name) {
|
|
127
|
+
const overwrite = await confirm({
|
|
128
|
+
message: `An API Recipe with name ${f.var(name)} already exists. Do you want to overwrite it?`,
|
|
129
|
+
initialValue: false
|
|
171
130
|
});
|
|
172
|
-
if (isCancel(
|
|
173
|
-
|
|
174
|
-
return process.exit(0);
|
|
131
|
+
if (isCancel(overwrite)) {
|
|
132
|
+
return false;
|
|
175
133
|
}
|
|
176
|
-
return
|
|
134
|
+
return overwrite;
|
|
177
135
|
}
|
|
178
136
|
displayStepAddedSuccessfullyMessage() {
|
|
179
137
|
log.step(`Step has been added successfully.`);
|
|
180
138
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
139
|
+
invalidBuildDirectory(directory) {
|
|
140
|
+
const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
|
|
141
|
+
log.error(message);
|
|
142
|
+
}
|
|
143
|
+
serviceError(serviceError) {
|
|
144
|
+
log.error(getErrorMessage(serviceError));
|
|
145
|
+
}
|
|
146
|
+
openRecipeMarkdownEditor() {
|
|
147
|
+
log.step("Opening markdown editor for you to enter recipe content...");
|
|
184
148
|
}
|
|
185
|
-
|
|
186
|
-
|
|
149
|
+
displayRecipeStructure(tocStructure) {
|
|
150
|
+
const heading = `You can edit the following files to customize your API Recipe:\n`;
|
|
151
|
+
const message = getTree(tocStructure);
|
|
152
|
+
log.info(heading + message);
|
|
187
153
|
}
|
|
188
|
-
|
|
189
|
-
|
|
154
|
+
nextSteps() {
|
|
155
|
+
const message = `Run the command '${f.cmdAlt(`apimatic`, 'portal', 'serve')}' to preview your documentation portal`;
|
|
156
|
+
note(message, "Next Steps");
|
|
190
157
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const coloredLogString = tree
|
|
194
|
-
.split("\n")
|
|
195
|
-
.map((line) => line.replace(/#.*/, (match) => getMessageInGreenColor(match)))
|
|
196
|
-
.join("\n");
|
|
197
|
-
log.step(`🛠️ You can edit the following files to customize your API Recipe :\n\n` + coloredLogString);
|
|
158
|
+
generateSdl(fn) {
|
|
159
|
+
return withSpinner("Extracting endpoints", "Endpoints extracted", "Endpoints extraction failed", fn);
|
|
198
160
|
}
|
|
199
|
-
|
|
200
|
-
|
|
161
|
+
recipeCreated() {
|
|
162
|
+
log.info(`A new API Recipe has been created successfully.`);
|
|
201
163
|
}
|
|
202
164
|
}
|
|
203
165
|
//# sourceMappingURL=new-recipe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-recipe.js","sourceRoot":"","sources":["../../../../src/prompts/portal/recipe/new-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"new-recipe.js","sourceR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AM,OAAO,GAAG,oBAAoB,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,wCAAwC,CAAC;QACpH,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9B,CAAC;IAEM,WAAW,CAAC,EAAsC;QACvD,OAAO,WAAW,CAChB,sBAAsB,EACtB,qBAAqB,EACrB,6BAA6B,EAC7B,EAAE,CACH,CAAC;IACJ,CAAC;IAEM,aAAa;QAClB,GAAG,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { UrlPath } from "../../types/file/urlPath.js";
|
|
2
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
3
|
+
export declare class PortalServePrompts {
|
|
4
|
+
usingFallbackPort(currentPort: number, availablePort: number): void;
|
|
5
|
+
portalServed(urlPath: UrlPath): void;
|
|
6
|
+
promptForExit(): void;
|
|
7
|
+
changesDetected(): void;
|
|
8
|
+
watcherError(): void;
|
|
9
|
+
blockExecution(): Promise<void>;
|
|
10
|
+
hotReloadEnabled(srcDirectory: DirectoryPath): void;
|
|
4
11
|
}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import { log,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
import { log, note } from "@clack/prompts";
|
|
2
|
+
import { format as f } from "../format.js";
|
|
3
|
+
import { once } from "events";
|
|
4
|
+
export class PortalServePrompts {
|
|
5
|
+
usingFallbackPort(currentPort, availablePort) {
|
|
6
|
+
const message = `Port ${f.var(currentPort.toString())} is already in use. Available port ${f.var(availablePort.toString())} will be used.`;
|
|
7
|
+
log.step(message);
|
|
8
|
+
}
|
|
9
|
+
portalServed(urlPath) {
|
|
10
|
+
const message = `The portal is running at ${f.link(urlPath.toString())}`;
|
|
11
|
+
log.message(message);
|
|
12
|
+
}
|
|
13
|
+
promptForExit() {
|
|
14
|
+
const message = "Press CTRL+C to stop the server.";
|
|
15
|
+
log.message(message);
|
|
16
|
+
}
|
|
17
|
+
changesDetected() {
|
|
18
|
+
const message = "Changes detected...";
|
|
19
|
+
log.info(message);
|
|
20
|
+
}
|
|
21
|
+
watcherError() {
|
|
22
|
+
const message = `An unexpected error occurred while watching your build folder for changes. Please try again later. If the issue persists, contact our team at ${f.var('support@apimatic.io')}`;
|
|
23
|
+
log.error(message);
|
|
24
|
+
}
|
|
25
|
+
async blockExecution() {
|
|
26
|
+
await Promise.race([once(process, "SIGINT"), once(process, "SIGTERM")]);
|
|
27
|
+
}
|
|
28
|
+
hotReloadEnabled(srcDirectory) {
|
|
29
|
+
note(`Hot reload is enabled.
|
|
30
|
+
Watching the directory ${f.path(srcDirectory)} for any changes`, `Note`);
|
|
12
31
|
}
|
|
13
32
|
}
|
|
14
33
|
//# sourceMappingURL=serve.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/prompts/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/prompts/portal/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,OAAO,kBAAkB;IACtB,iBAAiB,CAAC,WAAmB,EAAE,aAAqB;QACjE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,sCAAsC,CAAC,CAAC,GAAG,CAC9F,aAAa,CAAC,QAAQ,EAAE,CACzB,gBAAgB,CAAC;QAClB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,YAAY,CAAC,OAAgB;QAClC,MAAM,OAAO,GAAG,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAEM,aAAa;QAClB,MAAM,OAAO,GAAG,kCAAkC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAEM,eAAe;QACpB,MAAM,OAAO,GAAG,qBAAqB,CAAC;QACtC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAEM,YAAY;QACjB,MAAM,OAAO,GACX,iJAAiJ,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAClL,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEM,gBAAgB,CAAC,YAA2B;QACjD,IAAI,CAAC;yBACgB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { FilePath } from "../../../types/file/filePath.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
4
|
+
import { ServiceError } from "../../../infrastructure/api-utils.js";
|
|
5
|
+
import { Sdl } from "../../../types/sdl/sdl.js";
|
|
2
6
|
export declare class PortalNewTocPrompts {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
overwriteToc(tocPath: FilePath): Promise<boolean>;
|
|
8
|
+
fallingBackToDefault(): void;
|
|
9
|
+
tocFileAlreadyExists(): void;
|
|
10
|
+
logError(message: string): void;
|
|
11
|
+
contentDirectoryNotFound(contentFolderPath: DirectoryPath): void;
|
|
12
|
+
invalidBuildDirectory(directory: DirectoryPath): void;
|
|
13
|
+
extractEndpointGroupsAndModels(fn: Promise<Result<Sdl, ServiceError>>): Promise<Result<Sdl, ServiceError>>;
|
|
14
|
+
tocCreated(tocPath: FilePath): void;
|
|
11
15
|
}
|
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { confirm, isCancel, log } from "@clack/prompts";
|
|
2
|
+
import { format as f, withSpinner } from "../../format.js";
|
|
2
3
|
export class PortalNewTocPrompts {
|
|
3
|
-
|
|
4
|
-
this.spin = spinner();
|
|
5
|
-
}
|
|
6
|
-
async overwriteExistingTocPrompt(tocPath) {
|
|
4
|
+
async overwriteToc(tocPath) {
|
|
7
5
|
const overwrite = await confirm({
|
|
8
|
-
message:
|
|
6
|
+
message: `The destination file ${f.path(tocPath)} already exists, do you want to overwrite it?`,
|
|
9
7
|
initialValue: false
|
|
10
8
|
});
|
|
11
9
|
if (isCancel(overwrite)) {
|
|
12
|
-
cancel("Operation cancelled.");
|
|
13
10
|
return false;
|
|
14
11
|
}
|
|
15
|
-
if (!overwrite) {
|
|
16
|
-
log.error("Please enter a different destination path or delete the existing toc.yml file and try again.");
|
|
17
|
-
}
|
|
18
12
|
return overwrite;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
fallingBackToDefault() {
|
|
15
|
+
log.warn(`Falling back to the default TOC structure.`);
|
|
16
|
+
}
|
|
17
|
+
tocFileAlreadyExists() {
|
|
18
|
+
log.error(`Please enter a different destination path or delete the existing toc.yml file and try again.`);
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
logError(message) {
|
|
21
|
+
log.error(message);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
contentDirectoryNotFound(contentFolderPath) {
|
|
24
|
+
log.error(`Content folder not found at: ${contentFolderPath}`);
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
invalidBuildDirectory(directory) {
|
|
27
|
+
const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
|
|
28
|
+
log.error(message);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
extractEndpointGroupsAndModels(fn) {
|
|
31
|
+
return withSpinner("Extracting endpoint groups and models", "Endpoint groups and models extracted", "Endpoint groups and models extraction failed", fn);
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
log.
|
|
33
|
+
tocCreated(tocPath) {
|
|
34
|
+
log.info(`The TOC file successfully created at: ${f.path(tocPath)}`);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
//# sourceMappingURL=new-toc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-toc.js","sourceRoot":"","sources":["../../../../src/prompts/portal/toc/new-toc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"new-toc.js","sourceRoot":"","sources":["../../../../src/prompts/portal/toc/new-toc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGxD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK3D,MAAM,OAAO,mBAAmB;IACvB,KAAK,CAAC,YAAY,CAAC,OAAiB;QACzC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAC9B,OAAO,EAAE,wBAAwB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,+CAA+C;YAC/F,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,oBAAoB;QACzB,GAAG,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IACzD,CAAC;IAEM,oBAAoB;QACzB,GAAG,CAAC,KAAK,CAAC,8FAA8F,CAAC,CAAC;IAC5G,CAAC;IAEM,QAAQ,CAAC,OAAe;QAC7B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,wBAAwB,CAAC,iBAAgC;QAC9D,GAAG,CAAC,KAAK,CAAC,gCAAgC,iBAAiB,EAAE,CAAC,CAAC;IACjE,CAAC;IAEM,qBAAqB,CAAC,SAAwB;QACnD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACjG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAEM,8BAA8B,CAAC,EAAsC;QAC1E,OAAO,WAAW,CAChB,uCAAuC,EACvC,sCAAsC,EACtC,8CAA8C,EAC9C,EAAE,CACH,CAAC;IACJ,CAAC;IAEM,UAAU,CAAC,OAAiB;QACjC,GAAG,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
2
3
|
export declare class SdkGeneratePrompts {
|
|
3
|
-
private readonly spin;
|
|
4
4
|
overwriteSdk(directory: DirectoryPath): Promise<boolean>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
sameSpecAndSdkDir(directory: DirectoryPath): void;
|
|
6
|
+
invalidSpecDirectory(directory: DirectoryPath): void;
|
|
7
|
+
destinationDirNotEmpty(): void;
|
|
8
|
+
generateSDK(fn: Promise<Result<NodeJS.ReadableStream, string>>): Promise<Result<NodeJS.ReadableStream, string>>;
|
|
9
|
+
logGenerationError(error: string): void;
|
|
10
|
+
sdkGenerated(sdk: DirectoryPath): void;
|
|
11
11
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isCancel, confirm, log } from "@clack/prompts";
|
|
2
|
+
import { format as f, withSpinner } from "../format.js";
|
|
3
3
|
export class SdkGeneratePrompts {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.spin = spinner();
|
|
6
|
-
}
|
|
7
4
|
async overwriteSdk(directory) {
|
|
8
5
|
const overwrite = await confirm({
|
|
9
|
-
message: `The destination
|
|
6
|
+
message: `The destination ${f.path(directory)} is not empty, do you want to overwrite?`,
|
|
10
7
|
initialValue: false
|
|
11
8
|
});
|
|
12
9
|
if (isCancel(overwrite)) {
|
|
@@ -14,29 +11,26 @@ export class SdkGeneratePrompts {
|
|
|
14
11
|
}
|
|
15
12
|
return overwrite;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
sameSpecAndSdkDir(directory) {
|
|
15
|
+
const message = `The ${f.var("src")} and ${f.var("portal")} directories must be different. Current value: ${f.path(directory)}`;
|
|
16
|
+
this.logGenerationError(message);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
18
|
+
invalidSpecDirectory(directory) {
|
|
19
|
+
const message = `The ${f.var("src")} directory is either empty or invalid: ${f.path(directory)}`;
|
|
20
|
+
this.logGenerationError(message);
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.
|
|
22
|
+
destinationDirNotEmpty() {
|
|
23
|
+
const message = `Please enter a different destination folder or remove the existing files and try again.`;
|
|
24
|
+
this.logGenerationError(message);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
generateSDK(fn) {
|
|
27
|
+
return withSpinner("Generating SDK", "SDK generated successfully.", "SDK Generation failed.", fn);
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
logGenerationError(error) {
|
|
32
30
|
log.error(error);
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (process.stdin.isTTY) {
|
|
37
|
-
process.stdin.setRawMode(false);
|
|
38
|
-
process.stdin.pause();
|
|
39
|
-
}
|
|
32
|
+
sdkGenerated(sdk) {
|
|
33
|
+
log.info(`Generated SDK can be found at ${f.path(sdk)}.`);
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
//# sourceMappingURL=generate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/prompts/sdk/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/prompts/sdk/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,OAAO,kBAAkB;IACtB,KAAK,CAAC,YAAY,CAAC,SAAwB;QAChD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAC9B,OAAO,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,0CAA0C;YACvF,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,iBAAiB,CAAC,SAAwB;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,kDAAkD,CAAC,CAAC,IAAI,CAC/G,SAAS,CACV,EAAE,CAAC;QAAI,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAEM,oBAAoB,CAAC,SAAwB;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACjG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAEM,sBAAsB;QAC3B,MAAM,OAAO,GAAG,yFAAyF,CAAC;QAC1G,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAEM,WAAW,CAAC,EAAkD;QACnE,OAAO,WAAW,CAAC,gBAAgB,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,EAAE,CAAC,CAAC;IACpG,CAAC;IAEM,kBAAkB,CAAC,KAAa;QACrC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,YAAY,CAAC,GAAkB;QACpC,GAAG,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import { TransformationController } from "@apimatic/sdk";
|
|
2
|
-
export type TransformationIdParams = {
|
|
3
|
-
file: string;
|
|
4
|
-
url: string;
|
|
5
|
-
format: string;
|
|
6
|
-
};
|
|
7
|
-
export type DownloadTransformationParams = {
|
|
8
|
-
id: string;
|
|
9
|
-
destinationFilePath: string;
|
|
10
|
-
transformationController: TransformationController;
|
|
11
|
-
};
|
|
12
1
|
export type TransformationData = {
|
|
13
2
|
result: NodeJS.ReadableStream | Blob;
|
|
14
3
|
};
|
|
@@ -28,18 +17,18 @@ export declare const DestinationFormats: {
|
|
|
28
17
|
GraphQlSchema: string;
|
|
29
18
|
};
|
|
30
19
|
export declare enum TransformationFormats {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
apimatic = "Apimatic",
|
|
21
|
+
wadl2009 = "Wadl2009",
|
|
22
|
+
wsdl = "Wsdl",
|
|
23
|
+
swagger10 = "Swagger10",
|
|
24
|
+
swagger20 = "Swagger20",
|
|
25
|
+
swaggeryaml = "Swaggeryaml",
|
|
26
|
+
oas3 = "Oas3",
|
|
27
|
+
openapi3yaml = "Openapi3Yaml",
|
|
28
|
+
apiblueprint = "Apiblueprint",
|
|
29
|
+
raml = "Raml",
|
|
30
|
+
raml10 = "Raml10",
|
|
31
|
+
postman10 = "Postman10",
|
|
32
|
+
postman20 = "Postman20",
|
|
33
|
+
graphqlschema = "Graphqlschema"
|
|
45
34
|
}
|