node-autotask 0.87.0 → 0.88.1

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 (45) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/MCP_TOOL_CATALOG.json +152 -9
  3. package/README.md +1 -1
  4. package/capabilities.json +546 -26
  5. package/dist/capabilities-data.js +545 -25
  6. package/dist/capabilities.cjs +4 -4
  7. package/dist/capabilities.js +1 -1
  8. package/dist/{chunk-G57Q7OAC.js → chunk-33UVHMFN.js} +2 -2
  9. package/dist/{chunk-BD4AUGCJ.cjs → chunk-CM5O672I.cjs} +5 -4
  10. package/dist/{chunk-HUA4WB4N.cjs → chunk-DSHWQMF2.cjs} +31 -30
  11. package/dist/{chunk-RU4ECNQN.cjs → chunk-JHDT4O7N.cjs} +200 -200
  12. package/dist/{chunk-NXSQXXNK.js → chunk-JVVE4XEN.js} +3 -2
  13. package/dist/{chunk-GAFG7RHG.js → chunk-KM7ITBOT.js} +541 -304
  14. package/dist/{chunk-YVNGUGG6.cjs → chunk-SHJ7EOBW.cjs} +3 -3
  15. package/dist/{chunk-7NKB4UXV.js → chunk-X6VWD6WW.js} +5 -4
  16. package/dist/{chunk-CUZJJCI5.cjs → chunk-YTOBU3Z6.cjs} +553 -316
  17. package/dist/{chunk-EXNDYJPG.js → chunk-ZADTVF6M.js} +3 -3
  18. package/dist/{index-Cxfr_DOD.d.cts → index-4jmitXBs.d.cts} +29 -1
  19. package/dist/{index-Cxfr_DOD.d.ts → index-4jmitXBs.d.ts} +29 -1
  20. package/dist/{index-CsL5gGJo.d.ts → index-GSA44LRd.d.ts} +13 -7
  21. package/dist/{index-DGiua9uK.d.cts → index-XDIy_GvD.d.cts} +13 -7
  22. package/dist/index.cjs +90 -87
  23. package/dist/index.d.cts +4 -3
  24. package/dist/index.d.ts +4 -3
  25. package/dist/index.js +9 -6
  26. package/dist/operations/index.cjs +53 -53
  27. package/dist/operations/index.d.cts +4 -4
  28. package/dist/operations/index.d.ts +4 -4
  29. package/dist/operations/index.js +3 -3
  30. package/dist/pool.cjs +13 -13
  31. package/dist/pool.d.cts +1 -1
  32. package/dist/pool.d.ts +1 -1
  33. package/dist/pool.js +5 -5
  34. package/dist/resources/index.cjs +28 -28
  35. package/dist/resources/index.d.cts +2 -2
  36. package/dist/resources/index.d.ts +2 -2
  37. package/dist/resources/index.js +4 -4
  38. package/dist/types/index.d.cts +1 -1
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/untrusted.cjs +11 -11
  41. package/dist/untrusted.d.cts +1 -1
  42. package/dist/untrusted.d.ts +1 -1
  43. package/dist/untrusted.js +1 -1
  44. package/docs/API.md +6 -2
  45. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { loadCapabilityRecords } from './chunk-EXNDYJPG.js';
2
- import { NoopLogger, REDACTED, deepMarkUntrusted, wrapUntrusted } from './chunk-7NKB4UXV.js';
1
+ import { loadCapabilityRecords } from './chunk-ZADTVF6M.js';
2
+ import { NoopLogger, REDACTED, deepMarkUntrusted, wrapUntrusted } from './chunk-X6VWD6WW.js';
3
3
  import { randomUUID, createHash } from 'crypto';
4
4
  import { AsyncLocalStorage } from 'async_hooks';
5
5
 
@@ -323,12 +323,10 @@ function redactResponseBody(value, policy) {
323
323
  return value.map((entry) => redactResponseBody(entry, policy));
324
324
  }
325
325
  if (!isPlainRecord(value)) return value;
326
- const out = {};
327
- for (const [key, entry] of Object.entries(value)) {
326
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => {
328
327
  const pinned = SECRET_SET.has(key) || personal && OPTIONAL_SET.has(key);
329
- out[key] = pinned ? REDACTED : redactResponseBody(entry, policy);
330
- }
331
- return out;
328
+ return [key, pinned ? REDACTED : redactResponseBody(entry, policy)];
329
+ }));
332
330
  }
333
331
 
334
332
  // src/errors/from-status.ts
@@ -1450,8 +1448,14 @@ function isAuditDecimalId(id) {
1450
1448
  function isRecord2(value) {
1451
1449
  return typeof value === "object" && value !== null && !Array.isArray(value);
1452
1450
  }
1453
- function snapshotFields(record, keys) {
1454
- const captured = { ...record };
1451
+ function snapshotFields(record, keys, fixed) {
1452
+ const captured = fixed === void 0 ? { ...record } : {
1453
+ ...Object.fromEntries(Reflect.ownKeys(record).flatMap((key) => {
1454
+ if (Object.hasOwn(fixed, key) || !Object.prototype.propertyIsEnumerable.call(record, key)) return [];
1455
+ return [[key, Reflect.get(record, key)]];
1456
+ })),
1457
+ ...fixed
1458
+ };
1455
1459
  for (const key of keys) {
1456
1460
  if (Object.hasOwn(captured, key)) continue;
1457
1461
  const value = Reflect.get(record, key);
@@ -1671,9 +1675,20 @@ function snapshotQueryFilter(filter) {
1671
1675
  throw invalidFilterShape(filter);
1672
1676
  }
1673
1677
  function snapshotQueryBag(bag, keys) {
1674
- const snapshot = snapshotFields(bag, keys);
1678
+ let fixed;
1679
+ if (keys.includes("acknowledgeUnscoped")) {
1680
+ const acknowledgment = Object.getOwnPropertyDescriptor(bag, "acknowledgeUnscoped");
1681
+ const direct = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") ? acknowledgment.value : void 0;
1682
+ const filter = Reflect.get(bag, "filter");
1683
+ const capturedFilter = filter === void 0 ? void 0 : snapshotQueryFilter(filter);
1684
+ fixed = {
1685
+ filter: capturedFilter,
1686
+ acknowledgeUnscoped: direct === true ? Reflect.get(bag, "acknowledgeUnscoped") === true : direct
1687
+ };
1688
+ }
1689
+ const snapshot = snapshotFields(bag, keys, fixed);
1675
1690
  const captured = snapshot;
1676
- if (captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
1691
+ if (fixed === void 0 && captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
1677
1692
  if (Array.isArray(captured.includeFields)) {
1678
1693
  const fields = captured.includeFields;
1679
1694
  captured.includeFields = Array.from({ length: fields.length }, (_, i) => fields[i]);
@@ -10936,6 +10951,59 @@ var RELATIONSHIP_MAP = {
10936
10951
  },
10937
10952
  "deleteBoundary": null,
10938
10953
  "markerField": null
10954
+ },
10955
+ "inventory_locations": {
10956
+ "resource": "inventory_locations",
10957
+ "apiEntity": "InventoryLocation",
10958
+ "kind": "entity",
10959
+ "path": "InventoryLocations",
10960
+ "parentScoped": false,
10961
+ "tier": "extended",
10962
+ "workflowResource": false,
10963
+ "group": "A",
10964
+ "parent": null,
10965
+ "children": [],
10966
+ "naturalKeys": {
10967
+ "hasSearch": false,
10968
+ "searchCovers": null,
10969
+ "findBy": []
10970
+ },
10971
+ "blindSurfaces": null,
10972
+ "zoneFacts": {
10973
+ "createRequiredSet": [
10974
+ "locationName",
10975
+ "isActive"
10976
+ ],
10977
+ "createGuidance": {
10978
+ "createOp": "inventory_locations.create",
10979
+ "parentScoped": false,
10980
+ "liveProvenPrefix": [],
10981
+ "unproven": true,
10982
+ "blocker": {
10983
+ "kind": "unknown",
10984
+ "message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
10985
+ "remedy": "Read current metadata, supply locationName and isActive, and preview first.",
10986
+ "requires": {
10987
+ "allOf": [
10988
+ "locationName",
10989
+ "isActive"
10990
+ ]
10991
+ }
10992
+ },
10993
+ "vendorEvidence": [
10994
+ "https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
10995
+ ],
10996
+ "deleteBoundary": {
10997
+ "available": false,
10998
+ "note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
10999
+ }
11000
+ }
11001
+ },
11002
+ "deleteBoundary": {
11003
+ "note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API.",
11004
+ "proof": "spec-derived"
11005
+ },
11006
+ "markerField": null
10939
11007
  }
10940
11008
  };
10941
11009
  var BLIND_SURFACE_STAMPS = {
@@ -11047,7 +11115,8 @@ var DELETE_BOUNDARY_NOTES = {
11047
11115
  "user_defined_field_definitions": "the vendor defines no DELETE for user_defined_field_definitions (spec-derived: the vendored api-docs.json defines no DELETE on the entity's paths) \u2014 a UDF definition cannot be deleted through the API; deactivation is via isActive (vendor soft-removal); hard cleanup is UI-only.",
11048
11116
  "user_defined_field_list_items": "the vendor defines no DELETE for user_defined_field_list_items (spec-derived: the vendored api-docs.json defines no DELETE on the standalone or parent-scoped ListItems paths) \u2014 a picklist value cannot be deleted through the API; deactivation is via isActive (vendor soft-removal); hard cleanup is UI-only.",
11049
11117
  "task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
11050
- "time_off_requests": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting."
11118
+ "time_off_requests": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting.",
11119
+ "inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
11051
11120
  };
11052
11121
  var RESPONSE_DRIFT_MARKERS = {
11053
11122
  "ticket_checklist_libraries": {
@@ -12483,6 +12552,15 @@ var EMPTY_REASON_STAMPS = {
12483
12552
  "authority": null,
12484
12553
  "remedy": "verify the created record by id (ticket_checklist_libraries.get) \u2014 the create may have succeeded despite the drifted envelope"
12485
12554
  }
12555
+ },
12556
+ "inventory_locations": {
12557
+ "get": {
12558
+ "surface": "inventory_locations.get",
12559
+ "kind": "tenant-empty-for-user",
12560
+ "note": "No inventory location at this ID was visible to this API user. This is INCONCLUSIVE about tenant inventory because visibility may be limited by Inventory module access and permissions.",
12561
+ "authority": "inventory_locations.get",
12562
+ "remedy": "Verify the ID and check View permission, Inventory access and Inventory Manage Locations with an authorized user."
12563
+ }
12486
12564
  }
12487
12565
  };
12488
12566
  var POINTER_NOTES = {
@@ -13965,6 +14043,31 @@ var CREATE_GUIDANCE = {
13965
14043
  "note": null
13966
14044
  }
13967
14045
  },
14046
+ {
14047
+ "resource": "inventory_locations",
14048
+ "createOp": "inventory_locations.create",
14049
+ "parentScoped": false,
14050
+ "liveProvenPrefix": [],
14051
+ "unproven": true,
14052
+ "blocker": {
14053
+ "kind": "unknown",
14054
+ "message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
14055
+ "remedy": "Read current metadata, supply locationName and isActive, and preview first.",
14056
+ "requires": {
14057
+ "allOf": [
14058
+ "locationName",
14059
+ "isActive"
14060
+ ]
14061
+ }
14062
+ },
14063
+ "vendorEvidence": [
14064
+ "https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
14065
+ ],
14066
+ "deleteBoundary": {
14067
+ "available": false,
14068
+ "note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
14069
+ }
14070
+ },
13968
14071
  {
13969
14072
  "resource": "inventory_products",
13970
14073
  "createOp": "inventory_products.create",
@@ -15545,7 +15648,7 @@ var CREATE_GUIDANCE = {
15545
15648
  }
15546
15649
  ],
15547
15650
  "counts": {
15548
- "total": 116,
15651
+ "total": 117,
15549
15652
  "byKind": {
15550
15653
  "ok": 41,
15551
15654
  "blind-reference": 16,
@@ -15555,7 +15658,7 @@ var CREATE_GUIDANCE = {
15555
15658
  "resource-role-pair": 2,
15556
15659
  "delete-absent": 0,
15557
15660
  "non-mutable": 0,
15558
- "unknown": 40
15661
+ "unknown": 41
15559
15662
  }
15560
15663
  }
15561
15664
  };
@@ -16334,6 +16437,9 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
16334
16437
  "keywords",
16335
16438
  "referenceLink",
16336
16439
  "title"
16440
+ ],
16441
+ "inventory_locations": [
16442
+ "locationName"
16337
16443
  ]
16338
16444
  };
16339
16445
 
@@ -16792,22 +16898,32 @@ function auditReadTarget(path, operation) {
16792
16898
  function isKnowledgeBaseRootResource(resource) {
16793
16899
  return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
16794
16900
  }
16795
- var KNOWLEDGE_BASE_PATH = /^\/v1\.0\/(?:KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
16796
- function knowledgeBaseResponseTarget(path, method, operation) {
16797
- const match = KNOWLEDGE_BASE_PATH.exec(path);
16901
+ function isExactRecordResource(resource) {
16902
+ return resource === "inventory_locations" || isKnowledgeBaseRootResource(resource);
16903
+ }
16904
+ var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
16905
+ function exactRecordResponseTarget(path, method, operation) {
16906
+ const match = EXACT_RECORD_PATH.exec(path);
16798
16907
  if (match === null) return void 0;
16799
16908
  const suffix = match[1]?.toLowerCase();
16800
16909
  if (suffix === "query/count") return suffix;
16801
16910
  if (suffix?.startsWith("query")) return "query";
16802
16911
  if (suffix !== void 0 && !isAuditDecimalId(suffix)) {
16803
- throw new AutotaskConfigError("Knowledge Base record ID must be a non-negative signed 64-bit integer.", { operation });
16912
+ throw new AutotaskConfigError("Record ID must be a non-negative signed 64-bit integer.", { operation });
16804
16913
  }
16805
16914
  return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
16806
16915
  }
16916
+ function ownField(value, key) {
16917
+ return isRecord2(value) && Object.hasOwn(value, key) ? value[key] : void 0;
16918
+ }
16919
+ function receiptId(body) {
16920
+ const itemId = ownField(body, "itemId");
16921
+ return itemId === void 0 ? ownField(body, "id") : itemId;
16922
+ }
16807
16923
  function isNonNegativeInt64(id) {
16808
16924
  return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
16809
16925
  }
16810
- function validateKnowledgeBaseResponse(body, target, path, method, requestBody, operation) {
16926
+ function validateExactRecordResponse(body, target, path, method, requestBody, operation) {
16811
16927
  const invalid = (message) => {
16812
16928
  throw new AutotaskError(message, { code: "INVALID_RESPONSE", category: "server", operation, suggestedAction: INVALID_SHAPE_ACTION });
16813
16929
  };
@@ -16816,41 +16932,43 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
16816
16932
  return;
16817
16933
  }
16818
16934
  if (target === "query") {
16819
- if (!isRecord2(body) || !Array.isArray(body.items) || !isRecord2(body.pageDetails)) {
16820
- return invalid("Expected a Knowledge Base query page with paging details");
16821
- }
16822
- if (!body.items.every(hasExactRecordId)) invalid("Expected valid record IDs in the Knowledge Base query response");
16823
- if (body.pageDetails.count !== body.items.length) {
16824
- invalid("The Knowledge Base page record count did not match its rows");
16825
- }
16826
- const cursor = body.pageDetails.nextPageUrl;
16935
+ const items = ownField(body, "items");
16936
+ const paging = ownField(body, "pageDetails");
16937
+ if (!Array.isArray(items) || !isRecord2(paging)) {
16938
+ return invalid("Expected a query page with paging details");
16939
+ }
16940
+ if (!items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
16941
+ if (ownField(paging, "count") !== items.length) invalid("The page record count did not match its rows");
16942
+ const cursor = ownField(paging, "nextPageUrl");
16827
16943
  if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
16828
- invalid("Expected a valid Knowledge Base query cursor or an explicit end of results");
16944
+ invalid("Expected a valid query cursor or an explicit end of results");
16829
16945
  }
16830
16946
  return;
16831
16947
  }
16832
16948
  const parts = path.replace(/\/$/, "").split("/");
16833
16949
  const expectedId = parts.at(-1);
16834
16950
  if (target === "mutation") {
16835
- const id = isRecord2(body) ? body.itemId === void 0 ? body.id : body.itemId : void 0;
16836
- if (!isNonNegativeInt64(id)) invalid("Expected a valid Knowledge Base mutation receipt");
16837
- const expected = method === "DELETE" ? expectedId : isRecord2(requestBody) ? requestBody.id : void 0;
16838
- if (expected !== void 0 && String(id) !== String(expected)) {
16951
+ const id2 = receiptId(body);
16952
+ if (!isNonNegativeInt64(id2)) invalid("Expected a valid mutation receipt");
16953
+ const expected = method === "DELETE" ? expectedId : ownField(requestBody, "id");
16954
+ if (expected !== void 0 && String(id2) !== String(expected)) {
16839
16955
  invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
16840
16956
  }
16841
16957
  return;
16842
16958
  }
16843
- const item = isRecord2(body) ? body.item : void 0;
16959
+ const item = ownField(body, "item");
16844
16960
  if (item === null) return;
16845
- if (!isRecord2(item) || !isNonNegativeInt64(item.id)) {
16846
- return invalid("Expected a Knowledge Base item envelope with a valid record ID");
16961
+ const id = ownField(item, "id");
16962
+ if (!isNonNegativeInt64(id)) {
16963
+ return invalid("Expected an item envelope with a valid record ID");
16847
16964
  }
16848
- const resource = parts.at(-2)?.toLowerCase() === "knowledgebasearticles" ? "article" : "category";
16849
- if (String(item.id) !== expectedId) {
16965
+ const entity = parts.at(-2)?.toLowerCase();
16966
+ const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
16967
+ if (String(id) !== expectedId) {
16850
16968
  throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
16851
16969
  }
16852
16970
  if (parts.length === 6) {
16853
- const parent = item.articleCategoryID;
16971
+ const parent = ownField(item, "articleCategoryID");
16854
16972
  if (typeof parent !== "number" || !Number.isInteger(parent) || parent <= 0 || parent > 2147483647) {
16855
16973
  invalid("Expected a valid category ID in the Knowledge Base article response");
16856
16974
  }
@@ -16859,16 +16977,16 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
16859
16977
  }
16860
16978
  }
16861
16979
  }
16862
- function serializeKnowledgeBaseUpdate(body, operation) {
16863
- if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
16980
+ function serializeExactRecordUpdate(body, operation) {
16981
+ if (!isRecord2(body) || !Object.hasOwn(body, "id") || typeof body.id !== "string") return JSON.stringify(body);
16864
16982
  if (!isAuditDecimalId(body.id)) {
16865
- throw new AutotaskConfigError("Knowledge Base update id must be a non-negative signed 64-bit integer.", { operation });
16983
+ throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
16866
16984
  }
16867
16985
  const { rawJSON } = JSON;
16868
16986
  return JSON.stringify({ ...body, id: rawJSON(body.id) });
16869
16987
  }
16870
- function decodeResponseJson(text, auditTarget, knowledgeBaseTarget) {
16871
- const target = auditTarget ?? knowledgeBaseTarget;
16988
+ function decodeResponseJson(text, auditTarget, recordTarget) {
16989
+ const target = auditTarget ?? recordTarget;
16872
16990
  if (target === void 0) return JSON.parse(text);
16873
16991
  if (target === "query/count") {
16874
16992
  return JSON.parse(text, (key, value, context) => key === "queryCount" && typeof value === "number" && !isAuditDecimalId(context?.source ?? "") ? null : value);
@@ -16882,12 +17000,12 @@ function decodeResponseJson(text, auditTarget, knowledgeBaseTarget) {
16882
17000
  }
16883
17001
  return value;
16884
17002
  });
16885
- const rows = isRecord2(body) ? target === "query" ? body.items : [target === "mutation" ? body : body.item] : void 0;
17003
+ const rows = target === "query" ? ownField(body, "items") : [target === "mutation" ? body : ownField(body, "item")];
16886
17004
  if (Array.isArray(rows)) {
16887
17005
  for (const row of rows) {
16888
17006
  if (!isRecord2(row)) continue;
16889
- const key = target === "mutation" && row.itemId !== void 0 ? "itemId" : "id";
16890
- const value = row[key];
17007
+ const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
17008
+ const value = ownField(row, key);
16891
17009
  if (typeof value !== "number") continue;
16892
17010
  const token = (key === "id" ? idTokens : receiptTokens).get(row);
16893
17011
  if (token === void 0 || !isAuditDecimalId(token)) row[key] = null;
@@ -16897,8 +17015,7 @@ function decodeResponseJson(text, auditTarget, knowledgeBaseTarget) {
16897
17015
  return body;
16898
17016
  }
16899
17017
  function hasExactRecordId(item) {
16900
- if (!isRecord2(item)) return false;
16901
- return isNonNegativeInt64(item.id);
17018
+ return isNonNegativeInt64(ownField(item, "id"));
16902
17019
  }
16903
17020
  function isAuditPage(body) {
16904
17021
  if (!Array.isArray(body.items) || !isRecord2(body.pageDetails)) return false;
@@ -16928,9 +17045,9 @@ function attachEmptyReasonDetails(err) {
16928
17045
  const resource = err.operation.slice(0, dot);
16929
17046
  const op = err.operation.slice(dot + 1);
16930
17047
  const surface = err.operation;
16931
- const stamp = EMPTY_REASON_STAMPS[resource]?.[op];
16932
- const pointer = POINTER_NOTES[surface];
16933
17048
  const isGetMiss = err instanceof NotFoundError && op === "get";
17049
+ const stamp = op !== "get" || isGetMiss ? EMPTY_REASON_STAMPS[resource]?.[op] : void 0;
17050
+ const pointer = POINTER_NOTES[surface];
16934
17051
  if (stamp === void 0 && pointer === void 0 && !isGetMiss) return;
16935
17052
  err.details = { ...err.details ?? {} };
16936
17053
  if (stamp !== void 0) {
@@ -16967,7 +17084,7 @@ function unwrapItems(body, operation) {
16967
17084
  return { items: body.items, pageDetails: body.pageDetails };
16968
17085
  }
16969
17086
  function unwrapItem(body, id, operation, entity) {
16970
- if (!isRecord2(body) || !("item" in body)) {
17087
+ if (!isRecord2(body) || !Object.hasOwn(body, "item")) {
16971
17088
  throw new AutotaskError("Expected the item envelope { item }; got a different shape", {
16972
17089
  code: "INVALID_RESPONSE",
16973
17090
  category: "server",
@@ -16993,7 +17110,7 @@ function unwrapItem(body, id, operation, entity) {
16993
17110
  return item;
16994
17111
  }
16995
17112
  function unwrapQueryCount(body, operation) {
16996
- const count = isRecord2(body) ? body.queryCount : void 0;
17113
+ const count = ownField(body, "queryCount");
16997
17114
  if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > 2147483647) {
16998
17115
  const err = new AutotaskError("Expected the count envelope { queryCount: non-negative int32 }", {
16999
17116
  code: "INVALID_RESPONSE",
@@ -17007,7 +17124,7 @@ function unwrapQueryCount(body, operation) {
17007
17124
  return count;
17008
17125
  }
17009
17126
  function unwrapOperation(body, operation) {
17010
- const value = isRecord2(body) ? body.itemId !== void 0 ? body.itemId : body.id : void 0;
17127
+ const value = receiptId(body);
17011
17128
  const idValue = toIdentifierId(value);
17012
17129
  if (idValue === void 0) {
17013
17130
  const err = new AutotaskError(
@@ -17042,7 +17159,7 @@ function normalizeZoneBase(raw) {
17042
17159
  return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
17043
17160
  }
17044
17161
  function canReResolveZone(reResolveZoneOn401, zone, opts) {
17045
- if (!reResolveZoneOn401) return false;
17162
+ if (!reResolveZoneOn401 || opts.checkedBaseUrl !== void 0) return false;
17046
17163
  if (zone === void 0 || zone === "other") return false;
17047
17164
  if (!opts.path.startsWith("/") || /^https?:\/\//i.test(opts.path)) return false;
17048
17165
  return true;
@@ -17435,6 +17552,7 @@ var HttpClient = class {
17435
17552
  if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
17436
17553
  this.gate(s, false);
17437
17554
  if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
17555
+ this.assertCheckedBase(opts);
17438
17556
  const admission = admitHourlyAttempt(s.url, this.hourly, Date.now());
17439
17557
  if (!admission.admitted) {
17440
17558
  releaseCurrent();
@@ -17511,13 +17629,13 @@ var HttpClient = class {
17511
17629
  }
17512
17630
  let parsed;
17513
17631
  try {
17514
- parsed = decodeResponseJson(text, s.auditTarget, s.knowledgeBaseTarget);
17632
+ parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget);
17515
17633
  } catch {
17516
17634
  return this.handleNonJson2xx(s, res, status, text);
17517
17635
  }
17518
17636
  validateAuditResponse(parsed, s.auditTarget, opts.operation);
17519
- if (s.knowledgeBaseTarget !== void 0) {
17520
- validateKnowledgeBaseResponse(parsed, s.knowledgeBaseTarget, decodeURIComponent(opts.path), method, opts.body, opts.operation);
17637
+ if (s.recordTarget !== void 0) {
17638
+ validateExactRecordResponse(parsed, s.recordTarget, decodeURIComponent(opts.path), method, opts.body, opts.operation);
17521
17639
  }
17522
17640
  return {
17523
17641
  done: true,
@@ -17704,6 +17822,13 @@ var HttpClient = class {
17704
17822
  this.readCache?.clear();
17705
17823
  if (/\/V1\.0\/Companies(?:\/[^/]+)?(?:\?|$)/i.test(opts.path)) invalidateCompanyIndex(this);
17706
17824
  }
17825
+ assertCheckedBase(opts) {
17826
+ const baseUrl = this.baseUrl;
17827
+ if (opts.checkedBaseUrl !== void 0 && opts.checkedBaseUrl !== baseUrl) {
17828
+ throw new AutotaskConfigError("The Autotask zone changed after preflight. Preview or check the target again.", { operation: opts.operation });
17829
+ }
17830
+ return baseUrl;
17831
+ }
17707
17832
  /**
17708
17833
  * One request: build URL/headers, apply the whole-call deadline, retry
17709
17834
  * idempotent methods on 429/5xx, map failures to the typed errors.
@@ -17711,8 +17836,9 @@ var HttpClient = class {
17711
17836
  */
17712
17837
  async request(opts) {
17713
17838
  const method = opts.method;
17714
- const url = buildUrl(this.baseUrl, opts.path, opts.query);
17715
- const wirePath = url.slice(this.baseUrl.length);
17839
+ const baseUrl = this.assertCheckedBase(opts);
17840
+ const url = buildUrl(baseUrl, opts.path, opts.query);
17841
+ const wirePath = url.slice(baseUrl.length);
17716
17842
  const path = wirePath.split("?", 1)[0];
17717
17843
  const route = decodeURIComponent(path);
17718
17844
  const auditTarget = auditReadTarget(route, opts.operation);
@@ -17722,13 +17848,14 @@ var HttpClient = class {
17722
17848
  const queryRoute = /\/query(?:\/|$)/i.test(route);
17723
17849
  const getQuery = method === "GET" && queryRoute && requestUrl.search !== "";
17724
17850
  if (getQuery) assertGetQueryUrlLength(url);
17725
- const knowledgeBaseTarget = knowledgeBaseResponseTarget(route, method, opts.operation);
17726
- const knowledgeBaseUpdate = knowledgeBaseTarget === "mutation" && (method === "PUT" || method === "PATCH");
17727
- const bodyText = knowledgeBaseUpdate && opts.body !== void 0 ? serializeKnowledgeBaseUpdate(opts.body, opts.operation) : opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
17851
+ const recordTarget = exactRecordResponseTarget(route, method, opts.operation);
17852
+ const exactRecordUpdate = recordTarget === "mutation" && (method === "PUT" || method === "PATCH");
17853
+ const bodyText = exactRecordUpdate && opts.body !== void 0 ? serializeExactRecordUpdate(opts.body, opts.operation) : opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
17728
17854
  if (queryRoute) {
17729
17855
  const audit = auditTarget === "query" || auditTarget === "query/count";
17730
- const knowledgeBase = knowledgeBaseTarget === "query" || knowledgeBaseTarget === "query/count";
17731
- const exactIdLabel = audit ? "audit log" : knowledgeBase ? "Knowledge Base record" : void 0;
17856
+ const exactRecord = recordTarget === "query" || recordTarget === "query/count";
17857
+ const recordLabel = /^\/v1\.0\/InventoryLocations\//i.test(route) ? "inventory location" : "Knowledge Base record";
17858
+ const exactIdLabel = audit ? "audit log" : exactRecord ? recordLabel : void 0;
17732
17859
  assertQueryFilters(opts, requestUrl, bodyText, exactIdLabel);
17733
17860
  }
17734
17861
  opts = { ...opts, path };
@@ -17744,7 +17871,7 @@ var HttpClient = class {
17744
17871
  getQuery,
17745
17872
  method,
17746
17873
  auditTarget,
17747
- knowledgeBaseTarget,
17874
+ recordTarget,
17748
17875
  url,
17749
17876
  headers,
17750
17877
  bodyText,
@@ -18325,13 +18452,13 @@ async function runBounded(fn, items, opts) {
18325
18452
  const results = new Array(items.length);
18326
18453
  let next = 0;
18327
18454
  let failure;
18328
- const fail3 = (error, index) => {
18455
+ const fail4 = (error, index) => {
18329
18456
  if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
18330
18457
  };
18331
18458
  const worker = async () => {
18332
18459
  while (failure === void 0 && next < items.length) {
18333
18460
  if (signal?.aborted) {
18334
- fail3(signal.reason, -1);
18461
+ fail4(signal.reason, -1);
18335
18462
  return;
18336
18463
  }
18337
18464
  const i = next++;
@@ -18341,7 +18468,7 @@ async function runBounded(fn, items, opts) {
18341
18468
  results[i] = settle ? { status: "fulfilled", value } : value;
18342
18469
  } catch (error) {
18343
18470
  if (settle) results[i] = { status: "rejected", reason: error };
18344
- else fail3(error, i);
18471
+ else fail4(error, i);
18345
18472
  }
18346
18473
  }
18347
18474
  };
@@ -18852,7 +18979,7 @@ function computeFieldDiff(current, data) {
18852
18979
  const out = [];
18853
18980
  for (const [field, to] of Object.entries(data)) {
18854
18981
  if (field === "id" || to === void 0) continue;
18855
- const from = current[field];
18982
+ const from = Object.hasOwn(current, field) ? current[field] : void 0;
18856
18983
  if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
18857
18984
  out.push({ field, from: from === void 0 ? null : from, to });
18858
18985
  }
@@ -19690,6 +19817,130 @@ function notPersistedFields(sent, stored) {
19690
19817
  return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== REDACTED && !same(value, stored[key])).map(([key]) => key);
19691
19818
  }
19692
19819
 
19820
+ // src/operations/invoke/inputSets.ts
19821
+ var PARAMS_BAG_KEYS = {
19822
+ query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
19823
+ // No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
19824
+ // called directly), so this entry never fires. It is KEPT so that a future
19825
+ // `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
19826
+ // cannot silently open the bag (the keys are the vendor `QueryParams` set
19827
+ // the raw method accepts).
19828
+ queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
19829
+ // issue #145: the count bag carries the fieldCheck opt-out — the #140
19830
+ // refusal's advised remedy (before, the closed bag refused the very key it
19831
+ // advised, and the remedy looped into a second CONFIG_ERROR).
19832
+ count: ["filter", "fieldCheck"]
19833
+ };
19834
+ var BAG_KEY_SYNONYMS = {
19835
+ filters: "filter",
19836
+ last: "latest",
19837
+ // issue #59: the expected typo class (honoured only on `query`)
19838
+ lmit: "limit",
19839
+ page: "limit",
19840
+ pageSize: "limit",
19841
+ cursor: "limit",
19842
+ maxrecords: "maxRecords",
19843
+ fieldsPreset: "includeFields"
19844
+ // issue #287: the preset was removed — the refusal points at the explicit includeFields
19845
+ };
19846
+ function levenshtein(a, b) {
19847
+ if (a === b) return 0;
19848
+ const prev = new Array(b.length + 1);
19849
+ const cur = new Array(b.length + 1);
19850
+ for (let j = 0; j <= b.length; j += 1) prev[j] = j;
19851
+ for (let i = 1; i <= a.length; i += 1) {
19852
+ cur[0] = i;
19853
+ for (let j = 1; j <= b.length; j += 1) {
19854
+ cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
19855
+ }
19856
+ for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
19857
+ }
19858
+ return prev[b.length] ?? 0;
19859
+ }
19860
+ function suggestForKey(key, valid) {
19861
+ const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
19862
+ if (synonym !== void 0 && valid.includes(synonym)) return synonym;
19863
+ let best = null;
19864
+ for (const v of valid) {
19865
+ const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
19866
+ if (best === null || dist < best.dist) best = { key: v, dist };
19867
+ }
19868
+ if (best !== null && best.dist <= 3) return best.key;
19869
+ return null;
19870
+ }
19871
+ function keySuggestions(unknown, valid) {
19872
+ return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
19873
+ }
19874
+ function ownQueryBag(args) {
19875
+ const bag = args != null && Object.hasOwn(args, 0) ? args[0] : void 0;
19876
+ return isRecord2(bag) ? bag : void 0;
19877
+ }
19878
+ function validateParamsBag(record, args) {
19879
+ if (record.inputSchemaStrict !== true) return;
19880
+ const valid = PARAMS_BAG_KEYS[record.operation];
19881
+ if (valid === void 0) return;
19882
+ const bag = ownQueryBag(args);
19883
+ if (bag === void 0) return;
19884
+ const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
19885
+ if (unknown.length === 0) return;
19886
+ const suggestions = keySuggestions(unknown, valid);
19887
+ throw new AutotaskConfigError(
19888
+ `invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
19889
+ {
19890
+ operation: record.id,
19891
+ 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).`
19892
+ }
19893
+ );
19894
+ }
19895
+ var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
19896
+ function validateInvokeOptions(opts, operation) {
19897
+ if (opts === void 0 || opts === null) return;
19898
+ const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
19899
+ if (unknown.length === 0) return;
19900
+ const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
19901
+ throw new AutotaskConfigError(
19902
+ `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)`,
19903
+ {
19904
+ operation,
19905
+ suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
19906
+ }
19907
+ );
19908
+ }
19909
+ function unknownKeysRefusal(raw, validKeys, subject, operation) {
19910
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
19911
+ const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
19912
+ if (unknown.length === 0) return null;
19913
+ const suggestions = keySuggestions(unknown, [...validKeys]);
19914
+ return new AutotaskConfigError(
19915
+ `unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
19916
+ {
19917
+ ...operation !== void 0 ? { operation } : {},
19918
+ 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(", ")}).`
19919
+ }
19920
+ );
19921
+ }
19922
+
19923
+ // src/resources/special/inventoryLocations.ts
19924
+ var fail = (message) => {
19925
+ throw new AutotaskConfigError(`inventory_locations: ${message}`);
19926
+ };
19927
+ function admitInventoryLocation(value, creating) {
19928
+ if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
19929
+ const body = { ...value };
19930
+ for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
19931
+ const hasName = Object.hasOwn(body, "locationName");
19932
+ const hasActive = Object.hasOwn(body, "isActive");
19933
+ 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");
19934
+ if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
19935
+ if (!creating && !hasName && !hasActive) fail("update must contain locationName or isActive");
19936
+ return body;
19937
+ }
19938
+ function checkInventoryLocationCurrent(value, current, id) {
19939
+ if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail("current record requires its own id");
19940
+ if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail("current record id must match the requested id");
19941
+ 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");
19942
+ }
19943
+
19693
19944
  // src/resources/base/types.ts
19694
19945
  var BOUNDED_QUERY_DEFAULT_LIMIT = 500;
19695
19946
  var BOUNDED_QUERY_MAX_LIMIT = 2500;
@@ -19856,6 +20107,7 @@ var MODEL_FIELD_SETS = {
19856
20107
  "expense_reports": ["id", "amountDue", "approvedDate", "approverID", "departmentNumber", "internalCurrencyCashAdvanceAmount", "internalCurrencyExpenseTotal", "name", "organizationalLevelAssociationID", "quickBooksReferenceNumber", "reimbursementCurrencyAmountDue", "reimbursementCurrencyCashAdvanceAmount", "reimbursementCurrencyID", "rejectionReason", "status", "submit", "submitDate", "submitterID", "weekEnding"],
19857
20108
  "holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
19858
20109
  "holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
20110
+ "inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
19859
20111
  "inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
19860
20112
  "invoice_templates": ["id", "coveredByBlockRetainerContractLabel", "coveredByRecurringServiceFixedPricePerTicketContractLabel", "currencyNegativeFormat", "currencyPositiveFormat", "dateFormat", "displayFixedPriceContractLabor", "displayRecurringServiceContractLabor", "displaySeparateLineItemForEachTax", "displayTaxCategory", "displayTaxCategorySuperscripts", "displayZeroAmountRecurringServicesAndBundles", "groupBy", "itemizeItemsInEachGroup", "itemizeServicesAndBundles", "name", "nonBillableLaborLabel", "numberFormat", "pageLayout", "pageNumberFormat", "paymentTerms", "rateCostExpression", "showGridHeader", "showVerticalGridLines", "sortBy", "timeFormat"],
19861
20113
  "invoices": ["id", "batchID", "comments", "companyID", "createDateTime", "creatorResourceID", "dueDate", "fromDate", "invoiceDateTime", "invoiceEditorTemplateID", "invoiceNumber", "invoiceTotal", "isVoided", "orderNumber", "paidDate", "paymentTerm", "taxGroup", "taxRegionName", "toDate", "totalTaxValue", "voidedByResourceID", "voidedDate", "webServiceDate"],
@@ -20095,21 +20347,21 @@ function validateRelationLeaves(resourceKey, conditions, op) {
20095
20347
  assertUndottedUdfField(c, op);
20096
20348
  const field = c.field;
20097
20349
  const [rel, sub, ...rest] = field.split(".");
20098
- const fail3 = (why) => {
20350
+ const fail4 = (why) => {
20099
20351
  throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
20100
20352
  operation: op,
20101
20353
  suggestedAction: valid.length > 0 ? `Use ${valid.map((r) => `${r}.<${RELATION_TARGETS[r].resource} field>`).join(" or ")} (one hop; field names from operations.fieldCatalog).` : `${resourceKey} has no relation filters; filter on its own fields.`
20102
20354
  });
20103
20355
  };
20104
20356
  if (selfPrefixes(resourceKey).includes(rel)) {
20105
- if (rest.length > 0 || !sub) fail3("is not <resource>.<field> (multi-hop relations are not supported)");
20357
+ if (rest.length > 0 || !sub) fail4("is not <resource>.<field> (multi-hop relations are not supported)");
20106
20358
  continue;
20107
20359
  }
20108
- if (rest.length > 0 || !sub) fail3("is not <relation>.<field> (multi-hop relations are not supported)");
20109
- if (!valid.includes(rel)) fail3(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
20360
+ if (rest.length > 0 || !sub) fail4("is not <relation>.<field> (multi-hop relations are not supported)");
20361
+ if (!valid.includes(rel)) fail4(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
20110
20362
  const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
20111
20363
  if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
20112
- fail3(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
20364
+ fail4(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
20113
20365
  }
20114
20366
  }
20115
20367
  };
@@ -20437,7 +20689,7 @@ var QueryBase = class {
20437
20689
  }
20438
20690
  continueAcrossEmptyPage() {
20439
20691
  const { key } = this.config;
20440
- return isAuditLogResource(key) || isKnowledgeBaseRootResource(key);
20692
+ return isAuditLogResource(key) || isExactRecordResource(key);
20441
20693
  }
20442
20694
  /** @internal */
20443
20695
  readPage(body, page, pageSize, state2) {
@@ -20834,7 +21086,7 @@ var QueryBase = class {
20834
21086
  }
20835
21087
  if (total <= BOUNDED_QUERY_MAX_LIMIT) {
20836
21088
  const { items: items2, pages: pages3, guard: guard2, sliced: sliced2, cursor: cursor2 } = await this.walkBounded(params, total);
20837
- if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.hasCompleteKnowledgeBaseWindow(items2, total)) {
21089
+ if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.hasCompleteExactRecordWindow(items2, total)) {
20838
21090
  throw this.latestWindowIncompleteError(total);
20839
21091
  }
20840
21092
  return this.finishLatest(items2, latest, pages3);
@@ -20843,11 +21095,11 @@ var QueryBase = class {
20843
21095
  probes += 1;
20844
21096
  if (probes > LATEST_MAX_COUNT_PROBES) throw this.latestThresholdUnresolvedError();
20845
21097
  };
20846
- const knowledgeBase = isKnowledgeBaseRootResource(this.config.key);
20847
- let lo = knowledgeBase ? -1n : 0n;
21098
+ const exactRecord = isExactRecordResource(this.config.key);
21099
+ let lo = exactRecord ? -1n : 0n;
20848
21100
  let hi;
20849
21101
  let aboveThreshold = 0;
20850
- if (isAuditLogResource(this.config.key) || knowledgeBase) {
21102
+ if (isAuditLogResource(this.config.key) || exactRecord) {
20851
21103
  hi = BigInt(MAX_AUDIT_ID);
20852
21104
  } else {
20853
21105
  for (let t = 1n; ; t = t << 1n) {
@@ -20868,17 +21120,17 @@ var QueryBase = class {
20868
21120
  aboveThreshold = above;
20869
21121
  } else lo = mid;
20870
21122
  }
20871
- if (knowledgeBase && aboveThreshold !== latest) throw this.latestWindowIncompleteError(latest + 1);
21123
+ if (exactRecord && aboveThreshold !== latest) throw this.latestWindowIncompleteError(latest + 1);
20872
21124
  const windowValue = hi <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(hi) : hi.toString();
20873
21125
  const window = [...baseConds, { op: "gte", field: "id", value: windowValue }];
20874
21126
  const { items, pages: pages2, guard, sliced, cursor } = await this.walkBounded({ ...params, filter: window }, latest + 1);
20875
- if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.hasCompleteKnowledgeBaseWindow(items, latest + 1, hi)) {
21127
+ if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.hasCompleteExactRecordWindow(items, latest + 1, hi)) {
20876
21128
  throw this.latestWindowIncompleteError(latest + 1);
20877
21129
  }
20878
21130
  return this.finishLatest(items, latest, pages2);
20879
21131
  }
20880
- hasCompleteKnowledgeBaseWindow(items, expected, minimum) {
20881
- if (!isKnowledgeBaseRootResource(this.config.key)) return true;
21132
+ hasCompleteExactRecordWindow(items, expected, minimum) {
21133
+ if (!isExactRecordResource(this.config.key)) return true;
20882
21134
  if (items.length !== expected) return false;
20883
21135
  const ids2 = items.map((item) => String(item.id));
20884
21136
  if (new Set(ids2).size !== expected) return false;
@@ -21025,10 +21277,12 @@ var MetaBase = class _MetaBase extends QueryBase {
21025
21277
  return cachedMetadataGet(this.http, this.config.key, kind, path, operation, unwrap, fresh, maxRetries);
21026
21278
  }
21027
21279
  /** `GET /V1.0/<E>/{id}` → `{ item }` unwrapped (`item: null` → NotFoundError). */
21028
- async getGlobal(id, fresh = false, maxRetries) {
21280
+ async getGlobal(id, fresh = false, maxRetries, checkedBaseUrl) {
21029
21281
  const numeric2 = parseIdentifier(id, "id");
21030
- const res = await this.cachedGet(`${this.resourcePath}/${numeric2}`, `${this.config.key}.get`, fresh, maxRetries);
21031
- return unwrapItem(res, numeric2, `${this.config.key}.get`, this.entityName);
21282
+ const path = `${this.resourcePath}/${numeric2}`;
21283
+ const operation = `${this.config.key}.get`;
21284
+ const res = checkedBaseUrl === void 0 ? await this.cachedGet(path, operation, fresh, maxRetries) : await this.http.request({ method: "GET", path, operation, maxRetries, checkedBaseUrl });
21285
+ return unwrapItem(res, numeric2, operation, this.entityName);
21032
21286
  }
21033
21287
  /**
21034
21288
  * V2 merge read: a FRESH single-record GET that skips response redaction
@@ -21098,8 +21352,8 @@ var MetaBase = class _MetaBase extends QueryBase {
21098
21352
  if (Object.keys(body).length === 0) {
21099
21353
  throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
21100
21354
  }
21101
- if ("item" in body) return unwrapItem(body, id, void 0, entity);
21102
- if (Array.isArray(body.items)) {
21355
+ if (Object.hasOwn(body, "item")) return unwrapItem(body, id, void 0, entity);
21356
+ if (Object.hasOwn(body, "items") && Array.isArray(body.items)) {
21103
21357
  const first = body.items[0];
21104
21358
  if (first === null || first === void 0) {
21105
21359
  throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
@@ -21545,26 +21799,26 @@ var MetaBase = class _MetaBase extends QueryBase {
21545
21799
 
21546
21800
  // src/resources/special/knowledgeBaseCategories.ts
21547
21801
  function admitKnowledgeBaseCategory(data, creating, staleToken) {
21548
- const fail3 = (message) => {
21802
+ const fail4 = (message) => {
21549
21803
  throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
21550
21804
  };
21551
- if (!creating && staleToken !== void 0) fail3("no documented stale timestamp is available");
21552
- if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
21805
+ if (!creating && staleToken !== void 0) fail4("no documented stale timestamp is available");
21806
+ if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
21553
21807
  const body = { ...data };
21554
- for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail3(`${field} is not a writable KnowledgeBaseCategories field`);
21808
+ for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail4(`${field} is not a writable KnowledgeBaseCategories field`);
21555
21809
  for (const [field, max] of [["name", 50], ["description", 1e3]]) {
21556
21810
  const value = body[field];
21557
- if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail3(`${field} must be a string of at most ${max} characters`);
21811
+ if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail4(`${field} must be a string of at most ${max} characters`);
21558
21812
  }
21559
- if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail3("name is required");
21560
- if (creating && body.parentCategoryID === void 0) fail3("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
21813
+ if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail4("name is required");
21814
+ if (creating && body.parentCategoryID === void 0) fail4("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
21561
21815
  const parent = body.parentCategoryID;
21562
21816
  if (parent !== void 0) {
21563
- if (typeof parent !== "number") return fail3("parentCategoryID must be a numeric identifier");
21817
+ if (typeof parent !== "number") return fail4("parentCategoryID must be a numeric identifier");
21564
21818
  parseIdentifier(parent, "parentCategoryID");
21565
- if (parent > 2147483647) fail3("parentCategoryID must fit a signed 32-bit integer");
21819
+ if (parent > 2147483647) fail4("parentCategoryID must fit a signed 32-bit integer");
21566
21820
  }
21567
- if (!creating && !Object.values(body).some((value) => value !== void 0)) fail3("update must contain a writable field");
21821
+ if (!creating && !Object.values(body).some((value) => value !== void 0)) fail4("update must contain a writable field");
21568
21822
  return body;
21569
21823
  }
21570
21824
  function categoryReplacement(body) {
@@ -21578,45 +21832,45 @@ function categoryReplacement(body) {
21578
21832
  }
21579
21833
 
21580
21834
  // src/resources/special/knowledgeBaseArticles.ts
21581
- function fail(detail) {
21835
+ function fail2(detail) {
21582
21836
  throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
21583
21837
  }
21584
21838
  function reference(value, name) {
21585
- if (typeof value !== "number") fail(`${name} must be a numeric identifier`);
21839
+ if (typeof value !== "number") fail2(`${name} must be a numeric identifier`);
21586
21840
  parseIdentifier(value, name);
21587
- if (value > 2147483647) fail(`${name} must fit a signed 32-bit integer`);
21841
+ if (value > 2147483647) fail2(`${name} must fit a signed 32-bit integer`);
21588
21842
  return value;
21589
21843
  }
21590
21844
  function articleParent(value) {
21591
21845
  const parent = parseIdentifier(value, "parentId");
21592
- if (typeof parent !== "number" || parent > 2147483647) fail("parentId must fit a signed 32-bit category identifier");
21593
- if (parent === 0) fail("parentId must name an article category");
21846
+ if (typeof parent !== "number" || parent > 2147483647) fail2("parentId must fit a signed 32-bit category identifier");
21847
+ if (parent === 0) fail2("parentId must name an article category");
21594
21848
  return parent;
21595
21849
  }
21596
21850
  function admitArticle(data, parentId, creating) {
21597
21851
  const parent = articleParent(parentId);
21598
- if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail("data must be a plain record");
21852
+ if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
21599
21853
  const body = { ...data };
21600
21854
  const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
21601
21855
  for (const key of Object.keys(body)) {
21602
- if (!allowed.includes(key)) fail(`${key} is not a writable article root field`);
21856
+ if (!allowed.includes(key)) fail2(`${key} is not a writable article root field`);
21603
21857
  if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
21604
21858
  }
21605
21859
  for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
21606
- if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail(`${field} must be a string of at most ${max} characters`);
21607
- }
21608
- if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail("title is required and cannot be blank");
21609
- if (!creating && Object.hasOwn(body, "articleCategoryID")) fail("articleCategoryID is read-only after creation");
21610
- if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail("articleCategoryID must match parentId");
21611
- if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647)) fail("publish must be an int32 from current field metadata");
21612
- if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail("isActive must be boolean");
21613
- if (!creating && !Object.keys(body).length) fail("update must contain a writable field");
21860
+ if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail2(`${field} must be a string of at most ${max} characters`);
21861
+ }
21862
+ if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail2("title is required and cannot be blank");
21863
+ if (!creating && Object.hasOwn(body, "articleCategoryID")) fail2("articleCategoryID is read-only after creation");
21864
+ if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail2("articleCategoryID must match parentId");
21865
+ if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647)) fail2("publish must be an int32 from current field metadata");
21866
+ if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail2("isActive must be boolean");
21867
+ if (!creating && !Object.keys(body).length) fail2("update must contain a writable field");
21614
21868
  return body;
21615
21869
  }
21616
21870
  async function guardArticle(http, parentId, id, maxRetries) {
21617
21871
  const parent = articleParent(parentId);
21618
21872
  const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
21619
- if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail("id must name an article within the signed 64-bit range");
21873
+ if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail2("id must name an article within the signed 64-bit range");
21620
21874
  unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
21621
21875
  if (target !== void 0) {
21622
21876
  return unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}/KnowledgeBaseArticles/${target}`, operation: "knowledge_base_articles.get", maxRetries }), target, "knowledge_base_articles.get", "article");
@@ -21625,7 +21879,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
21625
21879
  }
21626
21880
  function assertArticlePublish(data, fields) {
21627
21881
  if (!Object.hasOwn(data, "publish")) return;
21628
- const unavailable = () => fail("publish requires an unambiguous active value in current field metadata");
21882
+ const unavailable = () => fail2("publish requires an unambiguous active value in current field metadata");
21629
21883
  if (!Array.isArray(fields)) unavailable();
21630
21884
  const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
21631
21885
  if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
@@ -21649,7 +21903,7 @@ var MutationBase = class extends MetaBase {
21649
21903
  /** Normalise a mutation body: `id` OR `itemId` → `id`; UDF map → UDF array (UDF-capable only). */
21650
21904
  normalizeMutationBody(data) {
21651
21905
  const body = { ...data };
21652
- if (body.itemId !== void 0 && body.id === void 0) {
21906
+ if (Object.hasOwn(body, "itemId") && body.itemId !== void 0 && (!Object.hasOwn(body, "id") || body.id === void 0)) {
21653
21907
  body.id = body.itemId;
21654
21908
  delete body.itemId;
21655
21909
  }
@@ -21831,23 +22085,31 @@ var MutationBase = class extends MetaBase {
21831
22085
  * write already happened, so a failed read-back is reported on the result
21832
22086
  * (`persistedCheckFailed`: the error code, or `UNKNOWN (<error name>)`), never thrown.
21833
22087
  */
21834
- async withPersistedCheck(result, data, opts, id, parentId) {
22088
+ async withPersistedCheck(result, data, opts, id, parentId, checkedBaseUrl) {
21835
22089
  if (opts.verifyPersisted !== true) return result;
21836
- const maxRetries = isKnowledgeBaseRootResource(this.config.key) ? opts.maxRetries : void 0;
22090
+ const maxRetries = isExactRecordResource(this.config.key) ? opts.maxRetries : void 0;
21837
22091
  try {
21838
- const stored = parentId === void 0 ? await this.getGlobal(id, true, maxRetries) : this.config.attachmentGet === true ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true, maxRetries);
21839
- return { ...result, notPersisted: notPersistedFields(data, stored) };
22092
+ 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);
22093
+ const submitted = data;
22094
+ const persisted = stored;
22095
+ if (this.config.key === "inventory_locations") {
22096
+ if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError("inventory_locations: persisted record requires its own id");
22097
+ validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
22098
+ }
22099
+ const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
22100
+ return { ...result, notPersisted };
21840
22101
  } catch (err) {
21841
22102
  return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
21842
22103
  }
21843
22104
  }
21844
- async updateGlobal(id, data, opts = {}, method = "PUT") {
22105
+ async updateGlobal(id, data, opts = {}, method = "PUT", checkedBaseUrl) {
21845
22106
  const numeric2 = parseIdentifier(id, "id");
21846
22107
  const operation = `${this.config.key}.update`;
21847
22108
  let body = this.normalizeMutationBody(data);
21848
- const collectionUpdate = this.config.collectionUpdate === true;
22109
+ const partialCollection = checkedBaseUrl !== void 0;
22110
+ const collectionUpdate = partialCollection || this.config.collectionUpdate === true;
21849
22111
  if (collectionUpdate) {
21850
- if (opts.raw !== true) {
22112
+ if (!partialCollection && opts.raw !== true) {
21851
22113
  let current;
21852
22114
  try {
21853
22115
  current = await this.getGlobalUnredacted(numeric2, { maxRetries: opts.maxRetries });
@@ -21871,7 +22133,9 @@ var MutationBase = class extends MetaBase {
21871
22133
  path: collectionUpdate ? this.resourcePath : `${this.resourcePath}/${numeric2}`,
21872
22134
  body,
21873
22135
  operation,
21874
- maxRetries: opts.maxRetries
22136
+ maxRetries: opts.maxRetries,
22137
+ // The preflight facts must be checked again before any later PATCH.
22138
+ ...partialCollection ? { maintenanceMaxWaitMs: 0, checkedBaseUrl } : {}
21875
22139
  });
21876
22140
  } catch (err) {
21877
22141
  if (method === "PATCH" || !this.putFallbackEligible(err)) throw err;
@@ -21898,7 +22162,7 @@ var MutationBase = class extends MetaBase {
21898
22162
  }
21899
22163
  return this.withPersistedCheck(unwrapOperation(retry, operation), data, opts, numeric2);
21900
22164
  }
21901
- return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2);
22165
+ return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2, void 0, checkedBaseUrl);
21902
22166
  }
21903
22167
  /** `DELETE /V1.0/<E>/{id}` → `{ id }` (OperationResultModel). A blank 2xx
21904
22168
  * (204 / empty body) is a valid vendor delete answer — synthesize the
@@ -22208,21 +22472,22 @@ var MutationBase = class extends MetaBase {
22208
22472
  * check (mismatch throws STALE_OBJECT) and the best-effort `diff`. NO
22209
22473
  * mutating request is issued.
22210
22474
  */
22211
- async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord) {
22475
+ async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord, partialCollection) {
22212
22476
  const operation = `${this.config.key}.update`;
22213
22477
  const checks = [];
22214
22478
  const warnings = [];
22215
22479
  checks.push({ name: "input-validation", ok: isRecord2(data) && Object.keys(data).length > 0 });
22216
22480
  const scopedUpdate = parentId !== void 0 && this.config.parentScopedPath !== void 0;
22217
- const collectionUpdate = scopedUpdate || this.config.collectionUpdate === true;
22481
+ const collectionUpdate = scopedUpdate || partialCollection !== void 0 || this.config.collectionUpdate === true;
22218
22482
  const path = scopedUpdate ? this.scopedCollectionPath(parentId) : collectionUpdate ? this.resourcePath : `${this.resourcePath}/${id}`;
22219
- const method = scopedUpdate ? "PATCH" : "PUT";
22483
+ const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
22220
22484
  let current;
22221
22485
  try {
22222
- current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" ? opts.maxRetries : void 0) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
22486
+ current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" || partialCollection !== void 0 ? opts.maxRetries : void 0) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
22223
22487
  } catch (err) {
22224
22488
  if (err instanceof NotFoundError) {
22225
- const updateReason = EMPTY_REASON_STAMPS[this.config.key]?.update;
22489
+ const reasons = EMPTY_REASON_STAMPS[this.config.key];
22490
+ const updateReason = reasons?.update ?? (partialCollection === void 0 ? void 0 : reasons?.get);
22226
22491
  checks.push({
22227
22492
  name: "current-record-exists",
22228
22493
  ok: false,
@@ -22237,18 +22502,19 @@ var MutationBase = class extends MetaBase {
22237
22502
  checks,
22238
22503
  impact: { affected: 1, scope: "single-record", reversible: true },
22239
22504
  warnings,
22240
- data,
22505
+ data: partialCollection === void 0 ? data : { ...data, id },
22241
22506
  ...updateReason !== void 0 ? { emptyReason: updateReason } : {}
22242
22507
  }, { redactPersonalData: this.http.redactPersonalData });
22243
22508
  }
22244
22509
  throw err;
22245
22510
  }
22246
22511
  checks.push({ name: "current-record-exists", ok: true });
22512
+ partialCollection?.checkCurrent(current);
22247
22513
  if (this.staleObjectCheck(current, opts, operation)) {
22248
22514
  checks.push({ name: "stale-check", ok: true });
22249
22515
  }
22250
22516
  let envelopeData = data;
22251
- if (this.config.key === "knowledge_base_articles") {
22517
+ if (partialCollection !== void 0 || this.config.key === "knowledge_base_articles") {
22252
22518
  envelopeData = { ...this.normalizeMutationBody(data), id };
22253
22519
  } else if (parentId === void 0 && this.config.collectionUpdate === true && opts.raw !== true) {
22254
22520
  const merged = mergePartialBody(current, this.normalizeMutationBody(data));
@@ -22325,34 +22591,34 @@ var BaseResource = class extends MutationBase {
22325
22591
  };
22326
22592
 
22327
22593
  // src/resources/special/taskPredecessors.ts
22328
- function fail2(detail) {
22594
+ function fail3(detail) {
22329
22595
  throw new AutotaskConfigError(`task_predecessors: ${detail}`);
22330
22596
  }
22331
22597
  function numeric(value, field) {
22332
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail2(`${field} must be a positive numeric identifier`);
22598
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail3(`${field} must be a positive numeric identifier`);
22333
22599
  return value;
22334
22600
  }
22335
22601
  function predecessorParent(value) {
22336
22602
  const parent = parseIdentifier(value, "parentId");
22337
- if (parent === 0) fail2("parentId must name a successor task");
22603
+ if (parent === 0) fail3("parentId must name a successor task");
22338
22604
  return parent;
22339
22605
  }
22340
22606
  function assertPredecessorBinding(value, parentId, id) {
22341
- if (!isRecord2(value)) fail2("the returned record must establish id and successorTaskID parent");
22342
- if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId))) fail2("the returned record must match id and successorTaskID parent");
22607
+ if (!isRecord2(value)) fail3("the returned record must establish id and successorTaskID parent");
22608
+ if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId))) fail3("the returned record must match id and successorTaskID parent");
22343
22609
  }
22344
22610
  function admitTaskPredecessor(data, parentId, creating) {
22345
22611
  const parent = predecessorParent(parentId);
22346
- if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
22612
+ if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
22347
22613
  const payload = { ...data };
22348
22614
  const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
22349
- if (Object.keys(payload).some((key) => !allowed.includes(key))) fail2(creating ? "only predecessorTaskID, successorTaskID and lagDays are writable on create" : "only lagDays can be updated");
22350
- if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647)) fail2("lagDays must be an int32 integer");
22615
+ if (Object.keys(payload).some((key) => !allowed.includes(key))) fail3(creating ? "only predecessorTaskID, successorTaskID and lagDays are writable on create" : "only lagDays can be updated");
22616
+ if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647)) fail3("lagDays must be an int32 integer");
22351
22617
  if (creating) {
22352
22618
  const successor = numeric(payload.successorTaskID, "successorTaskID");
22353
22619
  const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
22354
- if (String(successor) !== String(parent)) fail2("successorTaskID must match parentId");
22355
- if (predecessor === successor) fail2("predecessorTaskID and successorTaskID must be distinct");
22620
+ if (String(successor) !== String(parent)) fail3("successorTaskID must match parentId");
22621
+ if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
22356
22622
  }
22357
22623
  return payload;
22358
22624
  }
@@ -22361,50 +22627,50 @@ async function guardTaskPredecessor(http, parentId, id, data) {
22361
22627
  let row = data;
22362
22628
  if (id !== void 0) {
22363
22629
  const target = parseIdentifier(id, "id");
22364
- if (target === 0) fail2("id must name a predecessor relationship");
22630
+ if (target === 0) fail3("id must name a predecessor relationship");
22365
22631
  row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
22366
22632
  assertPredecessorBinding(row, parent, target);
22367
22633
  }
22368
22634
  const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
22369
22635
  const successor = numeric(row?.successorTaskID, "successorTaskID");
22370
- if (predecessor === successor) fail2("predecessorTaskID and successorTaskID must be distinct");
22636
+ if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
22371
22637
  const projects = [];
22372
22638
  for (const taskId of [predecessor, successor]) {
22373
22639
  const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
22374
- if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail2("the returned task must match its requested id");
22640
+ if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail3("the returned task must match its requested id");
22375
22641
  projects.push(numeric(task.projectID, "task.projectID"));
22376
22642
  }
22377
- if (projects[0] !== projects[1]) fail2("predecessor and successor tasks must belong to the same project");
22643
+ if (projects[0] !== projects[1]) fail3("predecessor and successor tasks must belong to the same project");
22378
22644
  }
22379
22645
 
22380
22646
  // src/resources/special/taskNotes.ts
22381
22647
  var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
22382
22648
  function admitTaskNote(data, parentId, creating) {
22383
22649
  const parent = parseIdentifier(parentId, "parentId");
22384
- const fail3 = (message) => {
22650
+ const fail4 = (message) => {
22385
22651
  throw new AutotaskConfigError(`task_notes: ${message}`);
22386
22652
  };
22387
- if (data === null || typeof data !== "object" || Array.isArray(data)) fail3("data must be a record");
22653
+ if (data === null || typeof data !== "object" || Array.isArray(data)) fail4("data must be a record");
22388
22654
  const body = data;
22389
- for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail3(`${key} is not a writable TaskNotes field`);
22655
+ for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail4(`${key} is not a writable TaskNotes field`);
22390
22656
  for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
22391
22657
  const value = body[field];
22392
- if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail3(`${field} must be a string of at most ${maximum} characters`);
22658
+ if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail4(`${field} must be a string of at most ${maximum} characters`);
22393
22659
  }
22394
- if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail3("description is required");
22660
+ if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail4("description is required");
22395
22661
  for (const field of ["noteType", "publish"]) {
22396
22662
  const value = body[field];
22397
- if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail3(`${field} must be an integer from the current field metadata`);
22663
+ if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail4(`${field} must be an integer from the current field metadata`);
22398
22664
  }
22399
- if (creating && body.taskID === void 0) fail3("taskID is required in the create body and must match parentId");
22665
+ if (creating && body.taskID === void 0) fail4("taskID is required in the create body and must match parentId");
22400
22666
  for (const field of ["createdByContactID", "taskID"]) {
22401
22667
  if (body[field] !== void 0) {
22402
- if (typeof body[field] !== "number") fail3(`${field} must be a numeric identifier`);
22668
+ if (typeof body[field] !== "number") fail4(`${field} must be a numeric identifier`);
22403
22669
  const id = parseIdentifier(body[field], field);
22404
- if (field === "taskID" && String(id) !== String(parent)) fail3("taskID must match the parentId path argument");
22670
+ if (field === "taskID" && String(id) !== String(parent)) fail4("taskID must match the parentId path argument");
22405
22671
  }
22406
22672
  }
22407
- if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail3("update must contain a writable field");
22673
+ if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail4("update must contain a writable field");
22408
22674
  }
22409
22675
 
22410
22676
  // src/operations/invoke/fieldSuggest.ts
@@ -22625,8 +22891,8 @@ function unknownNamesSuggestedAction(record, authority, filterUnknown) {
22625
22891
  return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
22626
22892
  }
22627
22893
  async function validateQueryFieldNames(record, holder, args) {
22628
- const bag = args[0];
22629
- if (!isRecord2(bag)) return;
22894
+ const bag = ownQueryBag(args);
22895
+ if (bag === void 0) return;
22630
22896
  const fieldCheck = readFieldCheck(record, bag);
22631
22897
  const includeNames = readIncludeNames(record, bag["includeFields"]);
22632
22898
  let filterNames;
@@ -22674,38 +22940,38 @@ function isBase64(value) {
22674
22940
  }
22675
22941
  function admitTaskAttachment(data, parentId) {
22676
22942
  const parent = parseIdentifier(parentId, "parentId");
22677
- const fail3 = (message) => {
22943
+ const fail4 = (message) => {
22678
22944
  throw new AutotaskConfigError(`task_attachments: ${message}`);
22679
22945
  };
22680
- if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
22946
+ if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
22681
22947
  const body = data;
22682
- for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail3(`${field} is not a supported create field`);
22948
+ for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail4(`${field} is not a supported create field`);
22683
22949
  for (const field of ["attachmentType", "fullPath", "title"]) {
22684
- if (typeof body[field] !== "string" || body[field].trim() === "") fail3(`${field} is required and must be a non-empty string`);
22950
+ if (typeof body[field] !== "string" || body[field].trim() === "") fail4(`${field} is required and must be a non-empty string`);
22685
22951
  }
22686
- if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail3("publish must be an integer from current field metadata");
22952
+ if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
22687
22953
  for (const field of ["data", "contentType"]) {
22688
- if (body[field] !== void 0 && typeof body[field] !== "string") fail3(`${field} must be a string`);
22954
+ if (body[field] !== void 0 && typeof body[field] !== "string") fail4(`${field} must be a string`);
22689
22955
  }
22690
22956
  if (body.attachmentType === "FILE_ATTACHMENT") {
22691
- if (typeof body.data !== "string" || body.data === "") return fail3("FILE_ATTACHMENT requires non-empty base64 data");
22692
- if (!isBase64(body.data)) fail3("FILE_ATTACHMENT data must be base64 encoded");
22957
+ if (typeof body.data !== "string" || body.data === "") return fail4("FILE_ATTACHMENT requires non-empty base64 data");
22958
+ if (!isBase64(body.data)) fail4("FILE_ATTACHMENT data must be base64 encoded");
22693
22959
  }
22694
22960
  if (body.taskID !== void 0) {
22695
- if (typeof body.taskID !== "number") fail3("taskID must be a numeric identifier");
22696
- if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail3("taskID must match the parentId path argument");
22961
+ if (typeof body.taskID !== "number") fail4("taskID must be a numeric identifier");
22962
+ if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail4("taskID must match the parentId path argument");
22697
22963
  }
22698
22964
  if (body.parentAttachmentID !== void 0) {
22699
- if (typeof body.parentAttachmentID !== "number") fail3("parentAttachmentID must be a numeric identifier");
22965
+ if (typeof body.parentAttachmentID !== "number") fail4("parentAttachmentID must be a numeric identifier");
22700
22966
  parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
22701
22967
  }
22702
22968
  }
22703
22969
  function admitFileAttachment(resource, data, parentId) {
22704
22970
  parseIdentifier(parentId, "parentId");
22705
- const fail3 = (message) => {
22971
+ const fail4 = (message) => {
22706
22972
  throw new AutotaskConfigError(`${resource}: ${message}`);
22707
22973
  };
22708
- if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
22974
+ if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
22709
22975
  const body = data;
22710
22976
  const reference2 = {
22711
22977
  project_attachments: void 0,
@@ -22718,20 +22984,20 @@ function admitFileAttachment(resource, data, parentId) {
22718
22984
  configuration_item_attachments: "parentAttachmentID",
22719
22985
  configuration_item_note_attachments: void 0
22720
22986
  }[resource];
22721
- for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail3(`${field} is not a supported create field`);
22722
- if (body.attachmentType !== "FILE_ATTACHMENT") fail3("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
22987
+ for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail4(`${field} is not a supported create field`);
22988
+ if (body.attachmentType !== "FILE_ATTACHMENT") fail4("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
22723
22989
  const maxLength = resource === "project_attachments" ? void 0 : 255;
22724
22990
  for (const field of ["fullPath", "title"]) {
22725
22991
  const value = body[field];
22726
22992
  const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
22727
- if (typeof value !== "string" || value.trim() === "") return fail3(requirement);
22728
- if (maxLength !== void 0 && value.length > maxLength) fail3(requirement);
22993
+ if (typeof value !== "string" || value.trim() === "") return fail4(requirement);
22994
+ if (maxLength !== void 0 && value.length > maxLength) fail4(requirement);
22729
22995
  }
22730
- if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail3("publish must be an integer from current field metadata");
22731
- if (typeof body.data !== "string" || !isBase64(body.data)) fail3("FILE_ATTACHMENT requires nonempty base64 data");
22996
+ if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
22997
+ if (typeof body.data !== "string" || !isBase64(body.data)) fail4("FILE_ATTACHMENT requires nonempty base64 data");
22732
22998
  if (reference2 !== void 0 && body[reference2] !== void 0) {
22733
- if (typeof body[reference2] !== "number") fail3(`${reference2} must be a numeric identifier`);
22734
- if (parseIdentifier(body[reference2], reference2) === 0) fail3(`${reference2} must be positive`);
22999
+ if (typeof body[reference2] !== "number") fail4(`${reference2} must be a numeric identifier`);
23000
+ if (parseIdentifier(body[reference2], reference2) === 0) fail4(`${reference2} must be positive`);
22735
23001
  }
22736
23002
  }
22737
23003
  function admitScopedAttachmentQuery(resource, params) {
@@ -23580,6 +23846,16 @@ var SIMPLE_RESOURCES = [
23580
23846
  helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
23581
23847
  opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
23582
23848
  },
23849
+ {
23850
+ key: "inventory_locations",
23851
+ accessor: "inventoryLocations",
23852
+ resourcePath: "/V1.0/InventoryLocations",
23853
+ deletable: false,
23854
+ udfCapable: false,
23855
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
23856
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
23857
+ opForms: { get: "global", create: "global", update: "global" }
23858
+ },
23583
23859
  {
23584
23860
  key: "invoice_templates",
23585
23861
  accessor: "invoiceTemplates",
@@ -24475,7 +24751,7 @@ var GenericResource = class extends BaseResource {
24475
24751
  if (["company_attachments", "company_note_attachments", "configuration_item_attachments", "configuration_item_note_attachments", "contract_note_attachments", "expense_report_attachments", "project_attachments", "project_note_attachments", "resource_attachments", "sales_order_attachments", "task_attachments", "task_note_attachments"].includes(config.key)) this.getUdfInfo = async () => {
24476
24752
  throw new OperationNotSupportedError(config.key, "getUdfInfo");
24477
24753
  };
24478
- if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles"].includes(config.key)) this.createIfNotExists = async () => {
24754
+ if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
24479
24755
  throw new OperationNotSupportedError(config.key, "createIfNotExists");
24480
24756
  };
24481
24757
  if (config.key === "knowledge_base_categories") {
@@ -24590,9 +24866,9 @@ var GenericResource = class extends BaseResource {
24590
24866
  return this.createScopedRaw(parentId, data2, opts2);
24591
24867
  }
24592
24868
  if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
24593
- const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : a;
24869
+ const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
24594
24870
  const supplied = b;
24595
- const opts = this.config.key === "knowledge_base_categories" ? snapshotMutationOptions(supplied) : supplied ?? {};
24871
+ const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
24596
24872
  if (opts.dryRun === true) return this.runCreateDryRun(data);
24597
24873
  return this.createGlobal(data, opts);
24598
24874
  }
@@ -24619,8 +24895,24 @@ var GenericResource = class extends BaseResource {
24619
24895
  }
24620
24896
  if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
24621
24897
  const category = this.config.key === "knowledge_base_categories";
24622
- const id = category ? parseIdentifier(a, "id") : a;
24898
+ const location = this.config.key === "inventory_locations";
24899
+ const id = category || location ? parseIdentifier(a, "id") : a;
24623
24900
  const supplied = c;
24901
+ if (location) {
24902
+ const body = admitInventoryLocation(b, false);
24903
+ const opts2 = snapshotMutationOptions(supplied);
24904
+ if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
24905
+ const checkCurrent = (current) => checkInventoryLocationCurrent(body, current, id);
24906
+ if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
24907
+ const checkedBaseUrl = this.http.baseUrl;
24908
+ try {
24909
+ checkCurrent(await this.getGlobal(id, true, opts2.maxRetries, checkedBaseUrl));
24910
+ } catch (error) {
24911
+ if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
24912
+ throw error;
24913
+ }
24914
+ return this.updateGlobal(id, body, opts2, "PATCH", checkedBaseUrl);
24915
+ }
24624
24916
  const opts = category ? snapshotMutationOptions(supplied) : supplied ?? {};
24625
24917
  if (category && opts.raw === true) throw new AutotaskConfigError("knowledge_base_categories: raw update is unsupported; a fresh merge is required");
24626
24918
  const data = category ? admitKnowledgeBaseCategory(b, false, opts.lastModifiedDate) : b;
@@ -25925,7 +26217,11 @@ function resolveDispatchArgs(record, argsIn) {
25925
26217
  const names = Object.keys(schema);
25926
26218
  const unknown = Object.keys(byName).filter((k) => !names.includes(k));
25927
26219
  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)})`);
25928
- const values = names.map((n) => byName[n]);
26220
+ const values = names.map((name) => {
26221
+ if (Object.hasOwn(byName, name)) return byName[name];
26222
+ if (!schema[name].required && name in byName) bad(`named input "${name}" must be supplied directly`);
26223
+ return void 0;
26224
+ });
25929
26225
  const missing = names.filter((n, i) => schema[n].required && values[i] === void 0);
25930
26226
  if (missing.length > 0) bad(`requires named input ${missing.map((k) => `"${k}"`).join(", ")} (declared: ${declaredArgList(record)})`);
25931
26227
  const last = values.findLastIndex((value) => value !== void 0);
@@ -25957,12 +26253,26 @@ function captureDispatchArgs(record, argsIn) {
25957
26253
  );
25958
26254
  }
25959
26255
  const captured = [];
26256
+ const isWrite = record.effect !== "read";
25960
26257
  for (let i = 0; i < length; i += 1) {
25961
- const value = args[i];
25962
- captured.push(value);
25963
- if (value === void 0) continue;
25964
26258
  const name = names[i];
25965
26259
  const spec = schema[name];
26260
+ const supplied = Object.hasOwn(args, i);
26261
+ const value = supplied ? args[i] : void 0;
26262
+ if (!supplied && !spec.required && i in args) {
26263
+ throw new AutotaskConfigError(
26264
+ `invoke: "${operation}" positional input ${i + 1} (${name}) must be supplied directly`,
26265
+ { operation }
26266
+ );
26267
+ }
26268
+ if (spec.required && (!supplied || isWrite && value === void 0)) {
26269
+ throw new AutotaskConfigError(
26270
+ `invoke: "${operation}" requires positional input ${i + 1} (${name}: ${spec.type})`,
26271
+ { operation }
26272
+ );
26273
+ }
26274
+ captured.push(value);
26275
+ if (value === void 0) continue;
25966
26276
  if (!looseTypeOk(spec.type, value)) {
25967
26277
  throw new AutotaskConfigError(
25968
26278
  `invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
@@ -25994,105 +26304,6 @@ function foldFlattenedOpts(record, toolArgs) {
25994
26304
  return { ...folded, opts: Object.fromEntries(flat.map((k) => [k, toolArgs[k]])) };
25995
26305
  }
25996
26306
 
25997
- // src/operations/invoke/inputSets.ts
25998
- var PARAMS_BAG_KEYS = {
25999
- query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
26000
- // No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
26001
- // called directly), so this entry never fires. It is KEPT so that a future
26002
- // `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
26003
- // cannot silently open the bag (the keys are the vendor `QueryParams` set
26004
- // the raw method accepts).
26005
- queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
26006
- // issue #145: the count bag carries the fieldCheck opt-out — the #140
26007
- // refusal's advised remedy (before, the closed bag refused the very key it
26008
- // advised, and the remedy looped into a second CONFIG_ERROR).
26009
- count: ["filter", "fieldCheck"]
26010
- };
26011
- var BAG_KEY_SYNONYMS = {
26012
- filters: "filter",
26013
- last: "latest",
26014
- // issue #59: the expected typo class (honoured only on `query`)
26015
- lmit: "limit",
26016
- page: "limit",
26017
- pageSize: "limit",
26018
- cursor: "limit",
26019
- maxrecords: "maxRecords",
26020
- fieldsPreset: "includeFields"
26021
- // issue #287: the preset was removed — the refusal points at the explicit includeFields
26022
- };
26023
- function levenshtein(a, b) {
26024
- if (a === b) return 0;
26025
- const prev = new Array(b.length + 1);
26026
- const cur = new Array(b.length + 1);
26027
- for (let j = 0; j <= b.length; j += 1) prev[j] = j;
26028
- for (let i = 1; i <= a.length; i += 1) {
26029
- cur[0] = i;
26030
- for (let j = 1; j <= b.length; j += 1) {
26031
- cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
26032
- }
26033
- for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
26034
- }
26035
- return prev[b.length] ?? 0;
26036
- }
26037
- function suggestForKey(key, valid) {
26038
- const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
26039
- if (synonym !== void 0 && valid.includes(synonym)) return synonym;
26040
- let best = null;
26041
- for (const v of valid) {
26042
- const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
26043
- if (best === null || dist < best.dist) best = { key: v, dist };
26044
- }
26045
- if (best !== null && best.dist <= 3) return best.key;
26046
- return null;
26047
- }
26048
- function keySuggestions(unknown, valid) {
26049
- return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
26050
- }
26051
- function validateParamsBag(record, args) {
26052
- if (record.inputSchemaStrict !== true) return;
26053
- const valid = PARAMS_BAG_KEYS[record.operation];
26054
- if (valid === void 0) return;
26055
- const bag = args?.[0];
26056
- if (bag === void 0 || bag === null || !isRecord2(bag)) return;
26057
- const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
26058
- if (unknown.length === 0) return;
26059
- const suggestions = keySuggestions(unknown, valid);
26060
- throw new AutotaskConfigError(
26061
- `invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
26062
- {
26063
- operation: record.id,
26064
- 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).`
26065
- }
26066
- );
26067
- }
26068
- var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
26069
- function validateInvokeOptions(opts, operation) {
26070
- if (opts === void 0 || opts === null) return;
26071
- const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
26072
- if (unknown.length === 0) return;
26073
- const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
26074
- throw new AutotaskConfigError(
26075
- `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)`,
26076
- {
26077
- operation,
26078
- suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
26079
- }
26080
- );
26081
- }
26082
- function unknownKeysRefusal(raw, validKeys, subject, operation) {
26083
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
26084
- const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
26085
- if (unknown.length === 0) return null;
26086
- const suggestions = keySuggestions(unknown, [...validKeys]);
26087
- return new AutotaskConfigError(
26088
- `unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
26089
- {
26090
- ...operation !== void 0 ? { operation } : {},
26091
- 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(", ")}).`
26092
- }
26093
- );
26094
- }
26095
-
26096
26307
  // src/operations/searchAcrossResources.ts
26097
26308
  var DEFAULT_LIMIT2 = 25;
26098
26309
  function resourceFor(client, key) {
@@ -26454,7 +26665,7 @@ function checkOptsBag(opts, problems) {
26454
26665
  }
26455
26666
  }
26456
26667
  if (opts?.names !== void 0 && typeof opts.names !== "boolean") problems.push(`names must be a boolean (got ${typeof opts.names})`);
26457
- if (opts?.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
26668
+ if (opts !== void 0 && Object.hasOwn(opts, "acknowledgeUnscoped") && opts.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
26458
26669
  problems.push(`acknowledgeUnscoped must be a boolean (got ${typeof opts.acknowledgeUnscoped})`);
26459
26670
  }
26460
26671
  }
@@ -26541,8 +26752,10 @@ async function checkFieldNames(resourceKey, conditions, opts, problems) {
26541
26752
  }
26542
26753
  async function validateAggregate(operation, filter, opts) {
26543
26754
  const problems = [];
26755
+ const acknowledgment = opts !== null && typeof opts === "object" ? Object.getOwnPropertyDescriptor(opts, "acknowledgeUnscoped") : void 0;
26544
26756
  const resourceKey = await parseOperationKey(operation, problems);
26545
26757
  const conditions = parseFilterConditions(filter, problems);
26758
+ const acknowledged = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") && acknowledgment.value === true && opts.acknowledgeUnscoped === true;
26546
26759
  checkOptsBag(opts, problems);
26547
26760
  if (resourceKey !== void 0) {
26548
26761
  opts = {
@@ -26569,7 +26782,7 @@ async function validateAggregate(operation, filter, opts) {
26569
26782
  { operation: "operations.aggregate" }
26570
26783
  );
26571
26784
  }
26572
- if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && opts.acknowledgeUnscoped !== true) {
26785
+ if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && !acknowledged) {
26573
26786
  throw new ScopeRequiredError(operation, { threshold: UNSCOPED_WALK_THRESHOLD }, "empty-filter");
26574
26787
  }
26575
26788
  return { resourceKey, conditions, groupBy, sum, top, limit };
@@ -26713,8 +26926,9 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
26713
26926
  try {
26714
26927
  const id = parseIdentifier(item.id, `${at}.id`);
26715
26928
  const audit = isAuditLogResource(resourceKey);
26716
- if ((audit || isKnowledgeBaseRootResource(resourceKey)) && !isAuditDecimalId(String(id))) {
26717
- problems.push(`${at}.id: ${audit ? "audit log" : "Knowledge Base record"} ID must be a non-negative signed 64-bit integer`);
26929
+ if ((audit || isExactRecordResource(resourceKey)) && !isAuditDecimalId(String(id))) {
26930
+ const label = audit ? "audit log" : resourceKey === "inventory_locations" ? "inventory location" : "Knowledge Base record";
26931
+ problems.push(`${at}.id: ${label} ID must be a non-negative signed 64-bit integer`);
26718
26932
  }
26719
26933
  } catch {
26720
26934
  if (typeof item.id === "string") {
@@ -29344,16 +29558,16 @@ function latchingHttp(raw, spend) {
29344
29558
  }
29345
29559
  };
29346
29560
  observeRecordReadFailures(http, latch);
29347
- const fail3 = (err) => {
29561
+ const fail4 = (err) => {
29348
29562
  latch(err);
29349
29563
  throw err;
29350
29564
  };
29351
29565
  http.request = (o) => {
29352
29566
  if (fatal) throw fatal;
29353
29567
  try {
29354
- return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail3);
29568
+ return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail4);
29355
29569
  } catch (err) {
29356
- return fail3(err);
29570
+ return fail4(err);
29357
29571
  }
29358
29572
  };
29359
29573
  return { http, fatal: () => fatal, signal };
@@ -31153,8 +31367,25 @@ function bufferResult(buf) {
31153
31367
  }
31154
31368
  var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
31155
31369
  function snapshotInvokeOptions(options, mode) {
31156
- const captured = isRecord2(options) ? snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS) : { ...options };
31157
- return { ...captured, mode };
31370
+ if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
31371
+ const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
31372
+ const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
31373
+ let confirmation;
31374
+ for (let owner = options; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
31375
+ confirmation = Object.getOwnPropertyDescriptor(owner, "confirm");
31376
+ if (confirmation !== void 0) break;
31377
+ }
31378
+ let confirm;
31379
+ if (confirmation !== void 0) {
31380
+ const visible = options.confirm;
31381
+ if (Object.hasOwn(confirmation, "value") && confirmation.value === visible || Object.hasOwn(confirmation, "get") && typeof confirmation.get === "function") confirm = visible;
31382
+ }
31383
+ const dryRun = options.dryRun;
31384
+ const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
31385
+ dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
31386
+ confirm
31387
+ });
31388
+ return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
31158
31389
  }
31159
31390
  async function resolveRecord(operation) {
31160
31391
  const record = (await operationIndex()).get(operation);
@@ -31368,15 +31599,19 @@ var PRE_REQUEST_VALIDATORS = [
31368
31599
  (c) => requireReadBack(c.record, c.operation, c.opts),
31369
31600
  (c) => {
31370
31601
  c.args = captureDispatchArgs(c.record, c.args);
31371
- const [bag, ...remaining] = c.args;
31372
- if (!c.boundedQuery && !c.countedQuery || !isRecord2(bag)) return;
31373
- c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...remaining];
31602
+ if (!c.boundedQuery && !c.countedQuery) return;
31603
+ const bag = ownQueryBag(c.args);
31604
+ if (bag === void 0) return;
31605
+ if (c.boundedQuery && "acknowledgeUnscoped" in bag && !Object.hasOwn(bag, "acknowledgeUnscoped")) {
31606
+ throw new AutotaskConfigError(`invoke: "${c.operation}" params bag key "acknowledgeUnscoped" must be supplied directly`, { operation: c.operation });
31607
+ }
31608
+ c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...c.args.slice(1)];
31374
31609
  },
31375
31610
  (c) => validateParamsBag(c.record, c.args),
31376
31611
  (c) => validateFreshSpelling(c.record, c.args),
31377
31612
  (c) => {
31378
31613
  if (!c.streaming) return;
31379
- const bag = c.args[0];
31614
+ const bag = ownQueryBag(c.args);
31380
31615
  if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
31381
31616
  throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
31382
31617
  }
@@ -31395,7 +31630,8 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
31395
31630
  const context = { record, operation, args: resolvedArgs, opts, client, holder, boundedQuery, countedQuery, streaming };
31396
31631
  await runPreRequestPass(context);
31397
31632
  const { args } = context;
31398
- const labelQuery = boundedQuery && readNamesOpt(client, args[0]?.["names"], `invoke: "${record.id}" params bag`);
31633
+ const queryParams = boundedQuery ? ownQueryBag(args) : void 0;
31634
+ const labelQuery = boundedQuery && readNamesOpt(client, queryParams?.["names"], `invoke: "${record.id}" params bag`);
31399
31635
  const methodName = boundedQuery ? "queryBounded" : record.operation;
31400
31636
  const method = streaming ? context.pageSession?.consume : holder[methodName];
31401
31637
  if (typeof method !== "function") {
@@ -31408,17 +31644,18 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
31408
31644
  const mutationOpts = buildMutationOpts(opts, isWrite);
31409
31645
  const callArgs = buildCallArgs(record, args, mutationOpts, isWrite);
31410
31646
  if (opts.fresh === true) appendFresh(record, callArgs);
31411
- if (boundedQuery) validateWalkBag(args[0]?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
31412
31647
  let scopeNote;
31413
- if (boundedQuery && args[0]?.["acknowledgeUnscoped"] !== true) {
31414
- scopeNote = (await guardUnscopedQueryWalk(holder, record.id, args[0])).note;
31648
+ if (boundedQuery) {
31649
+ validateWalkBag(queryParams?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
31650
+ const acknowledged = queryParams !== void 0 && Object.hasOwn(queryParams, "acknowledgeUnscoped") && queryParams.acknowledgeUnscoped === true;
31651
+ if (!acknowledged) scopeNote = (await guardUnscopedQueryWalk(holder, record.id, queryParams)).note;
31415
31652
  }
31416
31653
  return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
31417
31654
  }
31418
31655
  async function invokeMode(client, operation, argsIn = [], opts = {}) {
31419
31656
  const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
31420
31657
  const result = await method.apply(holder, callArgs);
31421
- if (labelQuery && args[0]?.["walk"] === void 0 && Array.isArray(result?.items)) {
31658
+ if (labelQuery && ownQueryBag(args)?.["walk"] === void 0 && Array.isArray(result?.items)) {
31422
31659
  const bounded = result;
31423
31660
  const labelled = await labelRows(client, record.resource, bounded.items);
31424
31661
  return { ...bounded, items: labelled.rows, ...labelled.names !== void 0 ? { names: labelled.names } : {}, ...scopeNote !== void 0 ? { scopeNote } : {} };