@apimatic/cli 1.0.2-alpha.2 → 1.1.0-alpha.10
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 +220 -72
- package/bin/run.js +5 -0
- package/lib/actions/portal/generate.d.ts +7 -0
- package/lib/actions/portal/generate.js +54 -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 +258 -0
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
- package/lib/actions/portal/toc/new-toc.d.ts +17 -0
- package/lib/actions/portal/toc/new-toc.js +130 -0
- package/lib/actions/portal/toc/new-toc.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/toc/sdl-parser.d.ts +16 -0
- package/lib/application/portal/toc/sdl-parser.js +74 -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 +1 -1
- package/lib/client-utils/auth-manager.js +9 -13
- package/lib/client-utils/auth-manager.js.map +1 -0
- package/lib/client-utils/sdk-client.js +24 -23
- 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 +44 -40
- package/lib/commands/api/transform.js.map +1 -0
- package/lib/commands/api/validate.d.ts +4 -4
- package/lib/commands/api/validate.js +33 -24
- package/lib/commands/api/validate.js.map +1 -0
- package/lib/commands/auth/login.d.ts +2 -2
- package/lib/commands/auth/login.js +33 -18
- package/lib/commands/auth/login.js.map +1 -0
- package/lib/commands/auth/logout.d.ts +1 -1
- package/lib/commands/auth/logout.js +6 -7
- package/lib/commands/auth/logout.js.map +1 -0
- package/lib/commands/auth/status.d.ts +1 -1
- package/lib/commands/auth/status.js +6 -7
- package/lib/commands/auth/status.js.map +1 -0
- package/lib/commands/portal/generate.d.ts +12 -7
- package/lib/commands/portal/generate.js +73 -79
- package/lib/commands/portal/generate.js.map +1 -0
- package/lib/commands/portal/quickstart.d.ts +10 -0
- package/lib/commands/portal/quickstart.js +77 -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 +44 -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 +135 -0
- package/lib/commands/portal/serve.js.map +1 -0
- package/lib/commands/portal/toc/new.d.ts +15 -0
- package/lib/commands/portal/toc/new.js +63 -0
- package/lib/commands/portal/toc/new.js.map +1 -0
- package/lib/commands/sdk/generate.d.ts +8 -8
- package/lib/commands/sdk/generate.js +48 -41
- 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 +27 -1
- package/lib/config/env.js +28 -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/generate.d.ts +3 -2
- package/lib/controllers/portal/generate.js +105 -48
- package/lib/controllers/portal/generate.js.map +1 -0
- package/lib/controllers/portal/quickstart.d.ts +14 -0
- package/lib/controllers/portal/quickstart.js +253 -0
- package/lib/controllers/portal/quickstart.js.map +1 -0
- package/lib/controllers/portal/serve.d.ts +3 -0
- package/lib/controllers/portal/serve.js +133 -0
- package/lib/controllers/portal/serve.js.map +1 -0
- package/lib/controllers/sdk/generate.d.ts +4 -4
- package/lib/controllers/sdk/generate.js +23 -26
- package/lib/controllers/sdk/generate.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/services/portal-service.d.ts +16 -0
- package/lib/infrastructure/services/portal-service.js +129 -0
- package/lib/infrastructure/services/portal-service.js.map +1 -0
- package/lib/prompts/portal/generate.d.ts +10 -0
- package/lib/prompts/portal/generate.js +57 -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 +212 -0
- package/lib/prompts/portal/quickstart.js.map +1 -0
- package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -0
- package/lib/prompts/portal/recipe/new-recipe.js +193 -0
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
- package/lib/prompts/portal/serve.d.ts +7 -0
- package/lib/prompts/portal/serve.js +21 -0
- package/lib/prompts/portal/serve.js.map +1 -0
- package/lib/prompts/portal/toc/new-toc.d.ts +10 -0
- package/lib/prompts/portal/toc/new-toc.js +42 -0
- package/lib/prompts/portal/toc/new-toc.js.map +1 -0
- package/lib/services/portal/server.d.ts +14 -0
- package/lib/services/portal/server.js +97 -0
- package/lib/services/portal/server.js.map +1 -0
- package/lib/types/api/transform.d.ts +19 -8
- 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/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/portal/generate.d.ts +26 -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/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 +6 -5
- package/lib/types/sdk/generate.js +5 -6
- package/lib/types/sdk/generate.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/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 +6 -2
- package/lib/types/utils.js +2 -2
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/utils.d.ts +31 -5
- package/lib/utils/utils.js +316 -74
- package/lib/utils/utils.js.map +1 -0
- package/lib/validators/common/directoryValidator.d.ts +9 -0
- package/lib/validators/common/directoryValidator.js +49 -0
- package/lib/validators/common/directoryValidator.js.map +1 -0
- package/lib/validators/common/portValidator.d.ts +5 -0
- package/lib/validators/common/portValidator.js +16 -0
- package/lib/validators/common/portValidator.js.map +1 -0
- package/lib/validators/portal/serveValidator.d.ts +6 -0
- package/lib/validators/portal/serveValidator.js +17 -0
- package/lib/validators/portal/serveValidator.js.map +1 -0
- package/package.json +86 -38
- package/bin/run +0 -5
|
@@ -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,EACj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,qBAAqB,CAAC,GAAG,CAA+B,CAAC;QACtF,OAAO,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"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { GeneratePortalParams } from "../../types/portal/generate";
|
|
2
|
-
|
|
1
|
+
import { GeneratePortalParams } from "../../types/portal/generate.js";
|
|
2
|
+
import { Result } from "../../types/common/result.js";
|
|
3
|
+
export declare const downloadDocsPortal: (params: GeneratePortalParams, configDir: string) => Promise<Result<string, string>>;
|
|
@@ -1,49 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
import fsExtra from "fs-extra";
|
|
2
|
+
import { deleteFile, extractZipFile, getMessageInRedColor, parseStreamBodyToJson } from "../../utils/utils.js";
|
|
3
|
+
import { getAuthInfo } from "../../client-utils/auth-manager.js";
|
|
4
|
+
import { ApiError, Client, ContentType, DocsPortalManagementController, FileWrapper, ProblemDetailsError, UnauthorizedResponseError } from "@apimatic/sdk";
|
|
5
|
+
import { Result } from "../../types/common/result.js";
|
|
6
|
+
const CONTENT_TYPE = ContentType.EnumMultipartformdata;
|
|
7
|
+
const TIMEOUT = 0;
|
|
8
|
+
export const downloadDocsPortal = async (params, configDir) => {
|
|
9
|
+
if (!(await fsExtra.pathExists(params.sourceBuildInputZipFilePath))) {
|
|
10
|
+
return Result.failure("Build file doesn't exist");
|
|
11
|
+
}
|
|
12
|
+
const authInfo = await getAuthInfo(configDir);
|
|
13
|
+
const authorizationHeader = createAuthorizationHeader(authInfo, params.overrideAuthKey);
|
|
14
|
+
const client = createApiClient(authorizationHeader);
|
|
15
|
+
const docsPortalManagementController = new DocsPortalManagementController(client);
|
|
16
|
+
try {
|
|
17
|
+
const stream = await generatePortalFromSyncEndpoint(docsPortalManagementController, params.sourceBuildInputZipFilePath);
|
|
18
|
+
await saveGeneratedPortalStreamToZipFile(stream, params.generatedPortalArtifactsZipFilePath);
|
|
19
|
+
await deleteFile(params.sourceBuildInputZipFilePath);
|
|
20
|
+
if (params.generateZipFile) {
|
|
21
|
+
return Result.success(params.generatedPortalArtifactsZipFilePath);
|
|
22
|
+
}
|
|
23
|
+
await extractZipFile(params.generatedPortalArtifactsZipFilePath, params.generatedPortalArtifactsFolderPath);
|
|
24
|
+
await deleteFile(params.generatedPortalArtifactsZipFilePath);
|
|
25
|
+
return Result.success(params.generatedPortalArtifactsFolderPath);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return handlePortalGenerationErrors(error, params);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const createAuthorizationHeader = (authInfo, overrideAuthKey) => {
|
|
32
|
+
if (overrideAuthKey) {
|
|
33
|
+
return `X-Auth-Key ${overrideAuthKey}`;
|
|
34
|
+
}
|
|
35
|
+
if (!authInfo) {
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
return `X-Auth-Key ${authInfo.authKey}`;
|
|
39
|
+
};
|
|
40
|
+
const createApiClient = (authorizationHeader) => {
|
|
41
|
+
return new Client({
|
|
42
|
+
customHeaderAuthenticationCredentials: {
|
|
43
|
+
Authorization: authorizationHeader
|
|
44
|
+
},
|
|
45
|
+
timeout: TIMEOUT
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const generatePortalFromSyncEndpoint = async (docsPortalManagementController, zippedBuildFilePath) => {
|
|
49
|
+
const file = new FileWrapper(fsExtra.createReadStream(zippedBuildFilePath));
|
|
50
|
+
const response = await docsPortalManagementController.generateOnPremPortalViaBuildInput(CONTENT_TYPE, file);
|
|
51
|
+
return response.result;
|
|
52
|
+
};
|
|
53
|
+
const saveGeneratedPortalStreamToZipFile = async (data, generatedPortalArtifactsZipFilePath) => {
|
|
54
|
+
const writeStream = fsExtra.createWriteStream(generatedPortalArtifactsZipFilePath);
|
|
55
|
+
await new Promise((resolve, reject) => {
|
|
56
|
+
data
|
|
57
|
+
.pipe(writeStream)
|
|
58
|
+
.on("finish", () => resolve())
|
|
59
|
+
.on("error", (error) => reject(Result.failure(`Failed to save downloaded portal to file: ${error.message}`)));
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
const handlePortalGenerationErrors = async (error, params) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
if (error instanceof UnauthorizedResponseError) {
|
|
65
|
+
//401
|
|
66
|
+
const body = await parseErrorResponse(error);
|
|
67
|
+
return Result.failure(getMessageInRedColor((_a = body.message) !== null && _a !== void 0 ? _a : "Unauthorized access"));
|
|
68
|
+
}
|
|
69
|
+
else if (error instanceof ProblemDetailsError) {
|
|
70
|
+
//400 & 403
|
|
71
|
+
const body = await parseErrorResponse(error);
|
|
72
|
+
const message = body.errors[Object.keys(body.errors)[0]][0];
|
|
73
|
+
return Result.failure(getMessageInRedColor(body.title + " " + ((_b = body.detail) !== null && _b !== void 0 ? _b : "") + ":\n" + message));
|
|
74
|
+
}
|
|
75
|
+
else if (error instanceof ApiError && error.statusCode === 422) {
|
|
76
|
+
//422
|
|
77
|
+
await extractErrorZipFile(error, params);
|
|
78
|
+
return Result.failure(getMessageInRedColor("An error occurred during portal generation due to an issue with the input. An error report has been written at the destination path: " +
|
|
79
|
+
params.generatedPortalArtifactsFolderPath));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return Result.failure(getMessageInRedColor(error instanceof Error ? error.message : String(error)));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const parseErrorResponse = async (error) => {
|
|
86
|
+
if (error instanceof Error && "body" in error) {
|
|
87
|
+
const stream = error.body;
|
|
88
|
+
return await parseStreamBodyToJson(stream);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
};
|
|
92
|
+
const extractErrorZipFile = async (error, params) => {
|
|
93
|
+
const data = error.body;
|
|
94
|
+
const writeStream = fsExtra.createWriteStream(params.generatedPortalArtifactsZipFilePath);
|
|
95
|
+
await new Promise((resolve, reject) => {
|
|
96
|
+
data
|
|
97
|
+
.pipe(writeStream)
|
|
98
|
+
.on("finish", () => resolve())
|
|
99
|
+
.on("error", reject);
|
|
100
|
+
});
|
|
101
|
+
if (!params.generateZipFile) {
|
|
102
|
+
await extractZipFile(params.generatedPortalArtifactsZipFilePath, params.generatedPortalArtifactsFolderPath);
|
|
103
|
+
await deleteFile(params.generatedPortalArtifactsZipFilePath);
|
|
104
|
+
}
|
|
49
105
|
};
|
|
106
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/controllers/portal/generate.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE/G,OAAO,EAAY,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACL,QAAQ,EAER,MAAM,EACN,WAAW,EACX,8BAA8B,EAC9B,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,MAAM,YAAY,GAAG,WAAW,CAAC,qBAAqB,CAAC;AACvD,MAAM,OAAO,GAAG,CAAC,CAAC;AAElB,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,MAA4B,EAC5B,SAAiB,EACgB,EAAE;IACnC,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,QAAQ,GAAoB,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;IAC/D,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IACxF,MAAM,MAAM,GAAG,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AAM,IAAI,GAAG,KAAK,CAAC,IAA6B,CAAC;IACjD,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;IAE1F,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI;aACD,IAAI,CAAC,WAAW,CAAC;aACjB,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;aAC7B,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QAC5B,MAAM,cAAc,CAAC,MAAM,CAAC,mCAAmC,EAAE,MAAM,CAAC,kCAAkC,CAAC,CAAC;QAC5G,MAAM,UAAU,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 specUrl;
|
|
7
|
+
isUserAuthenticated(configDir: string): Promise<boolean>;
|
|
8
|
+
userLogin(credentials: LoginCredentials, client: SDKClient, configDir: string): Promise<void>;
|
|
9
|
+
getSpecFile(spec: string): Promise<SpecFile>;
|
|
10
|
+
getSpecValidationSummary(prompts: PortalQuickstartPrompts, specFile: SpecFile, apiValidationController: ApiValidationExternalApIsController): Promise<ApiValidationSummary>;
|
|
11
|
+
setupBuildDirectory(prompts: PortalQuickstartPrompts, targetFolder: string, specFile: SpecFile, validationSummary: ApiValidationSummary, languages: string[]): Promise<void>;
|
|
12
|
+
generatePortalArtifacts(targetFolder: string, configDir: string): Promise<string>;
|
|
13
|
+
servePortal(generatedPortalPath: string, targetFolder: string, configDir: string): Promise<boolean>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { simpleGit } from "simple-git";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import * as filetype from "file-type";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import fsExtra from "fs-extra";
|
|
7
|
+
import { getAuthInfo } from "../../client-utils/auth-manager.js";
|
|
8
|
+
import { createTempDirectory, isValidUrl, unzipFile, getMessageInRedColor, clearDirectory, deleteFile, cleanUpGeneratedPortalFiles } from "../../utils/utils.js";
|
|
9
|
+
import { getValidationSummary } from "../api/validate.js";
|
|
10
|
+
import { generatePortal } from "./serve.js";
|
|
11
|
+
import { metadataFileContent, staticPortalRepoUrl } from "../../config/env.js";
|
|
12
|
+
import { PortalServerService } from "../../services/portal/server.js";
|
|
13
|
+
export class PortalQuickstartController {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.specUrl = "https://github.com/apimatic/static-portal-workflow/blob/master/spec/Apimatic-Calculator.json";
|
|
16
|
+
}
|
|
17
|
+
async isUserAuthenticated(configDir) {
|
|
18
|
+
const storedAuth = await getAuthInfo(configDir);
|
|
19
|
+
if (!(storedAuth === null || storedAuth === void 0 ? void 0 : storedAuth.authKey)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
async userLogin(credentials, client, configDir) {
|
|
25
|
+
await client.login(credentials.email, credentials.password, configDir);
|
|
26
|
+
}
|
|
27
|
+
async getSpecFile(spec) {
|
|
28
|
+
let filePath = "";
|
|
29
|
+
const tempSpecDir = await createTempDirectory();
|
|
30
|
+
if (spec) {
|
|
31
|
+
let specPath = String(spec);
|
|
32
|
+
if (isValidUrl(specPath)) {
|
|
33
|
+
try {
|
|
34
|
+
const response = await axios.head(specPath);
|
|
35
|
+
if (response.headers["content-type"].includes("text/html")) {
|
|
36
|
+
throw new Error(getMessageInRedColor(`Invalid URL. Please check the URL and ensure it points to a valid OpenAPI definition.`));
|
|
37
|
+
}
|
|
38
|
+
const specFile = await axios.get(specPath, { responseType: "arraybuffer" });
|
|
39
|
+
const fileName = path.basename(specPath);
|
|
40
|
+
filePath = path.join(tempSpecDir, fileName);
|
|
41
|
+
await fsExtra.writeFile(filePath, specFile.data);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (axios.isAxiosError(error)) {
|
|
45
|
+
if (error.response) {
|
|
46
|
+
if (error.response.status === 404) {
|
|
47
|
+
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.`));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new Error(getMessageInRedColor(`Unable to download the API Definition. The server returned ${error.response.status} ${error.response.statusText}`));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (error.request) {
|
|
54
|
+
if (error.code === "ECONNABORTED") {
|
|
55
|
+
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.`));
|
|
56
|
+
}
|
|
57
|
+
else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
|
|
58
|
+
throw new Error(getMessageInRedColor(`Failed to download the API Definition file due to network issues. Please check your internet connection and try again.`));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error(getMessageInRedColor(`Failed to download the API Definition file, no response was received from the server. Please try again later.`));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error(getMessageInRedColor(`Failed to download API Definition: ${error.message}`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(getMessageInRedColor(`Unable to save API Definition : ${error instanceof Error ? error.message : "Unknown error"}`));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
specPath = path.normalize(specPath);
|
|
75
|
+
const fileType = await filetype.fromFile(specPath);
|
|
76
|
+
if ((fileType === null || fileType === void 0 ? void 0 : fileType.ext) === "zip") {
|
|
77
|
+
filePath = tempSpecDir;
|
|
78
|
+
await unzipFile(fs.createReadStream(specPath), tempSpecDir);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const destinationPath = path.join(tempSpecDir, path.basename(specPath));
|
|
82
|
+
filePath = destinationPath;
|
|
83
|
+
await fsExtra.copy(specPath, destinationPath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { filePath, url: this.specUrl };
|
|
88
|
+
}
|
|
89
|
+
async getSpecValidationSummary(prompts, specFile, apiValidationController) {
|
|
90
|
+
const validationFlags = {
|
|
91
|
+
file: specFile.filePath,
|
|
92
|
+
url: specFile.url
|
|
93
|
+
};
|
|
94
|
+
try {
|
|
95
|
+
const validationSummary = await getValidationSummary(validationFlags, apiValidationController);
|
|
96
|
+
return validationSummary;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
prompts.displaySpecValidationErrorMessage();
|
|
100
|
+
if (axios.isAxiosError(error)) {
|
|
101
|
+
if (error.response) {
|
|
102
|
+
if (error.response.status === 400) {
|
|
103
|
+
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.`));
|
|
104
|
+
}
|
|
105
|
+
else if (error.response.status === 500) {
|
|
106
|
+
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`));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
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`));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (error.request) {
|
|
113
|
+
if (error.code === "ECONNABORTED") {
|
|
114
|
+
throw new Error(getMessageInRedColor(`The spec validation request timed out. Please try again.`));
|
|
115
|
+
}
|
|
116
|
+
else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
|
|
117
|
+
throw new Error(getMessageInRedColor(`Network error encountered while validating the spec file. Please check your connection and try again.`));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
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`));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw new Error(getMessageInRedColor(`Failed to validate spec file: ${error.message}`));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (error.result) {
|
|
128
|
+
const apiError = error;
|
|
129
|
+
if (error.body && apiError.statusCode === 401) {
|
|
130
|
+
throw new Error("You are not authorized to perform this action.");
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
throw new Error(error.message);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (error.statusCode === 401) {
|
|
137
|
+
throw new Error("You are not authorized to perform this action.");
|
|
138
|
+
}
|
|
139
|
+
else if (error.statusCode === 402 &&
|
|
140
|
+
error.body &&
|
|
141
|
+
typeof error.body === "string") {
|
|
142
|
+
throw new Error(error.body);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
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`));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async setupBuildDirectory(prompts, targetFolder, specFile, validationSummary, languages) {
|
|
150
|
+
const git = simpleGit({
|
|
151
|
+
timeout: {
|
|
152
|
+
block: 60 * 1000 // 1 minute timeout.
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
await git.clone(staticPortalRepoUrl, targetFolder);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
prompts.displayBuildDirectoryGenerationErrorMessage();
|
|
160
|
+
if (error instanceof Error) {
|
|
161
|
+
if (error.message.includes("timed out")) {
|
|
162
|
+
throw new Error(getMessageInRedColor("The operation timed out while setting up the build directory. Please check your internet connection and try again."));
|
|
163
|
+
}
|
|
164
|
+
else if (error.message.includes("Could not resolve host")) {
|
|
165
|
+
throw new Error(getMessageInRedColor("Unable to resolve the host. Please check your network settings and try again."));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
throw new Error(getMessageInRedColor(`Failed to set up the build directory. ${error.message}`));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw new Error(getMessageInRedColor(`Failed to set up the build directory. ${error}`));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
await clearDirectory(path.join(targetFolder, ".git"));
|
|
176
|
+
await clearDirectory(path.join(targetFolder, ".github"));
|
|
177
|
+
if (specFile.filePath && validationSummary.success) {
|
|
178
|
+
await deleteFile(path.join(targetFolder, "spec", "Apimatic-Calculator.json"));
|
|
179
|
+
fsExtra.copy(specFile.filePath, path.join(targetFolder, "spec", path.basename(specFile.filePath)));
|
|
180
|
+
}
|
|
181
|
+
const buildFilePath = path.join(targetFolder, "APIMATIC-BUILD.json");
|
|
182
|
+
const buildFileContent = JSON.parse(fs.readFileSync(buildFilePath, "utf8"));
|
|
183
|
+
const languageConfig = languages.reduce((config, lang) => {
|
|
184
|
+
config[lang] = {};
|
|
185
|
+
return config;
|
|
186
|
+
}, {});
|
|
187
|
+
buildFileContent.generatePortal.languageConfig = languageConfig;
|
|
188
|
+
fs.writeFileSync(buildFilePath, JSON.stringify(buildFileContent, null, 2));
|
|
189
|
+
const specFolder = path.join(targetFolder, "spec");
|
|
190
|
+
const metadataFile = fs.readdirSync(specFolder).find((file) => file.startsWith("APIMATIC-META"));
|
|
191
|
+
if (!metadataFile) {
|
|
192
|
+
const newMetadataFilePath = path.join(specFolder, "APIMATIC-META.json");
|
|
193
|
+
fs.writeFileSync(newMetadataFilePath, JSON.stringify(metadataFileContent, null, 2));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async generatePortalArtifacts(targetFolder, configDir) {
|
|
197
|
+
const generatedPortalPath = path.join(targetFolder, "generated_portal");
|
|
198
|
+
try {
|
|
199
|
+
await generatePortal(targetFolder, generatedPortalPath, configDir);
|
|
200
|
+
return generatedPortalPath;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (axios.isAxiosError(error)) {
|
|
204
|
+
if (error.response) {
|
|
205
|
+
if (error.response.status === 400) {
|
|
206
|
+
throw new Error(getMessageInRedColor(`The provided input is not valid. Please ensure the zip file contains a valid build file at the root level.`));
|
|
207
|
+
}
|
|
208
|
+
else if (error.response.status === 403) {
|
|
209
|
+
throw new Error(getMessageInRedColor(`Access denied. It looks like you don't have access to APIMatic's Docs as Code offering. Check your subscription details and contact our team at support@apimatic.io if you believe this is a mistake.`));
|
|
210
|
+
}
|
|
211
|
+
else if (error.response.status === 422) {
|
|
212
|
+
throw new Error(getMessageInRedColor(`Unable to process the build input. Please verify that your zip file is correctly structured and your build file is a valid JSON file.`));
|
|
213
|
+
}
|
|
214
|
+
else if (error.response.status === 500) {
|
|
215
|
+
throw new Error(getMessageInRedColor(`The server encountered an error while generating your portal, please try again. If the issue persists, contact our team at support@apimatic.io`));
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
throw new Error(getMessageInRedColor(`Something went wrong while generating the portal. 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`));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else if (error.request) {
|
|
222
|
+
if (error.code === "ECONNABORTED") {
|
|
223
|
+
throw new Error(getMessageInRedColor(`The portal generation request timed out. Please try again. If the issue persists, try out our Async API for Docs as Code: https://docs.apimatic.io/platform-api/#/http/api-endpoints/docs-portal-management/generate-on-prem-portal-via-build-input`));
|
|
224
|
+
}
|
|
225
|
+
else if (error.code === "ENOTFOUND" || error.code === "ERR_NETWORK") {
|
|
226
|
+
throw new Error(getMessageInRedColor(`Network error encountered while generating the portal. Please check your connection and try again.`));
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
throw new Error(getMessageInRedColor(`Something went wrong while generating the portal, please try again. If the issue persists, reach out to our support team at support@apimatic.io`));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
throw new Error(getMessageInRedColor(`Failed to generate portal: ${error.message}`));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
throw new Error(getMessageInRedColor(`Something went wrong while generating the portal, please try again later. If the issue persists, contact our team at support@apimatic.io`));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async servePortal(generatedPortalPath, targetFolder, configDir) {
|
|
242
|
+
const server = new PortalServerService();
|
|
243
|
+
server.setupServer(generatedPortalPath);
|
|
244
|
+
await cleanUpGeneratedPortalFiles(targetFolder);
|
|
245
|
+
return await server.startServer({
|
|
246
|
+
generatedPortalPath,
|
|
247
|
+
targetFolder,
|
|
248
|
+
configDir,
|
|
249
|
+
authKey: null
|
|
250
|
+
}, false, false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=quickstart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/controllers/portal/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,IAAI,CA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 @@
|
|
|
1
|
+
import chokidar from "chokidar";
|
|
2
|
+
export declare const watchAndRegeneratePortal: (sourceDir: string, portalDir: string, configDir: string, overrideAuthKey: string | null, ignoredPaths?: string[]) => Promise<chokidar.FSWatcher>;
|
|
3
|
+
export declare const generatePortal: (sourceDir: string, portalDir: string, configDir: string, ignoredPaths?: string[], overrideAuthKey?: string | null) => Promise<void>;
|