@uipath/maestro-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.
package/dist/index.js CHANGED
@@ -8280,7 +8280,165 @@ function requireJmespath() {
8280
8280
  }
8281
8281
  return codec;
8282
8282
  }
8283
- function applyFilter(data2, filter) {
8283
+ function countRecords(data2) {
8284
+ if (Array.isArray(data2))
8285
+ return data2.length;
8286
+ return data2 == null ? 0 : 1;
8287
+ }
8288
+ function availableFields(data2) {
8289
+ const records = Array.isArray(data2) ? data2 : [data2];
8290
+ const keys = new Set;
8291
+ for (const record of records) {
8292
+ if (record && typeof record === "object" && !Array.isArray(record)) {
8293
+ for (const key of Object.keys(record))
8294
+ keys.add(key);
8295
+ }
8296
+ }
8297
+ return [...keys];
8298
+ }
8299
+ function decodeQuotedIdentifier(whole, inner) {
8300
+ const [error, decoded] = catchError(() => JSON.parse(whole));
8301
+ if (!error && typeof decoded === "string")
8302
+ return decoded;
8303
+ return inner.replace(/\\(.)/g, "$1");
8304
+ }
8305
+ function referencedFields(filter) {
8306
+ const top = new Set;
8307
+ const nested = new Set;
8308
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
8309
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
8310
+ const quoted = [];
8311
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
8312
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
8313
+ if (!isAlias) {
8314
+ quoted.push({
8315
+ name: decodeQuotedIdentifier(whole, name),
8316
+ index,
8317
+ tail: isPathTail(withoutValueLiterals, index)
8318
+ });
8319
+ }
8320
+ return `"${" ".repeat(whole.length - 2)}"`;
8321
+ });
8322
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
8323
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
8324
+ const place = (name, index, tail) => {
8325
+ if (tail || index >= rootEnd)
8326
+ nested.add(name);
8327
+ else
8328
+ top.add(name);
8329
+ };
8330
+ for (const entry of quoted)
8331
+ place(entry.name, entry.index, entry.tail);
8332
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
8333
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
8334
+ for (const match of identifiers) {
8335
+ const [, name, trailing] = match;
8336
+ if (trailing || reserved.has(name))
8337
+ continue;
8338
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
8339
+ }
8340
+ return {
8341
+ top: [...top],
8342
+ nested: [...nested].filter((name) => !top.has(name)),
8343
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
8344
+ };
8345
+ }
8346
+ function appearsBelowTopLevel(data2, name) {
8347
+ let budget = 2000;
8348
+ const visit = (value, depth) => {
8349
+ if (budget-- <= 0 || depth > 4)
8350
+ return false;
8351
+ if (value === null || typeof value !== "object")
8352
+ return false;
8353
+ if (Array.isArray(value))
8354
+ return value.some((entry) => visit(entry, depth));
8355
+ const record = value;
8356
+ if (depth > 0 && Object.hasOwn(record, name))
8357
+ return true;
8358
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
8359
+ };
8360
+ return visit(data2, 0);
8361
+ }
8362
+ function alwaysNullKeys(records) {
8363
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
8364
+ if (objects.length === 0 || objects.length !== records.length)
8365
+ return [];
8366
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
8367
+ if (keys.length === 0)
8368
+ return [];
8369
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
8370
+ return nullKeys.length === keys.length ? nullKeys : [];
8371
+ }
8372
+ function carriesOnlyNulls(value) {
8373
+ if (value === null)
8374
+ return true;
8375
+ if (Array.isArray(value)) {
8376
+ return value.length > 0 && value.every(carriesOnlyNulls);
8377
+ }
8378
+ if (typeof value === "object" && value !== undefined) {
8379
+ const values = Object.values(value);
8380
+ return values.length > 0 && values.every(carriesOnlyNulls);
8381
+ }
8382
+ return false;
8383
+ }
8384
+ function nameList(names, cap2 = 12) {
8385
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
8386
+ const rest = names.length - shown.length;
8387
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
8388
+ }
8389
+ function buildFilterWarning(filter, data2, outcome) {
8390
+ const present = availableFields(data2);
8391
+ const refs = referencedFields(filter);
8392
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data2, name));
8393
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
8394
+ const count = countRecords(data2);
8395
+ const scope = `${count} record(s)`;
8396
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
8397
+ 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" : "";
8398
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
8399
+ let detail;
8400
+ let lede;
8401
+ if (outcome.kind === "null-elements") {
8402
+ lede = "returned only null values";
8403
+ const projected = `all ${outcome.count} of the elements it projected are null`;
8404
+ if (unknown.length > 0) {
8405
+ detail = `${projected}, because ${isNotAField(unknown)}`;
8406
+ } else if (unchecked.length > 0) {
8407
+ detail = withSoundness(projected);
8408
+ } else {
8409
+ 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`;
8410
+ }
8411
+ } else if (outcome.kind === "null-rows") {
8412
+ lede = "returned only null values";
8413
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
8414
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
8415
+ } else if (outcome.kind === "null-values") {
8416
+ lede = "returned only null values";
8417
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
8418
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
8419
+ if (sameSet) {
8420
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
8421
+ } else if (unknown.length > 0) {
8422
+ detail = `${projected}, because ${isNotAField(unknown)}`;
8423
+ } else {
8424
+ detail = withSoundness(`${projected} on all ${scope}`);
8425
+ }
8426
+ } else {
8427
+ lede = "returned nothing";
8428
+ if (unknown.length > 0) {
8429
+ detail = isNotAField(unknown);
8430
+ } else {
8431
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
8432
+ detail = withSoundness(`${selection} — it read ${scope}`);
8433
+ }
8434
+ }
8435
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
8436
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
8437
+ }
8438
+ function appendWarning(existing, note) {
8439
+ return existing ? `${existing} ${note}` : note;
8440
+ }
8441
+ function applyFilter(data2, filter, onWarning) {
8284
8442
  const codec = requireJmespath();
8285
8443
  let result;
8286
8444
  try {
@@ -8288,9 +8446,34 @@ function applyFilter(data2, filter) {
8288
8446
  } catch (err) {
8289
8447
  throw new FilterEvaluationError(filter, err);
8290
8448
  }
8291
- if (result == null)
8449
+ const inputCount = countRecords(data2);
8450
+ const warn = (outcome) => {
8451
+ if (inputCount === 0)
8452
+ return;
8453
+ const note = buildFilterWarning(filter, data2, outcome);
8454
+ getOutputSink().writeErr(`[WARN] ${note}
8455
+ `);
8456
+ onWarning?.(note);
8457
+ };
8458
+ const warnIfAllNull = (records) => {
8459
+ const keys = alwaysNullKeys(records);
8460
+ if (keys.length > 0)
8461
+ warn({ kind: "null-values", keys });
8462
+ };
8463
+ if (result == null) {
8464
+ warn({ kind: "empty" });
8292
8465
  return [];
8466
+ }
8293
8467
  if (Array.isArray(result)) {
8468
+ if (result.length === 0) {
8469
+ warn({ kind: "empty" });
8470
+ } else if (result.every((entry) => entry === null)) {
8471
+ warn({ kind: "null-elements", count: result.length });
8472
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
8473
+ warn({ kind: "null-rows", count: result.length });
8474
+ } else {
8475
+ warnIfAllNull(result);
8476
+ }
8294
8477
  if (result.length > 0 && typeof result[0] !== "object") {
8295
8478
  const fieldMatch = filter.match(/\.(\w+)$/);
8296
8479
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -8298,10 +8481,30 @@ function applyFilter(data2, filter) {
8298
8481
  }
8299
8482
  return result;
8300
8483
  }
8301
- if (typeof result === "object")
8484
+ if (typeof result === "object") {
8485
+ warnIfAllNull([result]);
8302
8486
  return result;
8487
+ }
8303
8488
  return { Value: result };
8304
8489
  }
8490
+ function filterFailureData(envelope) {
8491
+ const filter = getOutputFilter();
8492
+ const data2 = envelope.Data;
8493
+ if (!filter || data2 == null)
8494
+ return;
8495
+ let note;
8496
+ const [filterError, filtered] = catchError(() => applyFilter(data2, filter, (n) => {
8497
+ note = n;
8498
+ }));
8499
+ if (filterError) {
8500
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
8501
+ return;
8502
+ }
8503
+ envelope.Data = filtered;
8504
+ if (note) {
8505
+ envelope.Warning = appendWarning(envelope.Warning, note);
8506
+ }
8507
+ }
8305
8508
  function defaultErrorCodeForResult(result) {
8306
8509
  switch (result) {
8307
8510
  case RESULTS.AuthenticationError:
@@ -8370,6 +8573,7 @@ function defaultRetryForErrorCode(errorCode) {
8370
8573
  }
8371
8574
  var ANSI_STYLES, ANSI_RESET = "\x1B[0m", CLI_ERROR_CODES, RETRY_HINTS, CLI_ERROR_CODE_VALUES, RETRY_HINT_VALUES, RESULTS, EXIT_CODES, PLUMBING_KEYS, NESTED_INDENT = " ", MARKDOWN_MAX_CELL = 200, MARKDOWN_MAX_DEPTH = 3, BACKTICK_RUN, FilterEvaluationError, FilterImplicitLimitError, LOCAL_PERMISSION_TEXT_PATTERN, OutputFormatter;
8372
8575
  var init_formatter = __esm(() => {
8576
+ init_catch_error();
8373
8577
  init_logger();
8374
8578
  init_output_codecs();
8375
8579
  init_output_context();
@@ -8466,8 +8670,14 @@ var init_formatter = __esm(() => {
8466
8670
  }
8467
8671
  const filter = getOutputFilter();
8468
8672
  if (filter) {
8469
- const filtered = applyFilter(data2.Data, filter);
8673
+ let note;
8674
+ const filtered = applyFilter(data2.Data, filter, (n) => {
8675
+ note = n;
8676
+ });
8470
8677
  data2.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
8678
+ if (note) {
8679
+ data2.Warning = appendWarning(data2.Warning, note);
8680
+ }
8471
8681
  }
8472
8682
  logOutput(normalizeOutputKeys(data2), getOutputFormat(), options?.tableRowStyle);
8473
8683
  }
@@ -8495,6 +8705,7 @@ var init_formatter = __esm(() => {
8495
8705
  delete envelope.TelemetryErrorClass;
8496
8706
  delete envelope.TelemetryTerminalOutcome;
8497
8707
  delete envelope.TelemetryTerminalSignal;
8708
+ filterFailureData(envelope);
8498
8709
  if (!suppressTelemetry) {
8499
8710
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
8500
8711
  result: data2.Result,
@@ -8543,13 +8754,20 @@ var init_formatter = __esm(() => {
8543
8754
  OutputFormatter.log = log;
8544
8755
  function formatToString(data2) {
8545
8756
  const filter = getOutputFilter();
8757
+ const envelope = data2;
8546
8758
  if ("Data" in data2 && data2.Data != null) {
8547
8759
  data2.Data = normalizeDataKeys(data2.Data);
8548
8760
  if (filter) {
8549
- data2.Data = normalizeDataKeys(applyFilter(data2.Data, filter));
8761
+ let note;
8762
+ data2.Data = normalizeDataKeys(applyFilter(data2.Data, filter, (n) => {
8763
+ note = n;
8764
+ }));
8765
+ if (note) {
8766
+ envelope.Warning = appendWarning(envelope.Warning, note);
8767
+ }
8550
8768
  }
8551
8769
  }
8552
- const output = normalizeOutputKeys(data2);
8770
+ const output = normalizeOutputKeys(envelope);
8553
8771
  const lines = [];
8554
8772
  const sink = getOutputSink();
8555
8773
  printOutput(output, getOutputFormat(), (msg) => {
@@ -131808,7 +132026,7 @@ var init_package = __esm(() => {
131808
132026
  name: "@uipath/integrationservice-sdk",
131809
132027
  author: "UiPath",
131810
132028
  license: "SEE LICENSE IN LICENSE.txt",
131811
- version: "1.203.0-preview.233",
132029
+ version: "1.203.0-preview.237",
131812
132030
  repository: {
131813
132031
  type: "git",
131814
132032
  url: "https://github.com/UiPath/cli.git",
@@ -213945,4 +214163,4 @@ export {
213945
214163
  withPimsCall
213946
214164
  };
213947
214165
 
213948
- //# debugId=DB0159188C44ADBB64756E2164756E21
214166
+ //# debugId=B6FA8819C0E65B7564756E2164756E21
@@ -8271,7 +8271,165 @@ function requireJmespath() {
8271
8271
  }
8272
8272
  return codec;
8273
8273
  }
8274
- function applyFilter(data, filter) {
8274
+ function countRecords(data) {
8275
+ if (Array.isArray(data))
8276
+ return data.length;
8277
+ return data == null ? 0 : 1;
8278
+ }
8279
+ function availableFields(data) {
8280
+ const records = Array.isArray(data) ? data : [data];
8281
+ const keys = new Set;
8282
+ for (const record of records) {
8283
+ if (record && typeof record === "object" && !Array.isArray(record)) {
8284
+ for (const key of Object.keys(record))
8285
+ keys.add(key);
8286
+ }
8287
+ }
8288
+ return [...keys];
8289
+ }
8290
+ function decodeQuotedIdentifier(whole, inner) {
8291
+ const [error, decoded] = catchError(() => JSON.parse(whole));
8292
+ if (!error && typeof decoded === "string")
8293
+ return decoded;
8294
+ return inner.replace(/\\(.)/g, "$1");
8295
+ }
8296
+ function referencedFields(filter) {
8297
+ const top = new Set;
8298
+ const nested = new Set;
8299
+ const withoutValueLiterals = filter.replace(/'(?:\\.|[^'\\])*'/g, " ").replace(/`(?:\\.|[^`\\])*`/g, " ");
8300
+ const isPathTail = (text, index) => text[index - 1] === "." && /[A-Za-z0-9_"]/.test(text[index - 2] ?? "");
8301
+ const quoted = [];
8302
+ const withoutLiterals = withoutValueLiterals.replace(/"((?:\\.|[^"\\])*)"/g, (whole, name, index) => {
8303
+ const isAlias = /^\s*:/.test(withoutValueLiterals.slice(index + whole.length));
8304
+ if (!isAlias) {
8305
+ quoted.push({
8306
+ name: decodeQuotedIdentifier(whole, name),
8307
+ index,
8308
+ tail: isPathTail(withoutValueLiterals, index)
8309
+ });
8310
+ }
8311
+ return `"${" ".repeat(whole.length - 2)}"`;
8312
+ });
8313
+ const descent = /[A-Za-z0-9_"]\s*[.[]/.exec(withoutLiterals);
8314
+ const rootEnd = descent ? descent.index + 1 : Number.POSITIVE_INFINITY;
8315
+ const place = (name, index, tail) => {
8316
+ if (tail || index >= rootEnd)
8317
+ nested.add(name);
8318
+ else
8319
+ top.add(name);
8320
+ };
8321
+ for (const entry of quoted)
8322
+ place(entry.name, entry.index, entry.tail);
8323
+ const identifiers = withoutLiterals.matchAll(/([A-Za-z_][A-Za-z0-9_]*)(\s*[:(])?/g);
8324
+ const reserved = new Set(["true", "false", "null", "and", "or", "not"]);
8325
+ for (const match of identifiers) {
8326
+ const [, name, trailing] = match;
8327
+ if (trailing || reserved.has(name))
8328
+ continue;
8329
+ place(name, match.index, isPathTail(withoutLiterals, match.index));
8330
+ }
8331
+ return {
8332
+ top: [...top],
8333
+ nested: [...nested].filter((name) => !top.has(name)),
8334
+ hasPredicate: /\[\s*\?/.test(withoutValueLiterals)
8335
+ };
8336
+ }
8337
+ function appearsBelowTopLevel(data, name) {
8338
+ let budget = 2000;
8339
+ const visit = (value, depth) => {
8340
+ if (budget-- <= 0 || depth > 4)
8341
+ return false;
8342
+ if (value === null || typeof value !== "object")
8343
+ return false;
8344
+ if (Array.isArray(value))
8345
+ return value.some((entry) => visit(entry, depth));
8346
+ const record = value;
8347
+ if (depth > 0 && Object.hasOwn(record, name))
8348
+ return true;
8349
+ return Object.values(record).some((entry) => visit(entry, depth + 1));
8350
+ };
8351
+ return visit(data, 0);
8352
+ }
8353
+ function alwaysNullKeys(records) {
8354
+ const objects = records.filter((r) => r != null && typeof r === "object" && !Array.isArray(r));
8355
+ if (objects.length === 0 || objects.length !== records.length)
8356
+ return [];
8357
+ const keys = [...new Set(objects.flatMap((o) => Object.keys(o)))];
8358
+ if (keys.length === 0)
8359
+ return [];
8360
+ const nullKeys = keys.filter((key) => objects.every((record) => record[key] === null));
8361
+ return nullKeys.length === keys.length ? nullKeys : [];
8362
+ }
8363
+ function carriesOnlyNulls(value) {
8364
+ if (value === null)
8365
+ return true;
8366
+ if (Array.isArray(value)) {
8367
+ return value.length > 0 && value.every(carriesOnlyNulls);
8368
+ }
8369
+ if (typeof value === "object" && value !== undefined) {
8370
+ const values = Object.values(value);
8371
+ return values.length > 0 && values.every(carriesOnlyNulls);
8372
+ }
8373
+ return false;
8374
+ }
8375
+ function nameList(names, cap2 = 12) {
8376
+ const shown = names.slice(0, cap2).map((n) => `\`${n}\``);
8377
+ const rest = names.length - shown.length;
8378
+ return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
8379
+ }
8380
+ function buildFilterWarning(filter, data, outcome) {
8381
+ const present = availableFields(data);
8382
+ const refs = referencedFields(filter);
8383
+ const unknown = refs.top.filter((name) => !present.includes(name) && !appearsBelowTopLevel(data, name));
8384
+ const unchecked = refs.nested.filter((name) => !present.includes(name));
8385
+ const count = countRecords(data);
8386
+ const scope = `${count} record(s)`;
8387
+ const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
8388
+ 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" : "";
8389
+ const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
8390
+ let detail;
8391
+ let lede;
8392
+ if (outcome.kind === "null-elements") {
8393
+ lede = "returned only null values";
8394
+ const projected = `all ${outcome.count} of the elements it projected are null`;
8395
+ if (unknown.length > 0) {
8396
+ detail = `${projected}, because ${isNotAField(unknown)}`;
8397
+ } else if (unchecked.length > 0) {
8398
+ detail = withSoundness(projected);
8399
+ } else {
8400
+ 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`;
8401
+ }
8402
+ } else if (outcome.kind === "null-rows") {
8403
+ lede = "returned only null values";
8404
+ const projected = `every value it projected is null on all ${outcome.count} row(s)`;
8405
+ detail = unknown.length > 0 ? `${projected}, because ${isNotAField(unknown)}` : withSoundness(projected);
8406
+ } else if (outcome.kind === "null-values") {
8407
+ lede = "returned only null values";
8408
+ const projected = `every key it projected (${nameList(outcome.keys)}) is null`;
8409
+ const sameSet = unknown.length === outcome.keys.length && outcome.keys.every((k) => unknown.includes(k));
8410
+ if (sameSet) {
8411
+ detail = `${isNotAField(outcome.keys)}, so every key it projected is null`;
8412
+ } else if (unknown.length > 0) {
8413
+ detail = `${projected}, because ${isNotAField(unknown)}`;
8414
+ } else {
8415
+ detail = withSoundness(`${projected} on all ${scope}`);
8416
+ }
8417
+ } else {
8418
+ lede = "returned nothing";
8419
+ if (unknown.length > 0) {
8420
+ detail = isNotAField(unknown);
8421
+ } else {
8422
+ const selection = refs.hasPredicate ? "no record matched" : "the expression resolved to no value";
8423
+ detail = withSoundness(`${selection} — it read ${scope}`);
8424
+ }
8425
+ }
8426
+ const fields = present.length > 0 ? ` Available fields: ${nameList(present)}.` : "";
8427
+ return `--output-filter ${JSON.stringify(filter)} ${lede}: ${detail}.${fields}`;
8428
+ }
8429
+ function appendWarning(existing, note) {
8430
+ return existing ? `${existing} ${note}` : note;
8431
+ }
8432
+ function applyFilter(data, filter, onWarning) {
8275
8433
  const codec = requireJmespath();
8276
8434
  let result;
8277
8435
  try {
@@ -8279,9 +8437,34 @@ function applyFilter(data, filter) {
8279
8437
  } catch (err) {
8280
8438
  throw new FilterEvaluationError(filter, err);
8281
8439
  }
8282
- if (result == null)
8440
+ const inputCount = countRecords(data);
8441
+ const warn = (outcome) => {
8442
+ if (inputCount === 0)
8443
+ return;
8444
+ const note = buildFilterWarning(filter, data, outcome);
8445
+ getOutputSink().writeErr(`[WARN] ${note}
8446
+ `);
8447
+ onWarning?.(note);
8448
+ };
8449
+ const warnIfAllNull = (records) => {
8450
+ const keys = alwaysNullKeys(records);
8451
+ if (keys.length > 0)
8452
+ warn({ kind: "null-values", keys });
8453
+ };
8454
+ if (result == null) {
8455
+ warn({ kind: "empty" });
8283
8456
  return [];
8457
+ }
8284
8458
  if (Array.isArray(result)) {
8459
+ if (result.length === 0) {
8460
+ warn({ kind: "empty" });
8461
+ } else if (result.every((entry) => entry === null)) {
8462
+ warn({ kind: "null-elements", count: result.length });
8463
+ } else if (result.every((entry) => Array.isArray(entry)) && carriesOnlyNulls(result)) {
8464
+ warn({ kind: "null-rows", count: result.length });
8465
+ } else {
8466
+ warnIfAllNull(result);
8467
+ }
8285
8468
  if (result.length > 0 && typeof result[0] !== "object") {
8286
8469
  const fieldMatch = filter.match(/\.(\w+)$/);
8287
8470
  const key = fieldMatch ? fieldMatch[1] : "Value";
@@ -8289,10 +8472,30 @@ function applyFilter(data, filter) {
8289
8472
  }
8290
8473
  return result;
8291
8474
  }
8292
- if (typeof result === "object")
8475
+ if (typeof result === "object") {
8476
+ warnIfAllNull([result]);
8293
8477
  return result;
8478
+ }
8294
8479
  return { Value: result };
8295
8480
  }
8481
+ function filterFailureData(envelope) {
8482
+ const filter = getOutputFilter();
8483
+ const data = envelope.Data;
8484
+ if (!filter || data == null)
8485
+ return;
8486
+ let note;
8487
+ const [filterError, filtered] = catchError(() => applyFilter(data, filter, (n) => {
8488
+ note = n;
8489
+ }));
8490
+ if (filterError) {
8491
+ envelope.Warning = appendWarning(envelope.Warning, `--output-filter was not applied, so Data is shown in full: ${filterError.message}`);
8492
+ return;
8493
+ }
8494
+ envelope.Data = filtered;
8495
+ if (note) {
8496
+ envelope.Warning = appendWarning(envelope.Warning, note);
8497
+ }
8498
+ }
8296
8499
  function defaultErrorCodeForResult(result) {
8297
8500
  switch (result) {
8298
8501
  case RESULTS.AuthenticationError:
@@ -8361,6 +8564,7 @@ function defaultRetryForErrorCode(errorCode) {
8361
8564
  }
8362
8565
  var ANSI_STYLES, ANSI_RESET = "\x1B[0m", CLI_ERROR_CODES, RETRY_HINTS, CLI_ERROR_CODE_VALUES, RETRY_HINT_VALUES, RESULTS, EXIT_CODES, PLUMBING_KEYS, NESTED_INDENT = " ", MARKDOWN_MAX_CELL = 200, MARKDOWN_MAX_DEPTH = 3, BACKTICK_RUN, FilterEvaluationError, FilterImplicitLimitError, LOCAL_PERMISSION_TEXT_PATTERN, OutputFormatter;
8363
8566
  var init_formatter = __esm(() => {
8567
+ init_catch_error();
8364
8568
  init_logger();
8365
8569
  init_output_codecs();
8366
8570
  init_output_context();
@@ -8457,8 +8661,14 @@ var init_formatter = __esm(() => {
8457
8661
  }
8458
8662
  const filter = getOutputFilter();
8459
8663
  if (filter) {
8460
- const filtered = applyFilter(data.Data, filter);
8664
+ let note;
8665
+ const filtered = applyFilter(data.Data, filter, (n) => {
8666
+ note = n;
8667
+ });
8461
8668
  data.Data = normalize ? normalizeDataKeys(filtered, verbatim, subtrees && { refs: subtrees.refs, mode: "skip" }) : filtered;
8669
+ if (note) {
8670
+ data.Warning = appendWarning(data.Warning, note);
8671
+ }
8462
8672
  }
8463
8673
  logOutput(normalizeOutputKeys(data), getOutputFormat(), options?.tableRowStyle);
8464
8674
  }
@@ -8486,6 +8696,7 @@ var init_formatter = __esm(() => {
8486
8696
  delete envelope.TelemetryErrorClass;
8487
8697
  delete envelope.TelemetryTerminalOutcome;
8488
8698
  delete envelope.TelemetryTerminalSignal;
8699
+ filterFailureData(envelope);
8489
8700
  if (!suppressTelemetry) {
8490
8701
  telemetry.trackEvent(CommonTelemetryEvents.Error, {
8491
8702
  result: data.Result,
@@ -8534,13 +8745,20 @@ var init_formatter = __esm(() => {
8534
8745
  OutputFormatter.log = log;
8535
8746
  function formatToString(data) {
8536
8747
  const filter = getOutputFilter();
8748
+ const envelope = data;
8537
8749
  if ("Data" in data && data.Data != null) {
8538
8750
  data.Data = normalizeDataKeys(data.Data);
8539
8751
  if (filter) {
8540
- data.Data = normalizeDataKeys(applyFilter(data.Data, filter));
8752
+ let note;
8753
+ data.Data = normalizeDataKeys(applyFilter(data.Data, filter, (n) => {
8754
+ note = n;
8755
+ }));
8756
+ if (note) {
8757
+ envelope.Warning = appendWarning(envelope.Warning, note);
8758
+ }
8541
8759
  }
8542
8760
  }
8543
- const output = normalizeOutputKeys(data);
8761
+ const output = normalizeOutputKeys(envelope);
8544
8762
  const lines = [];
8545
8763
  const sink = getOutputSink();
8546
8764
  printOutput(output, getOutputFormat(), (msg) => {
@@ -11773,4 +11991,4 @@ export {
11773
11991
  resolveJsonInput
11774
11992
  };
11775
11993
 
11776
- //# debugId=E33445896218B1FE64756E2164756E21
11994
+ //# debugId=87A4419BB2E9C5E064756E2164756E21