node-autotask 0.68.0 → 0.68.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.
- package/CHANGELOG.md +6 -0
- package/dist/{chunk-HFWOHUVF.cjs → chunk-2D2KJOX2.cjs} +171 -171
- package/dist/{chunk-CG6OPTFG.cjs → chunk-KRQONGLD.cjs} +31 -31
- package/dist/{chunk-BF22HBNT.js → chunk-LOLWHPTJ.js} +2 -2
- package/dist/{chunk-OUVUQQXH.js → chunk-S6HEIGGM.js} +1 -1
- package/dist/{chunk-V2GE763R.cjs → chunk-XKIRTR37.cjs} +74 -51
- package/dist/{chunk-DPJLN5BB.js → chunk-YYHCZRUH.js} +74 -51
- package/dist/index.cjs +83 -83
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +49 -49
- package/dist/operations/index.js +1 -1
- package/dist/pool.cjs +11 -11
- package/dist/pool.js +3 -3
- package/dist/resources/index.cjs +26 -26
- package/dist/resources/index.js +2 -2
- package/docs/VENDOR-QUIRKS.md +15 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXKIRTR37_cjs = require('./chunk-XKIRTR37.cjs');
|
|
4
4
|
var chunkSGH7F2CH_cjs = require('./chunk-SGH7F2CH.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
|
|
11
|
+
throw new chunkXKIRTR37_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 =
|
|
17
|
+
const numericSource = chunkXKIRTR37_cjs.parseIdentifier(sourceId, "sourceId");
|
|
18
18
|
if (opts?.destinationCompanyId === void 0) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError("moveConfigurationItem: destinationCompanyId is required");
|
|
20
20
|
}
|
|
21
|
-
const destId =
|
|
21
|
+
const destId = chunkXKIRTR37_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
|
|
31
|
+
if (opts.newReferenceTitle.trim() === "") throw new chunkXKIRTR37_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
|
|
37
|
+
throw new chunkXKIRTR37_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
|
|
44
|
+
return chunkXKIRTR37_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
|
|
69
|
+
throw new chunkXKIRTR37_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
|
|
88
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
89
89
|
}
|
|
90
90
|
return n;
|
|
91
91
|
}
|
|
@@ -101,14 +101,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
|
|
|
101
101
|
});
|
|
102
102
|
const body = res;
|
|
103
103
|
if (body === null || !("item" in body)) {
|
|
104
|
-
throw new
|
|
104
|
+
throw new chunkXKIRTR37_cjs.NotFoundError(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
105
105
|
}
|
|
106
106
|
if (body.item === null || body.item === void 0) {
|
|
107
|
-
throw new
|
|
107
|
+
throw new chunkXKIRTR37_cjs.NotFoundError("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
108
108
|
}
|
|
109
109
|
return body.item;
|
|
110
110
|
} catch (err) {
|
|
111
|
-
if (err instanceof
|
|
111
|
+
if (err instanceof chunkXKIRTR37_cjs.NotFoundError) return null;
|
|
112
112
|
throw err;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -120,7 +120,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
120
120
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
121
121
|
operation: "configuration_items.profile"
|
|
122
122
|
});
|
|
123
|
-
return
|
|
123
|
+
return chunkXKIRTR37_cjs.unwrapItems(res).items;
|
|
124
124
|
}
|
|
125
125
|
async function profile(resource, id, opts = {}) {
|
|
126
126
|
const http = resource.http;
|
|
@@ -155,11 +155,11 @@ async function profile(resource, id, opts = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
157
|
if (opts.names === true) {
|
|
158
|
-
const builder =
|
|
158
|
+
const builder = chunkXKIRTR37_cjs.createNamePlan();
|
|
159
159
|
builder.addFk("contract", root["contractID"]);
|
|
160
|
-
const names = await
|
|
160
|
+
const names = await chunkXKIRTR37_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
161
161
|
const ciRow = { ...ci };
|
|
162
|
-
|
|
162
|
+
chunkXKIRTR37_cjs.addNameSibling(ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
163
163
|
result.ci = ciRow;
|
|
164
164
|
result.names = names.section;
|
|
165
165
|
}
|
|
@@ -167,7 +167,7 @@ async function profile(resource, id, opts = {}) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// src/resources/configuration_items.ts
|
|
170
|
-
var ConfigurationItemsResource = class extends
|
|
170
|
+
var ConfigurationItemsResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
171
171
|
constructor(http, pageSize) {
|
|
172
172
|
super(http, {
|
|
173
173
|
key: "configuration_items",
|
|
@@ -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
|
|
216
|
+
throw new chunkXKIRTR37_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 =
|
|
223
|
-
const destId =
|
|
222
|
+
const sourceId = chunkXKIRTR37_cjs.parseIdentifier(sourceContactId, "sourceContactId");
|
|
223
|
+
const destId = chunkXKIRTR37_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
|
|
227
|
+
throw new chunkXKIRTR37_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
|
|
232
|
+
throw new chunkXKIRTR37_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 =
|
|
254
|
+
const items = chunkXKIRTR37_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
|
|
257
|
+
throw new chunkXKIRTR37_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
|
|
271
|
+
return chunkXKIRTR37_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
|
|
297
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError("contacts.moveToCompany: vendor create response has no itemId");
|
|
298
298
|
}
|
|
299
299
|
let sourceDeleted = false;
|
|
300
300
|
if (opts.deleteSource === true) {
|
|
@@ -310,20 +310,20 @@ 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 =
|
|
314
|
-
const ticketLimit =
|
|
315
|
-
const contactId =
|
|
316
|
-
const envelope = await
|
|
313
|
+
const client = chunkXKIRTR37_cjs.clientOf(resource, FULL_PROFILE_OP);
|
|
314
|
+
const ticketLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", FULL_PROFILE_OP);
|
|
315
|
+
const contactId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
316
|
+
const envelope = await chunkXKIRTR37_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
|
|
321
|
+
throw new chunkXKIRTR37_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
|
|
325
|
-
const company = fk === null ? { value: null, absent: "NO_FK" } : await
|
|
326
|
-
const openTickets = await
|
|
324
|
+
const root = fk === null ? row : await chunkXKIRTR37_cjs.invokeRead(client, "contacts.get", [fk, contactId]);
|
|
325
|
+
const company = fk === null ? { value: null, absent: "NO_FK" } : await chunkXKIRTR37_cjs.compositePart(client, "companies.get", [fk]);
|
|
326
|
+
const openTickets = await chunkXKIRTR37_cjs.openTicketsOfPart(
|
|
327
327
|
client,
|
|
328
328
|
"contactID",
|
|
329
329
|
contactId,
|
|
@@ -333,7 +333,7 @@ async function fullProfile(resource, id, opts = {}) {
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
// src/resources/contacts.ts
|
|
336
|
-
var ContactsResource = class extends
|
|
336
|
+
var ContactsResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
337
337
|
constructor(http, pageSize) {
|
|
338
338
|
super(http, {
|
|
339
339
|
key: "contacts",
|
|
@@ -382,10 +382,10 @@ var PATH_SUFFIX = {
|
|
|
382
382
|
};
|
|
383
383
|
async function stockedItems(_resource, kind, parentId, data, opts = {}) {
|
|
384
384
|
const http = _resource.http;
|
|
385
|
-
const numericParent =
|
|
385
|
+
const numericParent = chunkXKIRTR37_cjs.parseIdentifier(parentId, "parentId");
|
|
386
386
|
const suffix = PATH_SUFFIX[kind];
|
|
387
387
|
if (opts.dryRun === true) {
|
|
388
|
-
return
|
|
388
|
+
return chunkXKIRTR37_cjs.buildDryRunResult({
|
|
389
389
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
390
390
|
method: "POST",
|
|
391
391
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -402,11 +402,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}) {
|
|
|
402
402
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
403
403
|
maxRetries: opts.maxRetries
|
|
404
404
|
});
|
|
405
|
-
return
|
|
405
|
+
return chunkXKIRTR37_cjs.unwrapOperation(res);
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
// src/resources/inventory_products.ts
|
|
409
|
-
var InventoryProductsResource = class extends
|
|
409
|
+
var InventoryProductsResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
410
410
|
constructor(http, pageSize) {
|
|
411
411
|
super(http, {
|
|
412
412
|
key: "inventory_products",
|
|
@@ -434,18 +434,18 @@ var InventoryProductsResource = class extends chunkV2GE763R_cjs.GenericResource
|
|
|
434
434
|
// src/resources/special/quotes.ts
|
|
435
435
|
var OP = "quotes.withItems";
|
|
436
436
|
async function withItems(resource, id, opts = {}) {
|
|
437
|
-
const client =
|
|
438
|
-
const itemLimit =
|
|
439
|
-
const quoteId =
|
|
440
|
-
const root = await
|
|
441
|
-
const items = await
|
|
437
|
+
const client = chunkXKIRTR37_cjs.clientOf(resource, OP);
|
|
438
|
+
const itemLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.itemLimit, "itemLimit", OP);
|
|
439
|
+
const quoteId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
440
|
+
const root = await chunkXKIRTR37_cjs.invokeRead(client, "quotes.get", [quoteId]);
|
|
441
|
+
const items = await chunkXKIRTR37_cjs.compositePart(client, "quote_items.query", [
|
|
442
442
|
{ filter: [{ field: "quoteID", op: "eq", value: quoteId }], limit: itemLimit }
|
|
443
443
|
]);
|
|
444
444
|
return { root, parts: { items } };
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
// src/resources/quotes.ts
|
|
448
|
-
var QuotesResource = class extends
|
|
448
|
+
var QuotesResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
449
449
|
constructor(http, pageSize) {
|
|
450
450
|
super(http, {
|
|
451
451
|
key: "quotes",
|
|
@@ -471,7 +471,7 @@ var QuotesResource = class extends chunkV2GE763R_cjs.GenericResource {
|
|
|
471
471
|
// src/resources/special/resource_time_off_additional.ts
|
|
472
472
|
async function getByResource(_resource, resourceId) {
|
|
473
473
|
const http = _resource.http;
|
|
474
|
-
const numericResource =
|
|
474
|
+
const numericResource = chunkXKIRTR37_cjs.parseIdentifier(resourceId, "resourceId");
|
|
475
475
|
const res = await http.request({
|
|
476
476
|
method: "GET",
|
|
477
477
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -485,11 +485,11 @@ async function getByResource(_resource, resourceId) {
|
|
|
485
485
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
return
|
|
488
|
+
return chunkXKIRTR37_cjs.unwrapItems(res, "resource_time_off_additional.getByResource").items;
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
// src/resources/resource_time_off_additional.ts
|
|
492
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
492
|
+
var ResourceTimeOffAdditionalResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
493
493
|
constructor(http, pageSize) {
|
|
494
494
|
super(http, {
|
|
495
495
|
key: "resource_time_off_additional",
|
|
@@ -510,30 +510,30 @@ var ResourceTimeOffAdditionalResource = class extends chunkV2GE763R_cjs.GenericR
|
|
|
510
510
|
// src/resources/special/resource_time_off_balances.ts
|
|
511
511
|
async function getByResource2(_resource, resourceId) {
|
|
512
512
|
const http = _resource.http;
|
|
513
|
-
const numericResource =
|
|
513
|
+
const numericResource = chunkXKIRTR37_cjs.parseIdentifier(resourceId, "resourceId");
|
|
514
514
|
const res = await http.request({
|
|
515
515
|
method: "GET",
|
|
516
516
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
517
517
|
operation: "resource_time_off_balances.getByResource"
|
|
518
518
|
});
|
|
519
|
-
return
|
|
519
|
+
return chunkXKIRTR37_cjs.unwrapItems(res, "resource_time_off_balances.getByResource").items;
|
|
520
520
|
}
|
|
521
521
|
async function getByYear(_resource, resourceId, year) {
|
|
522
522
|
const http = _resource.http;
|
|
523
|
-
const numericResource =
|
|
523
|
+
const numericResource = chunkXKIRTR37_cjs.parseIdentifier(resourceId, "resourceId");
|
|
524
524
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
525
|
-
throw new
|
|
525
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError("getByYear: year must be a positive integer");
|
|
526
526
|
}
|
|
527
527
|
const res = await http.request({
|
|
528
528
|
method: "GET",
|
|
529
529
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
530
530
|
operation: "resource_time_off_balances.getByYear"
|
|
531
531
|
});
|
|
532
|
-
return
|
|
532
|
+
return chunkXKIRTR37_cjs.unwrapItem(res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
533
533
|
}
|
|
534
534
|
|
|
535
535
|
// src/resources/resource_time_off_balances.ts
|
|
536
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
536
|
+
var ResourceTimeOffBalancesResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
537
537
|
constructor(http, pageSize) {
|
|
538
538
|
super(http, {
|
|
539
539
|
key: "resource_time_off_balances",
|
|
@@ -559,7 +559,7 @@ var ResourceTimeOffBalancesResource = class extends chunkV2GE763R_cjs.GenericRes
|
|
|
559
559
|
async function whoAmI(_resource, userName) {
|
|
560
560
|
const http = _resource.http;
|
|
561
561
|
const user = userName.trim();
|
|
562
|
-
if (user === "") throw new
|
|
562
|
+
if (user === "") throw new chunkXKIRTR37_cjs.AutotaskConfigError("whoAmI: the configured UserName is empty");
|
|
563
563
|
const value = user.includes("@") ? user.split("@")[0] ?? "" : user;
|
|
564
564
|
const res = await http.request({
|
|
565
565
|
method: "POST",
|
|
@@ -568,11 +568,11 @@ async function whoAmI(_resource, userName) {
|
|
|
568
568
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
569
569
|
operation: "resources.whoAmI"
|
|
570
570
|
});
|
|
571
|
-
const matches =
|
|
571
|
+
const matches = chunkXKIRTR37_cjs.unwrapItems(res).items;
|
|
572
572
|
if (matches.length === 0) return null;
|
|
573
573
|
if (matches.length > 1) {
|
|
574
574
|
const ids = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
575
|
-
throw new
|
|
575
|
+
throw new chunkXKIRTR37_cjs.ResolutionError(
|
|
576
576
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
577
577
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids, details: { idRefs: ids.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
578
578
|
);
|
|
@@ -581,23 +581,23 @@ async function whoAmI(_resource, userName) {
|
|
|
581
581
|
}
|
|
582
582
|
var WORKLOAD_OP = "resources.workload";
|
|
583
583
|
async function workload(resource, id, opts = {}) {
|
|
584
|
-
const client =
|
|
585
|
-
const ticketLimit =
|
|
586
|
-
const taskLimit =
|
|
587
|
-
const timeOffLimit =
|
|
588
|
-
const resourceId =
|
|
589
|
-
const root = await
|
|
584
|
+
const client = chunkXKIRTR37_cjs.clientOf(resource, WORKLOAD_OP);
|
|
585
|
+
const ticketLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", WORKLOAD_OP);
|
|
586
|
+
const taskLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.taskLimit, "taskLimit", WORKLOAD_OP);
|
|
587
|
+
const timeOffLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.timeOffLimit, "timeOffLimit", WORKLOAD_OP);
|
|
588
|
+
const resourceId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
589
|
+
const root = await chunkXKIRTR37_cjs.invokeRead(client, "resources.get", [resourceId]);
|
|
590
590
|
const strict = { allowAssumed: false };
|
|
591
|
-
const joined = await
|
|
591
|
+
const joined = await chunkXKIRTR37_cjs.compositePart(client, "tickets.forResource", [
|
|
592
592
|
resourceId,
|
|
593
593
|
{ openOnly: true, limit: Math.min(ticketLimit, 500), ...strict }
|
|
594
594
|
]);
|
|
595
|
-
const counted = await
|
|
596
|
-
const assignments = await
|
|
595
|
+
const counted = await chunkXKIRTR37_cjs.compositePart(client, "tickets.forResource", [resourceId, { countOnly: true, ...strict }]);
|
|
596
|
+
const assignments = await chunkXKIRTR37_cjs.compositePart(client, "service_call_task_resources.query", [
|
|
597
597
|
{ filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: taskLimit }
|
|
598
598
|
]);
|
|
599
|
-
const balances = await
|
|
600
|
-
const timeOff = await
|
|
599
|
+
const balances = await chunkXKIRTR37_cjs.compositePart(client, "resource_time_off_balances.getByResource", [resourceId]);
|
|
600
|
+
const timeOff = await chunkXKIRTR37_cjs.compositePart(client, "time_off_requests.query", [
|
|
601
601
|
{ filter: [{ field: "resourceID", op: "eq", value: resourceId }], limit: timeOffLimit }
|
|
602
602
|
]);
|
|
603
603
|
const openTickets = joined.value !== null && typeof joined.value === "object" ? counted.value !== null && typeof counted.value === "object" ? (() => {
|
|
@@ -610,11 +610,11 @@ async function workload(resource, id, opts = {}) {
|
|
|
610
610
|
...joined,
|
|
611
611
|
value: { ...joined.value, totalsAbsent: counted.absent ?? "NO_TOTALS" }
|
|
612
612
|
} : joined;
|
|
613
|
-
const taskIds =
|
|
613
|
+
const taskIds = chunkXKIRTR37_cjs.numericIds(
|
|
614
614
|
assignments.value?.items ?? [],
|
|
615
615
|
"serviceCallTaskID"
|
|
616
|
-
).slice(0,
|
|
617
|
-
const taskDetails = taskIds.length === 0 ? { value: null, absent: "NO_ASSIGNMENTS" } : await
|
|
616
|
+
).slice(0, chunkXKIRTR37_cjs.IN_FILTER_CAP);
|
|
617
|
+
const taskDetails = taskIds.length === 0 ? { value: null, absent: "NO_ASSIGNMENTS" } : await chunkXKIRTR37_cjs.compositePart(client, "service_call_tasks.query", [
|
|
618
618
|
{ filter: [{ field: "id", op: "in", value: taskIds }], limit: taskLimit }
|
|
619
619
|
]);
|
|
620
620
|
return {
|
|
@@ -630,7 +630,7 @@ async function workload(resource, id, opts = {}) {
|
|
|
630
630
|
}
|
|
631
631
|
|
|
632
632
|
// src/resources/resources.ts
|
|
633
|
-
var ResourcesResource = class extends
|
|
633
|
+
var ResourcesResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
634
634
|
clientConfig;
|
|
635
635
|
constructor(http, clientConfig, pageSize) {
|
|
636
636
|
super(http, {
|
|
@@ -662,22 +662,22 @@ var ResourcesResource = class extends chunkV2GE763R_cjs.GenericResource {
|
|
|
662
662
|
// src/resources/special/service_calls.ts
|
|
663
663
|
var OP2 = "service_calls.fullProfile";
|
|
664
664
|
async function fullProfile2(resource, id, opts = {}) {
|
|
665
|
-
const client =
|
|
666
|
-
const ticketLimit =
|
|
667
|
-
const taskLimit =
|
|
668
|
-
const callId =
|
|
669
|
-
const root = await
|
|
670
|
-
const tickets = await
|
|
665
|
+
const client = chunkXKIRTR37_cjs.clientOf(resource, OP2);
|
|
666
|
+
const ticketLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.ticketLimit, "ticketLimit", OP2);
|
|
667
|
+
const taskLimit = chunkXKIRTR37_cjs.compositePartLimit(opts.taskLimit, "taskLimit", OP2);
|
|
668
|
+
const callId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
669
|
+
const root = await chunkXKIRTR37_cjs.invokeRead(client, "service_calls.get", [callId]);
|
|
670
|
+
const tickets = await chunkXKIRTR37_cjs.compositePart(client, "service_call_tickets.query", [
|
|
671
671
|
{ filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: ticketLimit }
|
|
672
672
|
]);
|
|
673
|
-
const tasks = await
|
|
673
|
+
const tasks = await chunkXKIRTR37_cjs.compositePart(client, "service_call_tasks.query", [
|
|
674
674
|
{ filter: [{ field: "serviceCallID", op: "eq", value: callId }], limit: taskLimit }
|
|
675
675
|
]);
|
|
676
|
-
const taskIds =
|
|
676
|
+
const taskIds = chunkXKIRTR37_cjs.numericIds(
|
|
677
677
|
tasks.value?.items ?? [],
|
|
678
678
|
"id"
|
|
679
|
-
).slice(0,
|
|
680
|
-
const resourceAssignments = taskIds.length === 0 ? { value: null, absent: "NO_TASKS" } : await
|
|
679
|
+
).slice(0, chunkXKIRTR37_cjs.IN_FILTER_CAP);
|
|
680
|
+
const resourceAssignments = taskIds.length === 0 ? { value: null, absent: "NO_TASKS" } : await chunkXKIRTR37_cjs.compositePart(client, "service_call_task_resources.query", [
|
|
681
681
|
{ filter: [{ field: "serviceCallTaskID", op: "in", value: taskIds }], limit: taskLimit }
|
|
682
682
|
]);
|
|
683
683
|
return {
|
|
@@ -691,7 +691,7 @@ async function fullProfile2(resource, id, opts = {}) {
|
|
|
691
691
|
}
|
|
692
692
|
|
|
693
693
|
// src/resources/service_calls.ts
|
|
694
|
-
var ServiceCallsResource = class extends
|
|
694
|
+
var ServiceCallsResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
695
695
|
constructor(http, pageSize) {
|
|
696
696
|
super(http, {
|
|
697
697
|
key: "service_calls",
|
|
@@ -713,13 +713,13 @@ var OP3 = "ticket_charges.moveToTicket";
|
|
|
713
713
|
var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
|
|
714
714
|
var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
|
|
715
715
|
async function readCharge(http, id, retries) {
|
|
716
|
-
const rows = await
|
|
716
|
+
const rows = await chunkXKIRTR37_cjs.queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
|
|
717
717
|
return rows[0] ?? null;
|
|
718
718
|
}
|
|
719
719
|
async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
|
|
720
720
|
if (source.isBilled === true) {
|
|
721
|
-
throw
|
|
722
|
-
manualAction: { action: "delete_source", uiLink:
|
|
721
|
+
throw chunkXKIRTR37_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: chunkXKIRTR37_cjs.uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
|
|
723
723
|
});
|
|
724
724
|
}
|
|
725
725
|
}
|
|
@@ -753,14 +753,14 @@ var SPEC = {
|
|
|
753
753
|
]
|
|
754
754
|
}),
|
|
755
755
|
// charges have no ExecuteCommand code: the parent ticket is the closest clickable target
|
|
756
|
-
manualLink: (http, source) => typeof source.ticketID === "number" ?
|
|
756
|
+
manualLink: (http, source) => typeof source.ticketID === "number" ? chunkXKIRTR37_cjs.uiLinkFor(http, "tickets", source.ticketID) : null
|
|
757
757
|
};
|
|
758
758
|
function moveToTicket(resource, sourceId, toTicketId, opts) {
|
|
759
|
-
return
|
|
759
|
+
return chunkXKIRTR37_cjs.runMove(resource.http, SPEC, sourceId, toTicketId, opts);
|
|
760
760
|
}
|
|
761
761
|
|
|
762
762
|
// src/resources/ticket_charges.ts
|
|
763
|
-
var TicketChargesResource = class extends
|
|
763
|
+
var TicketChargesResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
764
764
|
constructor(http, pageSize) {
|
|
765
765
|
super(http, {
|
|
766
766
|
key: "ticket_charges",
|
|
@@ -785,7 +785,7 @@ var TicketChargesResource = class extends chunkV2GE763R_cjs.GenericResource {
|
|
|
785
785
|
};
|
|
786
786
|
|
|
787
787
|
// src/resources/special/tickets/errors.ts
|
|
788
|
-
var StatusUnknownError = class extends
|
|
788
|
+
var StatusUnknownError = class extends chunkXKIRTR37_cjs.AutotaskError {
|
|
789
789
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
790
790
|
picklistCount;
|
|
791
791
|
constructor(message, options = {}) {
|
|
@@ -799,7 +799,7 @@ var StatusUnknownError = class extends chunkV2GE763R_cjs.AutotaskError {
|
|
|
799
799
|
this.picklistCount = options.picklistCount ?? 0;
|
|
800
800
|
}
|
|
801
801
|
};
|
|
802
|
-
var StatusFieldsRequiredError = class extends
|
|
802
|
+
var StatusFieldsRequiredError = class extends chunkXKIRTR37_cjs.AutotaskError {
|
|
803
803
|
vendorFields;
|
|
804
804
|
currentStatus;
|
|
805
805
|
targetStatus;
|
|
@@ -821,8 +821,8 @@ function isPositiveInt(v) {
|
|
|
821
821
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
822
822
|
}
|
|
823
823
|
function namedVendorFields(err) {
|
|
824
|
-
if (!
|
|
825
|
-
const entries =
|
|
824
|
+
if (!chunkXKIRTR37_cjs.isAutotaskError(err) || err.vendorError === void 0) return [];
|
|
825
|
+
const entries = chunkXKIRTR37_cjs.parseVendorErrors(err.vendorError) ?? [];
|
|
826
826
|
const out = /* @__PURE__ */ new Set();
|
|
827
827
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
828
828
|
return [...out];
|
|
@@ -841,8 +841,8 @@ function unwrapItemOrNull(res) {
|
|
|
841
841
|
return body.item;
|
|
842
842
|
}
|
|
843
843
|
function discoveryMerge(err, body, defaults) {
|
|
844
|
-
if (!
|
|
845
|
-
const entries =
|
|
844
|
+
if (!chunkXKIRTR37_cjs.isAutotaskError(err) || err.vendorError === void 0) return null;
|
|
845
|
+
const entries = chunkXKIRTR37_cjs.parseVendorErrors(err.vendorError);
|
|
846
846
|
if (entries === void 0) return null;
|
|
847
847
|
for (const entry of entries) {
|
|
848
848
|
const field = entry.field;
|
|
@@ -877,7 +877,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
877
877
|
const ids = await readLiveStatusSet(resource);
|
|
878
878
|
if (ids.size > 0) liveStatus = ids;
|
|
879
879
|
} catch (err) {
|
|
880
|
-
if (!
|
|
880
|
+
if (!chunkXKIRTR37_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
881
881
|
}
|
|
882
882
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
883
883
|
http.fieldCache?.invalidate("tickets:");
|
|
@@ -887,7 +887,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
887
887
|
const freshIds = await readLiveStatusSet(resource);
|
|
888
888
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
889
889
|
} catch (err) {
|
|
890
|
-
if (!
|
|
890
|
+
if (!chunkXKIRTR37_cjs.isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
891
891
|
freshStatus = null;
|
|
892
892
|
reReadFailed = true;
|
|
893
893
|
}
|
|
@@ -905,7 +905,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
905
905
|
return { guardDegraded: liveStatus === null };
|
|
906
906
|
}
|
|
907
907
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
908
|
-
return
|
|
908
|
+
return chunkXKIRTR37_cjs.buildDryRunResult(
|
|
909
909
|
{
|
|
910
910
|
operation: OP_STATUS,
|
|
911
911
|
method: "PUT",
|
|
@@ -959,7 +959,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
959
959
|
if (mapEntry === void 0) {
|
|
960
960
|
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
961
|
}
|
|
962
|
-
return
|
|
962
|
+
return chunkXKIRTR37_cjs.buildDryRunResult(
|
|
963
963
|
{
|
|
964
964
|
operation: OP_STATUS,
|
|
965
965
|
method: "PUT",
|
|
@@ -979,7 +979,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
979
979
|
}
|
|
980
980
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
981
981
|
const safeDefaults = mapEntry?.safeDefaults ?? {};
|
|
982
|
-
const body =
|
|
982
|
+
const body = chunkXKIRTR37_cjs.mergePartialBody(current, mergeData);
|
|
983
983
|
body.id = ticketId;
|
|
984
984
|
let merges = 0;
|
|
985
985
|
for (; ; ) {
|
|
@@ -1003,8 +1003,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
1003
1003
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
1004
1004
|
{
|
|
1005
1005
|
operation: OP_STATUS,
|
|
1006
|
-
httpStatus:
|
|
1007
|
-
vendorError:
|
|
1006
|
+
httpStatus: chunkXKIRTR37_cjs.isAutotaskError(err) ? err.httpStatus : void 0,
|
|
1007
|
+
vendorError: chunkXKIRTR37_cjs.isAutotaskError(err) ? err.vendorError : void 0,
|
|
1008
1008
|
resourceIds: [ticketId],
|
|
1009
1009
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
1010
1010
|
}
|
|
@@ -1017,7 +1017,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
1017
1017
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
1018
1018
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
1019
1019
|
if (verify === null) {
|
|
1020
|
-
throw new
|
|
1020
|
+
throw new chunkXKIRTR37_cjs.AutotaskError(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
1021
1021
|
code: "INVALID_RESPONSE",
|
|
1022
1022
|
category: "server",
|
|
1023
1023
|
operation: OP_STATUS,
|
|
@@ -1027,7 +1027,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
1029
1029
|
if (finalStatus !== targetStatus) {
|
|
1030
|
-
throw new
|
|
1030
|
+
throw new chunkXKIRTR37_cjs.AutotaskError(
|
|
1031
1031
|
`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
1032
|
{
|
|
1033
1033
|
code: "INVALID_RESPONSE",
|
|
@@ -1043,17 +1043,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
async function changeStatus(resource, id, targetStatus, fields, opts) {
|
|
1045
1045
|
const http = resource.http;
|
|
1046
|
-
const ticketId =
|
|
1046
|
+
const ticketId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1047
1047
|
if (!isPositiveInt(targetStatus)) {
|
|
1048
|
-
throw new
|
|
1048
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
1049
1049
|
}
|
|
1050
1050
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
1051
1051
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
1052
|
-
throw new
|
|
1052
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
1053
1053
|
}
|
|
1054
1054
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
1055
1055
|
if (current === null) {
|
|
1056
|
-
throw new
|
|
1056
|
+
throw new chunkXKIRTR37_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
1057
|
}
|
|
1058
1058
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
1059
1059
|
if (previousStatus === targetStatus) {
|
|
@@ -1079,7 +1079,7 @@ var TICKET_FIELDS = ["id", "ticketNumber", "title", "status", "assignedResourceI
|
|
|
1079
1079
|
function positiveId(value, name) {
|
|
1080
1080
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
1081
1081
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
1082
|
-
throw new
|
|
1082
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
|
|
1083
1083
|
}
|
|
1084
1084
|
return n;
|
|
1085
1085
|
}
|
|
@@ -1091,7 +1091,7 @@ async function ticketPage(http, filter, maxRecords, fields) {
|
|
|
1091
1091
|
body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
|
|
1092
1092
|
operation: OP4
|
|
1093
1093
|
});
|
|
1094
|
-
const page =
|
|
1094
|
+
const page = chunkXKIRTR37_cjs.unwrapItems(res, OP4);
|
|
1095
1095
|
return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
|
|
1096
1096
|
}
|
|
1097
1097
|
async function readLinkIds(http, resourceID, maxPages = 1) {
|
|
@@ -1101,11 +1101,11 @@ async function readLinkIds(http, resourceID, maxPages = 1) {
|
|
|
1101
1101
|
const res = await http.request({
|
|
1102
1102
|
method: "POST",
|
|
1103
1103
|
idempotent: true,
|
|
1104
|
-
path: cursor === null ? "/V1.0/TicketSecondaryResources/query" :
|
|
1104
|
+
path: cursor === null ? "/V1.0/TicketSecondaryResources/query" : chunkXKIRTR37_cjs.cursorToPath(http.baseUrl, cursor),
|
|
1105
1105
|
body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
|
|
1106
1106
|
operation: OP4
|
|
1107
1107
|
});
|
|
1108
|
-
const page =
|
|
1108
|
+
const page = chunkXKIRTR37_cjs.unwrapItems(res, OP4);
|
|
1109
1109
|
for (const row of page.items) if (typeof row.ticketID === "number") ids.add(row.ticketID);
|
|
1110
1110
|
cursor = page.pageDetails.nextPageUrl;
|
|
1111
1111
|
if (cursor === null || page.items.length === 0) return { ids: [...ids], capped: false };
|
|
@@ -1114,35 +1114,35 @@ async function readLinkIds(http, resourceID, maxPages = 1) {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
async function forResource(_resource, resourceIDIn, opts = {}) {
|
|
1116
1116
|
const http = _resource.http;
|
|
1117
|
-
if (opts === null || typeof opts !== "object") throw new
|
|
1117
|
+
if (opts === null || typeof opts !== "object") throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: opts must be an object`, { operation: OP4 });
|
|
1118
1118
|
const resourceID = positiveId(resourceIDIn, "resourceID");
|
|
1119
1119
|
const scope = opts.scope ?? "both";
|
|
1120
1120
|
if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
|
|
1121
|
-
throw new
|
|
1121
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
|
|
1122
1122
|
}
|
|
1123
1123
|
if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
|
|
1124
|
-
throw new
|
|
1124
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
|
|
1125
1125
|
}
|
|
1126
1126
|
const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
|
|
1127
1127
|
if (opts.countOnly !== true && (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX)) {
|
|
1128
|
-
throw new
|
|
1128
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
|
|
1129
1129
|
}
|
|
1130
1130
|
const includeFields = opts.includeFields ?? [];
|
|
1131
1131
|
if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
|
|
1132
|
-
throw new
|
|
1132
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
|
|
1133
1133
|
}
|
|
1134
1134
|
const openOnly = opts.openOnly === true;
|
|
1135
1135
|
const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS, ...includeFields])];
|
|
1136
1136
|
if (opts.countOnly !== void 0 && typeof opts.countOnly !== "boolean") {
|
|
1137
|
-
throw new
|
|
1137
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`${OP4}: countOnly must be a boolean`, { operation: OP4 });
|
|
1138
1138
|
}
|
|
1139
|
-
const closed = await
|
|
1139
|
+
const closed = await chunkXKIRTR37_cjs.resolveTicketStatusSemantics(
|
|
1140
1140
|
http,
|
|
1141
1141
|
{ ...opts.excludeStatusIds === void 0 ? {} : { excludeStatusIds: opts.excludeStatusIds }, ...opts.allowAssumed === void 0 ? {} : { allowAssumed: opts.allowAssumed } },
|
|
1142
1142
|
OP4
|
|
1143
1143
|
);
|
|
1144
1144
|
const closedStatus = { closedIds: closed.closedIds, source: closed.source, note: closed.note };
|
|
1145
|
-
const openLeaf = openOnly || opts.countOnly === true ? [
|
|
1145
|
+
const openLeaf = openOnly || opts.countOnly === true ? [chunkXKIRTR37_cjs.openStatusFilter(closed.closedIds)] : [];
|
|
1146
1146
|
if (opts.countOnly === true) {
|
|
1147
1147
|
const primaryCount = scope === "secondary" ? 0 : await _resource.count({ filter: [{ field: "assignedResourceID", op: "eq", value: resourceID }, ...openLeaf] });
|
|
1148
1148
|
let secondaryCount = 0;
|
|
@@ -1156,7 +1156,7 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
|
|
|
1156
1156
|
const page = await ticketPage(http, [{ field: "id", op: "in", value: chunk }, ...openLeaf], chunk.length, ["id", "status", "assignedResourceID"]);
|
|
1157
1157
|
const seen = /* @__PURE__ */ new Set();
|
|
1158
1158
|
for (const t of page.rows) {
|
|
1159
|
-
if (typeof t.id !== "number" || seen.has(t.id) ||
|
|
1159
|
+
if (typeof t.id !== "number" || seen.has(t.id) || chunkXKIRTR37_cjs.isClosedStatus(t.status, closed.closedIds)) continue;
|
|
1160
1160
|
seen.add(t.id);
|
|
1161
1161
|
if (scope === "both" && t.assignedResourceID === resourceID) bothCount++;
|
|
1162
1162
|
}
|
|
@@ -1202,13 +1202,13 @@ async function forResource(_resource, resourceIDIn, opts = {}) {
|
|
|
1202
1202
|
for (const [id, t] of primary) merged.set(id, t);
|
|
1203
1203
|
for (const [id, t] of secondary) if (!merged.has(id)) merged.set(id, t);
|
|
1204
1204
|
let tickets = [...merged.values()];
|
|
1205
|
-
if (openOnly) tickets = tickets.filter((t) => !
|
|
1205
|
+
if (openOnly) tickets = tickets.filter((t) => !chunkXKIRTR37_cjs.isClosedStatus(t.status, closed.closedIds));
|
|
1206
1206
|
tickets.sort((a, b) => Number(a.id) - Number(b.id));
|
|
1207
1207
|
if (tickets.length > limit) {
|
|
1208
1208
|
tickets = tickets.slice(0, limit);
|
|
1209
1209
|
capped = true;
|
|
1210
1210
|
}
|
|
1211
|
-
const openCount = tickets.filter((t) => !
|
|
1211
|
+
const openCount = tickets.filter((t) => !chunkXKIRTR37_cjs.isClosedStatus(t.status, closed.closedIds)).length;
|
|
1212
1212
|
const primaryIds = [...primary.keys()].sort((a, b) => a - b);
|
|
1213
1213
|
const secondaryIds = [...secondary.keys()].sort((a, b) => a - b);
|
|
1214
1214
|
const both = primaryIds.filter((id) => secondary.has(id));
|
|
@@ -1236,9 +1236,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
1236
1236
|
});
|
|
1237
1237
|
const body = res;
|
|
1238
1238
|
if (body === null || !("item" in body)) {
|
|
1239
|
-
throw new
|
|
1239
|
+
throw new chunkXKIRTR37_cjs.NotFoundError(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
1240
1240
|
}
|
|
1241
|
-
if (body.item === null || body.item === void 0) throw new
|
|
1241
|
+
if (body.item === null || body.item === void 0) throw new chunkXKIRTR37_cjs.NotFoundError(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
1242
1242
|
return body.item;
|
|
1243
1243
|
}
|
|
1244
1244
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -1249,7 +1249,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
1249
1249
|
body: { MaxRecords: maxRecords, filter },
|
|
1250
1250
|
operation
|
|
1251
1251
|
});
|
|
1252
|
-
return
|
|
1252
|
+
return chunkXKIRTR37_cjs.unwrapItems(res).items;
|
|
1253
1253
|
}
|
|
1254
1254
|
function truncate(text, limit) {
|
|
1255
1255
|
const full = text ?? "";
|
|
@@ -1259,13 +1259,13 @@ function truncate(text, limit) {
|
|
|
1259
1259
|
|
|
1260
1260
|
// src/resources/special/tickets/childRead.ts
|
|
1261
1261
|
function isRouteUnavailable(err) {
|
|
1262
|
-
return
|
|
1262
|
+
return chunkXKIRTR37_cjs.isAutotaskError(err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
1263
1263
|
}
|
|
1264
1264
|
function routeFact(route, path, err) {
|
|
1265
1265
|
return {
|
|
1266
1266
|
route,
|
|
1267
1267
|
path,
|
|
1268
|
-
httpStatus:
|
|
1268
|
+
httpStatus: chunkXKIRTR37_cjs.isAutotaskError(err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
1269
1269
|
};
|
|
1270
1270
|
}
|
|
1271
1271
|
async function childDeclaresQuery(resourceKey) {
|
|
@@ -1276,10 +1276,10 @@ async function childDeclaresQuery(resourceKey) {
|
|
|
1276
1276
|
}
|
|
1277
1277
|
async function planScopedPath(resourceKey, ticketId) {
|
|
1278
1278
|
if (!await childDeclaresQuery(resourceKey)) return null;
|
|
1279
|
-
const entry =
|
|
1279
|
+
const entry = chunkXKIRTR37_cjs.RELATIONSHIP_MAP[resourceKey];
|
|
1280
1280
|
const parent = entry === void 0 ? null : entry.parent;
|
|
1281
1281
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
1282
|
-
const parentPath =
|
|
1282
|
+
const parentPath = chunkXKIRTR37_cjs.RELATIONSHIP_MAP[parent.resource]?.path;
|
|
1283
1283
|
if (parentPath === null || parentPath === void 0) return null;
|
|
1284
1284
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
1285
1285
|
}
|
|
@@ -1318,14 +1318,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
1318
1318
|
break;
|
|
1319
1319
|
}
|
|
1320
1320
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
1321
|
-
const { items: pageItems, pageDetails } =
|
|
1321
|
+
const { items: pageItems, pageDetails } = chunkXKIRTR37_cjs.unwrapItems(body, operation);
|
|
1322
1322
|
nextCursor = pageDetails.nextPageUrl;
|
|
1323
1323
|
pages += 1;
|
|
1324
1324
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
1325
1325
|
for (const row of window) if (accept(row)) items.push(row);
|
|
1326
1326
|
if (items.length >= limit) break;
|
|
1327
1327
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
1328
|
-
target =
|
|
1328
|
+
target = chunkXKIRTR37_cjs.cursorToPath(http.baseUrl, nextCursor);
|
|
1329
1329
|
}
|
|
1330
1330
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
1331
1331
|
return { items, capped };
|
|
@@ -1358,7 +1358,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
1358
1358
|
function partLimit(value, name) {
|
|
1359
1359
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
1360
1360
|
if (!Number.isInteger(n) || n < 1) {
|
|
1361
|
-
throw new
|
|
1361
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1362
1362
|
}
|
|
1363
1363
|
return n;
|
|
1364
1364
|
}
|
|
@@ -1371,13 +1371,13 @@ function servedTextRecord(row, textField, limit) {
|
|
|
1371
1371
|
return out;
|
|
1372
1372
|
}
|
|
1373
1373
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
1374
|
-
const builder =
|
|
1374
|
+
const builder = chunkXKIRTR37_cjs.createNamePlan(chunkXKIRTR37_cjs.TICKET_LABEL_FIELDS);
|
|
1375
1375
|
const t = ctx.ticket;
|
|
1376
1376
|
builder.addResource(t["creatorResourceID"]);
|
|
1377
1377
|
builder.addFk("contract", t["contractID"]);
|
|
1378
1378
|
builder.addFk("billingCode", t["billingCodeID"]);
|
|
1379
1379
|
builder.addFk("role", t["assignedResourceRoleID"]);
|
|
1380
|
-
const ticketLobPointer =
|
|
1380
|
+
const ticketLobPointer = chunkXKIRTR37_cjs.vendorId(t["organizationalLevelAssociationID"]);
|
|
1381
1381
|
if (ticketLobPointer !== void 0) {
|
|
1382
1382
|
builder.addLineOfBusiness(ticketLobPointer, { source: "ticket" });
|
|
1383
1383
|
} else {
|
|
@@ -1389,20 +1389,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
|
1389
1389
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
1390
1390
|
builder.addFk("contract", e["contractID"]);
|
|
1391
1391
|
}
|
|
1392
|
-
const names = await
|
|
1392
|
+
const names = await chunkXKIRTR37_cjs.resolveCompositeNames(http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1393
1393
|
const ticketRow = { ...ctx.ticket };
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
for (const f of
|
|
1394
|
+
chunkXKIRTR37_cjs.addNameSibling(ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
1395
|
+
chunkXKIRTR37_cjs.addNameSibling(ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
1396
|
+
chunkXKIRTR37_cjs.addNameSibling(ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1397
|
+
chunkXKIRTR37_cjs.addNameSibling(ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1398
|
+
for (const f of chunkXKIRTR37_cjs.TICKET_LABEL_FIELDS) chunkXKIRTR37_cjs.addLabelSibling(ticketRow, f, names);
|
|
1399
1399
|
result.ticket = ticketRow;
|
|
1400
1400
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
1401
1401
|
const row = { ...e };
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1402
|
+
chunkXKIRTR37_cjs.addNameSibling(row, "resourceID", (v) => names.resourceName(v));
|
|
1403
|
+
chunkXKIRTR37_cjs.addNameSibling(row, "roleID", (v) => names.recordName("role", v));
|
|
1404
|
+
chunkXKIRTR37_cjs.addNameSibling(row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1405
|
+
chunkXKIRTR37_cjs.addNameSibling(row, "contractID", (v) => names.recordName("contract", v));
|
|
1406
1406
|
return row;
|
|
1407
1407
|
});
|
|
1408
1408
|
result.names = names.section;
|
|
@@ -1419,7 +1419,7 @@ async function fullContext(resource, id, opts = {}) {
|
|
|
1419
1419
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
1420
1420
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
1421
1421
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
1422
|
-
const ticketId =
|
|
1422
|
+
const ticketId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1423
1423
|
const ctx = await resource.getContext(ticketId);
|
|
1424
1424
|
const op = "tickets.fullContext";
|
|
1425
1425
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -1481,7 +1481,7 @@ var OP5 = "tickets.lineOfBusiness";
|
|
|
1481
1481
|
function positiveId2(value, name) {
|
|
1482
1482
|
const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
|
|
1483
1483
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
1484
|
-
throw new
|
|
1484
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(OP5 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP5 });
|
|
1485
1485
|
}
|
|
1486
1486
|
return n;
|
|
1487
1487
|
}
|
|
@@ -1497,25 +1497,25 @@ async function lineOfBusiness(resource, ticketIdIn, associationIdIn) {
|
|
|
1497
1497
|
associationSource = "argument";
|
|
1498
1498
|
} else {
|
|
1499
1499
|
const ticket = await resource.get(ticketId);
|
|
1500
|
-
associationId =
|
|
1500
|
+
associationId = chunkXKIRTR37_cjs.vendorId(ticket.organizationalLevelAssociationID);
|
|
1501
1501
|
if (associationId !== void 0) {
|
|
1502
1502
|
associationSource = "ticket";
|
|
1503
1503
|
} else {
|
|
1504
|
-
const contractRef =
|
|
1504
|
+
const contractRef = chunkXKIRTR37_cjs.vendorId(ticket.contractID);
|
|
1505
1505
|
if (contractRef !== void 0) {
|
|
1506
1506
|
const client = http.client;
|
|
1507
1507
|
if (client === void 0) {
|
|
1508
|
-
throw new
|
|
1508
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(OP5 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP5 });
|
|
1509
1509
|
}
|
|
1510
1510
|
try {
|
|
1511
1511
|
const contract = await client.contracts.get(contractRef);
|
|
1512
1512
|
contractId = contractRef;
|
|
1513
|
-
associationId =
|
|
1513
|
+
associationId = chunkXKIRTR37_cjs.vendorId(contract.organizationalLevelAssociationID);
|
|
1514
1514
|
if (associationId !== void 0) associationSource = "contract";
|
|
1515
1515
|
} catch (e) {
|
|
1516
|
-
if (e instanceof
|
|
1516
|
+
if (e instanceof chunkXKIRTR37_cjs.NotFoundError) {
|
|
1517
1517
|
contractId = contractRef;
|
|
1518
|
-
} else if (
|
|
1518
|
+
} else if (chunkXKIRTR37_cjs.isAutotaskError(e) && e.code !== "ABORTED") {
|
|
1519
1519
|
contractId = contractRef;
|
|
1520
1520
|
contractUnread = true;
|
|
1521
1521
|
} else {
|
|
@@ -1536,7 +1536,7 @@ async function lineOfBusiness(resource, ticketIdIn, associationIdIn) {
|
|
|
1536
1536
|
markers: { association: contractUnread ? "unresolved" : "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
1537
1537
|
};
|
|
1538
1538
|
}
|
|
1539
|
-
const chain = await
|
|
1539
|
+
const chain = await chunkXKIRTR37_cjs.resolveLineOfBusinessChain(http, associationId, { budget: 3, operation: OP5, onError: "propagate" });
|
|
1540
1540
|
const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
|
|
1541
1541
|
return { ticketId, associationSource, contractId, association, organizationalLevel2, organizationalLevel1, markers };
|
|
1542
1542
|
}
|
|
@@ -1546,7 +1546,7 @@ var MS = 864e5;
|
|
|
1546
1546
|
var SLA_PAGE = 100;
|
|
1547
1547
|
async function slaHealthCheck(_resource, id, opts = {}) {
|
|
1548
1548
|
const http = _resource.http;
|
|
1549
|
-
const ticketId =
|
|
1549
|
+
const ticketId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1550
1550
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
1551
1551
|
const rows = await ticketQueryItems(
|
|
1552
1552
|
http,
|
|
@@ -1572,9 +1572,9 @@ async function summary(_resource, id, opts = {}) {
|
|
|
1572
1572
|
const http = _resource.http;
|
|
1573
1573
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
1574
1574
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
1575
|
-
throw new
|
|
1575
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
1576
1576
|
}
|
|
1577
|
-
const ticketId =
|
|
1577
|
+
const ticketId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1578
1578
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
1579
1579
|
const desc = truncate(ticket.description, limit);
|
|
1580
1580
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
@@ -1603,17 +1603,17 @@ async function summary(_resource, id, opts = {}) {
|
|
|
1603
1603
|
// src/resources/special/tickets/statusSemantics.ts
|
|
1604
1604
|
async function statusSemantics(_resource, opts = {}) {
|
|
1605
1605
|
const http = _resource.http;
|
|
1606
|
-
return
|
|
1606
|
+
return chunkXKIRTR37_cjs.resolveTicketStatusSemantics(http, opts);
|
|
1607
1607
|
}
|
|
1608
1608
|
|
|
1609
1609
|
// src/resources/special/tickets/timeline.ts
|
|
1610
1610
|
function validateTimelineLimits(opts) {
|
|
1611
1611
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
1612
|
-
if (!Number.isInteger(limit) || limit < 1) throw new
|
|
1612
|
+
if (!Number.isInteger(limit) || limit < 1) throw new chunkXKIRTR37_cjs.AutotaskConfigError(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1613
1613
|
const bounded = Math.min(limit, 500);
|
|
1614
1614
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
1615
1615
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
1616
|
-
throw new
|
|
1616
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
1617
1617
|
}
|
|
1618
1618
|
return { bounded, textLimit };
|
|
1619
1619
|
}
|
|
@@ -1666,7 +1666,7 @@ function compareEventDates(a, b) {
|
|
|
1666
1666
|
async function timeline(_resource, id, opts = {}) {
|
|
1667
1667
|
const http = _resource.http;
|
|
1668
1668
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
1669
|
-
const ticketId =
|
|
1669
|
+
const ticketId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1670
1670
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
1671
1671
|
const dateFilters = (field) => {
|
|
1672
1672
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -1706,7 +1706,7 @@ async function timeline(_resource, id, opts = {}) {
|
|
|
1706
1706
|
}
|
|
1707
1707
|
|
|
1708
1708
|
// src/resources/tickets.ts
|
|
1709
|
-
var TicketsResource = class extends
|
|
1709
|
+
var TicketsResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
1710
1710
|
constructor(http, pageSize) {
|
|
1711
1711
|
super(http, {
|
|
1712
1712
|
key: "tickets",
|
|
@@ -1775,9 +1775,9 @@ var TicketsResource = class extends chunkV2GE763R_cjs.GenericResource {
|
|
|
1775
1775
|
// src/resources/special/time_off_requests.ts
|
|
1776
1776
|
async function approve(_resource, id, opts = {}) {
|
|
1777
1777
|
const http = _resource.http;
|
|
1778
|
-
const numericId =
|
|
1778
|
+
const numericId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1779
1779
|
if (opts.dryRun === true) {
|
|
1780
|
-
return
|
|
1780
|
+
return chunkXKIRTR37_cjs.buildDryRunResult({
|
|
1781
1781
|
operation: "time_off_requests.approve",
|
|
1782
1782
|
method: "GET",
|
|
1783
1783
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -1793,17 +1793,17 @@ async function approve(_resource, id, opts = {}) {
|
|
|
1793
1793
|
operation: "time_off_requests.approve",
|
|
1794
1794
|
maxRetries: opts.maxRetries
|
|
1795
1795
|
});
|
|
1796
|
-
return
|
|
1796
|
+
return chunkXKIRTR37_cjs.unwrapOperation(res);
|
|
1797
1797
|
}
|
|
1798
1798
|
async function reject(_resource, id, reason, opts = {}) {
|
|
1799
1799
|
const http = _resource.http;
|
|
1800
|
-
const numericId =
|
|
1800
|
+
const numericId = chunkXKIRTR37_cjs.parseIdentifier(id, "id");
|
|
1801
1801
|
const text = reason.trim();
|
|
1802
1802
|
if (text === "") {
|
|
1803
|
-
throw new
|
|
1803
|
+
throw new chunkXKIRTR37_cjs.AutotaskConfigError("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
1804
1804
|
}
|
|
1805
1805
|
if (opts.dryRun === true) {
|
|
1806
|
-
return
|
|
1806
|
+
return chunkXKIRTR37_cjs.buildDryRunResult({
|
|
1807
1807
|
operation: "time_off_requests.reject",
|
|
1808
1808
|
method: "POST",
|
|
1809
1809
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -1821,11 +1821,11 @@ async function reject(_resource, id, reason, opts = {}) {
|
|
|
1821
1821
|
operation: "time_off_requests.reject",
|
|
1822
1822
|
maxRetries: opts.maxRetries
|
|
1823
1823
|
});
|
|
1824
|
-
return
|
|
1824
|
+
return chunkXKIRTR37_cjs.unwrapOperation(res);
|
|
1825
1825
|
}
|
|
1826
1826
|
|
|
1827
1827
|
// src/resources/time_off_requests.ts
|
|
1828
|
-
var TimeOffRequestsResource = class extends
|
|
1828
|
+
var TimeOffRequestsResource = class extends chunkXKIRTR37_cjs.GenericResource {
|
|
1829
1829
|
constructor(http, pageSize) {
|
|
1830
1830
|
super(http, {
|
|
1831
1831
|
key: "time_off_requests",
|