@uipath/integrationservice-sdk 1.203.0-preview.233 → 1.203.0-preview.237

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/index.js +225 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -65337,7 +65337,7 @@ var package_default = {
65337
65337
  name: "@uipath/integrationservice-sdk",
65338
65338
  author: "UiPath",
65339
65339
  license: "SEE LICENSE IN LICENSE.txt",
65340
- version: "1.203.0-preview.233",
65340
+ version: "1.203.0-preview.237",
65341
65341
  repository: {
65342
65342
  type: "git",
65343
65343
  url: "https://github.com/UiPath/cli.git",
@@ -89044,7 +89044,165 @@ class FilterImplicitLimitError extends Error {
89044
89044
  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).";
89045
89045
  }
89046
89046
  }
89047
- function applyFilter(data, filter) {
89047
+ function countRecords(data) {
89048
+ if (Array.isArray(data))
89049
+ return data.length;
89050
+ return data == null ? 0 : 1;
89051
+ }
89052
+ function availableFields(data) {
89053
+ const records = Array.isArray(data) ? data : [data];
89054
+ const keys2 = new Set;
89055
+ for (const record2 of records) {
89056
+ if (record2 && typeof record2 === "object" && !Array.isArray(record2)) {
89057
+ for (const key of Object.keys(record2))
89058
+ keys2.add(key);
89059
+ }
89060
+ }
89061
+ return [...keys2];
89062
+ }
89063
+ function decodeQuotedIdentifier(whole, inner) {
89064
+ const [error46, decoded] = catchError3(() => JSON.parse(whole));
89065
+ if (!error46 && typeof decoded === "string")
89066
+ return decoded;
89067
+ return inner.replace(/\\(.)/g, "$1");
89068
+ }
89069
+ function referencedFields(filter) {
89070
+ const top = new Set;
89071
+ const nested = new Set;
89072
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
89073
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
89074
+ const quoted = [];
89075
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
89076
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
89077
+ if (!isAlias) {
89078
+ quoted.push({
89079
+ name: decodeQuotedIdentifier(whole, name),
89080
+ index,
89081
+ tail: isPathTail(withoutValueLiterals, index)
89082
+ });
89083
+ }
89084
+ return `"${" ".repeat(whole.length - 2)}"`;
89085
+ });
89086
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
89087
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
89088
+ const place = (name, index, tail) => {
89089
+ if (tail || index >= rootEnd)
89090
+ nested.add(name);
89091
+ else
89092
+ top.add(name);
89093
+ };
89094
+ for (const entry of quoted)
89095
+ place(entry.name, entry.index, entry.tail);
89096
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
89097
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
89098
+ for (const match2 of identifiers) {
89099
+ const [, name, trailing] = match2;
89100
+ if (trailing || reserved.has(name))
89101
+ continue;
89102
+ place(name, match2.index, isPathTail(withoutLiterals, match2.index));
89103
+ }
89104
+ return {
89105
+ top: [...top],
89106
+ nested: [...nested].filter((name) => !top.has(name)),
89107
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
89108
+ };
89109
+ }
89110
+ function appearsBelowTopLevel(data, name) {
89111
+ let budget = 2000;
89112
+ const visit = (value, depth) => {
89113
+ if (budget-- <= 0 || depth > 4)
89114
+ return false;
89115
+ if (value === null || typeof value !== "object")
89116
+ return false;
89117
+ if (Array.isArray(value))
89118
+ return value.some((entry) => visit(entry, depth));
89119
+ const record2 = value;
89120
+ if (depth > 0 && Object.hasOwn(record2, name))
89121
+ return true;
89122
+ return Object.values(record2).some((entry) => visit(entry, depth + 1));
89123
+ };
89124
+ return visit(data, 0);
89125
+ }
89126
+ function alwaysNullKeys(records) {
89127
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
89128
+ if (objects.length === 0 || objects.length !== records.length)
89129
+ return [];
89130
+ const keys2 = [...new Set(objects.flatMap((o) => Object.keys(o)))];
89131
+ if (keys2.length === 0)
89132
+ return [];
89133
+ const nullKeys = keys2.filter((key) => objects.every((record2) => record2[key] === null));
89134
+ return nullKeys.length === keys2.length ? nullKeys : [];
89135
+ }
89136
+ function carriesOnlyNulls(value) {
89137
+ if (value === null)
89138
+ return true;
89139
+ if (Array.isArray(value)) {
89140
+ return value.length > 0 && value.every(carriesOnlyNulls);
89141
+ }
89142
+ if (typeof value === "object" && value !== undefined) {
89143
+ const values = Object.values(value);
89144
+ return values.length > 0 && values.every(carriesOnlyNulls);
89145
+ }
89146
+ return false;
89147
+ }
89148
+ function nameList(names, cap2 = 12) {
89149
+ const shown = names.slice(0, cap2).map((n2) => `\`${n2}\``);
89150
+ const rest = names.length - shown.length;
89151
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
89152
+ }
89153
+ function buildFilterWarning(filter, data, outcome) {
89154
+ const present = availableFields(data);
89155
+ const refs = referencedFields(filter);
89156
+ const unknown2 = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
89157
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
89158
+ const count = countRecords(data);
89159
+ const scope = `${count} record(s)`;
89160
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
89161
+ 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" : "";
89162
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
89163
+ let detail;
89164
+ let lede;
89165
+ if (outcome.kind === "null-elements") {
89166
+ lede = "returned only null values";
89167
+ const projected = `all ${outcome.count} of the elements it projected are null`;
89168
+ if (unknown2.length > 0) {
89169
+ detail = `${projected}, because ${isNotAField(unknown2)}`;
89170
+ } else if (unchecked.length > 0) {
89171
+ detail = withSoundness(projected);
89172
+ } else {
89173
+ 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`;
89174
+ }
89175
+ } else if (outcome.kind === "null-rows") {
89176
+ lede = "returned only null values";
89177
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
89178
+ detail = unknown2.length > 0 ? `${projected}, because ${isNotAField(unknown2)}` : withSoundness(projected);
89179
+ } else if (outcome.kind === "null-values") {
89180
+ lede = "returned only null values";
89181
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
89182
+ const sameSet = unknown2.length === outcome.keys.length && outcome.keys.every((k) => unknown2.includes(k));
89183
+ if (sameSet) {
89184
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
89185
+ } else if (unknown2.length > 0) {
89186
+ detail = `${projected}, because ${isNotAField(unknown2)}`;
89187
+ } else {
89188
+ detail = withSoundness(`${projected} on all ${scope}`);
89189
+ }
89190
+ } else {
89191
+ lede = "returned nothing";
89192
+ if (unknown2.length > 0) {
89193
+ detail = isNotAField(unknown2);
89194
+ } else {
89195
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
89196
+ detail = withSoundness(`${selection} — it read ${scope}`);
89197
+ }
89198
+ }
89199
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
89200
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
89201
+ }
89202
+ function appendWarning(existing, note) {
89203
+ return existing ? `${existing} ${note}` : note;
89204
+ }
89205
+ function applyFilter(data, filter, onWarning) {
89048
89206
  const codec2 = requireJmespath();
89049
89207
  let result;
89050
89208
  try {
@@ -89052,9 +89210,34 @@ function applyFilter(data, filter) {
89052
89210
  } catch (err) {
89053
89211
  throw new FilterEvaluationError(filter, err);
89054
89212
  }
89055
- if (result == null)
89213
+ const inputCount = countRecords(data);
89214
+ const warn = (outcome) => {
89215
+ if (inputCount === 0)
89216
+ return;
89217
+ const note = buildFilterWarning(filter, data, outcome);
89218
+ getOutputSink().writeErr(`[WARN] ${note}
89219
+ `);
89220
+ onWarning?.(note);
89221
+ };
89222
+ const warnIfAllNull = (records) => {
89223
+ const keys2 = alwaysNullKeys(records);
89224
+ if (keys2.length > 0)
89225
+ warn({ kind: "null-values", keys: keys2 });
89226
+ };
89227
+ if (result == null) {
89228
+ warn({ kind: "empty" });
89056
89229
  return [];
89230
+ }
89057
89231
  if (Array.isArray(result)) {
89232
+ if (result.length === 0) {
89233
+ warn({ kind: "empty" });
89234
+ } else if (result.every((entry) => entry === null)) {
89235
+ warn({ kind: "null-elements", count: result.length });
89236
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
89237
+ warn({ kind: "null-rows", count: result.length });
89238
+ } else {
89239
+ warnIfAllNull(result);
89240
+ }
89058
89241
  if (result.length > 0 && typeof result[0] !== "object") {
89059
89242
  const fieldMatch = filter.match(/\.(\w+)$/);
89060
89243
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -89062,10 +89245,30 @@ function applyFilter(data, filter) {
89062
89245
  }
89063
89246
  return result;
89064
89247
  }
89065
- if (typeof result === "object")
89248
+ if (typeof result === "object") {
89249
+ warnIfAllNull([result]);
89066
89250
  return result;
89251
+ }
89067
89252
  return { Value: result };
89068
89253
  }
89254
+ function filterFailureData(envelope) {
89255
+ const filter = getOutputFilter();
89256
+ const data = envelope.Data;
89257
+ if (!filter || data == null)
89258
+ return;
89259
+ let note;
89260
+ const [filterError, filtered] = catchError3(() => applyFilter(data, filter, (n2) => {
89261
+ note = n2;
89262
+ }));
89263
+ if (filterError) {
89264
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
89265
+ return;
89266
+ }
89267
+ envelope.Data = filtered;
89268
+ if (note) {
89269
+ envelope.Warning = appendWarning(envelope.Warning, note);
89270
+ }
89271
+ }
89069
89272
  function defaultErrorCodeForResult(result) {
89070
89273
  switch (result) {
89071
89274
  case RESULTS.AuthenticationError:
@@ -89148,8 +89351,14 @@ var OutputFormatter;
89148
89351
  }
89149
89352
  const filter = getOutputFilter();
89150
89353
  if (filter) {
89151
- const filtered = applyFilter(data.Data, filter);
89354
+ let note;
89355
+ const filtered = applyFilter(data.Data, filter, (n2) => {
89356
+ note = n2;
89357
+ });
89152
89358
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
89359
+ if (note) {
89360
+ data.Warning = appendWarning(data.Warning, note);
89361
+ }
89153
89362
  }
89154
89363
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
89155
89364
  }
@@ -89177,6 +89386,7 @@ var OutputFormatter;
89177
89386
  delete envelope.TelemetryErrorClass;
89178
89387
  delete envelope.TelemetryTerminalOutcome;
89179
89388
  delete envelope.TelemetryTerminalSignal;
89389
+ filterFailureData(envelope);
89180
89390
  if (!suppressTelemetry) {
89181
89391
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
89182
89392
  result: data.Result,
@@ -89225,13 +89435,20 @@ var OutputFormatter;
89225
89435
  OutputFormatter.log = log;
89226
89436
  function formatToString(data) {
89227
89437
  const filter = getOutputFilter();
89438
+ const envelope = data;
89228
89439
  if ("Data" in data && data.Data != null) {
89229
89440
  data.Data = normalizeDataKeys(data.Data);
89230
89441
  if (filter) {
89231
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
89442
+ let note;
89443
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n2) => {
89444
+ note = n2;
89445
+ }));
89446
+ if (note) {
89447
+ envelope.Warning = appendWarning(envelope.Warning, note);
89448
+ }
89232
89449
  }
89233
89450
  }
89234
- const output = normalizeOutputKeys(data);
89451
+ const output = normalizeOutputKeys(envelope);
89235
89452
  const lines = [];
89236
89453
  const sink = getOutputSink();
89237
89454
  printOutput(output, getOutputFormat(), (msg) => {
@@ -91724,4 +91941,4 @@ export {
91724
91941
  validateRequiredParameters
91725
91942
  };
91726
91943
 
91727
- //# debugId=299889398729B16F64756E2164756E21
91944
+ //# debugId=A2D690FA304AD12464756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/integrationservice-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.203.0-preview.233",
5
+ "version": "1.203.0-preview.237",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/UiPath/cli.git",
@@ -31,5 +31,5 @@
31
31
  "dependencies": {
32
32
  "@uipath/integration-service-design-time": "0.25.2"
33
33
  },
34
- "gitHead": "641614a6f9817662baaf51dabdebbfa2a9334b1b"
34
+ "gitHead": "4ad3e17a66f2c7fb7fe1f0e3e04a5b6175a0a9a3"
35
35
  }