@uipath/common 0.1.5 → 0.1.7
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/README.md +72 -110
- package/dist/index.js +142 -86
- package/package.json +44 -44
package/README.md
CHANGED
|
@@ -1,110 +1,72 @@
|
|
|
1
|
-
# common
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
export class LogOutput {
|
|
75
|
-
Message: string;
|
|
76
|
-
[key: string]: unknown;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function log(data: LogOutput, format: OutputFormat = "table"): void {
|
|
80
|
-
...
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## 2. Logger
|
|
86
|
-
|
|
87
|
-
A simple console wrapper that works in both Node.js/Bun and browser environments. Supports four log levels and respects a `DEBUG` flag to enable verbose output.
|
|
88
|
-
|
|
89
|
-
- **Node/Bun**: reads `process.env.DEBUG`
|
|
90
|
-
- **Browser**: reads `localStorage.debug` (same convention as the `debug` npm package)
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
import { logger, LogLevel } from "@uipath/common";
|
|
94
|
-
|
|
95
|
-
logger.debug("only visible when DEBUG is set");
|
|
96
|
-
logger.info("general info");
|
|
97
|
-
logger.warn("warning");
|
|
98
|
-
logger.error("error");
|
|
99
|
-
|
|
100
|
-
// Override the level at runtime
|
|
101
|
-
logger.setLevel(LogLevel.DEBUG);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
| Method | Level | Node stream | Visible by default |
|
|
105
|
-
|-----------------|---------|-------------|--------------------|
|
|
106
|
-
| `logger.debug` | DEBUG | stdout | No |
|
|
107
|
-
| `logger.info` | INFO | stdout | Yes |
|
|
108
|
-
| `logger.warn` | WARN | stdout | Yes |
|
|
109
|
-
| `logger.error` | ERROR | stderr | Yes |
|
|
110
|
-
|
|
1
|
+
# @uipath/common
|
|
2
|
+
|
|
3
|
+
Shared infrastructure for the UiPath CLI. Provides output formatting, logging, error handling, and telemetry.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @uipath/common
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Output Formatting
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { OutputFormatter } from "@uipath/common";
|
|
17
|
+
|
|
18
|
+
OutputFormatter.success({ Result: "Success", Code: "AssetList", Data: assets });
|
|
19
|
+
OutputFormatter.error({ Result: "Failure", Message: "Not found", Instructions: "Check the ID" });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Supported formats: `table`, `json`, `yaml`, `plain`.
|
|
23
|
+
|
|
24
|
+
### Error Handling
|
|
25
|
+
|
|
26
|
+
Go-style `[error, data]` tuple returns via `catchError`:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { catchError } from "@uipath/common";
|
|
30
|
+
|
|
31
|
+
const [error, result] = await catchError(api.getData());
|
|
32
|
+
if (error) {
|
|
33
|
+
OutputFormatter.error({ Result: "Failure", Message: error.message, Instructions: "Retry" });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Logging
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { logger, LogLevel } from "@uipath/common";
|
|
42
|
+
|
|
43
|
+
logger.info("Fetching resources...");
|
|
44
|
+
logger.debug("Request payload:", payload);
|
|
45
|
+
|
|
46
|
+
// Override level at runtime
|
|
47
|
+
logger.setLevel(LogLevel.DEBUG);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
| Method | Level | Stream | Visible by default |
|
|
51
|
+
| :--- | :--- | :--- | :--- |
|
|
52
|
+
| `logger.debug` | DEBUG | stdout | No |
|
|
53
|
+
| `logger.info` | INFO | stdout | Yes |
|
|
54
|
+
| `logger.warn` | WARN | stdout | Yes |
|
|
55
|
+
| `logger.error` | ERROR | stderr | Yes |
|
|
56
|
+
|
|
57
|
+
Debug output is enabled via `DEBUG` env var (Node/Bun) or `localStorage.debug` (browser).
|
|
58
|
+
|
|
59
|
+
## API
|
|
60
|
+
|
|
61
|
+
| Export | Description |
|
|
62
|
+
| :--- | :--- |
|
|
63
|
+
| `OutputFormatter` | Structured output in table, JSON, YAML, or plain text |
|
|
64
|
+
| `catchError(promise)` | Go-style error handling returning `[error, data]` tuples |
|
|
65
|
+
| `logger` | Cross-platform logger with debug/info/warn/error levels |
|
|
66
|
+
| `trackedAction` | Commander.js extension for automatic telemetry tracking |
|
|
67
|
+
| `CommandWalker` | CLI command introspection utility |
|
|
68
|
+
| `OutputSink` | Abstraction for output destinations |
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
See the [root repository](https://github.com/UiPath/uipcli) for license information.
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
3
|
|
|
20
4
|
// src/catch-error.ts
|
|
@@ -4666,26 +4650,21 @@ import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
|
4666
4650
|
import { dirname } from "node:path";
|
|
4667
4651
|
|
|
4668
4652
|
// src/output-context.ts
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
return;
|
|
4681
|
-
},
|
|
4682
|
-
run: (_store, fn) => fn()
|
|
4683
|
-
};
|
|
4684
|
-
}
|
|
4653
|
+
function createStorage() {
|
|
4654
|
+
try {
|
|
4655
|
+
const { AsyncLocalStorage } = __require("node:async_hooks");
|
|
4656
|
+
return new AsyncLocalStorage;
|
|
4657
|
+
} catch {
|
|
4658
|
+
return {
|
|
4659
|
+
getStore: () => {
|
|
4660
|
+
return;
|
|
4661
|
+
},
|
|
4662
|
+
run: (_store, fn) => fn()
|
|
4663
|
+
};
|
|
4685
4664
|
}
|
|
4686
|
-
return g[STORAGE_KEY];
|
|
4687
4665
|
}
|
|
4688
|
-
var outputStorage =
|
|
4666
|
+
var outputStorage = createStorage();
|
|
4667
|
+
var globalSink;
|
|
4689
4668
|
var CONSOLE_FALLBACK = {
|
|
4690
4669
|
writeOut: (str2) => process.stdout.write(str2),
|
|
4691
4670
|
writeErr: (str2) => process.stderr.write(str2),
|
|
@@ -4700,20 +4679,19 @@ function runWithSink(sink, fn) {
|
|
|
4700
4679
|
return outputStorage.run(sink, fn);
|
|
4701
4680
|
}
|
|
4702
4681
|
function getOutputSink() {
|
|
4703
|
-
|
|
4704
|
-
return outputStorage.getStore() ?? g[GLOBAL_SINK_KEY] ?? CONSOLE_FALLBACK;
|
|
4682
|
+
return outputStorage.getStore() ?? globalSink ?? CONSOLE_FALLBACK;
|
|
4705
4683
|
}
|
|
4706
4684
|
function setGlobalSink(sink) {
|
|
4707
|
-
|
|
4685
|
+
globalSink = sink;
|
|
4708
4686
|
}
|
|
4709
4687
|
|
|
4710
4688
|
// src/logger.ts
|
|
4711
|
-
var
|
|
4689
|
+
var sharedLogFilePath = "";
|
|
4712
4690
|
function setGlobalLogFilePath(path) {
|
|
4713
|
-
|
|
4691
|
+
sharedLogFilePath = path;
|
|
4714
4692
|
}
|
|
4715
4693
|
function getGlobalLogFilePath() {
|
|
4716
|
-
return
|
|
4694
|
+
return sharedLogFilePath;
|
|
4717
4695
|
}
|
|
4718
4696
|
var LogLevel;
|
|
4719
4697
|
((LogLevel2) => {
|
|
@@ -4722,6 +4700,7 @@ var LogLevel;
|
|
|
4722
4700
|
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
4723
4701
|
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
4724
4702
|
})(LogLevel ||= {});
|
|
4703
|
+
var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
|
|
4725
4704
|
|
|
4726
4705
|
class SimpleLogger {
|
|
4727
4706
|
static instance;
|
|
@@ -4742,21 +4721,17 @@ class SimpleLogger {
|
|
|
4742
4721
|
static resetInstance() {
|
|
4743
4722
|
SimpleLogger.instance = undefined;
|
|
4744
4723
|
}
|
|
4724
|
+
static isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
4745
4725
|
static resolveLevel() {
|
|
4746
|
-
if (
|
|
4747
|
-
|
|
4748
|
-
if (parsed !== undefined)
|
|
4749
|
-
return parsed;
|
|
4750
|
-
}
|
|
4751
|
-
if (typeof process !== "undefined" && process.env?.DEBUG) {
|
|
4752
|
-
return 0 /* DEBUG */;
|
|
4726
|
+
if (SimpleLogger.isNode) {
|
|
4727
|
+
return SimpleLogger.parseLevel(process.env?.UIPCLI_LOG_LEVEL ?? "") ?? (process.env?.DEBUG ? 0 /* DEBUG */ : DEFAULT_LOG_LEVEL);
|
|
4753
4728
|
}
|
|
4754
4729
|
try {
|
|
4755
4730
|
if (typeof localStorage !== "undefined" && localStorage.getItem("debug")) {
|
|
4756
4731
|
return 0 /* DEBUG */;
|
|
4757
4732
|
}
|
|
4758
4733
|
} catch {}
|
|
4759
|
-
return
|
|
4734
|
+
return DEFAULT_LOG_LEVEL;
|
|
4760
4735
|
}
|
|
4761
4736
|
static parseLevel(value) {
|
|
4762
4737
|
switch (value.toLowerCase()) {
|
|
@@ -4906,19 +4881,19 @@ function configureLogger(config) {
|
|
|
4906
4881
|
}
|
|
4907
4882
|
|
|
4908
4883
|
// src/output-format-context.ts
|
|
4909
|
-
var
|
|
4910
|
-
var
|
|
4884
|
+
var currentFormat;
|
|
4885
|
+
var currentFilter;
|
|
4911
4886
|
function setOutputFormat(format) {
|
|
4912
|
-
|
|
4887
|
+
currentFormat = format;
|
|
4913
4888
|
}
|
|
4914
4889
|
function getOutputFormat() {
|
|
4915
|
-
return
|
|
4890
|
+
return currentFormat ?? "table";
|
|
4916
4891
|
}
|
|
4917
4892
|
function setOutputFilter(filter) {
|
|
4918
|
-
|
|
4893
|
+
currentFilter = filter;
|
|
4919
4894
|
}
|
|
4920
4895
|
function getOutputFilter() {
|
|
4921
|
-
return
|
|
4896
|
+
return currentFilter;
|
|
4922
4897
|
}
|
|
4923
4898
|
|
|
4924
4899
|
// ../../node_modules/@uipath/telemetry/dist/node.js
|
|
@@ -5182,11 +5157,15 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
5182
5157
|
if (!client)
|
|
5183
5158
|
return;
|
|
5184
5159
|
const merged = this.mergeProperties(properties);
|
|
5185
|
-
logger.debug(`[AppInsights] trackEvent: ${eventName}`, merged
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5160
|
+
logger.debug(`[AppInsights] trackEvent: ${eventName}`, merged ? JSON.stringify(merged) : "");
|
|
5161
|
+
try {
|
|
5162
|
+
client.trackEvent({
|
|
5163
|
+
name: eventName,
|
|
5164
|
+
properties: merged
|
|
5165
|
+
});
|
|
5166
|
+
} catch {
|
|
5167
|
+
logger.debug(`[AppInsights] trackEvent failed for: ${eventName}`);
|
|
5168
|
+
}
|
|
5190
5169
|
}
|
|
5191
5170
|
async trackException(error, properties) {
|
|
5192
5171
|
const client = this.client;
|
|
@@ -5194,10 +5173,14 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
5194
5173
|
return;
|
|
5195
5174
|
const merged = this.mergeProperties(properties);
|
|
5196
5175
|
logger.debug(`[AppInsights] trackException: ${error.message}`, merged ?? "");
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5176
|
+
try {
|
|
5177
|
+
client.trackException({
|
|
5178
|
+
exception: error,
|
|
5179
|
+
properties: merged
|
|
5180
|
+
});
|
|
5181
|
+
} catch {
|
|
5182
|
+
logger.debug(`[AppInsights] trackException failed for: ${error.message}`);
|
|
5183
|
+
}
|
|
5201
5184
|
}
|
|
5202
5185
|
async trackRequest(name, duration, success, properties) {
|
|
5203
5186
|
const client = this.client;
|
|
@@ -5232,26 +5215,44 @@ class NodeAppInsightsTelemetryProvider {
|
|
|
5232
5215
|
}
|
|
5233
5216
|
async flush() {
|
|
5234
5217
|
const client = this.client;
|
|
5235
|
-
if (!client)
|
|
5218
|
+
if (!client) {
|
|
5219
|
+
logger.warn(`[AppInsights] flush error (non-fatal): nil client`);
|
|
5236
5220
|
return;
|
|
5221
|
+
}
|
|
5237
5222
|
logger.debug("[AppInsights] flush: sending buffered telemetry to cloud");
|
|
5238
|
-
const [error] = await catchError(
|
|
5223
|
+
const [error] = await catchError(new Promise((resolve, reject) => {
|
|
5224
|
+
client.flush({
|
|
5225
|
+
callback: (response) => {
|
|
5226
|
+
if (!response) {
|
|
5227
|
+
resolve();
|
|
5228
|
+
return;
|
|
5229
|
+
}
|
|
5230
|
+
const [parseError, parsed] = catchError(() => JSON.parse(response));
|
|
5231
|
+
if (parseError || parsed?.errors && parsed.errors.length > 0) {
|
|
5232
|
+
reject(new Error(response));
|
|
5233
|
+
} else {
|
|
5234
|
+
resolve();
|
|
5235
|
+
}
|
|
5236
|
+
}
|
|
5237
|
+
});
|
|
5238
|
+
}));
|
|
5239
5239
|
if (error) {
|
|
5240
5240
|
logger.warn(`[AppInsights] flush error (non-fatal): ${error.message}`);
|
|
5241
5241
|
}
|
|
5242
5242
|
}
|
|
5243
5243
|
async shutdown() {
|
|
5244
|
-
|
|
5245
|
-
|
|
5244
|
+
if (!this.appInsightsModule) {
|
|
5245
|
+
logger.warn(`[AppInsights] shutdown error (non-fatal): nil appInsightsModule`);
|
|
5246
5246
|
return;
|
|
5247
|
+
}
|
|
5247
5248
|
const appInsights = this.appInsightsModule;
|
|
5248
|
-
const [
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
})());
|
|
5252
|
-
if (error) {
|
|
5253
|
-
logger.warn(`[AppInsights] shutdown error (non-fatal): ${error.message}`);
|
|
5249
|
+
const [err] = catchError(() => appInsights.dispose());
|
|
5250
|
+
if (err) {
|
|
5251
|
+
logger.warn(`[AppInsights] shutdown error (non-fatal): ${err.message}`);
|
|
5254
5252
|
}
|
|
5253
|
+
this.client = undefined;
|
|
5254
|
+
this.appInsightsModule = undefined;
|
|
5255
|
+
this.initialized = false;
|
|
5255
5256
|
}
|
|
5256
5257
|
}
|
|
5257
5258
|
async function getOrCreateProvider(connectionString) {
|
|
@@ -5289,7 +5290,7 @@ function getOrCreateSessionId() {
|
|
|
5289
5290
|
return id;
|
|
5290
5291
|
}
|
|
5291
5292
|
var sessionId = getOrCreateSessionId();
|
|
5292
|
-
var DEFAULT_AI_CONNECTION_STRING = Buffer.from("
|
|
5293
|
+
var DEFAULT_AI_CONNECTION_STRING = Buffer.from("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj", "base64").toString("utf-8");
|
|
5293
5294
|
function getConnectionString() {
|
|
5294
5295
|
return process.env.UIPATH_AI_CONNECTION_STRING || DEFAULT_AI_CONNECTION_STRING;
|
|
5295
5296
|
}
|
|
@@ -5389,7 +5390,7 @@ async function telemetryFlushAndShutdown() {
|
|
|
5389
5390
|
|
|
5390
5391
|
// src/telemetry-events.ts
|
|
5391
5392
|
var CommonTelemetryEvents = {
|
|
5392
|
-
Error: "
|
|
5393
|
+
Error: "uip.error"
|
|
5393
5394
|
};
|
|
5394
5395
|
|
|
5395
5396
|
// src/formatter.ts
|
|
@@ -5470,11 +5471,6 @@ function logOutput(data, format = "table") {
|
|
|
5470
5471
|
printOutput(data, format, (msg) => sink.writeOut(`${msg}
|
|
5471
5472
|
`));
|
|
5472
5473
|
}
|
|
5473
|
-
function errorOutput(data, format = "table") {
|
|
5474
|
-
const sink = getOutputSink();
|
|
5475
|
-
printOutput(data, format, (msg) => sink.writeErr(`${msg}
|
|
5476
|
-
`));
|
|
5477
|
-
}
|
|
5478
5474
|
function printTable(data, logFn = console.log, externalLogValue) {
|
|
5479
5475
|
if (data.length === 0)
|
|
5480
5476
|
return;
|
|
@@ -5529,7 +5525,7 @@ var OutputFormatter;
|
|
|
5529
5525
|
result: data.Result,
|
|
5530
5526
|
message: data.Message
|
|
5531
5527
|
});
|
|
5532
|
-
|
|
5528
|
+
logOutput(data, getOutputFormat());
|
|
5533
5529
|
}
|
|
5534
5530
|
OutputFormatter.error = error;
|
|
5535
5531
|
function log(data) {
|
|
@@ -5616,14 +5612,14 @@ function formatHelpAll(command, baseName = "") {
|
|
|
5616
5612
|
var VALID_FORMATS = ["table", "json", "yaml", "plain"];
|
|
5617
5613
|
function extractFormatFromArgs(args) {
|
|
5618
5614
|
for (let i2 = 0;i2 < args.length; i2++) {
|
|
5619
|
-
if (args[i2] === "--
|
|
5615
|
+
if (args[i2] === "--output" && i2 + 1 < args.length) {
|
|
5620
5616
|
const value = args[i2 + 1];
|
|
5621
5617
|
if (VALID_FORMATS.includes(value)) {
|
|
5622
5618
|
return value;
|
|
5623
5619
|
}
|
|
5624
5620
|
}
|
|
5625
|
-
if (args[i2]?.startsWith("--
|
|
5626
|
-
const value = args[i2].substring("--
|
|
5621
|
+
if (args[i2]?.startsWith("--output=")) {
|
|
5622
|
+
const value = args[i2].substring("--output=".length);
|
|
5627
5623
|
if (VALID_FORMATS.includes(value)) {
|
|
5628
5624
|
return value;
|
|
5629
5625
|
}
|
|
@@ -5639,6 +5635,16 @@ function registerHelpAll(command) {
|
|
|
5639
5635
|
throw new CommanderError(0, "commander.helpDisplayed", "(outputHelp)");
|
|
5640
5636
|
});
|
|
5641
5637
|
}
|
|
5638
|
+
// src/constants.ts
|
|
5639
|
+
var UIPATH_HOME_DIR = ".uipath";
|
|
5640
|
+
var AUTH_FILENAME = ".auth";
|
|
5641
|
+
var CONFIG_FILENAME = "config.json";
|
|
5642
|
+
var LOCAL_CONFIG_FILENAME = "uipath.config.json";
|
|
5643
|
+
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
5644
|
+
var DEFAULT_PAGE_SIZE = 50;
|
|
5645
|
+
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
5646
|
+
var DEFAULT_FETCH_TIMEOUT_MS = 30000;
|
|
5647
|
+
var DEFAULT_REDIRECT_URI = "http://localhost:8104/oidc/login";
|
|
5642
5648
|
// ../../node_modules/jsonpath-plus/dist/index-node-esm.js
|
|
5643
5649
|
import vm from "vm";
|
|
5644
5650
|
|
|
@@ -7062,6 +7068,17 @@ class JsonPathError extends Error {
|
|
|
7062
7068
|
this.name = "JsonPathError";
|
|
7063
7069
|
}
|
|
7064
7070
|
}
|
|
7071
|
+
// src/tool-provider.ts
|
|
7072
|
+
var toolProvider;
|
|
7073
|
+
function setToolProvider(provider) {
|
|
7074
|
+
toolProvider = provider;
|
|
7075
|
+
}
|
|
7076
|
+
async function ensureToolAvailable(verb) {
|
|
7077
|
+
if (!toolProvider) {
|
|
7078
|
+
throw new Error(`Tool '${verb}' is required but cannot be auto-installed. ` + `Run 'uip tools install ${verb}' manually.`);
|
|
7079
|
+
}
|
|
7080
|
+
await toolProvider(verb);
|
|
7081
|
+
}
|
|
7065
7082
|
// src/trackedAction.ts
|
|
7066
7083
|
import { Command } from "commander";
|
|
7067
7084
|
var processContext = {
|
|
@@ -7069,8 +7086,34 @@ var processContext = {
|
|
|
7069
7086
|
process.exitCode = code;
|
|
7070
7087
|
}
|
|
7071
7088
|
};
|
|
7072
|
-
|
|
7089
|
+
function deriveCommandPath(cmd) {
|
|
7090
|
+
const parts = [];
|
|
7091
|
+
let current = cmd;
|
|
7092
|
+
while (current) {
|
|
7093
|
+
const name = current.name();
|
|
7094
|
+
if (name) {
|
|
7095
|
+
parts.unshift(name);
|
|
7096
|
+
}
|
|
7097
|
+
current = current.parent;
|
|
7098
|
+
}
|
|
7099
|
+
if (parts.length > 1) {
|
|
7100
|
+
parts.shift();
|
|
7101
|
+
}
|
|
7102
|
+
return ["uip", ...parts.filter((p) => p !== "uip")].join(".");
|
|
7103
|
+
}
|
|
7104
|
+
Command.prototype.trackedAction = function(context, fnOrName, fnOrProps, legacyProperties) {
|
|
7105
|
+
const command = this;
|
|
7106
|
+
let fn;
|
|
7107
|
+
let properties;
|
|
7108
|
+
if (typeof fnOrName === "string") {
|
|
7109
|
+
fn = fnOrProps;
|
|
7110
|
+
properties = legacyProperties;
|
|
7111
|
+
} else {
|
|
7112
|
+
fn = fnOrName;
|
|
7113
|
+
properties = fnOrProps;
|
|
7114
|
+
}
|
|
7073
7115
|
return this.action(async (...args) => {
|
|
7116
|
+
const telemetryName = deriveCommandPath(command);
|
|
7074
7117
|
const props = typeof properties === "function" ? properties(...args) : properties;
|
|
7075
7118
|
const startTime = performance.now();
|
|
7076
7119
|
let errorMessage;
|
|
@@ -7099,6 +7142,7 @@ export {
|
|
|
7099
7142
|
telemetryInit,
|
|
7100
7143
|
telemetryFlushAndShutdown,
|
|
7101
7144
|
telemetry,
|
|
7145
|
+
setToolProvider,
|
|
7102
7146
|
setOutputFormat,
|
|
7103
7147
|
setOutputFilter,
|
|
7104
7148
|
setGlobalTelemetryProperties,
|
|
@@ -7120,15 +7164,27 @@ export {
|
|
|
7120
7164
|
extractFormatFromArgs,
|
|
7121
7165
|
extractCommandHelp,
|
|
7122
7166
|
evaluateJsonPath,
|
|
7167
|
+
ensureToolAvailable,
|
|
7168
|
+
deriveCommandPath,
|
|
7123
7169
|
createTelemetryProvider,
|
|
7124
7170
|
createAppInsightsProvider,
|
|
7125
7171
|
configureLogger,
|
|
7126
7172
|
collectCommands,
|
|
7127
7173
|
catchError,
|
|
7174
|
+
UIPATH_HOME_DIR,
|
|
7128
7175
|
SuccessOutput,
|
|
7129
7176
|
OutputFormatter,
|
|
7130
7177
|
LogLevel,
|
|
7178
|
+
LOCAL_CONFIG_FILENAME,
|
|
7131
7179
|
JsonPathError,
|
|
7132
7180
|
FailureOutput,
|
|
7133
|
-
|
|
7181
|
+
DEFAULT_REDIRECT_URI,
|
|
7182
|
+
DEFAULT_PAGE_SIZE,
|
|
7183
|
+
DEFAULT_LOG_LEVEL,
|
|
7184
|
+
DEFAULT_FETCH_TIMEOUT_MS,
|
|
7185
|
+
DEFAULT_BASE_URL,
|
|
7186
|
+
DEFAULT_AUTH_TIMEOUT_MS,
|
|
7187
|
+
CommonTelemetryEvents,
|
|
7188
|
+
CONFIG_FILENAME,
|
|
7189
|
+
AUTH_FILENAME
|
|
7134
7190
|
};
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
"name": "@uipath/common",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "Common infrastructure needed by uipcli tools.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/UiPath/uipcli.git",
|
|
8
|
+
"directory": "packages/common"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"registry": "https://registry.npmjs.org/"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"maintainers": [
|
|
22
|
+
"aoltean16",
|
|
23
|
+
"mihaigirleanu",
|
|
24
|
+
"vlad-uipath"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "bun build ./src/index.ts --outdir dist --format esm --target node --external commander --external applicationinsights",
|
|
28
|
+
"lint": "biome check .",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:coverage": "vitest run --coverage"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@jmespath-community/jmespath": "^1.3.0",
|
|
34
|
+
"@uipath/telemetry": "0.0.3",
|
|
35
|
+
"js-yaml": "^4.1.0",
|
|
36
|
+
"jsonpath-plus": "^10.4.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
|
+
"@types/node": "^25.2.3",
|
|
41
|
+
"typescript": "^5"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"commander": "^14.0.3"
|
|
45
|
+
}
|
|
46
46
|
}
|