@apimatic/cli 1.1.0-alpha.21 → 1.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -90
- package/lib/actions/action-result.d.ts +8 -3
- package/lib/actions/action-result.js +34 -15
- package/lib/actions/action-result.js.map +1 -1
- package/lib/actions/api/transform.d.ts +15 -0
- package/lib/actions/api/transform.js +48 -0
- package/lib/actions/api/transform.js.map +1 -0
- package/lib/actions/api/validate.d.ts +12 -0
- package/lib/actions/api/validate.js +41 -0
- package/lib/actions/api/validate.js.map +1 -0
- package/lib/actions/auth/login.d.ts +6 -5
- package/lib/actions/auth/login.js +25 -33
- package/lib/actions/auth/login.js.map +1 -1
- package/lib/actions/auth/logout.d.ts +8 -0
- package/lib/actions/auth/logout.js +15 -0
- package/lib/actions/auth/logout.js.map +1 -0
- package/lib/actions/auth/status.d.ts +11 -0
- package/lib/actions/auth/status.js +26 -0
- package/lib/actions/auth/status.js.map +1 -0
- package/lib/actions/portal/copilot.d.ts +5 -3
- package/lib/actions/portal/copilot.js +47 -37
- package/lib/actions/portal/copilot.js.map +1 -1
- package/lib/actions/portal/generate.d.ts +4 -5
- package/lib/actions/portal/generate.js +30 -37
- package/lib/actions/portal/generate.js.map +1 -1
- package/lib/actions/portal/quickstart.d.ts +16 -0
- package/lib/actions/portal/quickstart.js +145 -0
- package/lib/actions/portal/quickstart.js.map +1 -0
- package/lib/actions/portal/recipe/new-recipe.d.ts +11 -20
- package/lib/actions/portal/recipe/new-recipe.js +147 -221
- package/lib/actions/portal/recipe/new-recipe.js.map +1 -1
- package/lib/actions/portal/serve.d.ts +12 -10
- package/lib/actions/portal/serve.js +112 -17
- package/lib/actions/portal/serve.js.map +1 -1
- package/lib/actions/portal/toc/new-toc.d.ts +16 -15
- package/lib/actions/portal/toc/new-toc.js +80 -116
- package/lib/actions/portal/toc/new-toc.js.map +1 -1
- package/lib/actions/sdk/generate.d.ts +5 -6
- package/lib/actions/sdk/generate.js +22 -47
- package/lib/actions/sdk/generate.js.map +1 -1
- package/lib/application/portal/recipe/portal-recipe.d.ts +2 -2
- package/lib/application/portal/recipe/portal-recipe.js +9 -9
- package/lib/application/portal/recipe/portal-recipe.js.map +1 -1
- package/lib/application/portal/recipe/recipe-generator.d.ts +7 -2
- package/lib/application/portal/recipe/recipe-generator.js +21 -22
- package/lib/application/portal/recipe/recipe-generator.js.map +1 -1
- package/lib/client-utils/auth-manager.d.ts +1 -1
- package/lib/client-utils/auth-manager.js +3 -4
- package/lib/client-utils/auth-manager.js.map +1 -1
- package/lib/commands/api/transform.d.ts +6 -3
- package/lib/commands/api/transform.js +43 -94
- package/lib/commands/api/transform.js.map +1 -1
- package/lib/commands/api/validate.d.ts +6 -3
- package/lib/commands/api/validate.js +27 -66
- package/lib/commands/api/validate.js.map +1 -1
- package/lib/commands/auth/login.d.ts +2 -1
- package/lib/commands/auth/login.js +15 -9
- package/lib/commands/auth/login.js.map +1 -1
- package/lib/commands/auth/logout.d.ts +3 -1
- package/lib/commands/auth/logout.js +12 -13
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/status.d.ts +1 -0
- package/lib/commands/auth/status.js +13 -11
- package/lib/commands/auth/status.js.map +1 -1
- package/lib/commands/portal/copilot.d.ts +2 -2
- package/lib/commands/portal/copilot.js +22 -20
- package/lib/commands/portal/copilot.js.map +1 -1
- package/lib/commands/portal/generate.d.ts +3 -4
- package/lib/commands/portal/generate.js +19 -14
- package/lib/commands/portal/generate.js.map +1 -1
- package/lib/commands/portal/quickstart.d.ts +3 -4
- package/lib/commands/portal/quickstart.js +24 -101
- package/lib/commands/portal/quickstart.js.map +1 -1
- package/lib/commands/portal/recipe/new.d.ts +3 -1
- package/lib/commands/portal/recipe/new.js +31 -23
- package/lib/commands/portal/recipe/new.js.map +1 -1
- package/lib/commands/portal/serve.d.ts +5 -5
- package/lib/commands/portal/serve.js +31 -57
- package/lib/commands/portal/serve.js.map +1 -1
- package/lib/commands/portal/toc/new.d.ts +2 -2
- package/lib/commands/portal/toc/new.js +35 -26
- package/lib/commands/portal/toc/new.js.map +1 -1
- package/lib/commands/sdk/generate.d.ts +5 -4
- package/lib/commands/sdk/generate.js +26 -17
- package/lib/commands/sdk/generate.js.map +1 -1
- package/lib/hooks/not-found.js +1 -1
- package/lib/hooks/not-found.js.map +1 -1
- package/lib/infrastructure/api-utils.js +3 -2
- package/lib/infrastructure/api-utils.js.map +1 -1
- package/lib/{application/portal/serve/watcher-handler.d.ts → infrastructure/debounce-service.d.ts} +3 -3
- package/lib/{application/portal/serve/watcher-handler.js → infrastructure/debounce-service.js} +5 -4
- package/lib/infrastructure/debounce-service.js.map +1 -0
- package/lib/infrastructure/env-info.d.ts +1 -1
- package/lib/infrastructure/env-info.js +2 -2
- package/lib/infrastructure/env-info.js.map +1 -1
- package/lib/infrastructure/file-service.d.ts +7 -2
- package/lib/infrastructure/file-service.js +46 -5
- package/lib/infrastructure/file-service.js.map +1 -1
- package/lib/infrastructure/launcher-service.d.ts +2 -0
- package/lib/infrastructure/launcher-service.js +4 -0
- package/lib/infrastructure/launcher-service.js.map +1 -1
- package/lib/infrastructure/network-service.d.ts +3 -0
- package/lib/infrastructure/network-service.js +7 -0
- package/lib/infrastructure/network-service.js.map +1 -0
- package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
- package/lib/infrastructure/services/api-client-factory.js +20 -0
- package/lib/infrastructure/services/api-client-factory.js.map +1 -0
- package/lib/infrastructure/services/api-service.d.ts +2 -2
- package/lib/infrastructure/services/api-service.js +6 -6
- package/lib/infrastructure/services/api-service.js.map +1 -1
- package/lib/infrastructure/services/auth-service.d.ts +1 -1
- package/lib/infrastructure/services/auth-service.js +7 -5
- package/lib/infrastructure/services/auth-service.js.map +1 -1
- package/lib/infrastructure/services/file-download-service.d.ts +15 -0
- package/lib/infrastructure/services/file-download-service.js +104 -0
- package/lib/infrastructure/services/file-download-service.js.map +1 -0
- package/lib/infrastructure/services/portal-service.d.ts +11 -13
- package/lib/infrastructure/services/portal-service.js +73 -102
- package/lib/infrastructure/services/portal-service.js.map +1 -1
- package/lib/infrastructure/services/telemetry-service.d.ts +3 -2
- package/lib/infrastructure/services/telemetry-service.js +4 -6
- package/lib/infrastructure/services/telemetry-service.js.map +1 -1
- package/lib/infrastructure/services/transformation-service.d.ts +23 -0
- package/lib/infrastructure/services/transformation-service.js +56 -0
- package/lib/infrastructure/services/transformation-service.js.map +1 -0
- package/lib/infrastructure/services/validation-service.d.ts +17 -0
- package/lib/infrastructure/services/validation-service.js +49 -0
- package/lib/infrastructure/services/validation-service.js.map +1 -0
- package/lib/prompts/api/transform.d.ts +11 -0
- package/lib/prompts/api/transform.js +30 -0
- package/lib/prompts/api/transform.js.map +1 -0
- package/lib/prompts/api/validate.d.ts +12 -0
- package/lib/prompts/api/validate.js +41 -0
- package/lib/prompts/api/validate.js.map +1 -0
- package/lib/prompts/auth/login.d.ts +6 -1
- package/lib/prompts/auth/login.js +12 -3
- package/lib/prompts/auth/login.js.map +1 -1
- package/lib/prompts/auth/logout.d.ts +3 -0
- package/lib/prompts/auth/logout.js +7 -0
- package/lib/prompts/auth/logout.js.map +1 -0
- package/lib/prompts/auth/status.d.ts +8 -0
- package/lib/prompts/auth/status.js +21 -0
- package/lib/prompts/auth/status.js.map +1 -0
- package/lib/prompts/format.d.ts +33 -0
- package/lib/prompts/format.js +99 -0
- package/lib/prompts/format.js.map +1 -0
- package/lib/prompts/portal/copilot.d.ts +8 -4
- package/lib/prompts/portal/copilot.js +35 -24
- package/lib/prompts/portal/copilot.js.map +1 -1
- package/lib/prompts/portal/generate.d.ts +9 -7
- package/lib/prompts/portal/generate.js +22 -23
- package/lib/prompts/portal/generate.js.map +1 -1
- package/lib/prompts/portal/quickstart.d.ts +30 -29
- package/lib/prompts/portal/quickstart.js +99 -193
- package/lib/prompts/portal/quickstart.js.map +1 -1
- package/lib/prompts/portal/recipe/new-recipe.d.ts +23 -18
- package/lib/prompts/portal/recipe/new-recipe.js +70 -108
- package/lib/prompts/portal/recipe/new-recipe.js.map +1 -1
- package/lib/prompts/portal/serve.d.ts +10 -3
- package/lib/prompts/portal/serve.js +30 -11
- package/lib/prompts/portal/serve.js.map +1 -1
- package/lib/prompts/portal/toc/new-toc.d.ts +12 -8
- package/lib/prompts/portal/toc/new-toc.js +20 -22
- package/lib/prompts/portal/toc/new-toc.js.map +1 -1
- package/lib/prompts/sdk/generate.d.ts +7 -7
- package/lib/prompts/sdk/generate.js +17 -23
- package/lib/prompts/sdk/generate.js.map +1 -1
- package/lib/types/api/account.d.ts +1 -1
- package/lib/types/api/transform.d.ts +14 -25
- package/lib/types/api/transform.js +16 -16
- package/lib/types/api/transform.js.map +1 -1
- package/lib/types/build/build.d.ts +9 -1
- package/lib/types/build/build.js +5 -2
- package/lib/types/build/build.js.map +1 -1
- package/lib/types/build-context.d.ts +5 -1
- package/lib/types/build-context.js +21 -4
- package/lib/types/build-context.js.map +1 -1
- package/lib/types/common/command-metadata.d.ts +4 -0
- package/lib/types/common/command-metadata.js +2 -0
- package/lib/types/common/command-metadata.js.map +1 -0
- package/lib/types/events/domain-event.d.ts +1 -1
- package/lib/types/events/domain-event.js.map +1 -1
- package/lib/types/events/quickstart-completed.js +1 -1
- package/lib/types/events/quickstart-initiated.js +1 -1
- package/lib/types/events/recipe-creation-failed.d.ts +1 -1
- package/lib/types/events/recipe-creation-failed.js +1 -1
- package/lib/types/events/recipe-creation-failed.js.map +1 -1
- package/lib/types/events/toc-creation-failed.d.ts +1 -1
- package/lib/types/events/toc-creation-failed.js +1 -1
- package/lib/types/events/toc-creation-failed.js.map +1 -1
- package/lib/types/file/directory.d.ts +17 -0
- package/lib/types/file/directory.js +86 -0
- package/lib/types/file/directory.js.map +1 -0
- package/lib/types/file/directoryPath.d.ts +3 -1
- package/lib/types/file/directoryPath.js +8 -2
- package/lib/types/file/directoryPath.js.map +1 -1
- package/lib/types/file/fileName.d.ts +2 -0
- package/lib/types/file/fileName.js +12 -0
- package/lib/types/file/fileName.js.map +1 -1
- package/lib/types/file/filePath.d.ts +2 -0
- package/lib/types/file/filePath.js +21 -0
- package/lib/types/file/filePath.js.map +1 -1
- package/lib/types/file/resource-input.d.ts +5 -0
- package/lib/types/file/resource-input.js +42 -0
- package/lib/types/file/resource-input.js.map +1 -0
- package/lib/types/file/urlPath.d.ts +6 -0
- package/lib/types/file/urlPath.js +22 -0
- package/lib/types/file/urlPath.js.map +1 -0
- package/lib/types/portal-context.d.ts +3 -1
- package/lib/types/portal-context.js +10 -0
- package/lib/types/portal-context.js.map +1 -1
- package/lib/types/recipe/recipe.d.ts +2 -17
- package/lib/types/recipe-context.d.ts +8 -0
- package/lib/types/recipe-context.js +21 -0
- package/lib/types/recipe-context.js.map +1 -0
- package/lib/types/resource-context.d.ts +12 -0
- package/lib/types/resource-context.js +30 -0
- package/lib/types/resource-context.js.map +1 -0
- package/lib/types/sdk/generate.d.ts +2 -15
- package/lib/types/sdk/generate.js +24 -10
- package/lib/types/sdk/generate.js.map +1 -1
- package/lib/types/sdk-context.d.ts +6 -5
- package/lib/types/sdk-context.js +12 -8
- package/lib/types/sdk-context.js.map +1 -1
- package/lib/types/sdl/sdl.d.ts +9 -0
- package/lib/types/sdl/sdl.js +46 -1
- package/lib/types/sdl/sdl.js.map +1 -1
- package/lib/types/spec-context.d.ts +3 -0
- package/lib/types/spec-context.js +7 -2
- package/lib/types/spec-context.js.map +1 -1
- package/lib/types/temp-context.d.ts +11 -0
- package/lib/types/temp-context.js +27 -0
- package/lib/types/temp-context.js.map +1 -0
- package/lib/types/toc-context.d.ts +12 -0
- package/lib/types/toc-context.js +26 -0
- package/lib/types/toc-context.js.map +1 -0
- package/lib/types/transform-context.d.ts +13 -0
- package/lib/types/transform-context.js +30 -0
- package/lib/types/transform-context.js.map +1 -0
- package/lib/types/utils.d.ts +0 -9
- package/lib/utils/string-utils.d.ts +1 -0
- package/lib/utils/string-utils.js +10 -0
- package/lib/utils/string-utils.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -27
- package/lib/utils/utils.js +6 -145
- package/lib/utils/utils.js.map +1 -1
- package/package.json +4 -4
- package/lib/application/portal/serve/portal-watcher.d.ts +0 -11
- package/lib/application/portal/serve/portal-watcher.js +0 -64
- package/lib/application/portal/serve/portal-watcher.js.map +0 -1
- package/lib/application/portal/serve/serve-handler.d.ts +0 -16
- package/lib/application/portal/serve/serve-handler.js +0 -91
- package/lib/application/portal/serve/serve-handler.js.map +0 -1
- package/lib/application/portal/serve/watcher-handler.js.map +0 -1
- package/lib/application/portal/toc/sdl-parser.d.ts +0 -19
- package/lib/application/portal/toc/sdl-parser.js +0 -90
- package/lib/application/portal/toc/sdl-parser.js.map +0 -1
- package/lib/client-utils/sdk-client.d.ts +0 -18
- package/lib/client-utils/sdk-client.js +0 -41
- package/lib/client-utils/sdk-client.js.map +0 -1
- package/lib/config/env.d.ts +0 -26
- package/lib/config/env.js +0 -27
- package/lib/config/env.js.map +0 -1
- package/lib/controllers/api/transform.d.ts +0 -5
- package/lib/controllers/api/transform.js +0 -50
- package/lib/controllers/api/transform.js.map +0 -1
- package/lib/controllers/api/validate.d.ts +0 -3
- package/lib/controllers/api/validate.js +0 -29
- package/lib/controllers/api/validate.js.map +0 -1
- package/lib/controllers/portal/quickstart.d.ts +0 -13
- package/lib/controllers/portal/quickstart.js +0 -214
- package/lib/controllers/portal/quickstart.js.map +0 -1
- package/lib/infrastructure/api-client-utils.d.ts +0 -6
- package/lib/infrastructure/api-client-utils.js +0 -34
- package/lib/infrastructure/api-client-utils.js.map +0 -1
- package/lib/prompts/portal/common/base-prompts.d.ts +0 -7
- package/lib/prompts/portal/common/base-prompts.js +0 -19
- package/lib/prompts/portal/common/base-prompts.js.map +0 -1
- package/lib/types/api/validate.d.ts +0 -12
- package/lib/types/api/validate.js +0 -2
- package/lib/types/api/validate.js.map +0 -1
- package/lib/types/common/result.d.ts +0 -17
- package/lib/types/common/result.js +0 -32
- package/lib/types/common/result.js.map +0 -1
- package/lib/types/portal/generate.d.ts +0 -13
- package/lib/types/portal/generate.js +0 -3
- package/lib/types/portal/generate.js.map +0 -1
- package/lib/types/portal/quickstart.d.ts +0 -17
- package/lib/types/portal/quickstart.js +0 -2
- package/lib/types/portal/quickstart.js.map +0 -1
- package/lib/types/portal/serve.d.ts +0 -12
- package/lib/types/portal/serve.js +0 -2
- package/lib/types/portal/serve.js.map +0 -1
- package/lib/validators/common/directoryValidator.d.ts +0 -5
- package/lib/validators/common/directoryValidator.js +0 -22
- package/lib/validators/common/directoryValidator.js.map +0 -1
- package/lib/validators/portal/serve-validator.d.ts +0 -6
- package/lib/validators/portal/serve-validator.js +0 -15
- package/lib/validators/portal/serve-validator.js.map +0 -1
package/lib/utils/utils.js
CHANGED
|
@@ -1,140 +1,13 @@
|
|
|
1
1
|
import { __asyncValues } from "tslib";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import
|
|
4
|
-
import fsExtra from "fs-extra";
|
|
5
|
-
import os from "os";
|
|
6
|
-
import archiver from "archiver";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
7
4
|
import stripTags from "striptags";
|
|
8
|
-
import colors from "picocolors";
|
|
9
|
-
export const createTempDirectory = async () => {
|
|
10
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), "apimatic-cli-"));
|
|
11
|
-
};
|
|
12
|
-
export const clearDirectory = async (folderPath) => {
|
|
13
|
-
if (!fs.existsSync(folderPath)) {
|
|
14
|
-
throw new Error(`Directory ${folderPath} does not exist`);
|
|
15
|
-
}
|
|
16
|
-
const files = await fsExtra.readdir(folderPath);
|
|
17
|
-
for (const file of files) {
|
|
18
|
-
const filePath = path.join(folderPath, file);
|
|
19
|
-
await deleteFile(filePath);
|
|
20
|
-
}
|
|
21
|
-
await deleteFile(folderPath);
|
|
22
|
-
};
|
|
23
|
-
// TODO: Move to portal:quickstart command.
|
|
24
|
-
const descriptions = Object.entries({
|
|
25
|
-
"APIMATIC-BUILD.json": "# Defines all configurations for the API portal, including programming languages and themes",
|
|
26
|
-
spec: "# Contains all API definition files",
|
|
27
|
-
content: "# Includes custom documentation pages in Markdown",
|
|
28
|
-
"content/toc.yml": "# Controls the structure of the side navigation bar in the API portal",
|
|
29
|
-
static: "# Includes all static files, such as images, GIFs, and PDFs"
|
|
30
|
-
}).reduce((acc, [key, value]) => {
|
|
31
|
-
acc[path.normalize(key)] = value;
|
|
32
|
-
return acc;
|
|
33
|
-
}, {});
|
|
34
|
-
// TODO: Move to portal:quickstart command.
|
|
35
|
-
export const directoryToJson = (dirPath, parentPath = "") => {
|
|
36
|
-
const directoryStructure = {};
|
|
37
|
-
const items = fs.readdirSync(dirPath);
|
|
38
|
-
items.forEach((item) => {
|
|
39
|
-
if (item === ".git")
|
|
40
|
-
return; // Skip .git directory
|
|
41
|
-
const itemPath = path.join(dirPath, item);
|
|
42
|
-
const relativePath = path.join(parentPath, item);
|
|
43
|
-
const stats = fs.statSync(itemPath);
|
|
44
|
-
if (stats.isDirectory()) {
|
|
45
|
-
const subdirectoryStructure = directoryToJson(itemPath, relativePath);
|
|
46
|
-
const folderName = descriptions[path.normalize(relativePath)]
|
|
47
|
-
? `${item} : ${descriptions[path.normalize(relativePath)]}`
|
|
48
|
-
: item;
|
|
49
|
-
directoryStructure[folderName] = subdirectoryStructure;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
directoryStructure[descriptions[path.normalize(relativePath)] ? `${item} : ${descriptions[path.normalize(relativePath)]}` : item] = null;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return directoryStructure;
|
|
56
|
-
};
|
|
57
|
-
export const isValidUrl = (input) => {
|
|
58
|
-
if (!input) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
const url = new URL(input);
|
|
63
|
-
if (!["http:", "https:"].includes(url.protocol)) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
if (url.protocol === "file:" || fs.existsSync(input)) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
if (!url.host) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
catch (_) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
export const deleteFile = async (filePath) => {
|
|
79
|
-
return await fsExtra.remove(filePath);
|
|
80
|
-
};
|
|
81
|
-
export const writeFileUsingReadableStream = (stream, destinationPath) => {
|
|
82
|
-
return new Promise((resolve) => {
|
|
83
|
-
const writeStream = fs.createWriteStream(destinationPath);
|
|
84
|
-
stream.pipe(writeStream);
|
|
85
|
-
writeStream.on("close", () => {
|
|
86
|
-
resolve("Zipped");
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Packages local files into a ZIP archive
|
|
92
|
-
*
|
|
93
|
-
* @param {docsPortalFolderPath} path to portal directory.
|
|
94
|
-
* @param {destinationZipPath} path to generated zip
|
|
95
|
-
* return {string}
|
|
96
|
-
*/
|
|
97
|
-
export const zipDirectory = async (sourcePath, destinationPath) => {
|
|
98
|
-
// Check if the directory exists for the user or not
|
|
99
|
-
await fsExtra.ensureDir(sourcePath);
|
|
100
|
-
const zipPath = path.join(destinationPath, ".target.zip");
|
|
101
|
-
const output = fs.createWriteStream(zipPath);
|
|
102
|
-
const archive = archiver("zip");
|
|
103
|
-
return new Promise((resolve, reject) => {
|
|
104
|
-
archive.on("error", (err) => {
|
|
105
|
-
reject(new Error(err.message));
|
|
106
|
-
});
|
|
107
|
-
output.on("error", (err) => {
|
|
108
|
-
reject(new Error(err.message));
|
|
109
|
-
});
|
|
110
|
-
output.on("close", () => {
|
|
111
|
-
resolve(zipPath);
|
|
112
|
-
});
|
|
113
|
-
archive.pipe(output);
|
|
114
|
-
archive.directory(sourcePath, false);
|
|
115
|
-
archive.finalize().catch(reject);
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
5
|
export const replaceHTML = (string) => {
|
|
119
6
|
return stripTags(string);
|
|
120
7
|
};
|
|
121
8
|
export const getFileNameFromPath = (filePath) => {
|
|
122
9
|
return path.basename(filePath).split(".")[0];
|
|
123
10
|
};
|
|
124
|
-
export const printValidationMessages = ({ warnings, errors, messages }, { log, warn, error }) => {
|
|
125
|
-
warnings = warnings || [];
|
|
126
|
-
messages = messages || [];
|
|
127
|
-
const singleError = errors.join("\n") || "";
|
|
128
|
-
messages.forEach((message) => {
|
|
129
|
-
log(`Info: ${replaceHTML(message)}`);
|
|
130
|
-
});
|
|
131
|
-
warnings.forEach((warning) => {
|
|
132
|
-
warn(replaceHTML(warning));
|
|
133
|
-
});
|
|
134
|
-
if (errors.length > 0) {
|
|
135
|
-
error(replaceHTML(singleError));
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
11
|
export async function parseStreamBodyToJson(body) {
|
|
139
12
|
var _a, e_1, _b, _c;
|
|
140
13
|
const chunks = [];
|
|
@@ -156,22 +29,10 @@ export async function parseStreamBodyToJson(body) {
|
|
|
156
29
|
const text = Buffer.concat(chunks).toString("utf-8");
|
|
157
30
|
return JSON.parse(text);
|
|
158
31
|
}
|
|
159
|
-
export const
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
};
|
|
165
|
-
export const getMessageInCyanColor = (message) => {
|
|
166
|
-
return colors.cyan(message);
|
|
167
|
-
};
|
|
168
|
-
export const getMessageInGreenColor = (message) => {
|
|
169
|
-
return colors.greenBright(message);
|
|
170
|
-
};
|
|
171
|
-
export const getMessageInMagentaColor = (message) => {
|
|
172
|
-
return colors.magentaBright(message);
|
|
173
|
-
};
|
|
174
|
-
export const getMessageInRedColor = (message) => {
|
|
175
|
-
return colors.redBright(message);
|
|
32
|
+
export const toPascalCase = (str) => {
|
|
33
|
+
return str
|
|
34
|
+
.split(" ")
|
|
35
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
36
|
+
.join("");
|
|
176
37
|
};
|
|
177
38
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACtD,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAA2B;;IACrE,MAAM,MAAM,GAAa,EAAE,CAAC;;QAC5B,KAA0B,eAAA,SAAA,cAAA,IAAI,CAAA,UAAA,sEAAE,CAAC;YAAP,oBAAI;YAAJ,WAAI;YAAnB,MAAM,KAAK,KAAA,CAAA;YACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,CAAC;;;;;;;;;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAU,EAAE;IAClD,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SACzE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apimatic/cli",
|
|
3
3
|
"description": "The official CLI for APIMatic.",
|
|
4
|
-
"version": "1.1.0-alpha.
|
|
4
|
+
"version": "1.1.0-alpha.22",
|
|
5
5
|
"author": "APIMatic",
|
|
6
6
|
"bin": {
|
|
7
7
|
"apimatic": "./bin/run.js"
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"express": "^4.17.1",
|
|
62
62
|
"extract-zip": "^2.0.1",
|
|
63
63
|
"fast-levenshtein": "^3.0.0",
|
|
64
|
-
"file-type": "^15.0.0",
|
|
65
64
|
"form-data": "^4.0.2",
|
|
66
65
|
"fs-extra": "^11.3.0",
|
|
67
66
|
"get-port": "^7.1.0",
|
|
@@ -71,7 +70,6 @@
|
|
|
71
70
|
"prettier": "^2.8.8",
|
|
72
71
|
"striptags": "^3.2.0",
|
|
73
72
|
"tmp-promise": "^3.0.3",
|
|
74
|
-
"treeify": "^1.1.0",
|
|
75
73
|
"tslib": "^2.8.1",
|
|
76
74
|
"uuid": "^11.1.0",
|
|
77
75
|
"yaml": "^2.8.0"
|
|
@@ -79,10 +77,11 @@
|
|
|
79
77
|
"devDependencies": {
|
|
80
78
|
"@commitlint/cli": "^15.0.0",
|
|
81
79
|
"@commitlint/config-conventional": "^15.0.0",
|
|
80
|
+
"@eslint/js": "^9.34.0",
|
|
82
81
|
"@oclif/test": "^4.1.13",
|
|
83
82
|
"@semantic-release/changelog": "^6.0.3",
|
|
84
83
|
"@semantic-release/git": "^10.0.1",
|
|
85
|
-
"@types/archiver": "^5.
|
|
84
|
+
"@types/archiver": "^5.3.4",
|
|
86
85
|
"@types/base-64": "^1.0.0",
|
|
87
86
|
"@types/chai": "^4.3.20",
|
|
88
87
|
"@types/connect-livereload": "^0.5.32",
|
|
@@ -145,6 +144,7 @@
|
|
|
145
144
|
"description": "Generate a Table of Contents (TOC) file for your API documentation portal."
|
|
146
145
|
}
|
|
147
146
|
},
|
|
147
|
+
"topicSeparator": " ",
|
|
148
148
|
"state": "Alpha"
|
|
149
149
|
},
|
|
150
150
|
"lint-staged": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import chokidar from "chokidar";
|
|
2
|
-
import { ServePaths } from "../../../types/portal/serve.js";
|
|
3
|
-
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
4
|
-
import { ActionResult } from "../../../actions/action-result.js";
|
|
5
|
-
export declare class PortalWatcher {
|
|
6
|
-
private watcherHandler;
|
|
7
|
-
constructor();
|
|
8
|
-
watchAndRegeneratePortalOnChange(paths: ServePaths, commandName: string, generatePortal: (buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, commandName: string, force: boolean, zipPortal: boolean) => Promise<ActionResult>): Promise<chokidar.FSWatcher>;
|
|
9
|
-
cancelPendingOperations(): void;
|
|
10
|
-
protected handleFileChange(paths: ServePaths, eventQueue: Map<string, string>, eventId: string, commandName: string, generatePortal: (buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, commandName: string, force: boolean, zipPortal: boolean) => Promise<ActionResult>): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import chokidar from "chokidar";
|
|
2
|
-
import crypto from "crypto";
|
|
3
|
-
import console from "console";
|
|
4
|
-
import { Mutex } from "async-mutex";
|
|
5
|
-
import { WatcherHandler } from "./watcher-handler.js";
|
|
6
|
-
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
7
|
-
export class PortalWatcher {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.watcherHandler = new WatcherHandler();
|
|
10
|
-
}
|
|
11
|
-
async watchAndRegeneratePortalOnChange(paths, commandName, generatePortal) {
|
|
12
|
-
//Regex matches any hidden files and folders.
|
|
13
|
-
const watcher = chokidar.watch(paths.sourceDirectoryPath, {
|
|
14
|
-
ignored: [/(^|[/\\])\..+/],
|
|
15
|
-
ignoreInitial: true,
|
|
16
|
-
persistent: true,
|
|
17
|
-
awaitWriteFinish: true,
|
|
18
|
-
atomic: true
|
|
19
|
-
});
|
|
20
|
-
const deletedDirectories = new Set();
|
|
21
|
-
const eventQueue = new Map();
|
|
22
|
-
const mutex = new Mutex();
|
|
23
|
-
watcher
|
|
24
|
-
.on("all", async (event, path) => {
|
|
25
|
-
if (event == "unlinkDir") {
|
|
26
|
-
deletedDirectories.add(path);
|
|
27
|
-
}
|
|
28
|
-
if (event == "unlink") {
|
|
29
|
-
for (const dir of deletedDirectories) {
|
|
30
|
-
if (path.startsWith(dir)) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const eventId = `${Date.now()}-${crypto.randomUUID()}`;
|
|
36
|
-
await mutex.runExclusive(async () => {
|
|
37
|
-
eventQueue.clear();
|
|
38
|
-
eventQueue.set(eventId, path);
|
|
39
|
-
});
|
|
40
|
-
await this.watcherHandler.execute(async () => {
|
|
41
|
-
await this.handleFileChange(paths, eventQueue, eventId, commandName, generatePortal);
|
|
42
|
-
});
|
|
43
|
-
})
|
|
44
|
-
.on("error", () => {
|
|
45
|
-
console.error("An unexpected error occurred while watching your build folder for changes. Please try again later. If the issue persists, contact our team at support@apimatic.io");
|
|
46
|
-
watcher.close();
|
|
47
|
-
});
|
|
48
|
-
return watcher;
|
|
49
|
-
}
|
|
50
|
-
// TODO: Remove this method. Figure out a better way to do this.
|
|
51
|
-
cancelPendingOperations() {
|
|
52
|
-
if (this.watcherHandler) {
|
|
53
|
-
this.watcherHandler.cancel();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async handleFileChange(paths, eventQueue, eventId, commandName, generatePortal) {
|
|
57
|
-
if (!eventQueue.has(eventId)) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const result = await generatePortal(new DirectoryPath(paths.sourceDirectoryPath), new DirectoryPath(paths.destinationDirectoryPath), commandName, true, false);
|
|
61
|
-
result.map((error) => console.log(error));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=portal-watcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portal-watcher.js","sourceRoot":"","sources":["../../../../src/application/portal/serve/portal-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAGrE,MAAM,OAAO,aAAa;IAGxB;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,gCAAgC,CAC3C,KAAiB,EACjB,WAAmB,EACnB,cAM0B;QAE1B,6CAA6C;QAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE;YACxD,OAAO,EAAE,CAAC,eAAe,CAAC;YAC1B,aAAa,EAAE,IAAI;YACnB,UAAU,EAAE,IAAI;YAChB,gBAAgB,EAAE,IAAI;YACtB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;Q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ACzD,uBAAuB;QAC5B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IAES,KAAK,CAAC,gBAAgB,CAC9B,KAAiB,EACjB,UAA+B,EAC/B,OAAe,EACf,WAAmB,EACnB,cAM0B;QAE1B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,IAAI,aAAa,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAC5C,IAAI,aAAa,CAAC,KAAK,CAAC,wBAAwB,CAAC,EACjD,WAAW,EACX,IAAI,EACJ,KAAK,CACN,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Result } from "../../../types/common/result.js";
|
|
2
|
-
import { ServeFlags, ServePaths } from "../../../types/portal/serve.js";
|
|
3
|
-
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
4
|
-
import { ActionResult } from "../../../actions/action-result.js";
|
|
5
|
-
export declare class ServeHandler {
|
|
6
|
-
private server;
|
|
7
|
-
private liveReloadServer;
|
|
8
|
-
private readonly app;
|
|
9
|
-
private readonly portalWatcher;
|
|
10
|
-
constructor();
|
|
11
|
-
setupServer(generatedPortalArtifactsDirectoryPath: string): Promise<Result<string, string>>;
|
|
12
|
-
startServer(paths: ServePaths, flags: ServeFlags, commandName: string, generatePortal: (buildDirectory: DirectoryPath, portalDirectory: DirectoryPath, commandName: string, force: boolean, zipPortal: boolean) => Promise<ActionResult>, displayShutdownMessages?: boolean): Promise<Result<boolean, string>>;
|
|
13
|
-
private stopServer;
|
|
14
|
-
private createLiveReloadServer;
|
|
15
|
-
private getPortForReloadServer;
|
|
16
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import express from "express";
|
|
2
|
-
import livereload from "livereload";
|
|
3
|
-
import connectLivereload from "connect-livereload";
|
|
4
|
-
import open from "open";
|
|
5
|
-
import process from "process";
|
|
6
|
-
import getPort from "get-port";
|
|
7
|
-
import console from "console";
|
|
8
|
-
import { Result } from "../../../types/common/result.js";
|
|
9
|
-
import { PortalWatcher } from "./portal-watcher.js";
|
|
10
|
-
export class ServeHandler {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.app = express();
|
|
13
|
-
this.portalWatcher = new PortalWatcher();
|
|
14
|
-
}
|
|
15
|
-
//TODO: Needs to be refactored after refactoring quickstart.
|
|
16
|
-
async setupServer(generatedPortalArtifactsDirectoryPath) {
|
|
17
|
-
const createLiveReloadServerResult = await this.createLiveReloadServer(generatedPortalArtifactsDirectoryPath);
|
|
18
|
-
if (createLiveReloadServerResult.isFailed()) {
|
|
19
|
-
return Result.failure(createLiveReloadServerResult.error);
|
|
20
|
-
}
|
|
21
|
-
this.app.use(express.static(generatedPortalArtifactsDirectoryPath, { extensions: ["html"] }));
|
|
22
|
-
return Result.success(`Server is set up and serving files from ${generatedPortalArtifactsDirectoryPath}`);
|
|
23
|
-
}
|
|
24
|
-
//TODO: Needs to be refactored after refactoring quickstart.
|
|
25
|
-
async startServer(paths, flags, commandName, generatePortal, displayShutdownMessages = true) {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
this.server = this.app
|
|
28
|
-
.listen(flags.port, async () => {
|
|
29
|
-
if (flags.open) {
|
|
30
|
-
await open(`http://localhost:${flags.port}`);
|
|
31
|
-
}
|
|
32
|
-
if (!flags["no-reload"]) {
|
|
33
|
-
await this.portalWatcher.watchAndRegeneratePortalOnChange(paths, commandName, generatePortal);
|
|
34
|
-
}
|
|
35
|
-
if (process.platform !== "darwin") {
|
|
36
|
-
//For non-macOS users.
|
|
37
|
-
if (process.stdin.setRawMode) {
|
|
38
|
-
process.stdin.setRawMode(false);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
resolve(Result.success(true));
|
|
42
|
-
})
|
|
43
|
-
.on("error", () => {
|
|
44
|
-
reject(new Error(`Something went wrong while serving your portal. Please try again later. If the issue persists, contact our team at support@apimatic.io`));
|
|
45
|
-
});
|
|
46
|
-
const shutdown = async () => {
|
|
47
|
-
if (displayShutdownMessages) {
|
|
48
|
-
console.log("Shutting down server...");
|
|
49
|
-
}
|
|
50
|
-
await this.stopServer();
|
|
51
|
-
if (displayShutdownMessages) {
|
|
52
|
-
console.log("Server shut down successfully.");
|
|
53
|
-
}
|
|
54
|
-
resolve(Result.success(true));
|
|
55
|
-
process.exit(0);
|
|
56
|
-
};
|
|
57
|
-
process.on("SIGINT", shutdown);
|
|
58
|
-
process.on("SIGTERM", shutdown);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async stopServer() {
|
|
62
|
-
this.portalWatcher.cancelPendingOperations();
|
|
63
|
-
if (this.liveReloadServer) {
|
|
64
|
-
this.liveReloadServer.close();
|
|
65
|
-
}
|
|
66
|
-
if (this.server) {
|
|
67
|
-
await new Promise((resolve) => {
|
|
68
|
-
this.server.close(() => resolve());
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async createLiveReloadServer(generatedPortalPath) {
|
|
73
|
-
try {
|
|
74
|
-
const availablePort = await this.getPortForReloadServer();
|
|
75
|
-
this.liveReloadServer = livereload.createServer({
|
|
76
|
-
port: availablePort
|
|
77
|
-
});
|
|
78
|
-
this.liveReloadServer.watch(generatedPortalPath);
|
|
79
|
-
this.app.use(connectLivereload());
|
|
80
|
-
return Result.success("Live Reload Server setup successfully.");
|
|
81
|
-
}
|
|
82
|
-
catch (_a) {
|
|
83
|
-
return Result.failure("An unexpected error occurred while serving your portal, please try again later. If the issue persists, contact our team at support@apimatic.io for assistance.");
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async getPortForReloadServer() {
|
|
87
|
-
const defaultPorts = [35729, 35730, 35731];
|
|
88
|
-
return await getPort({ port: defaultPorts });
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=serve-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serve-handler.js","sourceRoot":"","sources":["../../../../src/application/portal/serve/serve-handler.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,OAAO,YAAY;IAMvB;QACE,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC3C,CAAC;IAED,4DAA4D;IACrD,KAAK,CAAC,WAAW,CAAC,qCAA6C;QACpE,MAAM,4BAA4B,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,qCAAqC,CAAC,CAAC;QAC9G,IAAI,4BAA4B,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,KAAM,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,qCAAqC,EAAE,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAE9F,OAAO,MAAM,CAAC,OAAO,CAAC,2CAA2C,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CAAC;QAAC,WAAM,CAAC;YACP,OAAO,MAAM,CAAC,OAAO,CACnB,gKAAgK,CACjK,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB;QAClC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watcher-handler.js","sourceRoot":"","sources":["../../../../src/application/portal/serve/watcher-handler.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAc;IAMzB,YAAY,aAAqB,GAAG;QAL5B,iBAAY,GAAG,KAAK,CAAC;QACrB,kBAAa,GAAiC,IAAI,CAAC;QACnD,kBAAa,GAA0B,IAAI,CAAC;QAIlD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAA4B;QACxC,kCAAkC;QAClC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAE7B,iFAAiF;QACjF,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,2BAA2B;QAC3B,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;QAED,6BAA6B;QAC7B,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE;YACzC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,OAAO;YACT,CAAC;YAED,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAE1B,IAAI,CAAC;gBACH,0CAA0C;gBAC1C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;oBACvB,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;oBAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;oBAC1B,MAAM,cAAc,EAAE,CAAC;gBACzB,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;YAC5B,CAAC;QACH,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED,yCAAyC;IAClC,MAAM;QACX,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PortalService } from "../../../infrastructure/services/portal-service.js";
|
|
2
|
-
import { TocEndpoint, TocModel } from "../../../types/toc/toc.js";
|
|
3
|
-
import { Result } from "../../../types/common/result.js";
|
|
4
|
-
import { SdlEndpoint } from "../../../types/sdl/sdl.js";
|
|
5
|
-
export declare class SdlParser {
|
|
6
|
-
private readonly portalService;
|
|
7
|
-
private readonly zipArchiver;
|
|
8
|
-
private readonly fileService;
|
|
9
|
-
constructor(portalService: PortalService);
|
|
10
|
-
getTocComponentsFromSdl(specFolderPath: string, configDir: string, commandName: string): Promise<Result<{
|
|
11
|
-
endpointGroups: Map<string, TocEndpoint[]>;
|
|
12
|
-
models: TocModel[];
|
|
13
|
-
}, string>>;
|
|
14
|
-
getEndpointGroupsFromSdl(specFolderPath: string, configDir: string, commandName: string): Promise<Result<Map<string, SdlEndpoint[]>, string>>;
|
|
15
|
-
private generateSdlFromSpec;
|
|
16
|
-
private extractEndpointGroupsForRecipe;
|
|
17
|
-
private extractEndpointGroupsForToc;
|
|
18
|
-
private extractModelsForToc;
|
|
19
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Result } from "../../../types/common/result.js";
|
|
2
|
-
import { DirectoryPath } from "../../../types/file/directoryPath.js";
|
|
3
|
-
import { withDirPath } from "../../../infrastructure/tmp-extensions.js";
|
|
4
|
-
import { FileName } from "../../../types/file/fileName.js";
|
|
5
|
-
import { ZipService } from "../../../infrastructure/zip-service.js";
|
|
6
|
-
import { FilePath } from "../../../types/file/filePath.js";
|
|
7
|
-
import { FileService } from "../../../infrastructure/file-service.js";
|
|
8
|
-
export class SdlParser {
|
|
9
|
-
constructor(portalService) {
|
|
10
|
-
this.portalService = portalService;
|
|
11
|
-
this.zipArchiver = new ZipService();
|
|
12
|
-
this.fileService = new FileService();
|
|
13
|
-
}
|
|
14
|
-
async getTocComponentsFromSdl(specFolderPath, configDir, commandName) {
|
|
15
|
-
const sdlResult = await this.generateSdlFromSpec(specFolderPath, configDir, commandName);
|
|
16
|
-
if (!sdlResult.isSuccess()) {
|
|
17
|
-
return Result.failure("Failed to extract endpoints/models from the specification. Please validate your spec using APIMatic's interactive VS Code Extension and then try again.");
|
|
18
|
-
}
|
|
19
|
-
const sdl = sdlResult.value;
|
|
20
|
-
const endpointGroups = this.extractEndpointGroupsForToc(sdl);
|
|
21
|
-
const models = this.extractModelsForToc(sdl);
|
|
22
|
-
return Result.success({ endpointGroups, models });
|
|
23
|
-
}
|
|
24
|
-
async getEndpointGroupsFromSdl(specFolderPath, configDir, commandName) {
|
|
25
|
-
const sdlResult = await this.generateSdlFromSpec(specFolderPath, configDir, commandName);
|
|
26
|
-
if (!sdlResult.isSuccess()) {
|
|
27
|
-
return Result.failure("Failed to extract endpoints from the API specification. Please validate your spec using APIMatic's interactive VS Code Extension and then try again.");
|
|
28
|
-
}
|
|
29
|
-
const sdl = sdlResult.value;
|
|
30
|
-
const endpointGroups = this.extractEndpointGroupsForRecipe(sdl);
|
|
31
|
-
return Result.success(endpointGroups);
|
|
32
|
-
}
|
|
33
|
-
async generateSdlFromSpec(specFolderPath, configDir, commandName) {
|
|
34
|
-
return await withDirPath(async (tempDirectory) => {
|
|
35
|
-
const specZipPath = new FilePath(tempDirectory, new FileName("spec.zip"));
|
|
36
|
-
await this.zipArchiver.archive(new DirectoryPath(specFolderPath), specZipPath);
|
|
37
|
-
const specFileStream = await this.fileService.getStream(specZipPath);
|
|
38
|
-
let result;
|
|
39
|
-
try {
|
|
40
|
-
result = await this.portalService.generateSdl(specFileStream, configDir, commandName);
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
specFileStream.close();
|
|
44
|
-
}
|
|
45
|
-
if (!result.isSuccess()) {
|
|
46
|
-
return Result.failure("Failed to generate SDL from the API specification. Please validate your spec using APIMatic's interactive VS Code Extension.");
|
|
47
|
-
}
|
|
48
|
-
return Result.success(result.value);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
extractEndpointGroupsForRecipe(sdl) {
|
|
52
|
-
const endpointGroups = new Map();
|
|
53
|
-
for (const endpoint of sdl.Endpoints) {
|
|
54
|
-
if (!endpointGroups.has(endpoint.Group)) {
|
|
55
|
-
endpointGroups.set(endpoint.Group, []);
|
|
56
|
-
}
|
|
57
|
-
endpointGroups.get(endpoint.Group).push({
|
|
58
|
-
Name: endpoint.Name,
|
|
59
|
-
Description: endpoint.Description,
|
|
60
|
-
Group: endpoint.Group
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return endpointGroups;
|
|
64
|
-
}
|
|
65
|
-
extractEndpointGroupsForToc(sdl) {
|
|
66
|
-
const endpointGroups = new Map();
|
|
67
|
-
const endpoints = sdl.Endpoints.map((e) => ({
|
|
68
|
-
generate: null,
|
|
69
|
-
from: "endpoint",
|
|
70
|
-
endpointName: e.Name,
|
|
71
|
-
endpointGroup: e.Group
|
|
72
|
-
}));
|
|
73
|
-
endpoints.forEach((endpoint) => {
|
|
74
|
-
const group = endpoint.endpointGroup;
|
|
75
|
-
if (!endpointGroups.has(group)) {
|
|
76
|
-
endpointGroups.set(group, []);
|
|
77
|
-
}
|
|
78
|
-
endpointGroups.get(group).push(endpoint);
|
|
79
|
-
});
|
|
80
|
-
return endpointGroups;
|
|
81
|
-
}
|
|
82
|
-
extractModelsForToc(sdl) {
|
|
83
|
-
return sdl.CustomTypes.map((e) => ({
|
|
84
|
-
generate: null,
|
|
85
|
-
from: "model",
|
|
86
|
-
modelName: e.Name
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=sdl-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdl-parser.js","sourceRoot":"","sources":["../../../../src/application/portal/toc/sdl-parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAEtE,MAAM,OAAO,SAAS;IAIpB,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAHxC,gBAAW,GAAe,IAAI,UAAU,EAAE,CAAC;QAC3C,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IAEW,CAAC;IAEtD,KAAK,CAAC,uBAAuB,CAClC,cAAsB,EACtB,SAAiB,EACjB,WAAmB;QAEnB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QAEzF,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;YAC3B,OAAO,M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,EAAE,CAAC,CAAC,IAAI;YACpB,aAAa,EAAE,CAAC,CAAC,KAAK;SACvB,CAAC,CACH,CAAC;QAEF,SAAS,CAAC,OAAO,CAAC,CAAC,QAAqB,EAAE,EAAE;YAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC;YACrC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAChC,CAAC;YACD,cAAc,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC;IACxB,CAAC;IAEO,mBAAmB,CAAC,GAAQ;QAClC,OAAO,GAAG,CAAC,WAAW,CAAC,GAAG,CACxB,CAAC,CAAW,EAAY,EAAE,CAAC,CAAC;YAC1B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,SAAS,EAAE,CAAC,CAAC,IAAI;SAClB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Client } from "@apimatic/sdk";
|
|
2
|
-
/**
|
|
3
|
-
* The Singleton class defines the `getInstance` method that lets clients access
|
|
4
|
-
* the unique singleton instance.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SDKClient {
|
|
7
|
-
static client: Client;
|
|
8
|
-
private static instance;
|
|
9
|
-
/**
|
|
10
|
-
* The static method that controls the access to the SDKClient instance.
|
|
11
|
-
*
|
|
12
|
-
* This implementation let you subclass the SDKClient class while keeping
|
|
13
|
-
* just one instance of each subclass around.
|
|
14
|
-
*/
|
|
15
|
-
static getInstance(): SDKClient;
|
|
16
|
-
logout(configDir: string): Promise<string>;
|
|
17
|
-
status(configDir: string): Promise<string>;
|
|
18
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { getAuthInfo, removeAuthInfo } from "./auth-manager.js";
|
|
2
|
-
/**
|
|
3
|
-
* The Singleton class defines the `getInstance` method that lets clients access
|
|
4
|
-
* the unique singleton instance.
|
|
5
|
-
*/
|
|
6
|
-
export class SDKClient {
|
|
7
|
-
/**
|
|
8
|
-
* The static method that controls the access to the SDKClient instance.
|
|
9
|
-
*
|
|
10
|
-
* This implementation let you subclass the SDKClient class while keeping
|
|
11
|
-
* just one instance of each subclass around.
|
|
12
|
-
*/
|
|
13
|
-
static getInstance() {
|
|
14
|
-
if (!SDKClient.instance) {
|
|
15
|
-
SDKClient.instance = new SDKClient();
|
|
16
|
-
}
|
|
17
|
-
return SDKClient.instance;
|
|
18
|
-
}
|
|
19
|
-
async logout(configDir) {
|
|
20
|
-
await removeAuthInfo(configDir);
|
|
21
|
-
return "Logged out";
|
|
22
|
-
}
|
|
23
|
-
async status(configDir) {
|
|
24
|
-
try {
|
|
25
|
-
let storedAuthInfo = await getAuthInfo(configDir);
|
|
26
|
-
if (!storedAuthInfo) {
|
|
27
|
-
// If no config file or no credentials exist in the config file
|
|
28
|
-
storedAuthInfo = { email: "", authKey: "" };
|
|
29
|
-
}
|
|
30
|
-
return storedAuthInfo.email === "" && storedAuthInfo.authKey === ""
|
|
31
|
-
? "Not logged in"
|
|
32
|
-
: storedAuthInfo.email === "" && storedAuthInfo.authKey !== ""
|
|
33
|
-
? "Logged in with authentication key"
|
|
34
|
-
: `Currently logged in as ${storedAuthInfo.email}`;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=sdk-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-client.js","sourceRoot":"","sources":["../../src/client-utils/sdk-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1E;;;GAGG;AACH,MAAM,OAAO,SAAS;IAIpB;;;;;OAKG;IACI,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACxB,SAAS,CAAC,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACvC,CAAC;QAED,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAiB;QACnC,MAAM,cAAc,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAiB;QACnC,IAAI,CAAC;YACH,IAAI,cAAc,GAAoB,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;YAEnE,IAAI,CAAC,cAAc,EAAE,CAAC;gBACpB,+DAA+D;gBAC/D,cAAc,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YAC9C,CAAC;YAED,OAAO,cAAc,CAAC,KAAK,KAAK,EAAE,IAAI,cAAc,CAAC,OAAO,KAAK,EAAE;gBACjE,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,cAAc,CAAC,KAAK,KAAK,EAAE,IAAI,cAAc,CAAC,OAAO,KAAK,EAAE;oBAC9D,CAAC,CAAC,mCAAmC;oBACrC,CAAC,CAAC,0BAA0B,cAAc,CAAC,KAAK,EAAE,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAc,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
package/lib/config/env.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare const baseURL = "https://api.apimatic.io";
|
|
2
|
-
export declare const metadataFileContent: {
|
|
3
|
-
ImportSettings: {
|
|
4
|
-
AutoGenerateTestCases: boolean;
|
|
5
|
-
ImportAdditionalHeader: boolean;
|
|
6
|
-
ImportAdditionalTypeCombinatorModels: boolean;
|
|
7
|
-
ImportTypeCombinatorsWithOnlyOneType: boolean;
|
|
8
|
-
};
|
|
9
|
-
CodeGenSettings: {
|
|
10
|
-
Timeout: number;
|
|
11
|
-
ValidateRequiredParameters: boolean;
|
|
12
|
-
AddSingleAuthDeprecatedCode: boolean;
|
|
13
|
-
EnableGlobalUserAgent: boolean;
|
|
14
|
-
UserAgent: string;
|
|
15
|
-
EnableLogging: boolean;
|
|
16
|
-
EnableModelKeywordArgsInRuby: boolean;
|
|
17
|
-
SymbolizeHashKeysInRuby: boolean;
|
|
18
|
-
ReturnCompleteHttpResponse: boolean;
|
|
19
|
-
UserConfigurableRetries: boolean;
|
|
20
|
-
UseEnumPrefix: boolean;
|
|
21
|
-
ExtendedAdditionalPropertiesSupport: boolean;
|
|
22
|
-
EnforceStandardizedCasing: boolean;
|
|
23
|
-
ControllerPostfix: string;
|
|
24
|
-
DoNotSplitWords: string[];
|
|
25
|
-
};
|
|
26
|
-
};
|