@celonis/content-cli 0.13.5 → 1.0.0
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 +13 -6
- package/{api → commands/action-flows/action-flow}/action-flow-api.js +10 -9
- package/commands/{action-flow.command.js → action-flows/action-flow/action-flow-command.service.js} +11 -8
- package/{services/action-flow/action-flow-service.js → commands/action-flows/action-flow/action-flow.service.js} +12 -10
- package/commands/action-flows/module.js +88 -0
- package/commands/{skill.command.js → action-flows/skill/skill-command.service.js} +9 -11
- package/{content/factory/skill-manager.factory.js → commands/action-flows/skill/skill.manager-factory.js} +7 -4
- package/{content/manager → commands/action-flows/skill}/skill.manager.js +7 -4
- package/commands/analysis/analysis-bookmarks-command.service.js +39 -0
- package/{content/factory/analysis-bookmarks-manager.factory.js → commands/analysis/analysis-bookmarks.manager-factory.js} +7 -4
- package/{content/manager → commands/analysis}/analysis-bookmarks.manager.js +8 -5
- package/commands/analysis/module.js +52 -0
- package/commands/configuration-management/api/batch-import-export-api.js +84 -0
- package/{api → commands/configuration-management/api}/diff-api.js +8 -7
- package/commands/configuration-management/api/variable-assignment-candidates-api.js +41 -0
- package/{services/package-manager/batch-import-export-service.js → commands/configuration-management/batch-import-export.service.js} +31 -26
- package/commands/{config.command.js → configuration-management/config-command.service.js} +21 -16
- package/{services/package-manager/diff-service.js → commands/configuration-management/diff.service.js} +11 -8
- package/commands/configuration-management/module.js +102 -0
- package/{services/studio → commands/configuration-management}/studio.service.js +33 -24
- package/commands/{variable.command.js → configuration-management/variable-command.service.js} +10 -7
- package/{services/package-manager/variable-service.js → commands/configuration-management/variable.service.js} +36 -42
- package/commands/{ctp.command.js → cpm4/ctp-command.service.js} +11 -13
- package/{content/manager → commands/cpm4}/ctp.analysis.manager.js +3 -0
- package/{content/manager → commands/cpm4}/ctp.datamodel.manager.js +2 -2
- package/{content/factory/ctp-manager.factory.js → commands/cpm4/ctp.manager-factory.js} +9 -6
- package/{content/manager → commands/cpm4}/ctp.manager.js +6 -4
- package/commands/cpm4/module.js +46 -0
- package/commands/{connection.command.js → data-pipeline/connection/connection-command.service.js} +14 -11
- package/commands/data-pipeline/connection/connection.commands.js +65 -0
- package/{services → commands/data-pipeline}/connection/connection.service.js +18 -15
- package/{api → commands/data-pipeline/data-pool}/data-pool-api.js +14 -13
- package/commands/{data-pool.command.js → data-pipeline/data-pool/data-pool-command.service.js} +25 -23
- package/{content/factory → commands/data-pipeline/data-pool}/data-pool-manager.factory.js +9 -6
- package/{services → commands/data-pipeline}/data-pool/data-pool-service.js +13 -10
- package/commands/data-pipeline/data-pool/data-pool.commands.js +99 -0
- package/{content/manager → commands/data-pipeline/data-pool}/data-pool.manager.js +8 -9
- package/commands/data-pipeline/module.js +24 -0
- package/commands/profile/module.js +60 -0
- package/commands/profile/profile-command.service.js +94 -0
- package/{api → commands/studio/api}/asset-api.js +8 -7
- package/{api → commands/studio/api}/compute-pool-api.js +7 -6
- package/{api → commands/studio/api}/node-api.js +9 -8
- package/{api → commands/studio/api}/package-api.js +18 -17
- package/{api → commands/studio/api}/package-dependencies-api.js +12 -11
- package/{api → commands/studio/api}/space-api.js +10 -9
- package/commands/{analysis-bookmarks.command.js → studio/api/studio-variables-api.js} +18 -13
- package/commands/{asset.command.js → studio/command-service/asset-command.service.js} +21 -19
- package/commands/{package.command.js → studio/command-service/package-command.service.js} +22 -20
- package/commands/{space.command.js → studio/command-service/space-command.service.js} +9 -11
- package/commands/studio/command-service/widget.command.js +56 -0
- package/{content/factory/asset-manager.factory.js → commands/studio/manager/asset.manager-factory.js} +7 -4
- package/{content → commands/studio}/manager/asset.manager.js +8 -5
- package/{content/factory/package-manager.factory.js → commands/studio/manager/package.manager-factory.js} +7 -4
- package/{content → commands/studio}/manager/package.manager.js +9 -6
- package/{content/factory/space-manager.factory.js → commands/studio/manager/space.manager-factory.js} +6 -3
- package/{content → commands/studio}/manager/space.manager.js +7 -4
- package/{content/factory/widget-manager.factory.js → commands/studio/manager/widget.manager-factory.js} +8 -5
- package/{content → commands/studio}/manager/widget.manager.js +5 -5
- package/commands/studio/module.js +169 -0
- package/{services/package-manager → commands/studio/service}/asset-service.js +10 -9
- package/{services/package-manager/datamodel-service.js → commands/studio/service/data-model.service.js} +8 -6
- package/{services/package-manager/package-service.js → commands/studio/service/package.service.js} +59 -49
- package/{services/package-manager/space-service.js → commands/studio/service/space.service.js} +9 -9
- package/commands/studio/service/studio-variable.service.js +41 -0
- package/content-cli.js +69 -20
- package/core/command/cli-context.js +69 -0
- package/core/command/module-handler.js +200 -0
- package/core/http/base-api.js +115 -0
- package/{services/http-client-service.v2.js → core/http/http-client.js} +39 -24
- package/{services/context.service.js → core/http/http-shared/base.manager.helper.js} +6 -16
- package/{content/manager → core/http/http-shared}/base.manager.js +14 -21
- package/{services → core/profile}/profile.service.js +11 -5
- package/{validators → core/profile}/profile.validator.js +3 -3
- package/{services → core/utils}/file-service.js +2 -7
- package/core/utils/logger.js +102 -0
- package/{services → core/utils}/question.service.js +18 -7
- package/{util → core/utils}/version.js +1 -1
- package/lib/{api → commands/action-flows/action-flow}/action-flow-api.d.ts +4 -4
- package/lib/commands/{action-flow.command.d.ts → action-flows/action-flow/action-flow-command.service.d.ts} +4 -1
- package/lib/{services/action-flow/action-flow-service.d.ts → commands/action-flows/action-flow/action-flow.service.d.ts} +4 -4
- package/lib/commands/action-flows/module.d.ts +14 -0
- package/lib/commands/{skill.command.d.ts → action-flows/skill/skill-command.service.d.ts} +3 -2
- package/lib/commands/action-flows/skill/skill.manager-factory.d.ts +8 -0
- package/lib/{content/manager → commands/action-flows/skill}/skill.manager.d.ts +4 -2
- package/lib/commands/analysis/analysis-bookmarks-command.service.d.ts +7 -0
- package/lib/commands/analysis/analysis-bookmarks.manager-factory.d.ts +8 -0
- package/lib/{content/manager → commands/analysis}/analysis-bookmarks.manager.d.ts +4 -2
- package/lib/commands/analysis/module.d.ts +11 -0
- package/lib/{api → commands/configuration-management/api}/batch-import-export-api.d.ts +5 -5
- package/lib/{api → commands/configuration-management/api}/diff-api.d.ts +5 -5
- package/lib/commands/configuration-management/api/variable-assignment-candidates-api.d.ts +8 -0
- package/lib/{services/package-manager/batch-import-export-service.d.ts → commands/configuration-management/batch-import-export.service.d.ts} +6 -3
- package/lib/commands/{config.command.d.ts → configuration-management/config-command.service.d.ts} +6 -1
- package/lib/{services/package-manager/diff-service.d.ts → commands/configuration-management/diff.service.d.ts} +4 -3
- package/lib/{interfaces/package-export-transport.d.ts → commands/configuration-management/interfaces/package-export.interfaces.d.ts} +2 -2
- package/lib/{api/variable-assignment-apis.d.ts → commands/configuration-management/interfaces/variable-assignment-apis.constants.d.ts} +3 -1
- package/lib/commands/configuration-management/module.d.ts +15 -0
- package/lib/{services/studio → commands/configuration-management}/studio.service.d.ts +12 -5
- package/lib/commands/configuration-management/variable-command.service.d.ts +6 -0
- package/lib/{services/package-manager/variable-service.d.ts → commands/configuration-management/variable.service.d.ts} +8 -8
- package/lib/commands/cpm4/ctp-command.service.d.ts +7 -0
- package/lib/{content/manager → commands/cpm4}/ctp.analysis.manager.d.ts +2 -0
- package/lib/{content/manager → commands/cpm4}/ctp.datamodel.manager.d.ts +2 -1
- package/lib/{content/factory/ctp-manager.factory.d.ts → commands/cpm4/ctp.manager-factory.d.ts} +4 -1
- package/lib/{content/manager → commands/cpm4}/ctp.manager.d.ts +4 -2
- package/lib/commands/cpm4/module.d.ts +10 -0
- package/lib/commands/data-pipeline/connection/connection-command.service.d.ts +8 -0
- package/lib/commands/data-pipeline/connection/connection.commands.d.ts +11 -0
- package/lib/{services → commands/data-pipeline}/connection/connection.service.d.ts +4 -3
- package/lib/{api → commands/data-pipeline/data-pool}/data-pool-api.d.ts +5 -5
- package/lib/commands/data-pipeline/data-pool/data-pool-command.service.d.ts +14 -0
- package/lib/commands/data-pipeline/data-pool/data-pool-manager.factory.d.ts +9 -0
- package/lib/{services → commands/data-pipeline}/data-pool/data-pool-service.d.ts +4 -3
- package/lib/commands/data-pipeline/data-pool/data-pool.commands.d.ts +15 -0
- package/lib/{content/manager → commands/data-pipeline/data-pool}/data-pool.manager.d.ts +4 -2
- package/lib/commands/data-pipeline/module.d.ts +9 -0
- package/lib/commands/profile/module.d.ts +12 -0
- package/lib/commands/{profile.command.d.ts → profile/profile-command.service.d.ts} +1 -1
- package/lib/{api → commands/studio/api}/asset-api.d.ts +4 -4
- package/lib/{api → commands/studio/api}/compute-pool-api.d.ts +4 -4
- package/lib/{api → commands/studio/api}/node-api.d.ts +4 -4
- package/lib/{api → commands/studio/api}/package-api.d.ts +4 -4
- package/lib/{api → commands/studio/api}/package-dependencies-api.d.ts +4 -4
- package/lib/commands/studio/api/space-api.d.ts +9 -0
- package/lib/commands/studio/api/studio-variables-api.d.ts +8 -0
- package/lib/commands/studio/command-service/asset-command.service.d.ts +11 -0
- package/lib/commands/{package.command.d.ts → studio/command-service/package-command.service.d.ts} +8 -5
- package/lib/commands/studio/command-service/space-command.service.d.ts +6 -0
- package/lib/commands/studio/command-service/widget.command.d.ts +7 -0
- package/lib/{interfaces/batch-export-node-transport.d.ts → commands/studio/interfaces/batch-export-node.interfaces.d.ts} +1 -9
- package/lib/{content/factory/asset-manager.factory.d.ts → commands/studio/manager/asset.manager-factory.d.ts} +4 -1
- package/lib/{content → commands/studio}/manager/asset.manager.d.ts +4 -2
- package/lib/{content/factory/package-manager.factory.d.ts → commands/studio/manager/package.manager-factory.d.ts} +4 -1
- package/lib/{content → commands/studio}/manager/package.manager.d.ts +4 -2
- package/lib/commands/studio/manager/space.manager-factory.d.ts +8 -0
- package/lib/{content → commands/studio}/manager/space.manager.d.ts +4 -2
- package/lib/{content/factory/widget-manager.factory.d.ts → commands/studio/manager/widget.manager-factory.d.ts} +10 -7
- package/lib/{content → commands/studio}/manager/widget.manager.d.ts +4 -2
- package/lib/commands/studio/module.d.ts +21 -0
- package/lib/{services/package-manager → commands/studio/service}/asset-service.d.ts +4 -3
- package/lib/{services/package-manager/datamodel-service.d.ts → commands/studio/service/data-model.service.d.ts} +5 -5
- package/lib/{services/package-manager/package-service.d.ts → commands/studio/service/package.service.d.ts} +13 -6
- package/lib/commands/studio/service/space.service.d.ts +11 -0
- package/lib/commands/studio/service/studio-variable.service.d.ts +9 -0
- package/lib/core/command/cli-context.d.ts +17 -0
- package/lib/core/command/module-handler.d.ts +57 -0
- package/lib/core/http/base-api.d.ts +32 -0
- package/lib/{services/http-client-service.v2.d.ts → core/http/http-client.d.ts} +8 -3
- package/lib/{content/manager → core/http/http-shared}/base.manager.d.ts +4 -6
- package/lib/core/http/http-shared/base.manager.helper.d.ts +4 -0
- package/lib/{services → core/profile}/profile.service.d.ts +2 -1
- package/lib/{validators → core/profile}/profile.validator.d.ts +1 -1
- package/lib/{services → core/utils}/file-service.d.ts +0 -2
- package/lib/core/utils/question.service.d.ts +10 -0
- package/package.json +3 -3
- package/api/batch-import-export-api.js +0 -62
- package/api/variables-api.js +0 -56
- package/commands/profile.command.js +0 -88
- package/commands/widget.command.js +0 -36
- package/content-cli-analyze.js +0 -56
- package/content-cli-config.js +0 -119
- package/content-cli-export.js +0 -90
- package/content-cli-get.js +0 -52
- package/content-cli-import.js +0 -93
- package/content-cli-list.js +0 -129
- package/content-cli-profile.js +0 -64
- package/content-cli-pull.js +0 -104
- package/content-cli-push.js +0 -196
- package/content-cli-set.js +0 -55
- package/content-cli-update.js +0 -44
- package/interfaces/variable-assignment-api.interface.js +0 -12
- package/lib/api/space-api.d.ts +0 -9
- package/lib/api/variables-api.d.ts +0 -14
- package/lib/commands/analysis-bookmarks.command.d.ts +0 -6
- package/lib/commands/asset.command.d.ts +0 -8
- package/lib/commands/connection.command.d.ts +0 -5
- package/lib/commands/ctp.command.d.ts +0 -6
- package/lib/commands/data-pool.command.d.ts +0 -11
- package/lib/commands/space.command.d.ts +0 -5
- package/lib/commands/variable.command.d.ts +0 -3
- package/lib/commands/widget.command.d.ts +0 -5
- package/lib/content/factory/analysis-bookmarks-manager.factory.d.ts +0 -5
- package/lib/content/factory/data-pool-manager.factory.d.ts +0 -6
- package/lib/content/factory/skill-manager.factory.d.ts +0 -5
- package/lib/content/factory/space-manager.factory.d.ts +0 -5
- package/lib/content-cli-analyze.d.ts +0 -1
- package/lib/content-cli-config.d.ts +0 -8
- package/lib/content-cli-export.d.ts +0 -6
- package/lib/content-cli-get.d.ts +0 -1
- package/lib/content-cli-import.d.ts +0 -6
- package/lib/content-cli-list.d.ts +0 -9
- package/lib/content-cli-profile.d.ts +0 -1
- package/lib/content-cli-pull.d.ts +0 -1
- package/lib/content-cli-push.d.ts +0 -1
- package/lib/content-cli-set.d.ts +0 -1
- package/lib/content-cli-update.d.ts +0 -1
- package/lib/interfaces/variable-assignment-api.interface.d.ts +0 -3
- package/lib/services/command.service.d.ts +0 -6
- package/lib/services/content.service.d.ts +0 -11
- package/lib/services/context.service.d.ts +0 -13
- package/lib/services/http-client.service.d.ts +0 -15
- package/lib/services/package-manager/space-service.d.ts +0 -11
- package/lib/services/question.service.d.ts +0 -4
- package/lib/util/context-initializer.d.ts +0 -3
- package/lib/util/program.d.ts +0 -2
- package/services/command.service.js +0 -24
- package/services/content.service.js +0 -130
- package/services/http-client.service.js +0 -157
- package/util/context-initializer.js +0 -39
- package/util/logger.js +0 -49
- package/util/program.js +0 -16
- /package/{interfaces/batch-export-import-constants.js → commands/configuration-management/interfaces/batch-export-import.constants.js} +0 -0
- /package/{interfaces/diff-package.transport.js → commands/configuration-management/interfaces/diff-package.interfaces.js} +0 -0
- /package/{interfaces/batch-export-node-transport.js → commands/configuration-management/interfaces/package-export.interfaces.js} +0 -0
- /package/{api/variable-assignment-apis.js → commands/configuration-management/interfaces/variable-assignment-apis.constants.js} +0 -0
- /package/{interfaces → commands/data-pipeline/data-pool}/data-pool-manager.interfaces.js +0 -0
- /package/{interfaces/manager-config.interface.js → commands/studio/interfaces/batch-export-node.interfaces.js} +0 -0
- /package/{interfaces/manifest-transport.js → commands/studio/interfaces/manifest.interface.js} +0 -0
- /package/{interfaces → commands/studio/interfaces}/package-manager.interfaces.js +0 -0
- /package/{interfaces → commands/studio/interfaces}/save-content-node.interface.js +0 -0
- /package/{interfaces/package-export-transport.js → commands/studio/interfaces/space.interface.js} +0 -0
- /package/{util → commands/studio/utils}/semantic-versioning.js +0 -0
- /package/{util → core/http}/axios-initializer.js +0 -0
- /package/{interfaces/save-space.interface.js → core/http/http-shared/manager-config.interface.js} +0 -0
- /package/{util → core/http}/tracing.js +0 -0
- /package/{interfaces → core/profile}/profile.interface.js +0 -0
- /package/{util → core/utils}/json.js +0 -0
- /package/{util → core/utils}/yaml.js +0 -0
- /package/lib/{interfaces/batch-export-import-constants.d.ts → commands/configuration-management/interfaces/batch-export-import.constants.d.ts} +0 -0
- /package/lib/{interfaces/diff-package.transport.d.ts → commands/configuration-management/interfaces/diff-package.interfaces.d.ts} +0 -0
- /package/lib/{interfaces → commands/data-pipeline/data-pool}/data-pool-manager.interfaces.d.ts +0 -0
- /package/lib/{interfaces/manifest-transport.d.ts → commands/studio/interfaces/manifest.interface.d.ts} +0 -0
- /package/lib/{interfaces → commands/studio/interfaces}/package-manager.interfaces.d.ts +0 -0
- /package/lib/{interfaces → commands/studio/interfaces}/save-content-node.interface.d.ts +0 -0
- /package/lib/{interfaces/save-space.interface.d.ts → commands/studio/interfaces/space.interface.d.ts} +0 -0
- /package/lib/{util → commands/studio/utils}/semantic-versioning.d.ts +0 -0
- /package/lib/{util → core/http}/axios-initializer.d.ts +0 -0
- /package/lib/{interfaces → core/http/http-shared}/manager-config.interface.d.ts +0 -0
- /package/lib/{util → core/http}/tracing.d.ts +0 -0
- /package/lib/{interfaces → core/profile}/profile.interface.d.ts +0 -0
- /package/lib/{util → core/utils}/json.d.ts +0 -0
- /package/lib/{util → core/utils}/logger.d.ts +0 -0
- /package/lib/{util → core/utils}/version.d.ts +0 -0
- /package/lib/{util → core/utils}/yaml.d.ts +0 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
(function (factory) {
|
|
11
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
12
|
+
var v = factory(require, exports);
|
|
13
|
+
if (v !== undefined) module.exports = v;
|
|
14
|
+
}
|
|
15
|
+
else if (typeof define === "function" && define.amd) {
|
|
16
|
+
define(["require", "exports", "path", "fs", "../utils/logger"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.CommandConfig = exports.Configurator = exports.ModuleHandler = exports.IModule = void 0;
|
|
22
|
+
const path = require("path");
|
|
23
|
+
const fs = require("fs");
|
|
24
|
+
const logger_1 = require("../utils/logger");
|
|
25
|
+
class IModule {
|
|
26
|
+
}
|
|
27
|
+
exports.IModule = IModule;
|
|
28
|
+
class ModuleHandler {
|
|
29
|
+
constructor(program, context) {
|
|
30
|
+
this.program = program;
|
|
31
|
+
this.context = context;
|
|
32
|
+
// Store registered module instances if needed later
|
|
33
|
+
this.registeredModules = [];
|
|
34
|
+
this.configurator = new Configurator(this.program, this.context);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Discovers modules in the specified directory, imports them,
|
|
38
|
+
* instantiates the default exported class, and calls its register method.
|
|
39
|
+
*
|
|
40
|
+
* @param {any} rootPath - __dirname when invoked from the main entry file
|
|
41
|
+
* @param devMode - Use uncompiled modules for development debug mode
|
|
42
|
+
*/
|
|
43
|
+
discoverAndRegisterModules(rootPath, devMode = false) {
|
|
44
|
+
const modulesDirPath = path.resolve(rootPath, "commands");
|
|
45
|
+
try {
|
|
46
|
+
const moduleFolders = fs.readdirSync(modulesDirPath, { withFileTypes: true });
|
|
47
|
+
for (const dirent of moduleFolders) {
|
|
48
|
+
if (dirent.isDirectory()) {
|
|
49
|
+
const moduleFolderName = dirent.name;
|
|
50
|
+
const moduleFileName = devMode ? "module.ts" : "module.js";
|
|
51
|
+
// Calculate path relative to *this file's location in dist*
|
|
52
|
+
let potentialModuleJsPath;
|
|
53
|
+
potentialModuleJsPath = path.resolve(rootPath, "commands", moduleFolderName, moduleFileName // Look for the compiled JS file
|
|
54
|
+
);
|
|
55
|
+
try {
|
|
56
|
+
fs.accessSync(potentialModuleJsPath);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
// apparently the file does not exist of is not accessible
|
|
60
|
+
potentialModuleJsPath = null;
|
|
61
|
+
}
|
|
62
|
+
if (!potentialModuleJsPath) {
|
|
63
|
+
logger_1.logger.debug(`Module folder ${moduleFolderName} does not contain a valid entry point and is skipped.`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Check if the compiled JS file exists
|
|
67
|
+
try {
|
|
68
|
+
logger_1.logger.debug(`Found potential module definition: ${potentialModuleJsPath}`);
|
|
69
|
+
// Dynamically require the module
|
|
70
|
+
const requiredModule = require(potentialModuleJsPath);
|
|
71
|
+
// With 'export =' or 'module.exports =', the required value *is* the class
|
|
72
|
+
const ModuleClass = requiredModule; // Cast for TS check
|
|
73
|
+
// Basic check: Is it a class (function)?
|
|
74
|
+
if (typeof ModuleClass === "function" && ModuleClass.prototype) {
|
|
75
|
+
const moduleInstance = new ModuleClass(); // Instantiate
|
|
76
|
+
// Check if the instance has the register method
|
|
77
|
+
if (typeof moduleInstance.register === "function") {
|
|
78
|
+
logger_1.logger.debug(`Registering module: ${moduleFolderName}`);
|
|
79
|
+
// Call register - can still be async even if require() is sync
|
|
80
|
+
moduleInstance.register(this.context, this.configurator);
|
|
81
|
+
this.registeredModules.push(moduleInstance);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
logger_1.logger.warn(`Module ${moduleFolderName} export does not have a 'register' method.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
logger_1.logger.warn(`Module ${moduleFolderName} export is not a class/constructor function.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error.code === "ENOENT") {
|
|
93
|
+
// Compiled module.js not found, maybe folder doesn't contain a valid module
|
|
94
|
+
logger_1.logger.warn(`Directory ${moduleFolderName} does not contain a compiled module.js file.`);
|
|
95
|
+
}
|
|
96
|
+
else if (error.code === "MODULE_NOT_FOUND") {
|
|
97
|
+
logger_1.logger.debug("Error details", error);
|
|
98
|
+
logger_1.logger.warn(`Could not require module ${moduleFolderName}. Check dependencies or compilation. Path: ${potentialModuleJsPath}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
logger_1.logger.error(`Error processing module in ${moduleFolderName}:`, error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error.code === "ENOENT") {
|
|
110
|
+
logger_1.logger.error(`Modules directory not found relative to JS output: ${path.resolve(path.dirname(__filename), "commands")}`);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
logger_1.logger.error("Failed to read modules directory:", error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
logger_1.logger.debug(`Module discovery complete. ${this.registeredModules.length} modules registered.`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.ModuleHandler = ModuleHandler;
|
|
120
|
+
/**
|
|
121
|
+
* Allows the creation of root level commands.
|
|
122
|
+
*/
|
|
123
|
+
class Configurator {
|
|
124
|
+
constructor(program, ctx) {
|
|
125
|
+
this.program = program;
|
|
126
|
+
this.ctx = ctx;
|
|
127
|
+
this.rootCommandMap = new Map();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get or create a root level command.
|
|
131
|
+
* @param name
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
command(name) {
|
|
135
|
+
if (this.rootCommandMap.has(name)) {
|
|
136
|
+
return this.rootCommandMap.get(name);
|
|
137
|
+
}
|
|
138
|
+
const cmd = this.program.command(name);
|
|
139
|
+
const cmdConfig = new CommandConfig(cmd, this.ctx);
|
|
140
|
+
this.rootCommandMap.set(name, cmdConfig);
|
|
141
|
+
return cmdConfig;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.Configurator = Configurator;
|
|
145
|
+
/**
|
|
146
|
+
* Delegate wrapper around the Command object, to simply change the way the program is
|
|
147
|
+
* executed.
|
|
148
|
+
*/
|
|
149
|
+
class CommandConfig {
|
|
150
|
+
constructor(cmd, ctx) {
|
|
151
|
+
this.cmd = cmd;
|
|
152
|
+
this.ctx = ctx;
|
|
153
|
+
}
|
|
154
|
+
command(nameAndArgs, opts) {
|
|
155
|
+
return new CommandConfig(this.cmd.command(nameAndArgs, opts), this.ctx)
|
|
156
|
+
.option("-p, --profile <profile>", "Profile which you want to use");
|
|
157
|
+
}
|
|
158
|
+
alias(alias) {
|
|
159
|
+
this.cmd.alias(alias);
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
description(description) {
|
|
163
|
+
this.cmd.description(description);
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
argument(name, description, defaultValue) {
|
|
167
|
+
this.cmd.argument(name, description, defaultValue);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
option(flags, description, defaultValue) {
|
|
171
|
+
this.cmd.option(flags, description, defaultValue);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
requiredOption(flags, description, defaultValue) {
|
|
175
|
+
this.cmd.requiredOption(flags, description, defaultValue);
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
deprecationNotice(deprecationMessage) {
|
|
179
|
+
this.deprecationMessage = deprecationMessage;
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
action(handler) {
|
|
183
|
+
this.cmd.action(() => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
try {
|
|
185
|
+
this.printDeprecationNoticeIfDeprecated();
|
|
186
|
+
yield handler(this.ctx, this.cmd, this.cmd.opts());
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
logger_1.logger.error(`An unexpected error occured executing a command: ${error}`);
|
|
190
|
+
}
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
printDeprecationNoticeIfDeprecated() {
|
|
194
|
+
if (this.deprecationMessage) {
|
|
195
|
+
logger_1.logger.warn("⚠️ [DEPRECATION NOTICE] \n" + this.deprecationMessage);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.CommandConfig = CommandConfig;
|
|
200
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base API implementation, which provides basic error handling for common problems.
|
|
3
|
+
*/
|
|
4
|
+
(function (factory) {
|
|
5
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
|
+
var v = factory(require, exports);
|
|
7
|
+
if (v !== undefined) module.exports = v;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof define === "function" && define.amd) {
|
|
10
|
+
define(["require", "exports", "../utils/logger"], factory);
|
|
11
|
+
}
|
|
12
|
+
})(function (require, exports) {
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BaseApi = exports.NetworkError = exports.NotFoundError = exports.ServerError = exports.ForbiddenError = void 0;
|
|
16
|
+
const logger_1 = require("../utils/logger");
|
|
17
|
+
class ForbiddenError extends Error {
|
|
18
|
+
constructor(message = "Access Forbidden") {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "ForbiddenError";
|
|
21
|
+
// Maintains proper stack trace in V8 environments (Node, Chrome)
|
|
22
|
+
if (Error.captureStackTrace) {
|
|
23
|
+
Error.captureStackTrace(this, ForbiddenError);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ForbiddenError = ForbiddenError;
|
|
28
|
+
// Custom error for Server (5xx) responses.
|
|
29
|
+
class ServerError extends Error {
|
|
30
|
+
constructor(message = "Internal Server Error") {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "ServerError";
|
|
33
|
+
if (Error.captureStackTrace) {
|
|
34
|
+
Error.captureStackTrace(this, ServerError);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ServerError = ServerError;
|
|
39
|
+
// Custom error for Not Found (404) responses.
|
|
40
|
+
class NotFoundError extends Error {
|
|
41
|
+
constructor(message = "Resource Not Found") {
|
|
42
|
+
super(message);
|
|
43
|
+
this.name = "NotFoundError";
|
|
44
|
+
if (Error.captureStackTrace) {
|
|
45
|
+
Error.captureStackTrace(this, NotFoundError);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.NotFoundError = NotFoundError;
|
|
50
|
+
// Custom error for general network or unexpected issues.
|
|
51
|
+
class NetworkError extends Error {
|
|
52
|
+
constructor(message = "Network or unexpected error occurred") {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = "NetworkError";
|
|
55
|
+
if (Error.captureStackTrace) {
|
|
56
|
+
Error.captureStackTrace(this, NetworkError);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.NetworkError = NetworkError;
|
|
61
|
+
class BaseApi {
|
|
62
|
+
/**
|
|
63
|
+
* Constructor for BaseApiService.
|
|
64
|
+
* @param httpClient - An instance of HttpClient to be used for requests.
|
|
65
|
+
*/
|
|
66
|
+
constructor(httpClient) {
|
|
67
|
+
this.httpClient = httpClient;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Handles errors from HttpClient requests.
|
|
71
|
+
* Logs the error and throws specific custom errors based on HTTP status codes.
|
|
72
|
+
* Subclasses can override this for more specific error handling.
|
|
73
|
+
* @param error - The error object caught from the HttpClient promise.
|
|
74
|
+
* @returns Never, as this method always throws an error.
|
|
75
|
+
*/
|
|
76
|
+
handleError(error) {
|
|
77
|
+
logger_1.logger.debug("API Error:", error); // Basic logging
|
|
78
|
+
// Check if it looks like an HTTP error with a status code
|
|
79
|
+
if (error && typeof error.status === "number") {
|
|
80
|
+
const httpError = error;
|
|
81
|
+
switch (httpError.status) {
|
|
82
|
+
case 401:
|
|
83
|
+
// Handle Unauthorized (e.g., redirect to login)
|
|
84
|
+
// Depending on the app, might not throw, but trigger auth flow
|
|
85
|
+
// Example: throw new AuthenticationError('Authentication required');
|
|
86
|
+
throw new Error(`Unauthorized (401): ${httpError.message || "Authentication required"}`); // Placeholder
|
|
87
|
+
case 403:
|
|
88
|
+
throw new ForbiddenError(`Forbidden (403): ${httpError.message || "Access denied"}`);
|
|
89
|
+
case 404:
|
|
90
|
+
throw new NotFoundError(`Not Found (404): ${httpError.message || "Resource not found"}`);
|
|
91
|
+
case 500:
|
|
92
|
+
case 501:
|
|
93
|
+
case 502:
|
|
94
|
+
case 503:
|
|
95
|
+
case 504:
|
|
96
|
+
throw new ServerError(`Server Error (${httpError.status}): ${httpError.message || "Server issue"}`);
|
|
97
|
+
default:
|
|
98
|
+
// Handle other HTTP errors (e.g., 400 Bad Request)
|
|
99
|
+
throw new Error(`HTTP Error (${httpError.status}): ${httpError.message || "An HTTP error occurred"}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (error instanceof Error) {
|
|
103
|
+
// Handle non-HTTP errors (e.g., network issues, client-side errors)
|
|
104
|
+
console.debug("Non-HTTP Error:", error.message);
|
|
105
|
+
throw new NetworkError(`Network or client-side error: ${error.message}`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Handle cases where the caught object is not an Error instance
|
|
109
|
+
console.debug("Unknown error structure:", error);
|
|
110
|
+
throw new Error("An unknown error occurred");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.BaseApi = BaseApi;
|
|
115
|
+
});
|
|
@@ -13,30 +13,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "
|
|
16
|
+
define(["require", "exports", "form-data", "./axios-initializer", "../utils/logger", "./tracing", "../profile/profile.interface", "../utils/version"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const logger_1 = require("../
|
|
25
|
-
const tracing_1 = require("
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
exports.HttpClient = void 0;
|
|
22
|
+
const FormData = require("form-data");
|
|
23
|
+
const axios_initializer_1 = require("./axios-initializer");
|
|
24
|
+
const logger_1 = require("../utils/logger");
|
|
25
|
+
const tracing_1 = require("./tracing");
|
|
26
|
+
const profile_interface_1 = require("../profile/profile.interface");
|
|
27
|
+
const version_1 = require("../utils/version");
|
|
28
|
+
/**
|
|
29
|
+
* Http client configured based upon the CLI context. It will authenticate
|
|
30
|
+
* based on the profile in the context and also use the base URL accordingly.
|
|
31
|
+
*/
|
|
32
|
+
class HttpClient {
|
|
33
|
+
constructor(context) {
|
|
34
|
+
this.context = context;
|
|
30
35
|
this.axios = axios_initializer_1.AxiosInitializer.initializeAxios();
|
|
31
36
|
}
|
|
32
37
|
get(url) {
|
|
33
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const fullUrl = this.resolveUrl(url);
|
|
40
|
+
logger_1.logger.debug(`HttpClient - GET ${fullUrl}`);
|
|
34
41
|
return new Promise((resolve, reject) => {
|
|
35
|
-
this.axios.get(
|
|
36
|
-
headers: this.buildHeaders(
|
|
42
|
+
this.axios.get(fullUrl, {
|
|
43
|
+
headers: this.buildHeaders()
|
|
37
44
|
}).then(response => {
|
|
45
|
+
logger_1.logger.debug(`Response ${response.status}`);
|
|
38
46
|
this.handleResponse(response, resolve, reject);
|
|
39
47
|
}).catch(err => {
|
|
48
|
+
logger_1.logger.debug("HTTP GET resulted in error", err);
|
|
40
49
|
this.handleError(err, resolve, reject);
|
|
41
50
|
});
|
|
42
51
|
}).catch(e => {
|
|
@@ -48,7 +57,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
48
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
58
|
return new Promise((resolve, reject) => {
|
|
50
59
|
this.axios.get(this.resolveUrl(url), {
|
|
51
|
-
headers: this.buildHeaders(
|
|
60
|
+
headers: this.buildHeaders(),
|
|
52
61
|
responseType: "stream",
|
|
53
62
|
validateStatus: status => status >= 200
|
|
54
63
|
}).then(response => {
|
|
@@ -73,7 +82,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
73
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
83
|
return new Promise((resolve, reject) => {
|
|
75
84
|
this.axios.post(this.resolveUrl(url), formData, {
|
|
76
|
-
headers: Object.assign(Object.assign({}, this.buildHeaders(
|
|
85
|
+
headers: Object.assign(Object.assign({}, this.buildHeaders("multipart/form-data")), formData.getHeaders()),
|
|
77
86
|
params: parameters
|
|
78
87
|
}).then(response => {
|
|
79
88
|
this.handleResponse(response, resolve, reject);
|
|
@@ -87,9 +96,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
87
96
|
}
|
|
88
97
|
post(url, body) {
|
|
89
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const contentType = body instanceof FormData
|
|
100
|
+
? "multipart/form-data"
|
|
101
|
+
: "application/json;charset=utf-8";
|
|
102
|
+
const requestBody = typeof body === "string" || body instanceof String || body instanceof FormData
|
|
103
|
+
? body
|
|
104
|
+
: JSON.stringify(body);
|
|
90
105
|
return new Promise((resolve, reject) => {
|
|
91
|
-
this.axios.post(this.resolveUrl(url),
|
|
92
|
-
headers: this.buildHeaders(
|
|
106
|
+
this.axios.post(this.resolveUrl(url), requestBody, {
|
|
107
|
+
headers: this.buildHeaders(contentType)
|
|
93
108
|
}).then(response => {
|
|
94
109
|
this.handleResponse(response, resolve, reject);
|
|
95
110
|
}).catch(err => {
|
|
@@ -104,7 +119,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
104
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
120
|
return new Promise((resolve, reject) => {
|
|
106
121
|
this.axios.put(this.resolveUrl(url), JSON.stringify(body), {
|
|
107
|
-
headers: this.buildHeaders(
|
|
122
|
+
headers: this.buildHeaders("application/json;charset=utf-8")
|
|
108
123
|
}).then(response => {
|
|
109
124
|
this.handleResponse(response, resolve, reject);
|
|
110
125
|
}).catch(err => {
|
|
@@ -119,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
119
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
135
|
return new Promise((resolve, reject) => {
|
|
121
136
|
this.axios.delete(this.resolveUrl(url), {
|
|
122
|
-
headers: this.buildHeaders(
|
|
137
|
+
headers: this.buildHeaders("application/json;charset=utf-8")
|
|
123
138
|
}).then(response => {
|
|
124
139
|
this.handleResponse(response, resolve, reject);
|
|
125
140
|
}).catch(err => {
|
|
@@ -134,7 +149,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
134
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
150
|
return new Promise((resolve, reject) => {
|
|
136
151
|
this.axios.post(this.resolveUrl(url), null, {
|
|
137
|
-
headers: this.buildHeaders(
|
|
152
|
+
headers: this.buildHeaders(),
|
|
138
153
|
responseType: "stream"
|
|
139
154
|
}).then(response => {
|
|
140
155
|
const data = [];
|
|
@@ -164,7 +179,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
164
179
|
reject();
|
|
165
180
|
}
|
|
166
181
|
resolveUrl(url) {
|
|
167
|
-
return
|
|
182
|
+
return this.context.profile.team.replace(/\/?$/, url);
|
|
168
183
|
}
|
|
169
184
|
handleResponse(res, resolve, reject) {
|
|
170
185
|
if (this.checkBadRequest(res.status)) {
|
|
@@ -178,7 +193,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
178
193
|
this.handleResponse(err.response, resolve, reject);
|
|
179
194
|
}
|
|
180
195
|
else {
|
|
181
|
-
reject(err
|
|
196
|
+
reject(err);
|
|
182
197
|
}
|
|
183
198
|
}
|
|
184
199
|
checkBadRequest(statusCode) {
|
|
@@ -193,8 +208,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
193
208
|
reject("Backend responded with status code " + statusCode);
|
|
194
209
|
}
|
|
195
210
|
}
|
|
196
|
-
buildHeaders(
|
|
197
|
-
return Object.assign(Object.assign(Object.assign({}, this.buildAuthorizationHeaders(profile, contentType)), tracing_1.TracingUtils.getTracingHeaders()), { "User-Agent": "content-cli v" + version_1.VersionUtils.getCurrentCliVersion() });
|
|
211
|
+
buildHeaders(contentType) {
|
|
212
|
+
return Object.assign(Object.assign(Object.assign({}, this.buildAuthorizationHeaders(this.context.profile, contentType)), tracing_1.TracingUtils.getTracingHeaders()), { "User-Agent": "content-cli v" + version_1.VersionUtils.getCurrentCliVersion() });
|
|
198
213
|
}
|
|
199
214
|
buildAuthorizationHeaders(profile, contentType) {
|
|
200
215
|
const authenticationType = profile.authenticationType || profile_interface_1.AuthenticationType.BEARER;
|
|
@@ -204,5 +219,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
204
219
|
};
|
|
205
220
|
}
|
|
206
221
|
}
|
|
207
|
-
exports.
|
|
222
|
+
exports.HttpClient = HttpClient;
|
|
208
223
|
});
|
|
@@ -13,28 +13,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports"
|
|
16
|
+
define(["require", "exports"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
getContext() {
|
|
25
|
-
return this.context;
|
|
26
|
-
}
|
|
27
|
-
resolveProfile(profile) {
|
|
21
|
+
exports.BaseManagerHelper = void 0;
|
|
22
|
+
class BaseManagerHelper {
|
|
23
|
+
batchPush(baseManagers) {
|
|
28
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
|
|
30
|
-
this.setContext({ profile: resolvedProfile });
|
|
25
|
+
return Promise.all(baseManagers.map(baseManager => baseManager.push()));
|
|
31
26
|
});
|
|
32
27
|
}
|
|
33
|
-
;
|
|
34
|
-
setContext(context) {
|
|
35
|
-
this.context = context;
|
|
36
|
-
}
|
|
37
28
|
}
|
|
38
|
-
|
|
39
|
-
exports.contextService = ContextService.INSTANCE;
|
|
29
|
+
exports.BaseManagerHelper = BaseManagerHelper;
|
|
40
30
|
});
|
|
@@ -13,32 +13,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "
|
|
16
|
+
define(["require", "exports", "fs", "path", "../../utils/logger"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.BaseManager = void 0;
|
|
22
|
-
const logger_1 = require("../../util/logger");
|
|
23
|
-
const http_client_service_1 = require("../../services/http-client.service");
|
|
24
22
|
const fs = require("fs");
|
|
25
23
|
const path = require("path");
|
|
24
|
+
const logger_1 = require("../../utils/logger");
|
|
26
25
|
class BaseManager {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.httpClientService = new http_client_service_1.HttpClientService();
|
|
26
|
+
constructor(context) {
|
|
29
27
|
this.fileDownloadedMessage = "File downloaded successfully. New filename: ";
|
|
30
|
-
|
|
31
|
-
get profile() {
|
|
32
|
-
return this._profile;
|
|
33
|
-
}
|
|
34
|
-
set profile(value) {
|
|
35
|
-
this._profile = value;
|
|
28
|
+
this.httpClient = context.httpClient;
|
|
36
29
|
}
|
|
37
30
|
pull() {
|
|
38
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
32
|
return new Promise((resolve, reject) => {
|
|
40
|
-
this.
|
|
41
|
-
.
|
|
33
|
+
this.httpClient
|
|
34
|
+
.get(this.getConfig().pullUrl)
|
|
42
35
|
.then(data => {
|
|
43
36
|
try {
|
|
44
37
|
const filename = this.writeToFile(data);
|
|
@@ -60,8 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
60
53
|
pullFile() {
|
|
61
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
55
|
return new Promise((resolve, reject) => {
|
|
63
|
-
this.
|
|
64
|
-
.
|
|
56
|
+
this.httpClient
|
|
57
|
+
.downloadFile(this.getConfig().pullUrl)
|
|
65
58
|
.then(data => {
|
|
66
59
|
const filename = this.writeStreamToFile(data);
|
|
67
60
|
logger_1.logger.info(this.fileDownloadedMessage + filename);
|
|
@@ -77,8 +70,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
77
70
|
push() {
|
|
78
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
72
|
return new Promise((resolve, reject) => {
|
|
80
|
-
this.
|
|
81
|
-
.
|
|
73
|
+
this.httpClient
|
|
74
|
+
.post(this.getConfig().pushUrl, this.getBody())
|
|
82
75
|
.then(data => {
|
|
83
76
|
logger_1.logger.info(this.getConfig().onPushSuccessMessage(data));
|
|
84
77
|
resolve(data);
|
|
@@ -93,8 +86,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
93
86
|
update() {
|
|
94
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
88
|
return new Promise((resolve, reject) => {
|
|
96
|
-
this.
|
|
97
|
-
.
|
|
89
|
+
this.httpClient
|
|
90
|
+
.put(this.getConfig().updateUrl, this.getBody())
|
|
98
91
|
.then(data => {
|
|
99
92
|
logger_1.logger.info(this.getConfig().onUpdateSuccessMessage());
|
|
100
93
|
resolve(data);
|
|
@@ -109,8 +102,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
109
102
|
findAll() {
|
|
110
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
104
|
return new Promise((resolve, reject) => {
|
|
112
|
-
this.
|
|
113
|
-
.
|
|
105
|
+
this.httpClient
|
|
106
|
+
.get(this.getConfig().findAllUrl)
|
|
114
107
|
.then(data => {
|
|
115
108
|
this.getConfig().onFindAll(data);
|
|
116
109
|
resolve(data);
|
|
@@ -13,17 +13,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "
|
|
16
|
+
define(["require", "exports", "./profile.interface", "./profile.validator", "path", "fs", "../utils/logger", "openid-client", "axios", "os"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.profileService = exports.ProfileService = void 0;
|
|
22
|
-
const profile_interface_1 = require("
|
|
23
|
-
const profile_validator_1 = require("
|
|
22
|
+
const profile_interface_1 = require("./profile.interface");
|
|
23
|
+
const profile_validator_1 = require("./profile.validator");
|
|
24
24
|
const path = require("path");
|
|
25
25
|
const fs = require("fs");
|
|
26
|
-
const logger_1 = require("../
|
|
26
|
+
const logger_1 = require("../utils/logger");
|
|
27
27
|
const openid_client_1 = require("openid-client");
|
|
28
28
|
const axios_1 = require("axios");
|
|
29
29
|
const os = require("os");
|
|
@@ -40,6 +40,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
40
40
|
findProfile(profileName) {
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
return new Promise((resolve, reject) => {
|
|
43
|
+
this.checkIfMissingProfile(profileName, reject);
|
|
43
44
|
try {
|
|
44
45
|
if (process.env.TEAM_URL && process.env.API_TOKEN) {
|
|
45
46
|
resolve(this.buildProfileFromEnvVariables());
|
|
@@ -52,7 +53,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
catch (e) {
|
|
55
|
-
reject(
|
|
56
|
+
reject(`The profile ${profileName} couldn't be resolved.`);
|
|
56
57
|
}
|
|
57
58
|
});
|
|
58
59
|
});
|
|
@@ -305,6 +306,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
305
306
|
});
|
|
306
307
|
});
|
|
307
308
|
}
|
|
309
|
+
checkIfMissingProfile(profileName, reject) {
|
|
310
|
+
if (!profileName && (!process.env.TEAM_URL || !process.env.API_TOKEN)) {
|
|
311
|
+
reject("No profile provided. Please provide a profile or an TEAM_URL and API_TOKEN through env variables");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
308
314
|
}
|
|
309
315
|
exports.ProfileService = ProfileService;
|
|
310
316
|
exports.profileService = new ProfileService();
|
|
@@ -13,15 +13,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
if (v !== undefined) module.exports = v;
|
|
14
14
|
}
|
|
15
15
|
else if (typeof define === "function" && define.amd) {
|
|
16
|
-
define(["require", "exports", "../
|
|
16
|
+
define(["require", "exports", "../utils/logger", "valid-url", "./profile.interface"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.ProfileValidator = void 0;
|
|
22
|
-
const
|
|
23
|
-
const logger_1 = require("../util/logger");
|
|
22
|
+
const logger_1 = require("../utils/logger");
|
|
24
23
|
const validUrl = require("valid-url");
|
|
24
|
+
const profile_interface_1 = require("./profile.interface");
|
|
25
25
|
class ProfileValidator {
|
|
26
26
|
static validateProfile(profile) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|