node-autotask 0.68.0 → 0.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/MCP_TOOL_CATALOG.json +2 -2
  3. package/README.md +51 -10
  4. package/capabilities.json +7 -7
  5. package/dist/capabilities-data.js +6 -6
  6. package/dist/capabilities.cjs +4 -4
  7. package/dist/capabilities.js +1 -1
  8. package/dist/{chunk-HFWOHUVF.cjs → chunk-24GRFW55.cjs} +236 -222
  9. package/dist/{chunk-BF22HBNT.js → chunk-2BB7OASJ.js} +3 -30
  10. package/dist/{chunk-OUVUQQXH.js → chunk-AH6WAGPS.js} +80 -66
  11. package/dist/{chunk-CG6OPTFG.cjs → chunk-DPRY3CUJ.cjs} +30 -57
  12. package/dist/{chunk-V2GE763R.cjs → chunk-JLBSUZ5B.cjs} +993 -395
  13. package/dist/{chunk-SGH7F2CH.cjs → chunk-KAZE4WC7.cjs} +3 -3
  14. package/dist/{chunk-DPJLN5BB.js → chunk-QDBJCGQD.js} +986 -390
  15. package/dist/{chunk-JCMXQUIC.js → chunk-SCFB5MF3.js} +3 -3
  16. package/dist/{index-DQ08uOH0.d.ts → index-CxBU31jT.d.ts} +16 -9
  17. package/dist/{index-mIsdpO5d.d.cts → index-WZ3A8nG6.d.cts} +16 -9
  18. package/dist/index.cjs +92 -85
  19. package/dist/index.d.cts +3 -3
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +14 -7
  22. package/dist/operations/index.cjs +50 -50
  23. package/dist/operations/index.d.cts +2 -2
  24. package/dist/operations/index.d.ts +2 -2
  25. package/dist/operations/index.js +2 -2
  26. package/dist/pool.cjs +12 -12
  27. package/dist/pool.js +4 -4
  28. package/dist/resources/index.cjs +27 -27
  29. package/dist/resources/index.d.cts +1 -1
  30. package/dist/resources/index.d.ts +1 -1
  31. package/dist/resources/index.js +3 -3
  32. package/docs/API.md +77 -16
  33. package/docs/LIVE-TESTING.md +16 -2
  34. package/docs/VENDOR-QUIRKS.md +54 -0
  35. package/docs/performance-finance.md +35 -0
  36. package/examples/mcp-env-config.ts +3 -4
  37. package/package.json +1 -1
@@ -1,24 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var chunkV2GE763R_cjs = require('./chunk-V2GE763R.cjs');
4
- var chunkSGH7F2CH_cjs = require('./chunk-SGH7F2CH.cjs');
3
+ var chunkJLBSUZ5B_cjs = require('./chunk-JLBSUZ5B.cjs');
4
+ var chunkKAZE4WC7_cjs = require('./chunk-KAZE4WC7.cjs');
5
5
 
6
6
  // src/resources/special/configuration_items.ts
7
7
  async function fetchRecord(http, path, label, readOpts) {
8
8
  const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: readOpts?.maxRetries });
9
9
  const body = res;
10
10
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
11
- throw new chunkV2GE763R_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
11
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
12
12
  }
13
13
  return body.item;
14
14
  }
15
15
  async function moveConfigurationItem(_resource, sourceId, opts) {
16
16
  const http = _resource.http;
17
- const numericSource = chunkV2GE763R_cjs.parseIdentifier(sourceId, "sourceId");
17
+ const numericSource = chunkJLBSUZ5B_cjs.parseIdentifier(sourceId, "sourceId");
18
18
  if (opts?.destinationCompanyId === void 0) {
19
- throw new chunkV2GE763R_cjs.AutotaskConfigError("moveConfigurationItem: destinationCompanyId is required");
19
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("moveConfigurationItem: destinationCompanyId is required");
20
20
  }
21
- const destId = chunkV2GE763R_cjs.parseIdentifier(opts.destinationCompanyId, "destinationCompanyId");
21
+ const destId = chunkJLBSUZ5B_cjs.parseIdentifier(opts.destinationCompanyId, "destinationCompanyId");
22
22
  const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
23
23
  await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
24
24
  const body = { ...source };
@@ -28,20 +28,20 @@ async function moveConfigurationItem(_resource, sourceId, opts) {
28
28
  body.companyID = destId;
29
29
  body.isActive = true;
30
30
  if (opts.newReferenceTitle !== void 0) {
31
- if (opts.newReferenceTitle.trim() === "") throw new chunkV2GE763R_cjs.AutotaskConfigError("moveConfigurationItem: newReferenceTitle must be non-empty");
31
+ if (opts.newReferenceTitle.trim() === "") throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("moveConfigurationItem: newReferenceTitle must be non-empty");
32
32
  body.referenceTitle = opts.newReferenceTitle.trim();
33
33
  }
34
34
  if (opts.lastModifiedDate !== void 0) {
35
35
  const current = source.lastModifiedDate;
36
36
  if (current !== opts.lastModifiedDate) {
37
- throw new chunkV2GE763R_cjs.StaleObjectError(
37
+ throw new chunkJLBSUZ5B_cjs.StaleObjectError(
38
38
  `moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${current ?? "unknown"})`,
39
39
  { operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
40
40
  );
41
41
  }
42
42
  }
43
43
  if (opts.dryRun === true) {
44
- return chunkV2GE763R_cjs.buildDryRunResult({
44
+ return chunkJLBSUZ5B_cjs.buildDryRunResult({
45
45
  operation: "configuration_items.moveConfigurationItem",
46
46
  method: "POST",
47
47
  path: "/V1.0/ConfigurationItems",
@@ -66,7 +66,7 @@ async function moveConfigurationItem(_resource, sourceId, opts) {
66
66
  const createdBody = created;
67
67
  const newId = createdBody !== null ? createdBody.itemId ?? createdBody.id : void 0;
68
68
  if (typeof newId !== "number") {
69
- throw new chunkV2GE763R_cjs.AutotaskConfigError("moveConfigurationItem: vendor create response has no itemId");
69
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("moveConfigurationItem: vendor create response has no itemId");
70
70
  }
71
71
  let sourceDeactivated = false;
72
72
  if (opts.deactivateSource !== false) {
@@ -85,7 +85,7 @@ var PROFILE_PART_LIMIT = 50;
85
85
  function profilePartLimit(value, name) {
86
86
  const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
87
87
  if (!Number.isInteger(n) || n < 1) {
88
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
88
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
89
89
  }
90
90
  return n;
91
91
  }
@@ -94,21 +94,17 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
94
94
  return null;
95
95
  }
96
96
  try {
97
- const res = await http.request({
98
- method: "GET",
99
- path: `${entityPath}/${referenceId}`,
100
- operation: "configuration_items.profile"
101
- });
97
+ const res = await chunkJLBSUZ5B_cjs.cachedRecordGet(http, `${entityPath}/${referenceId}`, "configuration_items.profile");
102
98
  const body = res;
103
99
  if (body === null || !("item" in body)) {
104
- throw new chunkV2GE763R_cjs.NotFoundError(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
100
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
105
101
  }
106
102
  if (body.item === null || body.item === void 0) {
107
- throw new chunkV2GE763R_cjs.NotFoundError("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
103
+ throw new chunkJLBSUZ5B_cjs.NotFoundError("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
108
104
  }
109
105
  return body.item;
110
106
  } catch (err) {
111
- if (err instanceof chunkV2GE763R_cjs.NotFoundError) return null;
107
+ if (err instanceof chunkJLBSUZ5B_cjs.NotFoundError) return null;
112
108
  throw err;
113
109
  }
114
110
  }
@@ -120,7 +116,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
120
116
  body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
121
117
  operation: "configuration_items.profile"
122
118
  });
123
- return chunkV2GE763R_cjs.unwrapItems(res).items;
119
+ return chunkJLBSUZ5B_cjs.unwrapItems(res).items;
124
120
  }
125
121
  async function profile(resource, id, opts = {}) {
126
122
  const http = resource.http;
@@ -128,11 +124,13 @@ async function profile(resource, id, opts = {}) {
128
124
  const relatedLimit = profilePartLimit(opts.relatedLimit, "relatedLimit");
129
125
  const ci = await resource.get(id);
130
126
  const root = ci;
131
- const type = await contextFetchPart(http, "/V1.0/ConfigurationItemTypes", root["configurationItemType"], "configuration_item_type");
132
- const category = await contextFetchPart(http, "/V1.0/ConfigurationItemCategories", root["configurationItemCategoryID"], "configuration_item_category");
133
- const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
134
- const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
135
- const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT);
127
+ const [type, category, notes, relatedItems, associations] = await chunkJLBSUZ5B_cjs.readTasks(http, [
128
+ () => contextFetchPart(http, "/V1.0/ConfigurationItemTypes", root["configurationItemType"], "configuration_item_type"),
129
+ () => contextFetchPart(http, "/V1.0/ConfigurationItemCategories", root["configurationItemCategoryID"], "configuration_item_category"),
130
+ () => ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit),
131
+ () => ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit),
132
+ () => ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT)
133
+ ]);
136
134
  const productAssociations = {
137
135
  items: associations,
138
136
  capped: associations.length >= PROFILE_PART_LIMIT,
@@ -155,11 +153,11 @@ async function profile(resource, id, opts = {}) {
155
153
  }
156
154
  };
157
155
  if (opts.names === true) {
158
- const builder = chunkV2GE763R_cjs.createNamePlan();
156
+ const builder = chunkJLBSUZ5B_cjs.createNamePlan();
159
157
  builder.addFk("contract", root["contractID"]);
160
- const names = await chunkV2GE763R_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
158
+ const names = await chunkJLBSUZ5B_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
161
159
  const ciRow = { ...ci };
162
- chunkV2GE763R_cjs.addNameSibling(ciRow, "contractID", (v) => names.recordName("contract", v));
160
+ chunkJLBSUZ5B_cjs.addNameSibling(ciRow, "contractID", (v) => names.recordName("contract", v));
163
161
  result.ci = ciRow;
164
162
  result.names = names.section;
165
163
  }
@@ -167,7 +165,7 @@ async function profile(resource, id, opts = {}) {
167
165
  }
168
166
 
169
167
  // src/resources/configuration_items.ts
170
- var ConfigurationItemsResource = class extends chunkV2GE763R_cjs.GenericResource {
168
+ var ConfigurationItemsResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
171
169
  constructor(http, pageSize) {
172
170
  super(http, {
173
171
  key: "configuration_items",
@@ -193,9 +191,11 @@ var ConfigurationItemsResource = class extends chunkV2GE763R_cjs.GenericResource
193
191
  async getContext(id) {
194
192
  const configurationItem = await this.fetchRecordRaw("/V1.0/ConfigurationItems", id);
195
193
  const root = configurationItem;
196
- const company = await this.contextFetch("/V1.0/Companies", root["companyID"]);
197
- const contact = await this.contextFetch("/V1.0/Contacts", root["contactID"]);
198
- const contract = await this.contextFetch("/V1.0/Contracts", root["contractID"]);
194
+ const [company, contact, contract] = await chunkJLBSUZ5B_cjs.readTasks(this.http, [
195
+ () => this.contextFetch("/V1.0/Companies", root["companyID"]),
196
+ () => this.contextFetch("/V1.0/Contacts", root["contactID"]),
197
+ () => this.contextFetch("/V1.0/Contracts", root["contractID"])
198
+ ]);
199
199
  return { configurationItem, company, contact, contract };
200
200
  }
201
201
  /** Node-parity special op (hand-written in src/resources/special/configuration_items.ts). */
@@ -213,23 +213,23 @@ async function fetchRecord2(http, path, label, readOpts) {
213
213
  const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: readOpts?.maxRetries });
214
214
  const body = res;
215
215
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
216
- throw new chunkV2GE763R_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
216
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
217
217
  }
218
218
  return body.item;
219
219
  }
220
220
  async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}) {
221
221
  const http = _resource.http;
222
- const sourceId = chunkV2GE763R_cjs.parseIdentifier(sourceContactId, "sourceContactId");
223
- const destId = chunkV2GE763R_cjs.parseIdentifier(destinationCompanyId, "destinationCompanyId");
222
+ const sourceId = chunkJLBSUZ5B_cjs.parseIdentifier(sourceContactId, "sourceContactId");
223
+ const destId = chunkJLBSUZ5B_cjs.parseIdentifier(destinationCompanyId, "destinationCompanyId");
224
224
  const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
225
225
  const companyID = source.companyID;
226
226
  if (typeof companyID !== "number" || companyID < 0) {
227
- throw new chunkV2GE763R_cjs.NotFoundError(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
227
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
228
228
  }
229
229
  if (opts.lastModifiedDate !== void 0) {
230
230
  const current = source.lastModifiedDate;
231
231
  if (current !== opts.lastModifiedDate) {
232
- throw new chunkV2GE763R_cjs.StaleObjectError(
232
+ throw new chunkJLBSUZ5B_cjs.StaleObjectError(
233
233
  `moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
234
234
  { operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
235
235
  );
@@ -251,10 +251,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
251
251
  },
252
252
  operation: "contacts.moveToCompany"
253
253
  });
254
- const items = chunkV2GE763R_cjs.unwrapItems(res).items;
254
+ const items = chunkJLBSUZ5B_cjs.unwrapItems(res).items;
255
255
  const clash = items.find((c) => String(c.id) !== String(sourceId));
256
256
  if (clash !== void 0) {
257
- throw new chunkV2GE763R_cjs.ConflictError(
257
+ throw new chunkJLBSUZ5B_cjs.ConflictError(
258
258
  `Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
259
259
  { resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
260
260
  );
@@ -268,7 +268,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
268
268
  if (opts.dryRun === true) {
269
269
  const warnings = [];
270
270
  if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
271
- return chunkV2GE763R_cjs.buildDryRunResult({
271
+ return chunkJLBSUZ5B_cjs.buildDryRunResult({
272
272
  operation: "contacts.moveToCompany",
273
273
  method: "POST",
274
274
  path: `/V1.0/Companies/${destId}/Contacts`,
@@ -294,7 +294,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
294
294
  const createdBody = created;
295
295
  const newId = createdBody !== null ? createdBody.itemId ?? createdBody.id : void 0;
296
296
  if (typeof newId !== "number") {
297
- throw new chunkV2GE763R_cjs.AutotaskConfigError("contacts.moveToCompany: vendor create response has no itemId");
297
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("contacts.moveToCompany: vendor create response has no itemId");
298
298
  }
299
299
  let sourceDeleted = false;
300
300
  if (opts.deleteSource === true) {
@@ -310,30 +310,27 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
310
310
  }
311
311
  var FULL_PROFILE_OP = "contacts.fullProfile";
312
312
  async function fullProfile(resource, id, opts = {}) {
313
- const client = chunkV2GE763R_cjs.clientOf(resource, FULL_PROFILE_OP);
314
- const ticketLimit = chunkV2GE763R_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", FULL_PROFILE_OP);
315
- const contactId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
316
- const envelope = await chunkV2GE763R_cjs.invokeRead(client, "contacts.query", [
313
+ const client = chunkJLBSUZ5B_cjs.clientOf(resource, FULL_PROFILE_OP);
314
+ const ticketLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", FULL_PROFILE_OP);
315
+ const contactId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
316
+ const envelope = await chunkJLBSUZ5B_cjs.invokeRead(client, "contacts.query", [
317
317
  { filter: [{ field: "id", op: "eq", value: contactId }], limit: 1 }
318
318
  ]);
319
319
  const row = (envelope.items ?? [])[0];
320
320
  if (row === void 0) {
321
- throw new chunkV2GE763R_cjs.NotFoundError(`Contact ${contactId} not found`, { operation: "contacts.get", httpStatus: 404 });
321
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`Contact ${contactId} not found`, { operation: "contacts.get", httpStatus: 404 });
322
322
  }
323
323
  const fk = typeof row.companyID === "number" && row.companyID > 0 ? row.companyID : null;
324
- const root = fk === null ? row : await chunkV2GE763R_cjs.invokeRead(client, "contacts.get", [fk, contactId]);
325
- const company = fk === null ? { value: null, absent: "NO_FK" } : await chunkV2GE763R_cjs.compositePart(client, "companies.get", [fk]);
326
- const openTickets = await chunkV2GE763R_cjs.openTicketsOfPart(
327
- client,
328
- "contactID",
329
- contactId,
330
- ticketLimit
331
- );
324
+ const root = fk === null ? row : await chunkJLBSUZ5B_cjs.invokeRead(client, "contacts.get", [fk, contactId]);
325
+ const [company, openTickets] = await chunkJLBSUZ5B_cjs.readTasks(resource.http, [
326
+ async () => fk === null ? { value: null, absent: "NO_FK" } : await chunkJLBSUZ5B_cjs.compositePart(client, "companies.get", [fk]),
327
+ async () => await chunkJLBSUZ5B_cjs.openTicketsOfPart(client, "contactID", contactId, ticketLimit)
328
+ ]);
332
329
  return { root, parts: { company, open_tickets: openTickets } };
333
330
  }
334
331
 
335
332
  // src/resources/contacts.ts
336
- var ContactsResource = class extends chunkV2GE763R_cjs.GenericResource {
333
+ var ContactsResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
337
334
  constructor(http, pageSize) {
338
335
  super(http, {
339
336
  key: "contacts",
@@ -382,10 +379,10 @@ var PATH_SUFFIX = {
382
379
  };
383
380
  async function stockedItems(_resource, kind, parentId, data, opts = {}) {
384
381
  const http = _resource.http;
385
- const numericParent = chunkV2GE763R_cjs.parseIdentifier(parentId, "parentId");
382
+ const numericParent = chunkJLBSUZ5B_cjs.parseIdentifier(parentId, "parentId");
386
383
  const suffix = PATH_SUFFIX[kind];
387
384
  if (opts.dryRun === true) {
388
- return chunkV2GE763R_cjs.buildDryRunResult({
385
+ return chunkJLBSUZ5B_cjs.buildDryRunResult({
389
386
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
390
387
  method: "POST",
391
388
  path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
@@ -402,11 +399,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}) {
402
399
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
403
400
  maxRetries: opts.maxRetries
404
401
  });
405
- return chunkV2GE763R_cjs.unwrapOperation(res);
402
+ return chunkJLBSUZ5B_cjs.unwrapOperation(res);
406
403
  }
407
404
 
408
405
  // src/resources/inventory_products.ts
409
- var InventoryProductsResource = class extends chunkV2GE763R_cjs.GenericResource {
406
+ var InventoryProductsResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
410
407
  constructor(http, pageSize) {
411
408
  super(http, {
412
409
  key: "inventory_products",
@@ -434,18 +431,18 @@ var InventoryProductsResource = class extends chunkV2GE763R_cjs.GenericResource
434
431
  // src/resources/special/quotes.ts
435
432
  var OP = "quotes.withItems";
436
433
  async function withItems(resource, id, opts = {}) {
437
- const client = chunkV2GE763R_cjs.clientOf(resource, OP);
438
- const itemLimit = chunkV2GE763R_cjs.compositePartLimit(opts.itemLimit, "itemLimit", OP);
439
- const quoteId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
440
- const root = await chunkV2GE763R_cjs.invokeRead(client, "quotes.get", [quoteId]);
441
- const items = await chunkV2GE763R_cjs.compositePart(client, "quote_items.query", [
434
+ const client = chunkJLBSUZ5B_cjs.clientOf(resource, OP);
435
+ const itemLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.itemLimit, "itemLimit", OP);
436
+ const quoteId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
437
+ const root = await chunkJLBSUZ5B_cjs.invokeRead(client, "quotes.get", [quoteId]);
438
+ const items = await chunkJLBSUZ5B_cjs.compositePart(client, "quote_items.query", [
442
439
  { filter: [{ field: "quoteID", op: "eq", value: quoteId }], limit: itemLimit }
443
440
  ]);
444
441
  return { root, parts: { items } };
445
442
  }
446
443
 
447
444
  // src/resources/quotes.ts
448
- var QuotesResource = class extends chunkV2GE763R_cjs.GenericResource {
445
+ var QuotesResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
449
446
  constructor(http, pageSize) {
450
447
  super(http, {
451
448
  key: "quotes",
@@ -471,7 +468,7 @@ var QuotesResource = class extends chunkV2GE763R_cjs.GenericResource {
471
468
  // src/resources/special/resource_time_off_additional.ts
472
469
  async function getByResource(_resource, resourceId) {
473
470
  const http = _resource.http;
474
- const numericResource = chunkV2GE763R_cjs.parseIdentifier(resourceId, "resourceId");
471
+ const numericResource = chunkJLBSUZ5B_cjs.parseIdentifier(resourceId, "resourceId");
475
472
  const res = await http.request({
476
473
  method: "GET",
477
474
  path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
@@ -485,11 +482,11 @@ async function getByResource(_resource, resourceId) {
485
482
  if (typeof item === "object" && !Array.isArray(item)) return [item];
486
483
  }
487
484
  }
488
- return chunkV2GE763R_cjs.unwrapItems(res, "resource_time_off_additional.getByResource").items;
485
+ return chunkJLBSUZ5B_cjs.unwrapItems(res, "resource_time_off_additional.getByResource").items;
489
486
  }
490
487
 
491
488
  // src/resources/resource_time_off_additional.ts
492
- var ResourceTimeOffAdditionalResource = class extends chunkV2GE763R_cjs.GenericResource {
489
+ var ResourceTimeOffAdditionalResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
493
490
  constructor(http, pageSize) {
494
491
  super(http, {
495
492
  key: "resource_time_off_additional",
@@ -510,30 +507,30 @@ var ResourceTimeOffAdditionalResource = class extends chunkV2GE763R_cjs.GenericR
510
507
  // src/resources/special/resource_time_off_balances.ts
511
508
  async function getByResource2(_resource, resourceId) {
512
509
  const http = _resource.http;
513
- const numericResource = chunkV2GE763R_cjs.parseIdentifier(resourceId, "resourceId");
510
+ const numericResource = chunkJLBSUZ5B_cjs.parseIdentifier(resourceId, "resourceId");
514
511
  const res = await http.request({
515
512
  method: "GET",
516
513
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
517
514
  operation: "resource_time_off_balances.getByResource"
518
515
  });
519
- return chunkV2GE763R_cjs.unwrapItems(res, "resource_time_off_balances.getByResource").items;
516
+ return chunkJLBSUZ5B_cjs.unwrapItems(res, "resource_time_off_balances.getByResource").items;
520
517
  }
521
518
  async function getByYear(_resource, resourceId, year) {
522
519
  const http = _resource.http;
523
- const numericResource = chunkV2GE763R_cjs.parseIdentifier(resourceId, "resourceId");
520
+ const numericResource = chunkJLBSUZ5B_cjs.parseIdentifier(resourceId, "resourceId");
524
521
  if (!Number.isSafeInteger(year) || year < 1) {
525
- throw new chunkV2GE763R_cjs.AutotaskConfigError("getByYear: year must be a positive integer");
522
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("getByYear: year must be a positive integer");
526
523
  }
527
524
  const res = await http.request({
528
525
  method: "GET",
529
526
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
530
527
  operation: "resource_time_off_balances.getByYear"
531
528
  });
532
- return chunkV2GE763R_cjs.unwrapItem(res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
529
+ return chunkJLBSUZ5B_cjs.unwrapItem(res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
533
530
  }
534
531
 
535
532
  // src/resources/resource_time_off_balances.ts
536
- var ResourceTimeOffBalancesResource = class extends chunkV2GE763R_cjs.GenericResource {
533
+ var ResourceTimeOffBalancesResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
537
534
  constructor(http, pageSize) {
538
535
  super(http, {
539
536
  key: "resource_time_off_balances",
@@ -559,7 +556,7 @@ var ResourceTimeOffBalancesResource = class extends chunkV2GE763R_cjs.GenericRes
559
556
  async function whoAmI(_resource, userName) {
560
557
  const http = _resource.http;
561
558
  const user = userName.trim();
562
- if (user === "") throw new chunkV2GE763R_cjs.AutotaskConfigError("whoAmI: the configured UserName is empty");
559
+ if (user === "") throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("whoAmI: the configured UserName is empty");
563
560
  const value = user.includes("@") ? user.split("@")[0] ?? "" : user;
564
561
  const res = await http.request({
565
562
  method: "POST",
@@ -568,11 +565,11 @@ async function whoAmI(_resource, userName) {
568
565
  body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
569
566
  operation: "resources.whoAmI"
570
567
  });
571
- const matches = chunkV2GE763R_cjs.unwrapItems(res).items;
568
+ const matches = chunkJLBSUZ5B_cjs.unwrapItems(res).items;
572
569
  if (matches.length === 0) return null;
573
570
  if (matches.length > 1) {
574
571
  const ids = matches.map((m) => m.id).filter((id) => typeof id === "number");
575
- throw new chunkV2GE763R_cjs.ResolutionError(
572
+ throw new chunkJLBSUZ5B_cjs.ResolutionError(
576
573
  `whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
577
574
  { code: "RESOLUTION_AMBIGUOUS", resourceIds: ids, details: { idRefs: ids.map((cid) => ({ entity: "resource", id: cid })) } }
578
575
  );
@@ -581,24 +578,30 @@ async function whoAmI(_resource, userName) {
581
578
  }
582
579
  var WORKLOAD_OP = "resources.workload";
583
580
  async function workload(resource, id, opts = {}) {
584
- const client = chunkV2GE763R_cjs.clientOf(resource, WORKLOAD_OP);
585
- const ticketLimit = chunkV2GE763R_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", WORKLOAD_OP);
586
- const taskLimit = chunkV2GE763R_cjs.compositePartLimit(opts.taskLimit, "taskLimit", WORKLOAD_OP);
587
- const timeOffLimit = chunkV2GE763R_cjs.compositePartLimit(opts.timeOffLimit, "timeOffLimit", WORKLOAD_OP);
588
- const resourceId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
589
- const root = await chunkV2GE763R_cjs.invokeRead(client, "resources.get", [resourceId]);
581
+ const client = chunkJLBSUZ5B_cjs.clientOf(resource, WORKLOAD_OP);
582
+ const ticketLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", WORKLOAD_OP);
583
+ const taskLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.taskLimit, "taskLimit", WORKLOAD_OP);
584
+ const timeOffLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.timeOffLimit, "timeOffLimit", WORKLOAD_OP);
585
+ const resourceId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
586
+ const root = await chunkJLBSUZ5B_cjs.invokeRead(client, "resources.get", [resourceId]);
590
587
  const strict = { allowAssumed: false };
591
- const joined = await chunkV2GE763R_cjs.compositePart(client, "tickets.forResource", [
592
- resourceId,
593
- { openOnly: true, limit: Math.min(ticketLimit, 500), ...strict }
594
- ]);
595
- const counted = await chunkV2GE763R_cjs.compositePart(client, "tickets.forResource", [resourceId, { countOnly: true, ...strict }]);
596
- const assignments = await chunkV2GE763R_cjs.compositePart(client, "service_call_task_resources.query", [
597
- { filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: taskLimit }
598
- ]);
599
- const balances = await chunkV2GE763R_cjs.compositePart(client, "resource_time_off_balances.getByResource", [resourceId]);
600
- const timeOff = await chunkV2GE763R_cjs.compositePart(client, "time_off_requests.query", [
601
- { filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: timeOffLimit }
588
+ const [joined, counted, assignmentBranch, balances, timeOff] = await chunkJLBSUZ5B_cjs.readTasks(resource.http, [
589
+ () => chunkJLBSUZ5B_cjs.compositePart(client, "tickets.forResource", [
590
+ resourceId,
591
+ { openOnly: true, limit: Math.min(ticketLimit, 500), ...strict }
592
+ ]),
593
+ () => chunkJLBSUZ5B_cjs.compositePart(client, "tickets.forResource", [resourceId, { countOnly: true, ...strict }]),
594
+ async () => {
595
+ const assignments2 = await chunkJLBSUZ5B_cjs.compositePart(client, "service_call_task_resources.query", [
596
+ { filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: taskLimit }
597
+ ]);
598
+ const taskDetails2 = await chunkJLBSUZ5B_cjs.joinedCompositePart(client, assignments2, "serviceCallTaskID", "service_call_tasks.query", "id", taskLimit, "NO_ASSIGNMENTS");
599
+ return { assignments: assignments2, taskDetails: taskDetails2 };
600
+ },
601
+ () => chunkJLBSUZ5B_cjs.compositePart(client, "resource_time_off_balances.getByResource", [resourceId]),
602
+ () => chunkJLBSUZ5B_cjs.compositePart(client, "time_off_requests.query", [
603
+ { filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: timeOffLimit }
604
+ ])
602
605
  ]);
603
606
  const openTickets = joined.value !== null && typeof joined.value === "object" ? counted.value !== null && typeof counted.value === "object" ? (() => {
604
607
  const { primary, secondary, both, open, capped } = counted.value;
@@ -610,13 +613,7 @@ async function workload(resource, id, opts = {}) {
610
613
  ...joined,
611
614
  value: { ...joined.value, totalsAbsent: counted.absent ?? "NO_TOTALS" }
612
615
  } : joined;
613
- const taskIds = chunkV2GE763R_cjs.numericIds(
614
- assignments.value?.items ?? [],
615
- "serviceCallTaskID"
616
- ).slice(0, chunkV2GE763R_cjs.IN_FILTER_CAP);
617
- const taskDetails = taskIds.length === 0 ? { value: null, absent: "NO_ASSIGNMENTS" } : await chunkV2GE763R_cjs.compositePart(client, "service_call_tasks.query", [
618
- { filter: [{ field: "id", op: "in", value: taskIds }], limit: taskLimit }
619
- ]);
616
+ const { assignments, taskDetails } = assignmentBranch;
620
617
  return {
621
618
  root,
622
619
  parts: {
@@ -630,7 +627,7 @@ async function workload(resource, id, opts = {}) {
630
627
  }
631
628
 
632
629
  // src/resources/resources.ts
633
- var ResourcesResource = class extends chunkV2GE763R_cjs.GenericResource {
630
+ var ResourcesResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
634
631
  clientConfig;
635
632
  constructor(http, clientConfig, pageSize) {
636
633
  super(http, {
@@ -662,24 +659,24 @@ var ResourcesResource = class extends chunkV2GE763R_cjs.GenericResource {
662
659
  // src/resources/special/service_calls.ts
663
660
  var OP2 = "service_calls.fullProfile";
664
661
  async function fullProfile2(resource, id, opts = {}) {
665
- const client = chunkV2GE763R_cjs.clientOf(resource, OP2);
666
- const ticketLimit = chunkV2GE763R_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", OP2);
667
- const taskLimit = chunkV2GE763R_cjs.compositePartLimit(opts.taskLimit, "taskLimit", OP2);
668
- const callId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
669
- const root = await chunkV2GE763R_cjs.invokeRead(client, "service_calls.get", [callId]);
670
- const tickets = await chunkV2GE763R_cjs.compositePart(client, "service_call_tickets.query", [
671
- { filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: ticketLimit }
672
- ]);
673
- const tasks = await chunkV2GE763R_cjs.compositePart(client, "service_call_tasks.query", [
674
- { filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: taskLimit }
675
- ]);
676
- const taskIds = chunkV2GE763R_cjs.numericIds(
677
- tasks.value?.items ?? [],
678
- "id"
679
- ).slice(0, chunkV2GE763R_cjs.IN_FILTER_CAP);
680
- const resourceAssignments = taskIds.length === 0 ? { value: null, absent: "NO_TASKS" } : await chunkV2GE763R_cjs.compositePart(client, "service_call_task_resources.query", [
681
- { filter: [{ field: "serviceCallTaskID", op: "in", value: taskIds }], limit: taskLimit }
662
+ const client = chunkJLBSUZ5B_cjs.clientOf(resource, OP2);
663
+ const ticketLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", OP2);
664
+ const taskLimit = chunkJLBSUZ5B_cjs.compositePartLimit(opts.taskLimit, "taskLimit", OP2);
665
+ const callId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
666
+ const root = await chunkJLBSUZ5B_cjs.invokeRead(client, "service_calls.get", [callId]);
667
+ const [tickets, taskBranch] = await chunkJLBSUZ5B_cjs.readTasks(resource.http, [
668
+ () => chunkJLBSUZ5B_cjs.compositePart(client, "service_call_tickets.query", [
669
+ { filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: ticketLimit }
670
+ ]),
671
+ async () => {
672
+ const tasks2 = await chunkJLBSUZ5B_cjs.compositePart(client, "service_call_tasks.query", [
673
+ { filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: taskLimit }
674
+ ]);
675
+ const resourceAssignments2 = await chunkJLBSUZ5B_cjs.joinedCompositePart(client, tasks2, "id", "service_call_task_resources.query", "serviceCallTaskID", taskLimit, "NO_TASKS");
676
+ return { tasks: tasks2, resourceAssignments: resourceAssignments2 };
677
+ }
682
678
  ]);
679
+ const { tasks, resourceAssignments } = taskBranch;
683
680
  return {
684
681
  root,
685
682
  parts: {
@@ -691,7 +688,7 @@ async function fullProfile2(resource, id, opts = {}) {
691
688
  }
692
689
 
693
690
  // src/resources/service_calls.ts
694
- var ServiceCallsResource = class extends chunkV2GE763R_cjs.GenericResource {
691
+ var ServiceCallsResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
695
692
  constructor(http, pageSize) {
696
693
  super(http, {
697
694
  key: "service_calls",
@@ -713,13 +710,13 @@ var OP3 = "ticket_charges.moveToTicket";
713
710
  var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
714
711
  var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
715
712
  async function readCharge(http, id, retries) {
716
- const rows = await chunkV2GE763R_cjs.queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
713
+ const rows = await chunkJLBSUZ5B_cjs.queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
717
714
  return rows[0] ?? null;
718
715
  }
719
716
  async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
720
717
  if (source.isBilled === true) {
721
- throw chunkV2GE763R_cjs.refuse("MOVE_BLOCKED_BILLED", `${OP3}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP3, {
722
- manualAction: { action: "delete_source", uiLink: chunkV2GE763R_cjs.uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
718
+ throw chunkJLBSUZ5B_cjs.refuse("MOVE_BLOCKED_BILLED", `${OP3}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP3, {
719
+ manualAction: { action: "delete_source", uiLink: chunkJLBSUZ5B_cjs.uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
723
720
  });
724
721
  }
725
722
  }
@@ -753,14 +750,14 @@ var SPEC = {
753
750
  ]
754
751
  }),
755
752
  // charges have no ExecuteCommand code: the parent ticket is the closest clickable target
756
- manualLink: (http, source) => typeof source.ticketID === "number" ? chunkV2GE763R_cjs.uiLinkFor(http, "tickets", source.ticketID) : null
753
+ manualLink: (http, source) => typeof source.ticketID === "number" ? chunkJLBSUZ5B_cjs.uiLinkFor(http, "tickets", source.ticketID) : null
757
754
  };
758
755
  function moveToTicket(resource, sourceId, toTicketId, opts) {
759
- return chunkV2GE763R_cjs.runMove(resource.http, SPEC, sourceId, toTicketId, opts);
756
+ return chunkJLBSUZ5B_cjs.runMove(resource.http, SPEC, sourceId, toTicketId, opts);
760
757
  }
761
758
 
762
759
  // src/resources/ticket_charges.ts
763
- var TicketChargesResource = class extends chunkV2GE763R_cjs.GenericResource {
760
+ var TicketChargesResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
764
761
  constructor(http, pageSize) {
765
762
  super(http, {
766
763
  key: "ticket_charges",
@@ -785,7 +782,7 @@ var TicketChargesResource = class extends chunkV2GE763R_cjs.GenericResource {
785
782
  };
786
783
 
787
784
  // src/resources/special/tickets/errors.ts
788
- var StatusUnknownError = class extends chunkV2GE763R_cjs.AutotaskError {
785
+ var StatusUnknownError = class extends chunkJLBSUZ5B_cjs.AutotaskError {
789
786
  /** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
790
787
  picklistCount;
791
788
  constructor(message, options = {}) {
@@ -799,7 +796,7 @@ var StatusUnknownError = class extends chunkV2GE763R_cjs.AutotaskError {
799
796
  this.picklistCount = options.picklistCount ?? 0;
800
797
  }
801
798
  };
802
- var StatusFieldsRequiredError = class extends chunkV2GE763R_cjs.AutotaskError {
799
+ var StatusFieldsRequiredError = class extends chunkJLBSUZ5B_cjs.AutotaskError {
803
800
  vendorFields;
804
801
  currentStatus;
805
802
  targetStatus;
@@ -821,8 +818,8 @@ function isPositiveInt(v) {
821
818
  return typeof v === "number" && Number.isInteger(v) && v > 0;
822
819
  }
823
820
  function namedVendorFields(err) {
824
- if (!chunkV2GE763R_cjs.isAutotaskError(err) || err.vendorError === void 0) return [];
825
- const entries = chunkV2GE763R_cjs.parseVendorErrors(err.vendorError) ?? [];
821
+ if (!chunkJLBSUZ5B_cjs.isAutotaskError(err) || err.vendorError === void 0) return [];
822
+ const entries = chunkJLBSUZ5B_cjs.parseVendorErrors(err.vendorError) ?? [];
826
823
  const out = /* @__PURE__ */ new Set();
827
824
  for (const e of entries) if (e.field !== void 0) out.add(e.field);
828
825
  return [...out];
@@ -841,8 +838,8 @@ function unwrapItemOrNull(res) {
841
838
  return body.item;
842
839
  }
843
840
  function discoveryMerge(err, body, defaults) {
844
- if (!chunkV2GE763R_cjs.isAutotaskError(err) || err.vendorError === void 0) return null;
845
- const entries = chunkV2GE763R_cjs.parseVendorErrors(err.vendorError);
841
+ if (!chunkJLBSUZ5B_cjs.isAutotaskError(err) || err.vendorError === void 0) return null;
842
+ const entries = chunkJLBSUZ5B_cjs.parseVendorErrors(err.vendorError);
846
843
  if (entries === void 0) return null;
847
844
  for (const entry of entries) {
848
845
  const field = entry.field;
@@ -877,7 +874,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
877
874
  const ids = await readLiveStatusSet(resource);
878
875
  if (ids.size > 0) liveStatus = ids;
879
876
  } catch (err) {
880
- if (!chunkV2GE763R_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
877
+ if (!chunkJLBSUZ5B_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
881
878
  }
882
879
  if (liveStatus !== null && !liveStatus.has(targetStatus)) {
883
880
  http.fieldCache?.invalidate("tickets:");
@@ -887,7 +884,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
887
884
  const freshIds = await readLiveStatusSet(resource);
888
885
  if (freshIds.size > 0) freshStatus = freshIds;
889
886
  } catch (err) {
890
- if (!chunkV2GE763R_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
887
+ if (!chunkJLBSUZ5B_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
891
888
  freshStatus = null;
892
889
  reReadFailed = true;
893
890
  }
@@ -905,7 +902,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
905
902
  return { guardDegraded: liveStatus === null };
906
903
  }
907
904
  function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
908
- return chunkV2GE763R_cjs.buildDryRunResult(
905
+ return chunkJLBSUZ5B_cjs.buildDryRunResult(
909
906
  {
910
907
  operation: OP_STATUS,
911
908
  method: "PUT",
@@ -959,7 +956,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
959
956
  if (mapEntry === void 0) {
960
957
  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).`);
961
958
  }
962
- return chunkV2GE763R_cjs.buildDryRunResult(
959
+ return chunkJLBSUZ5B_cjs.buildDryRunResult(
963
960
  {
964
961
  operation: OP_STATUS,
965
962
  method: "PUT",
@@ -979,7 +976,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
979
976
  }
980
977
  async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
981
978
  const safeDefaults = mapEntry?.safeDefaults ?? {};
982
- const body = chunkV2GE763R_cjs.mergePartialBody(current, mergeData);
979
+ const body = chunkJLBSUZ5B_cjs.mergePartialBody(current, mergeData);
983
980
  body.id = ticketId;
984
981
  let merges = 0;
985
982
  for (; ; ) {
@@ -1003,8 +1000,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
1003
1000
  { vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
1004
1001
  {
1005
1002
  operation: OP_STATUS,
1006
- httpStatus: chunkV2GE763R_cjs.isAutotaskError(err) ? err.httpStatus : void 0,
1007
- vendorError: chunkV2GE763R_cjs.isAutotaskError(err) ? err.vendorError : void 0,
1003
+ httpStatus: chunkJLBSUZ5B_cjs.isAutotaskError(err) ? err.httpStatus : void 0,
1004
+ vendorError: chunkJLBSUZ5B_cjs.isAutotaskError(err) ? err.vendorError : void 0,
1008
1005
  resourceIds: [ticketId],
1009
1006
  details: { idRefs: [{ entity: "ticket", id: ticketId }] }
1010
1007
  }
@@ -1017,7 +1014,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
1017
1014
  async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
1018
1015
  const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
1019
1016
  if (verify === null) {
1020
- throw new chunkV2GE763R_cjs.AutotaskError(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
1017
+ throw new chunkJLBSUZ5B_cjs.AutotaskError(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
1021
1018
  code: "INVALID_RESPONSE",
1022
1019
  category: "server",
1023
1020
  operation: OP_STATUS,
@@ -1027,7 +1024,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
1027
1024
  }
1028
1025
  const finalStatus = typeof verify.status === "number" ? verify.status : null;
1029
1026
  if (finalStatus !== targetStatus) {
1030
- throw new chunkV2GE763R_cjs.AutotaskError(
1027
+ throw new chunkJLBSUZ5B_cjs.AutotaskError(
1031
1028
  `changeStatus: the post-PUT read-back shows status ${finalStatus ?? "unknown"} (the vendor 200ed the PUT but did not apply ${targetStatus} \u2014 the F-A1 lesson: the 200 proves nothing)`,
1032
1029
  {
1033
1030
  code: "INVALID_RESPONSE",
@@ -1043,17 +1040,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
1043
1040
  }
1044
1041
  async function changeStatus(resource, id, targetStatus, fields, opts) {
1045
1042
  const http = resource.http;
1046
- const ticketId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1043
+ const ticketId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1047
1044
  if (!isPositiveInt(targetStatus)) {
1048
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
1045
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
1049
1046
  }
1050
1047
  const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
1051
1048
  if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
1052
- throw new chunkV2GE763R_cjs.AutotaskConfigError("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
1049
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
1053
1050
  }
1054
1051
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
1055
1052
  if (current === null) {
1056
- throw new chunkV2GE763R_cjs.NotFoundError(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
1053
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
1057
1054
  }
1058
1055
  const previousStatus = typeof current.status === "number" ? current.status : null;
1059
1056
  if (previousStatus === targetStatus) {
@@ -1079,7 +1076,7 @@ var TICKET_FIELDS = ["id", "ticketNumber", "title", "status", "assignedResourceI
1079
1076
  function positiveId(value, name) {
1080
1077
  const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
1081
1078
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
1082
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
1079
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
1083
1080
  }
1084
1081
  return n;
1085
1082
  }
@@ -1091,7 +1088,7 @@ async function ticketPage(http, filter, maxRecords, fields) {
1091
1088
  body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
1092
1089
  operation: OP4
1093
1090
  });
1094
- const page = chunkV2GE763R_cjs.unwrapItems(res, OP4);
1091
+ const page = chunkJLBSUZ5B_cjs.unwrapItems(res, OP4);
1095
1092
  return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
1096
1093
  }
1097
1094
  async function readLinkIds(http, resourceID, maxPages = 1) {
@@ -1101,11 +1098,11 @@ async function readLinkIds(http, resourceID, maxPages = 1) {
1101
1098
  const res = await http.request({
1102
1099
  method: "POST",
1103
1100
  idempotent: true,
1104
- path: cursor === null ? "/V1.0/TicketSecondaryResources/query" : chunkV2GE763R_cjs.cursorToPath(http.baseUrl, cursor),
1101
+ path: cursor === null ? "/V1.0/TicketSecondaryResources/query" : chunkJLBSUZ5B_cjs.cursorToPath(http.baseUrl, cursor),
1105
1102
  body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
1106
1103
  operation: OP4
1107
1104
  });
1108
- const page = chunkV2GE763R_cjs.unwrapItems(res, OP4);
1105
+ const page = chunkJLBSUZ5B_cjs.unwrapItems(res, OP4);
1109
1106
  for (const row of page.items) if (typeof row.ticketID === "number") ids.add(row.ticketID);
1110
1107
  cursor = page.pageDetails.nextPageUrl;
1111
1108
  if (cursor === null || page.items.length === 0) return { ids: [...ids], capped: false };
@@ -1114,35 +1111,35 @@ async function readLinkIds(http, resourceID, maxPages = 1) {
1114
1111
  }
1115
1112
  async function forResource(_resource, resourceIDIn, opts = {}) {
1116
1113
  const http = _resource.http;
1117
- if (opts === null || typeof opts !== "object") throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: opts must be an object`, { operation: OP4 });
1114
+ if (opts === null || typeof opts !== "object") throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: opts must be an object`, { operation: OP4 });
1118
1115
  const resourceID = positiveId(resourceIDIn, "resourceID");
1119
1116
  const scope = opts.scope ?? "both";
1120
1117
  if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
1121
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
1118
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
1122
1119
  }
1123
1120
  if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
1124
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
1121
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
1125
1122
  }
1126
1123
  const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
1127
1124
  if (opts.countOnly !== true && (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX)) {
1128
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
1125
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
1129
1126
  }
1130
1127
  const includeFields = opts.includeFields ?? [];
1131
1128
  if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
1132
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
1129
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
1133
1130
  }
1134
1131
  const openOnly = opts.openOnly === true;
1135
1132
  const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS, ...includeFields])];
1136
1133
  if (opts.countOnly !== void 0 && typeof opts.countOnly !== "boolean") {
1137
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`${OP4}: countOnly must be a boolean`, { operation: OP4 });
1134
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`${OP4}: countOnly must be a boolean`, { operation: OP4 });
1138
1135
  }
1139
- const closed = await chunkV2GE763R_cjs.resolveTicketStatusSemantics(
1136
+ const closed = await chunkJLBSUZ5B_cjs.resolveTicketStatusSemantics(
1140
1137
  http,
1141
1138
  { ...opts.excludeStatusIds === void 0 ? {} : { excludeStatusIds: opts.excludeStatusIds }, ...opts.allowAssumed === void 0 ? {} : { allowAssumed: opts.allowAssumed } },
1142
1139
  OP4
1143
1140
  );
1144
1141
  const closedStatus = { closedIds: closed.closedIds, source: closed.source, note: closed.note };
1145
- const openLeaf = openOnly || opts.countOnly === true ? [chunkV2GE763R_cjs.openStatusFilter(closed.closedIds)] : [];
1142
+ const openLeaf = openOnly || opts.countOnly === true ? [chunkJLBSUZ5B_cjs.openStatusFilter(closed.closedIds)] : [];
1146
1143
  if (opts.countOnly === true) {
1147
1144
  const primaryCount = scope === "secondary" ? 0 : await _resource.count({ filter: [{ field: "assignedResourceID", op: "eq", value: resourceID }, ...openLeaf] });
1148
1145
  let secondaryCount = 0;
@@ -1156,7 +1153,7 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
1156
1153
  const page = await ticketPage(http, [{ field: "id", op: "in", value: chunk }, ...openLeaf], chunk.length, ["id", "status", "assignedResourceID"]);
1157
1154
  const seen = /* @__PURE__ */ new Set();
1158
1155
  for (const t of page.rows) {
1159
- if (typeof t.id !== "number" || seen.has(t.id) || chunkV2GE763R_cjs.isClosedStatus(t.status, closed.closedIds)) continue;
1156
+ if (typeof t.id !== "number" || seen.has(t.id) || chunkJLBSUZ5B_cjs.isClosedStatus(t.status, closed.closedIds)) continue;
1160
1157
  seen.add(t.id);
1161
1158
  if (scope === "both" && t.assignedResourceID === resourceID) bothCount++;
1162
1159
  }
@@ -1202,13 +1199,13 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
1202
1199
  for (const [id, t] of primary) merged.set(id, t);
1203
1200
  for (const [id, t] of secondary) if (!merged.has(id)) merged.set(id, t);
1204
1201
  let tickets = [...merged.values()];
1205
- if (openOnly) tickets = tickets.filter((t) => !chunkV2GE763R_cjs.isClosedStatus(t.status, closed.closedIds));
1202
+ if (openOnly) tickets = tickets.filter((t) => !chunkJLBSUZ5B_cjs.isClosedStatus(t.status, closed.closedIds));
1206
1203
  tickets.sort((a, b) => Number(a.id) - Number(b.id));
1207
1204
  if (tickets.length > limit) {
1208
1205
  tickets = tickets.slice(0, limit);
1209
1206
  capped = true;
1210
1207
  }
1211
- const openCount = tickets.filter((t) => !chunkV2GE763R_cjs.isClosedStatus(t.status, closed.closedIds)).length;
1208
+ const openCount = tickets.filter((t) => !chunkJLBSUZ5B_cjs.isClosedStatus(t.status, closed.closedIds)).length;
1212
1209
  const primaryIds = [...primary.keys()].sort((a, b) => a - b);
1213
1210
  const secondaryIds = [...secondary.keys()].sort((a, b) => a - b);
1214
1211
  const both = primaryIds.filter((id) => secondary.has(id));
@@ -1227,6 +1224,12 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
1227
1224
  };
1228
1225
  }
1229
1226
 
1227
+ // src/resources/special/tickets/context.ts
1228
+ function ticketContextValue(ticket, parts) {
1229
+ const [company, contact, resource, project] = parts;
1230
+ return { ticket, company, contact, resource, project };
1231
+ }
1232
+
1230
1233
  // src/resources/special/tickets/common.ts
1231
1234
  async function fetchTicket(http, id, operation) {
1232
1235
  const res = await http.request({
@@ -1236,9 +1239,9 @@ async function fetchTicket(http, id, operation) {
1236
1239
  });
1237
1240
  const body = res;
1238
1241
  if (body === null || !("item" in body)) {
1239
- throw new chunkV2GE763R_cjs.NotFoundError(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1242
+ throw new chunkJLBSUZ5B_cjs.NotFoundError(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1240
1243
  }
1241
- if (body.item === null || body.item === void 0) throw new chunkV2GE763R_cjs.NotFoundError(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1244
+ if (body.item === null || body.item === void 0) throw new chunkJLBSUZ5B_cjs.NotFoundError(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1242
1245
  return body.item;
1243
1246
  }
1244
1247
  async function ticketQueryItems(http, path, filter, maxRecords, operation) {
@@ -1249,7 +1252,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
1249
1252
  body: { MaxRecords: maxRecords, filter },
1250
1253
  operation
1251
1254
  });
1252
- return chunkV2GE763R_cjs.unwrapItems(res).items;
1255
+ return chunkJLBSUZ5B_cjs.unwrapItems(res).items;
1253
1256
  }
1254
1257
  function truncate(text, limit) {
1255
1258
  const full = text ?? "";
@@ -1259,27 +1262,27 @@ function truncate(text, limit) {
1259
1262
 
1260
1263
  // src/resources/special/tickets/childRead.ts
1261
1264
  function isRouteUnavailable(err) {
1262
- return chunkV2GE763R_cjs.isAutotaskError(err) && (err.httpStatus === 404 || err.httpStatus === 500);
1265
+ return chunkJLBSUZ5B_cjs.isAutotaskError(err) && (err.httpStatus === 404 || err.httpStatus === 500);
1263
1266
  }
1264
1267
  function routeFact(route, path, err) {
1265
1268
  return {
1266
1269
  route,
1267
1270
  path,
1268
- httpStatus: chunkV2GE763R_cjs.isAutotaskError(err) && typeof err.httpStatus === "number" ? err.httpStatus : null
1271
+ httpStatus: chunkJLBSUZ5B_cjs.isAutotaskError(err) && typeof err.httpStatus === "number" ? err.httpStatus : null
1269
1272
  };
1270
1273
  }
1271
1274
  async function childDeclaresQuery(resourceKey) {
1272
- const records = await chunkSGH7F2CH_cjs.loadCapabilityRecords();
1275
+ const records = await chunkKAZE4WC7_cjs.loadCapabilityRecords();
1273
1276
  return records.some(
1274
1277
  (c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
1275
1278
  );
1276
1279
  }
1277
1280
  async function planScopedPath(resourceKey, ticketId) {
1278
1281
  if (!await childDeclaresQuery(resourceKey)) return null;
1279
- const entry = chunkV2GE763R_cjs.RELATIONSHIP_MAP[resourceKey];
1282
+ const entry = chunkJLBSUZ5B_cjs.RELATIONSHIP_MAP[resourceKey];
1280
1283
  const parent = entry === void 0 ? null : entry.parent;
1281
1284
  if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
1282
- const parentPath = chunkV2GE763R_cjs.RELATIONSHIP_MAP[parent.resource]?.path;
1285
+ const parentPath = chunkJLBSUZ5B_cjs.RELATIONSHIP_MAP[parent.resource]?.path;
1283
1286
  if (parentPath === null || parentPath === void 0) return null;
1284
1287
  return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
1285
1288
  }
@@ -1318,14 +1321,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
1318
1321
  break;
1319
1322
  }
1320
1323
  const body = await http.request({ method: "GET", path: target, operation });
1321
- const { items: pageItems, pageDetails } = chunkV2GE763R_cjs.unwrapItems(body, operation);
1324
+ const { items: pageItems, pageDetails } = chunkJLBSUZ5B_cjs.unwrapItems(body, operation);
1322
1325
  nextCursor = pageDetails.nextPageUrl;
1323
1326
  pages += 1;
1324
1327
  const window = pageItems.slice(0, Math.max(0, limit - items.length));
1325
1328
  for (const row of window) if (accept(row)) items.push(row);
1326
1329
  if (items.length >= limit) break;
1327
1330
  if (nextCursor === null || pageItems.length === 0) break;
1328
- target = chunkV2GE763R_cjs.cursorToPath(http.baseUrl, nextCursor);
1331
+ target = chunkJLBSUZ5B_cjs.cursorToPath(http.baseUrl, nextCursor);
1329
1332
  }
1330
1333
  const capped = items.length >= limit || guard && nextCursor !== null;
1331
1334
  return { items, capped };
@@ -1358,7 +1361,7 @@ var DEFAULT_PART_LIMIT = 50;
1358
1361
  function partLimit(value, name) {
1359
1362
  const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
1360
1363
  if (!Number.isInteger(n) || n < 1) {
1361
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
1364
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
1362
1365
  }
1363
1366
  return n;
1364
1367
  }
@@ -1371,13 +1374,13 @@ function servedTextRecord(row, textField, limit) {
1371
1374
  return out;
1372
1375
  }
1373
1376
  async function addCompositeNames(http, ctx, entriesPart, result, opts) {
1374
- const builder = chunkV2GE763R_cjs.createNamePlan(chunkV2GE763R_cjs.TICKET_LABEL_FIELDS);
1377
+ const builder = chunkJLBSUZ5B_cjs.createNamePlan(chunkJLBSUZ5B_cjs.TICKET_LABEL_FIELDS);
1375
1378
  const t = ctx.ticket;
1376
1379
  builder.addResource(t["creatorResourceID"]);
1377
1380
  builder.addFk("contract", t["contractID"]);
1378
1381
  builder.addFk("billingCode", t["billingCodeID"]);
1379
1382
  builder.addFk("role", t["assignedResourceRoleID"]);
1380
- const ticketLobPointer = chunkV2GE763R_cjs.vendorId(t["organizationalLevelAssociationID"]);
1383
+ const ticketLobPointer = chunkJLBSUZ5B_cjs.vendorId(t["organizationalLevelAssociationID"]);
1381
1384
  if (ticketLobPointer !== void 0) {
1382
1385
  builder.addLineOfBusiness(ticketLobPointer, { source: "ticket" });
1383
1386
  } else {
@@ -1389,20 +1392,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
1389
1392
  builder.addFk("billingCode", e["billingCodeID"]);
1390
1393
  builder.addFk("contract", e["contractID"]);
1391
1394
  }
1392
- const names = await chunkV2GE763R_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
1395
+ const names = await chunkJLBSUZ5B_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
1393
1396
  const ticketRow = { ...ctx.ticket };
1394
- chunkV2GE763R_cjs.addNameSibling(ticketRow, "creatorResourceID", (v) => names.resourceName(v));
1395
- chunkV2GE763R_cjs.addNameSibling(ticketRow, "contractID", (v) => names.recordName("contract", v));
1396
- chunkV2GE763R_cjs.addNameSibling(ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
1397
- chunkV2GE763R_cjs.addNameSibling(ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
1398
- for (const f of chunkV2GE763R_cjs.TICKET_LABEL_FIELDS) chunkV2GE763R_cjs.addLabelSibling(ticketRow, f, names);
1397
+ chunkJLBSUZ5B_cjs.addNameSibling(ticketRow, "creatorResourceID", (v) => names.resourceName(v));
1398
+ chunkJLBSUZ5B_cjs.addNameSibling(ticketRow, "contractID", (v) => names.recordName("contract", v));
1399
+ chunkJLBSUZ5B_cjs.addNameSibling(ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
1400
+ chunkJLBSUZ5B_cjs.addNameSibling(ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
1401
+ for (const f of chunkJLBSUZ5B_cjs.TICKET_LABEL_FIELDS) chunkJLBSUZ5B_cjs.addLabelSibling(ticketRow, f, names);
1399
1402
  result.ticket = ticketRow;
1400
1403
  result.timeEntries.items = entriesPart.items.map((e) => {
1401
1404
  const row = { ...e };
1402
- chunkV2GE763R_cjs.addNameSibling(row, "resourceID", (v) => names.resourceName(v));
1403
- chunkV2GE763R_cjs.addNameSibling(row, "roleID", (v) => names.recordName("role", v));
1404
- chunkV2GE763R_cjs.addNameSibling(row, "billingCodeID", (v) => names.recordName("billingCode", v));
1405
- chunkV2GE763R_cjs.addNameSibling(row, "contractID", (v) => names.recordName("contract", v));
1405
+ chunkJLBSUZ5B_cjs.addNameSibling(row, "resourceID", (v) => names.resourceName(v));
1406
+ chunkJLBSUZ5B_cjs.addNameSibling(row, "roleID", (v) => names.recordName("role", v));
1407
+ chunkJLBSUZ5B_cjs.addNameSibling(row, "billingCodeID", (v) => names.recordName("billingCode", v));
1408
+ chunkJLBSUZ5B_cjs.addNameSibling(row, "contractID", (v) => names.recordName("contract", v));
1406
1409
  return row;
1407
1410
  });
1408
1411
  result.names = names.section;
@@ -1414,17 +1417,23 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
1414
1417
  };
1415
1418
  result.truncated = result.truncated || names.section.truncated;
1416
1419
  }
1417
- async function fullContext(resource, id, opts = {}) {
1420
+ async function fullContext(resource, id, opts = {}, loadContext) {
1418
1421
  const http = resource.http;
1419
1422
  const noteLimit = partLimit(opts.noteLimit, "noteLimit");
1420
1423
  const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
1421
1424
  const textLimit = partLimit(opts.textLimit, "textLimit");
1422
- const ticketId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1423
- const ctx = await resource.getContext(ticketId);
1425
+ const ticketId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1426
+ const { ticket, tasks: contextTasks } = await loadContext();
1424
1427
  const op = "tickets.fullContext";
1425
1428
  const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
1426
- const notes = await ticketChildRead(http, { globalPath: "/V1.0/TicketNotes/query", resourceKey: "ticket_notes", filter: ticketFilter, limit: noteLimit, operation: op }, ticketId);
1427
- const entries = await ticketChildRead(http, { globalPath: "/V1.0/TimeEntries/query", resourceKey: "time_entries", filter: ticketFilter, limit: timeEntryLimit, operation: op }, ticketId);
1429
+ const [company, contact, assignedResource, project, notes, entries, attachmentsRead, historiesRead] = await chunkJLBSUZ5B_cjs.readTasks(http, [
1430
+ ...contextTasks,
1431
+ () => ticketChildRead(http, { globalPath: "/V1.0/TicketNotes/query", resourceKey: "ticket_notes", filter: ticketFilter, limit: noteLimit, operation: op }, ticketId),
1432
+ () => ticketChildRead(http, { globalPath: "/V1.0/TimeEntries/query", resourceKey: "time_entries", filter: ticketFilter, limit: timeEntryLimit, operation: op }, ticketId),
1433
+ () => opts.includeAttachments !== false ? ticketChildRead(http, { globalPath: "/V1.0/TicketAttachments/query", resourceKey: "ticket_attachments", filter: ticketFilter, limit: DEFAULT_PART_LIMIT, operation: op }, ticketId) : Promise.resolve(void 0),
1434
+ () => opts.includeHistories === true ? ticketChildRead(http, { globalPath: "/V1.0/TicketHistory/query", resourceKey: "ticket_history", filter: ticketFilter, limit: DEFAULT_PART_LIMIT, operation: op }, ticketId) : Promise.resolve(void 0)
1435
+ ]);
1436
+ const ctx = ticketContextValue(ticket, [company, contact, assignedResource, project]);
1428
1437
  const notesRows = notes.items.map((n) => servedTextRecord(n, "description", textLimit));
1429
1438
  const notesPart = { items: notesRows, capped: notes.capped };
1430
1439
  applyRouteStatus(notesPart, notes);
@@ -1433,8 +1442,8 @@ async function fullContext(resource, id, opts = {}) {
1433
1442
  const notesTextTruncated = notesRows.some((n) => n.descriptionTruncated === true);
1434
1443
  let attachments = { ids: [], names: [], capped: false };
1435
1444
  let attachmentsStatus = "ok";
1436
- if (opts.includeAttachments !== false) {
1437
- const read = await ticketChildRead(http, { globalPath: "/V1.0/TicketAttachments/query", resourceKey: "ticket_attachments", filter: ticketFilter, limit: DEFAULT_PART_LIMIT, operation: op }, ticketId);
1445
+ if (attachmentsRead !== void 0) {
1446
+ const read = attachmentsRead;
1438
1447
  attachmentsStatus = read.status;
1439
1448
  attachments = {
1440
1449
  ids: read.items.map((r) => Number(r.id)),
@@ -1463,8 +1472,7 @@ async function fullContext(resource, id, opts = {}) {
1463
1472
  attachments: attachmentsStatus
1464
1473
  }
1465
1474
  };
1466
- if (opts.includeHistories === true) {
1467
- const historiesRead = await ticketChildRead(http, { globalPath: "/V1.0/TicketHistory/query", resourceKey: "ticket_history", filter: ticketFilter, limit: DEFAULT_PART_LIMIT, operation: op }, ticketId);
1475
+ if (historiesRead !== void 0) {
1468
1476
  const historyRows = historiesRead.items.map((h) => servedTextRecord(h, "detail", textLimit));
1469
1477
  const part = { items: historyRows, capped: historiesRead.capped };
1470
1478
  applyRouteStatus(part, historiesRead);
@@ -1481,7 +1489,7 @@ var OP5 = "tickets.lineOfBusiness";
1481
1489
  function positiveId2(value, name) {
1482
1490
  const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
1483
1491
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
1484
- throw new chunkV2GE763R_cjs.AutotaskConfigError(OP5 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP5 });
1492
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(OP5 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP5 });
1485
1493
  }
1486
1494
  return n;
1487
1495
  }
@@ -1497,25 +1505,25 @@ async function lineOfBusiness(resource, ticketIdIn, associationIdIn) {
1497
1505
  associationSource = "argument";
1498
1506
  } else {
1499
1507
  const ticket = await resource.get(ticketId);
1500
- associationId = chunkV2GE763R_cjs.vendorId(ticket.organizationalLevelAssociationID);
1508
+ associationId = chunkJLBSUZ5B_cjs.vendorId(ticket.organizationalLevelAssociationID);
1501
1509
  if (associationId !== void 0) {
1502
1510
  associationSource = "ticket";
1503
1511
  } else {
1504
- const contractRef = chunkV2GE763R_cjs.vendorId(ticket.contractID);
1512
+ const contractRef = chunkJLBSUZ5B_cjs.vendorId(ticket.contractID);
1505
1513
  if (contractRef !== void 0) {
1506
1514
  const client = http.client;
1507
1515
  if (client === void 0) {
1508
- throw new chunkV2GE763R_cjs.AutotaskConfigError(OP5 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP5 });
1516
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(OP5 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP5 });
1509
1517
  }
1510
1518
  try {
1511
1519
  const contract = await client.contracts.get(contractRef);
1512
1520
  contractId = contractRef;
1513
- associationId = chunkV2GE763R_cjs.vendorId(contract.organizationalLevelAssociationID);
1521
+ associationId = chunkJLBSUZ5B_cjs.vendorId(contract.organizationalLevelAssociationID);
1514
1522
  if (associationId !== void 0) associationSource = "contract";
1515
1523
  } catch (e) {
1516
- if (e instanceof chunkV2GE763R_cjs.NotFoundError) {
1524
+ if (e instanceof chunkJLBSUZ5B_cjs.NotFoundError) {
1517
1525
  contractId = contractRef;
1518
- } else if (chunkV2GE763R_cjs.isAutotaskError(e) && e.code !== "ABORTED") {
1526
+ } else if (chunkJLBSUZ5B_cjs.isAutotaskError(e) && e.code !== "ABORTED") {
1519
1527
  contractId = contractRef;
1520
1528
  contractUnread = true;
1521
1529
  } else {
@@ -1536,7 +1544,7 @@ async function lineOfBusiness(resource, ticketIdIn, associationIdIn) {
1536
1544
  markers: { association: contractUnread ? "unresolved" : "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
1537
1545
  };
1538
1546
  }
1539
- const chain = await chunkV2GE763R_cjs.resolveLineOfBusinessChain(http, associationId, { budget: 3, operation: OP5, onError: "propagate" });
1547
+ const chain = await chunkJLBSUZ5B_cjs.resolveLineOfBusinessChain(http, associationId, { budget: 3, operation: OP5, onError: "propagate" });
1540
1548
  const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
1541
1549
  return { ticketId, associationSource, contractId, association, organizationalLevel2, organizationalLevel1, markers };
1542
1550
  }
@@ -1546,7 +1554,7 @@ var MS = 864e5;
1546
1554
  var SLA_PAGE = 100;
1547
1555
  async function slaHealthCheck(_resource, id, opts = {}) {
1548
1556
  const http = _resource.http;
1549
- const ticketId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1557
+ const ticketId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1550
1558
  await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
1551
1559
  const rows = await ticketQueryItems(
1552
1560
  http,
@@ -1572,9 +1580,9 @@ async function summary(_resource, id, opts = {}) {
1572
1580
  const http = _resource.http;
1573
1581
  const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
1574
1582
  if (!Number.isInteger(limit) || limit < 1) {
1575
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
1583
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
1576
1584
  }
1577
- const ticketId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1585
+ const ticketId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1578
1586
  const ticket = await fetchTicket(http, ticketId, "tickets.summary");
1579
1587
  const desc = truncate(ticket.description, limit);
1580
1588
  const now = opts.now ?? /* @__PURE__ */ new Date();
@@ -1603,17 +1611,17 @@ async function summary(_resource, id, opts = {}) {
1603
1611
  // src/resources/special/tickets/statusSemantics.ts
1604
1612
  async function statusSemantics(_resource, opts = {}) {
1605
1613
  const http = _resource.http;
1606
- return chunkV2GE763R_cjs.resolveTicketStatusSemantics(http, opts);
1614
+ return chunkJLBSUZ5B_cjs.resolveTicketStatusSemantics(http, opts);
1607
1615
  }
1608
1616
 
1609
1617
  // src/resources/special/tickets/timeline.ts
1610
1618
  function validateTimelineLimits(opts) {
1611
1619
  const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
1612
- if (!Number.isInteger(limit) || limit < 1) throw new chunkV2GE763R_cjs.AutotaskConfigError(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
1620
+ if (!Number.isInteger(limit) || limit < 1) throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
1613
1621
  const bounded = Math.min(limit, 500);
1614
1622
  const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
1615
1623
  if (!Number.isInteger(textLimit) || textLimit < 1) {
1616
- throw new chunkV2GE763R_cjs.AutotaskConfigError(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
1624
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
1617
1625
  }
1618
1626
  return { bounded, textLimit };
1619
1627
  }
@@ -1666,7 +1674,7 @@ function compareEventDates(a, b) {
1666
1674
  async function timeline(_resource, id, opts = {}) {
1667
1675
  const http = _resource.http;
1668
1676
  const { bounded, textLimit } = validateTimelineLimits(opts);
1669
- const ticketId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1677
+ const ticketId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1670
1678
  await fetchTicket(http, ticketId, "tickets.timeline");
1671
1679
  const dateFilters = (field) => {
1672
1680
  const f = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -1706,7 +1714,7 @@ async function timeline(_resource, id, opts = {}) {
1706
1714
  }
1707
1715
 
1708
1716
  // src/resources/tickets.ts
1709
- var TicketsResource = class extends chunkV2GE763R_cjs.GenericResource {
1717
+ var TicketsResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
1710
1718
  constructor(http, pageSize) {
1711
1719
  super(http, {
1712
1720
  key: "tickets",
@@ -1731,13 +1739,19 @@ var TicketsResource = class extends chunkV2GE763R_cjs.GenericResource {
1731
1739
  /** Get the Ticket with its primary context records in one call (each part a single-record
1732
1740
  * fetch; no sub-lists; absent/dangling references come back null). */
1733
1741
  async getContext(id) {
1742
+ const { ticket, tasks } = await this.readTicketContext(id);
1743
+ return ticketContextValue(ticket, await chunkJLBSUZ5B_cjs.readTasks(this.http, tasks));
1744
+ }
1745
+ /** Root authority and reusable lazy FK tasks shared by both ticket composites. */
1746
+ async readTicketContext(id) {
1734
1747
  const ticket = await this.fetchRecordRaw("/V1.0/Tickets", id, true);
1735
1748
  const root = ticket;
1736
- const company = await this.contextFetch("/V1.0/Companies", root["companyID"]);
1737
- const contact = await this.contextFetch("/V1.0/Contacts", root["contactID"]);
1738
- const resource = await this.contextFetch("/V1.0/Resources", root["assignedResourceID"]);
1739
- const project = await this.contextFetch("/V1.0/Projects", root["projectID"]);
1740
- return { ticket, company, contact, resource, project };
1749
+ return { ticket, tasks: [
1750
+ () => this.contextFetch("/V1.0/Companies", root["companyID"]),
1751
+ () => this.contextFetch("/V1.0/Contacts", root["contactID"]),
1752
+ () => this.contextFetch("/V1.0/Resources", root["assignedResourceID"]),
1753
+ () => this.contextFetch("/V1.0/Projects", root["projectID"])
1754
+ ] };
1741
1755
  }
1742
1756
  /** Node-parity special op (hand-written in src/resources/special/tickets/changeStatus.ts). */
1743
1757
  changeStatus(id, targetStatus, fields, opts = {}) {
@@ -1757,7 +1771,7 @@ var TicketsResource = class extends chunkV2GE763R_cjs.GenericResource {
1757
1771
  }
1758
1772
  /** Node-parity special op (hand-written in src/resources/special/tickets/fullContext.ts). */
1759
1773
  fullContext(id, opts) {
1760
- return fullContext(this, id, opts);
1774
+ return fullContext(this, id, opts, () => this.readTicketContext(id));
1761
1775
  }
1762
1776
  /** Node-parity special op (hand-written in src/resources/special/tickets/statusSemantics.ts). */
1763
1777
  statusSemantics(opts) {
@@ -1775,9 +1789,9 @@ var TicketsResource = class extends chunkV2GE763R_cjs.GenericResource {
1775
1789
  // src/resources/special/time_off_requests.ts
1776
1790
  async function approve(_resource, id, opts = {}) {
1777
1791
  const http = _resource.http;
1778
- const numericId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1792
+ const numericId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1779
1793
  if (opts.dryRun === true) {
1780
- return chunkV2GE763R_cjs.buildDryRunResult({
1794
+ return chunkJLBSUZ5B_cjs.buildDryRunResult({
1781
1795
  operation: "time_off_requests.approve",
1782
1796
  method: "GET",
1783
1797
  path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
@@ -1793,17 +1807,17 @@ async function approve(_resource, id, opts = {}) {
1793
1807
  operation: "time_off_requests.approve",
1794
1808
  maxRetries: opts.maxRetries
1795
1809
  });
1796
- return chunkV2GE763R_cjs.unwrapOperation(res);
1810
+ return chunkJLBSUZ5B_cjs.unwrapOperation(res);
1797
1811
  }
1798
1812
  async function reject(_resource, id, reason, opts = {}) {
1799
1813
  const http = _resource.http;
1800
- const numericId = chunkV2GE763R_cjs.parseIdentifier(id, "id");
1814
+ const numericId = chunkJLBSUZ5B_cjs.parseIdentifier(id, "id");
1801
1815
  const text = reason.trim();
1802
1816
  if (text === "") {
1803
- throw new chunkV2GE763R_cjs.AutotaskConfigError("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
1817
+ throw new chunkJLBSUZ5B_cjs.AutotaskConfigError("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
1804
1818
  }
1805
1819
  if (opts.dryRun === true) {
1806
- return chunkV2GE763R_cjs.buildDryRunResult({
1820
+ return chunkJLBSUZ5B_cjs.buildDryRunResult({
1807
1821
  operation: "time_off_requests.reject",
1808
1822
  method: "POST",
1809
1823
  path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
@@ -1821,11 +1835,11 @@ async function reject(_resource, id, reason, opts = {}) {
1821
1835
  operation: "time_off_requests.reject",
1822
1836
  maxRetries: opts.maxRetries
1823
1837
  });
1824
- return chunkV2GE763R_cjs.unwrapOperation(res);
1838
+ return chunkJLBSUZ5B_cjs.unwrapOperation(res);
1825
1839
  }
1826
1840
 
1827
1841
  // src/resources/time_off_requests.ts
1828
- var TimeOffRequestsResource = class extends chunkV2GE763R_cjs.GenericResource {
1842
+ var TimeOffRequestsResource = class extends chunkJLBSUZ5B_cjs.GenericResource {
1829
1843
  constructor(http, pageSize) {
1830
1844
  super(http, {
1831
1845
  key: "time_off_requests",