@celonis/content-cli 0.11.0 → 0.12.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/api/action-flow-api.js +52 -0
- package/commands/{analysis.command.js → action-flow.command.js} +13 -13
- package/content-cli-analyze.js +56 -0
- package/content-cli-export.js +16 -1
- package/content-cli-import.js +18 -1
- package/content-cli-pull.js +1 -16
- package/content-cli-push.js +1 -16
- package/content-cli.js +2 -1
- package/lib/api/action-flow-api.d.ts +10 -0
- package/lib/commands/action-flow.command.d.ts +5 -0
- package/lib/content-cli-analyze.d.ts +1 -0
- package/lib/content-cli-export.d.ts +1 -0
- package/lib/content-cli-import.d.ts +1 -0
- package/lib/services/action-flow/action-flow-service.d.ts +11 -0
- package/package.json +1 -1
- package/services/action-flow/action-flow-service.js +90 -0
- package/content/factory/analysis-manager.factory.js +0 -36
- package/content/manager/analysis.manager.js +0 -72
- package/lib/commands/analysis.command.d.ts +0 -6
- package/lib/content/factory/analysis-manager.factory.d.ts +0 -5
- package/lib/content/manager/analysis.manager.d.ts +0 -22
|
@@ -0,0 +1,52 @@
|
|
|
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", "../services/http-client-service.v2", "../util/logger"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.actionFlowApi = void 0;
|
|
22
|
+
const http_client_service_v2_1 = require("../services/http-client-service.v2");
|
|
23
|
+
const logger_1 = require("../util/logger");
|
|
24
|
+
class ActionFlowApi {
|
|
25
|
+
exportRawAssets(packageId) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return http_client_service_v2_1.httpClientV2.getFile(`/ems-automation/api/root/${packageId}/export/assets`).catch(e => {
|
|
28
|
+
throw new logger_1.FatalError(`Problem getting Action Flow assets: ${e}`);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
analyzeAssets(packageId) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return http_client_service_v2_1.httpClientV2.get(`/ems-automation/api/root/${packageId}/export/assets/analyze`).catch(e => {
|
|
35
|
+
throw new logger_1.FatalError(`Problem analyzing Action Flow assets: ${e}`);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
importAssets(packageId, data, dryRun) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const params = {
|
|
42
|
+
dryRun: dryRun,
|
|
43
|
+
};
|
|
44
|
+
return http_client_service_v2_1.httpClientV2.postFile(`/ems-automation/api/root/${packageId}/import/assets`, data, params).catch(e => {
|
|
45
|
+
throw new logger_1.FatalError(`Problem importing Action Flow assets: ${e}`);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
ActionFlowApi.INSTANCE = new ActionFlowApi();
|
|
51
|
+
exports.actionFlowApi = ActionFlowApi.INSTANCE;
|
|
52
|
+
});
|
|
@@ -13,29 +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", "../services/
|
|
16
|
+
define(["require", "exports", "../services/action-flow/action-flow-service"], 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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
exports.ActionFlowCommand = void 0;
|
|
22
|
+
const action_flow_service_1 = require("../services/action-flow/action-flow-service");
|
|
23
|
+
class ActionFlowCommand {
|
|
24
|
+
exportActionFlows(packageId, metadataFile) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield action_flow_service_1.actionFlowService.exportActionFlows(packageId, metadataFile);
|
|
27
|
+
});
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
analyzeActionFlows(packageId, outputToJsonFile) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
yield
|
|
31
|
+
yield action_flow_service_1.actionFlowService.analyzeActionFlows(packageId, outputToJsonFile);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
importActionFlows(packageId, filePath, dryRun, outputToJsonFile) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
yield
|
|
36
|
+
yield action_flow_service_1.actionFlowService.importActionFlows(packageId, filePath, dryRun, outputToJsonFile);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
40
|
+
exports.ActionFlowCommand = ActionFlowCommand;
|
|
41
41
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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", "./util/context-initializer", "./util/logger", "./commands/action-flow.command", "commander"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const context_initializer_1 = require("./util/context-initializer");
|
|
22
|
+
const logger_1 = require("./util/logger");
|
|
23
|
+
const action_flow_command_1 = require("./commands/action-flow.command");
|
|
24
|
+
const commander = require("commander");
|
|
25
|
+
class Analyze {
|
|
26
|
+
static actionFlows(program) {
|
|
27
|
+
program
|
|
28
|
+
.command("action-flows")
|
|
29
|
+
.description("Analyze Action Flows dependencies for a certain package")
|
|
30
|
+
.option("-p, --profile <profile>", "Profile which you want to use to analyze Action Flows")
|
|
31
|
+
.requiredOption("--packageId <packageId>", "ID of the package from which you want to export Action Flows")
|
|
32
|
+
.option("-o, --outputToJsonFile", "Output the analyze result in a JSON file")
|
|
33
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
yield new action_flow_command_1.ActionFlowCommand().analyzeActionFlows(cmd.packageId, cmd.outputToJsonFile);
|
|
35
|
+
process.exit();
|
|
36
|
+
}));
|
|
37
|
+
return program;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const loadCommands = () => {
|
|
41
|
+
getAllCommands();
|
|
42
|
+
};
|
|
43
|
+
context_initializer_1.ContextInitializer.initContext()
|
|
44
|
+
.then(loadCommands, loadCommands)
|
|
45
|
+
.catch(e => {
|
|
46
|
+
logger_1.logger.error(e);
|
|
47
|
+
});
|
|
48
|
+
if (!process.argv.slice(2).length) {
|
|
49
|
+
commander.outputHelp();
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
function getAllCommands() {
|
|
53
|
+
Analyze.actionFlows(commander);
|
|
54
|
+
commander.parse(process.argv);
|
|
55
|
+
}
|
|
56
|
+
});
|
package/content-cli-export.js
CHANGED
|
@@ -13,7 +13,7 @@ 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", "commander", "./commands/package.command", "./util/logger", "./commands/data-pool.command", "./util/context-initializer"], factory);
|
|
16
|
+
define(["require", "exports", "commander", "./commands/package.command", "./util/logger", "./commands/data-pool.command", "./util/context-initializer", "./commands/action-flow.command"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -24,6 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
const logger_1 = require("./util/logger");
|
|
25
25
|
const data_pool_command_1 = require("./commands/data-pool.command");
|
|
26
26
|
const context_initializer_1 = require("./util/context-initializer");
|
|
27
|
+
const action_flow_command_1 = require("./commands/action-flow.command");
|
|
27
28
|
class Export {
|
|
28
29
|
static packages(program) {
|
|
29
30
|
program
|
|
@@ -53,6 +54,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
53
54
|
}));
|
|
54
55
|
return program;
|
|
55
56
|
}
|
|
57
|
+
static actionFlows(program) {
|
|
58
|
+
program
|
|
59
|
+
.command("action-flows")
|
|
60
|
+
.description("Command to export all Action Flows in a package with their objects and dependencies")
|
|
61
|
+
.option("-p, --profile <profile>", "Profile which you want to use to export Action Flows")
|
|
62
|
+
.requiredOption("--packageId <packageId>", "ID of the package from which you want to export Action Flows")
|
|
63
|
+
.option("-f, --file <file>", "Action flows metadata file (relative path)")
|
|
64
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
yield new action_flow_command_1.ActionFlowCommand().exportActionFlows(cmd.packageId, cmd.file);
|
|
66
|
+
process.exit();
|
|
67
|
+
}));
|
|
68
|
+
return program;
|
|
69
|
+
}
|
|
56
70
|
}
|
|
57
71
|
exports.Export = Export;
|
|
58
72
|
const loadCommands = () => {
|
|
@@ -70,6 +84,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
70
84
|
function getAllCommands() {
|
|
71
85
|
Export.packages(commander);
|
|
72
86
|
Export.dataPool(commander);
|
|
87
|
+
Export.actionFlows(commander);
|
|
73
88
|
commander.parse(process.argv);
|
|
74
89
|
}
|
|
75
90
|
});
|
package/content-cli-import.js
CHANGED
|
@@ -13,7 +13,7 @@ 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", "commander", "./commands/package.command", "./commands/data-pool.command", "./util/context-initializer", "./util/logger"], factory);
|
|
16
|
+
define(["require", "exports", "commander", "./commands/package.command", "./commands/data-pool.command", "./util/context-initializer", "./util/logger", "./commands/action-flow.command"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -24,6 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
const data_pool_command_1 = require("./commands/data-pool.command");
|
|
25
25
|
const context_initializer_1 = require("./util/context-initializer");
|
|
26
26
|
const logger_1 = require("./util/logger");
|
|
27
|
+
const action_flow_command_1 = require("./commands/action-flow.command");
|
|
27
28
|
class Import {
|
|
28
29
|
static packages(program) {
|
|
29
30
|
program
|
|
@@ -54,6 +55,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
54
55
|
}));
|
|
55
56
|
return program;
|
|
56
57
|
}
|
|
58
|
+
static actionFlows(program) {
|
|
59
|
+
program
|
|
60
|
+
.command("action-flows")
|
|
61
|
+
.description("Command to import all Action Flows in a package with their objects and dependencies")
|
|
62
|
+
.option("-p, --profile <profile>", "Profile which you want to use to import Action Flows")
|
|
63
|
+
.requiredOption("--packageId <packageId>", "ID of the package to which you want to export Action Flows")
|
|
64
|
+
.requiredOption("-f, --file <file>", "Exported Action Flows file (relative path)")
|
|
65
|
+
.requiredOption("-d, --dryRun <dryRun>", "Execute the import on dry run mode")
|
|
66
|
+
.option("-o, --outputToJsonFile", "Output the import result in a JSON file")
|
|
67
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
yield new action_flow_command_1.ActionFlowCommand().importActionFlows(cmd.packageId, cmd.file, cmd.dryRun, cmd.outputToJsonFile);
|
|
69
|
+
process.exit();
|
|
70
|
+
}));
|
|
71
|
+
return program;
|
|
72
|
+
}
|
|
57
73
|
}
|
|
58
74
|
exports.Import = Import;
|
|
59
75
|
const loadCommands = () => {
|
|
@@ -71,6 +87,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
71
87
|
function getAllCommands() {
|
|
72
88
|
Import.packages(commander);
|
|
73
89
|
Import.dataPools(commander);
|
|
90
|
+
Import.actionFlows(commander);
|
|
74
91
|
commander.parse(process.argv);
|
|
75
92
|
}
|
|
76
93
|
});
|
package/content-cli-pull.js
CHANGED
|
@@ -13,12 +13,11 @@ 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", "./commands/
|
|
16
|
+
define(["require", "exports", "./commands/skill.command", "./commands/data-pool.command", "./commands/asset.command", "./commands/package.command", "./commands/analysis-bookmarks.command", "commander"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
const analysis_command_1 = require("./commands/analysis.command");
|
|
22
21
|
const skill_command_1 = require("./commands/skill.command");
|
|
23
22
|
const data_pool_command_1 = require("./commands/data-pool.command");
|
|
24
23
|
const asset_command_1 = require("./commands/asset.command");
|
|
@@ -26,19 +25,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
26
25
|
const analysis_bookmarks_command_1 = require("./commands/analysis-bookmarks.command");
|
|
27
26
|
const commander = require("commander");
|
|
28
27
|
class Pull {
|
|
29
|
-
static analysis(program) {
|
|
30
|
-
program
|
|
31
|
-
.command("analysis")
|
|
32
|
-
.description("Command to pull an analysis")
|
|
33
|
-
.option("-p, --profile <profile>", "Profile which you want to use to pull the analysis")
|
|
34
|
-
.requiredOption("--id <id>", "Id of the analysis you want to pull")
|
|
35
|
-
.option("--asset", "Pull workflow as an asset")
|
|
36
|
-
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
yield new analysis_command_1.AnalysisCommand().pullAnalysis(cmd.profile, cmd.id, !!cmd.asset);
|
|
38
|
-
process.exit();
|
|
39
|
-
}));
|
|
40
|
-
return program;
|
|
41
|
-
}
|
|
42
28
|
static analysisBookmarks(program) {
|
|
43
29
|
program
|
|
44
30
|
.command("bookmarks")
|
|
@@ -105,7 +91,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
105
91
|
return program;
|
|
106
92
|
}
|
|
107
93
|
}
|
|
108
|
-
Pull.analysis(commander);
|
|
109
94
|
Pull.analysisBookmarks(commander);
|
|
110
95
|
Pull.skill(commander);
|
|
111
96
|
Pull.dataPool(commander);
|
package/content-cli-push.js
CHANGED
|
@@ -13,7 +13,7 @@ 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", "commander", "fs", "path", "./commands/
|
|
16
|
+
define(["require", "exports", "commander", "fs", "path", "./commands/skill.command", "./commands/widget.command", "./commands/data-pool.command", "./commands/asset.command", "./commands/package.command", "./commands/ctp.command", "./commands/analysis-bookmarks.command", "child_process", "./util/logger"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -21,7 +21,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
const commander = require("commander");
|
|
22
22
|
const fs = require("fs");
|
|
23
23
|
const path = require("path");
|
|
24
|
-
const analysis_command_1 = require("./commands/analysis.command");
|
|
25
24
|
const skill_command_1 = require("./commands/skill.command");
|
|
26
25
|
const widget_command_1 = require("./commands/widget.command");
|
|
27
26
|
const data_pool_command_1 = require("./commands/data-pool.command");
|
|
@@ -32,19 +31,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
31
|
const child_process_1 = require("child_process");
|
|
33
32
|
const logger_1 = require("./util/logger");
|
|
34
33
|
class Push {
|
|
35
|
-
static analysis(program) {
|
|
36
|
-
program
|
|
37
|
-
.command("analysis")
|
|
38
|
-
.description("Command to push an analysis to a workspace")
|
|
39
|
-
.option("-p, --profile <profile>", "Profile which you want to use to push the analysis")
|
|
40
|
-
.requiredOption("--workspaceId <workspaceId>", "Id of the workspace to which you want to push the analysis")
|
|
41
|
-
.requiredOption("-f, --file <file>", "The file you want to push")
|
|
42
|
-
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
yield new analysis_command_1.AnalysisCommand().pushAnalysis(cmd.profile, cmd.workspaceId, cmd.file);
|
|
44
|
-
process.exit();
|
|
45
|
-
}));
|
|
46
|
-
return program;
|
|
47
|
-
}
|
|
48
34
|
static analysisBookmarks(program) {
|
|
49
35
|
program
|
|
50
36
|
.command("bookmarks")
|
|
@@ -192,7 +178,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
192
178
|
return program;
|
|
193
179
|
}
|
|
194
180
|
}
|
|
195
|
-
Push.analysis(commander);
|
|
196
181
|
Push.analysisBookmarks(commander);
|
|
197
182
|
Push.ctp(commander);
|
|
198
183
|
Push.skill(commander);
|
package/content-cli.js
CHANGED
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
program.command("profile", "Commands related to profiles.");
|
|
23
23
|
program.command("pull", "Commands to pull content.");
|
|
24
24
|
program.command("export", "Commands to export content.");
|
|
25
|
-
program.command("import", "Commands to
|
|
25
|
+
program.command("import", "Commands to import content.");
|
|
26
26
|
program.command("push", "Commands to push content.");
|
|
27
27
|
program.command("update", "Commands to update content.");
|
|
28
28
|
program.command("list", "Commands to list content.").alias("ls");
|
|
29
29
|
program.command("get", "Commands to get configuration properties.");
|
|
30
30
|
program.command("set", "Commands to set configuration properties.");
|
|
31
31
|
program.command("config", "Commands related to config management.");
|
|
32
|
+
program.command("analyze", "Commands to analyze assets dependencies.");
|
|
32
33
|
program.version(version_1.VersionUtils.getCurrentCliVersion());
|
|
33
34
|
program.parse(process.argv);
|
|
34
35
|
if (!process.argv.slice(2).length) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as FormData from "form-data";
|
|
3
|
+
declare class ActionFlowApi {
|
|
4
|
+
static readonly INSTANCE: ActionFlowApi;
|
|
5
|
+
exportRawAssets(packageId: string): Promise<Buffer>;
|
|
6
|
+
analyzeAssets(packageId: string): Promise<any>;
|
|
7
|
+
importAssets(packageId: string, data: FormData, dryRun: boolean): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export declare const actionFlowApi: ActionFlowApi;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare class ActionFlowCommand {
|
|
2
|
+
exportActionFlows(packageId: string, metadataFile: string): Promise<void>;
|
|
3
|
+
analyzeActionFlows(packageId: string, outputToJsonFile: boolean): Promise<void>;
|
|
4
|
+
importActionFlows(packageId: string, filePath: string, dryRun: boolean, outputToJsonFile: boolean): Promise<void>;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class ActionFlowService {
|
|
2
|
+
static readonly METADATA_FILE_NAME = "metadata.json";
|
|
3
|
+
exportActionFlows(packageId: string, metadataFilePath: string): Promise<void>;
|
|
4
|
+
analyzeActionFlows(packageId: string, outputToJsonFile: boolean): Promise<void>;
|
|
5
|
+
importActionFlows(packageId: string, filePath: string, dryRun: boolean, outputToJsonFile: boolean): Promise<void>;
|
|
6
|
+
private createBodyForImport;
|
|
7
|
+
private attachMetadataFile;
|
|
8
|
+
}
|
|
9
|
+
export declare const actionFlowService: ActionFlowService;
|
|
10
|
+
export declare const metadataFileName = "metadata.json";
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
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", "../../util/logger", "uuid", "../file-service", "../../api/action-flow-api", "adm-zip", "form-data", "fs"], factory);
|
|
17
|
+
}
|
|
18
|
+
})(function (require, exports) {
|
|
19
|
+
"use strict";
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.metadataFileName = exports.actionFlowService = void 0;
|
|
22
|
+
const logger_1 = require("../../util/logger");
|
|
23
|
+
const uuid_1 = require("uuid");
|
|
24
|
+
const file_service_1 = require("../file-service");
|
|
25
|
+
const action_flow_api_1 = require("../../api/action-flow-api");
|
|
26
|
+
const AdmZip = require("adm-zip");
|
|
27
|
+
const FormData = require("form-data");
|
|
28
|
+
const fs = require("fs");
|
|
29
|
+
class ActionFlowService {
|
|
30
|
+
exportActionFlows(packageId, metadataFilePath) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const exportedActionFlowsData = yield action_flow_api_1.actionFlowApi.exportRawAssets(packageId);
|
|
33
|
+
const tmpZip = new AdmZip(exportedActionFlowsData);
|
|
34
|
+
const zip = new AdmZip();
|
|
35
|
+
tmpZip.getEntries().forEach(entry => {
|
|
36
|
+
zip.addFile(entry.entryName, entry.getData());
|
|
37
|
+
});
|
|
38
|
+
if (metadataFilePath) {
|
|
39
|
+
this.attachMetadataFile(metadataFilePath, zip);
|
|
40
|
+
}
|
|
41
|
+
const fileName = "action-flows_export_" + (0, uuid_1.v4)() + ".zip";
|
|
42
|
+
zip.writeZip(fileName);
|
|
43
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + fileName);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
analyzeActionFlows(packageId, outputToJsonFile) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const actionFlowsMetadata = yield action_flow_api_1.actionFlowApi.analyzeAssets(packageId);
|
|
49
|
+
const actionFlowsMetadataString = JSON.stringify(actionFlowsMetadata, null, 4);
|
|
50
|
+
if (outputToJsonFile) {
|
|
51
|
+
const metadataFileName = "action-flows_metadata_" + (0, uuid_1.v4)() + ".json";
|
|
52
|
+
file_service_1.fileService.writeToFileWithGivenName(actionFlowsMetadataString, metadataFileName);
|
|
53
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + metadataFileName);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
logger_1.logger.info("Action flows analyze metadata: \n" + actionFlowsMetadataString);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
importActionFlows(packageId, filePath, dryRun, outputToJsonFile) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const actionFlowsZip = this.createBodyForImport(filePath);
|
|
63
|
+
const eventLog = yield action_flow_api_1.actionFlowApi.importAssets(packageId, actionFlowsZip, dryRun);
|
|
64
|
+
const eventLogString = JSON.stringify(eventLog, null, 4);
|
|
65
|
+
if (outputToJsonFile) {
|
|
66
|
+
const eventLogFileName = "action-flows_import_event_log_" + (0, uuid_1.v4)() + ".json";
|
|
67
|
+
file_service_1.fileService.writeToFileWithGivenName(eventLogString, eventLogFileName);
|
|
68
|
+
logger_1.logger.info(file_service_1.FileService.fileDownloadedMessage + eventLogFileName);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
logger_1.logger.info("Action flows import event log: \n" + eventLogString);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
createBodyForImport(fileName) {
|
|
76
|
+
fileName = fileName + (fileName.endsWith(".zip") ? "" : ".zip");
|
|
77
|
+
const formData = new FormData();
|
|
78
|
+
formData.append("file", fs.createReadStream(fileName, { encoding: null }), { filename: fileName });
|
|
79
|
+
return formData;
|
|
80
|
+
}
|
|
81
|
+
attachMetadataFile(fileName, zip) {
|
|
82
|
+
fileName = fileName + (fileName.endsWith(".json") ? "" : ".json");
|
|
83
|
+
const metadata = file_service_1.fileService.readFile(fileName);
|
|
84
|
+
zip.addFile(ActionFlowService.METADATA_FILE_NAME, Buffer.from(metadata));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
ActionFlowService.METADATA_FILE_NAME = "metadata.json";
|
|
88
|
+
exports.actionFlowService = new ActionFlowService();
|
|
89
|
+
exports.metadataFileName = ActionFlowService.METADATA_FILE_NAME;
|
|
90
|
+
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "fs", "path", "../../util/logger", "../manager/analysis.manager"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AnalysisManagerFactory = void 0;
|
|
13
|
-
const fs = require("fs");
|
|
14
|
-
const path = require("path");
|
|
15
|
-
const logger_1 = require("../../util/logger");
|
|
16
|
-
const analysis_manager_1 = require("../manager/analysis.manager");
|
|
17
|
-
class AnalysisManagerFactory {
|
|
18
|
-
createManager(id, processId, filename, packageManager) {
|
|
19
|
-
const analysisManager = new analysis_manager_1.AnalysisManager();
|
|
20
|
-
analysisManager.id = id;
|
|
21
|
-
analysisManager.processId = processId;
|
|
22
|
-
if (filename !== null) {
|
|
23
|
-
analysisManager.fileName = this.resolvePackageFilePath(filename);
|
|
24
|
-
}
|
|
25
|
-
analysisManager.packageManager = packageManager;
|
|
26
|
-
return analysisManager;
|
|
27
|
-
}
|
|
28
|
-
resolvePackageFilePath(fileName) {
|
|
29
|
-
if (!fs.existsSync(path.resolve(process.cwd(), fileName))) {
|
|
30
|
-
logger_1.logger.error(new logger_1.FatalError("The provided file does not exist"));
|
|
31
|
-
}
|
|
32
|
-
return path.resolve(process.cwd(), fileName);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.AnalysisManagerFactory = AnalysisManagerFactory;
|
|
36
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./base.manager", "./asset.manager", "fs", "../../util/yaml", "form-data"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AnalysisManager = void 0;
|
|
13
|
-
const base_manager_1 = require("./base.manager");
|
|
14
|
-
const asset_manager_1 = require("./asset.manager");
|
|
15
|
-
const fs = require("fs");
|
|
16
|
-
const yaml_1 = require("../../util/yaml");
|
|
17
|
-
const FormData = require("form-data");
|
|
18
|
-
class AnalysisManager extends base_manager_1.BaseManager {
|
|
19
|
-
get fileName() {
|
|
20
|
-
return this._fileName;
|
|
21
|
-
}
|
|
22
|
-
set fileName(value) {
|
|
23
|
-
this._fileName = value;
|
|
24
|
-
}
|
|
25
|
-
get id() {
|
|
26
|
-
return this._id;
|
|
27
|
-
}
|
|
28
|
-
set id(value) {
|
|
29
|
-
this._id = value;
|
|
30
|
-
}
|
|
31
|
-
get processId() {
|
|
32
|
-
return this._processId;
|
|
33
|
-
}
|
|
34
|
-
set processId(value) {
|
|
35
|
-
this._processId = value;
|
|
36
|
-
}
|
|
37
|
-
get packageManager() {
|
|
38
|
-
return this._packageManager;
|
|
39
|
-
}
|
|
40
|
-
set packageManager(value) {
|
|
41
|
-
this._packageManager = value;
|
|
42
|
-
}
|
|
43
|
-
getConfig() {
|
|
44
|
-
const pullUrl = this.packageManager
|
|
45
|
-
? `${AnalysisManager.BASE_URL}${this.id}/package/export`
|
|
46
|
-
: `${AnalysisManager.PULL_URL}${this.id}`;
|
|
47
|
-
return {
|
|
48
|
-
pushUrl: this.profile.team.replace(/\/?$/, `${AnalysisManager.BASE_URL}/import?processId=${this.processId}`),
|
|
49
|
-
pullUrl: this.profile.team.replace(/\/?$/, pullUrl),
|
|
50
|
-
exportFileName: `${this.packageManager ? asset_manager_1.AssetManager.ASSET_FILE_PREFIX : AnalysisManager.ANALYSIS_FILE_PREFIX}${this.id}${this.packageManager ? ".yaml" : ".json"}`,
|
|
51
|
-
onPushSuccessMessage: (data) => {
|
|
52
|
-
return "Analysis was pushed successfully. New ID: " + data.id;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
getBody() {
|
|
57
|
-
const formData = new FormData();
|
|
58
|
-
formData.append("file", fs.createReadStream(this.fileName));
|
|
59
|
-
return formData;
|
|
60
|
-
}
|
|
61
|
-
getSerializedFileContent(data) {
|
|
62
|
-
if (this.packageManager) {
|
|
63
|
-
return (0, yaml_1.stringify)(data);
|
|
64
|
-
}
|
|
65
|
-
return JSON.stringify(data);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.AnalysisManager = AnalysisManager;
|
|
69
|
-
AnalysisManager.BASE_URL = "/process-mining/api/analysis/";
|
|
70
|
-
AnalysisManager.PULL_URL = `${AnalysisManager.BASE_URL}/export?id=`;
|
|
71
|
-
AnalysisManager.ANALYSIS_FILE_PREFIX = "analysis_";
|
|
72
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare class AnalysisCommand {
|
|
2
|
-
private contentService;
|
|
3
|
-
private analysisManagerFactory;
|
|
4
|
-
pullAnalysis(profile: string, id: string, packageManager: boolean): Promise<void>;
|
|
5
|
-
pushAnalysis(profile: string, workspaceId: string, filename: string): Promise<void>;
|
|
6
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseManager } from "./base.manager";
|
|
2
|
-
import { ManagerConfig } from "../../interfaces/manager-config.interface";
|
|
3
|
-
export declare class AnalysisManager extends BaseManager {
|
|
4
|
-
private static BASE_URL;
|
|
5
|
-
private static PULL_URL;
|
|
6
|
-
private static ANALYSIS_FILE_PREFIX;
|
|
7
|
-
private _id;
|
|
8
|
-
private _processId;
|
|
9
|
-
private _fileName;
|
|
10
|
-
private _packageManager;
|
|
11
|
-
get fileName(): string;
|
|
12
|
-
set fileName(value: string);
|
|
13
|
-
get id(): string;
|
|
14
|
-
set id(value: string);
|
|
15
|
-
get processId(): string;
|
|
16
|
-
set processId(value: string);
|
|
17
|
-
get packageManager(): boolean;
|
|
18
|
-
set packageManager(value: boolean);
|
|
19
|
-
getConfig(): ManagerConfig;
|
|
20
|
-
getBody(): any;
|
|
21
|
-
protected getSerializedFileContent(data: any): string;
|
|
22
|
-
}
|