@celonis/content-cli 0.9.0 → 0.10.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/interfaces/batch-export-import-constants.js +4 -4
- package/lib/interfaces/batch-export-import-constants.d.ts +4 -4
- package/lib/interfaces/package-export-transport.d.ts +4 -3
- package/lib/util/json.d.ts +2 -0
- package/package.json +1 -1
- package/services/package-manager/batch-import-export-service.js +6 -6
- package/services/studio/studio.service.js +10 -11
- package/util/json.js +27 -0
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
exports.BatchExportImportConstants = void 0;
|
|
13
13
|
var BatchExportImportConstants;
|
|
14
14
|
(function (BatchExportImportConstants) {
|
|
15
|
-
BatchExportImportConstants["STUDIO_FILE_NAME"] = "studio.
|
|
16
|
-
BatchExportImportConstants["VARIABLES_FILE_NAME"] = "variables.
|
|
17
|
-
BatchExportImportConstants["MANIFEST_FILE_NAME"] = "manifest.
|
|
15
|
+
BatchExportImportConstants["STUDIO_FILE_NAME"] = "studio.json";
|
|
16
|
+
BatchExportImportConstants["VARIABLES_FILE_NAME"] = "variables.json";
|
|
17
|
+
BatchExportImportConstants["MANIFEST_FILE_NAME"] = "manifest.json";
|
|
18
18
|
BatchExportImportConstants["STUDIO"] = "STUDIO";
|
|
19
19
|
BatchExportImportConstants["APP_MODE_VIEWER"] = "VIEWER";
|
|
20
20
|
BatchExportImportConstants["ZIP_EXTENSION"] = ".zip";
|
|
21
|
-
BatchExportImportConstants["
|
|
21
|
+
BatchExportImportConstants["JSON_EXTENSION"] = ".json";
|
|
22
22
|
BatchExportImportConstants["NODES_FOLDER_NAME"] = "nodes/";
|
|
23
23
|
BatchExportImportConstants["SCENARIO_NODE"] = "SCENARIO";
|
|
24
24
|
})(BatchExportImportConstants || (exports.BatchExportImportConstants = BatchExportImportConstants = {}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare enum BatchExportImportConstants {
|
|
2
|
-
STUDIO_FILE_NAME = "studio.
|
|
3
|
-
VARIABLES_FILE_NAME = "variables.
|
|
4
|
-
MANIFEST_FILE_NAME = "manifest.
|
|
2
|
+
STUDIO_FILE_NAME = "studio.json",
|
|
3
|
+
VARIABLES_FILE_NAME = "variables.json",
|
|
4
|
+
MANIFEST_FILE_NAME = "manifest.json",
|
|
5
5
|
STUDIO = "STUDIO",
|
|
6
6
|
APP_MODE_VIEWER = "VIEWER",
|
|
7
7
|
ZIP_EXTENSION = ".zip",
|
|
8
|
-
|
|
8
|
+
JSON_EXTENSION = ".json",
|
|
9
9
|
NODES_FOLDER_NAME = "nodes/",
|
|
10
10
|
SCENARIO_NODE = "SCENARIO"
|
|
11
11
|
}
|
|
@@ -45,14 +45,15 @@ export interface NodeExportTransport {
|
|
|
45
45
|
name: string;
|
|
46
46
|
type: string;
|
|
47
47
|
exportSerializationType: string;
|
|
48
|
-
configuration:
|
|
48
|
+
configuration: NodeConfiguration;
|
|
49
49
|
schemaVersion: number;
|
|
50
50
|
spaceId: string;
|
|
51
51
|
invalidContent?: boolean;
|
|
52
52
|
serializedDocument?: Buffer;
|
|
53
53
|
}
|
|
54
|
-
export interface
|
|
55
|
-
variables
|
|
54
|
+
export interface NodeConfiguration {
|
|
55
|
+
variables?: VariableDefinition[];
|
|
56
|
+
[key: string]: any;
|
|
56
57
|
}
|
|
57
58
|
export interface StudioPackageManifest {
|
|
58
59
|
packageKey: string;
|
package/package.json
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", "../../api/batch-import-export-api", "../../util/logger", "uuid", "../file-service", "../studio/studio.service", "../../util/
|
|
16
|
+
define(["require", "exports", "../../api/batch-import-export-api", "../../util/logger", "uuid", "../file-service", "../studio/studio.service", "../../util/json", "form-data", "../../interfaces/batch-export-import-constants", "../../api/package-api", "stream", "adm-zip"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -24,7 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
const uuid_1 = require("uuid");
|
|
25
25
|
const file_service_1 = require("../file-service");
|
|
26
26
|
const studio_service_1 = require("../studio/studio.service");
|
|
27
|
-
const
|
|
27
|
+
const json_1 = require("../../util/json");
|
|
28
28
|
const FormData = require("form-data");
|
|
29
29
|
const batch_export_import_constants_1 = require("../../interfaces/batch-export-import-constants");
|
|
30
30
|
const package_api_1 = require("../../api/package-api");
|
|
@@ -56,15 +56,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
const exportedPackagesData = yield batch_import_export_api_1.batchImportExportApi.exportPackages(packageKeys, withDependencies);
|
|
58
58
|
const exportedPackagesZip = new AdmZip(exportedPackagesData);
|
|
59
|
-
const manifest = (0,
|
|
59
|
+
const manifest = (0, json_1.parse)(exportedPackagesZip.getEntry(batch_export_import_constants_1.BatchExportImportConstants.MANIFEST_FILE_NAME).getData().toString());
|
|
60
60
|
const versionsByPackageKey = this.getVersionsByPackageKey(manifest);
|
|
61
61
|
let exportedVariables = yield this.getVersionedVariablesForPackagesWithKeys(versionsByPackageKey);
|
|
62
62
|
exportedVariables = studio_service_1.studioService.fixConnectionVariables(exportedVariables);
|
|
63
|
-
exportedPackagesZip.addFile(batch_export_import_constants_1.BatchExportImportConstants.VARIABLES_FILE_NAME, Buffer.from((0,
|
|
63
|
+
exportedPackagesZip.addFile(batch_export_import_constants_1.BatchExportImportConstants.VARIABLES_FILE_NAME, Buffer.from((0, json_1.stringify)(exportedVariables), "utf8"));
|
|
64
64
|
const studioPackageKeys = manifest.filter(packageManifest => packageManifest.flavor === batch_export_import_constants_1.BatchExportImportConstants.STUDIO)
|
|
65
65
|
.map(packageManifest => packageManifest.packageKey);
|
|
66
66
|
const studioData = yield studio_service_1.studioService.getStudioPackageManifests(studioPackageKeys);
|
|
67
|
-
exportedPackagesZip.addFile(batch_export_import_constants_1.BatchExportImportConstants.STUDIO_FILE_NAME, Buffer.from((0,
|
|
67
|
+
exportedPackagesZip.addFile(batch_export_import_constants_1.BatchExportImportConstants.STUDIO_FILE_NAME, Buffer.from((0, json_1.stringify)(studioData), "utf8"));
|
|
68
68
|
exportedPackagesZip.getEntries().forEach(entry => {
|
|
69
69
|
if (entry.name.endsWith(batch_export_import_constants_1.BatchExportImportConstants.ZIP_EXTENSION)) {
|
|
70
70
|
const lastUnderscoreIndex = entry.name.lastIndexOf("_");
|
|
@@ -142,7 +142,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
142
142
|
parseEntryData(configs, fileName) {
|
|
143
143
|
const entry = configs.getEntry(fileName);
|
|
144
144
|
if (entry) {
|
|
145
|
-
return ((0,
|
|
145
|
+
return ((0, json_1.parse)(entry.getData().toString()));
|
|
146
146
|
}
|
|
147
147
|
return null;
|
|
148
148
|
}
|
|
@@ -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", "../../api/package-api", "../../interfaces/package-manager.interfaces", "../package-manager/datamodel-service", "../../util/
|
|
16
|
+
define(["require", "exports", "../../api/package-api", "../../interfaces/package-manager.interfaces", "../package-manager/datamodel-service", "../../util/json", "../../api/node-api", "../../api/variables-api", "../../api/space-api", "../package-manager/space-service", "../package-manager/variable-service", "../../interfaces/batch-export-import-constants", "adm-zip"], factory);
|
|
17
17
|
}
|
|
18
18
|
})(function (require, exports) {
|
|
19
19
|
"use strict";
|
|
@@ -22,7 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
const package_api_1 = require("../../api/package-api");
|
|
23
23
|
const package_manager_interfaces_1 = require("../../interfaces/package-manager.interfaces");
|
|
24
24
|
const datamodel_service_1 = require("../package-manager/datamodel-service");
|
|
25
|
-
const
|
|
25
|
+
const json_1 = require("../../util/json");
|
|
26
26
|
const node_api_1 = require("../../api/node-api");
|
|
27
27
|
const variables_api_1 = require("../../api/variables-api");
|
|
28
28
|
const space_api_1 = require("../../api/space-api");
|
|
@@ -113,9 +113,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
113
113
|
return Object.assign(Object.assign({}, variable), { metadata: Object.assign(Object.assign({}, variable.metadata), { appName: variable.value.appName }) });
|
|
114
114
|
}
|
|
115
115
|
deleteScenarioAssets(packageZip) {
|
|
116
|
-
packageZip.getEntries().filter(entry => entry.entryName.startsWith(batch_export_import_constants_1.BatchExportImportConstants.NODES_FOLDER_NAME) && entry.entryName.endsWith(batch_export_import_constants_1.BatchExportImportConstants.
|
|
116
|
+
packageZip.getEntries().filter(entry => entry.entryName.startsWith(batch_export_import_constants_1.BatchExportImportConstants.NODES_FOLDER_NAME) && entry.entryName.endsWith(batch_export_import_constants_1.BatchExportImportConstants.JSON_EXTENSION))
|
|
117
117
|
.forEach(entry => {
|
|
118
|
-
const node = (0,
|
|
118
|
+
const node = (0, json_1.parse)(entry.getData().toString());
|
|
119
119
|
if (node.type === batch_export_import_constants_1.BatchExportImportConstants.SCENARIO_NODE) {
|
|
120
120
|
packageZip.deleteFile(entry);
|
|
121
121
|
}
|
|
@@ -127,13 +127,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
127
127
|
if (connectionVariablesByKey.size === 0) {
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
const packageEntry = packageZip.getEntry("package.
|
|
131
|
-
const exportedNode = (0,
|
|
132
|
-
const nodeContent =
|
|
130
|
+
const packageEntry = packageZip.getEntry("package.json");
|
|
131
|
+
const exportedNode = (0, json_1.parse)(packageEntry.getData().toString());
|
|
132
|
+
const nodeContent = exportedNode.configuration;
|
|
133
133
|
nodeContent.variables = nodeContent.variables.map(variable => (Object.assign(Object.assign({}, variable), { metadata: variable.type === package_manager_interfaces_1.PackageManagerVariableType.CONNECTION ?
|
|
134
134
|
connectionVariablesByKey.get(variable.key).metadata : variable.metadata })));
|
|
135
|
-
|
|
136
|
-
packageZip.updateFile(packageEntry, Buffer.from((0, yaml_1.stringify)(exportedNode)));
|
|
135
|
+
packageZip.updateFile(packageEntry, Buffer.from((0, json_1.stringify)(exportedNode)));
|
|
137
136
|
}
|
|
138
137
|
getPackageKeyAndVersion(zipName) {
|
|
139
138
|
const lastUnderscoreIndex = zipName.lastIndexOf("_");
|
|
@@ -168,7 +167,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
168
167
|
studioManifest.space.id = spaceId;
|
|
169
168
|
const packageZip = new AdmZip(file.getData());
|
|
170
169
|
packageZip.getEntries().forEach(nodeFile => {
|
|
171
|
-
if (nodeFile.entryName.endsWith(batch_export_import_constants_1.BatchExportImportConstants.
|
|
170
|
+
if (nodeFile.entryName.endsWith(batch_export_import_constants_1.BatchExportImportConstants.JSON_EXTENSION)) {
|
|
172
171
|
const updatedNodeFile = this.updateSpaceIdForNode(nodeFile.getData().toString(), spaceId);
|
|
173
172
|
packageZip.updateFile(nodeFile, Buffer.from(updatedNodeFile));
|
|
174
173
|
}
|
|
@@ -210,7 +209,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
210
209
|
});
|
|
211
210
|
}
|
|
212
211
|
updateSpaceIdForNode(nodeContent, spaceId) {
|
|
213
|
-
const exportedNode = (0,
|
|
212
|
+
const exportedNode = (0, json_1.parse)(nodeContent);
|
|
214
213
|
const oldSpaceId = exportedNode.spaceId;
|
|
215
214
|
nodeContent = nodeContent.replace(new RegExp(oldSpaceId, "g"), spaceId);
|
|
216
215
|
return nodeContent;
|
package/util/json.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parse = exports.stringify = void 0;
|
|
13
|
+
function stringify(data) {
|
|
14
|
+
return JSON.stringify(data, replacer, 2);
|
|
15
|
+
}
|
|
16
|
+
exports.stringify = stringify;
|
|
17
|
+
function parse(data) {
|
|
18
|
+
return JSON.parse(data);
|
|
19
|
+
}
|
|
20
|
+
exports.parse = parse;
|
|
21
|
+
const replacer = (key, value) => {
|
|
22
|
+
if (value instanceof Map) {
|
|
23
|
+
return Object.fromEntries(value);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
});
|