Skip to content

Commit

Permalink
Merge pull request #183 from celonis/promeris/ta-2977-rename-properties
Browse files Browse the repository at this point in the history
TA-2977: Rename config export properties to match API
  • Loading branch information
promeris authored May 22, 2024
2 parents 4198c61 + 1c32ab5 commit 1807f22
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celonis/content-cli",
"version": "0.8.2",
"version": "0.8.3",
"description": "CLI Tool to help manage content in Celonis EMS",
"main": "content-cli.js",
"bin": {
Expand Down
8 changes: 3 additions & 5 deletions src/interfaces/package-export-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,16 @@ export interface PackageKeyAndVersionPair {
export interface NodeExportTransport {
key: string;
parentNodeKey: string;
packageNodeKey: string;
name: string;
type: string;
exportSerializationType: string;
serializedContent: string;
configuration: string;
schemaVersion: number;

unversionedMetadata: any;
versionedMetdata: object;
spaceId: string;

invalidContent?: boolean;
serializedDocument: Buffer;
serializedDocument?: Buffer;
}

export interface NodeSerializedContent {
Expand Down
7 changes: 4 additions & 3 deletions src/services/studio/studio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ class StudioService {
const packageEntry = packageZip.getEntry("package.yml");

const exportedNode: NodeExportTransport = parse(packageEntry.getData().toString());
const nodeContent: NodeSerializedContent = parse(exportedNode.serializedContent);
const nodeContent: NodeSerializedContent = parse(exportedNode.configuration);

nodeContent.variables = nodeContent.variables.map(variable => ({
...variable,
metadata: variable.type === PackageManagerVariableType.CONNECTION ?
connectionVariablesByKey.get(variable.key).metadata : variable.metadata
}));

exportedNode.serializedContent = stringify(nodeContent);
exportedNode.configuration = stringify(nodeContent);
packageZip.updateFile(packageEntry, Buffer.from(stringify(exportedNode)));
}

Expand Down Expand Up @@ -254,9 +254,10 @@ class StudioService {
await variableService.assignVariableValues(manifest.packageKey, manifest.runtimeVariableAssignments);
}
}

private updateSpaceIdForNode(nodeContent: string, spaceId: string): string {
const exportedNode: NodeExportTransport = parse(nodeContent);
const oldSpaceId = exportedNode.unversionedMetadata.spaceId;
const oldSpaceId = exportedNode.spaceId;

nodeContent = nodeContent.replace(new RegExp(oldSpaceId, "g"), spaceId);
return nodeContent;
Expand Down
6 changes: 3 additions & 3 deletions tests/config/config-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ describe("Config export", () => {
const firstPackageExportedZip = new AdmZip(actualZip.getEntry("key-1_1.0.0.zip").getData());
const firstPackageExportedNode: NodeExportTransport = parse(firstPackageExportedZip.getEntry("package.yml").getData().toString());
expect(firstPackageExportedNode).toBeTruthy();
const firstPackageContent: NodeSerializedContent = parse(firstPackageExportedNode.serializedContent);
const firstPackageContent: NodeSerializedContent = parse(firstPackageExportedNode.configuration);
expect(firstPackageContent.variables).toHaveLength(2);
expect(firstPackageContent.variables).toEqual([
{
Expand All @@ -422,7 +422,7 @@ describe("Config export", () => {
const secondPackageExportedZip = new AdmZip(actualZip.getEntry("key-2_1.0.0.zip").getData());
const secondPackageExportedNode: NodeExportTransport = parse(secondPackageExportedZip.getEntry("package.yml").getData().toString());
expect(secondPackageExportedNode).toBeTruthy();
const secondPackageContent: NodeSerializedContent = parse(secondPackageExportedNode.serializedContent);
const secondPackageContent: NodeSerializedContent = parse(secondPackageExportedNode.configuration);
expect(secondPackageContent.variables).toHaveLength(2);
expect(secondPackageContent.variables).toEqual([{
...secondPackageVariableDefinition[0],
Expand Down Expand Up @@ -513,7 +513,7 @@ describe("Config export", () => {
const firstPackageExportedZip = new AdmZip(actualZip.getEntry("key_with_underscores_1_1.0.0.zip").getData());
const firstPackageExportedNode: NodeExportTransport = parse(firstPackageExportedZip.getEntry("package.yml").getData().toString());
expect(firstPackageExportedNode).toBeTruthy();
const firstPackageContent: NodeSerializedContent = parse(firstPackageExportedNode.serializedContent);
const firstPackageContent: NodeSerializedContent = parse(firstPackageExportedNode.configuration);
expect(firstPackageContent.variables).toHaveLength(3);
expect(firstPackageContent.variables).toEqual([
{
Expand Down
18 changes: 7 additions & 11 deletions tests/utls/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,33 @@ export class ConfigUtils {
};
}

public static buildPackageNode(key: string, serializedContent: string): NodeExportTransport {
public static buildPackageNode(key: string, configuration: string): NodeExportTransport {
return {
key,
parentNodeKey: key,
packageNodeKey: key,
name: "name",
type: "PACKAGE",
exportSerializationType: "YAML",
serializedContent,
configuration: configuration,
schemaVersion: 1,
unversionedMetadata: {},
versionedMetdata: {},
invalidContent: false,
serializedDocument: null
serializedDocument: null,
spaceId: null
};
}

public static buildChildNode(key: string, parentKey: string, type: string): NodeExportTransport {
return {
key,
parentNodeKey: parentKey,
packageNodeKey: parentKey,
name: "name",
type: type,
exportSerializationType: "YAML",
serializedContent: "",
configuration: "",
schemaVersion: 1,
unversionedMetadata: {},
versionedMetdata: {},
invalidContent: false,
serializedDocument: null
serializedDocument: null,
spaceId: null
};
}

Expand Down

0 comments on commit 1807f22

Please sign in to comment.