@apimatic/cli 1.1.0-alpha.2 → 1.1.0-alpha.20
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 +249 -99
- package/bin/run.js +5 -0
- package/lib/actions/action-result.d.ts +8 -0
- package/lib/actions/action-result.js +25 -0
- package/lib/actions/action-result.js.map +1 -0
- package/lib/actions/auth/login.d.ts +12 -0
- package/lib/actions/auth/login.js +63 -0
- package/lib/actions/auth/login.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +11 -0
- package/lib/actions/portal/copilot.js +49 -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 +61 -0
- package/lib/actions/portal/generate.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +24 -0
- package/lib/actions/portal/recipe/new-recipe.js +250 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/serve.d.ts +14 -0
- package/lib/actions/portal/serve.js +24 -0
- package/lib/actions/portal/serve.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +20 -0
- package/lib/actions/portal/toc/new-toc.js +133 -0
- package/lib/actions/portal/toc/new-toc.js.map +1 -0
- package/lib/actions/sdk/generate.d.ts +14 -0
- package/lib/actions/sdk/generate.js +72 -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 +16 -0
- package/lib/application/portal/recipe/recipe-generator.js +147 -0
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
- package/lib/application/portal/serve/portal-watcher.d.ts +11 -0
- package/lib/application/portal/serve/portal-watcher.js +64 -0
- package/lib/application/portal/serve/portal-watcher.js.map +1 -0
- package/lib/application/portal/serve/serve-handler.d.ts +16 -0
- package/lib/application/portal/serve/serve-handler.js +91 -0
- package/lib/application/portal/serve/serve-handler.js.map +1 -0
- package/lib/application/portal/serve/watcher-handler.d.ts +10 -0
- package/lib/application/portal/serve/watcher-handler.js +51 -0
- package/lib/application/portal/serve/watcher-handler.js.map +1 -0
- package/lib/application/portal/toc/sdl-parser.d.ts +19 -0
- package/lib/application/portal/toc/sdl-parser.js +90 -0
- package/lib/application/portal/toc/sdl-parser.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 +23 -10
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/client-utils/sdk-client.d.ts +0 -1
- package/lib/client-utils/sdk-client.js +25 -55
- package/lib/client-utils/sdk-client.js.map +1 -0
- package/lib/commands/api/transform.d.ts +7 -7
- package/lib/commands/api/transform.js +43 -51
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +4 -4
- package/lib/commands/api/validate.js +26 -33
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +3 -2
- package/lib/commands/auth/login.js +22 -53
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +1 -1
- package/lib/commands/auth/logout.js +8 -13
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +1 -1
- package/lib/commands/auth/status.js +9 -13
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/copilot.d.ts +12 -0
- package/lib/commands/portal/copilot.js +32 -0
- package/lib/commands/portal/copilot.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +10 -8
- package/lib/commands/portal/generate.js +28 -107
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/quickstart.d.ts +10 -0
- package/lib/commands/portal/quickstart.js +105 -0
- package/lib/commands/portal/quickstart.js.map +1 -0
- package/lib/commands/portal/recipe/new.d.ts +10 -0
- package/lib/commands/portal/recipe/new.js +38 -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 +80 -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 +52 -0
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +9 -8
- package/lib/commands/sdk/generate.js +39 -128
- 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/config/env.d.ts +26 -1
- package/lib/config/env.js +27 -4
- package/lib/config/env.js.map +1 -0
- package/lib/controllers/api/transform.d.ts +1 -1
- package/lib/controllers/api/transform.js +23 -22
- package/lib/controllers/api/transform.js.map +1 -0
- package/lib/controllers/api/validate.d.ts +3 -3
- package/lib/controllers/api/validate.js +19 -12
- package/lib/controllers/api/validate.js.map +1 -0
- package/lib/controllers/portal/quickstart.d.ts +15 -0
- package/lib/controllers/portal/quickstart.js +217 -0
- package/lib/controllers/portal/quickstart.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 +33 -0
- package/lib/infrastructure/api-utils.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +8 -0
- package/lib/infrastructure/env-info.js +37 -0
- package/lib/infrastructure/env-info.js.map +1 -0
- package/lib/infrastructure/file-service.d.ts +18 -0
- package/lib/infrastructure/file-service.js +76 -0
- package/lib/infrastructure/file-service.js.map +1 -0
- package/lib/infrastructure/services/api-service.d.ts +10 -0
- package/lib/infrastructure/services/api-service.js +54 -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 +33 -0
- package/lib/infrastructure/services/auth-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +20 -0
- package/lib/infrastructure/services/portal-service.js +163 -0
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/infrastructure/services/telemetry-service.d.ts +8 -0
- package/lib/infrastructure/services/telemetry-service.js +40 -0
- package/lib/infrastructure/services/telemetry-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/auth/login.d.ts +5 -0
- package/lib/prompts/auth/login.js +13 -0
- package/lib/prompts/auth/login.js.map +1 -0
- package/lib/prompts/portal/common/base-prompts.d.ts +7 -0
- package/lib/prompts/portal/common/base-prompts.js +19 -0
- package/lib/prompts/portal/common/base-prompts.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +8 -0
- package/lib/prompts/portal/copilot.js +54 -0
- package/lib/prompts/portal/copilot.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +11 -0
- package/lib/prompts/portal/generate.js +42 -0
- package/lib/prompts/portal/generate.js.map +1 -0
- package/lib/prompts/portal/quickstart.d.ts +30 -0
- package/lib/prompts/portal/quickstart.js +240 -0
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +24 -0
- package/lib/prompts/portal/recipe/new-recipe.js +203 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +4 -0
- package/lib/prompts/portal/serve.js +14 -0
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +11 -0
- package/lib/prompts/portal/toc/new-toc.js +39 -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 +42 -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 +19 -4
- package/lib/types/api/transform.js +19 -4
- package/lib/types/api/transform.js.map +1 -0
- package/lib/types/api/validate.d.ts +3 -3
- package/lib/types/api/validate.js +2 -2
- package/lib/types/api/validate.js.map +1 -0
- package/lib/types/build/build.d.ts +14 -0
- package/lib/types/build/build.js +4 -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 +30 -0
- package/lib/types/build-context.js.map +1 -0
- package/lib/types/common/result.d.ts +17 -0
- package/lib/types/common/result.js +32 -0
- package/lib/types/common/result.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/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/directoryPath.d.ts +7 -0
- package/lib/types/file/directoryPath.js +16 -0
- package/lib/types/file/directoryPath.js.map +1 -0
- package/lib/types/file/fileName.d.ts +5 -0
- package/lib/types/file/fileName.js +9 -0
- package/lib/types/file/fileName.js.map +1 -0
- package/lib/types/file/filePath.d.ts +8 -0
- package/lib/types/file/filePath.js +11 -0
- package/lib/types/file/filePath.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/generate.d.ts +13 -9
- package/lib/types/portal/generate.js +3 -2
- package/lib/types/portal/generate.js.map +1 -0
- package/lib/types/portal/quickstart.d.ts +17 -0
- package/lib/types/portal/quickstart.js +2 -0
- package/lib/types/portal/quickstart.js.map +1 -0
- package/lib/types/portal/serve.d.ts +12 -0
- package/lib/types/portal/serve.js +2 -0
- package/lib/types/portal/serve.js.map +1 -0
- package/lib/types/portal-context.d.ts +11 -0
- package/lib/types/portal-context.js +28 -0
- package/lib/types/portal-context.js.map +1 -0
- package/lib/types/recipe/recipe.d.ts +37 -0
- package/lib/types/recipe/recipe.js +6 -0
- package/lib/types/recipe/recipe.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +11 -10
- package/lib/types/sdk/generate.js +11 -12
- package/lib/types/sdk/generate.js.map +1 -0
- package/lib/types/sdk-context.d.ts +13 -0
- package/lib/types/sdk-context.js +28 -0
- package/lib/types/sdk-context.js.map +1 -0
- package/lib/types/sdl/sdl.d.ts +12 -0
- package/lib/types/sdl/sdl.js +2 -0
- package/lib/types/sdl/sdl.js.map +1 -0
- package/lib/types/spec-context.d.ts +7 -0
- package/lib/types/spec-context.js +12 -0
- package/lib/types/spec-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/utils.d.ts +3 -3
- package/lib/types/utils.js +2 -2
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/utils.d.ts +16 -7
- package/lib/utils/utils.js +142 -86
- package/lib/utils/utils.js.map +1 -0
- package/lib/validators/common/directoryValidator.d.ts +5 -0
- package/lib/validators/common/directoryValidator.js +22 -0
- package/lib/validators/common/directoryValidator.js.map +1 -0
- package/lib/validators/portal/serve-validator.d.ts +6 -0
- package/lib/validators/portal/serve-validator.js +15 -0
- package/lib/validators/portal/serve-validator.js.map +1 -0
- package/package.json +96 -40
- package/bin/run +0 -5
- 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/config/env.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const baseURL = "https://api.apimatic.io";
|
|
2
|
+
export const metadataFileContent = {
|
|
3
|
+
ImportSettings: {
|
|
4
|
+
AutoGenerateTestCases: false,
|
|
5
|
+
ImportAdditionalHeader: false,
|
|
6
|
+
ImportAdditionalTypeCombinatorModels: false,
|
|
7
|
+
ImportTypeCombinatorsWithOnlyOneType: false
|
|
8
|
+
},
|
|
9
|
+
CodeGenSettings: {
|
|
10
|
+
Timeout: 30,
|
|
11
|
+
ValidateRequiredParameters: true,
|
|
12
|
+
AddSingleAuthDeprecatedCode: false,
|
|
13
|
+
EnableGlobalUserAgent: true,
|
|
14
|
+
UserAgent: "{language}-SDK/{version} (OS: {os-info}, Engine: {engine}/{engine-version})",
|
|
15
|
+
EnableLogging: true,
|
|
16
|
+
EnableModelKeywordArgsInRuby: true,
|
|
17
|
+
SymbolizeHashKeysInRuby: true,
|
|
18
|
+
ReturnCompleteHttpResponse: true,
|
|
19
|
+
UserConfigurableRetries: true,
|
|
20
|
+
UseEnumPrefix: false,
|
|
21
|
+
ExtendedAdditionalPropertiesSupport: true,
|
|
22
|
+
EnforceStandardizedCasing: true,
|
|
23
|
+
ControllerPostfix: "Api",
|
|
24
|
+
DoNotSplitWords: ["oauth"]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/config/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,cAAc,EAAE;QACd,qBAAqB,EAAE,KAAK;QAC5B,sBAAsB,EAAE,KAAK;QAC7B,oCAAoC,EAAE,KAAK;QAC3C,oCAAoC,EAAE,KAAK;KAC5C;IACD,eAAe,EAAE;QACf,OAAO,EAAE,EAAE;QACX,0BAA0B,EAAE,IAAI;QAChC,2BAA2B,EAAE,KAAK;QAClC,qBAAqB,EAAE,IAAI;QAC3B,SAAS,EAAE,6EAA6E;QACxF,aAAa,EAAE,IAAI;QACnB,4BAA4B,EAAE,IAAI;QAClC,uBAAuB,EAAE,IAAI;QAC7B,0BAA0B,EAAE,IAAI;QAChC,uBAAuB,EAAE,IAAI;QAC7B,aAAa,EAAE,KAAK;QACpB,mCAAmC,EAAE,IAAI;QACzC,yBAAyB,EAAE,IAAI;QAC/B,iBAAiB,EAAE,KAAK;QACxB,eAAe,EAAE,CAAC,OAAO,CAAC;KAC3B;CACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform";
|
|
1
|
+
import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform.js";
|
|
2
2
|
import { ExportFormats, Transformation, TransformationController } from "@apimatic/sdk";
|
|
3
3
|
export declare const getTransformationId: ({ file, url, format }: TransformationIdParams, transformationController: TransformationController) => Promise<Transformation>;
|
|
4
4
|
export declare const downloadTransformationFile: ({ id, destinationFilePath, transformationController }: DownloadTransformationParams) => Promise<string>;
|
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
exports.getTransformationId = async ({ file, url, format }, transformationController) => {
|
|
9
|
-
cli_ux_1.default.action.start("Transforming API specification");
|
|
1
|
+
import { ux } from "@oclif/core";
|
|
2
|
+
import fsExtra from "fs-extra";
|
|
3
|
+
import { writeFileUsingReadableStream } from "../../utils/utils.js";
|
|
4
|
+
import { TransformationFormats } from "../../types/api/transform.js";
|
|
5
|
+
import { ContentType, ExportFormats, FileWrapper } from "@apimatic/sdk";
|
|
6
|
+
export const getTransformationId = async ({ file, url, format }, transformationController) => {
|
|
7
|
+
ux.action.start("Transforming API specification");
|
|
10
8
|
let generation;
|
|
11
9
|
if (file) {
|
|
12
|
-
const fileDescriptor = new
|
|
13
|
-
generation = await transformationController.transformViaFile(fileDescriptor, format);
|
|
10
|
+
const fileDescriptor = new FileWrapper(fsExtra.createReadStream(file));
|
|
11
|
+
generation = await transformationController.transformViaFile(ContentType.EnumMultipartformdata, fileDescriptor, format);
|
|
14
12
|
}
|
|
15
13
|
else if (url) {
|
|
16
14
|
const body = {
|
|
17
15
|
url: url,
|
|
18
16
|
exportFormat: format
|
|
19
17
|
};
|
|
20
|
-
generation = await transformationController.
|
|
18
|
+
generation = await transformationController.transformViaUrl(body);
|
|
21
19
|
}
|
|
22
20
|
else {
|
|
23
21
|
throw new Error("Please provide a specification file");
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
ux.action.stop();
|
|
26
24
|
return generation.result;
|
|
27
25
|
};
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
export const downloadTransformationFile = async ({ id, destinationFilePath, transformationController }) => {
|
|
27
|
+
ux.action.start("Downloading Transformed file");
|
|
30
28
|
const { result } = await transformationController.downloadTransformedFile(id);
|
|
31
29
|
if (result.readable) {
|
|
32
|
-
await
|
|
30
|
+
await writeFileUsingReadableStream(result, destinationFilePath);
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
35
33
|
throw new Error("Couldn't save transformation file");
|
|
36
34
|
}
|
|
37
|
-
|
|
35
|
+
ux.action.stop();
|
|
38
36
|
return destinationFilePath;
|
|
39
37
|
};
|
|
40
38
|
// Get valid platform from user's input, convert simple platform to valid Platforms enum value
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
export const getValidFormat = (format) => {
|
|
40
|
+
const key = Object.keys(TransformationFormats).find((value) => value === format);
|
|
41
|
+
if (key) {
|
|
42
|
+
const transformationFormat = TransformationFormats[key];
|
|
43
|
+
return ExportFormats[transformationFormat];
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
const formats = Object.keys(
|
|
47
|
-
throw new Error(`Please provide a valid platform
|
|
46
|
+
const formats = Object.keys(TransformationFormats).join("|");
|
|
47
|
+
throw new Error(`Please provide a valid platform, e.g. ${formats}`);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/controllers/api/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAGL,qBAAqB,EAEtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,WAAW,EACX,aAAa,EACb,WAAW,EAIZ,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAA0B,EAC7C,wBAAkD,EACzB,EAAE;IAC3B,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAElD,IAAI,UAAuC,CAAC;IAC5C,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,UAAU,GAAG,MAAM,wBAAwB,CAAC,gBAAgB,CAC1D,WAAW,CAAC,qBAAqB,EACjC,cAAc,EACd,MAAuB,CACxB,CAAC;IACJ,CAAC;SA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aAAa,CAAC,oBAAoB,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,yCAAyC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
1
|
+
import { ApiValidationExternalApisController, ApiValidationSummary } from "@apimatic/sdk";
|
|
2
|
+
import { GetValidationParams } from "../../types/api/validate.js";
|
|
3
|
+
export declare const getValidationSummary: ({ file, url }: GetValidationParams, apiValidationController: ApiValidationExternalApisController) => Promise<ApiValidationSummary>;
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const fs = require("fs-extra");
|
|
6
|
-
const core_1 = require("@apimatic/core");
|
|
7
|
-
exports.getValidation = async ({ file, url }, apiValidationController) => {
|
|
1
|
+
import fsExtra from "fs-extra";
|
|
2
|
+
import { ContentType, FileWrapper } from "@apimatic/sdk";
|
|
3
|
+
import { createTempDirectory, deleteFile, zipDirectory } from "../../utils/utils.js";
|
|
4
|
+
export const getValidationSummary = async ({ file, url }, apiValidationController) => {
|
|
8
5
|
let validation;
|
|
9
|
-
cli_ux_1.default.action.start("Validating specification file");
|
|
10
6
|
if (file) {
|
|
11
|
-
const
|
|
12
|
-
|
|
7
|
+
const fileStatus = fsExtra.statSync(file);
|
|
8
|
+
if (fileStatus.isDirectory()) {
|
|
9
|
+
const tempDir = await createTempDirectory();
|
|
10
|
+
const zipPath = await zipDirectory(file, tempDir);
|
|
11
|
+
const zipFile = new FileWrapper(fsExtra.createReadStream(zipPath));
|
|
12
|
+
validation = await apiValidationController.validateApiViaFile(ContentType.EnumMultipartformdata, zipFile);
|
|
13
|
+
await deleteFile(zipPath);
|
|
14
|
+
await fsExtra.remove(tempDir);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const fileDescriptor = new FileWrapper(fsExtra.createReadStream(file));
|
|
18
|
+
validation = await apiValidationController.validateApiViaFile(ContentType.EnumMultipartformdata, fileDescriptor);
|
|
19
|
+
}
|
|
13
20
|
}
|
|
14
21
|
else if (url) {
|
|
15
|
-
validation = await apiValidationController.
|
|
22
|
+
validation = await apiValidationController.validateApiViaUrl(url);
|
|
16
23
|
}
|
|
17
24
|
else {
|
|
18
25
|
throw new Error("Please provide a specification file");
|
|
19
26
|
}
|
|
20
|
-
cli_ux_1.default.action.stop();
|
|
21
27
|
return validation.result;
|
|
22
28
|
};
|
|
29
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/controllers/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAA0E,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjI,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAErF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,EAAE,IAAI,EAAE,GAAG,EAAuB,EAClC,uBAA4D,EAC7B,EAAE;IACjC,IAAI,UAA6C,CAAC;IAElD,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,MAAM,mBAAmB,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;YACnE,UAAU,GAAG,MAAM,uBAAuB,CAAC,kBAAkB,CAAC,WAAW,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;YAE1G,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;YAE1B,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,cAAc,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;YACvE,UAAU,GAAG,MAAM,uBAAuB,CAAC,kBAAkB,CAAC,WAAW,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;QACnH,CAAC;IACH,CAAC;SAAM,IAAI,GAAG,EAAE,CAAC;QACf,UAAU,GAAG,MAAM,uBAAuB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACpE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiValidationExternalApisController, ApiValidationSummary } from "@apimatic/sdk";
|
|
2
|
+
import { LoginCredentials, SpecFile } from "../../types/portal/quickstart.js";
|
|
3
|
+
import { SDKClient } from "../../client-utils/sdk-client.js";
|
|
4
|
+
import { PortalQuickstartPrompts } from "../../prompts/portal/quickstart.js";
|
|
5
|
+
export declare class PortalQuickstartController {
|
|
6
|
+
private readonly zipService;
|
|
7
|
+
private readonly fileService;
|
|
8
|
+
private readonly specUrl;
|
|
9
|
+
isUserAuthenticated(configDir: string): Promise<boolean>;
|
|
10
|
+
userLogin(credentials: LoginCredentials, client: SDKClient, configDir: string): Promise<void>;
|
|
11
|
+
getSpecFile(spec: string): Promise<SpecFile>;
|
|
12
|
+
getSpecValidationSummary(prompts: PortalQuickstartPrompts, specFile: SpecFile, apiValidationController: ApiValidationExternalApisController): Promise<ApiValidationSummary>;
|
|
13
|
+
private downloadRepositoryFromGitHub;
|
|
14
|
+
setupBuildDirectory(prompts: PortalQuickstartPrompts, targetFolder: string, specFile: SpecFile, validationSummary: ApiValidationSummary, languages: string[]): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import filetype from "file-type";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import fsExtra from "fs-extra";
|
|
6
|
+
import { readdir } from "fs/promises";
|
|
7
|
+
import { getAuthInfo } from "../../client-utils/auth-manager.js";
|
|
8
|
+
import { createTempDirectory, isValidUrl, getMessageInRedColor, clearDirectory, deleteFile } from "../../utils/utils.js";
|
|
9
|
+
import { getValidationSummary } from "../api/validate.js";
|
|
10
|
+
import { metadataFileContent } from "../../config/env.js";
|
|
11
|
+
import { ZipService } from "../../infrastructure/zip-service.js";
|
|
12
|
+
import { FilePath } from "../../types/file/filePath.js";
|
|
13
|
+
import { DirectoryPath } from "../../types/file/directoryPath.js";
|
|
14
|
+
import { FileName } from "../../types/file/fileName.js";
|
|
15
|
+
import { withDirPath } from "../../infrastructure/tmp-extensions.js";
|
|
16
|
+
import { FileService } from "../../infrastructure/file-service.js";
|
|
17
|
+
export class PortalQuickstartController {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.zipService = new ZipService();
|
|
20
|
+
this.fileService = new FileService();
|
|
21
|
+
this.specUrl = "https://github.com/apimatic/static-portal-workflow/blob/master/spec/openapi.json";
|
|
22
|
+
}
|
|
23
|
+
async isUserAuthenticated(configDir) {
|
|
24
|
+
const storedAuth = await getAuthInfo(configDir);
|
|
25
|
+
if (!(storedAuth === null || storedAuth === void 0 ? void 0 : storedAuth.authKey)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
async userLogin(credentials, client, configDir) {
|
|
31
|
+
await client.login(credentials.email, credentials.password, configDir);
|
|
32
|
+
}
|
|
33
|
+
async getSpecFile(spec) {
|
|
34
|
+
const tempSpecDir = await createTempDirectory();
|
|
35
|
+
if (spec) {
|
|
36
|
+
let specPath = String(spec);
|
|
37
|
+
if (isValidUrl(specPath)) {
|
|
38
|
+
try {
|
|
39
|
+
const response = await axios.head(specPath);
|
|
40
|
+
if (response.headers["content-type"].includes("text/html")) {
|
|
41
|
+
throw new Error(getMessageInRedColor(`Invalid URL. Please check the URL and ensure it points to a valid OpenAPI definition.`));
|
|
42
|
+
}
|
|
43
|
+
const specFile = await axios.get(specPath, { responseType: "arraybuffer" });
|
|
44
|
+
const fileName = path.basename(specPath);
|
|
45
|
+
const filePath = path.join(tempSpecDir, fileName);
|
|
46
|
+
await fsExtra.writeFile(filePath, specFile.data);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (axios.isAxiosError(error)) {
|
|
50
|
+
if (error.response) {
|
|
51
|
+
if (error.response.status === 404) {
|
|
52
|
+
throw new Error(getMessageInRedColor(`Unable to download the API Definition. The server returned a 404 Not Found error. Please verify that the provided URL is correct and publicly accessible.`));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error(getMessageInRedColor(`Unable to download the API Definition. The server returned ${error.response.status} ${error.response.statusText}`));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (error.request) {
|
|
59
|
+
if (error.code === "ECONNABORTED") {
|
|
60
|
+
throw new Error(getMessageInRedColor(`Unable to download the API Definition, your request timed out. Please check your internet connection and try again, or contact APIMatic support for help if your problem persists.`));
|
|
61
|
+
}
|
|
62
|
+
else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
|
|
63
|
+
throw new Error(getMessageInRedColor(`Failed to download the API Definition file due to network issues. Please check your internet connection and try again.`));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new Error(getMessageInRedColor(`Failed to download the API Definition file, no response was received from the server. Please try again later.`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new Error(getMessageInRedColor(`Failed to download API Definition: ${error.message}`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
throw new Error(getMessageInRedColor(`Unable to save API Definition : ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
specPath = path.normalize(specPath);
|
|
80
|
+
const fileType = await filetype.fromFile(specPath);
|
|
81
|
+
if ((fileType === null || fileType === void 0 ? void 0 : fileType.ext) === "zip") {
|
|
82
|
+
await this.zipService.unArchive(new FilePath(new DirectoryPath(path.dirname(specPath)), new FileName(path.basename(specPath))), new DirectoryPath(tempSpecDir));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const destinationPath = path.join(tempSpecDir, path.basename(specPath));
|
|
86
|
+
await fsExtra.copy(specPath, destinationPath);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { localPath: tempSpecDir, url: this.specUrl };
|
|
91
|
+
}
|
|
92
|
+
async getSpecValidationSummary(prompts, specFile, apiValidationController) {
|
|
93
|
+
const validationFlags = {
|
|
94
|
+
file: specFile.localPath,
|
|
95
|
+
url: specFile.url
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
const validationSummary = await getValidationSummary(validationFlags, apiValidationController);
|
|
99
|
+
return validationSummary;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
prompts.displaySpecValidationErrorMessage();
|
|
103
|
+
if (axios.isAxiosError(error)) {
|
|
104
|
+
if (error.response) {
|
|
105
|
+
if (error.response.status === 400) {
|
|
106
|
+
throw new Error(getMessageInRedColor(`The provided spec file is not valid. Please ensure that the spec you have provided is a valid API definition file.`));
|
|
107
|
+
}
|
|
108
|
+
else if (error.response.status === 500) {
|
|
109
|
+
throw new Error(getMessageInRedColor(`The server encountered an error while validating your spec file, please try again later. If the issue persists, contact our team at support@apimatic.io`));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw new Error(getMessageInRedColor(`Something went wrong while validating your spec file. The server returned the following error ${error.response.status} ${error.response.statusText}. Please try again later. If the issue persists, contact our team at support@apimatic.io`));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (error.request) {
|
|
116
|
+
if (error.code === "ECONNABORTED") {
|
|
117
|
+
throw new Error(getMessageInRedColor(`The spec validation request timed out. Please try again.`));
|
|
118
|
+
}
|
|
119
|
+
else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
|
|
120
|
+
throw new Error(getMessageInRedColor(`Network error encountered while validating the spec file. Please check your connection and try again.`));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new Error(getMessageInRedColor(`Something went wrong while validating the spec file, please try again. If the issue persists, reach out to our support team at support@apimatic.io`));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
throw new Error(getMessageInRedColor(`Failed to validate spec file: ${error.message}`));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else if (error.result) {
|
|
131
|
+
const apiError = error;
|
|
132
|
+
if (error.body && apiError.statusCode === 401) {
|
|
133
|
+
throw new Error("You are not authorized to perform this action.");
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
throw new Error(error.message);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (error.statusCode === 401) {
|
|
140
|
+
throw new Error("You are not authorized to perform this action.");
|
|
141
|
+
}
|
|
142
|
+
else if (error.statusCode === 402 &&
|
|
143
|
+
error.body &&
|
|
144
|
+
typeof error.body === "string") {
|
|
145
|
+
throw new Error(error.body);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(getMessageInRedColor(`Something went wrong while validating the spec file, please try again later. If the issue persists, contact our team at support@apimatic.io`));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async downloadRepositoryFromGitHub(targetFolder) {
|
|
153
|
+
return await withDirPath(async (tempDirectory) => {
|
|
154
|
+
const zipUrl = `https://github.com/apimatic/static-portal-workflow/archive/refs/heads/master.zip`;
|
|
155
|
+
const response = await fetch(zipUrl);
|
|
156
|
+
const repositoryFolderName = "static-portal-workflow-master";
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
throw new Error(`Unable to setup your portal, please try again later.`);
|
|
159
|
+
}
|
|
160
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
161
|
+
const tempZipPath = new FilePath(tempDirectory, new FileName("static-repo.zip"));
|
|
162
|
+
await this.fileService.writeBuffer(tempZipPath, Buffer.from(arrayBuffer));
|
|
163
|
+
await this.zipService.unArchive(tempZipPath, tempDirectory);
|
|
164
|
+
const extractedFolderPath = new DirectoryPath(tempDirectory.toString(), repositoryFolderName);
|
|
165
|
+
await this.fileService.copyDirectoryContents(extractedFolderPath, new DirectoryPath(targetFolder));
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async setupBuildDirectory(prompts, targetFolder, specFile, validationSummary, languages) {
|
|
169
|
+
fsExtra.emptyDirSync(targetFolder);
|
|
170
|
+
try {
|
|
171
|
+
await this.downloadRepositoryFromGitHub(targetFolder);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
prompts.displayBuildDirectoryGenerationErrorMessage();
|
|
175
|
+
if (error instanceof Error) {
|
|
176
|
+
if (error.message.includes("timed out") || error.message.includes("timeout")) {
|
|
177
|
+
throw new Error(getMessageInRedColor("The operation timed out while setting up the build directory. Please check your internet connection and try again."));
|
|
178
|
+
}
|
|
179
|
+
else if (error.message.includes("Could not resolve host")) {
|
|
180
|
+
throw new Error(getMessageInRedColor("Unable to resolve the host. Please check your network settings and try again."));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
throw new Error(getMessageInRedColor(`Failed to set up the build directory. ${error.message}`));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw new Error(getMessageInRedColor(`Failed to set up the build directory. ${error}`));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
await clearDirectory(path.join(targetFolder, ".github"));
|
|
191
|
+
if (specFile.localPath && validationSummary.success) {
|
|
192
|
+
const specFolder = path.join(targetFolder, "spec");
|
|
193
|
+
await deleteFile(path.join(specFolder, "openapi.json"));
|
|
194
|
+
const files = await readdir(specFile.localPath);
|
|
195
|
+
for (const file of files) {
|
|
196
|
+
const srcPath = path.join(specFile.localPath, file);
|
|
197
|
+
const destPath = path.join(specFolder, file);
|
|
198
|
+
await fsExtra.copy(srcPath, destPath);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const buildFilePath = path.join(targetFolder, "APIMATIC-BUILD.json");
|
|
202
|
+
const buildFileContent = JSON.parse(fs.readFileSync(buildFilePath, "utf8"));
|
|
203
|
+
const languageConfig = languages.reduce((config, lang) => {
|
|
204
|
+
config[lang] = {};
|
|
205
|
+
return config;
|
|
206
|
+
}, {});
|
|
207
|
+
buildFileContent.generatePortal.languageConfig = languageConfig;
|
|
208
|
+
fs.writeFileSync(buildFilePath, JSON.stringify(buildFileContent, null, 2));
|
|
209
|
+
const specFolder = path.join(targetFolder, "spec");
|
|
210
|
+
const metadataFile = fs.readdirSync(specFolder).find((file) => file.startsWith("APIMATIC-META"));
|
|
211
|
+
if (!metadataFile) {
|
|
212
|
+
const newMetadataFilePath = path.join(specFolder, "APIMATIC-META.json");
|
|
213
|
+
fs.writeFileSync(newMetadataFilePath, JSON.stringify(metadataFileContent, null, 2));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=quickstart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/controllers/portal/quickstart.ts"],"names":[],"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SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAE3E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAEnD,MAAM,YAAY,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;QAEjG,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;YACxE,EAAE,CAAC,aAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;CACF"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { run } from "@oclif/
|
|
1
|
+
export { run } from "@oclif/core";
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var command_1 = require("@oclif/command");
|
|
4
|
-
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return command_1.run; } });
|
|
1
|
+
export { run } from "@oclif/core";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
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,9 @@
|
|
|
1
|
+
export declare const enum ServiceError {
|
|
2
|
+
NotFound = "NOT_FOUND",
|
|
3
|
+
ServerError = "SERVER_ERROR",
|
|
4
|
+
NetworkError = "NETWORK_ERROR",
|
|
5
|
+
InvalidResponse = "INVALID_RESPONSE",
|
|
6
|
+
UnAuthorized = "UNAUTHORIZED"
|
|
7
|
+
}
|
|
8
|
+
export declare function getErrorMessage(error: ServiceError): string;
|
|
9
|
+
export declare function handleServiceError(error: unknown): ServiceError;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
export function getErrorMessage(error) {
|
|
3
|
+
switch (error) {
|
|
4
|
+
case "NETWORK_ERROR" /* ServiceError.NetworkError */:
|
|
5
|
+
return "Unable to connect to the server.";
|
|
6
|
+
case "UNAUTHORIZED" /* ServiceError.UnAuthorized */:
|
|
7
|
+
return "Unauthorized access.";
|
|
8
|
+
case "NOT_FOUND" /* ServiceError.NotFound */:
|
|
9
|
+
case "SERVER_ERROR" /* ServiceError.ServerError */:
|
|
10
|
+
case "INVALID_RESPONSE" /* ServiceError.InvalidResponse */:
|
|
11
|
+
default:
|
|
12
|
+
return "An unexpected error occurred, please try again later. If the problem persists, please reach out to our team at support@apimatic.io";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function handleServiceError(error) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
if (axios.isAxiosError(error)) {
|
|
18
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
19
|
+
return "UNAUTHORIZED" /* ServiceError.UnAuthorized */;
|
|
20
|
+
}
|
|
21
|
+
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 404) {
|
|
22
|
+
return "NOT_FOUND" /* ServiceError.NotFound */;
|
|
23
|
+
}
|
|
24
|
+
if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 500) {
|
|
25
|
+
return "SERVER_ERROR" /* ServiceError.ServerError */;
|
|
26
|
+
}
|
|
27
|
+
if (error.code === "ECONNABORTED" || error.code === "ECONNREFUSED") {
|
|
28
|
+
return "NETWORK_ERROR" /* ServiceError.NetworkError */;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return "SERVER_ERROR" /* ServiceError.ServerError */;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=api-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-utils.js","sourceRoot":"","sources":["../../src/infrastructure/api-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,UAAU,eAAe,CAAC,KAAmB;IACjD,QAAQ,KAAK,EAAE,CAAC;QACd;YACE,OAAO,kCAAkC,CAAC;QAC5C;YACE,OAAO,sBAAsB,CAAC;QAChC,6CAA2B;QAC3B,mDAA8B;QAC9B,2DAAkC;QAClC;YACE,OAAO,oIAAoI,CAAC;IAChJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;;IAC/C,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;YACnC,sDAAkC;QACpC,CAAC;QACD,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;YACnC,+CAA6B;QAC/B,CAAC;QACD,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;YACnC,qDAAgC;QAClC,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACnE,uDAAiC;QACnC,CAAC;IACH,CAAC;IACD,qDAAgC;AAClC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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() {
|
|
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})`;
|
|
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
|
+
}
|
|
34
|
+
EnvInfo.cachedCliVersion = null;
|
|
35
|
+
EnvInfo.cachedUserAgent = null;
|
|
36
|
+
export const envInfo = new EnvInfo();
|
|
37
|
+
//# 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;IAIJ,YAAY;QACjB,IAAI,CAAC,OAAO,CAA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
|
2
|
+
import { FilePath } from "../types/file/filePath.js";
|
|
3
|
+
import { DirectoryPath } from "../types/file/directoryPath.js";
|
|
4
|
+
export declare class FileService {
|
|
5
|
+
fileExists(file: FilePath): Promise<boolean>;
|
|
6
|
+
directoryExists(dir: DirectoryPath): Promise<boolean>;
|
|
7
|
+
directoryEmpty(dir: DirectoryPath): Promise<boolean>;
|
|
8
|
+
cleanDirectory(dir: DirectoryPath): Promise<void>;
|
|
9
|
+
copyDirectory(source: DirectoryPath, destination: DirectoryPath): Promise<void>;
|
|
10
|
+
copyDirectoryContents(source: DirectoryPath, destination: DirectoryPath): Promise<void>;
|
|
11
|
+
deleteFile(filePath: FilePath): Promise<void>;
|
|
12
|
+
getStream(filePath: FilePath): Promise<fs.ReadStream>;
|
|
13
|
+
getContents(filePath: FilePath): Promise<string>;
|
|
14
|
+
writeFile(filePath: FilePath, stream: NodeJS.ReadableStream): Promise<void>;
|
|
15
|
+
writeContents(filePath: FilePath, contents: string): Promise<void>;
|
|
16
|
+
writeBuffer(filePath: FilePath, buffer: Buffer): Promise<void>;
|
|
17
|
+
copy(source: FilePath, destination: FilePath): Promise<void>;
|
|
18
|
+
}
|