node-autotask 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/MCP_TOOL_CATALOG.json +29 -8
- package/MCP_TOOL_MANIFEST.md +15 -14
- package/N8N_MCP_MANIFEST.json +48 -9
- package/N8N_MCP_MANIFEST.md +8 -7
- package/README.md +2 -2
- package/capabilities.json +1901 -1715
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.d.cts +4 -1
- package/dist/capabilities.d.ts +4 -1
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-D5TVBI4U.cjs → chunk-2H7YI54B.cjs} +28 -3
- package/dist/{chunk-PVUUOM5G.js → chunk-6PIJ6AZG.js} +167 -57
- package/dist/{chunk-OGNUI3UR.js → chunk-EFR2XWRX.js} +1900 -1714
- package/dist/{chunk-TTQB537V.cjs → chunk-FKJ77K6Z.cjs} +135 -135
- package/dist/{chunk-B5SNZ3TZ.js → chunk-VUGZKP33.js} +27 -2
- package/dist/{chunk-JUO3URUI.cjs → chunk-WBMRACCV.cjs} +1900 -1714
- package/dist/{chunk-VYFO2N5F.js → chunk-XUB3S6AM.js} +2 -2
- package/dist/{chunk-N27NUB4R.cjs → chunk-Z5L7Q33V.cjs} +627 -517
- package/dist/{index-NC-x-bYl.d.cts → index-C0OwQhon.d.cts} +55 -4
- package/dist/{index-DBoX-Dnk.d.ts → index-CZ94y401.d.ts} +55 -4
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +147 -108
- package/dist/operations/index.d.cts +17 -7
- package/dist/operations/index.d.ts +17 -7
- package/dist/operations/index.js +42 -3
- package/dist/pool.cjs +8 -8
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +3 -3
- package/docs/API.md +49 -11
- package/package.json +1 -1
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
var
|
|
41
|
+
var _chunk2H7YI54Bcjs = require('./chunk-2H7YI54B.cjs');
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var _chunkWBMRACCVcjs = require('./chunk-WBMRACCV.cjs');
|
|
45
45
|
|
|
46
46
|
// src/resources/appointments.ts
|
|
47
|
-
var AppointmentsResource = class extends
|
|
47
|
+
var AppointmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
48
48
|
constructor(http, pageSize) {
|
|
49
49
|
super(http, {
|
|
50
50
|
key: "appointments",
|
|
@@ -129,7 +129,7 @@ var AuthenticateResource = class {
|
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
// src/resources/billing_codes.ts
|
|
132
|
-
var BillingCodesResource = class extends
|
|
132
|
+
var BillingCodesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
133
133
|
constructor(http, pageSize) {
|
|
134
134
|
super(http, {
|
|
135
135
|
key: "billing_codes",
|
|
@@ -168,7 +168,7 @@ var BillingCodesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
168
168
|
/** Search BillingCode records: bounded contains on name (no vendor free-text search exists);
|
|
169
169
|
* limit defaults to 25, max 500. */
|
|
170
170
|
async search(query, opts) {
|
|
171
|
-
return this.searchBase(query, opts);
|
|
171
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _ => _.limit]) });
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
@@ -179,7 +179,7 @@ var MAX_LIMIT = 500;
|
|
|
179
179
|
function clampWindowLimit(limit) {
|
|
180
180
|
const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
|
|
181
181
|
if (!Number.isInteger(n) || n < 1) {
|
|
182
|
-
throw new (0,
|
|
182
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
183
183
|
}
|
|
184
184
|
return Math.min(n, MAX_LIMIT);
|
|
185
185
|
}
|
|
@@ -225,7 +225,7 @@ function wallParts(tz, ms) {
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
|
|
228
|
-
throw new (0,
|
|
228
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
|
|
229
229
|
}
|
|
230
230
|
return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
|
|
231
231
|
}
|
|
@@ -252,7 +252,7 @@ function localDayEndMs(y, m, d, tz) {
|
|
|
252
252
|
}
|
|
253
253
|
function validateZone(tz, opName = "dateWindow") {
|
|
254
254
|
if (typeof tz !== "string" || tz.length === 0) {
|
|
255
|
-
throw new (0,
|
|
255
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
256
256
|
`${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
257
257
|
{ operation: opName }
|
|
258
258
|
);
|
|
@@ -260,7 +260,7 @@ function validateZone(tz, opName = "dateWindow") {
|
|
|
260
260
|
try {
|
|
261
261
|
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
262
262
|
} catch (e2) {
|
|
263
|
-
throw new (0,
|
|
263
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
264
264
|
`${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
265
265
|
{ operation: opName }
|
|
266
266
|
);
|
|
@@ -398,6 +398,14 @@ function dateWindowBounds(kind, now, tz) {
|
|
|
398
398
|
}
|
|
399
399
|
return { from: iso(from), to: iso(to) };
|
|
400
400
|
}
|
|
401
|
+
function dateOnlyWindowBounds(kind, now, tz) {
|
|
402
|
+
if (tz === void 0 || kind === "last24h") return dateWindowBounds(kind, now, tz);
|
|
403
|
+
const zone = validateZone(tz);
|
|
404
|
+
const { from, to } = dateWindowBounds(kind, now, zone);
|
|
405
|
+
const f = wallParts(zone, Date.parse(from));
|
|
406
|
+
const t = wallParts(zone, Date.parse(to));
|
|
407
|
+
return { from: iso(Date.UTC(f.y, f.m - 1, f.d)), to: iso(Date.UTC(t.y, t.m - 1, t.d) + DAY_MS - 1) };
|
|
408
|
+
}
|
|
401
409
|
async function dateWindowQuery(http, path, field, kind, limit, operation, now, tz) {
|
|
402
410
|
const zone = tz === void 0 ? void 0 : validateZone(tz, operation);
|
|
403
411
|
const { from, to } = dateWindowBounds(kind, now, zone);
|
|
@@ -412,13 +420,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
|
|
|
412
420
|
body: { MaxRecords: limit, filter },
|
|
413
421
|
operation
|
|
414
422
|
});
|
|
415
|
-
return
|
|
423
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
416
424
|
}
|
|
417
425
|
var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
|
|
418
426
|
function customRangeDay(value, label, zone, opName) {
|
|
419
427
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
420
428
|
if (!m) {
|
|
421
|
-
throw new (0,
|
|
429
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
422
430
|
zone === void 0 ? `${opName}: ${label} must be a UTC 'YYYY-MM-DD' date (got ${JSON.stringify(value)})` : `${opName}: ${label} must be a 'YYYY-MM-DD' local calendar day in ${zone} (got ${JSON.stringify(value)})`,
|
|
423
431
|
{ operation: opName }
|
|
424
432
|
);
|
|
@@ -430,7 +438,7 @@ function customRangeDay(value, label, zone, opName) {
|
|
|
430
438
|
const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
|
|
431
439
|
const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
|
|
432
440
|
if (!Number.isFinite(ms)) {
|
|
433
|
-
throw new (0,
|
|
441
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
434
442
|
zone === void 0 ? `${opName}: ${label} is not a valid UTC date (${JSON.stringify(value)})` : `${opName}: ${label} is not a valid calendar day in ${zone} (${JSON.stringify(value)})`,
|
|
435
443
|
{ operation: opName }
|
|
436
444
|
);
|
|
@@ -441,7 +449,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
441
449
|
const fromB = customRangeDay(from, "from", zone, operation);
|
|
442
450
|
const toB = customRangeDay(to, "to", zone, operation);
|
|
443
451
|
if (fromB.ms > toB.ms) {
|
|
444
|
-
throw new (0,
|
|
452
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
445
453
|
`${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
|
|
446
454
|
{ operation }
|
|
447
455
|
);
|
|
@@ -458,40 +466,40 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
458
466
|
body: { MaxRecords: limit, filter },
|
|
459
467
|
operation
|
|
460
468
|
});
|
|
461
|
-
return
|
|
469
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
462
470
|
}
|
|
463
471
|
|
|
464
472
|
// src/resources/special/billing_items.ts
|
|
465
473
|
async function windowQuery(_resource, kind, http, opts) {
|
|
466
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
467
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
474
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _2 => _2.now]), () => ( /* @__PURE__ */ new Date()));
|
|
475
|
+
const tz = _optionalChain([opts, 'optionalAccess', _3 => _3.tz]) === void 0 ? void 0 : validateZone(opts.tz, `billing_items.${kind}`);
|
|
468
476
|
return dateWindowQuery(
|
|
469
477
|
http,
|
|
470
478
|
"/V1.0/BillingItems/query",
|
|
471
479
|
"itemDate",
|
|
472
480
|
kind,
|
|
473
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
481
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _4 => _4.limit])),
|
|
474
482
|
`billing_items.${kind}`,
|
|
475
483
|
now,
|
|
476
484
|
tz
|
|
477
485
|
);
|
|
478
486
|
}
|
|
479
487
|
async function customRange(_resource, from, to, http, opts) {
|
|
480
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
488
|
+
const zone = _optionalChain([opts, 'optionalAccess', _5 => _5.tz]) === void 0 ? void 0 : validateZone(opts.tz, "billing_items.customRange");
|
|
481
489
|
return customRangeQuery(
|
|
482
490
|
http,
|
|
483
491
|
"/V1.0/BillingItems/query",
|
|
484
492
|
"itemDate",
|
|
485
493
|
from,
|
|
486
494
|
to,
|
|
487
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
495
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _6 => _6.limit])),
|
|
488
496
|
"billing_items.customRange",
|
|
489
497
|
zone
|
|
490
498
|
);
|
|
491
499
|
}
|
|
492
500
|
|
|
493
501
|
// src/resources/billing_items.ts
|
|
494
|
-
var BillingItemsResource = class extends
|
|
502
|
+
var BillingItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
495
503
|
constructor(http, pageSize) {
|
|
496
504
|
super(http, {
|
|
497
505
|
key: "billing_items",
|
|
@@ -593,7 +601,7 @@ var BillingItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
593
601
|
};
|
|
594
602
|
|
|
595
603
|
// src/resources/change_request_links.ts
|
|
596
|
-
var ChangeRequestLinksResource = class extends
|
|
604
|
+
var ChangeRequestLinksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
597
605
|
constructor(http, pageSize) {
|
|
598
606
|
super(http, {
|
|
599
607
|
key: "change_request_links",
|
|
@@ -647,7 +655,7 @@ var ChangeRequestLinksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
647
655
|
};
|
|
648
656
|
|
|
649
657
|
// src/resources/checklist_libraries.ts
|
|
650
|
-
var ChecklistLibrariesResource = class extends
|
|
658
|
+
var ChecklistLibrariesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
651
659
|
constructor(http, pageSize) {
|
|
652
660
|
super(http, {
|
|
653
661
|
key: "checklist_libraries",
|
|
@@ -716,12 +724,12 @@ var ChecklistLibrariesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
716
724
|
/** Search ChecklistLibrary records: bounded contains on name (no vendor free-text search exists);
|
|
717
725
|
* limit defaults to 25, max 500. */
|
|
718
726
|
async search(query, opts) {
|
|
719
|
-
return this.searchBase(query, opts);
|
|
727
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _7 => _7.limit]) });
|
|
720
728
|
}
|
|
721
729
|
};
|
|
722
730
|
|
|
723
731
|
// src/resources/checklist_library_checklist_items.ts
|
|
724
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
732
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
725
733
|
constructor(http, pageSize) {
|
|
726
734
|
super(http, {
|
|
727
735
|
key: "checklist_library_checklist_items",
|
|
@@ -787,7 +795,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkD5TVBI4Ucjs.Bas
|
|
|
787
795
|
};
|
|
788
796
|
|
|
789
797
|
// src/resources/classification_icons.ts
|
|
790
|
-
var ClassificationIconsResource = class extends
|
|
798
|
+
var ClassificationIconsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
791
799
|
constructor(http, pageSize) {
|
|
792
800
|
super(http, {
|
|
793
801
|
key: "classification_icons",
|
|
@@ -826,7 +834,7 @@ var ClassificationIconsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
826
834
|
/** Search ClassificationIcon records: bounded contains on name (no vendor free-text search exists);
|
|
827
835
|
* limit defaults to 25, max 500. */
|
|
828
836
|
async search(query, opts) {
|
|
829
|
-
return this.searchBase(query, opts);
|
|
837
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _8 => _8.limit]) });
|
|
830
838
|
}
|
|
831
839
|
};
|
|
832
840
|
|
|
@@ -894,7 +902,7 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
|
|
|
894
902
|
body,
|
|
895
903
|
operation
|
|
896
904
|
});
|
|
897
|
-
const { items, pageDetails } =
|
|
905
|
+
const { items, pageDetails } = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, operation);
|
|
898
906
|
const capped = items.length >= limit;
|
|
899
907
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
900
908
|
}
|
|
@@ -904,7 +912,7 @@ var DEFAULT_LIMIT2 = 25;
|
|
|
904
912
|
var MAX_LIMIT2 = 500;
|
|
905
913
|
function clampLimit(limit) {
|
|
906
914
|
const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
|
|
907
|
-
if (!Number.isInteger(n) || n < 1) throw new (0,
|
|
915
|
+
if (!Number.isInteger(n) || n < 1) throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
908
916
|
return Math.min(n, MAX_LIMIT2);
|
|
909
917
|
}
|
|
910
918
|
|
|
@@ -917,7 +925,7 @@ async function queryCompanies(http, filter, limit) {
|
|
|
917
925
|
body: { MaxRecords: limit, filter },
|
|
918
926
|
operation: "companies.searchByDomain"
|
|
919
927
|
});
|
|
920
|
-
return
|
|
928
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
921
929
|
}
|
|
922
930
|
async function queryContacts(http, filter, limit) {
|
|
923
931
|
const res = await http.request({
|
|
@@ -927,7 +935,7 @@ async function queryContacts(http, filter, limit) {
|
|
|
927
935
|
body: { MaxRecords: limit, filter },
|
|
928
936
|
operation: "companies.searchByDomain"
|
|
929
937
|
});
|
|
930
|
-
return
|
|
938
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
931
939
|
}
|
|
932
940
|
async function fetchCompanies(http, ids2, limit) {
|
|
933
941
|
const out = [];
|
|
@@ -942,7 +950,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
942
950
|
const item = body && "item" in body ? body.item : null;
|
|
943
951
|
if (item) out.push(item);
|
|
944
952
|
} catch (err) {
|
|
945
|
-
if (err instanceof
|
|
953
|
+
if (err instanceof _chunk2H7YI54Bcjs.NotFoundError) continue;
|
|
946
954
|
throw err;
|
|
947
955
|
}
|
|
948
956
|
}
|
|
@@ -950,7 +958,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
950
958
|
}
|
|
951
959
|
async function searchByDomain(_resource, domain, opts = {}, http) {
|
|
952
960
|
const text = domain.trim();
|
|
953
|
-
if (text === "") throw new (0,
|
|
961
|
+
if (text === "") throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("searchByDomain: empty domain");
|
|
954
962
|
const limit = clampLimit(opts.limit);
|
|
955
963
|
const filter = [{ field: "webAddress", op: "contains", value: text }];
|
|
956
964
|
const direct = await queryCompanies(http, filter, limit);
|
|
@@ -960,11 +968,11 @@ async function searchByDomain(_resource, domain, opts = {}, http) {
|
|
|
960
968
|
return fetchCompanies(http, ids2, limit);
|
|
961
969
|
}
|
|
962
970
|
async function searchByIdentity(_resource, identity, opts = {}, http) {
|
|
963
|
-
const name = _nullishCoalesce(_optionalChain([identity, 'access',
|
|
964
|
-
const email = _nullishCoalesce(_optionalChain([identity, 'access',
|
|
965
|
-
const website = _nullishCoalesce(_optionalChain([identity, 'access',
|
|
971
|
+
const name = _nullishCoalesce(_optionalChain([identity, 'access', _9 => _9.companyName, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]), () => ( ""));
|
|
972
|
+
const email = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.email, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
|
|
973
|
+
const website = _nullishCoalesce(_optionalChain([identity, 'access', _15 => _15.website, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]), () => ( ""));
|
|
966
974
|
if (name === "" && email === "" && website === "") {
|
|
967
|
-
throw new (0,
|
|
975
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
|
|
968
976
|
}
|
|
969
977
|
const limit = clampLimit(opts.limit);
|
|
970
978
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -993,23 +1001,23 @@ async function familyChildPage(http, parentID) {
|
|
|
993
1001
|
path: "/V1.0/Companies/query",
|
|
994
1002
|
body: {
|
|
995
1003
|
MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
|
|
996
|
-
filter:
|
|
1004
|
+
filter: _chunk2H7YI54Bcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
|
|
997
1005
|
},
|
|
998
1006
|
operation: "companies.search"
|
|
999
1007
|
});
|
|
1000
|
-
const { items, pageDetails } =
|
|
1008
|
+
const { items, pageDetails } = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, "companies.search");
|
|
1001
1009
|
return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
|
|
1002
1010
|
}
|
|
1003
1011
|
function assertSearchWithDetailOpts(opts) {
|
|
1004
1012
|
if (opts === void 0) return;
|
|
1005
1013
|
if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
|
|
1006
|
-
throw new (0,
|
|
1014
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
|
|
1007
1015
|
operation: "companies.searchWithDetail"
|
|
1008
1016
|
});
|
|
1009
1017
|
}
|
|
1010
1018
|
for (const key of Object.keys(opts)) {
|
|
1011
1019
|
if (key !== "limit") {
|
|
1012
|
-
throw new (0,
|
|
1020
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
1013
1021
|
`companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
|
|
1014
1022
|
{ operation: "companies.searchWithDetail" }
|
|
1015
1023
|
);
|
|
@@ -1018,32 +1026,32 @@ function assertSearchWithDetailOpts(opts) {
|
|
|
1018
1026
|
}
|
|
1019
1027
|
async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
1020
1028
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1021
|
-
throw new (0,
|
|
1029
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
|
|
1022
1030
|
}
|
|
1023
1031
|
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
1024
1032
|
if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
|
|
1025
|
-
throw new (0,
|
|
1033
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
1026
1034
|
`companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
|
|
1027
1035
|
{ operation: "companies.search" }
|
|
1028
1036
|
);
|
|
1029
1037
|
}
|
|
1030
1038
|
}
|
|
1031
1039
|
if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
|
|
1032
|
-
throw new (0,
|
|
1040
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
|
|
1033
1041
|
operation: "companies.search"
|
|
1034
1042
|
});
|
|
1035
1043
|
}
|
|
1036
1044
|
const text = query.trim();
|
|
1037
|
-
if (text === "") throw new (0,
|
|
1038
|
-
const limit = opts.limit === void 0 ? 25 :
|
|
1045
|
+
if (text === "") throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
1046
|
+
const limit = opts.limit === void 0 ? 25 : _chunk2H7YI54Bcjs.clampPageSize.call(void 0, opts.limit);
|
|
1039
1047
|
const res = await http.request({
|
|
1040
1048
|
method: "POST",
|
|
1041
1049
|
idempotent: true,
|
|
1042
1050
|
path: "/V1.0/Companies/query",
|
|
1043
|
-
body: { MaxRecords: limit, filter:
|
|
1051
|
+
body: { MaxRecords: limit, filter: _chunk2H7YI54Bcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
1044
1052
|
operation: "companies.search"
|
|
1045
1053
|
});
|
|
1046
|
-
const hits =
|
|
1054
|
+
const hits = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, "companies.search").items;
|
|
1047
1055
|
if (opts.includeFamily !== true) return hits;
|
|
1048
1056
|
const rows = [];
|
|
1049
1057
|
for (const hit of hits) {
|
|
@@ -1063,7 +1071,7 @@ async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
|
1063
1071
|
}
|
|
1064
1072
|
|
|
1065
1073
|
// src/resources/special/companies/errors.ts
|
|
1066
|
-
var OwnerResourceRequiredError = class extends
|
|
1074
|
+
var OwnerResourceRequiredError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
1067
1075
|
constructor(message, options = {}) {
|
|
1068
1076
|
super(message, {
|
|
1069
1077
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1074,13 +1082,13 @@ var OwnerResourceRequiredError = class extends _chunkD5TVBI4Ucjs.AutotaskError {
|
|
|
1074
1082
|
this.name = "OwnerResourceRequiredError";
|
|
1075
1083
|
}
|
|
1076
1084
|
};
|
|
1077
|
-
var CompanyResourceInvalidError = class extends
|
|
1085
|
+
var CompanyResourceInvalidError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
1078
1086
|
constructor(message, options = {}) {
|
|
1079
1087
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
1080
1088
|
this.name = "CompanyResourceInvalidError";
|
|
1081
1089
|
}
|
|
1082
1090
|
};
|
|
1083
|
-
var CompanyCreateFailedError = class extends
|
|
1091
|
+
var CompanyCreateFailedError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
1084
1092
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
1085
1093
|
|
|
1086
1094
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -1099,23 +1107,23 @@ var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumer
|
|
|
1099
1107
|
var SAFE_COMPANY_CREATE_DEFAULTS = {};
|
|
1100
1108
|
function validateUpsertInput(companyName, params) {
|
|
1101
1109
|
if (typeof companyName !== "string" || companyName.trim() === "") {
|
|
1102
|
-
throw new (0,
|
|
1110
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
|
|
1103
1111
|
}
|
|
1104
|
-
if (typeof _optionalChain([params, 'optionalAccess',
|
|
1105
|
-
throw new (0,
|
|
1112
|
+
if (typeof _optionalChain([params, 'optionalAccess', _18 => _18.phone]) !== "string" || params.phone.trim() === "") {
|
|
1113
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("upsertByName: params.phone is required (a non-empty string \u2014 the ww29 live-required set is { companyName, companyType, phone, ownerResourceID })", { operation: OP_UPSERT_NAME });
|
|
1106
1114
|
}
|
|
1107
1115
|
const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
|
|
1108
1116
|
if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
|
|
1109
|
-
throw new (0,
|
|
1117
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`upsertByName: params.companyType must be a positive integer picklist value (got ${String(params.companyType)}; default 1 \u2014 the ww29-proven value)`, { operation: OP_UPSERT_NAME });
|
|
1110
1118
|
}
|
|
1111
1119
|
const owner = params.ownerResourceID;
|
|
1112
1120
|
if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
|
|
1113
|
-
throw new (0,
|
|
1121
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
|
|
1114
1122
|
}
|
|
1115
1123
|
return { companyType, owner };
|
|
1116
1124
|
}
|
|
1117
1125
|
function existsDryRun(http, companyName, match) {
|
|
1118
|
-
return
|
|
1126
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
1119
1127
|
{
|
|
1120
1128
|
operation: OP_UPSERT_NAME,
|
|
1121
1129
|
method: "POST",
|
|
@@ -1141,7 +1149,7 @@ function createDryRun(http, body, owner) {
|
|
|
1141
1149
|
"ownerResourceID is REQUIRED on the apply path (the vendor requires it; the node cannot enumerate candidates \u2014 the resources table is blind to this API user (count/query return 0)): the apply throws the typed OWNER_RESOURCE_REQUIRED if it is still absent"
|
|
1142
1150
|
);
|
|
1143
1151
|
}
|
|
1144
|
-
return
|
|
1152
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
1145
1153
|
{
|
|
1146
1154
|
operation: OP_UPSERT_NAME,
|
|
1147
1155
|
method: "POST",
|
|
@@ -1186,8 +1194,8 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1186
1194
|
sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
|
|
1187
1195
|
};
|
|
1188
1196
|
} catch (err) {
|
|
1189
|
-
if (!
|
|
1190
|
-
const named = (_nullishCoalesce(
|
|
1197
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1198
|
+
const named = (_nullishCoalesce(_chunk2H7YI54Bcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
1191
1199
|
const seen = /* @__PURE__ */ new Set();
|
|
1192
1200
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
1193
1201
|
const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -1201,7 +1209,7 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1201
1209
|
}
|
|
1202
1210
|
continue;
|
|
1203
1211
|
}
|
|
1204
|
-
const detail =
|
|
1212
|
+
const detail = _chunk2H7YI54Bcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
1205
1213
|
throw new CompanyCreateFailedError(
|
|
1206
1214
|
`upsertByName: the vendor rejected the company create${unique.length > 0 ? ` naming field(s) ${unique.join(", ")}` : ""} (no proven-safe default \u2014 the ww29 required set is fully filled by the node)${detail ? ` \u2014 ${detail}` : ""}`,
|
|
1207
1215
|
unique,
|
|
@@ -1262,30 +1270,30 @@ var LOCATION_LIMIT_MAX = 500;
|
|
|
1262
1270
|
function locationLimit(value) {
|
|
1263
1271
|
if (value === void 0) return PROFILE_PART_LIMIT;
|
|
1264
1272
|
if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
|
|
1265
|
-
throw new (0,
|
|
1273
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
|
|
1266
1274
|
}
|
|
1267
1275
|
return value;
|
|
1268
1276
|
}
|
|
1269
1277
|
function validateProjection(fields) {
|
|
1270
1278
|
if (fields === void 0) return {};
|
|
1271
1279
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
|
|
1272
|
-
throw new (0,
|
|
1280
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
|
|
1273
1281
|
}
|
|
1274
1282
|
const out = {};
|
|
1275
1283
|
for (const [part, list] of Object.entries(fields)) {
|
|
1276
1284
|
if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
|
|
1277
|
-
throw new (0,
|
|
1285
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
|
|
1278
1286
|
}
|
|
1279
1287
|
if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
|
|
1280
|
-
throw new (0,
|
|
1288
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
|
|
1281
1289
|
}
|
|
1282
1290
|
const names = [...new Set(list)];
|
|
1283
1291
|
const entity = PART_ENTITY[part];
|
|
1284
|
-
const known = _nullishCoalesce(
|
|
1292
|
+
const known = _nullishCoalesce(_chunk2H7YI54Bcjs.MODEL_FIELD_SETS[entity], () => ( []));
|
|
1285
1293
|
const unknown = names.filter((n) => !known.includes(n));
|
|
1286
1294
|
if (unknown.length > 0) {
|
|
1287
|
-
throw new (0,
|
|
1288
|
-
`fullProfile: fields.${part} has unknown field name(s) ${
|
|
1295
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
1296
|
+
`fullProfile: fields.${part} has unknown field name(s) ${_chunk2H7YI54Bcjs.formatUnknownNameList.call(void 0, unknown)} against the vendored spec for ${entity} (${known.length} fields; operations.fieldCatalog resources: ["${entity}"] lists the live set) \u2014 no request was issued`
|
|
1289
1297
|
);
|
|
1290
1298
|
}
|
|
1291
1299
|
out[part] = names;
|
|
@@ -1302,7 +1310,7 @@ function project(items, names) {
|
|
|
1302
1310
|
function profilePartLimit(value, name) {
|
|
1303
1311
|
const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
|
|
1304
1312
|
if (!Number.isInteger(n) || n < 1) {
|
|
1305
|
-
throw new (0,
|
|
1313
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1306
1314
|
}
|
|
1307
1315
|
return n;
|
|
1308
1316
|
}
|
|
@@ -1314,7 +1322,7 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
|
|
|
1314
1322
|
body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
|
|
1315
1323
|
operation: "companies.fullProfile"
|
|
1316
1324
|
});
|
|
1317
|
-
return project(
|
|
1325
|
+
return project(_chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1318
1326
|
}
|
|
1319
1327
|
async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
1320
1328
|
const openRows = await (async () => {
|
|
@@ -1329,7 +1337,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1329
1337
|
},
|
|
1330
1338
|
operation: "companies.fullProfile"
|
|
1331
1339
|
});
|
|
1332
|
-
return project(
|
|
1340
|
+
return project(_chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1333
1341
|
})();
|
|
1334
1342
|
let openTickets = {
|
|
1335
1343
|
items: openRows,
|
|
@@ -1338,7 +1346,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1338
1346
|
note: OPEN_TICKETS_NOTE
|
|
1339
1347
|
};
|
|
1340
1348
|
if (openRows.length === 0) {
|
|
1341
|
-
const stamp =
|
|
1349
|
+
const stamp = _chunk2H7YI54Bcjs.blindStampFor.call(void 0, _optionalChain([_chunk2H7YI54Bcjs.BLIND_SURFACE_STAMPS, 'access', _19 => _19["tickets"], 'optionalAccess', _20 => _20.query]), [
|
|
1342
1350
|
{ field: "companyID", op: "eq", value: companyID },
|
|
1343
1351
|
{ field: "status", op: "noteq", value: 5 }
|
|
1344
1352
|
]);
|
|
@@ -1355,7 +1363,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1355
1363
|
return openTickets;
|
|
1356
1364
|
}
|
|
1357
1365
|
async function addProfileNames(http, company, openTickets, projects, result, opts) {
|
|
1358
|
-
const builder =
|
|
1366
|
+
const builder = _chunk2H7YI54Bcjs.createNamePlan.call(void 0, _chunk2H7YI54Bcjs.TICKET_LABEL_FIELDS);
|
|
1359
1367
|
const c = company;
|
|
1360
1368
|
builder.addResource(c["ownerResourceID"]);
|
|
1361
1369
|
builder.addResource(c["createdByResourceID"]);
|
|
@@ -1372,20 +1380,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1372
1380
|
builder.addResource(r["creatorResourceID"]);
|
|
1373
1381
|
builder.addFk("contract", r["contractID"]);
|
|
1374
1382
|
}
|
|
1375
|
-
const names = await
|
|
1383
|
+
const names = await _chunk2H7YI54Bcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1376
1384
|
const companyRow = { ...company };
|
|
1377
|
-
|
|
1378
|
-
|
|
1385
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1386
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
|
|
1379
1387
|
result.company = companyRow;
|
|
1380
1388
|
result.openTickets = {
|
|
1381
1389
|
...openTickets,
|
|
1382
1390
|
items: openTickets.items.map((row) => {
|
|
1383
1391
|
const r = { ...row };
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
for (const f of
|
|
1392
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1393
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1394
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1395
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1396
|
+
for (const f of _chunk2H7YI54Bcjs.TICKET_LABEL_FIELDS) _chunk2H7YI54Bcjs.addLabelSibling.call(void 0, r, f, names);
|
|
1389
1397
|
return r;
|
|
1390
1398
|
})
|
|
1391
1399
|
};
|
|
@@ -1393,9 +1401,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1393
1401
|
...result.projects,
|
|
1394
1402
|
items: result.projects.items.map((row) => {
|
|
1395
1403
|
const r = { ...row };
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1404
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1405
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1406
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1399
1407
|
return r;
|
|
1400
1408
|
})
|
|
1401
1409
|
};
|
|
@@ -1408,7 +1416,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1408
1416
|
const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
|
|
1409
1417
|
const locLimit = locationLimit(opts.locationLimit);
|
|
1410
1418
|
const proj = validateProjection(opts.fields);
|
|
1411
|
-
const companyID =
|
|
1419
|
+
const companyID = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
1412
1420
|
const company = await resource.get(companyID);
|
|
1413
1421
|
const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
|
|
1414
1422
|
const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
|
|
@@ -1455,7 +1463,7 @@ var UNBILLED_WORK_OPT_KEYS = [
|
|
|
1455
1463
|
var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
|
|
1456
1464
|
function validateUnbilledWorkOptions(companyId, opts) {
|
|
1457
1465
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1458
|
-
throw new (0,
|
|
1466
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
1459
1467
|
`unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
1460
1468
|
{ operation: "companies.unbilledWork" }
|
|
1461
1469
|
);
|
|
@@ -1484,7 +1492,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1484
1492
|
try {
|
|
1485
1493
|
limit = clampLimit(opts.limit);
|
|
1486
1494
|
} catch (err) {
|
|
1487
|
-
problems.push(err instanceof
|
|
1495
|
+
problems.push(err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1488
1496
|
limit = 50;
|
|
1489
1497
|
}
|
|
1490
1498
|
if (source === "date_range") {
|
|
@@ -1499,9 +1507,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1499
1507
|
problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
|
|
1500
1508
|
} else {
|
|
1501
1509
|
try {
|
|
1502
|
-
|
|
1510
|
+
_chunk2H7YI54Bcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1503
1511
|
} catch (err) {
|
|
1504
|
-
problems.push(err instanceof
|
|
1512
|
+
problems.push(err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
|
|
1505
1513
|
}
|
|
1506
1514
|
}
|
|
1507
1515
|
}
|
|
@@ -1511,20 +1519,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1511
1519
|
} else {
|
|
1512
1520
|
opts.ticketIds.forEach((tid, i) => {
|
|
1513
1521
|
try {
|
|
1514
|
-
|
|
1522
|
+
_chunk2H7YI54Bcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1515
1523
|
} catch (err) {
|
|
1516
|
-
problems.push(err instanceof
|
|
1524
|
+
problems.push(err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1517
1525
|
}
|
|
1518
1526
|
});
|
|
1519
1527
|
}
|
|
1520
1528
|
}
|
|
1521
1529
|
try {
|
|
1522
|
-
|
|
1530
|
+
_chunk2H7YI54Bcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1523
1531
|
} catch (err) {
|
|
1524
|
-
problems.push(err instanceof
|
|
1532
|
+
problems.push(err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
|
|
1525
1533
|
}
|
|
1526
1534
|
if (problems.length > 0) {
|
|
1527
|
-
throw new (0,
|
|
1535
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
1528
1536
|
`unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
1529
1537
|
- ` + problems.join("\n- "),
|
|
1530
1538
|
{ operation: "companies.unbilledWork" }
|
|
@@ -1553,7 +1561,7 @@ function capJoinSet(ids2, cap) {
|
|
|
1553
1561
|
}
|
|
1554
1562
|
function unbilledWorkPartStatus(key, conditions, items) {
|
|
1555
1563
|
if (items.length !== 0) return { status: "ok" };
|
|
1556
|
-
const stamp =
|
|
1564
|
+
const stamp = _chunk2H7YI54Bcjs.blindStampFor.call(void 0, _optionalChain([_chunk2H7YI54Bcjs.BLIND_SURFACE_STAMPS, 'access', _21 => _21[key], 'optionalAccess', _22 => _22.query]), conditions);
|
|
1557
1565
|
if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
|
|
1558
1566
|
return {
|
|
1559
1567
|
status: "ok",
|
|
@@ -1573,7 +1581,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1573
1581
|
parentStatus = "ok";
|
|
1574
1582
|
companyIds.push(num(parent.id));
|
|
1575
1583
|
} catch (err) {
|
|
1576
|
-
if (err instanceof
|
|
1584
|
+
if (err instanceof _chunk2H7YI54Bcjs.NotFoundError) parent = null;
|
|
1577
1585
|
else throw err;
|
|
1578
1586
|
}
|
|
1579
1587
|
}
|
|
@@ -1611,14 +1619,14 @@ async function readBillingPart(http, v, companyIds) {
|
|
|
1611
1619
|
if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
|
|
1612
1620
|
if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
|
|
1613
1621
|
}
|
|
1614
|
-
const billingFields =
|
|
1622
|
+
const billingFields = _chunk2H7YI54Bcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
|
|
1615
1623
|
const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
|
|
1616
1624
|
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP, billingIncludeFields);
|
|
1617
1625
|
let billingItems = billingRaw.items;
|
|
1618
1626
|
let billingNoteCharsTruncated = 0;
|
|
1619
1627
|
if (v.includeNotes) {
|
|
1620
|
-
const noteFields = (_nullishCoalesce(
|
|
1621
|
-
[billingItems, billingNoteCharsTruncated] =
|
|
1628
|
+
const noteFields = (_nullishCoalesce(_chunk2H7YI54Bcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1629
|
+
[billingItems, billingNoteCharsTruncated] = _chunk2H7YI54Bcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
|
|
1622
1630
|
}
|
|
1623
1631
|
const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
|
|
1624
1632
|
const billingItemsPart = {
|
|
@@ -1662,7 +1670,7 @@ async function readTimePart(http, v, join) {
|
|
|
1662
1670
|
let cappedItems = entries;
|
|
1663
1671
|
let noteCharsTruncated = 0;
|
|
1664
1672
|
if (v.includeNotes) {
|
|
1665
|
-
[cappedItems, noteCharsTruncated] =
|
|
1673
|
+
[cappedItems, noteCharsTruncated] = _chunk2H7YI54Bcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
|
|
1666
1674
|
}
|
|
1667
1675
|
const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
|
|
1668
1676
|
timePart = {
|
|
@@ -1750,7 +1758,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
|
|
|
1750
1758
|
}
|
|
1751
1759
|
async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
1752
1760
|
const v = validateUnbilledWorkOptions(companyId, opts);
|
|
1753
|
-
const id =
|
|
1761
|
+
const id = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1754
1762
|
const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
|
|
1755
1763
|
const join = await readJoinSets(http, companyIds, v);
|
|
1756
1764
|
const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
|
|
@@ -1777,7 +1785,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1777
1785
|
}
|
|
1778
1786
|
|
|
1779
1787
|
// src/resources/companies.ts
|
|
1780
|
-
var CompaniesResource = class extends
|
|
1788
|
+
var CompaniesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
1781
1789
|
constructor(http, pageSize) {
|
|
1782
1790
|
super(http, {
|
|
1783
1791
|
key: "companies",
|
|
@@ -1884,7 +1892,7 @@ var CompaniesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
1884
1892
|
};
|
|
1885
1893
|
|
|
1886
1894
|
// src/resources/company_alerts.ts
|
|
1887
|
-
var CompanyAlertsResource = class extends
|
|
1895
|
+
var CompanyAlertsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
1888
1896
|
constructor(http, pageSize) {
|
|
1889
1897
|
super(http, {
|
|
1890
1898
|
key: "company_alerts",
|
|
@@ -1950,7 +1958,7 @@ var CompanyAlertsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
1950
1958
|
};
|
|
1951
1959
|
|
|
1952
1960
|
// src/resources/company_locations.ts
|
|
1953
|
-
var CompanyLocationsResource = class extends
|
|
1961
|
+
var CompanyLocationsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
1954
1962
|
constructor(http, pageSize) {
|
|
1955
1963
|
super(http, {
|
|
1956
1964
|
key: "company_locations",
|
|
@@ -2016,12 +2024,12 @@ var CompanyLocationsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
2016
2024
|
/** Search CompanyLocation records: bounded contains on name (no vendor free-text search exists);
|
|
2017
2025
|
* limit defaults to 25, max 500. */
|
|
2018
2026
|
async search(query, opts) {
|
|
2019
|
-
return this.searchBase(query, opts);
|
|
2027
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _23 => _23.limit]) });
|
|
2020
2028
|
}
|
|
2021
2029
|
};
|
|
2022
2030
|
|
|
2023
2031
|
// src/resources/company_notes.ts
|
|
2024
|
-
var CompanyNotesResource = class extends
|
|
2032
|
+
var CompanyNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2025
2033
|
constructor(http, pageSize) {
|
|
2026
2034
|
super(http, {
|
|
2027
2035
|
key: "company_notes",
|
|
@@ -2081,12 +2089,12 @@ var CompanyNotesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
2081
2089
|
/** Search CompanyNote records: bounded contains on name (no vendor free-text search exists);
|
|
2082
2090
|
* limit defaults to 25, max 500. */
|
|
2083
2091
|
async search(query, opts) {
|
|
2084
|
-
return this.searchBase(query, opts);
|
|
2092
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _24 => _24.limit]) });
|
|
2085
2093
|
}
|
|
2086
2094
|
};
|
|
2087
2095
|
|
|
2088
2096
|
// src/resources/company_site_configurations.ts
|
|
2089
|
-
var CompanySiteConfigurationsResource = class extends
|
|
2097
|
+
var CompanySiteConfigurationsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2090
2098
|
constructor(http, pageSize) {
|
|
2091
2099
|
super(http, {
|
|
2092
2100
|
key: "company_site_configurations",
|
|
@@ -2137,7 +2145,7 @@ var CompanySiteConfigurationsResource = class extends _chunkD5TVBI4Ucjs.BaseReso
|
|
|
2137
2145
|
};
|
|
2138
2146
|
|
|
2139
2147
|
// src/resources/company_webhooks.ts
|
|
2140
|
-
var CompanyWebhooksResource = class extends
|
|
2148
|
+
var CompanyWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2141
2149
|
constructor(http, pageSize) {
|
|
2142
2150
|
super(http, {
|
|
2143
2151
|
key: "company_webhooks",
|
|
@@ -2208,12 +2216,12 @@ var CompanyWebhooksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
2208
2216
|
/** Search CompanyWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
2209
2217
|
* limit defaults to 25, max 500. */
|
|
2210
2218
|
async search(query, opts) {
|
|
2211
|
-
return this.searchBase(query, opts);
|
|
2219
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _25 => _25.limit]) });
|
|
2212
2220
|
}
|
|
2213
2221
|
};
|
|
2214
2222
|
|
|
2215
2223
|
// src/resources/configuration_item_billing_product_associations.ts
|
|
2216
|
-
var ConfigurationItemBillingProductAssociationsResource = class extends
|
|
2224
|
+
var ConfigurationItemBillingProductAssociationsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2217
2225
|
constructor(http, pageSize) {
|
|
2218
2226
|
super(http, {
|
|
2219
2227
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2279,7 +2287,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkD5
|
|
|
2279
2287
|
};
|
|
2280
2288
|
|
|
2281
2289
|
// src/resources/configuration_item_categories.ts
|
|
2282
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2290
|
+
var ConfigurationItemCategoriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2283
2291
|
constructor(http, pageSize) {
|
|
2284
2292
|
super(http, {
|
|
2285
2293
|
key: "configuration_item_categories",
|
|
@@ -2341,12 +2349,12 @@ var ConfigurationItemCategoriesResource = class extends _chunkD5TVBI4Ucjs.BaseRe
|
|
|
2341
2349
|
/** Search ConfigurationItemCategory records: bounded contains on name (no vendor free-text search exists);
|
|
2342
2350
|
* limit defaults to 25, max 500. */
|
|
2343
2351
|
async search(query, opts) {
|
|
2344
|
-
return this.searchBase(query, opts);
|
|
2352
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _26 => _26.limit]) });
|
|
2345
2353
|
}
|
|
2346
2354
|
};
|
|
2347
2355
|
|
|
2348
2356
|
// src/resources/configuration_item_category_udf_associations.ts
|
|
2349
|
-
var ConfigurationItemCategoryUdfAssociationsResource = class extends
|
|
2357
|
+
var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2350
2358
|
constructor(http, pageSize) {
|
|
2351
2359
|
super(http, {
|
|
2352
2360
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2412,7 +2420,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkD5TVB
|
|
|
2412
2420
|
};
|
|
2413
2421
|
|
|
2414
2422
|
// src/resources/configuration_item_dns_records.ts
|
|
2415
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2423
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2416
2424
|
constructor(http, pageSize) {
|
|
2417
2425
|
super(http, {
|
|
2418
2426
|
key: "configuration_item_dns_records",
|
|
@@ -2461,7 +2469,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkD5TVBI4Ucjs.BaseRe
|
|
|
2461
2469
|
};
|
|
2462
2470
|
|
|
2463
2471
|
// src/resources/configuration_item_notes.ts
|
|
2464
|
-
var ConfigurationItemNotesResource = class extends
|
|
2472
|
+
var ConfigurationItemNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2465
2473
|
constructor(http, pageSize) {
|
|
2466
2474
|
super(http, {
|
|
2467
2475
|
key: "configuration_item_notes",
|
|
@@ -2520,7 +2528,7 @@ var ConfigurationItemNotesResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
2520
2528
|
};
|
|
2521
2529
|
|
|
2522
2530
|
// src/resources/configuration_item_related_items.ts
|
|
2523
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2531
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2524
2532
|
constructor(http, pageSize) {
|
|
2525
2533
|
super(http, {
|
|
2526
2534
|
key: "configuration_item_related_items",
|
|
@@ -2578,19 +2586,19 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkD5TVBI4Ucjs.Base
|
|
|
2578
2586
|
|
|
2579
2587
|
// src/resources/special/configuration_items.ts
|
|
2580
2588
|
async function fetchRecord(http, path, label, readOpts) {
|
|
2581
|
-
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
2589
|
+
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _27 => _27.maxRetries]) });
|
|
2582
2590
|
const body = res;
|
|
2583
2591
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
2584
|
-
throw new (0,
|
|
2592
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
2585
2593
|
}
|
|
2586
2594
|
return body.item;
|
|
2587
2595
|
}
|
|
2588
2596
|
async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
2589
|
-
const numericSource =
|
|
2590
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
2591
|
-
throw new (0,
|
|
2597
|
+
const numericSource = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2598
|
+
if (_optionalChain([opts, 'optionalAccess', _28 => _28.destinationCompanyId]) === void 0) {
|
|
2599
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2592
2600
|
}
|
|
2593
|
-
const destId =
|
|
2601
|
+
const destId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2594
2602
|
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
|
|
2595
2603
|
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
2596
2604
|
const body = { ...source };
|
|
@@ -2600,20 +2608,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2600
2608
|
body.companyID = destId;
|
|
2601
2609
|
body.isActive = true;
|
|
2602
2610
|
if (opts.newReferenceTitle !== void 0) {
|
|
2603
|
-
if (opts.newReferenceTitle.trim() === "") throw new (0,
|
|
2611
|
+
if (opts.newReferenceTitle.trim() === "") throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
|
|
2604
2612
|
body.referenceTitle = opts.newReferenceTitle.trim();
|
|
2605
2613
|
}
|
|
2606
2614
|
if (opts.lastModifiedDate !== void 0) {
|
|
2607
2615
|
const current = source.lastModifiedDate;
|
|
2608
2616
|
if (current !== opts.lastModifiedDate) {
|
|
2609
|
-
throw new (0,
|
|
2617
|
+
throw new (0, _chunk2H7YI54Bcjs.StaleObjectError)(
|
|
2610
2618
|
`moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
|
|
2611
2619
|
{ operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
|
|
2612
2620
|
);
|
|
2613
2621
|
}
|
|
2614
2622
|
}
|
|
2615
2623
|
if (opts.dryRun === true) {
|
|
2616
|
-
return
|
|
2624
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
2617
2625
|
operation: "configuration_items.moveConfigurationItem",
|
|
2618
2626
|
method: "POST",
|
|
2619
2627
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2638,7 +2646,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2638
2646
|
const createdBody = created;
|
|
2639
2647
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2640
2648
|
if (typeof newId !== "number") {
|
|
2641
|
-
throw new (0,
|
|
2649
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2642
2650
|
}
|
|
2643
2651
|
let sourceDeactivated = false;
|
|
2644
2652
|
if (opts.deactivateSource !== false) {
|
|
@@ -2657,7 +2665,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2657
2665
|
function profilePartLimit2(value, name) {
|
|
2658
2666
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2659
2667
|
if (!Number.isInteger(n) || n < 1) {
|
|
2660
|
-
throw new (0,
|
|
2668
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2661
2669
|
}
|
|
2662
2670
|
return n;
|
|
2663
2671
|
}
|
|
@@ -2673,14 +2681,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
|
|
|
2673
2681
|
});
|
|
2674
2682
|
const body = res;
|
|
2675
2683
|
if (body === null || !("item" in body)) {
|
|
2676
|
-
throw new (0,
|
|
2684
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2677
2685
|
}
|
|
2678
2686
|
if (body.item === null || body.item === void 0) {
|
|
2679
|
-
throw new (0,
|
|
2687
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2680
2688
|
}
|
|
2681
2689
|
return body.item;
|
|
2682
2690
|
} catch (err) {
|
|
2683
|
-
if (err instanceof
|
|
2691
|
+
if (err instanceof _chunk2H7YI54Bcjs.NotFoundError) return null;
|
|
2684
2692
|
throw err;
|
|
2685
2693
|
}
|
|
2686
2694
|
}
|
|
@@ -2692,7 +2700,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2692
2700
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2693
2701
|
operation: "configuration_items.profile"
|
|
2694
2702
|
});
|
|
2695
|
-
return
|
|
2703
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
2696
2704
|
}
|
|
2697
2705
|
async function profile(resource, id, opts = {}, http) {
|
|
2698
2706
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2704,7 +2712,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2704
2712
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2705
2713
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2706
2714
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2707
|
-
const wallQuirk = _optionalChain([
|
|
2715
|
+
const wallQuirk = _optionalChain([_chunk2H7YI54Bcjs.RELATIONSHIP_MAP, 'access', _29 => _29["configuration_items"], 'optionalAccess', _30 => _30.zoneFacts, 'optionalAccess', _31 => _31.quirks, 'optionalAccess', _32 => _32.find, 'call', _33 => _33((q) => q.startsWith("product wall"))]);
|
|
2708
2716
|
const productAssociations = {
|
|
2709
2717
|
items: associations,
|
|
2710
2718
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2728,11 +2736,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2728
2736
|
}
|
|
2729
2737
|
};
|
|
2730
2738
|
if (opts.names === true) {
|
|
2731
|
-
const builder =
|
|
2739
|
+
const builder = _chunk2H7YI54Bcjs.createNamePlan.call(void 0, );
|
|
2732
2740
|
builder.addFk("contract", root["contractID"]);
|
|
2733
|
-
const names = await
|
|
2741
|
+
const names = await _chunk2H7YI54Bcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2734
2742
|
const ciRow = { ...ci };
|
|
2735
|
-
|
|
2743
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2736
2744
|
result.ci = ciRow;
|
|
2737
2745
|
result.names = names.section;
|
|
2738
2746
|
}
|
|
@@ -2740,7 +2748,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2740
2748
|
}
|
|
2741
2749
|
|
|
2742
2750
|
// src/resources/configuration_items.ts
|
|
2743
|
-
var ConfigurationItemsResource = class extends
|
|
2751
|
+
var ConfigurationItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2744
2752
|
constructor(http, pageSize) {
|
|
2745
2753
|
super(http, {
|
|
2746
2754
|
key: "configuration_items",
|
|
@@ -2806,7 +2814,7 @@ var ConfigurationItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
2806
2814
|
/** Search ConfigurationItem records: bounded contains on referenceTitle (no vendor free-text search exists);
|
|
2807
2815
|
* limit defaults to 25, max 500. */
|
|
2808
2816
|
async search(query, opts) {
|
|
2809
|
-
return this.searchBase(query, opts);
|
|
2817
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _34 => _34.limit]) });
|
|
2810
2818
|
}
|
|
2811
2819
|
/** Get the ConfigurationItem with its primary context records in one call (each part a single-record
|
|
2812
2820
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
@@ -2829,7 +2837,7 @@ var ConfigurationItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
2829
2837
|
};
|
|
2830
2838
|
|
|
2831
2839
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2832
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
2840
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2833
2841
|
constructor(http, pageSize) {
|
|
2834
2842
|
super(http, {
|
|
2835
2843
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -2887,12 +2895,12 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkD5
|
|
|
2887
2895
|
/** Search ConfigurationItemSslSubjectAlternativeName records: bounded contains on name (no vendor free-text search exists);
|
|
2888
2896
|
* limit defaults to 25, max 500. */
|
|
2889
2897
|
async search(query, opts) {
|
|
2890
|
-
return this.searchBase(query, opts);
|
|
2898
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _35 => _35.limit]) });
|
|
2891
2899
|
}
|
|
2892
2900
|
};
|
|
2893
2901
|
|
|
2894
2902
|
// src/resources/configuration_item_types.ts
|
|
2895
|
-
var ConfigurationItemTypesResource = class extends
|
|
2903
|
+
var ConfigurationItemTypesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2896
2904
|
constructor(http, pageSize) {
|
|
2897
2905
|
super(http, {
|
|
2898
2906
|
key: "configuration_item_types",
|
|
@@ -2961,12 +2969,12 @@ var ConfigurationItemTypesResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
2961
2969
|
/** Search ConfigurationItemType records: bounded contains on name (no vendor free-text search exists);
|
|
2962
2970
|
* limit defaults to 25, max 500. */
|
|
2963
2971
|
async search(query, opts) {
|
|
2964
|
-
return this.searchBase(query, opts);
|
|
2972
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _36 => _36.limit]) });
|
|
2965
2973
|
}
|
|
2966
2974
|
};
|
|
2967
2975
|
|
|
2968
2976
|
// src/resources/configuration_item_webhooks.ts
|
|
2969
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
2977
|
+
var ConfigurationItemWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
2970
2978
|
constructor(http, pageSize) {
|
|
2971
2979
|
super(http, {
|
|
2972
2980
|
key: "configuration_item_webhooks",
|
|
@@ -3037,12 +3045,12 @@ var ConfigurationItemWebhooksResource = class extends _chunkD5TVBI4Ucjs.BaseReso
|
|
|
3037
3045
|
/** Search ConfigurationItemWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
3038
3046
|
* limit defaults to 25, max 500. */
|
|
3039
3047
|
async search(query, opts) {
|
|
3040
|
-
return this.searchBase(query, opts);
|
|
3048
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _37 => _37.limit]) });
|
|
3041
3049
|
}
|
|
3042
3050
|
};
|
|
3043
3051
|
|
|
3044
3052
|
// src/resources/contact_group_contacts.ts
|
|
3045
|
-
var ContactGroupContactsResource = class extends
|
|
3053
|
+
var ContactGroupContactsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3046
3054
|
constructor(http, pageSize) {
|
|
3047
3055
|
super(http, {
|
|
3048
3056
|
key: "contact_group_contacts",
|
|
@@ -3096,7 +3104,7 @@ var ContactGroupContactsResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
3096
3104
|
};
|
|
3097
3105
|
|
|
3098
3106
|
// src/resources/contact_groups.ts
|
|
3099
|
-
var ContactGroupsResource = class extends
|
|
3107
|
+
var ContactGroupsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3100
3108
|
constructor(http, pageSize) {
|
|
3101
3109
|
super(http, {
|
|
3102
3110
|
key: "contact_groups",
|
|
@@ -3165,31 +3173,31 @@ var ContactGroupsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
3165
3173
|
/** Search ContactGroups records: bounded contains on name (no vendor free-text search exists);
|
|
3166
3174
|
* limit defaults to 25, max 500. */
|
|
3167
3175
|
async search(query, opts) {
|
|
3168
|
-
return this.searchBase(query, opts);
|
|
3176
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _38 => _38.limit]) });
|
|
3169
3177
|
}
|
|
3170
3178
|
};
|
|
3171
3179
|
|
|
3172
3180
|
// src/resources/special/contacts.ts
|
|
3173
3181
|
async function fetchRecord2(http, path, label, readOpts) {
|
|
3174
|
-
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
3182
|
+
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _39 => _39.maxRetries]) });
|
|
3175
3183
|
const body = res;
|
|
3176
3184
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3177
|
-
throw new (0,
|
|
3185
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3178
3186
|
}
|
|
3179
3187
|
return body.item;
|
|
3180
3188
|
}
|
|
3181
3189
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3182
|
-
const sourceId =
|
|
3183
|
-
const destId =
|
|
3190
|
+
const sourceId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3191
|
+
const destId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3184
3192
|
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
|
|
3185
3193
|
const companyID = source.companyID;
|
|
3186
3194
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3187
|
-
throw new (0,
|
|
3195
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3188
3196
|
}
|
|
3189
3197
|
if (opts.lastModifiedDate !== void 0) {
|
|
3190
3198
|
const current = source.lastModifiedDate;
|
|
3191
3199
|
if (current !== opts.lastModifiedDate) {
|
|
3192
|
-
throw new (0,
|
|
3200
|
+
throw new (0, _chunk2H7YI54Bcjs.StaleObjectError)(
|
|
3193
3201
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3194
3202
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3195
3203
|
);
|
|
@@ -3211,10 +3219,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3211
3219
|
},
|
|
3212
3220
|
operation: "contacts.moveToCompany"
|
|
3213
3221
|
});
|
|
3214
|
-
const items =
|
|
3222
|
+
const items = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
3215
3223
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3216
3224
|
if (clash !== void 0) {
|
|
3217
|
-
throw new (0,
|
|
3225
|
+
throw new (0, _chunk2H7YI54Bcjs.ConflictError)(
|
|
3218
3226
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3219
3227
|
{ resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3220
3228
|
);
|
|
@@ -3228,7 +3236,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3228
3236
|
if (opts.dryRun === true) {
|
|
3229
3237
|
const warnings = [];
|
|
3230
3238
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3231
|
-
return
|
|
3239
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
3232
3240
|
operation: "contacts.moveToCompany",
|
|
3233
3241
|
method: "POST",
|
|
3234
3242
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3254,7 +3262,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3254
3262
|
const createdBody = created;
|
|
3255
3263
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3256
3264
|
if (typeof newId !== "number") {
|
|
3257
|
-
throw new (0,
|
|
3265
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3258
3266
|
}
|
|
3259
3267
|
let sourceDeleted = false;
|
|
3260
3268
|
if (opts.deleteSource === true) {
|
|
@@ -3273,7 +3281,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3273
3281
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3274
3282
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3275
3283
|
var DEDUP_LIMIT = 10;
|
|
3276
|
-
var CompanyNotFoundError = class extends
|
|
3284
|
+
var CompanyNotFoundError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
3277
3285
|
constructor(message, options = {}) {
|
|
3278
3286
|
super(message, {
|
|
3279
3287
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3284,7 +3292,7 @@ var CompanyNotFoundError = class extends _chunkD5TVBI4Ucjs.AutotaskError {
|
|
|
3284
3292
|
this.name = "CompanyNotFoundError";
|
|
3285
3293
|
}
|
|
3286
3294
|
};
|
|
3287
|
-
var ContactCreateFailedError = class extends
|
|
3295
|
+
var ContactCreateFailedError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
3288
3296
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3289
3297
|
|
|
3290
3298
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3294,25 +3302,25 @@ var ContactCreateFailedError = class extends _chunkD5TVBI4Ucjs.AutotaskError {
|
|
|
3294
3302
|
}
|
|
3295
3303
|
};
|
|
3296
3304
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3297
|
-
const cid =
|
|
3305
|
+
const cid = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3298
3306
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3299
|
-
throw new (0,
|
|
3307
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
3300
3308
|
`upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
|
|
3301
3309
|
{ operation: OP_UPSERT_EMAIL }
|
|
3302
3310
|
);
|
|
3303
3311
|
}
|
|
3304
3312
|
if (extra !== void 0) {
|
|
3305
3313
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3306
|
-
throw new (0,
|
|
3314
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
3307
3315
|
`upsertByEmail: extra.isActive must be a boolean (mapped to the zone-correct number 1/0) or a raw 0/1 number (got ${String(extra.isActive)})`,
|
|
3308
3316
|
{ operation: OP_UPSERT_EMAIL }
|
|
3309
3317
|
);
|
|
3310
3318
|
}
|
|
3311
3319
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3312
|
-
throw new (0,
|
|
3320
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("upsertByEmail: extra.firstName must be a non-empty string (or omitted \u2014 the node defaults it to the email local-part)", { operation: OP_UPSERT_EMAIL });
|
|
3313
3321
|
}
|
|
3314
3322
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3315
|
-
throw new (0,
|
|
3323
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("upsertByEmail: extra.lastName must be a string (or omitted \u2014 the node defaults it to the non-empty neutral value Unknown)", { operation: OP_UPSERT_EMAIL });
|
|
3316
3324
|
}
|
|
3317
3325
|
}
|
|
3318
3326
|
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
|
|
@@ -3333,7 +3341,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3333
3341
|
const match = q.items[0];
|
|
3334
3342
|
if (match !== void 0) {
|
|
3335
3343
|
if (opts.dryRun === true) {
|
|
3336
|
-
return
|
|
3344
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
3337
3345
|
{
|
|
3338
3346
|
operation: OP_UPSERT_EMAIL,
|
|
3339
3347
|
method: "POST",
|
|
@@ -3354,16 +3362,16 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3354
3362
|
return { id: Number(match.id), created: false, existing: match };
|
|
3355
3363
|
}
|
|
3356
3364
|
const localPart = email.split("@")[0];
|
|
3357
|
-
const isActive = _optionalChain([extra, 'optionalAccess',
|
|
3365
|
+
const isActive = _optionalChain([extra, 'optionalAccess', _40 => _40.isActive]) === void 0 ? true : extra.isActive;
|
|
3358
3366
|
const body = {
|
|
3359
3367
|
emailAddress: email,
|
|
3360
3368
|
companyID: cid,
|
|
3361
|
-
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3362
|
-
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3369
|
+
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _41 => _41.firstName]), () => ( localPart)),
|
|
3370
|
+
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _42 => _42.lastName]), () => ( "Unknown")),
|
|
3363
3371
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3364
3372
|
};
|
|
3365
3373
|
if (opts.dryRun === true) {
|
|
3366
|
-
return
|
|
3374
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
3367
3375
|
{
|
|
3368
3376
|
operation: OP_UPSERT_EMAIL,
|
|
3369
3377
|
method: "POST",
|
|
@@ -3386,8 +3394,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3386
3394
|
const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
|
|
3387
3395
|
return { id: created.id, created: true };
|
|
3388
3396
|
} catch (err) {
|
|
3389
|
-
if (!
|
|
3390
|
-
const named = (_nullishCoalesce(
|
|
3397
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3398
|
+
const named = (_nullishCoalesce(_chunk2H7YI54Bcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3391
3399
|
const seen = /* @__PURE__ */ new Set();
|
|
3392
3400
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3393
3401
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3401,7 +3409,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3401
3409
|
}
|
|
3402
3410
|
continue;
|
|
3403
3411
|
}
|
|
3404
|
-
const detail =
|
|
3412
|
+
const detail = _chunk2H7YI54Bcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3405
3413
|
throw new ContactCreateFailedError(
|
|
3406
3414
|
`upsertByEmail: the vendor rejected the contact create${unique.length > 0 ? ` naming field(s) ${unique.join(", ")}` : ""} (no proven-safe default \u2014 the required set is fully filled by the node)${detail ? ` \u2014 ${detail}` : ""}`,
|
|
3407
3415
|
unique,
|
|
@@ -3418,7 +3426,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3418
3426
|
}
|
|
3419
3427
|
|
|
3420
3428
|
// src/resources/contacts.ts
|
|
3421
|
-
var ContactsResource = class extends
|
|
3429
|
+
var ContactsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3422
3430
|
constructor(http, pageSize) {
|
|
3423
3431
|
super(http, {
|
|
3424
3432
|
key: "contacts",
|
|
@@ -3489,7 +3497,7 @@ var ContactsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
3489
3497
|
/** Search Contact records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
3490
3498
|
* limit defaults to 25, max 500. */
|
|
3491
3499
|
async search(query, opts) {
|
|
3492
|
-
return this.searchBase(query, opts);
|
|
3500
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _43 => _43.limit]) });
|
|
3493
3501
|
}
|
|
3494
3502
|
/** Get the Contact with its primary context records in one call (each part a single-record
|
|
3495
3503
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
@@ -3510,7 +3518,7 @@ var ContactsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
3510
3518
|
};
|
|
3511
3519
|
|
|
3512
3520
|
// src/resources/contact_webhooks.ts
|
|
3513
|
-
var ContactWebhooksResource = class extends
|
|
3521
|
+
var ContactWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3514
3522
|
constructor(http, pageSize) {
|
|
3515
3523
|
super(http, {
|
|
3516
3524
|
key: "contact_webhooks",
|
|
@@ -3581,12 +3589,12 @@ var ContactWebhooksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
3581
3589
|
/** Search ContactWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
3582
3590
|
* limit defaults to 25, max 500. */
|
|
3583
3591
|
async search(query, opts) {
|
|
3584
|
-
return this.searchBase(query, opts);
|
|
3592
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _44 => _44.limit]) });
|
|
3585
3593
|
}
|
|
3586
3594
|
};
|
|
3587
3595
|
|
|
3588
3596
|
// src/resources/contract_billing_rules.ts
|
|
3589
|
-
var ContractBillingRulesResource = class extends
|
|
3597
|
+
var ContractBillingRulesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3590
3598
|
constructor(http, pageSize) {
|
|
3591
3599
|
super(http, {
|
|
3592
3600
|
key: "contract_billing_rules",
|
|
@@ -3652,7 +3660,7 @@ var ContractBillingRulesResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
3652
3660
|
};
|
|
3653
3661
|
|
|
3654
3662
|
// src/resources/contract_block_hour_factors.ts
|
|
3655
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3663
|
+
var ContractBlockHourFactorsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3656
3664
|
constructor(http, pageSize) {
|
|
3657
3665
|
super(http, {
|
|
3658
3666
|
key: "contract_block_hour_factors",
|
|
@@ -3711,7 +3719,7 @@ var ContractBlockHourFactorsResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
3711
3719
|
};
|
|
3712
3720
|
|
|
3713
3721
|
// src/resources/contract_blocks.ts
|
|
3714
|
-
var ContractBlocksResource = class extends
|
|
3722
|
+
var ContractBlocksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3715
3723
|
constructor(http, pageSize) {
|
|
3716
3724
|
super(http, {
|
|
3717
3725
|
key: "contract_blocks",
|
|
@@ -3770,7 +3778,7 @@ var ContractBlocksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
3770
3778
|
};
|
|
3771
3779
|
|
|
3772
3780
|
// src/resources/contract_charges.ts
|
|
3773
|
-
var ContractChargesResource = class extends
|
|
3781
|
+
var ContractChargesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3774
3782
|
constructor(http, pageSize) {
|
|
3775
3783
|
super(http, {
|
|
3776
3784
|
key: "contract_charges",
|
|
@@ -3836,12 +3844,12 @@ var ContractChargesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
3836
3844
|
/** Search ContractCharge records: bounded contains on name (no vendor free-text search exists);
|
|
3837
3845
|
* limit defaults to 25, max 500. */
|
|
3838
3846
|
async search(query, opts) {
|
|
3839
|
-
return this.searchBase(query, opts);
|
|
3847
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _45 => _45.limit]) });
|
|
3840
3848
|
}
|
|
3841
3849
|
};
|
|
3842
3850
|
|
|
3843
3851
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3844
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
3852
|
+
var ContractExclusionBillingCodesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3845
3853
|
constructor(http, pageSize) {
|
|
3846
3854
|
super(http, {
|
|
3847
3855
|
key: "contract_exclusion_billing_codes",
|
|
@@ -3898,7 +3906,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkD5TVBI4Ucjs.Base
|
|
|
3898
3906
|
};
|
|
3899
3907
|
|
|
3900
3908
|
// src/resources/contract_exclusion_roles.ts
|
|
3901
|
-
var ContractExclusionRolesResource = class extends
|
|
3909
|
+
var ContractExclusionRolesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3902
3910
|
constructor(http, pageSize) {
|
|
3903
3911
|
super(http, {
|
|
3904
3912
|
key: "contract_exclusion_roles",
|
|
@@ -3955,7 +3963,7 @@ var ContractExclusionRolesResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
3955
3963
|
};
|
|
3956
3964
|
|
|
3957
3965
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
3958
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
3966
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
3959
3967
|
constructor(http, pageSize) {
|
|
3960
3968
|
super(http, {
|
|
3961
3969
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -4012,7 +4020,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkD5TVBI4Ucjs.
|
|
|
4012
4020
|
};
|
|
4013
4021
|
|
|
4014
4022
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
4015
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
4023
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4016
4024
|
constructor(http, pageSize) {
|
|
4017
4025
|
super(http, {
|
|
4018
4026
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -4069,7 +4077,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkD5TVBI4U
|
|
|
4069
4077
|
};
|
|
4070
4078
|
|
|
4071
4079
|
// src/resources/contract_exclusion_sets.ts
|
|
4072
|
-
var ContractExclusionSetsResource = class extends
|
|
4080
|
+
var ContractExclusionSetsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4073
4081
|
constructor(http, pageSize) {
|
|
4074
4082
|
super(http, {
|
|
4075
4083
|
key: "contract_exclusion_sets",
|
|
@@ -4138,12 +4146,12 @@ var ContractExclusionSetsResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
4138
4146
|
/** Search ContractExclusionSets records: bounded contains on name (no vendor free-text search exists);
|
|
4139
4147
|
* limit defaults to 25, max 500. */
|
|
4140
4148
|
async search(query, opts) {
|
|
4141
|
-
return this.searchBase(query, opts);
|
|
4149
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _46 => _46.limit]) });
|
|
4142
4150
|
}
|
|
4143
4151
|
};
|
|
4144
4152
|
|
|
4145
4153
|
// src/resources/contract_milestones.ts
|
|
4146
|
-
var ContractMilestonesResource = class extends
|
|
4154
|
+
var ContractMilestonesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4147
4155
|
constructor(http, pageSize) {
|
|
4148
4156
|
super(http, {
|
|
4149
4157
|
key: "contract_milestones",
|
|
@@ -4202,7 +4210,7 @@ var ContractMilestonesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
4202
4210
|
};
|
|
4203
4211
|
|
|
4204
4212
|
// src/resources/contract_notes.ts
|
|
4205
|
-
var ContractNotesResource = class extends
|
|
4213
|
+
var ContractNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4206
4214
|
constructor(http, pageSize) {
|
|
4207
4215
|
super(http, {
|
|
4208
4216
|
key: "contract_notes",
|
|
@@ -4261,7 +4269,7 @@ var ContractNotesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
4261
4269
|
};
|
|
4262
4270
|
|
|
4263
4271
|
// src/resources/contract_rates.ts
|
|
4264
|
-
var ContractRatesResource = class extends
|
|
4272
|
+
var ContractRatesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4265
4273
|
constructor(http, pageSize) {
|
|
4266
4274
|
super(http, {
|
|
4267
4275
|
key: "contract_rates",
|
|
@@ -4320,7 +4328,7 @@ var ContractRatesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
4320
4328
|
};
|
|
4321
4329
|
|
|
4322
4330
|
// src/resources/contract_retainers.ts
|
|
4323
|
-
var ContractRetainersResource = class extends
|
|
4331
|
+
var ContractRetainersResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4324
4332
|
constructor(http, pageSize) {
|
|
4325
4333
|
super(http, {
|
|
4326
4334
|
key: "contract_retainers",
|
|
@@ -4379,7 +4387,7 @@ var ContractRetainersResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
4379
4387
|
};
|
|
4380
4388
|
|
|
4381
4389
|
// src/resources/contract_role_costs.ts
|
|
4382
|
-
var ContractRoleCostsResource = class extends
|
|
4390
|
+
var ContractRoleCostsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4383
4391
|
constructor(http, pageSize) {
|
|
4384
4392
|
super(http, {
|
|
4385
4393
|
key: "contract_role_costs",
|
|
@@ -4438,7 +4446,7 @@ var ContractRoleCostsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
4438
4446
|
};
|
|
4439
4447
|
|
|
4440
4448
|
// src/resources/contract_service_adjustments.ts
|
|
4441
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4449
|
+
var ContractServiceAdjustmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4442
4450
|
constructor(http, pageSize) {
|
|
4443
4451
|
super(http, {
|
|
4444
4452
|
key: "contract_service_adjustments",
|
|
@@ -4472,7 +4480,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkD5TVBI4Ucjs.BaseRes
|
|
|
4472
4480
|
};
|
|
4473
4481
|
|
|
4474
4482
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4475
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4483
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4476
4484
|
constructor(http, pageSize) {
|
|
4477
4485
|
super(http, {
|
|
4478
4486
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4506,7 +4514,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkD5TVBI4Ucjs.B
|
|
|
4506
4514
|
};
|
|
4507
4515
|
|
|
4508
4516
|
// src/resources/contract_service_bundles.ts
|
|
4509
|
-
var ContractServiceBundlesResource = class extends
|
|
4517
|
+
var ContractServiceBundlesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4510
4518
|
constructor(http, pageSize) {
|
|
4511
4519
|
super(http, {
|
|
4512
4520
|
key: "contract_service_bundles",
|
|
@@ -4565,7 +4573,7 @@ var ContractServiceBundlesResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
4565
4573
|
};
|
|
4566
4574
|
|
|
4567
4575
|
// src/resources/contract_service_bundle_units.ts
|
|
4568
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4576
|
+
var ContractServiceBundleUnitsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4569
4577
|
constructor(http, pageSize) {
|
|
4570
4578
|
super(http, {
|
|
4571
4579
|
key: "contract_service_bundle_units",
|
|
@@ -4607,7 +4615,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkD5TVBI4Ucjs.BaseRes
|
|
|
4607
4615
|
};
|
|
4608
4616
|
|
|
4609
4617
|
// src/resources/contract_services.ts
|
|
4610
|
-
var ContractServicesResource = class extends
|
|
4618
|
+
var ContractServicesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4611
4619
|
constructor(http, pageSize) {
|
|
4612
4620
|
super(http, {
|
|
4613
4621
|
key: "contract_services",
|
|
@@ -4666,7 +4674,7 @@ var ContractServicesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
4666
4674
|
};
|
|
4667
4675
|
|
|
4668
4676
|
// src/resources/contract_service_units.ts
|
|
4669
|
-
var ContractServiceUnitsResource = class extends
|
|
4677
|
+
var ContractServiceUnitsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
4670
4678
|
constructor(http, pageSize) {
|
|
4671
4679
|
super(http, {
|
|
4672
4680
|
key: "contract_service_units",
|
|
@@ -4934,7 +4942,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
|
|
|
4934
4942
|
// src/resources/special/contracts/profitability.validate.ts
|
|
4935
4943
|
function validateProfitabilityOptions(contractId, opts) {
|
|
4936
4944
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
4937
|
-
throw new (0,
|
|
4945
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
4938
4946
|
`profitability: opts is required \u2014 the options object with dateFrom and dateTo (YYYY-MM-DD) (got ${opts === void 0 ? "undefined" : Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
4939
4947
|
{ operation: "contracts.profitability" }
|
|
4940
4948
|
);
|
|
@@ -5011,12 +5019,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
5011
5019
|
}
|
|
5012
5020
|
}
|
|
5013
5021
|
try {
|
|
5014
|
-
|
|
5022
|
+
_chunk2H7YI54Bcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5015
5023
|
} catch (err) {
|
|
5016
|
-
problems.push(err instanceof
|
|
5024
|
+
problems.push(err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
5017
5025
|
}
|
|
5018
5026
|
if (problems.length > 0) {
|
|
5019
|
-
throw new (0,
|
|
5027
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
5020
5028
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
5021
5029
|
- ` + problems.join("\n- "),
|
|
5022
5030
|
{ operation: "contracts.profitability" }
|
|
@@ -5065,23 +5073,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5065
5073
|
const byKey = /* @__PURE__ */ new Map();
|
|
5066
5074
|
const misses = [];
|
|
5067
5075
|
const notes = [];
|
|
5068
|
-
for (let c = 0; c < unique.length; c +=
|
|
5069
|
-
const chunk = unique.slice(c, c +
|
|
5076
|
+
for (let c = 0; c < unique.length; c += _chunk2H7YI54Bcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
5077
|
+
const chunk = unique.slice(c, c + _chunk2H7YI54Bcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
5070
5078
|
const chunkKeys = new Set(chunk);
|
|
5071
5079
|
try {
|
|
5072
5080
|
const body = {
|
|
5073
|
-
MaxRecords:
|
|
5081
|
+
MaxRecords: _chunk2H7YI54Bcjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
5074
5082
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
5075
5083
|
IncludeFields: fields
|
|
5076
5084
|
};
|
|
5077
5085
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
5078
|
-
const { items: rows } =
|
|
5086
|
+
const { items: rows } = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, operation);
|
|
5079
5087
|
for (const row of rows) {
|
|
5080
5088
|
const k = num(row.id);
|
|
5081
5089
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
5082
5090
|
}
|
|
5083
5091
|
} catch (err) {
|
|
5084
|
-
const code = err instanceof
|
|
5092
|
+
const code = err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
5085
5093
|
for (const k of chunk) {
|
|
5086
5094
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
5087
5095
|
}
|
|
@@ -5091,11 +5099,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5091
5099
|
for (const k of queryMissed) {
|
|
5092
5100
|
try {
|
|
5093
5101
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
5094
|
-
byKey.set(k,
|
|
5102
|
+
byKey.set(k, _chunk2H7YI54Bcjs.unwrapItem.call(void 0, res, k, operation, entity));
|
|
5095
5103
|
} catch (err) {
|
|
5096
|
-
if (err instanceof
|
|
5104
|
+
if (err instanceof _chunk2H7YI54Bcjs.NotFoundError) {
|
|
5097
5105
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
5098
|
-
} else if (err instanceof
|
|
5106
|
+
} else if (err instanceof _chunk2H7YI54Bcjs.AutotaskError) {
|
|
5099
5107
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
5100
5108
|
} else {
|
|
5101
5109
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -5149,7 +5157,7 @@ async function degradable(read) {
|
|
|
5149
5157
|
try {
|
|
5150
5158
|
return await read();
|
|
5151
5159
|
} catch (err) {
|
|
5152
|
-
if (!(err instanceof
|
|
5160
|
+
if (!(err instanceof _chunk2H7YI54Bcjs.AutotaskError)) throw err;
|
|
5153
5161
|
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
5154
5162
|
}
|
|
5155
5163
|
}
|
|
@@ -5169,15 +5177,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
|
|
|
5169
5177
|
status: st.status,
|
|
5170
5178
|
blindSurface: st.blindSurface,
|
|
5171
5179
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
5172
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5180
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunk2H7YI54Bcjs.EMPTY_REASON_STAMPS, 'access', _47 => _47[key], 'optionalAccess', _48 => _48.query]) : void 0
|
|
5173
5181
|
};
|
|
5174
5182
|
};
|
|
5175
5183
|
function appendWiresNote(wires, note) {
|
|
5176
5184
|
wires.note = (wires.note ? wires.note + " | " : "") + note;
|
|
5177
5185
|
}
|
|
5178
5186
|
function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
5179
|
-
const
|
|
5180
|
-
const id =
|
|
5187
|
+
const OP6 = PROFITABILITY_OP;
|
|
5188
|
+
const id = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5181
5189
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
5182
5190
|
const wires = { issued: 0, requests: 0, budget };
|
|
5183
5191
|
const toExcl = dayAfter(v.dateTo);
|
|
@@ -5188,19 +5196,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
|
5188
5196
|
} };
|
|
5189
5197
|
const readPart = (path, conditions, fields) => {
|
|
5190
5198
|
wires.issued += 1;
|
|
5191
|
-
return degradable(() => boundedPart(http, path, conditions, v.limit,
|
|
5199
|
+
return degradable(() => boundedPart(http, path, conditions, v.limit, OP6, fields));
|
|
5192
5200
|
};
|
|
5193
5201
|
const truncatedMonths = {};
|
|
5194
5202
|
const windowedPart = async (name, key, path, cond, fields, dateField) => {
|
|
5195
5203
|
const first = await readPart(path, cond, fields);
|
|
5196
5204
|
if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
|
|
5197
|
-
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit,
|
|
5205
|
+
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP6, fields, dateField, v.dateFrom, v.dateTo, wires));
|
|
5198
5206
|
if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
|
|
5199
5207
|
const { truncatedMonths: tm, ...part } = wp;
|
|
5200
5208
|
truncatedMonths[name] = tm;
|
|
5201
5209
|
return { part, rows: wp.items };
|
|
5202
5210
|
};
|
|
5203
|
-
return { v, OP:
|
|
5211
|
+
return { v, OP: OP6, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
|
|
5204
5212
|
}
|
|
5205
5213
|
|
|
5206
5214
|
// src/resources/special/contracts/profitability.stages.ts
|
|
@@ -5215,12 +5223,12 @@ async function fetchCustomer(ctx, companyID) {
|
|
|
5215
5223
|
path: `/V1.0/Companies/${companyID}`,
|
|
5216
5224
|
operation: ctx.OP
|
|
5217
5225
|
});
|
|
5218
|
-
const item =
|
|
5226
|
+
const item = _chunk2H7YI54Bcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
|
|
5219
5227
|
customer = _nullishCoalesce(item, () => ( null));
|
|
5220
5228
|
customerStatus = "ok";
|
|
5221
5229
|
} catch (err) {
|
|
5222
|
-
if (!(err instanceof
|
|
5223
|
-
if (!(err instanceof
|
|
5230
|
+
if (!(err instanceof _chunk2H7YI54Bcjs.AutotaskError)) throw err;
|
|
5231
|
+
if (!(err instanceof _chunk2H7YI54Bcjs.NotFoundError)) {
|
|
5224
5232
|
customerStatus = "absent";
|
|
5225
5233
|
customerAbsent = err.code;
|
|
5226
5234
|
}
|
|
@@ -5234,9 +5242,9 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5234
5242
|
if (contractType > 0) {
|
|
5235
5243
|
ctx.wires.issued += 1;
|
|
5236
5244
|
try {
|
|
5237
|
-
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async
|
|
5245
|
+
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _49 => _49.get, 'call', async _50 => _50("contractType"), 'optionalAccess', async _51 => _51.get, 'call', async _52 => _52(contractType)]), async () => ( null));
|
|
5238
5246
|
} catch (err) {
|
|
5239
|
-
if (!(err instanceof
|
|
5247
|
+
if (!(err instanceof _chunk2H7YI54Bcjs.AutotaskError)) throw err;
|
|
5240
5248
|
}
|
|
5241
5249
|
}
|
|
5242
5250
|
const contractTypeKnown = contractTypeLabel !== null;
|
|
@@ -5245,7 +5253,7 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5245
5253
|
return { contractTypeLabel, contractTypeKnown, isBlockHours, isTimeAndMaterials };
|
|
5246
5254
|
}
|
|
5247
5255
|
async function fetchRoot(ctx, resource) {
|
|
5248
|
-
const contractCached = _optionalChain([ctx, 'access',
|
|
5256
|
+
const contractCached = _optionalChain([ctx, 'access', _53 => _53.rawHttp, 'access', _54 => _54.readCache, 'optionalAccess', _55 => _55.get, 'call', _56 => _56(`/V1.0/Contracts/${ctx.id}`)]) !== void 0;
|
|
5249
5257
|
const contract = await resource.get(ctx.id);
|
|
5250
5258
|
ctx.wires.issued += 1;
|
|
5251
5259
|
if (!contractCached) ctx.wires.requests += 1;
|
|
@@ -5298,8 +5306,8 @@ async function fetchInvoices(ctx, billingRows) {
|
|
|
5298
5306
|
if (invoiceIds.length === 0) {
|
|
5299
5307
|
return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
|
|
5300
5308
|
}
|
|
5301
|
-
const capped = capJoinSet2(invoiceIds,
|
|
5302
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${
|
|
5309
|
+
const capped = capJoinSet2(invoiceIds, _chunk2H7YI54Bcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5310
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunk2H7YI54Bcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5303
5311
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
|
|
5304
5312
|
ctx.wires.issued += 1;
|
|
5305
5313
|
return {
|
|
@@ -5345,7 +5353,7 @@ async function readOpenStatusSet(ctx) {
|
|
|
5345
5353
|
}
|
|
5346
5354
|
}
|
|
5347
5355
|
} catch (err) {
|
|
5348
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof
|
|
5356
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunk2H7YI54Bcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5349
5357
|
}
|
|
5350
5358
|
return { openStatusSet, statusNote };
|
|
5351
5359
|
}
|
|
@@ -5368,8 +5376,8 @@ async function fetchResources(ctx, entries) {
|
|
|
5368
5376
|
if (resourceIds.length === 0) {
|
|
5369
5377
|
return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
|
|
5370
5378
|
}
|
|
5371
|
-
const capped = capJoinSet2(resourceIds,
|
|
5372
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${
|
|
5379
|
+
const capped = capJoinSet2(resourceIds, _chunk2H7YI54Bcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5380
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunk2H7YI54Bcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5373
5381
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
|
|
5374
5382
|
ctx.wires.issued += 1;
|
|
5375
5383
|
for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
|
|
@@ -5436,7 +5444,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
|
|
|
5436
5444
|
try {
|
|
5437
5445
|
return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
|
|
5438
5446
|
} catch (err) {
|
|
5439
|
-
if (!(err instanceof
|
|
5447
|
+
if (!(err instanceof _chunk2H7YI54Bcjs.AutotaskError)) throw err;
|
|
5440
5448
|
return null;
|
|
5441
5449
|
}
|
|
5442
5450
|
}
|
|
@@ -5453,17 +5461,17 @@ async function fetchSubscriptions(ctx, cis) {
|
|
|
5453
5461
|
cancelledSubs
|
|
5454
5462
|
};
|
|
5455
5463
|
}
|
|
5456
|
-
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0),
|
|
5464
|
+
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunk2H7YI54Bcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5457
5465
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5458
5466
|
const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5459
5467
|
const subscriptions = raw.items;
|
|
5460
5468
|
const labels = await readSubscriptionLabels(ctx, subscriptions);
|
|
5461
5469
|
for (const x of subscriptions) {
|
|
5462
5470
|
const sid = num(x["id"]);
|
|
5463
|
-
const periodLabel = _optionalChain([labels, 'optionalAccess',
|
|
5471
|
+
const periodLabel = _optionalChain([labels, 'optionalAccess', _57 => _57.get, 'call', _58 => _58("periodType"), 'optionalAccess', _59 => _59.get, 'call', _60 => _60(num(x["periodType"]))]);
|
|
5464
5472
|
subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
|
|
5465
5473
|
if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
|
|
5466
|
-
const statusLabel = _optionalChain([labels, 'optionalAccess',
|
|
5474
|
+
const statusLabel = _optionalChain([labels, 'optionalAccess', _61 => _61.get, 'call', _62 => _62("status"), 'optionalAccess', _63 => _63.get, 'call', _64 => _64(num(x["status"]))]);
|
|
5467
5475
|
const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num(x["status"]));
|
|
5468
5476
|
if (notActive) cancelledSubs.add(sid);
|
|
5469
5477
|
}
|
|
@@ -6138,7 +6146,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
6138
6146
|
}
|
|
6139
6147
|
|
|
6140
6148
|
// src/resources/contracts.ts
|
|
6141
|
-
var ContractsResource = class extends
|
|
6149
|
+
var ContractsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6142
6150
|
constructor(http, pageSize) {
|
|
6143
6151
|
super(http, {
|
|
6144
6152
|
key: "contracts",
|
|
@@ -6200,7 +6208,7 @@ var ContractsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6200
6208
|
/** Search Contract records: bounded contains on contractName (no vendor free-text search exists);
|
|
6201
6209
|
* limit defaults to 25, max 500. */
|
|
6202
6210
|
async search(query, opts) {
|
|
6203
|
-
return this.searchBase(query, opts);
|
|
6211
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _65 => _65.limit]) });
|
|
6204
6212
|
}
|
|
6205
6213
|
/** Node-parity special op (hand-written in src/resources/special/contracts.ts). */
|
|
6206
6214
|
profitability(id, opts) {
|
|
@@ -6209,7 +6217,7 @@ var ContractsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6209
6217
|
};
|
|
6210
6218
|
|
|
6211
6219
|
// src/resources/contract_ticket_purchases.ts
|
|
6212
|
-
var ContractTicketPurchasesResource = class extends
|
|
6220
|
+
var ContractTicketPurchasesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6213
6221
|
constructor(http, pageSize) {
|
|
6214
6222
|
super(http, {
|
|
6215
6223
|
key: "contract_ticket_purchases",
|
|
@@ -6268,7 +6276,7 @@ var ContractTicketPurchasesResource = class extends _chunkD5TVBI4Ucjs.BaseResour
|
|
|
6268
6276
|
};
|
|
6269
6277
|
|
|
6270
6278
|
// src/resources/countries.ts
|
|
6271
|
-
var CountriesResource = class extends
|
|
6279
|
+
var CountriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6272
6280
|
constructor(http, pageSize) {
|
|
6273
6281
|
super(http, {
|
|
6274
6282
|
key: "countries",
|
|
@@ -6322,12 +6330,12 @@ var CountriesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6322
6330
|
/** Search Country records: bounded contains on name (no vendor free-text search exists);
|
|
6323
6331
|
* limit defaults to 25, max 500. */
|
|
6324
6332
|
async search(query, opts) {
|
|
6325
|
-
return this.searchBase(query, opts);
|
|
6333
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _66 => _66.limit]) });
|
|
6326
6334
|
}
|
|
6327
6335
|
};
|
|
6328
6336
|
|
|
6329
6337
|
// src/resources/departments.ts
|
|
6330
|
-
var DepartmentsResource = class extends
|
|
6338
|
+
var DepartmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6331
6339
|
constructor(http, pageSize) {
|
|
6332
6340
|
super(http, {
|
|
6333
6341
|
key: "departments",
|
|
@@ -6389,12 +6397,12 @@ var DepartmentsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6389
6397
|
/** Search Department records: bounded contains on name (no vendor free-text search exists);
|
|
6390
6398
|
* limit defaults to 25, max 500. */
|
|
6391
6399
|
async search(query, opts) {
|
|
6392
|
-
return this.searchBase(query, opts);
|
|
6400
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _67 => _67.limit]) });
|
|
6393
6401
|
}
|
|
6394
6402
|
};
|
|
6395
6403
|
|
|
6396
6404
|
// src/resources/domain_registrars.ts
|
|
6397
|
-
var DomainRegistrarsResource = class extends
|
|
6405
|
+
var DomainRegistrarsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6398
6406
|
constructor(http, pageSize) {
|
|
6399
6407
|
super(http, {
|
|
6400
6408
|
key: "domain_registrars",
|
|
@@ -6456,7 +6464,7 @@ var DomainRegistrarsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6456
6464
|
/** Search DomainRegistrar records: bounded contains on name (no vendor free-text search exists);
|
|
6457
6465
|
* limit defaults to 25, max 500. */
|
|
6458
6466
|
async search(query, opts) {
|
|
6459
|
-
return this.searchBase(query, opts);
|
|
6467
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _68 => _68.limit]) });
|
|
6460
6468
|
}
|
|
6461
6469
|
};
|
|
6462
6470
|
|
|
@@ -6477,7 +6485,7 @@ var EntityInformationResource = class {
|
|
|
6477
6485
|
};
|
|
6478
6486
|
|
|
6479
6487
|
// src/resources/expense_item_attachments.ts
|
|
6480
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6488
|
+
var ExpenseItemAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6481
6489
|
constructor(http, pageSize) {
|
|
6482
6490
|
super(http, {
|
|
6483
6491
|
key: "expense_item_attachments",
|
|
@@ -6539,7 +6547,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
6539
6547
|
};
|
|
6540
6548
|
|
|
6541
6549
|
// src/resources/expense_items.ts
|
|
6542
|
-
var ExpenseItemsResource = class extends
|
|
6550
|
+
var ExpenseItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6543
6551
|
constructor(http, pageSize) {
|
|
6544
6552
|
super(http, {
|
|
6545
6553
|
key: "expense_items",
|
|
@@ -6598,7 +6606,7 @@ var ExpenseItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6598
6606
|
};
|
|
6599
6607
|
|
|
6600
6608
|
// src/resources/expense_reports.ts
|
|
6601
|
-
var ExpenseReportsResource = class extends
|
|
6609
|
+
var ExpenseReportsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6602
6610
|
constructor(http, pageSize) {
|
|
6603
6611
|
super(http, {
|
|
6604
6612
|
key: "expense_reports",
|
|
@@ -6660,12 +6668,12 @@ var ExpenseReportsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6660
6668
|
/** Search ExpenseReport records: bounded contains on name (no vendor free-text search exists);
|
|
6661
6669
|
* limit defaults to 25, max 500. */
|
|
6662
6670
|
async search(query, opts) {
|
|
6663
|
-
return this.searchBase(query, opts);
|
|
6671
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _69 => _69.limit]) });
|
|
6664
6672
|
}
|
|
6665
6673
|
};
|
|
6666
6674
|
|
|
6667
6675
|
// src/resources/holiday_sets.ts
|
|
6668
|
-
var HolidaySetsResource = class extends
|
|
6676
|
+
var HolidaySetsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6669
6677
|
constructor(http, pageSize) {
|
|
6670
6678
|
super(http, {
|
|
6671
6679
|
key: "holiday_sets",
|
|
@@ -6734,7 +6742,7 @@ var HolidaySetsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6734
6742
|
};
|
|
6735
6743
|
|
|
6736
6744
|
// src/resources/holidays.ts
|
|
6737
|
-
var HolidaysResource = class extends
|
|
6745
|
+
var HolidaysResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6738
6746
|
constructor(http, pageSize) {
|
|
6739
6747
|
super(http, {
|
|
6740
6748
|
key: "holidays",
|
|
@@ -6806,10 +6814,10 @@ var PATH_SUFFIX = {
|
|
|
6806
6814
|
transfer: "StockedItemsTransfer"
|
|
6807
6815
|
};
|
|
6808
6816
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6809
|
-
const numericParent =
|
|
6817
|
+
const numericParent = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6810
6818
|
const suffix = PATH_SUFFIX[kind];
|
|
6811
6819
|
if (opts.dryRun === true) {
|
|
6812
|
-
return
|
|
6820
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
6813
6821
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6814
6822
|
method: "POST",
|
|
6815
6823
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6826,11 +6834,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6826
6834
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6827
6835
|
maxRetries: opts.maxRetries
|
|
6828
6836
|
});
|
|
6829
|
-
return
|
|
6837
|
+
return _chunk2H7YI54Bcjs.unwrapOperation.call(void 0, res);
|
|
6830
6838
|
}
|
|
6831
6839
|
|
|
6832
6840
|
// src/resources/inventory_products.ts
|
|
6833
|
-
var InventoryProductsResource = class extends
|
|
6841
|
+
var InventoryProductsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6834
6842
|
constructor(http, pageSize) {
|
|
6835
6843
|
super(http, {
|
|
6836
6844
|
key: "inventory_products",
|
|
@@ -6912,7 +6920,7 @@ var InventoryProductsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
6912
6920
|
|
|
6913
6921
|
// src/resources/special/invoices.ts
|
|
6914
6922
|
async function markup(_resource, id, format, http) {
|
|
6915
|
-
const numericId =
|
|
6923
|
+
const numericId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
6916
6924
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
6917
6925
|
const res = await http.request({
|
|
6918
6926
|
method: "GET",
|
|
@@ -6921,7 +6929,7 @@ async function markup(_resource, id, format, http) {
|
|
|
6921
6929
|
});
|
|
6922
6930
|
const body = res;
|
|
6923
6931
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
6924
|
-
throw new (0,
|
|
6932
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskError)(
|
|
6925
6933
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
6926
6934
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
|
|
6927
6935
|
);
|
|
@@ -6929,44 +6937,44 @@ async function markup(_resource, id, format, http) {
|
|
|
6929
6937
|
return body.invoiceMarkup;
|
|
6930
6938
|
}
|
|
6931
6939
|
async function pdf(_resource, id, http) {
|
|
6932
|
-
const numericId =
|
|
6940
|
+
const numericId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
6933
6941
|
const res = await http.request({
|
|
6934
6942
|
method: "GET",
|
|
6935
6943
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
6936
6944
|
operation: "invoices.pdf"
|
|
6937
6945
|
});
|
|
6938
|
-
return
|
|
6946
|
+
return _chunk2H7YI54Bcjs.decodeFileData.call(void 0, res);
|
|
6939
6947
|
}
|
|
6940
6948
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
6941
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
6942
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
6949
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _70 => _70.now]), () => ( /* @__PURE__ */ new Date()));
|
|
6950
|
+
const tz = _optionalChain([opts, 'optionalAccess', _71 => _71.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
|
|
6943
6951
|
return dateWindowQuery(
|
|
6944
6952
|
http,
|
|
6945
6953
|
"/V1.0/Invoices/query",
|
|
6946
6954
|
"invoiceDateTime",
|
|
6947
6955
|
kind,
|
|
6948
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
6956
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _72 => _72.limit])),
|
|
6949
6957
|
`invoices.${kind}`,
|
|
6950
6958
|
now,
|
|
6951
6959
|
tz
|
|
6952
6960
|
);
|
|
6953
6961
|
}
|
|
6954
6962
|
async function customRange2(_resource, from, to, http, opts) {
|
|
6955
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
6963
|
+
const zone = _optionalChain([opts, 'optionalAccess', _73 => _73.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
|
|
6956
6964
|
return customRangeQuery(
|
|
6957
6965
|
http,
|
|
6958
6966
|
"/V1.0/Invoices/query",
|
|
6959
6967
|
"invoiceDateTime",
|
|
6960
6968
|
from,
|
|
6961
6969
|
to,
|
|
6962
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
6970
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _74 => _74.limit])),
|
|
6963
6971
|
"invoices.customRange",
|
|
6964
6972
|
zone
|
|
6965
6973
|
);
|
|
6966
6974
|
}
|
|
6967
6975
|
|
|
6968
6976
|
// src/resources/invoices.ts
|
|
6969
|
-
var InvoicesResource = class extends
|
|
6977
|
+
var InvoicesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
6970
6978
|
constructor(http, pageSize) {
|
|
6971
6979
|
super(http, {
|
|
6972
6980
|
key: "invoices",
|
|
@@ -7096,7 +7104,7 @@ var ModulesResource = class {
|
|
|
7096
7104
|
};
|
|
7097
7105
|
|
|
7098
7106
|
// src/resources/notification_history.ts
|
|
7099
|
-
var NotificationHistoryResource = class extends
|
|
7107
|
+
var NotificationHistoryResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7100
7108
|
constructor(http, pageSize) {
|
|
7101
7109
|
super(http, {
|
|
7102
7110
|
key: "notification_history",
|
|
@@ -7135,7 +7143,7 @@ var NotificationHistoryResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7135
7143
|
};
|
|
7136
7144
|
|
|
7137
7145
|
// src/resources/opportunities.ts
|
|
7138
|
-
var OpportunitiesResource = class extends
|
|
7146
|
+
var OpportunitiesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7139
7147
|
constructor(http, pageSize) {
|
|
7140
7148
|
super(http, {
|
|
7141
7149
|
key: "opportunities",
|
|
@@ -7197,7 +7205,7 @@ var OpportunitiesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7197
7205
|
};
|
|
7198
7206
|
|
|
7199
7207
|
// src/resources/opportunity_attachments.ts
|
|
7200
|
-
var OpportunityAttachmentsResource = class extends
|
|
7208
|
+
var OpportunityAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7201
7209
|
constructor(http, pageSize) {
|
|
7202
7210
|
super(http, {
|
|
7203
7211
|
key: "opportunity_attachments",
|
|
@@ -7259,7 +7267,7 @@ var OpportunityAttachmentsResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
7259
7267
|
};
|
|
7260
7268
|
|
|
7261
7269
|
// src/resources/opportunity_categories.ts
|
|
7262
|
-
var OpportunityCategoriesResource = class extends
|
|
7270
|
+
var OpportunityCategoriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7263
7271
|
constructor(http, pageSize) {
|
|
7264
7272
|
super(http, {
|
|
7265
7273
|
key: "opportunity_categories",
|
|
@@ -7313,12 +7321,12 @@ var OpportunityCategoriesResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
7313
7321
|
/** Search OpportunityCategory records: bounded contains on name (no vendor free-text search exists);
|
|
7314
7322
|
* limit defaults to 25, max 500. */
|
|
7315
7323
|
async search(query, opts) {
|
|
7316
|
-
return this.searchBase(query, opts);
|
|
7324
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _75 => _75.limit]) });
|
|
7317
7325
|
}
|
|
7318
7326
|
};
|
|
7319
7327
|
|
|
7320
7328
|
// src/resources/phases.ts
|
|
7321
|
-
var PhasesResource = class extends
|
|
7329
|
+
var PhasesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7322
7330
|
constructor(http, pageSize) {
|
|
7323
7331
|
super(http, {
|
|
7324
7332
|
key: "phases",
|
|
@@ -7377,7 +7385,7 @@ var PhasesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7377
7385
|
};
|
|
7378
7386
|
|
|
7379
7387
|
// src/resources/products.ts
|
|
7380
|
-
var ProductsResource = class extends
|
|
7388
|
+
var ProductsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7381
7389
|
constructor(http, pageSize) {
|
|
7382
7390
|
super(http, {
|
|
7383
7391
|
key: "products",
|
|
@@ -7439,12 +7447,12 @@ var ProductsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7439
7447
|
/** Search Product records: bounded contains on name (no vendor free-text search exists);
|
|
7440
7448
|
* limit defaults to 25, max 500. */
|
|
7441
7449
|
async search(query, opts) {
|
|
7442
|
-
return this.searchBase(query, opts);
|
|
7450
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _76 => _76.limit]) });
|
|
7443
7451
|
}
|
|
7444
7452
|
};
|
|
7445
7453
|
|
|
7446
7454
|
// src/resources/product_vendors.ts
|
|
7447
|
-
var ProductVendorsResource = class extends
|
|
7455
|
+
var ProductVendorsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7448
7456
|
constructor(http, pageSize) {
|
|
7449
7457
|
super(http, {
|
|
7450
7458
|
key: "product_vendors",
|
|
@@ -7503,7 +7511,7 @@ var ProductVendorsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7503
7511
|
};
|
|
7504
7512
|
|
|
7505
7513
|
// src/resources/project_charges.ts
|
|
7506
|
-
var ProjectChargesResource = class extends
|
|
7514
|
+
var ProjectChargesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7507
7515
|
constructor(http, pageSize) {
|
|
7508
7516
|
super(http, {
|
|
7509
7517
|
key: "project_charges",
|
|
@@ -7569,12 +7577,12 @@ var ProjectChargesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7569
7577
|
/** Search ProjectCharge records: bounded contains on name (no vendor free-text search exists);
|
|
7570
7578
|
* limit defaults to 25, max 500. */
|
|
7571
7579
|
async search(query, opts) {
|
|
7572
|
-
return this.searchBase(query, opts);
|
|
7580
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _77 => _77.limit]) });
|
|
7573
7581
|
}
|
|
7574
7582
|
};
|
|
7575
7583
|
|
|
7576
7584
|
// src/resources/project_notes.ts
|
|
7577
|
-
var ProjectNotesResource = class extends
|
|
7585
|
+
var ProjectNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7578
7586
|
constructor(http, pageSize) {
|
|
7579
7587
|
super(http, {
|
|
7580
7588
|
key: "project_notes",
|
|
@@ -7633,7 +7641,7 @@ var ProjectNotesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7633
7641
|
};
|
|
7634
7642
|
|
|
7635
7643
|
// src/resources/projects.ts
|
|
7636
|
-
var ProjectsResource = class extends
|
|
7644
|
+
var ProjectsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7637
7645
|
constructor(http, pageSize) {
|
|
7638
7646
|
super(http, {
|
|
7639
7647
|
key: "projects",
|
|
@@ -7695,7 +7703,7 @@ var ProjectsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7695
7703
|
/** Search Project records: bounded contains on projectName (no vendor free-text search exists);
|
|
7696
7704
|
* limit defaults to 25, max 500. */
|
|
7697
7705
|
async search(query, opts) {
|
|
7698
|
-
return this.searchBase(query, opts);
|
|
7706
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _78 => _78.limit]) });
|
|
7699
7707
|
}
|
|
7700
7708
|
/** Get the Project with its primary context records in one call (each part a single-record
|
|
7701
7709
|
* fetch; no sub-lists; absent/dangling references come back null). `names: true` (issue #77)
|
|
@@ -7710,13 +7718,13 @@ var ProjectsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7710
7718
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
7711
7719
|
const result = { project: project2, company, opportunity, leadResource };
|
|
7712
7720
|
if (opts.names === true) {
|
|
7713
|
-
const builder =
|
|
7721
|
+
const builder = _chunk2H7YI54Bcjs.createNamePlan.call(void 0, );
|
|
7714
7722
|
builder.addResource(root["creatorResourceID"]);
|
|
7715
7723
|
builder.addFk("contract", root["contractID"]);
|
|
7716
|
-
const names = await
|
|
7724
|
+
const names = await _chunk2H7YI54Bcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
7717
7725
|
const row = { ...project2 };
|
|
7718
|
-
|
|
7719
|
-
|
|
7726
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
7727
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
7720
7728
|
result.project = row;
|
|
7721
7729
|
result.names = names.section;
|
|
7722
7730
|
}
|
|
@@ -7725,7 +7733,7 @@ var ProjectsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7725
7733
|
};
|
|
7726
7734
|
|
|
7727
7735
|
// src/resources/purchase_approvals.ts
|
|
7728
|
-
var PurchaseApprovalsResource = class extends
|
|
7736
|
+
var PurchaseApprovalsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7729
7737
|
constructor(http, pageSize) {
|
|
7730
7738
|
super(http, {
|
|
7731
7739
|
key: "purchase_approvals",
|
|
@@ -7779,7 +7787,7 @@ var PurchaseApprovalsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7779
7787
|
};
|
|
7780
7788
|
|
|
7781
7789
|
// src/resources/purchase_order_item_receiving.ts
|
|
7782
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
7790
|
+
var PurchaseOrderItemReceivingResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7783
7791
|
constructor(http, pageSize) {
|
|
7784
7792
|
super(http, {
|
|
7785
7793
|
key: "purchase_order_item_receiving",
|
|
@@ -7829,7 +7837,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkD5TVBI4Ucjs.BaseRes
|
|
|
7829
7837
|
};
|
|
7830
7838
|
|
|
7831
7839
|
// src/resources/purchase_order_items.ts
|
|
7832
|
-
var PurchaseOrderItemsResource = class extends
|
|
7840
|
+
var PurchaseOrderItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7833
7841
|
constructor(http, pageSize) {
|
|
7834
7842
|
super(http, {
|
|
7835
7843
|
key: "purchase_order_items",
|
|
@@ -7888,7 +7896,7 @@ var PurchaseOrderItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7888
7896
|
};
|
|
7889
7897
|
|
|
7890
7898
|
// src/resources/purchase_orders.ts
|
|
7891
|
-
var PurchaseOrdersResource = class extends
|
|
7899
|
+
var PurchaseOrdersResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7892
7900
|
constructor(http, pageSize) {
|
|
7893
7901
|
super(http, {
|
|
7894
7902
|
key: "purchase_orders",
|
|
@@ -7950,7 +7958,7 @@ var PurchaseOrdersResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
7950
7958
|
};
|
|
7951
7959
|
|
|
7952
7960
|
// src/resources/quote_items.ts
|
|
7953
|
-
var QuoteItemsResource = class extends
|
|
7961
|
+
var QuoteItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
7954
7962
|
constructor(http, pageSize) {
|
|
7955
7963
|
super(http, {
|
|
7956
7964
|
key: "quote_items",
|
|
@@ -8016,12 +8024,12 @@ var QuoteItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8016
8024
|
/** Search QuoteItem records: bounded contains on name (no vendor free-text search exists);
|
|
8017
8025
|
* limit defaults to 25, max 500. */
|
|
8018
8026
|
async search(query, opts) {
|
|
8019
|
-
return this.searchBase(query, opts);
|
|
8027
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _79 => _79.limit]) });
|
|
8020
8028
|
}
|
|
8021
8029
|
};
|
|
8022
8030
|
|
|
8023
8031
|
// src/resources/quote_locations.ts
|
|
8024
|
-
var QuoteLocationsResource = class extends
|
|
8032
|
+
var QuoteLocationsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8025
8033
|
constructor(http, pageSize) {
|
|
8026
8034
|
super(http, {
|
|
8027
8035
|
key: "quote_locations",
|
|
@@ -8086,7 +8094,7 @@ var QuoteLocationsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8086
8094
|
};
|
|
8087
8095
|
|
|
8088
8096
|
// src/resources/quotes.ts
|
|
8089
|
-
var QuotesResource = class extends
|
|
8097
|
+
var QuotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8090
8098
|
constructor(http, pageSize) {
|
|
8091
8099
|
super(http, {
|
|
8092
8100
|
key: "quotes",
|
|
@@ -8148,12 +8156,12 @@ var QuotesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8148
8156
|
/** Search Quote records: bounded contains on name (no vendor free-text search exists);
|
|
8149
8157
|
* limit defaults to 25, max 500. */
|
|
8150
8158
|
async search(query, opts) {
|
|
8151
|
-
return this.searchBase(query, opts);
|
|
8159
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _80 => _80.limit]) });
|
|
8152
8160
|
}
|
|
8153
8161
|
};
|
|
8154
8162
|
|
|
8155
8163
|
// src/resources/quote_templates.ts
|
|
8156
|
-
var QuoteTemplatesResource = class extends
|
|
8164
|
+
var QuoteTemplatesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8157
8165
|
constructor(http, pageSize) {
|
|
8158
8166
|
super(http, {
|
|
8159
8167
|
key: "quote_templates",
|
|
@@ -8192,12 +8200,12 @@ var QuoteTemplatesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8192
8200
|
/** Search QuoteTemplate records: bounded contains on name (no vendor free-text search exists);
|
|
8193
8201
|
* limit defaults to 25, max 500. */
|
|
8194
8202
|
async search(query, opts) {
|
|
8195
|
-
return this.searchBase(query, opts);
|
|
8203
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
|
|
8196
8204
|
}
|
|
8197
8205
|
};
|
|
8198
8206
|
|
|
8199
8207
|
// src/resources/resource_role_queues.ts
|
|
8200
|
-
var ResourceRoleQueuesResource = class extends
|
|
8208
|
+
var ResourceRoleQueuesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8201
8209
|
constructor(http, pageSize) {
|
|
8202
8210
|
super(http, {
|
|
8203
8211
|
key: "resource_role_queues",
|
|
@@ -8256,7 +8264,7 @@ var ResourceRoleQueuesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8256
8264
|
};
|
|
8257
8265
|
|
|
8258
8266
|
// src/resources/resource_roles.ts
|
|
8259
|
-
var ResourceRolesResource = class extends
|
|
8267
|
+
var ResourceRolesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8260
8268
|
constructor(http, pageSize) {
|
|
8261
8269
|
super(http, {
|
|
8262
8270
|
key: "resource_roles",
|
|
@@ -8298,7 +8306,7 @@ var ResourceRolesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8298
8306
|
};
|
|
8299
8307
|
|
|
8300
8308
|
// src/resources/resource_skills.ts
|
|
8301
|
-
var ResourceSkillsResource = class extends
|
|
8309
|
+
var ResourceSkillsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8302
8310
|
constructor(http, pageSize) {
|
|
8303
8311
|
super(http, {
|
|
8304
8312
|
key: "resource_skills",
|
|
@@ -8352,16 +8360,16 @@ var ResourceSkillsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8352
8360
|
var MAX_TRANSFER_IDS = 500;
|
|
8353
8361
|
function requirePositiveIds(ids2, label) {
|
|
8354
8362
|
if (!Array.isArray(ids2) || ids2.length === 0) {
|
|
8355
|
-
throw new (0,
|
|
8363
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8356
8364
|
}
|
|
8357
8365
|
if (ids2.length > MAX_TRANSFER_IDS) {
|
|
8358
|
-
throw new (0,
|
|
8366
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8359
8367
|
}
|
|
8360
8368
|
const out = [];
|
|
8361
8369
|
for (const raw of ids2) {
|
|
8362
|
-
const id =
|
|
8370
|
+
const id = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8363
8371
|
if (typeof id === "number" && id < 1) {
|
|
8364
|
-
throw new (0,
|
|
8372
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8365
8373
|
}
|
|
8366
8374
|
out.push(id);
|
|
8367
8375
|
}
|
|
@@ -8369,7 +8377,7 @@ function requirePositiveIds(ids2, label) {
|
|
|
8369
8377
|
}
|
|
8370
8378
|
async function whoAmI(_resource, userName, http) {
|
|
8371
8379
|
const user = userName.trim();
|
|
8372
|
-
if (user === "") throw new (0,
|
|
8380
|
+
if (user === "") throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8373
8381
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8374
8382
|
const res = await http.request({
|
|
8375
8383
|
method: "POST",
|
|
@@ -8378,11 +8386,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8378
8386
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8379
8387
|
operation: "resources.whoAmI"
|
|
8380
8388
|
});
|
|
8381
|
-
const matches =
|
|
8389
|
+
const matches = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
8382
8390
|
if (matches.length === 0) return null;
|
|
8383
8391
|
if (matches.length > 1) {
|
|
8384
8392
|
const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8385
|
-
throw new (0,
|
|
8393
|
+
throw new (0, _chunk2H7YI54Bcjs.ResolutionError)(
|
|
8386
8394
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8387
8395
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
8388
8396
|
);
|
|
@@ -8391,11 +8399,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8391
8399
|
}
|
|
8392
8400
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8393
8401
|
const ids2 = requirePositiveIds(companyIds, "transferOwnership");
|
|
8394
|
-
const destination =
|
|
8402
|
+
const destination = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8395
8403
|
if (typeof destination === "number" && destination < 1) {
|
|
8396
|
-
throw new (0,
|
|
8404
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8397
8405
|
}
|
|
8398
|
-
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
8406
|
+
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _82 => _82.dryRun]), () => ( true));
|
|
8399
8407
|
const changes = [];
|
|
8400
8408
|
const applied = [];
|
|
8401
8409
|
for (const id of ids2) {
|
|
@@ -8404,9 +8412,9 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8404
8412
|
method: "GET",
|
|
8405
8413
|
path: `/V1.0/Companies/${id}`,
|
|
8406
8414
|
operation: "resources.transferOwnership",
|
|
8407
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8415
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _83 => _83.maxRetries])
|
|
8408
8416
|
});
|
|
8409
|
-
const company =
|
|
8417
|
+
const company = _chunk2H7YI54Bcjs.unwrapItem.call(void 0, res, id, void 0, "company");
|
|
8410
8418
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8411
8419
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8412
8420
|
if (!dryRun) {
|
|
@@ -8415,15 +8423,15 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8415
8423
|
path: "/V1.0/Companies",
|
|
8416
8424
|
body: { id, ownerResourceID: destination },
|
|
8417
8425
|
operation: "resources.transferOwnership",
|
|
8418
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8426
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _84 => _84.maxRetries])
|
|
8419
8427
|
});
|
|
8420
|
-
|
|
8428
|
+
_chunk2H7YI54Bcjs.unwrapOperation.call(void 0, update);
|
|
8421
8429
|
applied.push(id);
|
|
8422
8430
|
}
|
|
8423
8431
|
} catch (err) {
|
|
8424
|
-
if (!dryRun && err instanceof
|
|
8432
|
+
if (!dryRun && err instanceof _chunk2H7YI54Bcjs.AutotaskError) {
|
|
8425
8433
|
err.resourceIds = [id];
|
|
8426
|
-
err.details =
|
|
8434
|
+
err.details = _chunk2H7YI54Bcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
|
|
8427
8435
|
err.suggestedAction = `Partial transfer: ${applied.length} of ${ids2.length} companies were re-owned (ids: ${applied.join(", ") || "none"}); id ${id} failed. Re-run transferOwnership for the remaining ids (from ${id} on).`;
|
|
8428
8436
|
}
|
|
8429
8437
|
throw err;
|
|
@@ -8432,7 +8440,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8432
8440
|
if (dryRun) {
|
|
8433
8441
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8434
8442
|
return {
|
|
8435
|
-
...
|
|
8443
|
+
..._chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
8436
8444
|
operation: "resources.transferOwnership",
|
|
8437
8445
|
method: "PUT",
|
|
8438
8446
|
path: "/V1.0/Companies",
|
|
@@ -8456,7 +8464,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8456
8464
|
}
|
|
8457
8465
|
|
|
8458
8466
|
// src/resources/resources.ts
|
|
8459
|
-
var ResourcesResource = class extends
|
|
8467
|
+
var ResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8460
8468
|
|
|
8461
8469
|
constructor(http, clientConfig, pageSize) {
|
|
8462
8470
|
super(http, {
|
|
@@ -8515,7 +8523,7 @@ var ResourcesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8515
8523
|
/** Search Resource records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
8516
8524
|
* limit defaults to 25, max 500. */
|
|
8517
8525
|
async search(query, opts) {
|
|
8518
|
-
return this.searchBase(query, opts);
|
|
8526
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _85 => _85.limit]) });
|
|
8519
8527
|
}
|
|
8520
8528
|
/** Node-parity special op (hand-written in src/resources/special/resources.ts). */
|
|
8521
8529
|
transferOwnership(sourceResourceIds, destinationResourceId, opts = {}) {
|
|
@@ -8529,7 +8537,7 @@ var ResourcesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8529
8537
|
|
|
8530
8538
|
// src/resources/special/resource_time_off_additional.ts
|
|
8531
8539
|
async function getByResource(_resource, resourceId, http) {
|
|
8532
|
-
const numericResource =
|
|
8540
|
+
const numericResource = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8533
8541
|
const res = await http.request({
|
|
8534
8542
|
method: "GET",
|
|
8535
8543
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8543,11 +8551,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8543
8551
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8544
8552
|
}
|
|
8545
8553
|
}
|
|
8546
|
-
return
|
|
8554
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8547
8555
|
}
|
|
8548
8556
|
|
|
8549
8557
|
// src/resources/resource_time_off_additional.ts
|
|
8550
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8558
|
+
var ResourceTimeOffAdditionalResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8551
8559
|
constructor(http, pageSize) {
|
|
8552
8560
|
super(http, {
|
|
8553
8561
|
key: "resource_time_off_additional",
|
|
@@ -8586,7 +8594,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkD5TVBI4Ucjs.BaseReso
|
|
|
8586
8594
|
};
|
|
8587
8595
|
|
|
8588
8596
|
// src/resources/resource_time_off_approvers.ts
|
|
8589
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8597
|
+
var ResourceTimeOffApproversResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8590
8598
|
constructor(http, pageSize) {
|
|
8591
8599
|
super(http, {
|
|
8592
8600
|
key: "resource_time_off_approvers",
|
|
@@ -8629,29 +8637,29 @@ var ResourceTimeOffApproversResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
8629
8637
|
|
|
8630
8638
|
// src/resources/special/resource_time_off_balances.ts
|
|
8631
8639
|
async function getByResource2(_resource, resourceId, http) {
|
|
8632
|
-
const numericResource =
|
|
8640
|
+
const numericResource = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8633
8641
|
const res = await http.request({
|
|
8634
8642
|
method: "GET",
|
|
8635
8643
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8636
8644
|
operation: "resource_time_off_balances.getByResource"
|
|
8637
8645
|
});
|
|
8638
|
-
return
|
|
8646
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8639
8647
|
}
|
|
8640
8648
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8641
|
-
const numericResource =
|
|
8649
|
+
const numericResource = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8642
8650
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8643
|
-
throw new (0,
|
|
8651
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8644
8652
|
}
|
|
8645
8653
|
const res = await http.request({
|
|
8646
8654
|
method: "GET",
|
|
8647
8655
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8648
8656
|
operation: "resource_time_off_balances.getByYear"
|
|
8649
8657
|
});
|
|
8650
|
-
return
|
|
8658
|
+
return _chunk2H7YI54Bcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
8651
8659
|
}
|
|
8652
8660
|
|
|
8653
8661
|
// src/resources/resource_time_off_balances.ts
|
|
8654
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
8662
|
+
var ResourceTimeOffBalancesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8655
8663
|
constructor(http, pageSize) {
|
|
8656
8664
|
super(http, {
|
|
8657
8665
|
key: "resource_time_off_balances",
|
|
@@ -8689,7 +8697,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkD5TVBI4Ucjs.BaseResour
|
|
|
8689
8697
|
};
|
|
8690
8698
|
|
|
8691
8699
|
// src/resources/roles.ts
|
|
8692
|
-
var RolesResource = class extends
|
|
8700
|
+
var RolesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8693
8701
|
constructor(http, pageSize) {
|
|
8694
8702
|
super(http, {
|
|
8695
8703
|
key: "roles",
|
|
@@ -8751,12 +8759,12 @@ var RolesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8751
8759
|
/** Search Role records: bounded contains on name (no vendor free-text search exists);
|
|
8752
8760
|
* limit defaults to 25, max 500. */
|
|
8753
8761
|
async search(query, opts) {
|
|
8754
|
-
return this.searchBase(query, opts);
|
|
8762
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _86 => _86.limit]) });
|
|
8755
8763
|
}
|
|
8756
8764
|
};
|
|
8757
8765
|
|
|
8758
8766
|
// src/resources/service_calls.ts
|
|
8759
|
-
var ServiceCallsResource = class extends
|
|
8767
|
+
var ServiceCallsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8760
8768
|
constructor(http, pageSize) {
|
|
8761
8769
|
super(http, {
|
|
8762
8770
|
key: "service_calls",
|
|
@@ -8825,7 +8833,7 @@ var ServiceCallsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8825
8833
|
};
|
|
8826
8834
|
|
|
8827
8835
|
// src/resources/service_call_task_resources.ts
|
|
8828
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
8836
|
+
var ServiceCallTaskResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8829
8837
|
constructor(http, pageSize) {
|
|
8830
8838
|
super(http, {
|
|
8831
8839
|
key: "service_call_task_resources",
|
|
@@ -8882,7 +8890,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
8882
8890
|
};
|
|
8883
8891
|
|
|
8884
8892
|
// src/resources/service_call_tasks.ts
|
|
8885
|
-
var ServiceCallTasksResource = class extends
|
|
8893
|
+
var ServiceCallTasksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8886
8894
|
constructor(http, pageSize) {
|
|
8887
8895
|
super(http, {
|
|
8888
8896
|
key: "service_call_tasks",
|
|
@@ -8939,7 +8947,7 @@ var ServiceCallTasksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
8939
8947
|
};
|
|
8940
8948
|
|
|
8941
8949
|
// src/resources/service_call_ticket_resources.ts
|
|
8942
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
8950
|
+
var ServiceCallTicketResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
8943
8951
|
constructor(http, pageSize) {
|
|
8944
8952
|
super(http, {
|
|
8945
8953
|
key: "service_call_ticket_resources",
|
|
@@ -8996,7 +9004,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkD5TVBI4Ucjs.BaseRes
|
|
|
8996
9004
|
};
|
|
8997
9005
|
|
|
8998
9006
|
// src/resources/service_call_tickets.ts
|
|
8999
|
-
var ServiceCallTicketsResource = class extends
|
|
9007
|
+
var ServiceCallTicketsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9000
9008
|
constructor(http, pageSize) {
|
|
9001
9009
|
super(http, {
|
|
9002
9010
|
key: "service_call_tickets",
|
|
@@ -9053,7 +9061,7 @@ var ServiceCallTicketsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9053
9061
|
};
|
|
9054
9062
|
|
|
9055
9063
|
// src/resources/service_level_agreement_results.ts
|
|
9056
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
9064
|
+
var ServiceLevelAgreementResultsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9057
9065
|
constructor(http, pageSize) {
|
|
9058
9066
|
super(http, {
|
|
9059
9067
|
key: "service_level_agreement_results",
|
|
@@ -9092,7 +9100,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkD5TVBI4Ucjs.BaseR
|
|
|
9092
9100
|
};
|
|
9093
9101
|
|
|
9094
9102
|
// src/resources/services.ts
|
|
9095
|
-
var ServicesResource = class extends
|
|
9103
|
+
var ServicesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9096
9104
|
constructor(http, pageSize) {
|
|
9097
9105
|
super(http, {
|
|
9098
9106
|
key: "services",
|
|
@@ -9155,12 +9163,12 @@ var ServicesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9155
9163
|
/** Search Service records: bounded contains on name (no vendor free-text search exists);
|
|
9156
9164
|
* limit defaults to 25, max 500. */
|
|
9157
9165
|
async search(query, opts) {
|
|
9158
|
-
return this.searchBase(query, opts);
|
|
9166
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _87 => _87.limit]) });
|
|
9159
9167
|
}
|
|
9160
9168
|
};
|
|
9161
9169
|
|
|
9162
9170
|
// src/resources/skills.ts
|
|
9163
|
-
var SkillsResource = class extends
|
|
9171
|
+
var SkillsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9164
9172
|
constructor(http, pageSize) {
|
|
9165
9173
|
super(http, {
|
|
9166
9174
|
key: "skills",
|
|
@@ -9199,12 +9207,12 @@ var SkillsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9199
9207
|
/** Search Skill records: bounded contains on name (no vendor free-text search exists);
|
|
9200
9208
|
* limit defaults to 25, max 500. */
|
|
9201
9209
|
async search(query, opts) {
|
|
9202
|
-
return this.searchBase(query, opts);
|
|
9210
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _88 => _88.limit]) });
|
|
9203
9211
|
}
|
|
9204
9212
|
};
|
|
9205
9213
|
|
|
9206
9214
|
// src/resources/subscription_periods.ts
|
|
9207
|
-
var SubscriptionPeriodsResource = class extends
|
|
9215
|
+
var SubscriptionPeriodsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9208
9216
|
constructor(http, pageSize) {
|
|
9209
9217
|
super(http, {
|
|
9210
9218
|
key: "subscription_periods",
|
|
@@ -9243,7 +9251,7 @@ var SubscriptionPeriodsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9243
9251
|
};
|
|
9244
9252
|
|
|
9245
9253
|
// src/resources/subscriptions.ts
|
|
9246
|
-
var SubscriptionsResource = class extends
|
|
9254
|
+
var SubscriptionsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9247
9255
|
constructor(http, pageSize) {
|
|
9248
9256
|
super(http, {
|
|
9249
9257
|
key: "subscriptions",
|
|
@@ -9312,7 +9320,7 @@ var SubscriptionsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9312
9320
|
};
|
|
9313
9321
|
|
|
9314
9322
|
// src/resources/survey_results.ts
|
|
9315
|
-
var SurveyResultsResource = class extends
|
|
9323
|
+
var SurveyResultsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9316
9324
|
constructor(http, pageSize) {
|
|
9317
9325
|
super(http, {
|
|
9318
9326
|
key: "survey_results",
|
|
@@ -9351,7 +9359,7 @@ var SurveyResultsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9351
9359
|
};
|
|
9352
9360
|
|
|
9353
9361
|
// src/resources/surveys.ts
|
|
9354
|
-
var SurveysResource = class extends
|
|
9362
|
+
var SurveysResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9355
9363
|
constructor(http, pageSize) {
|
|
9356
9364
|
super(http, {
|
|
9357
9365
|
key: "surveys",
|
|
@@ -9390,12 +9398,12 @@ var SurveysResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9390
9398
|
/** Search Survey records: bounded contains on name (no vendor free-text search exists);
|
|
9391
9399
|
* limit defaults to 25, max 500. */
|
|
9392
9400
|
async search(query, opts) {
|
|
9393
|
-
return this.searchBase(query, opts);
|
|
9401
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _89 => _89.limit]) });
|
|
9394
9402
|
}
|
|
9395
9403
|
};
|
|
9396
9404
|
|
|
9397
9405
|
// src/resources/tag_aliases.ts
|
|
9398
|
-
var TagAliasesResource = class extends
|
|
9406
|
+
var TagAliasesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9399
9407
|
constructor(http, pageSize) {
|
|
9400
9408
|
super(http, {
|
|
9401
9409
|
key: "tag_aliases",
|
|
@@ -9452,7 +9460,7 @@ var TagAliasesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9452
9460
|
};
|
|
9453
9461
|
|
|
9454
9462
|
// src/resources/tag_groups.ts
|
|
9455
|
-
var TagGroupsResource = class extends
|
|
9463
|
+
var TagGroupsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9456
9464
|
constructor(http, pageSize) {
|
|
9457
9465
|
super(http, {
|
|
9458
9466
|
key: "tag_groups",
|
|
@@ -9521,7 +9529,7 @@ var TagGroupsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9521
9529
|
};
|
|
9522
9530
|
|
|
9523
9531
|
// src/resources/tags.ts
|
|
9524
|
-
var TagsResource = class extends
|
|
9532
|
+
var TagsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9525
9533
|
constructor(http, pageSize) {
|
|
9526
9534
|
super(http, {
|
|
9527
9535
|
key: "tags",
|
|
@@ -9590,7 +9598,7 @@ var TagsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9590
9598
|
};
|
|
9591
9599
|
|
|
9592
9600
|
// src/resources/task_secondary_resources.ts
|
|
9593
|
-
var TaskSecondaryResourcesResource = class extends
|
|
9601
|
+
var TaskSecondaryResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9594
9602
|
constructor(http, pageSize) {
|
|
9595
9603
|
super(http, {
|
|
9596
9604
|
key: "task_secondary_resources",
|
|
@@ -9647,7 +9655,7 @@ var TaskSecondaryResourcesResource = class extends _chunkD5TVBI4Ucjs.BaseResourc
|
|
|
9647
9655
|
};
|
|
9648
9656
|
|
|
9649
9657
|
// src/resources/tasks.ts
|
|
9650
|
-
var TasksResource = class extends
|
|
9658
|
+
var TasksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9651
9659
|
constructor(http, pageSize) {
|
|
9652
9660
|
super(http, {
|
|
9653
9661
|
key: "tasks",
|
|
@@ -9706,7 +9714,7 @@ var TasksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9706
9714
|
/** Search Task records: bounded contains on title (no vendor free-text search exists);
|
|
9707
9715
|
* limit defaults to 25, max 500. */
|
|
9708
9716
|
async search(query, opts) {
|
|
9709
|
-
return this.searchBase(query, opts);
|
|
9717
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _90 => _90.limit]) });
|
|
9710
9718
|
}
|
|
9711
9719
|
};
|
|
9712
9720
|
|
|
@@ -9735,7 +9743,7 @@ var ThresholdInformationResource = class {
|
|
|
9735
9743
|
};
|
|
9736
9744
|
|
|
9737
9745
|
// src/resources/ticket_additional_configuration_items.ts
|
|
9738
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
9746
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9739
9747
|
constructor(http, pageSize) {
|
|
9740
9748
|
super(http, {
|
|
9741
9749
|
key: "ticket_additional_configuration_items",
|
|
@@ -9792,7 +9800,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkD5TVBI4Ucjs
|
|
|
9792
9800
|
};
|
|
9793
9801
|
|
|
9794
9802
|
// src/resources/ticket_additional_contacts.ts
|
|
9795
|
-
var TicketAdditionalContactsResource = class extends
|
|
9803
|
+
var TicketAdditionalContactsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9796
9804
|
constructor(http, pageSize) {
|
|
9797
9805
|
super(http, {
|
|
9798
9806
|
key: "ticket_additional_contacts",
|
|
@@ -9849,7 +9857,7 @@ var TicketAdditionalContactsResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
9849
9857
|
};
|
|
9850
9858
|
|
|
9851
9859
|
// src/resources/ticket_attachments.ts
|
|
9852
|
-
var TicketAttachmentsResource = class extends
|
|
9860
|
+
var TicketAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9853
9861
|
constructor(http, pageSize) {
|
|
9854
9862
|
super(http, {
|
|
9855
9863
|
key: "ticket_attachments",
|
|
@@ -9911,7 +9919,7 @@ var TicketAttachmentsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9911
9919
|
};
|
|
9912
9920
|
|
|
9913
9921
|
// src/resources/ticket_categories.ts
|
|
9914
|
-
var TicketCategoriesResource = class extends
|
|
9922
|
+
var TicketCategoriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9915
9923
|
constructor(http, pageSize) {
|
|
9916
9924
|
super(http, {
|
|
9917
9925
|
key: "ticket_categories",
|
|
@@ -9965,12 +9973,12 @@ var TicketCategoriesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
9965
9973
|
/** Search TicketCategory records: bounded contains on name (no vendor free-text search exists);
|
|
9966
9974
|
* limit defaults to 25, max 500. */
|
|
9967
9975
|
async search(query, opts) {
|
|
9968
|
-
return this.searchBase(query, opts);
|
|
9976
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
|
|
9969
9977
|
}
|
|
9970
9978
|
};
|
|
9971
9979
|
|
|
9972
9980
|
// src/resources/ticket_category_field_defaults.ts
|
|
9973
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
9981
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
9974
9982
|
constructor(http, pageSize) {
|
|
9975
9983
|
super(http, {
|
|
9976
9984
|
key: "ticket_category_field_defaults",
|
|
@@ -10012,7 +10020,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkD5TVBI4Ucjs.BaseRe
|
|
|
10012
10020
|
};
|
|
10013
10021
|
|
|
10014
10022
|
// src/resources/ticket_change_request_approvals.ts
|
|
10015
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
10023
|
+
var TicketChangeRequestApprovalsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10016
10024
|
constructor(http, pageSize) {
|
|
10017
10025
|
super(http, {
|
|
10018
10026
|
key: "ticket_change_request_approvals",
|
|
@@ -10073,10 +10081,10 @@ var _crypto = require('crypto');
|
|
|
10073
10081
|
var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
|
|
10074
10082
|
var TICKET_COMPLETE_STATUS = 5;
|
|
10075
10083
|
var MOVE_EFFECTS_NOTE = "Create then delete: the new record gets a fresh create date and creator; creating/deleting may trigger notifications, SLA and workflow rules the API cannot suppress; vendor acceptance of the create is not validated by a dry run";
|
|
10076
|
-
var refuse = (code, message, ids2, operation, extra = {}) => new (0,
|
|
10084
|
+
var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunk2H7YI54Bcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
|
|
10077
10085
|
async function queryRows(http, resource, filter, operation, retries) {
|
|
10078
10086
|
const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
|
|
10079
|
-
return
|
|
10087
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
10080
10088
|
}
|
|
10081
10089
|
function sameValue(a, b) {
|
|
10082
10090
|
if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
|
|
@@ -10093,10 +10101,10 @@ function sameValue(a, b) {
|
|
|
10093
10101
|
async function readTicket(http, id, retries, operation) {
|
|
10094
10102
|
try {
|
|
10095
10103
|
const res = await http.request({ method: "GET", path: `/V1.0/Tickets/${id}`, operation, maxRetries: retries });
|
|
10096
|
-
const item = _optionalChain([res, 'optionalAccess',
|
|
10104
|
+
const item = _optionalChain([res, 'optionalAccess', _92 => _92.item]);
|
|
10097
10105
|
return _nullishCoalesce(item, () => ( null));
|
|
10098
10106
|
} catch (e) {
|
|
10099
|
-
if (
|
|
10107
|
+
if (_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
10100
10108
|
throw e;
|
|
10101
10109
|
}
|
|
10102
10110
|
}
|
|
@@ -10117,7 +10125,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10117
10125
|
}
|
|
10118
10126
|
}
|
|
10119
10127
|
const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
|
|
10120
|
-
if (!Number.isFinite(cap) || cap < 0) throw new (0,
|
|
10128
|
+
if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
|
|
10121
10129
|
const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
|
|
10122
10130
|
if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
|
|
10123
10131
|
throw refuse("MOVE_SOURCE_TOO_OLD", `${op}: source ${spec.entity} ${sourceId} is older than ${cap} day(s) (or undated) \u2014 move it in the Autotask UI`, ids2, op, { manualAction: manualFor(http, spec, source, "older than the move age limit") });
|
|
@@ -10130,7 +10138,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10130
10138
|
const origin = await readTicket(http, sourceTicketId, opts.maxRetries, op);
|
|
10131
10139
|
const facts = {
|
|
10132
10140
|
sourceTicketId,
|
|
10133
|
-
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess',
|
|
10141
|
+
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _93 => _93.companyID]), () => ( null)),
|
|
10134
10142
|
targetCompanyID: _nullishCoalesce(target.companyID, () => ( null)),
|
|
10135
10143
|
companyChanged: origin === null ? null : origin.companyID !== target.companyID,
|
|
10136
10144
|
contractChanged: origin === null ? null : (_nullishCoalesce(origin.contractID, () => ( null))) !== (_nullishCoalesce(target.contractID, () => ( null)))
|
|
@@ -10152,17 +10160,17 @@ async function assertNoTwin(ctx, payload) {
|
|
|
10152
10160
|
throw refuse("MOVE_TARGET_HAS_TWIN", `${ctx.spec.operation}: target ticket ${ctx.toTicketId} already has an equivalent ${ctx.spec.entity} (id ${String(rows[0].id)}) \u2014 a duplicate or resumed move`, { sourceId: ctx.sourceId, toTicketId: ctx.toTicketId }, ctx.spec.operation, { twinId: rows[0].id });
|
|
10153
10161
|
}
|
|
10154
10162
|
}
|
|
10155
|
-
var statusOf = (e) =>
|
|
10163
|
+
var statusOf = (e) => _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
|
|
10156
10164
|
async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
10157
10165
|
const op = spec.operation;
|
|
10158
|
-
const sourceId = Number(
|
|
10159
|
-
const toTicketId = Number(
|
|
10166
|
+
const sourceId = Number(_chunk2H7YI54Bcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
|
|
10167
|
+
const toTicketId = Number(_chunk2H7YI54Bcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
|
|
10160
10168
|
if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
|
|
10161
|
-
throw new (0,
|
|
10169
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
|
|
10162
10170
|
}
|
|
10163
10171
|
const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
|
|
10164
10172
|
if (opts.dryRun === true) {
|
|
10165
|
-
return
|
|
10173
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
10166
10174
|
{
|
|
10167
10175
|
operation: op,
|
|
10168
10176
|
method: "POST",
|
|
@@ -10187,22 +10195,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10187
10195
|
let newId;
|
|
10188
10196
|
try {
|
|
10189
10197
|
const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
|
|
10190
|
-
newId = Number(
|
|
10198
|
+
newId = Number(_chunk2H7YI54Bcjs.unwrapOperation.call(void 0, created, op).id);
|
|
10191
10199
|
} catch (e) {
|
|
10192
10200
|
const status = statusOf(e);
|
|
10193
10201
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
10194
|
-
throw new (0,
|
|
10202
|
+
throw new (0, _chunk2H7YI54Bcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
|
|
10195
10203
|
}
|
|
10196
|
-
throw new (0,
|
|
10204
|
+
throw new (0, _chunk2H7YI54Bcjs.MoveRefusedError)(`${op}: the create outcome is unknown (never resent) \u2014 check the target ticket for a new ${spec.entity} before retrying; the twin check blocks a second create`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2 } });
|
|
10197
10205
|
}
|
|
10198
10206
|
const rollback = async (code, message) => {
|
|
10199
10207
|
try {
|
|
10200
10208
|
await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
|
|
10201
10209
|
} catch (re) {
|
|
10202
10210
|
const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
|
|
10203
|
-
throw new (0,
|
|
10211
|
+
throw new (0, _chunk2H7YI54Bcjs.MoveRefusedError)(`${op}: ${message}; rolling back the new ${spec.entity} ${newId} FAILED \u2014 both records exist`, { code: unreadable ? "MOVE_UNKNOWN" : "MOVE_PARTIAL", operation: op, details: { status: unreadable ? "unknown" : "partial", ...ids2, newId, reason: code } });
|
|
10204
10212
|
}
|
|
10205
|
-
throw new (0,
|
|
10213
|
+
throw new (0, _chunk2H7YI54Bcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
|
|
10206
10214
|
};
|
|
10207
10215
|
const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
|
|
10208
10216
|
if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
|
|
@@ -10231,14 +10239,14 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10231
10239
|
};
|
|
10232
10240
|
}
|
|
10233
10241
|
if (status === void 0) {
|
|
10234
|
-
throw new (0,
|
|
10242
|
+
throw new (0, _chunk2H7YI54Bcjs.MoveRefusedError)(`${op}: the source delete outcome is unknown (never resent) \u2014 re-read the source: absent means the move completed`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2, newId } });
|
|
10235
10243
|
}
|
|
10236
10244
|
return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
|
|
10237
10245
|
}
|
|
10238
10246
|
return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
|
|
10239
10247
|
}
|
|
10240
10248
|
function uiLinkFor(http, entity, id) {
|
|
10241
|
-
return _nullishCoalesce(
|
|
10249
|
+
return _nullishCoalesce(_chunk2H7YI54Bcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
|
|
10242
10250
|
}
|
|
10243
10251
|
|
|
10244
10252
|
// src/resources/special/ticket_charges.ts
|
|
@@ -10293,7 +10301,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
|
|
|
10293
10301
|
}
|
|
10294
10302
|
|
|
10295
10303
|
// src/resources/ticket_charges.ts
|
|
10296
|
-
var TicketChargesResource = class extends
|
|
10304
|
+
var TicketChargesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10297
10305
|
constructor(http, pageSize) {
|
|
10298
10306
|
super(http, {
|
|
10299
10307
|
key: "ticket_charges",
|
|
@@ -10359,7 +10367,7 @@ var TicketChargesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
10359
10367
|
/** Search TicketCharge records: bounded contains on name (no vendor free-text search exists);
|
|
10360
10368
|
* limit defaults to 25, max 500. */
|
|
10361
10369
|
async search(query, opts) {
|
|
10362
|
-
return this.searchBase(query, opts);
|
|
10370
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _94 => _94.limit]) });
|
|
10363
10371
|
}
|
|
10364
10372
|
/** Node-parity special op (hand-written in src/resources/special/ticket_charges.ts). */
|
|
10365
10373
|
moveToTicket(sourceId, toTicketId, opts = {}) {
|
|
@@ -10368,7 +10376,7 @@ var TicketChargesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
10368
10376
|
};
|
|
10369
10377
|
|
|
10370
10378
|
// src/resources/ticket_checklist_items.ts
|
|
10371
|
-
var TicketChecklistItemsResource = class extends
|
|
10379
|
+
var TicketChecklistItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10372
10380
|
constructor(http, pageSize) {
|
|
10373
10381
|
super(http, {
|
|
10374
10382
|
key: "ticket_checklist_items",
|
|
@@ -10434,7 +10442,7 @@ var TicketChecklistItemsResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
10434
10442
|
};
|
|
10435
10443
|
|
|
10436
10444
|
// src/resources/ticket_checklist_libraries.ts
|
|
10437
|
-
var TicketChecklistLibrariesResource = class extends
|
|
10445
|
+
var TicketChecklistLibrariesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10438
10446
|
constructor(http, pageSize) {
|
|
10439
10447
|
super(http, {
|
|
10440
10448
|
key: "ticket_checklist_libraries",
|
|
@@ -10458,9 +10466,9 @@ var TicketChecklistLibrariesResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
10458
10466
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
10459
10467
|
* surface — no documents read op — and never issues the POST). */
|
|
10460
10468
|
async attachToDocument(documentID, data, opts = {}) {
|
|
10461
|
-
const n =
|
|
10469
|
+
const n = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
10462
10470
|
if (opts.dryRun === true) {
|
|
10463
|
-
return
|
|
10471
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
10464
10472
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10465
10473
|
method: "POST",
|
|
10466
10474
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -10478,7 +10486,7 @@ var TicketChecklistLibrariesResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
10478
10486
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10479
10487
|
maxRetries: opts.maxRetries
|
|
10480
10488
|
});
|
|
10481
|
-
return
|
|
10489
|
+
return _chunk2H7YI54Bcjs.unwrapOperation.call(void 0, res);
|
|
10482
10490
|
}
|
|
10483
10491
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
10484
10492
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10494,7 +10502,7 @@ var TicketChecklistLibrariesResource = class extends _chunkD5TVBI4Ucjs.BaseResou
|
|
|
10494
10502
|
};
|
|
10495
10503
|
|
|
10496
10504
|
// src/resources/ticket_history.ts
|
|
10497
|
-
var TicketHistoryResource = class extends
|
|
10505
|
+
var TicketHistoryResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10498
10506
|
constructor(http, pageSize) {
|
|
10499
10507
|
super(http, {
|
|
10500
10508
|
key: "ticket_history",
|
|
@@ -10533,7 +10541,7 @@ var TicketHistoryResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
10533
10541
|
};
|
|
10534
10542
|
|
|
10535
10543
|
// src/resources/ticket_note_attachments.ts
|
|
10536
|
-
var TicketNoteAttachmentsResource = class extends
|
|
10544
|
+
var TicketNoteAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10537
10545
|
constructor(http, pageSize) {
|
|
10538
10546
|
super(http, {
|
|
10539
10547
|
key: "ticket_note_attachments",
|
|
@@ -10595,7 +10603,7 @@ var TicketNoteAttachmentsResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
10595
10603
|
};
|
|
10596
10604
|
|
|
10597
10605
|
// src/resources/ticket_notes.ts
|
|
10598
|
-
var TicketNotesResource = class extends
|
|
10606
|
+
var TicketNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10599
10607
|
constructor(http, pageSize) {
|
|
10600
10608
|
super(http, {
|
|
10601
10609
|
key: "ticket_notes",
|
|
@@ -10654,7 +10662,7 @@ var TicketNotesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
10654
10662
|
};
|
|
10655
10663
|
|
|
10656
10664
|
// src/resources/ticket_note_webhooks.ts
|
|
10657
|
-
var TicketNoteWebhooksResource = class extends
|
|
10665
|
+
var TicketNoteWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10658
10666
|
constructor(http, pageSize) {
|
|
10659
10667
|
super(http, {
|
|
10660
10668
|
key: "ticket_note_webhooks",
|
|
@@ -10725,12 +10733,12 @@ var TicketNoteWebhooksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
10725
10733
|
/** Search TicketNoteWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
10726
10734
|
* limit defaults to 25, max 500. */
|
|
10727
10735
|
async search(query, opts) {
|
|
10728
|
-
return this.searchBase(query, opts);
|
|
10736
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
|
|
10729
10737
|
}
|
|
10730
10738
|
};
|
|
10731
10739
|
|
|
10732
10740
|
// src/resources/ticket_secondary_resources.ts
|
|
10733
|
-
var TicketSecondaryResourcesResource = class extends
|
|
10741
|
+
var TicketSecondaryResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
10734
10742
|
constructor(http, pageSize) {
|
|
10735
10743
|
super(http, {
|
|
10736
10744
|
key: "ticket_secondary_resources",
|
|
@@ -10795,9 +10803,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
10795
10803
|
});
|
|
10796
10804
|
const body = res;
|
|
10797
10805
|
if (body === null || !("item" in body)) {
|
|
10798
|
-
throw new (0,
|
|
10806
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
10799
10807
|
}
|
|
10800
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
10808
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
10801
10809
|
return body.item;
|
|
10802
10810
|
}
|
|
10803
10811
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -10808,7 +10816,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
10808
10816
|
body: { MaxRecords: maxRecords, filter },
|
|
10809
10817
|
operation
|
|
10810
10818
|
});
|
|
10811
|
-
return
|
|
10819
|
+
return _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res).items;
|
|
10812
10820
|
}
|
|
10813
10821
|
function truncate(text, limit) {
|
|
10814
10822
|
const full = _nullishCoalesce(text, () => ( ""));
|
|
@@ -10818,26 +10826,26 @@ function truncate(text, limit) {
|
|
|
10818
10826
|
|
|
10819
10827
|
// src/resources/special/tickets/childRead.ts
|
|
10820
10828
|
function isRouteUnavailable(err) {
|
|
10821
|
-
return
|
|
10829
|
+
return _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
10822
10830
|
}
|
|
10823
10831
|
function routeFact(route, path, err) {
|
|
10824
10832
|
return {
|
|
10825
10833
|
route,
|
|
10826
10834
|
path,
|
|
10827
|
-
httpStatus:
|
|
10835
|
+
httpStatus: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
10828
10836
|
};
|
|
10829
10837
|
}
|
|
10830
10838
|
function childDeclaresQuery(resourceKey) {
|
|
10831
|
-
return
|
|
10839
|
+
return _chunkWBMRACCVcjs.CAPABILITIES.some(
|
|
10832
10840
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
10833
10841
|
);
|
|
10834
10842
|
}
|
|
10835
10843
|
function planScopedPath(resourceKey, ticketId) {
|
|
10836
10844
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
10837
|
-
const entry =
|
|
10845
|
+
const entry = _chunk2H7YI54Bcjs.RELATIONSHIP_MAP[resourceKey];
|
|
10838
10846
|
const parent = entry === void 0 ? null : entry.parent;
|
|
10839
10847
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
10840
|
-
const parentPath = _optionalChain([
|
|
10848
|
+
const parentPath = _optionalChain([_chunk2H7YI54Bcjs.RELATIONSHIP_MAP, 'access', _96 => _96[parent.resource], 'optionalAccess', _97 => _97.path]);
|
|
10841
10849
|
if (parentPath === null || parentPath === void 0) return null;
|
|
10842
10850
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
10843
10851
|
}
|
|
@@ -10876,14 +10884,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
10876
10884
|
break;
|
|
10877
10885
|
}
|
|
10878
10886
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
10879
|
-
const { items: pageItems, pageDetails } =
|
|
10887
|
+
const { items: pageItems, pageDetails } = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, body, operation);
|
|
10880
10888
|
nextCursor = pageDetails.nextPageUrl;
|
|
10881
10889
|
pages += 1;
|
|
10882
10890
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
10883
10891
|
for (const row of window) if (accept(row)) items.push(row);
|
|
10884
10892
|
if (items.length >= limit) break;
|
|
10885
10893
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
10886
|
-
target =
|
|
10894
|
+
target = _chunk2H7YI54Bcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
10887
10895
|
}
|
|
10888
10896
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
10889
10897
|
return { items, capped };
|
|
@@ -10916,7 +10924,7 @@ var MS = 864e5;
|
|
|
10916
10924
|
var SLA_PAGE = 100;
|
|
10917
10925
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
10918
10926
|
void opts;
|
|
10919
|
-
const ticketId =
|
|
10927
|
+
const ticketId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
10920
10928
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
10921
10929
|
const rows = await ticketQueryItems(
|
|
10922
10930
|
http,
|
|
@@ -10941,9 +10949,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
10941
10949
|
async function summary(_resource, id, opts = {}, http) {
|
|
10942
10950
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
10943
10951
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
10944
|
-
throw new (0,
|
|
10952
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
10945
10953
|
}
|
|
10946
|
-
const ticketId =
|
|
10954
|
+
const ticketId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
10947
10955
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
10948
10956
|
const desc = truncate(ticket.description, limit);
|
|
10949
10957
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -10972,11 +10980,11 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
10972
10980
|
// src/resources/special/tickets/timeline.ts
|
|
10973
10981
|
function validateTimelineLimits(opts) {
|
|
10974
10982
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
10975
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
10983
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
10976
10984
|
const bounded = Math.min(limit, 500);
|
|
10977
10985
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
10978
10986
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
10979
|
-
throw new (0,
|
|
10987
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
10980
10988
|
}
|
|
10981
10989
|
return { bounded, textLimit };
|
|
10982
10990
|
}
|
|
@@ -11028,7 +11036,7 @@ function compareEventDates(a, b) {
|
|
|
11028
11036
|
}
|
|
11029
11037
|
async function timeline(_resource, id, opts = {}, http) {
|
|
11030
11038
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
11031
|
-
const ticketId =
|
|
11039
|
+
const ticketId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
11032
11040
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
11033
11041
|
const dateFilters = (field) => {
|
|
11034
11042
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11068,7 +11076,7 @@ async function timeline(_resource, id, opts = {}, http) {
|
|
|
11068
11076
|
}
|
|
11069
11077
|
|
|
11070
11078
|
// src/resources/special/tickets/errors.ts
|
|
11071
|
-
var QueueRequiredError = class extends
|
|
11079
|
+
var QueueRequiredError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11072
11080
|
constructor(message, options = {}) {
|
|
11073
11081
|
super(message, {
|
|
11074
11082
|
code: "QUEUE_REQUIRED",
|
|
@@ -11079,13 +11087,13 @@ var QueueRequiredError = class extends _chunkD5TVBI4Ucjs.AutotaskError {
|
|
|
11079
11087
|
this.name = "QueueRequiredError";
|
|
11080
11088
|
}
|
|
11081
11089
|
};
|
|
11082
|
-
var TicketResourceInvalidError = class extends
|
|
11090
|
+
var TicketResourceInvalidError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11083
11091
|
constructor(message, options = {}) {
|
|
11084
11092
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11085
11093
|
this.name = "TicketResourceInvalidError";
|
|
11086
11094
|
}
|
|
11087
11095
|
};
|
|
11088
|
-
var TicketCreateValidationFailedError = class extends
|
|
11096
|
+
var TicketCreateValidationFailedError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11089
11097
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
11090
11098
|
|
|
11091
11099
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -11094,7 +11102,7 @@ var TicketCreateValidationFailedError = class extends _chunkD5TVBI4Ucjs.Autotask
|
|
|
11094
11102
|
this.vendorFields = vendorFields;
|
|
11095
11103
|
}
|
|
11096
11104
|
};
|
|
11097
|
-
var StatusUnknownError = class extends
|
|
11105
|
+
var StatusUnknownError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11098
11106
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
11099
11107
|
|
|
11100
11108
|
constructor(message, options = {}) {
|
|
@@ -11108,7 +11116,7 @@ var StatusUnknownError = class extends _chunkD5TVBI4Ucjs.AutotaskError {
|
|
|
11108
11116
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
11109
11117
|
}
|
|
11110
11118
|
};
|
|
11111
|
-
var StatusFieldsRequiredError = class extends
|
|
11119
|
+
var StatusFieldsRequiredError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11112
11120
|
|
|
11113
11121
|
|
|
11114
11122
|
|
|
@@ -11131,21 +11139,21 @@ function isPositiveInt(v) {
|
|
|
11131
11139
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
11132
11140
|
}
|
|
11133
11141
|
function namedVendorFields(err) {
|
|
11134
|
-
if (!
|
|
11135
|
-
const entries = _nullishCoalesce(
|
|
11142
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
11143
|
+
const entries = _nullishCoalesce(_chunk2H7YI54Bcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
11136
11144
|
const out = /* @__PURE__ */ new Set();
|
|
11137
11145
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
11138
11146
|
return [...out];
|
|
11139
11147
|
}
|
|
11140
11148
|
function vendorDetailOf(err) {
|
|
11141
|
-
return
|
|
11149
|
+
return _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? _chunk2H7YI54Bcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
11142
11150
|
}
|
|
11143
11151
|
async function fetchItem(http, path, operation, readOpts) {
|
|
11144
|
-
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11152
|
+
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _98 => _98.maxRetries]) });
|
|
11145
11153
|
return unwrapItemOrNull(res);
|
|
11146
11154
|
}
|
|
11147
11155
|
async function fetchItemUnredacted(http, path, operation, readOpts) {
|
|
11148
|
-
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11156
|
+
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _99 => _99.maxRetries]) });
|
|
11149
11157
|
return unwrapItemOrNull(res);
|
|
11150
11158
|
}
|
|
11151
11159
|
function unwrapItemOrNull(res) {
|
|
@@ -11159,8 +11167,8 @@ function operationId(res) {
|
|
|
11159
11167
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
11160
11168
|
}
|
|
11161
11169
|
function discoveryMerge(err, body, defaults) {
|
|
11162
|
-
if (!
|
|
11163
|
-
const entries =
|
|
11170
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11171
|
+
const entries = _chunk2H7YI54Bcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11164
11172
|
if (entries === void 0) return null;
|
|
11165
11173
|
for (const entry of entries) {
|
|
11166
11174
|
const field = entry.field;
|
|
@@ -11172,7 +11180,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
11172
11180
|
}
|
|
11173
11181
|
function stepErrorText(code, err) {
|
|
11174
11182
|
const detail = vendorDetailOf(err);
|
|
11175
|
-
const base =
|
|
11183
|
+
const base = _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
11176
11184
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
11177
11185
|
}
|
|
11178
11186
|
|
|
@@ -11184,43 +11192,43 @@ var DEFAULT_PUBLISH = 1;
|
|
|
11184
11192
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
11185
11193
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
11186
11194
|
function validateOpenInput(params, note, assign) {
|
|
11187
|
-
const companyID =
|
|
11188
|
-
const title = _optionalChain([params, 'optionalAccess',
|
|
11195
|
+
const companyID = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _100 => _100.companyID]), "params.companyID");
|
|
11196
|
+
const title = _optionalChain([params, 'optionalAccess', _101 => _101.title]);
|
|
11189
11197
|
if (typeof title !== "string" || title.trim() === "") {
|
|
11190
|
-
throw new (0,
|
|
11198
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
11191
11199
|
}
|
|
11192
11200
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
11193
11201
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
11194
11202
|
if (!isPositiveInt(priority)) {
|
|
11195
|
-
throw new (0,
|
|
11203
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
11196
11204
|
}
|
|
11197
11205
|
if (!isPositiveInt(status)) {
|
|
11198
|
-
throw new (0,
|
|
11206
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
11199
11207
|
}
|
|
11200
11208
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
11201
|
-
throw new (0,
|
|
11209
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
11202
11210
|
}
|
|
11203
11211
|
if (note !== void 0) {
|
|
11204
11212
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
11205
|
-
throw new (0,
|
|
11213
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
11206
11214
|
}
|
|
11207
11215
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
11208
|
-
throw new (0,
|
|
11216
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("openWithNoteAndAssign: note.title is required (a non-empty string) \u2014 the ww29 scoped note create 500s without it (S12-A live-verified: Missing Required Field: title; the S11-B proven note body is { title, description, noteType: 1, publish: 1 })", { operation: OP_OPEN });
|
|
11209
11217
|
}
|
|
11210
11218
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
11211
|
-
throw new (0,
|
|
11219
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
11212
11220
|
}
|
|
11213
11221
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
11214
|
-
throw new (0,
|
|
11222
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
11215
11223
|
}
|
|
11216
11224
|
}
|
|
11217
|
-
const assignee = assign === void 0 ? void 0 :
|
|
11225
|
+
const assignee = assign === void 0 ? void 0 : _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
11218
11226
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
11219
|
-
throw new (0,
|
|
11227
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
11220
11228
|
}
|
|
11221
|
-
const roleID = _optionalChain([assign, 'optionalAccess',
|
|
11229
|
+
const roleID = _optionalChain([assign, 'optionalAccess', _102 => _102.roleID]);
|
|
11222
11230
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
11223
|
-
throw new (0,
|
|
11231
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("openWithNoteAndAssign: assign.roleID is required (a positive integer) \u2014 the ww29 vendor requires BOTH assignedResourceID and assignedResourceRoleID when assigning a resource (S12-A live-verified: Data violation: When assigning a Resource, you must assign both a assignedResourceID and assignedResourceRoleID)", { operation: OP_OPEN });
|
|
11224
11232
|
}
|
|
11225
11233
|
return { companyID, title, priority, status, assignee, roleID };
|
|
11226
11234
|
}
|
|
@@ -11249,7 +11257,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
|
|
|
11249
11257
|
if (assign !== void 0) {
|
|
11250
11258
|
warnings.push(`the assignment is the v0.6.0 MERGE update (unredacted GET + collection PUT, 2 wire) setting assignedResourceID ${String(assignee)} + assignedResourceRoleID ${String(roleID)} (the vendor requires both \u2014 S12-A live-verified); a failure lands in steps[] as ASSIGN_FAILED (the applied ticketId is still returned).`);
|
|
11251
11259
|
}
|
|
11252
|
-
return
|
|
11260
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
11253
11261
|
{
|
|
11254
11262
|
operation: OP_OPEN,
|
|
11255
11263
|
method: "POST",
|
|
@@ -11289,8 +11297,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11289
11297
|
`openWithNoteAndAssign: the vendor rejected the ticket create naming 'queueID' (the ww29 live-required set is { title, status, priority, companyID, queueID }) and the node never guesses a queue${detail ? ` \u2014 ${detail}` : ""}`,
|
|
11290
11298
|
{
|
|
11291
11299
|
operation: OP_OPEN,
|
|
11292
|
-
httpStatus:
|
|
11293
|
-
vendorError:
|
|
11300
|
+
httpStatus: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11301
|
+
vendorError: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
11294
11302
|
}
|
|
11295
11303
|
);
|
|
11296
11304
|
}
|
|
@@ -11305,8 +11313,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11305
11313
|
named,
|
|
11306
11314
|
{
|
|
11307
11315
|
operation: OP_OPEN,
|
|
11308
|
-
httpStatus:
|
|
11309
|
-
vendorError:
|
|
11316
|
+
httpStatus: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11317
|
+
vendorError: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11310
11318
|
resourceIds: [companyID],
|
|
11311
11319
|
details: { idRefs: [{ entity: "company", id: companyID }] }
|
|
11312
11320
|
}
|
|
@@ -11331,10 +11339,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
|
|
|
11331
11339
|
try {
|
|
11332
11340
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
11333
11341
|
if (current === null) {
|
|
11334
|
-
throw new (0,
|
|
11342
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11335
11343
|
}
|
|
11336
11344
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
11337
|
-
const merged =
|
|
11345
|
+
const merged = _chunk2H7YI54Bcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
11338
11346
|
merged.id = ticketId;
|
|
11339
11347
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
11340
11348
|
assigned = true;
|
|
@@ -11398,17 +11406,17 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11398
11406
|
const ids2 = await readLiveStatusSet(resource);
|
|
11399
11407
|
if (ids2.size > 0) liveStatus = ids2;
|
|
11400
11408
|
} catch (err) {
|
|
11401
|
-
if (!
|
|
11409
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11402
11410
|
}
|
|
11403
11411
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
11404
|
-
_optionalChain([http, 'access',
|
|
11412
|
+
_optionalChain([http, 'access', _103 => _103.fieldCache, 'optionalAccess', _104 => _104.invalidate, 'call', _105 => _105("tickets")]);
|
|
11405
11413
|
let freshStatus = null;
|
|
11406
11414
|
let reReadFailed = false;
|
|
11407
11415
|
try {
|
|
11408
11416
|
const freshIds = await readLiveStatusSet(resource);
|
|
11409
11417
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
11410
11418
|
} catch (err) {
|
|
11411
|
-
if (!
|
|
11419
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11412
11420
|
freshStatus = null;
|
|
11413
11421
|
reReadFailed = true;
|
|
11414
11422
|
}
|
|
@@ -11426,7 +11434,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11426
11434
|
return { guardDegraded: liveStatus === null };
|
|
11427
11435
|
}
|
|
11428
11436
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
11429
|
-
return
|
|
11437
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
11430
11438
|
{
|
|
11431
11439
|
operation: OP_STATUS,
|
|
11432
11440
|
method: "PUT",
|
|
@@ -11457,7 +11465,7 @@ function resolveMergeData(ticketId, targetStatus, previousStatus, current, field
|
|
|
11457
11465
|
for (const field of mapEntry.requiredFields) {
|
|
11458
11466
|
if (mergeData[field] !== void 0) continue;
|
|
11459
11467
|
if (current[field] !== null && current[field] !== void 0) continue;
|
|
11460
|
-
const safe = _optionalChain([mapEntry, 'access',
|
|
11468
|
+
const safe = _optionalChain([mapEntry, 'access', _106 => _106.safeDefaults, 'optionalAccess', _107 => _107[field]]);
|
|
11461
11469
|
if (safe === void 0) {
|
|
11462
11470
|
throw new StatusFieldsRequiredError(
|
|
11463
11471
|
`changeStatus: status ${targetStatus} requires the field '${field}' and the live-discovered map has no proven-safe default for it \u2014 the op is safe-without-the-map (never a blind full update): supply the value in fields and retry`,
|
|
@@ -11480,7 +11488,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11480
11488
|
if (mapEntry === void 0) {
|
|
11481
11489
|
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).`);
|
|
11482
11490
|
}
|
|
11483
|
-
return
|
|
11491
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
11484
11492
|
{
|
|
11485
11493
|
operation: OP_STATUS,
|
|
11486
11494
|
method: "PUT",
|
|
@@ -11499,8 +11507,8 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11499
11507
|
);
|
|
11500
11508
|
}
|
|
11501
11509
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
11502
|
-
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess',
|
|
11503
|
-
const body =
|
|
11510
|
+
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _108 => _108.safeDefaults]), () => ( {}));
|
|
11511
|
+
const body = _chunk2H7YI54Bcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
11504
11512
|
body.id = ticketId;
|
|
11505
11513
|
let merges = 0;
|
|
11506
11514
|
for (; ; ) {
|
|
@@ -11524,8 +11532,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11524
11532
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
11525
11533
|
{
|
|
11526
11534
|
operation: OP_STATUS,
|
|
11527
|
-
httpStatus:
|
|
11528
|
-
vendorError:
|
|
11535
|
+
httpStatus: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11536
|
+
vendorError: _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11529
11537
|
resourceIds: [ticketId],
|
|
11530
11538
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
11531
11539
|
}
|
|
@@ -11538,7 +11546,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11538
11546
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
11539
11547
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11540
11548
|
if (verify === null) {
|
|
11541
|
-
throw new (0,
|
|
11549
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
11542
11550
|
code: "INVALID_RESPONSE",
|
|
11543
11551
|
category: "server",
|
|
11544
11552
|
operation: OP_STATUS,
|
|
@@ -11548,7 +11556,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11548
11556
|
}
|
|
11549
11557
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
11550
11558
|
if (finalStatus !== targetStatus) {
|
|
11551
|
-
throw new (0,
|
|
11559
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskError)(
|
|
11552
11560
|
`changeStatus: the post-PUT read-back shows status ${_nullishCoalesce(finalStatus, () => ( "unknown"))} (the vendor 200ed the PUT but did not apply ${targetStatus} \u2014 the F-A1 lesson: the 200 proves nothing)`,
|
|
11553
11561
|
{
|
|
11554
11562
|
code: "INVALID_RESPONSE",
|
|
@@ -11563,17 +11571,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11563
11571
|
}
|
|
11564
11572
|
}
|
|
11565
11573
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
11566
|
-
const ticketId =
|
|
11574
|
+
const ticketId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
11567
11575
|
if (!isPositiveInt(targetStatus)) {
|
|
11568
|
-
throw new (0,
|
|
11576
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
11569
11577
|
}
|
|
11570
11578
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
11571
11579
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
11572
|
-
throw new (0,
|
|
11580
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
11573
11581
|
}
|
|
11574
11582
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11575
11583
|
if (current === null) {
|
|
11576
|
-
throw new (0,
|
|
11584
|
+
throw new (0, _chunk2H7YI54Bcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11577
11585
|
}
|
|
11578
11586
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
11579
11587
|
if (previousStatus === targetStatus) {
|
|
@@ -11593,7 +11601,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
11593
11601
|
function partLimit(value, name) {
|
|
11594
11602
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
11595
11603
|
if (!Number.isInteger(n) || n < 1) {
|
|
11596
|
-
throw new (0,
|
|
11604
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
11597
11605
|
}
|
|
11598
11606
|
return n;
|
|
11599
11607
|
}
|
|
@@ -11606,7 +11614,7 @@ function servedTextRecord(row, textField, limit) {
|
|
|
11606
11614
|
return out;
|
|
11607
11615
|
}
|
|
11608
11616
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
11609
|
-
const builder =
|
|
11617
|
+
const builder = _chunk2H7YI54Bcjs.createNamePlan.call(void 0, _chunk2H7YI54Bcjs.TICKET_LABEL_FIELDS);
|
|
11610
11618
|
const t = ctx.ticket;
|
|
11611
11619
|
builder.addResource(t["creatorResourceID"]);
|
|
11612
11620
|
builder.addFk("contract", t["contractID"]);
|
|
@@ -11618,20 +11626,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
|
11618
11626
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
11619
11627
|
builder.addFk("contract", e["contractID"]);
|
|
11620
11628
|
}
|
|
11621
|
-
const names = await
|
|
11629
|
+
const names = await _chunk2H7YI54Bcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
11622
11630
|
const ticketRow = { ...ctx.ticket };
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
for (const f of
|
|
11631
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
11632
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
11633
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11634
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
11635
|
+
for (const f of _chunk2H7YI54Bcjs.TICKET_LABEL_FIELDS) _chunk2H7YI54Bcjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
11628
11636
|
result.ticket = ticketRow;
|
|
11629
11637
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
11630
11638
|
const row = { ...e };
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11639
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
11640
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
11641
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11642
|
+
_chunk2H7YI54Bcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
11635
11643
|
return row;
|
|
11636
11644
|
});
|
|
11637
11645
|
result.names = names.section;
|
|
@@ -11641,7 +11649,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11641
11649
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
11642
11650
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
11643
11651
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
11644
|
-
const ticketId =
|
|
11652
|
+
const ticketId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
11645
11653
|
const ctx = await resource.getContext(ticketId);
|
|
11646
11654
|
const op = "tickets.fullContext";
|
|
11647
11655
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11699,7 +11707,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11699
11707
|
}
|
|
11700
11708
|
|
|
11701
11709
|
// src/resources/tickets.ts
|
|
11702
|
-
var TicketsResource = class extends
|
|
11710
|
+
var TicketsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
11703
11711
|
constructor(http, pageSize) {
|
|
11704
11712
|
super(http, {
|
|
11705
11713
|
key: "tickets",
|
|
@@ -11763,7 +11771,8 @@ var TicketsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
11763
11771
|
return this.findByField("ticketNumber", value);
|
|
11764
11772
|
}
|
|
11765
11773
|
/** Search Ticket records: bounded contains on title (no vendor free-text search exists);
|
|
11766
|
-
* limit defaults to 25, max 500.
|
|
11774
|
+
* limit defaults to 25, max 500. Optional companyID scopes the search to one company's tickets (and-joined
|
|
11775
|
+
* with the title match, server-side); includeFields projects the returned columns (id is always returned). */
|
|
11767
11776
|
async search(query, opts) {
|
|
11768
11777
|
return this.searchBase(query, opts);
|
|
11769
11778
|
}
|
|
@@ -11805,7 +11814,7 @@ var TicketsResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
11805
11814
|
};
|
|
11806
11815
|
|
|
11807
11816
|
// src/resources/ticket_webhooks.ts
|
|
11808
|
-
var TicketWebhooksResource = class extends
|
|
11817
|
+
var TicketWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
11809
11818
|
constructor(http, pageSize) {
|
|
11810
11819
|
super(http, {
|
|
11811
11820
|
key: "ticket_webhooks",
|
|
@@ -11876,7 +11885,7 @@ var TicketWebhooksResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
11876
11885
|
/** Search TicketWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
11877
11886
|
* limit defaults to 25, max 500. */
|
|
11878
11887
|
async search(query, opts) {
|
|
11879
|
-
return this.searchBase(query, opts);
|
|
11888
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _109 => _109.limit]) });
|
|
11880
11889
|
}
|
|
11881
11890
|
};
|
|
11882
11891
|
|
|
@@ -11891,62 +11900,62 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
11891
11900
|
body: { MaxRecords: limit, filter },
|
|
11892
11901
|
operation
|
|
11893
11902
|
});
|
|
11894
|
-
const { items, pageDetails } =
|
|
11903
|
+
const { items, pageDetails } = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res);
|
|
11895
11904
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
11896
11905
|
}
|
|
11897
11906
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
11898
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
11899
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
11900
|
-
const { from, to } =
|
|
11907
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _110 => _110.now]), () => ( /* @__PURE__ */ new Date()));
|
|
11908
|
+
const tz = _optionalChain([opts, 'optionalAccess', _111 => _111.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
|
|
11909
|
+
const { from, to } = dateOnlyWindowBounds(kind, now, tz);
|
|
11901
11910
|
const filter = [
|
|
11902
11911
|
{ field: "dateWorked", op: "gte", value: from },
|
|
11903
11912
|
{ field: "dateWorked", op: "lte", value: to }
|
|
11904
11913
|
];
|
|
11905
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11914
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _112 => _112.limit])), `time_entries.${kind}`, http);
|
|
11906
11915
|
return items;
|
|
11907
11916
|
}
|
|
11908
11917
|
async function customRange3(_resource, from, to, http, opts) {
|
|
11909
|
-
|
|
11910
|
-
const fromB = customRangeDay(from, "from",
|
|
11911
|
-
const toB = customRangeDay(to, "to",
|
|
11918
|
+
if (_optionalChain([opts, 'optionalAccess', _113 => _113.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
|
|
11919
|
+
const fromB = customRangeDay(from, "from", void 0, "customRange");
|
|
11920
|
+
const toB = customRangeDay(to, "to", void 0, "customRange");
|
|
11912
11921
|
if (fromB.ms > toB.ms) {
|
|
11913
|
-
throw new (0,
|
|
11922
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
11914
11923
|
}
|
|
11915
|
-
const toEndMs =
|
|
11924
|
+
const toEndMs = toB.ms + DAY_MS2 - 1;
|
|
11916
11925
|
const filter = [
|
|
11917
11926
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11918
11927
|
{ field: "dateWorked", op: "lte", value: iso2(toEndMs) }
|
|
11919
11928
|
];
|
|
11920
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11929
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _114 => _114.limit])), "time_entries.customRange", http);
|
|
11921
11930
|
return items;
|
|
11922
11931
|
}
|
|
11923
11932
|
async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
11924
11933
|
const filter = [
|
|
11925
11934
|
{ field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
|
|
11926
11935
|
];
|
|
11927
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11936
|
+
if (_optionalChain([opts, 'optionalAccess', _115 => _115.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11928
11937
|
const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
|
|
11929
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11938
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _116 => _116.limit])), operation, http);
|
|
11930
11939
|
return items;
|
|
11931
11940
|
}
|
|
11932
11941
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
11933
|
-
const
|
|
11934
|
-
|
|
11935
|
-
const fromB = customRangeDay(from, "from",
|
|
11936
|
-
const toB = customRangeDay(to, "to",
|
|
11942
|
+
const OP6 = opLabel;
|
|
11943
|
+
if (_optionalChain([opts, 'optionalAccess', _117 => _117.tz]) !== void 0) validateZone(opts.tz, OP6);
|
|
11944
|
+
const fromB = customRangeDay(from, "from", void 0, OP6);
|
|
11945
|
+
const toB = customRangeDay(to, "to", void 0, OP6);
|
|
11937
11946
|
if (fromB.ms > toB.ms) {
|
|
11938
|
-
throw new (0,
|
|
11947
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${OP6}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP6 });
|
|
11939
11948
|
}
|
|
11940
|
-
const windowToMs =
|
|
11949
|
+
const windowToMs = toB.ms + DAY_MS2 - 1;
|
|
11941
11950
|
const filter = [
|
|
11942
11951
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11943
11952
|
{ field: "dateWorked", op: "lte", value: iso2(windowToMs) }
|
|
11944
11953
|
];
|
|
11945
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11946
|
-
else if (_optionalChain([opts, 'optionalAccess',
|
|
11947
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11948
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11949
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11954
|
+
if (_optionalChain([opts, 'optionalAccess', _118 => _118.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
|
|
11955
|
+
else if (_optionalChain([opts, 'optionalAccess', _119 => _119.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
11956
|
+
if (_optionalChain([opts, 'optionalAccess', _120 => _120.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11957
|
+
if (_optionalChain([opts, 'optionalAccess', _121 => _121.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
11958
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _122 => _122.limit])), OP6, http);
|
|
11950
11959
|
let postedCount = 0;
|
|
11951
11960
|
for (const item of items) {
|
|
11952
11961
|
const postedDate = item.postedDate;
|
|
@@ -11969,13 +11978,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
|
|
|
11969
11978
|
}
|
|
11970
11979
|
|
|
11971
11980
|
// src/resources/special/time_entries/errors.ts
|
|
11972
|
-
var ResourceInvalidError = class extends
|
|
11981
|
+
var ResourceInvalidError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11973
11982
|
constructor(message, options = {}) {
|
|
11974
11983
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11975
11984
|
this.name = "ResourceInvalidError";
|
|
11976
11985
|
}
|
|
11977
11986
|
};
|
|
11978
|
-
var AllocationCodeError = class extends
|
|
11987
|
+
var AllocationCodeError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11979
11988
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
11980
11989
|
|
|
11981
11990
|
constructor(kind, message, options = {}) {
|
|
@@ -11984,7 +11993,7 @@ var AllocationCodeError = class extends _chunkD5TVBI4Ucjs.AutotaskError {
|
|
|
11984
11993
|
this.kind = kind;
|
|
11985
11994
|
}
|
|
11986
11995
|
};
|
|
11987
|
-
var NoApplicableAllocationCodeError = class extends
|
|
11996
|
+
var NoApplicableAllocationCodeError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
11988
11997
|
/** The structured blocker details (filters tried + department sets). */
|
|
11989
11998
|
|
|
11990
11999
|
constructor(details, options = {}) {
|
|
@@ -12049,7 +12058,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12049
12058
|
let pages = 0;
|
|
12050
12059
|
for (; ; ) {
|
|
12051
12060
|
if (pages >= PAGE_GUARD) {
|
|
12052
|
-
throw new (0,
|
|
12061
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
12053
12062
|
code: "RESOLUTION_TRUNCATED",
|
|
12054
12063
|
category: "resolution",
|
|
12055
12064
|
operation,
|
|
@@ -12060,11 +12069,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12060
12069
|
const res = await http.request({
|
|
12061
12070
|
method: "POST",
|
|
12062
12071
|
idempotent: true,
|
|
12063
|
-
path: isFirst ? path :
|
|
12072
|
+
path: isFirst ? path : _chunk2H7YI54Bcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
12064
12073
|
body: { MaxRecords: pageSize, filter },
|
|
12065
12074
|
operation
|
|
12066
12075
|
});
|
|
12067
|
-
const { items: pageItems, pageDetails } =
|
|
12076
|
+
const { items: pageItems, pageDetails } = _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, operation);
|
|
12068
12077
|
items.push(...pageItems);
|
|
12069
12078
|
pages += 1;
|
|
12070
12079
|
if (items.length >= totalCap) break;
|
|
@@ -12181,7 +12190,7 @@ function windowDefaults(params) {
|
|
|
12181
12190
|
var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
|
|
12182
12191
|
var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
|
|
12183
12192
|
function validateCreateParams(params) {
|
|
12184
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
12193
|
+
const pin = (value, label) => typeof value === "number" ? _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
12185
12194
|
const pins = {
|
|
12186
12195
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
12187
12196
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -12190,19 +12199,19 @@ function validateCreateParams(params) {
|
|
|
12190
12199
|
};
|
|
12191
12200
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
12192
12201
|
if (pinCount > 1) {
|
|
12193
|
-
throw new (0,
|
|
12202
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
12194
12203
|
"createForResource: exactly one linkage pin is honoured (internallAllocationCodeID | ticketID | taskID) \u2014 the vendor gate requires exactly one; pass one pin (or none for the default internal linkage)",
|
|
12195
12204
|
{ operation: OP3 }
|
|
12196
12205
|
);
|
|
12197
12206
|
}
|
|
12198
12207
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
12199
|
-
throw new (0,
|
|
12208
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
12200
12209
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
12201
12210
|
{ operation: OP3 }
|
|
12202
12211
|
);
|
|
12203
12212
|
}
|
|
12204
12213
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
12205
|
-
throw new (0,
|
|
12214
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(
|
|
12206
12215
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
12207
12216
|
{ operation: OP3 }
|
|
12208
12217
|
);
|
|
@@ -12285,7 +12294,7 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
|
|
|
12285
12294
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
12286
12295
|
warnings.push("the task had zero applicable general allocation codes \u2014 the linkage fell back to internal (the sanctioned fallback; no taskID/roleID in the body).");
|
|
12287
12296
|
}
|
|
12288
|
-
return
|
|
12297
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0,
|
|
12289
12298
|
{
|
|
12290
12299
|
operation: OP3,
|
|
12291
12300
|
method: "POST",
|
|
@@ -12325,7 +12334,7 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12325
12334
|
};
|
|
12326
12335
|
} catch (err) {
|
|
12327
12336
|
lastError = err;
|
|
12328
|
-
const text =
|
|
12337
|
+
const text = _chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunk2H7YI54Bcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
12329
12338
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
12330
12339
|
if (usedLinkage !== "internal" && gate3) {
|
|
12331
12340
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
@@ -12345,13 +12354,13 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12345
12354
|
throw err;
|
|
12346
12355
|
}
|
|
12347
12356
|
}
|
|
12348
|
-
if (
|
|
12357
|
+
if (_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, lastError)) {
|
|
12349
12358
|
lastError.suggestedAction = (lastError.suggestedAction ? `${lastError.suggestedAction} ` : "") + `The createForResource attempt budget (${MAX_CREATE_ATTEMPTS} attempts: the role ladder + ${MAX_DISCOVERY_MERGES2} discovery merges) was exhausted \u2014 the vendor oracle rejected every candidate. Re-read the record/fields (operations.fieldCatalog, billing_codes.query with a filter) and retry with an explicit pin.`;
|
|
12350
12359
|
}
|
|
12351
12360
|
throw lastError;
|
|
12352
12361
|
}
|
|
12353
12362
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
12354
|
-
const rid =
|
|
12363
|
+
const rid = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
12355
12364
|
const pins = validateCreateParams(params);
|
|
12356
12365
|
await assertResourceActive(http, rid);
|
|
12357
12366
|
const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
|
|
@@ -12364,8 +12373,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
12364
12373
|
return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
|
|
12365
12374
|
}
|
|
12366
12375
|
function discoveryField(err, body, defaults) {
|
|
12367
|
-
if (!
|
|
12368
|
-
const entries =
|
|
12376
|
+
if (!_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
12377
|
+
const entries = _chunk2H7YI54Bcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
12369
12378
|
if (entries === void 0) return null;
|
|
12370
12379
|
for (const entry of entries) {
|
|
12371
12380
|
const field = entry.field;
|
|
@@ -12384,9 +12393,9 @@ var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundl
|
|
|
12384
12393
|
async function readTimeEntry(http, id, retries) {
|
|
12385
12394
|
try {
|
|
12386
12395
|
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP4, maxRetries: retries });
|
|
12387
|
-
return _nullishCoalesce(_optionalChain([res, 'optionalAccess',
|
|
12396
|
+
return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _123 => _123.item]), () => ( null));
|
|
12388
12397
|
} catch (e) {
|
|
12389
|
-
if (
|
|
12398
|
+
if (_chunk2H7YI54Bcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
12390
12399
|
throw e;
|
|
12391
12400
|
}
|
|
12392
12401
|
}
|
|
@@ -12447,8 +12456,105 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
|
|
|
12447
12456
|
return runMove(http, SPEC2, sourceId, toTicketId, opts);
|
|
12448
12457
|
}
|
|
12449
12458
|
|
|
12459
|
+
// src/resources/special/time_entries/recentTickets.ts
|
|
12460
|
+
var OP5 = "time_entries.recentTickets";
|
|
12461
|
+
var DAY_MS3 = 864e5;
|
|
12462
|
+
var TICKET_CHUNK = 100;
|
|
12463
|
+
var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
12464
|
+
function positiveId(value, name) {
|
|
12465
|
+
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12466
|
+
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12467
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${OP5}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP5 });
|
|
12468
|
+
}
|
|
12469
|
+
return n;
|
|
12470
|
+
}
|
|
12471
|
+
async function recentTickets(_resource, from, to, http, opts) {
|
|
12472
|
+
if (opts === void 0 || opts === null || typeof opts !== "object") {
|
|
12473
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${OP5}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP5 });
|
|
12474
|
+
}
|
|
12475
|
+
const resourceID = positiveId(opts.resourceID, "resourceID");
|
|
12476
|
+
const companyID = opts.companyID === void 0 ? void 0 : positiveId(opts.companyID, "companyID");
|
|
12477
|
+
if (opts.tz !== void 0) validateZone(opts.tz, OP5);
|
|
12478
|
+
const fromB = customRangeDay(from, "from", void 0, OP5);
|
|
12479
|
+
const toB = customRangeDay(to, "to", void 0, OP5);
|
|
12480
|
+
if (fromB.ms > toB.ms) {
|
|
12481
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)(`${OP5}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP5 });
|
|
12482
|
+
}
|
|
12483
|
+
const windowToMs = toB.ms + DAY_MS3 - 1;
|
|
12484
|
+
const { items: entries, hasMore } = await queryTimeEntries(
|
|
12485
|
+
_resource,
|
|
12486
|
+
[
|
|
12487
|
+
{ field: "dateWorked", op: "gte", value: isoUtc(fromB.ms) },
|
|
12488
|
+
{ field: "dateWorked", op: "lte", value: isoUtc(windowToMs) },
|
|
12489
|
+
{ field: "resourceID", op: "eq", value: resourceID }
|
|
12490
|
+
],
|
|
12491
|
+
clampWindowLimit(opts.limit),
|
|
12492
|
+
OP5,
|
|
12493
|
+
http
|
|
12494
|
+
);
|
|
12495
|
+
const groups = /* @__PURE__ */ new Map();
|
|
12496
|
+
let entriesWithoutTicket = 0;
|
|
12497
|
+
for (const e of entries) {
|
|
12498
|
+
if (typeof e.ticketID !== "number") {
|
|
12499
|
+
entriesWithoutTicket += 1;
|
|
12500
|
+
continue;
|
|
12501
|
+
}
|
|
12502
|
+
const g = _nullishCoalesce(groups.get(e.ticketID), () => ( { entryCount: 0, totalHours: 0, lastWorked: "" }));
|
|
12503
|
+
g.entryCount += 1;
|
|
12504
|
+
g.totalHours += _nullishCoalesce(e.hoursWorked, () => ( 0));
|
|
12505
|
+
if ((_nullishCoalesce(e.dateWorked, () => ( ""))) > g.lastWorked) g.lastWorked = _nullishCoalesce(e.dateWorked, () => ( ""));
|
|
12506
|
+
groups.set(e.ticketID, g);
|
|
12507
|
+
}
|
|
12508
|
+
const ids2 = [...groups.keys()];
|
|
12509
|
+
const tickets = /* @__PURE__ */ new Map();
|
|
12510
|
+
for (let c = 0; c < ids2.length; c += TICKET_CHUNK) {
|
|
12511
|
+
const chunk = ids2.slice(c, c + TICKET_CHUNK);
|
|
12512
|
+
const filter = [{ field: "id", op: "in", value: chunk }];
|
|
12513
|
+
const res = await http.request({
|
|
12514
|
+
method: "POST",
|
|
12515
|
+
idempotent: true,
|
|
12516
|
+
path: "/V1.0/Tickets/query",
|
|
12517
|
+
body: { MaxRecords: TICKET_CHUNK, filter, IncludeFields: TICKET_FIELDS2 },
|
|
12518
|
+
operation: OP5
|
|
12519
|
+
});
|
|
12520
|
+
for (const t of _chunk2H7YI54Bcjs.unwrapItems.call(void 0, res, OP5).items) if (typeof t.id === "number") tickets.set(t.id, t);
|
|
12521
|
+
}
|
|
12522
|
+
const items = [];
|
|
12523
|
+
const unresolvedTicketIDs = [];
|
|
12524
|
+
let excludedTickets = 0;
|
|
12525
|
+
for (const [ticketID, g] of groups) {
|
|
12526
|
+
const t = tickets.get(ticketID);
|
|
12527
|
+
if (t === void 0) unresolvedTicketIDs.push(ticketID);
|
|
12528
|
+
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _124 => _124.companyID]) !== companyID) {
|
|
12529
|
+
if (t !== void 0) excludedTickets += 1;
|
|
12530
|
+
continue;
|
|
12531
|
+
}
|
|
12532
|
+
items.push({
|
|
12533
|
+
ticketID,
|
|
12534
|
+
..._optionalChain([t, 'optionalAccess', _125 => _125.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
|
|
12535
|
+
..._optionalChain([t, 'optionalAccess', _126 => _126.title]) !== void 0 ? { title: t.title } : {},
|
|
12536
|
+
..._optionalChain([t, 'optionalAccess', _127 => _127.status]) !== void 0 ? { status: t.status } : {},
|
|
12537
|
+
..._optionalChain([t, 'optionalAccess', _128 => _128.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
|
|
12538
|
+
..._optionalChain([t, 'optionalAccess', _129 => _129.companyID]) !== void 0 ? { companyID: t.companyID } : {},
|
|
12539
|
+
entryCount: g.entryCount,
|
|
12540
|
+
totalHours: Math.round(g.totalHours * 100) / 100,
|
|
12541
|
+
lastWorked: g.lastWorked
|
|
12542
|
+
});
|
|
12543
|
+
}
|
|
12544
|
+
items.sort((a, b) => a.lastWorked < b.lastWorked ? 1 : a.lastWorked > b.lastWorked ? -1 : a.ticketID - b.ticketID);
|
|
12545
|
+
return {
|
|
12546
|
+
items,
|
|
12547
|
+
entriesRead: entries.length,
|
|
12548
|
+
entriesWithoutTicket,
|
|
12549
|
+
unresolvedTicketIDs,
|
|
12550
|
+
...companyID !== void 0 ? { excludedTickets } : {},
|
|
12551
|
+
window: { from: isoUtc(fromB.ms), to: isoUtc(windowToMs) },
|
|
12552
|
+
truncated: hasMore
|
|
12553
|
+
};
|
|
12554
|
+
}
|
|
12555
|
+
|
|
12450
12556
|
// src/resources/time_entries.ts
|
|
12451
|
-
var TimeEntriesResource = class extends
|
|
12557
|
+
var TimeEntriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
12452
12558
|
constructor(http, pageSize) {
|
|
12453
12559
|
super(http, {
|
|
12454
12560
|
key: "time_entries",
|
|
@@ -12579,6 +12685,10 @@ var TimeEntriesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
12579
12685
|
return postedWithin(this, from, to, this.http, opts);
|
|
12580
12686
|
}
|
|
12581
12687
|
/** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
|
|
12688
|
+
recentTickets(from, to, opts) {
|
|
12689
|
+
return recentTickets(this, from, to, this.http, opts);
|
|
12690
|
+
}
|
|
12691
|
+
/** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
|
|
12582
12692
|
today(opts) {
|
|
12583
12693
|
return windowQuery3(this, "today", this.http, opts);
|
|
12584
12694
|
}
|
|
@@ -12589,7 +12699,7 @@ var TimeEntriesResource = class extends _chunkD5TVBI4Ucjs.BaseResource {
|
|
|
12589
12699
|
};
|
|
12590
12700
|
|
|
12591
12701
|
// src/resources/time_entry_attachments.ts
|
|
12592
|
-
var TimeEntryAttachmentsResource = class extends
|
|
12702
|
+
var TimeEntryAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
12593
12703
|
constructor(http, pageSize) {
|
|
12594
12704
|
super(http, {
|
|
12595
12705
|
key: "time_entry_attachments",
|
|
@@ -12652,9 +12762,9 @@ var TimeEntryAttachmentsResource = class extends _chunkD5TVBI4Ucjs.BaseResource
|
|
|
12652
12762
|
|
|
12653
12763
|
// src/resources/special/time_off_requests.ts
|
|
12654
12764
|
async function approve(_resource, id, opts = {}, http) {
|
|
12655
|
-
const numericId =
|
|
12765
|
+
const numericId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
12656
12766
|
if (opts.dryRun === true) {
|
|
12657
|
-
return
|
|
12767
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
12658
12768
|
operation: "time_off_requests.approve",
|
|
12659
12769
|
method: "GET",
|
|
12660
12770
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -12670,16 +12780,16 @@ async function approve(_resource, id, opts = {}, http) {
|
|
|
12670
12780
|
operation: "time_off_requests.approve",
|
|
12671
12781
|
maxRetries: opts.maxRetries
|
|
12672
12782
|
});
|
|
12673
|
-
return
|
|
12783
|
+
return _chunk2H7YI54Bcjs.unwrapOperation.call(void 0, res);
|
|
12674
12784
|
}
|
|
12675
12785
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
12676
|
-
const numericId =
|
|
12786
|
+
const numericId = _chunk2H7YI54Bcjs.parseIdentifier.call(void 0, id, "id");
|
|
12677
12787
|
const text = reason.trim();
|
|
12678
12788
|
if (text === "") {
|
|
12679
|
-
throw new (0,
|
|
12789
|
+
throw new (0, _chunk2H7YI54Bcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
12680
12790
|
}
|
|
12681
12791
|
if (opts.dryRun === true) {
|
|
12682
|
-
return
|
|
12792
|
+
return _chunk2H7YI54Bcjs.buildDryRunResult.call(void 0, {
|
|
12683
12793
|
operation: "time_off_requests.reject",
|
|
12684
12794
|
method: "POST",
|
|
12685
12795
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -12697,11 +12807,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
12697
12807
|
operation: "time_off_requests.reject",
|
|
12698
12808
|
maxRetries: opts.maxRetries
|
|
12699
12809
|
});
|
|
12700
|
-
return
|
|
12810
|
+
return _chunk2H7YI54Bcjs.unwrapOperation.call(void 0, res);
|
|
12701
12811
|
}
|
|
12702
12812
|
|
|
12703
12813
|
// src/resources/time_off_requests.ts
|
|
12704
|
-
var TimeOffRequestsResource = class extends
|
|
12814
|
+
var TimeOffRequestsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
12705
12815
|
constructor(http, pageSize) {
|
|
12706
12816
|
super(http, {
|
|
12707
12817
|
key: "time_off_requests",
|