node-autotask 0.88.0 → 0.88.1

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkGEFUSYH5_cjs = require('./chunk-GEFUSYH5.cjs');
3
+ var chunkYTOBU3Z6_cjs = require('./chunk-YTOBU3Z6.cjs');
4
4
  var chunkSHJ7EOBW_cjs = require('./chunk-SHJ7EOBW.cjs');
5
5
 
6
6
  // src/resources/special/configuration_items.ts
@@ -8,17 +8,17 @@ 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 chunkGEFUSYH5_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
11
+ throw new chunkYTOBU3Z6_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 = chunkGEFUSYH5_cjs.parseIdentifier(sourceId, "sourceId");
17
+ const numericSource = chunkYTOBU3Z6_cjs.parseIdentifier(sourceId, "sourceId");
18
18
  if (opts?.destinationCompanyId === void 0) {
19
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError("moveConfigurationItem: destinationCompanyId is required");
19
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("moveConfigurationItem: destinationCompanyId is required");
20
20
  }
21
- const destId = chunkGEFUSYH5_cjs.parseIdentifier(opts.destinationCompanyId, "destinationCompanyId");
21
+ const destId = chunkYTOBU3Z6_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 chunkGEFUSYH5_cjs.AutotaskConfigError("moveConfigurationItem: newReferenceTitle must be non-empty");
31
+ if (opts.newReferenceTitle.trim() === "") throw new chunkYTOBU3Z6_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 chunkGEFUSYH5_cjs.StaleObjectError(
37
+ throw new chunkYTOBU3Z6_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 chunkGEFUSYH5_cjs.buildDryRunResult({
44
+ return chunkYTOBU3Z6_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 chunkGEFUSYH5_cjs.AutotaskConfigError("moveConfigurationItem: vendor create response has no itemId");
69
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("moveConfigurationItem: vendor create response has no itemId");
70
70
  }
71
71
  let sourceDeactivated = false;
72
72
  if (opts.deactivateSource !== false) {
@@ -90,7 +90,7 @@ var CI_NAME_FKS = [
90
90
  function profilePartLimit(value, name) {
91
91
  const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
92
92
  if (!Number.isInteger(n) || n < 1) {
93
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
93
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
94
94
  }
95
95
  return n;
96
96
  }
@@ -99,17 +99,17 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
99
99
  return null;
100
100
  }
101
101
  try {
102
- const res = await chunkGEFUSYH5_cjs.cachedRecordGet(http, `${entityPath}/${referenceId}`, "configuration_items.profile");
102
+ const res = await chunkYTOBU3Z6_cjs.cachedRecordGet(http, `${entityPath}/${referenceId}`, "configuration_items.profile");
103
103
  const body = res;
104
104
  if (body === null || !("item" in body)) {
105
- throw new chunkGEFUSYH5_cjs.NotFoundError(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
105
+ throw new chunkYTOBU3Z6_cjs.NotFoundError(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
106
106
  }
107
107
  if (body.item === null || body.item === void 0) {
108
- throw new chunkGEFUSYH5_cjs.NotFoundError("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
108
+ throw new chunkYTOBU3Z6_cjs.NotFoundError("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
109
109
  }
110
110
  return body.item;
111
111
  } catch (err) {
112
- if (err instanceof chunkGEFUSYH5_cjs.NotFoundError) return null;
112
+ if (err instanceof chunkYTOBU3Z6_cjs.NotFoundError) return null;
113
113
  throw err;
114
114
  }
115
115
  }
@@ -117,7 +117,7 @@ async function degradable(read) {
117
117
  try {
118
118
  return { value: await read() };
119
119
  } catch (err) {
120
- if (chunkGEFUSYH5_cjs.isAutotaskError(err) && err.code !== "ABORTED") return { fault: err.code };
120
+ if (chunkYTOBU3Z6_cjs.isAutotaskError(err) && err.code !== "ABORTED") return { fault: err.code };
121
121
  throw err;
122
122
  }
123
123
  }
@@ -129,7 +129,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
129
129
  body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
130
130
  operation: "configuration_items.profile"
131
131
  });
132
- return chunkGEFUSYH5_cjs.unwrapItems(res).items;
132
+ return chunkYTOBU3Z6_cjs.unwrapItems(res).items;
133
133
  }
134
134
  async function profile(resource, id, opts = {}) {
135
135
  const http = resource.http;
@@ -139,7 +139,7 @@ async function profile(resource, id, opts = {}) {
139
139
  const ci = await resource.get(id);
140
140
  const root = ci;
141
141
  const productRef = root["productID"] === 0 ? null : root["productID"];
142
- const [type, category, productRead, notes, relatedItems, associations, subscriptionsRead] = await chunkGEFUSYH5_cjs.readTasks(http, [
142
+ const [type, category, productRead, notes, relatedItems, associations, subscriptionsRead] = await chunkYTOBU3Z6_cjs.readTasks(http, [
143
143
  () => contextFetchPart(http, "/V1.0/ConfigurationItemTypes", root["configurationItemType"], "configuration_item_type"),
144
144
  () => contextFetchPart(http, "/V1.0/ConfigurationItemCategories", root["configurationItemCategoryID"], "configuration_item_category"),
145
145
  () => degradable(() => contextFetchPart(http, "/V1.0/Products", productRef, "product")),
@@ -180,11 +180,11 @@ async function profile(resource, id, opts = {}) {
180
180
  };
181
181
  if (Object.keys(unavailable).length > 0) result.unavailable = unavailable;
182
182
  if (opts.names === true) {
183
- const builder = chunkGEFUSYH5_cjs.createNamePlan();
183
+ const builder = chunkYTOBU3Z6_cjs.createNamePlan();
184
184
  for (const [field, table] of CI_NAME_FKS) builder.addFk(table, root[field]);
185
- const names = await chunkGEFUSYH5_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
185
+ const names = await chunkYTOBU3Z6_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
186
186
  const ciRow = { ...ci };
187
- for (const [field, table] of CI_NAME_FKS) chunkGEFUSYH5_cjs.addNameSibling(ciRow, field, (v) => names.recordName(table, v));
187
+ for (const [field, table] of CI_NAME_FKS) chunkYTOBU3Z6_cjs.addNameSibling(ciRow, field, (v) => names.recordName(table, v));
188
188
  if (root["productID"] !== void 0) {
189
189
  const raw = product?.["name"];
190
190
  const name = typeof raw === "string" && raw.trim() !== "" ? raw : null;
@@ -200,7 +200,7 @@ async function profile(resource, id, opts = {}) {
200
200
  }
201
201
 
202
202
  // src/resources/configuration_items.ts
203
- var ConfigurationItemsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
203
+ var ConfigurationItemsResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
204
204
  constructor(http, pageSize) {
205
205
  super(http, {
206
206
  key: "configuration_items",
@@ -226,7 +226,7 @@ var ConfigurationItemsResource = class extends chunkGEFUSYH5_cjs.GenericResource
226
226
  async getContext(id) {
227
227
  const configurationItem = await this.fetchRecordRaw("/V1.0/ConfigurationItems", id);
228
228
  const root = configurationItem;
229
- const [company, contact, contract] = await chunkGEFUSYH5_cjs.readTasks(this.http, [
229
+ const [company, contact, contract] = await chunkYTOBU3Z6_cjs.readTasks(this.http, [
230
230
  () => this.contextFetch("/V1.0/Companies", root["companyID"]),
231
231
  () => this.contextFetch("/V1.0/Contacts", root["contactID"]),
232
232
  () => this.contextFetch("/V1.0/Contracts", root["contractID"])
@@ -248,23 +248,23 @@ async function fetchRecord2(http, path, label, readOpts) {
248
248
  const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: readOpts?.maxRetries });
249
249
  const body = res;
250
250
  if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
251
- throw new chunkGEFUSYH5_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
251
+ throw new chunkYTOBU3Z6_cjs.NotFoundError(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
252
252
  }
253
253
  return body.item;
254
254
  }
255
255
  async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}) {
256
256
  const http = _resource.http;
257
- const sourceId = chunkGEFUSYH5_cjs.parseIdentifier(sourceContactId, "sourceContactId");
258
- const destId = chunkGEFUSYH5_cjs.parseIdentifier(destinationCompanyId, "destinationCompanyId");
257
+ const sourceId = chunkYTOBU3Z6_cjs.parseIdentifier(sourceContactId, "sourceContactId");
258
+ const destId = chunkYTOBU3Z6_cjs.parseIdentifier(destinationCompanyId, "destinationCompanyId");
259
259
  const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
260
260
  const companyID = source.companyID;
261
261
  if (typeof companyID !== "number" || companyID < 0) {
262
- throw new chunkGEFUSYH5_cjs.NotFoundError(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
262
+ throw new chunkYTOBU3Z6_cjs.NotFoundError(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
263
263
  }
264
264
  if (opts.lastModifiedDate !== void 0) {
265
265
  const current = source.lastModifiedDate;
266
266
  if (current !== opts.lastModifiedDate) {
267
- throw new chunkGEFUSYH5_cjs.StaleObjectError(
267
+ throw new chunkYTOBU3Z6_cjs.StaleObjectError(
268
268
  `moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
269
269
  { operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
270
270
  );
@@ -286,10 +286,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
286
286
  },
287
287
  operation: "contacts.moveToCompany"
288
288
  });
289
- const items = chunkGEFUSYH5_cjs.unwrapItems(res).items;
289
+ const items = chunkYTOBU3Z6_cjs.unwrapItems(res).items;
290
290
  const clash = items.find((c) => String(c.id) !== String(sourceId));
291
291
  if (clash !== void 0) {
292
- throw new chunkGEFUSYH5_cjs.ConflictError(
292
+ throw new chunkYTOBU3Z6_cjs.ConflictError(
293
293
  `Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
294
294
  { resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
295
295
  );
@@ -303,7 +303,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
303
303
  if (opts.dryRun === true) {
304
304
  const warnings = [];
305
305
  if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
306
- return chunkGEFUSYH5_cjs.buildDryRunResult({
306
+ return chunkYTOBU3Z6_cjs.buildDryRunResult({
307
307
  operation: "contacts.moveToCompany",
308
308
  method: "POST",
309
309
  path: `/V1.0/Companies/${destId}/Contacts`,
@@ -329,7 +329,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
329
329
  const createdBody = created;
330
330
  const newId = createdBody !== null ? createdBody.itemId ?? createdBody.id : void 0;
331
331
  if (typeof newId !== "number") {
332
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError("contacts.moveToCompany: vendor create response has no itemId");
332
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("contacts.moveToCompany: vendor create response has no itemId");
333
333
  }
334
334
  let sourceDeleted = false;
335
335
  if (opts.deleteSource === true) {
@@ -345,27 +345,27 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
345
345
  }
346
346
  var FULL_PROFILE_OP = "contacts.fullProfile";
347
347
  async function fullProfile(resource, id, opts = {}) {
348
- const client = chunkGEFUSYH5_cjs.clientOf(resource, FULL_PROFILE_OP);
349
- const ticketLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", FULL_PROFILE_OP);
350
- const contactId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
351
- const envelope = await chunkGEFUSYH5_cjs.invokeRead(client, "contacts.query", [
348
+ const client = chunkYTOBU3Z6_cjs.clientOf(resource, FULL_PROFILE_OP);
349
+ const ticketLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", FULL_PROFILE_OP);
350
+ const contactId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
351
+ const envelope = await chunkYTOBU3Z6_cjs.invokeRead(client, "contacts.query", [
352
352
  { filter: [{ field: "id", op: "eq", value: contactId }], limit: 1 }
353
353
  ]);
354
354
  const row = (envelope.items ?? [])[0];
355
355
  if (row === void 0) {
356
- throw new chunkGEFUSYH5_cjs.NotFoundError(`Contact ${contactId} not found`, { operation: "contacts.get", httpStatus: 404 });
356
+ throw new chunkYTOBU3Z6_cjs.NotFoundError(`Contact ${contactId} not found`, { operation: "contacts.get", httpStatus: 404 });
357
357
  }
358
358
  const fk = typeof row.companyID === "number" && row.companyID > 0 ? row.companyID : null;
359
- const root = fk === null ? row : await chunkGEFUSYH5_cjs.invokeRead(client, "contacts.get", [fk, contactId]);
360
- const [company, openTickets] = await chunkGEFUSYH5_cjs.readTasks(resource.http, [
361
- async () => fk === null ? { value: null, absent: "NO_FK" } : await chunkGEFUSYH5_cjs.compositePart(client, "companies.get", [fk]),
362
- async () => await chunkGEFUSYH5_cjs.openTicketsOfPart(client, "contactID", contactId, ticketLimit)
359
+ const root = fk === null ? row : await chunkYTOBU3Z6_cjs.invokeRead(client, "contacts.get", [fk, contactId]);
360
+ const [company, openTickets] = await chunkYTOBU3Z6_cjs.readTasks(resource.http, [
361
+ async () => fk === null ? { value: null, absent: "NO_FK" } : await chunkYTOBU3Z6_cjs.compositePart(client, "companies.get", [fk]),
362
+ async () => await chunkYTOBU3Z6_cjs.openTicketsOfPart(client, "contactID", contactId, ticketLimit)
363
363
  ]);
364
364
  return { root, parts: { company, open_tickets: openTickets } };
365
365
  }
366
366
 
367
367
  // src/resources/contacts.ts
368
- var ContactsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
368
+ var ContactsResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
369
369
  constructor(http, pageSize) {
370
370
  super(http, {
371
371
  key: "contacts",
@@ -414,10 +414,10 @@ var PATH_SUFFIX = {
414
414
  };
415
415
  async function stockedItems(_resource, kind, parentId, data, opts = {}) {
416
416
  const http = _resource.http;
417
- const numericParent = chunkGEFUSYH5_cjs.parseIdentifier(parentId, "parentId");
417
+ const numericParent = chunkYTOBU3Z6_cjs.parseIdentifier(parentId, "parentId");
418
418
  const suffix = PATH_SUFFIX[kind];
419
419
  if (opts.dryRun === true) {
420
- return chunkGEFUSYH5_cjs.buildDryRunResult({
420
+ return chunkYTOBU3Z6_cjs.buildDryRunResult({
421
421
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
422
422
  method: "POST",
423
423
  path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
@@ -434,11 +434,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}) {
434
434
  operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
435
435
  maxRetries: opts.maxRetries
436
436
  });
437
- return chunkGEFUSYH5_cjs.unwrapOperation(res);
437
+ return chunkYTOBU3Z6_cjs.unwrapOperation(res);
438
438
  }
439
439
 
440
440
  // src/resources/inventory_products.ts
441
- var InventoryProductsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
441
+ var InventoryProductsResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
442
442
  constructor(http, pageSize) {
443
443
  super(http, {
444
444
  key: "inventory_products",
@@ -466,18 +466,18 @@ var InventoryProductsResource = class extends chunkGEFUSYH5_cjs.GenericResource
466
466
  // src/resources/special/quotes.ts
467
467
  var OP = "quotes.withItems";
468
468
  async function withItems(resource, id, opts = {}) {
469
- const client = chunkGEFUSYH5_cjs.clientOf(resource, OP);
470
- const itemLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.itemLimit, "itemLimit", OP);
471
- const quoteId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
472
- const root = await chunkGEFUSYH5_cjs.invokeRead(client, "quotes.get", [quoteId]);
473
- const items = await chunkGEFUSYH5_cjs.compositePart(client, "quote_items.query", [
469
+ const client = chunkYTOBU3Z6_cjs.clientOf(resource, OP);
470
+ const itemLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.itemLimit, "itemLimit", OP);
471
+ const quoteId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
472
+ const root = await chunkYTOBU3Z6_cjs.invokeRead(client, "quotes.get", [quoteId]);
473
+ const items = await chunkYTOBU3Z6_cjs.compositePart(client, "quote_items.query", [
474
474
  { filter: [{ field: "quoteID", op: "eq", value: quoteId }], limit: itemLimit }
475
475
  ]);
476
476
  return { root, parts: { items } };
477
477
  }
478
478
 
479
479
  // src/resources/quotes.ts
480
- var QuotesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
480
+ var QuotesResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
481
481
  constructor(http, pageSize) {
482
482
  super(http, {
483
483
  key: "quotes",
@@ -503,7 +503,7 @@ var QuotesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
503
503
  // src/resources/special/resource_time_off_additional.ts
504
504
  async function getByResource(_resource, resourceId) {
505
505
  const http = _resource.http;
506
- const numericResource = chunkGEFUSYH5_cjs.parseIdentifier(resourceId, "resourceId");
506
+ const numericResource = chunkYTOBU3Z6_cjs.parseIdentifier(resourceId, "resourceId");
507
507
  const res = await http.request({
508
508
  method: "GET",
509
509
  path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
@@ -517,11 +517,11 @@ async function getByResource(_resource, resourceId) {
517
517
  if (typeof item === "object" && !Array.isArray(item)) return [item];
518
518
  }
519
519
  }
520
- return chunkGEFUSYH5_cjs.unwrapItems(res, "resource_time_off_additional.getByResource").items;
520
+ return chunkYTOBU3Z6_cjs.unwrapItems(res, "resource_time_off_additional.getByResource").items;
521
521
  }
522
522
 
523
523
  // src/resources/resource_time_off_additional.ts
524
- var ResourceTimeOffAdditionalResource = class extends chunkGEFUSYH5_cjs.GenericResource {
524
+ var ResourceTimeOffAdditionalResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
525
525
  constructor(http, pageSize) {
526
526
  super(http, {
527
527
  key: "resource_time_off_additional",
@@ -542,30 +542,30 @@ var ResourceTimeOffAdditionalResource = class extends chunkGEFUSYH5_cjs.GenericR
542
542
  // src/resources/special/resource_time_off_balances.ts
543
543
  async function getByResource2(_resource, resourceId) {
544
544
  const http = _resource.http;
545
- const numericResource = chunkGEFUSYH5_cjs.parseIdentifier(resourceId, "resourceId");
545
+ const numericResource = chunkYTOBU3Z6_cjs.parseIdentifier(resourceId, "resourceId");
546
546
  const res = await http.request({
547
547
  method: "GET",
548
548
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
549
549
  operation: "resource_time_off_balances.getByResource"
550
550
  });
551
- return chunkGEFUSYH5_cjs.unwrapItems(res, "resource_time_off_balances.getByResource").items;
551
+ return chunkYTOBU3Z6_cjs.unwrapItems(res, "resource_time_off_balances.getByResource").items;
552
552
  }
553
553
  async function getByYear(_resource, resourceId, year) {
554
554
  const http = _resource.http;
555
- const numericResource = chunkGEFUSYH5_cjs.parseIdentifier(resourceId, "resourceId");
555
+ const numericResource = chunkYTOBU3Z6_cjs.parseIdentifier(resourceId, "resourceId");
556
556
  if (!Number.isSafeInteger(year) || year < 1) {
557
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError("getByYear: year must be a positive integer");
557
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("getByYear: year must be a positive integer");
558
558
  }
559
559
  const res = await http.request({
560
560
  method: "GET",
561
561
  path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
562
562
  operation: "resource_time_off_balances.getByYear"
563
563
  });
564
- return chunkGEFUSYH5_cjs.unwrapItem(res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
564
+ return chunkYTOBU3Z6_cjs.unwrapItem(res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
565
565
  }
566
566
 
567
567
  // src/resources/resource_time_off_balances.ts
568
- var ResourceTimeOffBalancesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
568
+ var ResourceTimeOffBalancesResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
569
569
  constructor(http, pageSize) {
570
570
  super(http, {
571
571
  key: "resource_time_off_balances",
@@ -591,7 +591,7 @@ var ResourceTimeOffBalancesResource = class extends chunkGEFUSYH5_cjs.GenericRes
591
591
  async function whoAmI(_resource, userName) {
592
592
  const http = _resource.http;
593
593
  const user = userName.trim();
594
- if (user === "") throw new chunkGEFUSYH5_cjs.AutotaskConfigError("whoAmI: the configured UserName is empty");
594
+ if (user === "") throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("whoAmI: the configured UserName is empty");
595
595
  const value = user.includes("@") ? user.split("@")[0] ?? "" : user;
596
596
  const res = await http.request({
597
597
  method: "POST",
@@ -600,11 +600,11 @@ async function whoAmI(_resource, userName) {
600
600
  body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
601
601
  operation: "resources.whoAmI"
602
602
  });
603
- const matches = chunkGEFUSYH5_cjs.unwrapItems(res).items;
603
+ const matches = chunkYTOBU3Z6_cjs.unwrapItems(res).items;
604
604
  if (matches.length === 0) return null;
605
605
  if (matches.length > 1) {
606
606
  const ids = matches.map((m) => m.id).filter((id) => typeof id === "number");
607
- throw new chunkGEFUSYH5_cjs.ResolutionError(
607
+ throw new chunkYTOBU3Z6_cjs.ResolutionError(
608
608
  `whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
609
609
  { code: "RESOLUTION_AMBIGUOUS", resourceIds: ids, details: { idRefs: ids.map((cid) => ({ entity: "resource", id: cid })) } }
610
610
  );
@@ -613,28 +613,28 @@ async function whoAmI(_resource, userName) {
613
613
  }
614
614
  var WORKLOAD_OP = "resources.workload";
615
615
  async function workload(resource, id, opts = {}) {
616
- const client = chunkGEFUSYH5_cjs.clientOf(resource, WORKLOAD_OP);
617
- const ticketLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", WORKLOAD_OP);
618
- const taskLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.taskLimit, "taskLimit", WORKLOAD_OP);
619
- const timeOffLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.timeOffLimit, "timeOffLimit", WORKLOAD_OP);
620
- const resourceId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
621
- const root = await chunkGEFUSYH5_cjs.invokeRead(client, "resources.get", [resourceId]);
616
+ const client = chunkYTOBU3Z6_cjs.clientOf(resource, WORKLOAD_OP);
617
+ const ticketLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", WORKLOAD_OP);
618
+ const taskLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.taskLimit, "taskLimit", WORKLOAD_OP);
619
+ const timeOffLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.timeOffLimit, "timeOffLimit", WORKLOAD_OP);
620
+ const resourceId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
621
+ const root = await chunkYTOBU3Z6_cjs.invokeRead(client, "resources.get", [resourceId]);
622
622
  const strict = { allowAssumed: false };
623
- const [joined, counted, assignmentBranch, balances, timeOff] = await chunkGEFUSYH5_cjs.readTasks(resource.http, [
624
- () => chunkGEFUSYH5_cjs.compositePart(client, "tickets.forResource", [
623
+ const [joined, counted, assignmentBranch, balances, timeOff] = await chunkYTOBU3Z6_cjs.readTasks(resource.http, [
624
+ () => chunkYTOBU3Z6_cjs.compositePart(client, "tickets.forResource", [
625
625
  resourceId,
626
626
  { openOnly: true, limit: Math.min(ticketLimit, 500), ...strict }
627
627
  ]),
628
- () => chunkGEFUSYH5_cjs.compositePart(client, "tickets.forResource", [resourceId, { countOnly: true, ...strict }]),
628
+ () => chunkYTOBU3Z6_cjs.compositePart(client, "tickets.forResource", [resourceId, { countOnly: true, ...strict }]),
629
629
  async () => {
630
- const assignments2 = await chunkGEFUSYH5_cjs.compositePart(client, "service_call_task_resources.query", [
630
+ const assignments2 = await chunkYTOBU3Z6_cjs.compositePart(client, "service_call_task_resources.query", [
631
631
  { filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: taskLimit }
632
632
  ]);
633
- const taskDetails2 = await chunkGEFUSYH5_cjs.joinedCompositePart(client, assignments2, "serviceCallTaskID", "service_call_tasks.query", "id", taskLimit, "NO_ASSIGNMENTS");
633
+ const taskDetails2 = await chunkYTOBU3Z6_cjs.joinedCompositePart(client, assignments2, "serviceCallTaskID", "service_call_tasks.query", "id", taskLimit, "NO_ASSIGNMENTS");
634
634
  return { assignments: assignments2, taskDetails: taskDetails2 };
635
635
  },
636
- () => chunkGEFUSYH5_cjs.compositePart(client, "resource_time_off_balances.getByResource", [resourceId]),
637
- () => chunkGEFUSYH5_cjs.compositePart(client, "time_off_requests.query", [
636
+ () => chunkYTOBU3Z6_cjs.compositePart(client, "resource_time_off_balances.getByResource", [resourceId]),
637
+ () => chunkYTOBU3Z6_cjs.compositePart(client, "time_off_requests.query", [
638
638
  { filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: timeOffLimit }
639
639
  ])
640
640
  ]);
@@ -662,7 +662,7 @@ async function workload(resource, id, opts = {}) {
662
662
  }
663
663
 
664
664
  // src/resources/resources.ts
665
- var ResourcesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
665
+ var ResourcesResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
666
666
  clientConfig;
667
667
  constructor(http, clientConfig, pageSize) {
668
668
  super(http, {
@@ -694,20 +694,20 @@ var ResourcesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
694
694
  // src/resources/special/service_calls.ts
695
695
  var OP2 = "service_calls.fullProfile";
696
696
  async function fullProfile2(resource, id, opts = {}) {
697
- const client = chunkGEFUSYH5_cjs.clientOf(resource, OP2);
698
- const ticketLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", OP2);
699
- const taskLimit = chunkGEFUSYH5_cjs.compositePartLimit(opts.taskLimit, "taskLimit", OP2);
700
- const callId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
701
- const root = await chunkGEFUSYH5_cjs.invokeRead(client, "service_calls.get", [callId]);
702
- const [tickets, taskBranch] = await chunkGEFUSYH5_cjs.readTasks(resource.http, [
703
- () => chunkGEFUSYH5_cjs.compositePart(client, "service_call_tickets.query", [
697
+ const client = chunkYTOBU3Z6_cjs.clientOf(resource, OP2);
698
+ const ticketLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", OP2);
699
+ const taskLimit = chunkYTOBU3Z6_cjs.compositePartLimit(opts.taskLimit, "taskLimit", OP2);
700
+ const callId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
701
+ const root = await chunkYTOBU3Z6_cjs.invokeRead(client, "service_calls.get", [callId]);
702
+ const [tickets, taskBranch] = await chunkYTOBU3Z6_cjs.readTasks(resource.http, [
703
+ () => chunkYTOBU3Z6_cjs.compositePart(client, "service_call_tickets.query", [
704
704
  { filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: ticketLimit }
705
705
  ]),
706
706
  async () => {
707
- const tasks2 = await chunkGEFUSYH5_cjs.compositePart(client, "service_call_tasks.query", [
707
+ const tasks2 = await chunkYTOBU3Z6_cjs.compositePart(client, "service_call_tasks.query", [
708
708
  { filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: taskLimit }
709
709
  ]);
710
- const resourceAssignments2 = await chunkGEFUSYH5_cjs.joinedCompositePart(client, tasks2, "id", "service_call_task_resources.query", "serviceCallTaskID", taskLimit, "NO_TASKS");
710
+ const resourceAssignments2 = await chunkYTOBU3Z6_cjs.joinedCompositePart(client, tasks2, "id", "service_call_task_resources.query", "serviceCallTaskID", taskLimit, "NO_TASKS");
711
711
  return { tasks: tasks2, resourceAssignments: resourceAssignments2 };
712
712
  }
713
713
  ]);
@@ -723,7 +723,7 @@ async function fullProfile2(resource, id, opts = {}) {
723
723
  }
724
724
 
725
725
  // src/resources/service_calls.ts
726
- var ServiceCallsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
726
+ var ServiceCallsResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
727
727
  constructor(http, pageSize) {
728
728
  super(http, {
729
729
  key: "service_calls",
@@ -745,13 +745,13 @@ var OP3 = "ticket_charges.moveToTicket";
745
745
  var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
746
746
  var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
747
747
  async function readCharge(http, id, retries) {
748
- const rows = await chunkGEFUSYH5_cjs.queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
748
+ const rows = await chunkYTOBU3Z6_cjs.queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
749
749
  return rows[0] ?? null;
750
750
  }
751
751
  async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
752
752
  if (source.isBilled === true) {
753
- throw chunkGEFUSYH5_cjs.refuse("MOVE_BLOCKED_BILLED", `${OP3}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP3, {
754
- manualAction: { action: "delete_source", uiLink: chunkGEFUSYH5_cjs.uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
753
+ throw chunkYTOBU3Z6_cjs.refuse("MOVE_BLOCKED_BILLED", `${OP3}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP3, {
754
+ manualAction: { action: "delete_source", uiLink: chunkYTOBU3Z6_cjs.uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
755
755
  });
756
756
  }
757
757
  }
@@ -785,14 +785,14 @@ var SPEC = {
785
785
  ]
786
786
  }),
787
787
  // charges have no ExecuteCommand code: the parent ticket is the closest clickable target
788
- manualLink: (http, source) => typeof source.ticketID === "number" ? chunkGEFUSYH5_cjs.uiLinkFor(http, "tickets", source.ticketID) : null
788
+ manualLink: (http, source) => typeof source.ticketID === "number" ? chunkYTOBU3Z6_cjs.uiLinkFor(http, "tickets", source.ticketID) : null
789
789
  };
790
790
  function moveToTicket(resource, sourceId, toTicketId, opts) {
791
- return chunkGEFUSYH5_cjs.runMove(resource.http, SPEC, sourceId, toTicketId, opts);
791
+ return chunkYTOBU3Z6_cjs.runMove(resource.http, SPEC, sourceId, toTicketId, opts);
792
792
  }
793
793
 
794
794
  // src/resources/ticket_charges.ts
795
- var TicketChargesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
795
+ var TicketChargesResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
796
796
  constructor(http, pageSize) {
797
797
  super(http, {
798
798
  key: "ticket_charges",
@@ -817,7 +817,7 @@ var TicketChargesResource = class extends chunkGEFUSYH5_cjs.GenericResource {
817
817
  };
818
818
 
819
819
  // src/resources/special/tickets/errors.ts
820
- var StatusUnknownError = class extends chunkGEFUSYH5_cjs.AutotaskError {
820
+ var StatusUnknownError = class extends chunkYTOBU3Z6_cjs.AutotaskError {
821
821
  /** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
822
822
  picklistCount;
823
823
  constructor(message, options = {}) {
@@ -831,7 +831,7 @@ var StatusUnknownError = class extends chunkGEFUSYH5_cjs.AutotaskError {
831
831
  this.picklistCount = options.picklistCount ?? 0;
832
832
  }
833
833
  };
834
- var StatusFieldsRequiredError = class extends chunkGEFUSYH5_cjs.AutotaskError {
834
+ var StatusFieldsRequiredError = class extends chunkYTOBU3Z6_cjs.AutotaskError {
835
835
  vendorFields;
836
836
  currentStatus;
837
837
  targetStatus;
@@ -853,8 +853,8 @@ function isPositiveInt(v) {
853
853
  return typeof v === "number" && Number.isInteger(v) && v > 0;
854
854
  }
855
855
  function namedVendorFields(err) {
856
- if (!chunkGEFUSYH5_cjs.isAutotaskError(err) || err.vendorError === void 0) return [];
857
- const entries = chunkGEFUSYH5_cjs.parseVendorErrors(err.vendorError) ?? [];
856
+ if (!chunkYTOBU3Z6_cjs.isAutotaskError(err) || err.vendorError === void 0) return [];
857
+ const entries = chunkYTOBU3Z6_cjs.parseVendorErrors(err.vendorError) ?? [];
858
858
  const out = /* @__PURE__ */ new Set();
859
859
  for (const e of entries) if (e.field !== void 0) out.add(e.field);
860
860
  return [...out];
@@ -873,8 +873,8 @@ function unwrapItemOrNull(res) {
873
873
  return body.item;
874
874
  }
875
875
  function discoveryMerge(err, body, defaults) {
876
- if (!chunkGEFUSYH5_cjs.isAutotaskError(err) || err.vendorError === void 0) return null;
877
- const entries = chunkGEFUSYH5_cjs.parseVendorErrors(err.vendorError);
876
+ if (!chunkYTOBU3Z6_cjs.isAutotaskError(err) || err.vendorError === void 0) return null;
877
+ const entries = chunkYTOBU3Z6_cjs.parseVendorErrors(err.vendorError);
878
878
  if (entries === void 0) return null;
879
879
  for (const entry of entries) {
880
880
  const field = entry.field;
@@ -909,7 +909,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
909
909
  const ids = await readLiveStatusSet(resource);
910
910
  if (ids.size > 0) liveStatus = ids;
911
911
  } catch (err) {
912
- if (!chunkGEFUSYH5_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
912
+ if (!chunkYTOBU3Z6_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
913
913
  }
914
914
  if (liveStatus !== null && !liveStatus.has(targetStatus)) {
915
915
  http.fieldCache?.invalidate("tickets:");
@@ -919,7 +919,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
919
919
  const freshIds = await readLiveStatusSet(resource);
920
920
  if (freshIds.size > 0) freshStatus = freshIds;
921
921
  } catch (err) {
922
- if (!chunkGEFUSYH5_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
922
+ if (!chunkYTOBU3Z6_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
923
923
  freshStatus = null;
924
924
  reReadFailed = true;
925
925
  }
@@ -937,7 +937,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
937
937
  return { guardDegraded: liveStatus === null };
938
938
  }
939
939
  function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
940
- return chunkGEFUSYH5_cjs.buildDryRunResult(
940
+ return chunkYTOBU3Z6_cjs.buildDryRunResult(
941
941
  {
942
942
  operation: OP_STATUS,
943
943
  method: "PUT",
@@ -991,7 +991,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
991
991
  if (mapEntry === void 0) {
992
992
  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).`);
993
993
  }
994
- return chunkGEFUSYH5_cjs.buildDryRunResult(
994
+ return chunkYTOBU3Z6_cjs.buildDryRunResult(
995
995
  {
996
996
  operation: OP_STATUS,
997
997
  method: "PUT",
@@ -1011,7 +1011,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
1011
1011
  }
1012
1012
  async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
1013
1013
  const safeDefaults = mapEntry?.safeDefaults ?? {};
1014
- const body = chunkGEFUSYH5_cjs.mergePartialBody(current, mergeData);
1014
+ const body = chunkYTOBU3Z6_cjs.mergePartialBody(current, mergeData);
1015
1015
  body.id = ticketId;
1016
1016
  let merges = 0;
1017
1017
  for (; ; ) {
@@ -1035,8 +1035,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
1035
1035
  { vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
1036
1036
  {
1037
1037
  operation: OP_STATUS,
1038
- httpStatus: chunkGEFUSYH5_cjs.isAutotaskError(err) ? err.httpStatus : void 0,
1039
- vendorError: chunkGEFUSYH5_cjs.isAutotaskError(err) ? err.vendorError : void 0,
1038
+ httpStatus: chunkYTOBU3Z6_cjs.isAutotaskError(err) ? err.httpStatus : void 0,
1039
+ vendorError: chunkYTOBU3Z6_cjs.isAutotaskError(err) ? err.vendorError : void 0,
1040
1040
  resourceIds: [ticketId],
1041
1041
  details: { idRefs: [{ entity: "ticket", id: ticketId }] }
1042
1042
  }
@@ -1049,7 +1049,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
1049
1049
  async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
1050
1050
  const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
1051
1051
  if (verify === null) {
1052
- throw new chunkGEFUSYH5_cjs.AutotaskError(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
1052
+ throw new chunkYTOBU3Z6_cjs.AutotaskError(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
1053
1053
  code: "INVALID_RESPONSE",
1054
1054
  category: "server",
1055
1055
  operation: OP_STATUS,
@@ -1059,7 +1059,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
1059
1059
  }
1060
1060
  const finalStatus = typeof verify.status === "number" ? verify.status : null;
1061
1061
  if (finalStatus !== targetStatus) {
1062
- throw new chunkGEFUSYH5_cjs.AutotaskError(
1062
+ throw new chunkYTOBU3Z6_cjs.AutotaskError(
1063
1063
  `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)`,
1064
1064
  {
1065
1065
  code: "INVALID_RESPONSE",
@@ -1075,17 +1075,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
1075
1075
  }
1076
1076
  async function changeStatus(resource, id, targetStatus, fields, opts) {
1077
1077
  const http = resource.http;
1078
- const ticketId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1078
+ const ticketId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1079
1079
  if (!isPositiveInt(targetStatus)) {
1080
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
1080
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
1081
1081
  }
1082
1082
  const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
1083
1083
  if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
1084
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
1084
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
1085
1085
  }
1086
1086
  const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
1087
1087
  if (current === null) {
1088
- throw new chunkGEFUSYH5_cjs.NotFoundError(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
1088
+ throw new chunkYTOBU3Z6_cjs.NotFoundError(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
1089
1089
  }
1090
1090
  const previousStatus = typeof current.status === "number" ? current.status : null;
1091
1091
  if (previousStatus === targetStatus) {
@@ -1111,7 +1111,7 @@ var TICKET_FIELDS = ["id", "ticketNumber", "title", "status", "assignedResourceI
1111
1111
  function positiveId(value, name) {
1112
1112
  const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
1113
1113
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
1114
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
1114
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
1115
1115
  }
1116
1116
  return n;
1117
1117
  }
@@ -1123,7 +1123,7 @@ async function ticketPage(http, filter, maxRecords, fields) {
1123
1123
  body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
1124
1124
  operation: OP4
1125
1125
  });
1126
- const page = chunkGEFUSYH5_cjs.unwrapItems(res, OP4);
1126
+ const page = chunkYTOBU3Z6_cjs.unwrapItems(res, OP4);
1127
1127
  return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
1128
1128
  }
1129
1129
  async function readLinkIds(http, resourceID, maxPages = 1) {
@@ -1133,11 +1133,11 @@ async function readLinkIds(http, resourceID, maxPages = 1) {
1133
1133
  const res = await http.request({
1134
1134
  method: "POST",
1135
1135
  idempotent: true,
1136
- path: cursor === null ? "/V1.0/TicketSecondaryResources/query" : chunkGEFUSYH5_cjs.cursorToPath(http.baseUrl, cursor),
1136
+ path: cursor === null ? "/V1.0/TicketSecondaryResources/query" : chunkYTOBU3Z6_cjs.cursorToPath(http.baseUrl, cursor),
1137
1137
  body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
1138
1138
  operation: OP4
1139
1139
  });
1140
- const page = chunkGEFUSYH5_cjs.unwrapItems(res, OP4);
1140
+ const page = chunkYTOBU3Z6_cjs.unwrapItems(res, OP4);
1141
1141
  for (const row of page.items) if (typeof row.ticketID === "number") ids.add(row.ticketID);
1142
1142
  cursor = page.pageDetails.nextPageUrl;
1143
1143
  if (cursor === null || page.items.length === 0) return { ids: [...ids], capped: false };
@@ -1146,35 +1146,35 @@ async function readLinkIds(http, resourceID, maxPages = 1) {
1146
1146
  }
1147
1147
  async function forResource(_resource, resourceIDIn, opts = {}) {
1148
1148
  const http = _resource.http;
1149
- if (opts === null || typeof opts !== "object") throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: opts must be an object`, { operation: OP4 });
1149
+ if (opts === null || typeof opts !== "object") throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: opts must be an object`, { operation: OP4 });
1150
1150
  const resourceID = positiveId(resourceIDIn, "resourceID");
1151
1151
  const scope = opts.scope ?? "both";
1152
1152
  if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
1153
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
1153
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
1154
1154
  }
1155
1155
  if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
1156
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
1156
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
1157
1157
  }
1158
1158
  const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
1159
1159
  if (opts.countOnly !== true && (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX)) {
1160
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
1160
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
1161
1161
  }
1162
1162
  const includeFields = opts.includeFields ?? [];
1163
1163
  if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
1164
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
1164
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
1165
1165
  }
1166
1166
  const openOnly = opts.openOnly === true;
1167
1167
  const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS, ...includeFields])];
1168
1168
  if (opts.countOnly !== void 0 && typeof opts.countOnly !== "boolean") {
1169
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`${OP4}: countOnly must be a boolean`, { operation: OP4 });
1169
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`${OP4}: countOnly must be a boolean`, { operation: OP4 });
1170
1170
  }
1171
- const closed = await chunkGEFUSYH5_cjs.resolveTicketStatusSemantics(
1171
+ const closed = await chunkYTOBU3Z6_cjs.resolveTicketStatusSemantics(
1172
1172
  http,
1173
1173
  { ...opts.excludeStatusIds === void 0 ? {} : { excludeStatusIds: opts.excludeStatusIds }, ...opts.allowAssumed === void 0 ? {} : { allowAssumed: opts.allowAssumed } },
1174
1174
  OP4
1175
1175
  );
1176
1176
  const closedStatus = { closedIds: closed.closedIds, source: closed.source, note: closed.note };
1177
- const openLeaf = openOnly || opts.countOnly === true ? [chunkGEFUSYH5_cjs.openStatusFilter(closed.closedIds)] : [];
1177
+ const openLeaf = openOnly || opts.countOnly === true ? [chunkYTOBU3Z6_cjs.openStatusFilter(closed.closedIds)] : [];
1178
1178
  if (opts.countOnly === true) {
1179
1179
  const primaryCount = scope === "secondary" ? 0 : await _resource.count({ filter: [{ field: "assignedResourceID", op: "eq", value: resourceID }, ...openLeaf] });
1180
1180
  let secondaryCount = 0;
@@ -1188,7 +1188,7 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
1188
1188
  const page = await ticketPage(http, [{ field: "id", op: "in", value: chunk }, ...openLeaf], chunk.length, ["id", "status", "assignedResourceID"]);
1189
1189
  const seen = /* @__PURE__ */ new Set();
1190
1190
  for (const t of page.rows) {
1191
- if (typeof t.id !== "number" || seen.has(t.id) || chunkGEFUSYH5_cjs.isClosedStatus(t.status, closed.closedIds)) continue;
1191
+ if (typeof t.id !== "number" || seen.has(t.id) || chunkYTOBU3Z6_cjs.isClosedStatus(t.status, closed.closedIds)) continue;
1192
1192
  seen.add(t.id);
1193
1193
  if (scope === "both" && t.assignedResourceID === resourceID) bothCount++;
1194
1194
  }
@@ -1234,13 +1234,13 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
1234
1234
  for (const [id, t] of primary) merged.set(id, t);
1235
1235
  for (const [id, t] of secondary) if (!merged.has(id)) merged.set(id, t);
1236
1236
  let tickets = [...merged.values()];
1237
- if (openOnly) tickets = tickets.filter((t) => !chunkGEFUSYH5_cjs.isClosedStatus(t.status, closed.closedIds));
1237
+ if (openOnly) tickets = tickets.filter((t) => !chunkYTOBU3Z6_cjs.isClosedStatus(t.status, closed.closedIds));
1238
1238
  tickets.sort((a, b) => Number(a.id) - Number(b.id));
1239
1239
  if (tickets.length > limit) {
1240
1240
  tickets = tickets.slice(0, limit);
1241
1241
  capped = true;
1242
1242
  }
1243
- const openCount = tickets.filter((t) => !chunkGEFUSYH5_cjs.isClosedStatus(t.status, closed.closedIds)).length;
1243
+ const openCount = tickets.filter((t) => !chunkYTOBU3Z6_cjs.isClosedStatus(t.status, closed.closedIds)).length;
1244
1244
  const primaryIds = [...primary.keys()].sort((a, b) => a - b);
1245
1245
  const secondaryIds = [...secondary.keys()].sort((a, b) => a - b);
1246
1246
  const both = primaryIds.filter((id) => secondary.has(id));
@@ -1274,9 +1274,9 @@ async function fetchTicket(http, id, operation) {
1274
1274
  });
1275
1275
  const body = res;
1276
1276
  if (body === null || !("item" in body)) {
1277
- throw new chunkGEFUSYH5_cjs.NotFoundError(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1277
+ throw new chunkYTOBU3Z6_cjs.NotFoundError(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1278
1278
  }
1279
- if (body.item === null || body.item === void 0) throw new chunkGEFUSYH5_cjs.NotFoundError(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1279
+ if (body.item === null || body.item === void 0) throw new chunkYTOBU3Z6_cjs.NotFoundError(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
1280
1280
  return body.item;
1281
1281
  }
1282
1282
  async function ticketQueryItems(http, path, filter, maxRecords, operation) {
@@ -1287,7 +1287,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
1287
1287
  body: { MaxRecords: maxRecords, filter },
1288
1288
  operation
1289
1289
  });
1290
- return chunkGEFUSYH5_cjs.unwrapItems(res).items;
1290
+ return chunkYTOBU3Z6_cjs.unwrapItems(res).items;
1291
1291
  }
1292
1292
  function truncate(text, limit) {
1293
1293
  const full = text ?? "";
@@ -1297,13 +1297,13 @@ function truncate(text, limit) {
1297
1297
 
1298
1298
  // src/resources/special/tickets/childRead.ts
1299
1299
  function isRouteUnavailable(err) {
1300
- return chunkGEFUSYH5_cjs.isAutotaskError(err) && (err.httpStatus === 404 || err.httpStatus === 500);
1300
+ return chunkYTOBU3Z6_cjs.isAutotaskError(err) && (err.httpStatus === 404 || err.httpStatus === 500);
1301
1301
  }
1302
1302
  function routeFact(route, path, err) {
1303
1303
  return {
1304
1304
  route,
1305
1305
  path,
1306
- httpStatus: chunkGEFUSYH5_cjs.isAutotaskError(err) && typeof err.httpStatus === "number" ? err.httpStatus : null
1306
+ httpStatus: chunkYTOBU3Z6_cjs.isAutotaskError(err) && typeof err.httpStatus === "number" ? err.httpStatus : null
1307
1307
  };
1308
1308
  }
1309
1309
  async function childDeclaresQuery(resourceKey) {
@@ -1314,10 +1314,10 @@ async function childDeclaresQuery(resourceKey) {
1314
1314
  }
1315
1315
  async function planScopedPath(resourceKey, ticketId) {
1316
1316
  if (!await childDeclaresQuery(resourceKey)) return null;
1317
- const entry = chunkGEFUSYH5_cjs.RELATIONSHIP_MAP[resourceKey];
1317
+ const entry = chunkYTOBU3Z6_cjs.RELATIONSHIP_MAP[resourceKey];
1318
1318
  const parent = entry === void 0 ? null : entry.parent;
1319
1319
  if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
1320
- const parentPath = chunkGEFUSYH5_cjs.RELATIONSHIP_MAP[parent.resource]?.path;
1320
+ const parentPath = chunkYTOBU3Z6_cjs.RELATIONSHIP_MAP[parent.resource]?.path;
1321
1321
  if (parentPath === null || parentPath === void 0) return null;
1322
1322
  return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
1323
1323
  }
@@ -1356,14 +1356,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
1356
1356
  break;
1357
1357
  }
1358
1358
  const body = await http.request({ method: "GET", path: target, operation });
1359
- const { items: pageItems, pageDetails } = chunkGEFUSYH5_cjs.unwrapItems(body, operation);
1359
+ const { items: pageItems, pageDetails } = chunkYTOBU3Z6_cjs.unwrapItems(body, operation);
1360
1360
  nextCursor = pageDetails.nextPageUrl;
1361
1361
  pages += 1;
1362
1362
  const window = pageItems.slice(0, Math.max(0, limit - items.length));
1363
1363
  for (const row of window) if (accept(row)) items.push(row);
1364
1364
  if (items.length >= limit) break;
1365
1365
  if (nextCursor === null || pageItems.length === 0) break;
1366
- target = chunkGEFUSYH5_cjs.cursorToPath(http.baseUrl, nextCursor);
1366
+ target = chunkYTOBU3Z6_cjs.cursorToPath(http.baseUrl, nextCursor);
1367
1367
  }
1368
1368
  const capped = items.length >= limit || guard && nextCursor !== null;
1369
1369
  return { items, capped };
@@ -1396,7 +1396,7 @@ var DEFAULT_PART_LIMIT = 50;
1396
1396
  function partLimit(value, name) {
1397
1397
  const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
1398
1398
  if (!Number.isInteger(n) || n < 1) {
1399
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
1399
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
1400
1400
  }
1401
1401
  return n;
1402
1402
  }
@@ -1409,13 +1409,13 @@ function servedTextRecord(row, textField, limit) {
1409
1409
  return out;
1410
1410
  }
1411
1411
  async function addCompositeNames(http, ctx, entriesPart, result, opts) {
1412
- const builder = chunkGEFUSYH5_cjs.createNamePlan(chunkGEFUSYH5_cjs.TICKET_LABEL_FIELDS);
1412
+ const builder = chunkYTOBU3Z6_cjs.createNamePlan(chunkYTOBU3Z6_cjs.TICKET_LABEL_FIELDS);
1413
1413
  const t = ctx.ticket;
1414
1414
  builder.addResource(t["creatorResourceID"]);
1415
1415
  builder.addFk("contract", t["contractID"]);
1416
1416
  builder.addFk("billingCode", t["billingCodeID"]);
1417
1417
  builder.addFk("role", t["assignedResourceRoleID"]);
1418
- const ticketLobPointer = chunkGEFUSYH5_cjs.vendorId(t["organizationalLevelAssociationID"]);
1418
+ const ticketLobPointer = chunkYTOBU3Z6_cjs.vendorId(t["organizationalLevelAssociationID"]);
1419
1419
  if (ticketLobPointer !== void 0) {
1420
1420
  builder.addLineOfBusiness(ticketLobPointer, { source: "ticket" });
1421
1421
  } else {
@@ -1427,20 +1427,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
1427
1427
  builder.addFk("billingCode", e["billingCodeID"]);
1428
1428
  builder.addFk("contract", e["contractID"]);
1429
1429
  }
1430
- const names = await chunkGEFUSYH5_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
1430
+ const names = await chunkYTOBU3Z6_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
1431
1431
  const ticketRow = { ...ctx.ticket };
1432
- chunkGEFUSYH5_cjs.addNameSibling(ticketRow, "creatorResourceID", (v) => names.resourceName(v));
1433
- chunkGEFUSYH5_cjs.addNameSibling(ticketRow, "contractID", (v) => names.recordName("contract", v));
1434
- chunkGEFUSYH5_cjs.addNameSibling(ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
1435
- chunkGEFUSYH5_cjs.addNameSibling(ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
1436
- for (const f of chunkGEFUSYH5_cjs.TICKET_LABEL_FIELDS) chunkGEFUSYH5_cjs.addLabelSibling(ticketRow, f, names);
1432
+ chunkYTOBU3Z6_cjs.addNameSibling(ticketRow, "creatorResourceID", (v) => names.resourceName(v));
1433
+ chunkYTOBU3Z6_cjs.addNameSibling(ticketRow, "contractID", (v) => names.recordName("contract", v));
1434
+ chunkYTOBU3Z6_cjs.addNameSibling(ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
1435
+ chunkYTOBU3Z6_cjs.addNameSibling(ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
1436
+ for (const f of chunkYTOBU3Z6_cjs.TICKET_LABEL_FIELDS) chunkYTOBU3Z6_cjs.addLabelSibling(ticketRow, f, names);
1437
1437
  result.ticket = ticketRow;
1438
1438
  result.timeEntries.items = entriesPart.items.map((e) => {
1439
1439
  const row = { ...e };
1440
- chunkGEFUSYH5_cjs.addNameSibling(row, "resourceID", (v) => names.resourceName(v));
1441
- chunkGEFUSYH5_cjs.addNameSibling(row, "roleID", (v) => names.recordName("role", v));
1442
- chunkGEFUSYH5_cjs.addNameSibling(row, "billingCodeID", (v) => names.recordName("billingCode", v));
1443
- chunkGEFUSYH5_cjs.addNameSibling(row, "contractID", (v) => names.recordName("contract", v));
1440
+ chunkYTOBU3Z6_cjs.addNameSibling(row, "resourceID", (v) => names.resourceName(v));
1441
+ chunkYTOBU3Z6_cjs.addNameSibling(row, "roleID", (v) => names.recordName("role", v));
1442
+ chunkYTOBU3Z6_cjs.addNameSibling(row, "billingCodeID", (v) => names.recordName("billingCode", v));
1443
+ chunkYTOBU3Z6_cjs.addNameSibling(row, "contractID", (v) => names.recordName("contract", v));
1444
1444
  return row;
1445
1445
  });
1446
1446
  result.names = names.section;
@@ -1457,11 +1457,11 @@ async function fullContext(resource, id, opts = {}, loadContext) {
1457
1457
  const noteLimit = partLimit(opts.noteLimit, "noteLimit");
1458
1458
  const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
1459
1459
  const textLimit = partLimit(opts.textLimit, "textLimit");
1460
- const ticketId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1460
+ const ticketId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1461
1461
  const { ticket, tasks: contextTasks } = await loadContext();
1462
1462
  const op = "tickets.fullContext";
1463
1463
  const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
1464
- const [company, contact, assignedResource, project, notes, entries, attachmentsRead, historiesRead] = await chunkGEFUSYH5_cjs.readTasks(http, [
1464
+ const [company, contact, assignedResource, project, notes, entries, attachmentsRead, historiesRead] = await chunkYTOBU3Z6_cjs.readTasks(http, [
1465
1465
  ...contextTasks,
1466
1466
  () => ticketChildRead(http, { globalPath: "/V1.0/TicketNotes/query", resourceKey: "ticket_notes", filter: ticketFilter, limit: noteLimit, operation: op }, ticketId),
1467
1467
  () => ticketChildRead(http, { globalPath: "/V1.0/TimeEntries/query", resourceKey: "time_entries", filter: ticketFilter, limit: timeEntryLimit, operation: op }, ticketId),
@@ -1524,7 +1524,7 @@ var OP5 = "tickets.lineOfBusiness";
1524
1524
  function positiveId2(value, name) {
1525
1525
  const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
1526
1526
  if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
1527
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(OP5 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP5 });
1527
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(OP5 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP5 });
1528
1528
  }
1529
1529
  return n;
1530
1530
  }
@@ -1540,25 +1540,25 @@ async function lineOfBusiness(resource, ticketIdIn, associationIdIn) {
1540
1540
  associationSource = "argument";
1541
1541
  } else {
1542
1542
  const ticket = await resource.get(ticketId);
1543
- associationId = chunkGEFUSYH5_cjs.vendorId(ticket.organizationalLevelAssociationID);
1543
+ associationId = chunkYTOBU3Z6_cjs.vendorId(ticket.organizationalLevelAssociationID);
1544
1544
  if (associationId !== void 0) {
1545
1545
  associationSource = "ticket";
1546
1546
  } else {
1547
- const contractRef = chunkGEFUSYH5_cjs.vendorId(ticket.contractID);
1547
+ const contractRef = chunkYTOBU3Z6_cjs.vendorId(ticket.contractID);
1548
1548
  if (contractRef !== void 0) {
1549
1549
  const client = http.client;
1550
1550
  if (client === void 0) {
1551
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(OP5 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP5 });
1551
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(OP5 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP5 });
1552
1552
  }
1553
1553
  try {
1554
1554
  const contract = await client.contracts.get(contractRef);
1555
1555
  contractId = contractRef;
1556
- associationId = chunkGEFUSYH5_cjs.vendorId(contract.organizationalLevelAssociationID);
1556
+ associationId = chunkYTOBU3Z6_cjs.vendorId(contract.organizationalLevelAssociationID);
1557
1557
  if (associationId !== void 0) associationSource = "contract";
1558
1558
  } catch (e) {
1559
- if (e instanceof chunkGEFUSYH5_cjs.NotFoundError) {
1559
+ if (e instanceof chunkYTOBU3Z6_cjs.NotFoundError) {
1560
1560
  contractId = contractRef;
1561
- } else if (chunkGEFUSYH5_cjs.isAutotaskError(e) && e.code !== "ABORTED") {
1561
+ } else if (chunkYTOBU3Z6_cjs.isAutotaskError(e) && e.code !== "ABORTED") {
1562
1562
  contractId = contractRef;
1563
1563
  contractUnread = true;
1564
1564
  } else {
@@ -1579,7 +1579,7 @@ async function lineOfBusiness(resource, ticketIdIn, associationIdIn) {
1579
1579
  markers: { association: contractUnread ? "unresolved" : "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
1580
1580
  };
1581
1581
  }
1582
- const chain = await chunkGEFUSYH5_cjs.resolveLineOfBusinessChain(http, associationId, { budget: 3, operation: OP5, onError: "propagate" });
1582
+ const chain = await chunkYTOBU3Z6_cjs.resolveLineOfBusinessChain(http, associationId, { budget: 3, operation: OP5, onError: "propagate" });
1583
1583
  const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
1584
1584
  return { ticketId, associationSource, contractId, association, organizationalLevel2, organizationalLevel1, markers };
1585
1585
  }
@@ -1589,7 +1589,7 @@ var MS = 864e5;
1589
1589
  var SLA_PAGE = 100;
1590
1590
  async function slaHealthCheck(_resource, id, opts = {}) {
1591
1591
  const http = _resource.http;
1592
- const ticketId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1592
+ const ticketId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1593
1593
  await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
1594
1594
  const rows = await ticketQueryItems(
1595
1595
  http,
@@ -1615,9 +1615,9 @@ async function summary(_resource, id, opts = {}) {
1615
1615
  const http = _resource.http;
1616
1616
  const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
1617
1617
  if (!Number.isInteger(limit) || limit < 1) {
1618
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
1618
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
1619
1619
  }
1620
- const ticketId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1620
+ const ticketId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1621
1621
  const ticket = await fetchTicket(http, ticketId, "tickets.summary");
1622
1622
  const desc = truncate(ticket.description, limit);
1623
1623
  const now = opts.now ?? /* @__PURE__ */ new Date();
@@ -1646,17 +1646,17 @@ async function summary(_resource, id, opts = {}) {
1646
1646
  // src/resources/special/tickets/statusSemantics.ts
1647
1647
  async function statusSemantics(_resource, opts = {}) {
1648
1648
  const http = _resource.http;
1649
- return chunkGEFUSYH5_cjs.resolveTicketStatusSemantics(http, opts);
1649
+ return chunkYTOBU3Z6_cjs.resolveTicketStatusSemantics(http, opts);
1650
1650
  }
1651
1651
 
1652
1652
  // src/resources/special/tickets/timeline.ts
1653
1653
  function validateTimelineLimits(opts) {
1654
1654
  const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
1655
- if (!Number.isInteger(limit) || limit < 1) throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
1655
+ if (!Number.isInteger(limit) || limit < 1) throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
1656
1656
  const bounded = Math.min(limit, 500);
1657
1657
  const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
1658
1658
  if (!Number.isInteger(textLimit) || textLimit < 1) {
1659
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
1659
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
1660
1660
  }
1661
1661
  return { bounded, textLimit };
1662
1662
  }
@@ -1709,7 +1709,7 @@ function compareEventDates(a, b) {
1709
1709
  async function timeline(_resource, id, opts = {}) {
1710
1710
  const http = _resource.http;
1711
1711
  const { bounded, textLimit } = validateTimelineLimits(opts);
1712
- const ticketId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1712
+ const ticketId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1713
1713
  await fetchTicket(http, ticketId, "tickets.timeline");
1714
1714
  const dateFilters = (field) => {
1715
1715
  const f = [{ field: "ticketID", op: "eq", value: ticketId }];
@@ -1749,7 +1749,7 @@ async function timeline(_resource, id, opts = {}) {
1749
1749
  }
1750
1750
 
1751
1751
  // src/resources/tickets.ts
1752
- var TicketsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1752
+ var TicketsResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
1753
1753
  constructor(http, pageSize) {
1754
1754
  super(http, {
1755
1755
  key: "tickets",
@@ -1775,7 +1775,7 @@ var TicketsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1775
1775
  * fetch; no sub-lists; absent/dangling references come back null). */
1776
1776
  async getContext(id) {
1777
1777
  const { ticket, tasks } = await this.readTicketContext(id);
1778
- return ticketContextValue(ticket, await chunkGEFUSYH5_cjs.readTasks(this.http, tasks));
1778
+ return ticketContextValue(ticket, await chunkYTOBU3Z6_cjs.readTasks(this.http, tasks));
1779
1779
  }
1780
1780
  /** Root authority and reusable lazy FK tasks shared by both ticket composites. */
1781
1781
  async readTicketContext(id) {
@@ -1824,9 +1824,9 @@ var TicketsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1824
1824
  // src/resources/special/time_off_requests.ts
1825
1825
  async function approve(_resource, id, opts = {}) {
1826
1826
  const http = _resource.http;
1827
- const numericId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1827
+ const numericId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1828
1828
  if (opts.dryRun === true) {
1829
- return chunkGEFUSYH5_cjs.buildDryRunResult({
1829
+ return chunkYTOBU3Z6_cjs.buildDryRunResult({
1830
1830
  operation: "time_off_requests.approve",
1831
1831
  method: "GET",
1832
1832
  path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
@@ -1842,17 +1842,17 @@ async function approve(_resource, id, opts = {}) {
1842
1842
  operation: "time_off_requests.approve",
1843
1843
  maxRetries: opts.maxRetries
1844
1844
  });
1845
- return chunkGEFUSYH5_cjs.unwrapOperation(res);
1845
+ return chunkYTOBU3Z6_cjs.unwrapOperation(res);
1846
1846
  }
1847
1847
  async function reject(_resource, id, reason, opts = {}) {
1848
1848
  const http = _resource.http;
1849
- const numericId = chunkGEFUSYH5_cjs.parseIdentifier(id, "id");
1849
+ const numericId = chunkYTOBU3Z6_cjs.parseIdentifier(id, "id");
1850
1850
  const text = reason.trim();
1851
1851
  if (text === "") {
1852
- throw new chunkGEFUSYH5_cjs.AutotaskConfigError("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
1852
+ throw new chunkYTOBU3Z6_cjs.AutotaskConfigError("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
1853
1853
  }
1854
1854
  if (opts.dryRun === true) {
1855
- return chunkGEFUSYH5_cjs.buildDryRunResult({
1855
+ return chunkYTOBU3Z6_cjs.buildDryRunResult({
1856
1856
  operation: "time_off_requests.reject",
1857
1857
  method: "POST",
1858
1858
  path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
@@ -1870,11 +1870,11 @@ async function reject(_resource, id, reason, opts = {}) {
1870
1870
  operation: "time_off_requests.reject",
1871
1871
  maxRetries: opts.maxRetries
1872
1872
  });
1873
- return chunkGEFUSYH5_cjs.unwrapOperation(res);
1873
+ return chunkYTOBU3Z6_cjs.unwrapOperation(res);
1874
1874
  }
1875
1875
 
1876
1876
  // src/resources/time_off_requests.ts
1877
- var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1877
+ var TimeOffRequestsResource = class extends chunkYTOBU3Z6_cjs.GenericResource {
1878
1878
  constructor(http, pageSize) {
1879
1879
  super(http, {
1880
1880
  key: "time_off_requests",
@@ -1891,13 +1891,13 @@ var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1891
1891
  }
1892
1892
  async get(id, opts) {
1893
1893
  if (typeof opts === "number" || typeof opts === "string") {
1894
- throw new chunkGEFUSYH5_cjs.OperationNotSupportedError("time_off_requests", "get");
1894
+ throw new chunkYTOBU3Z6_cjs.OperationNotSupportedError("time_off_requests", "get");
1895
1895
  }
1896
1896
  return super.get(id, opts);
1897
1897
  }
1898
1898
  async create(a, b, c = {}) {
1899
- if (typeof a !== "number" && typeof a !== "string") throw new chunkGEFUSYH5_cjs.OperationNotSupportedError("time_off_requests", "create");
1900
- const parentId = chunkGEFUSYH5_cjs.parseIdentifier(a, "parentId");
1899
+ if (typeof a !== "number" && typeof a !== "string") throw new chunkYTOBU3Z6_cjs.OperationNotSupportedError("time_off_requests", "create");
1900
+ const parentId = chunkYTOBU3Z6_cjs.parseIdentifier(a, "parentId");
1901
1901
  if (typeof parentId !== "number") throw this.writeError("create", "parentId cannot be represented safely in the numeric resourceID create body; this is an SDK create-body limit, not a vendor record-id maximum");
1902
1902
  const data = this.writePayload(b, "create");
1903
1903
  const opts = { ...c };
@@ -1907,9 +1907,9 @@ var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1907
1907
  return super.create(parentId, { ...data, resourceID: parentId }, opts);
1908
1908
  }
1909
1909
  async update(a, b, c, d = {}) {
1910
- if (typeof b !== "number" && typeof b !== "string") throw new chunkGEFUSYH5_cjs.OperationNotSupportedError("time_off_requests", "update");
1911
- const parentId = chunkGEFUSYH5_cjs.parseIdentifier(a, "parentId");
1912
- const id = chunkGEFUSYH5_cjs.parseIdentifier(b, "id");
1910
+ if (typeof b !== "number" && typeof b !== "string") throw new chunkYTOBU3Z6_cjs.OperationNotSupportedError("time_off_requests", "update");
1911
+ const parentId = chunkYTOBU3Z6_cjs.parseIdentifier(a, "parentId");
1912
+ const id = chunkYTOBU3Z6_cjs.parseIdentifier(b, "id");
1913
1913
  const data = this.writePayload(c, "update");
1914
1914
  const opts = { ...d };
1915
1915
  await this.guardWriteStatus(data.status, "Canceled", "update");
@@ -1928,39 +1928,39 @@ var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1928
1928
  }
1929
1929
  async getScopedRaw(parentId, id, fresh = false) {
1930
1930
  const current = await super.getScopedRaw(parentId, id, fresh);
1931
- if (current.resourceID === void 0 || chunkGEFUSYH5_cjs.parseIdentifier(current.resourceID, "resourceID") !== parentId) {
1931
+ if (current.resourceID === void 0 || chunkYTOBU3Z6_cjs.parseIdentifier(current.resourceID, "resourceID") !== parentId) {
1932
1932
  throw this.writeError("update", "the current request resourceID must match parentId");
1933
1933
  }
1934
- if (chunkGEFUSYH5_cjs.parseIdentifier(current.id, "id") !== id) {
1934
+ if (chunkYTOBU3Z6_cjs.parseIdentifier(current.id, "id") !== id) {
1935
1935
  throw this.writeError("update", "the current request id must match the requested id");
1936
1936
  }
1937
1937
  return current;
1938
1938
  }
1939
1939
  async createIfNotExists(..._args) {
1940
- throw new chunkGEFUSYH5_cjs.OperationNotSupportedError("time_off_requests", "createIfNotExists");
1940
+ throw new chunkYTOBU3Z6_cjs.OperationNotSupportedError("time_off_requests", "createIfNotExists");
1941
1941
  }
1942
1942
  // Cancellation permits status only; never replace a full model through PUT fallback.
1943
1943
  putFallbackEligible(_err) {
1944
1944
  return false;
1945
1945
  }
1946
1946
  writeError(operation, detail) {
1947
- return new chunkGEFUSYH5_cjs.AutotaskConfigError(`time_off_requests.${operation}: ${detail}`, { operation: `time_off_requests.${operation}` });
1947
+ return new chunkYTOBU3Z6_cjs.AutotaskConfigError(`time_off_requests.${operation}: ${detail}`, { operation: `time_off_requests.${operation}` });
1948
1948
  }
1949
1949
  writePayload(value, operation) {
1950
- if (!chunkGEFUSYH5_cjs.isRecord(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) throw this.writeError(operation, "supply a plain object");
1950
+ if (!chunkYTOBU3Z6_cjs.isRecord(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) throw this.writeError(operation, "supply a plain object");
1951
1951
  const allowed = operation === "create" ? ["hours", "requestDate", "resourceID", "status", "timeOffRequestType"] : ["status"];
1952
1952
  for (const key of Object.keys(value)) if (!allowed.includes(key)) throw this.writeError(operation, operation === "update" ? "cancellation accepts status only" : `${key} is not a supported create field`);
1953
1953
  if (typeof value.status !== "number" || !Number.isSafeInteger(value.status)) throw this.writeError(operation, "status must be a numeric picklist id");
1954
1954
  if (operation === "create") {
1955
1955
  if (typeof value.hours !== "number" || !Number.isFinite(value.hours) || value.hours < -24 || value.hours > 24) throw this.writeError(operation, "hours must be a finite decimal in the documented range -24 to 24");
1956
1956
  const date = value.requestDate;
1957
- if (typeof date !== "string" || !chunkGEFUSYH5_cjs.isDateYMD(date.slice(0, 10)) || date.length !== 10 && (!/^T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(date.slice(10)) || !Number.isFinite(Date.parse(date)))) {
1957
+ if (typeof date !== "string" || !chunkYTOBU3Z6_cjs.isDateYMD(date.slice(0, 10)) || date.length !== 10 && (!/^T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(date.slice(10)) || !Number.isFinite(Date.parse(date)))) {
1958
1958
  throw this.writeError(operation, "requestDate must be an ISO calendar date or timestamp for the single requested day");
1959
1959
  }
1960
1960
  if (typeof value.timeOffRequestType !== "number" || !Number.isSafeInteger(value.timeOffRequestType)) throw this.writeError(operation, "timeOffRequestType must be a numeric picklist id");
1961
1961
  if (value.resourceID !== void 0) {
1962
1962
  if (typeof value.resourceID !== "number") throw this.writeError(operation, "resourceID must be a numeric identifier");
1963
- chunkGEFUSYH5_cjs.parseIdentifier(value.resourceID, "resourceID");
1963
+ chunkYTOBU3Z6_cjs.parseIdentifier(value.resourceID, "resourceID");
1964
1964
  }
1965
1965
  }
1966
1966
  return { ...value, status: value.status };
@@ -1970,11 +1970,11 @@ var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1970
1970
  try {
1971
1971
  fields = await this.cachedMeta("fields", `${this.resourcePath}/entityInformation/fields`, "time_off_requests.getFieldInfo", (body) => this.unwrapFields(body, "FieldInformationResultModel"), true);
1972
1972
  } catch (error) {
1973
- if (chunkGEFUSYH5_cjs.isAutotaskError(error) && error.code === "ABORTED") throw error;
1974
- if ((error instanceof chunkGEFUSYH5_cjs.RateLimitError || error instanceof chunkGEFUSYH5_cjs.MaintenanceError) && error.notSent === true) throw error;
1973
+ if (chunkYTOBU3Z6_cjs.isAutotaskError(error) && error.code === "ABORTED") throw error;
1974
+ if ((error instanceof chunkYTOBU3Z6_cjs.RateLimitError || error instanceof chunkYTOBU3Z6_cjs.MaintenanceError) && error.notSent === true) throw error;
1975
1975
  const detail = `status requires readable current field metadata for ${label}`;
1976
- if (!chunkGEFUSYH5_cjs.isAutotaskError(error)) throw this.writeError(operation, detail);
1977
- const safe = new chunkGEFUSYH5_cjs.AutotaskError(`time_off_requests.${operation}: ${detail}`, {
1976
+ if (!chunkYTOBU3Z6_cjs.isAutotaskError(error)) throw this.writeError(operation, detail);
1977
+ const safe = new chunkYTOBU3Z6_cjs.AutotaskError(`time_off_requests.${operation}: ${detail}`, {
1978
1978
  code: error.code,
1979
1979
  category: error.category,
1980
1980
  correlationId: error.correlationId,
@@ -1984,14 +1984,14 @@ var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
1984
1984
  retryable: error.retryable,
1985
1985
  suggestedAction: error.suggestedAction,
1986
1986
  url: error.url,
1987
- ...error instanceof chunkGEFUSYH5_cjs.MaintenanceError ? { details: {
1987
+ ...error instanceof chunkYTOBU3Z6_cjs.MaintenanceError ? { details: {
1988
1988
  since: error.details?.since,
1989
1989
  retryAfterMs: error.details?.retryAfterMs
1990
1990
  } } : {}
1991
1991
  });
1992
1992
  Object.setPrototypeOf(safe, Object.getPrototypeOf(error));
1993
1993
  safe.name = error.name;
1994
- if (error instanceof chunkGEFUSYH5_cjs.RateLimitError || error instanceof chunkGEFUSYH5_cjs.MaintenanceError) {
1994
+ if (error instanceof chunkYTOBU3Z6_cjs.RateLimitError || error instanceof chunkYTOBU3Z6_cjs.MaintenanceError) {
1995
1995
  Object.assign(safe, { retryAfter: error.retryAfter, notSent: error.notSent });
1996
1996
  }
1997
1997
  throw safe;
@@ -2001,11 +2001,11 @@ var TimeOffRequestsResource = class extends chunkGEFUSYH5_cjs.GenericResource {
2001
2001
  }
2002
2002
  guardChoice(fields, name, id, operation, label) {
2003
2003
  const unavailable = () => this.writeError(operation, `${name} requires an unambiguous active exposed ${label ?? "request-type"} picklist value; inspect time_off_requests.getFieldInfo`);
2004
- const rows = fields.filter((field) => chunkGEFUSYH5_cjs.isRecord(field) && field.name === name);
2004
+ const rows = fields.filter((field) => chunkYTOBU3Z6_cjs.isRecord(field) && field.name === name);
2005
2005
  if (rows.length !== 1 || rows[0].isPickList !== true || !Array.isArray(rows[0].picklistValues)) throw unavailable();
2006
2006
  const values = rows[0].picklistValues;
2007
- const numeric = (value) => chunkGEFUSYH5_cjs.isRecord(value) && typeof value.value === "string" && /^-?\d+$/.test(value.value) && Number.isSafeInteger(Number(value.value));
2008
- const named = label === void 0 ? values.filter((value) => numeric(value) && Number(value.value) === id) : values.filter((value) => chunkGEFUSYH5_cjs.isRecord(value) && typeof value.label === "string" && value.label.trim().toLowerCase() === label.toLowerCase());
2007
+ const numeric = (value) => chunkYTOBU3Z6_cjs.isRecord(value) && typeof value.value === "string" && /^-?\d+$/.test(value.value) && Number.isSafeInteger(Number(value.value));
2008
+ const named = label === void 0 ? values.filter((value) => numeric(value) && Number(value.value) === id) : values.filter((value) => chunkYTOBU3Z6_cjs.isRecord(value) && typeof value.label === "string" && value.label.trim().toLowerCase() === label.toLowerCase());
2009
2009
  if (named.length !== 1 || !numeric(named[0]) || named[0].isActive !== true || Number(named[0].value) !== id) throw unavailable();
2010
2010
  if (values.filter((value) => numeric(value) && Number(value.value) === id).length !== 1) throw unavailable();
2011
2011
  }