Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 53 additions & 4 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
- [Listing package variables](#listing-package-variables)
- [Listing assignments](#listing-assignments)
- [Mapping variables](#mapping-variables)
- [Finding staging nodes](#finding-staging-nodes)
- [Find a node](#find-a-node)
- [Find a node with configuration](#find-a-node-with-configuration)
- [Finding nodes](#finding-nodes)
- [Find a staging node](#find-a-staging-node)
- [Find a staging node with configuration](#find-a-staging-node-with-configuration)
- [Find a versioned node](#find-a-versioned-node)
- [Find a versioned node with configuration](#find-a-versioned-node-with-configuration)
- [Export node as JSON](#export-node-as-json)
- [Data Pool export / import commands](#data-pool-export--import-commands)
- [Export Data Pool](#export-data-pool)
Expand Down Expand Up @@ -672,7 +674,44 @@ When configuration is included, it will be displayed as a JSON string in the out
info: Configuration: {"key":"value","nested":{"field":"data"}}
```

##### Export staging node as JSON
##### Find a versioned node
To find a specific node in a package by version, use the `--version` option:
```
content-cli config nodes find --packageKey <packageKey> --nodeKey <nodeKey> --version <version>
Comment thread
ksalihu marked this conversation as resolved.
Outdated
```

For example, to find a node in version 1.2.3.4:
```
content-cli config nodes find --packageKey my-package --nodeKey my-node --version 1.2.3.4
Comment thread
ksalihu marked this conversation as resolved.
Outdated
```

The command will display the node information in the console with the same format as staging nodes:
```
info: ID: node-id-123
info: Key: node-key
info: Name: My Node
info: Type: VIEW
info: Package Node Key: package-node-key
info: Parent Node Key: parent-node-key
info: Created By: user@celonis.com
info: Updated By: user@celonis.com
info: Creation Date: 2025-10-22T10:30:00.000Z
info: Change Date: 2025-10-22T15:45:00.000Z
info: Flavor: STUDIO
```

##### Find a versioned node with configuration
You can combine the `--version` and `--withConfiguration` options to retrieve a versioned node with its configuration:
```
content-cli config nodes find --packageKey <packageKey> --nodeKey <nodeKey> --version <version> --withConfiguration
```

When configuration is included, it will be displayed as a JSON string in the output:
```
info: Configuration: {"key":"value","nested":{"field":"data"}}
```

##### Export node as JSON
To export the node information as a JSON file instead of displaying it in the console, use the `--json` option:
```
content-cli config nodes find --packageKey <packageKey> --nodeKey <nodeKey> --json
Expand All @@ -690,6 +729,16 @@ You can combine options to export a node with its configuration:
content-cli config nodes find --packageKey <packageKey> --nodeKey <nodeKey> --withConfiguration --json
```

You can also export versioned nodes as JSON:
```
content-cli config nodes find --packageKey <packageKey> --nodeKey <nodeKey> --version <version> --json
```

Or combine all options for a versioned node with configuration:
```
content-cli config nodes find --packageKey <packageKey> --nodeKey <nodeKey> --version <version> --withConfiguration --json
```

### Deployment commands (beta)
The **deployment** command group allows you to create deployments, list their history, check active deployments, and retrieve deployables and targets.

Expand Down
12 changes: 12 additions & 0 deletions src/commands/configuration-management/api/node-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,17 @@ export class NodeApi {
throw new FatalError(`Problem finding node ${nodeKey} in package ${packageKey}: ${e}`);
});
}

public async findVersionedNodeByKey(packageKey: string, nodeKey: string, version: string, withConfiguration: boolean): Promise<NodeTransport> {
const queryParams = new URLSearchParams();
queryParams.set("version", version);
queryParams.set("withConfiguration", withConfiguration.toString());

return this.httpClient()
.get(`/pacman/api/core/packages/${packageKey}/nodes/${nodeKey}?${queryParams.toString()}`)
.catch((e) => {
throw new FatalError(`Problem finding node ${nodeKey} in package ${packageKey} for version ${version}: ${e}`);
});
}
}

3 changes: 2 additions & 1 deletion src/commands/configuration-management/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Module extends IModule {
.description("Find a specific node in a package")
.requiredOption("--packageKey <packageKey>", "Identifier of the package")
.requiredOption("--nodeKey <nodeKey>", "Identifier of the node")
.option("--version <version>", "Version of the package")
.option("--withConfiguration", "Include node configuration in the response", false)
.option("--json", "Return the response as a JSON file")
.action(this.findNode);
Expand Down Expand Up @@ -128,7 +129,7 @@ class Module extends IModule {
}

private async findNode(context: Context, command: Command, options: OptionValues): Promise<void> {
await new NodeService(context).findNode(options.packageKey, options.nodeKey, options.withConfiguration, options.json);
await new NodeService(context).findNode(options.packageKey, options.nodeKey, options.withConfiguration, options.version ?? null, options.json);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/commands/configuration-management/node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export class NodeService {
this.nodeApi = new NodeApi(context);
}

public async findNode(packageKey: string, nodeKey: string, withConfiguration: boolean, jsonResponse: boolean): Promise<void> {
const node = await this.nodeApi.findStagingNodeByKey(packageKey, nodeKey, withConfiguration);
public async findNode(packageKey: string, nodeKey: string, withConfiguration: boolean, version: string | null, jsonResponse: boolean): Promise<void> {
const node = version
? await this.nodeApi.findVersionedNodeByKey(packageKey, nodeKey, version, withConfiguration)
: await this.nodeApi.findStagingNodeByKey(packageKey, nodeKey, withConfiguration);

if (jsonResponse) {
const filename = uuidv4() + ".json";
Expand Down
26 changes: 19 additions & 7 deletions tests/commands/configuration-management/config-node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("Node find", () => {
const nodeKey = "node-key";
mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=false`, node);

await new NodeService(testContext).findNode(packageKey, nodeKey, false, false);
await new NodeService(testContext).findNode(packageKey, nodeKey, false, null, false);

expect(loggingTestTransport.logMessages.length).toBe(11);
expect(loggingTestTransport.logMessages[0].message).toContain(`ID: ${node.id}`);
Expand All @@ -45,6 +45,18 @@ describe("Node find", () => {
expect(loggingTestTransport.logMessages[10].message).toContain(`Flavor: ${node.flavor}`);
});

it("Should find versioned node without configuration", async () => {
const packageKey = "package-key";
const nodeKey = "node-key";
const version = "1.2.3.4";
mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/packages/${packageKey}/nodes/${nodeKey}?version=${version}&withConfiguration=false`, node);

await new NodeService(testContext).findNode(packageKey, nodeKey, false, version, false);

expect(loggingTestTransport.logMessages.length).toBe(11);
expect(loggingTestTransport.logMessages[0].message).toContain(`ID: ${node.id}`);
});

it("Should find node with configuration", async () => {
const packageKey = "package-key";
const nodeKey = "node-key";
Expand All @@ -58,7 +70,7 @@ describe("Node find", () => {

mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=true`, nodeWithConfig);

await new NodeService(testContext).findNode(packageKey, nodeKey, true, false);
await new NodeService(testContext).findNode(packageKey, nodeKey, true, null, false);

expect(loggingTestTransport.logMessages.length).toBe(12);
expect(loggingTestTransport.logMessages[0].message).toContain(`ID: ${nodeWithConfig.id}`);
Expand All @@ -76,7 +88,7 @@ describe("Node find", () => {

mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=false`, nodeWithoutParent);

await new NodeService(testContext).findNode(packageKey, nodeKey, false, false);
await new NodeService(testContext).findNode(packageKey, nodeKey, false, null, false);

expect(loggingTestTransport.logMessages.length).toBe(10);
// Verify that parent node key is not logged
Expand All @@ -89,7 +101,7 @@ describe("Node find", () => {
const nodeKey = "node-key";
mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=false`, node);

await new NodeService(testContext).findNode(packageKey, nodeKey, false, true);
await new NodeService(testContext).findNode(packageKey, nodeKey, false, null, true);

const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1];

Expand All @@ -115,7 +127,7 @@ describe("Node find", () => {

mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=true`, nodeWithConfig);

await new NodeService(testContext).findNode(packageKey, nodeKey, true, true);
await new NodeService(testContext).findNode(packageKey, nodeKey, true, null, true);

const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1];

Expand All @@ -139,7 +151,7 @@ describe("Node find", () => {

mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=false`, nodeWithInvalidConfig);

await new NodeService(testContext).findNode(packageKey, nodeKey, false, false);
await new NodeService(testContext).findNode(packageKey, nodeKey, false, null, false);

expect(loggingTestTransport.logMessages.length).toBe(12);
expect(loggingTestTransport.logMessages[0].message).toContain(`ID: ${nodeWithInvalidConfig.id}`);
Expand All @@ -159,7 +171,7 @@ describe("Node find", () => {

mockAxiosGet(`https://myTeam.celonis.cloud/pacman/api/core/staging/packages/${packageKey}/nodes/${nodeKey}?withConfiguration=false`, nodeWithInvalidConfig);

await new NodeService(testContext).findNode(packageKey, nodeKey, false, true);
await new NodeService(testContext).findNode(packageKey, nodeKey, false, null, true);

const expectedFileName = loggingTestTransport.logMessages[0].message.split(FileService.fileDownloadedMessage)[1];

Expand Down