@apimatic/cli 0.0.0-alpha.3 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +308 -130
- package/bin/run.js +5 -0
- package/lib/actions/action-result.d.ts +13 -0
- package/lib/actions/action-result.js +44 -0
- package/lib/actions/action-result.js.map +1 -0
- 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 +13 -0
- package/lib/actions/auth/login.js +55 -0
- package/lib/actions/auth/login.js.map +1 -0
- 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 +16 -0
- package/lib/actions/portal/copilot.js +89 -0
- package/lib/actions/portal/copilot.js.map +1 -0
- package/lib/actions/portal/generate.d.ts +13 -0
- package/lib/actions/portal/generate.js +59 -0
- package/lib/actions/portal/generate.js.map +1 -0
- 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 +15 -0
- package/lib/actions/portal/recipe/new-recipe.js +176 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +16 -0
- package/lib/actions/portal/serve.js +119 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +21 -0
- package/lib/actions/portal/toc/new-toc.js +97 -0
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +13 -0
- package/lib/actions/sdk/generate.js +47 -0
- package/lib/actions/sdk/generate.js.map +1 -0
- package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
- package/lib/application/portal/recipe/portal-recipe.js +33 -0
- package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
- package/lib/application/portal/recipe/recipe-generator.d.ts +21 -0
- package/lib/application/portal/recipe/recipe-generator.js +146 -0
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
- package/lib/application/portal/toc/toc-content-parser.d.ts +5 -0
- package/lib/application/portal/toc/toc-content-parser.js +44 -0
- package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-structure-generator.d.ts +6 -0
- package/lib/application/portal/toc/toc-structure-generator.js +84 -0
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
- package/lib/client-utils/auth-manager.d.ts +8 -3
- package/lib/client-utils/auth-manager.js +26 -14
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/commands/api/transform.d.ts +11 -8
- package/lib/commands/api/transform.js +52 -105
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +8 -5
- package/lib/commands/api/validate.js +31 -63
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +4 -2
- package/lib/commands/auth/login.js +26 -51
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +4 -2
- package/lib/commands/auth/logout.js +14 -20
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +2 -1
- package/lib/commands/auth/status.js +18 -20
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/copilot.d.ts +13 -0
- package/lib/commands/portal/copilot.js +34 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +9 -8
- package/lib/commands/portal/generate.js +31 -97
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/quickstart.d.ts +9 -0
- package/lib/commands/portal/quickstart.js +37 -0
- package/lib/commands/portal/quickstart.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +12 -0
- package/lib/commands/portal/recipe/new.js +46 -0
- package/lib/commands/portal/recipe/new.js.map +1 -0
- package/lib/commands/portal/serve.d.ts +16 -0
- package/lib/commands/portal/serve.js +54 -0
- package/lib/commands/portal/serve.js.map +1 -0
- package/lib/commands/portal/toc/new.d.ts +14 -0
- package/lib/commands/portal/toc/new.js +61 -0
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +11 -9
- package/lib/commands/sdk/generate.js +48 -122
- package/lib/commands/sdk/generate.js.map +1 -0
- package/lib/config/axios-config.d.ts +2 -0
- package/lib/config/axios-config.js +10 -0
- package/lib/config/axios-config.js.map +1 -0
- package/lib/hooks/not-found.d.ts +3 -0
- package/lib/hooks/not-found.js +52 -0
- package/lib/hooks/not-found.js.map +1 -0
- package/lib/hooks/utils.d.ts +5 -0
- package/lib/hooks/utils.js +51 -0
- package/lib/hooks/utils.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -0
- package/lib/infrastructure/api-utils.d.ts +9 -0
- package/lib/infrastructure/api-utils.js +34 -0
- package/lib/infrastructure/api-utils.js.map +1 -0
- package/lib/infrastructure/debounce-service.d.ts +10 -0
- package/lib/infrastructure/debounce-service.js +52 -0
- package/lib/infrastructure/debounce-service.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +12 -0
- package/lib/infrastructure/env-info.js +58 -0
- package/lib/infrastructure/env-info.js.map +1 -0
- package/lib/infrastructure/file-service.d.ts +23 -0
- package/lib/infrastructure/file-service.js +117 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +7 -0
- package/lib/infrastructure/launcher-service.js +51 -0
- package/lib/infrastructure/launcher-service.js.map +1 -0
- 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 +10 -0
- package/lib/infrastructure/services/api-service.js +55 -0
- package/lib/infrastructure/services/api-service.js.map +1 -0
- package/lib/infrastructure/services/auth-service.d.ts +11 -0
- package/lib/infrastructure/services/auth-service.js +37 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- 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 +21 -0
- package/lib/infrastructure/services/portal-service.js +157 -0
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
- package/lib/infrastructure/services/telemetry-service.js +38 -0
- package/lib/infrastructure/services/telemetry-service.js.map +1 -0
- 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/infrastructure/tmp-extensions.d.ts +2 -0
- package/lib/infrastructure/tmp-extensions.js +6 -0
- package/lib/infrastructure/tmp-extensions.js.map +1 -0
- package/lib/infrastructure/zip-service.d.ts +6 -0
- package/lib/infrastructure/zip-service.js +39 -0
- package/lib/infrastructure/zip-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 +10 -0
- package/lib/prompts/auth/login.js +22 -0
- package/lib/prompts/auth/login.js.map +1 -0
- 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 +18 -0
- package/lib/prompts/portal/copilot.js +82 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +13 -0
- package/lib/prompts/portal/generate.js +41 -0
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +31 -0
- package/lib/prompts/portal/quickstart.js +146 -0
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
- package/lib/prompts/portal/recipe/new-recipe.js +165 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +11 -0
- package/lib/prompts/portal/serve.js +33 -0
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +15 -0
- package/lib/prompts/portal/toc/new-toc.js +37 -0
- package/lib/prompts/portal/toc/new-toc.js.map +1 -0
- package/lib/prompts/sdk/generate.d.ts +11 -0
- package/lib/prompts/sdk/generate.js +36 -0
- package/lib/prompts/sdk/generate.js.map +1 -0
- package/lib/types/api/account.d.ts +10 -0
- package/lib/types/api/account.js +2 -0
- package/lib/types/api/account.js.map +1 -0
- package/lib/types/api/transform.d.ts +17 -17
- package/lib/types/api/transform.js +21 -6
- package/lib/types/api/transform.js.map +1 -0
- package/lib/types/build/build.d.ts +22 -0
- package/lib/types/build/build.js +7 -0
- package/lib/types/build/build.js.map +1 -0
- package/lib/types/build-context.d.ts +17 -0
- package/lib/types/build-context.js +47 -0
- package/lib/types/build-context.js.map +1 -0
- 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 +8 -0
- package/lib/types/events/domain-event.js +11 -0
- package/lib/types/events/domain-event.js.map +1 -0
- package/lib/types/events/quickstart-completed.d.ts +7 -0
- package/lib/types/events/quickstart-completed.js +10 -0
- package/lib/types/events/quickstart-completed.js.map +1 -0
- package/lib/types/events/quickstart-initiated.d.ts +7 -0
- package/lib/types/events/quickstart-initiated.js +10 -0
- package/lib/types/events/quickstart-initiated.js.map +1 -0
- package/lib/types/events/recipe-creation-failed.d.ts +5 -0
- package/lib/types/events/recipe-creation-failed.js +8 -0
- package/lib/types/events/recipe-creation-failed.js.map +1 -0
- package/lib/types/events/toc-creation-failed.d.ts +5 -0
- package/lib/types/events/toc-creation-failed.js +8 -0
- package/lib/types/events/toc-creation-failed.js.map +1 -0
- 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 +9 -0
- package/lib/types/file/directoryPath.js +22 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +7 -0
- package/lib/types/file/fileName.js +21 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +10 -0
- package/lib/types/file/filePath.js +32 -0
- package/lib/types/file/filePath.js.map +1 -0
- 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/flags-provider.d.ts +15 -0
- package/lib/types/flags-provider.js +34 -0
- package/lib/types/flags-provider.js.map +1 -0
- package/lib/types/portal-context.d.ts +13 -0
- package/lib/types/portal-context.js +38 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/recipe/recipe.d.ts +22 -0
- package/lib/types/recipe/recipe.js +6 -0
- package/lib/types/recipe/recipe.js.map +1 -0
- 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 +9 -21
- package/lib/types/sdk/generate.js +25 -12
- package/lib/types/sdk/generate.js.map +1 -0
- package/lib/types/sdk-context.d.ts +14 -0
- package/lib/types/sdk-context.js +32 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/sdl/sdl.d.ts +21 -0
- package/lib/types/sdl/sdl.js +47 -0
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +10 -0
- package/lib/types/spec-context.js +17 -0
- package/lib/types/spec-context.js.map +1 -0
- 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/toc.d.ts +31 -0
- package/lib/types/toc/toc.js +9 -0
- package/lib/types/toc/toc.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 +1 -6
- package/lib/types/utils.js +2 -2
- package/lib/types/utils.js.map +1 -0
- 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 -18
- package/lib/utils/utils.js +33 -116
- package/lib/utils/utils.js.map +1 -0
- package/package.json +101 -46
- package/bin/run +0 -5
- package/lib/client-utils/sdk-client.d.ts +0 -23
- package/lib/client-utils/sdk-client.js +0 -119
- package/lib/config/env.d.ts +0 -1
- package/lib/config/env.js +0 -4
- package/lib/controllers/api/transform.d.ts +0 -5
- package/lib/controllers/api/transform.js +0 -49
- package/lib/controllers/api/validate.d.ts +0 -3
- package/lib/controllers/api/validate.js +0 -22
- package/lib/controllers/portal/generate.d.ts +0 -2
- package/lib/controllers/portal/generate.js +0 -49
- package/lib/controllers/sdk/generate.d.ts +0 -4
- package/lib/controllers/sdk/generate.js +0 -64
- package/lib/types/api/validate.d.ts +0 -12
- package/lib/types/api/validate.js +0 -2
- package/lib/types/portal/generate.d.ts +0 -9
- package/lib/types/portal/generate.js +0 -2
- package/oclif.manifest.json +0 -1
|
@@ -1,68 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
3
|
+
import { FlagsProvider } from "../../types/flags-provider.js";
|
|
4
|
+
import { ValidateAction } from "../../actions/api/validate.js";
|
|
5
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
6
|
+
import { createResourceInput } from "../../types/file/resource-input.js";
|
|
7
|
+
class Validate extends Command {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.getConfigDir = () => {
|
|
11
|
+
return new DirectoryPath(this.config.configDir);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
10
14
|
async run() {
|
|
11
|
-
const { flags } = this.parse(Validate);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
log: this.log,
|
|
22
|
-
warn: this.warn,
|
|
23
|
-
error: this.error
|
|
24
|
-
};
|
|
25
|
-
utils_1.printValidationMessages(validationSummary, logFunctions);
|
|
26
|
-
validationSummary.success
|
|
27
|
-
? this.log("Specification file provided is valid")
|
|
28
|
-
: this.error("Specification file provided is invalid");
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error.result) {
|
|
32
|
-
const apiError = error;
|
|
33
|
-
const result = apiError.result;
|
|
34
|
-
if (result.modelState["exception Error"] && apiError.statusCode === 400) {
|
|
35
|
-
this.error(utils_1.replaceHTML(result.modelState["exception Error"][0]));
|
|
36
|
-
}
|
|
37
|
-
else if (error.body && apiError.statusCode === 401) {
|
|
38
|
-
this.error(error.body);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this.error(error.message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.error(`${error.message}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
15
|
+
const { flags: { file, url, "auth-key": authKey } } = await this.parse(Validate);
|
|
16
|
+
const commandMetadata = {
|
|
17
|
+
commandName: Validate.id,
|
|
18
|
+
shell: this.config.shell
|
|
19
|
+
};
|
|
20
|
+
const action = new ValidateAction(this.getConfigDir(), commandMetadata, authKey);
|
|
21
|
+
const resourceInput = createResourceInput(file, url);
|
|
22
|
+
intro("Validate API");
|
|
23
|
+
const result = await action.execute(resourceInput);
|
|
24
|
+
outro(result);
|
|
48
25
|
}
|
|
49
26
|
}
|
|
50
|
-
|
|
51
|
-
Validate.description =
|
|
27
|
+
Validate.summary = "Validate API specification for syntactic and semantic correctness";
|
|
28
|
+
Validate.description = `Validate your API specification to ensure it adheres to syntactic and semantic standards.`;
|
|
29
|
+
Validate.cmdTxt = format.cmd("apimatic", "api", "validate");
|
|
52
30
|
Validate.examples = [
|
|
53
|
-
`$
|
|
54
|
-
|
|
55
|
-
`,
|
|
56
|
-
`$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
|
|
57
|
-
Specification file provided is valid
|
|
58
|
-
`
|
|
31
|
+
`${Validate.cmdTxt} ${format.flag("file", "./specs/sample.json")}`,
|
|
32
|
+
`${Validate.cmdTxt} ${format.flag("url", '"https://petstore.swagger.io/v2/swagger.json"')}`
|
|
59
33
|
];
|
|
60
|
-
Validate.flags = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
default: "",
|
|
64
|
-
description: "URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available."
|
|
65
|
-
}),
|
|
66
|
-
// docs: flags.boolean({ default: false, description: "Validate specification for docs generation" }), // Next tier, not included in API spec
|
|
67
|
-
"auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
|
|
68
|
-
};
|
|
34
|
+
Validate.flags = Object.assign({ file: Flags.string({ description: "Path to the API specification file to validate" }), url: Flags.string({ description: "URL to the API specification file to validate (publicly accessible)" }) }, FlagsProvider.authKey);
|
|
35
|
+
export default Validate;
|
|
36
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAqB,QAAS,SAAQ,OAAO;IAA7C;;QAoCmB,iBAAY,GAAG,GAAG,EAAE;YACnC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IArBC,KAAK,CAAC,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AAQ"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
2
|
export default class Login extends Command {
|
|
3
|
+
static summary: string;
|
|
3
4
|
static description: string;
|
|
5
|
+
private static cmdTxt;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
static flags: {
|
|
6
|
-
"auth-key":
|
|
8
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
9
|
};
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
}
|
|
@@ -1,60 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
7
|
-
class Login extends command_1.Command {
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
3
|
+
import { LoginAction } from "../../actions/auth/login.js";
|
|
4
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
5
|
+
class Login extends Command {
|
|
8
6
|
async run() {
|
|
9
|
-
const { flags } = this.parse(Login);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const client = sdk_client_1.SDKClient.getInstance();
|
|
13
|
-
// If user is setting auth key
|
|
14
|
-
if (flags["auth-key"]) {
|
|
15
|
-
const response = client.setAuthKey(flags["auth-key"], configDir);
|
|
16
|
-
return this.log(response);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
// If user logs in with email and password
|
|
20
|
-
const email = await cli_ux_1.cli.prompt("Please enter your registered email");
|
|
21
|
-
const password = await cli_ux_1.cli.prompt("Please enter your password", {
|
|
22
|
-
type: "hide"
|
|
23
|
-
});
|
|
24
|
-
const response = await client.login(email, password, configDir);
|
|
25
|
-
this.log(response);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
if (error && error.response) {
|
|
30
|
-
const apiError = error;
|
|
31
|
-
const apiResponse = apiError.response;
|
|
32
|
-
if (apiResponse) {
|
|
33
|
-
const responseData = apiResponse.data;
|
|
34
|
-
if (apiResponse.status === 403 && responseData) {
|
|
35
|
-
return this.error(utils_1.replaceHTML(responseData));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return this.error(apiError.message);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
this.error(error.message);
|
|
7
|
+
const { flags: { "auth-key": authKey } } = await this.parse(Login);
|
|
8
|
+
if (authKey === "") {
|
|
9
|
+
this.error("Flag --auth-key must not be empty when provided.");
|
|
43
10
|
}
|
|
11
|
+
const commandMetadata = {
|
|
12
|
+
commandName: Login.id,
|
|
13
|
+
shell: this.config.shell
|
|
14
|
+
};
|
|
15
|
+
intro("Login");
|
|
16
|
+
const loginAction = new LoginAction(new DirectoryPath(this.config.configDir), commandMetadata);
|
|
17
|
+
const result = await loginAction.execute(authKey);
|
|
18
|
+
outro(result);
|
|
44
19
|
}
|
|
45
20
|
}
|
|
46
|
-
|
|
21
|
+
Login.summary = "Login to your APIMatic account";
|
|
47
22
|
Login.description = "Login using your APIMatic credentials or an API Key";
|
|
23
|
+
Login.cmdTxt = format.cmd('apimatic', 'auth', 'login');
|
|
48
24
|
Login.examples = [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Please enter your password: *********
|
|
52
|
-
|
|
53
|
-
You have successfully logged into APIMatic
|
|
54
|
-
`,
|
|
55
|
-
`$ apimatic auth:login --auth-key=xxxxxx
|
|
56
|
-
Authentication key successfully set`
|
|
25
|
+
Login.cmdTxt,
|
|
26
|
+
`${Login.cmdTxt} ${format.flag('auth-key', '{api-key}')}`
|
|
57
27
|
];
|
|
58
28
|
Login.flags = {
|
|
59
|
-
"auth-key":
|
|
29
|
+
"auth-key": Flags.string({
|
|
30
|
+
char: "k",
|
|
31
|
+
description: "Sets authentication key for all commands."
|
|
32
|
+
})
|
|
60
33
|
};
|
|
34
|
+
export default Login;
|
|
35
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAqB,KAAM,SAAQ,OAAO;IAkBxC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAC/B,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE5B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,KAAK,CAAC,EAAE;YACrB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC;QAC/F,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClD,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;;AAnCM,aAAO,GAAG,gCAAgC,CAAC;AAE3C,iBAAW,GAAG,qDAAqD,CAAC;AAE5D,YAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAG,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1D,cAAQ,GAAG;IAChB,KAAK,CAAC,MAAM;IACZ,GAAG,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE;CAAC,CAAC;AAEtD,WAAK,GAAG;IACb,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,2CAA2C;KACzD,CAAC;CACH,CAAC;eAfiB,KAAK"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Command } from "@oclif/
|
|
2
|
-
export default class
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class Logout extends Command {
|
|
3
|
+
static summary: string;
|
|
3
4
|
static description: string;
|
|
5
|
+
private static cmdTxt;
|
|
4
6
|
static examples: string[];
|
|
5
7
|
run(): Promise<void>;
|
|
6
8
|
}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
3
|
+
import { LogoutAction } from "../../actions/auth/logout.js";
|
|
4
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
5
|
+
class Logout extends Command {
|
|
6
6
|
async run() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.log(response);
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
this.error(error);
|
|
14
|
-
}
|
|
7
|
+
intro("Logout");
|
|
8
|
+
const actionResult = await new LogoutAction(new DirectoryPath(this.config.configDir)).execute();
|
|
9
|
+
outro(actionResult);
|
|
15
10
|
}
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
];
|
|
12
|
+
Logout.summary = "Clears the local login credentials.";
|
|
13
|
+
Logout.description = "Clears the local login credentials. This will also clear any cached credentials from the CLI.";
|
|
14
|
+
Logout.cmdTxt = format.cmd('apimatic', 'auth', 'logout');
|
|
15
|
+
Logout.examples = [Logout.cmdTxt];
|
|
16
|
+
export default Logout;
|
|
17
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,MAAqB,MAAO,SAAQ,OAAO;IAQzC,KAAK,CAAC,GAAG;QAEP,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,MAAM,YAAY,GAAG,MAAM,IAAI,YAAY,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAChG,KAAK,CAAC,YAAY,CAAC,CAAA;IACrB,CAAC;;AAZM,cAAO,GAAG,qCAAqC,CAAC;AAEhD,kBAAW,GAAG,+FAA+F,CAAC;AAEtG,aAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC3D,eAAQ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;eANf,MAAM"}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Status extends
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
3
|
+
import { StatusAction } from "../../actions/auth/status.js";
|
|
4
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
5
|
+
class Status extends Command {
|
|
6
6
|
async run() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const commandMetadata = {
|
|
8
|
+
commandName: Status.id,
|
|
9
|
+
shell: this.config.shell
|
|
10
|
+
};
|
|
11
|
+
intro('Status');
|
|
12
|
+
const statusAction = new StatusAction(new DirectoryPath(this.config.configDir), commandMetadata);
|
|
13
|
+
const actionResult = await statusAction.execute(null);
|
|
14
|
+
outro(actionResult);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
Status.
|
|
19
|
-
Status.examples = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
];
|
|
17
|
+
Status.description = "View the currently logged in user.";
|
|
18
|
+
Status.cmdTxt = format.cmd('apimatic', 'auth', 'status');
|
|
19
|
+
Status.examples = [Status.cmdTxt];
|
|
20
|
+
export default Status;
|
|
21
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE,MAAqB,MAAO,SAAQ,OAAO;IAMzC,KAAK,CAAC,GAAG;QAEP,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,MAAM,CAAC,EAAE;YACtB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,QAAQ,CAAC,CAAA;QACf,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC;QACjG,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,KAAK,CAAC,YAAY,CAAC,CAAA;IACrB,CAAC;;AAhBM,kBAAW,GAAG,oCAAoC,CAAC;AAE3C,aAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC3D,eAAQ,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;eAJf,MAAM"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class PortalCopilot extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
disable: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static cmdTxt: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { Command, Flags } from "@oclif/core";
|
|
3
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
4
|
+
import { FlagsProvider } from "../../types/flags-provider.js";
|
|
5
|
+
import { CopilotAction } from "../../actions/portal/copilot.js";
|
|
6
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
7
|
+
class PortalCopilot extends Command {
|
|
8
|
+
async run() {
|
|
9
|
+
const { flags: { input, "auth-key": authKey, disable, force } } = await this.parse(_a);
|
|
10
|
+
const commandMetadata = {
|
|
11
|
+
commandName: _a.id,
|
|
12
|
+
shell: this.config.shell
|
|
13
|
+
};
|
|
14
|
+
intro("Configure API Copilot");
|
|
15
|
+
const buildDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : "./", "src");
|
|
16
|
+
const copilotConfigAction = new CopilotAction(new DirectoryPath(this.config.configDir), commandMetadata, authKey);
|
|
17
|
+
const result = await copilotConfigAction.execute(buildDirectory, force, !disable);
|
|
18
|
+
outro(result);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
_a = PortalCopilot;
|
|
22
|
+
PortalCopilot.summary = "Configure API Copilot for your API Documentation portal";
|
|
23
|
+
PortalCopilot.description = `Displays available API Copilots associated with your account and allows you to select which one to integrate with your portal. Each APIMatic account includes one Copilot by default. The selected Copilot will be added to your ${format.var("APIMATIC-BUILD.json")} file`;
|
|
24
|
+
PortalCopilot.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), { disable: Flags.boolean({
|
|
25
|
+
default: false,
|
|
26
|
+
description: "marks the API Copilot as disabled in the configuration"
|
|
27
|
+
}) }), FlagsProvider.force), FlagsProvider.force), FlagsProvider.authKey);
|
|
28
|
+
PortalCopilot.cmdTxt = format.cmd("apimatic", "portal", "copilot");
|
|
29
|
+
PortalCopilot.examples = [
|
|
30
|
+
`${_a.cmdTxt} ${format.flag("input", './')}`,
|
|
31
|
+
`${_a.cmdTxt} ${format.flag("input", './')} ${format.flag("disable")}`
|
|
32
|
+
];
|
|
33
|
+
export default PortalCopilot;
|
|
34
|
+
//# sourceMappingURL=copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../src/commands/portal/copilot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAA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AC,KAAK,GACnB,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,OAAO,CARd,CASV;AAEK,oBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,AAA9C,CAA+C;AACrD,sBAAQ,GAAG;IAChB,GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;IAC9C,GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;CACzE,AAHc,CAGb;eArBiB,aAAa"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Command
|
|
2
|
-
export
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export declare class PortalGenerate extends Command {
|
|
3
|
+
static summary: string;
|
|
3
4
|
static description: string;
|
|
4
5
|
static flags: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
force: import("@oclif/
|
|
8
|
-
|
|
9
|
-
"auth-key": flags.IOptionFlag<string>;
|
|
6
|
+
"auth-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
zip: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
destination: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
};
|
|
11
|
+
static cmdTxt: string;
|
|
11
12
|
static examples: string[];
|
|
12
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<void>;
|
|
13
14
|
}
|
|
@@ -1,102 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const utils_1 = require("../../utils/utils");
|
|
10
|
-
class PortalGenerate extends command_1.Command {
|
|
1
|
+
var _a;
|
|
2
|
+
import { Command, Flags } from "@oclif/core";
|
|
3
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
4
|
+
import { GenerateAction } from "../../actions/portal/generate.js";
|
|
5
|
+
import { FlagsProvider } from "../../types/flags-provider.js";
|
|
6
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
7
|
+
const DEFAULT_WORKING_DIRECTORY = "./";
|
|
8
|
+
export class PortalGenerate extends Command {
|
|
11
9
|
async run() {
|
|
12
|
-
const { flags } = this.parse(
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
if (!(await fs.pathExists(flags.destination))) {
|
|
27
|
-
throw new Error(`Destination path ${flags.destination} does not exist`);
|
|
28
|
-
}
|
|
29
|
-
else if (!(await fs.pathExists(flags.folder))) {
|
|
30
|
-
throw new Error(`Portal build folder ${flags.folder} does not exist`);
|
|
31
|
-
}
|
|
32
|
-
const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
|
|
33
|
-
const docsPortalController = new sdk_1.DocsPortalManagementController(client);
|
|
34
|
-
const zippedBuildFilePath = await utils_1.zipDirectory(sourceFolderPath, flags.destination);
|
|
35
|
-
const generatePortalParams = {
|
|
36
|
-
zippedBuildFilePath,
|
|
37
|
-
portalFolderPath,
|
|
38
|
-
zippedPortalPath,
|
|
39
|
-
docsPortalController,
|
|
40
|
-
overrideAuthKey,
|
|
41
|
-
zip
|
|
42
|
-
};
|
|
43
|
-
const generatedPortalPath = await generate_1.downloadDocsPortal(generatePortalParams, this.config.configDir);
|
|
44
|
-
this.log(`Your portal has been generated at ${generatedPortalPath}`);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
if (error && error.response) {
|
|
48
|
-
const apiError = error;
|
|
49
|
-
const apiResponse = apiError.response;
|
|
50
|
-
if (apiResponse) {
|
|
51
|
-
const responseData = apiResponse.data.toString();
|
|
52
|
-
if (apiResponse.status === 422 && responseData.length > 0 && utils_1.isJSONParsable(responseData)) {
|
|
53
|
-
const nestedErrors = JSON.parse(responseData);
|
|
54
|
-
if (nestedErrors.error) {
|
|
55
|
-
return this.error(utils_1.replaceHTML(nestedErrors.error));
|
|
56
|
-
}
|
|
57
|
-
else if (nestedErrors.message) {
|
|
58
|
-
return this.error(utils_1.replaceHTML(nestedErrors.message));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (apiResponse.status === 401 && responseData.length > 0) {
|
|
62
|
-
this.error(utils_1.replaceHTML(responseData));
|
|
63
|
-
}
|
|
64
|
-
else if (apiResponse.status === 403 && apiResponse.statusText) {
|
|
65
|
-
return this.error(utils_1.replaceHTML(apiResponse.statusText));
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
return this.error(apiError.message);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.error(`${error.message}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
10
|
+
const { flags: { input, destination, force, zip: zipPortal, "auth-key": authKey } } = await this.parse(_a);
|
|
11
|
+
const workingDirectory = new DirectoryPath(input !== null && input !== void 0 ? input : DEFAULT_WORKING_DIRECTORY);
|
|
12
|
+
const buildDirectory = input ? new DirectoryPath(input, "src") : workingDirectory.join("src");
|
|
13
|
+
const portalDirectory = destination ? new DirectoryPath(destination) : workingDirectory.join("portal");
|
|
14
|
+
const commandMetadata = {
|
|
15
|
+
commandName: _a.id,
|
|
16
|
+
shell: this.config.shell
|
|
17
|
+
};
|
|
18
|
+
intro("Generate Portal");
|
|
19
|
+
const action = new GenerateAction(new DirectoryPath(this.config.configDir), commandMetadata, authKey);
|
|
20
|
+
const result = await action.execute(buildDirectory, portalDirectory, force, zipPortal);
|
|
21
|
+
outro(result);
|
|
76
22
|
}
|
|
77
23
|
}
|
|
78
|
-
|
|
79
|
-
PortalGenerate.
|
|
80
|
-
PortalGenerate.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
destination: command_1.flags.string({
|
|
87
|
-
parse: (input) => path.resolve(input),
|
|
88
|
-
default: path.resolve("./"),
|
|
89
|
-
description: "path to the downloaded portal"
|
|
90
|
-
}),
|
|
91
|
-
force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if a portal exists in the destination" }),
|
|
92
|
-
zip: command_1.flags.boolean({ default: false, description: "download the generated portal as a .zip archive" }),
|
|
93
|
-
"auth-key": command_1.flags.string({
|
|
94
|
-
default: "",
|
|
95
|
-
description: "override current authentication state with an authentication key"
|
|
96
|
-
})
|
|
97
|
-
};
|
|
24
|
+
_a = PortalGenerate;
|
|
25
|
+
PortalGenerate.summary = "Generate an API Documentation portal";
|
|
26
|
+
PortalGenerate.description = "Generate an API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://docs.apimatic.io/platform-api/#/http/guides/generating-on-prem-api-portal/build-file-reference)";
|
|
27
|
+
PortalGenerate.flags = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, FlagsProvider.input), FlagsProvider.destination("portal", "portal")), FlagsProvider.force), { zip: Flags.boolean({
|
|
28
|
+
default: false,
|
|
29
|
+
description: "Download the generated portal as a .zip archive"
|
|
30
|
+
}) }), FlagsProvider.authKey);
|
|
31
|
+
PortalGenerate.cmdTxt = format.cmd("apimatic", "portal", "generate");
|
|
98
32
|
PortalGenerate.examples = [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
`
|
|
33
|
+
_a.cmdTxt,
|
|
34
|
+
`${_a.cmdTxt} ${format.flag("input", '"./"')} ${format.flag("destination", '"./portal"')}`
|
|
102
35
|
];
|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QAEF,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QACtG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACvF,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;;;AAvCM,sBAAO,GAAG,sCAAsC,AAAzC,CAA0C;AAEjD,0BAAW,GAChB,mSAAmS,AADnR,CACoR;AAE/R,oBAAK,6EACP,aAAa,CAAC,KAAK,GACnB,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAC7C,aAAa,CAAC,KAAK,KACtB,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QACjB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,iDAAiD;KAC/D,CAAC,KACC,aAAa,CAAC,OAAO,CARd,CASV;AAEK,qBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,AAA/C,CAAgD;AACtD,uBAAQ,GAAG;IAChB,EAAI,CAAC,MAAM;IACX,GAAG,EAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE;CAC7F,AAHc,CAGb"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class PortalQuickstart extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static summary: string;
|
|
5
|
+
static cmdTxt: string;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
run(): Promise<void>;
|
|
8
|
+
private readonly getConfigDir;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { Command } from "@oclif/core";
|
|
3
|
+
import { PortalQuickstartAction } from "../../actions/portal/quickstart.js";
|
|
4
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
5
|
+
import { TelemetryService } from "../../infrastructure/services/telemetry-service.js";
|
|
6
|
+
import { QuickstartInitiatedEvent } from "../../types/events/quickstart-initiated.js";
|
|
7
|
+
import { QuickstartCompletedEvent } from "../../types/events/quickstart-completed.js";
|
|
8
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
9
|
+
class PortalQuickstart extends Command {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.getConfigDir = () => {
|
|
13
|
+
return new DirectoryPath(this.config.configDir);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async run() {
|
|
17
|
+
const telemetryService = new TelemetryService(this.getConfigDir());
|
|
18
|
+
const commandMetadata = {
|
|
19
|
+
commandName: _a.id,
|
|
20
|
+
shell: this.config.shell
|
|
21
|
+
};
|
|
22
|
+
await telemetryService.trackEvent(new QuickstartInitiatedEvent(), commandMetadata.shell);
|
|
23
|
+
intro("Portal Quickstart");
|
|
24
|
+
const action = new PortalQuickstartAction(this.getConfigDir(), commandMetadata);
|
|
25
|
+
const result = await action.execute();
|
|
26
|
+
outro(result);
|
|
27
|
+
// TODO: Remove this, find a solution for tracking.
|
|
28
|
+
await result.mapAll(async () => await telemetryService.trackEvent(new QuickstartCompletedEvent(), commandMetadata.shell), () => new Promise(() => { }), () => new Promise(() => { }));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
_a = PortalQuickstart;
|
|
32
|
+
PortalQuickstart.description = "Create your first API Portal using APIMatic's Docs as Code offering.";
|
|
33
|
+
PortalQuickstart.summary = "Get started with your first API Portal in four easy steps.";
|
|
34
|
+
PortalQuickstart.cmdTxt = format.cmd("apimatic", "portal", "quickstart");
|
|
35
|
+
PortalQuickstart.examples = [_a.cmdTxt];
|
|
36
|
+
export default PortalQuickstart;
|
|
37
|
+
//# sourceMappingURL=quickstart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/commands/portal/quickstart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAEtF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAqB,gBAAiB,SAAQ,OAAO;IAArD;;QA+BmB,iBAAY,GAAG,GAAG,EAAE;YACnC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IAzBC,KAAK,CAAC,GAAG;QACP,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACnE,MAAM,eAAe,GAAoB;YACvC,WAAW,EAAE,EAAgB,CAAC,EAAE;YAChC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;SACzB,CAAC;QAEF,MAAM,gBAAgB,CAAC,UAAU,CAAC,IAAI,wBAAwB,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;QAEzF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,eAAe,CAAC,CAAC;QAChF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,mDAAmD;QACnD,MAAM,MAAM,CAAC,MAAM,CACjB,KAAK,IAAI,EAAE,CAAC,MAAM,gBAAgB,CAAC,UAAU,CAAC,IAAI,wBAAwB,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,EACpG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAC5B,CAAC;IACJ,CAAC;;;AA5BM,4BAAW,GAAG,sEAAsE,AAAzE,CAA0E;AAErF,wBAAO,GAAG,4DAA4D,AAA/D,CAAgE;AAEvE,uBAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,AAAjD,CAAkD;AAExD,yBAAQ,GAAG,CAAC,EAAI,CAAC,MAAM,CAAC,AAAhB,CAAiB;eAPb,gBAAgB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class PortalRecipeNew extends Command {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static readonly cmdTxt: string;
|
|
10
|
+
static readonly examples: string[];
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|