@celonis/content-cli 0.5.5 → 0.6.1
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/api/asset-api.js +1 -0
- package/api/compute-pool-api.js +1 -0
- package/api/data-pool-api.js +1 -0
- package/api/node-api.js +1 -0
- package/api/package-api.js +1 -0
- package/api/package-dependencies-api.js +1 -0
- package/api/space-api.js +1 -0
- package/api/variable-assignment-apis.js +1 -0
- package/api/variables-api.js +1 -0
- package/commands/analysis-bookmarks.command.js +1 -0
- package/commands/analysis.command.js +1 -0
- package/commands/asset.command.js +1 -0
- package/commands/connection.command.js +1 -0
- package/commands/ctp.command.js +1 -0
- package/commands/data-pool.command.js +1 -0
- package/commands/objective.command.js +1 -0
- package/commands/package.command.js +1 -0
- package/commands/profile.command.js +1 -0
- package/commands/skill.command.js +1 -0
- package/commands/space.command.js +1 -0
- package/commands/variable.command.js +1 -0
- package/commands/widget-sourcemaps.command.js +1 -0
- package/commands/widget.command.js +1 -0
- package/content/factory/analysis-bookmarks-manager.factory.js +1 -0
- package/content/factory/analysis-manager.factory.js +1 -0
- package/content/factory/asset-manager.factory.js +1 -0
- package/content/factory/ctp-manager.factory.js +1 -0
- package/content/factory/data-pool-manager.factory.js +1 -0
- package/content/factory/objective-manager.factory.js +1 -0
- package/content/factory/package-manager.factory.js +1 -0
- package/content/factory/skill-manager.factory.js +1 -0
- package/content/factory/space-manager.factory.js +1 -0
- package/content/factory/widget-manager.factory.js +3 -2
- package/content/factory/widget-sourcemaps-manager.factory.js +1 -0
- package/content/manager/analysis-bookmarks.manager.js +6 -6
- package/content/manager/analysis.manager.js +7 -7
- package/content/manager/asset.manager.js +4 -5
- package/content/manager/base.manager.js +1 -0
- package/content/manager/ctp.analysis.manager.js +8 -8
- package/content/manager/ctp.datamodel.manager.js +1 -0
- package/content/manager/ctp.manager.js +1 -0
- package/content/manager/data-pool.manager.js +3 -6
- package/content/manager/objective.manager.js +3 -4
- package/content/manager/package.manager.js +6 -6
- package/content/manager/skill.manager.js +6 -6
- package/content/manager/space.manager.js +2 -1
- package/content/manager/widget-sourcemaps.manager.js +3 -2
- package/content/manager/widget.manager.js +6 -6
- package/content-cli-export.js +1 -0
- package/content-cli-import.js +1 -0
- package/content-cli-list.js +1 -0
- package/content-cli-push.js +1 -1
- package/interfaces/package-manager.interfaces.js +2 -1
- package/interfaces/profile.interface.js +1 -0
- package/lib/content-cli-list.d.ts +1 -1
- package/lib/interfaces/data-pool-manager.interfaces.d.ts +1 -1
- package/lib/interfaces/profile.interface.d.ts +1 -1
- package/lib/services/http-client-service.v2.d.ts +1 -3
- package/lib/services/http-client.service.d.ts +2 -3
- package/lib/validators/profile.validator.d.ts +1 -1
- package/package.json +12 -8
- package/services/connection/connection.service.js +1 -0
- package/services/content.service.js +1 -0
- package/services/context.service.js +1 -0
- package/services/data-pool/data-pool-service.js +4 -3
- package/services/file-service.js +2 -1
- package/services/http-client-service.v2.js +60 -54
- package/services/http-client.service.js +55 -45
- package/services/package-manager/asset-service.js +2 -1
- package/services/package-manager/datamodel-service.js +1 -0
- package/services/package-manager/package-service.js +5 -4
- package/services/package-manager/space-service.js +2 -1
- package/services/package-manager/variable-service.js +2 -1
- package/services/profile.service.js +1 -0
- package/services/question.service.js +1 -0
- package/util/context-initializer.js +1 -0
- package/util/logger.js +1 -0
- package/util/semantic-versioning.js +1 -0
- package/util/tracing.js +1 -0
- package/util/version.js +1 -0
- package/util/yaml.js +1 -0
- package/validators/profile.validator.js +31 -33
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.WidgetSourcemapsManager = void 0;
|
|
21
22
|
const child_process_1 = require("child_process");
|
|
22
23
|
const logger_1 = require("../../util/logger");
|
|
23
24
|
const base_manager_1 = require("./base.manager");
|
|
@@ -44,7 +45,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
44
45
|
"--disable-git",
|
|
45
46
|
];
|
|
46
47
|
const datadogCommandLine = [...commandLines, "--minified-path-prefix=/package-manager/"].join(" ");
|
|
47
|
-
child_process_1.exec(datadogCommandLine, (error, stdout) => {
|
|
48
|
+
(0, child_process_1.exec)(datadogCommandLine, (error, stdout) => {
|
|
48
49
|
var _a;
|
|
49
50
|
if (error) {
|
|
50
51
|
logger_1.logger.error(new logger_1.GracefulError(error.message));
|
|
@@ -54,7 +55,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
54
55
|
}
|
|
55
56
|
if (process.env.AWS_ACCESS_KEY_ID_CDN && process.env.AWS_SECRET_ACCESS_KEY_CDN) {
|
|
56
57
|
try {
|
|
57
|
-
const uploadSourcemapsStdout = child_process_1.execSync([
|
|
58
|
+
const uploadSourcemapsStdout = (0, child_process_1.execSync)([
|
|
58
59
|
...commandLines,
|
|
59
60
|
`--minified-path-prefix=https://static.celonis.cloud/static/package-manager/`,
|
|
60
61
|
].join(" "));
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./base.manager"], factory);
|
|
7
|
+
define(["require", "exports", "./base.manager", "form-data"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WidgetManager = void 0;
|
|
12
13
|
const base_manager_1 = require("./base.manager");
|
|
14
|
+
const FormData = require("form-data");
|
|
13
15
|
class WidgetManager extends base_manager_1.BaseManager {
|
|
14
16
|
constructor() {
|
|
15
17
|
super(...arguments);
|
|
@@ -49,11 +51,9 @@
|
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
getBody() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
};
|
|
54
|
+
const formData = new FormData();
|
|
55
|
+
formData.append("file", this.content);
|
|
56
|
+
return formData;
|
|
57
57
|
}
|
|
58
58
|
getSerializedFileContent(data) {
|
|
59
59
|
return data;
|
package/content-cli-export.js
CHANGED
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Export = void 0;
|
|
21
22
|
const commander = require("commander");
|
|
22
23
|
const package_command_1 = require("./commands/package.command");
|
|
23
24
|
const logger_1 = require("./util/logger");
|
package/content-cli-import.js
CHANGED
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Import = void 0;
|
|
21
22
|
const commander = require("commander");
|
|
22
23
|
const package_command_1 = require("./commands/package.command");
|
|
23
24
|
const data_pool_command_1 = require("./commands/data-pool.command");
|
package/content-cli-list.js
CHANGED
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.List = void 0;
|
|
21
22
|
const package_command_1 = require("./commands/package.command");
|
|
22
23
|
const space_command_1 = require("./commands/space.command");
|
|
23
24
|
const data_pool_command_1 = require("./commands/data-pool.command");
|
package/content-cli-push.js
CHANGED
|
@@ -104,7 +104,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
104
104
|
if (process.env.AWS_ACCESS_KEY_ID_CDN && process.env.AWS_SECRET_ACCESS_KEY_CDN) {
|
|
105
105
|
try {
|
|
106
106
|
const dir = path.resolve(process.cwd());
|
|
107
|
-
const pushToS3stdout = child_process_1.execSync(`aws s3 cp ${dir} s3://celonis-static-origin/static/package-manager/ --recursive --exclude="*.map" --exclude="*.yaml" --profile default`).toString("utf-8");
|
|
107
|
+
const pushToS3stdout = (0, child_process_1.execSync)(`aws s3 cp ${dir} s3://celonis-static-origin/static/package-manager/ --recursive --exclude="*.map" --exclude="*.yaml" --profile default`).toString("utf-8");
|
|
108
108
|
logger_1.logger.info(pushToS3stdout);
|
|
109
109
|
}
|
|
110
110
|
catch (error) {
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PackageManagerVariableType = void 0;
|
|
12
13
|
var PackageManagerVariableType;
|
|
13
14
|
(function (PackageManagerVariableType) {
|
|
14
15
|
PackageManagerVariableType["DATA_MODEL"] = "DATA_MODEL";
|
|
15
16
|
PackageManagerVariableType["CONNECTION"] = "CONNECTION";
|
|
16
17
|
PackageManagerVariableType["ASSIGNMENT_RULE"] = "ASSIGNMENT_RULE";
|
|
17
18
|
PackageManagerVariableType["PLAIN_TEXT"] = "PLAIN_TEXT";
|
|
18
|
-
})(PackageManagerVariableType
|
|
19
|
+
})(PackageManagerVariableType || (exports.PackageManagerVariableType = PackageManagerVariableType = {}));
|
|
19
20
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import commander = require("commander");
|
|
2
|
-
|
|
2
|
+
type CommanderStatic = commander.CommanderStatic;
|
|
3
3
|
export declare class List {
|
|
4
4
|
static packages(program: CommanderStatic): CommanderStatic;
|
|
5
5
|
static spaces(program: CommanderStatic): CommanderStatic;
|
|
@@ -4,7 +4,7 @@ export interface Profile {
|
|
|
4
4
|
apiToken: string;
|
|
5
5
|
authenticationType: AuthenticationType;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type AuthenticationType = "Bearer" | "AppKey";
|
|
8
8
|
export declare const AuthenticationType: {
|
|
9
9
|
[key: string]: AuthenticationType;
|
|
10
10
|
};
|
|
@@ -7,12 +7,10 @@ declare class HttpClientServiceV2 {
|
|
|
7
7
|
downloadFile(url: string): Promise<any>;
|
|
8
8
|
private handleResponseStreamData;
|
|
9
9
|
private resolveUrl;
|
|
10
|
-
private makeFileDownloadOptions;
|
|
11
10
|
private handleResponse;
|
|
11
|
+
private handleError;
|
|
12
12
|
private checkBadRequest;
|
|
13
13
|
private handleBadRequest;
|
|
14
|
-
private makeOptions;
|
|
15
|
-
private makeOptionsJson;
|
|
16
14
|
private buildHeaders;
|
|
17
15
|
private buildAuthorizationHeaders;
|
|
18
16
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Profile } from "../interfaces/profile.interface";
|
|
2
2
|
export declare class HttpClientService {
|
|
3
|
-
pushData(url: string, profile: Profile, body:
|
|
3
|
+
pushData(url: string, profile: Profile, body: any): Promise<any>;
|
|
4
4
|
pullData(url: string, profile: Profile): Promise<any>;
|
|
5
5
|
pullFileData(url: string, profile: Profile): Promise<any>;
|
|
6
6
|
updateData(url: string, profile: Profile, body: object): Promise<any>;
|
|
7
7
|
findAll(url: string, profile: Profile): Promise<any>;
|
|
8
|
-
private makeOptions;
|
|
9
|
-
private makeFileDownloadOptions;
|
|
10
8
|
private buildAuthorizationHeaders;
|
|
11
9
|
private handleResponseStreamData;
|
|
12
10
|
private handleResponse;
|
|
11
|
+
private handleError;
|
|
13
12
|
private checkBadRequest;
|
|
14
13
|
private handleBadRequest;
|
|
15
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celonis/content-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "CLI Tool to help manage content in Celonis EMS",
|
|
5
5
|
"main": "content-cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -11,29 +11,33 @@
|
|
|
11
11
|
"homepage": "https://github.com/celonis/content-cli",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "./node_modules/.bin/tsc && cp package.json dist/package.json",
|
|
14
|
-
"lint": "tslint -p ."
|
|
14
|
+
"lint": "tslint -p .",
|
|
15
|
+
"test": "jest"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@datadog/datadog-ci": "^0.17.12",
|
|
18
19
|
"adm-zip": "^0.4.14",
|
|
20
|
+
"axios": "1.6.2",
|
|
19
21
|
"commander": "^6.0.0",
|
|
20
|
-
"
|
|
21
|
-
"request-promise-native": "^1.0.5",
|
|
22
|
+
"form-data": "4.0.0",
|
|
22
23
|
"semver": "^7.3.2",
|
|
23
24
|
"valid-url": "^1.0.9",
|
|
24
25
|
"winston": "^3.1.0",
|
|
25
|
-
"yaml": "2.
|
|
26
|
+
"yaml": "2.2.2"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/adm-zip": "^0.4.34",
|
|
29
|
-
"@types/
|
|
30
|
-
"@types/
|
|
30
|
+
"@types/jest": "29.5.11",
|
|
31
|
+
"@types/node": "20.10.4",
|
|
32
|
+
"jest": "29.7.0",
|
|
31
33
|
"lint-staged": "^9.5.0",
|
|
32
34
|
"prettier": "^1.19.1",
|
|
35
|
+
"ts-jest": "29.1.1",
|
|
36
|
+
"ts-node": "10.9.2",
|
|
33
37
|
"tslint": "^5.20.1",
|
|
34
38
|
"tslint-config-prettier": "^1.18.0",
|
|
35
39
|
"tslint-consistent-codestyle": "^1.16.0",
|
|
36
|
-
"typescript": "
|
|
40
|
+
"typescript": "5.3.3"
|
|
37
41
|
},
|
|
38
42
|
"lint-staged": {
|
|
39
43
|
"src/**/*.ts": [
|
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.connectionService = void 0;
|
|
21
22
|
const data_pool_api_1 = require("../../api/data-pool-api");
|
|
22
23
|
const logger_1 = require("../../util/logger");
|
|
23
24
|
class ConnectionService {
|
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.ContentService = void 0;
|
|
21
22
|
const profile_service_1 = require("./profile.service");
|
|
22
23
|
const logger_1 = require("../util/logger");
|
|
23
24
|
class ContentService {
|
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.contextService = void 0;
|
|
21
22
|
const profile_service_1 = require("./profile.service");
|
|
22
23
|
class ContextService {
|
|
23
24
|
getContext() {
|
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.dataPoolService = void 0;
|
|
21
22
|
const data_pool_api_1 = require("../../api/data-pool-api");
|
|
22
23
|
const logger_1 = require("../../util/logger");
|
|
23
24
|
const uuid_1 = require("uuid");
|
|
@@ -29,7 +30,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
29
30
|
const importReport = yield data_pool_api_1.dataPoolApi.executeDataPoolsBatchImport(requestFileContent);
|
|
30
31
|
const importReportString = JSON.stringify(importReport, null, 4);
|
|
31
32
|
if (outputToJsonFile) {
|
|
32
|
-
const reportFileName = "batch_import_report_" + uuid_1.v4() + ".json";
|
|
33
|
+
const reportFileName = "batch_import_report_" + (0, uuid_1.v4)() + ".json";
|
|
33
34
|
file_service_1.fileService.writeToFileWithGivenName(importReportString, reportFileName);
|
|
34
35
|
logger_1.logger.info("Batch import report file: " + reportFileName);
|
|
35
36
|
}
|
|
@@ -43,7 +44,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
44
|
const exportedDataPool = yield data_pool_api_1.dataPoolApi.exportDataPool(poolId);
|
|
44
45
|
const exportedDataPoolString = JSON.stringify(exportedDataPool, null, 4);
|
|
45
46
|
if (outputToJsonFile) {
|
|
46
|
-
const reportFileName = uuid_1.v4() + "_data_pool_" + poolId + ".json";
|
|
47
|
+
const reportFileName = (0, uuid_1.v4)() + "_data_pool_" + poolId + ".json";
|
|
47
48
|
file_service_1.fileService.writeToFileWithGivenName(exportedDataPoolString, reportFileName);
|
|
48
49
|
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + reportFileName);
|
|
49
50
|
}
|
|
@@ -79,7 +80,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
exportListOfPools(nodes) {
|
|
82
|
-
const filename = uuid_1.v4() + ".json";
|
|
83
|
+
const filename = (0, uuid_1.v4)() + ".json";
|
|
83
84
|
file_service_1.fileService.writeToFileWithGivenName(JSON.stringify(nodes), filename);
|
|
84
85
|
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + filename);
|
|
85
86
|
}
|
package/services/file-service.js
CHANGED
|
@@ -18,6 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.fileService = exports.FileService = void 0;
|
|
21
22
|
const fs = require("fs");
|
|
22
23
|
const path = require("path");
|
|
23
24
|
const logger_1 = require("../util/logger");
|
|
@@ -32,7 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
33
|
fs.mkdirSync(path.resolve(process.cwd(), dirName));
|
|
33
34
|
}
|
|
34
35
|
readManifestFile(importedFileName) {
|
|
35
|
-
const manifest = yaml_1.parse(fs.readFileSync(path.resolve(importedFileName + "/manifest.yml"), { encoding: "utf-8" }));
|
|
36
|
+
const manifest = (0, yaml_1.parse)(fs.readFileSync(path.resolve(importedFileName + "/manifest.yml"), { encoding: "utf-8" }));
|
|
36
37
|
return Promise.all(manifest);
|
|
37
38
|
}
|
|
38
39
|
readFileToJson(fileName) {
|
|
@@ -13,24 +13,29 @@ 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", "../interfaces/profile.interface", "
|
|
16
|
+
define(["require", "exports", "../interfaces/profile.interface", "./context.service", "../util/logger", "../util/tracing", "../util/version", "axios", "form-data"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.httpClientV2 = void 0;
|
|
21
22
|
const profile_interface_1 = require("../interfaces/profile.interface");
|
|
22
|
-
const request = require("request");
|
|
23
23
|
const context_service_1 = require("./context.service");
|
|
24
24
|
const logger_1 = require("../util/logger");
|
|
25
|
-
const querystring = require("querystring");
|
|
26
25
|
const tracing_1 = require("../util/tracing");
|
|
27
26
|
const version_1 = require("../util/version");
|
|
27
|
+
const axios_1 = require("axios");
|
|
28
|
+
const FormData = require("form-data");
|
|
28
29
|
class HttpClientServiceV2 {
|
|
29
30
|
get(url) {
|
|
30
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
32
|
return new Promise((resolve, reject) => {
|
|
32
|
-
|
|
33
|
-
this.
|
|
33
|
+
axios_1.default.get(this.resolveUrl(url), {
|
|
34
|
+
headers: this.buildHeaders(context_service_1.contextService.getContext().profile)
|
|
35
|
+
}).then(response => {
|
|
36
|
+
this.handleResponse(response, resolve, reject);
|
|
37
|
+
}).catch(err => {
|
|
38
|
+
this.handleError(err, resolve, reject);
|
|
34
39
|
});
|
|
35
40
|
}).catch(e => {
|
|
36
41
|
throw new logger_1.FatalError(e);
|
|
@@ -40,8 +45,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
40
45
|
postFile(url, body, parameters) {
|
|
41
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
47
|
return new Promise((resolve, reject) => {
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
const formData = new FormData();
|
|
49
|
+
formData.append("package", body.formData.package);
|
|
50
|
+
axios_1.default.post(this.resolveUrl(url), formData, {
|
|
51
|
+
headers: Object.assign(Object.assign({}, this.buildHeaders(context_service_1.contextService.getContext().profile, "multipart/form-data")), formData.getHeaders()),
|
|
52
|
+
params: parameters
|
|
53
|
+
}).then(response => {
|
|
54
|
+
this.handleResponse(response, resolve, reject);
|
|
55
|
+
}).catch(err => {
|
|
56
|
+
this.handleError(err, resolve, reject);
|
|
45
57
|
});
|
|
46
58
|
}).catch(e => {
|
|
47
59
|
throw new logger_1.FatalError(e);
|
|
@@ -51,8 +63,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
51
63
|
post(url, body) {
|
|
52
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
65
|
return new Promise((resolve, reject) => {
|
|
54
|
-
|
|
55
|
-
this.
|
|
66
|
+
axios_1.default.post(this.resolveUrl(url), typeof body === "string" || body instanceof String ? body : JSON.stringify(body), {
|
|
67
|
+
headers: this.buildHeaders(context_service_1.contextService.getContext().profile, "application/json;charset=utf-8")
|
|
68
|
+
}).then(response => {
|
|
69
|
+
this.handleResponse(response, resolve, reject);
|
|
70
|
+
}).catch(err => {
|
|
71
|
+
this.handleError(err, resolve, reject);
|
|
56
72
|
});
|
|
57
73
|
}).catch(e => {
|
|
58
74
|
throw new logger_1.FatalError(e);
|
|
@@ -62,8 +78,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
62
78
|
put(url, body) {
|
|
63
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
80
|
return new Promise((resolve, reject) => {
|
|
65
|
-
|
|
66
|
-
this.
|
|
81
|
+
axios_1.default.put(this.resolveUrl(url), JSON.stringify(body), {
|
|
82
|
+
headers: this.buildHeaders(context_service_1.contextService.getContext().profile, "application/json;charset=utf-8")
|
|
83
|
+
}).then(response => {
|
|
84
|
+
this.handleResponse(response, resolve, reject);
|
|
85
|
+
}).catch(err => {
|
|
86
|
+
this.handleError(err, resolve, reject);
|
|
67
87
|
});
|
|
68
88
|
}).catch(e => {
|
|
69
89
|
throw new logger_1.FatalError(e);
|
|
@@ -73,8 +93,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
73
93
|
delete(url) {
|
|
74
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
95
|
return new Promise((resolve, reject) => {
|
|
76
|
-
|
|
77
|
-
this.
|
|
96
|
+
axios_1.default.delete(this.resolveUrl(url), {
|
|
97
|
+
headers: this.buildHeaders(context_service_1.contextService.getContext().profile, "application/json;charset=utf-8")
|
|
98
|
+
}).then(response => {
|
|
99
|
+
this.handleResponse(response, resolve, reject);
|
|
100
|
+
}).catch(err => {
|
|
101
|
+
this.handleError(err, resolve, reject);
|
|
78
102
|
});
|
|
79
103
|
}).catch(e => {
|
|
80
104
|
throw new logger_1.FatalError(e);
|
|
@@ -84,23 +108,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
84
108
|
downloadFile(url) {
|
|
85
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
110
|
return new Promise((resolve, reject) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
111
|
+
axios_1.default.post(this.resolveUrl(url), null, {
|
|
112
|
+
headers: this.buildHeaders(context_service_1.contextService.getContext().profile),
|
|
113
|
+
responseType: "stream"
|
|
114
|
+
}).then(response => {
|
|
90
115
|
const data = [];
|
|
91
|
-
response.on("data", (chunk) => {
|
|
116
|
+
response.data.on("data", (chunk) => {
|
|
92
117
|
data.push(chunk);
|
|
93
118
|
});
|
|
94
|
-
response.on("end", () => {
|
|
95
|
-
if (this.checkBadRequest(response.
|
|
96
|
-
this.handleBadRequest(response.
|
|
119
|
+
response.data.on("end", () => {
|
|
120
|
+
if (this.checkBadRequest(response.status)) {
|
|
121
|
+
this.handleBadRequest(response.status, data.toString(), reject);
|
|
97
122
|
}
|
|
98
123
|
else {
|
|
99
124
|
this.handleResponseStreamData(Buffer.concat(data), resolve, reject);
|
|
100
125
|
}
|
|
101
126
|
});
|
|
102
|
-
})
|
|
103
|
-
.
|
|
127
|
+
}).catch(err => {
|
|
128
|
+
this.handleError(err, resolve, reject);
|
|
129
|
+
});
|
|
104
130
|
});
|
|
105
131
|
});
|
|
106
132
|
}
|
|
@@ -115,28 +141,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
115
141
|
resolveUrl(url) {
|
|
116
142
|
return context_service_1.contextService.getContext().profile.team.replace(/\/?$/, url);
|
|
117
143
|
}
|
|
118
|
-
makeFileDownloadOptions(profile) {
|
|
119
|
-
return {
|
|
120
|
-
headers: this.buildHeaders(profile),
|
|
121
|
-
responseType: "binary",
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
144
|
handleResponse(res, resolve, reject) {
|
|
125
|
-
if (this.checkBadRequest(res.
|
|
126
|
-
this.handleBadRequest(res.
|
|
145
|
+
if (this.checkBadRequest(res.status)) {
|
|
146
|
+
this.handleBadRequest(res.status, res.data, reject);
|
|
127
147
|
return;
|
|
128
148
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
149
|
+
resolve(res.data);
|
|
150
|
+
}
|
|
151
|
+
handleError(err, resolve, reject) {
|
|
152
|
+
if (err.response) {
|
|
153
|
+
this.handleResponse(err.response, resolve, reject);
|
|
134
154
|
}
|
|
135
|
-
|
|
136
|
-
reject(
|
|
137
|
-
return;
|
|
155
|
+
else {
|
|
156
|
+
reject(err.message);
|
|
138
157
|
}
|
|
139
|
-
resolve(body);
|
|
140
158
|
}
|
|
141
159
|
checkBadRequest(statusCode) {
|
|
142
160
|
return statusCode >= 400;
|
|
@@ -144,32 +162,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
144
162
|
// tslint:disable-next-line:typedef
|
|
145
163
|
handleBadRequest(statusCode, data, reject) {
|
|
146
164
|
if (data) {
|
|
147
|
-
reject(data);
|
|
165
|
+
reject(JSON.stringify(data));
|
|
148
166
|
}
|
|
149
167
|
else {
|
|
150
168
|
reject("Backend responded with status code " + statusCode);
|
|
151
169
|
}
|
|
152
170
|
}
|
|
153
|
-
makeOptions(profile, body = {}) {
|
|
154
|
-
const options = {
|
|
155
|
-
headers: this.buildHeaders(profile),
|
|
156
|
-
};
|
|
157
|
-
return Object.assign(options, body);
|
|
158
|
-
}
|
|
159
|
-
makeOptionsJson(profile, body, contentType) {
|
|
160
|
-
return {
|
|
161
|
-
headers: this.buildHeaders(profile, contentType),
|
|
162
|
-
body: body,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
171
|
buildHeaders(profile, contentType) {
|
|
166
172
|
return Object.assign(Object.assign(Object.assign({}, this.buildAuthorizationHeaders(profile, contentType)), tracing_1.TracingUtils.getTracingHeaders()), { "User-Agent": "content-cli v" + version_1.VersionUtils.getCurrentCliVersion() });
|
|
167
173
|
}
|
|
168
174
|
buildAuthorizationHeaders(profile, contentType) {
|
|
169
175
|
const authenticationType = profile.authenticationType || profile_interface_1.AuthenticationType.BEARER;
|
|
170
176
|
return {
|
|
171
|
-
|
|
172
|
-
"
|
|
177
|
+
Authorization: `${authenticationType} ${profile.apiToken}`,
|
|
178
|
+
"Content-Type": contentType !== null && contentType !== void 0 ? contentType : "application/json",
|
|
173
179
|
};
|
|
174
180
|
}
|
|
175
181
|
}
|