@uipath/common
v0.1.6
Published
Common infrastructure needed by uipcli tools.
Maintainers
Keywords
Readme
@uipath/common
Shared infrastructure for the UiPath CLI. Provides output formatting, logging, error handling, and telemetry.
Installation
npm install @uipath/commonUsage
Output Formatting
import { OutputFormatter } from "@uipath/common";
OutputFormatter.success({ Result: "Success", Code: "AssetList", Data: assets });
OutputFormatter.error({ Result: "Failure", Message: "Not found", Instructions: "Check the ID" });Supported formats: table, json, yaml, plain.
Error Handling
Go-style [error, data] tuple returns via catchError:
import { catchError } from "@uipath/common";
const [error, result] = await catchError(api.getData());
if (error) {
OutputFormatter.error({ Result: "Failure", Message: error.message, Instructions: "Retry" });
return;
}Logging
import { logger, LogLevel } from "@uipath/common";
logger.info("Fetching resources...");
logger.debug("Request payload:", payload);
// Override level at runtime
logger.setLevel(LogLevel.DEBUG);| Method | Level | Stream | Visible by default |
| :--- | :--- | :--- | :--- |
| logger.debug | DEBUG | stdout | No |
| logger.info | INFO | stdout | Yes |
| logger.warn | WARN | stdout | Yes |
| logger.error | ERROR | stderr | Yes |
Debug output is enabled via DEBUG env var (Node/Bun) or localStorage.debug (browser).
API
| Export | Description |
| :--- | :--- |
| OutputFormatter | Structured output in table, JSON, YAML, or plain text |
| catchError(promise) | Go-style error handling returning [error, data] tuples |
| logger | Cross-platform logger with debug/info/warn/error levels |
| trackedAction | Commander.js extension for automatic telemetry tracking |
| CommandWalker | CLI command introspection utility |
| OutputSink | Abstraction for output destinations |
License
See the root repository for license information.
