@uipath/api-workflow-tool 0.1.10 → 0.1.11

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.
Files changed (2) hide show
  1. package/dist/tool.js +62 -52
  2. package/package.json +3 -3
package/dist/tool.js CHANGED
@@ -22429,19 +22429,19 @@ toolsFactoryRepository.registerProjectToolFactory(new ApiWorkflowToolFactory);
22429
22429
  // package.json
22430
22430
  var package_default = {
22431
22431
  name: "@uipath/api-workflow-tool",
22432
- version: "0.1.10",
22432
+ version: "0.1.11",
22433
22433
  description: "Run UiPath API Workflows locally.",
22434
22434
  private: false,
22435
22435
  repository: {
22436
22436
  type: "git",
22437
- url: "https://github.com/UiPath/uipcli.git",
22437
+ url: "https://github.com/UiPath/cli.git",
22438
22438
  directory: "packages/api-workflow-tool"
22439
22439
  },
22440
22440
  publishConfig: {
22441
22441
  registry: "https://registry.npmjs.org/"
22442
22442
  },
22443
22443
  keywords: [
22444
- "uipcli-tool"
22444
+ "cli-tool"
22445
22445
  ],
22446
22446
  type: "module",
22447
22447
  main: "./dist/tool.js",
@@ -22482,6 +22482,7 @@ import { processContext } from "@uipath/common";
22482
22482
  var import_api_workflow_executor2 = __toESM(require_dist2(), 1);
22483
22483
  import { getLoginStatusAsync } from "@uipath/auth";
22484
22484
  import {
22485
+ catchError,
22485
22486
  FailureOutput,
22486
22487
  logger as logger2,
22487
22488
  OutputFormatter,
@@ -22592,51 +22593,61 @@ class WorkflowRunService {
22592
22593
  context.exit(1);
22593
22594
  return;
22594
22595
  }
22595
- let workflow;
22596
- try {
22597
- const raw = await fs.readFile(resolvedPath, "utf-8");
22598
- workflow = JSON.parse(raw ?? "");
22599
- } catch (error) {
22600
- OutputFormatter.error(new FailureOutput("Failure", `Failed to parse workflow file: ${error instanceof Error ? error.message : String(error)}`, "Ensure the file contains valid JSON."));
22596
+ const [readError, raw] = await catchError(fs.readFile(resolvedPath, "utf-8"));
22597
+ if (readError) {
22598
+ OutputFormatter.error(new FailureOutput("Failure", `Failed to parse workflow file: ${readError.message}`, "Ensure the file contains valid JSON."));
22599
+ context.exit(1);
22600
+ return;
22601
+ }
22602
+ const [parseError, workflow] = catchError(() => JSON.parse(raw ?? ""));
22603
+ if (parseError) {
22604
+ OutputFormatter.error(new FailureOutput("Failure", `Failed to parse workflow file: ${parseError.message}`, "Ensure the file contains valid JSON."));
22601
22605
  context.exit(1);
22602
22606
  return;
22603
22607
  }
22604
22608
  let input = {};
22605
22609
  if (options.inputArguments) {
22606
- try {
22607
- input = JSON.parse(options.inputArguments);
22608
- } catch (error) {
22609
- OutputFormatter.error(new FailureOutput("Failure", `Failed to parse --input-arguments JSON: ${error instanceof Error ? error.message : String(error)}`, `Provide valid JSON (e.g. '{"name": "World"}').`));
22610
+ const rawInput = options.inputArguments;
22611
+ const [inputParseError, parsedInput] = catchError(() => JSON.parse(rawInput));
22612
+ if (inputParseError) {
22613
+ OutputFormatter.error(new FailureOutput("Failure", `Failed to parse --input-arguments JSON: ${inputParseError.message}`, `Provide valid JSON (e.g. '{"name": "World"}').`));
22610
22614
  context.exit(1);
22611
22615
  return;
22612
22616
  }
22617
+ input = parsedInput;
22613
22618
  }
22614
22619
  const workflowLogger = createConsoleLogger();
22615
- try {
22616
- const workflowConfig = await this.buildWorkflowConfig(options.auth);
22617
- logger2.info(`
22618
- Running workflow: ${fs.path.basename(resolvedPath)}`);
22619
- if (workflowConfig.accessToken) {
22620
- logger2.info(`Auth: connected to ${workflowConfig.baseUrl}`);
22621
- } else {
22622
- logger2.info("Auth: local mode (no credentials)");
22623
- }
22624
- if (Object.keys(input).length > 0) {
22625
- logger2.info(`Input: ${JSON.stringify(input, null, 2)}`);
22626
- }
22627
- const result = await import_api_workflow_executor2.ServerlessWorkflowExecutor.execute(workflow, workflowConfig, input, { logger: workflowLogger });
22620
+ const [configError, workflowConfig] = await catchError(this.buildWorkflowConfig(options.auth));
22621
+ if (configError) {
22628
22622
  await workflowLogger.shutdown();
22629
- logger2.debug(`Raw response: ${JSON.stringify(result, null, 2)}`);
22630
- if (result.status === "Successful") {
22631
- const data = result.data ?? { message: "(no output)" };
22632
- OutputFormatter.success(new SuccessOutput("WorkflowRun", data));
22633
- } else {
22634
- OutputFormatter.error(new FailureOutput("Failure", result.errorMessage ?? "Unknown error", "Check the workflow definition and input parameters."));
22635
- context.exit(1);
22636
- }
22637
- } catch (error) {
22623
+ OutputFormatter.error(new FailureOutput("Failure", `Execution error: ${configError.message}`, "Check the workflow definition and try again with --log-level debug for more details."));
22624
+ context.exit(1);
22625
+ return;
22626
+ }
22627
+ logger2.info(`
22628
+ Running workflow: ${fs.path.basename(resolvedPath)}`);
22629
+ if (workflowConfig.accessToken) {
22630
+ logger2.info(`Auth: connected to ${workflowConfig.baseUrl}`);
22631
+ } else {
22632
+ logger2.info("Auth: local mode (no credentials)");
22633
+ }
22634
+ if (Object.keys(input).length > 0) {
22635
+ logger2.info(`Input: ${JSON.stringify(input, null, 2)}`);
22636
+ }
22637
+ const [execError, result] = await catchError(import_api_workflow_executor2.ServerlessWorkflowExecutor.execute(workflow, workflowConfig, input, { logger: workflowLogger }));
22638
+ if (execError) {
22638
22639
  await workflowLogger.shutdown();
22639
- OutputFormatter.error(new FailureOutput("Failure", `Execution error: ${error instanceof Error ? error.message : String(error)}`, "Check the workflow definition and try again with --log-level debug for more details."));
22640
+ OutputFormatter.error(new FailureOutput("Failure", `Execution error: ${execError.message}`, "Check the workflow definition and try again with --log-level debug for more details."));
22641
+ context.exit(1);
22642
+ return;
22643
+ }
22644
+ await workflowLogger.shutdown();
22645
+ logger2.debug(`Raw response: ${JSON.stringify(result, null, 2)}`);
22646
+ if (result.status === "Successful") {
22647
+ const data = result.data ?? { message: "(no output)" };
22648
+ OutputFormatter.success(new SuccessOutput("WorkflowRun", data));
22649
+ } else {
22650
+ OutputFormatter.error(new FailureOutput("Failure", result.errorMessage ?? "Unknown error", "Check the workflow definition and input parameters."));
22640
22651
  context.exit(1);
22641
22652
  }
22642
22653
  }
@@ -22652,24 +22663,23 @@ Running workflow: ${fs.path.basename(resolvedPath)}`);
22652
22663
  logger2.debug("Auth disabled via --no-auth flag");
22653
22664
  return localConfig;
22654
22665
  }
22655
- try {
22656
- const status = await getLoginStatusAsync({
22657
- ensureTokenValidityMinutes: 10
22658
- });
22659
- if (status.loginStatus === "Logged in" && status.accessToken) {
22660
- return {
22661
- organizationId: status.organizationId ?? "local",
22662
- tenantId: status.tenantId ?? "local",
22663
- accessToken: status.accessToken,
22664
- baseUrl: status.baseUrl ?? "",
22665
- source: "uipcli"
22666
- };
22667
- }
22668
- logger2.debug("Not logged in, using local mode");
22669
- return localConfig;
22670
- } catch {
22666
+ const [error, status] = await catchError(getLoginStatusAsync({
22667
+ ensureTokenValidityMinutes: 10
22668
+ }));
22669
+ if (error) {
22671
22670
  return localConfig;
22672
22671
  }
22672
+ if (status.loginStatus === "Logged in" && status.accessToken) {
22673
+ return {
22674
+ organizationId: status.organizationId ?? "local",
22675
+ tenantId: status.tenantId ?? "local",
22676
+ accessToken: status.accessToken,
22677
+ baseUrl: status.baseUrl ?? "",
22678
+ source: "uipcli"
22679
+ };
22680
+ }
22681
+ logger2.debug("Not logged in, using local mode");
22682
+ return localConfig;
22673
22683
  }
22674
22684
  }
22675
22685
 
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@uipath/api-workflow-tool",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Run UiPath API Workflows locally.",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/UiPath/uipcli.git",
8
+ "url": "https://github.com/UiPath/cli.git",
9
9
  "directory": "packages/api-workflow-tool"
10
10
  },
11
11
  "publishConfig": {
12
12
  "registry": "https://registry.npmjs.org/"
13
13
  },
14
14
  "keywords": [
15
- "uipcli-tool"
15
+ "cli-tool"
16
16
  ],
17
17
  "type": "module",
18
18
  "main": "./dist/tool.js",