@apimatic/cli 1.1.0-alpha.9 → 1.1.0-beta.2
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 +436 -374
- 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 +11 -5
- package/lib/actions/portal/generate.js +60 -55
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/quickstart.d.ts +16 -0
- package/lib/actions/portal/quickstart.js +146 -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 +177 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +15 -0
- package/lib/actions/portal/serve.js +118 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +17 -13
- package/lib/actions/portal/toc/new-toc.js +85 -122
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/quickstart.d.ts +10 -0
- package/lib/actions/quickstart.js +30 -0
- package/lib/actions/quickstart.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/actions/sdk/quickstart.d.ts +14 -0
- package/lib/actions/sdk/quickstart.js +149 -0
- package/lib/actions/sdk/quickstart.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 +145 -0
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
- package/lib/application/portal/toc/toc-content-parser.d.ts +1 -1
- package/lib/application/portal/toc/toc-content-parser.js +9 -11
- package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
- package/lib/application/portal/toc/toc-structure-generator.d.ts +1 -1
- package/lib/application/portal/toc/toc-structure-generator.js +4 -8
- package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
- package/lib/client-utils/auth-manager.d.ts +7 -2
- 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 +10 -7
- package/lib/commands/api/transform.js +51 -111
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +7 -4
- package/lib/commands/api/validate.js +31 -74
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +3 -1
- package/lib/commands/auth/login.js +26 -68
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +3 -1
- package/lib/commands/auth/logout.js +14 -21
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +1 -0
- package/lib/commands/auth/status.js +18 -21
- 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 +7 -11
- package/lib/commands/portal/generate.js +26 -89
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +12 -0
- package/lib/commands/portal/recipe/new.js +45 -0
- package/lib/commands/portal/recipe/new.js.map +1 -0
- package/lib/commands/portal/serve.d.ts +8 -8
- package/lib/commands/portal/serve.js +41 -125
- package/lib/commands/portal/serve.js.map +1 -0
- package/lib/commands/portal/toc/new.d.ts +5 -6
- package/lib/commands/portal/toc/new.js +45 -50
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/quickstart.d.ts +9 -0
- package/lib/commands/quickstart.js +37 -0
- package/lib/commands/quickstart.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +10 -8
- package/lib/commands/sdk/generate.js +46 -131
- package/lib/commands/sdk/generate.js.map +1 -0
- package/lib/config/axios-config.js +4 -6
- 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.js +2 -5
- package/lib/index.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 +24 -0
- package/lib/infrastructure/file-service.js +120 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/launcher-service.d.ts +9 -0
- package/lib/infrastructure/launcher-service.js +72 -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/service-error.d.ts +16 -0
- package/lib/infrastructure/service-error.js +49 -0
- package/lib/infrastructure/service-error.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 +12 -0
- package/lib/infrastructure/services/api-service.js +79 -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 +17 -12
- package/lib/infrastructure/services/portal-service.js +134 -99
- 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 +29 -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 +40 -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 +22 -0
- package/lib/prompts/auth/status.js.map +1 -0
- package/lib/prompts/format.d.ts +31 -0
- package/lib/prompts/format.js +89 -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 -8
- package/lib/prompts/portal/generate.js +36 -53
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +28 -29
- package/lib/prompts/portal/quickstart.js +102 -185
- 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 +9 -5
- package/lib/prompts/portal/serve.js +29 -19
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +13 -8
- package/lib/prompts/portal/toc/new-toc.js +28 -36
- package/lib/prompts/portal/toc/new-toc.js.map +1 -0
- package/lib/prompts/prompt.d.ts +3 -0
- package/lib/prompts/prompt.js +37 -0
- package/lib/prompts/prompt.js.map +1 -0
- package/lib/prompts/quickstart.d.ts +6 -0
- package/lib/prompts/quickstart.js +25 -0
- package/lib/prompts/quickstart.js.map +1 -0
- package/lib/prompts/sdk/generate.d.ts +11 -0
- package/lib/prompts/sdk/generate.js +37 -0
- package/lib/prompts/sdk/generate.js.map +1 -0
- package/lib/prompts/sdk/quickstart.d.ts +32 -0
- package/lib/prompts/sdk/quickstart.js +140 -0
- package/lib/prompts/sdk/quickstart.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 +14 -25
- package/lib/types/api/transform.js +20 -23
- 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 +13 -0
- package/lib/types/build-context.js +33 -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 +87 -0
- package/lib/types/file/directory.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +10 -0
- package/lib/types/file/directoryPath.js +26 -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 +9 -0
- package/lib/types/recipe-context.js +26 -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 -22
- package/lib/types/sdk/generate.js +25 -14
- 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 +10 -0
- package/lib/types/sdl/sdl.js +47 -3
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +12 -0
- package/lib/types/spec-context.js +29 -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.js +2 -10
- 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 +0 -9
- package/lib/types/utils.js +2 -3
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/string-utils.d.ts +2 -0
- package/lib/utils/string-utils.js +37 -0
- package/lib/utils/string-utils.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -44
- package/lib/utils/utils.js +14 -366
- package/lib/utils/utils.js.map +1 -0
- package/package.json +50 -31
- package/bin/run +0 -9
- package/lib/application/portal/toc/sdl-parser.d.ts +0 -13
- package/lib/application/portal/toc/sdl-parser.js +0 -53
- package/lib/client-utils/sdk-client.d.ts +0 -23
- package/lib/client-utils/sdk-client.js +0 -124
- package/lib/commands/portal/quickstart.d.ts +0 -10
- package/lib/commands/portal/quickstart.js +0 -79
- package/lib/config/env.d.ts +0 -27
- package/lib/config/env.js +0 -31
- package/lib/controllers/api/transform.d.ts +0 -5
- package/lib/controllers/api/transform.js +0 -56
- package/lib/controllers/api/validate.d.ts +0 -3
- package/lib/controllers/api/validate.js +0 -33
- package/lib/controllers/portal/generate.d.ts +0 -3
- package/lib/controllers/portal/generate.js +0 -110
- package/lib/controllers/portal/quickstart.d.ts +0 -14
- package/lib/controllers/portal/quickstart.js +0 -258
- package/lib/controllers/portal/serve.d.ts +0 -3
- package/lib/controllers/portal/serve.js +0 -138
- package/lib/controllers/sdk/generate.d.ts +0 -4
- package/lib/controllers/sdk/generate.js +0 -66
- package/lib/services/portal/server.d.ts +0 -14
- package/lib/services/portal/server.js +0 -101
- package/lib/types/api/validate.d.ts +0 -12
- package/lib/types/api/validate.js +0 -3
- package/lib/types/common/result.d.ts +0 -17
- package/lib/types/common/result.js +0 -36
- package/lib/types/portal/generate.d.ts +0 -26
- package/lib/types/portal/generate.js +0 -4
- package/lib/types/portal/quickstart.d.ts +0 -17
- package/lib/types/portal/quickstart.js +0 -3
- package/lib/validators/common/directoryValidator.d.ts +0 -9
- package/lib/validators/common/directoryValidator.js +0 -53
- package/lib/validators/common/portValidator.d.ts +0 -5
- package/lib/validators/common/portValidator.js +0 -20
- package/lib/validators/portal/serveValidator.d.ts +0 -6
- package/lib/validators/portal/serveValidator.js +0 -21
|
@@ -1,138 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 { GenerateAction } from "../../actions/sdk/generate.js";
|
|
5
|
+
import { Language } from "../../types/sdk/generate.js";
|
|
6
|
+
import { format, intro, outro } from "../../prompts/format.js";
|
|
7
|
+
class SdkGenerate extends Command {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.getConfigDir = () => {
|
|
11
|
+
return new DirectoryPath(this.config.configDir);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
12
14
|
async run() {
|
|
13
|
-
const { flags } = await this.parse(
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
if (!(await fs.pathExists(path.resolve(flags.destination)))) {
|
|
27
|
-
throw new Error(`Destination path ${flags.destination} does not exist`);
|
|
28
|
-
}
|
|
29
|
-
else if (!(await fs.pathExists(path.resolve(flags.file)))) {
|
|
30
|
-
throw new Error(`Specification file ${flags.file} does not exist`);
|
|
31
|
-
}
|
|
32
|
-
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
33
|
-
const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
|
|
34
|
-
const sdkGenerationController = new sdk_1.CodeGenerationExternalApIsController(client);
|
|
35
|
-
// Get generation id for the specification and platform
|
|
36
|
-
const codeGenId = await (0, generate_1.getSDKGenerationId)(flags, sdkGenerationController);
|
|
37
|
-
// If user wanted to download the SDK as well
|
|
38
|
-
const sdkDownloadParams = {
|
|
39
|
-
codeGenId,
|
|
40
|
-
zippedSDKPath,
|
|
41
|
-
sdkFolderPath,
|
|
42
|
-
zip
|
|
43
|
-
};
|
|
44
|
-
const sdkPath = await (0, generate_1.downloadGeneratedSDK)(sdkDownloadParams, sdkGenerationController);
|
|
45
|
-
this.log(`Success! Your SDK is located at ${sdkPath}`);
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
if (error.result) {
|
|
49
|
-
const apiError = error;
|
|
50
|
-
const result = apiError.result;
|
|
51
|
-
if (apiError.statusCode === 400 && (0, utils_1.isJSONParsable)(result.message)) {
|
|
52
|
-
const errors = JSON.parse(result.message);
|
|
53
|
-
if (Array.isArray(errors.Errors) && apiError.statusCode === 400) {
|
|
54
|
-
this.error((0, utils_1.replaceHTML)(`${JSON.parse(result.message).Errors[0]}`));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else if (apiError.statusCode === 401 && apiError.body && typeof apiError.body === "string") {
|
|
58
|
-
this.error("You are not authorized to perform this action");
|
|
59
|
-
}
|
|
60
|
-
else if (apiError.statusCode === 500 &&
|
|
61
|
-
apiError.body &&
|
|
62
|
-
typeof apiError.body === "string" &&
|
|
63
|
-
(0, utils_1.isJSONParsable)(apiError.body)) {
|
|
64
|
-
this.error(JSON.parse(apiError.body).message);
|
|
65
|
-
}
|
|
66
|
-
else if (apiError.statusCode === 422 &&
|
|
67
|
-
apiError.body &&
|
|
68
|
-
typeof apiError.body === "string" &&
|
|
69
|
-
(0, utils_1.isJSONParsable)(apiError.body)) {
|
|
70
|
-
this.error(JSON.parse(apiError.body)["dto.Url"][0]);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.error((0, utils_1.replaceHTML)(result.message));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (error.statusCode === 401) {
|
|
77
|
-
this.error("You are not authorized to perform this action");
|
|
78
|
-
}
|
|
79
|
-
else if (error.statusCode === 402 &&
|
|
80
|
-
error.body &&
|
|
81
|
-
typeof error.body === "string") {
|
|
82
|
-
this.error((0, utils_1.replaceHTML)(error.body));
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
this.error(`${error.message}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
15
|
+
const { flags: { language, spec, destination, force, zip: zipSdk, "auth-key": authKey } } = await this.parse(SdkGenerate);
|
|
16
|
+
const specDirectory = new DirectoryPath(spec);
|
|
17
|
+
const sdkDirectory = destination ? new DirectoryPath(destination) : DirectoryPath.default.join("sdk");
|
|
18
|
+
const commandMetadata = {
|
|
19
|
+
commandName: SdkGenerate.id,
|
|
20
|
+
shell: this.config.shell
|
|
21
|
+
};
|
|
22
|
+
intro("Generate SDK");
|
|
23
|
+
const action = new GenerateAction(this.getConfigDir(), commandMetadata, authKey);
|
|
24
|
+
const result = await action.execute(specDirectory, sdkDirectory, language, force, zipSdk);
|
|
25
|
+
outro(result);
|
|
88
26
|
}
|
|
89
27
|
}
|
|
90
|
-
|
|
91
|
-
SdkGenerate.description =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
28
|
+
SdkGenerate.summary = "Generate an SDK for your API";
|
|
29
|
+
SdkGenerate.description = `Generate Software Development Kits (SDKs) from API specifications.
|
|
30
|
+
Supports multiple programming languages including Java, C#, Python, JavaScript, and more.`;
|
|
31
|
+
SdkGenerate.cmdTxt = format.cmd("apimatic", "sdk", "generate");
|
|
32
|
+
SdkGenerate.flags = Object.assign(Object.assign(Object.assign({ language: Flags.string({
|
|
33
|
+
char: "l",
|
|
95
34
|
required: true,
|
|
96
|
-
description:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
description: "
|
|
104
|
-
}),
|
|
105
|
-
url: core_1.Flags.string({
|
|
106
|
-
default: "",
|
|
107
|
-
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."
|
|
108
|
-
}),
|
|
109
|
-
destination: core_1.Flags.string({
|
|
110
|
-
parse: async (input) => path.resolve(input),
|
|
111
|
-
default: path.resolve("./"),
|
|
112
|
-
description: "directory to download the generated SDK to"
|
|
113
|
-
}),
|
|
114
|
-
force: core_1.Flags.boolean({
|
|
115
|
-
char: "f",
|
|
35
|
+
description: "Programming language for SDK generation",
|
|
36
|
+
options: Object.values(Language).map((p) => p.valueOf()),
|
|
37
|
+
}), spec: Flags.string({
|
|
38
|
+
description: "Path to the folder containing the API specification file",
|
|
39
|
+
default: "./src/spec"
|
|
40
|
+
}), destination: Flags.string({
|
|
41
|
+
char: "d",
|
|
42
|
+
description: "Directory where the SDK will be generated"
|
|
43
|
+
}) }, FlagsProvider.force), { zip: Flags.boolean({
|
|
116
44
|
default: false,
|
|
117
|
-
description: "
|
|
118
|
-
}),
|
|
119
|
-
zip: core_1.Flags.boolean({ default: false, description: "download the generated SDK as a .zip archive" }),
|
|
120
|
-
"auth-key": core_1.Flags.string({
|
|
121
|
-
default: "",
|
|
122
|
-
description: "override current authentication state with an authentication key"
|
|
123
|
-
})
|
|
124
|
-
};
|
|
45
|
+
description: "Download the generated SDK as a .zip archive"
|
|
46
|
+
}) }), FlagsProvider.authKey);
|
|
125
47
|
SdkGenerate.examples = [
|
|
126
|
-
`$
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Success! Your SDK is located at swagger_sdk_csharp`,
|
|
130
|
-
`
|
|
131
|
-
$ apimatic sdk:generate --platform="CSHARP" --url=https://petstore.swagger.io/v2/swagger.json
|
|
132
|
-
Generating SDK... done
|
|
133
|
-
Downloading SDK... done
|
|
134
|
-
Success! Your SDK is located at swagger_sdk_csharp
|
|
135
|
-
`
|
|
48
|
+
`${SdkGenerate.cmdTxt} ${format.flag("language", "java")}`,
|
|
49
|
+
`${SdkGenerate.cmdTxt} ${format.flag("language", "csharp")} ${format.flag("spec", "./src/spec")}`,
|
|
50
|
+
`${SdkGenerate.cmdTxt} ${format.flag("language", "python")} ${format.flag("destination", "./sdk")} ${format.flag("zip")}`
|
|
136
51
|
];
|
|
137
|
-
|
|
138
|
-
//# sourceMappingURL=
|
|
52
|
+
export default SdkGenerate;
|
|
53
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/sdk/generate.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;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAqB,WAAY,SAAQ,OAAO;IAAhD;;QA0DmB,iBAAY,GAAG,GAAG,EAAE;YACnC,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IAtBC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,EAChF,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAElC,MAAM,aAAa,GAAG,IAAI,aAAa,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AG;QACT,WAAW,EAAE,2CAA2C;KACzD,CAAC,IACC,aAAa,CAAC,KAAK,KACtB,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;QACjB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,8CAA8C;KAC5D,CAAC,KACC,aAAa,CAAC,OAAO,CApBd,CAqBV;AAEK,oBAAQ,GAAG;IAChB,GAAG,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE;IAC1D,GAAG,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;IACjG,GAAG,WAAW,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAC9G,KAAK,CACN,EAAE;CACJ,AANc,CAMb;eArCiB,WAAW"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const axios_1 = require("axios");
|
|
1
|
+
import axios from "axios";
|
|
4
2
|
const fiftyMBsInBytes = 50 * 1024 * 1024;
|
|
5
3
|
const fiveMinutesInMilliseconds = 5 * 60 * 1000;
|
|
6
|
-
const axiosInstance =
|
|
4
|
+
const axiosInstance = axios.create({
|
|
7
5
|
maxContentLength: fiftyMBsInBytes,
|
|
8
6
|
maxBodyLength: fiftyMBsInBytes,
|
|
9
7
|
timeout: fiveMinutesInMilliseconds
|
|
10
8
|
});
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=
|
|
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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// This code was originally forked from https://github.com/oclif/plugin-not-found/blob/main/src/index.ts
|
|
2
|
+
import { toConfiguredId } from "@oclif/core";
|
|
3
|
+
import { cyan, yellow } from "ansis";
|
|
4
|
+
import utils from "./utils.js";
|
|
5
|
+
const hook = async function (opts) {
|
|
6
|
+
var _a;
|
|
7
|
+
const hiddenCommandIds = new Set(opts.config.commands.filter((c) => c.hidden).map((c) => c.id));
|
|
8
|
+
const commandIDs = [...opts.config.commandIDs, ...opts.config.commands.flatMap((c) => c.aliases)].filter((c) => !hiddenCommandIds.has(c));
|
|
9
|
+
if (commandIDs.length === 0)
|
|
10
|
+
return;
|
|
11
|
+
let binHelp = `${opts.config.bin} help`;
|
|
12
|
+
const idSplit = opts.id.split(":");
|
|
13
|
+
if (opts.config.findTopic(idSplit[0])) {
|
|
14
|
+
binHelp = `${binHelp} ${idSplit[0]}`;
|
|
15
|
+
}
|
|
16
|
+
let suggestion;
|
|
17
|
+
if (/:?help:?/.test(opts.id)) {
|
|
18
|
+
suggestion = ["help", ...opts.id.split(":").filter((cmd) => cmd !== "help")].join(":");
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
suggestion = utils.closest(opts.id, commandIDs);
|
|
22
|
+
}
|
|
23
|
+
const readableSuggestion = suggestion ? toConfiguredId(suggestion, this.config) : null;
|
|
24
|
+
const originalCmd = toConfiguredId(opts.id, this.config);
|
|
25
|
+
this.warn(`${yellow(originalCmd)} is not a ${opts.config.bin} command.`);
|
|
26
|
+
if (!process.stdin.isTTY || !suggestion) {
|
|
27
|
+
this.error(`Run ${cyan.bold(binHelp)} for a list of available commands.`, {
|
|
28
|
+
exit: 127
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
let response;
|
|
32
|
+
try {
|
|
33
|
+
response = await utils.getConfirmation(readableSuggestion);
|
|
34
|
+
}
|
|
35
|
+
catch (_b) {
|
|
36
|
+
response = false;
|
|
37
|
+
}
|
|
38
|
+
if (response) {
|
|
39
|
+
const confirmedSuggestion = suggestion;
|
|
40
|
+
let argv = ((_a = opts.argv) === null || _a === void 0 ? void 0 : _a.length) ? opts.argv : opts.id.split(":").slice(confirmedSuggestion.split(":").length);
|
|
41
|
+
if (confirmedSuggestion.startsWith("help:")) {
|
|
42
|
+
argv = confirmedSuggestion.split(":").slice(1);
|
|
43
|
+
suggestion = "help";
|
|
44
|
+
}
|
|
45
|
+
return this.config.runCommand(confirmedSuggestion, argv);
|
|
46
|
+
}
|
|
47
|
+
this.error(`Run ${cyan.bold(binHelp)} for a list of available commands.`, {
|
|
48
|
+
exit: 127
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export default hook;
|
|
52
|
+
//# sourceMappingURL=not-found.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found.js","sourceRoot":"","sources":["../../src/hooks/not-found.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,EAAQ,cAAc,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,IAAI,GAAyB,KAAK,WAAW,IAAI;;IACrD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,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CAAC;YAC/C,UAAU,GAAG,MAAM,CAAC;QACtB,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oCAAoC,EAAE;QACxE,IAAI,EAAE,GAAG;KACV,CAAC,CAAC;AAEL,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// This code was originally forked from https://github.com/oclif/plugin-not-found/blob/main/src/utils.ts
|
|
2
|
+
import readline from 'node:readline';
|
|
3
|
+
import { blueBright, reset } from 'ansis';
|
|
4
|
+
import levenshtein from 'fast-levenshtein';
|
|
5
|
+
const getConfirmation = async (suggestion) => {
|
|
6
|
+
if (!process.stdin.isTTY)
|
|
7
|
+
return false;
|
|
8
|
+
const question = `${reset('Did you mean ' + blueBright(suggestion) + '?')} (Y/n) `;
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const rl = readline.createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stdout,
|
|
13
|
+
});
|
|
14
|
+
let settled = false;
|
|
15
|
+
const cleanup = () => {
|
|
16
|
+
rl.close();
|
|
17
|
+
clearTimeout(timeout);
|
|
18
|
+
};
|
|
19
|
+
const finish = (result) => {
|
|
20
|
+
if (!settled) {
|
|
21
|
+
settled = true;
|
|
22
|
+
cleanup();
|
|
23
|
+
resolve(result);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const timeout = setTimeout(() => {
|
|
27
|
+
finish(false);
|
|
28
|
+
}, 10000);
|
|
29
|
+
rl.question(question, (answer) => {
|
|
30
|
+
const a = (answer !== null && answer !== void 0 ? answer : '').trim().toLowerCase();
|
|
31
|
+
finish(a === '' || a === 'y' || a === 'yes');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const closest = (target, possibilities) => {
|
|
36
|
+
let best = null;
|
|
37
|
+
let bestDistance = Infinity;
|
|
38
|
+
for (const id of possibilities) {
|
|
39
|
+
const distance = levenshtein.get(target, id, { useCollator: true });
|
|
40
|
+
if (distance < bestDistance) {
|
|
41
|
+
bestDistance = distance;
|
|
42
|
+
best = id;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return best;
|
|
46
|
+
};
|
|
47
|
+
export default {
|
|
48
|
+
closest,
|
|
49
|
+
getConfirmation,
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/hooks/utils.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,MAAM,eAAe,GAAG,KAAK,EAAE,UAAkB,EAAoB,EAAE;IACrE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEvC,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,eAAe,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC;IAEnF,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC,CAAC;QAEF,MA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|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var core_1 = require("@oclif/core");
|
|
4
|
-
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxvQ0FBa0M7QUFBekIsMkZBQUEsR0FBRyxPQUFBIn0=
|
|
1
|
+
export { run } from "@oclif/core";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class DebounceService {
|
|
2
|
+
private isProcessing;
|
|
3
|
+
private latestHandler;
|
|
4
|
+
private debounceTimer;
|
|
5
|
+
private readonly debounceMs;
|
|
6
|
+
constructor(debounceMs?: number);
|
|
7
|
+
batchSingleRequest(handler: () => Promise<void>): Promise<void>;
|
|
8
|
+
private scheduleExecution;
|
|
9
|
+
close(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { clearTimeout, setTimeout } from "timers";
|
|
2
|
+
export class DebounceService {
|
|
3
|
+
constructor(debounceMs = 500) {
|
|
4
|
+
this.isProcessing = false;
|
|
5
|
+
this.latestHandler = null;
|
|
6
|
+
this.debounceTimer = null;
|
|
7
|
+
this.debounceMs = debounceMs;
|
|
8
|
+
}
|
|
9
|
+
async batchSingleRequest(handler) {
|
|
10
|
+
// Always store the latest handler
|
|
11
|
+
this.latestHandler = handler;
|
|
12
|
+
// If already processing, don't start a new timer. Just update the latest handler
|
|
13
|
+
if (this.isProcessing) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
// Clear any existing timer
|
|
17
|
+
if (this.debounceTimer) {
|
|
18
|
+
clearTimeout(this.debounceTimer);
|
|
19
|
+
}
|
|
20
|
+
// Set up debounced execution
|
|
21
|
+
this.scheduleExecution();
|
|
22
|
+
}
|
|
23
|
+
scheduleExecution() {
|
|
24
|
+
this.debounceTimer = setTimeout(async () => {
|
|
25
|
+
if (this.isProcessing) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.isProcessing = true;
|
|
29
|
+
this.debounceTimer = null;
|
|
30
|
+
try {
|
|
31
|
+
// Execute the latest handler if it exists
|
|
32
|
+
if (this.latestHandler) {
|
|
33
|
+
const currentHandler = this.latestHandler;
|
|
34
|
+
this.latestHandler = null;
|
|
35
|
+
await currentHandler();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
this.isProcessing = false;
|
|
40
|
+
}
|
|
41
|
+
}, this.debounceMs);
|
|
42
|
+
}
|
|
43
|
+
// Method to clear any pending execution.
|
|
44
|
+
close() {
|
|
45
|
+
if (this.debounceTimer) {
|
|
46
|
+
clearTimeout(this.debounceTimer);
|
|
47
|
+
this.debounceTimer = null;
|
|
48
|
+
}
|
|
49
|
+
this.latestHandler = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=debounce-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce-service.js","sourceRoot":"","sources":["../../src/infrastructure/debounce-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAElD,MAAM,OAAO,eAAe;IAM1B,YAAY,aAAqB,GAAG;QAL5B,iBAAY,GAAG,KAAK,CAAC;QACrB,kBAAa,GAAiC,IAAI,CAAC;QACnD,kBAAa,GAA0B,IAAI,CAAC;QAIlD,IAAI,CAAC,UA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
|
1
|
+
declare class EnvInfo {
|
|
2
|
+
private static cachedCliVersion;
|
|
3
|
+
private static cachedUserAgent;
|
|
4
|
+
private static cachedBaseUrl;
|
|
5
|
+
private static cachedAuthBaseUrl;
|
|
6
|
+
getUserAgent(shell: string): string;
|
|
7
|
+
getCLIVersion(): string;
|
|
8
|
+
getBaseUrl(): string | undefined;
|
|
9
|
+
getAuthBaseUrl(): string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare const envInfo: EnvInfo;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
class EnvInfo {
|
|
6
|
+
getUserAgent(shell) {
|
|
7
|
+
if (!EnvInfo.cachedUserAgent) {
|
|
8
|
+
const osInfo = `${os.platform()} ${os.release()}`;
|
|
9
|
+
const engine = "Node.js";
|
|
10
|
+
const engineVersion = process.version;
|
|
11
|
+
EnvInfo.cachedUserAgent = `APIMATIC CLI/${this.getCLIVersion()} - (OS: ${osInfo}, Engine: ${engine}/${engineVersion}, Shell: ${shell})`;
|
|
12
|
+
}
|
|
13
|
+
return EnvInfo.cachedUserAgent;
|
|
14
|
+
}
|
|
15
|
+
getCLIVersion() {
|
|
16
|
+
if (EnvInfo.cachedCliVersion) {
|
|
17
|
+
return EnvInfo.cachedCliVersion;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = dirname(__filename);
|
|
22
|
+
const pkgPath = join(__dirname, "../../package.json");
|
|
23
|
+
const pkgJson = fs.readFileSync(pkgPath, "utf-8");
|
|
24
|
+
const pkg = JSON.parse(pkgJson);
|
|
25
|
+
const version = pkg.version || "unknown";
|
|
26
|
+
EnvInfo.cachedCliVersion = version;
|
|
27
|
+
return version;
|
|
28
|
+
}
|
|
29
|
+
catch (_a) {
|
|
30
|
+
return "unknown";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
getBaseUrl() {
|
|
34
|
+
if (EnvInfo.cachedBaseUrl) {
|
|
35
|
+
return EnvInfo.cachedBaseUrl;
|
|
36
|
+
}
|
|
37
|
+
const envBaseUrls = process.env.APIMATIC_BASE_URL;
|
|
38
|
+
if (envBaseUrls) {
|
|
39
|
+
EnvInfo.cachedBaseUrl = envBaseUrls.split(";")[0];
|
|
40
|
+
}
|
|
41
|
+
return EnvInfo.cachedBaseUrl;
|
|
42
|
+
}
|
|
43
|
+
getAuthBaseUrl() {
|
|
44
|
+
if (EnvInfo.cachedAuthBaseUrl) {
|
|
45
|
+
return EnvInfo.cachedAuthBaseUrl;
|
|
46
|
+
}
|
|
47
|
+
const envBaseUrls = process.env.APIMATIC_BASE_URL;
|
|
48
|
+
if (envBaseUrls) {
|
|
49
|
+
const baseUrls = envBaseUrls.split(";");
|
|
50
|
+
EnvInfo.cachedAuthBaseUrl = baseUrls.length === 2 ? baseUrls[1] : undefined;
|
|
51
|
+
}
|
|
52
|
+
return EnvInfo.cachedAuthBaseUrl;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
EnvInfo.cachedCliVersion = null;
|
|
56
|
+
EnvInfo.cachedUserAgent = null;
|
|
57
|
+
export const envInfo = new EnvInfo();
|
|
58
|
+
//# sourceMappingURL=env-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-info.js","sourceRoot":"","sources":["../../src/infrastructure/env-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,MAAM,OAAO;IAMJ,YAAY,CAAC,KAAa;QAC/B,IAAI,CAAC,OAAO,CAAC,eA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WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,OAAO,CAAC,aAAa,CAAC;IAC/B,CAAC;IAEM,cAAc;QACnB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,iBAAiB,CAAC;QACnC,CAAC;QACD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAClD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxC,OAAO,CAAC,iBAAiB,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9E,CAAC;QACD,OAAO,OAAO,CAAC,iBAAiB,CAAC;IACnC,CAAC;;AAvDc,wBAAgB,GAAkB,IAAI,CAAC;AACvC,uBAAe,GAAkB,IAAI,CAAC;AAwDvD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { FilePath } from "../types/file/filePath.js";
|
|
3
|
+
import { DirectoryPath } from "../types/file/directoryPath.js";
|
|
4
|
+
import { Directory } from "../types/file/directory.js";
|
|
5
|
+
export declare class FileService {
|
|
6
|
+
fileExists(file: FilePath): Promise<boolean>;
|
|
7
|
+
directoryExists(dir: DirectoryPath): Promise<boolean>;
|
|
8
|
+
directoryEmpty(dir: DirectoryPath): Promise<boolean>;
|
|
9
|
+
cleanDirectory(dir: DirectoryPath): Promise<void>;
|
|
10
|
+
createDirectoryIfNotExists(dir: DirectoryPath): Promise<void>;
|
|
11
|
+
getDirectory(directoryPath: DirectoryPath): Promise<Directory>;
|
|
12
|
+
copyDirectoryContents(source: DirectoryPath, destination: DirectoryPath): Promise<void>;
|
|
13
|
+
deleteFile(filePath: FilePath): Promise<void>;
|
|
14
|
+
deleteDirectory(dirPath: DirectoryPath): Promise<void>;
|
|
15
|
+
getRelativePath(filePath: FilePath, basePath: DirectoryPath): string;
|
|
16
|
+
getStream(filePath: FilePath): Promise<fs.ReadStream>;
|
|
17
|
+
getContents(filePath: FilePath): Promise<string>;
|
|
18
|
+
writeFile(filePath: FilePath, stream: NodeJS.ReadableStream): Promise<void>;
|
|
19
|
+
ensurePathExists(filePath: FilePath): Promise<void>;
|
|
20
|
+
writeContents(filePath: FilePath, contents: string): Promise<void>;
|
|
21
|
+
copy(source: FilePath, destination: FilePath): Promise<void>;
|
|
22
|
+
copyToDir(source: FilePath, destination: DirectoryPath): Promise<void>;
|
|
23
|
+
isZipFile(filePath: FilePath): Promise<boolean>;
|
|
24
|
+
}
|