node-autotask 0.27.0 → 0.28.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 (37) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/MCP_TOOL_CATALOG.json +44 -8
  3. package/MCP_TOOL_MANIFEST.md +13 -11
  4. package/N8N_MCP_MANIFEST.json +55 -5
  5. package/N8N_MCP_MANIFEST.md +9 -7
  6. package/README.md +1 -1
  7. package/capabilities.json +1607 -1305
  8. package/dist/capabilities.cjs +2 -2
  9. package/dist/capabilities.js +1 -1
  10. package/dist/{chunk-F7FVOXPQ.js → chunk-6EQSXYRW.js} +1606 -1304
  11. package/dist/{chunk-ZJ4ONAQF.cjs → chunk-D5IVS6GY.cjs} +4 -4
  12. package/dist/{chunk-UHTZLUDE.cjs → chunk-GUY2KK7U.cjs} +143 -143
  13. package/dist/{chunk-42ZUISDH.js → chunk-IRVZGW5K.js} +1 -1
  14. package/dist/{chunk-GURC52J7.js → chunk-O2D7KDDD.js} +2 -2
  15. package/dist/{chunk-ZGTFVZL5.js → chunk-SYX6EWMT.js} +287 -78
  16. package/dist/{chunk-5GGCSRT4.cjs → chunk-WYKGD5UD.cjs} +795 -586
  17. package/dist/{chunk-5CC7LGNM.cjs → chunk-ZEGMVEF3.cjs} +1606 -1304
  18. package/dist/{index-D4XYtn4s.d.cts → index-CORcZUNm.d.cts} +79 -2
  19. package/dist/{index-BIWy9m-a.d.ts → index-DXuV04zM.d.ts} +79 -2
  20. package/dist/index.cjs +22 -22
  21. package/dist/index.d.cts +2 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +4 -4
  24. package/dist/operations/index.cjs +112 -112
  25. package/dist/operations/index.d.cts +2 -2
  26. package/dist/operations/index.d.ts +2 -2
  27. package/dist/operations/index.js +2 -2
  28. package/dist/pool.cjs +9 -9
  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 +40 -2
  37. package/package.json +1 -1
@@ -38,13 +38,13 @@
38
38
 
39
39
 
40
40
 
41
- var _chunkZJ4ONAQFcjs = require('./chunk-ZJ4ONAQF.cjs');
41
+ var _chunkD5IVS6GYcjs = require('./chunk-D5IVS6GY.cjs');
42
42
 
43
43
 
44
- var _chunk5CC7LGNMcjs = require('./chunk-5CC7LGNM.cjs');
44
+ var _chunkZEGMVEF3cjs = require('./chunk-ZEGMVEF3.cjs');
45
45
 
46
46
  // src/resources/appointments.ts
47
- var AppointmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
47
+ var AppointmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
48
48
  constructor(http, pageSize) {
49
49
  super(http, {
50
50
  key: "appointments",
@@ -129,7 +129,7 @@ var AuthenticateResource = class {
129
129
  };
130
130
 
131
131
  // src/resources/billing_codes.ts
132
- var BillingCodesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
132
+ var BillingCodesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
133
133
  constructor(http, pageSize) {
134
134
  super(http, {
135
135
  key: "billing_codes",
@@ -173,7 +173,7 @@ var BillingCodesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
173
173
  };
174
174
 
175
175
  // src/resources/billing_item_approval_levels.ts
176
- var BillingItemApprovalLevelsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
176
+ var BillingItemApprovalLevelsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
177
177
  constructor(http, pageSize) {
178
178
  super(http, {
179
179
  key: "billing_item_approval_levels",
@@ -215,7 +215,7 @@ var MAX_LIMIT = 500;
215
215
  function clampWindowLimit(limit) {
216
216
  const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
217
217
  if (!Number.isInteger(n) || n < 1) {
218
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
218
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
219
219
  }
220
220
  return Math.min(n, MAX_LIMIT);
221
221
  }
@@ -261,7 +261,7 @@ function wallParts(tz, ms) {
261
261
  }
262
262
  }
263
263
  if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
264
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
264
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
265
265
  }
266
266
  return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
267
267
  }
@@ -288,7 +288,7 @@ function localDayEndMs(y, m, d, tz) {
288
288
  }
289
289
  function validateZone(tz, opName = "dateWindow") {
290
290
  if (typeof tz !== "string" || tz.length === 0) {
291
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
291
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
292
292
  `${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
293
293
  { operation: opName }
294
294
  );
@@ -296,7 +296,7 @@ function validateZone(tz, opName = "dateWindow") {
296
296
  try {
297
297
  new Intl.DateTimeFormat("en-US", { timeZone: tz });
298
298
  } catch (e2) {
299
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
299
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
300
300
  `${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
301
301
  { operation: opName }
302
302
  );
@@ -456,13 +456,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
456
456
  body: { MaxRecords: limit, filter },
457
457
  operation
458
458
  });
459
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
459
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
460
460
  }
461
461
  var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
462
462
  function customRangeDay(value, label, zone, opName) {
463
463
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
464
464
  if (!m) {
465
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
465
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
466
466
  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)})`,
467
467
  { operation: opName }
468
468
  );
@@ -474,7 +474,7 @@ function customRangeDay(value, label, zone, opName) {
474
474
  const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
475
475
  const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
476
476
  if (!Number.isFinite(ms)) {
477
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
477
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
478
478
  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)})`,
479
479
  { operation: opName }
480
480
  );
@@ -485,7 +485,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
485
485
  const fromB = customRangeDay(from, "from", zone, operation);
486
486
  const toB = customRangeDay(to, "to", zone, operation);
487
487
  if (fromB.ms > toB.ms) {
488
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
488
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
489
489
  `${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
490
490
  { operation }
491
491
  );
@@ -502,7 +502,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
502
502
  body: { MaxRecords: limit, filter },
503
503
  operation
504
504
  });
505
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
505
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
506
506
  }
507
507
 
508
508
  // src/resources/special/billing_items.ts
@@ -535,7 +535,7 @@ async function customRange(_resource, from, to, http, opts) {
535
535
  }
536
536
 
537
537
  // src/resources/billing_items.ts
538
- var BillingItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
538
+ var BillingItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
539
539
  constructor(http, pageSize) {
540
540
  super(http, {
541
541
  key: "billing_items",
@@ -637,7 +637,7 @@ var BillingItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
637
637
  };
638
638
 
639
639
  // src/resources/change_request_links.ts
640
- var ChangeRequestLinksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
640
+ var ChangeRequestLinksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
641
641
  constructor(http, pageSize) {
642
642
  super(http, {
643
643
  key: "change_request_links",
@@ -691,7 +691,7 @@ var ChangeRequestLinksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
691
691
  };
692
692
 
693
693
  // src/resources/checklist_libraries.ts
694
- var ChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
694
+ var ChecklistLibrariesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
695
695
  constructor(http, pageSize) {
696
696
  super(http, {
697
697
  key: "checklist_libraries",
@@ -765,7 +765,7 @@ var ChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
765
765
  };
766
766
 
767
767
  // src/resources/checklist_library_checklist_items.ts
768
- var ChecklistLibraryChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
768
+ var ChecklistLibraryChecklistItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
769
769
  constructor(http, pageSize) {
770
770
  super(http, {
771
771
  key: "checklist_library_checklist_items",
@@ -831,7 +831,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.Bas
831
831
  };
832
832
 
833
833
  // src/resources/classification_icons.ts
834
- var ClassificationIconsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
834
+ var ClassificationIconsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
835
835
  constructor(http, pageSize) {
836
836
  super(http, {
837
837
  key: "classification_icons",
@@ -938,7 +938,7 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
938
938
  body,
939
939
  operation
940
940
  });
941
- const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
941
+ const { items, pageDetails } = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, operation);
942
942
  const capped = items.length >= limit;
943
943
  return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
944
944
  }
@@ -948,7 +948,7 @@ var DEFAULT_LIMIT2 = 25;
948
948
  var MAX_LIMIT2 = 500;
949
949
  function clampLimit(limit) {
950
950
  const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
951
- if (!Number.isInteger(n) || n < 1) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
951
+ if (!Number.isInteger(n) || n < 1) throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
952
952
  return Math.min(n, MAX_LIMIT2);
953
953
  }
954
954
 
@@ -961,7 +961,7 @@ async function queryCompanies(http, filter, limit) {
961
961
  body: { MaxRecords: limit, filter },
962
962
  operation: "companies.searchByDomain"
963
963
  });
964
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
964
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
965
965
  }
966
966
  async function queryContacts(http, filter, limit) {
967
967
  const res = await http.request({
@@ -971,7 +971,7 @@ async function queryContacts(http, filter, limit) {
971
971
  body: { MaxRecords: limit, filter },
972
972
  operation: "companies.searchByDomain"
973
973
  });
974
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
974
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
975
975
  }
976
976
  async function fetchCompanies(http, ids2, limit) {
977
977
  const out = [];
@@ -986,7 +986,7 @@ async function fetchCompanies(http, ids2, limit) {
986
986
  const item = body && "item" in body ? body.item : null;
987
987
  if (item) out.push(item);
988
988
  } catch (err) {
989
- if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) continue;
989
+ if (err instanceof _chunkD5IVS6GYcjs.NotFoundError) continue;
990
990
  throw err;
991
991
  }
992
992
  }
@@ -994,7 +994,7 @@ async function fetchCompanies(http, ids2, limit) {
994
994
  }
995
995
  async function searchByDomain(_resource, domain, opts = {}, http) {
996
996
  const text = domain.trim();
997
- if (text === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("searchByDomain: empty domain");
997
+ if (text === "") throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("searchByDomain: empty domain");
998
998
  const limit = clampLimit(opts.limit);
999
999
  const filter = [{ field: "webAddress", op: "contains", value: text }];
1000
1000
  const direct = await queryCompanies(http, filter, limit);
@@ -1008,7 +1008,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
1008
1008
  const email = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.email, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
1009
1009
  const website = _nullishCoalesce(_optionalChain([identity, 'access', _15 => _15.website, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]), () => ( ""));
1010
1010
  if (name === "" && email === "" && website === "") {
1011
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
1011
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
1012
1012
  }
1013
1013
  const limit = clampLimit(opts.limit);
1014
1014
  const found = /* @__PURE__ */ new Map();
@@ -1037,23 +1037,23 @@ async function familyChildPage(http, parentID) {
1037
1037
  path: "/V1.0/Companies/query",
1038
1038
  body: {
1039
1039
  MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
1040
- filter: _chunkZJ4ONAQFcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
1040
+ filter: _chunkD5IVS6GYcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
1041
1041
  },
1042
1042
  operation: "companies.search"
1043
1043
  });
1044
- const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "companies.search");
1044
+ const { items, pageDetails } = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, "companies.search");
1045
1045
  return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
1046
1046
  }
1047
1047
  function assertSearchWithDetailOpts(opts) {
1048
1048
  if (opts === void 0) return;
1049
1049
  if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
1050
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
1050
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
1051
1051
  operation: "companies.searchWithDetail"
1052
1052
  });
1053
1053
  }
1054
1054
  for (const key of Object.keys(opts)) {
1055
1055
  if (key !== "limit") {
1056
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
1056
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
1057
1057
  `companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
1058
1058
  { operation: "companies.searchWithDetail" }
1059
1059
  );
@@ -1062,32 +1062,32 @@ function assertSearchWithDetailOpts(opts) {
1062
1062
  }
1063
1063
  async function searchWithFamily(_resource, query, opts = {}, http) {
1064
1064
  if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
1065
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
1065
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
1066
1066
  }
1067
1067
  for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
1068
1068
  if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
1069
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
1069
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
1070
1070
  `companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
1071
1071
  { operation: "companies.search" }
1072
1072
  );
1073
1073
  }
1074
1074
  }
1075
1075
  if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
1076
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
1076
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
1077
1077
  operation: "companies.search"
1078
1078
  });
1079
1079
  }
1080
1080
  const text = query.trim();
1081
- if (text === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
1082
- const limit = opts.limit === void 0 ? 25 : _chunkZJ4ONAQFcjs.clampPageSize.call(void 0, opts.limit);
1081
+ if (text === "") throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
1082
+ const limit = opts.limit === void 0 ? 25 : _chunkD5IVS6GYcjs.clampPageSize.call(void 0, opts.limit);
1083
1083
  const res = await http.request({
1084
1084
  method: "POST",
1085
1085
  idempotent: true,
1086
1086
  path: "/V1.0/Companies/query",
1087
- body: { MaxRecords: limit, filter: _chunkZJ4ONAQFcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
1087
+ body: { MaxRecords: limit, filter: _chunkD5IVS6GYcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
1088
1088
  operation: "companies.search"
1089
1089
  });
1090
- const hits = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "companies.search").items;
1090
+ const hits = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, "companies.search").items;
1091
1091
  if (opts.includeFamily !== true) return hits;
1092
1092
  const rows = [];
1093
1093
  for (const hit of hits) {
@@ -1107,7 +1107,7 @@ async function searchWithFamily(_resource, query, opts = {}, http) {
1107
1107
  }
1108
1108
 
1109
1109
  // src/resources/special/companies/errors.ts
1110
- var OwnerResourceRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
1110
+ var OwnerResourceRequiredError = class extends _chunkD5IVS6GYcjs.AutotaskError {
1111
1111
  constructor(message, options = {}) {
1112
1112
  super(message, {
1113
1113
  code: "OWNER_RESOURCE_REQUIRED",
@@ -1118,13 +1118,13 @@ var OwnerResourceRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
1118
1118
  this.name = "OwnerResourceRequiredError";
1119
1119
  }
1120
1120
  };
1121
- var CompanyResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
1121
+ var CompanyResourceInvalidError = class extends _chunkD5IVS6GYcjs.AutotaskError {
1122
1122
  constructor(message, options = {}) {
1123
1123
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
1124
1124
  this.name = "CompanyResourceInvalidError";
1125
1125
  }
1126
1126
  };
1127
- var CompanyCreateFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
1127
+ var CompanyCreateFailedError = class extends _chunkD5IVS6GYcjs.AutotaskError {
1128
1128
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
1129
1129
 
1130
1130
  constructor(message, vendorFields, options = {}) {
@@ -1143,23 +1143,23 @@ var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumer
1143
1143
  var SAFE_COMPANY_CREATE_DEFAULTS = {};
1144
1144
  function validateUpsertInput(companyName, params) {
1145
1145
  if (typeof companyName !== "string" || companyName.trim() === "") {
1146
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
1146
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
1147
1147
  }
1148
1148
  if (typeof _optionalChain([params, 'optionalAccess', _18 => _18.phone]) !== "string" || params.phone.trim() === "") {
1149
- throw new (0, _chunkZJ4ONAQFcjs.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 });
1149
+ throw new (0, _chunkD5IVS6GYcjs.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 });
1150
1150
  }
1151
1151
  const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
1152
1152
  if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
1153
- throw new (0, _chunkZJ4ONAQFcjs.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 });
1153
+ throw new (0, _chunkD5IVS6GYcjs.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 });
1154
1154
  }
1155
1155
  const owner = params.ownerResourceID;
1156
1156
  if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
1157
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
1157
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
1158
1158
  }
1159
1159
  return { companyType, owner };
1160
1160
  }
1161
1161
  function existsDryRun(http, companyName, match) {
1162
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
1162
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
1163
1163
  {
1164
1164
  operation: OP_UPSERT_NAME,
1165
1165
  method: "POST",
@@ -1185,7 +1185,7 @@ function createDryRun(http, body, owner) {
1185
1185
  "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"
1186
1186
  );
1187
1187
  }
1188
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
1188
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
1189
1189
  {
1190
1190
  operation: OP_UPSERT_NAME,
1191
1191
  method: "POST",
@@ -1230,8 +1230,8 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
1230
1230
  sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
1231
1231
  };
1232
1232
  } catch (err) {
1233
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
1234
- const named = (_nullishCoalesce(_chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
1233
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
1234
+ const named = (_nullishCoalesce(_chunkD5IVS6GYcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
1235
1235
  const seen = /* @__PURE__ */ new Set();
1236
1236
  const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
1237
1237
  const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
@@ -1245,7 +1245,7 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
1245
1245
  }
1246
1246
  continue;
1247
1247
  }
1248
- const detail = _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError);
1248
+ const detail = _chunkD5IVS6GYcjs.formatVendorDetail.call(void 0, err.vendorError);
1249
1249
  throw new CompanyCreateFailedError(
1250
1250
  `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}` : ""}`,
1251
1251
  unique,
@@ -1291,6 +1291,82 @@ async function upsertByName(resource, companyName, params, opts, http) {
1291
1291
  return createWithDiscovery(resource, body, owner, caveat, opts);
1292
1292
  }
1293
1293
 
1294
+ // src/resources/special/_shared/ticketStatus.ts
1295
+ var ASSUMED_CLOSED_STATUS_ID = 5;
1296
+ var CLOSED_STATUS_LABELS = ["complete", "completed", "closed", "cancelled", "canceled", "resolved"];
1297
+ var OP = "tickets.statusSemantics";
1298
+ function picklistOf(fields) {
1299
+ if (!Array.isArray(fields)) return [];
1300
+ const status = fields.find((f) => typeof _optionalChain([f, 'optionalAccess', _19 => _19.name]) === "string" && f.name.toLowerCase() === "status");
1301
+ if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
1302
+ const out = [];
1303
+ for (const v of status.picklistValues) {
1304
+ const id = Number(_optionalChain([v, 'optionalAccess', _20 => _20.value]));
1305
+ if (!Number.isSafeInteger(id)) continue;
1306
+ out.push({ id, label: typeof v.label === "string" ? v.label : "" });
1307
+ }
1308
+ return out;
1309
+ }
1310
+ async function readFields(http, fresh) {
1311
+ const cache = http.fieldCache;
1312
+ const key = "tickets";
1313
+ if (!fresh && cache !== void 0) {
1314
+ const shared = cache.inflight(key, "fields");
1315
+ if (shared !== void 0) return await shared;
1316
+ const hit = cache.get(key, "fields");
1317
+ if (hit !== void 0) return hit;
1318
+ }
1319
+ const res = await http.request({ method: "GET", path: "/V1.0/Tickets/entityInformation/fields", operation: OP, maxRetries: 0 });
1320
+ const fields = _optionalChain([res, 'optionalAccess', _21 => _21.fields]);
1321
+ if (!Array.isArray(fields)) {
1322
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskError)("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
1323
+ }
1324
+ _optionalChain([cache, 'optionalAccess', _22 => _22.set, 'call', _23 => _23(key, "fields", fields)]);
1325
+ return fields;
1326
+ }
1327
+ function assumed(excludeStatusIds) {
1328
+ const closedIds = excludeStatusIds === void 0 ? [ASSUMED_CLOSED_STATUS_ID] : [...excludeStatusIds];
1329
+ return {
1330
+ picklist: [],
1331
+ closedIds,
1332
+ source: "assumed",
1333
+ assumedId: ASSUMED_CLOSED_STATUS_ID,
1334
+ note: `closed = status ${closedIds.join(", ")} \u2014 ASSUMED, not read from the tenant: the Tickets status picklist could not be resolved, so the historical id ${ASSUMED_CLOSED_STATUS_ID} stands in (fix: expose the Tickets field catalog to this API user, or pass excludeStatusIds)`
1335
+ };
1336
+ }
1337
+ async function resolveTicketStatusSemantics(http, opts = {}) {
1338
+ if (opts.excludeStatusIds !== void 0) {
1339
+ const closedIds2 = [...new Set(opts.excludeStatusIds.map((id) => Number(id)))];
1340
+ if (closedIds2.length === 0 || closedIds2.some((id) => !Number.isSafeInteger(id) || id < 1)) {
1341
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`excludeStatusIds must be a non-empty list of positive status ids (got ${JSON.stringify(opts.excludeStatusIds)})`, { operation: OP });
1342
+ }
1343
+ return { picklist: [], closedIds: closedIds2, source: "picklist", note: `closed = status ${closedIds2.join(", ")} \u2014 supplied by the caller` };
1344
+ }
1345
+ let fields;
1346
+ try {
1347
+ fields = await readFields(http, opts.fresh === true);
1348
+ } catch (e) {
1349
+ if (e instanceof _chunkD5IVS6GYcjs.AutotaskError && e.code === "ABORTED") throw e;
1350
+ return assumed();
1351
+ }
1352
+ const picklist = picklistOf(fields);
1353
+ const closedIds = picklist.filter((v) => CLOSED_STATUS_LABELS.includes(v.label.trim().toLowerCase())).map((v) => v.id);
1354
+ if (closedIds.length === 0) return assumed();
1355
+ const labels = picklist.filter((v) => closedIds.includes(v.id)).map((v) => `${v.id} ${v.label}`).join(", ");
1356
+ return {
1357
+ picklist,
1358
+ closedIds,
1359
+ source: "picklist",
1360
+ note: `closed = status not in [${closedIds.join(", ")}] (${labels}) \u2014 resolved from the tenant's Tickets status picklist`
1361
+ };
1362
+ }
1363
+ function openStatusFilter(closedIds) {
1364
+ return closedIds.length === 1 ? { field: "status", op: "noteq", value: closedIds[0] } : { field: "status", op: "notIn", value: [...closedIds] };
1365
+ }
1366
+ function isClosedStatus(status, closedIds) {
1367
+ return typeof status === "number" && closedIds.includes(status);
1368
+ }
1369
+
1294
1370
  // src/resources/special/companies/fullProfile.ts
1295
1371
  var FULL_PROFILE_PROJECTABLE_PARTS = ["locations", "contacts", "notes", "projects", "openTickets"];
1296
1372
  var PART_ENTITY = {
@@ -1300,36 +1376,36 @@ var PART_ENTITY = {
1300
1376
  projects: "projects",
1301
1377
  openTickets: "tickets"
1302
1378
  };
1303
- var OPEN_TICKETS_NOTE = "open = status != 5 (Complete) \u2014 the ww29 ticket-status picklist has no Closed value; tickets in any other status count as open";
1379
+ var OPEN_TICKETS_NOTE = "open = status != 5 (Complete) \u2014 ASSUMED: the tenant Tickets status picklist could not be read, so id 5 is the fallback closed id; tickets in any other status count as open";
1304
1380
  var PROFILE_PART_LIMIT = 50;
1305
1381
  var LOCATION_LIMIT_MAX = 500;
1306
1382
  function locationLimit(value) {
1307
1383
  if (value === void 0) return PROFILE_PART_LIMIT;
1308
1384
  if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
1309
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
1385
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
1310
1386
  }
1311
1387
  return value;
1312
1388
  }
1313
1389
  function validateProjection(fields) {
1314
1390
  if (fields === void 0) return {};
1315
1391
  if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
1316
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
1392
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
1317
1393
  }
1318
1394
  const out = {};
1319
1395
  for (const [part, list] of Object.entries(fields)) {
1320
1396
  if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
1321
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
1397
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
1322
1398
  }
1323
1399
  if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
1324
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
1400
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
1325
1401
  }
1326
1402
  const names = [...new Set(list)];
1327
1403
  const entity = PART_ENTITY[part];
1328
- const known = _nullishCoalesce(_chunkZJ4ONAQFcjs.MODEL_FIELD_SETS[entity], () => ( []));
1404
+ const known = _nullishCoalesce(_chunkD5IVS6GYcjs.MODEL_FIELD_SETS[entity], () => ( []));
1329
1405
  const unknown = names.filter((n) => !known.includes(n));
1330
1406
  if (unknown.length > 0) {
1331
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
1332
- `fullProfile: fields.${part} has unknown field name(s) ${_chunkZJ4ONAQFcjs.formatUnknownNameList.call(void 0, unknown)} against the vendored spec for ${entity} (${known.length} fields; operations.fieldCatalog resources: ["${entity}"] lists the live set) \u2014 no request was issued`
1407
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
1408
+ `fullProfile: fields.${part} has unknown field name(s) ${_chunkD5IVS6GYcjs.formatUnknownNameList.call(void 0, unknown)} against the vendored spec for ${entity} (${known.length} fields; operations.fieldCatalog resources: ["${entity}"] lists the live set) \u2014 no request was issued`
1333
1409
  );
1334
1410
  }
1335
1411
  out[part] = names;
@@ -1346,7 +1422,7 @@ function project(items, names) {
1346
1422
  function profilePartLimit(value, name) {
1347
1423
  const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
1348
1424
  if (!Number.isInteger(n) || n < 1) {
1349
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
1425
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
1350
1426
  }
1351
1427
  return n;
1352
1428
  }
@@ -1358,9 +1434,11 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
1358
1434
  body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
1359
1435
  operation: "companies.fullProfile"
1360
1436
  });
1361
- return project(_chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items, includeFields);
1437
+ return project(_chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items, includeFields);
1362
1438
  }
1363
1439
  async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1440
+ const semantics = await resolveTicketStatusSemantics(http);
1441
+ const openLeaf = openStatusFilter(semantics.closedIds);
1364
1442
  const openRows = await (async () => {
1365
1443
  const res = await http.request({
1366
1444
  method: "POST",
@@ -1368,30 +1446,31 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1368
1446
  path: "/V1.0/Tickets/query",
1369
1447
  body: {
1370
1448
  MaxRecords: ticketLimit,
1371
- filter: [{ field: "companyID", op: "eq", value: companyID }, { field: "status", op: "noteq", value: 5 }],
1449
+ filter: [{ field: "companyID", op: "eq", value: companyID }, openLeaf],
1372
1450
  ...includeFields ? { IncludeFields: includeFields } : {}
1373
1451
  },
1374
1452
  operation: "companies.fullProfile"
1375
1453
  });
1376
- return project(_chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items, includeFields);
1454
+ return project(_chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items, includeFields);
1377
1455
  })();
1456
+ const closedStatus = { closedIds: semantics.closedIds, source: semantics.source, note: semantics.note };
1457
+ const partNote = semantics.source === "assumed" ? OPEN_TICKETS_NOTE : semantics.note;
1378
1458
  let openTickets = {
1379
1459
  items: openRows,
1380
1460
  capped: openRows.length >= ticketLimit,
1381
1461
  blind: false,
1382
- note: OPEN_TICKETS_NOTE
1462
+ note: partNote,
1463
+ closedStatus
1383
1464
  };
1384
1465
  if (openRows.length === 0) {
1385
- const stamp = _chunkZJ4ONAQFcjs.blindStampFor.call(void 0, _optionalChain([_chunkZJ4ONAQFcjs.BLIND_SURFACE_STAMPS, 'access', _19 => _19["tickets"], 'optionalAccess', _20 => _20.query]), [
1386
- { field: "companyID", op: "eq", value: companyID },
1387
- { field: "status", op: "noteq", value: 5 }
1388
- ]);
1466
+ const stamp = _chunkD5IVS6GYcjs.blindStampFor.call(void 0, _optionalChain([_chunkD5IVS6GYcjs.BLIND_SURFACE_STAMPS, 'access', _24 => _24["tickets"], 'optionalAccess', _25 => _25.query]), [{ field: "companyID", op: "eq", value: companyID }, openLeaf]);
1389
1467
  if (stamp !== void 0) {
1390
1468
  openTickets = {
1391
1469
  items: openRows,
1392
1470
  capped: openRows.length >= ticketLimit,
1393
1471
  blind: true,
1394
- note: `${stamp.note} ${OPEN_TICKETS_NOTE}`,
1472
+ note: `${stamp.note} ${partNote}`,
1473
+ closedStatus,
1395
1474
  blindSurface: stamp
1396
1475
  };
1397
1476
  }
@@ -1399,7 +1478,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1399
1478
  return openTickets;
1400
1479
  }
1401
1480
  async function addProfileNames(http, company, openTickets, projects, result, opts) {
1402
- const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS);
1481
+ const builder = _chunkD5IVS6GYcjs.createNamePlan.call(void 0, _chunkD5IVS6GYcjs.TICKET_LABEL_FIELDS);
1403
1482
  const c = company;
1404
1483
  builder.addResource(c["ownerResourceID"]);
1405
1484
  builder.addResource(c["createdByResourceID"]);
@@ -1416,20 +1495,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
1416
1495
  builder.addResource(r["creatorResourceID"]);
1417
1496
  builder.addFk("contract", r["contractID"]);
1418
1497
  }
1419
- const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
1498
+ const names = await _chunkD5IVS6GYcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
1420
1499
  const companyRow = { ...company };
1421
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
1422
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
1500
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
1501
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
1423
1502
  result.company = companyRow;
1424
1503
  result.openTickets = {
1425
1504
  ...openTickets,
1426
1505
  items: openTickets.items.map((row) => {
1427
1506
  const r = { ...row };
1428
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1429
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1430
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
1431
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
1432
- for (const f of _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS) _chunkZJ4ONAQFcjs.addLabelSibling.call(void 0, r, f, names);
1507
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1508
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1509
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
1510
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
1511
+ for (const f of _chunkD5IVS6GYcjs.TICKET_LABEL_FIELDS) _chunkD5IVS6GYcjs.addLabelSibling.call(void 0, r, f, names);
1433
1512
  return r;
1434
1513
  })
1435
1514
  };
@@ -1437,9 +1516,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
1437
1516
  ...result.projects,
1438
1517
  items: result.projects.items.map((row) => {
1439
1518
  const r = { ...row };
1440
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
1441
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1442
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1519
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
1520
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1521
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1443
1522
  return r;
1444
1523
  })
1445
1524
  };
@@ -1452,7 +1531,7 @@ async function fullProfile(resource, id, opts = {}, http) {
1452
1531
  const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
1453
1532
  const locLimit = locationLimit(opts.locationLimit);
1454
1533
  const proj = validateProjection(opts.fields);
1455
- const companyID = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
1534
+ const companyID = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
1456
1535
  const company = await resource.get(companyID);
1457
1536
  const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
1458
1537
  const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
@@ -1499,7 +1578,7 @@ var UNBILLED_WORK_OPT_KEYS = [
1499
1578
  var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
1500
1579
  function validateUnbilledWorkOptions(companyId, opts) {
1501
1580
  if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
1502
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
1581
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
1503
1582
  `unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
1504
1583
  { operation: "companies.unbilledWork" }
1505
1584
  );
@@ -1528,7 +1607,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
1528
1607
  try {
1529
1608
  limit = clampLimit(opts.limit);
1530
1609
  } catch (err) {
1531
- problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
1610
+ problems.push(err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
1532
1611
  limit = 50;
1533
1612
  }
1534
1613
  if (source === "date_range") {
@@ -1543,9 +1622,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
1543
1622
  problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
1544
1623
  } else {
1545
1624
  try {
1546
- _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
1625
+ _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
1547
1626
  } catch (err) {
1548
- problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
1627
+ problems.push(err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
1549
1628
  }
1550
1629
  }
1551
1630
  }
@@ -1555,20 +1634,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
1555
1634
  } else {
1556
1635
  opts.ticketIds.forEach((tid, i) => {
1557
1636
  try {
1558
- _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
1637
+ _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
1559
1638
  } catch (err) {
1560
- problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
1639
+ problems.push(err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
1561
1640
  }
1562
1641
  });
1563
1642
  }
1564
1643
  }
1565
1644
  try {
1566
- _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, companyId, "companyId");
1645
+ _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, companyId, "companyId");
1567
1646
  } catch (err) {
1568
- problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
1647
+ problems.push(err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
1569
1648
  }
1570
1649
  if (problems.length > 0) {
1571
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
1650
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
1572
1651
  `unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
1573
1652
  - ` + problems.join("\n- "),
1574
1653
  { operation: "companies.unbilledWork" }
@@ -1589,7 +1668,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
1589
1668
  }
1590
1669
 
1591
1670
  // src/resources/special/companies/unbilledWork.ts
1592
- var OP = "companies.unbilledWork";
1671
+ var OP2 = "companies.unbilledWork";
1593
1672
  function capJoinSet(ids2, cap) {
1594
1673
  const sorted = [...new Set(ids2)].sort((a, b) => a - b);
1595
1674
  if (sorted.length <= cap) return { ids: sorted, truncated: false };
@@ -1597,7 +1676,7 @@ function capJoinSet(ids2, cap) {
1597
1676
  }
1598
1677
  function unbilledWorkPartStatus(key, conditions, items) {
1599
1678
  if (items.length !== 0) return { status: "ok" };
1600
- const stamp = _chunkZJ4ONAQFcjs.blindStampFor.call(void 0, _optionalChain([_chunkZJ4ONAQFcjs.BLIND_SURFACE_STAMPS, 'access', _21 => _21[key], 'optionalAccess', _22 => _22.query]), conditions);
1679
+ const stamp = _chunkD5IVS6GYcjs.blindStampFor.call(void 0, _optionalChain([_chunkD5IVS6GYcjs.BLIND_SURFACE_STAMPS, 'access', _26 => _26[key], 'optionalAccess', _27 => _27.query]), conditions);
1601
1680
  if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
1602
1681
  return {
1603
1682
  status: "ok",
@@ -1617,7 +1696,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
1617
1696
  parentStatus = "ok";
1618
1697
  companyIds.push(num(parent.id));
1619
1698
  } catch (err) {
1620
- if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) parent = null;
1699
+ if (err instanceof _chunkD5IVS6GYcjs.NotFoundError) parent = null;
1621
1700
  else throw err;
1622
1701
  }
1623
1702
  }
@@ -1626,14 +1705,14 @@ async function readCompanyAndParent(resource, id, includeParent) {
1626
1705
  }
1627
1706
  async function readJoinSets(http, companyIds, v) {
1628
1707
  const ticketsCond = [{ field: "companyID", op: "in", value: companyIds }];
1629
- const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit, OP);
1708
+ const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit, OP2);
1630
1709
  const projectsCond = [{ field: "companyID", op: "in", value: companyIds }];
1631
- const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit, OP);
1710
+ const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit, OP2);
1632
1711
  const projectIds = projectsRaw.items.map((p) => num(p.id)).filter((n) => n > 0);
1633
1712
  let taskIds = [];
1634
1713
  let tasksHasMore = false;
1635
1714
  if (projectIds.length > 0) {
1636
- const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit, OP);
1715
+ const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit, OP2);
1637
1716
  taskIds = tasksRaw.items.map((t) => num(t.id)).filter((n) => n > 0);
1638
1717
  tasksHasMore = tasksRaw.hasMore;
1639
1718
  }
@@ -1655,14 +1734,14 @@ async function readBillingPart(http, v, companyIds) {
1655
1734
  if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
1656
1735
  if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
1657
1736
  }
1658
- const billingFields = _chunkZJ4ONAQFcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
1737
+ const billingFields = _chunkD5IVS6GYcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
1659
1738
  const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
1660
- const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP, billingIncludeFields);
1739
+ const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP2, billingIncludeFields);
1661
1740
  let billingItems = billingRaw.items;
1662
1741
  let billingNoteCharsTruncated = 0;
1663
1742
  if (v.includeNotes) {
1664
- const noteFields = (_nullishCoalesce(_chunkZJ4ONAQFcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
1665
- [billingItems, billingNoteCharsTruncated] = _chunkZJ4ONAQFcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
1743
+ const noteFields = (_nullishCoalesce(_chunkD5IVS6GYcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
1744
+ [billingItems, billingNoteCharsTruncated] = _chunkD5IVS6GYcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
1666
1745
  }
1667
1746
  const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
1668
1747
  const billingItemsPart = {
@@ -1701,12 +1780,12 @@ async function readTimePart(http, v, join) {
1701
1780
  if (v.dateFrom !== void 0) timeConditions.push({ field: "dateWorked", op: "gte", value: v.dateFrom });
1702
1781
  if (v.dateTo !== void 0) timeConditions.push({ field: "dateWorked", op: "lte", value: v.dateTo });
1703
1782
  const timeFields = ["taskID", "ticketID", "hoursWorked", "dateWorked", "id", ...v.includeNotes ? ["summaryNotes"] : []];
1704
- const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit, OP, timeFields);
1783
+ const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit, OP2, timeFields);
1705
1784
  entries = raw.items;
1706
1785
  let cappedItems = entries;
1707
1786
  let noteCharsTruncated = 0;
1708
1787
  if (v.includeNotes) {
1709
- [cappedItems, noteCharsTruncated] = _chunkZJ4ONAQFcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
1788
+ [cappedItems, noteCharsTruncated] = _chunkD5IVS6GYcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
1710
1789
  }
1711
1790
  const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
1712
1791
  timePart = {
@@ -1794,7 +1873,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
1794
1873
  }
1795
1874
  async function unbilledWork(resource, companyId, opts = {}, http) {
1796
1875
  const v = validateUnbilledWorkOptions(companyId, opts);
1797
- const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, companyId, "companyId");
1876
+ const id = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, companyId, "companyId");
1798
1877
  const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
1799
1878
  const join = await readJoinSets(http, companyIds, v);
1800
1879
  const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
@@ -1821,7 +1900,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1821
1900
  }
1822
1901
 
1823
1902
  // src/resources/companies.ts
1824
- var CompaniesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
1903
+ var CompaniesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
1825
1904
  constructor(http, pageSize) {
1826
1905
  super(http, {
1827
1906
  key: "companies",
@@ -1928,7 +2007,7 @@ var CompaniesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
1928
2007
  };
1929
2008
 
1930
2009
  // src/resources/company_alerts.ts
1931
- var CompanyAlertsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2010
+ var CompanyAlertsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
1932
2011
  constructor(http, pageSize) {
1933
2012
  super(http, {
1934
2013
  key: "company_alerts",
@@ -1994,7 +2073,7 @@ var CompanyAlertsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
1994
2073
  };
1995
2074
 
1996
2075
  // src/resources/company_locations.ts
1997
- var CompanyLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2076
+ var CompanyLocationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
1998
2077
  constructor(http, pageSize) {
1999
2078
  super(http, {
2000
2079
  key: "company_locations",
@@ -2060,12 +2139,12 @@ var CompanyLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2060
2139
  /** Search CompanyLocation records: bounded contains on name (no vendor free-text search exists);
2061
2140
  * limit defaults to 25, max 500. */
2062
2141
  async search(query, opts) {
2063
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _23 => _23.limit]) });
2142
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _28 => _28.limit]) });
2064
2143
  }
2065
2144
  };
2066
2145
 
2067
2146
  // src/resources/company_notes.ts
2068
- var CompanyNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2147
+ var CompanyNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2069
2148
  constructor(http, pageSize) {
2070
2149
  super(http, {
2071
2150
  key: "company_notes",
@@ -2125,12 +2204,12 @@ var CompanyNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2125
2204
  /** Search CompanyNote records: bounded contains on name (no vendor free-text search exists);
2126
2205
  * limit defaults to 25, max 500. */
2127
2206
  async search(query, opts) {
2128
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _24 => _24.limit]) });
2207
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _29 => _29.limit]) });
2129
2208
  }
2130
2209
  };
2131
2210
 
2132
2211
  // src/resources/company_site_configurations.ts
2133
- var CompanySiteConfigurationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2212
+ var CompanySiteConfigurationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2134
2213
  constructor(http, pageSize) {
2135
2214
  super(http, {
2136
2215
  key: "company_site_configurations",
@@ -2181,7 +2260,7 @@ var CompanySiteConfigurationsResource = class extends _chunkZJ4ONAQFcjs.BaseReso
2181
2260
  };
2182
2261
 
2183
2262
  // src/resources/company_webhooks.ts
2184
- var CompanyWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2263
+ var CompanyWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2185
2264
  constructor(http, pageSize) {
2186
2265
  super(http, {
2187
2266
  key: "company_webhooks",
@@ -2252,12 +2331,12 @@ var CompanyWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2252
2331
  /** Search CompanyWebhook records: bounded contains on name (no vendor free-text search exists);
2253
2332
  * limit defaults to 25, max 500. */
2254
2333
  async search(query, opts) {
2255
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _25 => _25.limit]) });
2334
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _30 => _30.limit]) });
2256
2335
  }
2257
2336
  };
2258
2337
 
2259
2338
  // src/resources/configuration_item_billing_product_associations.ts
2260
- var ConfigurationItemBillingProductAssociationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2339
+ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2261
2340
  constructor(http, pageSize) {
2262
2341
  super(http, {
2263
2342
  key: "configuration_item_billing_product_associations",
@@ -2323,7 +2402,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkZJ
2323
2402
  };
2324
2403
 
2325
2404
  // src/resources/configuration_item_categories.ts
2326
- var ConfigurationItemCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2405
+ var ConfigurationItemCategoriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2327
2406
  constructor(http, pageSize) {
2328
2407
  super(http, {
2329
2408
  key: "configuration_item_categories",
@@ -2385,12 +2464,12 @@ var ConfigurationItemCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseRe
2385
2464
  /** Search ConfigurationItemCategory records: bounded contains on name (no vendor free-text search exists);
2386
2465
  * limit defaults to 25, max 500. */
2387
2466
  async search(query, opts) {
2388
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _26 => _26.limit]) });
2467
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _31 => _31.limit]) });
2389
2468
  }
2390
2469
  };
2391
2470
 
2392
2471
  // src/resources/configuration_item_category_udf_associations.ts
2393
- var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2472
+ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2394
2473
  constructor(http, pageSize) {
2395
2474
  super(http, {
2396
2475
  key: "configuration_item_category_udf_associations",
@@ -2456,7 +2535,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkZJ4ON
2456
2535
  };
2457
2536
 
2458
2537
  // src/resources/configuration_item_dns_records.ts
2459
- var ConfigurationItemDnsRecordsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2538
+ var ConfigurationItemDnsRecordsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2460
2539
  constructor(http, pageSize) {
2461
2540
  super(http, {
2462
2541
  key: "configuration_item_dns_records",
@@ -2505,7 +2584,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkZJ4ONAQFcjs.BaseRe
2505
2584
  };
2506
2585
 
2507
2586
  // src/resources/configuration_item_notes.ts
2508
- var ConfigurationItemNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2587
+ var ConfigurationItemNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2509
2588
  constructor(http, pageSize) {
2510
2589
  super(http, {
2511
2590
  key: "configuration_item_notes",
@@ -2564,7 +2643,7 @@ var ConfigurationItemNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
2564
2643
  };
2565
2644
 
2566
2645
  // src/resources/configuration_item_related_items.ts
2567
- var ConfigurationItemRelatedItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2646
+ var ConfigurationItemRelatedItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2568
2647
  constructor(http, pageSize) {
2569
2648
  super(http, {
2570
2649
  key: "configuration_item_related_items",
@@ -2622,19 +2701,19 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkZJ4ONAQFcjs.Base
2622
2701
 
2623
2702
  // src/resources/special/configuration_items.ts
2624
2703
  async function fetchRecord(http, path, label, readOpts) {
2625
- const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _27 => _27.maxRetries]) });
2704
+ const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _32 => _32.maxRetries]) });
2626
2705
  const body = res;
2627
2706
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
2628
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
2707
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
2629
2708
  }
2630
2709
  return body.item;
2631
2710
  }
2632
2711
  async function moveConfigurationItem(_resource, sourceId, opts, http) {
2633
- const numericSource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
2634
- if (_optionalChain([opts, 'optionalAccess', _28 => _28.destinationCompanyId]) === void 0) {
2635
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
2712
+ const numericSource = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
2713
+ if (_optionalChain([opts, 'optionalAccess', _33 => _33.destinationCompanyId]) === void 0) {
2714
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
2636
2715
  }
2637
- const destId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
2716
+ const destId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
2638
2717
  const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
2639
2718
  await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
2640
2719
  const body = { ...source };
@@ -2644,20 +2723,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
2644
2723
  body.companyID = destId;
2645
2724
  body.isActive = true;
2646
2725
  if (opts.newReferenceTitle !== void 0) {
2647
- if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
2726
+ if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
2648
2727
  body.referenceTitle = opts.newReferenceTitle.trim();
2649
2728
  }
2650
2729
  if (opts.lastModifiedDate !== void 0) {
2651
2730
  const current = source.lastModifiedDate;
2652
2731
  if (current !== opts.lastModifiedDate) {
2653
- throw new (0, _chunkZJ4ONAQFcjs.StaleObjectError)(
2732
+ throw new (0, _chunkD5IVS6GYcjs.StaleObjectError)(
2654
2733
  `moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
2655
2734
  { operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
2656
2735
  );
2657
2736
  }
2658
2737
  }
2659
2738
  if (opts.dryRun === true) {
2660
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
2739
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
2661
2740
  operation: "configuration_items.moveConfigurationItem",
2662
2741
  method: "POST",
2663
2742
  path: "/V1.0/ConfigurationItems",
@@ -2682,7 +2761,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
2682
2761
  const createdBody = created;
2683
2762
  const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
2684
2763
  if (typeof newId !== "number") {
2685
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
2764
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
2686
2765
  }
2687
2766
  let sourceDeactivated = false;
2688
2767
  if (opts.deactivateSource !== false) {
@@ -2701,7 +2780,7 @@ var PROFILE_PART_LIMIT2 = 50;
2701
2780
  function profilePartLimit2(value, name) {
2702
2781
  const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
2703
2782
  if (!Number.isInteger(n) || n < 1) {
2704
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
2783
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
2705
2784
  }
2706
2785
  return n;
2707
2786
  }
@@ -2717,14 +2796,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
2717
2796
  });
2718
2797
  const body = res;
2719
2798
  if (body === null || !("item" in body)) {
2720
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2799
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2721
2800
  }
2722
2801
  if (body.item === null || body.item === void 0) {
2723
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2802
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2724
2803
  }
2725
2804
  return body.item;
2726
2805
  } catch (err) {
2727
- if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) return null;
2806
+ if (err instanceof _chunkD5IVS6GYcjs.NotFoundError) return null;
2728
2807
  throw err;
2729
2808
  }
2730
2809
  }
@@ -2736,7 +2815,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
2736
2815
  body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
2737
2816
  operation: "configuration_items.profile"
2738
2817
  });
2739
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
2818
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
2740
2819
  }
2741
2820
  async function profile(resource, id, opts = {}, http) {
2742
2821
  const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
@@ -2748,7 +2827,7 @@ async function profile(resource, id, opts = {}, http) {
2748
2827
  const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
2749
2828
  const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
2750
2829
  const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
2751
- const wallQuirk = _optionalChain([_chunkZJ4ONAQFcjs.RELATIONSHIP_MAP, 'access', _29 => _29["configuration_items"], 'optionalAccess', _30 => _30.zoneFacts, 'optionalAccess', _31 => _31.quirks, 'optionalAccess', _32 => _32.find, 'call', _33 => _33((q) => q.startsWith("product wall"))]);
2830
+ const wallQuirk = _optionalChain([_chunkD5IVS6GYcjs.RELATIONSHIP_MAP, 'access', _34 => _34["configuration_items"], 'optionalAccess', _35 => _35.zoneFacts, 'optionalAccess', _36 => _36.quirks, 'optionalAccess', _37 => _37.find, 'call', _38 => _38((q) => q.startsWith("product wall"))]);
2752
2831
  const productAssociations = {
2753
2832
  items: associations,
2754
2833
  capped: associations.length >= PROFILE_PART_LIMIT2,
@@ -2772,11 +2851,11 @@ async function profile(resource, id, opts = {}, http) {
2772
2851
  }
2773
2852
  };
2774
2853
  if (opts.names === true) {
2775
- const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, );
2854
+ const builder = _chunkD5IVS6GYcjs.createNamePlan.call(void 0, );
2776
2855
  builder.addFk("contract", root["contractID"]);
2777
- const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
2856
+ const names = await _chunkD5IVS6GYcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
2778
2857
  const ciRow = { ...ci };
2779
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
2858
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
2780
2859
  result.ci = ciRow;
2781
2860
  result.names = names.section;
2782
2861
  }
@@ -2784,7 +2863,7 @@ async function profile(resource, id, opts = {}, http) {
2784
2863
  }
2785
2864
 
2786
2865
  // src/resources/configuration_items.ts
2787
- var ConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2866
+ var ConfigurationItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2788
2867
  constructor(http, pageSize) {
2789
2868
  super(http, {
2790
2869
  key: "configuration_items",
@@ -2850,7 +2929,7 @@ var ConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2850
2929
  /** Search ConfigurationItem records: bounded contains on referenceTitle (no vendor free-text search exists);
2851
2930
  * limit defaults to 25, max 500. */
2852
2931
  async search(query, opts) {
2853
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _34 => _34.limit]) });
2932
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _39 => _39.limit]) });
2854
2933
  }
2855
2934
  /** Get the ConfigurationItem with its primary context records in one call (each part a single-record
2856
2935
  * fetch; no sub-lists; absent/dangling references come back null). */
@@ -2873,7 +2952,7 @@ var ConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2873
2952
  };
2874
2953
 
2875
2954
  // src/resources/configuration_item_ssl_subject_alternative_names.ts
2876
- var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
2955
+ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2877
2956
  constructor(http, pageSize) {
2878
2957
  super(http, {
2879
2958
  key: "configuration_item_ssl_subject_alternative_names",
@@ -2931,12 +3010,12 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkZJ
2931
3010
  /** Search ConfigurationItemSslSubjectAlternativeName records: bounded contains on name (no vendor free-text search exists);
2932
3011
  * limit defaults to 25, max 500. */
2933
3012
  async search(query, opts) {
2934
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _35 => _35.limit]) });
3013
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _40 => _40.limit]) });
2935
3014
  }
2936
3015
  };
2937
3016
 
2938
3017
  // src/resources/configuration_item_types.ts
2939
- var ConfigurationItemTypesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3018
+ var ConfigurationItemTypesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
2940
3019
  constructor(http, pageSize) {
2941
3020
  super(http, {
2942
3021
  key: "configuration_item_types",
@@ -3005,12 +3084,12 @@ var ConfigurationItemTypesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
3005
3084
  /** Search ConfigurationItemType records: bounded contains on name (no vendor free-text search exists);
3006
3085
  * limit defaults to 25, max 500. */
3007
3086
  async search(query, opts) {
3008
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _36 => _36.limit]) });
3087
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _41 => _41.limit]) });
3009
3088
  }
3010
3089
  };
3011
3090
 
3012
3091
  // src/resources/configuration_item_webhooks.ts
3013
- var ConfigurationItemWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3092
+ var ConfigurationItemWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3014
3093
  constructor(http, pageSize) {
3015
3094
  super(http, {
3016
3095
  key: "configuration_item_webhooks",
@@ -3081,12 +3160,12 @@ var ConfigurationItemWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseReso
3081
3160
  /** Search ConfigurationItemWebhook records: bounded contains on name (no vendor free-text search exists);
3082
3161
  * limit defaults to 25, max 500. */
3083
3162
  async search(query, opts) {
3084
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _37 => _37.limit]) });
3163
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _42 => _42.limit]) });
3085
3164
  }
3086
3165
  };
3087
3166
 
3088
3167
  // src/resources/contact_group_contacts.ts
3089
- var ContactGroupContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3168
+ var ContactGroupContactsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3090
3169
  constructor(http, pageSize) {
3091
3170
  super(http, {
3092
3171
  key: "contact_group_contacts",
@@ -3140,7 +3219,7 @@ var ContactGroupContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
3140
3219
  };
3141
3220
 
3142
3221
  // src/resources/contact_groups.ts
3143
- var ContactGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3222
+ var ContactGroupsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3144
3223
  constructor(http, pageSize) {
3145
3224
  super(http, {
3146
3225
  key: "contact_groups",
@@ -3209,31 +3288,31 @@ var ContactGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3209
3288
  /** Search ContactGroups records: bounded contains on name (no vendor free-text search exists);
3210
3289
  * limit defaults to 25, max 500. */
3211
3290
  async search(query, opts) {
3212
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _38 => _38.limit]) });
3291
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _43 => _43.limit]) });
3213
3292
  }
3214
3293
  };
3215
3294
 
3216
3295
  // src/resources/special/contacts.ts
3217
3296
  async function fetchRecord2(http, path, label, readOpts) {
3218
- const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _39 => _39.maxRetries]) });
3297
+ const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _44 => _44.maxRetries]) });
3219
3298
  const body = res;
3220
3299
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
3221
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
3300
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
3222
3301
  }
3223
3302
  return body.item;
3224
3303
  }
3225
3304
  async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
3226
- const sourceId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
3227
- const destId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
3305
+ const sourceId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
3306
+ const destId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
3228
3307
  const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
3229
3308
  const companyID = source.companyID;
3230
3309
  if (typeof companyID !== "number" || companyID < 0) {
3231
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
3310
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
3232
3311
  }
3233
3312
  if (opts.lastModifiedDate !== void 0) {
3234
3313
  const current = source.lastModifiedDate;
3235
3314
  if (current !== opts.lastModifiedDate) {
3236
- throw new (0, _chunkZJ4ONAQFcjs.StaleObjectError)(
3315
+ throw new (0, _chunkD5IVS6GYcjs.StaleObjectError)(
3237
3316
  `moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
3238
3317
  { operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
3239
3318
  );
@@ -3255,10 +3334,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3255
3334
  },
3256
3335
  operation: "contacts.moveToCompany"
3257
3336
  });
3258
- const items = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
3337
+ const items = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
3259
3338
  const clash = items.find((c) => String(c.id) !== String(sourceId));
3260
3339
  if (clash !== void 0) {
3261
- throw new (0, _chunkZJ4ONAQFcjs.ConflictError)(
3340
+ throw new (0, _chunkD5IVS6GYcjs.ConflictError)(
3262
3341
  `Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
3263
3342
  { resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
3264
3343
  );
@@ -3272,7 +3351,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3272
3351
  if (opts.dryRun === true) {
3273
3352
  const warnings = [];
3274
3353
  if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
3275
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
3354
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
3276
3355
  operation: "contacts.moveToCompany",
3277
3356
  method: "POST",
3278
3357
  path: `/V1.0/Companies/${destId}/Contacts`,
@@ -3298,7 +3377,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3298
3377
  const createdBody = created;
3299
3378
  const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
3300
3379
  if (typeof newId !== "number") {
3301
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
3380
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
3302
3381
  }
3303
3382
  let sourceDeleted = false;
3304
3383
  if (opts.deleteSource === true) {
@@ -3317,7 +3396,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
3317
3396
  var EMAIL_SHAPE = /^.+@.+/;
3318
3397
  var SAFE_CONTACT_CREATE_DEFAULTS = {};
3319
3398
  var DEDUP_LIMIT = 10;
3320
- var CompanyNotFoundError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
3399
+ var CompanyNotFoundError = class extends _chunkD5IVS6GYcjs.AutotaskError {
3321
3400
  constructor(message, options = {}) {
3322
3401
  super(message, {
3323
3402
  code: "COMPANY_NOT_FOUND",
@@ -3328,7 +3407,7 @@ var CompanyNotFoundError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
3328
3407
  this.name = "CompanyNotFoundError";
3329
3408
  }
3330
3409
  };
3331
- var ContactCreateFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
3410
+ var ContactCreateFailedError = class extends _chunkD5IVS6GYcjs.AutotaskError {
3332
3411
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
3333
3412
 
3334
3413
  constructor(message, vendorFields, options = {}) {
@@ -3338,25 +3417,25 @@ var ContactCreateFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
3338
3417
  }
3339
3418
  };
3340
3419
  async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3341
- const cid = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, companyID, "companyID");
3420
+ const cid = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, companyID, "companyID");
3342
3421
  if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
3343
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
3422
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
3344
3423
  `upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
3345
3424
  { operation: OP_UPSERT_EMAIL }
3346
3425
  );
3347
3426
  }
3348
3427
  if (extra !== void 0) {
3349
3428
  if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
3350
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
3429
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
3351
3430
  `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)})`,
3352
3431
  { operation: OP_UPSERT_EMAIL }
3353
3432
  );
3354
3433
  }
3355
3434
  if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
3356
- throw new (0, _chunkZJ4ONAQFcjs.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 });
3435
+ throw new (0, _chunkD5IVS6GYcjs.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 });
3357
3436
  }
3358
3437
  if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
3359
- throw new (0, _chunkZJ4ONAQFcjs.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 });
3438
+ throw new (0, _chunkD5IVS6GYcjs.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 });
3360
3439
  }
3361
3440
  }
3362
3441
  const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
@@ -3377,7 +3456,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3377
3456
  const match = q.items[0];
3378
3457
  if (match !== void 0) {
3379
3458
  if (opts.dryRun === true) {
3380
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
3459
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
3381
3460
  {
3382
3461
  operation: OP_UPSERT_EMAIL,
3383
3462
  method: "POST",
@@ -3398,16 +3477,16 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3398
3477
  return { id: Number(match.id), created: false, existing: match };
3399
3478
  }
3400
3479
  const localPart = email.split("@")[0];
3401
- const isActive = _optionalChain([extra, 'optionalAccess', _40 => _40.isActive]) === void 0 ? true : extra.isActive;
3480
+ const isActive = _optionalChain([extra, 'optionalAccess', _45 => _45.isActive]) === void 0 ? true : extra.isActive;
3402
3481
  const body = {
3403
3482
  emailAddress: email,
3404
3483
  companyID: cid,
3405
- firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _41 => _41.firstName]), () => ( localPart)),
3406
- lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _42 => _42.lastName]), () => ( "Unknown")),
3484
+ firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _46 => _46.firstName]), () => ( localPart)),
3485
+ lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _47 => _47.lastName]), () => ( "Unknown")),
3407
3486
  isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
3408
3487
  };
3409
3488
  if (opts.dryRun === true) {
3410
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
3489
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
3411
3490
  {
3412
3491
  operation: OP_UPSERT_EMAIL,
3413
3492
  method: "POST",
@@ -3430,8 +3509,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3430
3509
  const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
3431
3510
  return { id: created.id, created: true };
3432
3511
  } catch (err) {
3433
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
3434
- const named = (_nullishCoalesce(_chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
3512
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
3513
+ const named = (_nullishCoalesce(_chunkD5IVS6GYcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
3435
3514
  const seen = /* @__PURE__ */ new Set();
3436
3515
  const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
3437
3516
  const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
@@ -3445,7 +3524,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3445
3524
  }
3446
3525
  continue;
3447
3526
  }
3448
- const detail = _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError);
3527
+ const detail = _chunkD5IVS6GYcjs.formatVendorDetail.call(void 0, err.vendorError);
3449
3528
  throw new ContactCreateFailedError(
3450
3529
  `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}` : ""}`,
3451
3530
  unique,
@@ -3462,7 +3541,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3462
3541
  }
3463
3542
 
3464
3543
  // src/resources/contacts.ts
3465
- var ContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3544
+ var ContactsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3466
3545
  constructor(http, pageSize) {
3467
3546
  super(http, {
3468
3547
  key: "contacts",
@@ -3533,7 +3612,7 @@ var ContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3533
3612
  /** Search Contact records: bounded contains on firstName + lastName (no vendor free-text search exists);
3534
3613
  * limit defaults to 25, max 500. */
3535
3614
  async search(query, opts) {
3536
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _43 => _43.limit]) });
3615
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _48 => _48.limit]) });
3537
3616
  }
3538
3617
  /** Get the Contact with its primary context records in one call (each part a single-record
3539
3618
  * fetch; no sub-lists; absent/dangling references come back null). */
@@ -3554,7 +3633,7 @@ var ContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3554
3633
  };
3555
3634
 
3556
3635
  // src/resources/contact_webhooks.ts
3557
- var ContactWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3636
+ var ContactWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3558
3637
  constructor(http, pageSize) {
3559
3638
  super(http, {
3560
3639
  key: "contact_webhooks",
@@ -3625,12 +3704,12 @@ var ContactWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3625
3704
  /** Search ContactWebhook records: bounded contains on name (no vendor free-text search exists);
3626
3705
  * limit defaults to 25, max 500. */
3627
3706
  async search(query, opts) {
3628
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _44 => _44.limit]) });
3707
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _49 => _49.limit]) });
3629
3708
  }
3630
3709
  };
3631
3710
 
3632
3711
  // src/resources/contract_billing_rules.ts
3633
- var ContractBillingRulesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3712
+ var ContractBillingRulesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3634
3713
  constructor(http, pageSize) {
3635
3714
  super(http, {
3636
3715
  key: "contract_billing_rules",
@@ -3696,7 +3775,7 @@ var ContractBillingRulesResource = class extends _chunkZJ4ONAQFcjs.BaseResource
3696
3775
  };
3697
3776
 
3698
3777
  // src/resources/contract_block_hour_factors.ts
3699
- var ContractBlockHourFactorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3778
+ var ContractBlockHourFactorsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3700
3779
  constructor(http, pageSize) {
3701
3780
  super(http, {
3702
3781
  key: "contract_block_hour_factors",
@@ -3755,7 +3834,7 @@ var ContractBlockHourFactorsResource = class extends _chunkZJ4ONAQFcjs.BaseResou
3755
3834
  };
3756
3835
 
3757
3836
  // src/resources/contract_blocks.ts
3758
- var ContractBlocksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3837
+ var ContractBlocksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3759
3838
  constructor(http, pageSize) {
3760
3839
  super(http, {
3761
3840
  key: "contract_blocks",
@@ -3814,7 +3893,7 @@ var ContractBlocksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3814
3893
  };
3815
3894
 
3816
3895
  // src/resources/contract_charges.ts
3817
- var ContractChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3896
+ var ContractChargesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3818
3897
  constructor(http, pageSize) {
3819
3898
  super(http, {
3820
3899
  key: "contract_charges",
@@ -3880,12 +3959,12 @@ var ContractChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3880
3959
  /** Search ContractCharge records: bounded contains on name (no vendor free-text search exists);
3881
3960
  * limit defaults to 25, max 500. */
3882
3961
  async search(query, opts) {
3883
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _45 => _45.limit]) });
3962
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _50 => _50.limit]) });
3884
3963
  }
3885
3964
  };
3886
3965
 
3887
3966
  // src/resources/contract_exclusion_billing_codes.ts
3888
- var ContractExclusionBillingCodesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
3967
+ var ContractExclusionBillingCodesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3889
3968
  constructor(http, pageSize) {
3890
3969
  super(http, {
3891
3970
  key: "contract_exclusion_billing_codes",
@@ -3942,7 +4021,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkZJ4ONAQFcjs.Base
3942
4021
  };
3943
4022
 
3944
4023
  // src/resources/contract_exclusion_roles.ts
3945
- var ContractExclusionRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4024
+ var ContractExclusionRolesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
3946
4025
  constructor(http, pageSize) {
3947
4026
  super(http, {
3948
4027
  key: "contract_exclusion_roles",
@@ -3999,7 +4078,7 @@ var ContractExclusionRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
3999
4078
  };
4000
4079
 
4001
4080
  // src/resources/contract_exclusion_set_excluded_roles.ts
4002
- var ContractExclusionSetExcludedRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4081
+ var ContractExclusionSetExcludedRolesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4003
4082
  constructor(http, pageSize) {
4004
4083
  super(http, {
4005
4084
  key: "contract_exclusion_set_excluded_roles",
@@ -4056,7 +4135,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkZJ4ONAQFcjs.
4056
4135
  };
4057
4136
 
4058
4137
  // src/resources/contract_exclusion_set_excluded_work_types.ts
4059
- var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4138
+ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4060
4139
  constructor(http, pageSize) {
4061
4140
  super(http, {
4062
4141
  key: "contract_exclusion_set_excluded_work_types",
@@ -4113,7 +4192,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkZJ4ONAQF
4113
4192
  };
4114
4193
 
4115
4194
  // src/resources/contract_exclusion_sets.ts
4116
- var ContractExclusionSetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4195
+ var ContractExclusionSetsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4117
4196
  constructor(http, pageSize) {
4118
4197
  super(http, {
4119
4198
  key: "contract_exclusion_sets",
@@ -4182,12 +4261,12 @@ var ContractExclusionSetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
4182
4261
  /** Search ContractExclusionSets records: bounded contains on name (no vendor free-text search exists);
4183
4262
  * limit defaults to 25, max 500. */
4184
4263
  async search(query, opts) {
4185
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _46 => _46.limit]) });
4264
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _51 => _51.limit]) });
4186
4265
  }
4187
4266
  };
4188
4267
 
4189
4268
  // src/resources/contract_milestones.ts
4190
- var ContractMilestonesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4269
+ var ContractMilestonesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4191
4270
  constructor(http, pageSize) {
4192
4271
  super(http, {
4193
4272
  key: "contract_milestones",
@@ -4246,7 +4325,7 @@ var ContractMilestonesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4246
4325
  };
4247
4326
 
4248
4327
  // src/resources/contract_notes.ts
4249
- var ContractNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4328
+ var ContractNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4250
4329
  constructor(http, pageSize) {
4251
4330
  super(http, {
4252
4331
  key: "contract_notes",
@@ -4305,7 +4384,7 @@ var ContractNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4305
4384
  };
4306
4385
 
4307
4386
  // src/resources/contract_rates.ts
4308
- var ContractRatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4387
+ var ContractRatesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4309
4388
  constructor(http, pageSize) {
4310
4389
  super(http, {
4311
4390
  key: "contract_rates",
@@ -4364,7 +4443,7 @@ var ContractRatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4364
4443
  };
4365
4444
 
4366
4445
  // src/resources/contract_retainers.ts
4367
- var ContractRetainersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4446
+ var ContractRetainersResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4368
4447
  constructor(http, pageSize) {
4369
4448
  super(http, {
4370
4449
  key: "contract_retainers",
@@ -4423,7 +4502,7 @@ var ContractRetainersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4423
4502
  };
4424
4503
 
4425
4504
  // src/resources/contract_role_costs.ts
4426
- var ContractRoleCostsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4505
+ var ContractRoleCostsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4427
4506
  constructor(http, pageSize) {
4428
4507
  super(http, {
4429
4508
  key: "contract_role_costs",
@@ -4482,7 +4561,7 @@ var ContractRoleCostsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4482
4561
  };
4483
4562
 
4484
4563
  // src/resources/contract_service_adjustments.ts
4485
- var ContractServiceAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4564
+ var ContractServiceAdjustmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4486
4565
  constructor(http, pageSize) {
4487
4566
  super(http, {
4488
4567
  key: "contract_service_adjustments",
@@ -4516,7 +4595,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.BaseRes
4516
4595
  };
4517
4596
 
4518
4597
  // src/resources/contract_service_bundle_adjustments.ts
4519
- var ContractServiceBundleAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4598
+ var ContractServiceBundleAdjustmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4520
4599
  constructor(http, pageSize) {
4521
4600
  super(http, {
4522
4601
  key: "contract_service_bundle_adjustments",
@@ -4550,7 +4629,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.B
4550
4629
  };
4551
4630
 
4552
4631
  // src/resources/contract_service_bundles.ts
4553
- var ContractServiceBundlesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4632
+ var ContractServiceBundlesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4554
4633
  constructor(http, pageSize) {
4555
4634
  super(http, {
4556
4635
  key: "contract_service_bundles",
@@ -4609,7 +4688,7 @@ var ContractServiceBundlesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
4609
4688
  };
4610
4689
 
4611
4690
  // src/resources/contract_service_bundle_units.ts
4612
- var ContractServiceBundleUnitsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4691
+ var ContractServiceBundleUnitsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4613
4692
  constructor(http, pageSize) {
4614
4693
  super(http, {
4615
4694
  key: "contract_service_bundle_units",
@@ -4651,7 +4730,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkZJ4ONAQFcjs.BaseRes
4651
4730
  };
4652
4731
 
4653
4732
  // src/resources/contract_services.ts
4654
- var ContractServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4733
+ var ContractServicesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4655
4734
  constructor(http, pageSize) {
4656
4735
  super(http, {
4657
4736
  key: "contract_services",
@@ -4710,7 +4789,7 @@ var ContractServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4710
4789
  };
4711
4790
 
4712
4791
  // src/resources/contract_service_units.ts
4713
- var ContractServiceUnitsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
4792
+ var ContractServiceUnitsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
4714
4793
  constructor(http, pageSize) {
4715
4794
  super(http, {
4716
4795
  key: "contract_service_units",
@@ -4978,7 +5057,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
4978
5057
  // src/resources/special/contracts/profitability.validate.ts
4979
5058
  function validateProfitabilityOptions(contractId, opts) {
4980
5059
  if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
4981
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
5060
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
4982
5061
  `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})`,
4983
5062
  { operation: "contracts.profitability" }
4984
5063
  );
@@ -5055,12 +5134,12 @@ function validateProfitabilityOptions(contractId, opts) {
5055
5134
  }
5056
5135
  }
5057
5136
  try {
5058
- _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, contractId, "contractId");
5137
+ _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, contractId, "contractId");
5059
5138
  } catch (err) {
5060
- problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
5139
+ problems.push(err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
5061
5140
  }
5062
5141
  if (problems.length > 0) {
5063
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
5142
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
5064
5143
  `profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
5065
5144
  - ` + problems.join("\n- "),
5066
5145
  { operation: "contracts.profitability" }
@@ -5109,23 +5188,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
5109
5188
  const byKey = /* @__PURE__ */ new Map();
5110
5189
  const misses = [];
5111
5190
  const notes = [];
5112
- for (let c = 0; c < unique.length; c += _chunkZJ4ONAQFcjs.FETCH_BY_IDS_CHUNK_SIZE) {
5113
- const chunk = unique.slice(c, c + _chunkZJ4ONAQFcjs.FETCH_BY_IDS_CHUNK_SIZE);
5191
+ for (let c = 0; c < unique.length; c += _chunkD5IVS6GYcjs.FETCH_BY_IDS_CHUNK_SIZE) {
5192
+ const chunk = unique.slice(c, c + _chunkD5IVS6GYcjs.FETCH_BY_IDS_CHUNK_SIZE);
5114
5193
  const chunkKeys = new Set(chunk);
5115
5194
  try {
5116
5195
  const body = {
5117
- MaxRecords: _chunkZJ4ONAQFcjs.FETCH_BY_IDS_CHUNK_SIZE,
5196
+ MaxRecords: _chunkD5IVS6GYcjs.FETCH_BY_IDS_CHUNK_SIZE,
5118
5197
  filter: [{ field: "id", op: "in", value: chunk }],
5119
5198
  IncludeFields: fields
5120
5199
  };
5121
5200
  const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
5122
- const { items: rows } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
5201
+ const { items: rows } = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, operation);
5123
5202
  for (const row of rows) {
5124
5203
  const k = num(row.id);
5125
5204
  if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
5126
5205
  }
5127
5206
  } catch (err) {
5128
- const code = err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.code : "SERVER_ERROR";
5207
+ const code = err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.code : "SERVER_ERROR";
5129
5208
  for (const k of chunk) {
5130
5209
  if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
5131
5210
  }
@@ -5135,11 +5214,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
5135
5214
  for (const k of queryMissed) {
5136
5215
  try {
5137
5216
  const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
5138
- byKey.set(k, _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, k, operation, entity));
5217
+ byKey.set(k, _chunkD5IVS6GYcjs.unwrapItem.call(void 0, res, k, operation, entity));
5139
5218
  } catch (err) {
5140
- if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) {
5219
+ if (err instanceof _chunkD5IVS6GYcjs.NotFoundError) {
5141
5220
  misses.push({ id: k, code: "NOT_FOUND", message: err.message });
5142
- } else if (err instanceof _chunkZJ4ONAQFcjs.AutotaskError) {
5221
+ } else if (err instanceof _chunkD5IVS6GYcjs.AutotaskError) {
5143
5222
  misses.push({ id: k, code: err.code, message: err.message });
5144
5223
  } else {
5145
5224
  misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
@@ -5193,7 +5272,7 @@ async function degradable(read) {
5193
5272
  try {
5194
5273
  return await read();
5195
5274
  } catch (err) {
5196
- if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
5275
+ if (!(err instanceof _chunkD5IVS6GYcjs.AutotaskError)) throw err;
5197
5276
  return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
5198
5277
  }
5199
5278
  }
@@ -5213,15 +5292,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
5213
5292
  status: st.status,
5214
5293
  blindSurface: st.blindSurface,
5215
5294
  note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
5216
- emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkZJ4ONAQFcjs.EMPTY_REASON_STAMPS, 'access', _47 => _47[key], 'optionalAccess', _48 => _48.query]) : void 0
5295
+ emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkD5IVS6GYcjs.EMPTY_REASON_STAMPS, 'access', _52 => _52[key], 'optionalAccess', _53 => _53.query]) : void 0
5217
5296
  };
5218
5297
  };
5219
5298
  function appendWiresNote(wires, note) {
5220
5299
  wires.note = (wires.note ? wires.note + " | " : "") + note;
5221
5300
  }
5222
5301
  function makeFetchCtx(rawHttp, v, contractId, budget) {
5223
- const OP7 = PROFITABILITY_OP;
5224
- const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, contractId, "contractId");
5302
+ const OP9 = PROFITABILITY_OP;
5303
+ const id = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, contractId, "contractId");
5225
5304
  const idNum = typeof id === "number" ? id : Number(id);
5226
5305
  const wires = { issued: 0, requests: 0, budget };
5227
5306
  const toExcl = dayAfter(v.dateTo);
@@ -5232,19 +5311,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
5232
5311
  } };
5233
5312
  const readPart = (path, conditions, fields) => {
5234
5313
  wires.issued += 1;
5235
- return degradable(() => boundedPart(http, path, conditions, v.limit, OP7, fields));
5314
+ return degradable(() => boundedPart(http, path, conditions, v.limit, OP9, fields));
5236
5315
  };
5237
5316
  const truncatedMonths = {};
5238
5317
  const windowedPart = async (name, key, path, cond, fields, dateField) => {
5239
5318
  const first = await readPart(path, cond, fields);
5240
5319
  if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
5241
- const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP7, fields, dateField, v.dateFrom, v.dateTo, wires));
5320
+ const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP9, fields, dateField, v.dateFrom, v.dateTo, wires));
5242
5321
  if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
5243
5322
  const { truncatedMonths: tm, ...part } = wp;
5244
5323
  truncatedMonths[name] = tm;
5245
5324
  return { part, rows: wp.items };
5246
5325
  };
5247
- return { v, OP: OP7, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
5326
+ return { v, OP: OP9, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
5248
5327
  }
5249
5328
 
5250
5329
  // src/resources/special/contracts/profitability.stages.ts
@@ -5259,12 +5338,12 @@ async function fetchCustomer(ctx, companyID) {
5259
5338
  path: `/V1.0/Companies/${companyID}`,
5260
5339
  operation: ctx.OP
5261
5340
  });
5262
- const item = _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
5341
+ const item = _chunkD5IVS6GYcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
5263
5342
  customer = _nullishCoalesce(item, () => ( null));
5264
5343
  customerStatus = "ok";
5265
5344
  } catch (err) {
5266
- if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
5267
- if (!(err instanceof _chunkZJ4ONAQFcjs.NotFoundError)) {
5345
+ if (!(err instanceof _chunkD5IVS6GYcjs.AutotaskError)) throw err;
5346
+ if (!(err instanceof _chunkD5IVS6GYcjs.NotFoundError)) {
5268
5347
  customerStatus = "absent";
5269
5348
  customerAbsent = err.code;
5270
5349
  }
@@ -5278,9 +5357,9 @@ async function resolveContractType(ctx, contractType) {
5278
5357
  if (contractType > 0) {
5279
5358
  ctx.wires.issued += 1;
5280
5359
  try {
5281
- contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _49 => _49.get, 'call', async _50 => _50("contractType"), 'optionalAccess', async _51 => _51.get, 'call', async _52 => _52(contractType)]), async () => ( null));
5360
+ contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _54 => _54.get, 'call', async _55 => _55("contractType"), 'optionalAccess', async _56 => _56.get, 'call', async _57 => _57(contractType)]), async () => ( null));
5282
5361
  } catch (err) {
5283
- if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
5362
+ if (!(err instanceof _chunkD5IVS6GYcjs.AutotaskError)) throw err;
5284
5363
  }
5285
5364
  }
5286
5365
  const contractTypeKnown = contractTypeLabel !== null;
@@ -5289,7 +5368,7 @@ async function resolveContractType(ctx, contractType) {
5289
5368
  return { contractTypeLabel, contractTypeKnown, isBlockHours, isTimeAndMaterials };
5290
5369
  }
5291
5370
  async function fetchRoot(ctx, resource) {
5292
- const contractCached = _optionalChain([ctx, 'access', _53 => _53.rawHttp, 'access', _54 => _54.readCache, 'optionalAccess', _55 => _55.get, 'call', _56 => _56(`/V1.0/Contracts/${ctx.id}`)]) !== void 0;
5371
+ const contractCached = _optionalChain([ctx, 'access', _58 => _58.rawHttp, 'access', _59 => _59.readCache, 'optionalAccess', _60 => _60.get, 'call', _61 => _61(`/V1.0/Contracts/${ctx.id}`)]) !== void 0;
5293
5372
  const contract = await resource.get(ctx.id);
5294
5373
  ctx.wires.issued += 1;
5295
5374
  if (!contractCached) ctx.wires.requests += 1;
@@ -5342,8 +5421,8 @@ async function fetchInvoices(ctx, billingRows) {
5342
5421
  if (invoiceIds.length === 0) {
5343
5422
  return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
5344
5423
  }
5345
- const capped = capJoinSet2(invoiceIds, _chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS);
5346
- if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5424
+ const capped = capJoinSet2(invoiceIds, _chunkD5IVS6GYcjs.FETCH_BY_IDS_MAX_ITEMS);
5425
+ if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunkD5IVS6GYcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5347
5426
  const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
5348
5427
  ctx.wires.issued += 1;
5349
5428
  return {
@@ -5389,7 +5468,7 @@ async function readOpenStatusSet(ctx) {
5389
5468
  }
5390
5469
  }
5391
5470
  } catch (err) {
5392
- statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
5471
+ statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkD5IVS6GYcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
5393
5472
  }
5394
5473
  return { openStatusSet, statusNote };
5395
5474
  }
@@ -5412,8 +5491,8 @@ async function fetchResources(ctx, entries) {
5412
5491
  if (resourceIds.length === 0) {
5413
5492
  return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
5414
5493
  }
5415
- const capped = capJoinSet2(resourceIds, _chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS);
5416
- if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5494
+ const capped = capJoinSet2(resourceIds, _chunkD5IVS6GYcjs.FETCH_BY_IDS_MAX_ITEMS);
5495
+ if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunkD5IVS6GYcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5417
5496
  const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
5418
5497
  ctx.wires.issued += 1;
5419
5498
  for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
@@ -5480,7 +5559,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
5480
5559
  try {
5481
5560
  return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
5482
5561
  } catch (err) {
5483
- if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
5562
+ if (!(err instanceof _chunkD5IVS6GYcjs.AutotaskError)) throw err;
5484
5563
  return null;
5485
5564
  }
5486
5565
  }
@@ -5497,17 +5576,17 @@ async function fetchSubscriptions(ctx, cis) {
5497
5576
  cancelledSubs
5498
5577
  };
5499
5578
  }
5500
- const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS);
5579
+ const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunkD5IVS6GYcjs.FETCH_BY_IDS_MAX_ITEMS);
5501
5580
  const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
5502
5581
  const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
5503
5582
  const subscriptions = raw.items;
5504
5583
  const labels = await readSubscriptionLabels(ctx, subscriptions);
5505
5584
  for (const x of subscriptions) {
5506
5585
  const sid = num(x["id"]);
5507
- const periodLabel = _optionalChain([labels, 'optionalAccess', _57 => _57.get, 'call', _58 => _58("periodType"), 'optionalAccess', _59 => _59.get, 'call', _60 => _60(num(x["periodType"]))]);
5586
+ const periodLabel = _optionalChain([labels, 'optionalAccess', _62 => _62.get, 'call', _63 => _63("periodType"), 'optionalAccess', _64 => _64.get, 'call', _65 => _65(num(x["periodType"]))]);
5508
5587
  subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
5509
5588
  if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
5510
- const statusLabel = _optionalChain([labels, 'optionalAccess', _61 => _61.get, 'call', _62 => _62("status"), 'optionalAccess', _63 => _63.get, 'call', _64 => _64(num(x["status"]))]);
5589
+ const statusLabel = _optionalChain([labels, 'optionalAccess', _66 => _66.get, 'call', _67 => _67("status"), 'optionalAccess', _68 => _68.get, 'call', _69 => _69(num(x["status"]))]);
5511
5590
  const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num(x["status"]));
5512
5591
  if (notActive) cancelledSubs.add(sid);
5513
5592
  }
@@ -6182,7 +6261,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
6182
6261
  }
6183
6262
 
6184
6263
  // src/resources/contracts.ts
6185
- var ContractsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6264
+ var ContractsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6186
6265
  constructor(http, pageSize) {
6187
6266
  super(http, {
6188
6267
  key: "contracts",
@@ -6244,7 +6323,7 @@ var ContractsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6244
6323
  /** Search Contract records: bounded contains on contractName (no vendor free-text search exists);
6245
6324
  * limit defaults to 25, max 500. */
6246
6325
  async search(query, opts) {
6247
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _65 => _65.limit]) });
6326
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _70 => _70.limit]) });
6248
6327
  }
6249
6328
  /** Node-parity special op (hand-written in src/resources/special/contracts.ts). */
6250
6329
  profitability(id, opts) {
@@ -6253,7 +6332,7 @@ var ContractsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6253
6332
  };
6254
6333
 
6255
6334
  // src/resources/contract_ticket_purchases.ts
6256
- var ContractTicketPurchasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6335
+ var ContractTicketPurchasesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6257
6336
  constructor(http, pageSize) {
6258
6337
  super(http, {
6259
6338
  key: "contract_ticket_purchases",
@@ -6312,7 +6391,7 @@ var ContractTicketPurchasesResource = class extends _chunkZJ4ONAQFcjs.BaseResour
6312
6391
  };
6313
6392
 
6314
6393
  // src/resources/countries.ts
6315
- var CountriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6394
+ var CountriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6316
6395
  constructor(http, pageSize) {
6317
6396
  super(http, {
6318
6397
  key: "countries",
@@ -6366,12 +6445,12 @@ var CountriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6366
6445
  /** Search Country records: bounded contains on name (no vendor free-text search exists);
6367
6446
  * limit defaults to 25, max 500. */
6368
6447
  async search(query, opts) {
6369
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _66 => _66.limit]) });
6448
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _71 => _71.limit]) });
6370
6449
  }
6371
6450
  };
6372
6451
 
6373
6452
  // src/resources/currencies.ts
6374
- var CurrenciesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6453
+ var CurrenciesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6375
6454
  constructor(http, pageSize) {
6376
6455
  super(http, {
6377
6456
  key: "currencies",
@@ -6410,12 +6489,12 @@ var CurrenciesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6410
6489
  /** Search Currency records: bounded contains on name (no vendor free-text search exists);
6411
6490
  * limit defaults to 25, max 500. */
6412
6491
  async search(query, opts) {
6413
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _67 => _67.limit]) });
6492
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _72 => _72.limit]) });
6414
6493
  }
6415
6494
  };
6416
6495
 
6417
6496
  // src/resources/departments.ts
6418
- var DepartmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6497
+ var DepartmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6419
6498
  constructor(http, pageSize) {
6420
6499
  super(http, {
6421
6500
  key: "departments",
@@ -6477,12 +6556,12 @@ var DepartmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6477
6556
  /** Search Department records: bounded contains on name (no vendor free-text search exists);
6478
6557
  * limit defaults to 25, max 500. */
6479
6558
  async search(query, opts) {
6480
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _68 => _68.limit]) });
6559
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _73 => _73.limit]) });
6481
6560
  }
6482
6561
  };
6483
6562
 
6484
6563
  // src/resources/domain_registrars.ts
6485
- var DomainRegistrarsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6564
+ var DomainRegistrarsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6486
6565
  constructor(http, pageSize) {
6487
6566
  super(http, {
6488
6567
  key: "domain_registrars",
@@ -6544,7 +6623,7 @@ var DomainRegistrarsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6544
6623
  /** Search DomainRegistrar records: bounded contains on name (no vendor free-text search exists);
6545
6624
  * limit defaults to 25, max 500. */
6546
6625
  async search(query, opts) {
6547
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _69 => _69.limit]) });
6626
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _74 => _74.limit]) });
6548
6627
  }
6549
6628
  };
6550
6629
 
@@ -6565,7 +6644,7 @@ var EntityInformationResource = class {
6565
6644
  };
6566
6645
 
6567
6646
  // src/resources/expense_item_attachments.ts
6568
- var ExpenseItemAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6647
+ var ExpenseItemAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6569
6648
  constructor(http, pageSize) {
6570
6649
  super(http, {
6571
6650
  key: "expense_item_attachments",
@@ -6627,7 +6706,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
6627
6706
  };
6628
6707
 
6629
6708
  // src/resources/expense_items.ts
6630
- var ExpenseItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6709
+ var ExpenseItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6631
6710
  constructor(http, pageSize) {
6632
6711
  super(http, {
6633
6712
  key: "expense_items",
@@ -6686,7 +6765,7 @@ var ExpenseItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6686
6765
  };
6687
6766
 
6688
6767
  // src/resources/expense_reports.ts
6689
- var ExpenseReportsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6768
+ var ExpenseReportsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6690
6769
  constructor(http, pageSize) {
6691
6770
  super(http, {
6692
6771
  key: "expense_reports",
@@ -6748,12 +6827,12 @@ var ExpenseReportsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6748
6827
  /** Search ExpenseReport records: bounded contains on name (no vendor free-text search exists);
6749
6828
  * limit defaults to 25, max 500. */
6750
6829
  async search(query, opts) {
6751
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _70 => _70.limit]) });
6830
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _75 => _75.limit]) });
6752
6831
  }
6753
6832
  };
6754
6833
 
6755
6834
  // src/resources/holiday_sets.ts
6756
- var HolidaySetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6835
+ var HolidaySetsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6757
6836
  constructor(http, pageSize) {
6758
6837
  super(http, {
6759
6838
  key: "holiday_sets",
@@ -6822,7 +6901,7 @@ var HolidaySetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6822
6901
  };
6823
6902
 
6824
6903
  // src/resources/holidays.ts
6825
- var HolidaysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
6904
+ var HolidaysResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6826
6905
  constructor(http, pageSize) {
6827
6906
  super(http, {
6828
6907
  key: "holidays",
@@ -6894,10 +6973,10 @@ var PATH_SUFFIX = {
6894
6973
  transfer: "StockedItemsTransfer"
6895
6974
  };
6896
6975
  async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
6897
- const numericParent = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, parentId, "parentId");
6976
+ const numericParent = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, parentId, "parentId");
6898
6977
  const suffix = PATH_SUFFIX[kind];
6899
6978
  if (opts.dryRun === true) {
6900
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
6979
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
6901
6980
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
6902
6981
  method: "POST",
6903
6982
  path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
@@ -6914,11 +6993,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
6914
6993
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
6915
6994
  maxRetries: opts.maxRetries
6916
6995
  });
6917
- return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
6996
+ return _chunkD5IVS6GYcjs.unwrapOperation.call(void 0, res);
6918
6997
  }
6919
6998
 
6920
6999
  // src/resources/inventory_products.ts
6921
- var InventoryProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7000
+ var InventoryProductsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
6922
7001
  constructor(http, pageSize) {
6923
7002
  super(http, {
6924
7003
  key: "inventory_products",
@@ -7000,7 +7079,7 @@ var InventoryProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7000
7079
 
7001
7080
  // src/resources/special/invoices.ts
7002
7081
  async function markup(_resource, id, format, http) {
7003
- const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
7082
+ const numericId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
7004
7083
  const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
7005
7084
  const res = await http.request({
7006
7085
  method: "GET",
@@ -7009,7 +7088,7 @@ async function markup(_resource, id, format, http) {
7009
7088
  });
7010
7089
  const body = res;
7011
7090
  if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
7012
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(
7091
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskError)(
7013
7092
  `Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
7014
7093
  { code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
7015
7094
  );
@@ -7017,44 +7096,44 @@ async function markup(_resource, id, format, http) {
7017
7096
  return body.invoiceMarkup;
7018
7097
  }
7019
7098
  async function pdf(_resource, id, http) {
7020
- const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
7099
+ const numericId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
7021
7100
  const res = await http.request({
7022
7101
  method: "GET",
7023
7102
  path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
7024
7103
  operation: "invoices.pdf"
7025
7104
  });
7026
- return _chunkZJ4ONAQFcjs.decodeFileData.call(void 0, res);
7105
+ return _chunkD5IVS6GYcjs.decodeFileData.call(void 0, res);
7027
7106
  }
7028
7107
  async function windowQuery2(_resource, kind, http, opts) {
7029
- const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _71 => _71.now]), () => ( /* @__PURE__ */ new Date()));
7030
- const tz = _optionalChain([opts, 'optionalAccess', _72 => _72.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
7108
+ const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _76 => _76.now]), () => ( /* @__PURE__ */ new Date()));
7109
+ const tz = _optionalChain([opts, 'optionalAccess', _77 => _77.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
7031
7110
  return dateWindowQuery(
7032
7111
  http,
7033
7112
  "/V1.0/Invoices/query",
7034
7113
  "invoiceDateTime",
7035
7114
  kind,
7036
- clampWindowLimit(_optionalChain([opts, 'optionalAccess', _73 => _73.limit])),
7115
+ clampWindowLimit(_optionalChain([opts, 'optionalAccess', _78 => _78.limit])),
7037
7116
  `invoices.${kind}`,
7038
7117
  now,
7039
7118
  tz
7040
7119
  );
7041
7120
  }
7042
7121
  async function customRange2(_resource, from, to, http, opts) {
7043
- const zone = _optionalChain([opts, 'optionalAccess', _74 => _74.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
7122
+ const zone = _optionalChain([opts, 'optionalAccess', _79 => _79.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
7044
7123
  return customRangeQuery(
7045
7124
  http,
7046
7125
  "/V1.0/Invoices/query",
7047
7126
  "invoiceDateTime",
7048
7127
  from,
7049
7128
  to,
7050
- clampWindowLimit(_optionalChain([opts, 'optionalAccess', _75 => _75.limit])),
7129
+ clampWindowLimit(_optionalChain([opts, 'optionalAccess', _80 => _80.limit])),
7051
7130
  "invoices.customRange",
7052
7131
  zone
7053
7132
  );
7054
7133
  }
7055
7134
 
7056
7135
  // src/resources/invoices.ts
7057
- var InvoicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7136
+ var InvoicesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7058
7137
  constructor(http, pageSize) {
7059
7138
  super(http, {
7060
7139
  key: "invoices",
@@ -7168,7 +7247,7 @@ var InvoicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7168
7247
  };
7169
7248
 
7170
7249
  // src/resources/invoice_templates.ts
7171
- var InvoiceTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7250
+ var InvoiceTemplatesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7172
7251
  constructor(http, pageSize) {
7173
7252
  super(http, {
7174
7253
  key: "invoice_templates",
@@ -7212,7 +7291,7 @@ var ModulesResource = class {
7212
7291
  };
7213
7292
 
7214
7293
  // src/resources/notification_history.ts
7215
- var NotificationHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7294
+ var NotificationHistoryResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7216
7295
  constructor(http, pageSize) {
7217
7296
  super(http, {
7218
7297
  key: "notification_history",
@@ -7251,7 +7330,7 @@ var NotificationHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7251
7330
  };
7252
7331
 
7253
7332
  // src/resources/opportunities.ts
7254
- var OpportunitiesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7333
+ var OpportunitiesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7255
7334
  constructor(http, pageSize) {
7256
7335
  super(http, {
7257
7336
  key: "opportunities",
@@ -7313,7 +7392,7 @@ var OpportunitiesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7313
7392
  };
7314
7393
 
7315
7394
  // src/resources/opportunity_attachments.ts
7316
- var OpportunityAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7395
+ var OpportunityAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7317
7396
  constructor(http, pageSize) {
7318
7397
  super(http, {
7319
7398
  key: "opportunity_attachments",
@@ -7375,7 +7454,7 @@ var OpportunityAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
7375
7454
  };
7376
7455
 
7377
7456
  // src/resources/opportunity_categories.ts
7378
- var OpportunityCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7457
+ var OpportunityCategoriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7379
7458
  constructor(http, pageSize) {
7380
7459
  super(http, {
7381
7460
  key: "opportunity_categories",
@@ -7429,12 +7508,12 @@ var OpportunityCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource
7429
7508
  /** Search OpportunityCategory records: bounded contains on name (no vendor free-text search exists);
7430
7509
  * limit defaults to 25, max 500. */
7431
7510
  async search(query, opts) {
7432
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _76 => _76.limit]) });
7511
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
7433
7512
  }
7434
7513
  };
7435
7514
 
7436
7515
  // src/resources/organizational_level1s.ts
7437
- var OrganizationalLevel1sResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7516
+ var OrganizationalLevel1sResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7438
7517
  constructor(http, pageSize) {
7439
7518
  super(http, {
7440
7519
  key: "organizational_level1s",
@@ -7485,7 +7564,7 @@ var OrganizationalLevel1sResource = class extends _chunkZJ4ONAQFcjs.BaseResource
7485
7564
  };
7486
7565
 
7487
7566
  // src/resources/organizational_level2s.ts
7488
- var OrganizationalLevel2sResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7567
+ var OrganizationalLevel2sResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7489
7568
  constructor(http, pageSize) {
7490
7569
  super(http, {
7491
7570
  key: "organizational_level2s",
@@ -7536,7 +7615,7 @@ var OrganizationalLevel2sResource = class extends _chunkZJ4ONAQFcjs.BaseResource
7536
7615
  };
7537
7616
 
7538
7617
  // src/resources/organizational_level_associations.ts
7539
- var OrganizationalLevelAssociationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7618
+ var OrganizationalLevelAssociationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7540
7619
  constructor(http, pageSize) {
7541
7620
  super(http, {
7542
7621
  key: "organizational_level_associations",
@@ -7587,7 +7666,7 @@ var OrganizationalLevelAssociationsResource = class extends _chunkZJ4ONAQFcjs.Ba
7587
7666
  };
7588
7667
 
7589
7668
  // src/resources/phases.ts
7590
- var PhasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7669
+ var PhasesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7591
7670
  constructor(http, pageSize) {
7592
7671
  super(http, {
7593
7672
  key: "phases",
@@ -7646,7 +7725,7 @@ var PhasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7646
7725
  };
7647
7726
 
7648
7727
  // src/resources/products.ts
7649
- var ProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7728
+ var ProductsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7650
7729
  constructor(http, pageSize) {
7651
7730
  super(http, {
7652
7731
  key: "products",
@@ -7708,12 +7787,12 @@ var ProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7708
7787
  /** Search Product records: bounded contains on name (no vendor free-text search exists);
7709
7788
  * limit defaults to 25, max 500. */
7710
7789
  async search(query, opts) {
7711
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _77 => _77.limit]) });
7790
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
7712
7791
  }
7713
7792
  };
7714
7793
 
7715
7794
  // src/resources/product_vendors.ts
7716
- var ProductVendorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7795
+ var ProductVendorsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7717
7796
  constructor(http, pageSize) {
7718
7797
  super(http, {
7719
7798
  key: "product_vendors",
@@ -7772,7 +7851,7 @@ var ProductVendorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7772
7851
  };
7773
7852
 
7774
7853
  // src/resources/project_charges.ts
7775
- var ProjectChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7854
+ var ProjectChargesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7776
7855
  constructor(http, pageSize) {
7777
7856
  super(http, {
7778
7857
  key: "project_charges",
@@ -7838,12 +7917,12 @@ var ProjectChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7838
7917
  /** Search ProjectCharge records: bounded contains on name (no vendor free-text search exists);
7839
7918
  * limit defaults to 25, max 500. */
7840
7919
  async search(query, opts) {
7841
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _78 => _78.limit]) });
7920
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _83 => _83.limit]) });
7842
7921
  }
7843
7922
  };
7844
7923
 
7845
7924
  // src/resources/project_notes.ts
7846
- var ProjectNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7925
+ var ProjectNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7847
7926
  constructor(http, pageSize) {
7848
7927
  super(http, {
7849
7928
  key: "project_notes",
@@ -7902,7 +7981,7 @@ var ProjectNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7902
7981
  };
7903
7982
 
7904
7983
  // src/resources/projects.ts
7905
- var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7984
+ var ProjectsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7906
7985
  constructor(http, pageSize) {
7907
7986
  super(http, {
7908
7987
  key: "projects",
@@ -7964,7 +8043,7 @@ var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7964
8043
  /** Search Project records: bounded contains on projectName (no vendor free-text search exists);
7965
8044
  * limit defaults to 25, max 500. */
7966
8045
  async search(query, opts) {
7967
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _79 => _79.limit]) });
8046
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _84 => _84.limit]) });
7968
8047
  }
7969
8048
  /** Get the Project with its primary context records in one call (each part a single-record
7970
8049
  * fetch; no sub-lists; absent/dangling references come back null). `names: true` (issue #77)
@@ -7979,13 +8058,13 @@ var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7979
8058
  const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
7980
8059
  const result = { project: project2, company, opportunity, leadResource };
7981
8060
  if (opts.names === true) {
7982
- const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, );
8061
+ const builder = _chunkD5IVS6GYcjs.createNamePlan.call(void 0, );
7983
8062
  builder.addResource(root["creatorResourceID"]);
7984
8063
  builder.addFk("contract", root["contractID"]);
7985
- const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
8064
+ const names = await _chunkD5IVS6GYcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
7986
8065
  const row = { ...project2 };
7987
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
7988
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
8066
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
8067
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
7989
8068
  result.project = row;
7990
8069
  result.names = names.section;
7991
8070
  }
@@ -7994,7 +8073,7 @@ var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
7994
8073
  };
7995
8074
 
7996
8075
  // src/resources/purchase_approvals.ts
7997
- var PurchaseApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8076
+ var PurchaseApprovalsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
7998
8077
  constructor(http, pageSize) {
7999
8078
  super(http, {
8000
8079
  key: "purchase_approvals",
@@ -8048,7 +8127,7 @@ var PurchaseApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8048
8127
  };
8049
8128
 
8050
8129
  // src/resources/purchase_order_item_receiving.ts
8051
- var PurchaseOrderItemReceivingResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8130
+ var PurchaseOrderItemReceivingResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8052
8131
  constructor(http, pageSize) {
8053
8132
  super(http, {
8054
8133
  key: "purchase_order_item_receiving",
@@ -8098,7 +8177,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkZJ4ONAQFcjs.BaseRes
8098
8177
  };
8099
8178
 
8100
8179
  // src/resources/purchase_order_items.ts
8101
- var PurchaseOrderItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8180
+ var PurchaseOrderItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8102
8181
  constructor(http, pageSize) {
8103
8182
  super(http, {
8104
8183
  key: "purchase_order_items",
@@ -8157,7 +8236,7 @@ var PurchaseOrderItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8157
8236
  };
8158
8237
 
8159
8238
  // src/resources/purchase_orders.ts
8160
- var PurchaseOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8239
+ var PurchaseOrdersResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8161
8240
  constructor(http, pageSize) {
8162
8241
  super(http, {
8163
8242
  key: "purchase_orders",
@@ -8219,7 +8298,7 @@ var PurchaseOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8219
8298
  };
8220
8299
 
8221
8300
  // src/resources/quote_items.ts
8222
- var QuoteItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8301
+ var QuoteItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8223
8302
  constructor(http, pageSize) {
8224
8303
  super(http, {
8225
8304
  key: "quote_items",
@@ -8285,12 +8364,12 @@ var QuoteItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8285
8364
  /** Search QuoteItem records: bounded contains on name (no vendor free-text search exists);
8286
8365
  * limit defaults to 25, max 500. */
8287
8366
  async search(query, opts) {
8288
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _80 => _80.limit]) });
8367
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _85 => _85.limit]) });
8289
8368
  }
8290
8369
  };
8291
8370
 
8292
8371
  // src/resources/quote_locations.ts
8293
- var QuoteLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8372
+ var QuoteLocationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8294
8373
  constructor(http, pageSize) {
8295
8374
  super(http, {
8296
8375
  key: "quote_locations",
@@ -8355,7 +8434,7 @@ var QuoteLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8355
8434
  };
8356
8435
 
8357
8436
  // src/resources/quotes.ts
8358
- var QuotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8437
+ var QuotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8359
8438
  constructor(http, pageSize) {
8360
8439
  super(http, {
8361
8440
  key: "quotes",
@@ -8417,12 +8496,12 @@ var QuotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8417
8496
  /** Search Quote records: bounded contains on name (no vendor free-text search exists);
8418
8497
  * limit defaults to 25, max 500. */
8419
8498
  async search(query, opts) {
8420
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
8499
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _86 => _86.limit]) });
8421
8500
  }
8422
8501
  };
8423
8502
 
8424
8503
  // src/resources/quote_templates.ts
8425
- var QuoteTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8504
+ var QuoteTemplatesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8426
8505
  constructor(http, pageSize) {
8427
8506
  super(http, {
8428
8507
  key: "quote_templates",
@@ -8461,12 +8540,12 @@ var QuoteTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8461
8540
  /** Search QuoteTemplate records: bounded contains on name (no vendor free-text search exists);
8462
8541
  * limit defaults to 25, max 500. */
8463
8542
  async search(query, opts) {
8464
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
8543
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _87 => _87.limit]) });
8465
8544
  }
8466
8545
  };
8467
8546
 
8468
8547
  // src/resources/resource_role_queues.ts
8469
- var ResourceRoleQueuesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8548
+ var ResourceRoleQueuesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8470
8549
  constructor(http, pageSize) {
8471
8550
  super(http, {
8472
8551
  key: "resource_role_queues",
@@ -8525,7 +8604,7 @@ var ResourceRoleQueuesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8525
8604
  };
8526
8605
 
8527
8606
  // src/resources/resource_roles.ts
8528
- var ResourceRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8607
+ var ResourceRolesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8529
8608
  constructor(http, pageSize) {
8530
8609
  super(http, {
8531
8610
  key: "resource_roles",
@@ -8567,7 +8646,7 @@ var ResourceRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8567
8646
  };
8568
8647
 
8569
8648
  // src/resources/resource_skills.ts
8570
- var ResourceSkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8649
+ var ResourceSkillsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8571
8650
  constructor(http, pageSize) {
8572
8651
  super(http, {
8573
8652
  key: "resource_skills",
@@ -8621,16 +8700,16 @@ var ResourceSkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8621
8700
  var MAX_TRANSFER_IDS = 500;
8622
8701
  function requirePositiveIds(ids2, label) {
8623
8702
  if (!Array.isArray(ids2) || ids2.length === 0) {
8624
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
8703
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
8625
8704
  }
8626
8705
  if (ids2.length > MAX_TRANSFER_IDS) {
8627
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
8706
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
8628
8707
  }
8629
8708
  const out = [];
8630
8709
  for (const raw of ids2) {
8631
- const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, raw, `${label} id`);
8710
+ const id = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, raw, `${label} id`);
8632
8711
  if (typeof id === "number" && id < 1) {
8633
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
8712
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
8634
8713
  }
8635
8714
  out.push(id);
8636
8715
  }
@@ -8638,7 +8717,7 @@ function requirePositiveIds(ids2, label) {
8638
8717
  }
8639
8718
  async function whoAmI(_resource, userName, http) {
8640
8719
  const user = userName.trim();
8641
- if (user === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
8720
+ if (user === "") throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
8642
8721
  const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
8643
8722
  const res = await http.request({
8644
8723
  method: "POST",
@@ -8647,11 +8726,11 @@ async function whoAmI(_resource, userName, http) {
8647
8726
  body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
8648
8727
  operation: "resources.whoAmI"
8649
8728
  });
8650
- const matches = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
8729
+ const matches = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
8651
8730
  if (matches.length === 0) return null;
8652
8731
  if (matches.length > 1) {
8653
8732
  const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
8654
- throw new (0, _chunkZJ4ONAQFcjs.ResolutionError)(
8733
+ throw new (0, _chunkD5IVS6GYcjs.ResolutionError)(
8655
8734
  `whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
8656
8735
  { code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
8657
8736
  );
@@ -8660,11 +8739,11 @@ async function whoAmI(_resource, userName, http) {
8660
8739
  }
8661
8740
  async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
8662
8741
  const ids2 = requirePositiveIds(companyIds, "transferOwnership");
8663
- const destination = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
8742
+ const destination = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
8664
8743
  if (typeof destination === "number" && destination < 1) {
8665
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
8744
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
8666
8745
  }
8667
- const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _83 => _83.dryRun]), () => ( true));
8746
+ const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _88 => _88.dryRun]), () => ( true));
8668
8747
  const changes = [];
8669
8748
  const applied = [];
8670
8749
  for (const id of ids2) {
@@ -8673,9 +8752,9 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8673
8752
  method: "GET",
8674
8753
  path: `/V1.0/Companies/${id}`,
8675
8754
  operation: "resources.transferOwnership",
8676
- maxRetries: _optionalChain([opts, 'optionalAccess', _84 => _84.maxRetries])
8755
+ maxRetries: _optionalChain([opts, 'optionalAccess', _89 => _89.maxRetries])
8677
8756
  });
8678
- const company = _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, id, void 0, "company");
8757
+ const company = _chunkD5IVS6GYcjs.unwrapItem.call(void 0, res, id, void 0, "company");
8679
8758
  const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
8680
8759
  changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
8681
8760
  if (!dryRun) {
@@ -8684,15 +8763,15 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8684
8763
  path: "/V1.0/Companies",
8685
8764
  body: { id, ownerResourceID: destination },
8686
8765
  operation: "resources.transferOwnership",
8687
- maxRetries: _optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries])
8766
+ maxRetries: _optionalChain([opts, 'optionalAccess', _90 => _90.maxRetries])
8688
8767
  });
8689
- _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, update);
8768
+ _chunkD5IVS6GYcjs.unwrapOperation.call(void 0, update);
8690
8769
  applied.push(id);
8691
8770
  }
8692
8771
  } catch (err) {
8693
- if (!dryRun && err instanceof _chunkZJ4ONAQFcjs.AutotaskError) {
8772
+ if (!dryRun && err instanceof _chunkD5IVS6GYcjs.AutotaskError) {
8694
8773
  err.resourceIds = [id];
8695
- err.details = _chunkZJ4ONAQFcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
8774
+ err.details = _chunkD5IVS6GYcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
8696
8775
  err.suggestedAction = `Partial transfer: ${applied.length} of ${ids2.length} companies were re-owned (ids: ${applied.join(", ") || "none"}); id ${id} failed. Re-run transferOwnership for the remaining ids (from ${id} on).`;
8697
8776
  }
8698
8777
  throw err;
@@ -8701,7 +8780,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8701
8780
  if (dryRun) {
8702
8781
  const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
8703
8782
  return {
8704
- ..._chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
8783
+ ..._chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
8705
8784
  operation: "resources.transferOwnership",
8706
8785
  method: "PUT",
8707
8786
  path: "/V1.0/Companies",
@@ -8725,7 +8804,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8725
8804
  }
8726
8805
 
8727
8806
  // src/resources/resources.ts
8728
- var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8807
+ var ResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8729
8808
 
8730
8809
  constructor(http, clientConfig, pageSize) {
8731
8810
  super(http, {
@@ -8784,7 +8863,7 @@ var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8784
8863
  /** Search Resource records: bounded contains on firstName + lastName (no vendor free-text search exists);
8785
8864
  * limit defaults to 25, max 500. */
8786
8865
  async search(query, opts) {
8787
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _86 => _86.limit]) });
8866
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
8788
8867
  }
8789
8868
  /** Node-parity special op (hand-written in src/resources/special/resources.ts). */
8790
8869
  transferOwnership(sourceResourceIds, destinationResourceId, opts = {}) {
@@ -8798,7 +8877,7 @@ var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8798
8877
 
8799
8878
  // src/resources/special/resource_time_off_additional.ts
8800
8879
  async function getByResource(_resource, resourceId, http) {
8801
- const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8880
+ const numericResource = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8802
8881
  const res = await http.request({
8803
8882
  method: "GET",
8804
8883
  path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
@@ -8812,11 +8891,11 @@ async function getByResource(_resource, resourceId, http) {
8812
8891
  if (typeof item === "object" && !Array.isArray(item)) return [item];
8813
8892
  }
8814
8893
  }
8815
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
8894
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
8816
8895
  }
8817
8896
 
8818
8897
  // src/resources/resource_time_off_additional.ts
8819
- var ResourceTimeOffAdditionalResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8898
+ var ResourceTimeOffAdditionalResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8820
8899
  constructor(http, pageSize) {
8821
8900
  super(http, {
8822
8901
  key: "resource_time_off_additional",
@@ -8855,7 +8934,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkZJ4ONAQFcjs.BaseReso
8855
8934
  };
8856
8935
 
8857
8936
  // src/resources/resource_time_off_approvers.ts
8858
- var ResourceTimeOffApproversResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
8937
+ var ResourceTimeOffApproversResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8859
8938
  constructor(http, pageSize) {
8860
8939
  super(http, {
8861
8940
  key: "resource_time_off_approvers",
@@ -8898,29 +8977,29 @@ var ResourceTimeOffApproversResource = class extends _chunkZJ4ONAQFcjs.BaseResou
8898
8977
 
8899
8978
  // src/resources/special/resource_time_off_balances.ts
8900
8979
  async function getByResource2(_resource, resourceId, http) {
8901
- const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8980
+ const numericResource = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8902
8981
  const res = await http.request({
8903
8982
  method: "GET",
8904
8983
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
8905
8984
  operation: "resource_time_off_balances.getByResource"
8906
8985
  });
8907
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
8986
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
8908
8987
  }
8909
8988
  async function getByYear(_resource, resourceId, year, http) {
8910
- const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8989
+ const numericResource = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8911
8990
  if (!Number.isSafeInteger(year) || year < 1) {
8912
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
8991
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
8913
8992
  }
8914
8993
  const res = await http.request({
8915
8994
  method: "GET",
8916
8995
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
8917
8996
  operation: "resource_time_off_balances.getByYear"
8918
8997
  });
8919
- return _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
8998
+ return _chunkD5IVS6GYcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
8920
8999
  }
8921
9000
 
8922
9001
  // src/resources/resource_time_off_balances.ts
8923
- var ResourceTimeOffBalancesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9002
+ var ResourceTimeOffBalancesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8924
9003
  constructor(http, pageSize) {
8925
9004
  super(http, {
8926
9005
  key: "resource_time_off_balances",
@@ -8958,7 +9037,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkZJ4ONAQFcjs.BaseResour
8958
9037
  };
8959
9038
 
8960
9039
  // src/resources/roles.ts
8961
- var RolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9040
+ var RolesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
8962
9041
  constructor(http, pageSize) {
8963
9042
  super(http, {
8964
9043
  key: "roles",
@@ -9020,12 +9099,12 @@ var RolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9020
9099
  /** Search Role records: bounded contains on name (no vendor free-text search exists);
9021
9100
  * limit defaults to 25, max 500. */
9022
9101
  async search(query, opts) {
9023
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _87 => _87.limit]) });
9102
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
9024
9103
  }
9025
9104
  };
9026
9105
 
9027
9106
  // src/resources/sales_orders.ts
9028
- var SalesOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9107
+ var SalesOrdersResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9029
9108
  constructor(http, pageSize) {
9030
9109
  super(http, {
9031
9110
  key: "sales_orders",
@@ -9068,7 +9147,7 @@ var SalesOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9068
9147
  };
9069
9148
 
9070
9149
  // src/resources/service_calls.ts
9071
- var ServiceCallsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9150
+ var ServiceCallsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9072
9151
  constructor(http, pageSize) {
9073
9152
  super(http, {
9074
9153
  key: "service_calls",
@@ -9137,7 +9216,7 @@ var ServiceCallsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9137
9216
  };
9138
9217
 
9139
9218
  // src/resources/service_call_task_resources.ts
9140
- var ServiceCallTaskResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9219
+ var ServiceCallTaskResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9141
9220
  constructor(http, pageSize) {
9142
9221
  super(http, {
9143
9222
  key: "service_call_task_resources",
@@ -9194,7 +9273,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
9194
9273
  };
9195
9274
 
9196
9275
  // src/resources/service_call_tasks.ts
9197
- var ServiceCallTasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9276
+ var ServiceCallTasksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9198
9277
  constructor(http, pageSize) {
9199
9278
  super(http, {
9200
9279
  key: "service_call_tasks",
@@ -9251,7 +9330,7 @@ var ServiceCallTasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9251
9330
  };
9252
9331
 
9253
9332
  // src/resources/service_call_ticket_resources.ts
9254
- var ServiceCallTicketResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9333
+ var ServiceCallTicketResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9255
9334
  constructor(http, pageSize) {
9256
9335
  super(http, {
9257
9336
  key: "service_call_ticket_resources",
@@ -9308,7 +9387,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseRes
9308
9387
  };
9309
9388
 
9310
9389
  // src/resources/service_call_tickets.ts
9311
- var ServiceCallTicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9390
+ var ServiceCallTicketsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9312
9391
  constructor(http, pageSize) {
9313
9392
  super(http, {
9314
9393
  key: "service_call_tickets",
@@ -9365,7 +9444,7 @@ var ServiceCallTicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9365
9444
  };
9366
9445
 
9367
9446
  // src/resources/service_level_agreement_results.ts
9368
- var ServiceLevelAgreementResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9447
+ var ServiceLevelAgreementResultsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9369
9448
  constructor(http, pageSize) {
9370
9449
  super(http, {
9371
9450
  key: "service_level_agreement_results",
@@ -9404,7 +9483,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkZJ4ONAQFcjs.BaseR
9404
9483
  };
9405
9484
 
9406
9485
  // src/resources/services.ts
9407
- var ServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9486
+ var ServicesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9408
9487
  constructor(http, pageSize) {
9409
9488
  super(http, {
9410
9489
  key: "services",
@@ -9467,12 +9546,12 @@ var ServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9467
9546
  /** Search Service records: bounded contains on name (no vendor free-text search exists);
9468
9547
  * limit defaults to 25, max 500. */
9469
9548
  async search(query, opts) {
9470
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _88 => _88.limit]) });
9549
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _93 => _93.limit]) });
9471
9550
  }
9472
9551
  };
9473
9552
 
9474
9553
  // src/resources/skills.ts
9475
- var SkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9554
+ var SkillsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9476
9555
  constructor(http, pageSize) {
9477
9556
  super(http, {
9478
9557
  key: "skills",
@@ -9511,12 +9590,12 @@ var SkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9511
9590
  /** Search Skill records: bounded contains on name (no vendor free-text search exists);
9512
9591
  * limit defaults to 25, max 500. */
9513
9592
  async search(query, opts) {
9514
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _89 => _89.limit]) });
9593
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _94 => _94.limit]) });
9515
9594
  }
9516
9595
  };
9517
9596
 
9518
9597
  // src/resources/subscription_periods.ts
9519
- var SubscriptionPeriodsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9598
+ var SubscriptionPeriodsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9520
9599
  constructor(http, pageSize) {
9521
9600
  super(http, {
9522
9601
  key: "subscription_periods",
@@ -9555,7 +9634,7 @@ var SubscriptionPeriodsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9555
9634
  };
9556
9635
 
9557
9636
  // src/resources/subscriptions.ts
9558
- var SubscriptionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9637
+ var SubscriptionsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9559
9638
  constructor(http, pageSize) {
9560
9639
  super(http, {
9561
9640
  key: "subscriptions",
@@ -9624,7 +9703,7 @@ var SubscriptionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9624
9703
  };
9625
9704
 
9626
9705
  // src/resources/survey_results.ts
9627
- var SurveyResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9706
+ var SurveyResultsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9628
9707
  constructor(http, pageSize) {
9629
9708
  super(http, {
9630
9709
  key: "survey_results",
@@ -9663,7 +9742,7 @@ var SurveyResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9663
9742
  };
9664
9743
 
9665
9744
  // src/resources/surveys.ts
9666
- var SurveysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9745
+ var SurveysResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9667
9746
  constructor(http, pageSize) {
9668
9747
  super(http, {
9669
9748
  key: "surveys",
@@ -9702,12 +9781,12 @@ var SurveysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9702
9781
  /** Search Survey records: bounded contains on name (no vendor free-text search exists);
9703
9782
  * limit defaults to 25, max 500. */
9704
9783
  async search(query, opts) {
9705
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _90 => _90.limit]) });
9784
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
9706
9785
  }
9707
9786
  };
9708
9787
 
9709
9788
  // src/resources/tag_aliases.ts
9710
- var TagAliasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9789
+ var TagAliasesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9711
9790
  constructor(http, pageSize) {
9712
9791
  super(http, {
9713
9792
  key: "tag_aliases",
@@ -9764,7 +9843,7 @@ var TagAliasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9764
9843
  };
9765
9844
 
9766
9845
  // src/resources/tag_groups.ts
9767
- var TagGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9846
+ var TagGroupsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9768
9847
  constructor(http, pageSize) {
9769
9848
  super(http, {
9770
9849
  key: "tag_groups",
@@ -9833,7 +9912,7 @@ var TagGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9833
9912
  };
9834
9913
 
9835
9914
  // src/resources/tags.ts
9836
- var TagsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9915
+ var TagsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9837
9916
  constructor(http, pageSize) {
9838
9917
  super(http, {
9839
9918
  key: "tags",
@@ -9902,7 +9981,7 @@ var TagsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9902
9981
  };
9903
9982
 
9904
9983
  // src/resources/task_secondary_resources.ts
9905
- var TaskSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
9984
+ var TaskSecondaryResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9906
9985
  constructor(http, pageSize) {
9907
9986
  super(http, {
9908
9987
  key: "task_secondary_resources",
@@ -9959,7 +10038,7 @@ var TaskSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
9959
10038
  };
9960
10039
 
9961
10040
  // src/resources/tasks.ts
9962
- var TasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10041
+ var TasksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
9963
10042
  constructor(http, pageSize) {
9964
10043
  super(http, {
9965
10044
  key: "tasks",
@@ -10018,12 +10097,12 @@ var TasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10018
10097
  /** Search Task records: bounded contains on title (no vendor free-text search exists);
10019
10098
  * limit defaults to 25, max 500. */
10020
10099
  async search(query, opts) {
10021
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
10100
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
10022
10101
  }
10023
10102
  };
10024
10103
 
10025
10104
  // src/resources/tax_regions.ts
10026
- var TaxRegionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10105
+ var TaxRegionsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10027
10106
  constructor(http, pageSize) {
10028
10107
  super(http, {
10029
10108
  key: "tax_regions",
@@ -10098,7 +10177,7 @@ var ThresholdInformationResource = class {
10098
10177
  };
10099
10178
 
10100
10179
  // src/resources/ticket_additional_configuration_items.ts
10101
- var TicketAdditionalConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10180
+ var TicketAdditionalConfigurationItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10102
10181
  constructor(http, pageSize) {
10103
10182
  super(http, {
10104
10183
  key: "ticket_additional_configuration_items",
@@ -10155,7 +10234,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs
10155
10234
  };
10156
10235
 
10157
10236
  // src/resources/ticket_additional_contacts.ts
10158
- var TicketAdditionalContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10237
+ var TicketAdditionalContactsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10159
10238
  constructor(http, pageSize) {
10160
10239
  super(http, {
10161
10240
  key: "ticket_additional_contacts",
@@ -10212,7 +10291,7 @@ var TicketAdditionalContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResou
10212
10291
  };
10213
10292
 
10214
10293
  // src/resources/ticket_attachments.ts
10215
- var TicketAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10294
+ var TicketAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10216
10295
  constructor(http, pageSize) {
10217
10296
  super(http, {
10218
10297
  key: "ticket_attachments",
@@ -10274,7 +10353,7 @@ var TicketAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10274
10353
  };
10275
10354
 
10276
10355
  // src/resources/ticket_categories.ts
10277
- var TicketCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10356
+ var TicketCategoriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10278
10357
  constructor(http, pageSize) {
10279
10358
  super(http, {
10280
10359
  key: "ticket_categories",
@@ -10328,12 +10407,12 @@ var TicketCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10328
10407
  /** Search TicketCategory records: bounded contains on name (no vendor free-text search exists);
10329
10408
  * limit defaults to 25, max 500. */
10330
10409
  async search(query, opts) {
10331
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
10410
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _97 => _97.limit]) });
10332
10411
  }
10333
10412
  };
10334
10413
 
10335
10414
  // src/resources/ticket_category_field_defaults.ts
10336
- var TicketCategoryFieldDefaultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10415
+ var TicketCategoryFieldDefaultsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10337
10416
  constructor(http, pageSize) {
10338
10417
  super(http, {
10339
10418
  key: "ticket_category_field_defaults",
@@ -10375,7 +10454,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkZJ4ONAQFcjs.BaseRe
10375
10454
  };
10376
10455
 
10377
10456
  // src/resources/ticket_change_request_approvals.ts
10378
- var TicketChangeRequestApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10457
+ var TicketChangeRequestApprovalsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10379
10458
  constructor(http, pageSize) {
10380
10459
  super(http, {
10381
10460
  key: "ticket_change_request_approvals",
@@ -10434,12 +10513,11 @@ var TicketChangeRequestApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseR
10434
10513
  // src/resources/special/_shared/move-engine.ts
10435
10514
  var _crypto = require('crypto');
10436
10515
  var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
10437
- var TICKET_COMPLETE_STATUS = 5;
10438
10516
  var MOVE_EFFECTS_NOTE = "Create then delete: the new record gets a fresh create date and creator; creating/deleting may trigger notifications, SLA and workflow rules the API cannot suppress; vendor acceptance of the create is not validated by a dry run";
10439
- var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
10517
+ var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunkD5IVS6GYcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
10440
10518
  async function queryRows(http, resource, filter, operation, retries) {
10441
10519
  const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
10442
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
10520
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
10443
10521
  }
10444
10522
  function sameValue(a, b) {
10445
10523
  if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
@@ -10456,10 +10534,10 @@ function sameValue(a, b) {
10456
10534
  async function readTicket(http, id, retries, operation) {
10457
10535
  try {
10458
10536
  const res = await http.request({ method: "GET", path: `/V1.0/Tickets/${id}`, operation, maxRetries: retries });
10459
- const item = _optionalChain([res, 'optionalAccess', _93 => _93.item]);
10537
+ const item = _optionalChain([res, 'optionalAccess', _98 => _98.item]);
10460
10538
  return _nullishCoalesce(item, () => ( null));
10461
10539
  } catch (e) {
10462
- if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
10540
+ if (_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
10463
10541
  throw e;
10464
10542
  }
10465
10543
  }
@@ -10480,20 +10558,28 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
10480
10558
  }
10481
10559
  }
10482
10560
  const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
10483
- if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
10561
+ if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
10484
10562
  const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
10485
10563
  if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
10486
10564
  throw refuse("MOVE_SOURCE_TOO_OLD", `${op}: source ${spec.entity} ${sourceId} is older than ${cap} day(s) (or undated) \u2014 move it in the Autotask UI`, ids2, op, { manualAction: manualFor(http, spec, source, "older than the move age limit") });
10487
10565
  }
10488
10566
  const target = await readTicket(http, toTicketId, opts.maxRetries, op);
10489
10567
  if (target === null) throw refuse("MOVE_TARGET_MISSING", `${op}: target ticket ${toTicketId} does not exist`, ids2, op);
10490
- if (target.status === TICKET_COMPLETE_STATUS || target.completedDate !== void 0 && target.completedDate !== null) {
10491
- throw refuse("MOVE_TARGET_CLOSED", `${op}: target ticket ${toTicketId} is closed (status 5 or completed)`, ids2, op);
10568
+ const closedStatus = await resolveTicketStatusSemantics(http);
10569
+ if (isClosedStatus(target.status, closedStatus.closedIds) || target.completedDate !== void 0 && target.completedDate !== null) {
10570
+ throw refuse(
10571
+ "MOVE_TARGET_CLOSED",
10572
+ `${op}: target ticket ${toTicketId} is closed (status in [${closedStatus.closedIds.join(", ")}] or completed) \u2014 closed ids ${closedStatus.source === "assumed" ? "ASSUMED (the tenant status picklist could not be read)" : "resolved from the tenant Tickets status picklist"}`,
10573
+ ids2,
10574
+ op,
10575
+ { closedStatusIds: closedStatus.closedIds, closedStatusSource: closedStatus.source }
10576
+ );
10492
10577
  }
10493
10578
  const origin = await readTicket(http, sourceTicketId, opts.maxRetries, op);
10494
10579
  const facts = {
10580
+ closedStatus: { closedIds: closedStatus.closedIds, source: closedStatus.source, note: closedStatus.note },
10495
10581
  sourceTicketId,
10496
- sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _94 => _94.companyID]), () => ( null)),
10582
+ sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _99 => _99.companyID]), () => ( null)),
10497
10583
  targetCompanyID: _nullishCoalesce(target.companyID, () => ( null)),
10498
10584
  companyChanged: origin === null ? null : origin.companyID !== target.companyID,
10499
10585
  contractChanged: origin === null ? null : (_nullishCoalesce(origin.contractID, () => ( null))) !== (_nullishCoalesce(target.contractID, () => ( null)))
@@ -10515,17 +10601,17 @@ async function assertNoTwin(ctx, payload) {
10515
10601
  throw refuse("MOVE_TARGET_HAS_TWIN", `${ctx.spec.operation}: target ticket ${ctx.toTicketId} already has an equivalent ${ctx.spec.entity} (id ${String(rows[0].id)}) \u2014 a duplicate or resumed move`, { sourceId: ctx.sourceId, toTicketId: ctx.toTicketId }, ctx.spec.operation, { twinId: rows[0].id });
10516
10602
  }
10517
10603
  }
10518
- var statusOf = (e) => _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
10604
+ var statusOf = (e) => _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
10519
10605
  async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
10520
10606
  const op = spec.operation;
10521
- const sourceId = Number(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
10522
- const toTicketId = Number(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
10607
+ const sourceId = Number(_chunkD5IVS6GYcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
10608
+ const toTicketId = Number(_chunkD5IVS6GYcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
10523
10609
  if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
10524
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
10610
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
10525
10611
  }
10526
10612
  const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
10527
10613
  if (opts.dryRun === true) {
10528
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
10614
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
10529
10615
  {
10530
10616
  operation: op,
10531
10617
  method: "POST",
@@ -10550,22 +10636,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
10550
10636
  let newId;
10551
10637
  try {
10552
10638
  const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
10553
- newId = Number(_chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, created, op).id);
10639
+ newId = Number(_chunkD5IVS6GYcjs.unwrapOperation.call(void 0, created, op).id);
10554
10640
  } catch (e) {
10555
10641
  const status = statusOf(e);
10556
10642
  if (status !== void 0 && status >= 400 && status < 500) {
10557
- throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
10643
+ throw new (0, _chunkD5IVS6GYcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
10558
10644
  }
10559
- throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: the create outcome is unknown (never resent) \u2014 check the target ticket for a new ${spec.entity} before retrying; the twin check blocks a second create`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2 } });
10645
+ throw new (0, _chunkD5IVS6GYcjs.MoveRefusedError)(`${op}: the create outcome is unknown (never resent) \u2014 check the target ticket for a new ${spec.entity} before retrying; the twin check blocks a second create`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2 } });
10560
10646
  }
10561
10647
  const rollback = async (code, message) => {
10562
10648
  try {
10563
10649
  await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
10564
10650
  } catch (re) {
10565
10651
  const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
10566
- throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: ${message}; rolling back the new ${spec.entity} ${newId} FAILED \u2014 both records exist`, { code: unreadable ? "MOVE_UNKNOWN" : "MOVE_PARTIAL", operation: op, details: { status: unreadable ? "unknown" : "partial", ...ids2, newId, reason: code } });
10652
+ throw new (0, _chunkD5IVS6GYcjs.MoveRefusedError)(`${op}: ${message}; rolling back the new ${spec.entity} ${newId} FAILED \u2014 both records exist`, { code: unreadable ? "MOVE_UNKNOWN" : "MOVE_PARTIAL", operation: op, details: { status: unreadable ? "unknown" : "partial", ...ids2, newId, reason: code } });
10567
10653
  }
10568
- throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
10654
+ throw new (0, _chunkD5IVS6GYcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
10569
10655
  };
10570
10656
  const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
10571
10657
  if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
@@ -10594,33 +10680,33 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
10594
10680
  };
10595
10681
  }
10596
10682
  if (status === void 0) {
10597
- throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: the source delete outcome is unknown (never resent) \u2014 re-read the source: absent means the move completed`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2, newId } });
10683
+ throw new (0, _chunkD5IVS6GYcjs.MoveRefusedError)(`${op}: the source delete outcome is unknown (never resent) \u2014 re-read the source: absent means the move completed`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2, newId } });
10598
10684
  }
10599
10685
  return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
10600
10686
  }
10601
10687
  return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
10602
10688
  }
10603
10689
  function uiLinkFor(http, entity, id) {
10604
- return _nullishCoalesce(_chunkZJ4ONAQFcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
10690
+ return _nullishCoalesce(_chunkD5IVS6GYcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
10605
10691
  }
10606
10692
 
10607
10693
  // src/resources/special/ticket_charges.ts
10608
- var OP2 = "ticket_charges.moveToTicket";
10694
+ var OP3 = "ticket_charges.moveToTicket";
10609
10695
  var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
10610
10696
  var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
10611
10697
  async function readCharge(http, id, retries) {
10612
- const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP2, retries);
10698
+ const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
10613
10699
  return _nullishCoalesce(rows[0], () => ( null));
10614
10700
  }
10615
10701
  async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
10616
10702
  if (source.isBilled === true) {
10617
- throw refuse("MOVE_BLOCKED_BILLED", `${OP2}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP2, {
10703
+ throw refuse("MOVE_BLOCKED_BILLED", `${OP3}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP3, {
10618
10704
  manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
10619
10705
  });
10620
10706
  }
10621
10707
  }
10622
10708
  var SPEC = {
10623
- operation: OP2,
10709
+ operation: OP3,
10624
10710
  entity: "ticket_charge",
10625
10711
  readSource: readCharge,
10626
10712
  sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
@@ -10656,7 +10742,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
10656
10742
  }
10657
10743
 
10658
10744
  // src/resources/ticket_charges.ts
10659
- var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10745
+ var TicketChargesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10660
10746
  constructor(http, pageSize) {
10661
10747
  super(http, {
10662
10748
  key: "ticket_charges",
@@ -10722,7 +10808,7 @@ var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10722
10808
  /** Search TicketCharge records: bounded contains on name (no vendor free-text search exists);
10723
10809
  * limit defaults to 25, max 500. */
10724
10810
  async search(query, opts) {
10725
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
10811
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _100 => _100.limit]) });
10726
10812
  }
10727
10813
  /** Node-parity special op (hand-written in src/resources/special/ticket_charges.ts). */
10728
10814
  moveToTicket(sourceId, toTicketId, opts = {}) {
@@ -10731,7 +10817,7 @@ var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10731
10817
  };
10732
10818
 
10733
10819
  // src/resources/ticket_checklist_items.ts
10734
- var TicketChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10820
+ var TicketChecklistItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10735
10821
  constructor(http, pageSize) {
10736
10822
  super(http, {
10737
10823
  key: "ticket_checklist_items",
@@ -10797,7 +10883,7 @@ var TicketChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
10797
10883
  };
10798
10884
 
10799
10885
  // src/resources/ticket_checklist_libraries.ts
10800
- var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10886
+ var TicketChecklistLibrariesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10801
10887
  constructor(http, pageSize) {
10802
10888
  super(http, {
10803
10889
  key: "ticket_checklist_libraries",
@@ -10821,9 +10907,9 @@ var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
10821
10907
  * `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
10822
10908
  * surface — no documents read op — and never issues the POST). */
10823
10909
  async attachToDocument(documentID, data, opts = {}) {
10824
- const n = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, documentID, "documentID");
10910
+ const n = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, documentID, "documentID");
10825
10911
  if (opts.dryRun === true) {
10826
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
10912
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
10827
10913
  operation: "ticket_checklist_libraries.attachToDocument",
10828
10914
  method: "POST",
10829
10915
  path: `/V1.0/Documents/${n}/ChecklistLibraries`,
@@ -10841,7 +10927,7 @@ var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
10841
10927
  operation: "ticket_checklist_libraries.attachToDocument",
10842
10928
  maxRetries: opts.maxRetries
10843
10929
  });
10844
- return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
10930
+ return _chunkD5IVS6GYcjs.unwrapOperation.call(void 0, res);
10845
10931
  }
10846
10932
  /** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
10847
10933
  * from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
@@ -10857,7 +10943,7 @@ var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
10857
10943
  };
10858
10944
 
10859
10945
  // src/resources/ticket_history.ts
10860
- var TicketHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10946
+ var TicketHistoryResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10861
10947
  constructor(http, pageSize) {
10862
10948
  super(http, {
10863
10949
  key: "ticket_history",
@@ -10896,7 +10982,7 @@ var TicketHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10896
10982
  };
10897
10983
 
10898
10984
  // src/resources/ticket_note_attachments.ts
10899
- var TicketNoteAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
10985
+ var TicketNoteAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10900
10986
  constructor(http, pageSize) {
10901
10987
  super(http, {
10902
10988
  key: "ticket_note_attachments",
@@ -10958,7 +11044,7 @@ var TicketNoteAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
10958
11044
  };
10959
11045
 
10960
11046
  // src/resources/ticket_notes.ts
10961
- var TicketNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
11047
+ var TicketNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
10962
11048
  constructor(http, pageSize) {
10963
11049
  super(http, {
10964
11050
  key: "ticket_notes",
@@ -11017,7 +11103,7 @@ var TicketNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
11017
11103
  };
11018
11104
 
11019
11105
  // src/resources/ticket_note_webhooks.ts
11020
- var TicketNoteWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
11106
+ var TicketNoteWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
11021
11107
  constructor(http, pageSize) {
11022
11108
  super(http, {
11023
11109
  key: "ticket_note_webhooks",
@@ -11088,12 +11174,12 @@ var TicketNoteWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
11088
11174
  /** Search TicketNoteWebhook records: bounded contains on name (no vendor free-text search exists);
11089
11175
  * limit defaults to 25, max 500. */
11090
11176
  async search(query, opts) {
11091
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
11177
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _101 => _101.limit]) });
11092
11178
  }
11093
11179
  };
11094
11180
 
11095
11181
  // src/resources/ticket_secondary_resources.ts
11096
- var TicketSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
11182
+ var TicketSecondaryResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
11097
11183
  constructor(http, pageSize) {
11098
11184
  super(http, {
11099
11185
  key: "ticket_secondary_resources",
@@ -11158,9 +11244,9 @@ async function fetchTicket(http, id, operation) {
11158
11244
  });
11159
11245
  const body = res;
11160
11246
  if (body === null || !("item" in body)) {
11161
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11247
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11162
11248
  }
11163
- if (body.item === null || body.item === void 0) throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11249
+ if (body.item === null || body.item === void 0) throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11164
11250
  return body.item;
11165
11251
  }
11166
11252
  async function ticketQueryItems(http, path, filter, maxRecords, operation) {
@@ -11171,7 +11257,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
11171
11257
  body: { MaxRecords: maxRecords, filter },
11172
11258
  operation
11173
11259
  });
11174
- return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
11260
+ return _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res).items;
11175
11261
  }
11176
11262
  function truncate(text, limit) {
11177
11263
  const full = _nullishCoalesce(text, () => ( ""));
@@ -11181,26 +11267,26 @@ function truncate(text, limit) {
11181
11267
 
11182
11268
  // src/resources/special/tickets/childRead.ts
11183
11269
  function isRouteUnavailable(err) {
11184
- return _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
11270
+ return _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
11185
11271
  }
11186
11272
  function routeFact(route, path, err) {
11187
11273
  return {
11188
11274
  route,
11189
11275
  path,
11190
- httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
11276
+ httpStatus: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
11191
11277
  };
11192
11278
  }
11193
11279
  function childDeclaresQuery(resourceKey) {
11194
- return _chunk5CC7LGNMcjs.CAPABILITIES.some(
11280
+ return _chunkZEGMVEF3cjs.CAPABILITIES.some(
11195
11281
  (c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
11196
11282
  );
11197
11283
  }
11198
11284
  function planScopedPath(resourceKey, ticketId) {
11199
11285
  if (!childDeclaresQuery(resourceKey)) return null;
11200
- const entry = _chunkZJ4ONAQFcjs.RELATIONSHIP_MAP[resourceKey];
11286
+ const entry = _chunkD5IVS6GYcjs.RELATIONSHIP_MAP[resourceKey];
11201
11287
  const parent = entry === void 0 ? null : entry.parent;
11202
11288
  if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
11203
- const parentPath = _optionalChain([_chunkZJ4ONAQFcjs.RELATIONSHIP_MAP, 'access', _97 => _97[parent.resource], 'optionalAccess', _98 => _98.path]);
11289
+ const parentPath = _optionalChain([_chunkD5IVS6GYcjs.RELATIONSHIP_MAP, 'access', _102 => _102[parent.resource], 'optionalAccess', _103 => _103.path]);
11204
11290
  if (parentPath === null || parentPath === void 0) return null;
11205
11291
  return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
11206
11292
  }
@@ -11239,14 +11325,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
11239
11325
  break;
11240
11326
  }
11241
11327
  const body = await http.request({ method: "GET", path: target, operation });
11242
- const { items: pageItems, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, body, operation);
11328
+ const { items: pageItems, pageDetails } = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, body, operation);
11243
11329
  nextCursor = pageDetails.nextPageUrl;
11244
11330
  pages += 1;
11245
11331
  const window = pageItems.slice(0, Math.max(0, limit - items.length));
11246
11332
  for (const row of window) if (accept(row)) items.push(row);
11247
11333
  if (items.length >= limit) break;
11248
11334
  if (nextCursor === null || pageItems.length === 0) break;
11249
- target = _chunkZJ4ONAQFcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
11335
+ target = _chunkD5IVS6GYcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
11250
11336
  }
11251
11337
  const capped = items.length >= limit || guard && nextCursor !== null;
11252
11338
  return { items, capped };
@@ -11279,7 +11365,7 @@ var MS = 864e5;
11279
11365
  var SLA_PAGE = 100;
11280
11366
  async function slaHealthCheck(_resource, id, opts = {}, http) {
11281
11367
  void opts;
11282
- const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
11368
+ const ticketId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
11283
11369
  await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
11284
11370
  const rows = await ticketQueryItems(
11285
11371
  http,
@@ -11304,9 +11390,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
11304
11390
  async function summary(_resource, id, opts = {}, http) {
11305
11391
  const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
11306
11392
  if (!Number.isInteger(limit) || limit < 1) {
11307
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
11393
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
11308
11394
  }
11309
- const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
11395
+ const ticketId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
11310
11396
  const ticket = await fetchTicket(http, ticketId, "tickets.summary");
11311
11397
  const desc = truncate(ticket.description, limit);
11312
11398
  const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
@@ -11335,11 +11421,11 @@ async function summary(_resource, id, opts = {}, http) {
11335
11421
  // src/resources/special/tickets/timeline.ts
11336
11422
  function validateTimelineLimits(opts) {
11337
11423
  const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
11338
- if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
11424
+ if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
11339
11425
  const bounded = Math.min(limit, 500);
11340
11426
  const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
11341
11427
  if (!Number.isInteger(textLimit) || textLimit < 1) {
11342
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
11428
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
11343
11429
  }
11344
11430
  return { bounded, textLimit };
11345
11431
  }
@@ -11391,7 +11477,7 @@ function compareEventDates(a, b) {
11391
11477
  }
11392
11478
  async function timeline(_resource, id, opts = {}, http) {
11393
11479
  const { bounded, textLimit } = validateTimelineLimits(opts);
11394
- const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
11480
+ const ticketId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
11395
11481
  await fetchTicket(http, ticketId, "tickets.timeline");
11396
11482
  const dateFilters = (field) => {
11397
11483
  const f = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -11431,7 +11517,7 @@ async function timeline(_resource, id, opts = {}, http) {
11431
11517
  }
11432
11518
 
11433
11519
  // src/resources/special/tickets/errors.ts
11434
- var QueueRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11520
+ var QueueRequiredError = class extends _chunkD5IVS6GYcjs.AutotaskError {
11435
11521
  constructor(message, options = {}) {
11436
11522
  super(message, {
11437
11523
  code: "QUEUE_REQUIRED",
@@ -11442,13 +11528,13 @@ var QueueRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11442
11528
  this.name = "QueueRequiredError";
11443
11529
  }
11444
11530
  };
11445
- var TicketResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11531
+ var TicketResourceInvalidError = class extends _chunkD5IVS6GYcjs.AutotaskError {
11446
11532
  constructor(message, options = {}) {
11447
11533
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
11448
11534
  this.name = "TicketResourceInvalidError";
11449
11535
  }
11450
11536
  };
11451
- var TicketCreateValidationFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11537
+ var TicketCreateValidationFailedError = class extends _chunkD5IVS6GYcjs.AutotaskError {
11452
11538
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
11453
11539
 
11454
11540
  constructor(message, vendorFields, options = {}) {
@@ -11457,7 +11543,7 @@ var TicketCreateValidationFailedError = class extends _chunkZJ4ONAQFcjs.Autotask
11457
11543
  this.vendorFields = vendorFields;
11458
11544
  }
11459
11545
  };
11460
- var StatusUnknownError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11546
+ var StatusUnknownError = class extends _chunkD5IVS6GYcjs.AutotaskError {
11461
11547
  /** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
11462
11548
 
11463
11549
  constructor(message, options = {}) {
@@ -11471,7 +11557,7 @@ var StatusUnknownError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11471
11557
  this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
11472
11558
  }
11473
11559
  };
11474
- var StatusFieldsRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
11560
+ var StatusFieldsRequiredError = class extends _chunkD5IVS6GYcjs.AutotaskError {
11475
11561
 
11476
11562
 
11477
11563
 
@@ -11494,21 +11580,21 @@ function isPositiveInt(v) {
11494
11580
  return typeof v === "number" && Number.isInteger(v) && v > 0;
11495
11581
  }
11496
11582
  function namedVendorFields(err) {
11497
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
11498
- const entries = _nullishCoalesce(_chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
11583
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
11584
+ const entries = _nullishCoalesce(_chunkD5IVS6GYcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
11499
11585
  const out = /* @__PURE__ */ new Set();
11500
11586
  for (const e of entries) if (e.field !== void 0) out.add(e.field);
11501
11587
  return [...out];
11502
11588
  }
11503
11589
  function vendorDetailOf(err) {
11504
- return _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
11590
+ return _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? _chunkD5IVS6GYcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
11505
11591
  }
11506
11592
  async function fetchItem(http, path, operation, readOpts) {
11507
- const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _99 => _99.maxRetries]) });
11593
+ const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _104 => _104.maxRetries]) });
11508
11594
  return unwrapItemOrNull(res);
11509
11595
  }
11510
11596
  async function fetchItemUnredacted(http, path, operation, readOpts) {
11511
- const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _100 => _100.maxRetries]) });
11597
+ const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _105 => _105.maxRetries]) });
11512
11598
  return unwrapItemOrNull(res);
11513
11599
  }
11514
11600
  function unwrapItemOrNull(res) {
@@ -11522,8 +11608,8 @@ function operationId(res) {
11522
11608
  return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
11523
11609
  }
11524
11610
  function discoveryMerge(err, body, defaults) {
11525
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
11526
- const entries = _chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError);
11611
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
11612
+ const entries = _chunkD5IVS6GYcjs.parseVendorErrors.call(void 0, err.vendorError);
11527
11613
  if (entries === void 0) return null;
11528
11614
  for (const entry of entries) {
11529
11615
  const field = entry.field;
@@ -11535,7 +11621,7 @@ function discoveryMerge(err, body, defaults) {
11535
11621
  }
11536
11622
  function stepErrorText(code, err) {
11537
11623
  const detail = vendorDetailOf(err);
11538
- const base = _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
11624
+ const base = _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
11539
11625
  return detail ? `${code}: ${detail}` : `${code}: ${base}`;
11540
11626
  }
11541
11627
 
@@ -11547,43 +11633,43 @@ var DEFAULT_PUBLISH = 1;
11547
11633
  var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
11548
11634
  var SAFE_TICKET_CREATE_DEFAULTS = {};
11549
11635
  function validateOpenInput(params, note, assign) {
11550
- const companyID = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _101 => _101.companyID]), "params.companyID");
11551
- const title = _optionalChain([params, 'optionalAccess', _102 => _102.title]);
11636
+ const companyID = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _106 => _106.companyID]), "params.companyID");
11637
+ const title = _optionalChain([params, 'optionalAccess', _107 => _107.title]);
11552
11638
  if (typeof title !== "string" || title.trim() === "") {
11553
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
11639
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
11554
11640
  }
11555
11641
  const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
11556
11642
  const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
11557
11643
  if (!isPositiveInt(priority)) {
11558
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
11644
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
11559
11645
  }
11560
11646
  if (!isPositiveInt(status)) {
11561
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
11647
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
11562
11648
  }
11563
11649
  if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
11564
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
11650
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
11565
11651
  }
11566
11652
  if (note !== void 0) {
11567
11653
  if (typeof note.description !== "string" || note.description.trim() === "") {
11568
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
11654
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
11569
11655
  }
11570
11656
  if (typeof note.title !== "string" || note.title.trim() === "") {
11571
- throw new (0, _chunkZJ4ONAQFcjs.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 });
11657
+ throw new (0, _chunkD5IVS6GYcjs.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 });
11572
11658
  }
11573
11659
  if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
11574
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
11660
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
11575
11661
  }
11576
11662
  if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
11577
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
11663
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
11578
11664
  }
11579
11665
  }
11580
- const assignee = assign === void 0 ? void 0 : _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
11666
+ const assignee = assign === void 0 ? void 0 : _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
11581
11667
  if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
11582
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
11668
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
11583
11669
  }
11584
- const roleID = _optionalChain([assign, 'optionalAccess', _103 => _103.roleID]);
11670
+ const roleID = _optionalChain([assign, 'optionalAccess', _108 => _108.roleID]);
11585
11671
  if (assign !== void 0 && !isPositiveInt(roleID)) {
11586
- throw new (0, _chunkZJ4ONAQFcjs.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 });
11672
+ throw new (0, _chunkD5IVS6GYcjs.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 });
11587
11673
  }
11588
11674
  return { companyID, title, priority, status, assignee, roleID };
11589
11675
  }
@@ -11612,7 +11698,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
11612
11698
  if (assign !== void 0) {
11613
11699
  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).`);
11614
11700
  }
11615
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
11701
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
11616
11702
  {
11617
11703
  operation: OP_OPEN,
11618
11704
  method: "POST",
@@ -11652,8 +11738,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
11652
11738
  `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}` : ""}`,
11653
11739
  {
11654
11740
  operation: OP_OPEN,
11655
- httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11656
- vendorError: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
11741
+ httpStatus: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11742
+ vendorError: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
11657
11743
  }
11658
11744
  );
11659
11745
  }
@@ -11668,8 +11754,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
11668
11754
  named,
11669
11755
  {
11670
11756
  operation: OP_OPEN,
11671
- httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11672
- vendorError: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
11757
+ httpStatus: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11758
+ vendorError: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
11673
11759
  resourceIds: [companyID],
11674
11760
  details: { idRefs: [{ entity: "company", id: companyID }] }
11675
11761
  }
@@ -11694,10 +11780,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
11694
11780
  try {
11695
11781
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
11696
11782
  if (current === null) {
11697
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
11783
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
11698
11784
  }
11699
11785
  ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
11700
- const merged = _chunkZJ4ONAQFcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
11786
+ const merged = _chunkD5IVS6GYcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
11701
11787
  merged.id = ticketId;
11702
11788
  await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
11703
11789
  assigned = true;
@@ -11761,17 +11847,17 @@ async function guardTargetStatus(resource, http, targetStatus) {
11761
11847
  const ids2 = await readLiveStatusSet(resource);
11762
11848
  if (ids2.size > 0) liveStatus = ids2;
11763
11849
  } catch (err) {
11764
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
11850
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
11765
11851
  }
11766
11852
  if (liveStatus !== null && !liveStatus.has(targetStatus)) {
11767
- _optionalChain([http, 'access', _104 => _104.fieldCache, 'optionalAccess', _105 => _105.invalidate, 'call', _106 => _106("tickets")]);
11853
+ _optionalChain([http, 'access', _109 => _109.fieldCache, 'optionalAccess', _110 => _110.invalidate, 'call', _111 => _111("tickets")]);
11768
11854
  let freshStatus = null;
11769
11855
  let reReadFailed = false;
11770
11856
  try {
11771
11857
  const freshIds = await readLiveStatusSet(resource);
11772
11858
  if (freshIds.size > 0) freshStatus = freshIds;
11773
11859
  } catch (err) {
11774
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
11860
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
11775
11861
  freshStatus = null;
11776
11862
  reReadFailed = true;
11777
11863
  }
@@ -11789,7 +11875,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
11789
11875
  return { guardDegraded: liveStatus === null };
11790
11876
  }
11791
11877
  function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
11792
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
11878
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
11793
11879
  {
11794
11880
  operation: OP_STATUS,
11795
11881
  method: "PUT",
@@ -11820,7 +11906,7 @@ function resolveMergeData(ticketId, targetStatus, previousStatus, current, field
11820
11906
  for (const field of mapEntry.requiredFields) {
11821
11907
  if (mergeData[field] !== void 0) continue;
11822
11908
  if (current[field] !== null && current[field] !== void 0) continue;
11823
- const safe = _optionalChain([mapEntry, 'access', _107 => _107.safeDefaults, 'optionalAccess', _108 => _108[field]]);
11909
+ const safe = _optionalChain([mapEntry, 'access', _112 => _112.safeDefaults, 'optionalAccess', _113 => _113[field]]);
11824
11910
  if (safe === void 0) {
11825
11911
  throw new StatusFieldsRequiredError(
11826
11912
  `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`,
@@ -11843,7 +11929,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
11843
11929
  if (mapEntry === void 0) {
11844
11930
  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).`);
11845
11931
  }
11846
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
11932
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
11847
11933
  {
11848
11934
  operation: OP_STATUS,
11849
11935
  method: "PUT",
@@ -11862,8 +11948,8 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
11862
11948
  );
11863
11949
  }
11864
11950
  async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
11865
- const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _109 => _109.safeDefaults]), () => ( {}));
11866
- const body = _chunkZJ4ONAQFcjs.mergePartialBody.call(void 0, current, mergeData);
11951
+ const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _114 => _114.safeDefaults]), () => ( {}));
11952
+ const body = _chunkD5IVS6GYcjs.mergePartialBody.call(void 0, current, mergeData);
11867
11953
  body.id = ticketId;
11868
11954
  let merges = 0;
11869
11955
  for (; ; ) {
@@ -11887,8 +11973,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
11887
11973
  { vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
11888
11974
  {
11889
11975
  operation: OP_STATUS,
11890
- httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11891
- vendorError: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
11976
+ httpStatus: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11977
+ vendorError: _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
11892
11978
  resourceIds: [ticketId],
11893
11979
  details: { idRefs: [{ entity: "ticket", id: ticketId }] }
11894
11980
  }
@@ -11901,7 +11987,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
11901
11987
  async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
11902
11988
  const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
11903
11989
  if (verify === null) {
11904
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
11990
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
11905
11991
  code: "INVALID_RESPONSE",
11906
11992
  category: "server",
11907
11993
  operation: OP_STATUS,
@@ -11911,7 +11997,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
11911
11997
  }
11912
11998
  const finalStatus = typeof verify.status === "number" ? verify.status : null;
11913
11999
  if (finalStatus !== targetStatus) {
11914
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(
12000
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskError)(
11915
12001
  `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)`,
11916
12002
  {
11917
12003
  code: "INVALID_RESPONSE",
@@ -11926,17 +12012,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
11926
12012
  }
11927
12013
  }
11928
12014
  async function changeStatus(resource, id, targetStatus, fields, opts, http) {
11929
- const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
12015
+ const ticketId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
11930
12016
  if (!isPositiveInt(targetStatus)) {
11931
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
12017
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
11932
12018
  }
11933
12019
  const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
11934
12020
  if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
11935
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
12021
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
11936
12022
  }
11937
12023
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
11938
12024
  if (current === null) {
11939
- throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
12025
+ throw new (0, _chunkD5IVS6GYcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
11940
12026
  }
11941
12027
  const previousStatus = typeof current.status === "number" ? current.status : null;
11942
12028
  if (previousStatus === targetStatus) {
@@ -11956,7 +12042,7 @@ var DEFAULT_PART_LIMIT = 50;
11956
12042
  function partLimit(value, name) {
11957
12043
  const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
11958
12044
  if (!Number.isInteger(n) || n < 1) {
11959
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
12045
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
11960
12046
  }
11961
12047
  return n;
11962
12048
  }
@@ -11969,7 +12055,7 @@ function servedTextRecord(row, textField, limit) {
11969
12055
  return out;
11970
12056
  }
11971
12057
  async function addCompositeNames(http, ctx, entriesPart, result, opts) {
11972
- const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS);
12058
+ const builder = _chunkD5IVS6GYcjs.createNamePlan.call(void 0, _chunkD5IVS6GYcjs.TICKET_LABEL_FIELDS);
11973
12059
  const t = ctx.ticket;
11974
12060
  builder.addResource(t["creatorResourceID"]);
11975
12061
  builder.addFk("contract", t["contractID"]);
@@ -11981,20 +12067,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
11981
12067
  builder.addFk("billingCode", e["billingCodeID"]);
11982
12068
  builder.addFk("contract", e["contractID"]);
11983
12069
  }
11984
- const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
12070
+ const names = await _chunkD5IVS6GYcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
11985
12071
  const ticketRow = { ...ctx.ticket };
11986
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
11987
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
11988
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
11989
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
11990
- for (const f of _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS) _chunkZJ4ONAQFcjs.addLabelSibling.call(void 0, ticketRow, f, names);
12072
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
12073
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
12074
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
12075
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
12076
+ for (const f of _chunkD5IVS6GYcjs.TICKET_LABEL_FIELDS) _chunkD5IVS6GYcjs.addLabelSibling.call(void 0, ticketRow, f, names);
11991
12077
  result.ticket = ticketRow;
11992
12078
  result.timeEntries.items = entriesPart.items.map((e) => {
11993
12079
  const row = { ...e };
11994
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
11995
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
11996
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
11997
- _chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
12080
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
12081
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
12082
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
12083
+ _chunkD5IVS6GYcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
11998
12084
  return row;
11999
12085
  });
12000
12086
  result.names = names.section;
@@ -12004,7 +12090,7 @@ async function fullContext(resource, id, opts = {}, http) {
12004
12090
  const noteLimit = partLimit(opts.noteLimit, "noteLimit");
12005
12091
  const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
12006
12092
  const textLimit = partLimit(opts.textLimit, "textLimit");
12007
- const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
12093
+ const ticketId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
12008
12094
  const ctx = await resource.getContext(ticketId);
12009
12095
  const op = "tickets.fullContext";
12010
12096
  const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -12061,8 +12147,123 @@ async function fullContext(resource, id, opts = {}, http) {
12061
12147
  return result;
12062
12148
  }
12063
12149
 
12150
+ // src/resources/special/tickets/forResource.ts
12151
+ var OP4 = "tickets.forResource";
12152
+ var TICKET_CHUNK = 100;
12153
+ var LIMIT_DEFAULT = 100;
12154
+ var LIMIT_MAX = 500;
12155
+ var LINK_READ_CAP = 500;
12156
+ var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
12157
+ function positiveId(value, name) {
12158
+ const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
12159
+ if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
12160
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
12161
+ }
12162
+ return n;
12163
+ }
12164
+ async function ticketPage(http, filter, maxRecords, fields) {
12165
+ const res = await http.request({
12166
+ method: "POST",
12167
+ idempotent: true,
12168
+ path: "/V1.0/Tickets/query",
12169
+ body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
12170
+ operation: OP4
12171
+ });
12172
+ const page = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, OP4);
12173
+ return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
12174
+ }
12175
+ async function forResource(_resource, resourceIDIn, http, opts = {}) {
12176
+ if (opts === null || typeof opts !== "object") throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP4}: opts must be an object`, { operation: OP4 });
12177
+ const resourceID = positiveId(resourceIDIn, "resourceID");
12178
+ const scope = _nullishCoalesce(opts.scope, () => ( "both"));
12179
+ if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
12180
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
12181
+ }
12182
+ if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
12183
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
12184
+ }
12185
+ const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
12186
+ if (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX) {
12187
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
12188
+ }
12189
+ const includeFields = _nullishCoalesce(opts.includeFields, () => ( []));
12190
+ if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
12191
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
12192
+ }
12193
+ const openOnly = opts.openOnly === true;
12194
+ const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS2, ...includeFields])];
12195
+ const closed = await resolveTicketStatusSemantics(http, opts.excludeStatusIds === void 0 ? {} : { excludeStatusIds: opts.excludeStatusIds });
12196
+ const closedStatus = { closedIds: closed.closedIds, source: closed.source, note: closed.note };
12197
+ const openLeaf = openOnly ? [openStatusFilter(closed.closedIds)] : [];
12198
+ const linkIds = [];
12199
+ let capped = false;
12200
+ if (scope !== "primary") {
12201
+ const res = await http.request({
12202
+ method: "POST",
12203
+ idempotent: true,
12204
+ path: "/V1.0/TicketSecondaryResources/query",
12205
+ body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
12206
+ operation: OP4
12207
+ });
12208
+ const page = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, OP4);
12209
+ for (const row of page.items) if (typeof row.ticketID === "number" && !linkIds.includes(row.ticketID)) linkIds.push(row.ticketID);
12210
+ if (page.items.length >= LINK_READ_CAP || page.pageDetails.nextPageUrl !== null) capped = true;
12211
+ }
12212
+ const primary = /* @__PURE__ */ new Map();
12213
+ if (scope !== "secondary") {
12214
+ const page = await ticketPage(http, [{ field: "assignedResourceID", op: "eq", value: resourceID }, ...openLeaf], limit, fields);
12215
+ if (page.more || page.rows.length >= limit) capped = true;
12216
+ for (const t of page.rows) if (typeof t.id === "number") primary.set(t.id, t);
12217
+ }
12218
+ const secondary = /* @__PURE__ */ new Map();
12219
+ const unresolvedIds = [];
12220
+ for (let c = 0; c < linkIds.length; c += TICKET_CHUNK) {
12221
+ const chunk = linkIds.slice(c, c + TICKET_CHUNK);
12222
+ const page = await ticketPage(http, [{ field: "id", op: "in", value: chunk }, ...openLeaf], chunk.length, fields);
12223
+ const seen = /* @__PURE__ */ new Set();
12224
+ for (const t of page.rows) {
12225
+ if (typeof t.id !== "number") continue;
12226
+ secondary.set(t.id, t);
12227
+ seen.add(t.id);
12228
+ }
12229
+ for (const id of chunk) if (!seen.has(id)) unresolvedIds.push(id);
12230
+ }
12231
+ const merged = /* @__PURE__ */ new Map();
12232
+ for (const [id, t] of primary) merged.set(id, t);
12233
+ for (const [id, t] of secondary) if (!merged.has(id)) merged.set(id, t);
12234
+ let tickets = [...merged.values()];
12235
+ if (openOnly) tickets = tickets.filter((t) => !isClosedStatus(t.status, closed.closedIds));
12236
+ tickets.sort((a, b) => Number(a.id) - Number(b.id));
12237
+ if (tickets.length > limit) {
12238
+ tickets = tickets.slice(0, limit);
12239
+ capped = true;
12240
+ }
12241
+ const openCount = tickets.filter((t) => !isClosedStatus(t.status, closed.closedIds)).length;
12242
+ const primaryIds = [...primary.keys()].sort((a, b) => a - b);
12243
+ const secondaryIds = [...secondary.keys()].sort((a, b) => a - b);
12244
+ const both = primaryIds.filter((id) => secondary.has(id));
12245
+ return {
12246
+ resourceID,
12247
+ scope,
12248
+ openOnly,
12249
+ tickets,
12250
+ primaryIds,
12251
+ secondaryIds,
12252
+ bothIds: both,
12253
+ counts: { primary: primaryIds.length, secondary: secondaryIds.length, both: both.length, open: openCount },
12254
+ capped,
12255
+ unresolvedIds: unresolvedIds.sort((a, b) => a - b),
12256
+ closedStatus
12257
+ };
12258
+ }
12259
+
12260
+ // src/resources/special/tickets/statusSemantics.ts
12261
+ async function statusSemantics(_resource, opts = {}, http) {
12262
+ return resolveTicketStatusSemantics(http, opts);
12263
+ }
12264
+
12064
12265
  // src/resources/tickets.ts
12065
- var TicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
12266
+ var TicketsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
12066
12267
  constructor(http, pageSize) {
12067
12268
  super(http, {
12068
12269
  key: "tickets",
@@ -12166,10 +12367,18 @@ var TicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
12166
12367
  fullContext(id, opts) {
12167
12368
  return fullContext(this, id, opts, this.http);
12168
12369
  }
12370
+ /** Node-parity special op (hand-written in src/resources/special/tickets.ts). */
12371
+ statusSemantics(opts) {
12372
+ return statusSemantics(this, opts, this.http);
12373
+ }
12374
+ /** Node-parity special op (hand-written in src/resources/special/tickets.ts). */
12375
+ forResource(resourceID, opts) {
12376
+ return forResource(this, resourceID, this.http, opts);
12377
+ }
12169
12378
  };
12170
12379
 
12171
12380
  // src/resources/ticket_webhooks.ts
12172
- var TicketWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
12381
+ var TicketWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
12173
12382
  constructor(http, pageSize) {
12174
12383
  super(http, {
12175
12384
  key: "ticket_webhooks",
@@ -12240,7 +12449,7 @@ var TicketWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
12240
12449
  /** Search TicketWebhook records: bounded contains on name (no vendor free-text search exists);
12241
12450
  * limit defaults to 25, max 500. */
12242
12451
  async search(query, opts) {
12243
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _110 => _110.limit]) });
12452
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _115 => _115.limit]) });
12244
12453
  }
12245
12454
  };
12246
12455
 
@@ -12255,62 +12464,62 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
12255
12464
  body: { MaxRecords: limit, filter },
12256
12465
  operation
12257
12466
  });
12258
- const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res);
12467
+ const { items, pageDetails } = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res);
12259
12468
  return { items, hasMore: pageDetails.nextPageUrl != null };
12260
12469
  }
12261
12470
  async function windowQuery3(_resource, kind, http, opts) {
12262
- const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _111 => _111.now]), () => ( /* @__PURE__ */ new Date()));
12263
- const tz = _optionalChain([opts, 'optionalAccess', _112 => _112.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
12471
+ const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _116 => _116.now]), () => ( /* @__PURE__ */ new Date()));
12472
+ const tz = _optionalChain([opts, 'optionalAccess', _117 => _117.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
12264
12473
  const { from, to } = dateOnlyWindowBounds(kind, now, tz);
12265
12474
  const filter = [
12266
12475
  { field: "dateWorked", op: "gte", value: from },
12267
12476
  { field: "dateWorked", op: "lte", value: to }
12268
12477
  ];
12269
- const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _113 => _113.limit])), `time_entries.${kind}`, http);
12478
+ const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _118 => _118.limit])), `time_entries.${kind}`, http);
12270
12479
  return items;
12271
12480
  }
12272
12481
  async function customRange3(_resource, from, to, http, opts) {
12273
- if (_optionalChain([opts, 'optionalAccess', _114 => _114.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
12482
+ if (_optionalChain([opts, 'optionalAccess', _119 => _119.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
12274
12483
  const fromB = customRangeDay(from, "from", void 0, "customRange");
12275
12484
  const toB = customRangeDay(to, "to", void 0, "customRange");
12276
12485
  if (fromB.ms > toB.ms) {
12277
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("customRange: from must not be after to");
12486
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("customRange: from must not be after to");
12278
12487
  }
12279
12488
  const toEndMs = toB.ms + DAY_MS2 - 1;
12280
12489
  const filter = [
12281
12490
  { field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
12282
12491
  { field: "dateWorked", op: "lte", value: iso2(toEndMs) }
12283
12492
  ];
12284
- const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _115 => _115.limit])), "time_entries.customRange", http);
12493
+ const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _120 => _120.limit])), "time_entries.customRange", http);
12285
12494
  return items;
12286
12495
  }
12287
12496
  async function postedDateStatusQuery(_resource, mode, http, opts) {
12288
12497
  const filter = [
12289
12498
  { field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
12290
12499
  ];
12291
- if (_optionalChain([opts, 'optionalAccess', _116 => _116.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12500
+ if (_optionalChain([opts, 'optionalAccess', _121 => _121.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12292
12501
  const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
12293
- const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _117 => _117.limit])), operation, http);
12502
+ const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _122 => _122.limit])), operation, http);
12294
12503
  return items;
12295
12504
  }
12296
12505
  async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
12297
- const OP7 = opLabel;
12298
- if (_optionalChain([opts, 'optionalAccess', _118 => _118.tz]) !== void 0) validateZone(opts.tz, OP7);
12299
- const fromB = customRangeDay(from, "from", void 0, OP7);
12300
- const toB = customRangeDay(to, "to", void 0, OP7);
12506
+ const OP9 = opLabel;
12507
+ if (_optionalChain([opts, 'optionalAccess', _123 => _123.tz]) !== void 0) validateZone(opts.tz, OP9);
12508
+ const fromB = customRangeDay(from, "from", void 0, OP9);
12509
+ const toB = customRangeDay(to, "to", void 0, OP9);
12301
12510
  if (fromB.ms > toB.ms) {
12302
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP7}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP7 });
12511
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP9}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP9 });
12303
12512
  }
12304
12513
  const windowToMs = toB.ms + DAY_MS2 - 1;
12305
12514
  const filter = [
12306
12515
  { field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
12307
12516
  { field: "dateWorked", op: "lte", value: iso2(windowToMs) }
12308
12517
  ];
12309
- if (_optionalChain([opts, 'optionalAccess', _119 => _119.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
12310
- else if (_optionalChain([opts, 'optionalAccess', _120 => _120.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
12311
- if (_optionalChain([opts, 'optionalAccess', _121 => _121.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12312
- if (_optionalChain([opts, 'optionalAccess', _122 => _122.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
12313
- const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _123 => _123.limit])), OP7, http);
12518
+ if (_optionalChain([opts, 'optionalAccess', _124 => _124.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
12519
+ else if (_optionalChain([opts, 'optionalAccess', _125 => _125.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
12520
+ if (_optionalChain([opts, 'optionalAccess', _126 => _126.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12521
+ if (_optionalChain([opts, 'optionalAccess', _127 => _127.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
12522
+ const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])), OP9, http);
12314
12523
  let postedCount = 0;
12315
12524
  for (const item of items) {
12316
12525
  const postedDate = item.postedDate;
@@ -12333,13 +12542,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
12333
12542
  }
12334
12543
 
12335
12544
  // src/resources/special/time_entries/errors.ts
12336
- var ResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
12545
+ var ResourceInvalidError = class extends _chunkD5IVS6GYcjs.AutotaskError {
12337
12546
  constructor(message, options = {}) {
12338
12547
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
12339
12548
  this.name = "ResourceInvalidError";
12340
12549
  }
12341
12550
  };
12342
- var AllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
12551
+ var AllocationCodeError = class extends _chunkD5IVS6GYcjs.AutotaskError {
12343
12552
  /** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
12344
12553
 
12345
12554
  constructor(kind, message, options = {}) {
@@ -12348,7 +12557,7 @@ var AllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
12348
12557
  this.kind = kind;
12349
12558
  }
12350
12559
  };
12351
- var NoApplicableAllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
12560
+ var NoApplicableAllocationCodeError = class extends _chunkD5IVS6GYcjs.AutotaskError {
12352
12561
  /** The structured blocker details (filters tried + department sets). */
12353
12562
 
12354
12563
  constructor(details, options = {}) {
@@ -12413,7 +12622,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
12413
12622
  let pages = 0;
12414
12623
  for (; ; ) {
12415
12624
  if (pages >= PAGE_GUARD) {
12416
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
12625
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
12417
12626
  code: "RESOLUTION_TRUNCATED",
12418
12627
  category: "resolution",
12419
12628
  operation,
@@ -12424,11 +12633,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
12424
12633
  const res = await http.request({
12425
12634
  method: "POST",
12426
12635
  idempotent: true,
12427
- path: isFirst ? path : _chunkZJ4ONAQFcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
12636
+ path: isFirst ? path : _chunkD5IVS6GYcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
12428
12637
  body: { MaxRecords: pageSize, filter },
12429
12638
  operation
12430
12639
  });
12431
- const { items: pageItems, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
12640
+ const { items: pageItems, pageDetails } = _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, operation);
12432
12641
  items.push(...pageItems);
12433
12642
  pages += 1;
12434
12643
  if (items.length >= totalCap) break;
@@ -12520,7 +12729,7 @@ async function resolveCode(http, family, familyLabel2, pinnedId, departments, op
12520
12729
  }
12521
12730
 
12522
12731
  // src/resources/special/time_entries/createForResource.ts
12523
- var OP3 = "time_entries.createForResource";
12732
+ var OP5 = "time_entries.createForResource";
12524
12733
  var PARAM_KEYS = /* @__PURE__ */ new Set([
12525
12734
  "internallAllocationCodeID",
12526
12735
  "ticketID",
@@ -12545,7 +12754,7 @@ function windowDefaults(params) {
12545
12754
  var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
12546
12755
  var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
12547
12756
  function validateCreateParams(params) {
12548
- const pin = (value, label) => typeof value === "number" ? _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, value, label) : void 0;
12757
+ const pin = (value, label) => typeof value === "number" ? _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, value, label) : void 0;
12549
12758
  const pins = {
12550
12759
  code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
12551
12760
  ticket: pin(params.ticketID, "ticketID"),
@@ -12554,32 +12763,32 @@ function validateCreateParams(params) {
12554
12763
  };
12555
12764
  const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
12556
12765
  if (pinCount > 1) {
12557
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
12766
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
12558
12767
  "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)",
12559
- { operation: OP3 }
12768
+ { operation: OP5 }
12560
12769
  );
12561
12770
  }
12562
12771
  if (pins.role !== void 0 && pins.code !== void 0) {
12563
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
12772
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
12564
12773
  "createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
12565
- { operation: OP3 }
12774
+ { operation: OP5 }
12566
12775
  );
12567
12776
  }
12568
12777
  if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
12569
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
12778
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
12570
12779
  `createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
12571
- { operation: OP3 }
12780
+ { operation: OP5 }
12572
12781
  );
12573
12782
  }
12574
12783
  return pins;
12575
12784
  }
12576
12785
  async function assertResourceActive(http, rid) {
12577
- const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP3);
12786
+ const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP5);
12578
12787
  if (rec === null) {
12579
12788
  throw new ResourceInvalidError(`Resource ${rid} was not found \u2014 a time entry cannot attach to a missing resource`, {
12580
12789
  resourceIds: [rid],
12581
12790
  details: { idRefs: [{ entity: "resource", id: rid }] },
12582
- operation: OP3,
12791
+ operation: OP5,
12583
12792
  category: "not_found",
12584
12793
  suggestedAction: "Resolve the resource id (resources.get / resources.search) and retry."
12585
12794
  });
@@ -12588,7 +12797,7 @@ async function assertResourceActive(http, rid) {
12588
12797
  throw new ResourceInvalidError(`Resource ${rid} is not active (isActive !== true) \u2014 the vendor would reject a time entry for an inactive resource`, {
12589
12798
  resourceIds: [rid],
12590
12799
  details: { idRefs: [{ entity: "resource", id: rid }] },
12591
- operation: OP3,
12800
+ operation: OP5,
12592
12801
  suggestedAction: "Activate the resource or pick an active one."
12593
12802
  });
12594
12803
  }
@@ -12598,11 +12807,11 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
12598
12807
  const pinnedForCode = pins.code !== void 0 ? pins.code : pins.role;
12599
12808
  let code = null;
12600
12809
  const familiesTried = [];
12601
- code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP3);
12810
+ code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP5);
12602
12811
  familiesTried.push({ family: familyOf(linkage), label: familyLabel(familyOf(linkage)), filters: [{ field: "useType", op: "eq", value: familyOf(linkage) }, { field: "isActive", op: "eq", value: true }] });
12603
12812
  if (code === null && linkage === "task" && pins.role === void 0) {
12604
12813
  usedLinkage = "internal";
12605
- code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP3);
12814
+ code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP5);
12606
12815
  familiesTried.push({ family: USE_TYPE_INTERNAL, label: familyLabel(USE_TYPE_INTERNAL), filters: [{ field: "useType", op: "eq", value: USE_TYPE_INTERNAL }, { field: "isActive", op: "eq", value: true }] });
12607
12816
  }
12608
12817
  if (code === null) {
@@ -12612,7 +12821,7 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
12612
12821
  families: familiesTried,
12613
12822
  resourceDepartments: [...departments].sort((a, b) => a - b)
12614
12823
  },
12615
- { operation: OP3 }
12824
+ { operation: OP5 }
12616
12825
  );
12617
12826
  }
12618
12827
  const resolvedCode = codeInfo(code);
@@ -12649,9 +12858,9 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
12649
12858
  if (usedLinkage === "internal" && linkage === "task") {
12650
12859
  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).");
12651
12860
  }
12652
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
12861
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
12653
12862
  {
12654
- operation: OP3,
12863
+ operation: OP5,
12655
12864
  method: "POST",
12656
12865
  path: "/V1.0/TimeEntries",
12657
12866
  ids: [rid],
@@ -12689,11 +12898,11 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
12689
12898
  };
12690
12899
  } catch (err) {
12691
12900
  lastError = err;
12692
- const text = _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
12901
+ const text = _chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkD5IVS6GYcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
12693
12902
  const gate3 = ROLE_REJECTION_PATTERN.test(text);
12694
12903
  if (usedLinkage !== "internal" && gate3) {
12695
12904
  if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
12696
- const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP3);
12905
+ const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP5);
12697
12906
  taskRoleFetched = true;
12698
12907
  if (task !== null) pushLadder(task.assignedResourceRoleID);
12699
12908
  }
@@ -12709,17 +12918,17 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
12709
12918
  throw err;
12710
12919
  }
12711
12920
  }
12712
- if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, lastError)) {
12921
+ if (_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, lastError)) {
12713
12922
  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.`;
12714
12923
  }
12715
12924
  throw lastError;
12716
12925
  }
12717
12926
  async function createForResource(resource, resourceID, params, opts = {}, http) {
12718
- const rid = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
12927
+ const rid = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
12719
12928
  const pins = validateCreateParams(params);
12720
12929
  await assertResourceActive(http, rid);
12721
12930
  const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
12722
- const roleRows = await resourceRoleRows(http, rid, OP3);
12931
+ const roleRows = await resourceRoleRows(http, rid, OP5);
12723
12932
  const departments = roleRows.departments;
12724
12933
  const { usedLinkage, resolvedCode } = await resolveAllocationCode(http, rid, linkage, pins, departments);
12725
12934
  const defaults = windowDefaults(params);
@@ -12728,8 +12937,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
12728
12937
  return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
12729
12938
  }
12730
12939
  function discoveryField(err, body, defaults) {
12731
- if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
12732
- const entries = _chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError);
12940
+ if (!_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
12941
+ const entries = _chunkD5IVS6GYcjs.parseVendorErrors.call(void 0, err.vendorError);
12733
12942
  if (entries === void 0) return null;
12734
12943
  for (const entry of entries) {
12735
12944
  const field = entry.field;
@@ -12742,42 +12951,42 @@ function discoveryField(err, body, defaults) {
12742
12951
  }
12743
12952
 
12744
12953
  // src/resources/special/time_entries/move.ts
12745
- var OP4 = "time_entries.moveToTicket";
12954
+ var OP6 = "time_entries.moveToTicket";
12746
12955
  var COPY2 = ["resourceID", "roleID", "billingCodeID", "dateWorked", "startDateTime", "endDateTime", "hoursWorked", "offsetHours", "summaryNotes", "internalNotes", "isNonBillable", "showOnInvoice"];
12747
12956
  var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundleID"];
12748
12957
  async function readTimeEntry(http, id, retries) {
12749
12958
  try {
12750
- const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP4, maxRetries: retries });
12751
- return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _124 => _124.item]), () => ( null));
12959
+ const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP6, maxRetries: retries });
12960
+ return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _129 => _129.item]), () => ( null));
12752
12961
  } catch (e) {
12753
- if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
12962
+ if (_chunkD5IVS6GYcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
12754
12963
  throw e;
12755
12964
  }
12756
12965
  }
12757
12966
  async function checkSource2({ http, source, sourceId, toTicketId, retries }) {
12758
12967
  const ids2 = { sourceId, toTicketId };
12759
12968
  if (source.taskID !== null && source.taskID !== void 0) {
12760
- throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP4}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP4);
12969
+ throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP6}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP6);
12761
12970
  }
12762
12971
  if (source.billingApprovalDateTime || source.billingApprovalResourceID || source.billingApprovalLevelMostRecent) {
12763
- throw refuse("MOVE_BLOCKED_APPROVED", `${OP4}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP4, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
12972
+ throw refuse("MOVE_BLOCKED_APPROVED", `${OP6}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP6, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
12764
12973
  }
12765
12974
  let billing;
12766
12975
  try {
12767
- billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP4, retries);
12976
+ billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP6, retries);
12768
12977
  } catch (e3) {
12769
- throw refuse("MOVE_BLOCKED_BILLED", `${OP4}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP4, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
12978
+ throw refuse("MOVE_BLOCKED_BILLED", `${OP6}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP6, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
12770
12979
  }
12771
12980
  if (billing.some((b) => b.invoiceID || b.postedDate)) {
12772
- throw refuse("MOVE_BLOCKED_BILLED", `${OP4}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP4, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
12981
+ throw refuse("MOVE_BLOCKED_BILLED", `${OP6}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP6, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
12773
12982
  }
12774
- const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP4, retries);
12983
+ const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP6, retries);
12775
12984
  if (attachments.length > 0) {
12776
- throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP4}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP4, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
12985
+ throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP6}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP6, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
12777
12986
  }
12778
12987
  }
12779
12988
  var SPEC2 = {
12780
- operation: OP4,
12989
+ operation: OP6,
12781
12990
  entity: "time_entry",
12782
12991
  readSource: readTimeEntry,
12783
12992
  sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
@@ -12812,15 +13021,15 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
12812
13021
  }
12813
13022
 
12814
13023
  // src/resources/special/time_entries/approve.ts
12815
- var OP5 = "time_entries.approve";
13024
+ var OP7 = "time_entries.approve";
12816
13025
  var APPROVAL_LEVELS_PATH = "/V1.0/BillingItemApprovalLevels";
12817
13026
  function toIso(value) {
12818
13027
  if (value instanceof Date) {
12819
- if (Number.isNaN(value.getTime())) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
13028
+ if (Number.isNaN(value.getTime())) throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
12820
13029
  return value.toISOString();
12821
13030
  }
12822
13031
  const parsed = new Date(value);
12823
- if (Number.isNaN(parsed.getTime())) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
13032
+ if (Number.isNaN(parsed.getTime())) throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
12824
13033
  return parsed.toISOString();
12825
13034
  }
12826
13035
  function toNumber(value) {
@@ -12833,24 +13042,24 @@ function sameInstant(a, b) {
12833
13042
  return !Number.isNaN(left) && left === right;
12834
13043
  }
12835
13044
  async function approve(resource, id, opts = {}, http) {
12836
- const numericId = toNumber(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id"));
13045
+ const numericId = toNumber(_chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id"));
12837
13046
  if (opts.approvalLevel !== void 0 && (!Number.isInteger(opts.approvalLevel) || opts.approvalLevel < 1)) {
12838
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
13047
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
12839
13048
  }
12840
13049
  const approvalLevel = _nullishCoalesce(opts.approvalLevel, () => ( 1));
12841
13050
  const approvalDateTime = toIso(_nullishCoalesce(opts.approvalDateTime, () => ( /* @__PURE__ */ new Date())));
12842
13051
  const entry = await resource.get(numericId);
12843
- const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
13052
+ const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunkD5IVS6GYcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
12844
13053
  if (approvalResourceID === void 0) {
12845
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
13054
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(
12846
13055
  `time_entries.approve: time entry ${numericId} carries no resourceID and the caller supplied no approvalResourceID \u2014 the vendor requires an approving resource`
12847
13056
  );
12848
13057
  }
12849
13058
  const body = { timeEntryID: numericId, approvalLevel, approvalResourceID, approvalDateTime };
12850
13059
  if (opts.dryRun === true) {
12851
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
13060
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0,
12852
13061
  {
12853
- operation: OP5,
13062
+ operation: OP7,
12854
13063
  method: "POST",
12855
13064
  path: APPROVAL_LEVELS_PATH,
12856
13065
  ids: [numericId],
@@ -12873,10 +13082,10 @@ async function approve(resource, id, opts = {}, http) {
12873
13082
  method: "POST",
12874
13083
  path: APPROVAL_LEVELS_PATH,
12875
13084
  body,
12876
- operation: OP5,
13085
+ operation: OP7,
12877
13086
  maxRetries: opts.maxRetries
12878
13087
  });
12879
- const levelId = toNumber(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, created, OP5).id, "billingItemApprovalLevelID"));
13088
+ const levelId = toNumber(_chunkD5IVS6GYcjs.parseIdentifier.call(void 0, _chunkD5IVS6GYcjs.unwrapOperation.call(void 0, created, OP7).id, "billingItemApprovalLevelID"));
12880
13089
  await resource.update(
12881
13090
  numericId,
12882
13091
  { billingApprovalDateTime: approvalDateTime, billingApprovalResourceID: approvalResourceID },
@@ -12899,28 +13108,28 @@ async function approve(resource, id, opts = {}, http) {
12899
13108
  }
12900
13109
 
12901
13110
  // src/resources/special/time_entries/recentTickets.ts
12902
- var OP6 = "time_entries.recentTickets";
13111
+ var OP8 = "time_entries.recentTickets";
12903
13112
  var DAY_MS3 = 864e5;
12904
- var TICKET_CHUNK = 100;
12905
- var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
12906
- function positiveId(value, name) {
13113
+ var TICKET_CHUNK2 = 100;
13114
+ var TICKET_FIELDS3 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
13115
+ function positiveId2(value, name) {
12907
13116
  const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
12908
13117
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
12909
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP6 });
13118
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP8}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP8 });
12910
13119
  }
12911
13120
  return n;
12912
13121
  }
12913
13122
  async function recentTickets(_resource, from, to, http, opts) {
12914
13123
  if (opts === void 0 || opts === null || typeof opts !== "object") {
12915
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP6 });
13124
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP8}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP8 });
12916
13125
  }
12917
- const resourceID = positiveId(opts.resourceID, "resourceID");
12918
- const companyID = opts.companyID === void 0 ? void 0 : positiveId(opts.companyID, "companyID");
12919
- if (opts.tz !== void 0) validateZone(opts.tz, OP6);
12920
- const fromB = customRangeDay(from, "from", void 0, OP6);
12921
- const toB = customRangeDay(to, "to", void 0, OP6);
13126
+ const resourceID = positiveId2(opts.resourceID, "resourceID");
13127
+ const companyID = opts.companyID === void 0 ? void 0 : positiveId2(opts.companyID, "companyID");
13128
+ if (opts.tz !== void 0) validateZone(opts.tz, OP8);
13129
+ const fromB = customRangeDay(from, "from", void 0, OP8);
13130
+ const toB = customRangeDay(to, "to", void 0, OP8);
12922
13131
  if (fromB.ms > toB.ms) {
12923
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP6 });
13132
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)(`${OP8}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP8 });
12924
13133
  }
12925
13134
  const windowToMs = toB.ms + DAY_MS3 - 1;
12926
13135
  const { items: entries, hasMore } = await queryTimeEntries(
@@ -12931,7 +13140,7 @@ async function recentTickets(_resource, from, to, http, opts) {
12931
13140
  { field: "resourceID", op: "eq", value: resourceID }
12932
13141
  ],
12933
13142
  clampWindowLimit(opts.limit),
12934
- OP6,
13143
+ OP8,
12935
13144
  http
12936
13145
  );
12937
13146
  const groups = /* @__PURE__ */ new Map();
@@ -12949,17 +13158,17 @@ async function recentTickets(_resource, from, to, http, opts) {
12949
13158
  }
12950
13159
  const ids2 = [...groups.keys()];
12951
13160
  const tickets = /* @__PURE__ */ new Map();
12952
- for (let c = 0; c < ids2.length; c += TICKET_CHUNK) {
12953
- const chunk = ids2.slice(c, c + TICKET_CHUNK);
13161
+ for (let c = 0; c < ids2.length; c += TICKET_CHUNK2) {
13162
+ const chunk = ids2.slice(c, c + TICKET_CHUNK2);
12954
13163
  const filter = [{ field: "id", op: "in", value: chunk }];
12955
13164
  const res = await http.request({
12956
13165
  method: "POST",
12957
13166
  idempotent: true,
12958
13167
  path: "/V1.0/Tickets/query",
12959
- body: { MaxRecords: TICKET_CHUNK, filter, IncludeFields: TICKET_FIELDS2 },
12960
- operation: OP6
13168
+ body: { MaxRecords: TICKET_CHUNK2, filter, IncludeFields: TICKET_FIELDS3 },
13169
+ operation: OP8
12961
13170
  });
12962
- for (const t of _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, OP6).items) if (typeof t.id === "number") tickets.set(t.id, t);
13171
+ for (const t of _chunkD5IVS6GYcjs.unwrapItems.call(void 0, res, OP8).items) if (typeof t.id === "number") tickets.set(t.id, t);
12963
13172
  }
12964
13173
  const items = [];
12965
13174
  const unresolvedTicketIDs = [];
@@ -12967,17 +13176,17 @@ async function recentTickets(_resource, from, to, http, opts) {
12967
13176
  for (const [ticketID, g] of groups) {
12968
13177
  const t = tickets.get(ticketID);
12969
13178
  if (t === void 0) unresolvedTicketIDs.push(ticketID);
12970
- if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _125 => _125.companyID]) !== companyID) {
13179
+ if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _130 => _130.companyID]) !== companyID) {
12971
13180
  if (t !== void 0) excludedTickets += 1;
12972
13181
  continue;
12973
13182
  }
12974
13183
  items.push({
12975
13184
  ticketID,
12976
- ..._optionalChain([t, 'optionalAccess', _126 => _126.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
12977
- ..._optionalChain([t, 'optionalAccess', _127 => _127.title]) !== void 0 ? { title: t.title } : {},
12978
- ..._optionalChain([t, 'optionalAccess', _128 => _128.status]) !== void 0 ? { status: t.status } : {},
12979
- ..._optionalChain([t, 'optionalAccess', _129 => _129.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
12980
- ..._optionalChain([t, 'optionalAccess', _130 => _130.companyID]) !== void 0 ? { companyID: t.companyID } : {},
13185
+ ..._optionalChain([t, 'optionalAccess', _131 => _131.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
13186
+ ..._optionalChain([t, 'optionalAccess', _132 => _132.title]) !== void 0 ? { title: t.title } : {},
13187
+ ..._optionalChain([t, 'optionalAccess', _133 => _133.status]) !== void 0 ? { status: t.status } : {},
13188
+ ..._optionalChain([t, 'optionalAccess', _134 => _134.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
13189
+ ..._optionalChain([t, 'optionalAccess', _135 => _135.companyID]) !== void 0 ? { companyID: t.companyID } : {},
12981
13190
  entryCount: g.entryCount,
12982
13191
  totalHours: Math.round(g.totalHours * 100) / 100,
12983
13192
  lastWorked: g.lastWorked
@@ -12996,7 +13205,7 @@ async function recentTickets(_resource, from, to, http, opts) {
12996
13205
  }
12997
13206
 
12998
13207
  // src/resources/time_entries.ts
12999
- var TimeEntriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
13208
+ var TimeEntriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
13000
13209
  constructor(http, pageSize) {
13001
13210
  super(http, {
13002
13211
  key: "time_entries",
@@ -13145,7 +13354,7 @@ var TimeEntriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
13145
13354
  };
13146
13355
 
13147
13356
  // src/resources/time_entry_attachments.ts
13148
- var TimeEntryAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
13357
+ var TimeEntryAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
13149
13358
  constructor(http, pageSize) {
13150
13359
  super(http, {
13151
13360
  key: "time_entry_attachments",
@@ -13208,9 +13417,9 @@ var TimeEntryAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
13208
13417
 
13209
13418
  // src/resources/special/time_off_requests.ts
13210
13419
  async function approve2(_resource, id, opts = {}, http) {
13211
- const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
13420
+ const numericId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
13212
13421
  if (opts.dryRun === true) {
13213
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
13422
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
13214
13423
  operation: "time_off_requests.approve",
13215
13424
  method: "GET",
13216
13425
  path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
@@ -13226,16 +13435,16 @@ async function approve2(_resource, id, opts = {}, http) {
13226
13435
  operation: "time_off_requests.approve",
13227
13436
  maxRetries: opts.maxRetries
13228
13437
  });
13229
- return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
13438
+ return _chunkD5IVS6GYcjs.unwrapOperation.call(void 0, res);
13230
13439
  }
13231
13440
  async function reject(_resource, id, reason, opts = {}, http) {
13232
- const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
13441
+ const numericId = _chunkD5IVS6GYcjs.parseIdentifier.call(void 0, id, "id");
13233
13442
  const text = reason.trim();
13234
13443
  if (text === "") {
13235
- throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
13444
+ throw new (0, _chunkD5IVS6GYcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
13236
13445
  }
13237
13446
  if (opts.dryRun === true) {
13238
- return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
13447
+ return _chunkD5IVS6GYcjs.buildDryRunResult.call(void 0, {
13239
13448
  operation: "time_off_requests.reject",
13240
13449
  method: "POST",
13241
13450
  path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
@@ -13253,11 +13462,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
13253
13462
  operation: "time_off_requests.reject",
13254
13463
  maxRetries: opts.maxRetries
13255
13464
  });
13256
- return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
13465
+ return _chunkD5IVS6GYcjs.unwrapOperation.call(void 0, res);
13257
13466
  }
13258
13467
 
13259
13468
  // src/resources/time_off_requests.ts
13260
- var TimeOffRequestsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
13469
+ var TimeOffRequestsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
13261
13470
  constructor(http, pageSize) {
13262
13471
  super(http, {
13263
13472
  key: "time_off_requests",