@uipath/function-tool 1.203.0-preview.235 → 1.203.0-preview.240

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.
@@ -762,6 +762,12 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
762
762
  identity.clientId = clientId;
763
763
  return identity;
764
764
  };
765
+ var pickScopes = (claims) => {
766
+ const raw = claims?.scope;
767
+ const scopes = Array.isArray(raw) ? raw.filter((entry) => asString(entry) !== undefined) : typeof raw === "string" ? raw.split(/\s+/).filter(Boolean) : [];
768
+ return scopes.length > 0 ? scopes : undefined;
769
+ };
770
+ var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
765
771
 
766
772
  // ../auth/src/envAuth.ts
767
773
  var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
@@ -2499,6 +2505,7 @@ export {
2499
2505
  parseAuthFlow,
2500
2506
  parseJWT,
2501
2507
  readAuthFromEnv,
2508
+ readTokenScopes,
2502
2509
  refreshAccessToken,
2503
2510
  refreshTokenFingerprint,
2504
2511
  registerRobotClientLoader,
@@ -2515,4 +2522,4 @@ export {
2515
2522
  setAuthFileConfig
2516
2523
  };
2517
2524
 
2518
- //# debugId=7A3E8DCE180A960B64756E2164756E21
2525
+ //# debugId=1207D8EF430B6FC564756E2164756E21
@@ -10,7 +10,7 @@ import {
10
10
  logger,
11
11
  summarizePlatformBody,
12
12
  unsupportedSolutionProjectType
13
- } from "./packager-tool-9331shqx.js";
13
+ } from "./packager-tool-awxx02vb.js";
14
14
  import"./packager-tool-g0hcxnae.js";
15
15
  import"./packager-tool-1de529jm.js";
16
16
 
@@ -314,7 +314,7 @@ var package_default = {
314
314
  name: "@uipath/solution-sdk",
315
315
  author: "UiPath",
316
316
  license: "SEE LICENSE IN LICENSE.txt",
317
- version: "1.203.0-preview.235",
317
+ version: "1.203.0-preview.240",
318
318
  repository: {
319
319
  type: "git",
320
320
  url: "https://github.com/UiPath/cli.git",
@@ -5794,4 +5794,4 @@ export {
5794
5794
  uploadOrOverwriteSolution
5795
5795
  };
5796
5796
 
5797
- //# debugId=89520B292CF0A9FA64756E2164756E21
5797
+ //# debugId=15D53766D0ABA94364756E2164756E21
@@ -4369,7 +4369,165 @@ class FilterImplicitLimitError extends Error {
4369
4369
  this.instructions = "Pass --limit <n> to choose how many records the filter applies to. " + "To filter over all records, pass the command's maximum accepted --limit (see the option's description in --help).";
4370
4370
  }
4371
4371
  }
4372
- function applyFilter(data, filter) {
4372
+ function countRecords(data) {
4373
+ if (Array.isArray(data))
4374
+ return data.length;
4375
+ return data == null ? 0 : 1;
4376
+ }
4377
+ function availableFields(data) {
4378
+ const records = Array.isArray(data) ? data : [data];
4379
+ const keys = new Set;
4380
+ for (const record of records) {
4381
+ if (record && typeof record === "object" && !Array.isArray(record)) {
4382
+ for (const key of Object.keys(record))
4383
+ keys.add(key);
4384
+ }
4385
+ }
4386
+ return [...keys];
4387
+ }
4388
+ function decodeQuotedIdentifier(whole, inner) {
4389
+ const [error, decoded] = catchError(() => JSON.parse(whole));
4390
+ if (!error && typeof decoded === "string")
4391
+ return decoded;
4392
+ return inner.replace(/\\(.)/g, "$1");
4393
+ }
4394
+ function referencedFields(filter) {
4395
+ const top = new Set;
4396
+ const nested = new Set;
4397
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
4398
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
4399
+ const quoted = [];
4400
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
4401
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
4402
+ if (!isAlias) {
4403
+ quoted.push({
4404
+ name: decodeQuotedIdentifier(whole, name),
4405
+ index,
4406
+ tail: isPathTail(withoutValueLiterals, index)
4407
+ });
4408
+ }
4409
+ return `"${" ".repeat(whole.length - 2)}"`;
4410
+ });
4411
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
4412
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
4413
+ const place = (name, index, tail) => {
4414
+ if (tail || index >= rootEnd)
4415
+ nested.add(name);
4416
+ else
4417
+ top.add(name);
4418
+ };
4419
+ for (const entry of quoted)
4420
+ place(entry.name, entry.index, entry.tail);
4421
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
4422
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
4423
+ for (const match of identifiers) {
4424
+ const [, name, trailing] = match;
4425
+ if (trailing || reserved.has(name))
4426
+ continue;
4427
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
4428
+ }
4429
+ return {
4430
+ top: [...top],
4431
+ nested: [...nested].filter((name) => !top.has(name)),
4432
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
4433
+ };
4434
+ }
4435
+ function appearsBelowTopLevel(data, name) {
4436
+ let budget = 2000;
4437
+ const visit = (value, depth) => {
4438
+ if (budget-- <= 0 || depth > 4)
4439
+ return false;
4440
+ if (value === null || typeof value !== "object")
4441
+ return false;
4442
+ if (Array.isArray(value))
4443
+ return value.some((entry) => visit(entry, depth));
4444
+ const record = value;
4445
+ if (depth > 0 && Object.hasOwn(record, name))
4446
+ return true;
4447
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
4448
+ };
4449
+ return visit(data, 0);
4450
+ }
4451
+ function alwaysNullKeys(records) {
4452
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
4453
+ if (objects.length === 0 || objects.length !== records.length)
4454
+ return [];
4455
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
4456
+ if (keys.length === 0)
4457
+ return [];
4458
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
4459
+ return nullKeys.length === keys.length ? nullKeys : [];
4460
+ }
4461
+ function carriesOnlyNulls(value) {
4462
+ if (value === null)
4463
+ return true;
4464
+ if (Array.isArray(value)) {
4465
+ return value.length > 0 && value.every(carriesOnlyNulls);
4466
+ }
4467
+ if (typeof value === "object" && value !== undefined) {
4468
+ const values = Object.values(value);
4469
+ return values.length > 0 && values.every(carriesOnlyNulls);
4470
+ }
4471
+ return false;
4472
+ }
4473
+ function nameList(names, cap2 = 12) {
4474
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
4475
+ const rest = names.length - shown.length;
4476
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
4477
+ }
4478
+ function buildFilterWarning(filter, data, outcome) {
4479
+ const present = availableFields(data);
4480
+ const refs = referencedFields(filter);
4481
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
4482
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
4483
+ const count = countRecords(data);
4484
+ const scope = `${count} record(s)`;
4485
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
4486
+ const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
4487
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
4488
+ let detail;
4489
+ let lede;
4490
+ if (outcome.kind === "null-elements") {
4491
+ lede = "returned only null values";
4492
+ const projected = `all ${outcome.count} of the elements it projected are null`;
4493
+ if (unknown.length > 0) {
4494
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4495
+ } else if (unchecked.length > 0) {
4496
+ detail = withSoundness(projected);
4497
+ } else {
4498
+ detail = `${projected}, and every field it names exists — a multi-select list ` + `(\`[A, B]\`) reads each entry against \`Data\` itself, so on a list ` + `result use \`[].[A, B]\` or \`[].{a: A, b: B}\` to read the records`;
4499
+ }
4500
+ } else if (outcome.kind === "null-rows") {
4501
+ lede = "returned only null values";
4502
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
4503
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
4504
+ } else if (outcome.kind === "null-values") {
4505
+ lede = "returned only null values";
4506
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
4507
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
4508
+ if (sameSet) {
4509
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
4510
+ } else if (unknown.length > 0) {
4511
+ detail = `${projected}, because ${isNotAField(unknown)}`;
4512
+ } else {
4513
+ detail = withSoundness(`${projected} on all ${scope}`);
4514
+ }
4515
+ } else {
4516
+ lede = "returned nothing";
4517
+ if (unknown.length > 0) {
4518
+ detail = isNotAField(unknown);
4519
+ } else {
4520
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
4521
+ detail = withSoundness(`${selection} — it read ${scope}`);
4522
+ }
4523
+ }
4524
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
4525
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
4526
+ }
4527
+ function appendWarning(existing, note) {
4528
+ return existing ? `${existing} ${note}` : note;
4529
+ }
4530
+ function applyFilter(data, filter, onWarning) {
4373
4531
  const codec = requireJmespath();
4374
4532
  let result;
4375
4533
  try {
@@ -4377,9 +4535,34 @@ function applyFilter(data, filter) {
4377
4535
  } catch (err) {
4378
4536
  throw new FilterEvaluationError(filter, err);
4379
4537
  }
4380
- if (result == null)
4538
+ const inputCount = countRecords(data);
4539
+ const warn = (outcome) => {
4540
+ if (inputCount === 0)
4541
+ return;
4542
+ const note = buildFilterWarning(filter, data, outcome);
4543
+ getOutputSink().writeErr(`[WARN] ${note}
4544
+ `);
4545
+ onWarning?.(note);
4546
+ };
4547
+ const warnIfAllNull = (records) => {
4548
+ const keys = alwaysNullKeys(records);
4549
+ if (keys.length > 0)
4550
+ warn({ kind: "null-values", keys });
4551
+ };
4552
+ if (result == null) {
4553
+ warn({ kind: "empty" });
4381
4554
  return [];
4555
+ }
4382
4556
  if (Array.isArray(result)) {
4557
+ if (result.length === 0) {
4558
+ warn({ kind: "empty" });
4559
+ } else if (result.every((entry) => entry === null)) {
4560
+ warn({ kind: "null-elements", count: result.length });
4561
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
4562
+ warn({ kind: "null-rows", count: result.length });
4563
+ } else {
4564
+ warnIfAllNull(result);
4565
+ }
4383
4566
  if (result.length > 0 && typeof result[0] !== "object") {
4384
4567
  const fieldMatch = filter.match(/\.(\w+)$/);
4385
4568
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -4387,10 +4570,30 @@ function applyFilter(data, filter) {
4387
4570
  }
4388
4571
  return result;
4389
4572
  }
4390
- if (typeof result === "object")
4573
+ if (typeof result === "object") {
4574
+ warnIfAllNull([result]);
4391
4575
  return result;
4576
+ }
4392
4577
  return { Value: result };
4393
4578
  }
4579
+ function filterFailureData(envelope) {
4580
+ const filter = getOutputFilter();
4581
+ const data = envelope.Data;
4582
+ if (!filter || data == null)
4583
+ return;
4584
+ let note;
4585
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
4586
+ note = n;
4587
+ }));
4588
+ if (filterError) {
4589
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
4590
+ return;
4591
+ }
4592
+ envelope.Data = filtered;
4593
+ if (note) {
4594
+ envelope.Warning = appendWarning(envelope.Warning, note);
4595
+ }
4596
+ }
4394
4597
  function defaultErrorCodeForResult(result) {
4395
4598
  switch (result) {
4396
4599
  case RESULTS.AuthenticationError:
@@ -4473,8 +4676,14 @@ var OutputFormatter;
4473
4676
  }
4474
4677
  const filter = getOutputFilter();
4475
4678
  if (filter) {
4476
- const filtered = applyFilter(data.Data, filter);
4679
+ let note;
4680
+ const filtered = applyFilter(data.Data, filter, (n) => {
4681
+ note = n;
4682
+ });
4477
4683
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
4684
+ if (note) {
4685
+ data.Warning = appendWarning(data.Warning, note);
4686
+ }
4478
4687
  }
4479
4688
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
4480
4689
  }
@@ -4502,6 +4711,7 @@ var OutputFormatter;
4502
4711
  delete envelope.TelemetryErrorClass;
4503
4712
  delete envelope.TelemetryTerminalOutcome;
4504
4713
  delete envelope.TelemetryTerminalSignal;
4714
+ filterFailureData(envelope);
4505
4715
  if (!suppressTelemetry) {
4506
4716
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
4507
4717
  result: data.Result,
@@ -4550,13 +4760,20 @@ var OutputFormatter;
4550
4760
  OutputFormatter.log = log;
4551
4761
  function formatToString(data) {
4552
4762
  const filter = getOutputFilter();
4763
+ const envelope = data;
4553
4764
  if ("Data" in data && data.Data != null) {
4554
4765
  data.Data = normalizeDataKeys(data.Data);
4555
4766
  if (filter) {
4556
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
4767
+ let note;
4768
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
4769
+ note = n;
4770
+ }));
4771
+ if (note) {
4772
+ envelope.Warning = appendWarning(envelope.Warning, note);
4773
+ }
4557
4774
  }
4558
4775
  }
4559
- const output = normalizeOutputKeys(data);
4776
+ const output = normalizeOutputKeys(envelope);
4560
4777
  const lines = [];
4561
4778
  const sink = getOutputSink();
4562
4779
  printOutput(output, getOutputFormat(), (msg) => {
@@ -5464,4 +5681,4 @@ function trackShipSucceeded(payload) {
5464
5681
  var factorySlot = singleton("PackagerFactoryProvider");
5465
5682
  export { catchError, logger, RESULTS, OutputFormatter, summarizePlatformBody, Option, processContext, stripHostGlobalOptions, createHiddenDeprecatedTenantOption, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, unsupportedSolutionProjectType, trackShipSucceeded };
5466
5683
 
5467
- //# debugId=0E74615FB54AC2F464756E2164756E21
5684
+ //# debugId=7CFDB3A2C18A0DDC64756E2164756E21
package/dist/tool.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  processContext,
8
8
  stripHostGlobalOptions,
9
9
  trackShipSucceeded
10
- } from "./packager-tool-9331shqx.js";
10
+ } from "./packager-tool-awxx02vb.js";
11
11
  import {
12
12
  getFileSystem
13
13
  } from "./packager-tool-g0hcxnae.js";
@@ -19,7 +19,7 @@ var package_default = {
19
19
  name: "@uipath/function-tool",
20
20
  author: "UiPath",
21
21
  license: "SEE LICENSE IN LICENSE.txt",
22
- version: "1.203.0-preview.235",
22
+ version: "1.203.0-preview.240",
23
23
  description: "UiPath CLI tool for JS/TS and Python Functions — thin passthrough to uipath-functions / uipath",
24
24
  keywords: [
25
25
  "uipcli-tool",
@@ -185,7 +185,7 @@ function namesRunTarget(arg) {
185
185
  import { spawn } from "node:child_process";
186
186
  async function loadGlobalAuthEnv() {
187
187
  try {
188
- const { loadEnvFileAsync, resolveEnvFilePathAsync } = await import("./index-t0pqjb4h.js");
188
+ const { loadEnvFileAsync, resolveEnvFilePathAsync } = await import("./index-b3kekctx.js");
189
189
  const { absolutePath } = await resolveEnvFilePathAsync();
190
190
  if (!absolutePath) {
191
191
  return {};
@@ -370,7 +370,7 @@ function flagsToDrop(verb) {
370
370
  var fs4 = getFileSystem();
371
371
  async function spawnPythonCli(args, cwd) {
372
372
  const uipathExe = await resolveUipathPythonExe() ?? "uipath";
373
- const { getAuthEnv } = await import("./index-t0pqjb4h.js");
373
+ const { getAuthEnv } = await import("./index-b3kekctx.js");
374
374
  const { authEnv, loginStatus } = await getAuthEnv();
375
375
  if (!loginStatus) {
376
376
  logger.debug("Auth unavailable, continuing without credentials.");
@@ -488,7 +488,7 @@ async function dispatch(rawArgs) {
488
488
  }
489
489
  }
490
490
  async function reportSolutionRegistration(projectDir, skipSolutionRegistration) {
491
- const { tryRegisterProjectInParentSolution } = await import("./index-tgx1qzea.js");
491
+ const { tryRegisterProjectInParentSolution } = await import("./index-w3pscbp7.js");
492
492
  const registration = await tryRegisterProjectInParentSolution(fs5, projectDir, {
493
493
  skipRegistration: skipSolutionRegistration
494
494
  });
@@ -671,4 +671,4 @@ export {
671
671
  registerCommands
672
672
  };
673
673
 
674
- //# debugId=CABC5498CAD54C3E64756E2164756E21
674
+ //# debugId=9F58640D994B847064756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/function-tool",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.235",
5
+ "version": "1.203.0-preview.240",
6
6
  "description": "UiPath CLI tool for JS/TS and Python Functions — thin passthrough to uipath-functions / uipath",
7
7
  "keywords": [
8
8
  "uipcli-tool",
@@ -35,5 +35,5 @@
35
35
  "dependencies": {
36
36
  "typescript": "^5.7.0"
37
37
  },
38
- "gitHead": "4788b04c17a4429e5a994af2c3eba3898d1c4b13"
38
+ "gitHead": "95409ea61d359dff5465afaf59cb3a5efae542af"
39
39
  }