node-autotask 0.88.0 → 0.89.0

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.
@@ -325,12 +325,10 @@ function redactResponseBody(value, policy) {
325
325
  return value.map((entry) => redactResponseBody(entry, policy));
326
326
  }
327
327
  if (!isPlainRecord(value)) return value;
328
- const out = {};
329
- for (const [key, entry] of Object.entries(value)) {
328
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => {
330
329
  const pinned = SECRET_SET.has(key) || personal && OPTIONAL_SET.has(key);
331
- out[key] = pinned ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry, policy);
332
- }
333
- return out;
330
+ return [key, pinned ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry, policy)];
331
+ }));
334
332
  }
335
333
 
336
334
  // src/errors/from-status.ts
@@ -404,7 +402,7 @@ function suggestedActionForStatus(status) {
404
402
  return status >= 500 ? "The SDK already retried per its policy. A repeated 500 on one entity while others work usually means the API user lacks permission on that entity \u2014 ask the Autotask admin to grant it; otherwise retry once more at most." : void 0;
405
403
  }
406
404
  }
407
- function errorFromStatus(status, body, url, operation, redactPersonalData = true, credential, includeVendorDetails = true) {
405
+ function errorFromStatus(status, body, url, operation, redactPersonalData = false, credential, includeVendorDetails = true) {
408
406
  const safeBody = redactResponseBody(body, { redactPersonalData });
409
407
  const exposedBody = includeVendorDetails ? safeBody : void 0;
410
408
  let detail = formatVendorDetail(exposedBody);
@@ -1399,7 +1397,7 @@ function resolveConfig(config) {
1399
1397
  const rateLimit = resolveRateLimit(config, agent);
1400
1398
  const cooldown = resolveCooldown(config);
1401
1399
  const resolution = resolveResolution(config, agent);
1402
- const redactPersonalData = config.redactPersonalData ?? true;
1400
+ const redactPersonalData = config.redactPersonalData ?? false;
1403
1401
  const caches = resolveCaches(config);
1404
1402
  const update = { putFallback: config.update?.putFallback === true };
1405
1403
  const reResolveZoneOn401 = config.reResolveZoneOn401 === true;
@@ -1452,8 +1450,14 @@ function isAuditDecimalId(id) {
1452
1450
  function isRecord2(value) {
1453
1451
  return typeof value === "object" && value !== null && !Array.isArray(value);
1454
1452
  }
1455
- function snapshotFields(record, keys) {
1456
- const captured = { ...record };
1453
+ function snapshotFields(record, keys, fixed) {
1454
+ const captured = fixed === void 0 ? { ...record } : {
1455
+ ...Object.fromEntries(Reflect.ownKeys(record).flatMap((key) => {
1456
+ if (Object.hasOwn(fixed, key) || !Object.prototype.propertyIsEnumerable.call(record, key)) return [];
1457
+ return [[key, Reflect.get(record, key)]];
1458
+ })),
1459
+ ...fixed
1460
+ };
1457
1461
  for (const key of keys) {
1458
1462
  if (Object.hasOwn(captured, key)) continue;
1459
1463
  const value = Reflect.get(record, key);
@@ -1673,9 +1677,20 @@ function snapshotQueryFilter(filter) {
1673
1677
  throw invalidFilterShape(filter);
1674
1678
  }
1675
1679
  function snapshotQueryBag(bag, keys) {
1676
- const snapshot = snapshotFields(bag, keys);
1680
+ let fixed;
1681
+ if (keys.includes("acknowledgeUnscoped")) {
1682
+ const acknowledgment = Object.getOwnPropertyDescriptor(bag, "acknowledgeUnscoped");
1683
+ const direct = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") ? acknowledgment.value : void 0;
1684
+ const filter = Reflect.get(bag, "filter");
1685
+ const capturedFilter = filter === void 0 ? void 0 : snapshotQueryFilter(filter);
1686
+ fixed = {
1687
+ filter: capturedFilter,
1688
+ acknowledgeUnscoped: direct === true ? Reflect.get(bag, "acknowledgeUnscoped") === true : direct
1689
+ };
1690
+ }
1691
+ const snapshot = snapshotFields(bag, keys, fixed);
1677
1692
  const captured = snapshot;
1678
- if (captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
1693
+ if (fixed === void 0 && captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
1679
1694
  if (Array.isArray(captured.includeFields)) {
1680
1695
  const fields = captured.includeFields;
1681
1696
  captured.includeFields = Array.from({ length: fields.length }, (_, i) => fields[i]);
@@ -1972,9 +1987,8 @@ function isJsonMediaType(header) {
1972
1987
  const mediaType = header.split(";")[0]?.trim().toLowerCase() ?? "";
1973
1988
  return mediaType.startsWith("application/json") || mediaType.endsWith("+json");
1974
1989
  }
1975
- function bodySnippet(text, redactPersonalData) {
1976
- const bytes = Buffer.from(text, "utf8").subarray(0, 256).toString("utf8");
1977
- return redactResponseBody(bytes, { redactPersonalData });
1990
+ function bodySnippet(text) {
1991
+ return Buffer.from(text, "utf8").subarray(0, 256).toString("utf8");
1978
1992
  }
1979
1993
 
1980
1994
  // src/http/limits.ts
@@ -16900,6 +16914,13 @@ function exactRecordResponseTarget(path, method, operation) {
16900
16914
  }
16901
16915
  return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
16902
16916
  }
16917
+ function ownField(value, key) {
16918
+ return isRecord2(value) && Object.hasOwn(value, key) ? value[key] : void 0;
16919
+ }
16920
+ function receiptId(body) {
16921
+ const itemId = ownField(body, "itemId");
16922
+ return itemId === void 0 ? ownField(body, "id") : itemId;
16923
+ }
16903
16924
  function isNonNegativeInt64(id) {
16904
16925
  return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
16905
16926
  }
@@ -16912,14 +16933,14 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
16912
16933
  return;
16913
16934
  }
16914
16935
  if (target === "query") {
16915
- if (!isRecord2(body) || !Array.isArray(body.items) || !isRecord2(body.pageDetails)) {
16936
+ const items = ownField(body, "items");
16937
+ const paging = ownField(body, "pageDetails");
16938
+ if (!Array.isArray(items) || !isRecord2(paging)) {
16916
16939
  return invalid("Expected a query page with paging details");
16917
16940
  }
16918
- if (!body.items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
16919
- if (body.pageDetails.count !== body.items.length) {
16920
- invalid("The page record count did not match its rows");
16921
- }
16922
- const cursor = body.pageDetails.nextPageUrl;
16941
+ if (!items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
16942
+ if (ownField(paging, "count") !== items.length) invalid("The page record count did not match its rows");
16943
+ const cursor = ownField(paging, "nextPageUrl");
16923
16944
  if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
16924
16945
  invalid("Expected a valid query cursor or an explicit end of results");
16925
16946
  }
@@ -16928,26 +16949,27 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
16928
16949
  const parts = path.replace(/\/$/, "").split("/");
16929
16950
  const expectedId = parts.at(-1);
16930
16951
  if (target === "mutation") {
16931
- const id = isRecord2(body) ? body.itemId === void 0 ? body.id : body.itemId : void 0;
16932
- if (!isNonNegativeInt64(id)) invalid("Expected a valid mutation receipt");
16933
- const expected = method === "DELETE" ? expectedId : isRecord2(requestBody) ? requestBody.id : void 0;
16934
- if (expected !== void 0 && String(id) !== String(expected)) {
16952
+ const id2 = receiptId(body);
16953
+ if (!isNonNegativeInt64(id2)) invalid("Expected a valid mutation receipt");
16954
+ const expected = method === "DELETE" ? expectedId : ownField(requestBody, "id");
16955
+ if (expected !== void 0 && String(id2) !== String(expected)) {
16935
16956
  invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
16936
16957
  }
16937
16958
  return;
16938
16959
  }
16939
- const item = isRecord2(body) ? body.item : void 0;
16960
+ const item = ownField(body, "item");
16940
16961
  if (item === null) return;
16941
- if (!isRecord2(item) || !isNonNegativeInt64(item.id)) {
16962
+ const id = ownField(item, "id");
16963
+ if (!isNonNegativeInt64(id)) {
16942
16964
  return invalid("Expected an item envelope with a valid record ID");
16943
16965
  }
16944
16966
  const entity = parts.at(-2)?.toLowerCase();
16945
16967
  const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
16946
- if (String(item.id) !== expectedId) {
16968
+ if (String(id) !== expectedId) {
16947
16969
  throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
16948
16970
  }
16949
16971
  if (parts.length === 6) {
16950
- const parent = item.articleCategoryID;
16972
+ const parent = ownField(item, "articleCategoryID");
16951
16973
  if (typeof parent !== "number" || !Number.isInteger(parent) || parent <= 0 || parent > 2147483647) {
16952
16974
  invalid("Expected a valid category ID in the Knowledge Base article response");
16953
16975
  }
@@ -16957,7 +16979,7 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
16957
16979
  }
16958
16980
  }
16959
16981
  function serializeExactRecordUpdate(body, operation) {
16960
- if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
16982
+ if (!isRecord2(body) || !Object.hasOwn(body, "id") || typeof body.id !== "string") return JSON.stringify(body);
16961
16983
  if (!isAuditDecimalId(body.id)) {
16962
16984
  throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
16963
16985
  }
@@ -16979,12 +17001,12 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
16979
17001
  }
16980
17002
  return value;
16981
17003
  });
16982
- const rows = isRecord2(body) ? target === "query" ? body.items : [target === "mutation" ? body : body.item] : void 0;
17004
+ const rows = target === "query" ? ownField(body, "items") : [target === "mutation" ? body : ownField(body, "item")];
16983
17005
  if (Array.isArray(rows)) {
16984
17006
  for (const row of rows) {
16985
17007
  if (!isRecord2(row)) continue;
16986
- const key = target === "mutation" && row.itemId !== void 0 ? "itemId" : "id";
16987
- const value = row[key];
17008
+ const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
17009
+ const value = ownField(row, key);
16988
17010
  if (typeof value !== "number") continue;
16989
17011
  const token = (key === "id" ? idTokens : receiptTokens).get(row);
16990
17012
  if (token === void 0 || !isAuditDecimalId(token)) row[key] = null;
@@ -16994,8 +17016,7 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
16994
17016
  return body;
16995
17017
  }
16996
17018
  function hasExactRecordId(item) {
16997
- if (!isRecord2(item)) return false;
16998
- return isNonNegativeInt64(item.id);
17019
+ return isNonNegativeInt64(ownField(item, "id"));
16999
17020
  }
17000
17021
  function isAuditPage(body) {
17001
17022
  if (!Array.isArray(body.items) || !isRecord2(body.pageDetails)) return false;
@@ -17064,7 +17085,7 @@ function unwrapItems(body, operation) {
17064
17085
  return { items: body.items, pageDetails: body.pageDetails };
17065
17086
  }
17066
17087
  function unwrapItem(body, id, operation, entity) {
17067
- if (!isRecord2(body) || !("item" in body)) {
17088
+ if (!isRecord2(body) || !Object.hasOwn(body, "item")) {
17068
17089
  throw new AutotaskError("Expected the item envelope { item }; got a different shape", {
17069
17090
  code: "INVALID_RESPONSE",
17070
17091
  category: "server",
@@ -17090,7 +17111,7 @@ function unwrapItem(body, id, operation, entity) {
17090
17111
  return item;
17091
17112
  }
17092
17113
  function unwrapQueryCount(body, operation) {
17093
- const count = isRecord2(body) ? body.queryCount : void 0;
17114
+ const count = ownField(body, "queryCount");
17094
17115
  if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > 2147483647) {
17095
17116
  const err = new AutotaskError("Expected the count envelope { queryCount: non-negative int32 }", {
17096
17117
  code: "INVALID_RESPONSE",
@@ -17104,7 +17125,7 @@ function unwrapQueryCount(body, operation) {
17104
17125
  return count;
17105
17126
  }
17106
17127
  function unwrapOperation(body, operation) {
17107
- const value = isRecord2(body) ? body.itemId !== void 0 ? body.itemId : body.id : void 0;
17128
+ const value = receiptId(body);
17108
17129
  const idValue = toIdentifierId(value);
17109
17130
  if (idValue === void 0) {
17110
17131
  const err = new AutotaskError(
@@ -17455,7 +17476,7 @@ var HttpClient = class {
17455
17476
  since,
17456
17477
  retryAfterMs: s.maintenancePollMs,
17457
17478
  httpStatus: status,
17458
- ...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text, this.redactPersonalData) },
17479
+ ...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text) },
17459
17480
  maintenanceDetected: true
17460
17481
  },
17461
17482
  suggestedAction: unknownWrite ? `A maintenance-shaped page answered ${method} ${opts.path} (HTTP ${status}); it was NOT waited out or re-sent \u2014 a non-2xx edge page can arrive after the request was forwarded, so verify the record before re-issuing (only a GET or an explicitly idempotent-flagged call waits this window out).` : `The Autotask zone is in its maintenance window (since ${since}); retry after the window (windows usually last 30-90 min).`
@@ -17633,7 +17654,7 @@ var HttpClient = class {
17633
17654
  httpStatus: status,
17634
17655
  details: {
17635
17656
  httpStatus: status,
17636
- ...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text, this.redactPersonalData) }
17657
+ ...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text) }
17637
17658
  },
17638
17659
  // The content-type is host-sourced (a host-supplied
17639
17660
  // baseUrl can serve arbitrary HTML) — capped, never prose;
@@ -17684,7 +17705,7 @@ var HttpClient = class {
17684
17705
  nonJsonBody = text;
17685
17706
  }
17686
17707
  }
17687
- const nonJsonSnippet = nonJsonBody === void 0 || s.getQuery ? void 0 : bodySnippet(nonJsonBody, this.redactPersonalData);
17708
+ const nonJsonSnippet = nonJsonBody === void 0 || s.getQuery ? void 0 : bodySnippet(nonJsonBody);
17688
17709
  const nonJsonIsMaintenance = s.maintenancePage;
17689
17710
  const nonJsonIsHtmlCandidate = nonJsonBody !== void 0 && isHtmlLike(res.headers.get("Content-Type"), nonJsonBody);
17690
17711
  if (nonJsonIsMaintenance) {
@@ -18927,7 +18948,7 @@ function attachUpdateTargetMissReason(err, key) {
18927
18948
  if (pinned === void 0) return;
18928
18949
  err.details = { ...err.details ?? {}, emptyReason: pinned };
18929
18950
  }
18930
- function buildDryRunResult(spec, policy = { redactPersonalData: true }) {
18951
+ function buildDryRunResult(spec, policy) {
18931
18952
  if (spec.operation === "") {
18932
18953
  throw new AutotaskConfigError("dry-run: the operation name is required");
18933
18954
  }
@@ -18959,7 +18980,7 @@ function computeFieldDiff(current, data) {
18959
18980
  const out = [];
18960
18981
  for (const [field, to] of Object.entries(data)) {
18961
18982
  if (field === "id" || to === void 0) continue;
18962
- const from = current[field];
18983
+ const from = Object.hasOwn(current, field) ? current[field] : void 0;
18963
18984
  if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
18964
18985
  out.push({ field, from: from === void 0 ? null : from, to });
18965
18986
  }
@@ -19797,6 +19818,109 @@ function notPersistedFields(sent, stored) {
19797
19818
  return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== chunkCM5O672I_cjs.REDACTED && !same(value, stored[key])).map(([key]) => key);
19798
19819
  }
19799
19820
 
19821
+ // src/operations/invoke/inputSets.ts
19822
+ var PARAMS_BAG_KEYS = {
19823
+ query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
19824
+ // No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
19825
+ // called directly), so this entry never fires. It is KEPT so that a future
19826
+ // `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
19827
+ // cannot silently open the bag (the keys are the vendor `QueryParams` set
19828
+ // the raw method accepts).
19829
+ queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
19830
+ // issue #145: the count bag carries the fieldCheck opt-out — the #140
19831
+ // refusal's advised remedy (before, the closed bag refused the very key it
19832
+ // advised, and the remedy looped into a second CONFIG_ERROR).
19833
+ count: ["filter", "fieldCheck"]
19834
+ };
19835
+ var BAG_KEY_SYNONYMS = {
19836
+ filters: "filter",
19837
+ last: "latest",
19838
+ // issue #59: the expected typo class (honoured only on `query`)
19839
+ lmit: "limit",
19840
+ page: "limit",
19841
+ pageSize: "limit",
19842
+ cursor: "limit",
19843
+ maxrecords: "maxRecords",
19844
+ fieldsPreset: "includeFields"
19845
+ // issue #287: the preset was removed — the refusal points at the explicit includeFields
19846
+ };
19847
+ function levenshtein(a, b) {
19848
+ if (a === b) return 0;
19849
+ const prev = new Array(b.length + 1);
19850
+ const cur = new Array(b.length + 1);
19851
+ for (let j = 0; j <= b.length; j += 1) prev[j] = j;
19852
+ for (let i = 1; i <= a.length; i += 1) {
19853
+ cur[0] = i;
19854
+ for (let j = 1; j <= b.length; j += 1) {
19855
+ cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
19856
+ }
19857
+ for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
19858
+ }
19859
+ return prev[b.length] ?? 0;
19860
+ }
19861
+ function suggestForKey(key, valid) {
19862
+ const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
19863
+ if (synonym !== void 0 && valid.includes(synonym)) return synonym;
19864
+ let best = null;
19865
+ for (const v of valid) {
19866
+ const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
19867
+ if (best === null || dist < best.dist) best = { key: v, dist };
19868
+ }
19869
+ if (best !== null && best.dist <= 3) return best.key;
19870
+ return null;
19871
+ }
19872
+ function keySuggestions(unknown, valid) {
19873
+ return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
19874
+ }
19875
+ function ownQueryBag(args) {
19876
+ const bag = args != null && Object.hasOwn(args, 0) ? args[0] : void 0;
19877
+ return isRecord2(bag) ? bag : void 0;
19878
+ }
19879
+ function validateParamsBag(record, args) {
19880
+ if (record.inputSchemaStrict !== true) return;
19881
+ const valid = PARAMS_BAG_KEYS[record.operation];
19882
+ if (valid === void 0) return;
19883
+ const bag = ownQueryBag(args);
19884
+ if (bag === void 0) return;
19885
+ const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
19886
+ if (unknown.length === 0) return;
19887
+ const suggestions = keySuggestions(unknown, valid);
19888
+ throw new AutotaskConfigError(
19889
+ `invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
19890
+ {
19891
+ operation: record.id,
19892
+ suggestedAction: suggestions.length > 0 ? `Fix the key name (${suggestions.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).` : `Pass only the valid keys (${valid.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).`
19893
+ }
19894
+ );
19895
+ }
19896
+ var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
19897
+ function validateInvokeOptions(opts, operation) {
19898
+ if (opts === void 0 || opts === null) return;
19899
+ const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
19900
+ if (unknown.length === 0) return;
19901
+ const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
19902
+ throw new AutotaskConfigError(
19903
+ `invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
19904
+ {
19905
+ operation,
19906
+ suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
19907
+ }
19908
+ );
19909
+ }
19910
+ function unknownKeysRefusal(raw, validKeys, subject, operation) {
19911
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
19912
+ const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
19913
+ if (unknown.length === 0) return null;
19914
+ const suggestions = keySuggestions(unknown, [...validKeys]);
19915
+ return new AutotaskConfigError(
19916
+ `unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
19917
+ {
19918
+ ...operation !== void 0 ? { operation } : {},
19919
+ suggestedAction: suggestions.length > 0 ? operation === void 0 ? `Fix the ${subject} name (${suggestions.join(", ")}); the tool's full contract is in the tool's inputSchema, served by the MCP client's list_tools.` : `Fix the ${subject} name (${suggestions.join(", ")}); the full contract is in the tool's inputSchema (autotask_describe).` : `Pass only the valid keys (${validKeys.join(", ")}).`
19920
+ }
19921
+ );
19922
+ }
19923
+
19800
19924
  // src/resources/special/inventoryLocations.ts
19801
19925
  var fail = (message) => {
19802
19926
  throw new AutotaskConfigError(`inventory_locations: ${message}`);
@@ -19805,13 +19929,17 @@ function admitInventoryLocation(value, creating) {
19805
19929
  if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
19806
19930
  const body = { ...value };
19807
19931
  for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
19808
- if ((creating || Object.hasOwn(body, "locationName")) && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail("locationName is required and must be a nonblank string of at most 50 characters");
19809
- if ((creating || Object.hasOwn(body, "isActive")) && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
19810
- if (!creating && !Object.keys(body).length) fail("update must contain locationName or isActive");
19932
+ const hasName = Object.hasOwn(body, "locationName");
19933
+ const hasActive = Object.hasOwn(body, "isActive");
19934
+ if (creating && !hasName || hasName && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail("locationName is required and must be a nonblank string of at most 50 characters");
19935
+ if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
19936
+ if (!creating && !hasName && !hasActive) fail("update must contain locationName or isActive");
19811
19937
  return body;
19812
19938
  }
19813
- function checkInventoryLocationCurrent(value, current) {
19814
- if (value.isActive === false && current.isDefault !== false) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
19939
+ function checkInventoryLocationCurrent(value, current, id) {
19940
+ if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail("current record requires its own id");
19941
+ if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail("current record id must match the requested id");
19942
+ if (Object.hasOwn(value, "isActive") && value.isActive === false && (!Object.hasOwn(current, "isDefault") || current.isDefault !== false)) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
19815
19943
  }
19816
19944
 
19817
19945
  // src/resources/base/types.ts
@@ -21225,8 +21353,8 @@ var MetaBase = class _MetaBase extends QueryBase {
21225
21353
  if (Object.keys(body).length === 0) {
21226
21354
  throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
21227
21355
  }
21228
- if ("item" in body) return unwrapItem(body, id, void 0, entity);
21229
- if (Array.isArray(body.items)) {
21356
+ if (Object.hasOwn(body, "item")) return unwrapItem(body, id, void 0, entity);
21357
+ if (Object.hasOwn(body, "items") && Array.isArray(body.items)) {
21230
21358
  const first = body.items[0];
21231
21359
  if (first === null || first === void 0) {
21232
21360
  throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
@@ -21776,7 +21904,7 @@ var MutationBase = class extends MetaBase {
21776
21904
  /** Normalise a mutation body: `id` OR `itemId` → `id`; UDF map → UDF array (UDF-capable only). */
21777
21905
  normalizeMutationBody(data) {
21778
21906
  const body = { ...data };
21779
- if (body.itemId !== void 0 && body.id === void 0) {
21907
+ if (Object.hasOwn(body, "itemId") && body.itemId !== void 0 && (!Object.hasOwn(body, "id") || body.id === void 0)) {
21780
21908
  body.id = body.itemId;
21781
21909
  delete body.itemId;
21782
21910
  }
@@ -21965,7 +22093,11 @@ var MutationBase = class extends MetaBase {
21965
22093
  const stored = parentId === void 0 ? await this.getGlobal(id, true, maxRetries, checkedBaseUrl) : this.config.attachmentGet === true ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true, maxRetries);
21966
22094
  const submitted = data;
21967
22095
  const persisted = stored;
21968
- const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
22096
+ if (this.config.key === "inventory_locations") {
22097
+ if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError("inventory_locations: persisted record requires its own id");
22098
+ validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
22099
+ }
22100
+ const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
21969
22101
  return { ...result, notPersisted };
21970
22102
  } catch (err) {
21971
22103
  return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
@@ -22760,8 +22892,8 @@ function unknownNamesSuggestedAction(record, authority, filterUnknown) {
22760
22892
  return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
22761
22893
  }
22762
22894
  async function validateQueryFieldNames(record, holder, args) {
22763
- const bag = args[0];
22764
- if (!isRecord2(bag)) return;
22895
+ const bag = ownQueryBag(args);
22896
+ if (bag === void 0) return;
22765
22897
  const fieldCheck = readFieldCheck(record, bag);
22766
22898
  const includeNames = readIncludeNames(record, bag["includeFields"]);
22767
22899
  let filterNames;
@@ -24771,7 +24903,7 @@ var GenericResource = class extends BaseResource {
24771
24903
  const body = admitInventoryLocation(b, false);
24772
24904
  const opts2 = snapshotMutationOptions(supplied);
24773
24905
  if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
24774
- const checkCurrent = (current) => checkInventoryLocationCurrent(body, current);
24906
+ const checkCurrent = (current) => checkInventoryLocationCurrent(body, current, id);
24775
24907
  if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
24776
24908
  const checkedBaseUrl = this.http.baseUrl;
24777
24909
  try {
@@ -26086,7 +26218,11 @@ function resolveDispatchArgs(record, argsIn) {
26086
26218
  const names = Object.keys(schema);
26087
26219
  const unknown = Object.keys(byName).filter((k) => !names.includes(k));
26088
26220
  if (unknown.length > 0) bad(`has no input named ${unknown.slice(0, 10).map((k) => `"${k}"`).join(", ")}${unknown.length > 10 ? ` (and ${unknown.length - 10} more)` : ""} (declared: ${declaredArgList(record)})`);
26089
- const values = names.map((n) => byName[n]);
26221
+ const values = names.map((name) => {
26222
+ if (Object.hasOwn(byName, name)) return byName[name];
26223
+ if (!schema[name].required && name in byName) bad(`named input "${name}" must be supplied directly`);
26224
+ return void 0;
26225
+ });
26090
26226
  const missing = names.filter((n, i) => schema[n].required && values[i] === void 0);
26091
26227
  if (missing.length > 0) bad(`requires named input ${missing.map((k) => `"${k}"`).join(", ")} (declared: ${declaredArgList(record)})`);
26092
26228
  const last = values.findLastIndex((value) => value !== void 0);
@@ -26118,12 +26254,26 @@ function captureDispatchArgs(record, argsIn) {
26118
26254
  );
26119
26255
  }
26120
26256
  const captured = [];
26257
+ const isWrite = record.effect !== "read";
26121
26258
  for (let i = 0; i < length; i += 1) {
26122
- const value = args[i];
26123
- captured.push(value);
26124
- if (value === void 0) continue;
26125
26259
  const name = names[i];
26126
26260
  const spec = schema[name];
26261
+ const supplied = Object.hasOwn(args, i);
26262
+ const value = supplied ? args[i] : void 0;
26263
+ if (!supplied && !spec.required && i in args) {
26264
+ throw new AutotaskConfigError(
26265
+ `invoke: "${operation}" positional input ${i + 1} (${name}) must be supplied directly`,
26266
+ { operation }
26267
+ );
26268
+ }
26269
+ if (spec.required && (!supplied || isWrite && value === void 0)) {
26270
+ throw new AutotaskConfigError(
26271
+ `invoke: "${operation}" requires positional input ${i + 1} (${name}: ${spec.type})`,
26272
+ { operation }
26273
+ );
26274
+ }
26275
+ captured.push(value);
26276
+ if (value === void 0) continue;
26127
26277
  if (!looseTypeOk(spec.type, value)) {
26128
26278
  throw new AutotaskConfigError(
26129
26279
  `invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
@@ -26155,105 +26305,6 @@ function foldFlattenedOpts(record, toolArgs) {
26155
26305
  return { ...folded, opts: Object.fromEntries(flat.map((k) => [k, toolArgs[k]])) };
26156
26306
  }
26157
26307
 
26158
- // src/operations/invoke/inputSets.ts
26159
- var PARAMS_BAG_KEYS = {
26160
- query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
26161
- // No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
26162
- // called directly), so this entry never fires. It is KEPT so that a future
26163
- // `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
26164
- // cannot silently open the bag (the keys are the vendor `QueryParams` set
26165
- // the raw method accepts).
26166
- queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
26167
- // issue #145: the count bag carries the fieldCheck opt-out — the #140
26168
- // refusal's advised remedy (before, the closed bag refused the very key it
26169
- // advised, and the remedy looped into a second CONFIG_ERROR).
26170
- count: ["filter", "fieldCheck"]
26171
- };
26172
- var BAG_KEY_SYNONYMS = {
26173
- filters: "filter",
26174
- last: "latest",
26175
- // issue #59: the expected typo class (honoured only on `query`)
26176
- lmit: "limit",
26177
- page: "limit",
26178
- pageSize: "limit",
26179
- cursor: "limit",
26180
- maxrecords: "maxRecords",
26181
- fieldsPreset: "includeFields"
26182
- // issue #287: the preset was removed — the refusal points at the explicit includeFields
26183
- };
26184
- function levenshtein(a, b) {
26185
- if (a === b) return 0;
26186
- const prev = new Array(b.length + 1);
26187
- const cur = new Array(b.length + 1);
26188
- for (let j = 0; j <= b.length; j += 1) prev[j] = j;
26189
- for (let i = 1; i <= a.length; i += 1) {
26190
- cur[0] = i;
26191
- for (let j = 1; j <= b.length; j += 1) {
26192
- cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
26193
- }
26194
- for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
26195
- }
26196
- return prev[b.length] ?? 0;
26197
- }
26198
- function suggestForKey(key, valid) {
26199
- const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
26200
- if (synonym !== void 0 && valid.includes(synonym)) return synonym;
26201
- let best = null;
26202
- for (const v of valid) {
26203
- const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
26204
- if (best === null || dist < best.dist) best = { key: v, dist };
26205
- }
26206
- if (best !== null && best.dist <= 3) return best.key;
26207
- return null;
26208
- }
26209
- function keySuggestions(unknown, valid) {
26210
- return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
26211
- }
26212
- function validateParamsBag(record, args) {
26213
- if (record.inputSchemaStrict !== true) return;
26214
- const valid = PARAMS_BAG_KEYS[record.operation];
26215
- if (valid === void 0) return;
26216
- const bag = args?.[0];
26217
- if (bag === void 0 || bag === null || !isRecord2(bag)) return;
26218
- const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
26219
- if (unknown.length === 0) return;
26220
- const suggestions = keySuggestions(unknown, valid);
26221
- throw new AutotaskConfigError(
26222
- `invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
26223
- {
26224
- operation: record.id,
26225
- suggestedAction: suggestions.length > 0 ? `Fix the key name (${suggestions.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).` : `Pass only the valid keys (${valid.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).`
26226
- }
26227
- );
26228
- }
26229
- var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
26230
- function validateInvokeOptions(opts, operation) {
26231
- if (opts === void 0 || opts === null) return;
26232
- const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
26233
- if (unknown.length === 0) return;
26234
- const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
26235
- throw new AutotaskConfigError(
26236
- `invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
26237
- {
26238
- operation,
26239
- suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
26240
- }
26241
- );
26242
- }
26243
- function unknownKeysRefusal(raw, validKeys, subject, operation) {
26244
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
26245
- const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
26246
- if (unknown.length === 0) return null;
26247
- const suggestions = keySuggestions(unknown, [...validKeys]);
26248
- return new AutotaskConfigError(
26249
- `unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
26250
- {
26251
- ...operation !== void 0 ? { operation } : {},
26252
- suggestedAction: suggestions.length > 0 ? operation === void 0 ? `Fix the ${subject} name (${suggestions.join(", ")}); the tool's full contract is in the tool's inputSchema, served by the MCP client's list_tools.` : `Fix the ${subject} name (${suggestions.join(", ")}); the full contract is in the tool's inputSchema (autotask_describe).` : `Pass only the valid keys (${validKeys.join(", ")}).`
26253
- }
26254
- );
26255
- }
26256
-
26257
26308
  // src/operations/searchAcrossResources.ts
26258
26309
  var DEFAULT_LIMIT2 = 25;
26259
26310
  function resourceFor(client, key) {
@@ -26615,7 +26666,7 @@ function checkOptsBag(opts, problems) {
26615
26666
  }
26616
26667
  }
26617
26668
  if (opts?.names !== void 0 && typeof opts.names !== "boolean") problems.push(`names must be a boolean (got ${typeof opts.names})`);
26618
- if (opts?.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
26669
+ if (opts !== void 0 && Object.hasOwn(opts, "acknowledgeUnscoped") && opts.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
26619
26670
  problems.push(`acknowledgeUnscoped must be a boolean (got ${typeof opts.acknowledgeUnscoped})`);
26620
26671
  }
26621
26672
  }
@@ -26702,8 +26753,10 @@ async function checkFieldNames(resourceKey, conditions, opts, problems) {
26702
26753
  }
26703
26754
  async function validateAggregate(operation, filter, opts) {
26704
26755
  const problems = [];
26756
+ const acknowledgment = opts !== null && typeof opts === "object" ? Object.getOwnPropertyDescriptor(opts, "acknowledgeUnscoped") : void 0;
26705
26757
  const resourceKey = await parseOperationKey(operation, problems);
26706
26758
  const conditions = parseFilterConditions(filter, problems);
26759
+ const acknowledged = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") && acknowledgment.value === true && opts.acknowledgeUnscoped === true;
26707
26760
  checkOptsBag(opts, problems);
26708
26761
  if (resourceKey !== void 0) {
26709
26762
  opts = {
@@ -26730,7 +26783,7 @@ async function validateAggregate(operation, filter, opts) {
26730
26783
  { operation: "operations.aggregate" }
26731
26784
  );
26732
26785
  }
26733
- if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && opts.acknowledgeUnscoped !== true) {
26786
+ if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && !acknowledged) {
26734
26787
  throw new ScopeRequiredError(operation, { threshold: UNSCOPED_WALK_THRESHOLD }, "empty-filter");
26735
26788
  }
26736
26789
  return { resourceKey, conditions, groupBy, sum, top, limit };
@@ -31315,8 +31368,25 @@ function bufferResult(buf) {
31315
31368
  }
31316
31369
  var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
31317
31370
  function snapshotInvokeOptions(options, mode) {
31318
- const captured = isRecord2(options) ? snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS) : { ...options };
31319
- return { ...captured, mode };
31371
+ if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
31372
+ const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
31373
+ const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
31374
+ let confirmation;
31375
+ for (let owner = options; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
31376
+ confirmation = Object.getOwnPropertyDescriptor(owner, "confirm");
31377
+ if (confirmation !== void 0) break;
31378
+ }
31379
+ let confirm;
31380
+ if (confirmation !== void 0) {
31381
+ const visible = options.confirm;
31382
+ if (Object.hasOwn(confirmation, "value") && confirmation.value === visible || Object.hasOwn(confirmation, "get") && typeof confirmation.get === "function") confirm = visible;
31383
+ }
31384
+ const dryRun = options.dryRun;
31385
+ const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
31386
+ dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
31387
+ confirm
31388
+ });
31389
+ return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
31320
31390
  }
31321
31391
  async function resolveRecord(operation) {
31322
31392
  const record = (await operationIndex()).get(operation);
@@ -31530,15 +31600,19 @@ var PRE_REQUEST_VALIDATORS = [
31530
31600
  (c) => requireReadBack(c.record, c.operation, c.opts),
31531
31601
  (c) => {
31532
31602
  c.args = captureDispatchArgs(c.record, c.args);
31533
- const [bag, ...remaining] = c.args;
31534
- if (!c.boundedQuery && !c.countedQuery || !isRecord2(bag)) return;
31535
- c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...remaining];
31603
+ if (!c.boundedQuery && !c.countedQuery) return;
31604
+ const bag = ownQueryBag(c.args);
31605
+ if (bag === void 0) return;
31606
+ if (c.boundedQuery && "acknowledgeUnscoped" in bag && !Object.hasOwn(bag, "acknowledgeUnscoped")) {
31607
+ throw new AutotaskConfigError(`invoke: "${c.operation}" params bag key "acknowledgeUnscoped" must be supplied directly`, { operation: c.operation });
31608
+ }
31609
+ c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...c.args.slice(1)];
31536
31610
  },
31537
31611
  (c) => validateParamsBag(c.record, c.args),
31538
31612
  (c) => validateFreshSpelling(c.record, c.args),
31539
31613
  (c) => {
31540
31614
  if (!c.streaming) return;
31541
- const bag = c.args[0];
31615
+ const bag = ownQueryBag(c.args);
31542
31616
  if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
31543
31617
  throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
31544
31618
  }
@@ -31557,7 +31631,8 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
31557
31631
  const context = { record, operation, args: resolvedArgs, opts, client, holder, boundedQuery, countedQuery, streaming };
31558
31632
  await runPreRequestPass(context);
31559
31633
  const { args } = context;
31560
- const labelQuery = boundedQuery && readNamesOpt(client, args[0]?.["names"], `invoke: "${record.id}" params bag`);
31634
+ const queryParams = boundedQuery ? ownQueryBag(args) : void 0;
31635
+ const labelQuery = boundedQuery && readNamesOpt(client, queryParams?.["names"], `invoke: "${record.id}" params bag`);
31561
31636
  const methodName = boundedQuery ? "queryBounded" : record.operation;
31562
31637
  const method = streaming ? context.pageSession?.consume : holder[methodName];
31563
31638
  if (typeof method !== "function") {
@@ -31570,17 +31645,18 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
31570
31645
  const mutationOpts = buildMutationOpts(opts, isWrite);
31571
31646
  const callArgs = buildCallArgs(record, args, mutationOpts, isWrite);
31572
31647
  if (opts.fresh === true) appendFresh(record, callArgs);
31573
- if (boundedQuery) validateWalkBag(args[0]?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
31574
31648
  let scopeNote;
31575
- if (boundedQuery && args[0]?.["acknowledgeUnscoped"] !== true) {
31576
- scopeNote = (await guardUnscopedQueryWalk(holder, record.id, args[0])).note;
31649
+ if (boundedQuery) {
31650
+ validateWalkBag(queryParams?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
31651
+ const acknowledged = queryParams !== void 0 && Object.hasOwn(queryParams, "acknowledgeUnscoped") && queryParams.acknowledgeUnscoped === true;
31652
+ if (!acknowledged) scopeNote = (await guardUnscopedQueryWalk(holder, record.id, queryParams)).note;
31577
31653
  }
31578
31654
  return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
31579
31655
  }
31580
31656
  async function invokeMode(client, operation, argsIn = [], opts = {}) {
31581
31657
  const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
31582
31658
  const result = await method.apply(holder, callArgs);
31583
- if (labelQuery && args[0]?.["walk"] === void 0 && Array.isArray(result?.items)) {
31659
+ if (labelQuery && ownQueryBag(args)?.["walk"] === void 0 && Array.isArray(result?.items)) {
31584
31660
  const bounded = result;
31585
31661
  const labelled = await labelRows(client, record.resource, bounded.items);
31586
31662
  return { ...bounded, items: labelled.rows, ...labelled.names !== void 0 ? { names: labelled.names } : {}, ...scopeNote !== void 0 ? { scopeNote } : {} };