node-autotask 0.86.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/MCP_TOOL_CATALOG.json +152 -9
  3. package/README.md +1 -1
  4. package/capabilities.json +714 -194
  5. package/dist/capabilities-data.js +713 -193
  6. package/dist/capabilities.cjs +4 -4
  7. package/dist/capabilities.js +1 -1
  8. package/dist/{chunk-SZ33SCCI.cjs → chunk-AB326MJO.cjs} +200 -200
  9. package/dist/{chunk-BD4AUGCJ.cjs → chunk-CM5O672I.cjs} +5 -4
  10. package/dist/{chunk-23LTWBKP.cjs → chunk-ESKQAINP.cjs} +31 -30
  11. package/dist/{chunk-YX6SSS4I.cjs → chunk-GEFUSYH5.cjs} +739 -378
  12. package/dist/{chunk-ELZTECDS.js → chunk-K72PPAAD.js} +726 -365
  13. package/dist/{chunk-AZ54RMQR.js → chunk-LGOJ2HBH.js} +3 -2
  14. package/dist/{chunk-DVD7RZIB.js → chunk-QKRHKLVY.js} +2 -2
  15. package/dist/{chunk-EYRQUMA2.cjs → chunk-SHJ7EOBW.cjs} +3 -3
  16. package/dist/{chunk-7NKB4UXV.js → chunk-X6VWD6WW.js} +5 -4
  17. package/dist/{chunk-KYFJOIG4.js → chunk-ZADTVF6M.js} +3 -3
  18. package/dist/{index-B3zO78nP.d.ts → index-BFgZJsqx.d.ts} +19 -13
  19. package/dist/{index-CIgmz8qI.d.cts → index-D0KHVqoO.d.cts} +37 -3
  20. package/dist/{index-CIgmz8qI.d.ts → index-D0KHVqoO.d.ts} +37 -3
  21. package/dist/{index-C2p8D2mZ.d.cts → index-DsA1-2GA.d.cts} +19 -13
  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/docs/VENDOR-QUIRKS.md +34 -17
  46. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { loadCapabilityRecords } from './chunk-KYFJOIG4.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
 
@@ -1692,13 +1692,13 @@ function normalizeInCondition(cond, path) {
1692
1692
  return items === cond.items ? cond : { ...cond, items };
1693
1693
  }
1694
1694
  if (cond.op !== "in" && cond.op !== "notIn" || typeof cond.value !== "string") return cond;
1695
- const tokens = cond.value.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
1696
- if (tokens.length === 0) {
1695
+ const tokens2 = cond.value.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
1696
+ if (tokens2.length === 0) {
1697
1697
  throw new AutotaskConfigError(
1698
1698
  `Operator "${cond.op}" at ${path} has an empty value list \u2014 pass an array or a comma-separated string with at least one value (e.g. "1,2,3")`
1699
1699
  );
1700
1700
  }
1701
- const value = cond.udf === true ? tokens : tokens.map((t) => /^(0|[1-9]\d*)$/.test(t) && Number.isSafeInteger(Number(t)) ? Number(t) : t);
1701
+ const value = cond.udf === true ? tokens2 : tokens2.map((t) => /^(0|[1-9]\d*)$/.test(t) && Number.isSafeInteger(Number(t)) ? Number(t) : t);
1702
1702
  return { ...cond, value };
1703
1703
  }
1704
1704
  function refusedFilterShape(filter) {
@@ -10936,6 +10936,59 @@ var RELATIONSHIP_MAP = {
10936
10936
  },
10937
10937
  "deleteBoundary": null,
10938
10938
  "markerField": null
10939
+ },
10940
+ "inventory_locations": {
10941
+ "resource": "inventory_locations",
10942
+ "apiEntity": "InventoryLocation",
10943
+ "kind": "entity",
10944
+ "path": "InventoryLocations",
10945
+ "parentScoped": false,
10946
+ "tier": "extended",
10947
+ "workflowResource": false,
10948
+ "group": "A",
10949
+ "parent": null,
10950
+ "children": [],
10951
+ "naturalKeys": {
10952
+ "hasSearch": false,
10953
+ "searchCovers": null,
10954
+ "findBy": []
10955
+ },
10956
+ "blindSurfaces": null,
10957
+ "zoneFacts": {
10958
+ "createRequiredSet": [
10959
+ "locationName",
10960
+ "isActive"
10961
+ ],
10962
+ "createGuidance": {
10963
+ "createOp": "inventory_locations.create",
10964
+ "parentScoped": false,
10965
+ "liveProvenPrefix": [],
10966
+ "unproven": true,
10967
+ "blocker": {
10968
+ "kind": "unknown",
10969
+ "message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
10970
+ "remedy": "Read current metadata, supply locationName and isActive, and preview first.",
10971
+ "requires": {
10972
+ "allOf": [
10973
+ "locationName",
10974
+ "isActive"
10975
+ ]
10976
+ }
10977
+ },
10978
+ "vendorEvidence": [
10979
+ "https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
10980
+ ],
10981
+ "deleteBoundary": {
10982
+ "available": false,
10983
+ "note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
10984
+ }
10985
+ }
10986
+ },
10987
+ "deleteBoundary": {
10988
+ "note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API.",
10989
+ "proof": "spec-derived"
10990
+ },
10991
+ "markerField": null
10939
10992
  }
10940
10993
  };
10941
10994
  var BLIND_SURFACE_STAMPS = {
@@ -11047,7 +11100,8 @@ var DELETE_BOUNDARY_NOTES = {
11047
11100
  "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
11101
  "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
11102
  "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."
11103
+ "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.",
11104
+ "inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
11051
11105
  };
11052
11106
  var RESPONSE_DRIFT_MARKERS = {
11053
11107
  "ticket_checklist_libraries": {
@@ -12483,6 +12537,15 @@ var EMPTY_REASON_STAMPS = {
12483
12537
  "authority": null,
12484
12538
  "remedy": "verify the created record by id (ticket_checklist_libraries.get) \u2014 the create may have succeeded despite the drifted envelope"
12485
12539
  }
12540
+ },
12541
+ "inventory_locations": {
12542
+ "get": {
12543
+ "surface": "inventory_locations.get",
12544
+ "kind": "tenant-empty-for-user",
12545
+ "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.",
12546
+ "authority": "inventory_locations.get",
12547
+ "remedy": "Verify the ID and check View permission, Inventory access and Inventory Manage Locations with an authorized user."
12548
+ }
12486
12549
  }
12487
12550
  };
12488
12551
  var POINTER_NOTES = {
@@ -13965,6 +14028,31 @@ var CREATE_GUIDANCE = {
13965
14028
  "note": null
13966
14029
  }
13967
14030
  },
14031
+ {
14032
+ "resource": "inventory_locations",
14033
+ "createOp": "inventory_locations.create",
14034
+ "parentScoped": false,
14035
+ "liveProvenPrefix": [],
14036
+ "unproven": true,
14037
+ "blocker": {
14038
+ "kind": "unknown",
14039
+ "message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
14040
+ "remedy": "Read current metadata, supply locationName and isActive, and preview first.",
14041
+ "requires": {
14042
+ "allOf": [
14043
+ "locationName",
14044
+ "isActive"
14045
+ ]
14046
+ }
14047
+ },
14048
+ "vendorEvidence": [
14049
+ "https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
14050
+ ],
14051
+ "deleteBoundary": {
14052
+ "available": false,
14053
+ "note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
14054
+ }
14055
+ },
13968
14056
  {
13969
14057
  "resource": "inventory_products",
13970
14058
  "createOp": "inventory_products.create",
@@ -15545,7 +15633,7 @@ var CREATE_GUIDANCE = {
15545
15633
  }
15546
15634
  ],
15547
15635
  "counts": {
15548
- "total": 116,
15636
+ "total": 117,
15549
15637
  "byKind": {
15550
15638
  "ok": 41,
15551
15639
  "blind-reference": 16,
@@ -15555,7 +15643,7 @@ var CREATE_GUIDANCE = {
15555
15643
  "resource-role-pair": 2,
15556
15644
  "delete-absent": 0,
15557
15645
  "non-mutable": 0,
15558
- "unknown": 40
15646
+ "unknown": 41
15559
15647
  }
15560
15648
  }
15561
15649
  };
@@ -16334,6 +16422,9 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
16334
16422
  "keywords",
16335
16423
  "referenceLink",
16336
16424
  "title"
16425
+ ],
16426
+ "inventory_locations": [
16427
+ "locationName"
16337
16428
  ]
16338
16429
  };
16339
16430
 
@@ -16792,22 +16883,25 @@ function auditReadTarget(path, operation) {
16792
16883
  function isKnowledgeBaseRootResource(resource) {
16793
16884
  return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
16794
16885
  }
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);
16886
+ function isExactRecordResource(resource) {
16887
+ return resource === "inventory_locations" || isKnowledgeBaseRootResource(resource);
16888
+ }
16889
+ var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
16890
+ function exactRecordResponseTarget(path, method, operation) {
16891
+ const match = EXACT_RECORD_PATH.exec(path);
16798
16892
  if (match === null) return void 0;
16799
16893
  const suffix = match[1]?.toLowerCase();
16800
16894
  if (suffix === "query/count") return suffix;
16801
16895
  if (suffix?.startsWith("query")) return "query";
16802
16896
  if (suffix !== void 0 && !isAuditDecimalId(suffix)) {
16803
- throw new AutotaskConfigError("Knowledge Base record ID must be a non-negative signed 64-bit integer.", { operation });
16897
+ throw new AutotaskConfigError("Record ID must be a non-negative signed 64-bit integer.", { operation });
16804
16898
  }
16805
16899
  return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
16806
16900
  }
16807
16901
  function isNonNegativeInt64(id) {
16808
16902
  return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
16809
16903
  }
16810
- function validateKnowledgeBaseResponse(body, target, path, method, requestBody, operation) {
16904
+ function validateExactRecordResponse(body, target, path, method, requestBody, operation) {
16811
16905
  const invalid = (message) => {
16812
16906
  throw new AutotaskError(message, { code: "INVALID_RESPONSE", category: "server", operation, suggestedAction: INVALID_SHAPE_ACTION });
16813
16907
  };
@@ -16817,15 +16911,15 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
16817
16911
  }
16818
16912
  if (target === "query") {
16819
16913
  if (!isRecord2(body) || !Array.isArray(body.items) || !isRecord2(body.pageDetails)) {
16820
- return invalid("Expected a Knowledge Base query page with paging details");
16914
+ return invalid("Expected a query page with paging details");
16821
16915
  }
16822
- if (!body.items.every(hasExactRecordId)) invalid("Expected valid record IDs in the Knowledge Base query response");
16916
+ if (!body.items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
16823
16917
  if (body.pageDetails.count !== body.items.length) {
16824
- invalid("The Knowledge Base page record count did not match its rows");
16918
+ invalid("The page record count did not match its rows");
16825
16919
  }
16826
16920
  const cursor = body.pageDetails.nextPageUrl;
16827
16921
  if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
16828
- invalid("Expected a valid Knowledge Base query cursor or an explicit end of results");
16922
+ invalid("Expected a valid query cursor or an explicit end of results");
16829
16923
  }
16830
16924
  return;
16831
16925
  }
@@ -16833,7 +16927,7 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
16833
16927
  const expectedId = parts.at(-1);
16834
16928
  if (target === "mutation") {
16835
16929
  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");
16930
+ if (!isNonNegativeInt64(id)) invalid("Expected a valid mutation receipt");
16837
16931
  const expected = method === "DELETE" ? expectedId : isRecord2(requestBody) ? requestBody.id : void 0;
16838
16932
  if (expected !== void 0 && String(id) !== String(expected)) {
16839
16933
  invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
@@ -16843,9 +16937,10 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
16843
16937
  const item = isRecord2(body) ? body.item : void 0;
16844
16938
  if (item === null) return;
16845
16939
  if (!isRecord2(item) || !isNonNegativeInt64(item.id)) {
16846
- return invalid("Expected a Knowledge Base item envelope with a valid record ID");
16940
+ return invalid("Expected an item envelope with a valid record ID");
16847
16941
  }
16848
- const resource = parts.at(-2)?.toLowerCase() === "knowledgebasearticles" ? "article" : "category";
16942
+ const entity = parts.at(-2)?.toLowerCase();
16943
+ const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
16849
16944
  if (String(item.id) !== expectedId) {
16850
16945
  throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
16851
16946
  }
@@ -16859,16 +16954,16 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
16859
16954
  }
16860
16955
  }
16861
16956
  }
16862
- function serializeKnowledgeBaseUpdate(body, operation) {
16957
+ function serializeExactRecordUpdate(body, operation) {
16863
16958
  if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
16864
16959
  if (!isAuditDecimalId(body.id)) {
16865
- throw new AutotaskConfigError("Knowledge Base update id must be a non-negative signed 64-bit integer.", { operation });
16960
+ throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
16866
16961
  }
16867
16962
  const { rawJSON } = JSON;
16868
16963
  return JSON.stringify({ ...body, id: rawJSON(body.id) });
16869
16964
  }
16870
- function decodeResponseJson(text, auditTarget, knowledgeBaseTarget) {
16871
- const target = auditTarget ?? knowledgeBaseTarget;
16965
+ function decodeResponseJson(text, auditTarget, recordTarget) {
16966
+ const target = auditTarget ?? recordTarget;
16872
16967
  if (target === void 0) return JSON.parse(text);
16873
16968
  if (target === "query/count") {
16874
16969
  return JSON.parse(text, (key, value, context) => key === "queryCount" && typeof value === "number" && !isAuditDecimalId(context?.source ?? "") ? null : value);
@@ -16928,9 +17023,9 @@ function attachEmptyReasonDetails(err) {
16928
17023
  const resource = err.operation.slice(0, dot);
16929
17024
  const op = err.operation.slice(dot + 1);
16930
17025
  const surface = err.operation;
16931
- const stamp = EMPTY_REASON_STAMPS[resource]?.[op];
16932
- const pointer = POINTER_NOTES[surface];
16933
17026
  const isGetMiss = err instanceof NotFoundError && op === "get";
17027
+ const stamp = op !== "get" || isGetMiss ? EMPTY_REASON_STAMPS[resource]?.[op] : void 0;
17028
+ const pointer = POINTER_NOTES[surface];
16934
17029
  if (stamp === void 0 && pointer === void 0 && !isGetMiss) return;
16935
17030
  err.details = { ...err.details ?? {} };
16936
17031
  if (stamp !== void 0) {
@@ -17042,7 +17137,7 @@ function normalizeZoneBase(raw) {
17042
17137
  return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
17043
17138
  }
17044
17139
  function canReResolveZone(reResolveZoneOn401, zone, opts) {
17045
- if (!reResolveZoneOn401) return false;
17140
+ if (!reResolveZoneOn401 || opts.checkedBaseUrl !== void 0) return false;
17046
17141
  if (zone === void 0 || zone === "other") return false;
17047
17142
  if (!opts.path.startsWith("/") || /^https?:\/\//i.test(opts.path)) return false;
17048
17143
  return true;
@@ -17435,6 +17530,7 @@ var HttpClient = class {
17435
17530
  if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
17436
17531
  this.gate(s, false);
17437
17532
  if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
17533
+ this.assertCheckedBase(opts);
17438
17534
  const admission = admitHourlyAttempt(s.url, this.hourly, Date.now());
17439
17535
  if (!admission.admitted) {
17440
17536
  releaseCurrent();
@@ -17511,13 +17607,13 @@ var HttpClient = class {
17511
17607
  }
17512
17608
  let parsed;
17513
17609
  try {
17514
- parsed = decodeResponseJson(text, s.auditTarget, s.knowledgeBaseTarget);
17610
+ parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget);
17515
17611
  } catch {
17516
17612
  return this.handleNonJson2xx(s, res, status, text);
17517
17613
  }
17518
17614
  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);
17615
+ if (s.recordTarget !== void 0) {
17616
+ validateExactRecordResponse(parsed, s.recordTarget, decodeURIComponent(opts.path), method, opts.body, opts.operation);
17521
17617
  }
17522
17618
  return {
17523
17619
  done: true,
@@ -17704,6 +17800,13 @@ var HttpClient = class {
17704
17800
  this.readCache?.clear();
17705
17801
  if (/\/V1\.0\/Companies(?:\/[^/]+)?(?:\?|$)/i.test(opts.path)) invalidateCompanyIndex(this);
17706
17802
  }
17803
+ assertCheckedBase(opts) {
17804
+ const baseUrl = this.baseUrl;
17805
+ if (opts.checkedBaseUrl !== void 0 && opts.checkedBaseUrl !== baseUrl) {
17806
+ throw new AutotaskConfigError("The Autotask zone changed after preflight. Preview or check the target again.", { operation: opts.operation });
17807
+ }
17808
+ return baseUrl;
17809
+ }
17707
17810
  /**
17708
17811
  * One request: build URL/headers, apply the whole-call deadline, retry
17709
17812
  * idempotent methods on 429/5xx, map failures to the typed errors.
@@ -17711,8 +17814,9 @@ var HttpClient = class {
17711
17814
  */
17712
17815
  async request(opts) {
17713
17816
  const method = opts.method;
17714
- const url = buildUrl(this.baseUrl, opts.path, opts.query);
17715
- const wirePath = url.slice(this.baseUrl.length);
17817
+ const baseUrl = this.assertCheckedBase(opts);
17818
+ const url = buildUrl(baseUrl, opts.path, opts.query);
17819
+ const wirePath = url.slice(baseUrl.length);
17716
17820
  const path = wirePath.split("?", 1)[0];
17717
17821
  const route = decodeURIComponent(path);
17718
17822
  const auditTarget = auditReadTarget(route, opts.operation);
@@ -17722,13 +17826,14 @@ var HttpClient = class {
17722
17826
  const queryRoute = /\/query(?:\/|$)/i.test(route);
17723
17827
  const getQuery = method === "GET" && queryRoute && requestUrl.search !== "";
17724
17828
  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);
17829
+ const recordTarget = exactRecordResponseTarget(route, method, opts.operation);
17830
+ const exactRecordUpdate = recordTarget === "mutation" && (method === "PUT" || method === "PATCH");
17831
+ const bodyText = exactRecordUpdate && opts.body !== void 0 ? serializeExactRecordUpdate(opts.body, opts.operation) : opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
17728
17832
  if (queryRoute) {
17729
17833
  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;
17834
+ const exactRecord = recordTarget === "query" || recordTarget === "query/count";
17835
+ const recordLabel = /^\/v1\.0\/InventoryLocations\//i.test(route) ? "inventory location" : "Knowledge Base record";
17836
+ const exactIdLabel = audit ? "audit log" : exactRecord ? recordLabel : void 0;
17732
17837
  assertQueryFilters(opts, requestUrl, bodyText, exactIdLabel);
17733
17838
  }
17734
17839
  opts = { ...opts, path };
@@ -17744,7 +17849,7 @@ var HttpClient = class {
17744
17849
  getQuery,
17745
17850
  method,
17746
17851
  auditTarget,
17747
- knowledgeBaseTarget,
17852
+ recordTarget,
17748
17853
  url,
17749
17854
  headers,
17750
17855
  bodyText,
@@ -18325,13 +18430,13 @@ async function runBounded(fn, items, opts) {
18325
18430
  const results = new Array(items.length);
18326
18431
  let next = 0;
18327
18432
  let failure;
18328
- const fail3 = (error, index) => {
18433
+ const fail4 = (error, index) => {
18329
18434
  if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
18330
18435
  };
18331
18436
  const worker = async () => {
18332
18437
  while (failure === void 0 && next < items.length) {
18333
18438
  if (signal?.aborted) {
18334
- fail3(signal.reason, -1);
18439
+ fail4(signal.reason, -1);
18335
18440
  return;
18336
18441
  }
18337
18442
  const i = next++;
@@ -18341,7 +18446,7 @@ async function runBounded(fn, items, opts) {
18341
18446
  results[i] = settle ? { status: "fulfilled", value } : value;
18342
18447
  } catch (error) {
18343
18448
  if (settle) results[i] = { status: "rejected", reason: error };
18344
- else fail3(error, i);
18449
+ else fail4(error, i);
18345
18450
  }
18346
18451
  }
18347
18452
  };
@@ -19053,6 +19158,210 @@ async function expandResourceNames(client, ids2, opts = {}) {
19053
19158
  return { results, resolved, blind, failed };
19054
19159
  }
19055
19160
 
19161
+ // src/resources/special/_shared/numbers.ts
19162
+ function num(v) {
19163
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
19164
+ }
19165
+
19166
+ // src/resources/special/_shared/finance.ts
19167
+ function budgetExceededError(operation, message, details, suggestedAction) {
19168
+ return new AutotaskError(message, { code: "BUDGET_EXCEEDED", category: "policy", operation, details, suggestedAction });
19169
+ }
19170
+ function makeCallBudget(budget, onExceed) {
19171
+ let spent = 0;
19172
+ return {
19173
+ spend() {
19174
+ if (spent >= budget) throw onExceed(spent);
19175
+ spent += 1;
19176
+ },
19177
+ spent: () => spent
19178
+ };
19179
+ }
19180
+ function countingHttp(raw, spend) {
19181
+ const http = Object.create(raw);
19182
+ http.request = (o) => {
19183
+ spend();
19184
+ return raw.request(o);
19185
+ };
19186
+ return http;
19187
+ }
19188
+ function idChunks(ids2, size) {
19189
+ const out = [];
19190
+ for (let i = 0; i < ids2.length; i += size) out.push(ids2.slice(i, i + size));
19191
+ return out;
19192
+ }
19193
+ async function fetchIdChunks(http, entityPath, ids2, fields, operation, opts) {
19194
+ const chunkSize = opts?.chunkSize ?? 250;
19195
+ const out = /* @__PURE__ */ new Map();
19196
+ for (const chunk of idChunks(ids2, chunkSize)) {
19197
+ opts?.budgetSpend?.();
19198
+ const chunkKeys = new Set(chunk.map((id) => String(id)));
19199
+ try {
19200
+ const req = buildQueryRequest(http.baseUrl, entityPath, {
19201
+ filter: [{ field: "id", op: "in", value: chunk }],
19202
+ maxRecords: opts?.maxRecords ?? chunkSize,
19203
+ includeFields: fields
19204
+ });
19205
+ const res = await http.request({ ...req, operation });
19206
+ const { items: rows } = unwrapItems(res, operation);
19207
+ for (const row of rows) {
19208
+ const k = String(row["id"]);
19209
+ if (!chunkKeys.has(k)) continue;
19210
+ out.set(k, row);
19211
+ }
19212
+ } catch (err) {
19213
+ if (opts?.onChunkFault?.(chunk, err) !== true) throw err;
19214
+ }
19215
+ }
19216
+ return out;
19217
+ }
19218
+ function internalAmount(row, internalKey, localKey) {
19219
+ const v = row[internalKey];
19220
+ return typeof v === "number" && Number.isFinite(v) ? v : num(row[localKey]);
19221
+ }
19222
+ function toCents(v) {
19223
+ return Math.round(num(v) * 100);
19224
+ }
19225
+ async function readPicklists(http, entityPath, operation) {
19226
+ const res = await http.request({ method: "GET", path: `${entityPath}/entityInformation/fields`, operation });
19227
+ const body = typeof res === "object" && res !== null ? res : {};
19228
+ const fields = Array.isArray(body["fields"]) ? body["fields"] : [];
19229
+ const out = /* @__PURE__ */ new Map();
19230
+ for (const f of fields) {
19231
+ if (f["isPickList"] !== true || typeof f["name"] !== "string" || !Array.isArray(f["picklistValues"])) continue;
19232
+ const values = /* @__PURE__ */ new Map();
19233
+ for (const p of f["picklistValues"]) {
19234
+ const id = typeof p["value"] === "string" ? Number.parseInt(p["value"], 10) : Number.NaN;
19235
+ if (Number.isFinite(id)) values.set(id, String(p["label"] ?? ""));
19236
+ }
19237
+ out.set(f["name"], values);
19238
+ }
19239
+ return out;
19240
+ }
19241
+ function resolveSelector(operation, name, sel, values) {
19242
+ const out = /* @__PURE__ */ new Map();
19243
+ const misses = [];
19244
+ for (const s of sel) {
19245
+ const hits = typeof s === "number" ? values.has(s) ? [s] : [] : [...values].filter(([, l]) => l.trim().toLowerCase() === s.trim().toLowerCase()).map(([id]) => id);
19246
+ if (hits.length === 0) misses.push(JSON.stringify(s));
19247
+ for (const h of hits) out.set(h, values.get(h));
19248
+ }
19249
+ if (misses.length > 0) throw selectorUnmatched(operation, name, `${misses.join(", ")} matched no live value`, values);
19250
+ return out;
19251
+ }
19252
+ function selectorUnmatched(operation, name, what, values) {
19253
+ const live = [...values].map(([id, l]) => `${id} ${l}`).join("; ") || "(the picklist serves no values)";
19254
+ return new AutotaskConfigError(`${shortName(operation)}: ${name}: ${what}. Live values (id label): ${live}`, {
19255
+ operation,
19256
+ suggestedAction: `Pass ${name} as ids or exact labels from the live list.`
19257
+ });
19258
+ }
19259
+ var TENANT_HOURLY_LIMIT = 1e4;
19260
+ function tenantHourlyShare(calls) {
19261
+ return `${(calls / TENANT_HOURLY_LIMIT * 100).toFixed(2)}% of ${TENANT_HOURLY_LIMIT.toLocaleString("en-US")}/h`;
19262
+ }
19263
+ var isPosInt = (v) => Number.isSafeInteger(v) && v > 0;
19264
+ function checkIdList(name, v, max, problems, opts) {
19265
+ const ok = opts?.allowZero ? (x) => x === 0 || isPosInt(x) : isPosInt;
19266
+ if (!Array.isArray(v) || v.length === 0 || v.length > max || !v.every(ok)) {
19267
+ problems.push(`${name} must be a non-empty array of at most ${max} ${opts?.allowZero ? "non-negative" : "positive"} integer ids`);
19268
+ return void 0;
19269
+ }
19270
+ return [...new Set(v)].sort((a, b) => a - b);
19271
+ }
19272
+ function checkSelector(name, v, problems) {
19273
+ if (v === void 0) return void 0;
19274
+ if (!Array.isArray(v) || v.length === 0 || !v.every((x) => isPosInt(x) || typeof x === "string" && x.trim() !== "")) {
19275
+ problems.push(`${name} must be a non-empty array of picklist ids or labels`);
19276
+ return void 0;
19277
+ }
19278
+ return v;
19279
+ }
19280
+ function checkInt(name, v, def, max, problems) {
19281
+ if (v === void 0) return def;
19282
+ if (!Number.isInteger(v) || v < 1 || v > max) {
19283
+ problems.push(`${name} must be an integer 1..${max} (got ${String(v)})`);
19284
+ return def;
19285
+ }
19286
+ return v;
19287
+ }
19288
+ async function collectRows(res, filter, includeFields, page) {
19289
+ const out = [];
19290
+ for await (const r of res.query({ filter, includeFields, maxRecords: page, names: false })) out.push(r);
19291
+ return out;
19292
+ }
19293
+ function blindCountError(operation, subject, suggestedAction) {
19294
+ return new AutotaskError(`${shortName(operation)}: a gate count came back blind (unknown, not zero); ${subject} cannot be sized`, {
19295
+ code: "INVALID_RESPONSE",
19296
+ category: "server",
19297
+ operation,
19298
+ details: { reason: "blind_count" },
19299
+ suggestedAction
19300
+ });
19301
+ }
19302
+ function countMismatchError(operation, what, streamed, counted, rows) {
19303
+ const rowNote = rows !== void 0 && rows !== streamed ? ` (${rows} rows)` : "";
19304
+ return new AutotaskError(`${shortName(operation)}: the ${what} stream returned ${streamed} distinct ids${rowNote} but the gate count was ${counted} (the data changed mid-walk or a page dropped rows); the fold was discarded`, {
19305
+ code: "INVALID_RESPONSE",
19306
+ category: "server",
19307
+ operation,
19308
+ details: { reason: "count_mismatch", stream: what, streamed, counted },
19309
+ suggestedAction: "Retry the call."
19310
+ });
19311
+ }
19312
+ function compareIds(a, b) {
19313
+ for (let i = 0; i < a.length; i++) {
19314
+ const x = a[i] ?? null;
19315
+ const y = b[i] ?? null;
19316
+ if (x === y) continue;
19317
+ if (x === null) return -1;
19318
+ if (y === null) return 1;
19319
+ if (typeof x === "number" && typeof y === "number") return x - y;
19320
+ return String(x) < String(y) ? -1 : 1;
19321
+ }
19322
+ return 0;
19323
+ }
19324
+ var sortedRecord = (m) => Object.fromEntries([...m].sort((a, b) => a[0] - b[0]).map(([id, l]) => [String(id), l]));
19325
+ var shortName = (operation) => operation.split(".").pop() ?? operation;
19326
+
19327
+ // src/operations/nameBatch.ts
19328
+ var NAME_BATCH_CHUNK_SIZE = 250;
19329
+ function nameEntryKey(path) {
19330
+ return path + "\0name";
19331
+ }
19332
+ function nameEntrySnapshot(cache, path) {
19333
+ const value = cache?.get(nameEntryKey(path));
19334
+ if (value === void 0 || value === null || typeof value !== "object") return void 0;
19335
+ return () => value;
19336
+ }
19337
+ async function batchNameReads(http, entityPath, ids2, fields, operation) {
19338
+ const cache = http.readCache;
19339
+ const epoch = cache?.epoch ?? 0;
19340
+ const out = /* @__PURE__ */ new Map();
19341
+ const rows = await fetchIdChunks(http, entityPath, ids2, fields, operation, {
19342
+ chunkSize: NAME_BATCH_CHUNK_SIZE,
19343
+ maxRecords: NAME_BATCH_CHUNK_SIZE,
19344
+ onChunkFault: (chunk, err) => {
19345
+ if (!isAutotaskError(err) || err.code === "ABORTED") return false;
19346
+ const error = err.httpStatus !== void 0 ? { code: err.code, message: err.message, httpStatus: err.httpStatus } : { code: err.code, message: err.message };
19347
+ for (const id of chunk) out.set(String(id), { kind: "error", error });
19348
+ return true;
19349
+ }
19350
+ });
19351
+ for (const id of ids2) {
19352
+ const k = String(id);
19353
+ if (out.has(k)) continue;
19354
+ const record = rows.get(k);
19355
+ if (record === void 0) {
19356
+ out.set(k, { kind: "unreadable" });
19357
+ continue;
19358
+ }
19359
+ cache?.set(nameEntryKey(`${entityPath}/${k}`), record, epoch);
19360
+ out.set(k, { kind: "record", record });
19361
+ }
19362
+ return out;
19363
+ }
19364
+
19056
19365
  // src/operations/lineOfBusinessChain.ts
19057
19366
  function vendorId(value) {
19058
19367
  if (typeof value === "number") return Number.isSafeInteger(value) && value >= 1 ? value : void 0;
@@ -19133,7 +19442,7 @@ async function resolveLineOfBusinessChain(http, associationId, options) {
19133
19442
 
19134
19443
  // src/operations/compositeNames.ts
19135
19444
  var PICKLIST_VALUE_NOT_SERVED_NOTE = "The picklist is served to this API user, but this record's value is not in it (an inactive or unexposed value) \u2014 the label cannot be resolved and is null; refreshing the field catalog will not surface it. (A picklist the vendor does not expose at all is reported with the field-catalog honesty note instead.)";
19136
- var DEFAULT_MAX_NAME_READS = 20;
19445
+ var DEFAULT_MAX_NAME_READS = 50;
19137
19446
  var TICKET_LABEL_FIELDS = ["status", "priority", "ticketType", "issueType", "subIssueType", "source", "queueID"];
19138
19447
  function isVendorId(value) {
19139
19448
  if (typeof value === "number") return Number.isSafeInteger(value) && value >= 0;
@@ -19226,6 +19535,15 @@ var FK_NAME_FIELD = {
19226
19535
  product: "name",
19227
19536
  configurationItemCategory: "name"
19228
19537
  };
19538
+ var FK_BATCH_FIELDS = {
19539
+ role: ["name"],
19540
+ billingCode: ["name"],
19541
+ contract: ["contractName"],
19542
+ company: ["companyName"],
19543
+ ticket: ["ticketNumber", "title"],
19544
+ product: ["name"],
19545
+ configurationItemCategory: ["name"]
19546
+ };
19229
19547
  function fkName(record, table) {
19230
19548
  if (table === "ticket") {
19231
19549
  const parts = [record["ticketNumber"], record["title"]].filter((v) => typeof v === "string" && v.trim() !== "").map((v) => v.trim());
@@ -19250,6 +19568,8 @@ async function resolveCompositeNames(http, plan, opts = {}) {
19250
19568
  const readCache = http.readCache;
19251
19569
  const section = { truncated: false, rows: {}, reasons: {} };
19252
19570
  let remaining = budget;
19571
+ let overBudget = 0;
19572
+ let unreadable = 0;
19253
19573
  const tasks = [];
19254
19574
  let contractLobPointer;
19255
19575
  let contractLobUnread;
@@ -19266,6 +19586,7 @@ async function resolveCompositeNames(http, plan, opts = {}) {
19266
19586
  for (const id of overBudgetResource) {
19267
19587
  section.rows[`resource:${id}`] = { name: null, blind: false };
19268
19588
  section.truncated = true;
19589
+ overBudget += 1;
19269
19590
  }
19270
19591
  const overSet = new Set(overBudgetResource.map((id) => String(id)));
19271
19592
  const opIds = plan.resourceIds.filter((id) => !overSet.has(String(id)));
@@ -19275,6 +19596,7 @@ async function resolveCompositeNames(http, plan, opts = {}) {
19275
19596
  for (const id of pass.slice(500)) {
19276
19597
  section.rows[`resource:${id}`] = { name: null, blind: false };
19277
19598
  section.truncated = true;
19599
+ overBudget += 1;
19278
19600
  }
19279
19601
  pass = pass.slice(0, 500);
19280
19602
  }
@@ -19303,48 +19625,89 @@ async function resolveCompositeNames(http, plan, opts = {}) {
19303
19625
  product: client.products,
19304
19626
  configurationItemCategory: client.configurationItemCategories
19305
19627
  };
19628
+ const isLobContract = (fk2) => fk2.table === "contract" && plan.lineOfBusinessContractId !== void 0 && String(fk2.id) === String(plan.lineOfBusinessContractId);
19629
+ const fkRows = /* @__PURE__ */ new Map();
19630
+ const takeLobPointer = (fk2, record) => {
19631
+ if (plan.lineOfBusinessId === void 0 && isLobContract(fk2)) contractLobPointer = vendorId(record["organizationalLevelAssociationID"]);
19632
+ };
19633
+ const steps = [];
19634
+ const coldByTable = /* @__PURE__ */ new Map();
19306
19635
  for (const fk2 of plan.recordFks) {
19307
19636
  const key = `${fk2.table}:${fk2.id}`;
19308
- const snapshot = nameRecordSnapshot(readCache, `${FK_TABLE_PATH[fk2.table]}/${fk2.id}`, fk2.id, FK_GET_OPERATION[fk2.table]);
19309
- const cold = snapshot === void 0;
19310
- if (cold) {
19311
- if (remaining < 1) {
19312
- tasks.push(async () => () => {
19313
- section.rows[key] = { name: null, blind: false };
19314
- });
19315
- section.truncated = true;
19316
- if (fk2.table === "contract" && plan.lineOfBusinessContractId !== void 0 && String(fk2.id) === String(plan.lineOfBusinessContractId)) {
19317
- contractLobUnread = "capped";
19318
- }
19319
- continue;
19320
- }
19321
- remaining -= 1;
19637
+ const path = `${FK_TABLE_PATH[fk2.table]}/${fk2.id}`;
19638
+ const snapshot = nameRecordSnapshot(readCache, path, fk2.id, FK_GET_OPERATION[fk2.table]) ?? (isLobContract(fk2) ? void 0 : nameEntrySnapshot(readCache, path));
19639
+ if (snapshot !== void 0) {
19640
+ steps.push({ fk: fk2, snapshot });
19641
+ continue;
19642
+ }
19643
+ if (remaining < 1) {
19644
+ fkRows.set(key, { name: null, blind: false });
19645
+ overBudget += 1;
19646
+ section.truncated = true;
19647
+ if (isLobContract(fk2)) contractLobUnread = "capped";
19648
+ continue;
19322
19649
  }
19650
+ remaining -= 1;
19651
+ steps.push({ fk: fk2 });
19652
+ if (!isLobContract(fk2)) coldByTable.set(fk2.table, [...coldByTable.get(fk2.table) ?? [], fk2]);
19653
+ }
19654
+ const batched = /* @__PURE__ */ new Set();
19655
+ for (const { fk: fk2, snapshot } of steps) {
19656
+ const key = `${fk2.table}:${fk2.id}`;
19657
+ if (snapshot !== void 0) {
19658
+ tasks.push(async () => {
19659
+ const row = await fkRow(fk2, async () => snapshot());
19660
+ return () => {
19661
+ fkRows.set(key, row);
19662
+ };
19663
+ });
19664
+ continue;
19665
+ }
19666
+ const group = isLobContract(fk2) ? void 0 : coldByTable.get(fk2.table);
19667
+ if (group === void 0 || group.length === 1) {
19668
+ tasks.push(async () => {
19669
+ const row = await fkRow(fk2, async () => await holders[fk2.table].get(fk2.id));
19670
+ return () => {
19671
+ fkRows.set(key, row);
19672
+ };
19673
+ });
19674
+ continue;
19675
+ }
19676
+ if (batched.has(fk2.table)) continue;
19677
+ batched.add(fk2.table);
19678
+ const table = fk2.table;
19323
19679
  tasks.push(async () => {
19324
- let row;
19325
- try {
19326
- const record = snapshot !== void 0 ? snapshot() : await holders[fk2.table].get(fk2.id);
19327
- if (fk2.table === "contract" && plan.lineOfBusinessId === void 0 && plan.lineOfBusinessContractId !== void 0 && String(fk2.id) === String(plan.lineOfBusinessContractId)) {
19328
- contractLobPointer = vendorId(record["organizationalLevelAssociationID"]);
19329
- }
19330
- row = { name: fkName(record, fk2.table), blind: false };
19331
- } catch (err) {
19332
- if (err instanceof NotFoundError) {
19333
- row = { name: null, blind: true };
19334
- } else if (isAutotaskError(err) && err.code !== "ABORTED") {
19335
- row = { name: null, blind: false, error: faultRow(err) };
19336
- if (fk2.table === "contract" && plan.lineOfBusinessContractId !== void 0 && String(fk2.id) === String(plan.lineOfBusinessContractId)) {
19337
- contractLobUnread = "unresolved";
19680
+ const outcomes = await batchNameReads(http, FK_TABLE_PATH[table], group.map((g) => g.id), FK_BATCH_FIELDS[table], FK_GET_OPERATION[table].replace(/\.get$/, ".query"));
19681
+ return () => {
19682
+ for (const g of group) {
19683
+ const out = outcomes.get(String(g.id));
19684
+ const gKey = `${table}:${g.id}`;
19685
+ if (out.kind === "record") fkRows.set(gKey, { name: fkName(out.record, table), blind: false });
19686
+ else if (out.kind === "error") fkRows.set(gKey, { name: null, blind: false, error: out.error });
19687
+ else {
19688
+ fkRows.set(gKey, { name: null, blind: true, unreadable: true });
19689
+ unreadable += 1;
19338
19690
  }
19339
- } else {
19340
- throw err;
19341
19691
  }
19342
- }
19343
- return () => {
19344
- section.rows[key] = row;
19345
19692
  };
19346
19693
  });
19347
19694
  }
19695
+ async function fkRow(fk2, read) {
19696
+ try {
19697
+ const record = await read();
19698
+ takeLobPointer(fk2, record);
19699
+ return { name: fkName(record, fk2.table), blind: false };
19700
+ } catch (err) {
19701
+ if (err instanceof NotFoundError) {
19702
+ return { name: null, blind: true };
19703
+ }
19704
+ if (isAutotaskError(err) && err.code !== "ABORTED") {
19705
+ if (isLobContract(fk2)) contractLobUnread = "unresolved";
19706
+ return { name: null, blind: false, error: faultRow(err) };
19707
+ }
19708
+ throw err;
19709
+ }
19710
+ }
19348
19711
  let picklists = null;
19349
19712
  if (plan.labelFields.length > 0) {
19350
19713
  tasks.push(async () => {
@@ -19358,6 +19721,10 @@ async function resolveCompositeNames(http, plan, opts = {}) {
19358
19721
  });
19359
19722
  }
19360
19723
  for (const merge of await readTasks(http, tasks)) merge();
19724
+ for (const fk2 of plan.recordFks) {
19725
+ const key = `${fk2.table}:${fk2.id}`;
19726
+ section.rows[key] = fkRows.get(key);
19727
+ }
19361
19728
  let lineOfBusiness2 = null;
19362
19729
  const lobId = plan.lineOfBusinessId ?? contractLobPointer;
19363
19730
  if (lobId !== void 0) {
@@ -19382,6 +19749,8 @@ async function resolveCompositeNames(http, plan, opts = {}) {
19382
19749
  return {
19383
19750
  section,
19384
19751
  lineOfBusiness: lineOfBusiness2,
19752
+ overBudget,
19753
+ unreadable,
19385
19754
  resourceName: (id) => section.rows[`resource:${id}`]?.name ?? null,
19386
19755
  recordName: (table, id) => section.rows[`${table}:${id}`]?.name ?? null,
19387
19756
  labelFor: (field, value) => {
@@ -19426,6 +19795,23 @@ function notPersistedFields(sent, stored) {
19426
19795
  return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== REDACTED && !same(value, stored[key])).map(([key]) => key);
19427
19796
  }
19428
19797
 
19798
+ // src/resources/special/inventoryLocations.ts
19799
+ var fail = (message) => {
19800
+ throw new AutotaskConfigError(`inventory_locations: ${message}`);
19801
+ };
19802
+ function admitInventoryLocation(value, creating) {
19803
+ if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
19804
+ const body = { ...value };
19805
+ for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
19806
+ if ((creating || Object.hasOwn(body, "locationName")) && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail("locationName is required and must be a nonblank string of at most 50 characters");
19807
+ if ((creating || Object.hasOwn(body, "isActive")) && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
19808
+ if (!creating && !Object.keys(body).length) fail("update must contain locationName or isActive");
19809
+ return body;
19810
+ }
19811
+ function checkInventoryLocationCurrent(value, current) {
19812
+ if (value.isActive === false && current.isDefault !== false) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
19813
+ }
19814
+
19429
19815
  // src/resources/base/types.ts
19430
19816
  var BOUNDED_QUERY_DEFAULT_LIMIT = 500;
19431
19817
  var BOUNDED_QUERY_MAX_LIMIT = 2500;
@@ -19592,6 +19978,7 @@ var MODEL_FIELD_SETS = {
19592
19978
  "expense_reports": ["id", "amountDue", "approvedDate", "approverID", "departmentNumber", "internalCurrencyCashAdvanceAmount", "internalCurrencyExpenseTotal", "name", "organizationalLevelAssociationID", "quickBooksReferenceNumber", "reimbursementCurrencyAmountDue", "reimbursementCurrencyCashAdvanceAmount", "reimbursementCurrencyID", "rejectionReason", "status", "submit", "submitDate", "submitterID", "weekEnding"],
19593
19979
  "holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
19594
19980
  "holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
19981
+ "inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
19595
19982
  "inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
19596
19983
  "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"],
19597
19984
  "invoices": ["id", "batchID", "comments", "companyID", "createDateTime", "creatorResourceID", "dueDate", "fromDate", "invoiceDateTime", "invoiceEditorTemplateID", "invoiceNumber", "invoiceTotal", "isVoided", "orderNumber", "paidDate", "paymentTerm", "taxGroup", "taxRegionName", "toDate", "totalTaxValue", "voidedByResourceID", "voidedDate", "webServiceDate"],
@@ -19831,21 +20218,21 @@ function validateRelationLeaves(resourceKey, conditions, op) {
19831
20218
  assertUndottedUdfField(c, op);
19832
20219
  const field = c.field;
19833
20220
  const [rel, sub, ...rest] = field.split(".");
19834
- const fail3 = (why) => {
20221
+ const fail4 = (why) => {
19835
20222
  throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
19836
20223
  operation: op,
19837
20224
  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.`
19838
20225
  });
19839
20226
  };
19840
20227
  if (selfPrefixes(resourceKey).includes(rel)) {
19841
- if (rest.length > 0 || !sub) fail3("is not <resource>.<field> (multi-hop relations are not supported)");
20228
+ if (rest.length > 0 || !sub) fail4("is not <resource>.<field> (multi-hop relations are not supported)");
19842
20229
  continue;
19843
20230
  }
19844
- if (rest.length > 0 || !sub) fail3("is not <relation>.<field> (multi-hop relations are not supported)");
19845
- if (!valid.includes(rel)) fail3(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
20231
+ if (rest.length > 0 || !sub) fail4("is not <relation>.<field> (multi-hop relations are not supported)");
20232
+ if (!valid.includes(rel)) fail4(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
19846
20233
  const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
19847
20234
  if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
19848
- fail3(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
20235
+ fail4(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
19849
20236
  }
19850
20237
  }
19851
20238
  };
@@ -19998,11 +20385,13 @@ async function labelRows(client, resourceKey, rows) {
19998
20385
  }
19999
20386
  return r;
20000
20387
  });
20001
- const capHit = names?.section.truncated === true;
20388
+ const overBudget = names?.overBudget ?? 0;
20389
+ const unreadable = names?.unreadable ?? 0;
20002
20390
  const unresolved2 = Object.keys(names?.section.reasons ?? {});
20003
- if (capHit === false && unresolved2.length === 0) return { rows: out };
20391
+ if (overBudget === 0 && unreadable === 0 && unresolved2.length === 0) return { rows: out };
20004
20392
  const parts = [];
20005
- if (capHit) parts.push(`ids left unlabelled (their *Name is null): the per-call cap of ${DEFAULT_MAX_NAME_READS} uncached name reads was hit \u2014 names already read are cached, so repeating or narrowing the call labels more`);
20393
+ if (overBudget > 0) parts.push(`ids left unlabelled (their *Name is null): ${overBudget} id(s) over the per-call cap of ${DEFAULT_MAX_NAME_READS} uncached name reads \u2014 names already read are cached, so repeating or narrowing the call labels more`);
20394
+ if (unreadable > 0) parts.push(`${unreadable} id(s) not returned by the batched name read (their *Name is null): the record may be absent or not visible to this API user, so this is not a not-found`);
20006
20395
  if (unresolved2.length > 0) parts.push(`picklist label(s) unavailable for ${unresolved2.join(", ")} (see reasons)`);
20007
20396
  return { rows: out, names: { note: parts.join("; "), ...Object.keys(names.section.reasons).length > 0 ? { reasons: names.section.reasons } : {} } };
20008
20397
  }
@@ -20171,7 +20560,7 @@ var QueryBase = class {
20171
20560
  }
20172
20561
  continueAcrossEmptyPage() {
20173
20562
  const { key } = this.config;
20174
- return isAuditLogResource(key) || isKnowledgeBaseRootResource(key);
20563
+ return isAuditLogResource(key) || isExactRecordResource(key);
20175
20564
  }
20176
20565
  /** @internal */
20177
20566
  readPage(body, page, pageSize, state2) {
@@ -20223,7 +20612,7 @@ var QueryBase = class {
20223
20612
  * (as queryBounded). Label siblings are opt-in (issue #287): the per-call
20224
20613
  * `names` key is the explicit override, absent = the client's `labels`
20225
20614
  * option (off by default). When on, labelling runs per page, so the cold
20226
- * name-read cap (20) applies per page; a capped id gets a null `*Name`
20615
+ * name-read cap (DEFAULT_MAX_NAME_READS) applies per page; a capped id gets a null `*Name`
20227
20616
  * (an iterator has no result envelope for the `names` summary). A
20228
20617
  * resource built without a client (bare `HttpClient`) yields raw rows.
20229
20618
  */
@@ -20568,7 +20957,7 @@ var QueryBase = class {
20568
20957
  }
20569
20958
  if (total <= BOUNDED_QUERY_MAX_LIMIT) {
20570
20959
  const { items: items2, pages: pages3, guard: guard2, sliced: sliced2, cursor: cursor2 } = await this.walkBounded(params, total);
20571
- if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.hasCompleteKnowledgeBaseWindow(items2, total)) {
20960
+ if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.hasCompleteExactRecordWindow(items2, total)) {
20572
20961
  throw this.latestWindowIncompleteError(total);
20573
20962
  }
20574
20963
  return this.finishLatest(items2, latest, pages3);
@@ -20577,11 +20966,11 @@ var QueryBase = class {
20577
20966
  probes += 1;
20578
20967
  if (probes > LATEST_MAX_COUNT_PROBES) throw this.latestThresholdUnresolvedError();
20579
20968
  };
20580
- const knowledgeBase = isKnowledgeBaseRootResource(this.config.key);
20581
- let lo = knowledgeBase ? -1n : 0n;
20969
+ const exactRecord = isExactRecordResource(this.config.key);
20970
+ let lo = exactRecord ? -1n : 0n;
20582
20971
  let hi;
20583
20972
  let aboveThreshold = 0;
20584
- if (isAuditLogResource(this.config.key) || knowledgeBase) {
20973
+ if (isAuditLogResource(this.config.key) || exactRecord) {
20585
20974
  hi = BigInt(MAX_AUDIT_ID);
20586
20975
  } else {
20587
20976
  for (let t = 1n; ; t = t << 1n) {
@@ -20602,17 +20991,17 @@ var QueryBase = class {
20602
20991
  aboveThreshold = above;
20603
20992
  } else lo = mid;
20604
20993
  }
20605
- if (knowledgeBase && aboveThreshold !== latest) throw this.latestWindowIncompleteError(latest + 1);
20994
+ if (exactRecord && aboveThreshold !== latest) throw this.latestWindowIncompleteError(latest + 1);
20606
20995
  const windowValue = hi <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(hi) : hi.toString();
20607
20996
  const window = [...baseConds, { op: "gte", field: "id", value: windowValue }];
20608
20997
  const { items, pages: pages2, guard, sliced, cursor } = await this.walkBounded({ ...params, filter: window }, latest + 1);
20609
- if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.hasCompleteKnowledgeBaseWindow(items, latest + 1, hi)) {
20998
+ if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.hasCompleteExactRecordWindow(items, latest + 1, hi)) {
20610
20999
  throw this.latestWindowIncompleteError(latest + 1);
20611
21000
  }
20612
21001
  return this.finishLatest(items, latest, pages2);
20613
21002
  }
20614
- hasCompleteKnowledgeBaseWindow(items, expected, minimum) {
20615
- if (!isKnowledgeBaseRootResource(this.config.key)) return true;
21003
+ hasCompleteExactRecordWindow(items, expected, minimum) {
21004
+ if (!isExactRecordResource(this.config.key)) return true;
20616
21005
  if (items.length !== expected) return false;
20617
21006
  const ids2 = items.map((item) => String(item.id));
20618
21007
  if (new Set(ids2).size !== expected) return false;
@@ -20759,10 +21148,12 @@ var MetaBase = class _MetaBase extends QueryBase {
20759
21148
  return cachedMetadataGet(this.http, this.config.key, kind, path, operation, unwrap, fresh, maxRetries);
20760
21149
  }
20761
21150
  /** `GET /V1.0/<E>/{id}` → `{ item }` unwrapped (`item: null` → NotFoundError). */
20762
- async getGlobal(id, fresh = false, maxRetries) {
21151
+ async getGlobal(id, fresh = false, maxRetries, checkedBaseUrl) {
20763
21152
  const numeric2 = parseIdentifier(id, "id");
20764
- const res = await this.cachedGet(`${this.resourcePath}/${numeric2}`, `${this.config.key}.get`, fresh, maxRetries);
20765
- return unwrapItem(res, numeric2, `${this.config.key}.get`, this.entityName);
21153
+ const path = `${this.resourcePath}/${numeric2}`;
21154
+ const operation = `${this.config.key}.get`;
21155
+ const res = checkedBaseUrl === void 0 ? await this.cachedGet(path, operation, fresh, maxRetries) : await this.http.request({ method: "GET", path, operation, maxRetries, checkedBaseUrl });
21156
+ return unwrapItem(res, numeric2, operation, this.entityName);
20766
21157
  }
20767
21158
  /**
20768
21159
  * V2 merge read: a FRESH single-record GET that skips response redaction
@@ -21279,26 +21670,26 @@ var MetaBase = class _MetaBase extends QueryBase {
21279
21670
 
21280
21671
  // src/resources/special/knowledgeBaseCategories.ts
21281
21672
  function admitKnowledgeBaseCategory(data, creating, staleToken) {
21282
- const fail3 = (message) => {
21673
+ const fail4 = (message) => {
21283
21674
  throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
21284
21675
  };
21285
- if (!creating && staleToken !== void 0) fail3("no documented stale timestamp is available");
21286
- if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
21676
+ if (!creating && staleToken !== void 0) fail4("no documented stale timestamp is available");
21677
+ if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
21287
21678
  const body = { ...data };
21288
- for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail3(`${field} is not a writable KnowledgeBaseCategories field`);
21679
+ for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail4(`${field} is not a writable KnowledgeBaseCategories field`);
21289
21680
  for (const [field, max] of [["name", 50], ["description", 1e3]]) {
21290
21681
  const value = body[field];
21291
- if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail3(`${field} must be a string of at most ${max} characters`);
21682
+ if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail4(`${field} must be a string of at most ${max} characters`);
21292
21683
  }
21293
- if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail3("name is required");
21294
- if (creating && body.parentCategoryID === void 0) fail3("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
21684
+ if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail4("name is required");
21685
+ if (creating && body.parentCategoryID === void 0) fail4("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
21295
21686
  const parent = body.parentCategoryID;
21296
21687
  if (parent !== void 0) {
21297
- if (typeof parent !== "number") return fail3("parentCategoryID must be a numeric identifier");
21688
+ if (typeof parent !== "number") return fail4("parentCategoryID must be a numeric identifier");
21298
21689
  parseIdentifier(parent, "parentCategoryID");
21299
- if (parent > 2147483647) fail3("parentCategoryID must fit a signed 32-bit integer");
21690
+ if (parent > 2147483647) fail4("parentCategoryID must fit a signed 32-bit integer");
21300
21691
  }
21301
- if (!creating && !Object.values(body).some((value) => value !== void 0)) fail3("update must contain a writable field");
21692
+ if (!creating && !Object.values(body).some((value) => value !== void 0)) fail4("update must contain a writable field");
21302
21693
  return body;
21303
21694
  }
21304
21695
  function categoryReplacement(body) {
@@ -21312,45 +21703,45 @@ function categoryReplacement(body) {
21312
21703
  }
21313
21704
 
21314
21705
  // src/resources/special/knowledgeBaseArticles.ts
21315
- function fail(detail) {
21706
+ function fail2(detail) {
21316
21707
  throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
21317
21708
  }
21318
21709
  function reference(value, name) {
21319
- if (typeof value !== "number") fail(`${name} must be a numeric identifier`);
21710
+ if (typeof value !== "number") fail2(`${name} must be a numeric identifier`);
21320
21711
  parseIdentifier(value, name);
21321
- if (value > 2147483647) fail(`${name} must fit a signed 32-bit integer`);
21712
+ if (value > 2147483647) fail2(`${name} must fit a signed 32-bit integer`);
21322
21713
  return value;
21323
21714
  }
21324
21715
  function articleParent(value) {
21325
21716
  const parent = parseIdentifier(value, "parentId");
21326
- if (typeof parent !== "number" || parent > 2147483647) fail("parentId must fit a signed 32-bit category identifier");
21327
- if (parent === 0) fail("parentId must name an article category");
21717
+ if (typeof parent !== "number" || parent > 2147483647) fail2("parentId must fit a signed 32-bit category identifier");
21718
+ if (parent === 0) fail2("parentId must name an article category");
21328
21719
  return parent;
21329
21720
  }
21330
21721
  function admitArticle(data, parentId, creating) {
21331
21722
  const parent = articleParent(parentId);
21332
- if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail("data must be a plain record");
21723
+ if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
21333
21724
  const body = { ...data };
21334
21725
  const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
21335
21726
  for (const key of Object.keys(body)) {
21336
- if (!allowed.includes(key)) fail(`${key} is not a writable article root field`);
21727
+ if (!allowed.includes(key)) fail2(`${key} is not a writable article root field`);
21337
21728
  if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
21338
21729
  }
21339
21730
  for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
21340
- if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail(`${field} must be a string of at most ${max} characters`);
21341
- }
21342
- if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail("title is required and cannot be blank");
21343
- if (!creating && Object.hasOwn(body, "articleCategoryID")) fail("articleCategoryID is read-only after creation");
21344
- if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail("articleCategoryID must match parentId");
21345
- 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");
21346
- if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail("isActive must be boolean");
21347
- if (!creating && !Object.keys(body).length) fail("update must contain a writable field");
21731
+ if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail2(`${field} must be a string of at most ${max} characters`);
21732
+ }
21733
+ if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail2("title is required and cannot be blank");
21734
+ if (!creating && Object.hasOwn(body, "articleCategoryID")) fail2("articleCategoryID is read-only after creation");
21735
+ if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail2("articleCategoryID must match parentId");
21736
+ 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");
21737
+ if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail2("isActive must be boolean");
21738
+ if (!creating && !Object.keys(body).length) fail2("update must contain a writable field");
21348
21739
  return body;
21349
21740
  }
21350
21741
  async function guardArticle(http, parentId, id, maxRetries) {
21351
21742
  const parent = articleParent(parentId);
21352
21743
  const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
21353
- if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail("id must name an article within the signed 64-bit range");
21744
+ if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail2("id must name an article within the signed 64-bit range");
21354
21745
  unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
21355
21746
  if (target !== void 0) {
21356
21747
  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");
@@ -21359,7 +21750,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
21359
21750
  }
21360
21751
  function assertArticlePublish(data, fields) {
21361
21752
  if (!Object.hasOwn(data, "publish")) return;
21362
- const unavailable = () => fail("publish requires an unambiguous active value in current field metadata");
21753
+ const unavailable = () => fail2("publish requires an unambiguous active value in current field metadata");
21363
21754
  if (!Array.isArray(fields)) unavailable();
21364
21755
  const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
21365
21756
  if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
@@ -21565,23 +21956,27 @@ var MutationBase = class extends MetaBase {
21565
21956
  * write already happened, so a failed read-back is reported on the result
21566
21957
  * (`persistedCheckFailed`: the error code, or `UNKNOWN (<error name>)`), never thrown.
21567
21958
  */
21568
- async withPersistedCheck(result, data, opts, id, parentId) {
21959
+ async withPersistedCheck(result, data, opts, id, parentId, checkedBaseUrl) {
21569
21960
  if (opts.verifyPersisted !== true) return result;
21570
- const maxRetries = isKnowledgeBaseRootResource(this.config.key) ? opts.maxRetries : void 0;
21961
+ const maxRetries = isExactRecordResource(this.config.key) ? opts.maxRetries : void 0;
21571
21962
  try {
21572
- 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);
21573
- return { ...result, notPersisted: notPersistedFields(data, stored) };
21963
+ 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);
21964
+ const submitted = data;
21965
+ const persisted = stored;
21966
+ const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
21967
+ return { ...result, notPersisted };
21574
21968
  } catch (err) {
21575
21969
  return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
21576
21970
  }
21577
21971
  }
21578
- async updateGlobal(id, data, opts = {}, method = "PUT") {
21972
+ async updateGlobal(id, data, opts = {}, method = "PUT", checkedBaseUrl) {
21579
21973
  const numeric2 = parseIdentifier(id, "id");
21580
21974
  const operation = `${this.config.key}.update`;
21581
21975
  let body = this.normalizeMutationBody(data);
21582
- const collectionUpdate = this.config.collectionUpdate === true;
21976
+ const partialCollection = checkedBaseUrl !== void 0;
21977
+ const collectionUpdate = partialCollection || this.config.collectionUpdate === true;
21583
21978
  if (collectionUpdate) {
21584
- if (opts.raw !== true) {
21979
+ if (!partialCollection && opts.raw !== true) {
21585
21980
  let current;
21586
21981
  try {
21587
21982
  current = await this.getGlobalUnredacted(numeric2, { maxRetries: opts.maxRetries });
@@ -21605,7 +22000,9 @@ var MutationBase = class extends MetaBase {
21605
22000
  path: collectionUpdate ? this.resourcePath : `${this.resourcePath}/${numeric2}`,
21606
22001
  body,
21607
22002
  operation,
21608
- maxRetries: opts.maxRetries
22003
+ maxRetries: opts.maxRetries,
22004
+ // The preflight facts must be checked again before any later PATCH.
22005
+ ...partialCollection ? { maintenanceMaxWaitMs: 0, checkedBaseUrl } : {}
21609
22006
  });
21610
22007
  } catch (err) {
21611
22008
  if (method === "PATCH" || !this.putFallbackEligible(err)) throw err;
@@ -21632,7 +22029,7 @@ var MutationBase = class extends MetaBase {
21632
22029
  }
21633
22030
  return this.withPersistedCheck(unwrapOperation(retry, operation), data, opts, numeric2);
21634
22031
  }
21635
- return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2);
22032
+ return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2, void 0, checkedBaseUrl);
21636
22033
  }
21637
22034
  /** `DELETE /V1.0/<E>/{id}` → `{ id }` (OperationResultModel). A blank 2xx
21638
22035
  * (204 / empty body) is a valid vendor delete answer — synthesize the
@@ -21942,21 +22339,22 @@ var MutationBase = class extends MetaBase {
21942
22339
  * check (mismatch throws STALE_OBJECT) and the best-effort `diff`. NO
21943
22340
  * mutating request is issued.
21944
22341
  */
21945
- async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord) {
22342
+ async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord, partialCollection) {
21946
22343
  const operation = `${this.config.key}.update`;
21947
22344
  const checks = [];
21948
22345
  const warnings = [];
21949
22346
  checks.push({ name: "input-validation", ok: isRecord2(data) && Object.keys(data).length > 0 });
21950
22347
  const scopedUpdate = parentId !== void 0 && this.config.parentScopedPath !== void 0;
21951
- const collectionUpdate = scopedUpdate || this.config.collectionUpdate === true;
22348
+ const collectionUpdate = scopedUpdate || partialCollection !== void 0 || this.config.collectionUpdate === true;
21952
22349
  const path = scopedUpdate ? this.scopedCollectionPath(parentId) : collectionUpdate ? this.resourcePath : `${this.resourcePath}/${id}`;
21953
- const method = scopedUpdate ? "PATCH" : "PUT";
22350
+ const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
21954
22351
  let current;
21955
22352
  try {
21956
- 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));
22353
+ 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));
21957
22354
  } catch (err) {
21958
22355
  if (err instanceof NotFoundError) {
21959
- const updateReason = EMPTY_REASON_STAMPS[this.config.key]?.update;
22356
+ const reasons = EMPTY_REASON_STAMPS[this.config.key];
22357
+ const updateReason = reasons?.update ?? (partialCollection === void 0 ? void 0 : reasons?.get);
21960
22358
  checks.push({
21961
22359
  name: "current-record-exists",
21962
22360
  ok: false,
@@ -21971,18 +22369,19 @@ var MutationBase = class extends MetaBase {
21971
22369
  checks,
21972
22370
  impact: { affected: 1, scope: "single-record", reversible: true },
21973
22371
  warnings,
21974
- data,
22372
+ data: partialCollection === void 0 ? data : { ...data, id },
21975
22373
  ...updateReason !== void 0 ? { emptyReason: updateReason } : {}
21976
22374
  }, { redactPersonalData: this.http.redactPersonalData });
21977
22375
  }
21978
22376
  throw err;
21979
22377
  }
21980
22378
  checks.push({ name: "current-record-exists", ok: true });
22379
+ partialCollection?.checkCurrent(current);
21981
22380
  if (this.staleObjectCheck(current, opts, operation)) {
21982
22381
  checks.push({ name: "stale-check", ok: true });
21983
22382
  }
21984
22383
  let envelopeData = data;
21985
- if (this.config.key === "knowledge_base_articles") {
22384
+ if (partialCollection !== void 0 || this.config.key === "knowledge_base_articles") {
21986
22385
  envelopeData = { ...this.normalizeMutationBody(data), id };
21987
22386
  } else if (parentId === void 0 && this.config.collectionUpdate === true && opts.raw !== true) {
21988
22387
  const merged = mergePartialBody(current, this.normalizeMutationBody(data));
@@ -22059,34 +22458,34 @@ var BaseResource = class extends MutationBase {
22059
22458
  };
22060
22459
 
22061
22460
  // src/resources/special/taskPredecessors.ts
22062
- function fail2(detail) {
22461
+ function fail3(detail) {
22063
22462
  throw new AutotaskConfigError(`task_predecessors: ${detail}`);
22064
22463
  }
22065
22464
  function numeric(value, field) {
22066
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail2(`${field} must be a positive numeric identifier`);
22465
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail3(`${field} must be a positive numeric identifier`);
22067
22466
  return value;
22068
22467
  }
22069
22468
  function predecessorParent(value) {
22070
22469
  const parent = parseIdentifier(value, "parentId");
22071
- if (parent === 0) fail2("parentId must name a successor task");
22470
+ if (parent === 0) fail3("parentId must name a successor task");
22072
22471
  return parent;
22073
22472
  }
22074
22473
  function assertPredecessorBinding(value, parentId, id) {
22075
- if (!isRecord2(value)) fail2("the returned record must establish id and successorTaskID parent");
22076
- 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");
22474
+ if (!isRecord2(value)) fail3("the returned record must establish id and successorTaskID parent");
22475
+ 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");
22077
22476
  }
22078
22477
  function admitTaskPredecessor(data, parentId, creating) {
22079
22478
  const parent = predecessorParent(parentId);
22080
- if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
22479
+ if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
22081
22480
  const payload = { ...data };
22082
22481
  const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
22083
- 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");
22084
- 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");
22482
+ 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");
22483
+ 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");
22085
22484
  if (creating) {
22086
22485
  const successor = numeric(payload.successorTaskID, "successorTaskID");
22087
22486
  const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
22088
- if (String(successor) !== String(parent)) fail2("successorTaskID must match parentId");
22089
- if (predecessor === successor) fail2("predecessorTaskID and successorTaskID must be distinct");
22487
+ if (String(successor) !== String(parent)) fail3("successorTaskID must match parentId");
22488
+ if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
22090
22489
  }
22091
22490
  return payload;
22092
22491
  }
@@ -22095,50 +22494,137 @@ async function guardTaskPredecessor(http, parentId, id, data) {
22095
22494
  let row = data;
22096
22495
  if (id !== void 0) {
22097
22496
  const target = parseIdentifier(id, "id");
22098
- if (target === 0) fail2("id must name a predecessor relationship");
22497
+ if (target === 0) fail3("id must name a predecessor relationship");
22099
22498
  row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
22100
22499
  assertPredecessorBinding(row, parent, target);
22101
22500
  }
22102
22501
  const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
22103
22502
  const successor = numeric(row?.successorTaskID, "successorTaskID");
22104
- if (predecessor === successor) fail2("predecessorTaskID and successorTaskID must be distinct");
22503
+ if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
22105
22504
  const projects = [];
22106
22505
  for (const taskId of [predecessor, successor]) {
22107
22506
  const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
22108
- if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail2("the returned task must match its requested id");
22507
+ if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail3("the returned task must match its requested id");
22109
22508
  projects.push(numeric(task.projectID, "task.projectID"));
22110
22509
  }
22111
- if (projects[0] !== projects[1]) fail2("predecessor and successor tasks must belong to the same project");
22510
+ if (projects[0] !== projects[1]) fail3("predecessor and successor tasks must belong to the same project");
22112
22511
  }
22113
22512
 
22114
22513
  // src/resources/special/taskNotes.ts
22115
22514
  var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
22116
22515
  function admitTaskNote(data, parentId, creating) {
22117
22516
  const parent = parseIdentifier(parentId, "parentId");
22118
- const fail3 = (message) => {
22517
+ const fail4 = (message) => {
22119
22518
  throw new AutotaskConfigError(`task_notes: ${message}`);
22120
22519
  };
22121
- if (data === null || typeof data !== "object" || Array.isArray(data)) fail3("data must be a record");
22520
+ if (data === null || typeof data !== "object" || Array.isArray(data)) fail4("data must be a record");
22122
22521
  const body = data;
22123
- for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail3(`${key} is not a writable TaskNotes field`);
22522
+ for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail4(`${key} is not a writable TaskNotes field`);
22124
22523
  for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
22125
22524
  const value = body[field];
22126
- if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail3(`${field} must be a string of at most ${maximum} characters`);
22525
+ if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail4(`${field} must be a string of at most ${maximum} characters`);
22127
22526
  }
22128
- if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail3("description is required");
22527
+ if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail4("description is required");
22129
22528
  for (const field of ["noteType", "publish"]) {
22130
22529
  const value = body[field];
22131
- if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail3(`${field} must be an integer from the current field metadata`);
22530
+ if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail4(`${field} must be an integer from the current field metadata`);
22132
22531
  }
22133
- if (creating && body.taskID === void 0) fail3("taskID is required in the create body and must match parentId");
22532
+ if (creating && body.taskID === void 0) fail4("taskID is required in the create body and must match parentId");
22134
22533
  for (const field of ["createdByContactID", "taskID"]) {
22135
22534
  if (body[field] !== void 0) {
22136
- if (typeof body[field] !== "number") fail3(`${field} must be a numeric identifier`);
22535
+ if (typeof body[field] !== "number") fail4(`${field} must be a numeric identifier`);
22137
22536
  const id = parseIdentifier(body[field], field);
22138
- if (field === "taskID" && String(id) !== String(parent)) fail3("taskID must match the parentId path argument");
22537
+ if (field === "taskID" && String(id) !== String(parent)) fail4("taskID must match the parentId path argument");
22538
+ }
22539
+ }
22540
+ if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail4("update must contain a writable field");
22541
+ }
22542
+
22543
+ // src/operations/invoke/fieldSuggest.ts
22544
+ var MAX_SUGGESTIONS = 3;
22545
+ var MIN_SUBSTRING_CHARS = 4;
22546
+ var GENERIC_TOKENS = /* @__PURE__ */ new Set(["date", "time", "datetime", "day", "is", "number", "type", "name", "last", "on", "at", "id"]);
22547
+ var DATE_TOKENS = /* @__PURE__ */ new Set(["date", "time", "datetime", "day", "on", "at"]);
22548
+ var TOKEN_SYNONYMS = [["install", "purchase", "purchased"]];
22549
+ var SYNONYM_OF = new Map(TOKEN_SYNONYMS.flatMap((group) => group.map((t) => [t, group[0]])));
22550
+ var Tier = { Substring: 0, Tokens: 1, Edit: 2, Generic: 3, SameType: 4, Rest: 5 };
22551
+ function tokens(name) {
22552
+ return (name.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? []).map((t) => t.toLowerCase());
22553
+ }
22554
+ function normalTokens(name) {
22555
+ return new Set(tokens(name).map((t) => SYNONYM_OF.get(t) ?? t));
22556
+ }
22557
+ function editDistance(a, b, cap = Number.POSITIVE_INFINITY) {
22558
+ if (Math.abs(a.length - b.length) > cap) return cap + 1;
22559
+ const far = Number.isFinite(cap) ? cap + 1 : a.length + b.length + 1;
22560
+ const band = Number.isFinite(cap) ? cap : a.length + b.length;
22561
+ let prev2 = new Int32Array(b.length + 1).fill(far);
22562
+ let prev = Int32Array.from({ length: b.length + 1 }, (_, j) => j <= band ? j : far);
22563
+ let cur = new Int32Array(b.length + 1).fill(far);
22564
+ for (let i = 1; i <= a.length; i += 1) {
22565
+ const lo = Math.max(1, i - band);
22566
+ const hi = Math.min(b.length, i + band);
22567
+ cur.fill(far);
22568
+ cur[0] = i <= band ? i : far;
22569
+ let rowMin = cur[0];
22570
+ for (let j = lo; j <= hi; j += 1) {
22571
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
22572
+ let v = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + cost);
22573
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) v = Math.min(v, prev2[j - 2] + 1);
22574
+ cur[j] = v;
22575
+ if (v < rowMin) rowMin = v;
22576
+ }
22577
+ if (rowMin > cap) return cap + 1;
22578
+ [prev2, prev, cur] = [prev, cur, prev2];
22579
+ }
22580
+ return Math.min(prev[b.length], cap + 1);
22581
+ }
22582
+ function looksLikeDate(name) {
22583
+ return tokens(name).some((t) => DATE_TOKENS.has(t));
22584
+ }
22585
+ var MAX_EDITS = 6;
22586
+ var DISTANCE_CAP = 8;
22587
+ function score(unknown, candidate2) {
22588
+ const u = unknown.lower;
22589
+ const c = candidate2.lower;
22590
+ const [shorter, longer] = u.length <= c.length ? [u, c] : [c, u];
22591
+ let shared = 0;
22592
+ let meaningful = 0;
22593
+ for (const t of candidate2.tokens) {
22594
+ if (!unknown.tokens.has(t)) continue;
22595
+ shared += 1;
22596
+ if (!GENERIC_TOKENS.has(t)) meaningful += 1;
22597
+ }
22598
+ const threshold = Math.min(MAX_EDITS, Math.max(1, Math.floor(longer.length * 0.3)));
22599
+ const distance = editDistance(u, c, DISTANCE_CAP);
22600
+ const shorterGeneric = shorter === u ? unknown.allGeneric : [...candidate2.tokens].every((t) => GENERIC_TOKENS.has(t));
22601
+ if (shorter.length >= MIN_SUBSTRING_CHARS && longer.includes(shorter) && !shorterGeneric) return { tier: Tier.Substring, shared, distance };
22602
+ if (meaningful > 0) return { tier: Tier.Tokens, shared, distance };
22603
+ if (shorter.length >= 3 && distance <= threshold) return { tier: Tier.Edit, shared, distance };
22604
+ if (shared > 0) return { tier: Tier.Generic, shared, distance };
22605
+ if (candidate2.isDate && unknown.isDate) return { tier: Tier.SameType, shared, distance };
22606
+ return { tier: Tier.Rest, shared, distance };
22607
+ }
22608
+ var better = (a, b) => a.tier - b.tier || b.shared - a.shared || a.distance - b.distance;
22609
+ var isClose = (s) => s.tier <= Tier.Edit;
22610
+ function rankFieldNames(unknown, known, dateFields = []) {
22611
+ const dates = new Set(dateFields);
22612
+ const candidates = known.map((name) => ({ name, lower: name.toLowerCase(), tokens: normalTokens(name), isDate: dates.has(name) }));
22613
+ const best = /* @__PURE__ */ new Map();
22614
+ const suggestions = [];
22615
+ for (const name of new Set(unknown)) {
22616
+ const probeTokens = normalTokens(name);
22617
+ const probe = { lower: name.toLowerCase(), tokens: probeTokens, isDate: looksLikeDate(name), allGeneric: [...probeTokens].every((t) => GENERIC_TOKENS.has(t)) };
22618
+ const scored = candidates.map((c, index) => ({ k: c.name, index, s: score(probe, c) }));
22619
+ for (const { k, s } of scored) {
22620
+ const prev = best.get(k);
22621
+ if (prev === void 0 || better(s, prev) < 0) best.set(k, s);
22139
22622
  }
22623
+ const close = scored.filter((x) => isClose(x.s)).sort((a, b) => better(a.s, b.s) || a.index - b.index);
22624
+ if (close.length > 0) suggestions.push({ name, candidates: close.slice(0, MAX_SUGGESTIONS).map((x) => x.k) });
22140
22625
  }
22141
- if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail3("update must contain a writable field");
22626
+ const ordered = known.map((k, index) => ({ k, index, s: best.get(k) ?? { tier: Tier.Rest, shared: 0, distance: 0 } })).sort((a, b) => a.s.tier === Tier.Rest && b.s.tier === Tier.Rest ? a.index - b.index : better(a.s, b.s) || a.index - b.index).map((x) => x.k);
22627
+ return { ordered, suggestions };
22142
22628
  }
22143
22629
 
22144
22630
  // src/operations/invoke/fieldNames.ts
@@ -22156,6 +22642,14 @@ async function liveFieldNames(holder) {
22156
22642
  var UNKNOWN_NAME_LIST_CAP = 20;
22157
22643
  var UNKNOWN_NAME_DISPLAY_CHARS = 40;
22158
22644
  var ENTITY_NAME_LIST_CAP = 20;
22645
+ var REFUSAL_MAX_CHARS = 3e3;
22646
+ var SUGGESTED_NAME_CAP = 5;
22647
+ function didYouMeanClause(suggestions, take = SUGGESTED_NAME_CAP) {
22648
+ const shown = suggestions.slice(0, take);
22649
+ if (shown.length === 0) return "";
22650
+ const cut = (n) => n.length > UNKNOWN_NAME_DISPLAY_CHARS ? `${n.slice(0, UNKNOWN_NAME_DISPLAY_CHARS)}\u2026` : n;
22651
+ return ` \u2014 did you mean: ${shown.map((s) => `"${cut(s.name)}" -> ${s.candidates.map(cut).join(", ")}`).join("; ")}`;
22652
+ }
22159
22653
  function formatUnknownNameList(names, cap = UNKNOWN_NAME_LIST_CAP) {
22160
22654
  const listed = names.slice(0, cap).map((n) => `"${n.length > UNKNOWN_NAME_DISPLAY_CHARS ? `${n.slice(0, UNKNOWN_NAME_DISPLAY_CHARS)}\u2026` : n}"`).join(", ");
22161
22655
  const more = names.length > cap ? ` (and ${names.length - cap} more)` : "";
@@ -22238,10 +22732,16 @@ function unknownNamesRefusal(record, authority, known, unknownInclude, unknownFi
22238
22732
  if (unknownInclude.length > 0) parts.push(`includeFields has unknown field name(s) ${formatUnknownNameList(unknownInclude)}`);
22239
22733
  if (unknownFilter.length > 0) parts.push(`filter condition(s) carry unknown field name(s) ${formatUnknownNameList(unknownFilter)}`);
22240
22734
  const wireClause = record.operation === "count" ? "the count request was not issued" : "the query POST was not issued";
22241
- const head = `invoke: "${record.id}" ${parts.join("; ")} against ${authority}`;
22735
+ const base = `invoke: "${record.id}" ${parts.join("; ")} against ${authority}`;
22736
+ const ranked = [...unknownInclude.slice(0, UNKNOWN_NAME_LIST_CAP), ...unknownFilter.slice(0, UNKNOWN_NAME_LIST_CAP)];
22737
+ const { ordered, suggestions } = rankFieldNames(ranked, known, MODEL_DATE_FIELDS[record.resource]);
22242
22738
  const count = known.length > ENTITY_NAME_LIST_CAP ? `${known.length}, first ${ENTITY_NAME_LIST_CAP}` : `${known.length}`;
22243
- const withList = `${head} \u2014 fields available on ${record.resource} (${count}): ${formatUnknownNameList(known, ENTITY_NAME_LIST_CAP)} \u2014 ${wireClause}`;
22244
- const message = known.length === 0 ? `${head} \u2014 ${wireClause}` : withList.length <= 3e3 ? withList : `${head} \u2014 ${record.resource} has ${known.length} fields; use operations.fieldCatalog resources: ["${record.resource}"] for the full set \u2014 ${wireClause}`;
22739
+ const pointer = `${record.resource} has ${known.length} fields; use operations.fieldCatalog resources: ["${record.resource}"] for the full set`;
22740
+ let take = SUGGESTED_NAME_CAP;
22741
+ while (take > 0 && `${base}${didYouMeanClause(suggestions, take)} \u2014 ${pointer} \u2014 ${wireClause}`.length > REFUSAL_MAX_CHARS) take -= 1;
22742
+ const head = `${base}${didYouMeanClause(suggestions, take)}`;
22743
+ const withList = `${head} \u2014 fields available on ${record.resource} (${count}): ${formatUnknownNameList(ordered, ENTITY_NAME_LIST_CAP)} \u2014 ${wireClause}`;
22744
+ const message = known.length === 0 ? `${head} \u2014 ${wireClause}` : withList.length <= REFUSAL_MAX_CHARS ? withList : `${head} \u2014 ${pointer} \u2014 ${wireClause}`;
22245
22745
  return new AutotaskConfigError(
22246
22746
  message,
22247
22747
  {
@@ -22307,38 +22807,38 @@ function isBase64(value) {
22307
22807
  }
22308
22808
  function admitTaskAttachment(data, parentId) {
22309
22809
  const parent = parseIdentifier(parentId, "parentId");
22310
- const fail3 = (message) => {
22810
+ const fail4 = (message) => {
22311
22811
  throw new AutotaskConfigError(`task_attachments: ${message}`);
22312
22812
  };
22313
- if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
22813
+ if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
22314
22814
  const body = data;
22315
- for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail3(`${field} is not a supported create field`);
22815
+ for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail4(`${field} is not a supported create field`);
22316
22816
  for (const field of ["attachmentType", "fullPath", "title"]) {
22317
- if (typeof body[field] !== "string" || body[field].trim() === "") fail3(`${field} is required and must be a non-empty string`);
22817
+ if (typeof body[field] !== "string" || body[field].trim() === "") fail4(`${field} is required and must be a non-empty string`);
22318
22818
  }
22319
- if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail3("publish must be an integer from current field metadata");
22819
+ if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
22320
22820
  for (const field of ["data", "contentType"]) {
22321
- if (body[field] !== void 0 && typeof body[field] !== "string") fail3(`${field} must be a string`);
22821
+ if (body[field] !== void 0 && typeof body[field] !== "string") fail4(`${field} must be a string`);
22322
22822
  }
22323
22823
  if (body.attachmentType === "FILE_ATTACHMENT") {
22324
- if (typeof body.data !== "string" || body.data === "") return fail3("FILE_ATTACHMENT requires non-empty base64 data");
22325
- if (!isBase64(body.data)) fail3("FILE_ATTACHMENT data must be base64 encoded");
22824
+ if (typeof body.data !== "string" || body.data === "") return fail4("FILE_ATTACHMENT requires non-empty base64 data");
22825
+ if (!isBase64(body.data)) fail4("FILE_ATTACHMENT data must be base64 encoded");
22326
22826
  }
22327
22827
  if (body.taskID !== void 0) {
22328
- if (typeof body.taskID !== "number") fail3("taskID must be a numeric identifier");
22329
- if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail3("taskID must match the parentId path argument");
22828
+ if (typeof body.taskID !== "number") fail4("taskID must be a numeric identifier");
22829
+ if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail4("taskID must match the parentId path argument");
22330
22830
  }
22331
22831
  if (body.parentAttachmentID !== void 0) {
22332
- if (typeof body.parentAttachmentID !== "number") fail3("parentAttachmentID must be a numeric identifier");
22832
+ if (typeof body.parentAttachmentID !== "number") fail4("parentAttachmentID must be a numeric identifier");
22333
22833
  parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
22334
22834
  }
22335
22835
  }
22336
22836
  function admitFileAttachment(resource, data, parentId) {
22337
22837
  parseIdentifier(parentId, "parentId");
22338
- const fail3 = (message) => {
22838
+ const fail4 = (message) => {
22339
22839
  throw new AutotaskConfigError(`${resource}: ${message}`);
22340
22840
  };
22341
- if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
22841
+ if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
22342
22842
  const body = data;
22343
22843
  const reference2 = {
22344
22844
  project_attachments: void 0,
@@ -22351,20 +22851,20 @@ function admitFileAttachment(resource, data, parentId) {
22351
22851
  configuration_item_attachments: "parentAttachmentID",
22352
22852
  configuration_item_note_attachments: void 0
22353
22853
  }[resource];
22354
- for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail3(`${field} is not a supported create field`);
22355
- if (body.attachmentType !== "FILE_ATTACHMENT") fail3("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
22854
+ for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail4(`${field} is not a supported create field`);
22855
+ if (body.attachmentType !== "FILE_ATTACHMENT") fail4("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
22356
22856
  const maxLength = resource === "project_attachments" ? void 0 : 255;
22357
22857
  for (const field of ["fullPath", "title"]) {
22358
22858
  const value = body[field];
22359
22859
  const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
22360
- if (typeof value !== "string" || value.trim() === "") return fail3(requirement);
22361
- if (maxLength !== void 0 && value.length > maxLength) fail3(requirement);
22860
+ if (typeof value !== "string" || value.trim() === "") return fail4(requirement);
22861
+ if (maxLength !== void 0 && value.length > maxLength) fail4(requirement);
22362
22862
  }
22363
- if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail3("publish must be an integer from current field metadata");
22364
- if (typeof body.data !== "string" || !isBase64(body.data)) fail3("FILE_ATTACHMENT requires nonempty base64 data");
22863
+ if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
22864
+ if (typeof body.data !== "string" || !isBase64(body.data)) fail4("FILE_ATTACHMENT requires nonempty base64 data");
22365
22865
  if (reference2 !== void 0 && body[reference2] !== void 0) {
22366
- if (typeof body[reference2] !== "number") fail3(`${reference2} must be a numeric identifier`);
22367
- if (parseIdentifier(body[reference2], reference2) === 0) fail3(`${reference2} must be positive`);
22866
+ if (typeof body[reference2] !== "number") fail4(`${reference2} must be a numeric identifier`);
22867
+ if (parseIdentifier(body[reference2], reference2) === 0) fail4(`${reference2} must be positive`);
22368
22868
  }
22369
22869
  }
22370
22870
  function admitScopedAttachmentQuery(resource, params) {
@@ -23213,6 +23713,16 @@ var SIMPLE_RESOURCES = [
23213
23713
  helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
23214
23714
  opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
23215
23715
  },
23716
+ {
23717
+ key: "inventory_locations",
23718
+ accessor: "inventoryLocations",
23719
+ resourcePath: "/V1.0/InventoryLocations",
23720
+ deletable: false,
23721
+ udfCapable: false,
23722
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
23723
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
23724
+ opForms: { get: "global", create: "global", update: "global" }
23725
+ },
23216
23726
  {
23217
23727
  key: "invoice_templates",
23218
23728
  accessor: "invoiceTemplates",
@@ -24108,7 +24618,7 @@ var GenericResource = class extends BaseResource {
24108
24618
  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 () => {
24109
24619
  throw new OperationNotSupportedError(config.key, "getUdfInfo");
24110
24620
  };
24111
- if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles"].includes(config.key)) this.createIfNotExists = async () => {
24621
+ if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
24112
24622
  throw new OperationNotSupportedError(config.key, "createIfNotExists");
24113
24623
  };
24114
24624
  if (config.key === "knowledge_base_categories") {
@@ -24223,9 +24733,9 @@ var GenericResource = class extends BaseResource {
24223
24733
  return this.createScopedRaw(parentId, data2, opts2);
24224
24734
  }
24225
24735
  if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
24226
- const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : a;
24736
+ const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
24227
24737
  const supplied = b;
24228
- const opts = this.config.key === "knowledge_base_categories" ? snapshotMutationOptions(supplied) : supplied ?? {};
24738
+ const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
24229
24739
  if (opts.dryRun === true) return this.runCreateDryRun(data);
24230
24740
  return this.createGlobal(data, opts);
24231
24741
  }
@@ -24252,8 +24762,24 @@ var GenericResource = class extends BaseResource {
24252
24762
  }
24253
24763
  if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
24254
24764
  const category = this.config.key === "knowledge_base_categories";
24255
- const id = category ? parseIdentifier(a, "id") : a;
24765
+ const location = this.config.key === "inventory_locations";
24766
+ const id = category || location ? parseIdentifier(a, "id") : a;
24256
24767
  const supplied = c;
24768
+ if (location) {
24769
+ const body = admitInventoryLocation(b, false);
24770
+ const opts2 = snapshotMutationOptions(supplied);
24771
+ if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
24772
+ const checkCurrent = (current) => checkInventoryLocationCurrent(body, current);
24773
+ if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
24774
+ const checkedBaseUrl = this.http.baseUrl;
24775
+ try {
24776
+ checkCurrent(await this.getGlobal(id, true, opts2.maxRetries, checkedBaseUrl));
24777
+ } catch (error) {
24778
+ if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
24779
+ throw error;
24780
+ }
24781
+ return this.updateGlobal(id, body, opts2, "PATCH", checkedBaseUrl);
24782
+ }
24257
24783
  const opts = category ? snapshotMutationOptions(supplied) : supplied ?? {};
24258
24784
  if (category && opts.raw === true) throw new AutotaskConfigError("knowledge_base_categories: raw update is unsupported; a fresh merge is required");
24259
24785
  const data = category ? admitKnowledgeBaseCategory(b, false, opts.lastModifiedDate) : b;
@@ -24306,7 +24832,7 @@ var GenericResource = class extends BaseResource {
24306
24832
  /** Get the record with its primary context records in one call (each part a
24307
24833
  * single-record fetch; no sub-lists; absent/dangling references come back null).
24308
24834
  * `names: true` (projects) adds the opt-in name siblings + the top-level `names`
24309
- * section; `maxNameReads` may lower the name-read budget (default 20), never raise it. */
24835
+ * section; `maxNameReads` may lower the name-read budget (default 50), never raise it. */
24310
24836
  async getContext(id, opts = {}) {
24311
24837
  this.requireHelper("getContext");
24312
24838
  const cfg = this.config;
@@ -24479,7 +25005,7 @@ function prepare(query, opts) {
24479
25005
  function companyPieces(terms) {
24480
25006
  return textFragments(terms);
24481
25007
  }
24482
- function score(record, terms, source) {
25008
+ function score2(record, terms, source) {
24483
25009
  const match = scoreTerms(terms, companyTerms(record.companyName ?? ""));
24484
25010
  return match === void 0 ? void 0 : { record, source, ...match };
24485
25011
  }
@@ -24509,7 +25035,7 @@ async function searchFuzzy(resource, query, opts = {}) {
24509
25035
  const validIndex = index?.revision() === revision;
24510
25036
  for (const row of validIndex ? indexed : []) if (typeof row.id === "number") merged.set(row.id, { row, source: "index" });
24511
25037
  for (const row of live) if (typeof row.id === "number") merged.set(row.id, { row: slimCompany(row), source: merged.has(row.id) ? "both" : "live" });
24512
- const ranked = [...merged.values()].filter(({ row }) => opts.includeInactive || row.isActive === true).map(({ row, source }) => score(row, terms, source)).filter((row) => row !== void 0).sort((a, b) => compareTermScores(a, b) || Number(b.record.isActive === true) - Number(a.record.isActive === true) || (a.record.id ?? 0) - (b.record.id ?? 0));
25038
+ const ranked = [...merged.values()].filter(({ row }) => opts.includeInactive || row.isActive === true).map(({ row, source }) => score2(row, terms, source)).filter((row) => row !== void 0).sort((a, b) => compareTermScores(a, b) || Number(b.record.isActive === true) - Number(a.record.isActive === true) || (a.record.id ?? 0) - (b.record.id ?? 0));
24513
25039
  const items = ranked.slice(0, limit);
24514
25040
  if (opts.includeFamily) {
24515
25041
  const records = await addCompanyFamilies(resource.http, items.map((row) => row.record), "companies.searchFuzzy");
@@ -24982,11 +25508,6 @@ function monthsBefore(date, months) {
24982
25508
  return new Date(Date.UTC(y, m - 1 - months, Math.min(d, lastDay))).toISOString().slice(0, 10);
24983
25509
  }
24984
25510
 
24985
- // src/resources/special/_shared/numbers.ts
24986
- function num(v) {
24987
- return typeof v === "number" && Number.isFinite(v) ? v : 0;
24988
- }
24989
-
24990
25511
  // src/resources/special/companies/shared.ts
24991
25512
  var DEFAULT_LIMIT = 25;
24992
25513
  var MAX_LIMIT = 500;
@@ -26276,167 +26797,6 @@ async function aggregate(client, operation, filter, opts = {}) {
26276
26797
  return result;
26277
26798
  }
26278
26799
 
26279
- // src/resources/special/_shared/finance.ts
26280
- function budgetExceededError(operation, message, details, suggestedAction) {
26281
- return new AutotaskError(message, { code: "BUDGET_EXCEEDED", category: "policy", operation, details, suggestedAction });
26282
- }
26283
- function makeCallBudget(budget, onExceed) {
26284
- let spent = 0;
26285
- return {
26286
- spend() {
26287
- if (spent >= budget) throw onExceed(spent);
26288
- spent += 1;
26289
- },
26290
- spent: () => spent
26291
- };
26292
- }
26293
- function countingHttp(raw, spend) {
26294
- const http = Object.create(raw);
26295
- http.request = (o) => {
26296
- spend();
26297
- return raw.request(o);
26298
- };
26299
- return http;
26300
- }
26301
- function idChunks(ids2, size) {
26302
- const out = [];
26303
- for (let i = 0; i < ids2.length; i += size) out.push(ids2.slice(i, i + size));
26304
- return out;
26305
- }
26306
- async function fetchIdChunks(http, entityPath, ids2, fields, operation, opts) {
26307
- const chunkSize = opts?.chunkSize ?? 250;
26308
- const out = /* @__PURE__ */ new Map();
26309
- for (const chunk of idChunks(ids2, chunkSize)) {
26310
- opts?.budgetSpend?.();
26311
- const chunkKeys = new Set(chunk.map((id) => String(id)));
26312
- try {
26313
- const req = buildQueryRequest(http.baseUrl, entityPath, {
26314
- filter: [{ field: "id", op: "in", value: chunk }],
26315
- maxRecords: opts?.maxRecords ?? chunkSize,
26316
- includeFields: fields
26317
- });
26318
- const res = await http.request({ ...req, operation });
26319
- const { items: rows } = unwrapItems(res, operation);
26320
- for (const row of rows) {
26321
- const k = String(row["id"]);
26322
- if (!chunkKeys.has(k)) continue;
26323
- out.set(k, row);
26324
- }
26325
- } catch (err) {
26326
- if (opts?.onChunkFault?.(chunk, err) !== true) throw err;
26327
- }
26328
- }
26329
- return out;
26330
- }
26331
- function internalAmount(row, internalKey, localKey) {
26332
- const v = row[internalKey];
26333
- return typeof v === "number" && Number.isFinite(v) ? v : num(row[localKey]);
26334
- }
26335
- function toCents(v) {
26336
- return Math.round(num(v) * 100);
26337
- }
26338
- async function readPicklists(http, entityPath, operation) {
26339
- const res = await http.request({ method: "GET", path: `${entityPath}/entityInformation/fields`, operation });
26340
- const body = typeof res === "object" && res !== null ? res : {};
26341
- const fields = Array.isArray(body["fields"]) ? body["fields"] : [];
26342
- const out = /* @__PURE__ */ new Map();
26343
- for (const f of fields) {
26344
- if (f["isPickList"] !== true || typeof f["name"] !== "string" || !Array.isArray(f["picklistValues"])) continue;
26345
- const values = /* @__PURE__ */ new Map();
26346
- for (const p of f["picklistValues"]) {
26347
- const id = typeof p["value"] === "string" ? Number.parseInt(p["value"], 10) : Number.NaN;
26348
- if (Number.isFinite(id)) values.set(id, String(p["label"] ?? ""));
26349
- }
26350
- out.set(f["name"], values);
26351
- }
26352
- return out;
26353
- }
26354
- function resolveSelector(operation, name, sel, values) {
26355
- const out = /* @__PURE__ */ new Map();
26356
- const misses = [];
26357
- for (const s of sel) {
26358
- const hits = typeof s === "number" ? values.has(s) ? [s] : [] : [...values].filter(([, l]) => l.trim().toLowerCase() === s.trim().toLowerCase()).map(([id]) => id);
26359
- if (hits.length === 0) misses.push(JSON.stringify(s));
26360
- for (const h of hits) out.set(h, values.get(h));
26361
- }
26362
- if (misses.length > 0) throw selectorUnmatched(operation, name, `${misses.join(", ")} matched no live value`, values);
26363
- return out;
26364
- }
26365
- function selectorUnmatched(operation, name, what, values) {
26366
- const live = [...values].map(([id, l]) => `${id} ${l}`).join("; ") || "(the picklist serves no values)";
26367
- return new AutotaskConfigError(`${shortName(operation)}: ${name}: ${what}. Live values (id label): ${live}`, {
26368
- operation,
26369
- suggestedAction: `Pass ${name} as ids or exact labels from the live list.`
26370
- });
26371
- }
26372
- var TENANT_HOURLY_LIMIT = 1e4;
26373
- function tenantHourlyShare(calls) {
26374
- return `${(calls / TENANT_HOURLY_LIMIT * 100).toFixed(2)}% of ${TENANT_HOURLY_LIMIT.toLocaleString("en-US")}/h`;
26375
- }
26376
- var isPosInt = (v) => Number.isSafeInteger(v) && v > 0;
26377
- function checkIdList(name, v, max, problems, opts) {
26378
- const ok = opts?.allowZero ? (x) => x === 0 || isPosInt(x) : isPosInt;
26379
- if (!Array.isArray(v) || v.length === 0 || v.length > max || !v.every(ok)) {
26380
- problems.push(`${name} must be a non-empty array of at most ${max} ${opts?.allowZero ? "non-negative" : "positive"} integer ids`);
26381
- return void 0;
26382
- }
26383
- return [...new Set(v)].sort((a, b) => a - b);
26384
- }
26385
- function checkSelector(name, v, problems) {
26386
- if (v === void 0) return void 0;
26387
- if (!Array.isArray(v) || v.length === 0 || !v.every((x) => isPosInt(x) || typeof x === "string" && x.trim() !== "")) {
26388
- problems.push(`${name} must be a non-empty array of picklist ids or labels`);
26389
- return void 0;
26390
- }
26391
- return v;
26392
- }
26393
- function checkInt(name, v, def, max, problems) {
26394
- if (v === void 0) return def;
26395
- if (!Number.isInteger(v) || v < 1 || v > max) {
26396
- problems.push(`${name} must be an integer 1..${max} (got ${String(v)})`);
26397
- return def;
26398
- }
26399
- return v;
26400
- }
26401
- async function collectRows(res, filter, includeFields, page) {
26402
- const out = [];
26403
- for await (const r of res.query({ filter, includeFields, maxRecords: page, names: false })) out.push(r);
26404
- return out;
26405
- }
26406
- function blindCountError(operation, subject, suggestedAction) {
26407
- return new AutotaskError(`${shortName(operation)}: a gate count came back blind (unknown, not zero); ${subject} cannot be sized`, {
26408
- code: "INVALID_RESPONSE",
26409
- category: "server",
26410
- operation,
26411
- details: { reason: "blind_count" },
26412
- suggestedAction
26413
- });
26414
- }
26415
- function countMismatchError(operation, what, streamed, counted, rows) {
26416
- const rowNote = rows !== void 0 && rows !== streamed ? ` (${rows} rows)` : "";
26417
- return new AutotaskError(`${shortName(operation)}: the ${what} stream returned ${streamed} distinct ids${rowNote} but the gate count was ${counted} (the data changed mid-walk or a page dropped rows); the fold was discarded`, {
26418
- code: "INVALID_RESPONSE",
26419
- category: "server",
26420
- operation,
26421
- details: { reason: "count_mismatch", stream: what, streamed, counted },
26422
- suggestedAction: "Retry the call."
26423
- });
26424
- }
26425
- function compareIds(a, b) {
26426
- for (let i = 0; i < a.length; i++) {
26427
- const x = a[i] ?? null;
26428
- const y = b[i] ?? null;
26429
- if (x === y) continue;
26430
- if (x === null) return -1;
26431
- if (y === null) return 1;
26432
- if (typeof x === "number" && typeof y === "number") return x - y;
26433
- return String(x) < String(y) ? -1 : 1;
26434
- }
26435
- return 0;
26436
- }
26437
- var sortedRecord = (m) => Object.fromEntries([...m].sort((a, b) => a[0] - b[0]).map(([id, l]) => [String(id), l]));
26438
- var shortName = (operation) => operation.split(".").pop() ?? operation;
26439
-
26440
26800
  // src/operations/fetchByIds.ts
26441
26801
  var FETCH_BY_IDS_MAX_ITEMS = 500;
26442
26802
  var FETCH_BY_IDS_CHUNK_SIZE = 250;
@@ -26512,8 +26872,9 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
26512
26872
  try {
26513
26873
  const id = parseIdentifier(item.id, `${at}.id`);
26514
26874
  const audit = isAuditLogResource(resourceKey);
26515
- if ((audit || isKnowledgeBaseRootResource(resourceKey)) && !isAuditDecimalId(String(id))) {
26516
- problems.push(`${at}.id: ${audit ? "audit log" : "Knowledge Base record"} ID must be a non-negative signed 64-bit integer`);
26875
+ if ((audit || isExactRecordResource(resourceKey)) && !isAuditDecimalId(String(id))) {
26876
+ const label = audit ? "audit log" : resourceKey === "inventory_locations" ? "inventory location" : "Knowledge Base record";
26877
+ problems.push(`${at}.id: ${label} ID must be a non-negative signed 64-bit integer`);
26517
26878
  }
26518
26879
  } catch {
26519
26880
  if (typeof item.id === "string") {
@@ -29143,16 +29504,16 @@ function latchingHttp(raw, spend) {
29143
29504
  }
29144
29505
  };
29145
29506
  observeRecordReadFailures(http, latch);
29146
- const fail3 = (err) => {
29507
+ const fail4 = (err) => {
29147
29508
  latch(err);
29148
29509
  throw err;
29149
29510
  };
29150
29511
  http.request = (o) => {
29151
29512
  if (fatal) throw fatal;
29152
29513
  try {
29153
- return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail3);
29514
+ return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail4);
29154
29515
  } catch (err) {
29155
- return fail3(err);
29516
+ return fail4(err);
29156
29517
  }
29157
29518
  };
29158
29519
  return { http, fatal: () => fatal, signal };