Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
88 changes: 88 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
- [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)
- [Listing nodes](#listing-nodes)
- [List nodes in a package version](#list-nodes-in-a-package-version)
- [Pagination](#pagination)
- [List nodes with configuration](#list-nodes-with-configuration)
- [Export nodes list as JSON](#export-nodes-list-as-json)
- [Diffing node configurations](#diffing-node-configurations)
- [Diff two versions of a node](#diff-two-versions-of-a-node)
- [Understanding change types](#understanding-change-types)
Expand Down Expand Up @@ -765,6 +770,89 @@ Or combine all options for a versioned node with configuration:
```
content-cli config nodes get --packageKey <packageKey> --nodeKey <nodeKey> --packageVersion <packageVersion> --withConfiguration --json
```
#### Listing nodes

The **config nodes list** command allows you to retrieve all nodes within a specific package version.

##### List nodes in a package version
To list all nodes in a specific package version, use the following command:
```
content-cli config nodes list --packageKey <packageKey> --packageVersion <packageVersion>
```

For example, to list all nodes in version 1.2.3 of the package with key `my-package`:
```
content-cli config nodes list --packageKey my-package --packageVersion 1.2.3
Comment thread
jetakasabaqi marked this conversation as resolved.
```

The command will display information for each node in the console:
```
info: ID: node-id-123
Comment thread
ksalihu marked this conversation as resolved.
Outdated
info: Key: node-key-1
info: Name: My First Node
info: Type: VIEW
info: Package Node Key: my-package
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
info: ----------------------------------------
info: ID: node-id-456
info: Key: node-key-2
info: Name: My Second Node
info: Type: KNOWLEDGE_MODEL
...
```

##### Pagination
The response is paginated, and the page size can be controlled with the `--limit` and `--offset` options (defaults to 100 and 0 respectively).

To limit the number of nodes returned:
```
content-cli config nodes list --packageKey my-package --packageVersion 1.2.3 --limit 10
```

To retrieve the next page of results:
```
content-cli config nodes list --packageKey my-package --packageVersion 1.2.3 --limit 10 --offset 10
```

##### List nodes with configuration
By default, the node configuration is not included in the response. To include each node's configuration, use the `--withConfiguration` flag:
```
content-cli config nodes list --packageKey <packageKey> --packageVersion <packageVersion> --withConfiguration
```

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

##### Export nodes list as JSON
To export the nodes list as a JSON file instead of displaying it in the console, use the `--json` option:
```
content-cli config nodes list --packageKey <packageKey> --packageVersion <packageVersion> --json
```

This will create a JSON file in the current working directory with a UUID filename:
```
info: File downloaded successfully. New filename: 9560f81f-f746-4117-83ee-dd1f614ad624.json
```

The JSON file contains the complete list of nodes with all fields and, if requested, their configurations.

You can combine options to export nodes with their configurations:
```
content-cli config nodes list --packageKey <packageKey> --packageVersion <packageVersion> --withConfiguration --json
```

You can also combine pagination with JSON export:
```
content-cli config nodes list --packageKey my-package --packageVersion 1.2.3 --limit 50 --offset 100 --json
```

#### Diffing node configurations

The **config nodes diff** command allows you to compare two versions of a node's configuration within a package.
Expand Down
18 changes: 18 additions & 0 deletions src/commands/configuration-management/api/node-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,23 @@ export class NodeApi {
throw new FatalError(`Problem finding node ${nodeKey} in package ${packageKey} for version ${version}: ${e}`);
});
}

public async findVersionedNodesByPackage(packageKey: string, version: string, withConfiguration: boolean, limit: number, offset: number): Promise<NodeTransport[]> {
const queryParams = new URLSearchParams();
queryParams.set("version", version);
queryParams.set("withConfiguration", withConfiguration.toString());

if (limit) {
queryParams.set("limit", limit.toString());
}
if (offset) {
queryParams.set("offset", offset.toString());
}
return this.httpClient()
.get(`/pacman/api/core/packages/${packageKey}/nodes?${queryParams.toString()}`)
.catch(e => {
throw new FatalError(`Problem fetching nodes from package ${packageKey} for version ${version}: ${e}`);
});
}
}

14 changes: 14 additions & 0 deletions src/commands/configuration-management/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class Module extends IModule {
.option("--json", "Return the response as a JSON file")
.action(this.findNode);

nodesCommand.command("list")
.description("List nodes in a specific package version")
.requiredOption("--packageKey <packageKey>", "Identifier of the package")
.requiredOption("--packageVersion <packageVersion>", "Version of the package")
.option("--limit <limit>", "Limit the number of results returned")
.option("--offset <offset>", "Offset for pagination")
.option("--withConfiguration", "Include node configuration in the response", false)
.option("--json", "Return the response as a JSON file")
.action(this.listNodes);

nodesCommand.command("diff")
.description("Diff two versions of a specific node in a package")
.requiredOption("--packageKey <packageKey>", "Identifier of the package")
Expand Down Expand Up @@ -142,6 +152,10 @@ class Module extends IModule {
await new NodeService(context).findNode(options.packageKey, options.nodeKey, options.withConfiguration, options.packageVersion ?? null, options.json);
}

private async listNodes(context: Context, command: Command, options: OptionValues): Promise<void> {
await new NodeService(context).listNodes(options.packageKey, options.packageVersion, options.limit, options.offset, options.withConfiguration, options.json);
}

private async diffNode(context: Context, command: Command, options: OptionValues): Promise<void> {
await new NodeDiffService(context).diff(options.packageKey, options.nodeKey, options.baseVersion, options.compareVersion, options.json);
}
Expand Down
58 changes: 39 additions & 19 deletions src/commands/configuration-management/node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Context } from "../../core/command/cli-context";
import { fileService, FileService } from "../../core/utils/file-service";
import { logger } from "../../core/utils/logger";
import { v4 as uuidv4 } from "uuid";
import { NodeTransport } from "./interfaces/node.interfaces";

export class NodeService {
private nodeApi: NodeApi;
Expand All @@ -21,26 +22,45 @@ export class NodeService {
fileService.writeToFileWithGivenName(JSON.stringify(node, null, 2), filename);
logger.info(FileService.fileDownloadedMessage + filename);
} else {
logger.info(`ID: ${node.id}`);
logger.info(`Key: ${node.key}`);
logger.info(`Name: ${node.name}`);
logger.info(`Type: ${node.type}`);
logger.info(`Package Node Key: ${node.packageNodeKey}`);
if (node.parentNodeKey) {
logger.info(`Parent Node Key: ${node.parentNodeKey}`);
}
logger.info(`Created By: ${node.createdBy}`);
logger.info(`Updated By: ${node.updatedBy}`);
logger.info(`Creation Date: ${new Date(node.creationDate).toISOString()}`);
logger.info(`Change Date: ${new Date(node.changeDate).toISOString()}`);
if (node.configuration) {
logger.info(`Configuration: ${JSON.stringify(node.configuration, null, 2)}`);
}
if (node.invalidContent) {
logger.info(`Invalid Configuration: ${node.invalidConfiguration}`);
}
logger.info(`Flavor: ${node.flavor}`);
this.printNode(node);
}
}

public async listNodes(packageKey: string, packageVersion: string, limit: number, offset: number, withConfiguration: boolean, jsonResponse: boolean): Promise<void> {
const nodes: NodeTransport[] = await this.nodeApi.findVersionedNodesByPackage(packageKey, packageVersion, withConfiguration, limit, offset);

if (jsonResponse) {
const filename = uuidv4() + ".json";
fileService.writeToFileWithGivenName(JSON.stringify(nodes, null, 2), filename);
logger.info(FileService.fileDownloadedMessage + filename);
} else {
nodes.forEach(node => {
this.printNode(node)
logger.info("--------------------------------------------------");
Comment thread
ZgjimHaziri marked this conversation as resolved.
Outdated
});
}
}

private printNode(node: NodeTransport): void {
logger.info(`ID: ${node.id}`);
logger.info(`Key: ${node.key}`);
logger.info(`Name: ${node.name}`);
logger.info(`Type: ${node.type}`);
logger.info(`Package Node Key: ${node.packageNodeKey}`);
if (node.parentNodeKey) {
logger.info(`Parent Node Key: ${node.parentNodeKey}`);
}
logger.info(`Created By: ${node.createdBy}`);
logger.info(`Updated By: ${node.updatedBy}`);
logger.info(`Creation Date: ${new Date(node.creationDate).toISOString()}`);
logger.info(`Change Date: ${new Date(node.changeDate).toISOString()}`);
if (node.configuration) {
logger.info(`Configuration: ${JSON.stringify(node.configuration, null, 2)}`);
}
if (node.invalidContent) {
logger.info(`Invalid Configuration: ${node.invalidConfiguration}`);
}
logger.info(`Flavor: ${node.flavor}`);
}
}

Loading