node-autotask 0.31.0 → 0.33.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 (38) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/MCP_TOOL_CATALOG.json +31 -12
  3. package/MCP_TOOL_MANIFEST.md +18 -19
  4. package/MCP_TOOL_OVERRIDES.json +0 -12
  5. package/N8N_MCP_MANIFEST.json +44 -18
  6. package/N8N_MCP_MANIFEST.md +15 -14
  7. package/README.md +8 -6
  8. package/capabilities.json +1579 -1414
  9. package/dist/capabilities.cjs +2 -2
  10. package/dist/capabilities.js +1 -1
  11. package/dist/{chunk-3H3RJ4LA.cjs → chunk-3LAZZT7V.cjs} +143 -143
  12. package/dist/{chunk-PCLL536B.cjs → chunk-4QN43TRP.cjs} +75 -50
  13. package/dist/{chunk-6UA544OR.js → chunk-5DS6F6GF.js} +299 -113
  14. package/dist/{chunk-RQZUV74N.js → chunk-7WNE5MPG.js} +2 -2
  15. package/dist/{chunk-INSFDXHP.js → chunk-MFDQHFGJ.js} +28 -3
  16. package/dist/{chunk-DQLEVKZS.cjs → chunk-OO67MRHN.cjs} +814 -628
  17. package/dist/{chunk-QXUN2VCJ.cjs → chunk-SP2SJJZX.cjs} +1578 -1413
  18. package/dist/{chunk-EPOHRNSX.js → chunk-VKE56TTN.js} +1578 -1413
  19. package/dist/{index-Uqj987EE.d.ts → index-BaeMHZPk.d.ts} +149 -12
  20. package/dist/{index--5jrRl4u.d.cts → index-Cq0VsfSz.d.cts} +149 -12
  21. package/dist/index.cjs +22 -22
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +4 -4
  25. package/dist/operations/index.cjs +120 -133
  26. package/dist/operations/index.d.cts +2 -2
  27. package/dist/operations/index.d.ts +2 -2
  28. package/dist/operations/index.js +3 -16
  29. package/dist/pool.cjs +9 -9
  30. package/dist/pool.d.cts +1 -1
  31. package/dist/pool.d.ts +1 -1
  32. package/dist/pool.js +4 -4
  33. package/dist/resources/index.cjs +4 -4
  34. package/dist/resources/index.d.cts +1 -1
  35. package/dist/resources/index.d.ts +1 -1
  36. package/dist/resources/index.js +3 -3
  37. package/docs/API.md +62 -37
  38. package/package.json +2 -1
@@ -40,13 +40,14 @@
40
40
 
41
41
 
42
42
 
43
- var _chunkPCLL536Bcjs = require('./chunk-PCLL536B.cjs');
44
43
 
44
+ var _chunk4QN43TRPcjs = require('./chunk-4QN43TRP.cjs');
45
45
 
46
- var _chunkQXUN2VCJcjs = require('./chunk-QXUN2VCJ.cjs');
46
+
47
+ var _chunkSP2SJJZXcjs = require('./chunk-SP2SJJZX.cjs');
47
48
 
48
49
  // src/resources/appointments.ts
49
- var AppointmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
50
+ var AppointmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
50
51
  constructor(http, pageSize) {
51
52
  super(http, {
52
53
  key: "appointments",
@@ -131,7 +132,7 @@ var AuthenticateResource = class {
131
132
  };
132
133
 
133
134
  // src/resources/billing_codes.ts
134
- var BillingCodesResource = class extends _chunkPCLL536Bcjs.BaseResource {
135
+ var BillingCodesResource = class extends _chunk4QN43TRPcjs.BaseResource {
135
136
  constructor(http, pageSize) {
136
137
  super(http, {
137
138
  key: "billing_codes",
@@ -175,7 +176,7 @@ var BillingCodesResource = class extends _chunkPCLL536Bcjs.BaseResource {
175
176
  };
176
177
 
177
178
  // src/resources/billing_item_approval_levels.ts
178
- var BillingItemApprovalLevelsResource = class extends _chunkPCLL536Bcjs.BaseResource {
179
+ var BillingItemApprovalLevelsResource = class extends _chunk4QN43TRPcjs.BaseResource {
179
180
  constructor(http, pageSize) {
180
181
  super(http, {
181
182
  key: "billing_item_approval_levels",
@@ -217,7 +218,7 @@ var MAX_LIMIT = 500;
217
218
  function clampWindowLimit(limit) {
218
219
  const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
219
220
  if (!Number.isInteger(n) || n < 1) {
220
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
221
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
221
222
  }
222
223
  return Math.min(n, MAX_LIMIT);
223
224
  }
@@ -263,7 +264,7 @@ function wallParts(tz, ms) {
263
264
  }
264
265
  }
265
266
  if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
266
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
267
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
267
268
  }
268
269
  return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
269
270
  }
@@ -273,11 +274,11 @@ function tzOffsetMs(tz, ms) {
273
274
  }
274
275
  function localDayStartMs(y, m, d, tz) {
275
276
  if (tz === void 0) return Date.UTC(y, m - 1, d);
276
- const candidate = Date.UTC(y, m - 1, d);
277
- const offset = tzOffsetMs(tz, candidate);
278
- let start = candidate - offset;
277
+ const candidate2 = Date.UTC(y, m - 1, d);
278
+ const offset = tzOffsetMs(tz, candidate2);
279
+ let start = candidate2 - offset;
279
280
  if (tzOffsetMs(tz, start) !== offset) {
280
- start = candidate - tzOffsetMs(tz, start);
281
+ start = candidate2 - tzOffsetMs(tz, start);
281
282
  }
282
283
  const p = wallParts(tz, start);
283
284
  if (p.d !== d) start += 864e5 - ((p.h * 60 + p.mi) * 60 + p.s) * 1e3;
@@ -290,7 +291,7 @@ function localDayEndMs(y, m, d, tz) {
290
291
  }
291
292
  function validateZone(tz, opName = "dateWindow") {
292
293
  if (typeof tz !== "string" || tz.length === 0) {
293
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
294
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
294
295
  `${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
295
296
  { operation: opName }
296
297
  );
@@ -298,7 +299,7 @@ function validateZone(tz, opName = "dateWindow") {
298
299
  try {
299
300
  new Intl.DateTimeFormat("en-US", { timeZone: tz });
300
301
  } catch (e2) {
301
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
302
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
302
303
  `${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
303
304
  { operation: opName }
304
305
  );
@@ -446,7 +447,7 @@ function dateOnlyWindowBounds(kind, now, tz) {
446
447
  }
447
448
  async function dateWindowQuery(http, path, field, kind, limit, operation, now, tz) {
448
449
  const zone = tz === void 0 ? void 0 : validateZone(tz, operation);
449
- const { from, to } = dateWindowBounds(kind, now, zone);
450
+ const { from, to } = dateOnlyWindowBounds(kind, now, zone);
450
451
  const filter = [
451
452
  { field, op: "gte", value: from },
452
453
  { field, op: "lte", value: to }
@@ -458,13 +459,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
458
459
  body: { MaxRecords: limit, filter },
459
460
  operation
460
461
  });
461
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
462
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
462
463
  }
463
464
  var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
464
465
  function customRangeDay(value, label, zone, opName) {
465
466
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
466
467
  if (!m) {
467
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
468
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
468
469
  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)})`,
469
470
  { operation: opName }
470
471
  );
@@ -476,7 +477,7 @@ function customRangeDay(value, label, zone, opName) {
476
477
  const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
477
478
  const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
478
479
  if (!Number.isFinite(ms)) {
479
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
480
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
480
481
  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)})`,
481
482
  { operation: opName }
482
483
  );
@@ -484,15 +485,16 @@ function customRangeDay(value, label, zone, opName) {
484
485
  return { y, mo, d, ms };
485
486
  }
486
487
  async function customRangeQuery(http, path, field, from, to, limit, operation, zone) {
487
- const fromB = customRangeDay(from, "from", zone, operation);
488
- const toB = customRangeDay(to, "to", zone, operation);
488
+ if (zone !== void 0) validateZone(zone, operation);
489
+ const fromB = customRangeDay(from, "from", void 0, operation);
490
+ const toB = customRangeDay(to, "to", void 0, operation);
489
491
  if (fromB.ms > toB.ms) {
490
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
492
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
491
493
  `${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
492
494
  { operation }
493
495
  );
494
496
  }
495
- const toEndMs = zone === void 0 ? toB.ms + DAY_MS - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
497
+ const toEndMs = toB.ms + DAY_MS - 1;
496
498
  const filter = [
497
499
  { field, op: "gte", value: isoUtc(fromB.ms) },
498
500
  { field, op: "lte", value: isoUtc(toEndMs) }
@@ -504,7 +506,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
504
506
  body: { MaxRecords: limit, filter },
505
507
  operation
506
508
  });
507
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
509
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
508
510
  }
509
511
 
510
512
  // src/resources/special/billing_items.ts
@@ -537,7 +539,7 @@ async function customRange(_resource, from, to, http, opts) {
537
539
  }
538
540
 
539
541
  // src/resources/billing_items.ts
540
- var BillingItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
542
+ var BillingItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
541
543
  constructor(http, pageSize) {
542
544
  super(http, {
543
545
  key: "billing_items",
@@ -639,7 +641,7 @@ var BillingItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
639
641
  };
640
642
 
641
643
  // src/resources/change_request_links.ts
642
- var ChangeRequestLinksResource = class extends _chunkPCLL536Bcjs.BaseResource {
644
+ var ChangeRequestLinksResource = class extends _chunk4QN43TRPcjs.BaseResource {
643
645
  constructor(http, pageSize) {
644
646
  super(http, {
645
647
  key: "change_request_links",
@@ -693,7 +695,7 @@ var ChangeRequestLinksResource = class extends _chunkPCLL536Bcjs.BaseResource {
693
695
  };
694
696
 
695
697
  // src/resources/checklist_libraries.ts
696
- var ChecklistLibrariesResource = class extends _chunkPCLL536Bcjs.BaseResource {
698
+ var ChecklistLibrariesResource = class extends _chunk4QN43TRPcjs.BaseResource {
697
699
  constructor(http, pageSize) {
698
700
  super(http, {
699
701
  key: "checklist_libraries",
@@ -767,7 +769,7 @@ var ChecklistLibrariesResource = class extends _chunkPCLL536Bcjs.BaseResource {
767
769
  };
768
770
 
769
771
  // src/resources/checklist_library_checklist_items.ts
770
- var ChecklistLibraryChecklistItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
772
+ var ChecklistLibraryChecklistItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
771
773
  constructor(http, pageSize) {
772
774
  super(http, {
773
775
  key: "checklist_library_checklist_items",
@@ -833,7 +835,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkPCLL536Bcjs.Bas
833
835
  };
834
836
 
835
837
  // src/resources/classification_icons.ts
836
- var ClassificationIconsResource = class extends _chunkPCLL536Bcjs.BaseResource {
838
+ var ClassificationIconsResource = class extends _chunk4QN43TRPcjs.BaseResource {
837
839
  constructor(http, pageSize) {
838
840
  super(http, {
839
841
  key: "classification_icons",
@@ -940,7 +942,7 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
940
942
  body,
941
943
  operation
942
944
  });
943
- const { items, pageDetails } = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, operation);
945
+ const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, operation);
944
946
  const capped = items.length >= limit;
945
947
  return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
946
948
  }
@@ -950,7 +952,7 @@ var DEFAULT_LIMIT2 = 25;
950
952
  var MAX_LIMIT2 = 500;
951
953
  function clampLimit(limit) {
952
954
  const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
953
- if (!Number.isInteger(n) || n < 1) throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
955
+ if (!Number.isInteger(n) || n < 1) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
954
956
  return Math.min(n, MAX_LIMIT2);
955
957
  }
956
958
 
@@ -963,7 +965,7 @@ async function queryCompanies(http, filter, limit) {
963
965
  body: { MaxRecords: limit, filter },
964
966
  operation: "companies.searchByDomain"
965
967
  });
966
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
968
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
967
969
  }
968
970
  async function queryContacts(http, filter, limit) {
969
971
  const res = await http.request({
@@ -973,7 +975,7 @@ async function queryContacts(http, filter, limit) {
973
975
  body: { MaxRecords: limit, filter },
974
976
  operation: "companies.searchByDomain"
975
977
  });
976
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
978
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
977
979
  }
978
980
  async function fetchCompanies(http, ids2, limit) {
979
981
  const out = [];
@@ -988,7 +990,7 @@ async function fetchCompanies(http, ids2, limit) {
988
990
  const item = body && "item" in body ? body.item : null;
989
991
  if (item) out.push(item);
990
992
  } catch (err) {
991
- if (err instanceof _chunkPCLL536Bcjs.NotFoundError) continue;
993
+ if (err instanceof _chunk4QN43TRPcjs.NotFoundError) continue;
992
994
  throw err;
993
995
  }
994
996
  }
@@ -996,7 +998,7 @@ async function fetchCompanies(http, ids2, limit) {
996
998
  }
997
999
  async function searchByDomain(_resource, domain, opts = {}, http) {
998
1000
  const text = domain.trim();
999
- if (text === "") throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("searchByDomain: empty domain");
1001
+ if (text === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("searchByDomain: empty domain");
1000
1002
  const limit = clampLimit(opts.limit);
1001
1003
  const filter = [{ field: "webAddress", op: "contains", value: text }];
1002
1004
  const direct = await queryCompanies(http, filter, limit);
@@ -1010,7 +1012,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
1010
1012
  const email = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.email, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
1011
1013
  const website = _nullishCoalesce(_optionalChain([identity, 'access', _15 => _15.website, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]), () => ( ""));
1012
1014
  if (name === "" && email === "" && website === "") {
1013
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
1015
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
1014
1016
  }
1015
1017
  const limit = clampLimit(opts.limit);
1016
1018
  const found = /* @__PURE__ */ new Map();
@@ -1039,23 +1041,23 @@ async function familyChildPage(http, parentID) {
1039
1041
  path: "/V1.0/Companies/query",
1040
1042
  body: {
1041
1043
  MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
1042
- filter: _chunkPCLL536Bcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
1044
+ filter: _chunk4QN43TRPcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
1043
1045
  },
1044
1046
  operation: "companies.search"
1045
1047
  });
1046
- const { items, pageDetails } = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, "companies.search");
1048
+ const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "companies.search");
1047
1049
  return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
1048
1050
  }
1049
1051
  function assertSearchWithDetailOpts(opts) {
1050
1052
  if (opts === void 0) return;
1051
1053
  if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
1052
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
1054
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
1053
1055
  operation: "companies.searchWithDetail"
1054
1056
  });
1055
1057
  }
1056
1058
  for (const key of Object.keys(opts)) {
1057
1059
  if (key !== "limit") {
1058
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
1060
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
1059
1061
  `companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
1060
1062
  { operation: "companies.searchWithDetail" }
1061
1063
  );
@@ -1064,32 +1066,32 @@ function assertSearchWithDetailOpts(opts) {
1064
1066
  }
1065
1067
  async function searchWithFamily(_resource, query, opts = {}, http) {
1066
1068
  if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
1067
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
1069
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
1068
1070
  }
1069
1071
  for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
1070
1072
  if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
1071
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
1073
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
1072
1074
  `companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
1073
1075
  { operation: "companies.search" }
1074
1076
  );
1075
1077
  }
1076
1078
  }
1077
1079
  if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
1078
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
1080
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
1079
1081
  operation: "companies.search"
1080
1082
  });
1081
1083
  }
1082
1084
  const text = query.trim();
1083
- if (text === "") throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
1084
- const limit = opts.limit === void 0 ? 25 : _chunkPCLL536Bcjs.clampPageSize.call(void 0, opts.limit);
1085
+ if (text === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
1086
+ const limit = opts.limit === void 0 ? 25 : _chunk4QN43TRPcjs.clampPageSize.call(void 0, opts.limit);
1085
1087
  const res = await http.request({
1086
1088
  method: "POST",
1087
1089
  idempotent: true,
1088
1090
  path: "/V1.0/Companies/query",
1089
- body: { MaxRecords: limit, filter: _chunkPCLL536Bcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
1091
+ body: { MaxRecords: limit, filter: _chunk4QN43TRPcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
1090
1092
  operation: "companies.search"
1091
1093
  });
1092
- const hits = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, "companies.search").items;
1094
+ const hits = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "companies.search").items;
1093
1095
  if (opts.includeFamily !== true) return hits;
1094
1096
  const rows = [];
1095
1097
  for (const hit of hits) {
@@ -1109,7 +1111,7 @@ async function searchWithFamily(_resource, query, opts = {}, http) {
1109
1111
  }
1110
1112
 
1111
1113
  // src/resources/special/companies/errors.ts
1112
- var OwnerResourceRequiredError = class extends _chunkPCLL536Bcjs.AutotaskError {
1114
+ var OwnerResourceRequiredError = class extends _chunk4QN43TRPcjs.AutotaskError {
1113
1115
  constructor(message, options = {}) {
1114
1116
  super(message, {
1115
1117
  code: "OWNER_RESOURCE_REQUIRED",
@@ -1120,13 +1122,13 @@ var OwnerResourceRequiredError = class extends _chunkPCLL536Bcjs.AutotaskError {
1120
1122
  this.name = "OwnerResourceRequiredError";
1121
1123
  }
1122
1124
  };
1123
- var CompanyResourceInvalidError = class extends _chunkPCLL536Bcjs.AutotaskError {
1125
+ var CompanyResourceInvalidError = class extends _chunk4QN43TRPcjs.AutotaskError {
1124
1126
  constructor(message, options = {}) {
1125
1127
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
1126
1128
  this.name = "CompanyResourceInvalidError";
1127
1129
  }
1128
1130
  };
1129
- var CompanyCreateFailedError = class extends _chunkPCLL536Bcjs.AutotaskError {
1131
+ var CompanyCreateFailedError = class extends _chunk4QN43TRPcjs.AutotaskError {
1130
1132
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
1131
1133
 
1132
1134
  constructor(message, vendorFields, options = {}) {
@@ -1145,23 +1147,23 @@ var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumer
1145
1147
  var SAFE_COMPANY_CREATE_DEFAULTS = {};
1146
1148
  function validateUpsertInput(companyName, params) {
1147
1149
  if (typeof companyName !== "string" || companyName.trim() === "") {
1148
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
1150
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
1149
1151
  }
1150
1152
  if (typeof _optionalChain([params, 'optionalAccess', _18 => _18.phone]) !== "string" || params.phone.trim() === "") {
1151
- throw new (0, _chunkPCLL536Bcjs.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 });
1153
+ throw new (0, _chunk4QN43TRPcjs.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 });
1152
1154
  }
1153
1155
  const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
1154
1156
  if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
1155
- throw new (0, _chunkPCLL536Bcjs.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 });
1157
+ throw new (0, _chunk4QN43TRPcjs.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 });
1156
1158
  }
1157
1159
  const owner = params.ownerResourceID;
1158
1160
  if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
1159
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
1161
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
1160
1162
  }
1161
1163
  return { companyType, owner };
1162
1164
  }
1163
1165
  function existsDryRun(http, companyName, match) {
1164
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
1166
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
1165
1167
  {
1166
1168
  operation: OP_UPSERT_NAME,
1167
1169
  method: "POST",
@@ -1187,7 +1189,7 @@ function createDryRun(http, body, owner) {
1187
1189
  "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"
1188
1190
  );
1189
1191
  }
1190
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
1192
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
1191
1193
  {
1192
1194
  operation: OP_UPSERT_NAME,
1193
1195
  method: "POST",
@@ -1232,8 +1234,8 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
1232
1234
  sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
1233
1235
  };
1234
1236
  } catch (err) {
1235
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
1236
- const named = (_nullishCoalesce(_chunkPCLL536Bcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
1237
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
1238
+ const named = (_nullishCoalesce(_chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
1237
1239
  const seen = /* @__PURE__ */ new Set();
1238
1240
  const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
1239
1241
  const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
@@ -1247,7 +1249,7 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
1247
1249
  }
1248
1250
  continue;
1249
1251
  }
1250
- const detail = _chunkPCLL536Bcjs.formatVendorDetail.call(void 0, err.vendorError);
1252
+ const detail = _chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError);
1251
1253
  throw new CompanyCreateFailedError(
1252
1254
  `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}` : ""}`,
1253
1255
  unique,
@@ -1321,7 +1323,7 @@ async function readFields(http, fresh) {
1321
1323
  const res = await http.request({ method: "GET", path: "/V1.0/Tickets/entityInformation/fields", operation: OP, maxRetries: 0 });
1322
1324
  const fields = _optionalChain([res, 'optionalAccess', _21 => _21.fields]);
1323
1325
  if (!Array.isArray(fields)) {
1324
- throw new (0, _chunkPCLL536Bcjs.AutotaskError)("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
1326
+ throw new (0, _chunk4QN43TRPcjs.AutotaskError)("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
1325
1327
  }
1326
1328
  _optionalChain([cache, 'optionalAccess', _22 => _22.set, 'call', _23 => _23(key, "fields", fields)]);
1327
1329
  return fields;
@@ -1340,7 +1342,7 @@ async function resolveTicketStatusSemantics(http, opts = {}) {
1340
1342
  if (opts.excludeStatusIds !== void 0) {
1341
1343
  const closedIds2 = [...new Set(opts.excludeStatusIds.map((id) => Number(id)))];
1342
1344
  if (closedIds2.length === 0 || closedIds2.some((id) => !Number.isSafeInteger(id) || id < 1)) {
1343
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`excludeStatusIds must be a non-empty list of positive status ids (got ${JSON.stringify(opts.excludeStatusIds)})`, { operation: OP });
1345
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`excludeStatusIds must be a non-empty list of positive status ids (got ${JSON.stringify(opts.excludeStatusIds)})`, { operation: OP });
1344
1346
  }
1345
1347
  return { picklist: [], closedIds: closedIds2, source: "picklist", note: `closed = status ${closedIds2.join(", ")} \u2014 supplied by the caller` };
1346
1348
  }
@@ -1348,7 +1350,7 @@ async function resolveTicketStatusSemantics(http, opts = {}) {
1348
1350
  try {
1349
1351
  fields = await readFields(http, opts.fresh === true);
1350
1352
  } catch (e) {
1351
- if (e instanceof _chunkPCLL536Bcjs.AutotaskError && e.code === "ABORTED") throw e;
1353
+ if (e instanceof _chunk4QN43TRPcjs.AutotaskError && e.code === "ABORTED") throw e;
1352
1354
  return assumed();
1353
1355
  }
1354
1356
  const picklist = picklistOf(fields);
@@ -1384,30 +1386,30 @@ var LOCATION_LIMIT_MAX = 500;
1384
1386
  function locationLimit(value) {
1385
1387
  if (value === void 0) return PROFILE_PART_LIMIT;
1386
1388
  if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
1387
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
1389
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
1388
1390
  }
1389
1391
  return value;
1390
1392
  }
1391
1393
  function validateProjection(fields) {
1392
1394
  if (fields === void 0) return {};
1393
1395
  if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
1394
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
1396
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
1395
1397
  }
1396
1398
  const out = {};
1397
1399
  for (const [part, list] of Object.entries(fields)) {
1398
1400
  if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
1399
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
1401
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
1400
1402
  }
1401
1403
  if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
1402
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
1404
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
1403
1405
  }
1404
1406
  const names = [...new Set(list)];
1405
1407
  const entity = PART_ENTITY[part];
1406
- const known = _nullishCoalesce(_chunkPCLL536Bcjs.MODEL_FIELD_SETS[entity], () => ( []));
1408
+ const known = _nullishCoalesce(_chunk4QN43TRPcjs.MODEL_FIELD_SETS[entity], () => ( []));
1407
1409
  const unknown = names.filter((n) => !known.includes(n));
1408
1410
  if (unknown.length > 0) {
1409
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
1410
- `fullProfile: fields.${part} has unknown field name(s) ${_chunkPCLL536Bcjs.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`
1411
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
1412
+ `fullProfile: fields.${part} has unknown field name(s) ${_chunk4QN43TRPcjs.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`
1411
1413
  );
1412
1414
  }
1413
1415
  out[part] = names;
@@ -1424,7 +1426,7 @@ function project(items, names) {
1424
1426
  function profilePartLimit(value, name) {
1425
1427
  const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
1426
1428
  if (!Number.isInteger(n) || n < 1) {
1427
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
1429
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
1428
1430
  }
1429
1431
  return n;
1430
1432
  }
@@ -1436,7 +1438,7 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
1436
1438
  body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
1437
1439
  operation: "companies.fullProfile"
1438
1440
  });
1439
- return project(_chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items, includeFields);
1441
+ return project(_chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items, includeFields);
1440
1442
  }
1441
1443
  async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1442
1444
  const semantics = await resolveTicketStatusSemantics(http);
@@ -1453,7 +1455,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1453
1455
  },
1454
1456
  operation: "companies.fullProfile"
1455
1457
  });
1456
- return project(_chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items, includeFields);
1458
+ return project(_chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items, includeFields);
1457
1459
  })();
1458
1460
  const closedStatus = { closedIds: semantics.closedIds, source: semantics.source, note: semantics.note };
1459
1461
  const partNote = semantics.source === "assumed" ? OPEN_TICKETS_NOTE : semantics.note;
@@ -1465,7 +1467,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1465
1467
  closedStatus
1466
1468
  };
1467
1469
  if (openRows.length === 0) {
1468
- const stamp = _chunkPCLL536Bcjs.blindStampFor.call(void 0, _optionalChain([_chunkPCLL536Bcjs.BLIND_SURFACE_STAMPS, 'access', _24 => _24["tickets"], 'optionalAccess', _25 => _25.query]), [{ field: "companyID", op: "eq", value: companyID }, openLeaf]);
1470
+ const stamp = _chunk4QN43TRPcjs.blindStampFor.call(void 0, _optionalChain([_chunk4QN43TRPcjs.BLIND_SURFACE_STAMPS, 'access', _24 => _24["tickets"], 'optionalAccess', _25 => _25.query]), [{ field: "companyID", op: "eq", value: companyID }, openLeaf]);
1469
1471
  if (stamp !== void 0) {
1470
1472
  openTickets = {
1471
1473
  items: openRows,
@@ -1480,7 +1482,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
1480
1482
  return openTickets;
1481
1483
  }
1482
1484
  async function addProfileNames(http, company, openTickets, projects, result, opts) {
1483
- const builder = _chunkPCLL536Bcjs.createNamePlan.call(void 0, _chunkPCLL536Bcjs.TICKET_LABEL_FIELDS);
1485
+ const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS);
1484
1486
  const c = company;
1485
1487
  builder.addResource(c["ownerResourceID"]);
1486
1488
  builder.addResource(c["createdByResourceID"]);
@@ -1497,20 +1499,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
1497
1499
  builder.addResource(r["creatorResourceID"]);
1498
1500
  builder.addFk("contract", r["contractID"]);
1499
1501
  }
1500
- const names = await _chunkPCLL536Bcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
1502
+ const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
1501
1503
  const companyRow = { ...company };
1502
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
1503
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
1504
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
1505
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
1504
1506
  result.company = companyRow;
1505
1507
  result.openTickets = {
1506
1508
  ...openTickets,
1507
1509
  items: openTickets.items.map((row) => {
1508
1510
  const r = { ...row };
1509
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1510
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1511
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
1512
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
1513
- for (const f of _chunkPCLL536Bcjs.TICKET_LABEL_FIELDS) _chunkPCLL536Bcjs.addLabelSibling.call(void 0, r, f, names);
1511
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1512
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1513
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
1514
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
1515
+ for (const f of _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS) _chunk4QN43TRPcjs.addLabelSibling.call(void 0, r, f, names);
1514
1516
  return r;
1515
1517
  })
1516
1518
  };
@@ -1518,9 +1520,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
1518
1520
  ...result.projects,
1519
1521
  items: result.projects.items.map((row) => {
1520
1522
  const r = { ...row };
1521
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
1522
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1523
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1523
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
1524
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
1525
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
1524
1526
  return r;
1525
1527
  })
1526
1528
  };
@@ -1533,7 +1535,7 @@ async function fullProfile(resource, id, opts = {}, http) {
1533
1535
  const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
1534
1536
  const locLimit = locationLimit(opts.locationLimit);
1535
1537
  const proj = validateProjection(opts.fields);
1536
- const companyID = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
1538
+ const companyID = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
1537
1539
  const company = await resource.get(companyID);
1538
1540
  const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
1539
1541
  const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
@@ -1560,6 +1562,151 @@ async function fullProfile(resource, id, opts = {}, http) {
1560
1562
  return result;
1561
1563
  }
1562
1564
 
1565
+ // src/resources/special/companies/prepareCrmWrite.ts
1566
+ var FREEMAIL = /* @__PURE__ */ new Set(["gmail.com", "googlemail.com", "outlook.com", "hotmail.com", "live.com", "yahoo.com", "yahoo.com.au", "icloud.com", "bigpond.com", "optusnet.com.au", "me.com", "proton.me", "protonmail.com"]);
1567
+ var LIMIT = 10;
1568
+ var OP2 = "companies.prepareCrmWrite";
1569
+ async function readRows(http, path, filter) {
1570
+ const res = await http.request({ method: "POST", idempotent: true, path, body: { MaxRecords: LIMIT * 5, filter }, operation: OP2 });
1571
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
1572
+ }
1573
+ var str = (v) => typeof v === "string" && v !== "" ? v : null;
1574
+ var bool = (v) => typeof v === "boolean" ? v : null;
1575
+ var norm = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, " ").replace(/\b(pty|ltd|limited|inc|llc)\b/g, "").replace(/\s+/g, " ").trim();
1576
+ function domainOf(input) {
1577
+ if (!input) return null;
1578
+ const host = _nullishCoalesce(input.trim().toLowerCase().replace(/^[a-z]+:\/\//, "").replace(/^.*@/, "").replace(/^www\./, "").split(/[/?#:]/)[0], () => ( ""));
1579
+ return host.includes(".") && !FREEMAIL.has(host) ? host : null;
1580
+ }
1581
+ function candidate(r) {
1582
+ return { id: r.id, companyName: str(r.companyName), webAddress: str(r.webAddress), phone: str(r.phone), isActive: bool(r.isActive) };
1583
+ }
1584
+ function has(v) {
1585
+ return v !== void 0 && v !== null && v !== "";
1586
+ }
1587
+ async function prepareCrmWrite(resource, input, http) {
1588
+ const intents = ["create_company", "add_contact", "update_contact", "update_company"];
1589
+ if (!input || !intents.includes(input.intent)) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`prepareCrmWrite: intent must be one of ${intents.join(", ")}`);
1590
+ const co = _nullishCoalesce(input.company, () => ( {}));
1591
+ const ct = _nullishCoalesce(input.contact, () => ( {}));
1592
+ const caveats = [
1593
+ "Companies, resources and countries are blind surfaces on some tenants: a miss is not proof a record is absent, and owner / country candidates are lookups, not lists.",
1594
+ "Company name matching is `contains` (exact names ranked first); there is no semantic search in the SDK."
1595
+ ];
1596
+ const needsInput = [];
1597
+ let candidates = [];
1598
+ let matchedBy = null;
1599
+ let searched = false;
1600
+ if (has(co.id)) {
1601
+ searched = true;
1602
+ const rows = await readRows(http, "/V1.0/Companies/query", [{ field: "id", op: "eq", value: co.id }]);
1603
+ candidates = rows.map(candidate);
1604
+ matchedBy = candidates.length ? "id" : null;
1605
+ }
1606
+ const domain = _nullishCoalesce(_nullishCoalesce(domainOf(co.domain), () => ( domainOf(co.website))), () => ( domainOf(ct.emailAddress)));
1607
+ if (candidates.length === 0 && domain) {
1608
+ searched = true;
1609
+ candidates = (await resource.searchByDomain(domain, { limit: LIMIT })).map((c) => candidate(c));
1610
+ matchedBy = candidates.length ? "domain" : null;
1611
+ }
1612
+ if (candidates.length === 0 && has(co.companyName)) {
1613
+ searched = true;
1614
+ const rows = (await resource.searchByIdentity({ companyName: co.companyName }, { limit: LIMIT })).map((c) => candidate(c));
1615
+ const want = norm(co.companyName);
1616
+ const exact = rows.filter((r) => r.companyName !== null && norm(r.companyName) === want);
1617
+ candidates = exact.length ? exact : rows;
1618
+ matchedBy = candidates.length ? exact.length ? "name_exact" : "name_contains" : null;
1619
+ }
1620
+ const status = !searched ? "not_searched" : candidates.length === 0 ? "none" : candidates.length === 1 ? "matched" : "ambiguous";
1621
+ const companyID = status === "matched" ? candidates[0].id : null;
1622
+ const company = { status, matchedBy, candidates };
1623
+ if (status === "ambiguous") {
1624
+ needsInput.push({ field: "company", why: `${candidates.length} companies match; choose one`, source: "policy", lookup: { candidates: candidates.map((c) => ({ id: c.id, companyName: c.companyName })) }, research: "ask" });
1625
+ }
1626
+ if (status === "none" && input.intent !== "create_company") {
1627
+ needsInput.push({ field: "company", why: "no company matched; give a company id, name or domain, or use intent create_company (a miss is not proof of absence)", source: "policy", research: "ask" });
1628
+ }
1629
+ if (status === "not_searched" && input.intent !== "create_company") {
1630
+ needsInput.push({ field: "company", why: "give a company id, name, domain/website or a contact email to search by", source: "policy", research: "ask" });
1631
+ }
1632
+ let locations = null;
1633
+ if (companyID !== null) {
1634
+ const rows = await readRows(http, "/V1.0/CompanyLocations/query", [{ field: "companyID", op: "eq", value: companyID }]);
1635
+ const items = rows.map((r) => ({ id: r.id, name: str(r.name), isPrimary: bool(r.isPrimary), isActive: bool(r.isActive), city: str(r.city), state: str(r.state), postalCode: str(r.postalCode) }));
1636
+ const active = items.filter((l) => l.isActive !== false);
1637
+ const m = active.filter((l) => has(ct.city) && _optionalChain([l, 'access', _26 => _26.city, 'optionalAccess', _27 => _27.toLowerCase, 'call', _28 => _28()]) === String(ct.city).toLowerCase() || has(ct.postalCode) && l.postalCode === String(ct.postalCode));
1638
+ const pick = has(ct.companyLocationID) ? { rule: "matched", locationID: ct.companyLocationID } : active.length === 1 ? { rule: "single", locationID: active[0].id } : active.length > 1 && m.length === 1 ? { rule: "matched", locationID: m[0].id } : active.length > 1 ? { rule: "ask", locationID: null } : { rule: "none", locationID: null };
1639
+ locations = { items, pick };
1640
+ if (input.intent === "add_contact" && pick.locationID === null) {
1641
+ needsInput.push({
1642
+ field: "companyLocationID",
1643
+ why: active.length > 1 ? "the company has several active locations; do not guess" : "the company has no active location; create or reactivate one first",
1644
+ source: "policy",
1645
+ lookup: { candidates: active.map((l) => ({ id: l.id, name: l.name, isPrimary: l.isPrimary })) },
1646
+ research: "ask"
1647
+ });
1648
+ }
1649
+ }
1650
+ let contacts = null;
1651
+ if (input.intent !== "create_company" && (has(ct.emailAddress) || has(ct.firstName) && has(ct.lastName) || has(ct.id))) {
1652
+ const pickFields = (r) => ({ id: r.id, firstName: r.firstName, lastName: r.lastName, emailAddress: r.emailAddress, companyID: r.companyID, companyLocationID: r.companyLocationID, isActive: r.isActive });
1653
+ let rows = [];
1654
+ let by = null;
1655
+ if (has(ct.id)) rows = await readRows(http, "/V1.0/Contacts/query", [{ field: "id", op: "eq", value: ct.id }]);
1656
+ else if (has(ct.emailAddress)) {
1657
+ rows = await readRows(http, "/V1.0/Contacts/query", [{ field: "emailAddress", op: "eq", value: ct.emailAddress }]);
1658
+ by = rows.length ? "email" : null;
1659
+ }
1660
+ if (rows.length === 0 && has(ct.firstName) && has(ct.lastName)) {
1661
+ const f = [{ field: "firstName", op: "eq", value: ct.firstName }, { field: "lastName", op: "eq", value: ct.lastName }];
1662
+ if (companyID !== null) f.push({ field: "companyID", op: "eq", value: companyID });
1663
+ rows = await readRows(http, "/V1.0/Contacts/query", f);
1664
+ by = rows.length ? "name" : null;
1665
+ }
1666
+ contacts = { duplicates: rows.slice(0, LIMIT).map(pickFields), matchedBy: by };
1667
+ if (input.intent === "update_contact" && rows.length === 0) {
1668
+ needsInput.push({ field: "contact", why: "no contact matched; give a contact id or email", source: "policy", research: "ask" });
1669
+ }
1670
+ }
1671
+ if (input.intent === "create_company" && status !== "matched") {
1672
+ const eff = _chunk4QN43TRPcjs.effectiveRequiredFields.call(void 0, null, _optionalChain([_chunk4QN43TRPcjs.RELATIONSHIP_MAP, 'access', _29 => _29.companies, 'optionalAccess', _30 => _30.zoneFacts]));
1673
+ const research = (f) => ["companyType", "ownerResourceID", "countryID"].includes(f) ? "lookup" : "web_if_available_else_ask";
1674
+ const lookups = {
1675
+ companyType: { via: "operations.fieldCatalog", resource: "companies", field: "companyType", labels: true, note: "map the user wording to one returned label; never hardcode ids" },
1676
+ ownerResourceID: { via: "resources.get / the staff resolver", note: "owners cannot be enumerated on a blind surface: take a known resource id and confirm it with resources.get" },
1677
+ countryID: { via: "countries.query", note: "resolve the country name to an id; never guess" }
1678
+ };
1679
+ const wanted = [
1680
+ ...eff.fields.filter((f) => f !== "isActive").map((f) => [f, "live-proven"]),
1681
+ ...["address1", "city", "state", "postalCode", "countryID"].map((f) => [f, "policy"])
1682
+ ];
1683
+ for (const [f, source] of wanted) {
1684
+ if (has(co[f]) || needsInput.some((n) => n.field === f)) continue;
1685
+ needsInput.push({ field: f, why: source === "policy" ? `CRM policy: a new company needs ${f} (the vendor auto-creates a "Primary Address" location from it)` : `the vendor requires ${f} to create a company`, source, ...lookups[f] ? { lookup: lookups[f] } : {}, research: research(f) });
1686
+ }
1687
+ }
1688
+ if (input.intent === "add_contact") {
1689
+ for (const f of ["firstName", "lastName"]) if (!has(ct[f])) needsInput.push({ field: f, why: `the vendor requires contact ${f}`, source: "live-proven", research: "ask" });
1690
+ if (!has(ct.emailAddress) && !has(ct.phone) && !has(ct.mobilePhone)) needsInput.push({ field: "emailAddress", why: "CRM policy: a contact needs an email or a phone number", source: "policy", research: "ask" });
1691
+ }
1692
+ let next = null;
1693
+ const isInactive = (d) => d.isActive === false || d.isActive === 0;
1694
+ const dups = _nullishCoalesce(_optionalChain([contacts, 'optionalAccess', _31 => _31.duplicates]), () => ( []));
1695
+ const sameCompany = companyID === null ? dups : dups.filter((d) => d.companyID === companyID);
1696
+ const elsewhere = companyID === null ? [] : dups.filter((d) => d.companyID !== companyID && !isInactive(d));
1697
+ if (input.intent === "add_contact" && sameCompany.length === 0 && elsewhere.length > 0) {
1698
+ needsInput.push({ field: "contact", why: `a contact with this ${_nullishCoalesce(_optionalChain([contacts, 'optionalAccess', _32 => _32.matchedBy]), () => ( "identity"))} is active at another company: update it, move it with contacts.moveToCompany, or confirm a second record`, source: "policy", lookup: { duplicates: elsewhere }, research: "ask" });
1699
+ }
1700
+ if (needsInput.length === 0) {
1701
+ const dup = sameCompany[0];
1702
+ if (input.intent === "create_company") next = status === "matched" ? { operation: "companies.update", note: "the company already exists: update it instead of creating" } : { operation: "companies.create", note: 'then re-run with intent add_contact: the vendor auto-creates a "Primary Address" location (rename it with company_locations.update; locations cannot be deleted via the API)' };
1703
+ else if (input.intent === "add_contact") next = dup ? { operation: "contacts.update", note: `a contact already matches by ${_nullishCoalesce(_optionalChain([contacts, 'optionalAccess', _33 => _33.matchedBy]), () => ( "id"))} (id ${String(dup.id)}): update it, or move it with contacts.moveToCompany if it belongs to another company` } : { operation: "contacts.create", note: `set companyID ${String(companyID)} and companyLocationID ${String(_optionalChain([locations, 'optionalAccess', _34 => _34.pick, 'access', _35 => _35.locationID]))}` };
1704
+ else if (input.intent === "update_contact") next = { operation: "contacts.update", note: "send only the changed fields" };
1705
+ else next = { operation: "companies.update", note: "send only the changed fields" };
1706
+ }
1707
+ return { intent: input.intent, company, locations, contacts, needsInput, next, caveats };
1708
+ }
1709
+
1563
1710
  // src/resources/special/companies/unbilledWorkTypes.ts
1564
1711
  var UNBILLED_WORK_NOTE_CHARS_DEFAULT = 400;
1565
1712
  var UNBILLED_WORK_JOIN_SET_CAP = 300;
@@ -1580,7 +1727,7 @@ var UNBILLED_WORK_OPT_KEYS = [
1580
1727
  var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
1581
1728
  function validateUnbilledWorkOptions(companyId, opts) {
1582
1729
  if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
1583
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
1730
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
1584
1731
  `unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
1585
1732
  { operation: "companies.unbilledWork" }
1586
1733
  );
@@ -1609,7 +1756,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
1609
1756
  try {
1610
1757
  limit = clampLimit(opts.limit);
1611
1758
  } catch (err) {
1612
- problems.push(err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
1759
+ problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
1613
1760
  limit = 50;
1614
1761
  }
1615
1762
  if (source === "date_range") {
@@ -1624,9 +1771,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
1624
1771
  problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
1625
1772
  } else {
1626
1773
  try {
1627
- _chunkPCLL536Bcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
1774
+ _chunk4QN43TRPcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
1628
1775
  } catch (err) {
1629
- problems.push(err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
1776
+ problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
1630
1777
  }
1631
1778
  }
1632
1779
  }
@@ -1636,20 +1783,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
1636
1783
  } else {
1637
1784
  opts.ticketIds.forEach((tid, i) => {
1638
1785
  try {
1639
- _chunkPCLL536Bcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
1786
+ _chunk4QN43TRPcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
1640
1787
  } catch (err) {
1641
- problems.push(err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
1788
+ problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
1642
1789
  }
1643
1790
  });
1644
1791
  }
1645
1792
  }
1646
1793
  try {
1647
- _chunkPCLL536Bcjs.parseIdentifier.call(void 0, companyId, "companyId");
1794
+ _chunk4QN43TRPcjs.parseIdentifier.call(void 0, companyId, "companyId");
1648
1795
  } catch (err) {
1649
- problems.push(err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
1796
+ problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
1650
1797
  }
1651
1798
  if (problems.length > 0) {
1652
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
1799
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
1653
1800
  `unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
1654
1801
  - ` + problems.join("\n- "),
1655
1802
  { operation: "companies.unbilledWork" }
@@ -1670,7 +1817,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
1670
1817
  }
1671
1818
 
1672
1819
  // src/resources/special/companies/unbilledWork.ts
1673
- var OP2 = "companies.unbilledWork";
1820
+ var OP3 = "companies.unbilledWork";
1674
1821
  function capJoinSet(ids2, cap) {
1675
1822
  const sorted = [...new Set(ids2)].sort((a, b) => a - b);
1676
1823
  if (sorted.length <= cap) return { ids: sorted, truncated: false };
@@ -1678,7 +1825,7 @@ function capJoinSet(ids2, cap) {
1678
1825
  }
1679
1826
  function unbilledWorkPartStatus(key, conditions, items) {
1680
1827
  if (items.length !== 0) return { status: "ok" };
1681
- const stamp = _chunkPCLL536Bcjs.blindStampFor.call(void 0, _optionalChain([_chunkPCLL536Bcjs.BLIND_SURFACE_STAMPS, 'access', _26 => _26[key], 'optionalAccess', _27 => _27.query]), conditions);
1828
+ const stamp = _chunk4QN43TRPcjs.blindStampFor.call(void 0, _optionalChain([_chunk4QN43TRPcjs.BLIND_SURFACE_STAMPS, 'access', _36 => _36[key], 'optionalAccess', _37 => _37.query]), conditions);
1682
1829
  if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
1683
1830
  return {
1684
1831
  status: "ok",
@@ -1698,7 +1845,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
1698
1845
  parentStatus = "ok";
1699
1846
  companyIds.push(num(parent.id));
1700
1847
  } catch (err) {
1701
- if (err instanceof _chunkPCLL536Bcjs.NotFoundError) parent = null;
1848
+ if (err instanceof _chunk4QN43TRPcjs.NotFoundError) parent = null;
1702
1849
  else throw err;
1703
1850
  }
1704
1851
  }
@@ -1707,14 +1854,14 @@ async function readCompanyAndParent(resource, id, includeParent) {
1707
1854
  }
1708
1855
  async function readJoinSets(http, companyIds, v) {
1709
1856
  const ticketsCond = [{ field: "companyID", op: "in", value: companyIds }];
1710
- const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit, OP2);
1857
+ const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit, OP3);
1711
1858
  const projectsCond = [{ field: "companyID", op: "in", value: companyIds }];
1712
- const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit, OP2);
1859
+ const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit, OP3);
1713
1860
  const projectIds = projectsRaw.items.map((p) => num(p.id)).filter((n) => n > 0);
1714
1861
  let taskIds = [];
1715
1862
  let tasksHasMore = false;
1716
1863
  if (projectIds.length > 0) {
1717
- const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit, OP2);
1864
+ const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit, OP3);
1718
1865
  taskIds = tasksRaw.items.map((t) => num(t.id)).filter((n) => n > 0);
1719
1866
  tasksHasMore = tasksRaw.hasMore;
1720
1867
  }
@@ -1736,14 +1883,14 @@ async function readBillingPart(http, v, companyIds) {
1736
1883
  if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
1737
1884
  if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
1738
1885
  }
1739
- const billingFields = _chunkPCLL536Bcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
1886
+ const billingFields = _chunk4QN43TRPcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
1740
1887
  const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
1741
- const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP2, billingIncludeFields);
1888
+ const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP3, billingIncludeFields);
1742
1889
  let billingItems = billingRaw.items;
1743
1890
  let billingNoteCharsTruncated = 0;
1744
1891
  if (v.includeNotes) {
1745
- const noteFields = (_nullishCoalesce(_chunkPCLL536Bcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
1746
- [billingItems, billingNoteCharsTruncated] = _chunkPCLL536Bcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
1892
+ const noteFields = (_nullishCoalesce(_chunk4QN43TRPcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
1893
+ [billingItems, billingNoteCharsTruncated] = _chunk4QN43TRPcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
1747
1894
  }
1748
1895
  const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
1749
1896
  const billingItemsPart = {
@@ -1782,12 +1929,12 @@ async function readTimePart(http, v, join) {
1782
1929
  if (v.dateFrom !== void 0) timeConditions.push({ field: "dateWorked", op: "gte", value: v.dateFrom });
1783
1930
  if (v.dateTo !== void 0) timeConditions.push({ field: "dateWorked", op: "lte", value: v.dateTo });
1784
1931
  const timeFields = ["taskID", "ticketID", "hoursWorked", "dateWorked", "id", ...v.includeNotes ? ["summaryNotes"] : []];
1785
- const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit, OP2, timeFields);
1932
+ const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit, OP3, timeFields);
1786
1933
  entries = raw.items;
1787
1934
  let cappedItems = entries;
1788
1935
  let noteCharsTruncated = 0;
1789
1936
  if (v.includeNotes) {
1790
- [cappedItems, noteCharsTruncated] = _chunkPCLL536Bcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
1937
+ [cappedItems, noteCharsTruncated] = _chunk4QN43TRPcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
1791
1938
  }
1792
1939
  const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
1793
1940
  timePart = {
@@ -1875,7 +2022,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
1875
2022
  }
1876
2023
  async function unbilledWork(resource, companyId, opts = {}, http) {
1877
2024
  const v = validateUnbilledWorkOptions(companyId, opts);
1878
- const id = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, companyId, "companyId");
2025
+ const id = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, companyId, "companyId");
1879
2026
  const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
1880
2027
  const join = await readJoinSets(http, companyIds, v);
1881
2028
  const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
@@ -1902,7 +2049,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
1902
2049
  }
1903
2050
 
1904
2051
  // src/resources/companies.ts
1905
- var CompaniesResource = class extends _chunkPCLL536Bcjs.BaseResource {
2052
+ var CompaniesResource = class extends _chunk4QN43TRPcjs.BaseResource {
1906
2053
  constructor(http, pageSize) {
1907
2054
  super(http, {
1908
2055
  key: "companies",
@@ -2006,10 +2153,14 @@ var CompaniesResource = class extends _chunkPCLL536Bcjs.BaseResource {
2006
2153
  unbilledWork(id, opts) {
2007
2154
  return unbilledWork(this, id, opts, this.http);
2008
2155
  }
2156
+ /** Node-parity special op (hand-written in src/resources/special/companies.ts). */
2157
+ prepareCrmWrite(input) {
2158
+ return prepareCrmWrite(this, input, this.http);
2159
+ }
2009
2160
  };
2010
2161
 
2011
2162
  // src/resources/company_alerts.ts
2012
- var CompanyAlertsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2163
+ var CompanyAlertsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2013
2164
  constructor(http, pageSize) {
2014
2165
  super(http, {
2015
2166
  key: "company_alerts",
@@ -2075,7 +2226,7 @@ var CompanyAlertsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2075
2226
  };
2076
2227
 
2077
2228
  // src/resources/company_locations.ts
2078
- var CompanyLocationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2229
+ var CompanyLocationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2079
2230
  constructor(http, pageSize) {
2080
2231
  super(http, {
2081
2232
  key: "company_locations",
@@ -2141,12 +2292,12 @@ var CompanyLocationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2141
2292
  /** Search CompanyLocation records: bounded contains on name (no vendor free-text search exists);
2142
2293
  * limit defaults to 25, max 500. */
2143
2294
  async search(query, opts) {
2144
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _28 => _28.limit]) });
2295
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _38 => _38.limit]) });
2145
2296
  }
2146
2297
  };
2147
2298
 
2148
2299
  // src/resources/company_notes.ts
2149
- var CompanyNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
2300
+ var CompanyNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
2150
2301
  constructor(http, pageSize) {
2151
2302
  super(http, {
2152
2303
  key: "company_notes",
@@ -2206,12 +2357,12 @@ var CompanyNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
2206
2357
  /** Search CompanyNote records: bounded contains on name (no vendor free-text search exists);
2207
2358
  * limit defaults to 25, max 500. */
2208
2359
  async search(query, opts) {
2209
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _29 => _29.limit]) });
2360
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _39 => _39.limit]) });
2210
2361
  }
2211
2362
  };
2212
2363
 
2213
2364
  // src/resources/company_site_configurations.ts
2214
- var CompanySiteConfigurationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2365
+ var CompanySiteConfigurationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2215
2366
  constructor(http, pageSize) {
2216
2367
  super(http, {
2217
2368
  key: "company_site_configurations",
@@ -2262,7 +2413,7 @@ var CompanySiteConfigurationsResource = class extends _chunkPCLL536Bcjs.BaseReso
2262
2413
  };
2263
2414
 
2264
2415
  // src/resources/company_webhooks.ts
2265
- var CompanyWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
2416
+ var CompanyWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
2266
2417
  constructor(http, pageSize) {
2267
2418
  super(http, {
2268
2419
  key: "company_webhooks",
@@ -2333,12 +2484,12 @@ var CompanyWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
2333
2484
  /** Search CompanyWebhook records: bounded contains on name (no vendor free-text search exists);
2334
2485
  * limit defaults to 25, max 500. */
2335
2486
  async search(query, opts) {
2336
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _30 => _30.limit]) });
2487
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _40 => _40.limit]) });
2337
2488
  }
2338
2489
  };
2339
2490
 
2340
2491
  // src/resources/configuration_item_billing_product_associations.ts
2341
- var ConfigurationItemBillingProductAssociationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2492
+ var ConfigurationItemBillingProductAssociationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2342
2493
  constructor(http, pageSize) {
2343
2494
  super(http, {
2344
2495
  key: "configuration_item_billing_product_associations",
@@ -2404,7 +2555,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkPC
2404
2555
  };
2405
2556
 
2406
2557
  // src/resources/configuration_item_categories.ts
2407
- var ConfigurationItemCategoriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
2558
+ var ConfigurationItemCategoriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
2408
2559
  constructor(http, pageSize) {
2409
2560
  super(http, {
2410
2561
  key: "configuration_item_categories",
@@ -2466,12 +2617,12 @@ var ConfigurationItemCategoriesResource = class extends _chunkPCLL536Bcjs.BaseRe
2466
2617
  /** Search ConfigurationItemCategory records: bounded contains on name (no vendor free-text search exists);
2467
2618
  * limit defaults to 25, max 500. */
2468
2619
  async search(query, opts) {
2469
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _31 => _31.limit]) });
2620
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _41 => _41.limit]) });
2470
2621
  }
2471
2622
  };
2472
2623
 
2473
2624
  // src/resources/configuration_item_category_udf_associations.ts
2474
- var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2625
+ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2475
2626
  constructor(http, pageSize) {
2476
2627
  super(http, {
2477
2628
  key: "configuration_item_category_udf_associations",
@@ -2537,7 +2688,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkPCLL5
2537
2688
  };
2538
2689
 
2539
2690
  // src/resources/configuration_item_dns_records.ts
2540
- var ConfigurationItemDnsRecordsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2691
+ var ConfigurationItemDnsRecordsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2541
2692
  constructor(http, pageSize) {
2542
2693
  super(http, {
2543
2694
  key: "configuration_item_dns_records",
@@ -2586,7 +2737,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkPCLL536Bcjs.BaseRe
2586
2737
  };
2587
2738
 
2588
2739
  // src/resources/configuration_item_notes.ts
2589
- var ConfigurationItemNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
2740
+ var ConfigurationItemNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
2590
2741
  constructor(http, pageSize) {
2591
2742
  super(http, {
2592
2743
  key: "configuration_item_notes",
@@ -2645,7 +2796,7 @@ var ConfigurationItemNotesResource = class extends _chunkPCLL536Bcjs.BaseResourc
2645
2796
  };
2646
2797
 
2647
2798
  // src/resources/configuration_item_related_items.ts
2648
- var ConfigurationItemRelatedItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2799
+ var ConfigurationItemRelatedItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2649
2800
  constructor(http, pageSize) {
2650
2801
  super(http, {
2651
2802
  key: "configuration_item_related_items",
@@ -2703,19 +2854,19 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkPCLL536Bcjs.Base
2703
2854
 
2704
2855
  // src/resources/special/configuration_items.ts
2705
2856
  async function fetchRecord(http, path, label, readOpts) {
2706
- const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _32 => _32.maxRetries]) });
2857
+ const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _42 => _42.maxRetries]) });
2707
2858
  const body = res;
2708
2859
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
2709
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
2860
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
2710
2861
  }
2711
2862
  return body.item;
2712
2863
  }
2713
2864
  async function moveConfigurationItem(_resource, sourceId, opts, http) {
2714
- const numericSource = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
2715
- if (_optionalChain([opts, 'optionalAccess', _33 => _33.destinationCompanyId]) === void 0) {
2716
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
2865
+ const numericSource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
2866
+ if (_optionalChain([opts, 'optionalAccess', _43 => _43.destinationCompanyId]) === void 0) {
2867
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
2717
2868
  }
2718
- const destId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
2869
+ const destId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
2719
2870
  const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
2720
2871
  await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
2721
2872
  const body = { ...source };
@@ -2725,20 +2876,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
2725
2876
  body.companyID = destId;
2726
2877
  body.isActive = true;
2727
2878
  if (opts.newReferenceTitle !== void 0) {
2728
- if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
2879
+ if (opts.newReferenceTitle.trim() === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
2729
2880
  body.referenceTitle = opts.newReferenceTitle.trim();
2730
2881
  }
2731
2882
  if (opts.lastModifiedDate !== void 0) {
2732
2883
  const current = source.lastModifiedDate;
2733
2884
  if (current !== opts.lastModifiedDate) {
2734
- throw new (0, _chunkPCLL536Bcjs.StaleObjectError)(
2885
+ throw new (0, _chunk4QN43TRPcjs.StaleObjectError)(
2735
2886
  `moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
2736
2887
  { operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
2737
2888
  );
2738
2889
  }
2739
2890
  }
2740
2891
  if (opts.dryRun === true) {
2741
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
2892
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
2742
2893
  operation: "configuration_items.moveConfigurationItem",
2743
2894
  method: "POST",
2744
2895
  path: "/V1.0/ConfigurationItems",
@@ -2763,7 +2914,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
2763
2914
  const createdBody = created;
2764
2915
  const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
2765
2916
  if (typeof newId !== "number") {
2766
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
2917
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
2767
2918
  }
2768
2919
  let sourceDeactivated = false;
2769
2920
  if (opts.deactivateSource !== false) {
@@ -2782,7 +2933,7 @@ var PROFILE_PART_LIMIT2 = 50;
2782
2933
  function profilePartLimit2(value, name) {
2783
2934
  const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
2784
2935
  if (!Number.isInteger(n) || n < 1) {
2785
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
2936
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
2786
2937
  }
2787
2938
  return n;
2788
2939
  }
@@ -2798,14 +2949,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
2798
2949
  });
2799
2950
  const body = res;
2800
2951
  if (body === null || !("item" in body)) {
2801
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2952
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2802
2953
  }
2803
2954
  if (body.item === null || body.item === void 0) {
2804
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2955
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
2805
2956
  }
2806
2957
  return body.item;
2807
2958
  } catch (err) {
2808
- if (err instanceof _chunkPCLL536Bcjs.NotFoundError) return null;
2959
+ if (err instanceof _chunk4QN43TRPcjs.NotFoundError) return null;
2809
2960
  throw err;
2810
2961
  }
2811
2962
  }
@@ -2817,7 +2968,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
2817
2968
  body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
2818
2969
  operation: "configuration_items.profile"
2819
2970
  });
2820
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
2971
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
2821
2972
  }
2822
2973
  async function profile(resource, id, opts = {}, http) {
2823
2974
  const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
@@ -2829,7 +2980,7 @@ async function profile(resource, id, opts = {}, http) {
2829
2980
  const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
2830
2981
  const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
2831
2982
  const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
2832
- const wallQuirk = _optionalChain([_chunkPCLL536Bcjs.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"))]);
2983
+ const wallQuirk = _optionalChain([_chunk4QN43TRPcjs.RELATIONSHIP_MAP, 'access', _44 => _44["configuration_items"], 'optionalAccess', _45 => _45.zoneFacts, 'optionalAccess', _46 => _46.quirks, 'optionalAccess', _47 => _47.find, 'call', _48 => _48((q) => q.startsWith("product wall"))]);
2833
2984
  const productAssociations = {
2834
2985
  items: associations,
2835
2986
  capped: associations.length >= PROFILE_PART_LIMIT2,
@@ -2853,11 +3004,11 @@ async function profile(resource, id, opts = {}, http) {
2853
3004
  }
2854
3005
  };
2855
3006
  if (opts.names === true) {
2856
- const builder = _chunkPCLL536Bcjs.createNamePlan.call(void 0, );
3007
+ const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, );
2857
3008
  builder.addFk("contract", root["contractID"]);
2858
- const names = await _chunkPCLL536Bcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
3009
+ const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
2859
3010
  const ciRow = { ...ci };
2860
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
3011
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
2861
3012
  result.ci = ciRow;
2862
3013
  result.names = names.section;
2863
3014
  }
@@ -2865,7 +3016,7 @@ async function profile(resource, id, opts = {}, http) {
2865
3016
  }
2866
3017
 
2867
3018
  // src/resources/configuration_items.ts
2868
- var ConfigurationItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3019
+ var ConfigurationItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
2869
3020
  constructor(http, pageSize) {
2870
3021
  super(http, {
2871
3022
  key: "configuration_items",
@@ -2931,7 +3082,7 @@ var ConfigurationItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2931
3082
  /** Search ConfigurationItem records: bounded contains on referenceTitle (no vendor free-text search exists);
2932
3083
  * limit defaults to 25, max 500. */
2933
3084
  async search(query, opts) {
2934
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _39 => _39.limit]) });
3085
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _49 => _49.limit]) });
2935
3086
  }
2936
3087
  /** Get the ConfigurationItem with its primary context records in one call (each part a single-record
2937
3088
  * fetch; no sub-lists; absent/dangling references come back null). */
@@ -2954,7 +3105,7 @@ var ConfigurationItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
2954
3105
  };
2955
3106
 
2956
3107
  // src/resources/configuration_item_ssl_subject_alternative_names.ts
2957
- var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkPCLL536Bcjs.BaseResource {
3108
+ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunk4QN43TRPcjs.BaseResource {
2958
3109
  constructor(http, pageSize) {
2959
3110
  super(http, {
2960
3111
  key: "configuration_item_ssl_subject_alternative_names",
@@ -3012,12 +3163,12 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkPC
3012
3163
  /** Search ConfigurationItemSslSubjectAlternativeName records: bounded contains on name (no vendor free-text search exists);
3013
3164
  * limit defaults to 25, max 500. */
3014
3165
  async search(query, opts) {
3015
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _40 => _40.limit]) });
3166
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _50 => _50.limit]) });
3016
3167
  }
3017
3168
  };
3018
3169
 
3019
3170
  // src/resources/configuration_item_types.ts
3020
- var ConfigurationItemTypesResource = class extends _chunkPCLL536Bcjs.BaseResource {
3171
+ var ConfigurationItemTypesResource = class extends _chunk4QN43TRPcjs.BaseResource {
3021
3172
  constructor(http, pageSize) {
3022
3173
  super(http, {
3023
3174
  key: "configuration_item_types",
@@ -3086,12 +3237,12 @@ var ConfigurationItemTypesResource = class extends _chunkPCLL536Bcjs.BaseResourc
3086
3237
  /** Search ConfigurationItemType records: bounded contains on name (no vendor free-text search exists);
3087
3238
  * limit defaults to 25, max 500. */
3088
3239
  async search(query, opts) {
3089
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _41 => _41.limit]) });
3240
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _51 => _51.limit]) });
3090
3241
  }
3091
3242
  };
3092
3243
 
3093
3244
  // src/resources/configuration_item_webhooks.ts
3094
- var ConfigurationItemWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
3245
+ var ConfigurationItemWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
3095
3246
  constructor(http, pageSize) {
3096
3247
  super(http, {
3097
3248
  key: "configuration_item_webhooks",
@@ -3162,12 +3313,12 @@ var ConfigurationItemWebhooksResource = class extends _chunkPCLL536Bcjs.BaseReso
3162
3313
  /** Search ConfigurationItemWebhook records: bounded contains on name (no vendor free-text search exists);
3163
3314
  * limit defaults to 25, max 500. */
3164
3315
  async search(query, opts) {
3165
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _42 => _42.limit]) });
3316
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _52 => _52.limit]) });
3166
3317
  }
3167
3318
  };
3168
3319
 
3169
3320
  // src/resources/contact_group_contacts.ts
3170
- var ContactGroupContactsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3321
+ var ContactGroupContactsResource = class extends _chunk4QN43TRPcjs.BaseResource {
3171
3322
  constructor(http, pageSize) {
3172
3323
  super(http, {
3173
3324
  key: "contact_group_contacts",
@@ -3221,7 +3372,7 @@ var ContactGroupContactsResource = class extends _chunkPCLL536Bcjs.BaseResource
3221
3372
  };
3222
3373
 
3223
3374
  // src/resources/contact_groups.ts
3224
- var ContactGroupsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3375
+ var ContactGroupsResource = class extends _chunk4QN43TRPcjs.BaseResource {
3225
3376
  constructor(http, pageSize) {
3226
3377
  super(http, {
3227
3378
  key: "contact_groups",
@@ -3290,31 +3441,31 @@ var ContactGroupsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3290
3441
  /** Search ContactGroups records: bounded contains on name (no vendor free-text search exists);
3291
3442
  * limit defaults to 25, max 500. */
3292
3443
  async search(query, opts) {
3293
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _43 => _43.limit]) });
3444
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _53 => _53.limit]) });
3294
3445
  }
3295
3446
  };
3296
3447
 
3297
3448
  // src/resources/special/contacts.ts
3298
3449
  async function fetchRecord2(http, path, label, readOpts) {
3299
- const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _44 => _44.maxRetries]) });
3450
+ const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _54 => _54.maxRetries]) });
3300
3451
  const body = res;
3301
3452
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
3302
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
3453
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
3303
3454
  }
3304
3455
  return body.item;
3305
3456
  }
3306
3457
  async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
3307
- const sourceId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
3308
- const destId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
3458
+ const sourceId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
3459
+ const destId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
3309
3460
  const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
3310
3461
  const companyID = source.companyID;
3311
3462
  if (typeof companyID !== "number" || companyID < 0) {
3312
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
3463
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
3313
3464
  }
3314
3465
  if (opts.lastModifiedDate !== void 0) {
3315
3466
  const current = source.lastModifiedDate;
3316
3467
  if (current !== opts.lastModifiedDate) {
3317
- throw new (0, _chunkPCLL536Bcjs.StaleObjectError)(
3468
+ throw new (0, _chunk4QN43TRPcjs.StaleObjectError)(
3318
3469
  `moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
3319
3470
  { operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
3320
3471
  );
@@ -3336,10 +3487,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3336
3487
  },
3337
3488
  operation: "contacts.moveToCompany"
3338
3489
  });
3339
- const items = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
3490
+ const items = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
3340
3491
  const clash = items.find((c) => String(c.id) !== String(sourceId));
3341
3492
  if (clash !== void 0) {
3342
- throw new (0, _chunkPCLL536Bcjs.ConflictError)(
3493
+ throw new (0, _chunk4QN43TRPcjs.ConflictError)(
3343
3494
  `Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
3344
3495
  { resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
3345
3496
  );
@@ -3353,7 +3504,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3353
3504
  if (opts.dryRun === true) {
3354
3505
  const warnings = [];
3355
3506
  if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
3356
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
3507
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
3357
3508
  operation: "contacts.moveToCompany",
3358
3509
  method: "POST",
3359
3510
  path: `/V1.0/Companies/${destId}/Contacts`,
@@ -3379,7 +3530,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
3379
3530
  const createdBody = created;
3380
3531
  const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
3381
3532
  if (typeof newId !== "number") {
3382
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
3533
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
3383
3534
  }
3384
3535
  let sourceDeleted = false;
3385
3536
  if (opts.deleteSource === true) {
@@ -3398,7 +3549,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
3398
3549
  var EMAIL_SHAPE = /^.+@.+/;
3399
3550
  var SAFE_CONTACT_CREATE_DEFAULTS = {};
3400
3551
  var DEDUP_LIMIT = 10;
3401
- var CompanyNotFoundError = class extends _chunkPCLL536Bcjs.AutotaskError {
3552
+ var CompanyNotFoundError = class extends _chunk4QN43TRPcjs.AutotaskError {
3402
3553
  constructor(message, options = {}) {
3403
3554
  super(message, {
3404
3555
  code: "COMPANY_NOT_FOUND",
@@ -3409,7 +3560,7 @@ var CompanyNotFoundError = class extends _chunkPCLL536Bcjs.AutotaskError {
3409
3560
  this.name = "CompanyNotFoundError";
3410
3561
  }
3411
3562
  };
3412
- var ContactCreateFailedError = class extends _chunkPCLL536Bcjs.AutotaskError {
3563
+ var ContactCreateFailedError = class extends _chunk4QN43TRPcjs.AutotaskError {
3413
3564
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
3414
3565
 
3415
3566
  constructor(message, vendorFields, options = {}) {
@@ -3419,25 +3570,25 @@ var ContactCreateFailedError = class extends _chunkPCLL536Bcjs.AutotaskError {
3419
3570
  }
3420
3571
  };
3421
3572
  async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3422
- const cid = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, companyID, "companyID");
3573
+ const cid = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, companyID, "companyID");
3423
3574
  if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
3424
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
3575
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
3425
3576
  `upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
3426
3577
  { operation: OP_UPSERT_EMAIL }
3427
3578
  );
3428
3579
  }
3429
3580
  if (extra !== void 0) {
3430
3581
  if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
3431
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
3582
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
3432
3583
  `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)})`,
3433
3584
  { operation: OP_UPSERT_EMAIL }
3434
3585
  );
3435
3586
  }
3436
3587
  if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
3437
- throw new (0, _chunkPCLL536Bcjs.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 });
3588
+ throw new (0, _chunk4QN43TRPcjs.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 });
3438
3589
  }
3439
3590
  if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
3440
- throw new (0, _chunkPCLL536Bcjs.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 });
3591
+ throw new (0, _chunk4QN43TRPcjs.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 });
3441
3592
  }
3442
3593
  }
3443
3594
  const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
@@ -3458,7 +3609,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3458
3609
  const match = q.items[0];
3459
3610
  if (match !== void 0) {
3460
3611
  if (opts.dryRun === true) {
3461
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
3612
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
3462
3613
  {
3463
3614
  operation: OP_UPSERT_EMAIL,
3464
3615
  method: "POST",
@@ -3479,16 +3630,16 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3479
3630
  return { id: Number(match.id), created: false, existing: match };
3480
3631
  }
3481
3632
  const localPart = email.split("@")[0];
3482
- const isActive = _optionalChain([extra, 'optionalAccess', _45 => _45.isActive]) === void 0 ? true : extra.isActive;
3633
+ const isActive = _optionalChain([extra, 'optionalAccess', _55 => _55.isActive]) === void 0 ? true : extra.isActive;
3483
3634
  const body = {
3484
3635
  emailAddress: email,
3485
3636
  companyID: cid,
3486
- firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _46 => _46.firstName]), () => ( localPart)),
3487
- lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _47 => _47.lastName]), () => ( "Unknown")),
3637
+ firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _56 => _56.firstName]), () => ( localPart)),
3638
+ lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _57 => _57.lastName]), () => ( "Unknown")),
3488
3639
  isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
3489
3640
  };
3490
3641
  if (opts.dryRun === true) {
3491
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
3642
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
3492
3643
  {
3493
3644
  operation: OP_UPSERT_EMAIL,
3494
3645
  method: "POST",
@@ -3511,8 +3662,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3511
3662
  const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
3512
3663
  return { id: created.id, created: true };
3513
3664
  } catch (err) {
3514
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
3515
- const named = (_nullishCoalesce(_chunkPCLL536Bcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
3665
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
3666
+ const named = (_nullishCoalesce(_chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
3516
3667
  const seen = /* @__PURE__ */ new Set();
3517
3668
  const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
3518
3669
  const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
@@ -3526,7 +3677,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3526
3677
  }
3527
3678
  continue;
3528
3679
  }
3529
- const detail = _chunkPCLL536Bcjs.formatVendorDetail.call(void 0, err.vendorError);
3680
+ const detail = _chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError);
3530
3681
  throw new ContactCreateFailedError(
3531
3682
  `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}` : ""}`,
3532
3683
  unique,
@@ -3543,7 +3694,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
3543
3694
  }
3544
3695
 
3545
3696
  // src/resources/contacts.ts
3546
- var ContactsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3697
+ var ContactsResource = class extends _chunk4QN43TRPcjs.BaseResource {
3547
3698
  constructor(http, pageSize) {
3548
3699
  super(http, {
3549
3700
  key: "contacts",
@@ -3614,7 +3765,7 @@ var ContactsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3614
3765
  /** Search Contact records: bounded contains on firstName + lastName (no vendor free-text search exists);
3615
3766
  * limit defaults to 25, max 500. */
3616
3767
  async search(query, opts) {
3617
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _48 => _48.limit]) });
3768
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _58 => _58.limit]) });
3618
3769
  }
3619
3770
  /** Get the Contact with its primary context records in one call (each part a single-record
3620
3771
  * fetch; no sub-lists; absent/dangling references come back null). */
@@ -3635,7 +3786,7 @@ var ContactsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3635
3786
  };
3636
3787
 
3637
3788
  // src/resources/contact_webhooks.ts
3638
- var ContactWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
3789
+ var ContactWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
3639
3790
  constructor(http, pageSize) {
3640
3791
  super(http, {
3641
3792
  key: "contact_webhooks",
@@ -3706,12 +3857,12 @@ var ContactWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
3706
3857
  /** Search ContactWebhook records: bounded contains on name (no vendor free-text search exists);
3707
3858
  * limit defaults to 25, max 500. */
3708
3859
  async search(query, opts) {
3709
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _49 => _49.limit]) });
3860
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _59 => _59.limit]) });
3710
3861
  }
3711
3862
  };
3712
3863
 
3713
3864
  // src/resources/contract_billing_rules.ts
3714
- var ContractBillingRulesResource = class extends _chunkPCLL536Bcjs.BaseResource {
3865
+ var ContractBillingRulesResource = class extends _chunk4QN43TRPcjs.BaseResource {
3715
3866
  constructor(http, pageSize) {
3716
3867
  super(http, {
3717
3868
  key: "contract_billing_rules",
@@ -3777,7 +3928,7 @@ var ContractBillingRulesResource = class extends _chunkPCLL536Bcjs.BaseResource
3777
3928
  };
3778
3929
 
3779
3930
  // src/resources/contract_block_hour_factors.ts
3780
- var ContractBlockHourFactorsResource = class extends _chunkPCLL536Bcjs.BaseResource {
3931
+ var ContractBlockHourFactorsResource = class extends _chunk4QN43TRPcjs.BaseResource {
3781
3932
  constructor(http, pageSize) {
3782
3933
  super(http, {
3783
3934
  key: "contract_block_hour_factors",
@@ -3836,7 +3987,7 @@ var ContractBlockHourFactorsResource = class extends _chunkPCLL536Bcjs.BaseResou
3836
3987
  };
3837
3988
 
3838
3989
  // src/resources/contract_blocks.ts
3839
- var ContractBlocksResource = class extends _chunkPCLL536Bcjs.BaseResource {
3990
+ var ContractBlocksResource = class extends _chunk4QN43TRPcjs.BaseResource {
3840
3991
  constructor(http, pageSize) {
3841
3992
  super(http, {
3842
3993
  key: "contract_blocks",
@@ -3895,7 +4046,7 @@ var ContractBlocksResource = class extends _chunkPCLL536Bcjs.BaseResource {
3895
4046
  };
3896
4047
 
3897
4048
  // src/resources/contract_charges.ts
3898
- var ContractChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4049
+ var ContractChargesResource = class extends _chunk4QN43TRPcjs.BaseResource {
3899
4050
  constructor(http, pageSize) {
3900
4051
  super(http, {
3901
4052
  key: "contract_charges",
@@ -3961,12 +4112,12 @@ var ContractChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
3961
4112
  /** Search ContractCharge records: bounded contains on name (no vendor free-text search exists);
3962
4113
  * limit defaults to 25, max 500. */
3963
4114
  async search(query, opts) {
3964
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _50 => _50.limit]) });
4115
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _60 => _60.limit]) });
3965
4116
  }
3966
4117
  };
3967
4118
 
3968
4119
  // src/resources/contract_exclusion_billing_codes.ts
3969
- var ContractExclusionBillingCodesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4120
+ var ContractExclusionBillingCodesResource = class extends _chunk4QN43TRPcjs.BaseResource {
3970
4121
  constructor(http, pageSize) {
3971
4122
  super(http, {
3972
4123
  key: "contract_exclusion_billing_codes",
@@ -4023,7 +4174,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkPCLL536Bcjs.Base
4023
4174
  };
4024
4175
 
4025
4176
  // src/resources/contract_exclusion_roles.ts
4026
- var ContractExclusionRolesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4177
+ var ContractExclusionRolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4027
4178
  constructor(http, pageSize) {
4028
4179
  super(http, {
4029
4180
  key: "contract_exclusion_roles",
@@ -4080,7 +4231,7 @@ var ContractExclusionRolesResource = class extends _chunkPCLL536Bcjs.BaseResourc
4080
4231
  };
4081
4232
 
4082
4233
  // src/resources/contract_exclusion_set_excluded_roles.ts
4083
- var ContractExclusionSetExcludedRolesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4234
+ var ContractExclusionSetExcludedRolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4084
4235
  constructor(http, pageSize) {
4085
4236
  super(http, {
4086
4237
  key: "contract_exclusion_set_excluded_roles",
@@ -4137,7 +4288,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkPCLL536Bcjs.
4137
4288
  };
4138
4289
 
4139
4290
  // src/resources/contract_exclusion_set_excluded_work_types.ts
4140
- var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4291
+ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4141
4292
  constructor(http, pageSize) {
4142
4293
  super(http, {
4143
4294
  key: "contract_exclusion_set_excluded_work_types",
@@ -4194,7 +4345,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkPCLL536B
4194
4345
  };
4195
4346
 
4196
4347
  // src/resources/contract_exclusion_sets.ts
4197
- var ContractExclusionSetsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4348
+ var ContractExclusionSetsResource = class extends _chunk4QN43TRPcjs.BaseResource {
4198
4349
  constructor(http, pageSize) {
4199
4350
  super(http, {
4200
4351
  key: "contract_exclusion_sets",
@@ -4263,12 +4414,12 @@ var ContractExclusionSetsResource = class extends _chunkPCLL536Bcjs.BaseResource
4263
4414
  /** Search ContractExclusionSets records: bounded contains on name (no vendor free-text search exists);
4264
4415
  * limit defaults to 25, max 500. */
4265
4416
  async search(query, opts) {
4266
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _51 => _51.limit]) });
4417
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _61 => _61.limit]) });
4267
4418
  }
4268
4419
  };
4269
4420
 
4270
4421
  // src/resources/contract_milestones.ts
4271
- var ContractMilestonesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4422
+ var ContractMilestonesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4272
4423
  constructor(http, pageSize) {
4273
4424
  super(http, {
4274
4425
  key: "contract_milestones",
@@ -4327,7 +4478,7 @@ var ContractMilestonesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4327
4478
  };
4328
4479
 
4329
4480
  // src/resources/contract_notes.ts
4330
- var ContractNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4481
+ var ContractNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4331
4482
  constructor(http, pageSize) {
4332
4483
  super(http, {
4333
4484
  key: "contract_notes",
@@ -4386,7 +4537,7 @@ var ContractNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4386
4537
  };
4387
4538
 
4388
4539
  // src/resources/contract_rates.ts
4389
- var ContractRatesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4540
+ var ContractRatesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4390
4541
  constructor(http, pageSize) {
4391
4542
  super(http, {
4392
4543
  key: "contract_rates",
@@ -4445,7 +4596,7 @@ var ContractRatesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4445
4596
  };
4446
4597
 
4447
4598
  // src/resources/contract_retainers.ts
4448
- var ContractRetainersResource = class extends _chunkPCLL536Bcjs.BaseResource {
4599
+ var ContractRetainersResource = class extends _chunk4QN43TRPcjs.BaseResource {
4449
4600
  constructor(http, pageSize) {
4450
4601
  super(http, {
4451
4602
  key: "contract_retainers",
@@ -4504,7 +4655,7 @@ var ContractRetainersResource = class extends _chunkPCLL536Bcjs.BaseResource {
4504
4655
  };
4505
4656
 
4506
4657
  // src/resources/contract_role_costs.ts
4507
- var ContractRoleCostsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4658
+ var ContractRoleCostsResource = class extends _chunk4QN43TRPcjs.BaseResource {
4508
4659
  constructor(http, pageSize) {
4509
4660
  super(http, {
4510
4661
  key: "contract_role_costs",
@@ -4563,7 +4714,7 @@ var ContractRoleCostsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4563
4714
  };
4564
4715
 
4565
4716
  // src/resources/contract_service_adjustments.ts
4566
- var ContractServiceAdjustmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4717
+ var ContractServiceAdjustmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
4567
4718
  constructor(http, pageSize) {
4568
4719
  super(http, {
4569
4720
  key: "contract_service_adjustments",
@@ -4597,7 +4748,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkPCLL536Bcjs.BaseRes
4597
4748
  };
4598
4749
 
4599
4750
  // src/resources/contract_service_bundle_adjustments.ts
4600
- var ContractServiceBundleAdjustmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4751
+ var ContractServiceBundleAdjustmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
4601
4752
  constructor(http, pageSize) {
4602
4753
  super(http, {
4603
4754
  key: "contract_service_bundle_adjustments",
@@ -4631,7 +4782,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkPCLL536Bcjs.B
4631
4782
  };
4632
4783
 
4633
4784
  // src/resources/contract_service_bundles.ts
4634
- var ContractServiceBundlesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4785
+ var ContractServiceBundlesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4635
4786
  constructor(http, pageSize) {
4636
4787
  super(http, {
4637
4788
  key: "contract_service_bundles",
@@ -4690,7 +4841,7 @@ var ContractServiceBundlesResource = class extends _chunkPCLL536Bcjs.BaseResourc
4690
4841
  };
4691
4842
 
4692
4843
  // src/resources/contract_service_bundle_units.ts
4693
- var ContractServiceBundleUnitsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4844
+ var ContractServiceBundleUnitsResource = class extends _chunk4QN43TRPcjs.BaseResource {
4694
4845
  constructor(http, pageSize) {
4695
4846
  super(http, {
4696
4847
  key: "contract_service_bundle_units",
@@ -4732,7 +4883,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkPCLL536Bcjs.BaseRes
4732
4883
  };
4733
4884
 
4734
4885
  // src/resources/contract_services.ts
4735
- var ContractServicesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4886
+ var ContractServicesResource = class extends _chunk4QN43TRPcjs.BaseResource {
4736
4887
  constructor(http, pageSize) {
4737
4888
  super(http, {
4738
4889
  key: "contract_services",
@@ -4791,7 +4942,7 @@ var ContractServicesResource = class extends _chunkPCLL536Bcjs.BaseResource {
4791
4942
  };
4792
4943
 
4793
4944
  // src/resources/contract_service_units.ts
4794
- var ContractServiceUnitsResource = class extends _chunkPCLL536Bcjs.BaseResource {
4945
+ var ContractServiceUnitsResource = class extends _chunk4QN43TRPcjs.BaseResource {
4795
4946
  constructor(http, pageSize) {
4796
4947
  super(http, {
4797
4948
  key: "contract_service_units",
@@ -4833,11 +4984,11 @@ var ContractServiceUnitsResource = class extends _chunkPCLL536Bcjs.BaseResource
4833
4984
  };
4834
4985
 
4835
4986
  // src/resources/special/contracts/lineOfBusiness.ts
4836
- var OP3 = "contracts.lineOfBusiness";
4987
+ var OP4 = "contracts.lineOfBusiness";
4837
4988
  function positiveId(value, name) {
4838
4989
  const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
4839
4990
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
4840
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(OP3 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP3 });
4991
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(OP4 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP4 });
4841
4992
  }
4842
4993
  return n;
4843
4994
  }
@@ -4851,7 +5002,7 @@ async function lineOfBusiness(resource, contractIdIn, http, associationIdIn) {
4851
5002
  } else {
4852
5003
  associationSource = "contract";
4853
5004
  const contract = await resource.get(contractId);
4854
- associationId = _chunkPCLL536Bcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
5005
+ associationId = _chunk4QN43TRPcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
4855
5006
  }
4856
5007
  if (associationId === void 0) {
4857
5008
  return {
@@ -4863,7 +5014,7 @@ async function lineOfBusiness(resource, contractIdIn, http, associationIdIn) {
4863
5014
  markers: { association: "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
4864
5015
  };
4865
5016
  }
4866
- const chain = await _chunkPCLL536Bcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP3, onError: "propagate" });
5017
+ const chain = await _chunk4QN43TRPcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP4, onError: "propagate" });
4867
5018
  const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
4868
5019
  return { contractId, associationSource, association, organizationalLevel2, organizationalLevel1, markers };
4869
5020
  }
@@ -5095,7 +5246,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
5095
5246
  // src/resources/special/contracts/profitability.validate.ts
5096
5247
  function validateProfitabilityOptions(contractId, opts) {
5097
5248
  if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
5098
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
5249
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
5099
5250
  `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})`,
5100
5251
  { operation: "contracts.profitability" }
5101
5252
  );
@@ -5172,12 +5323,12 @@ function validateProfitabilityOptions(contractId, opts) {
5172
5323
  }
5173
5324
  }
5174
5325
  try {
5175
- _chunkPCLL536Bcjs.parseIdentifier.call(void 0, contractId, "contractId");
5326
+ _chunk4QN43TRPcjs.parseIdentifier.call(void 0, contractId, "contractId");
5176
5327
  } catch (err) {
5177
- problems.push(err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
5328
+ problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
5178
5329
  }
5179
5330
  if (problems.length > 0) {
5180
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
5331
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
5181
5332
  `profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
5182
5333
  - ` + problems.join("\n- "),
5183
5334
  { operation: "contracts.profitability" }
@@ -5226,23 +5377,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
5226
5377
  const byKey = /* @__PURE__ */ new Map();
5227
5378
  const misses = [];
5228
5379
  const notes = [];
5229
- for (let c = 0; c < unique.length; c += _chunkPCLL536Bcjs.FETCH_BY_IDS_CHUNK_SIZE) {
5230
- const chunk = unique.slice(c, c + _chunkPCLL536Bcjs.FETCH_BY_IDS_CHUNK_SIZE);
5380
+ for (let c = 0; c < unique.length; c += _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE) {
5381
+ const chunk = unique.slice(c, c + _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE);
5231
5382
  const chunkKeys = new Set(chunk);
5232
5383
  try {
5233
5384
  const body = {
5234
- MaxRecords: _chunkPCLL536Bcjs.FETCH_BY_IDS_CHUNK_SIZE,
5385
+ MaxRecords: _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE,
5235
5386
  filter: [{ field: "id", op: "in", value: chunk }],
5236
5387
  IncludeFields: fields
5237
5388
  };
5238
5389
  const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
5239
- const { items: rows } = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, operation);
5390
+ const { items: rows } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, operation);
5240
5391
  for (const row of rows) {
5241
5392
  const k = num(row.id);
5242
5393
  if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
5243
5394
  }
5244
5395
  } catch (err) {
5245
- const code = err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.code : "SERVER_ERROR";
5396
+ const code = err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.code : "SERVER_ERROR";
5246
5397
  for (const k of chunk) {
5247
5398
  if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
5248
5399
  }
@@ -5252,11 +5403,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
5252
5403
  for (const k of queryMissed) {
5253
5404
  try {
5254
5405
  const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
5255
- byKey.set(k, _chunkPCLL536Bcjs.unwrapItem.call(void 0, res, k, operation, entity));
5406
+ byKey.set(k, _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, k, operation, entity));
5256
5407
  } catch (err) {
5257
- if (err instanceof _chunkPCLL536Bcjs.NotFoundError) {
5408
+ if (err instanceof _chunk4QN43TRPcjs.NotFoundError) {
5258
5409
  misses.push({ id: k, code: "NOT_FOUND", message: err.message });
5259
- } else if (err instanceof _chunkPCLL536Bcjs.AutotaskError) {
5410
+ } else if (err instanceof _chunk4QN43TRPcjs.AutotaskError) {
5260
5411
  misses.push({ id: k, code: err.code, message: err.message });
5261
5412
  } else {
5262
5413
  misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
@@ -5310,7 +5461,7 @@ async function degradable(read) {
5310
5461
  try {
5311
5462
  return await read();
5312
5463
  } catch (err) {
5313
- if (!(err instanceof _chunkPCLL536Bcjs.AutotaskError)) throw err;
5464
+ if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
5314
5465
  return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
5315
5466
  }
5316
5467
  }
@@ -5330,15 +5481,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
5330
5481
  status: st.status,
5331
5482
  blindSurface: st.blindSurface,
5332
5483
  note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
5333
- emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkPCLL536Bcjs.EMPTY_REASON_STAMPS, 'access', _52 => _52[key], 'optionalAccess', _53 => _53.query]) : void 0
5484
+ emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunk4QN43TRPcjs.EMPTY_REASON_STAMPS, 'access', _62 => _62[key], 'optionalAccess', _63 => _63.query]) : void 0
5334
5485
  };
5335
5486
  };
5336
5487
  function appendWiresNote(wires, note) {
5337
5488
  wires.note = (wires.note ? wires.note + " | " : "") + note;
5338
5489
  }
5339
5490
  function makeFetchCtx(rawHttp, v, contractId, budget) {
5340
- const OP11 = PROFITABILITY_OP;
5341
- const id = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, contractId, "contractId");
5491
+ const OP12 = PROFITABILITY_OP;
5492
+ const id = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, contractId, "contractId");
5342
5493
  const idNum = typeof id === "number" ? id : Number(id);
5343
5494
  const wires = { issued: 0, requests: 0, budget };
5344
5495
  const toExcl = dayAfter(v.dateTo);
@@ -5349,19 +5500,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
5349
5500
  } };
5350
5501
  const readPart = (path, conditions, fields) => {
5351
5502
  wires.issued += 1;
5352
- return degradable(() => boundedPart(http, path, conditions, v.limit, OP11, fields));
5503
+ return degradable(() => boundedPart(http, path, conditions, v.limit, OP12, fields));
5353
5504
  };
5354
5505
  const truncatedMonths = {};
5355
5506
  const windowedPart = async (name, key, path, cond, fields, dateField) => {
5356
5507
  const first = await readPart(path, cond, fields);
5357
5508
  if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
5358
- const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP11, fields, dateField, v.dateFrom, v.dateTo, wires));
5509
+ const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP12, fields, dateField, v.dateFrom, v.dateTo, wires));
5359
5510
  if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
5360
5511
  const { truncatedMonths: tm, ...part } = wp;
5361
5512
  truncatedMonths[name] = tm;
5362
5513
  return { part, rows: wp.items };
5363
5514
  };
5364
- return { v, OP: OP11, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
5515
+ return { v, OP: OP12, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
5365
5516
  }
5366
5517
 
5367
5518
  // src/resources/special/contracts/profitability.stages.ts
@@ -5376,12 +5527,12 @@ async function fetchCustomer(ctx, companyID) {
5376
5527
  path: `/V1.0/Companies/${companyID}`,
5377
5528
  operation: ctx.OP
5378
5529
  });
5379
- const item = _chunkPCLL536Bcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
5530
+ const item = _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
5380
5531
  customer = _nullishCoalesce(item, () => ( null));
5381
5532
  customerStatus = "ok";
5382
5533
  } catch (err) {
5383
- if (!(err instanceof _chunkPCLL536Bcjs.AutotaskError)) throw err;
5384
- if (!(err instanceof _chunkPCLL536Bcjs.NotFoundError)) {
5534
+ if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
5535
+ if (!(err instanceof _chunk4QN43TRPcjs.NotFoundError)) {
5385
5536
  customerStatus = "absent";
5386
5537
  customerAbsent = err.code;
5387
5538
  }
@@ -5395,9 +5546,9 @@ async function resolveContractType(ctx, contractType) {
5395
5546
  if (contractType > 0) {
5396
5547
  ctx.wires.issued += 1;
5397
5548
  try {
5398
- 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));
5549
+ contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _64 => _64.get, 'call', async _65 => _65("contractType"), 'optionalAccess', async _66 => _66.get, 'call', async _67 => _67(contractType)]), async () => ( null));
5399
5550
  } catch (err) {
5400
- if (!(err instanceof _chunkPCLL536Bcjs.AutotaskError)) throw err;
5551
+ if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
5401
5552
  }
5402
5553
  }
5403
5554
  const contractTypeKnown = contractTypeLabel !== null;
@@ -5406,7 +5557,7 @@ async function resolveContractType(ctx, contractType) {
5406
5557
  return { contractTypeLabel, contractTypeKnown, isBlockHours, isTimeAndMaterials };
5407
5558
  }
5408
5559
  async function fetchRoot(ctx, resource) {
5409
- 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;
5560
+ const contractCached = _optionalChain([ctx, 'access', _68 => _68.rawHttp, 'access', _69 => _69.readCache, 'optionalAccess', _70 => _70.get, 'call', _71 => _71(`/V1.0/Contracts/${ctx.id}`)]) !== void 0;
5410
5561
  const contract = await resource.get(ctx.id);
5411
5562
  ctx.wires.issued += 1;
5412
5563
  if (!contractCached) ctx.wires.requests += 1;
@@ -5459,8 +5610,8 @@ async function fetchInvoices(ctx, billingRows) {
5459
5610
  if (invoiceIds.length === 0) {
5460
5611
  return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
5461
5612
  }
5462
- const capped = capJoinSet2(invoiceIds, _chunkPCLL536Bcjs.FETCH_BY_IDS_MAX_ITEMS);
5463
- if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunkPCLL536Bcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5613
+ const capped = capJoinSet2(invoiceIds, _chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS);
5614
+ if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5464
5615
  const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
5465
5616
  ctx.wires.issued += 1;
5466
5617
  return {
@@ -5506,7 +5657,7 @@ async function readOpenStatusSet(ctx) {
5506
5657
  }
5507
5658
  }
5508
5659
  } catch (err) {
5509
- statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkPCLL536Bcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
5660
+ statusNote = `the tickets.status field catalog read failed (${err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
5510
5661
  }
5511
5662
  return { openStatusSet, statusNote };
5512
5663
  }
@@ -5529,8 +5680,8 @@ async function fetchResources(ctx, entries) {
5529
5680
  if (resourceIds.length === 0) {
5530
5681
  return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
5531
5682
  }
5532
- const capped = capJoinSet2(resourceIds, _chunkPCLL536Bcjs.FETCH_BY_IDS_MAX_ITEMS);
5533
- if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunkPCLL536Bcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5683
+ const capped = capJoinSet2(resourceIds, _chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS);
5684
+ if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
5534
5685
  const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
5535
5686
  ctx.wires.issued += 1;
5536
5687
  for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
@@ -5597,7 +5748,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
5597
5748
  try {
5598
5749
  return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
5599
5750
  } catch (err) {
5600
- if (!(err instanceof _chunkPCLL536Bcjs.AutotaskError)) throw err;
5751
+ if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
5601
5752
  return null;
5602
5753
  }
5603
5754
  }
@@ -5614,17 +5765,17 @@ async function fetchSubscriptions(ctx, cis) {
5614
5765
  cancelledSubs
5615
5766
  };
5616
5767
  }
5617
- const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunkPCLL536Bcjs.FETCH_BY_IDS_MAX_ITEMS);
5768
+ const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS);
5618
5769
  const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
5619
5770
  const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
5620
5771
  const subscriptions = raw.items;
5621
5772
  const labels = await readSubscriptionLabels(ctx, subscriptions);
5622
5773
  for (const x of subscriptions) {
5623
5774
  const sid = num(x["id"]);
5624
- const periodLabel = _optionalChain([labels, 'optionalAccess', _62 => _62.get, 'call', _63 => _63("periodType"), 'optionalAccess', _64 => _64.get, 'call', _65 => _65(num(x["periodType"]))]);
5775
+ const periodLabel = _optionalChain([labels, 'optionalAccess', _72 => _72.get, 'call', _73 => _73("periodType"), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(num(x["periodType"]))]);
5625
5776
  subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
5626
5777
  if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
5627
- const statusLabel = _optionalChain([labels, 'optionalAccess', _66 => _66.get, 'call', _67 => _67("status"), 'optionalAccess', _68 => _68.get, 'call', _69 => _69(num(x["status"]))]);
5778
+ const statusLabel = _optionalChain([labels, 'optionalAccess', _76 => _76.get, 'call', _77 => _77("status"), 'optionalAccess', _78 => _78.get, 'call', _79 => _79(num(x["status"]))]);
5628
5779
  const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num(x["status"]));
5629
5780
  if (notActive) cancelledSubs.add(sid);
5630
5781
  }
@@ -6299,7 +6450,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
6299
6450
  }
6300
6451
 
6301
6452
  // src/resources/contracts.ts
6302
- var ContractsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6453
+ var ContractsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6303
6454
  constructor(http, pageSize) {
6304
6455
  super(http, {
6305
6456
  key: "contracts",
@@ -6361,7 +6512,7 @@ var ContractsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6361
6512
  /** Search Contract records: bounded contains on contractName (no vendor free-text search exists);
6362
6513
  * limit defaults to 25, max 500. */
6363
6514
  async search(query, opts) {
6364
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _70 => _70.limit]) });
6515
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _80 => _80.limit]) });
6365
6516
  }
6366
6517
  /** Node-parity special op (hand-written in src/resources/special/contracts.ts). */
6367
6518
  profitability(id, opts) {
@@ -6374,7 +6525,7 @@ var ContractsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6374
6525
  };
6375
6526
 
6376
6527
  // src/resources/contract_ticket_purchases.ts
6377
- var ContractTicketPurchasesResource = class extends _chunkPCLL536Bcjs.BaseResource {
6528
+ var ContractTicketPurchasesResource = class extends _chunk4QN43TRPcjs.BaseResource {
6378
6529
  constructor(http, pageSize) {
6379
6530
  super(http, {
6380
6531
  key: "contract_ticket_purchases",
@@ -6433,7 +6584,7 @@ var ContractTicketPurchasesResource = class extends _chunkPCLL536Bcjs.BaseResour
6433
6584
  };
6434
6585
 
6435
6586
  // src/resources/countries.ts
6436
- var CountriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
6587
+ var CountriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
6437
6588
  constructor(http, pageSize) {
6438
6589
  super(http, {
6439
6590
  key: "countries",
@@ -6487,12 +6638,12 @@ var CountriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
6487
6638
  /** Search Country records: bounded contains on name (no vendor free-text search exists);
6488
6639
  * limit defaults to 25, max 500. */
6489
6640
  async search(query, opts) {
6490
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _71 => _71.limit]) });
6641
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
6491
6642
  }
6492
6643
  };
6493
6644
 
6494
6645
  // src/resources/currencies.ts
6495
- var CurrenciesResource = class extends _chunkPCLL536Bcjs.BaseResource {
6646
+ var CurrenciesResource = class extends _chunk4QN43TRPcjs.BaseResource {
6496
6647
  constructor(http, pageSize) {
6497
6648
  super(http, {
6498
6649
  key: "currencies",
@@ -6531,12 +6682,12 @@ var CurrenciesResource = class extends _chunkPCLL536Bcjs.BaseResource {
6531
6682
  /** Search Currency records: bounded contains on name (no vendor free-text search exists);
6532
6683
  * limit defaults to 25, max 500. */
6533
6684
  async search(query, opts) {
6534
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _72 => _72.limit]) });
6685
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
6535
6686
  }
6536
6687
  };
6537
6688
 
6538
6689
  // src/resources/departments.ts
6539
- var DepartmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6690
+ var DepartmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6540
6691
  constructor(http, pageSize) {
6541
6692
  super(http, {
6542
6693
  key: "departments",
@@ -6598,12 +6749,12 @@ var DepartmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6598
6749
  /** Search Department records: bounded contains on name (no vendor free-text search exists);
6599
6750
  * limit defaults to 25, max 500. */
6600
6751
  async search(query, opts) {
6601
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _73 => _73.limit]) });
6752
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _83 => _83.limit]) });
6602
6753
  }
6603
6754
  };
6604
6755
 
6605
6756
  // src/resources/domain_registrars.ts
6606
- var DomainRegistrarsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6757
+ var DomainRegistrarsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6607
6758
  constructor(http, pageSize) {
6608
6759
  super(http, {
6609
6760
  key: "domain_registrars",
@@ -6665,7 +6816,7 @@ var DomainRegistrarsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6665
6816
  /** Search DomainRegistrar records: bounded contains on name (no vendor free-text search exists);
6666
6817
  * limit defaults to 25, max 500. */
6667
6818
  async search(query, opts) {
6668
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _74 => _74.limit]) });
6819
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _84 => _84.limit]) });
6669
6820
  }
6670
6821
  };
6671
6822
 
@@ -6686,7 +6837,7 @@ var EntityInformationResource = class {
6686
6837
  };
6687
6838
 
6688
6839
  // src/resources/expense_item_attachments.ts
6689
- var ExpenseItemAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6840
+ var ExpenseItemAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6690
6841
  constructor(http, pageSize) {
6691
6842
  super(http, {
6692
6843
  key: "expense_item_attachments",
@@ -6748,7 +6899,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResourc
6748
6899
  };
6749
6900
 
6750
6901
  // src/resources/expense_items.ts
6751
- var ExpenseItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6902
+ var ExpenseItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6752
6903
  constructor(http, pageSize) {
6753
6904
  super(http, {
6754
6905
  key: "expense_items",
@@ -6807,7 +6958,7 @@ var ExpenseItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6807
6958
  };
6808
6959
 
6809
6960
  // src/resources/expense_reports.ts
6810
- var ExpenseReportsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6961
+ var ExpenseReportsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6811
6962
  constructor(http, pageSize) {
6812
6963
  super(http, {
6813
6964
  key: "expense_reports",
@@ -6869,12 +7020,12 @@ var ExpenseReportsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6869
7020
  /** Search ExpenseReport records: bounded contains on name (no vendor free-text search exists);
6870
7021
  * limit defaults to 25, max 500. */
6871
7022
  async search(query, opts) {
6872
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _75 => _75.limit]) });
7023
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _85 => _85.limit]) });
6873
7024
  }
6874
7025
  };
6875
7026
 
6876
7027
  // src/resources/holiday_sets.ts
6877
- var HolidaySetsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7028
+ var HolidaySetsResource = class extends _chunk4QN43TRPcjs.BaseResource {
6878
7029
  constructor(http, pageSize) {
6879
7030
  super(http, {
6880
7031
  key: "holiday_sets",
@@ -6943,7 +7094,7 @@ var HolidaySetsResource = class extends _chunkPCLL536Bcjs.BaseResource {
6943
7094
  };
6944
7095
 
6945
7096
  // src/resources/holidays.ts
6946
- var HolidaysResource = class extends _chunkPCLL536Bcjs.BaseResource {
7097
+ var HolidaysResource = class extends _chunk4QN43TRPcjs.BaseResource {
6947
7098
  constructor(http, pageSize) {
6948
7099
  super(http, {
6949
7100
  key: "holidays",
@@ -7015,10 +7166,10 @@ var PATH_SUFFIX = {
7015
7166
  transfer: "StockedItemsTransfer"
7016
7167
  };
7017
7168
  async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
7018
- const numericParent = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, parentId, "parentId");
7169
+ const numericParent = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, parentId, "parentId");
7019
7170
  const suffix = PATH_SUFFIX[kind];
7020
7171
  if (opts.dryRun === true) {
7021
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
7172
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
7022
7173
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
7023
7174
  method: "POST",
7024
7175
  path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
@@ -7035,11 +7186,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
7035
7186
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
7036
7187
  maxRetries: opts.maxRetries
7037
7188
  });
7038
- return _chunkPCLL536Bcjs.unwrapOperation.call(void 0, res);
7189
+ return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
7039
7190
  }
7040
7191
 
7041
7192
  // src/resources/inventory_products.ts
7042
- var InventoryProductsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7193
+ var InventoryProductsResource = class extends _chunk4QN43TRPcjs.BaseResource {
7043
7194
  constructor(http, pageSize) {
7044
7195
  super(http, {
7045
7196
  key: "inventory_products",
@@ -7121,7 +7272,7 @@ var InventoryProductsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7121
7272
 
7122
7273
  // src/resources/special/invoices.ts
7123
7274
  async function markup(_resource, id, format, http) {
7124
- const numericId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
7275
+ const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
7125
7276
  const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
7126
7277
  const res = await http.request({
7127
7278
  method: "GET",
@@ -7130,7 +7281,7 @@ async function markup(_resource, id, format, http) {
7130
7281
  });
7131
7282
  const body = res;
7132
7283
  if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
7133
- throw new (0, _chunkPCLL536Bcjs.AutotaskError)(
7284
+ throw new (0, _chunk4QN43TRPcjs.AutotaskError)(
7134
7285
  `Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
7135
7286
  { code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
7136
7287
  );
@@ -7138,44 +7289,44 @@ async function markup(_resource, id, format, http) {
7138
7289
  return body.invoiceMarkup;
7139
7290
  }
7140
7291
  async function pdf(_resource, id, http) {
7141
- const numericId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
7292
+ const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
7142
7293
  const res = await http.request({
7143
7294
  method: "GET",
7144
7295
  path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
7145
7296
  operation: "invoices.pdf"
7146
7297
  });
7147
- return _chunkPCLL536Bcjs.decodeFileData.call(void 0, res);
7298
+ return _chunk4QN43TRPcjs.decodeFileData.call(void 0, res);
7148
7299
  }
7149
7300
  async function windowQuery2(_resource, kind, http, opts) {
7150
- const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _76 => _76.now]), () => ( /* @__PURE__ */ new Date()));
7151
- const tz = _optionalChain([opts, 'optionalAccess', _77 => _77.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
7301
+ const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _86 => _86.now]), () => ( /* @__PURE__ */ new Date()));
7302
+ const tz = _optionalChain([opts, 'optionalAccess', _87 => _87.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
7152
7303
  return dateWindowQuery(
7153
7304
  http,
7154
7305
  "/V1.0/Invoices/query",
7155
7306
  "invoiceDateTime",
7156
7307
  kind,
7157
- clampWindowLimit(_optionalChain([opts, 'optionalAccess', _78 => _78.limit])),
7308
+ clampWindowLimit(_optionalChain([opts, 'optionalAccess', _88 => _88.limit])),
7158
7309
  `invoices.${kind}`,
7159
7310
  now,
7160
7311
  tz
7161
7312
  );
7162
7313
  }
7163
7314
  async function customRange2(_resource, from, to, http, opts) {
7164
- const zone = _optionalChain([opts, 'optionalAccess', _79 => _79.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
7315
+ const zone = _optionalChain([opts, 'optionalAccess', _89 => _89.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
7165
7316
  return customRangeQuery(
7166
7317
  http,
7167
7318
  "/V1.0/Invoices/query",
7168
7319
  "invoiceDateTime",
7169
7320
  from,
7170
7321
  to,
7171
- clampWindowLimit(_optionalChain([opts, 'optionalAccess', _80 => _80.limit])),
7322
+ clampWindowLimit(_optionalChain([opts, 'optionalAccess', _90 => _90.limit])),
7172
7323
  "invoices.customRange",
7173
7324
  zone
7174
7325
  );
7175
7326
  }
7176
7327
 
7177
7328
  // src/resources/invoices.ts
7178
- var InvoicesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7329
+ var InvoicesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7179
7330
  constructor(http, pageSize) {
7180
7331
  super(http, {
7181
7332
  key: "invoices",
@@ -7289,7 +7440,7 @@ var InvoicesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7289
7440
  };
7290
7441
 
7291
7442
  // src/resources/invoice_templates.ts
7292
- var InvoiceTemplatesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7443
+ var InvoiceTemplatesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7293
7444
  constructor(http, pageSize) {
7294
7445
  super(http, {
7295
7446
  key: "invoice_templates",
@@ -7333,7 +7484,7 @@ var ModulesResource = class {
7333
7484
  };
7334
7485
 
7335
7486
  // src/resources/notification_history.ts
7336
- var NotificationHistoryResource = class extends _chunkPCLL536Bcjs.BaseResource {
7487
+ var NotificationHistoryResource = class extends _chunk4QN43TRPcjs.BaseResource {
7337
7488
  constructor(http, pageSize) {
7338
7489
  super(http, {
7339
7490
  key: "notification_history",
@@ -7372,7 +7523,7 @@ var NotificationHistoryResource = class extends _chunkPCLL536Bcjs.BaseResource {
7372
7523
  };
7373
7524
 
7374
7525
  // src/resources/opportunities.ts
7375
- var OpportunitiesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7526
+ var OpportunitiesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7376
7527
  constructor(http, pageSize) {
7377
7528
  super(http, {
7378
7529
  key: "opportunities",
@@ -7434,7 +7585,7 @@ var OpportunitiesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7434
7585
  };
7435
7586
 
7436
7587
  // src/resources/opportunity_attachments.ts
7437
- var OpportunityAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7588
+ var OpportunityAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
7438
7589
  constructor(http, pageSize) {
7439
7590
  super(http, {
7440
7591
  key: "opportunity_attachments",
@@ -7496,7 +7647,7 @@ var OpportunityAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResourc
7496
7647
  };
7497
7648
 
7498
7649
  // src/resources/opportunity_categories.ts
7499
- var OpportunityCategoriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7650
+ var OpportunityCategoriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7500
7651
  constructor(http, pageSize) {
7501
7652
  super(http, {
7502
7653
  key: "opportunity_categories",
@@ -7550,12 +7701,12 @@ var OpportunityCategoriesResource = class extends _chunkPCLL536Bcjs.BaseResource
7550
7701
  /** Search OpportunityCategory records: bounded contains on name (no vendor free-text search exists);
7551
7702
  * limit defaults to 25, max 500. */
7552
7703
  async search(query, opts) {
7553
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
7704
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
7554
7705
  }
7555
7706
  };
7556
7707
 
7557
7708
  // src/resources/organizational_level1s.ts
7558
- var OrganizationalLevel1sResource = class extends _chunkPCLL536Bcjs.BaseResource {
7709
+ var OrganizationalLevel1sResource = class extends _chunk4QN43TRPcjs.BaseResource {
7559
7710
  constructor(http, pageSize) {
7560
7711
  super(http, {
7561
7712
  key: "organizational_level1s",
@@ -7606,7 +7757,7 @@ var OrganizationalLevel1sResource = class extends _chunkPCLL536Bcjs.BaseResource
7606
7757
  };
7607
7758
 
7608
7759
  // src/resources/organizational_level2s.ts
7609
- var OrganizationalLevel2sResource = class extends _chunkPCLL536Bcjs.BaseResource {
7760
+ var OrganizationalLevel2sResource = class extends _chunk4QN43TRPcjs.BaseResource {
7610
7761
  constructor(http, pageSize) {
7611
7762
  super(http, {
7612
7763
  key: "organizational_level2s",
@@ -7657,7 +7808,7 @@ var OrganizationalLevel2sResource = class extends _chunkPCLL536Bcjs.BaseResource
7657
7808
  };
7658
7809
 
7659
7810
  // src/resources/organizational_level_associations.ts
7660
- var OrganizationalLevelAssociationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7811
+ var OrganizationalLevelAssociationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
7661
7812
  constructor(http, pageSize) {
7662
7813
  super(http, {
7663
7814
  key: "organizational_level_associations",
@@ -7708,7 +7859,7 @@ var OrganizationalLevelAssociationsResource = class extends _chunkPCLL536Bcjs.Ba
7708
7859
  };
7709
7860
 
7710
7861
  // src/resources/phases.ts
7711
- var PhasesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7862
+ var PhasesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7712
7863
  constructor(http, pageSize) {
7713
7864
  super(http, {
7714
7865
  key: "phases",
@@ -7767,7 +7918,7 @@ var PhasesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7767
7918
  };
7768
7919
 
7769
7920
  // src/resources/products.ts
7770
- var ProductsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7921
+ var ProductsResource = class extends _chunk4QN43TRPcjs.BaseResource {
7771
7922
  constructor(http, pageSize) {
7772
7923
  super(http, {
7773
7924
  key: "products",
@@ -7829,12 +7980,12 @@ var ProductsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7829
7980
  /** Search Product records: bounded contains on name (no vendor free-text search exists);
7830
7981
  * limit defaults to 25, max 500. */
7831
7982
  async search(query, opts) {
7832
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
7983
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
7833
7984
  }
7834
7985
  };
7835
7986
 
7836
7987
  // src/resources/product_vendors.ts
7837
- var ProductVendorsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7988
+ var ProductVendorsResource = class extends _chunk4QN43TRPcjs.BaseResource {
7838
7989
  constructor(http, pageSize) {
7839
7990
  super(http, {
7840
7991
  key: "product_vendors",
@@ -7893,7 +8044,7 @@ var ProductVendorsResource = class extends _chunkPCLL536Bcjs.BaseResource {
7893
8044
  };
7894
8045
 
7895
8046
  // src/resources/project_charges.ts
7896
- var ProjectChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8047
+ var ProjectChargesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7897
8048
  constructor(http, pageSize) {
7898
8049
  super(http, {
7899
8050
  key: "project_charges",
@@ -7959,12 +8110,12 @@ var ProjectChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
7959
8110
  /** Search ProjectCharge records: bounded contains on name (no vendor free-text search exists);
7960
8111
  * limit defaults to 25, max 500. */
7961
8112
  async search(query, opts) {
7962
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _83 => _83.limit]) });
8113
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _93 => _93.limit]) });
7963
8114
  }
7964
8115
  };
7965
8116
 
7966
8117
  // src/resources/project_notes.ts
7967
- var ProjectNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8118
+ var ProjectNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
7968
8119
  constructor(http, pageSize) {
7969
8120
  super(http, {
7970
8121
  key: "project_notes",
@@ -8023,7 +8174,7 @@ var ProjectNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8023
8174
  };
8024
8175
 
8025
8176
  // src/resources/projects.ts
8026
- var ProjectsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8177
+ var ProjectsResource = class extends _chunk4QN43TRPcjs.BaseResource {
8027
8178
  constructor(http, pageSize) {
8028
8179
  super(http, {
8029
8180
  key: "projects",
@@ -8085,7 +8236,7 @@ var ProjectsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8085
8236
  /** Search Project records: bounded contains on projectName (no vendor free-text search exists);
8086
8237
  * limit defaults to 25, max 500. */
8087
8238
  async search(query, opts) {
8088
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _84 => _84.limit]) });
8239
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _94 => _94.limit]) });
8089
8240
  }
8090
8241
  /** Get the Project with its primary context records in one call (each part a single-record
8091
8242
  * fetch; no sub-lists; absent/dangling references come back null). `names: true` (issue #77)
@@ -8100,13 +8251,13 @@ var ProjectsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8100
8251
  const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
8101
8252
  const result = { project: project2, company, opportunity, leadResource };
8102
8253
  if (opts.names === true) {
8103
- const builder = _chunkPCLL536Bcjs.createNamePlan.call(void 0, );
8254
+ const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, );
8104
8255
  builder.addResource(root["creatorResourceID"]);
8105
8256
  builder.addFk("contract", root["contractID"]);
8106
- const names = await _chunkPCLL536Bcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
8257
+ const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
8107
8258
  const row = { ...project2 };
8108
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
8109
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
8259
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
8260
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
8110
8261
  result.project = row;
8111
8262
  result.names = names.section;
8112
8263
  }
@@ -8115,7 +8266,7 @@ var ProjectsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8115
8266
  };
8116
8267
 
8117
8268
  // src/resources/purchase_approvals.ts
8118
- var PurchaseApprovalsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8269
+ var PurchaseApprovalsResource = class extends _chunk4QN43TRPcjs.BaseResource {
8119
8270
  constructor(http, pageSize) {
8120
8271
  super(http, {
8121
8272
  key: "purchase_approvals",
@@ -8169,7 +8320,7 @@ var PurchaseApprovalsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8169
8320
  };
8170
8321
 
8171
8322
  // src/resources/purchase_order_item_receiving.ts
8172
- var PurchaseOrderItemReceivingResource = class extends _chunkPCLL536Bcjs.BaseResource {
8323
+ var PurchaseOrderItemReceivingResource = class extends _chunk4QN43TRPcjs.BaseResource {
8173
8324
  constructor(http, pageSize) {
8174
8325
  super(http, {
8175
8326
  key: "purchase_order_item_receiving",
@@ -8219,7 +8370,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkPCLL536Bcjs.BaseRes
8219
8370
  };
8220
8371
 
8221
8372
  // src/resources/purchase_order_items.ts
8222
- var PurchaseOrderItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8373
+ var PurchaseOrderItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
8223
8374
  constructor(http, pageSize) {
8224
8375
  super(http, {
8225
8376
  key: "purchase_order_items",
@@ -8278,7 +8429,7 @@ var PurchaseOrderItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8278
8429
  };
8279
8430
 
8280
8431
  // src/resources/purchase_orders.ts
8281
- var PurchaseOrdersResource = class extends _chunkPCLL536Bcjs.BaseResource {
8432
+ var PurchaseOrdersResource = class extends _chunk4QN43TRPcjs.BaseResource {
8282
8433
  constructor(http, pageSize) {
8283
8434
  super(http, {
8284
8435
  key: "purchase_orders",
@@ -8340,7 +8491,7 @@ var PurchaseOrdersResource = class extends _chunkPCLL536Bcjs.BaseResource {
8340
8491
  };
8341
8492
 
8342
8493
  // src/resources/quote_items.ts
8343
- var QuoteItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8494
+ var QuoteItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
8344
8495
  constructor(http, pageSize) {
8345
8496
  super(http, {
8346
8497
  key: "quote_items",
@@ -8406,12 +8557,12 @@ var QuoteItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8406
8557
  /** Search QuoteItem records: bounded contains on name (no vendor free-text search exists);
8407
8558
  * limit defaults to 25, max 500. */
8408
8559
  async search(query, opts) {
8409
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _85 => _85.limit]) });
8560
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
8410
8561
  }
8411
8562
  };
8412
8563
 
8413
8564
  // src/resources/quote_locations.ts
8414
- var QuoteLocationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8565
+ var QuoteLocationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
8415
8566
  constructor(http, pageSize) {
8416
8567
  super(http, {
8417
8568
  key: "quote_locations",
@@ -8476,7 +8627,7 @@ var QuoteLocationsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8476
8627
  };
8477
8628
 
8478
8629
  // src/resources/quotes.ts
8479
- var QuotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8630
+ var QuotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
8480
8631
  constructor(http, pageSize) {
8481
8632
  super(http, {
8482
8633
  key: "quotes",
@@ -8538,12 +8689,12 @@ var QuotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8538
8689
  /** Search Quote records: bounded contains on name (no vendor free-text search exists);
8539
8690
  * limit defaults to 25, max 500. */
8540
8691
  async search(query, opts) {
8541
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _86 => _86.limit]) });
8692
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
8542
8693
  }
8543
8694
  };
8544
8695
 
8545
8696
  // src/resources/quote_templates.ts
8546
- var QuoteTemplatesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8697
+ var QuoteTemplatesResource = class extends _chunk4QN43TRPcjs.BaseResource {
8547
8698
  constructor(http, pageSize) {
8548
8699
  super(http, {
8549
8700
  key: "quote_templates",
@@ -8582,12 +8733,12 @@ var QuoteTemplatesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8582
8733
  /** Search QuoteTemplate records: bounded contains on name (no vendor free-text search exists);
8583
8734
  * limit defaults to 25, max 500. */
8584
8735
  async search(query, opts) {
8585
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _87 => _87.limit]) });
8736
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _97 => _97.limit]) });
8586
8737
  }
8587
8738
  };
8588
8739
 
8589
8740
  // src/resources/resource_role_queues.ts
8590
- var ResourceRoleQueuesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8741
+ var ResourceRoleQueuesResource = class extends _chunk4QN43TRPcjs.BaseResource {
8591
8742
  constructor(http, pageSize) {
8592
8743
  super(http, {
8593
8744
  key: "resource_role_queues",
@@ -8646,7 +8797,7 @@ var ResourceRoleQueuesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8646
8797
  };
8647
8798
 
8648
8799
  // src/resources/resource_roles.ts
8649
- var ResourceRolesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8800
+ var ResourceRolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
8650
8801
  constructor(http, pageSize) {
8651
8802
  super(http, {
8652
8803
  key: "resource_roles",
@@ -8688,7 +8839,7 @@ var ResourceRolesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8688
8839
  };
8689
8840
 
8690
8841
  // src/resources/resource_skills.ts
8691
- var ResourceSkillsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8842
+ var ResourceSkillsResource = class extends _chunk4QN43TRPcjs.BaseResource {
8692
8843
  constructor(http, pageSize) {
8693
8844
  super(http, {
8694
8845
  key: "resource_skills",
@@ -8742,16 +8893,16 @@ var ResourceSkillsResource = class extends _chunkPCLL536Bcjs.BaseResource {
8742
8893
  var MAX_TRANSFER_IDS = 500;
8743
8894
  function requirePositiveIds(ids2, label) {
8744
8895
  if (!Array.isArray(ids2) || ids2.length === 0) {
8745
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
8896
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
8746
8897
  }
8747
8898
  if (ids2.length > MAX_TRANSFER_IDS) {
8748
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
8899
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
8749
8900
  }
8750
8901
  const out = [];
8751
8902
  for (const raw of ids2) {
8752
- const id = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, raw, `${label} id`);
8903
+ const id = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, raw, `${label} id`);
8753
8904
  if (typeof id === "number" && id < 1) {
8754
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
8905
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
8755
8906
  }
8756
8907
  out.push(id);
8757
8908
  }
@@ -8759,7 +8910,7 @@ function requirePositiveIds(ids2, label) {
8759
8910
  }
8760
8911
  async function whoAmI(_resource, userName, http) {
8761
8912
  const user = userName.trim();
8762
- if (user === "") throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
8913
+ if (user === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
8763
8914
  const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
8764
8915
  const res = await http.request({
8765
8916
  method: "POST",
@@ -8768,11 +8919,11 @@ async function whoAmI(_resource, userName, http) {
8768
8919
  body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
8769
8920
  operation: "resources.whoAmI"
8770
8921
  });
8771
- const matches = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
8922
+ const matches = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
8772
8923
  if (matches.length === 0) return null;
8773
8924
  if (matches.length > 1) {
8774
8925
  const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
8775
- throw new (0, _chunkPCLL536Bcjs.ResolutionError)(
8926
+ throw new (0, _chunk4QN43TRPcjs.ResolutionError)(
8776
8927
  `whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
8777
8928
  { code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
8778
8929
  );
@@ -8781,11 +8932,11 @@ async function whoAmI(_resource, userName, http) {
8781
8932
  }
8782
8933
  async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
8783
8934
  const ids2 = requirePositiveIds(companyIds, "transferOwnership");
8784
- const destination = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
8935
+ const destination = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
8785
8936
  if (typeof destination === "number" && destination < 1) {
8786
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
8937
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
8787
8938
  }
8788
- const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _88 => _88.dryRun]), () => ( true));
8939
+ const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _98 => _98.dryRun]), () => ( true));
8789
8940
  const changes = [];
8790
8941
  const applied = [];
8791
8942
  for (const id of ids2) {
@@ -8794,9 +8945,9 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8794
8945
  method: "GET",
8795
8946
  path: `/V1.0/Companies/${id}`,
8796
8947
  operation: "resources.transferOwnership",
8797
- maxRetries: _optionalChain([opts, 'optionalAccess', _89 => _89.maxRetries])
8948
+ maxRetries: _optionalChain([opts, 'optionalAccess', _99 => _99.maxRetries])
8798
8949
  });
8799
- const company = _chunkPCLL536Bcjs.unwrapItem.call(void 0, res, id, void 0, "company");
8950
+ const company = _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, id, void 0, "company");
8800
8951
  const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
8801
8952
  changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
8802
8953
  if (!dryRun) {
@@ -8805,15 +8956,15 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8805
8956
  path: "/V1.0/Companies",
8806
8957
  body: { id, ownerResourceID: destination },
8807
8958
  operation: "resources.transferOwnership",
8808
- maxRetries: _optionalChain([opts, 'optionalAccess', _90 => _90.maxRetries])
8959
+ maxRetries: _optionalChain([opts, 'optionalAccess', _100 => _100.maxRetries])
8809
8960
  });
8810
- _chunkPCLL536Bcjs.unwrapOperation.call(void 0, update);
8961
+ _chunk4QN43TRPcjs.unwrapOperation.call(void 0, update);
8811
8962
  applied.push(id);
8812
8963
  }
8813
8964
  } catch (err) {
8814
- if (!dryRun && err instanceof _chunkPCLL536Bcjs.AutotaskError) {
8965
+ if (!dryRun && err instanceof _chunk4QN43TRPcjs.AutotaskError) {
8815
8966
  err.resourceIds = [id];
8816
- err.details = _chunkPCLL536Bcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
8967
+ err.details = _chunk4QN43TRPcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
8817
8968
  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).`;
8818
8969
  }
8819
8970
  throw err;
@@ -8822,7 +8973,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8822
8973
  if (dryRun) {
8823
8974
  const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
8824
8975
  return {
8825
- ..._chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
8976
+ ..._chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
8826
8977
  operation: "resources.transferOwnership",
8827
8978
  method: "PUT",
8828
8979
  path: "/V1.0/Companies",
@@ -8846,7 +8997,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
8846
8997
  }
8847
8998
 
8848
8999
  // src/resources/resources.ts
8849
- var ResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9000
+ var ResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
8850
9001
 
8851
9002
  constructor(http, clientConfig, pageSize) {
8852
9003
  super(http, {
@@ -8905,7 +9056,7 @@ var ResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8905
9056
  /** Search Resource records: bounded contains on firstName + lastName (no vendor free-text search exists);
8906
9057
  * limit defaults to 25, max 500. */
8907
9058
  async search(query, opts) {
8908
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
9059
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _101 => _101.limit]) });
8909
9060
  }
8910
9061
  /** Node-parity special op (hand-written in src/resources/special/resources.ts). */
8911
9062
  transferOwnership(sourceResourceIds, destinationResourceId, opts = {}) {
@@ -8919,7 +9070,7 @@ var ResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
8919
9070
 
8920
9071
  // src/resources/special/resource_time_off_additional.ts
8921
9072
  async function getByResource(_resource, resourceId, http) {
8922
- const numericResource = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
9073
+ const numericResource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
8923
9074
  const res = await http.request({
8924
9075
  method: "GET",
8925
9076
  path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
@@ -8933,11 +9084,11 @@ async function getByResource(_resource, resourceId, http) {
8933
9084
  if (typeof item === "object" && !Array.isArray(item)) return [item];
8934
9085
  }
8935
9086
  }
8936
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
9087
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
8937
9088
  }
8938
9089
 
8939
9090
  // src/resources/resource_time_off_additional.ts
8940
- var ResourceTimeOffAdditionalResource = class extends _chunkPCLL536Bcjs.BaseResource {
9091
+ var ResourceTimeOffAdditionalResource = class extends _chunk4QN43TRPcjs.BaseResource {
8941
9092
  constructor(http, pageSize) {
8942
9093
  super(http, {
8943
9094
  key: "resource_time_off_additional",
@@ -8976,7 +9127,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkPCLL536Bcjs.BaseReso
8976
9127
  };
8977
9128
 
8978
9129
  // src/resources/resource_time_off_approvers.ts
8979
- var ResourceTimeOffApproversResource = class extends _chunkPCLL536Bcjs.BaseResource {
9130
+ var ResourceTimeOffApproversResource = class extends _chunk4QN43TRPcjs.BaseResource {
8980
9131
  constructor(http, pageSize) {
8981
9132
  super(http, {
8982
9133
  key: "resource_time_off_approvers",
@@ -9019,29 +9170,29 @@ var ResourceTimeOffApproversResource = class extends _chunkPCLL536Bcjs.BaseResou
9019
9170
 
9020
9171
  // src/resources/special/resource_time_off_balances.ts
9021
9172
  async function getByResource2(_resource, resourceId, http) {
9022
- const numericResource = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
9173
+ const numericResource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
9023
9174
  const res = await http.request({
9024
9175
  method: "GET",
9025
9176
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
9026
9177
  operation: "resource_time_off_balances.getByResource"
9027
9178
  });
9028
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
9179
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
9029
9180
  }
9030
9181
  async function getByYear(_resource, resourceId, year, http) {
9031
- const numericResource = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
9182
+ const numericResource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
9032
9183
  if (!Number.isSafeInteger(year) || year < 1) {
9033
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
9184
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
9034
9185
  }
9035
9186
  const res = await http.request({
9036
9187
  method: "GET",
9037
9188
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
9038
9189
  operation: "resource_time_off_balances.getByYear"
9039
9190
  });
9040
- return _chunkPCLL536Bcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
9191
+ return _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
9041
9192
  }
9042
9193
 
9043
9194
  // src/resources/resource_time_off_balances.ts
9044
- var ResourceTimeOffBalancesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9195
+ var ResourceTimeOffBalancesResource = class extends _chunk4QN43TRPcjs.BaseResource {
9045
9196
  constructor(http, pageSize) {
9046
9197
  super(http, {
9047
9198
  key: "resource_time_off_balances",
@@ -9079,7 +9230,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkPCLL536Bcjs.BaseResour
9079
9230
  };
9080
9231
 
9081
9232
  // src/resources/roles.ts
9082
- var RolesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9233
+ var RolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
9083
9234
  constructor(http, pageSize) {
9084
9235
  super(http, {
9085
9236
  key: "roles",
@@ -9141,12 +9292,12 @@ var RolesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9141
9292
  /** Search Role records: bounded contains on name (no vendor free-text search exists);
9142
9293
  * limit defaults to 25, max 500. */
9143
9294
  async search(query, opts) {
9144
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
9295
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _102 => _102.limit]) });
9145
9296
  }
9146
9297
  };
9147
9298
 
9148
9299
  // src/resources/sales_orders.ts
9149
- var SalesOrdersResource = class extends _chunkPCLL536Bcjs.BaseResource {
9300
+ var SalesOrdersResource = class extends _chunk4QN43TRPcjs.BaseResource {
9150
9301
  constructor(http, pageSize) {
9151
9302
  super(http, {
9152
9303
  key: "sales_orders",
@@ -9189,7 +9340,7 @@ var SalesOrdersResource = class extends _chunkPCLL536Bcjs.BaseResource {
9189
9340
  };
9190
9341
 
9191
9342
  // src/resources/service_calls.ts
9192
- var ServiceCallsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9343
+ var ServiceCallsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9193
9344
  constructor(http, pageSize) {
9194
9345
  super(http, {
9195
9346
  key: "service_calls",
@@ -9258,7 +9409,7 @@ var ServiceCallsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9258
9409
  };
9259
9410
 
9260
9411
  // src/resources/service_call_task_resources.ts
9261
- var ServiceCallTaskResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9412
+ var ServiceCallTaskResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
9262
9413
  constructor(http, pageSize) {
9263
9414
  super(http, {
9264
9415
  key: "service_call_task_resources",
@@ -9315,7 +9466,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkPCLL536Bcjs.BaseResou
9315
9466
  };
9316
9467
 
9317
9468
  // src/resources/service_call_tasks.ts
9318
- var ServiceCallTasksResource = class extends _chunkPCLL536Bcjs.BaseResource {
9469
+ var ServiceCallTasksResource = class extends _chunk4QN43TRPcjs.BaseResource {
9319
9470
  constructor(http, pageSize) {
9320
9471
  super(http, {
9321
9472
  key: "service_call_tasks",
@@ -9372,7 +9523,7 @@ var ServiceCallTasksResource = class extends _chunkPCLL536Bcjs.BaseResource {
9372
9523
  };
9373
9524
 
9374
9525
  // src/resources/service_call_ticket_resources.ts
9375
- var ServiceCallTicketResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9526
+ var ServiceCallTicketResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
9376
9527
  constructor(http, pageSize) {
9377
9528
  super(http, {
9378
9529
  key: "service_call_ticket_resources",
@@ -9429,7 +9580,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkPCLL536Bcjs.BaseRes
9429
9580
  };
9430
9581
 
9431
9582
  // src/resources/service_call_tickets.ts
9432
- var ServiceCallTicketsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9583
+ var ServiceCallTicketsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9433
9584
  constructor(http, pageSize) {
9434
9585
  super(http, {
9435
9586
  key: "service_call_tickets",
@@ -9486,7 +9637,7 @@ var ServiceCallTicketsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9486
9637
  };
9487
9638
 
9488
9639
  // src/resources/service_level_agreement_results.ts
9489
- var ServiceLevelAgreementResultsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9640
+ var ServiceLevelAgreementResultsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9490
9641
  constructor(http, pageSize) {
9491
9642
  super(http, {
9492
9643
  key: "service_level_agreement_results",
@@ -9525,7 +9676,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkPCLL536Bcjs.BaseR
9525
9676
  };
9526
9677
 
9527
9678
  // src/resources/services.ts
9528
- var ServicesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9679
+ var ServicesResource = class extends _chunk4QN43TRPcjs.BaseResource {
9529
9680
  constructor(http, pageSize) {
9530
9681
  super(http, {
9531
9682
  key: "services",
@@ -9588,12 +9739,12 @@ var ServicesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9588
9739
  /** Search Service records: bounded contains on name (no vendor free-text search exists);
9589
9740
  * limit defaults to 25, max 500. */
9590
9741
  async search(query, opts) {
9591
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _93 => _93.limit]) });
9742
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _103 => _103.limit]) });
9592
9743
  }
9593
9744
  };
9594
9745
 
9595
9746
  // src/resources/skills.ts
9596
- var SkillsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9747
+ var SkillsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9597
9748
  constructor(http, pageSize) {
9598
9749
  super(http, {
9599
9750
  key: "skills",
@@ -9632,12 +9783,12 @@ var SkillsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9632
9783
  /** Search Skill records: bounded contains on name (no vendor free-text search exists);
9633
9784
  * limit defaults to 25, max 500. */
9634
9785
  async search(query, opts) {
9635
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _94 => _94.limit]) });
9786
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _104 => _104.limit]) });
9636
9787
  }
9637
9788
  };
9638
9789
 
9639
9790
  // src/resources/subscription_periods.ts
9640
- var SubscriptionPeriodsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9791
+ var SubscriptionPeriodsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9641
9792
  constructor(http, pageSize) {
9642
9793
  super(http, {
9643
9794
  key: "subscription_periods",
@@ -9676,7 +9827,7 @@ var SubscriptionPeriodsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9676
9827
  };
9677
9828
 
9678
9829
  // src/resources/subscriptions.ts
9679
- var SubscriptionsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9830
+ var SubscriptionsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9680
9831
  constructor(http, pageSize) {
9681
9832
  super(http, {
9682
9833
  key: "subscriptions",
@@ -9745,7 +9896,7 @@ var SubscriptionsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9745
9896
  };
9746
9897
 
9747
9898
  // src/resources/survey_results.ts
9748
- var SurveyResultsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9899
+ var SurveyResultsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9749
9900
  constructor(http, pageSize) {
9750
9901
  super(http, {
9751
9902
  key: "survey_results",
@@ -9784,7 +9935,7 @@ var SurveyResultsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9784
9935
  };
9785
9936
 
9786
9937
  // src/resources/surveys.ts
9787
- var SurveysResource = class extends _chunkPCLL536Bcjs.BaseResource {
9938
+ var SurveysResource = class extends _chunk4QN43TRPcjs.BaseResource {
9788
9939
  constructor(http, pageSize) {
9789
9940
  super(http, {
9790
9941
  key: "surveys",
@@ -9823,12 +9974,12 @@ var SurveysResource = class extends _chunkPCLL536Bcjs.BaseResource {
9823
9974
  /** Search Survey records: bounded contains on name (no vendor free-text search exists);
9824
9975
  * limit defaults to 25, max 500. */
9825
9976
  async search(query, opts) {
9826
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
9977
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _105 => _105.limit]) });
9827
9978
  }
9828
9979
  };
9829
9980
 
9830
9981
  // src/resources/tag_aliases.ts
9831
- var TagAliasesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9982
+ var TagAliasesResource = class extends _chunk4QN43TRPcjs.BaseResource {
9832
9983
  constructor(http, pageSize) {
9833
9984
  super(http, {
9834
9985
  key: "tag_aliases",
@@ -9885,7 +10036,7 @@ var TagAliasesResource = class extends _chunkPCLL536Bcjs.BaseResource {
9885
10036
  };
9886
10037
 
9887
10038
  // src/resources/tag_groups.ts
9888
- var TagGroupsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10039
+ var TagGroupsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9889
10040
  constructor(http, pageSize) {
9890
10041
  super(http, {
9891
10042
  key: "tag_groups",
@@ -9954,7 +10105,7 @@ var TagGroupsResource = class extends _chunkPCLL536Bcjs.BaseResource {
9954
10105
  };
9955
10106
 
9956
10107
  // src/resources/tags.ts
9957
- var TagsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10108
+ var TagsResource = class extends _chunk4QN43TRPcjs.BaseResource {
9958
10109
  constructor(http, pageSize) {
9959
10110
  super(http, {
9960
10111
  key: "tags",
@@ -10023,7 +10174,7 @@ var TagsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10023
10174
  };
10024
10175
 
10025
10176
  // src/resources/task_secondary_resources.ts
10026
- var TaskSecondaryResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
10177
+ var TaskSecondaryResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
10027
10178
  constructor(http, pageSize) {
10028
10179
  super(http, {
10029
10180
  key: "task_secondary_resources",
@@ -10080,7 +10231,7 @@ var TaskSecondaryResourcesResource = class extends _chunkPCLL536Bcjs.BaseResourc
10080
10231
  };
10081
10232
 
10082
10233
  // src/resources/tasks.ts
10083
- var TasksResource = class extends _chunkPCLL536Bcjs.BaseResource {
10234
+ var TasksResource = class extends _chunk4QN43TRPcjs.BaseResource {
10084
10235
  constructor(http, pageSize) {
10085
10236
  super(http, {
10086
10237
  key: "tasks",
@@ -10139,12 +10290,12 @@ var TasksResource = class extends _chunkPCLL536Bcjs.BaseResource {
10139
10290
  /** Search Task records: bounded contains on title (no vendor free-text search exists);
10140
10291
  * limit defaults to 25, max 500. */
10141
10292
  async search(query, opts) {
10142
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
10293
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _106 => _106.limit]) });
10143
10294
  }
10144
10295
  };
10145
10296
 
10146
10297
  // src/resources/tax_regions.ts
10147
- var TaxRegionsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10298
+ var TaxRegionsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10148
10299
  constructor(http, pageSize) {
10149
10300
  super(http, {
10150
10301
  key: "tax_regions",
@@ -10219,7 +10370,7 @@ var ThresholdInformationResource = class {
10219
10370
  };
10220
10371
 
10221
10372
  // src/resources/ticket_additional_configuration_items.ts
10222
- var TicketAdditionalConfigurationItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10373
+ var TicketAdditionalConfigurationItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10223
10374
  constructor(http, pageSize) {
10224
10375
  super(http, {
10225
10376
  key: "ticket_additional_configuration_items",
@@ -10276,7 +10427,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkPCLL536Bcjs
10276
10427
  };
10277
10428
 
10278
10429
  // src/resources/ticket_additional_contacts.ts
10279
- var TicketAdditionalContactsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10430
+ var TicketAdditionalContactsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10280
10431
  constructor(http, pageSize) {
10281
10432
  super(http, {
10282
10433
  key: "ticket_additional_contacts",
@@ -10333,7 +10484,7 @@ var TicketAdditionalContactsResource = class extends _chunkPCLL536Bcjs.BaseResou
10333
10484
  };
10334
10485
 
10335
10486
  // src/resources/ticket_attachments.ts
10336
- var TicketAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10487
+ var TicketAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10337
10488
  constructor(http, pageSize) {
10338
10489
  super(http, {
10339
10490
  key: "ticket_attachments",
@@ -10395,7 +10546,7 @@ var TicketAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10395
10546
  };
10396
10547
 
10397
10548
  // src/resources/ticket_categories.ts
10398
- var TicketCategoriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
10549
+ var TicketCategoriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
10399
10550
  constructor(http, pageSize) {
10400
10551
  super(http, {
10401
10552
  key: "ticket_categories",
@@ -10449,12 +10600,12 @@ var TicketCategoriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
10449
10600
  /** Search TicketCategory records: bounded contains on name (no vendor free-text search exists);
10450
10601
  * limit defaults to 25, max 500. */
10451
10602
  async search(query, opts) {
10452
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _97 => _97.limit]) });
10603
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _107 => _107.limit]) });
10453
10604
  }
10454
10605
  };
10455
10606
 
10456
10607
  // src/resources/ticket_category_field_defaults.ts
10457
- var TicketCategoryFieldDefaultsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10608
+ var TicketCategoryFieldDefaultsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10458
10609
  constructor(http, pageSize) {
10459
10610
  super(http, {
10460
10611
  key: "ticket_category_field_defaults",
@@ -10496,7 +10647,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkPCLL536Bcjs.BaseRe
10496
10647
  };
10497
10648
 
10498
10649
  // src/resources/ticket_change_request_approvals.ts
10499
- var TicketChangeRequestApprovalsResource = class extends _chunkPCLL536Bcjs.BaseResource {
10650
+ var TicketChangeRequestApprovalsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10500
10651
  constructor(http, pageSize) {
10501
10652
  super(http, {
10502
10653
  key: "ticket_change_request_approvals",
@@ -10556,10 +10707,10 @@ var TicketChangeRequestApprovalsResource = class extends _chunkPCLL536Bcjs.BaseR
10556
10707
  var _crypto = require('crypto');
10557
10708
  var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
10558
10709
  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";
10559
- var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunkPCLL536Bcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
10710
+ var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunk4QN43TRPcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
10560
10711
  async function queryRows(http, resource, filter, operation, retries) {
10561
10712
  const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
10562
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
10713
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
10563
10714
  }
10564
10715
  function sameValue(a, b) {
10565
10716
  if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
@@ -10576,10 +10727,10 @@ function sameValue(a, b) {
10576
10727
  async function readTicket(http, id, retries, operation) {
10577
10728
  try {
10578
10729
  const res = await http.request({ method: "GET", path: `/V1.0/Tickets/${id}`, operation, maxRetries: retries });
10579
- const item = _optionalChain([res, 'optionalAccess', _98 => _98.item]);
10730
+ const item = _optionalChain([res, 'optionalAccess', _108 => _108.item]);
10580
10731
  return _nullishCoalesce(item, () => ( null));
10581
10732
  } catch (e) {
10582
- if (_chunkPCLL536Bcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
10733
+ if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
10583
10734
  throw e;
10584
10735
  }
10585
10736
  }
@@ -10600,7 +10751,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
10600
10751
  }
10601
10752
  }
10602
10753
  const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
10603
- if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
10754
+ if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
10604
10755
  const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
10605
10756
  if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
10606
10757
  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") });
@@ -10621,7 +10772,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
10621
10772
  const facts = {
10622
10773
  closedStatus: { closedIds: closedStatus.closedIds, source: closedStatus.source, note: closedStatus.note },
10623
10774
  sourceTicketId,
10624
- sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _99 => _99.companyID]), () => ( null)),
10775
+ sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _109 => _109.companyID]), () => ( null)),
10625
10776
  targetCompanyID: _nullishCoalesce(target.companyID, () => ( null)),
10626
10777
  companyChanged: origin === null ? null : origin.companyID !== target.companyID,
10627
10778
  contractChanged: origin === null ? null : (_nullishCoalesce(origin.contractID, () => ( null))) !== (_nullishCoalesce(target.contractID, () => ( null)))
@@ -10643,17 +10794,17 @@ async function assertNoTwin(ctx, payload) {
10643
10794
  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 });
10644
10795
  }
10645
10796
  }
10646
- var statusOf = (e) => _chunkPCLL536Bcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
10797
+ var statusOf = (e) => _chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
10647
10798
  async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
10648
10799
  const op = spec.operation;
10649
- const sourceId = Number(_chunkPCLL536Bcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
10650
- const toTicketId = Number(_chunkPCLL536Bcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
10800
+ const sourceId = Number(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
10801
+ const toTicketId = Number(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
10651
10802
  if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
10652
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
10803
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
10653
10804
  }
10654
10805
  const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
10655
10806
  if (opts.dryRun === true) {
10656
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
10807
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
10657
10808
  {
10658
10809
  operation: op,
10659
10810
  method: "POST",
@@ -10678,22 +10829,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
10678
10829
  let newId;
10679
10830
  try {
10680
10831
  const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
10681
- newId = Number(_chunkPCLL536Bcjs.unwrapOperation.call(void 0, created, op).id);
10832
+ newId = Number(_chunk4QN43TRPcjs.unwrapOperation.call(void 0, created, op).id);
10682
10833
  } catch (e) {
10683
10834
  const status = statusOf(e);
10684
10835
  if (status !== void 0 && status >= 400 && status < 500) {
10685
- throw new (0, _chunkPCLL536Bcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
10836
+ throw new (0, _chunk4QN43TRPcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
10686
10837
  }
10687
- throw new (0, _chunkPCLL536Bcjs.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 } });
10838
+ throw new (0, _chunk4QN43TRPcjs.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 } });
10688
10839
  }
10689
10840
  const rollback = async (code, message) => {
10690
10841
  try {
10691
10842
  await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
10692
10843
  } catch (re) {
10693
10844
  const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
10694
- throw new (0, _chunkPCLL536Bcjs.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 } });
10845
+ throw new (0, _chunk4QN43TRPcjs.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 } });
10695
10846
  }
10696
- throw new (0, _chunkPCLL536Bcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
10847
+ throw new (0, _chunk4QN43TRPcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
10697
10848
  };
10698
10849
  const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
10699
10850
  if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
@@ -10722,33 +10873,33 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
10722
10873
  };
10723
10874
  }
10724
10875
  if (status === void 0) {
10725
- throw new (0, _chunkPCLL536Bcjs.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 } });
10876
+ throw new (0, _chunk4QN43TRPcjs.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 } });
10726
10877
  }
10727
10878
  return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
10728
10879
  }
10729
10880
  return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
10730
10881
  }
10731
10882
  function uiLinkFor(http, entity, id) {
10732
- return _nullishCoalesce(_chunkPCLL536Bcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
10883
+ return _nullishCoalesce(_chunk4QN43TRPcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
10733
10884
  }
10734
10885
 
10735
10886
  // src/resources/special/ticket_charges.ts
10736
- var OP4 = "ticket_charges.moveToTicket";
10887
+ var OP5 = "ticket_charges.moveToTicket";
10737
10888
  var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
10738
10889
  var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
10739
10890
  async function readCharge(http, id, retries) {
10740
- const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP4, retries);
10891
+ const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP5, retries);
10741
10892
  return _nullishCoalesce(rows[0], () => ( null));
10742
10893
  }
10743
10894
  async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
10744
10895
  if (source.isBilled === true) {
10745
- throw refuse("MOVE_BLOCKED_BILLED", `${OP4}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP4, {
10896
+ throw refuse("MOVE_BLOCKED_BILLED", `${OP5}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP5, {
10746
10897
  manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
10747
10898
  });
10748
10899
  }
10749
10900
  }
10750
10901
  var SPEC = {
10751
- operation: OP4,
10902
+ operation: OP5,
10752
10903
  entity: "ticket_charge",
10753
10904
  readSource: readCharge,
10754
10905
  sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
@@ -10784,7 +10935,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
10784
10935
  }
10785
10936
 
10786
10937
  // src/resources/ticket_charges.ts
10787
- var TicketChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
10938
+ var TicketChargesResource = class extends _chunk4QN43TRPcjs.BaseResource {
10788
10939
  constructor(http, pageSize) {
10789
10940
  super(http, {
10790
10941
  key: "ticket_charges",
@@ -10850,7 +11001,7 @@ var TicketChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
10850
11001
  /** Search TicketCharge records: bounded contains on name (no vendor free-text search exists);
10851
11002
  * limit defaults to 25, max 500. */
10852
11003
  async search(query, opts) {
10853
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _100 => _100.limit]) });
11004
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _110 => _110.limit]) });
10854
11005
  }
10855
11006
  /** Node-parity special op (hand-written in src/resources/special/ticket_charges.ts). */
10856
11007
  moveToTicket(sourceId, toTicketId, opts = {}) {
@@ -10859,7 +11010,7 @@ var TicketChargesResource = class extends _chunkPCLL536Bcjs.BaseResource {
10859
11010
  };
10860
11011
 
10861
11012
  // src/resources/ticket_checklist_items.ts
10862
- var TicketChecklistItemsResource = class extends _chunkPCLL536Bcjs.BaseResource {
11013
+ var TicketChecklistItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
10863
11014
  constructor(http, pageSize) {
10864
11015
  super(http, {
10865
11016
  key: "ticket_checklist_items",
@@ -10925,7 +11076,7 @@ var TicketChecklistItemsResource = class extends _chunkPCLL536Bcjs.BaseResource
10925
11076
  };
10926
11077
 
10927
11078
  // src/resources/ticket_checklist_libraries.ts
10928
- var TicketChecklistLibrariesResource = class extends _chunkPCLL536Bcjs.BaseResource {
11079
+ var TicketChecklistLibrariesResource = class extends _chunk4QN43TRPcjs.BaseResource {
10929
11080
  constructor(http, pageSize) {
10930
11081
  super(http, {
10931
11082
  key: "ticket_checklist_libraries",
@@ -10949,9 +11100,9 @@ var TicketChecklistLibrariesResource = class extends _chunkPCLL536Bcjs.BaseResou
10949
11100
  * `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
10950
11101
  * surface — no documents read op — and never issues the POST). */
10951
11102
  async attachToDocument(documentID, data, opts = {}) {
10952
- const n = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, documentID, "documentID");
11103
+ const n = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, documentID, "documentID");
10953
11104
  if (opts.dryRun === true) {
10954
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
11105
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
10955
11106
  operation: "ticket_checklist_libraries.attachToDocument",
10956
11107
  method: "POST",
10957
11108
  path: `/V1.0/Documents/${n}/ChecklistLibraries`,
@@ -10969,7 +11120,7 @@ var TicketChecklistLibrariesResource = class extends _chunkPCLL536Bcjs.BaseResou
10969
11120
  operation: "ticket_checklist_libraries.attachToDocument",
10970
11121
  maxRetries: opts.maxRetries
10971
11122
  });
10972
- return _chunkPCLL536Bcjs.unwrapOperation.call(void 0, res);
11123
+ return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
10973
11124
  }
10974
11125
  /** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
10975
11126
  * from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
@@ -10985,7 +11136,7 @@ var TicketChecklistLibrariesResource = class extends _chunkPCLL536Bcjs.BaseResou
10985
11136
  };
10986
11137
 
10987
11138
  // src/resources/ticket_history.ts
10988
- var TicketHistoryResource = class extends _chunkPCLL536Bcjs.BaseResource {
11139
+ var TicketHistoryResource = class extends _chunk4QN43TRPcjs.BaseResource {
10989
11140
  constructor(http, pageSize) {
10990
11141
  super(http, {
10991
11142
  key: "ticket_history",
@@ -11024,7 +11175,7 @@ var TicketHistoryResource = class extends _chunkPCLL536Bcjs.BaseResource {
11024
11175
  };
11025
11176
 
11026
11177
  // src/resources/ticket_note_attachments.ts
11027
- var TicketNoteAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
11178
+ var TicketNoteAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
11028
11179
  constructor(http, pageSize) {
11029
11180
  super(http, {
11030
11181
  key: "ticket_note_attachments",
@@ -11086,7 +11237,7 @@ var TicketNoteAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource
11086
11237
  };
11087
11238
 
11088
11239
  // src/resources/ticket_notes.ts
11089
- var TicketNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
11240
+ var TicketNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
11090
11241
  constructor(http, pageSize) {
11091
11242
  super(http, {
11092
11243
  key: "ticket_notes",
@@ -11145,7 +11296,7 @@ var TicketNotesResource = class extends _chunkPCLL536Bcjs.BaseResource {
11145
11296
  };
11146
11297
 
11147
11298
  // src/resources/ticket_note_webhooks.ts
11148
- var TicketNoteWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
11299
+ var TicketNoteWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
11149
11300
  constructor(http, pageSize) {
11150
11301
  super(http, {
11151
11302
  key: "ticket_note_webhooks",
@@ -11216,12 +11367,12 @@ var TicketNoteWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
11216
11367
  /** Search TicketNoteWebhook records: bounded contains on name (no vendor free-text search exists);
11217
11368
  * limit defaults to 25, max 500. */
11218
11369
  async search(query, opts) {
11219
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _101 => _101.limit]) });
11370
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _111 => _111.limit]) });
11220
11371
  }
11221
11372
  };
11222
11373
 
11223
11374
  // src/resources/ticket_secondary_resources.ts
11224
- var TicketSecondaryResourcesResource = class extends _chunkPCLL536Bcjs.BaseResource {
11375
+ var TicketSecondaryResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
11225
11376
  constructor(http, pageSize) {
11226
11377
  super(http, {
11227
11378
  key: "ticket_secondary_resources",
@@ -11286,9 +11437,9 @@ async function fetchTicket(http, id, operation) {
11286
11437
  });
11287
11438
  const body = res;
11288
11439
  if (body === null || !("item" in body)) {
11289
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11440
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11290
11441
  }
11291
- if (body.item === null || body.item === void 0) throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11442
+ if (body.item === null || body.item === void 0) throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
11292
11443
  return body.item;
11293
11444
  }
11294
11445
  async function ticketQueryItems(http, path, filter, maxRecords, operation) {
@@ -11299,7 +11450,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
11299
11450
  body: { MaxRecords: maxRecords, filter },
11300
11451
  operation
11301
11452
  });
11302
- return _chunkPCLL536Bcjs.unwrapItems.call(void 0, res).items;
11453
+ return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
11303
11454
  }
11304
11455
  function truncate(text, limit) {
11305
11456
  const full = _nullishCoalesce(text, () => ( ""));
@@ -11309,26 +11460,26 @@ function truncate(text, limit) {
11309
11460
 
11310
11461
  // src/resources/special/tickets/childRead.ts
11311
11462
  function isRouteUnavailable(err) {
11312
- return _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
11463
+ return _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
11313
11464
  }
11314
11465
  function routeFact(route, path, err) {
11315
11466
  return {
11316
11467
  route,
11317
11468
  path,
11318
- httpStatus: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
11469
+ httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
11319
11470
  };
11320
11471
  }
11321
11472
  function childDeclaresQuery(resourceKey) {
11322
- return _chunkQXUN2VCJcjs.CAPABILITIES.some(
11473
+ return _chunkSP2SJJZXcjs.CAPABILITIES.some(
11323
11474
  (c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
11324
11475
  );
11325
11476
  }
11326
11477
  function planScopedPath(resourceKey, ticketId) {
11327
11478
  if (!childDeclaresQuery(resourceKey)) return null;
11328
- const entry = _chunkPCLL536Bcjs.RELATIONSHIP_MAP[resourceKey];
11479
+ const entry = _chunk4QN43TRPcjs.RELATIONSHIP_MAP[resourceKey];
11329
11480
  const parent = entry === void 0 ? null : entry.parent;
11330
11481
  if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
11331
- const parentPath = _optionalChain([_chunkPCLL536Bcjs.RELATIONSHIP_MAP, 'access', _102 => _102[parent.resource], 'optionalAccess', _103 => _103.path]);
11482
+ const parentPath = _optionalChain([_chunk4QN43TRPcjs.RELATIONSHIP_MAP, 'access', _112 => _112[parent.resource], 'optionalAccess', _113 => _113.path]);
11332
11483
  if (parentPath === null || parentPath === void 0) return null;
11333
11484
  return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
11334
11485
  }
@@ -11367,14 +11518,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
11367
11518
  break;
11368
11519
  }
11369
11520
  const body = await http.request({ method: "GET", path: target, operation });
11370
- const { items: pageItems, pageDetails } = _chunkPCLL536Bcjs.unwrapItems.call(void 0, body, operation);
11521
+ const { items: pageItems, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, body, operation);
11371
11522
  nextCursor = pageDetails.nextPageUrl;
11372
11523
  pages += 1;
11373
11524
  const window = pageItems.slice(0, Math.max(0, limit - items.length));
11374
11525
  for (const row of window) if (accept(row)) items.push(row);
11375
11526
  if (items.length >= limit) break;
11376
11527
  if (nextCursor === null || pageItems.length === 0) break;
11377
- target = _chunkPCLL536Bcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
11528
+ target = _chunk4QN43TRPcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
11378
11529
  }
11379
11530
  const capped = items.length >= limit || guard && nextCursor !== null;
11380
11531
  return { items, capped };
@@ -11407,7 +11558,7 @@ var MS = 864e5;
11407
11558
  var SLA_PAGE = 100;
11408
11559
  async function slaHealthCheck(_resource, id, opts = {}, http) {
11409
11560
  void opts;
11410
- const ticketId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
11561
+ const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
11411
11562
  await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
11412
11563
  const rows = await ticketQueryItems(
11413
11564
  http,
@@ -11417,12 +11568,12 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
11417
11568
  "tickets.slaHealthCheck"
11418
11569
  );
11419
11570
  const slas = rows.map((row) => {
11420
- const bool = (v) => typeof v === "boolean" ? v : null;
11571
+ const bool2 = (v) => typeof v === "boolean" ? v : null;
11421
11572
  const num2 = (v) => typeof v === "number" ? v : null;
11422
11573
  const milestones = [
11423
- { name: "firstResponse", met: bool(row.isFirstResponseMet), elapsedHours: num2(row.firstResponseElapsedHours) },
11424
- { name: "resolution", met: bool(row.isResolutionMet), elapsedHours: num2(row.resolutionElapsedHours) },
11425
- { name: "resolutionPlan", met: bool(row.isResolutionPlanMet), elapsedHours: num2(row.resolutionPlanElapsedHours) }
11574
+ { name: "firstResponse", met: bool2(row.isFirstResponseMet), elapsedHours: num2(row.firstResponseElapsedHours) },
11575
+ { name: "resolution", met: bool2(row.isResolutionMet), elapsedHours: num2(row.resolutionElapsedHours) },
11576
+ { name: "resolutionPlan", met: bool2(row.isResolutionPlanMet), elapsedHours: num2(row.resolutionPlanElapsedHours) }
11426
11577
  ];
11427
11578
  return { id: Number(row.id), name: _nullishCoalesce(row.serviceLevelAgreementName, () => ( null)), milestones };
11428
11579
  });
@@ -11432,19 +11583,19 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
11432
11583
  async function summary(_resource, id, opts = {}, http) {
11433
11584
  const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
11434
11585
  if (!Number.isInteger(limit) || limit < 1) {
11435
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
11586
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
11436
11587
  }
11437
- const ticketId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
11588
+ const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
11438
11589
  const ticket = await fetchTicket(http, ticketId, "tickets.summary");
11439
11590
  const desc = truncate(ticket.description, limit);
11440
11591
  const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
11441
11592
  const ageDays = typeof ticket.createDate === "string" && ticket.createDate !== "" ? Math.max(0, Math.floor((now.getTime() - Date.parse(ticket.createDate)) / MS)) : null;
11442
11593
  const pick = (v) => typeof v === "number" ? v : null;
11443
- const str = (v) => typeof v === "string" && v !== "" ? v : null;
11594
+ const str2 = (v) => typeof v === "string" && v !== "" ? v : null;
11444
11595
  return {
11445
11596
  ticketId,
11446
- ticketNumber: str(ticket.ticketNumber),
11447
- title: str(ticket.title),
11597
+ ticketNumber: str2(ticket.ticketNumber),
11598
+ title: str2(ticket.title),
11448
11599
  description: desc.value,
11449
11600
  descriptionLength: desc.length,
11450
11601
  descriptionTruncated: desc.truncated,
@@ -11454,8 +11605,8 @@ async function summary(_resource, id, opts = {}, http) {
11454
11605
  contactID: pick(ticket.contactID),
11455
11606
  assignedResourceID: pick(ticket.assignedResourceID),
11456
11607
  projectID: pick(ticket.projectID),
11457
- createDate: str(ticket.createDate),
11458
- dueDateTime: str(ticket.dueDateTime),
11608
+ createDate: str2(ticket.createDate),
11609
+ dueDateTime: str2(ticket.dueDateTime),
11459
11610
  ageDays
11460
11611
  };
11461
11612
  }
@@ -11463,11 +11614,11 @@ async function summary(_resource, id, opts = {}, http) {
11463
11614
  // src/resources/special/tickets/timeline.ts
11464
11615
  function validateTimelineLimits(opts) {
11465
11616
  const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
11466
- if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
11617
+ if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
11467
11618
  const bounded = Math.min(limit, 500);
11468
11619
  const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
11469
11620
  if (!Number.isInteger(textLimit) || textLimit < 1) {
11470
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
11621
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
11471
11622
  }
11472
11623
  return { bounded, textLimit };
11473
11624
  }
@@ -11519,7 +11670,7 @@ function compareEventDates(a, b) {
11519
11670
  }
11520
11671
  async function timeline(_resource, id, opts = {}, http) {
11521
11672
  const { bounded, textLimit } = validateTimelineLimits(opts);
11522
- const ticketId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
11673
+ const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
11523
11674
  await fetchTicket(http, ticketId, "tickets.timeline");
11524
11675
  const dateFilters = (field) => {
11525
11676
  const f = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -11559,7 +11710,7 @@ async function timeline(_resource, id, opts = {}, http) {
11559
11710
  }
11560
11711
 
11561
11712
  // src/resources/special/tickets/errors.ts
11562
- var QueueRequiredError = class extends _chunkPCLL536Bcjs.AutotaskError {
11713
+ var QueueRequiredError = class extends _chunk4QN43TRPcjs.AutotaskError {
11563
11714
  constructor(message, options = {}) {
11564
11715
  super(message, {
11565
11716
  code: "QUEUE_REQUIRED",
@@ -11570,13 +11721,13 @@ var QueueRequiredError = class extends _chunkPCLL536Bcjs.AutotaskError {
11570
11721
  this.name = "QueueRequiredError";
11571
11722
  }
11572
11723
  };
11573
- var TicketResourceInvalidError = class extends _chunkPCLL536Bcjs.AutotaskError {
11724
+ var TicketResourceInvalidError = class extends _chunk4QN43TRPcjs.AutotaskError {
11574
11725
  constructor(message, options = {}) {
11575
11726
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
11576
11727
  this.name = "TicketResourceInvalidError";
11577
11728
  }
11578
11729
  };
11579
- var TicketCreateValidationFailedError = class extends _chunkPCLL536Bcjs.AutotaskError {
11730
+ var TicketCreateValidationFailedError = class extends _chunk4QN43TRPcjs.AutotaskError {
11580
11731
  /** The vendor-named fields (empty when the 500 body named nothing parseable). */
11581
11732
 
11582
11733
  constructor(message, vendorFields, options = {}) {
@@ -11585,7 +11736,7 @@ var TicketCreateValidationFailedError = class extends _chunkPCLL536Bcjs.Autotask
11585
11736
  this.vendorFields = vendorFields;
11586
11737
  }
11587
11738
  };
11588
- var StatusUnknownError = class extends _chunkPCLL536Bcjs.AutotaskError {
11739
+ var StatusUnknownError = class extends _chunk4QN43TRPcjs.AutotaskError {
11589
11740
  /** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
11590
11741
 
11591
11742
  constructor(message, options = {}) {
@@ -11599,7 +11750,7 @@ var StatusUnknownError = class extends _chunkPCLL536Bcjs.AutotaskError {
11599
11750
  this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
11600
11751
  }
11601
11752
  };
11602
- var StatusFieldsRequiredError = class extends _chunkPCLL536Bcjs.AutotaskError {
11753
+ var StatusFieldsRequiredError = class extends _chunk4QN43TRPcjs.AutotaskError {
11603
11754
 
11604
11755
 
11605
11756
 
@@ -11622,21 +11773,21 @@ function isPositiveInt(v) {
11622
11773
  return typeof v === "number" && Number.isInteger(v) && v > 0;
11623
11774
  }
11624
11775
  function namedVendorFields(err) {
11625
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
11626
- const entries = _nullishCoalesce(_chunkPCLL536Bcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
11776
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
11777
+ const entries = _nullishCoalesce(_chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
11627
11778
  const out = /* @__PURE__ */ new Set();
11628
11779
  for (const e of entries) if (e.field !== void 0) out.add(e.field);
11629
11780
  return [...out];
11630
11781
  }
11631
11782
  function vendorDetailOf(err) {
11632
- return _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? _chunkPCLL536Bcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
11783
+ return _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? _chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
11633
11784
  }
11634
11785
  async function fetchItem(http, path, operation, readOpts) {
11635
- const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _104 => _104.maxRetries]) });
11786
+ const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _114 => _114.maxRetries]) });
11636
11787
  return unwrapItemOrNull(res);
11637
11788
  }
11638
11789
  async function fetchItemUnredacted(http, path, operation, readOpts) {
11639
- const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _105 => _105.maxRetries]) });
11790
+ const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _115 => _115.maxRetries]) });
11640
11791
  return unwrapItemOrNull(res);
11641
11792
  }
11642
11793
  function unwrapItemOrNull(res) {
@@ -11650,8 +11801,8 @@ function operationId(res) {
11650
11801
  return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
11651
11802
  }
11652
11803
  function discoveryMerge(err, body, defaults) {
11653
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
11654
- const entries = _chunkPCLL536Bcjs.parseVendorErrors.call(void 0, err.vendorError);
11804
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
11805
+ const entries = _chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError);
11655
11806
  if (entries === void 0) return null;
11656
11807
  for (const entry of entries) {
11657
11808
  const field = entry.field;
@@ -11663,7 +11814,7 @@ function discoveryMerge(err, body, defaults) {
11663
11814
  }
11664
11815
  function stepErrorText(code, err) {
11665
11816
  const detail = vendorDetailOf(err);
11666
- const base = _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
11817
+ const base = _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
11667
11818
  return detail ? `${code}: ${detail}` : `${code}: ${base}`;
11668
11819
  }
11669
11820
 
@@ -11675,43 +11826,43 @@ var DEFAULT_PUBLISH = 1;
11675
11826
  var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
11676
11827
  var SAFE_TICKET_CREATE_DEFAULTS = {};
11677
11828
  function validateOpenInput(params, note, assign) {
11678
- const companyID = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _106 => _106.companyID]), "params.companyID");
11679
- const title = _optionalChain([params, 'optionalAccess', _107 => _107.title]);
11829
+ const companyID = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _116 => _116.companyID]), "params.companyID");
11830
+ const title = _optionalChain([params, 'optionalAccess', _117 => _117.title]);
11680
11831
  if (typeof title !== "string" || title.trim() === "") {
11681
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
11832
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
11682
11833
  }
11683
11834
  const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
11684
11835
  const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
11685
11836
  if (!isPositiveInt(priority)) {
11686
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
11837
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
11687
11838
  }
11688
11839
  if (!isPositiveInt(status)) {
11689
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
11840
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
11690
11841
  }
11691
11842
  if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
11692
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
11843
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
11693
11844
  }
11694
11845
  if (note !== void 0) {
11695
11846
  if (typeof note.description !== "string" || note.description.trim() === "") {
11696
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
11847
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
11697
11848
  }
11698
11849
  if (typeof note.title !== "string" || note.title.trim() === "") {
11699
- throw new (0, _chunkPCLL536Bcjs.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 });
11850
+ throw new (0, _chunk4QN43TRPcjs.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 });
11700
11851
  }
11701
11852
  if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
11702
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
11853
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
11703
11854
  }
11704
11855
  if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
11705
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
11856
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
11706
11857
  }
11707
11858
  }
11708
- const assignee = assign === void 0 ? void 0 : _chunkPCLL536Bcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
11859
+ const assignee = assign === void 0 ? void 0 : _chunk4QN43TRPcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
11709
11860
  if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
11710
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
11861
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
11711
11862
  }
11712
- const roleID = _optionalChain([assign, 'optionalAccess', _108 => _108.roleID]);
11863
+ const roleID = _optionalChain([assign, 'optionalAccess', _118 => _118.roleID]);
11713
11864
  if (assign !== void 0 && !isPositiveInt(roleID)) {
11714
- throw new (0, _chunkPCLL536Bcjs.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 });
11865
+ throw new (0, _chunk4QN43TRPcjs.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 });
11715
11866
  }
11716
11867
  return { companyID, title, priority, status, assignee, roleID };
11717
11868
  }
@@ -11740,7 +11891,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
11740
11891
  if (assign !== void 0) {
11741
11892
  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).`);
11742
11893
  }
11743
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
11894
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
11744
11895
  {
11745
11896
  operation: OP_OPEN,
11746
11897
  method: "POST",
@@ -11780,8 +11931,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
11780
11931
  `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}` : ""}`,
11781
11932
  {
11782
11933
  operation: OP_OPEN,
11783
- httpStatus: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11784
- vendorError: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
11934
+ httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11935
+ vendorError: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
11785
11936
  }
11786
11937
  );
11787
11938
  }
@@ -11796,8 +11947,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
11796
11947
  named,
11797
11948
  {
11798
11949
  operation: OP_OPEN,
11799
- httpStatus: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11800
- vendorError: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
11950
+ httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
11951
+ vendorError: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
11801
11952
  resourceIds: [companyID],
11802
11953
  details: { idRefs: [{ entity: "company", id: companyID }] }
11803
11954
  }
@@ -11822,10 +11973,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
11822
11973
  try {
11823
11974
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
11824
11975
  if (current === null) {
11825
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
11976
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
11826
11977
  }
11827
11978
  ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
11828
- const merged = _chunkPCLL536Bcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
11979
+ const merged = _chunk4QN43TRPcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
11829
11980
  merged.id = ticketId;
11830
11981
  await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
11831
11982
  assigned = true;
@@ -11889,17 +12040,17 @@ async function guardTargetStatus(resource, http, targetStatus) {
11889
12040
  const ids2 = await readLiveStatusSet(resource);
11890
12041
  if (ids2.size > 0) liveStatus = ids2;
11891
12042
  } catch (err) {
11892
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
12043
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
11893
12044
  }
11894
12045
  if (liveStatus !== null && !liveStatus.has(targetStatus)) {
11895
- _optionalChain([http, 'access', _109 => _109.fieldCache, 'optionalAccess', _110 => _110.invalidate, 'call', _111 => _111("tickets")]);
12046
+ _optionalChain([http, 'access', _119 => _119.fieldCache, 'optionalAccess', _120 => _120.invalidate, 'call', _121 => _121("tickets")]);
11896
12047
  let freshStatus = null;
11897
12048
  let reReadFailed = false;
11898
12049
  try {
11899
12050
  const freshIds = await readLiveStatusSet(resource);
11900
12051
  if (freshIds.size > 0) freshStatus = freshIds;
11901
12052
  } catch (err) {
11902
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
12053
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
11903
12054
  freshStatus = null;
11904
12055
  reReadFailed = true;
11905
12056
  }
@@ -11917,7 +12068,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
11917
12068
  return { guardDegraded: liveStatus === null };
11918
12069
  }
11919
12070
  function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
11920
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
12071
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
11921
12072
  {
11922
12073
  operation: OP_STATUS,
11923
12074
  method: "PUT",
@@ -11948,7 +12099,7 @@ function resolveMergeData(ticketId, targetStatus, previousStatus, current, field
11948
12099
  for (const field of mapEntry.requiredFields) {
11949
12100
  if (mergeData[field] !== void 0) continue;
11950
12101
  if (current[field] !== null && current[field] !== void 0) continue;
11951
- const safe = _optionalChain([mapEntry, 'access', _112 => _112.safeDefaults, 'optionalAccess', _113 => _113[field]]);
12102
+ const safe = _optionalChain([mapEntry, 'access', _122 => _122.safeDefaults, 'optionalAccess', _123 => _123[field]]);
11952
12103
  if (safe === void 0) {
11953
12104
  throw new StatusFieldsRequiredError(
11954
12105
  `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`,
@@ -11971,7 +12122,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
11971
12122
  if (mapEntry === void 0) {
11972
12123
  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).`);
11973
12124
  }
11974
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
12125
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
11975
12126
  {
11976
12127
  operation: OP_STATUS,
11977
12128
  method: "PUT",
@@ -11990,8 +12141,8 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
11990
12141
  );
11991
12142
  }
11992
12143
  async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
11993
- const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _114 => _114.safeDefaults]), () => ( {}));
11994
- const body = _chunkPCLL536Bcjs.mergePartialBody.call(void 0, current, mergeData);
12144
+ const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _124 => _124.safeDefaults]), () => ( {}));
12145
+ const body = _chunk4QN43TRPcjs.mergePartialBody.call(void 0, current, mergeData);
11995
12146
  body.id = ticketId;
11996
12147
  let merges = 0;
11997
12148
  for (; ; ) {
@@ -12015,8 +12166,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
12015
12166
  { vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
12016
12167
  {
12017
12168
  operation: OP_STATUS,
12018
- httpStatus: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
12019
- vendorError: _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
12169
+ httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
12170
+ vendorError: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
12020
12171
  resourceIds: [ticketId],
12021
12172
  details: { idRefs: [{ entity: "ticket", id: ticketId }] }
12022
12173
  }
@@ -12029,7 +12180,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
12029
12180
  async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
12030
12181
  const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
12031
12182
  if (verify === null) {
12032
- throw new (0, _chunkPCLL536Bcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
12183
+ throw new (0, _chunk4QN43TRPcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
12033
12184
  code: "INVALID_RESPONSE",
12034
12185
  category: "server",
12035
12186
  operation: OP_STATUS,
@@ -12039,7 +12190,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
12039
12190
  }
12040
12191
  const finalStatus = typeof verify.status === "number" ? verify.status : null;
12041
12192
  if (finalStatus !== targetStatus) {
12042
- throw new (0, _chunkPCLL536Bcjs.AutotaskError)(
12193
+ throw new (0, _chunk4QN43TRPcjs.AutotaskError)(
12043
12194
  `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)`,
12044
12195
  {
12045
12196
  code: "INVALID_RESPONSE",
@@ -12054,17 +12205,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
12054
12205
  }
12055
12206
  }
12056
12207
  async function changeStatus(resource, id, targetStatus, fields, opts, http) {
12057
- const ticketId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
12208
+ const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
12058
12209
  if (!isPositiveInt(targetStatus)) {
12059
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
12210
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
12060
12211
  }
12061
12212
  const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
12062
12213
  if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
12063
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
12214
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
12064
12215
  }
12065
12216
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
12066
12217
  if (current === null) {
12067
- throw new (0, _chunkPCLL536Bcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
12218
+ throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
12068
12219
  }
12069
12220
  const previousStatus = typeof current.status === "number" ? current.status : null;
12070
12221
  if (previousStatus === targetStatus) {
@@ -12084,7 +12235,7 @@ var DEFAULT_PART_LIMIT = 50;
12084
12235
  function partLimit(value, name) {
12085
12236
  const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
12086
12237
  if (!Number.isInteger(n) || n < 1) {
12087
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
12238
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
12088
12239
  }
12089
12240
  return n;
12090
12241
  }
@@ -12097,13 +12248,13 @@ function servedTextRecord(row, textField, limit) {
12097
12248
  return out;
12098
12249
  }
12099
12250
  async function addCompositeNames(http, ctx, entriesPart, result, opts) {
12100
- const builder = _chunkPCLL536Bcjs.createNamePlan.call(void 0, _chunkPCLL536Bcjs.TICKET_LABEL_FIELDS);
12251
+ const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS);
12101
12252
  const t = ctx.ticket;
12102
12253
  builder.addResource(t["creatorResourceID"]);
12103
12254
  builder.addFk("contract", t["contractID"]);
12104
12255
  builder.addFk("billingCode", t["billingCodeID"]);
12105
12256
  builder.addFk("role", t["assignedResourceRoleID"]);
12106
- const ticketLobPointer = _chunkPCLL536Bcjs.vendorId.call(void 0, t["organizationalLevelAssociationID"]);
12257
+ const ticketLobPointer = _chunk4QN43TRPcjs.vendorId.call(void 0, t["organizationalLevelAssociationID"]);
12107
12258
  if (ticketLobPointer !== void 0) {
12108
12259
  builder.addLineOfBusiness(ticketLobPointer, { source: "ticket" });
12109
12260
  } else {
@@ -12115,20 +12266,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
12115
12266
  builder.addFk("billingCode", e["billingCodeID"]);
12116
12267
  builder.addFk("contract", e["contractID"]);
12117
12268
  }
12118
- const names = await _chunkPCLL536Bcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
12269
+ const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
12119
12270
  const ticketRow = { ...ctx.ticket };
12120
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
12121
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
12122
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
12123
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
12124
- for (const f of _chunkPCLL536Bcjs.TICKET_LABEL_FIELDS) _chunkPCLL536Bcjs.addLabelSibling.call(void 0, ticketRow, f, names);
12271
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
12272
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
12273
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
12274
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
12275
+ for (const f of _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS) _chunk4QN43TRPcjs.addLabelSibling.call(void 0, ticketRow, f, names);
12125
12276
  result.ticket = ticketRow;
12126
12277
  result.timeEntries.items = entriesPart.items.map((e) => {
12127
12278
  const row = { ...e };
12128
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
12129
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
12130
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
12131
- _chunkPCLL536Bcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
12279
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
12280
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
12281
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
12282
+ _chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
12132
12283
  return row;
12133
12284
  });
12134
12285
  result.names = names.section;
@@ -12144,7 +12295,7 @@ async function fullContext(resource, id, opts = {}, http) {
12144
12295
  const noteLimit = partLimit(opts.noteLimit, "noteLimit");
12145
12296
  const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
12146
12297
  const textLimit = partLimit(opts.textLimit, "textLimit");
12147
- const ticketId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
12298
+ const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
12148
12299
  const ctx = await resource.getContext(ticketId);
12149
12300
  const op = "tickets.fullContext";
12150
12301
  const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -12202,7 +12353,7 @@ async function fullContext(resource, id, opts = {}, http) {
12202
12353
  }
12203
12354
 
12204
12355
  // src/resources/special/tickets/forResource.ts
12205
- var OP5 = "tickets.forResource";
12356
+ var OP6 = "tickets.forResource";
12206
12357
  var TICKET_CHUNK = 100;
12207
12358
  var LIMIT_DEFAULT = 100;
12208
12359
  var LIMIT_MAX = 500;
@@ -12211,7 +12362,7 @@ var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResource
12211
12362
  function positiveId2(value, name) {
12212
12363
  const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
12213
12364
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
12214
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP5}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP5 });
12365
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP6 });
12215
12366
  }
12216
12367
  return n;
12217
12368
  }
@@ -12221,28 +12372,28 @@ async function ticketPage(http, filter, maxRecords, fields) {
12221
12372
  idempotent: true,
12222
12373
  path: "/V1.0/Tickets/query",
12223
12374
  body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
12224
- operation: OP5
12375
+ operation: OP6
12225
12376
  });
12226
- const page = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, OP5);
12377
+ const page = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, OP6);
12227
12378
  return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
12228
12379
  }
12229
12380
  async function forResource(_resource, resourceIDIn, http, opts = {}) {
12230
- if (opts === null || typeof opts !== "object") throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP5}: opts must be an object`, { operation: OP5 });
12381
+ if (opts === null || typeof opts !== "object") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: opts must be an object`, { operation: OP6 });
12231
12382
  const resourceID = positiveId2(resourceIDIn, "resourceID");
12232
12383
  const scope = _nullishCoalesce(opts.scope, () => ( "both"));
12233
12384
  if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
12234
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP5}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP5 });
12385
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP6 });
12235
12386
  }
12236
12387
  if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
12237
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP5}: openOnly must be a boolean`, { operation: OP5 });
12388
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: openOnly must be a boolean`, { operation: OP6 });
12238
12389
  }
12239
12390
  const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
12240
12391
  if (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX) {
12241
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP5}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP5 });
12392
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP6 });
12242
12393
  }
12243
12394
  const includeFields = _nullishCoalesce(opts.includeFields, () => ( []));
12244
12395
  if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
12245
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP5}: includeFields must be a list of field names`, { operation: OP5 });
12396
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: includeFields must be a list of field names`, { operation: OP6 });
12246
12397
  }
12247
12398
  const openOnly = opts.openOnly === true;
12248
12399
  const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS2, ...includeFields])];
@@ -12257,9 +12408,9 @@ async function forResource(_resource, resourceIDIn, http, opts = {}) {
12257
12408
  idempotent: true,
12258
12409
  path: "/V1.0/TicketSecondaryResources/query",
12259
12410
  body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
12260
- operation: OP5
12411
+ operation: OP6
12261
12412
  });
12262
- const page = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, OP5);
12413
+ const page = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, OP6);
12263
12414
  for (const row of page.items) if (typeof row.ticketID === "number" && !linkIds.includes(row.ticketID)) linkIds.push(row.ticketID);
12264
12415
  if (page.items.length >= LINK_READ_CAP || page.pageDetails.nextPageUrl !== null) capped = true;
12265
12416
  }
@@ -12312,11 +12463,11 @@ async function forResource(_resource, resourceIDIn, http, opts = {}) {
12312
12463
  }
12313
12464
 
12314
12465
  // src/resources/special/tickets/lineOfBusiness.ts
12315
- var OP6 = "tickets.lineOfBusiness";
12466
+ var OP7 = "tickets.lineOfBusiness";
12316
12467
  function positiveId3(value, name) {
12317
12468
  const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
12318
12469
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
12319
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(OP6 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP6 });
12470
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(OP7 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP7 });
12320
12471
  }
12321
12472
  return n;
12322
12473
  }
@@ -12331,25 +12482,25 @@ async function lineOfBusiness2(resource, ticketIdIn, http, associationIdIn) {
12331
12482
  associationSource = "argument";
12332
12483
  } else {
12333
12484
  const ticket = await resource.get(ticketId);
12334
- associationId = _chunkPCLL536Bcjs.vendorId.call(void 0, ticket.organizationalLevelAssociationID);
12485
+ associationId = _chunk4QN43TRPcjs.vendorId.call(void 0, ticket.organizationalLevelAssociationID);
12335
12486
  if (associationId !== void 0) {
12336
12487
  associationSource = "ticket";
12337
12488
  } else {
12338
- const contractRef = _chunkPCLL536Bcjs.vendorId.call(void 0, ticket.contractID);
12489
+ const contractRef = _chunk4QN43TRPcjs.vendorId.call(void 0, ticket.contractID);
12339
12490
  if (contractRef !== void 0) {
12340
12491
  const client = http.client;
12341
12492
  if (client === void 0) {
12342
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(OP6 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP6 });
12493
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(OP7 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP7 });
12343
12494
  }
12344
12495
  try {
12345
12496
  const contract = await client.contracts.get(contractRef);
12346
12497
  contractId = contractRef;
12347
- associationId = _chunkPCLL536Bcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
12498
+ associationId = _chunk4QN43TRPcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
12348
12499
  if (associationId !== void 0) associationSource = "contract";
12349
12500
  } catch (e) {
12350
- if (e instanceof _chunkPCLL536Bcjs.NotFoundError) {
12501
+ if (e instanceof _chunk4QN43TRPcjs.NotFoundError) {
12351
12502
  contractId = contractRef;
12352
- } else if (_chunkPCLL536Bcjs.isAutotaskError.call(void 0, e) && e.code !== "ABORTED") {
12503
+ } else if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) && e.code !== "ABORTED") {
12353
12504
  contractId = contractRef;
12354
12505
  contractUnread = true;
12355
12506
  } else {
@@ -12370,7 +12521,7 @@ async function lineOfBusiness2(resource, ticketIdIn, http, associationIdIn) {
12370
12521
  markers: { association: contractUnread ? "unresolved" : "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
12371
12522
  };
12372
12523
  }
12373
- const chain = await _chunkPCLL536Bcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP6, onError: "propagate" });
12524
+ const chain = await _chunk4QN43TRPcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP7, onError: "propagate" });
12374
12525
  const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
12375
12526
  return { ticketId, associationSource, contractId, association, organizationalLevel2, organizationalLevel1, markers };
12376
12527
  }
@@ -12381,7 +12532,7 @@ async function statusSemantics(_resource, opts = {}, http) {
12381
12532
  }
12382
12533
 
12383
12534
  // src/resources/tickets.ts
12384
- var TicketsResource = class extends _chunkPCLL536Bcjs.BaseResource {
12535
+ var TicketsResource = class extends _chunk4QN43TRPcjs.BaseResource {
12385
12536
  constructor(http, pageSize) {
12386
12537
  super(http, {
12387
12538
  key: "tickets",
@@ -12500,7 +12651,7 @@ var TicketsResource = class extends _chunkPCLL536Bcjs.BaseResource {
12500
12651
  };
12501
12652
 
12502
12653
  // src/resources/ticket_webhooks.ts
12503
- var TicketWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
12654
+ var TicketWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
12504
12655
  constructor(http, pageSize) {
12505
12656
  super(http, {
12506
12657
  key: "ticket_webhooks",
@@ -12571,10 +12722,37 @@ var TicketWebhooksResource = class extends _chunkPCLL536Bcjs.BaseResource {
12571
12722
  /** Search TicketWebhook records: bounded contains on name (no vendor free-text search exists);
12572
12723
  * limit defaults to 25, max 500. */
12573
12724
  async search(query, opts) {
12574
- return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _115 => _115.limit]) });
12725
+ return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _125 => _125.limit]) });
12575
12726
  }
12576
12727
  };
12577
12728
 
12729
+ // src/resources/special/time_entries/posted.ts
12730
+ var isApproved = (entry) => typeof entry.billingApprovalDateTime === "string" && entry.billingApprovalDateTime.trim() !== "";
12731
+ async function postedStateOf(http, entries, op) {
12732
+ const states = /* @__PURE__ */ new Map();
12733
+ const ids2 = [...new Set(entries.map((e) => e.id))];
12734
+ let incomplete = false;
12735
+ for (let c = 0; c < ids2.length; c += _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE) {
12736
+ const chunk = ids2.slice(c, c + _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE);
12737
+ const res = await http.request({
12738
+ method: "POST",
12739
+ idempotent: true,
12740
+ path: "/V1.0/BillingItems/query",
12741
+ body: { MaxRecords: 500, IncludeFields: ["id", "timeEntryID"], filter: [{ field: "timeEntryID", op: "in", value: chunk }] },
12742
+ operation: op
12743
+ });
12744
+ const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res);
12745
+ const billed = new Set(items.map((i) => i.timeEntryID));
12746
+ const more = pageDetails.nextPageUrl != null;
12747
+ if (more) incomplete = true;
12748
+ for (const id of chunk) {
12749
+ if (billed.has(id)) states.set(id, "posted");
12750
+ else if (!more) states.set(id, "unposted");
12751
+ }
12752
+ }
12753
+ return { states, incomplete };
12754
+ }
12755
+
12578
12756
  // src/resources/special/time_entries/windows.ts
12579
12757
  var DAY_MS2 = 864e5;
12580
12758
  var iso2 = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
@@ -12586,77 +12764,85 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
12586
12764
  body: { MaxRecords: limit, filter },
12587
12765
  operation
12588
12766
  });
12589
- const { items, pageDetails } = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res);
12767
+ const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res);
12590
12768
  return { items, hasMore: pageDetails.nextPageUrl != null };
12591
12769
  }
12592
12770
  async function windowQuery3(_resource, kind, http, opts) {
12593
- const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _116 => _116.now]), () => ( /* @__PURE__ */ new Date()));
12594
- const tz = _optionalChain([opts, 'optionalAccess', _117 => _117.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
12771
+ const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _126 => _126.now]), () => ( /* @__PURE__ */ new Date()));
12772
+ const tz = _optionalChain([opts, 'optionalAccess', _127 => _127.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
12595
12773
  const { from, to } = dateOnlyWindowBounds(kind, now, tz);
12596
12774
  const filter = [
12597
12775
  { field: "dateWorked", op: "gte", value: from },
12598
12776
  { field: "dateWorked", op: "lte", value: to }
12599
12777
  ];
12600
- const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _118 => _118.limit])), `time_entries.${kind}`, http);
12778
+ const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])), `time_entries.${kind}`, http);
12601
12779
  return items;
12602
12780
  }
12603
12781
  async function customRange3(_resource, from, to, http, opts) {
12604
- if (_optionalChain([opts, 'optionalAccess', _119 => _119.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
12782
+ if (_optionalChain([opts, 'optionalAccess', _129 => _129.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
12605
12783
  const fromB = customRangeDay(from, "from", void 0, "customRange");
12606
12784
  const toB = customRangeDay(to, "to", void 0, "customRange");
12607
12785
  if (fromB.ms > toB.ms) {
12608
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("customRange: from must not be after to");
12786
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("customRange: from must not be after to");
12609
12787
  }
12610
12788
  const toEndMs = toB.ms + DAY_MS2 - 1;
12611
12789
  const filter = [
12612
12790
  { field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
12613
12791
  { field: "dateWorked", op: "lte", value: iso2(toEndMs) }
12614
12792
  ];
12615
- const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _120 => _120.limit])), "time_entries.customRange", http);
12793
+ const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _130 => _130.limit])), "time_entries.customRange", http);
12616
12794
  return items;
12617
12795
  }
12618
- async function postedDateStatusQuery(_resource, mode, http, opts) {
12619
- const filter = [
12620
- { field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
12621
- ];
12622
- if (_optionalChain([opts, 'optionalAccess', _121 => _121.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12796
+ async function postedStateQuery(_resource, mode, http, opts) {
12623
12797
  const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
12624
- const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _122 => _122.limit])), operation, http);
12625
- return items;
12798
+ const window = { from: null, to: null };
12799
+ const filter = [];
12800
+ const fromB = _optionalChain([opts, 'optionalAccess', _131 => _131.dateFrom]) === void 0 ? void 0 : customRangeDay(opts.dateFrom, "from", void 0, operation);
12801
+ const toB = _optionalChain([opts, 'optionalAccess', _132 => _132.dateTo]) === void 0 ? void 0 : customRangeDay(opts.dateTo, "to", void 0, operation);
12802
+ if (fromB && toB && fromB.ms > toB.ms) {
12803
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${operation}: dateFrom (${iso2(fromB.ms)}) must not be after dateTo (${iso2(toB.ms)})`, { operation });
12804
+ }
12805
+ if (fromB) filter.push({ field: "dateWorked", op: "gte", value: window.from = iso2(fromB.ms) });
12806
+ if (toB) filter.push({ field: "dateWorked", op: "lte", value: window.to = iso2(toB.ms + DAY_MS2 - 1) });
12807
+ if (_optionalChain([opts, 'optionalAccess', _133 => _133.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12808
+ const read = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _134 => _134.limit])), operation, http);
12809
+ const { states, incomplete } = await postedStateOf(http, read.items, operation);
12810
+ const items = read.items.filter((e) => states.get(e.id) === mode);
12811
+ const approvedCount = items.filter(isApproved).length;
12812
+ return { items, hasMore: read.hasMore || incomplete, window, approvedCount, unapprovedCount: items.length - approvedCount };
12626
12813
  }
12627
12814
  async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
12628
- const OP11 = opLabel;
12629
- if (_optionalChain([opts, 'optionalAccess', _123 => _123.tz]) !== void 0) validateZone(opts.tz, OP11);
12630
- const fromB = customRangeDay(from, "from", void 0, OP11);
12631
- const toB = customRangeDay(to, "to", void 0, OP11);
12815
+ const OP12 = opLabel;
12816
+ if (_optionalChain([opts, 'optionalAccess', _135 => _135.tz]) !== void 0) validateZone(opts.tz, OP12);
12817
+ const fromB = customRangeDay(from, "from", void 0, OP12);
12818
+ const toB = customRangeDay(to, "to", void 0, OP12);
12632
12819
  if (fromB.ms > toB.ms) {
12633
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP11}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP11 });
12820
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP12}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP12 });
12634
12821
  }
12635
12822
  const windowToMs = toB.ms + DAY_MS2 - 1;
12636
12823
  const filter = [
12637
12824
  { field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
12638
12825
  { field: "dateWorked", op: "lte", value: iso2(windowToMs) }
12639
12826
  ];
12640
- if (_optionalChain([opts, 'optionalAccess', _124 => _124.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
12641
- else if (_optionalChain([opts, 'optionalAccess', _125 => _125.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
12642
- if (_optionalChain([opts, 'optionalAccess', _126 => _126.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12643
- if (_optionalChain([opts, 'optionalAccess', _127 => _127.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
12644
- const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])), OP11, http);
12827
+ if (_optionalChain([opts, 'optionalAccess', _136 => _136.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
12828
+ if (_optionalChain([opts, 'optionalAccess', _137 => _137.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
12829
+ const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _138 => _138.limit])), OP12, http);
12830
+ const { states, incomplete } = await postedStateOf(http, items, OP12);
12645
12831
  let postedCount = 0;
12646
- for (const item of items) {
12647
- const postedDate = item.postedDate;
12648
- if (typeof postedDate === "string" ? postedDate.trim() !== "" : postedDate !== null && postedDate !== void 0) {
12649
- postedCount += 1;
12650
- }
12832
+ let unpostedCount = 0;
12833
+ for (const state of states.values()) {
12834
+ if (state === "posted") postedCount += 1;
12835
+ else unpostedCount += 1;
12651
12836
  }
12837
+ const keep = _optionalChain([opts, 'optionalAccess', _139 => _139.posted]) === void 0 ? void 0 : opts.posted ? "posted" : "unposted";
12652
12838
  return {
12653
- items,
12839
+ items: keep === void 0 ? items : items.filter((e) => states.get(e.id) === keep),
12654
12840
  postedCount,
12655
- unpostedCount: items.length - postedCount,
12841
+ unpostedCount,
12656
12842
  window: { from: iso2(fromB.ms), to: iso2(windowToMs) },
12657
12843
  // A live next-page cursor past the bounded read: the counts above cover
12658
12844
  // the returned rows ONLY when this is true (issue #66 AC1 — the 500-row cap case is the general case).
12659
- truncated: hasMore
12845
+ truncated: hasMore || incomplete
12660
12846
  };
12661
12847
  }
12662
12848
  async function dateWorkedWindow(resource, from, to, http, opts) {
@@ -12664,13 +12850,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
12664
12850
  }
12665
12851
 
12666
12852
  // src/resources/special/time_entries/errors.ts
12667
- var ResourceInvalidError = class extends _chunkPCLL536Bcjs.AutotaskError {
12853
+ var ResourceInvalidError = class extends _chunk4QN43TRPcjs.AutotaskError {
12668
12854
  constructor(message, options = {}) {
12669
12855
  super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
12670
12856
  this.name = "ResourceInvalidError";
12671
12857
  }
12672
12858
  };
12673
- var AllocationCodeError = class extends _chunkPCLL536Bcjs.AutotaskError {
12859
+ var AllocationCodeError = class extends _chunk4QN43TRPcjs.AutotaskError {
12674
12860
  /** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
12675
12861
 
12676
12862
  constructor(kind, message, options = {}) {
@@ -12679,7 +12865,7 @@ var AllocationCodeError = class extends _chunkPCLL536Bcjs.AutotaskError {
12679
12865
  this.kind = kind;
12680
12866
  }
12681
12867
  };
12682
- var NoApplicableAllocationCodeError = class extends _chunkPCLL536Bcjs.AutotaskError {
12868
+ var NoApplicableAllocationCodeError = class extends _chunk4QN43TRPcjs.AutotaskError {
12683
12869
  /** The structured blocker details (filters tried + department sets). */
12684
12870
 
12685
12871
  constructor(details, options = {}) {
@@ -12744,7 +12930,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
12744
12930
  let pages = 0;
12745
12931
  for (; ; ) {
12746
12932
  if (pages >= PAGE_GUARD) {
12747
- throw new (0, _chunkPCLL536Bcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
12933
+ throw new (0, _chunk4QN43TRPcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
12748
12934
  code: "RESOLUTION_TRUNCATED",
12749
12935
  category: "resolution",
12750
12936
  operation,
@@ -12755,11 +12941,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
12755
12941
  const res = await http.request({
12756
12942
  method: "POST",
12757
12943
  idempotent: true,
12758
- path: isFirst ? path : _chunkPCLL536Bcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
12944
+ path: isFirst ? path : _chunk4QN43TRPcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
12759
12945
  body: { MaxRecords: pageSize, filter },
12760
12946
  operation
12761
12947
  });
12762
- const { items: pageItems, pageDetails } = _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, operation);
12948
+ const { items: pageItems, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, operation);
12763
12949
  items.push(...pageItems);
12764
12950
  pages += 1;
12765
12951
  if (items.length >= totalCap) break;
@@ -12851,7 +13037,7 @@ async function resolveCode(http, family, familyLabel2, pinnedId, departments, op
12851
13037
  }
12852
13038
 
12853
13039
  // src/resources/special/time_entries/createForResource.ts
12854
- var OP7 = "time_entries.createForResource";
13040
+ var OP8 = "time_entries.createForResource";
12855
13041
  var PARAM_KEYS = /* @__PURE__ */ new Set([
12856
13042
  "internallAllocationCodeID",
12857
13043
  "ticketID",
@@ -12876,7 +13062,7 @@ function windowDefaults(params) {
12876
13062
  var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
12877
13063
  var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
12878
13064
  function validateCreateParams(params) {
12879
- const pin = (value, label) => typeof value === "number" ? _chunkPCLL536Bcjs.parseIdentifier.call(void 0, value, label) : void 0;
13065
+ const pin = (value, label) => typeof value === "number" ? _chunk4QN43TRPcjs.parseIdentifier.call(void 0, value, label) : void 0;
12880
13066
  const pins = {
12881
13067
  code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
12882
13068
  ticket: pin(params.ticketID, "ticketID"),
@@ -12885,32 +13071,32 @@ function validateCreateParams(params) {
12885
13071
  };
12886
13072
  const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
12887
13073
  if (pinCount > 1) {
12888
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
13074
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
12889
13075
  "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)",
12890
- { operation: OP7 }
13076
+ { operation: OP8 }
12891
13077
  );
12892
13078
  }
12893
13079
  if (pins.role !== void 0 && pins.code !== void 0) {
12894
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
13080
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
12895
13081
  "createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
12896
- { operation: OP7 }
13082
+ { operation: OP8 }
12897
13083
  );
12898
13084
  }
12899
13085
  if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
12900
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
13086
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
12901
13087
  `createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
12902
- { operation: OP7 }
13088
+ { operation: OP8 }
12903
13089
  );
12904
13090
  }
12905
13091
  return pins;
12906
13092
  }
12907
13093
  async function assertResourceActive(http, rid) {
12908
- const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP7);
13094
+ const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP8);
12909
13095
  if (rec === null) {
12910
13096
  throw new ResourceInvalidError(`Resource ${rid} was not found \u2014 a time entry cannot attach to a missing resource`, {
12911
13097
  resourceIds: [rid],
12912
13098
  details: { idRefs: [{ entity: "resource", id: rid }] },
12913
- operation: OP7,
13099
+ operation: OP8,
12914
13100
  category: "not_found",
12915
13101
  suggestedAction: "Resolve the resource id (resources.get / resources.search) and retry."
12916
13102
  });
@@ -12919,7 +13105,7 @@ async function assertResourceActive(http, rid) {
12919
13105
  throw new ResourceInvalidError(`Resource ${rid} is not active (isActive !== true) \u2014 the vendor would reject a time entry for an inactive resource`, {
12920
13106
  resourceIds: [rid],
12921
13107
  details: { idRefs: [{ entity: "resource", id: rid }] },
12922
- operation: OP7,
13108
+ operation: OP8,
12923
13109
  suggestedAction: "Activate the resource or pick an active one."
12924
13110
  });
12925
13111
  }
@@ -12929,11 +13115,11 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
12929
13115
  const pinnedForCode = pins.code !== void 0 ? pins.code : pins.role;
12930
13116
  let code = null;
12931
13117
  const familiesTried = [];
12932
- code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP7);
13118
+ code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP8);
12933
13119
  familiesTried.push({ family: familyOf(linkage), label: familyLabel(familyOf(linkage)), filters: [{ field: "useType", op: "eq", value: familyOf(linkage) }, { field: "isActive", op: "eq", value: true }] });
12934
13120
  if (code === null && linkage === "task" && pins.role === void 0) {
12935
13121
  usedLinkage = "internal";
12936
- code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP7);
13122
+ code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP8);
12937
13123
  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 }] });
12938
13124
  }
12939
13125
  if (code === null) {
@@ -12943,7 +13129,7 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
12943
13129
  families: familiesTried,
12944
13130
  resourceDepartments: [...departments].sort((a, b) => a - b)
12945
13131
  },
12946
- { operation: OP7 }
13132
+ { operation: OP8 }
12947
13133
  );
12948
13134
  }
12949
13135
  const resolvedCode = codeInfo(code);
@@ -12980,9 +13166,9 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
12980
13166
  if (usedLinkage === "internal" && linkage === "task") {
12981
13167
  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).");
12982
13168
  }
12983
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
13169
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
12984
13170
  {
12985
- operation: OP7,
13171
+ operation: OP8,
12986
13172
  method: "POST",
12987
13173
  path: "/V1.0/TimeEntries",
12988
13174
  ids: [rid],
@@ -13020,11 +13206,11 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
13020
13206
  };
13021
13207
  } catch (err) {
13022
13208
  lastError = err;
13023
- const text = _chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkPCLL536Bcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
13209
+ const text = _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
13024
13210
  const gate3 = ROLE_REJECTION_PATTERN.test(text);
13025
13211
  if (usedLinkage !== "internal" && gate3) {
13026
13212
  if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
13027
- const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP7);
13213
+ const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP8);
13028
13214
  taskRoleFetched = true;
13029
13215
  if (task !== null) pushLadder(task.assignedResourceRoleID);
13030
13216
  }
@@ -13040,17 +13226,17 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
13040
13226
  throw err;
13041
13227
  }
13042
13228
  }
13043
- if (_chunkPCLL536Bcjs.isAutotaskError.call(void 0, lastError)) {
13229
+ if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, lastError)) {
13044
13230
  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.`;
13045
13231
  }
13046
13232
  throw lastError;
13047
13233
  }
13048
13234
  async function createForResource(resource, resourceID, params, opts = {}, http) {
13049
- const rid = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
13235
+ const rid = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
13050
13236
  const pins = validateCreateParams(params);
13051
13237
  await assertResourceActive(http, rid);
13052
13238
  const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
13053
- const roleRows = await resourceRoleRows(http, rid, OP7);
13239
+ const roleRows = await resourceRoleRows(http, rid, OP8);
13054
13240
  const departments = roleRows.departments;
13055
13241
  const { usedLinkage, resolvedCode } = await resolveAllocationCode(http, rid, linkage, pins, departments);
13056
13242
  const defaults = windowDefaults(params);
@@ -13059,8 +13245,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
13059
13245
  return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
13060
13246
  }
13061
13247
  function discoveryField(err, body, defaults) {
13062
- if (!_chunkPCLL536Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
13063
- const entries = _chunkPCLL536Bcjs.parseVendorErrors.call(void 0, err.vendorError);
13248
+ if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
13249
+ const entries = _chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError);
13064
13250
  if (entries === void 0) return null;
13065
13251
  for (const entry of entries) {
13066
13252
  const field = entry.field;
@@ -13073,42 +13259,42 @@ function discoveryField(err, body, defaults) {
13073
13259
  }
13074
13260
 
13075
13261
  // src/resources/special/time_entries/move.ts
13076
- var OP8 = "time_entries.moveToTicket";
13262
+ var OP9 = "time_entries.moveToTicket";
13077
13263
  var COPY2 = ["resourceID", "roleID", "billingCodeID", "dateWorked", "startDateTime", "endDateTime", "hoursWorked", "offsetHours", "summaryNotes", "internalNotes", "isNonBillable", "showOnInvoice"];
13078
13264
  var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundleID"];
13079
13265
  async function readTimeEntry(http, id, retries) {
13080
13266
  try {
13081
- const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP8, maxRetries: retries });
13082
- return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _129 => _129.item]), () => ( null));
13267
+ const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP9, maxRetries: retries });
13268
+ return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _140 => _140.item]), () => ( null));
13083
13269
  } catch (e) {
13084
- if (_chunkPCLL536Bcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
13270
+ if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
13085
13271
  throw e;
13086
13272
  }
13087
13273
  }
13088
13274
  async function checkSource2({ http, source, sourceId, toTicketId, retries }) {
13089
13275
  const ids2 = { sourceId, toTicketId };
13090
13276
  if (source.taskID !== null && source.taskID !== void 0) {
13091
- throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP8}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP8);
13277
+ throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP9}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP9);
13092
13278
  }
13093
13279
  if (source.billingApprovalDateTime || source.billingApprovalResourceID || source.billingApprovalLevelMostRecent) {
13094
- throw refuse("MOVE_BLOCKED_APPROVED", `${OP8}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
13280
+ throw refuse("MOVE_BLOCKED_APPROVED", `${OP9}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
13095
13281
  }
13096
13282
  let billing;
13097
13283
  try {
13098
- billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP8, retries);
13284
+ billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP9, retries);
13099
13285
  } catch (e3) {
13100
- throw refuse("MOVE_BLOCKED_BILLED", `${OP8}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
13286
+ throw refuse("MOVE_BLOCKED_BILLED", `${OP9}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
13101
13287
  }
13102
13288
  if (billing.some((b) => b.invoiceID || b.postedDate)) {
13103
- throw refuse("MOVE_BLOCKED_BILLED", `${OP8}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
13289
+ throw refuse("MOVE_BLOCKED_BILLED", `${OP9}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
13104
13290
  }
13105
- const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP8, retries);
13291
+ const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP9, retries);
13106
13292
  if (attachments.length > 0) {
13107
- throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP8}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
13293
+ throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP9}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
13108
13294
  }
13109
13295
  }
13110
13296
  var SPEC2 = {
13111
- operation: OP8,
13297
+ operation: OP9,
13112
13298
  entity: "time_entry",
13113
13299
  readSource: readTimeEntry,
13114
13300
  sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
@@ -13143,15 +13329,15 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
13143
13329
  }
13144
13330
 
13145
13331
  // src/resources/special/time_entries/approve.ts
13146
- var OP9 = "time_entries.approve";
13332
+ var OP10 = "time_entries.approve";
13147
13333
  var APPROVAL_LEVELS_PATH = "/V1.0/BillingItemApprovalLevels";
13148
13334
  function toIso(value) {
13149
13335
  if (value instanceof Date) {
13150
- if (Number.isNaN(value.getTime())) throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
13336
+ if (Number.isNaN(value.getTime())) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
13151
13337
  return value.toISOString();
13152
13338
  }
13153
13339
  const parsed = new Date(value);
13154
- if (Number.isNaN(parsed.getTime())) throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
13340
+ if (Number.isNaN(parsed.getTime())) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
13155
13341
  return parsed.toISOString();
13156
13342
  }
13157
13343
  function toNumber(value) {
@@ -13164,24 +13350,24 @@ function sameInstant(a, b) {
13164
13350
  return !Number.isNaN(left) && left === right;
13165
13351
  }
13166
13352
  async function approve(resource, id, opts = {}, http) {
13167
- const numericId = toNumber(_chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id"));
13353
+ const numericId = toNumber(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id"));
13168
13354
  if (opts.approvalLevel !== void 0 && (!Number.isInteger(opts.approvalLevel) || opts.approvalLevel < 1)) {
13169
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
13355
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
13170
13356
  }
13171
13357
  const approvalLevel = _nullishCoalesce(opts.approvalLevel, () => ( 1));
13172
13358
  const approvalDateTime = toIso(_nullishCoalesce(opts.approvalDateTime, () => ( /* @__PURE__ */ new Date())));
13173
13359
  const entry = await resource.get(numericId);
13174
- const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunkPCLL536Bcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
13360
+ const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
13175
13361
  if (approvalResourceID === void 0) {
13176
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(
13362
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
13177
13363
  `time_entries.approve: time entry ${numericId} carries no resourceID and the caller supplied no approvalResourceID \u2014 the vendor requires an approving resource`
13178
13364
  );
13179
13365
  }
13180
13366
  const body = { timeEntryID: numericId, approvalLevel, approvalResourceID, approvalDateTime };
13181
13367
  if (opts.dryRun === true) {
13182
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0,
13368
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
13183
13369
  {
13184
- operation: OP9,
13370
+ operation: OP10,
13185
13371
  method: "POST",
13186
13372
  path: APPROVAL_LEVELS_PATH,
13187
13373
  ids: [numericId],
@@ -13204,10 +13390,10 @@ async function approve(resource, id, opts = {}, http) {
13204
13390
  method: "POST",
13205
13391
  path: APPROVAL_LEVELS_PATH,
13206
13392
  body,
13207
- operation: OP9,
13393
+ operation: OP10,
13208
13394
  maxRetries: opts.maxRetries
13209
13395
  });
13210
- const levelId = toNumber(_chunkPCLL536Bcjs.parseIdentifier.call(void 0, _chunkPCLL536Bcjs.unwrapOperation.call(void 0, created, OP9).id, "billingItemApprovalLevelID"));
13396
+ const levelId = toNumber(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, _chunk4QN43TRPcjs.unwrapOperation.call(void 0, created, OP10).id, "billingItemApprovalLevelID"));
13211
13397
  await resource.update(
13212
13398
  numericId,
13213
13399
  { billingApprovalDateTime: approvalDateTime, billingApprovalResourceID: approvalResourceID },
@@ -13230,28 +13416,28 @@ async function approve(resource, id, opts = {}, http) {
13230
13416
  }
13231
13417
 
13232
13418
  // src/resources/special/time_entries/recentTickets.ts
13233
- var OP10 = "time_entries.recentTickets";
13419
+ var OP11 = "time_entries.recentTickets";
13234
13420
  var DAY_MS3 = 864e5;
13235
13421
  var TICKET_CHUNK2 = 100;
13236
13422
  var TICKET_FIELDS3 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
13237
13423
  function positiveId4(value, name) {
13238
13424
  const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
13239
13425
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
13240
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP10}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP10 });
13426
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP11}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP11 });
13241
13427
  }
13242
13428
  return n;
13243
13429
  }
13244
13430
  async function recentTickets(_resource, from, to, http, opts) {
13245
13431
  if (opts === void 0 || opts === null || typeof opts !== "object") {
13246
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP10}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP10 });
13432
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP11}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP11 });
13247
13433
  }
13248
13434
  const resourceID = positiveId4(opts.resourceID, "resourceID");
13249
13435
  const companyID = opts.companyID === void 0 ? void 0 : positiveId4(opts.companyID, "companyID");
13250
- if (opts.tz !== void 0) validateZone(opts.tz, OP10);
13251
- const fromB = customRangeDay(from, "from", void 0, OP10);
13252
- const toB = customRangeDay(to, "to", void 0, OP10);
13436
+ if (opts.tz !== void 0) validateZone(opts.tz, OP11);
13437
+ const fromB = customRangeDay(from, "from", void 0, OP11);
13438
+ const toB = customRangeDay(to, "to", void 0, OP11);
13253
13439
  if (fromB.ms > toB.ms) {
13254
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)(`${OP10}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP10 });
13440
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP11}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP11 });
13255
13441
  }
13256
13442
  const windowToMs = toB.ms + DAY_MS3 - 1;
13257
13443
  const { items: entries, hasMore } = await queryTimeEntries(
@@ -13262,7 +13448,7 @@ async function recentTickets(_resource, from, to, http, opts) {
13262
13448
  { field: "resourceID", op: "eq", value: resourceID }
13263
13449
  ],
13264
13450
  clampWindowLimit(opts.limit),
13265
- OP10,
13451
+ OP11,
13266
13452
  http
13267
13453
  );
13268
13454
  const groups = /* @__PURE__ */ new Map();
@@ -13288,9 +13474,9 @@ async function recentTickets(_resource, from, to, http, opts) {
13288
13474
  idempotent: true,
13289
13475
  path: "/V1.0/Tickets/query",
13290
13476
  body: { MaxRecords: TICKET_CHUNK2, filter, IncludeFields: TICKET_FIELDS3 },
13291
- operation: OP10
13477
+ operation: OP11
13292
13478
  });
13293
- for (const t of _chunkPCLL536Bcjs.unwrapItems.call(void 0, res, OP10).items) if (typeof t.id === "number") tickets.set(t.id, t);
13479
+ for (const t of _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, OP11).items) if (typeof t.id === "number") tickets.set(t.id, t);
13294
13480
  }
13295
13481
  const items = [];
13296
13482
  const unresolvedTicketIDs = [];
@@ -13298,17 +13484,17 @@ async function recentTickets(_resource, from, to, http, opts) {
13298
13484
  for (const [ticketID, g] of groups) {
13299
13485
  const t = tickets.get(ticketID);
13300
13486
  if (t === void 0) unresolvedTicketIDs.push(ticketID);
13301
- if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _130 => _130.companyID]) !== companyID) {
13487
+ if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _141 => _141.companyID]) !== companyID) {
13302
13488
  if (t !== void 0) excludedTickets += 1;
13303
13489
  continue;
13304
13490
  }
13305
13491
  items.push({
13306
13492
  ticketID,
13307
- ..._optionalChain([t, 'optionalAccess', _131 => _131.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
13308
- ..._optionalChain([t, 'optionalAccess', _132 => _132.title]) !== void 0 ? { title: t.title } : {},
13309
- ..._optionalChain([t, 'optionalAccess', _133 => _133.status]) !== void 0 ? { status: t.status } : {},
13310
- ..._optionalChain([t, 'optionalAccess', _134 => _134.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
13311
- ..._optionalChain([t, 'optionalAccess', _135 => _135.companyID]) !== void 0 ? { companyID: t.companyID } : {},
13493
+ ..._optionalChain([t, 'optionalAccess', _142 => _142.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
13494
+ ..._optionalChain([t, 'optionalAccess', _143 => _143.title]) !== void 0 ? { title: t.title } : {},
13495
+ ..._optionalChain([t, 'optionalAccess', _144 => _144.status]) !== void 0 ? { status: t.status } : {},
13496
+ ..._optionalChain([t, 'optionalAccess', _145 => _145.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
13497
+ ..._optionalChain([t, 'optionalAccess', _146 => _146.companyID]) !== void 0 ? { companyID: t.companyID } : {},
13312
13498
  entryCount: g.entryCount,
13313
13499
  totalHours: Math.round(g.totalHours * 100) / 100,
13314
13500
  lastWorked: g.lastWorked
@@ -13327,7 +13513,7 @@ async function recentTickets(_resource, from, to, http, opts) {
13327
13513
  }
13328
13514
 
13329
13515
  // src/resources/time_entries.ts
13330
- var TimeEntriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
13516
+ var TimeEntriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
13331
13517
  constructor(http, pageSize) {
13332
13518
  super(http, {
13333
13519
  key: "time_entries",
@@ -13411,11 +13597,11 @@ var TimeEntriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
13411
13597
  }
13412
13598
  /** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
13413
13599
  getPosted(opts) {
13414
- return postedDateStatusQuery(this, "posted", this.http, opts);
13600
+ return postedStateQuery(this, "posted", this.http, opts);
13415
13601
  }
13416
13602
  /** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
13417
13603
  getUnposted(opts) {
13418
- return postedDateStatusQuery(this, "unposted", this.http, opts);
13604
+ return postedStateQuery(this, "unposted", this.http, opts);
13419
13605
  }
13420
13606
  /** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
13421
13607
  last14(opts) {
@@ -13476,7 +13662,7 @@ var TimeEntriesResource = class extends _chunkPCLL536Bcjs.BaseResource {
13476
13662
  };
13477
13663
 
13478
13664
  // src/resources/time_entry_attachments.ts
13479
- var TimeEntryAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource {
13665
+ var TimeEntryAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
13480
13666
  constructor(http, pageSize) {
13481
13667
  super(http, {
13482
13668
  key: "time_entry_attachments",
@@ -13539,9 +13725,9 @@ var TimeEntryAttachmentsResource = class extends _chunkPCLL536Bcjs.BaseResource
13539
13725
 
13540
13726
  // src/resources/special/time_off_requests.ts
13541
13727
  async function approve2(_resource, id, opts = {}, http) {
13542
- const numericId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
13728
+ const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
13543
13729
  if (opts.dryRun === true) {
13544
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
13730
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
13545
13731
  operation: "time_off_requests.approve",
13546
13732
  method: "GET",
13547
13733
  path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
@@ -13557,16 +13743,16 @@ async function approve2(_resource, id, opts = {}, http) {
13557
13743
  operation: "time_off_requests.approve",
13558
13744
  maxRetries: opts.maxRetries
13559
13745
  });
13560
- return _chunkPCLL536Bcjs.unwrapOperation.call(void 0, res);
13746
+ return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
13561
13747
  }
13562
13748
  async function reject(_resource, id, reason, opts = {}, http) {
13563
- const numericId = _chunkPCLL536Bcjs.parseIdentifier.call(void 0, id, "id");
13749
+ const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
13564
13750
  const text = reason.trim();
13565
13751
  if (text === "") {
13566
- throw new (0, _chunkPCLL536Bcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
13752
+ throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
13567
13753
  }
13568
13754
  if (opts.dryRun === true) {
13569
- return _chunkPCLL536Bcjs.buildDryRunResult.call(void 0, {
13755
+ return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
13570
13756
  operation: "time_off_requests.reject",
13571
13757
  method: "POST",
13572
13758
  path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
@@ -13584,11 +13770,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
13584
13770
  operation: "time_off_requests.reject",
13585
13771
  maxRetries: opts.maxRetries
13586
13772
  });
13587
- return _chunkPCLL536Bcjs.unwrapOperation.call(void 0, res);
13773
+ return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
13588
13774
  }
13589
13775
 
13590
13776
  // src/resources/time_off_requests.ts
13591
- var TimeOffRequestsResource = class extends _chunkPCLL536Bcjs.BaseResource {
13777
+ var TimeOffRequestsResource = class extends _chunk4QN43TRPcjs.BaseResource {
13592
13778
  constructor(http, pageSize) {
13593
13779
  super(http, {
13594
13780
  key: "time_off_requests",