node-autotask 0.16.0 → 0.18.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 (40) hide show
  1. package/ARCHITECTURE.md +10 -4
  2. package/MCP_TOOL_CATALOG.json +2 -2
  3. package/MCP_TOOL_MANIFEST.md +4 -4
  4. package/N8N_MCP_MANIFEST.json +2 -2
  5. package/N8N_MCP_MANIFEST.md +3 -3
  6. package/README.md +36 -0
  7. package/capabilities.json +1571 -1571
  8. package/dist/capabilities.cjs +2 -2
  9. package/dist/capabilities.js +1 -1
  10. package/dist/{chunk-EWMG3HHU.cjs → chunk-5O5EPYBO.cjs} +1570 -1570
  11. package/dist/{chunk-L3TK4CN5.cjs → chunk-7I3F3AJJ.cjs} +429 -419
  12. package/dist/{chunk-VCGC6YCI.cjs → chunk-G564CHXM.cjs} +135 -135
  13. package/dist/{chunk-NB254T3F.js → chunk-HXOWEYV3.js} +49 -39
  14. package/dist/{chunk-JIDR3NPV.js → chunk-VV2UUW2J.js} +1570 -1570
  15. package/dist/{chunk-U6JUHHMB.js → chunk-VYUZZIEE.js} +66 -32
  16. package/dist/{chunk-GWALLMAM.js → chunk-W2WSZOZA.js} +2 -2
  17. package/dist/{chunk-MAYYTYV5.cjs → chunk-WRWX6WIK.cjs} +68 -34
  18. package/dist/{index-CUsvZndu.d.ts → index-BqPY04ZG.d.ts} +89 -16
  19. package/dist/{index-leMyBJze.d.cts → index-D7x3MkLK.d.cts} +89 -16
  20. package/dist/index.cjs +24 -22
  21. package/dist/index.d.cts +2 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +6 -4
  24. package/dist/operations/index.cjs +178 -105
  25. package/dist/operations/index.d.cts +22 -7
  26. package/dist/operations/index.d.ts +22 -7
  27. package/dist/operations/index.js +77 -4
  28. package/dist/pool.cjs +8 -8
  29. package/dist/pool.d.cts +1 -1
  30. package/dist/pool.d.ts +1 -1
  31. package/dist/pool.js +4 -4
  32. package/dist/resources/index.cjs +4 -4
  33. package/dist/resources/index.d.cts +1 -1
  34. package/dist/resources/index.d.ts +1 -1
  35. package/dist/resources/index.js +3 -3
  36. package/docs/API.md +78 -15
  37. package/examples/basic.ts +2 -2
  38. package/examples/mcp-server-http.ts +5 -4
  39. package/examples/mcp-server.ts +3 -3
  40. package/package.json +3 -2
@@ -33,13 +33,14 @@
33
33
 
34
34
 
35
35
 
36
- var _chunkMAYYTYV5cjs = require('./chunk-MAYYTYV5.cjs');
37
36
 
37
+ var _chunkWRWX6WIKcjs = require('./chunk-WRWX6WIK.cjs');
38
38
 
39
- var _chunkEWMG3HHUcjs = require('./chunk-EWMG3HHU.cjs');
39
+
40
+ var _chunk5O5EPYBOcjs = require('./chunk-5O5EPYBO.cjs');
40
41
 
41
42
  // src/resources/appointments.ts
42
- var AppointmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
43
+ var AppointmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
43
44
  constructor(http, pageSize) {
44
45
  super(http, {
45
46
  key: "appointments",
@@ -124,7 +125,7 @@ var AuthenticateResource = class {
124
125
  };
125
126
 
126
127
  // src/resources/billing_codes.ts
127
- var BillingCodesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
128
+ var BillingCodesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
128
129
  constructor(http, pageSize) {
129
130
  super(http, {
130
131
  key: "billing_codes",
@@ -174,7 +175,7 @@ var MAX_LIMIT = 500;
174
175
  function clampWindowLimit(limit) {
175
176
  const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
176
177
  if (!Number.isInteger(n) || n < 1) {
177
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
178
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
178
179
  }
179
180
  return Math.min(n, MAX_LIMIT);
180
181
  }
@@ -220,7 +221,7 @@ function wallParts(tz, ms) {
220
221
  }
221
222
  }
222
223
  if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
223
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
224
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
224
225
  }
225
226
  return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
226
227
  }
@@ -247,7 +248,7 @@ function localDayEndMs(y, m, d, tz) {
247
248
  }
248
249
  function validateZone(tz, opName = "dateWindow") {
249
250
  if (typeof tz !== "string" || tz.length === 0) {
250
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
251
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
251
252
  `${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
252
253
  { operation: opName }
253
254
  );
@@ -255,7 +256,7 @@ function validateZone(tz, opName = "dateWindow") {
255
256
  try {
256
257
  new Intl.DateTimeFormat("en-US", { timeZone: tz });
257
258
  } catch (e2) {
258
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
259
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
259
260
  `${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
260
261
  { operation: opName }
261
262
  );
@@ -407,13 +408,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
407
408
  body: { MaxRecords: limit, filter },
408
409
  operation
409
410
  });
410
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
411
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
411
412
  }
412
413
  var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
413
414
  function customRangeDay(value, label, zone, opName) {
414
415
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
415
416
  if (!m) {
416
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
417
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
417
418
  zone === void 0 ? `${opName}: ${label} must be a UTC 'YYYY-MM-DD' date (got ${JSON.stringify(value)})` : `${opName}: ${label} must be a 'YYYY-MM-DD' local calendar day in ${zone} (got ${JSON.stringify(value)})`,
418
419
  { operation: opName }
419
420
  );
@@ -425,7 +426,7 @@ function customRangeDay(value, label, zone, opName) {
425
426
  const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
426
427
  const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
427
428
  if (!Number.isFinite(ms)) {
428
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
429
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
429
430
  zone === void 0 ? `${opName}: ${label} is not a valid UTC date (${JSON.stringify(value)})` : `${opName}: ${label} is not a valid calendar day in ${zone} (${JSON.stringify(value)})`,
430
431
  { operation: opName }
431
432
  );
@@ -436,7 +437,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
436
437
  const fromB = customRangeDay(from, "from", zone, operation);
437
438
  const toB = customRangeDay(to, "to", zone, operation);
438
439
  if (fromB.ms > toB.ms) {
439
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
440
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
440
441
  `${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
441
442
  { operation }
442
443
  );
@@ -453,7 +454,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
453
454
  body: { MaxRecords: limit, filter },
454
455
  operation
455
456
  });
456
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
457
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
457
458
  }
458
459
 
459
460
  // src/resources/special/billing_items.ts
@@ -486,7 +487,7 @@ async function customRange(_resource, from, to, http, opts) {
486
487
  }
487
488
 
488
489
  // src/resources/billing_items.ts
489
- var BillingItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
490
+ var BillingItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
490
491
  constructor(http, pageSize) {
491
492
  super(http, {
492
493
  key: "billing_items",
@@ -588,7 +589,7 @@ var BillingItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
588
589
  };
589
590
 
590
591
  // src/resources/change_request_links.ts
591
- var ChangeRequestLinksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
592
+ var ChangeRequestLinksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
592
593
  constructor(http, pageSize) {
593
594
  super(http, {
594
595
  key: "change_request_links",
@@ -642,7 +643,7 @@ var ChangeRequestLinksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
642
643
  };
643
644
 
644
645
  // src/resources/checklist_libraries.ts
645
- var ChecklistLibrariesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
646
+ var ChecklistLibrariesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
646
647
  constructor(http, pageSize) {
647
648
  super(http, {
648
649
  key: "checklist_libraries",
@@ -716,7 +717,7 @@ var ChecklistLibrariesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
716
717
  };
717
718
 
718
719
  // src/resources/checklist_library_checklist_items.ts
719
- var ChecklistLibraryChecklistItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
720
+ var ChecklistLibraryChecklistItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
720
721
  constructor(http, pageSize) {
721
722
  super(http, {
722
723
  key: "checklist_library_checklist_items",
@@ -782,7 +783,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkMAYYTYV5cjs.Bas
782
783
  };
783
784
 
784
785
  // src/resources/classification_icons.ts
785
- var ClassificationIconsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
786
+ var ClassificationIconsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
786
787
  constructor(http, pageSize) {
787
788
  super(http, {
788
789
  key: "classification_icons",
@@ -830,7 +831,7 @@ var DEFAULT_LIMIT2 = 25;
830
831
  var MAX_LIMIT2 = 500;
831
832
  function clampLimit(limit) {
832
833
  const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
833
- if (!Number.isInteger(n) || n < 1) throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
834
+ if (!Number.isInteger(n) || n < 1) throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
834
835
  return Math.min(n, MAX_LIMIT2);
835
836
  }
836
837
  async function queryCompanies(http, filter, limit) {
@@ -841,7 +842,7 @@ async function queryCompanies(http, filter, limit) {
841
842
  body: { MaxRecords: limit, filter },
842
843
  operation: "companies.searchByDomain"
843
844
  });
844
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
845
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
845
846
  }
846
847
  async function queryContacts(http, filter, limit) {
847
848
  const res = await http.request({
@@ -851,7 +852,7 @@ async function queryContacts(http, filter, limit) {
851
852
  body: { MaxRecords: limit, filter },
852
853
  operation: "companies.searchByDomain"
853
854
  });
854
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
855
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
855
856
  }
856
857
  async function fetchCompanies(http, ids, limit) {
857
858
  const out = [];
@@ -866,7 +867,7 @@ async function fetchCompanies(http, ids, limit) {
866
867
  const item = body && "item" in body ? body.item : null;
867
868
  if (item) out.push(item);
868
869
  } catch (err) {
869
- if (err instanceof _chunkMAYYTYV5cjs.NotFoundError) continue;
870
+ if (err instanceof _chunkWRWX6WIKcjs.NotFoundError) continue;
870
871
  throw err;
871
872
  }
872
873
  }
@@ -874,7 +875,7 @@ async function fetchCompanies(http, ids, limit) {
874
875
  }
875
876
  async function searchByDomain(_resource, domain, opts = {}, http) {
876
877
  const text = domain.trim();
877
- if (text === "") throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("searchByDomain: empty domain");
878
+ if (text === "") throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("searchByDomain: empty domain");
878
879
  const limit = clampLimit(opts.limit);
879
880
  const filter = [{ field: "webAddress", op: "contains", value: text }];
880
881
  const direct = await queryCompanies(http, filter, limit);
@@ -888,7 +889,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
888
889
  const email = _nullishCoalesce(_optionalChain([identity, 'access', _9 => _9.email, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]), () => ( ""));
889
890
  const website = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.website, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
890
891
  if (name === "" && email === "" && website === "") {
891
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
892
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
892
893
  }
893
894
  const limit = clampLimit(opts.limit);
894
895
  const found = /* @__PURE__ */ new Map();
@@ -915,23 +916,23 @@ async function familyChildPage(http, parentID) {
915
916
  path: "/V1.0/Companies/query",
916
917
  body: {
917
918
  MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
918
- filter: _chunkMAYYTYV5cjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
919
+ filter: _chunkWRWX6WIKcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
919
920
  },
920
921
  operation: "companies.search"
921
922
  });
922
- const { items, pageDetails } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, "companies.search");
923
+ const { items, pageDetails } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, "companies.search");
923
924
  return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
924
925
  }
925
926
  function assertSearchWithDetailOpts(opts) {
926
927
  if (opts === void 0) return;
927
928
  if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
928
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
929
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
929
930
  operation: "companies.searchWithDetail"
930
931
  });
931
932
  }
932
933
  for (const key of Object.keys(opts)) {
933
934
  if (key !== "limit") {
934
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
935
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
935
936
  `companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
936
937
  { operation: "companies.searchWithDetail" }
937
938
  );
@@ -940,32 +941,32 @@ function assertSearchWithDetailOpts(opts) {
940
941
  }
941
942
  async function searchWithFamily(_resource, query, opts = {}, http) {
942
943
  if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
943
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
944
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
944
945
  }
945
946
  for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
946
947
  if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
947
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
948
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
948
949
  `companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
949
950
  { operation: "companies.search" }
950
951
  );
951
952
  }
952
953
  }
953
954
  if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
954
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
955
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
955
956
  operation: "companies.search"
956
957
  });
957
958
  }
958
959
  const text = query.trim();
959
- if (text === "") throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
960
- const limit = opts.limit === void 0 ? 25 : _chunkMAYYTYV5cjs.clampPageSize.call(void 0, opts.limit);
960
+ if (text === "") throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
961
+ const limit = opts.limit === void 0 ? 25 : _chunkWRWX6WIKcjs.clampPageSize.call(void 0, opts.limit);
961
962
  const res = await http.request({
962
963
  method: "POST",
963
964
  idempotent: true,
964
965
  path: "/V1.0/Companies/query",
965
- body: { MaxRecords: limit, filter: _chunkMAYYTYV5cjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
966
+ body: { MaxRecords: limit, filter: _chunkWRWX6WIKcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
966
967
  operation: "companies.search"
967
968
  });
968
- const hits = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, "companies.search").items;
969
+ const hits = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, "companies.search").items;
969
970
  if (opts.includeFamily !== true) return hits;
970
971
  const rows = [];
971
972
  for (const hit of hits) {
@@ -989,7 +990,7 @@ var DEFAULT_COMPANY_TYPE = 1;
989
990
  var DEDUP_NAME_LIMIT = 10;
990
991
  var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumerate (the unowned surface is blind); a same-name company outside that scope is not detected";
991
992
  var SAFE_COMPANY_CREATE_DEFAULTS = {};
992
- var OwnerResourceRequiredError = class extends _chunkMAYYTYV5cjs.AutotaskError {
993
+ var OwnerResourceRequiredError = class extends _chunkWRWX6WIKcjs.AutotaskError {
993
994
  constructor(message, options = {}) {
994
995
  super(message, {
995
996
  code: "OWNER_RESOURCE_REQUIRED",
@@ -1000,13 +1001,13 @@ var OwnerResourceRequiredError = class extends _chunkMAYYTYV5cjs.AutotaskError {
1000
1001
  this.name = "OwnerResourceRequiredError";
1001
1002
  }
1002
1003
  };
1003
- var CompanyResourceInvalidError = class extends _chunkMAYYTYV5cjs.AutotaskError {
1004
+ var CompanyResourceInvalidError = class extends _chunkWRWX6WIKcjs.AutotaskError {
1004
1005
  constructor(message, options = {}) {
1005
1006
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
1006
1007
  this.name = "CompanyResourceInvalidError";
1007
1008
  }
1008
1009
  };
1009
- var CompanyCreateFailedError = class extends _chunkMAYYTYV5cjs.AutotaskError {
1010
+ var CompanyCreateFailedError = class extends _chunkWRWX6WIKcjs.AutotaskError {
1010
1011
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
1011
1012
 
1012
1013
  constructor(message, vendorFields, options = {}) {
@@ -1017,18 +1018,18 @@ var CompanyCreateFailedError = class extends _chunkMAYYTYV5cjs.AutotaskError {
1017
1018
  };
1018
1019
  async function upsertByName(resource, companyName, params, opts, http) {
1019
1020
  if (typeof companyName !== "string" || companyName.trim() === "") {
1020
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
1021
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
1021
1022
  }
1022
1023
  if (typeof _optionalChain([params, 'optionalAccess', _15 => _15.phone]) !== "string" || params.phone.trim() === "") {
1023
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("upsertByName: params.phone is required (a non-empty string \u2014 the ww29 live-required set is { companyName, companyType, phone, ownerResourceID })", { operation: OP_UPSERT_NAME });
1024
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("upsertByName: params.phone is required (a non-empty string \u2014 the ww29 live-required set is { companyName, companyType, phone, ownerResourceID })", { operation: OP_UPSERT_NAME });
1024
1025
  }
1025
1026
  const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
1026
1027
  if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
1027
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`upsertByName: params.companyType must be a positive integer picklist value (got ${String(params.companyType)}; default 1 \u2014 the ww29-proven value)`, { operation: OP_UPSERT_NAME });
1028
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`upsertByName: params.companyType must be a positive integer picklist value (got ${String(params.companyType)}; default 1 \u2014 the ww29-proven value)`, { operation: OP_UPSERT_NAME });
1028
1029
  }
1029
1030
  const owner = params.ownerResourceID;
1030
1031
  if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
1031
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
1032
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
1032
1033
  }
1033
1034
  const q = await resource.queryBounded({ filter: [{ field: "companyName", op: "eq", value: companyName }], limit: DEDUP_NAME_LIMIT });
1034
1035
  const caveat = {
@@ -1039,7 +1040,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
1039
1040
  const match = q.items[0];
1040
1041
  if (match !== void 0) {
1041
1042
  if (opts.dryRun === true) {
1042
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
1043
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
1043
1044
  {
1044
1045
  operation: OP_UPSERT_NAME,
1045
1046
  method: "POST",
@@ -1074,7 +1075,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
1074
1075
  "ownerResourceID is REQUIRED on the apply path (the vendor requires it; the node cannot enumerate candidates \u2014 the resources table is blind to this API user (count/query return 0)): the apply throws the typed OWNER_RESOURCE_REQUIRED if it is still absent"
1075
1076
  );
1076
1077
  }
1077
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
1078
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
1078
1079
  {
1079
1080
  operation: OP_UPSERT_NAME,
1080
1081
  method: "POST",
@@ -1102,13 +1103,13 @@ async function upsertByName(resource, companyName, params, opts, http) {
1102
1103
  if (ownerBody === null || !("item" in ownerBody) || ownerBody.item === null || ownerBody.item === void 0) {
1103
1104
  throw new CompanyResourceInvalidError(
1104
1105
  `upsertByName: owner resource ${owner} was not found (resources.get returned item: null \u2014 the resources table is blind to this API user; get is the authority)`,
1105
- { resourceIds: [owner], operation: OP_UPSERT_NAME, category: "not_found", suggestedAction: "Pass a known active non-API-only resource id (e.g. a ticket assignedResourceID via tickets.fullContext)." }
1106
+ { resourceIds: [owner], details: { idRefs: [{ entity: "resource", id: owner }] }, operation: OP_UPSERT_NAME, category: "not_found", suggestedAction: "Pass a known active non-API-only resource id (e.g. a ticket assignedResourceID via tickets.fullContext)." }
1106
1107
  );
1107
1108
  }
1108
1109
  if (ownerBody.item.isActive !== true) {
1109
1110
  throw new CompanyResourceInvalidError(
1110
1111
  `upsertByName: owner resource ${owner} is not active (isActive !== true) \u2014 the vendor requires an active NON-API-only owner`,
1111
- { resourceIds: [owner], operation: OP_UPSERT_NAME, suggestedAction: "Activate the resource or pass an active non-API-only one." }
1112
+ { resourceIds: [owner], details: { idRefs: [{ entity: "resource", id: owner }] }, operation: OP_UPSERT_NAME, suggestedAction: "Activate the resource or pass an active non-API-only one." }
1112
1113
  );
1113
1114
  }
1114
1115
  let merges = 0;
@@ -1122,8 +1123,8 @@ async function upsertByName(resource, companyName, params, opts, http) {
1122
1123
  sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
1123
1124
  };
1124
1125
  } catch (err) {
1125
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
1126
- const named = (_nullishCoalesce(_chunkMAYYTYV5cjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
1126
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
1127
+ const named = (_nullishCoalesce(_chunkWRWX6WIKcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
1127
1128
  const seen = /* @__PURE__ */ new Set();
1128
1129
  const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
1129
1130
  const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
@@ -1137,7 +1138,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
1137
1138
  }
1138
1139
  continue;
1139
1140
  }
1140
- const detail = _chunkMAYYTYV5cjs.formatVendorDetail.call(void 0, err.vendorError);
1141
+ const detail = _chunkWRWX6WIKcjs.formatVendorDetail.call(void 0, err.vendorError);
1141
1142
  throw new CompanyCreateFailedError(
1142
1143
  `upsertByName: the vendor rejected the company create${unique.length > 0 ? ` naming field(s) ${unique.join(", ")}` : ""} (no proven-safe default \u2014 the ww29 required set is fully filled by the node)${detail ? ` \u2014 ${detail}` : ""}`,
1143
1144
  unique,
@@ -1145,7 +1146,8 @@ async function upsertByName(resource, companyName, params, opts, http) {
1145
1146
  operation: OP_UPSERT_NAME,
1146
1147
  httpStatus: err.httpStatus,
1147
1148
  vendorError: err.vendorError,
1148
- resourceIds: [owner]
1149
+ resourceIds: [owner],
1150
+ details: { idRefs: [{ entity: "resource", id: owner }] }
1149
1151
  }
1150
1152
  );
1151
1153
  }
@@ -1156,7 +1158,7 @@ var PROFILE_PART_LIMIT = 50;
1156
1158
  function profilePartLimit(value, name) {
1157
1159
  const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
1158
1160
  if (!Number.isInteger(n) || n < 1) {
1159
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
1161
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
1160
1162
  }
1161
1163
  return n;
1162
1164
  }
@@ -1168,14 +1170,14 @@ async function scopedCompanyQuery(http, path, companyID, limit) {
1168
1170
  body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }] },
1169
1171
  operation: "companies.fullProfile"
1170
1172
  });
1171
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
1173
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
1172
1174
  }
1173
1175
  async function fullProfile(resource, id, opts = {}, http) {
1174
1176
  const contactLimit = profilePartLimit(opts.contactLimit, "contactLimit");
1175
1177
  const noteLimit = profilePartLimit(opts.noteLimit, "noteLimit");
1176
1178
  const ticketLimit = profilePartLimit(opts.ticketLimit, "ticketLimit");
1177
1179
  const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
1178
- const companyID = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
1180
+ const companyID = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
1179
1181
  const company = await resource.get(companyID);
1180
1182
  const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, PROFILE_PART_LIMIT);
1181
1183
  const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit);
@@ -1192,7 +1194,7 @@ async function fullProfile(resource, id, opts = {}, http) {
1192
1194
  },
1193
1195
  operation: "companies.fullProfile"
1194
1196
  });
1195
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
1197
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
1196
1198
  })();
1197
1199
  let openTickets = {
1198
1200
  items: openRows,
@@ -1201,7 +1203,7 @@ async function fullProfile(resource, id, opts = {}, http) {
1201
1203
  note: OPEN_TICKETS_NOTE
1202
1204
  };
1203
1205
  if (openRows.length === 0) {
1204
- const stamp = _chunkMAYYTYV5cjs.blindStampFor.call(void 0, _optionalChain([_chunkMAYYTYV5cjs.BLIND_SURFACE_STAMPS, 'access', _16 => _16["tickets"], 'optionalAccess', _17 => _17.query]), [
1206
+ const stamp = _chunkWRWX6WIKcjs.blindStampFor.call(void 0, _optionalChain([_chunkWRWX6WIKcjs.BLIND_SURFACE_STAMPS, 'access', _16 => _16["tickets"], 'optionalAccess', _17 => _17.query]), [
1205
1207
  { field: "companyID", op: "eq", value: companyID },
1206
1208
  { field: "status", op: "noteq", value: 5 }
1207
1209
  ]);
@@ -1232,7 +1234,7 @@ async function fullProfile(resource, id, opts = {}, http) {
1232
1234
  }
1233
1235
  };
1234
1236
  if (opts.names === true) {
1235
- const builder = _chunkMAYYTYV5cjs.createNamePlan.call(void 0, _chunkMAYYTYV5cjs.TICKET_LABEL_FIELDS);
1237
+ const builder = _chunkWRWX6WIKcjs.createNamePlan.call(void 0, _chunkWRWX6WIKcjs.TICKET_LABEL_FIELDS);
1236
1238
  const c = company;
1237
1239
  builder.addResource(c["ownerResourceID"]);
1238
1240
  builder.addResource(c["createdByResourceID"]);
@@ -1249,20 +1251,20 @@ async function fullProfile(resource, id, opts = {}, http) {
1249
1251
  builder.addResource(r["creatorResourceID"]);
1250
1252
  builder.addFk("contract", r["contractID"]);
1251
1253
  }
1252
- const names = await _chunkMAYYTYV5cjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
1254
+ const names = await _chunkWRWX6WIKcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
1253
1255
  const companyRow = { ...company };
1254
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
1255
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
1256
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
1257
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
1256
1258
  result.company = companyRow;
1257
1259
  result.openTickets = {
1258
1260
  ...openTickets,
1259
1261
  items: openTickets.items.map((row) => {
1260
1262
  const r = { ...row };
1261
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1262
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1263
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
1264
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
1265
- for (const f of _chunkMAYYTYV5cjs.TICKET_LABEL_FIELDS) _chunkMAYYTYV5cjs.addLabelSibling.call(void 0, r, f, names);
1263
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1264
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1265
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
1266
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
1267
+ for (const f of _chunkWRWX6WIKcjs.TICKET_LABEL_FIELDS) _chunkWRWX6WIKcjs.addLabelSibling.call(void 0, r, f, names);
1266
1268
  return r;
1267
1269
  })
1268
1270
  };
@@ -1270,9 +1272,9 @@ async function fullProfile(resource, id, opts = {}, http) {
1270
1272
  ...result.projects,
1271
1273
  items: result.projects.items.map((row) => {
1272
1274
  const r = { ...row };
1273
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
1274
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1275
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1275
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
1276
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1277
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1276
1278
  return r;
1277
1279
  })
1278
1280
  };
@@ -1304,7 +1306,7 @@ function isDateYMD(v) {
1304
1306
  }
1305
1307
  function validateUnbilledWorkOptions(companyId, opts) {
1306
1308
  if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
1307
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
1309
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
1308
1310
  `unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
1309
1311
  { operation: "companies.unbilledWork" }
1310
1312
  );
@@ -1333,7 +1335,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
1333
1335
  try {
1334
1336
  limit = clampLimit(opts.limit);
1335
1337
  } catch (err) {
1336
- problems.push(err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
1338
+ problems.push(err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
1337
1339
  limit = 50;
1338
1340
  }
1339
1341
  if (source === "date_range") {
@@ -1348,9 +1350,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
1348
1350
  problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
1349
1351
  } else {
1350
1352
  try {
1351
- _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
1353
+ _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
1352
1354
  } catch (err) {
1353
- problems.push(err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
1355
+ problems.push(err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
1354
1356
  }
1355
1357
  }
1356
1358
  }
@@ -1360,20 +1362,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
1360
1362
  } else {
1361
1363
  opts.ticketIds.forEach((tid, i) => {
1362
1364
  try {
1363
- _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
1365
+ _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
1364
1366
  } catch (err) {
1365
- problems.push(err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
1367
+ problems.push(err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
1366
1368
  }
1367
1369
  });
1368
1370
  }
1369
1371
  }
1370
1372
  try {
1371
- _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, companyId, "companyId");
1373
+ _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, companyId, "companyId");
1372
1374
  } catch (err) {
1373
- problems.push(err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
1375
+ problems.push(err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
1374
1376
  }
1375
1377
  if (problems.length > 0) {
1376
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
1378
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
1377
1379
  `unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
1378
1380
  - ` + problems.join("\n- "),
1379
1381
  { operation: "companies.unbilledWork" }
@@ -1402,7 +1404,7 @@ async function boundedPart(http, path, conditions, limit, includeFields) {
1402
1404
  body,
1403
1405
  operation: "companies.unbilledWork"
1404
1406
  });
1405
- const { items, pageDetails } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, "companies.unbilledWork");
1407
+ const { items, pageDetails } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, "companies.unbilledWork");
1406
1408
  const capped = items.length >= limit;
1407
1409
  return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
1408
1410
  }
@@ -1413,7 +1415,7 @@ function capJoinSet(ids, cap) {
1413
1415
  }
1414
1416
  function unbilledWorkPartStatus(key, conditions, items) {
1415
1417
  if (items.length !== 0) return { status: "ok" };
1416
- const stamp = _chunkMAYYTYV5cjs.blindStampFor.call(void 0, _optionalChain([_chunkMAYYTYV5cjs.BLIND_SURFACE_STAMPS, 'access', _18 => _18[key], 'optionalAccess', _19 => _19.query]), conditions);
1418
+ const stamp = _chunkWRWX6WIKcjs.blindStampFor.call(void 0, _optionalChain([_chunkWRWX6WIKcjs.BLIND_SURFACE_STAMPS, 'access', _18 => _18[key], 'optionalAccess', _19 => _19.query]), conditions);
1417
1419
  if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
1418
1420
  return {
1419
1421
  status: "ok",
@@ -1422,7 +1424,7 @@ function unbilledWorkPartStatus(key, conditions, items) {
1422
1424
  }
1423
1425
  async function unbilledWork(resource, companyId, opts = {}, http) {
1424
1426
  const v = validateUnbilledWorkOptions(companyId, opts);
1425
- const id = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, companyId, "companyId");
1427
+ const id = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, companyId, "companyId");
1426
1428
  const company = await resource.get(id);
1427
1429
  const companyIds = [num(company.id)];
1428
1430
  let parent = null;
@@ -1435,7 +1437,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1435
1437
  parentStatus = "ok";
1436
1438
  companyIds.push(num(parent.id));
1437
1439
  } catch (err) {
1438
- if (err instanceof _chunkMAYYTYV5cjs.NotFoundError) parent = null;
1440
+ if (err instanceof _chunkWRWX6WIKcjs.NotFoundError) parent = null;
1439
1441
  else throw err;
1440
1442
  }
1441
1443
  }
@@ -1467,7 +1469,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1467
1469
  if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
1468
1470
  if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
1469
1471
  }
1470
- const billingFields = _chunkMAYYTYV5cjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
1472
+ const billingFields = _chunkWRWX6WIKcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
1471
1473
  const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
1472
1474
  const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, billingIncludeFields);
1473
1475
  const taskCap = capJoinSet(taskIds, UNBILLED_WORK_JOIN_SET_CAP);
@@ -1499,7 +1501,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1499
1501
  let cappedItems = entries;
1500
1502
  let noteCharsTruncated = 0;
1501
1503
  if (v.includeNotes) {
1502
- [cappedItems, noteCharsTruncated] = _chunkMAYYTYV5cjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
1504
+ [cappedItems, noteCharsTruncated] = _chunkWRWX6WIKcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
1503
1505
  }
1504
1506
  const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
1505
1507
  timePart = {
@@ -1514,8 +1516,8 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1514
1516
  let billingItems = billingRaw.items;
1515
1517
  let billingNoteCharsTruncated = 0;
1516
1518
  if (v.includeNotes) {
1517
- const noteFields = (_nullishCoalesce(_chunkMAYYTYV5cjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
1518
- [billingItems, billingNoteCharsTruncated] = _chunkMAYYTYV5cjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
1519
+ const noteFields = (_nullishCoalesce(_chunkWRWX6WIKcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
1520
+ [billingItems, billingNoteCharsTruncated] = _chunkWRWX6WIKcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
1519
1521
  }
1520
1522
  const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
1521
1523
  const billingItemsPart = {
@@ -1612,7 +1614,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1612
1614
  }
1613
1615
 
1614
1616
  // src/resources/companies.ts
1615
- var CompaniesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1617
+ var CompaniesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
1616
1618
  constructor(http, pageSize) {
1617
1619
  super(http, {
1618
1620
  key: "companies",
@@ -1719,7 +1721,7 @@ var CompaniesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1719
1721
  };
1720
1722
 
1721
1723
  // src/resources/company_alerts.ts
1722
- var CompanyAlertsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1724
+ var CompanyAlertsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
1723
1725
  constructor(http, pageSize) {
1724
1726
  super(http, {
1725
1727
  key: "company_alerts",
@@ -1785,7 +1787,7 @@ var CompanyAlertsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1785
1787
  };
1786
1788
 
1787
1789
  // src/resources/company_locations.ts
1788
- var CompanyLocationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1790
+ var CompanyLocationsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
1789
1791
  constructor(http, pageSize) {
1790
1792
  super(http, {
1791
1793
  key: "company_locations",
@@ -1856,7 +1858,7 @@ var CompanyLocationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1856
1858
  };
1857
1859
 
1858
1860
  // src/resources/company_notes.ts
1859
- var CompanyNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1861
+ var CompanyNotesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
1860
1862
  constructor(http, pageSize) {
1861
1863
  super(http, {
1862
1864
  key: "company_notes",
@@ -1921,7 +1923,7 @@ var CompanyNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1921
1923
  };
1922
1924
 
1923
1925
  // src/resources/company_site_configurations.ts
1924
- var CompanySiteConfigurationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1926
+ var CompanySiteConfigurationsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
1925
1927
  constructor(http, pageSize) {
1926
1928
  super(http, {
1927
1929
  key: "company_site_configurations",
@@ -1972,7 +1974,7 @@ var CompanySiteConfigurationsResource = class extends _chunkMAYYTYV5cjs.BaseReso
1972
1974
  };
1973
1975
 
1974
1976
  // src/resources/company_webhooks.ts
1975
- var CompanyWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
1977
+ var CompanyWebhooksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
1976
1978
  constructor(http, pageSize) {
1977
1979
  super(http, {
1978
1980
  key: "company_webhooks",
@@ -2048,7 +2050,7 @@ var CompanyWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2048
2050
  };
2049
2051
 
2050
2052
  // src/resources/configuration_item_billing_product_associations.ts
2051
- var ConfigurationItemBillingProductAssociationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2053
+ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2052
2054
  constructor(http, pageSize) {
2053
2055
  super(http, {
2054
2056
  key: "configuration_item_billing_product_associations",
@@ -2114,7 +2116,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkMA
2114
2116
  };
2115
2117
 
2116
2118
  // src/resources/configuration_item_categories.ts
2117
- var ConfigurationItemCategoriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2119
+ var ConfigurationItemCategoriesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2118
2120
  constructor(http, pageSize) {
2119
2121
  super(http, {
2120
2122
  key: "configuration_item_categories",
@@ -2181,7 +2183,7 @@ var ConfigurationItemCategoriesResource = class extends _chunkMAYYTYV5cjs.BaseRe
2181
2183
  };
2182
2184
 
2183
2185
  // src/resources/configuration_item_category_udf_associations.ts
2184
- var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2186
+ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2185
2187
  constructor(http, pageSize) {
2186
2188
  super(http, {
2187
2189
  key: "configuration_item_category_udf_associations",
@@ -2247,7 +2249,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkMAYYT
2247
2249
  };
2248
2250
 
2249
2251
  // src/resources/configuration_item_dns_records.ts
2250
- var ConfigurationItemDnsRecordsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2252
+ var ConfigurationItemDnsRecordsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2251
2253
  constructor(http, pageSize) {
2252
2254
  super(http, {
2253
2255
  key: "configuration_item_dns_records",
@@ -2296,7 +2298,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkMAYYTYV5cjs.BaseRe
2296
2298
  };
2297
2299
 
2298
2300
  // src/resources/configuration_item_notes.ts
2299
- var ConfigurationItemNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2301
+ var ConfigurationItemNotesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2300
2302
  constructor(http, pageSize) {
2301
2303
  super(http, {
2302
2304
  key: "configuration_item_notes",
@@ -2355,7 +2357,7 @@ var ConfigurationItemNotesResource = class extends _chunkMAYYTYV5cjs.BaseResourc
2355
2357
  };
2356
2358
 
2357
2359
  // src/resources/configuration_item_related_items.ts
2358
- var ConfigurationItemRelatedItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2360
+ var ConfigurationItemRelatedItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2359
2361
  constructor(http, pageSize) {
2360
2362
  super(http, {
2361
2363
  key: "configuration_item_related_items",
@@ -2416,16 +2418,16 @@ async function fetchRecord(http, path, label, readOpts) {
2416
2418
  const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _20 => _20.maxRetries]) });
2417
2419
  const body = res;
2418
2420
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
2419
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
2421
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
2420
2422
  }
2421
2423
  return body.item;
2422
2424
  }
2423
2425
  async function moveConfigurationItem(_resource, sourceId, opts, http) {
2424
- const numericSource = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, sourceId, "sourceId");
2426
+ const numericSource = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
2425
2427
  if (_optionalChain([opts, 'optionalAccess', _21 => _21.destinationCompanyId]) === void 0) {
2426
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
2428
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
2427
2429
  }
2428
- const destId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
2430
+ const destId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
2429
2431
  const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
2430
2432
  await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
2431
2433
  const body = { ...source };
@@ -2435,20 +2437,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
2435
2437
  body.companyID = destId;
2436
2438
  body.isActive = true;
2437
2439
  if (opts.newReferenceTitle !== void 0) {
2438
- if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
2440
+ if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
2439
2441
  body.referenceTitle = opts.newReferenceTitle.trim();
2440
2442
  }
2441
2443
  if (opts.lastModifiedDate !== void 0) {
2442
2444
  const current = source.lastModifiedDate;
2443
2445
  if (current !== opts.lastModifiedDate) {
2444
- throw new (0, _chunkMAYYTYV5cjs.StaleObjectError)(
2446
+ throw new (0, _chunkWRWX6WIKcjs.StaleObjectError)(
2445
2447
  `moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
2446
- { operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource] }
2448
+ { operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
2447
2449
  );
2448
2450
  }
2449
2451
  }
2450
2452
  if (opts.dryRun === true) {
2451
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
2453
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
2452
2454
  operation: "configuration_items.moveConfigurationItem",
2453
2455
  method: "POST",
2454
2456
  path: "/V1.0/ConfigurationItems",
@@ -2473,7 +2475,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
2473
2475
  const createdBody = created;
2474
2476
  const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
2475
2477
  if (typeof newId !== "number") {
2476
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
2478
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
2477
2479
  }
2478
2480
  let sourceDeactivated = false;
2479
2481
  if (opts.deactivateSource !== false) {
@@ -2492,11 +2494,11 @@ var PROFILE_PART_LIMIT2 = 50;
2492
2494
  function profilePartLimit2(value, name) {
2493
2495
  const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
2494
2496
  if (!Number.isInteger(n) || n < 1) {
2495
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
2497
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
2496
2498
  }
2497
2499
  return n;
2498
2500
  }
2499
- async function contextFetchPart(http, entityPath, referenceId) {
2501
+ async function contextFetchPart(http, entityPath, referenceId, entity) {
2500
2502
  if (typeof referenceId !== "number" || !Number.isSafeInteger(referenceId) || referenceId < 0) {
2501
2503
  return null;
2502
2504
  }
@@ -2508,14 +2510,14 @@ async function contextFetchPart(http, entityPath, referenceId) {
2508
2510
  });
2509
2511
  const body = res;
2510
2512
  if (body === null || !("item" in body)) {
2511
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId] });
2513
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2512
2514
  }
2513
2515
  if (body.item === null || body.item === void 0) {
2514
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)("context part not found", { resourceIds: [referenceId] });
2516
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2515
2517
  }
2516
2518
  return body.item;
2517
2519
  } catch (err) {
2518
- if (err instanceof _chunkMAYYTYV5cjs.NotFoundError) return null;
2520
+ if (err instanceof _chunkWRWX6WIKcjs.NotFoundError) return null;
2519
2521
  throw err;
2520
2522
  }
2521
2523
  }
@@ -2527,19 +2529,19 @@ async function ciScopedQuery(http, path, itemID, limit) {
2527
2529
  body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
2528
2530
  operation: "configuration_items.profile"
2529
2531
  });
2530
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
2532
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
2531
2533
  }
2532
2534
  async function profile(resource, id, opts = {}, http) {
2533
2535
  const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
2534
2536
  const relatedLimit = profilePartLimit2(opts.relatedLimit, "relatedLimit");
2535
2537
  const ci = await resource.get(id);
2536
2538
  const root = ci;
2537
- const type = await contextFetchPart(http, "/V1.0/ConfigurationItemTypes", root["configurationItemType"]);
2538
- const category = await contextFetchPart(http, "/V1.0/ConfigurationItemCategories", root["configurationItemCategoryID"]);
2539
+ const type = await contextFetchPart(http, "/V1.0/ConfigurationItemTypes", root["configurationItemType"], "configuration_item_type");
2540
+ const category = await contextFetchPart(http, "/V1.0/ConfigurationItemCategories", root["configurationItemCategoryID"], "configuration_item_category");
2539
2541
  const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
2540
2542
  const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
2541
2543
  const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
2542
- const wallQuirk = _optionalChain([_chunkMAYYTYV5cjs.RELATIONSHIP_MAP, 'access', _22 => _22["configuration_items"], 'optionalAccess', _23 => _23.zoneFacts, 'optionalAccess', _24 => _24.quirks, 'optionalAccess', _25 => _25.find, 'call', _26 => _26((q) => q.startsWith("product wall"))]);
2544
+ const wallQuirk = _optionalChain([_chunkWRWX6WIKcjs.RELATIONSHIP_MAP, 'access', _22 => _22["configuration_items"], 'optionalAccess', _23 => _23.zoneFacts, 'optionalAccess', _24 => _24.quirks, 'optionalAccess', _25 => _25.find, 'call', _26 => _26((q) => q.startsWith("product wall"))]);
2543
2545
  const productAssociations = {
2544
2546
  items: associations,
2545
2547
  capped: associations.length >= PROFILE_PART_LIMIT2,
@@ -2563,11 +2565,11 @@ async function profile(resource, id, opts = {}, http) {
2563
2565
  }
2564
2566
  };
2565
2567
  if (opts.names === true) {
2566
- const builder = _chunkMAYYTYV5cjs.createNamePlan.call(void 0, );
2568
+ const builder = _chunkWRWX6WIKcjs.createNamePlan.call(void 0, );
2567
2569
  builder.addFk("contract", root["contractID"]);
2568
- const names = await _chunkMAYYTYV5cjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
2570
+ const names = await _chunkWRWX6WIKcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
2569
2571
  const ciRow = { ...ci };
2570
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
2572
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
2571
2573
  result.ci = ciRow;
2572
2574
  result.names = names.section;
2573
2575
  }
@@ -2575,7 +2577,7 @@ async function profile(resource, id, opts = {}, http) {
2575
2577
  }
2576
2578
 
2577
2579
  // src/resources/configuration_items.ts
2578
- var ConfigurationItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2580
+ var ConfigurationItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2579
2581
  constructor(http, pageSize) {
2580
2582
  super(http, {
2581
2583
  key: "configuration_items",
@@ -2664,7 +2666,7 @@ var ConfigurationItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2664
2666
  };
2665
2667
 
2666
2668
  // src/resources/configuration_item_ssl_subject_alternative_names.ts
2667
- var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2669
+ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2668
2670
  constructor(http, pageSize) {
2669
2671
  super(http, {
2670
2672
  key: "configuration_item_ssl_subject_alternative_names",
@@ -2727,7 +2729,7 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkMA
2727
2729
  };
2728
2730
 
2729
2731
  // src/resources/configuration_item_types.ts
2730
- var ConfigurationItemTypesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2732
+ var ConfigurationItemTypesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2731
2733
  constructor(http, pageSize) {
2732
2734
  super(http, {
2733
2735
  key: "configuration_item_types",
@@ -2801,7 +2803,7 @@ var ConfigurationItemTypesResource = class extends _chunkMAYYTYV5cjs.BaseResourc
2801
2803
  };
2802
2804
 
2803
2805
  // src/resources/configuration_item_webhooks.ts
2804
- var ConfigurationItemWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2806
+ var ConfigurationItemWebhooksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2805
2807
  constructor(http, pageSize) {
2806
2808
  super(http, {
2807
2809
  key: "configuration_item_webhooks",
@@ -2877,7 +2879,7 @@ var ConfigurationItemWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseReso
2877
2879
  };
2878
2880
 
2879
2881
  // src/resources/contact_group_contacts.ts
2880
- var ContactGroupContactsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2882
+ var ContactGroupContactsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2881
2883
  constructor(http, pageSize) {
2882
2884
  super(http, {
2883
2885
  key: "contact_group_contacts",
@@ -2931,7 +2933,7 @@ var ContactGroupContactsResource = class extends _chunkMAYYTYV5cjs.BaseResource
2931
2933
  };
2932
2934
 
2933
2935
  // src/resources/contact_groups.ts
2934
- var ContactGroupsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
2936
+ var ContactGroupsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
2935
2937
  constructor(http, pageSize) {
2936
2938
  super(http, {
2937
2939
  key: "contact_groups",
@@ -3009,24 +3011,24 @@ async function fetchRecord2(http, path, label, readOpts) {
3009
3011
  const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _27 => _27.maxRetries]) });
3010
3012
  const body = res;
3011
3013
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
3012
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
3014
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
3013
3015
  }
3014
3016
  return body.item;
3015
3017
  }
3016
3018
  async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
3017
- const sourceId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
3018
- const destId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
3019
+ const sourceId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
3020
+ const destId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
3019
3021
  const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
3020
3022
  const companyID = source.companyID;
3021
3023
  if (typeof companyID !== "number" || companyID < 0) {
3022
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
3024
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
3023
3025
  }
3024
3026
  if (opts.lastModifiedDate !== void 0) {
3025
3027
  const current = source.lastModifiedDate;
3026
3028
  if (current !== opts.lastModifiedDate) {
3027
- throw new (0, _chunkMAYYTYV5cjs.StaleObjectError)(
3029
+ throw new (0, _chunkWRWX6WIKcjs.StaleObjectError)(
3028
3030
  `moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
3029
- { operation: "contacts.moveToCompany", resourceIds: [sourceId, destId] }
3031
+ { operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
3030
3032
  );
3031
3033
  }
3032
3034
  }
@@ -3046,12 +3048,12 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3046
3048
  },
3047
3049
  operation: "contacts.moveToCompany"
3048
3050
  });
3049
- const items = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
3051
+ const items = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
3050
3052
  const clash = items.find((c) => String(c.id) !== String(sourceId));
3051
3053
  if (clash !== void 0) {
3052
- throw new (0, _chunkMAYYTYV5cjs.ConflictError)(
3054
+ throw new (0, _chunkWRWX6WIKcjs.ConflictError)(
3053
3055
  `Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
3054
- { resourceIds: [sourceId, destId] }
3056
+ { resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
3055
3057
  );
3056
3058
  }
3057
3059
  }
@@ -3063,7 +3065,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3063
3065
  if (opts.dryRun === true) {
3064
3066
  const warnings = [];
3065
3067
  if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
3066
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
3068
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
3067
3069
  operation: "contacts.moveToCompany",
3068
3070
  method: "POST",
3069
3071
  path: `/V1.0/Companies/${destId}/Contacts`,
@@ -3089,7 +3091,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3089
3091
  const createdBody = created;
3090
3092
  const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
3091
3093
  if (typeof newId !== "number") {
3092
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
3094
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
3093
3095
  }
3094
3096
  let sourceDeleted = false;
3095
3097
  if (opts.deleteSource === true) {
@@ -3108,7 +3110,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
3108
3110
  var EMAIL_SHAPE = /^.+@.+/;
3109
3111
  var SAFE_CONTACT_CREATE_DEFAULTS = {};
3110
3112
  var DEDUP_LIMIT = 10;
3111
- var CompanyNotFoundError = class extends _chunkMAYYTYV5cjs.AutotaskError {
3113
+ var CompanyNotFoundError = class extends _chunkWRWX6WIKcjs.AutotaskError {
3112
3114
  constructor(message, options = {}) {
3113
3115
  super(message, {
3114
3116
  code: "COMPANY_NOT_FOUND",
@@ -3119,7 +3121,7 @@ var CompanyNotFoundError = class extends _chunkMAYYTYV5cjs.AutotaskError {
3119
3121
  this.name = "CompanyNotFoundError";
3120
3122
  }
3121
3123
  };
3122
- var ContactCreateFailedError = class extends _chunkMAYYTYV5cjs.AutotaskError {
3124
+ var ContactCreateFailedError = class extends _chunkWRWX6WIKcjs.AutotaskError {
3123
3125
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
3124
3126
 
3125
3127
  constructor(message, vendorFields, options = {}) {
@@ -3129,25 +3131,25 @@ var ContactCreateFailedError = class extends _chunkMAYYTYV5cjs.AutotaskError {
3129
3131
  }
3130
3132
  };
3131
3133
  async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3132
- const cid = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, companyID, "companyID");
3134
+ const cid = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, companyID, "companyID");
3133
3135
  if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
3134
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
3136
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
3135
3137
  `upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
3136
3138
  { operation: OP_UPSERT_EMAIL }
3137
3139
  );
3138
3140
  }
3139
3141
  if (extra !== void 0) {
3140
3142
  if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
3141
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
3143
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
3142
3144
  `upsertByEmail: extra.isActive must be a boolean (mapped to the zone-correct number 1/0) or a raw 0/1 number (got ${String(extra.isActive)})`,
3143
3145
  { operation: OP_UPSERT_EMAIL }
3144
3146
  );
3145
3147
  }
3146
3148
  if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
3147
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("upsertByEmail: extra.firstName must be a non-empty string (or omitted \u2014 the node defaults it to the email local-part)", { operation: OP_UPSERT_EMAIL });
3149
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("upsertByEmail: extra.firstName must be a non-empty string (or omitted \u2014 the node defaults it to the email local-part)", { operation: OP_UPSERT_EMAIL });
3148
3150
  }
3149
3151
  if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
3150
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("upsertByEmail: extra.lastName must be a string (or omitted \u2014 the node defaults it to the non-empty neutral value Unknown)", { operation: OP_UPSERT_EMAIL });
3152
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("upsertByEmail: extra.lastName must be a string (or omitted \u2014 the node defaults it to the non-empty neutral value Unknown)", { operation: OP_UPSERT_EMAIL });
3151
3153
  }
3152
3154
  }
3153
3155
  const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
@@ -3155,7 +3157,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3155
3157
  if (parentBody === null || !("item" in parentBody) || parentBody.item === null || parentBody.item === void 0) {
3156
3158
  throw new CompanyNotFoundError(
3157
3159
  `upsertByEmail: company ${cid} was not found (companies.get returned item: null \u2014 the companies count/query surface is blind to this API user; get is the authority)`,
3158
- { resourceIds: [cid], operation: OP_UPSERT_EMAIL }
3160
+ { resourceIds: [cid], details: { idRefs: [{ entity: "company", id: cid }] }, operation: OP_UPSERT_EMAIL }
3159
3161
  );
3160
3162
  }
3161
3163
  const q = await resource.queryBounded({
@@ -3168,7 +3170,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3168
3170
  const match = q.items[0];
3169
3171
  if (match !== void 0) {
3170
3172
  if (opts.dryRun === true) {
3171
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
3173
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
3172
3174
  {
3173
3175
  operation: OP_UPSERT_EMAIL,
3174
3176
  method: "POST",
@@ -3198,7 +3200,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3198
3200
  isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
3199
3201
  };
3200
3202
  if (opts.dryRun === true) {
3201
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
3203
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
3202
3204
  {
3203
3205
  operation: OP_UPSERT_EMAIL,
3204
3206
  method: "POST",
@@ -3221,8 +3223,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3221
3223
  const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
3222
3224
  return { id: created.id, created: true };
3223
3225
  } catch (err) {
3224
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
3225
- const named = (_nullishCoalesce(_chunkMAYYTYV5cjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
3226
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
3227
+ const named = (_nullishCoalesce(_chunkWRWX6WIKcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
3226
3228
  const seen = /* @__PURE__ */ new Set();
3227
3229
  const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
3228
3230
  const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
@@ -3236,7 +3238,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3236
3238
  }
3237
3239
  continue;
3238
3240
  }
3239
- const detail = _chunkMAYYTYV5cjs.formatVendorDetail.call(void 0, err.vendorError);
3241
+ const detail = _chunkWRWX6WIKcjs.formatVendorDetail.call(void 0, err.vendorError);
3240
3242
  throw new ContactCreateFailedError(
3241
3243
  `upsertByEmail: the vendor rejected the contact create${unique.length > 0 ? ` naming field(s) ${unique.join(", ")}` : ""} (no proven-safe default \u2014 the required set is fully filled by the node)${detail ? ` \u2014 ${detail}` : ""}`,
3242
3244
  unique,
@@ -3244,7 +3246,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3244
3246
  operation: OP_UPSERT_EMAIL,
3245
3247
  httpStatus: err.httpStatus,
3246
3248
  vendorError: err.vendorError,
3247
- resourceIds: [cid]
3249
+ resourceIds: [cid],
3250
+ details: { idRefs: [{ entity: "company", id: cid }] }
3248
3251
  }
3249
3252
  );
3250
3253
  }
@@ -3252,7 +3255,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3252
3255
  }
3253
3256
 
3254
3257
  // src/resources/contacts.ts
3255
- var ContactsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3258
+ var ContactsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3256
3259
  constructor(http, pageSize) {
3257
3260
  super(http, {
3258
3261
  key: "contacts",
@@ -3344,7 +3347,7 @@ var ContactsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3344
3347
  };
3345
3348
 
3346
3349
  // src/resources/contact_webhooks.ts
3347
- var ContactWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3350
+ var ContactWebhooksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3348
3351
  constructor(http, pageSize) {
3349
3352
  super(http, {
3350
3353
  key: "contact_webhooks",
@@ -3420,7 +3423,7 @@ var ContactWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3420
3423
  };
3421
3424
 
3422
3425
  // src/resources/contract_billing_rules.ts
3423
- var ContractBillingRulesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3426
+ var ContractBillingRulesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3424
3427
  constructor(http, pageSize) {
3425
3428
  super(http, {
3426
3429
  key: "contract_billing_rules",
@@ -3486,7 +3489,7 @@ var ContractBillingRulesResource = class extends _chunkMAYYTYV5cjs.BaseResource
3486
3489
  };
3487
3490
 
3488
3491
  // src/resources/contract_block_hour_factors.ts
3489
- var ContractBlockHourFactorsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3492
+ var ContractBlockHourFactorsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3490
3493
  constructor(http, pageSize) {
3491
3494
  super(http, {
3492
3495
  key: "contract_block_hour_factors",
@@ -3545,7 +3548,7 @@ var ContractBlockHourFactorsResource = class extends _chunkMAYYTYV5cjs.BaseResou
3545
3548
  };
3546
3549
 
3547
3550
  // src/resources/contract_blocks.ts
3548
- var ContractBlocksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3551
+ var ContractBlocksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3549
3552
  constructor(http, pageSize) {
3550
3553
  super(http, {
3551
3554
  key: "contract_blocks",
@@ -3604,7 +3607,7 @@ var ContractBlocksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3604
3607
  };
3605
3608
 
3606
3609
  // src/resources/contract_charges.ts
3607
- var ContractChargesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3610
+ var ContractChargesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3608
3611
  constructor(http, pageSize) {
3609
3612
  super(http, {
3610
3613
  key: "contract_charges",
@@ -3675,7 +3678,7 @@ var ContractChargesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3675
3678
  };
3676
3679
 
3677
3680
  // src/resources/contract_exclusion_billing_codes.ts
3678
- var ContractExclusionBillingCodesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3681
+ var ContractExclusionBillingCodesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3679
3682
  constructor(http, pageSize) {
3680
3683
  super(http, {
3681
3684
  key: "contract_exclusion_billing_codes",
@@ -3732,7 +3735,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkMAYYTYV5cjs.Base
3732
3735
  };
3733
3736
 
3734
3737
  // src/resources/contract_exclusion_roles.ts
3735
- var ContractExclusionRolesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3738
+ var ContractExclusionRolesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3736
3739
  constructor(http, pageSize) {
3737
3740
  super(http, {
3738
3741
  key: "contract_exclusion_roles",
@@ -3789,7 +3792,7 @@ var ContractExclusionRolesResource = class extends _chunkMAYYTYV5cjs.BaseResourc
3789
3792
  };
3790
3793
 
3791
3794
  // src/resources/contract_exclusion_set_excluded_roles.ts
3792
- var ContractExclusionSetExcludedRolesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3795
+ var ContractExclusionSetExcludedRolesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3793
3796
  constructor(http, pageSize) {
3794
3797
  super(http, {
3795
3798
  key: "contract_exclusion_set_excluded_roles",
@@ -3846,7 +3849,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkMAYYTYV5cjs.
3846
3849
  };
3847
3850
 
3848
3851
  // src/resources/contract_exclusion_set_excluded_work_types.ts
3849
- var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3852
+ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3850
3853
  constructor(http, pageSize) {
3851
3854
  super(http, {
3852
3855
  key: "contract_exclusion_set_excluded_work_types",
@@ -3903,7 +3906,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkMAYYTYV5
3903
3906
  };
3904
3907
 
3905
3908
  // src/resources/contract_exclusion_sets.ts
3906
- var ContractExclusionSetsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3909
+ var ContractExclusionSetsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3907
3910
  constructor(http, pageSize) {
3908
3911
  super(http, {
3909
3912
  key: "contract_exclusion_sets",
@@ -3977,7 +3980,7 @@ var ContractExclusionSetsResource = class extends _chunkMAYYTYV5cjs.BaseResource
3977
3980
  };
3978
3981
 
3979
3982
  // src/resources/contract_milestones.ts
3980
- var ContractMilestonesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
3983
+ var ContractMilestonesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
3981
3984
  constructor(http, pageSize) {
3982
3985
  super(http, {
3983
3986
  key: "contract_milestones",
@@ -4036,7 +4039,7 @@ var ContractMilestonesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4036
4039
  };
4037
4040
 
4038
4041
  // src/resources/contract_notes.ts
4039
- var ContractNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4042
+ var ContractNotesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4040
4043
  constructor(http, pageSize) {
4041
4044
  super(http, {
4042
4045
  key: "contract_notes",
@@ -4095,7 +4098,7 @@ var ContractNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4095
4098
  };
4096
4099
 
4097
4100
  // src/resources/contract_rates.ts
4098
- var ContractRatesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4101
+ var ContractRatesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4099
4102
  constructor(http, pageSize) {
4100
4103
  super(http, {
4101
4104
  key: "contract_rates",
@@ -4154,7 +4157,7 @@ var ContractRatesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4154
4157
  };
4155
4158
 
4156
4159
  // src/resources/contract_retainers.ts
4157
- var ContractRetainersResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4160
+ var ContractRetainersResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4158
4161
  constructor(http, pageSize) {
4159
4162
  super(http, {
4160
4163
  key: "contract_retainers",
@@ -4213,7 +4216,7 @@ var ContractRetainersResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4213
4216
  };
4214
4217
 
4215
4218
  // src/resources/contract_role_costs.ts
4216
- var ContractRoleCostsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4219
+ var ContractRoleCostsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4217
4220
  constructor(http, pageSize) {
4218
4221
  super(http, {
4219
4222
  key: "contract_role_costs",
@@ -4272,7 +4275,7 @@ var ContractRoleCostsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4272
4275
  };
4273
4276
 
4274
4277
  // src/resources/contract_service_adjustments.ts
4275
- var ContractServiceAdjustmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4278
+ var ContractServiceAdjustmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4276
4279
  constructor(http, pageSize) {
4277
4280
  super(http, {
4278
4281
  key: "contract_service_adjustments",
@@ -4306,7 +4309,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkMAYYTYV5cjs.BaseRes
4306
4309
  };
4307
4310
 
4308
4311
  // src/resources/contract_service_bundle_adjustments.ts
4309
- var ContractServiceBundleAdjustmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4312
+ var ContractServiceBundleAdjustmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4310
4313
  constructor(http, pageSize) {
4311
4314
  super(http, {
4312
4315
  key: "contract_service_bundle_adjustments",
@@ -4340,7 +4343,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkMAYYTYV5cjs.B
4340
4343
  };
4341
4344
 
4342
4345
  // src/resources/contract_service_bundles.ts
4343
- var ContractServiceBundlesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4346
+ var ContractServiceBundlesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4344
4347
  constructor(http, pageSize) {
4345
4348
  super(http, {
4346
4349
  key: "contract_service_bundles",
@@ -4399,7 +4402,7 @@ var ContractServiceBundlesResource = class extends _chunkMAYYTYV5cjs.BaseResourc
4399
4402
  };
4400
4403
 
4401
4404
  // src/resources/contract_service_bundle_units.ts
4402
- var ContractServiceBundleUnitsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4405
+ var ContractServiceBundleUnitsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4403
4406
  constructor(http, pageSize) {
4404
4407
  super(http, {
4405
4408
  key: "contract_service_bundle_units",
@@ -4441,7 +4444,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkMAYYTYV5cjs.BaseRes
4441
4444
  };
4442
4445
 
4443
4446
  // src/resources/contract_services.ts
4444
- var ContractServicesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4447
+ var ContractServicesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4445
4448
  constructor(http, pageSize) {
4446
4449
  super(http, {
4447
4450
  key: "contract_services",
@@ -4500,7 +4503,7 @@ var ContractServicesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4500
4503
  };
4501
4504
 
4502
4505
  // src/resources/contract_service_units.ts
4503
- var ContractServiceUnitsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
4506
+ var ContractServiceUnitsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
4504
4507
  constructor(http, pageSize) {
4505
4508
  super(http, {
4506
4509
  key: "contract_service_units",
@@ -4692,7 +4695,7 @@ function dateToDay(v) {
4692
4695
  }
4693
4696
  function validateProfitabilityOptions(contractId, opts) {
4694
4697
  if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
4695
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
4698
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
4696
4699
  `profitability: opts is required \u2014 the options object with dateFrom and dateTo (YYYY-MM-DD) (got ${opts === void 0 ? "undefined" : Array.isArray(opts) ? "an array" : typeof opts})`,
4697
4700
  { operation: "contracts.profitability" }
4698
4701
  );
@@ -4769,12 +4772,12 @@ function validateProfitabilityOptions(contractId, opts) {
4769
4772
  }
4770
4773
  }
4771
4774
  try {
4772
- _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, contractId, "contractId");
4775
+ _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, contractId, "contractId");
4773
4776
  } catch (err) {
4774
- problems.push(err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
4777
+ problems.push(err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
4775
4778
  }
4776
4779
  if (problems.length > 0) {
4777
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
4780
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
4778
4781
  `profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
4779
4782
  - ` + problems.join("\n- "),
4780
4783
  { operation: "contracts.profitability" }
@@ -4805,7 +4808,7 @@ async function boundedPart2(http, path, conditions, limit, operation, includeFie
4805
4808
  body,
4806
4809
  operation
4807
4810
  });
4808
- const { items, pageDetails } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, operation);
4811
+ const { items, pageDetails } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, operation);
4809
4812
  const capped = items.length >= limit;
4810
4813
  return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
4811
4814
  }
@@ -4814,28 +4817,28 @@ function capJoinSet2(ids, cap) {
4814
4817
  if (sorted.length <= cap) return { ids: sorted, truncated: false, total: sorted.length };
4815
4818
  return { ids: sorted.slice(0, cap), truncated: true, total: sorted.length };
4816
4819
  }
4817
- async function fetchByIdsPart(http, entityPath, ids, fields, operation) {
4820
+ async function fetchByIdsPart(http, entityPath, ids, fields, operation, entity) {
4818
4821
  const unique = [...new Set(ids)].sort((a, b) => a - b);
4819
4822
  const byKey = /* @__PURE__ */ new Map();
4820
4823
  const misses = [];
4821
4824
  const notes = [];
4822
- for (let c = 0; c < unique.length; c += _chunkMAYYTYV5cjs.FETCH_BY_IDS_CHUNK_SIZE) {
4823
- const chunk = unique.slice(c, c + _chunkMAYYTYV5cjs.FETCH_BY_IDS_CHUNK_SIZE);
4825
+ for (let c = 0; c < unique.length; c += _chunkWRWX6WIKcjs.FETCH_BY_IDS_CHUNK_SIZE) {
4826
+ const chunk = unique.slice(c, c + _chunkWRWX6WIKcjs.FETCH_BY_IDS_CHUNK_SIZE);
4824
4827
  const chunkKeys = new Set(chunk);
4825
4828
  try {
4826
4829
  const body = {
4827
- MaxRecords: _chunkMAYYTYV5cjs.FETCH_BY_IDS_CHUNK_SIZE,
4830
+ MaxRecords: _chunkWRWX6WIKcjs.FETCH_BY_IDS_CHUNK_SIZE,
4828
4831
  filter: [{ field: "id", op: "in", value: chunk }],
4829
4832
  IncludeFields: fields
4830
4833
  };
4831
4834
  const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
4832
- const { items: rows } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, operation);
4835
+ const { items: rows } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, operation);
4833
4836
  for (const row of rows) {
4834
4837
  const k = num2(row.id);
4835
4838
  if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
4836
4839
  }
4837
4840
  } catch (err) {
4838
- const code = err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.code : "SERVER_ERROR";
4841
+ const code = err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.code : "SERVER_ERROR";
4839
4842
  for (const k of chunk) {
4840
4843
  if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
4841
4844
  }
@@ -4845,11 +4848,11 @@ async function fetchByIdsPart(http, entityPath, ids, fields, operation) {
4845
4848
  for (const k of queryMissed) {
4846
4849
  try {
4847
4850
  const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
4848
- byKey.set(k, _chunkMAYYTYV5cjs.unwrapItem.call(void 0, res, k, operation));
4851
+ byKey.set(k, _chunkWRWX6WIKcjs.unwrapItem.call(void 0, res, k, operation, entity));
4849
4852
  } catch (err) {
4850
- if (err instanceof _chunkMAYYTYV5cjs.NotFoundError) {
4853
+ if (err instanceof _chunkWRWX6WIKcjs.NotFoundError) {
4851
4854
  misses.push({ id: k, code: "NOT_FOUND", message: err.message });
4852
- } else if (err instanceof _chunkMAYYTYV5cjs.AutotaskError) {
4855
+ } else if (err instanceof _chunkWRWX6WIKcjs.AutotaskError) {
4853
4856
  misses.push({ id: k, code: err.code, message: err.message });
4854
4857
  } else {
4855
4858
  misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
@@ -4972,7 +4975,7 @@ async function degradable(read) {
4972
4975
  try {
4973
4976
  return await read();
4974
4977
  } catch (err) {
4975
- if (!(err instanceof _chunkMAYYTYV5cjs.AutotaskError)) throw err;
4978
+ if (!(err instanceof _chunkWRWX6WIKcjs.AutotaskError)) throw err;
4976
4979
  return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
4977
4980
  }
4978
4981
  }
@@ -4993,7 +4996,7 @@ function dedupeSortCap(ids, limit) {
4993
4996
  async function profitability(resource, contractId, opts, rawHttp) {
4994
4997
  const v = validateProfitabilityOptions(contractId, opts);
4995
4998
  const OP2 = "contracts.profitability";
4996
- const id = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, contractId, "contractId");
4999
+ const id = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, contractId, "contractId");
4997
5000
  const idNum = typeof id === "number" ? id : Number(id);
4998
5001
  const wires = { issued: 0, requests: 0, budget: PROFITABILITY_WIRE_BUDGET };
4999
5002
  const asOf = (/* @__PURE__ */ new Date()).toISOString();
@@ -5021,7 +5024,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
5021
5024
  status: st.status,
5022
5025
  blindSurface: st.blindSurface,
5023
5026
  note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
5024
- emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkMAYYTYV5cjs.EMPTY_REASON_STAMPS, 'access', _31 => _31[key], 'optionalAccess', _32 => _32.query]) : void 0
5027
+ emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkWRWX6WIKcjs.EMPTY_REASON_STAMPS, 'access', _31 => _31[key], 'optionalAccess', _32 => _32.query]) : void 0
5025
5028
  };
5026
5029
  };
5027
5030
  const truncatedMonths = {};
@@ -5051,12 +5054,12 @@ async function profitability(resource, contractId, opts, rawHttp) {
5051
5054
  path: `/V1.0/Companies/${companyID}`,
5052
5055
  operation: OP2
5053
5056
  });
5054
- const item = _chunkMAYYTYV5cjs.unwrapItem.call(void 0, res, companyID, OP2);
5057
+ const item = _chunkWRWX6WIKcjs.unwrapItem.call(void 0, res, companyID, OP2, "company");
5055
5058
  customer = _nullishCoalesce(item, () => ( null));
5056
5059
  customerStatus = "ok";
5057
5060
  } catch (err) {
5058
- if (!(err instanceof _chunkMAYYTYV5cjs.AutotaskError)) throw err;
5059
- if (!(err instanceof _chunkMAYYTYV5cjs.NotFoundError)) {
5061
+ if (!(err instanceof _chunkWRWX6WIKcjs.AutotaskError)) throw err;
5062
+ if (!(err instanceof _chunkWRWX6WIKcjs.NotFoundError)) {
5060
5063
  customerStatus = "absent";
5061
5064
  customerAbsent = err.code;
5062
5065
  }
@@ -5069,7 +5072,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
5069
5072
  try {
5070
5073
  contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(http, "/V1.0/Contracts", OP2)), 'access', async _36 => _36.get, 'call', async _37 => _37("contractType"), 'optionalAccess', async _38 => _38.get, 'call', async _39 => _39(contractType)]), async () => ( null));
5071
5074
  } catch (err) {
5072
- if (!(err instanceof _chunkMAYYTYV5cjs.AutotaskError)) throw err;
5075
+ if (!(err instanceof _chunkWRWX6WIKcjs.AutotaskError)) throw err;
5073
5076
  }
5074
5077
  }
5075
5078
  const contractTypeKnown = contractTypeLabel !== null;
@@ -5116,9 +5119,9 @@ async function profitability(resource, contractId, opts, rawHttp) {
5116
5119
  if (invoiceIds.length === 0) {
5117
5120
  invoicesPart = skipPart("skipped: the billing part has no invoiceIDs (zero wire)");
5118
5121
  } else {
5119
- const capped = capJoinSet2(invoiceIds, _chunkMAYYTYV5cjs.FETCH_BY_IDS_MAX_ITEMS);
5120
- if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `invoiceJoinTruncated: the join set is capped at ${_chunkMAYYTYV5cjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
5121
- const fb = await fetchByIdsPart(http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], OP2);
5122
+ const capped = capJoinSet2(invoiceIds, _chunkWRWX6WIKcjs.FETCH_BY_IDS_MAX_ITEMS);
5123
+ if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `invoiceJoinTruncated: the join set is capped at ${_chunkWRWX6WIKcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
5124
+ const fb = await fetchByIdsPart(http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], OP2, "invoice");
5122
5125
  wires.issued += 1;
5123
5126
  invoices = fb.items;
5124
5127
  invoicesPart = { items: fb.items, capped: capped.truncated, hasMore: capped.truncated, status: "ok", note: fb.notes.join(" | ") || void 0 };
@@ -5149,7 +5152,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
5149
5152
  }
5150
5153
  }
5151
5154
  } catch (err) {
5152
- statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkMAYYTYV5cjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
5155
+ statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkWRWX6WIKcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
5153
5156
  }
5154
5157
  let ticketsOpenPart;
5155
5158
  let openTickets = [];
@@ -5168,9 +5171,9 @@ async function profitability(resource, contractId, opts, rawHttp) {
5168
5171
  if (resourceIds.length === 0) {
5169
5172
  resourcesPart = skipPart("skipped: the time part has no resourceIDs (zero wire)");
5170
5173
  } else {
5171
- const capped = capJoinSet2(resourceIds, _chunkMAYYTYV5cjs.FETCH_BY_IDS_MAX_ITEMS);
5172
- if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `resourceJoinTruncated: the join set is capped at ${_chunkMAYYTYV5cjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
5173
- const fb = await fetchByIdsPart(http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], OP2);
5174
+ const capped = capJoinSet2(resourceIds, _chunkWRWX6WIKcjs.FETCH_BY_IDS_MAX_ITEMS);
5175
+ if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `resourceJoinTruncated: the join set is capped at ${_chunkWRWX6WIKcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
5176
+ const fb = await fetchByIdsPart(http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], OP2, "resource");
5174
5177
  wires.issued += 1;
5175
5178
  resources = fb.items;
5176
5179
  for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
@@ -5226,7 +5229,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
5226
5229
  if (cis.length === 0) {
5227
5230
  subscriptionsPart = skipPart("skipped: the CI join found no configuration items \u2014 the subscriptions part is not evaluable (zero wire)");
5228
5231
  } else {
5229
- const ciIds = capJoinSet2(cis.map((c) => num2(c["id"])).filter((n) => n > 0), _chunkMAYYTYV5cjs.FETCH_BY_IDS_MAX_ITEMS);
5232
+ const ciIds = capJoinSet2(cis.map((c) => num2(c["id"])).filter((n) => n > 0), _chunkWRWX6WIKcjs.FETCH_BY_IDS_MAX_ITEMS);
5230
5233
  const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
5231
5234
  const raw = await readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
5232
5235
  subscriptions = raw.items;
@@ -5236,7 +5239,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
5236
5239
  try {
5237
5240
  labels = await readPicklists(http, "/V1.0/Subscriptions", OP2);
5238
5241
  } catch (err) {
5239
- if (!(err instanceof _chunkMAYYTYV5cjs.AutotaskError)) throw err;
5242
+ if (!(err instanceof _chunkWRWX6WIKcjs.AutotaskError)) throw err;
5240
5243
  }
5241
5244
  }
5242
5245
  for (const x of subscriptions) {
@@ -5798,7 +5801,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
5798
5801
  }
5799
5802
 
5800
5803
  // src/resources/contracts.ts
5801
- var ContractsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
5804
+ var ContractsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
5802
5805
  constructor(http, pageSize) {
5803
5806
  super(http, {
5804
5807
  key: "contracts",
@@ -5869,7 +5872,7 @@ var ContractsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
5869
5872
  };
5870
5873
 
5871
5874
  // src/resources/contract_ticket_purchases.ts
5872
- var ContractTicketPurchasesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
5875
+ var ContractTicketPurchasesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
5873
5876
  constructor(http, pageSize) {
5874
5877
  super(http, {
5875
5878
  key: "contract_ticket_purchases",
@@ -5928,7 +5931,7 @@ var ContractTicketPurchasesResource = class extends _chunkMAYYTYV5cjs.BaseResour
5928
5931
  };
5929
5932
 
5930
5933
  // src/resources/countries.ts
5931
- var CountriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
5934
+ var CountriesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
5932
5935
  constructor(http, pageSize) {
5933
5936
  super(http, {
5934
5937
  key: "countries",
@@ -5987,7 +5990,7 @@ var CountriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
5987
5990
  };
5988
5991
 
5989
5992
  // src/resources/departments.ts
5990
- var DepartmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
5993
+ var DepartmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
5991
5994
  constructor(http, pageSize) {
5992
5995
  super(http, {
5993
5996
  key: "departments",
@@ -6054,7 +6057,7 @@ var DepartmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6054
6057
  };
6055
6058
 
6056
6059
  // src/resources/domain_registrars.ts
6057
- var DomainRegistrarsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6060
+ var DomainRegistrarsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6058
6061
  constructor(http, pageSize) {
6059
6062
  super(http, {
6060
6063
  key: "domain_registrars",
@@ -6137,7 +6140,7 @@ var EntityInformationResource = class {
6137
6140
  };
6138
6141
 
6139
6142
  // src/resources/expense_item_attachments.ts
6140
- var ExpenseItemAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6143
+ var ExpenseItemAttachmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6141
6144
  constructor(http, pageSize) {
6142
6145
  super(http, {
6143
6146
  key: "expense_item_attachments",
@@ -6199,7 +6202,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResourc
6199
6202
  };
6200
6203
 
6201
6204
  // src/resources/expense_items.ts
6202
- var ExpenseItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6205
+ var ExpenseItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6203
6206
  constructor(http, pageSize) {
6204
6207
  super(http, {
6205
6208
  key: "expense_items",
@@ -6258,7 +6261,7 @@ var ExpenseItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6258
6261
  };
6259
6262
 
6260
6263
  // src/resources/expense_reports.ts
6261
- var ExpenseReportsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6264
+ var ExpenseReportsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6262
6265
  constructor(http, pageSize) {
6263
6266
  super(http, {
6264
6267
  key: "expense_reports",
@@ -6325,7 +6328,7 @@ var ExpenseReportsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6325
6328
  };
6326
6329
 
6327
6330
  // src/resources/holiday_sets.ts
6328
- var HolidaySetsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6331
+ var HolidaySetsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6329
6332
  constructor(http, pageSize) {
6330
6333
  super(http, {
6331
6334
  key: "holiday_sets",
@@ -6394,7 +6397,7 @@ var HolidaySetsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6394
6397
  };
6395
6398
 
6396
6399
  // src/resources/holidays.ts
6397
- var HolidaysResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6400
+ var HolidaysResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6398
6401
  constructor(http, pageSize) {
6399
6402
  super(http, {
6400
6403
  key: "holidays",
@@ -6466,10 +6469,10 @@ var PATH_SUFFIX = {
6466
6469
  transfer: "StockedItemsTransfer"
6467
6470
  };
6468
6471
  async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
6469
- const numericParent = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, parentId, "parentId");
6472
+ const numericParent = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, parentId, "parentId");
6470
6473
  const suffix = PATH_SUFFIX[kind];
6471
6474
  if (opts.dryRun === true) {
6472
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
6475
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
6473
6476
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
6474
6477
  method: "POST",
6475
6478
  path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
@@ -6486,11 +6489,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
6486
6489
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
6487
6490
  maxRetries: opts.maxRetries
6488
6491
  });
6489
- return _chunkMAYYTYV5cjs.unwrapOperation.call(void 0, res);
6492
+ return _chunkWRWX6WIKcjs.unwrapOperation.call(void 0, res);
6490
6493
  }
6491
6494
 
6492
6495
  // src/resources/inventory_products.ts
6493
- var InventoryProductsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6496
+ var InventoryProductsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6494
6497
  constructor(http, pageSize) {
6495
6498
  super(http, {
6496
6499
  key: "inventory_products",
@@ -6572,7 +6575,7 @@ var InventoryProductsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6572
6575
 
6573
6576
  // src/resources/special/invoices.ts
6574
6577
  async function markup(_resource, id, format, http) {
6575
- const numericId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
6578
+ const numericId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
6576
6579
  const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
6577
6580
  const res = await http.request({
6578
6581
  method: "GET",
@@ -6581,21 +6584,21 @@ async function markup(_resource, id, format, http) {
6581
6584
  });
6582
6585
  const body = res;
6583
6586
  if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
6584
- throw new (0, _chunkMAYYTYV5cjs.AutotaskError)(
6587
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskError)(
6585
6588
  `Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
6586
- { code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId] }
6589
+ { code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
6587
6590
  );
6588
6591
  }
6589
6592
  return body.invoiceMarkup;
6590
6593
  }
6591
6594
  async function pdf(_resource, id, http) {
6592
- const numericId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
6595
+ const numericId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
6593
6596
  const res = await http.request({
6594
6597
  method: "GET",
6595
6598
  path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
6596
6599
  operation: "invoices.pdf"
6597
6600
  });
6598
- return _chunkMAYYTYV5cjs.decodeFileData.call(void 0, res);
6601
+ return _chunkWRWX6WIKcjs.decodeFileData.call(void 0, res);
6599
6602
  }
6600
6603
  async function windowQuery2(_resource, kind, http, opts) {
6601
6604
  const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _48 => _48.now]), () => ( /* @__PURE__ */ new Date()));
@@ -6626,7 +6629,7 @@ async function customRange2(_resource, from, to, http, opts) {
6626
6629
  }
6627
6630
 
6628
6631
  // src/resources/invoices.ts
6629
- var InvoicesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6632
+ var InvoicesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6630
6633
  constructor(http, pageSize) {
6631
6634
  super(http, {
6632
6635
  key: "invoices",
@@ -6756,7 +6759,7 @@ var ModulesResource = class {
6756
6759
  };
6757
6760
 
6758
6761
  // src/resources/notification_history.ts
6759
- var NotificationHistoryResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6762
+ var NotificationHistoryResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6760
6763
  constructor(http, pageSize) {
6761
6764
  super(http, {
6762
6765
  key: "notification_history",
@@ -6795,7 +6798,7 @@ var NotificationHistoryResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6795
6798
  };
6796
6799
 
6797
6800
  // src/resources/opportunities.ts
6798
- var OpportunitiesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6801
+ var OpportunitiesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6799
6802
  constructor(http, pageSize) {
6800
6803
  super(http, {
6801
6804
  key: "opportunities",
@@ -6857,7 +6860,7 @@ var OpportunitiesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6857
6860
  };
6858
6861
 
6859
6862
  // src/resources/opportunity_attachments.ts
6860
- var OpportunityAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6863
+ var OpportunityAttachmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6861
6864
  constructor(http, pageSize) {
6862
6865
  super(http, {
6863
6866
  key: "opportunity_attachments",
@@ -6919,7 +6922,7 @@ var OpportunityAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResourc
6919
6922
  };
6920
6923
 
6921
6924
  // src/resources/opportunity_categories.ts
6922
- var OpportunityCategoriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6925
+ var OpportunityCategoriesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6923
6926
  constructor(http, pageSize) {
6924
6927
  super(http, {
6925
6928
  key: "opportunity_categories",
@@ -6978,7 +6981,7 @@ var OpportunityCategoriesResource = class extends _chunkMAYYTYV5cjs.BaseResource
6978
6981
  };
6979
6982
 
6980
6983
  // src/resources/phases.ts
6981
- var PhasesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
6984
+ var PhasesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
6982
6985
  constructor(http, pageSize) {
6983
6986
  super(http, {
6984
6987
  key: "phases",
@@ -7037,7 +7040,7 @@ var PhasesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7037
7040
  };
7038
7041
 
7039
7042
  // src/resources/products.ts
7040
- var ProductsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7043
+ var ProductsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7041
7044
  constructor(http, pageSize) {
7042
7045
  super(http, {
7043
7046
  key: "products",
@@ -7104,7 +7107,7 @@ var ProductsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7104
7107
  };
7105
7108
 
7106
7109
  // src/resources/product_vendors.ts
7107
- var ProductVendorsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7110
+ var ProductVendorsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7108
7111
  constructor(http, pageSize) {
7109
7112
  super(http, {
7110
7113
  key: "product_vendors",
@@ -7163,7 +7166,7 @@ var ProductVendorsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7163
7166
  };
7164
7167
 
7165
7168
  // src/resources/project_charges.ts
7166
- var ProjectChargesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7169
+ var ProjectChargesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7167
7170
  constructor(http, pageSize) {
7168
7171
  super(http, {
7169
7172
  key: "project_charges",
@@ -7234,7 +7237,7 @@ var ProjectChargesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7234
7237
  };
7235
7238
 
7236
7239
  // src/resources/project_notes.ts
7237
- var ProjectNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7240
+ var ProjectNotesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7238
7241
  constructor(http, pageSize) {
7239
7242
  super(http, {
7240
7243
  key: "project_notes",
@@ -7293,7 +7296,7 @@ var ProjectNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7293
7296
  };
7294
7297
 
7295
7298
  // src/resources/projects.ts
7296
- var ProjectsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7299
+ var ProjectsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7297
7300
  constructor(http, pageSize) {
7298
7301
  super(http, {
7299
7302
  key: "projects",
@@ -7370,13 +7373,13 @@ var ProjectsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7370
7373
  const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
7371
7374
  const result = { project, company, opportunity, leadResource };
7372
7375
  if (opts.names === true) {
7373
- const builder = _chunkMAYYTYV5cjs.createNamePlan.call(void 0, );
7376
+ const builder = _chunkWRWX6WIKcjs.createNamePlan.call(void 0, );
7374
7377
  builder.addResource(root["creatorResourceID"]);
7375
7378
  builder.addFk("contract", root["contractID"]);
7376
- const names = await _chunkMAYYTYV5cjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
7379
+ const names = await _chunkWRWX6WIKcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
7377
7380
  const row = { ...project };
7378
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
7379
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
7381
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
7382
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
7380
7383
  result.project = row;
7381
7384
  result.names = names.section;
7382
7385
  }
@@ -7385,7 +7388,7 @@ var ProjectsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7385
7388
  };
7386
7389
 
7387
7390
  // src/resources/purchase_approvals.ts
7388
- var PurchaseApprovalsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7391
+ var PurchaseApprovalsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7389
7392
  constructor(http, pageSize) {
7390
7393
  super(http, {
7391
7394
  key: "purchase_approvals",
@@ -7439,7 +7442,7 @@ var PurchaseApprovalsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7439
7442
  };
7440
7443
 
7441
7444
  // src/resources/purchase_order_item_receiving.ts
7442
- var PurchaseOrderItemReceivingResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7445
+ var PurchaseOrderItemReceivingResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7443
7446
  constructor(http, pageSize) {
7444
7447
  super(http, {
7445
7448
  key: "purchase_order_item_receiving",
@@ -7489,7 +7492,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkMAYYTYV5cjs.BaseRes
7489
7492
  };
7490
7493
 
7491
7494
  // src/resources/purchase_order_items.ts
7492
- var PurchaseOrderItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7495
+ var PurchaseOrderItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7493
7496
  constructor(http, pageSize) {
7494
7497
  super(http, {
7495
7498
  key: "purchase_order_items",
@@ -7548,7 +7551,7 @@ var PurchaseOrderItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7548
7551
  };
7549
7552
 
7550
7553
  // src/resources/purchase_orders.ts
7551
- var PurchaseOrdersResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7554
+ var PurchaseOrdersResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7552
7555
  constructor(http, pageSize) {
7553
7556
  super(http, {
7554
7557
  key: "purchase_orders",
@@ -7610,7 +7613,7 @@ var PurchaseOrdersResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7610
7613
  };
7611
7614
 
7612
7615
  // src/resources/quote_items.ts
7613
- var QuoteItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7616
+ var QuoteItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7614
7617
  constructor(http, pageSize) {
7615
7618
  super(http, {
7616
7619
  key: "quote_items",
@@ -7681,7 +7684,7 @@ var QuoteItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7681
7684
  };
7682
7685
 
7683
7686
  // src/resources/quote_locations.ts
7684
- var QuoteLocationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7687
+ var QuoteLocationsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7685
7688
  constructor(http, pageSize) {
7686
7689
  super(http, {
7687
7690
  key: "quote_locations",
@@ -7746,7 +7749,7 @@ var QuoteLocationsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7746
7749
  };
7747
7750
 
7748
7751
  // src/resources/quotes.ts
7749
- var QuotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7752
+ var QuotesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7750
7753
  constructor(http, pageSize) {
7751
7754
  super(http, {
7752
7755
  key: "quotes",
@@ -7813,7 +7816,7 @@ var QuotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7813
7816
  };
7814
7817
 
7815
7818
  // src/resources/quote_templates.ts
7816
- var QuoteTemplatesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7819
+ var QuoteTemplatesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7817
7820
  constructor(http, pageSize) {
7818
7821
  super(http, {
7819
7822
  key: "quote_templates",
@@ -7857,7 +7860,7 @@ var QuoteTemplatesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7857
7860
  };
7858
7861
 
7859
7862
  // src/resources/resource_role_queues.ts
7860
- var ResourceRoleQueuesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7863
+ var ResourceRoleQueuesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7861
7864
  constructor(http, pageSize) {
7862
7865
  super(http, {
7863
7866
  key: "resource_role_queues",
@@ -7916,7 +7919,7 @@ var ResourceRoleQueuesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7916
7919
  };
7917
7920
 
7918
7921
  // src/resources/resource_roles.ts
7919
- var ResourceRolesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7922
+ var ResourceRolesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7920
7923
  constructor(http, pageSize) {
7921
7924
  super(http, {
7922
7925
  key: "resource_roles",
@@ -7958,7 +7961,7 @@ var ResourceRolesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7958
7961
  };
7959
7962
 
7960
7963
  // src/resources/resource_skills.ts
7961
- var ResourceSkillsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
7964
+ var ResourceSkillsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
7962
7965
  constructor(http, pageSize) {
7963
7966
  super(http, {
7964
7967
  key: "resource_skills",
@@ -8012,16 +8015,16 @@ var ResourceSkillsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8012
8015
  var MAX_TRANSFER_IDS = 500;
8013
8016
  function requirePositiveIds(ids, label) {
8014
8017
  if (!Array.isArray(ids) || ids.length === 0) {
8015
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
8018
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
8016
8019
  }
8017
8020
  if (ids.length > MAX_TRANSFER_IDS) {
8018
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
8021
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
8019
8022
  }
8020
8023
  const out = [];
8021
8024
  for (const raw of ids) {
8022
- const id = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, raw, `${label} id`);
8025
+ const id = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, raw, `${label} id`);
8023
8026
  if (typeof id === "number" && id < 1) {
8024
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
8027
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
8025
8028
  }
8026
8029
  out.push(id);
8027
8030
  }
@@ -8029,7 +8032,7 @@ function requirePositiveIds(ids, label) {
8029
8032
  }
8030
8033
  async function whoAmI(_resource, userName, http) {
8031
8034
  const user = userName.trim();
8032
- if (user === "") throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
8035
+ if (user === "") throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
8033
8036
  const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
8034
8037
  const res = await http.request({
8035
8038
  method: "POST",
@@ -8038,22 +8041,22 @@ async function whoAmI(_resource, userName, http) {
8038
8041
  body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
8039
8042
  operation: "resources.whoAmI"
8040
8043
  });
8041
- const matches = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
8044
+ const matches = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
8042
8045
  if (matches.length === 0) return null;
8043
8046
  if (matches.length > 1) {
8044
8047
  const ids = matches.map((m) => m.id).filter((id) => typeof id === "number");
8045
- throw new (0, _chunkMAYYTYV5cjs.ResolutionError)(
8048
+ throw new (0, _chunkWRWX6WIKcjs.ResolutionError)(
8046
8049
  `whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
8047
- { code: "RESOLUTION_AMBIGUOUS", resourceIds: ids }
8050
+ { code: "RESOLUTION_AMBIGUOUS", resourceIds: ids, details: { idRefs: ids.map((cid) => ({ entity: "resource", id: cid })) } }
8048
8051
  );
8049
8052
  }
8050
8053
  return matches[0];
8051
8054
  }
8052
8055
  async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
8053
8056
  const ids = requirePositiveIds(companyIds, "transferOwnership");
8054
- const destination = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
8057
+ const destination = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
8055
8058
  if (typeof destination === "number" && destination < 1) {
8056
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
8059
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
8057
8060
  }
8058
8061
  const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _53 => _53.dryRun]), () => ( true));
8059
8062
  const changes = [];
@@ -8066,7 +8069,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8066
8069
  operation: "resources.transferOwnership",
8067
8070
  maxRetries: _optionalChain([opts, 'optionalAccess', _54 => _54.maxRetries])
8068
8071
  });
8069
- const company = _chunkMAYYTYV5cjs.unwrapItem.call(void 0, res, id);
8072
+ const company = _chunkWRWX6WIKcjs.unwrapItem.call(void 0, res, id, void 0, "company");
8070
8073
  const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
8071
8074
  changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
8072
8075
  if (!dryRun) {
@@ -8077,12 +8080,13 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8077
8080
  operation: "resources.transferOwnership",
8078
8081
  maxRetries: _optionalChain([opts, 'optionalAccess', _55 => _55.maxRetries])
8079
8082
  });
8080
- _chunkMAYYTYV5cjs.unwrapOperation.call(void 0, update);
8083
+ _chunkWRWX6WIKcjs.unwrapOperation.call(void 0, update);
8081
8084
  applied.push(id);
8082
8085
  }
8083
8086
  } catch (err) {
8084
- if (!dryRun && err instanceof _chunkMAYYTYV5cjs.AutotaskError) {
8087
+ if (!dryRun && err instanceof _chunkWRWX6WIKcjs.AutotaskError) {
8085
8088
  err.resourceIds = [id];
8089
+ err.details = _chunkWRWX6WIKcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
8086
8090
  err.suggestedAction = `Partial transfer: ${applied.length} of ${ids.length} companies were re-owned (ids: ${applied.join(", ") || "none"}); id ${id} failed. Re-run transferOwnership for the remaining ids (from ${id} on).`;
8087
8091
  }
8088
8092
  throw err;
@@ -8091,7 +8095,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8091
8095
  if (dryRun) {
8092
8096
  const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
8093
8097
  return {
8094
- ..._chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
8098
+ ..._chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
8095
8099
  operation: "resources.transferOwnership",
8096
8100
  method: "PUT",
8097
8101
  path: "/V1.0/Companies",
@@ -8115,7 +8119,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8115
8119
  }
8116
8120
 
8117
8121
  // src/resources/resources.ts
8118
- var ResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8122
+ var ResourcesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8119
8123
 
8120
8124
  constructor(http, clientConfig, pageSize) {
8121
8125
  super(http, {
@@ -8188,7 +8192,7 @@ var ResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8188
8192
 
8189
8193
  // src/resources/special/resource_time_off_additional.ts
8190
8194
  async function getByResource(_resource, resourceId, http) {
8191
- const numericResource = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8195
+ const numericResource = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8192
8196
  const res = await http.request({
8193
8197
  method: "GET",
8194
8198
  path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
@@ -8202,11 +8206,11 @@ async function getByResource(_resource, resourceId, http) {
8202
8206
  if (typeof item === "object" && !Array.isArray(item)) return [item];
8203
8207
  }
8204
8208
  }
8205
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
8209
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
8206
8210
  }
8207
8211
 
8208
8212
  // src/resources/resource_time_off_additional.ts
8209
- var ResourceTimeOffAdditionalResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8213
+ var ResourceTimeOffAdditionalResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8210
8214
  constructor(http, pageSize) {
8211
8215
  super(http, {
8212
8216
  key: "resource_time_off_additional",
@@ -8245,7 +8249,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkMAYYTYV5cjs.BaseReso
8245
8249
  };
8246
8250
 
8247
8251
  // src/resources/resource_time_off_approvers.ts
8248
- var ResourceTimeOffApproversResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8252
+ var ResourceTimeOffApproversResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8249
8253
  constructor(http, pageSize) {
8250
8254
  super(http, {
8251
8255
  key: "resource_time_off_approvers",
@@ -8288,29 +8292,29 @@ var ResourceTimeOffApproversResource = class extends _chunkMAYYTYV5cjs.BaseResou
8288
8292
 
8289
8293
  // src/resources/special/resource_time_off_balances.ts
8290
8294
  async function getByResource2(_resource, resourceId, http) {
8291
- const numericResource = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8295
+ const numericResource = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8292
8296
  const res = await http.request({
8293
8297
  method: "GET",
8294
8298
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
8295
8299
  operation: "resource_time_off_balances.getByResource"
8296
8300
  });
8297
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
8301
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
8298
8302
  }
8299
8303
  async function getByYear(_resource, resourceId, year, http) {
8300
- const numericResource = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8304
+ const numericResource = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8301
8305
  if (!Number.isSafeInteger(year) || year < 1) {
8302
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("getByYear: year must be a positive integer");
8306
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
8303
8307
  }
8304
8308
  const res = await http.request({
8305
8309
  method: "GET",
8306
8310
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
8307
8311
  operation: "resource_time_off_balances.getByYear"
8308
8312
  });
8309
- return _chunkMAYYTYV5cjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear");
8313
+ return _chunkWRWX6WIKcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
8310
8314
  }
8311
8315
 
8312
8316
  // src/resources/resource_time_off_balances.ts
8313
- var ResourceTimeOffBalancesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8317
+ var ResourceTimeOffBalancesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8314
8318
  constructor(http, pageSize) {
8315
8319
  super(http, {
8316
8320
  key: "resource_time_off_balances",
@@ -8348,7 +8352,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkMAYYTYV5cjs.BaseResour
8348
8352
  };
8349
8353
 
8350
8354
  // src/resources/roles.ts
8351
- var RolesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8355
+ var RolesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8352
8356
  constructor(http, pageSize) {
8353
8357
  super(http, {
8354
8358
  key: "roles",
@@ -8415,7 +8419,7 @@ var RolesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8415
8419
  };
8416
8420
 
8417
8421
  // src/resources/service_calls.ts
8418
- var ServiceCallsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8422
+ var ServiceCallsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8419
8423
  constructor(http, pageSize) {
8420
8424
  super(http, {
8421
8425
  key: "service_calls",
@@ -8484,7 +8488,7 @@ var ServiceCallsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8484
8488
  };
8485
8489
 
8486
8490
  // src/resources/service_call_task_resources.ts
8487
- var ServiceCallTaskResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8491
+ var ServiceCallTaskResourcesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8488
8492
  constructor(http, pageSize) {
8489
8493
  super(http, {
8490
8494
  key: "service_call_task_resources",
@@ -8541,7 +8545,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResou
8541
8545
  };
8542
8546
 
8543
8547
  // src/resources/service_call_tasks.ts
8544
- var ServiceCallTasksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8548
+ var ServiceCallTasksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8545
8549
  constructor(http, pageSize) {
8546
8550
  super(http, {
8547
8551
  key: "service_call_tasks",
@@ -8598,7 +8602,7 @@ var ServiceCallTasksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8598
8602
  };
8599
8603
 
8600
8604
  // src/resources/service_call_ticket_resources.ts
8601
- var ServiceCallTicketResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8605
+ var ServiceCallTicketResourcesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8602
8606
  constructor(http, pageSize) {
8603
8607
  super(http, {
8604
8608
  key: "service_call_ticket_resources",
@@ -8655,7 +8659,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkMAYYTYV5cjs.BaseRes
8655
8659
  };
8656
8660
 
8657
8661
  // src/resources/service_call_tickets.ts
8658
- var ServiceCallTicketsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8662
+ var ServiceCallTicketsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8659
8663
  constructor(http, pageSize) {
8660
8664
  super(http, {
8661
8665
  key: "service_call_tickets",
@@ -8712,7 +8716,7 @@ var ServiceCallTicketsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8712
8716
  };
8713
8717
 
8714
8718
  // src/resources/service_level_agreement_results.ts
8715
- var ServiceLevelAgreementResultsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8719
+ var ServiceLevelAgreementResultsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8716
8720
  constructor(http, pageSize) {
8717
8721
  super(http, {
8718
8722
  key: "service_level_agreement_results",
@@ -8751,7 +8755,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkMAYYTYV5cjs.BaseR
8751
8755
  };
8752
8756
 
8753
8757
  // src/resources/services.ts
8754
- var ServicesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8758
+ var ServicesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8755
8759
  constructor(http, pageSize) {
8756
8760
  super(http, {
8757
8761
  key: "services",
@@ -8819,7 +8823,7 @@ var ServicesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8819
8823
  };
8820
8824
 
8821
8825
  // src/resources/skills.ts
8822
- var SkillsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8826
+ var SkillsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8823
8827
  constructor(http, pageSize) {
8824
8828
  super(http, {
8825
8829
  key: "skills",
@@ -8863,7 +8867,7 @@ var SkillsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8863
8867
  };
8864
8868
 
8865
8869
  // src/resources/subscription_periods.ts
8866
- var SubscriptionPeriodsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8870
+ var SubscriptionPeriodsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8867
8871
  constructor(http, pageSize) {
8868
8872
  super(http, {
8869
8873
  key: "subscription_periods",
@@ -8902,7 +8906,7 @@ var SubscriptionPeriodsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8902
8906
  };
8903
8907
 
8904
8908
  // src/resources/subscriptions.ts
8905
- var SubscriptionsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8909
+ var SubscriptionsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8906
8910
  constructor(http, pageSize) {
8907
8911
  super(http, {
8908
8912
  key: "subscriptions",
@@ -8971,7 +8975,7 @@ var SubscriptionsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8971
8975
  };
8972
8976
 
8973
8977
  // src/resources/survey_results.ts
8974
- var SurveyResultsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
8978
+ var SurveyResultsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
8975
8979
  constructor(http, pageSize) {
8976
8980
  super(http, {
8977
8981
  key: "survey_results",
@@ -9010,7 +9014,7 @@ var SurveyResultsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9010
9014
  };
9011
9015
 
9012
9016
  // src/resources/surveys.ts
9013
- var SurveysResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9017
+ var SurveysResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9014
9018
  constructor(http, pageSize) {
9015
9019
  super(http, {
9016
9020
  key: "surveys",
@@ -9054,7 +9058,7 @@ var SurveysResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9054
9058
  };
9055
9059
 
9056
9060
  // src/resources/tag_aliases.ts
9057
- var TagAliasesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9061
+ var TagAliasesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9058
9062
  constructor(http, pageSize) {
9059
9063
  super(http, {
9060
9064
  key: "tag_aliases",
@@ -9111,7 +9115,7 @@ var TagAliasesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9111
9115
  };
9112
9116
 
9113
9117
  // src/resources/tag_groups.ts
9114
- var TagGroupsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9118
+ var TagGroupsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9115
9119
  constructor(http, pageSize) {
9116
9120
  super(http, {
9117
9121
  key: "tag_groups",
@@ -9180,7 +9184,7 @@ var TagGroupsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9180
9184
  };
9181
9185
 
9182
9186
  // src/resources/tags.ts
9183
- var TagsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9187
+ var TagsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9184
9188
  constructor(http, pageSize) {
9185
9189
  super(http, {
9186
9190
  key: "tags",
@@ -9249,7 +9253,7 @@ var TagsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9249
9253
  };
9250
9254
 
9251
9255
  // src/resources/task_secondary_resources.ts
9252
- var TaskSecondaryResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9256
+ var TaskSecondaryResourcesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9253
9257
  constructor(http, pageSize) {
9254
9258
  super(http, {
9255
9259
  key: "task_secondary_resources",
@@ -9306,7 +9310,7 @@ var TaskSecondaryResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResourc
9306
9310
  };
9307
9311
 
9308
9312
  // src/resources/tasks.ts
9309
- var TasksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9313
+ var TasksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9310
9314
  constructor(http, pageSize) {
9311
9315
  super(http, {
9312
9316
  key: "tasks",
@@ -9394,7 +9398,7 @@ var ThresholdInformationResource = class {
9394
9398
  };
9395
9399
 
9396
9400
  // src/resources/ticket_additional_configuration_items.ts
9397
- var TicketAdditionalConfigurationItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9401
+ var TicketAdditionalConfigurationItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9398
9402
  constructor(http, pageSize) {
9399
9403
  super(http, {
9400
9404
  key: "ticket_additional_configuration_items",
@@ -9451,7 +9455,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkMAYYTYV5cjs
9451
9455
  };
9452
9456
 
9453
9457
  // src/resources/ticket_additional_contacts.ts
9454
- var TicketAdditionalContactsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9458
+ var TicketAdditionalContactsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9455
9459
  constructor(http, pageSize) {
9456
9460
  super(http, {
9457
9461
  key: "ticket_additional_contacts",
@@ -9508,7 +9512,7 @@ var TicketAdditionalContactsResource = class extends _chunkMAYYTYV5cjs.BaseResou
9508
9512
  };
9509
9513
 
9510
9514
  // src/resources/ticket_attachments.ts
9511
- var TicketAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9515
+ var TicketAttachmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9512
9516
  constructor(http, pageSize) {
9513
9517
  super(http, {
9514
9518
  key: "ticket_attachments",
@@ -9570,7 +9574,7 @@ var TicketAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9570
9574
  };
9571
9575
 
9572
9576
  // src/resources/ticket_categories.ts
9573
- var TicketCategoriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9577
+ var TicketCategoriesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9574
9578
  constructor(http, pageSize) {
9575
9579
  super(http, {
9576
9580
  key: "ticket_categories",
@@ -9629,7 +9633,7 @@ var TicketCategoriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9629
9633
  };
9630
9634
 
9631
9635
  // src/resources/ticket_category_field_defaults.ts
9632
- var TicketCategoryFieldDefaultsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9636
+ var TicketCategoryFieldDefaultsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9633
9637
  constructor(http, pageSize) {
9634
9638
  super(http, {
9635
9639
  key: "ticket_category_field_defaults",
@@ -9671,7 +9675,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkMAYYTYV5cjs.BaseRe
9671
9675
  };
9672
9676
 
9673
9677
  // src/resources/ticket_change_request_approvals.ts
9674
- var TicketChangeRequestApprovalsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9678
+ var TicketChangeRequestApprovalsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9675
9679
  constructor(http, pageSize) {
9676
9680
  super(http, {
9677
9681
  key: "ticket_change_request_approvals",
@@ -9728,7 +9732,7 @@ var TicketChangeRequestApprovalsResource = class extends _chunkMAYYTYV5cjs.BaseR
9728
9732
  };
9729
9733
 
9730
9734
  // src/resources/ticket_charges.ts
9731
- var TicketChargesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9735
+ var TicketChargesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9732
9736
  constructor(http, pageSize) {
9733
9737
  super(http, {
9734
9738
  key: "ticket_charges",
@@ -9799,7 +9803,7 @@ var TicketChargesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9799
9803
  };
9800
9804
 
9801
9805
  // src/resources/ticket_checklist_items.ts
9802
- var TicketChecklistItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9806
+ var TicketChecklistItemsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9803
9807
  constructor(http, pageSize) {
9804
9808
  super(http, {
9805
9809
  key: "ticket_checklist_items",
@@ -9865,7 +9869,7 @@ var TicketChecklistItemsResource = class extends _chunkMAYYTYV5cjs.BaseResource
9865
9869
  };
9866
9870
 
9867
9871
  // src/resources/ticket_checklist_libraries.ts
9868
- var TicketChecklistLibrariesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9872
+ var TicketChecklistLibrariesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9869
9873
  constructor(http, pageSize) {
9870
9874
  super(http, {
9871
9875
  key: "ticket_checklist_libraries",
@@ -9889,9 +9893,9 @@ var TicketChecklistLibrariesResource = class extends _chunkMAYYTYV5cjs.BaseResou
9889
9893
  * `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
9890
9894
  * surface — no documents read op — and never issues the POST). */
9891
9895
  async attachToDocument(documentID, data, opts = {}) {
9892
- const n = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, documentID, "documentID");
9896
+ const n = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, documentID, "documentID");
9893
9897
  if (opts.dryRun === true) {
9894
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
9898
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
9895
9899
  operation: "ticket_checklist_libraries.attachToDocument",
9896
9900
  method: "POST",
9897
9901
  path: `/V1.0/Documents/${n}/ChecklistLibraries`,
@@ -9909,7 +9913,7 @@ var TicketChecklistLibrariesResource = class extends _chunkMAYYTYV5cjs.BaseResou
9909
9913
  operation: "ticket_checklist_libraries.attachToDocument",
9910
9914
  maxRetries: opts.maxRetries
9911
9915
  });
9912
- return _chunkMAYYTYV5cjs.unwrapOperation.call(void 0, res);
9916
+ return _chunkWRWX6WIKcjs.unwrapOperation.call(void 0, res);
9913
9917
  }
9914
9918
  /** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
9915
9919
  * from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
@@ -9925,7 +9929,7 @@ var TicketChecklistLibrariesResource = class extends _chunkMAYYTYV5cjs.BaseResou
9925
9929
  };
9926
9930
 
9927
9931
  // src/resources/ticket_history.ts
9928
- var TicketHistoryResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9932
+ var TicketHistoryResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9929
9933
  constructor(http, pageSize) {
9930
9934
  super(http, {
9931
9935
  key: "ticket_history",
@@ -9964,7 +9968,7 @@ var TicketHistoryResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9964
9968
  };
9965
9969
 
9966
9970
  // src/resources/ticket_note_attachments.ts
9967
- var TicketNoteAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
9971
+ var TicketNoteAttachmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
9968
9972
  constructor(http, pageSize) {
9969
9973
  super(http, {
9970
9974
  key: "ticket_note_attachments",
@@ -10026,7 +10030,7 @@ var TicketNoteAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource
10026
10030
  };
10027
10031
 
10028
10032
  // src/resources/ticket_notes.ts
10029
- var TicketNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
10033
+ var TicketNotesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
10030
10034
  constructor(http, pageSize) {
10031
10035
  super(http, {
10032
10036
  key: "ticket_notes",
@@ -10085,7 +10089,7 @@ var TicketNotesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
10085
10089
  };
10086
10090
 
10087
10091
  // src/resources/ticket_note_webhooks.ts
10088
- var TicketNoteWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
10092
+ var TicketNoteWebhooksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
10089
10093
  constructor(http, pageSize) {
10090
10094
  super(http, {
10091
10095
  key: "ticket_note_webhooks",
@@ -10161,7 +10165,7 @@ var TicketNoteWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
10161
10165
  };
10162
10166
 
10163
10167
  // src/resources/ticket_secondary_resources.ts
10164
- var TicketSecondaryResourcesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
10168
+ var TicketSecondaryResourcesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
10165
10169
  constructor(http, pageSize) {
10166
10170
  super(http, {
10167
10171
  key: "ticket_secondary_resources",
@@ -10228,9 +10232,9 @@ async function fetchTicket(http, id, operation) {
10228
10232
  });
10229
10233
  const body = res;
10230
10234
  if (body === null || !("item" in body)) {
10231
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id] });
10235
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
10232
10236
  }
10233
- if (body.item === null || body.item === void 0) throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id] });
10237
+ if (body.item === null || body.item === void 0) throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
10234
10238
  return body.item;
10235
10239
  }
10236
10240
  async function ticketQueryItems(http, path, filter, maxRecords, operation) {
@@ -10241,29 +10245,29 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
10241
10245
  body: { MaxRecords: maxRecords, filter },
10242
10246
  operation
10243
10247
  });
10244
- return _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res).items;
10248
+ return _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res).items;
10245
10249
  }
10246
10250
  function isRouteUnavailable(err) {
10247
- return _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
10251
+ return _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
10248
10252
  }
10249
10253
  function routeFact(route, path, err) {
10250
10254
  return {
10251
10255
  route,
10252
10256
  path,
10253
- httpStatus: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
10257
+ httpStatus: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
10254
10258
  };
10255
10259
  }
10256
10260
  function childDeclaresQuery(resourceKey) {
10257
- return _chunkEWMG3HHUcjs.CAPABILITIES.some(
10261
+ return _chunk5O5EPYBOcjs.CAPABILITIES.some(
10258
10262
  (c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
10259
10263
  );
10260
10264
  }
10261
10265
  function planScopedPath(resourceKey, ticketId) {
10262
10266
  if (!childDeclaresQuery(resourceKey)) return null;
10263
- const entry = _chunkMAYYTYV5cjs.RELATIONSHIP_MAP[resourceKey];
10267
+ const entry = _chunkWRWX6WIKcjs.RELATIONSHIP_MAP[resourceKey];
10264
10268
  const parent = entry === void 0 ? null : entry.parent;
10265
10269
  if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
10266
- const parentPath = _optionalChain([_chunkMAYYTYV5cjs.RELATIONSHIP_MAP, 'access', _56 => _56[parent.resource], 'optionalAccess', _57 => _57.path]);
10270
+ const parentPath = _optionalChain([_chunkWRWX6WIKcjs.RELATIONSHIP_MAP, 'access', _56 => _56[parent.resource], 'optionalAccess', _57 => _57.path]);
10267
10271
  if (parentPath === null || parentPath === void 0) return null;
10268
10272
  return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
10269
10273
  }
@@ -10302,14 +10306,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
10302
10306
  break;
10303
10307
  }
10304
10308
  const body = await http.request({ method: "GET", path: target, operation });
10305
- const { items: pageItems, pageDetails } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, body, operation);
10309
+ const { items: pageItems, pageDetails } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, body, operation);
10306
10310
  nextCursor = pageDetails.nextPageUrl;
10307
10311
  pages += 1;
10308
10312
  const window = pageItems.slice(0, Math.max(0, limit - items.length));
10309
10313
  for (const row of window) if (accept(row)) items.push(row);
10310
10314
  if (items.length >= limit) break;
10311
10315
  if (nextCursor === null || pageItems.length === 0) break;
10312
- target = _chunkMAYYTYV5cjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
10316
+ target = _chunkWRWX6WIKcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
10313
10317
  }
10314
10318
  const capped = items.length >= limit || guard && nextCursor !== null;
10315
10319
  return { items, capped };
@@ -10343,7 +10347,7 @@ function truncate(text, limit) {
10343
10347
  }
10344
10348
  async function slaHealthCheck(_resource, id, opts = {}, http) {
10345
10349
  void opts;
10346
- const ticketId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
10350
+ const ticketId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
10347
10351
  await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
10348
10352
  const rows = await ticketQueryItems(
10349
10353
  http,
@@ -10368,9 +10372,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
10368
10372
  async function summary(_resource, id, opts = {}, http) {
10369
10373
  const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
10370
10374
  if (!Number.isInteger(limit) || limit < 1) {
10371
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
10375
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
10372
10376
  }
10373
- const ticketId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
10377
+ const ticketId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
10374
10378
  const ticket = await fetchTicket(http, ticketId, "tickets.summary");
10375
10379
  const desc = truncate(ticket.description, limit);
10376
10380
  const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
@@ -10397,13 +10401,13 @@ async function summary(_resource, id, opts = {}, http) {
10397
10401
  }
10398
10402
  async function timeline(_resource, id, opts = {}, http) {
10399
10403
  const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
10400
- if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
10404
+ if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
10401
10405
  const bounded = Math.min(limit, 500);
10402
10406
  const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
10403
10407
  if (!Number.isInteger(textLimit) || textLimit < 1) {
10404
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
10408
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
10405
10409
  }
10406
- const ticketId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
10410
+ const ticketId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
10407
10411
  await fetchTicket(http, ticketId, "tickets.timeline");
10408
10412
  const dateFilters = (field) => {
10409
10413
  const f = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -10490,14 +10494,14 @@ function isPositiveInt(v) {
10490
10494
  return typeof v === "number" && Number.isInteger(v) && v > 0;
10491
10495
  }
10492
10496
  function namedVendorFields(err) {
10493
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
10494
- const entries = _nullishCoalesce(_chunkMAYYTYV5cjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
10497
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
10498
+ const entries = _nullishCoalesce(_chunkWRWX6WIKcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
10495
10499
  const out = /* @__PURE__ */ new Set();
10496
10500
  for (const e of entries) if (e.field !== void 0) out.add(e.field);
10497
10501
  return [...out];
10498
10502
  }
10499
10503
  function vendorDetailOf(err) {
10500
- return _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? _chunkMAYYTYV5cjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
10504
+ return _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? _chunkWRWX6WIKcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
10501
10505
  }
10502
10506
  async function fetchItem(http, path, operation, readOpts) {
10503
10507
  const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _58 => _58.maxRetries]) });
@@ -10518,8 +10522,8 @@ function operationId(res) {
10518
10522
  return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
10519
10523
  }
10520
10524
  function discoveryMerge(err, body, defaults) {
10521
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
10522
- const entries = _chunkMAYYTYV5cjs.parseVendorErrors.call(void 0, err.vendorError);
10525
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
10526
+ const entries = _chunkWRWX6WIKcjs.parseVendorErrors.call(void 0, err.vendorError);
10523
10527
  if (entries === void 0) return null;
10524
10528
  for (const entry of entries) {
10525
10529
  const field = entry.field;
@@ -10531,7 +10535,7 @@ function discoveryMerge(err, body, defaults) {
10531
10535
  }
10532
10536
  function stepErrorText(code, err) {
10533
10537
  const detail = vendorDetailOf(err);
10534
- const base = _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
10538
+ const base = _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
10535
10539
  return detail ? `${code}: ${detail}` : `${code}: ${base}`;
10536
10540
  }
10537
10541
  var DEFAULT_TICKET_PRIORITY = 3;
@@ -10540,7 +10544,7 @@ var DEFAULT_NOTE_TYPE = 1;
10540
10544
  var DEFAULT_PUBLISH = 1;
10541
10545
  var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
10542
10546
  var SAFE_TICKET_CREATE_DEFAULTS = {};
10543
- var QueueRequiredError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10547
+ var QueueRequiredError = class extends _chunkWRWX6WIKcjs.AutotaskError {
10544
10548
  constructor(message, options = {}) {
10545
10549
  super(message, {
10546
10550
  code: "QUEUE_REQUIRED",
@@ -10551,13 +10555,13 @@ var QueueRequiredError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10551
10555
  this.name = "QueueRequiredError";
10552
10556
  }
10553
10557
  };
10554
- var TicketResourceInvalidError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10558
+ var TicketResourceInvalidError = class extends _chunkWRWX6WIKcjs.AutotaskError {
10555
10559
  constructor(message, options = {}) {
10556
10560
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
10557
10561
  this.name = "TicketResourceInvalidError";
10558
10562
  }
10559
10563
  };
10560
- var TicketCreateValidationFailedError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10564
+ var TicketCreateValidationFailedError = class extends _chunkWRWX6WIKcjs.AutotaskError {
10561
10565
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
10562
10566
 
10563
10567
  constructor(message, vendorFields, options = {}) {
@@ -10567,43 +10571,43 @@ var TicketCreateValidationFailedError = class extends _chunkMAYYTYV5cjs.Autotask
10567
10571
  }
10568
10572
  };
10569
10573
  async function openWithNoteAndAssign(resource, params, note, assign, opts, http) {
10570
- const companyID = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _60 => _60.companyID]), "params.companyID");
10574
+ const companyID = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _60 => _60.companyID]), "params.companyID");
10571
10575
  const title = _optionalChain([params, 'optionalAccess', _61 => _61.title]);
10572
10576
  if (typeof title !== "string" || title.trim() === "") {
10573
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
10577
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
10574
10578
  }
10575
10579
  const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
10576
10580
  const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
10577
10581
  if (!isPositiveInt(priority)) {
10578
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
10582
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
10579
10583
  }
10580
10584
  if (!isPositiveInt(status)) {
10581
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
10585
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
10582
10586
  }
10583
10587
  if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
10584
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
10588
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
10585
10589
  }
10586
10590
  if (note !== void 0) {
10587
10591
  if (typeof note.description !== "string" || note.description.trim() === "") {
10588
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
10592
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
10589
10593
  }
10590
10594
  if (typeof note.title !== "string" || note.title.trim() === "") {
10591
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("openWithNoteAndAssign: note.title is required (a non-empty string) \u2014 the ww29 scoped note create 500s without it (S12-A live-verified: Missing Required Field: title; the S11-B proven note body is { title, description, noteType: 1, publish: 1 })", { operation: OP_OPEN });
10595
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("openWithNoteAndAssign: note.title is required (a non-empty string) \u2014 the ww29 scoped note create 500s without it (S12-A live-verified: Missing Required Field: title; the S11-B proven note body is { title, description, noteType: 1, publish: 1 })", { operation: OP_OPEN });
10592
10596
  }
10593
10597
  if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
10594
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
10598
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
10595
10599
  }
10596
10600
  if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
10597
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
10601
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
10598
10602
  }
10599
10603
  }
10600
- const assignee = assign === void 0 ? void 0 : _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
10604
+ const assignee = assign === void 0 ? void 0 : _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
10601
10605
  if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
10602
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
10606
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
10603
10607
  }
10604
10608
  const roleID = _optionalChain([assign, 'optionalAccess', _62 => _62.roleID]);
10605
10609
  if (assign !== void 0 && !isPositiveInt(roleID)) {
10606
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("openWithNoteAndAssign: assign.roleID is required (a positive integer) \u2014 the ww29 vendor requires BOTH assignedResourceID and assignedResourceRoleID when assigning a resource (S12-A live-verified: Data violation: When assigning a Resource, you must assign both a assignedResourceID and assignedResourceRoleID)", { operation: OP_OPEN });
10610
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("openWithNoteAndAssign: assign.roleID is required (a positive integer) \u2014 the ww29 vendor requires BOTH assignedResourceID and assignedResourceRoleID when assigning a resource (S12-A live-verified: Data violation: When assigning a Resource, you must assign both a assignedResourceID and assignedResourceRoleID)", { operation: OP_OPEN });
10607
10611
  }
10608
10612
  if (assign !== void 0 && assignee !== void 0) {
10609
10613
  const rid = assignee;
@@ -10611,13 +10615,13 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
10611
10615
  if (rec === null) {
10612
10616
  throw new TicketResourceInvalidError(
10613
10617
  `openWithNoteAndAssign: assignee resource ${assignee} was not found (resources.get returned item: null \u2014 the resources table is blind to the API user; get is the authority)`,
10614
- { resourceIds: [rid], operation: OP_OPEN, category: "not_found", suggestedAction: "Resolve the resource id (a ticket assignedResourceID via tickets.fullContext) and retry." }
10618
+ { resourceIds: [rid], details: { idRefs: [{ entity: "resource", id: rid }] }, operation: OP_OPEN, category: "not_found", suggestedAction: "Resolve the resource id (a ticket assignedResourceID via tickets.fullContext) and retry." }
10615
10619
  );
10616
10620
  }
10617
10621
  if (rec.isActive !== true) {
10618
10622
  throw new TicketResourceInvalidError(
10619
10623
  `openWithNoteAndAssign: assignee resource ${assignee} is not active (isActive !== true) \u2014 the vendor would reject the assignment`,
10620
- { resourceIds: [rid], operation: OP_OPEN, suggestedAction: "Activate the resource or assign an active one." }
10624
+ { resourceIds: [rid], details: { idRefs: [{ entity: "resource", id: rid }] }, operation: OP_OPEN, suggestedAction: "Activate the resource or assign an active one." }
10621
10625
  );
10622
10626
  }
10623
10627
  }
@@ -10638,7 +10642,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
10638
10642
  if (assign !== void 0) {
10639
10643
  warnings.push(`the assignment is the v0.6.0 MERGE update (unredacted GET + collection PUT, 2 wire) setting assignedResourceID ${String(assignee)} + assignedResourceRoleID ${String(roleID)} (the vendor requires both \u2014 S12-A live-verified); a failure lands in steps[] as ASSIGN_FAILED (the applied ticketId is still returned).`);
10640
10644
  }
10641
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
10645
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
10642
10646
  {
10643
10647
  operation: OP_OPEN,
10644
10648
  method: "POST",
@@ -10680,8 +10684,8 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
10680
10684
  `openWithNoteAndAssign: the vendor rejected the ticket create naming 'queueID' (the ww29 live-required set is { title, status, priority, companyID, queueID }) and the node never guesses a queue${detail ? ` \u2014 ${detail}` : ""}`,
10681
10685
  {
10682
10686
  operation: OP_OPEN,
10683
- httpStatus: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
10684
- vendorError: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
10687
+ httpStatus: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
10688
+ vendorError: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
10685
10689
  }
10686
10690
  );
10687
10691
  }
@@ -10696,9 +10700,10 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
10696
10700
  named,
10697
10701
  {
10698
10702
  operation: OP_OPEN,
10699
- httpStatus: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
10700
- vendorError: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
10701
- resourceIds: [companyID]
10703
+ httpStatus: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
10704
+ vendorError: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
10705
+ resourceIds: [companyID],
10706
+ details: { idRefs: [{ entity: "company", id: companyID }] }
10702
10707
  }
10703
10708
  );
10704
10709
  }
@@ -10719,10 +10724,10 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
10719
10724
  try {
10720
10725
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
10721
10726
  if (current === null) {
10722
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId] });
10727
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
10723
10728
  }
10724
10729
  ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
10725
- const merged = _chunkMAYYTYV5cjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
10730
+ const merged = _chunkWRWX6WIKcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
10726
10731
  merged.id = ticketId;
10727
10732
  await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
10728
10733
  assigned = true;
@@ -10743,7 +10748,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
10743
10748
  var STATUS_REQUIRED_FIELDS = {
10744
10749
  // <discovery output lands here — e.g. 8: { requiredFields: ['dueDateTime'], safeDefaults: { dueDateTime: '<now>' } }>
10745
10750
  };
10746
- var StatusUnknownError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10751
+ var StatusUnknownError = class extends _chunkWRWX6WIKcjs.AutotaskError {
10747
10752
  /** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
10748
10753
 
10749
10754
  constructor(message, options = {}) {
@@ -10757,7 +10762,7 @@ var StatusUnknownError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10757
10762
  this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
10758
10763
  }
10759
10764
  };
10760
- var StatusFieldsRequiredError = class extends _chunkMAYYTYV5cjs.AutotaskError {
10765
+ var StatusFieldsRequiredError = class extends _chunkWRWX6WIKcjs.AutotaskError {
10761
10766
 
10762
10767
 
10763
10768
 
@@ -10786,16 +10791,16 @@ async function readLiveStatusSet(resource) {
10786
10791
  }
10787
10792
  var GUARD_DEGRADED_WARNING = "the tenant's live status picklist metadata was unavailable (the local guard is degraded for this call \u2014 the W-A4 wall or a metadata failure); the vendor's own validation is the final authority on the status value";
10788
10793
  async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10789
- const ticketId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
10794
+ const ticketId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
10790
10795
  if (!isPositiveInt(targetStatus)) {
10791
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
10796
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
10792
10797
  }
10793
10798
  let liveStatus = null;
10794
10799
  try {
10795
10800
  const ids = await readLiveStatusSet(resource);
10796
10801
  if (ids.size > 0) liveStatus = ids;
10797
10802
  } catch (err) {
10798
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
10803
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
10799
10804
  }
10800
10805
  if (liveStatus !== null && !liveStatus.has(targetStatus)) {
10801
10806
  _optionalChain([http, 'access', _63 => _63.fieldCache, 'optionalAccess', _64 => _64.invalidate, 'call', _65 => _65("tickets")]);
@@ -10805,7 +10810,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10805
10810
  const freshIds = await readLiveStatusSet(resource);
10806
10811
  if (freshIds.size > 0) freshStatus = freshIds;
10807
10812
  } catch (err) {
10808
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
10813
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
10809
10814
  freshStatus = null;
10810
10815
  reReadFailed = true;
10811
10816
  }
@@ -10822,16 +10827,16 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10822
10827
  }
10823
10828
  const guardDegraded = liveStatus === null;
10824
10829
  if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
10825
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
10830
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
10826
10831
  }
10827
10832
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
10828
10833
  if (current === null) {
10829
- throw new (0, _chunkMAYYTYV5cjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId] });
10834
+ throw new (0, _chunkWRWX6WIKcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
10830
10835
  }
10831
10836
  const previousStatus = typeof current.status === "number" ? current.status : null;
10832
10837
  if (previousStatus === targetStatus) {
10833
10838
  if (opts.dryRun === true) {
10834
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
10839
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
10835
10840
  {
10836
10841
  operation: OP_STATUS,
10837
10842
  method: "PUT",
@@ -10869,7 +10874,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10869
10874
  throw new StatusFieldsRequiredError(
10870
10875
  `changeStatus: status ${targetStatus} requires the field '${field}' and the live-discovered map has no proven-safe default for it \u2014 the op is safe-without-the-map (never a blind full update): supply the value in fields and retry`,
10871
10876
  { vendorFields: [field], currentStatus: previousStatus, targetStatus, currentValues: { [field]: _nullishCoalesce(current[field], () => ( null)) } },
10872
- { operation: OP_STATUS, resourceIds: [ticketId] }
10877
+ { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } }
10873
10878
  );
10874
10879
  }
10875
10880
  mergeData[field] = safe;
@@ -10885,7 +10890,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10885
10890
  if (mapEntry === void 0) {
10886
10891
  warnings.push(`status ${targetStatus} has no entry in the live-discovered required-field map yet \u2014 if the vendor 500 names a required field without a safe default, the apply throws the typed STATUS_FIELDS_REQUIRED (the caller supplies the value; never a blind retry).`);
10887
10892
  }
10888
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
10893
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
10889
10894
  {
10890
10895
  operation: OP_STATUS,
10891
10896
  method: "PUT",
@@ -10904,7 +10909,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10904
10909
  );
10905
10910
  }
10906
10911
  const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _68 => _68.safeDefaults]), () => ( {}));
10907
- const body = _chunkMAYYTYV5cjs.mergePartialBody.call(void 0, current, mergeData);
10912
+ const body = _chunkWRWX6WIKcjs.mergePartialBody.call(void 0, current, mergeData);
10908
10913
  body.id = ticketId;
10909
10914
  let merges = 0;
10910
10915
  for (; ; ) {
@@ -10928,9 +10933,10 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10928
10933
  { vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
10929
10934
  {
10930
10935
  operation: OP_STATUS,
10931
- httpStatus: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
10932
- vendorError: _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
10933
- resourceIds: [ticketId]
10936
+ httpStatus: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
10937
+ vendorError: _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
10938
+ resourceIds: [ticketId],
10939
+ details: { idRefs: [{ entity: "ticket", id: ticketId }] }
10934
10940
  }
10935
10941
  );
10936
10942
  }
@@ -10939,16 +10945,17 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10939
10945
  }
10940
10946
  const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
10941
10947
  if (verify === null) {
10942
- throw new (0, _chunkMAYYTYV5cjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
10948
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
10943
10949
  code: "INVALID_RESPONSE",
10944
10950
  category: "server",
10945
10951
  operation: OP_STATUS,
10946
- resourceIds: [ticketId]
10952
+ resourceIds: [ticketId],
10953
+ details: { idRefs: [{ entity: "ticket", id: ticketId }] }
10947
10954
  });
10948
10955
  }
10949
10956
  const finalStatus = typeof verify.status === "number" ? verify.status : null;
10950
10957
  if (finalStatus !== targetStatus) {
10951
- throw new (0, _chunkMAYYTYV5cjs.AutotaskError)(
10958
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskError)(
10952
10959
  `changeStatus: the post-PUT read-back shows status ${_nullishCoalesce(finalStatus, () => ( "unknown"))} (the vendor 200ed the PUT but did not apply ${targetStatus} \u2014 the F-A1 lesson: the 200 proves nothing)`,
10953
10960
  {
10954
10961
  code: "INVALID_RESPONSE",
@@ -10956,6 +10963,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
10956
10963
  httpStatus: 200,
10957
10964
  operation: OP_STATUS,
10958
10965
  resourceIds: [ticketId],
10966
+ details: { idRefs: [{ entity: "ticket", id: ticketId }] },
10959
10967
  suggestedAction: "Re-run changeStatus (the merge re-reads the current record) or inspect the ticket (tickets.get)."
10960
10968
  }
10961
10969
  );
@@ -10966,7 +10974,7 @@ var DEFAULT_PART_LIMIT = 50;
10966
10974
  function partLimit(value, name) {
10967
10975
  const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
10968
10976
  if (!Number.isInteger(n) || n < 1) {
10969
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
10977
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
10970
10978
  }
10971
10979
  return n;
10972
10980
  }
@@ -10982,7 +10990,7 @@ async function fullContext(resource, id, opts = {}, http) {
10982
10990
  const noteLimit = partLimit(opts.noteLimit, "noteLimit");
10983
10991
  const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
10984
10992
  const textLimit = partLimit(opts.textLimit, "textLimit");
10985
- const ticketId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
10993
+ const ticketId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
10986
10994
  const ctx = await resource.getContext(ticketId);
10987
10995
  const op = "tickets.fullContext";
10988
10996
  const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -11036,7 +11044,7 @@ async function fullContext(resource, id, opts = {}, http) {
11036
11044
  result.truncated = result.truncated || part.capped || historyRows.some((h) => h.detailTruncated === true);
11037
11045
  }
11038
11046
  if (opts.names === true) {
11039
- const builder = _chunkMAYYTYV5cjs.createNamePlan.call(void 0, _chunkMAYYTYV5cjs.TICKET_LABEL_FIELDS);
11047
+ const builder = _chunkWRWX6WIKcjs.createNamePlan.call(void 0, _chunkWRWX6WIKcjs.TICKET_LABEL_FIELDS);
11040
11048
  const t = ctx.ticket;
11041
11049
  builder.addResource(t["creatorResourceID"]);
11042
11050
  builder.addFk("contract", t["contractID"]);
@@ -11048,20 +11056,20 @@ async function fullContext(resource, id, opts = {}, http) {
11048
11056
  builder.addFk("billingCode", e["billingCodeID"]);
11049
11057
  builder.addFk("contract", e["contractID"]);
11050
11058
  }
11051
- const names = await _chunkMAYYTYV5cjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
11059
+ const names = await _chunkWRWX6WIKcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
11052
11060
  const ticketRow = { ...ctx.ticket };
11053
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
11054
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
11055
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
11056
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
11057
- for (const f of _chunkMAYYTYV5cjs.TICKET_LABEL_FIELDS) _chunkMAYYTYV5cjs.addLabelSibling.call(void 0, ticketRow, f, names);
11061
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
11062
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
11063
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
11064
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
11065
+ for (const f of _chunkWRWX6WIKcjs.TICKET_LABEL_FIELDS) _chunkWRWX6WIKcjs.addLabelSibling.call(void 0, ticketRow, f, names);
11058
11066
  result.ticket = ticketRow;
11059
11067
  result.timeEntries.items = entriesPart.items.map((e) => {
11060
11068
  const row = { ...e };
11061
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
11062
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
11063
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
11064
- _chunkMAYYTYV5cjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
11069
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
11070
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
11071
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
11072
+ _chunkWRWX6WIKcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
11065
11073
  return row;
11066
11074
  });
11067
11075
  result.names = names.section;
@@ -11071,7 +11079,7 @@ async function fullContext(resource, id, opts = {}, http) {
11071
11079
  }
11072
11080
 
11073
11081
  // src/resources/tickets.ts
11074
- var TicketsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11082
+ var TicketsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
11075
11083
  constructor(http, pageSize) {
11076
11084
  super(http, {
11077
11085
  key: "tickets",
@@ -11177,7 +11185,7 @@ var TicketsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11177
11185
  };
11178
11186
 
11179
11187
  // src/resources/ticket_webhooks.ts
11180
- var TicketWebhooksResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11188
+ var TicketWebhooksResource = class extends _chunkWRWX6WIKcjs.BaseResource {
11181
11189
  constructor(http, pageSize) {
11182
11190
  super(http, {
11183
11191
  key: "ticket_webhooks",
@@ -11263,7 +11271,7 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
11263
11271
  body: { MaxRecords: limit, filter },
11264
11272
  operation
11265
11273
  });
11266
- const { items, pageDetails } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res);
11274
+ const { items, pageDetails } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res);
11267
11275
  return { items, hasMore: pageDetails.nextPageUrl != null };
11268
11276
  }
11269
11277
  async function windowQuery3(_resource, kind, http, opts) {
@@ -11282,7 +11290,7 @@ async function customRange3(_resource, from, to, http, opts) {
11282
11290
  const fromB = customRangeDay(from, "from", zone, "customRange");
11283
11291
  const toB = customRangeDay(to, "to", zone, "customRange");
11284
11292
  if (fromB.ms > toB.ms) {
11285
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("customRange: from must not be after to");
11293
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("customRange: from must not be after to");
11286
11294
  }
11287
11295
  const toEndMs = zone === void 0 ? toB.ms + DAY_MS2 - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
11288
11296
  const filter = [
@@ -11307,7 +11315,7 @@ async function postedWithin(_resource, from, to, http, opts, opLabel = "time_ent
11307
11315
  const fromB = customRangeDay(from, "from", zone, OP2);
11308
11316
  const toB = customRangeDay(to, "to", zone, OP2);
11309
11317
  if (fromB.ms > toB.ms) {
11310
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(`${OP2}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP2 });
11318
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(`${OP2}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP2 });
11311
11319
  }
11312
11320
  const windowToMs = zone === void 0 ? toB.ms + DAY_MS2 - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
11313
11321
  const filter = [
@@ -11374,13 +11382,13 @@ var LINKAGE_OWNED_FIELDS = /* @__PURE__ */ new Set([
11374
11382
  "roleID"
11375
11383
  ]);
11376
11384
  var TIME_WINDOW_FIELDS = /* @__PURE__ */ new Set(["dateWorked", "startDateTime", "endDateTime", "hoursWorked"]);
11377
- var ResourceInvalidError = class extends _chunkMAYYTYV5cjs.AutotaskError {
11385
+ var ResourceInvalidError = class extends _chunkWRWX6WIKcjs.AutotaskError {
11378
11386
  constructor(message, options = {}) {
11379
11387
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
11380
11388
  this.name = "ResourceInvalidError";
11381
11389
  }
11382
11390
  };
11383
- var AllocationCodeError = class extends _chunkMAYYTYV5cjs.AutotaskError {
11391
+ var AllocationCodeError = class extends _chunkWRWX6WIKcjs.AutotaskError {
11384
11392
  /** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
11385
11393
 
11386
11394
  constructor(kind, message, options = {}) {
@@ -11389,7 +11397,7 @@ var AllocationCodeError = class extends _chunkMAYYTYV5cjs.AutotaskError {
11389
11397
  this.kind = kind;
11390
11398
  }
11391
11399
  };
11392
- var NoApplicableAllocationCodeError = class extends _chunkMAYYTYV5cjs.AutotaskError {
11400
+ var NoApplicableAllocationCodeError = class extends _chunkWRWX6WIKcjs.AutotaskError {
11393
11401
  /** The structured blocker details (filters tried + department sets). */
11394
11402
 
11395
11403
  constructor(details, options = {}) {
@@ -11405,7 +11413,7 @@ var NoApplicableAllocationCodeError = class extends _chunkMAYYTYV5cjs.AutotaskEr
11405
11413
  }
11406
11414
  );
11407
11415
  this.name = "NoApplicableAllocationCodeError";
11408
- this.details = details;
11416
+ this.details = { ...details, idRefs: [{ entity: "resource", id: details.resourceID }] };
11409
11417
  }
11410
11418
  };
11411
11419
  async function boundedQuery(http, path, filter, totalCap, operation) {
@@ -11415,7 +11423,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
11415
11423
  let pages = 0;
11416
11424
  for (; ; ) {
11417
11425
  if (pages >= PAGE_GUARD) {
11418
- throw new (0, _chunkMAYYTYV5cjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
11426
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
11419
11427
  code: "RESOLUTION_TRUNCATED",
11420
11428
  category: "resolution",
11421
11429
  operation,
@@ -11426,11 +11434,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
11426
11434
  const res = await http.request({
11427
11435
  method: "POST",
11428
11436
  idempotent: true,
11429
- path: isFirst ? path : _chunkMAYYTYV5cjs.cursorToPath.call(void 0, http.baseUrl, cursor),
11437
+ path: isFirst ? path : _chunkWRWX6WIKcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
11430
11438
  body: { MaxRecords: pageSize, filter },
11431
11439
  operation
11432
11440
  });
11433
- const { items: pageItems, pageDetails } = _chunkMAYYTYV5cjs.unwrapItems.call(void 0, res, operation);
11441
+ const { items: pageItems, pageDetails } = _chunkWRWX6WIKcjs.unwrapItems.call(void 0, res, operation);
11434
11442
  items.push(...pageItems);
11435
11443
  pages += 1;
11436
11444
  if (items.length >= totalCap) break;
@@ -11489,21 +11497,21 @@ async function resolveCode(http, family, familyLabel, pinnedId, departments, ope
11489
11497
  throw new AllocationCodeError(
11490
11498
  "NOT_FOUND",
11491
11499
  `Pinned allocation code ${pinnedId} was not found (billing_codes.get returned item: null)`,
11492
- { resourceIds: [pinnedId], operation, suggestedAction: `Resolve an existing ${familyLabel} allocation code id (billing_codes.query with a filter) and re-pin.` }
11500
+ { resourceIds: [pinnedId], details: { idRefs: [{ entity: "billing_code", id: pinnedId }] }, operation, suggestedAction: `Resolve an existing ${familyLabel} allocation code id (billing_codes.query with a filter) and re-pin.` }
11493
11501
  );
11494
11502
  }
11495
11503
  if (rec.isActive !== true) {
11496
11504
  throw new AllocationCodeError(
11497
11505
  "INACTIVE",
11498
11506
  `Pinned allocation code ${pinnedId} (${typeof rec.name === "string" ? rec.name : "unknown name"}) is not active (isActive !== true)`,
11499
- { resourceIds: [pinnedId], operation, suggestedAction: "Activate the code in the tenant administration or pin an active one." }
11507
+ { resourceIds: [pinnedId], details: { idRefs: [{ entity: "billing_code", id: pinnedId }] }, operation, suggestedAction: "Activate the code in the tenant administration or pin an active one." }
11500
11508
  );
11501
11509
  }
11502
11510
  if (rec.useType !== family) {
11503
11511
  throw new AllocationCodeError(
11504
11512
  "WRONG_TYPE",
11505
11513
  `Pinned allocation code ${pinnedId} is useType ${String(_nullishCoalesce(rec.useType, () => ( "unknown")))}, not the ${familyLabel} family (useType ${family})`,
11506
- { resourceIds: [pinnedId], operation, suggestedAction: `Pin a code from the right family (billing_codes.query with useType eq ${family} + isActive eq true).` }
11514
+ { resourceIds: [pinnedId], details: { idRefs: [{ entity: "billing_code", id: pinnedId }] }, operation, suggestedAction: `Pin a code from the right family (billing_codes.query with useType eq ${family} + isActive eq true).` }
11507
11515
  );
11508
11516
  }
11509
11517
  const dept = typeof rec.department === "number" ? rec.department : null;
@@ -11511,7 +11519,7 @@ async function resolveCode(http, family, familyLabel, pinnedId, departments, ope
11511
11519
  throw new AllocationCodeError(
11512
11520
  "NOT_APPLICABLE",
11513
11521
  `Pinned allocation code ${pinnedId} is scoped to department ${dept}, which is not among the resource's active role departments [${[...departments].sort((a, b) => a - b).join(", ")}] (and the code is not tenant-wide)`,
11514
- { resourceIds: [pinnedId], operation, suggestedAction: "Pin a tenant-wide (department null) code or one scoped to a resource department, or broaden the resource role assignments." }
11522
+ { resourceIds: [pinnedId], details: { idRefs: [{ entity: "billing_code", id: pinnedId }] }, operation, suggestedAction: "Pin a tenant-wide (department null) code or one scoped to a resource department, or broaden the resource role assignments." }
11515
11523
  );
11516
11524
  }
11517
11525
  return rec;
@@ -11543,8 +11551,8 @@ function windowDefaults(params) {
11543
11551
  };
11544
11552
  }
11545
11553
  async function createForResource(resource, resourceID, params, opts = {}, http) {
11546
- const rid = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, resourceID, "resourceID");
11547
- const pin = (value, label) => typeof value === "number" ? _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, value, label) : void 0;
11554
+ const rid = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
11555
+ const pin = (value, label) => typeof value === "number" ? _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, value, label) : void 0;
11548
11556
  const pins = {
11549
11557
  code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
11550
11558
  ticket: pin(params.ticketID, "ticketID"),
@@ -11553,19 +11561,19 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
11553
11561
  };
11554
11562
  const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
11555
11563
  if (pinCount > 1) {
11556
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
11564
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
11557
11565
  "createForResource: exactly one linkage pin is honoured (internallAllocationCodeID | ticketID | taskID) \u2014 the vendor gate requires exactly one; pass one pin (or none for the default internal linkage)",
11558
11566
  { operation: OP }
11559
11567
  );
11560
11568
  }
11561
11569
  if (pins.role !== void 0 && pins.code !== void 0) {
11562
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
11570
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
11563
11571
  "createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
11564
11572
  { operation: OP }
11565
11573
  );
11566
11574
  }
11567
11575
  if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
11568
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)(
11576
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)(
11569
11577
  `createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
11570
11578
  { operation: OP }
11571
11579
  );
@@ -11574,6 +11582,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
11574
11582
  if (rec === null) {
11575
11583
  throw new ResourceInvalidError(`Resource ${rid} was not found \u2014 a time entry cannot attach to a missing resource`, {
11576
11584
  resourceIds: [rid],
11585
+ details: { idRefs: [{ entity: "resource", id: rid }] },
11577
11586
  operation: OP,
11578
11587
  category: "not_found",
11579
11588
  suggestedAction: "Resolve the resource id (resources.get / resources.search) and retry."
@@ -11582,6 +11591,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
11582
11591
  if (rec.isActive !== true) {
11583
11592
  throw new ResourceInvalidError(`Resource ${rid} is not active (isActive !== true) \u2014 the vendor would reject a time entry for an inactive resource`, {
11584
11593
  resourceIds: [rid],
11594
+ details: { idRefs: [{ entity: "resource", id: rid }] },
11585
11595
  operation: OP,
11586
11596
  suggestedAction: "Activate the resource or pick an active one."
11587
11597
  });
@@ -11642,7 +11652,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
11642
11652
  if (usedLinkage === "internal" && linkage === "task") {
11643
11653
  warnings.push("the task had zero applicable general allocation codes \u2014 the linkage fell back to internal (the sanctioned fallback; no taskID/roleID in the body).");
11644
11654
  }
11645
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0,
11655
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0,
11646
11656
  {
11647
11657
  operation: OP,
11648
11658
  method: "POST",
@@ -11681,7 +11691,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
11681
11691
  };
11682
11692
  } catch (err) {
11683
11693
  lastError = err;
11684
- const text = _chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkMAYYTYV5cjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
11694
+ const text = _chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkWRWX6WIKcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
11685
11695
  const gate3 = ROLE_REJECTION_PATTERN.test(text);
11686
11696
  if (usedLinkage !== "internal" && gate3) {
11687
11697
  if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
@@ -11701,14 +11711,14 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
11701
11711
  throw err;
11702
11712
  }
11703
11713
  }
11704
- if (_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, lastError)) {
11714
+ if (_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, lastError)) {
11705
11715
  lastError.suggestedAction = (lastError.suggestedAction ? `${lastError.suggestedAction} ` : "") + `The createForResource attempt budget (${MAX_CREATE_ATTEMPTS} attempts: the role ladder + ${MAX_DISCOVERY_MERGES2} discovery merges) was exhausted \u2014 the vendor oracle rejected every candidate. Re-read the record/fields (operations.fieldCatalog, billing_codes.query with a filter) and retry with an explicit pin.`;
11706
11716
  }
11707
11717
  throw lastError;
11708
11718
  }
11709
11719
  function discoveryField(err, body, defaults) {
11710
- if (!_chunkMAYYTYV5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
11711
- const entries = _chunkMAYYTYV5cjs.parseVendorErrors.call(void 0, err.vendorError);
11720
+ if (!_chunkWRWX6WIKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
11721
+ const entries = _chunkWRWX6WIKcjs.parseVendorErrors.call(void 0, err.vendorError);
11712
11722
  if (entries === void 0) return null;
11713
11723
  for (const entry of entries) {
11714
11724
  const field = entry.field;
@@ -11721,7 +11731,7 @@ function discoveryField(err, body, defaults) {
11721
11731
  }
11722
11732
 
11723
11733
  // src/resources/time_entries.ts
11724
- var TimeEntriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11734
+ var TimeEntriesResource = class extends _chunkWRWX6WIKcjs.BaseResource {
11725
11735
  constructor(http, pageSize) {
11726
11736
  super(http, {
11727
11737
  key: "time_entries",
@@ -11858,7 +11868,7 @@ var TimeEntriesResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11858
11868
  };
11859
11869
 
11860
11870
  // src/resources/time_entry_attachments.ts
11861
- var TimeEntryAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11871
+ var TimeEntryAttachmentsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
11862
11872
  constructor(http, pageSize) {
11863
11873
  super(http, {
11864
11874
  key: "time_entry_attachments",
@@ -11921,9 +11931,9 @@ var TimeEntryAttachmentsResource = class extends _chunkMAYYTYV5cjs.BaseResource
11921
11931
 
11922
11932
  // src/resources/special/time_off_requests.ts
11923
11933
  async function approve(_resource, id, opts = {}, http) {
11924
- const numericId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
11934
+ const numericId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
11925
11935
  if (opts.dryRun === true) {
11926
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
11936
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
11927
11937
  operation: "time_off_requests.approve",
11928
11938
  method: "GET",
11929
11939
  path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
@@ -11939,16 +11949,16 @@ async function approve(_resource, id, opts = {}, http) {
11939
11949
  operation: "time_off_requests.approve",
11940
11950
  maxRetries: opts.maxRetries
11941
11951
  });
11942
- return _chunkMAYYTYV5cjs.unwrapOperation.call(void 0, res);
11952
+ return _chunkWRWX6WIKcjs.unwrapOperation.call(void 0, res);
11943
11953
  }
11944
11954
  async function reject(_resource, id, reason, opts = {}, http) {
11945
- const numericId = _chunkMAYYTYV5cjs.parseIdentifier.call(void 0, id, "id");
11955
+ const numericId = _chunkWRWX6WIKcjs.parseIdentifier.call(void 0, id, "id");
11946
11956
  const text = reason.trim();
11947
11957
  if (text === "") {
11948
- throw new (0, _chunkMAYYTYV5cjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
11958
+ throw new (0, _chunkWRWX6WIKcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
11949
11959
  }
11950
11960
  if (opts.dryRun === true) {
11951
- return _chunkMAYYTYV5cjs.buildDryRunResult.call(void 0, {
11961
+ return _chunkWRWX6WIKcjs.buildDryRunResult.call(void 0, {
11952
11962
  operation: "time_off_requests.reject",
11953
11963
  method: "POST",
11954
11964
  path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
@@ -11966,11 +11976,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
11966
11976
  operation: "time_off_requests.reject",
11967
11977
  maxRetries: opts.maxRetries
11968
11978
  });
11969
- return _chunkMAYYTYV5cjs.unwrapOperation.call(void 0, res);
11979
+ return _chunkWRWX6WIKcjs.unwrapOperation.call(void 0, res);
11970
11980
  }
11971
11981
 
11972
11982
  // src/resources/time_off_requests.ts
11973
- var TimeOffRequestsResource = class extends _chunkMAYYTYV5cjs.BaseResource {
11983
+ var TimeOffRequestsResource = class extends _chunkWRWX6WIKcjs.BaseResource {
11974
11984
  constructor(http, pageSize) {
11975
11985
  super(http, {
11976
11986
  key: "time_off_requests",