node-autotask 0.28.0 → 0.30.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 +31 -0
- package/MCP_TOOL_CATALOG.json +46 -8
- package/MCP_TOOL_MANIFEST.md +13 -11
- package/N8N_MCP_MANIFEST.json +34 -5
- package/N8N_MCP_MANIFEST.md +8 -7
- package/README.md +1 -2
- package/capabilities.json +1642 -1319
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-O2D7KDDD.js → chunk-2ETR5GSO.js} +2 -2
- package/dist/{chunk-ZEGMVEF3.cjs → chunk-EDVSWL32.cjs} +1641 -1318
- package/dist/{chunk-GUY2KK7U.cjs → chunk-L4TDVUJM.cjs} +143 -143
- package/dist/{chunk-D5IVS6GY.cjs → chunk-LLIB4JGK.cjs} +140 -6
- package/dist/{chunk-SYX6EWMT.js → chunk-P4PC32RJ.js} +192 -70
- package/dist/{chunk-IRVZGW5K.js → chunk-QQPCJT2L.js} +136 -2
- package/dist/{chunk-WYKGD5UD.cjs → chunk-RS7QMPRO.cjs} +622 -500
- package/dist/{chunk-6EQSXYRW.js → chunk-TZC4ZAA6.js} +1641 -1318
- package/dist/{index-CORcZUNm.d.cts → index-B9VNv-EP.d.cts} +52 -2
- package/dist/{index-DQ9NgraW.d.cts → index-CJ36PwRG.d.cts} +110 -82
- package/dist/{index-DQ9NgraW.d.ts → index-CJ36PwRG.d.ts} +110 -82
- package/dist/{index-DXuV04zM.d.ts → index-DkpaFqyu.d.ts} +52 -2
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +112 -112
- package/dist/operations/index.d.cts +4 -4
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +9 -9
- package/dist/pool.d.cts +2 -2
- package/dist/pool.d.ts +2 -2
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/API.md +1 -2
- package/package.json +1 -1
|
@@ -38,13 +38,15 @@
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
var _chunkD5IVS6GYcjs = require('./chunk-D5IVS6GY.cjs');
|
|
42
41
|
|
|
43
42
|
|
|
44
|
-
var
|
|
43
|
+
var _chunkLLIB4JGKcjs = require('./chunk-LLIB4JGK.cjs');
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var _chunkEDVSWL32cjs = require('./chunk-EDVSWL32.cjs');
|
|
45
47
|
|
|
46
48
|
// src/resources/appointments.ts
|
|
47
|
-
var AppointmentsResource = class extends
|
|
49
|
+
var AppointmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
48
50
|
constructor(http, pageSize) {
|
|
49
51
|
super(http, {
|
|
50
52
|
key: "appointments",
|
|
@@ -129,7 +131,7 @@ var AuthenticateResource = class {
|
|
|
129
131
|
};
|
|
130
132
|
|
|
131
133
|
// src/resources/billing_codes.ts
|
|
132
|
-
var BillingCodesResource = class extends
|
|
134
|
+
var BillingCodesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
133
135
|
constructor(http, pageSize) {
|
|
134
136
|
super(http, {
|
|
135
137
|
key: "billing_codes",
|
|
@@ -173,7 +175,7 @@ var BillingCodesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
173
175
|
};
|
|
174
176
|
|
|
175
177
|
// src/resources/billing_item_approval_levels.ts
|
|
176
|
-
var BillingItemApprovalLevelsResource = class extends
|
|
178
|
+
var BillingItemApprovalLevelsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
177
179
|
constructor(http, pageSize) {
|
|
178
180
|
super(http, {
|
|
179
181
|
key: "billing_item_approval_levels",
|
|
@@ -215,7 +217,7 @@ var MAX_LIMIT = 500;
|
|
|
215
217
|
function clampWindowLimit(limit) {
|
|
216
218
|
const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
|
|
217
219
|
if (!Number.isInteger(n) || n < 1) {
|
|
218
|
-
throw new (0,
|
|
220
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
219
221
|
}
|
|
220
222
|
return Math.min(n, MAX_LIMIT);
|
|
221
223
|
}
|
|
@@ -261,7 +263,7 @@ function wallParts(tz, ms) {
|
|
|
261
263
|
}
|
|
262
264
|
}
|
|
263
265
|
if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
|
|
264
|
-
throw new (0,
|
|
266
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
|
|
265
267
|
}
|
|
266
268
|
return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
|
|
267
269
|
}
|
|
@@ -288,7 +290,7 @@ function localDayEndMs(y, m, d, tz) {
|
|
|
288
290
|
}
|
|
289
291
|
function validateZone(tz, opName = "dateWindow") {
|
|
290
292
|
if (typeof tz !== "string" || tz.length === 0) {
|
|
291
|
-
throw new (0,
|
|
293
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
292
294
|
`${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
293
295
|
{ operation: opName }
|
|
294
296
|
);
|
|
@@ -296,7 +298,7 @@ function validateZone(tz, opName = "dateWindow") {
|
|
|
296
298
|
try {
|
|
297
299
|
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
298
300
|
} catch (e2) {
|
|
299
|
-
throw new (0,
|
|
301
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
300
302
|
`${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
301
303
|
{ operation: opName }
|
|
302
304
|
);
|
|
@@ -456,13 +458,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
|
|
|
456
458
|
body: { MaxRecords: limit, filter },
|
|
457
459
|
operation
|
|
458
460
|
});
|
|
459
|
-
return
|
|
461
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
460
462
|
}
|
|
461
463
|
var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
|
|
462
464
|
function customRangeDay(value, label, zone, opName) {
|
|
463
465
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
464
466
|
if (!m) {
|
|
465
|
-
throw new (0,
|
|
467
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
466
468
|
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)})`,
|
|
467
469
|
{ operation: opName }
|
|
468
470
|
);
|
|
@@ -474,7 +476,7 @@ function customRangeDay(value, label, zone, opName) {
|
|
|
474
476
|
const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
|
|
475
477
|
const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
|
|
476
478
|
if (!Number.isFinite(ms)) {
|
|
477
|
-
throw new (0,
|
|
479
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
478
480
|
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)})`,
|
|
479
481
|
{ operation: opName }
|
|
480
482
|
);
|
|
@@ -485,7 +487,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
485
487
|
const fromB = customRangeDay(from, "from", zone, operation);
|
|
486
488
|
const toB = customRangeDay(to, "to", zone, operation);
|
|
487
489
|
if (fromB.ms > toB.ms) {
|
|
488
|
-
throw new (0,
|
|
490
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
489
491
|
`${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
|
|
490
492
|
{ operation }
|
|
491
493
|
);
|
|
@@ -502,7 +504,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
502
504
|
body: { MaxRecords: limit, filter },
|
|
503
505
|
operation
|
|
504
506
|
});
|
|
505
|
-
return
|
|
507
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
506
508
|
}
|
|
507
509
|
|
|
508
510
|
// src/resources/special/billing_items.ts
|
|
@@ -535,7 +537,7 @@ async function customRange(_resource, from, to, http, opts) {
|
|
|
535
537
|
}
|
|
536
538
|
|
|
537
539
|
// src/resources/billing_items.ts
|
|
538
|
-
var BillingItemsResource = class extends
|
|
540
|
+
var BillingItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
539
541
|
constructor(http, pageSize) {
|
|
540
542
|
super(http, {
|
|
541
543
|
key: "billing_items",
|
|
@@ -637,7 +639,7 @@ var BillingItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
637
639
|
};
|
|
638
640
|
|
|
639
641
|
// src/resources/change_request_links.ts
|
|
640
|
-
var ChangeRequestLinksResource = class extends
|
|
642
|
+
var ChangeRequestLinksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
641
643
|
constructor(http, pageSize) {
|
|
642
644
|
super(http, {
|
|
643
645
|
key: "change_request_links",
|
|
@@ -691,7 +693,7 @@ var ChangeRequestLinksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
691
693
|
};
|
|
692
694
|
|
|
693
695
|
// src/resources/checklist_libraries.ts
|
|
694
|
-
var ChecklistLibrariesResource = class extends
|
|
696
|
+
var ChecklistLibrariesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
695
697
|
constructor(http, pageSize) {
|
|
696
698
|
super(http, {
|
|
697
699
|
key: "checklist_libraries",
|
|
@@ -765,7 +767,7 @@ var ChecklistLibrariesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
765
767
|
};
|
|
766
768
|
|
|
767
769
|
// src/resources/checklist_library_checklist_items.ts
|
|
768
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
770
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
769
771
|
constructor(http, pageSize) {
|
|
770
772
|
super(http, {
|
|
771
773
|
key: "checklist_library_checklist_items",
|
|
@@ -831,7 +833,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkD5IVS6GYcjs.Bas
|
|
|
831
833
|
};
|
|
832
834
|
|
|
833
835
|
// src/resources/classification_icons.ts
|
|
834
|
-
var ClassificationIconsResource = class extends
|
|
836
|
+
var ClassificationIconsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
835
837
|
constructor(http, pageSize) {
|
|
836
838
|
super(http, {
|
|
837
839
|
key: "classification_icons",
|
|
@@ -938,7 +940,7 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
|
|
|
938
940
|
body,
|
|
939
941
|
operation
|
|
940
942
|
});
|
|
941
|
-
const { items, pageDetails } =
|
|
943
|
+
const { items, pageDetails } = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, operation);
|
|
942
944
|
const capped = items.length >= limit;
|
|
943
945
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
944
946
|
}
|
|
@@ -948,7 +950,7 @@ var DEFAULT_LIMIT2 = 25;
|
|
|
948
950
|
var MAX_LIMIT2 = 500;
|
|
949
951
|
function clampLimit(limit) {
|
|
950
952
|
const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
|
|
951
|
-
if (!Number.isInteger(n) || n < 1) throw new (0,
|
|
953
|
+
if (!Number.isInteger(n) || n < 1) throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
952
954
|
return Math.min(n, MAX_LIMIT2);
|
|
953
955
|
}
|
|
954
956
|
|
|
@@ -961,7 +963,7 @@ async function queryCompanies(http, filter, limit) {
|
|
|
961
963
|
body: { MaxRecords: limit, filter },
|
|
962
964
|
operation: "companies.searchByDomain"
|
|
963
965
|
});
|
|
964
|
-
return
|
|
966
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
965
967
|
}
|
|
966
968
|
async function queryContacts(http, filter, limit) {
|
|
967
969
|
const res = await http.request({
|
|
@@ -971,7 +973,7 @@ async function queryContacts(http, filter, limit) {
|
|
|
971
973
|
body: { MaxRecords: limit, filter },
|
|
972
974
|
operation: "companies.searchByDomain"
|
|
973
975
|
});
|
|
974
|
-
return
|
|
976
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
975
977
|
}
|
|
976
978
|
async function fetchCompanies(http, ids2, limit) {
|
|
977
979
|
const out = [];
|
|
@@ -986,7 +988,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
986
988
|
const item = body && "item" in body ? body.item : null;
|
|
987
989
|
if (item) out.push(item);
|
|
988
990
|
} catch (err) {
|
|
989
|
-
if (err instanceof
|
|
991
|
+
if (err instanceof _chunkLLIB4JGKcjs.NotFoundError) continue;
|
|
990
992
|
throw err;
|
|
991
993
|
}
|
|
992
994
|
}
|
|
@@ -994,7 +996,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
994
996
|
}
|
|
995
997
|
async function searchByDomain(_resource, domain, opts = {}, http) {
|
|
996
998
|
const text = domain.trim();
|
|
997
|
-
if (text === "") throw new (0,
|
|
999
|
+
if (text === "") throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("searchByDomain: empty domain");
|
|
998
1000
|
const limit = clampLimit(opts.limit);
|
|
999
1001
|
const filter = [{ field: "webAddress", op: "contains", value: text }];
|
|
1000
1002
|
const direct = await queryCompanies(http, filter, limit);
|
|
@@ -1008,7 +1010,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
|
|
|
1008
1010
|
const email = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.email, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
|
|
1009
1011
|
const website = _nullishCoalesce(_optionalChain([identity, 'access', _15 => _15.website, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]), () => ( ""));
|
|
1010
1012
|
if (name === "" && email === "" && website === "") {
|
|
1011
|
-
throw new (0,
|
|
1013
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
|
|
1012
1014
|
}
|
|
1013
1015
|
const limit = clampLimit(opts.limit);
|
|
1014
1016
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -1037,23 +1039,23 @@ async function familyChildPage(http, parentID) {
|
|
|
1037
1039
|
path: "/V1.0/Companies/query",
|
|
1038
1040
|
body: {
|
|
1039
1041
|
MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
|
|
1040
|
-
filter:
|
|
1042
|
+
filter: _chunkLLIB4JGKcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
|
|
1041
1043
|
},
|
|
1042
1044
|
operation: "companies.search"
|
|
1043
1045
|
});
|
|
1044
|
-
const { items, pageDetails } =
|
|
1046
|
+
const { items, pageDetails } = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, "companies.search");
|
|
1045
1047
|
return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
|
|
1046
1048
|
}
|
|
1047
1049
|
function assertSearchWithDetailOpts(opts) {
|
|
1048
1050
|
if (opts === void 0) return;
|
|
1049
1051
|
if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
|
|
1050
|
-
throw new (0,
|
|
1052
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
|
|
1051
1053
|
operation: "companies.searchWithDetail"
|
|
1052
1054
|
});
|
|
1053
1055
|
}
|
|
1054
1056
|
for (const key of Object.keys(opts)) {
|
|
1055
1057
|
if (key !== "limit") {
|
|
1056
|
-
throw new (0,
|
|
1058
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
1057
1059
|
`companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
|
|
1058
1060
|
{ operation: "companies.searchWithDetail" }
|
|
1059
1061
|
);
|
|
@@ -1062,32 +1064,32 @@ function assertSearchWithDetailOpts(opts) {
|
|
|
1062
1064
|
}
|
|
1063
1065
|
async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
1064
1066
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1065
|
-
throw new (0,
|
|
1067
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
|
|
1066
1068
|
}
|
|
1067
1069
|
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
1068
1070
|
if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
|
|
1069
|
-
throw new (0,
|
|
1071
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
1070
1072
|
`companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
|
|
1071
1073
|
{ operation: "companies.search" }
|
|
1072
1074
|
);
|
|
1073
1075
|
}
|
|
1074
1076
|
}
|
|
1075
1077
|
if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
|
|
1076
|
-
throw new (0,
|
|
1078
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
|
|
1077
1079
|
operation: "companies.search"
|
|
1078
1080
|
});
|
|
1079
1081
|
}
|
|
1080
1082
|
const text = query.trim();
|
|
1081
|
-
if (text === "") throw new (0,
|
|
1082
|
-
const limit = opts.limit === void 0 ? 25 :
|
|
1083
|
+
if (text === "") throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
1084
|
+
const limit = opts.limit === void 0 ? 25 : _chunkLLIB4JGKcjs.clampPageSize.call(void 0, opts.limit);
|
|
1083
1085
|
const res = await http.request({
|
|
1084
1086
|
method: "POST",
|
|
1085
1087
|
idempotent: true,
|
|
1086
1088
|
path: "/V1.0/Companies/query",
|
|
1087
|
-
body: { MaxRecords: limit, filter:
|
|
1089
|
+
body: { MaxRecords: limit, filter: _chunkLLIB4JGKcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
1088
1090
|
operation: "companies.search"
|
|
1089
1091
|
});
|
|
1090
|
-
const hits =
|
|
1092
|
+
const hits = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, "companies.search").items;
|
|
1091
1093
|
if (opts.includeFamily !== true) return hits;
|
|
1092
1094
|
const rows = [];
|
|
1093
1095
|
for (const hit of hits) {
|
|
@@ -1107,7 +1109,7 @@ async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
|
1107
1109
|
}
|
|
1108
1110
|
|
|
1109
1111
|
// src/resources/special/companies/errors.ts
|
|
1110
|
-
var OwnerResourceRequiredError = class extends
|
|
1112
|
+
var OwnerResourceRequiredError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
1111
1113
|
constructor(message, options = {}) {
|
|
1112
1114
|
super(message, {
|
|
1113
1115
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1118,13 +1120,13 @@ var OwnerResourceRequiredError = class extends _chunkD5IVS6GYcjs.AutotaskError {
|
|
|
1118
1120
|
this.name = "OwnerResourceRequiredError";
|
|
1119
1121
|
}
|
|
1120
1122
|
};
|
|
1121
|
-
var CompanyResourceInvalidError = class extends
|
|
1123
|
+
var CompanyResourceInvalidError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
1122
1124
|
constructor(message, options = {}) {
|
|
1123
1125
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
1124
1126
|
this.name = "CompanyResourceInvalidError";
|
|
1125
1127
|
}
|
|
1126
1128
|
};
|
|
1127
|
-
var CompanyCreateFailedError = class extends
|
|
1129
|
+
var CompanyCreateFailedError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
1128
1130
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
1129
1131
|
|
|
1130
1132
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -1143,23 +1145,23 @@ var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumer
|
|
|
1143
1145
|
var SAFE_COMPANY_CREATE_DEFAULTS = {};
|
|
1144
1146
|
function validateUpsertInput(companyName, params) {
|
|
1145
1147
|
if (typeof companyName !== "string" || companyName.trim() === "") {
|
|
1146
|
-
throw new (0,
|
|
1148
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
|
|
1147
1149
|
}
|
|
1148
1150
|
if (typeof _optionalChain([params, 'optionalAccess', _18 => _18.phone]) !== "string" || params.phone.trim() === "") {
|
|
1149
|
-
throw new (0,
|
|
1151
|
+
throw new (0, _chunkLLIB4JGKcjs.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 });
|
|
1150
1152
|
}
|
|
1151
1153
|
const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
|
|
1152
1154
|
if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
|
|
1153
|
-
throw new (0,
|
|
1155
|
+
throw new (0, _chunkLLIB4JGKcjs.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 });
|
|
1154
1156
|
}
|
|
1155
1157
|
const owner = params.ownerResourceID;
|
|
1156
1158
|
if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
|
|
1157
|
-
throw new (0,
|
|
1159
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
|
|
1158
1160
|
}
|
|
1159
1161
|
return { companyType, owner };
|
|
1160
1162
|
}
|
|
1161
1163
|
function existsDryRun(http, companyName, match) {
|
|
1162
|
-
return
|
|
1164
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
1163
1165
|
{
|
|
1164
1166
|
operation: OP_UPSERT_NAME,
|
|
1165
1167
|
method: "POST",
|
|
@@ -1185,7 +1187,7 @@ function createDryRun(http, body, owner) {
|
|
|
1185
1187
|
"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"
|
|
1186
1188
|
);
|
|
1187
1189
|
}
|
|
1188
|
-
return
|
|
1190
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
1189
1191
|
{
|
|
1190
1192
|
operation: OP_UPSERT_NAME,
|
|
1191
1193
|
method: "POST",
|
|
@@ -1230,8 +1232,8 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1230
1232
|
sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
|
|
1231
1233
|
};
|
|
1232
1234
|
} catch (err) {
|
|
1233
|
-
if (!
|
|
1234
|
-
const named = (_nullishCoalesce(
|
|
1235
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1236
|
+
const named = (_nullishCoalesce(_chunkLLIB4JGKcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
1235
1237
|
const seen = /* @__PURE__ */ new Set();
|
|
1236
1238
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
1237
1239
|
const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -1245,7 +1247,7 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1245
1247
|
}
|
|
1246
1248
|
continue;
|
|
1247
1249
|
}
|
|
1248
|
-
const detail =
|
|
1250
|
+
const detail = _chunkLLIB4JGKcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
1249
1251
|
throw new CompanyCreateFailedError(
|
|
1250
1252
|
`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}` : ""}`,
|
|
1251
1253
|
unique,
|
|
@@ -1319,7 +1321,7 @@ async function readFields(http, fresh) {
|
|
|
1319
1321
|
const res = await http.request({ method: "GET", path: "/V1.0/Tickets/entityInformation/fields", operation: OP, maxRetries: 0 });
|
|
1320
1322
|
const fields = _optionalChain([res, 'optionalAccess', _21 => _21.fields]);
|
|
1321
1323
|
if (!Array.isArray(fields)) {
|
|
1322
|
-
throw new (0,
|
|
1324
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskError)("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
1323
1325
|
}
|
|
1324
1326
|
_optionalChain([cache, 'optionalAccess', _22 => _22.set, 'call', _23 => _23(key, "fields", fields)]);
|
|
1325
1327
|
return fields;
|
|
@@ -1338,7 +1340,7 @@ async function resolveTicketStatusSemantics(http, opts = {}) {
|
|
|
1338
1340
|
if (opts.excludeStatusIds !== void 0) {
|
|
1339
1341
|
const closedIds2 = [...new Set(opts.excludeStatusIds.map((id) => Number(id)))];
|
|
1340
1342
|
if (closedIds2.length === 0 || closedIds2.some((id) => !Number.isSafeInteger(id) || id < 1)) {
|
|
1341
|
-
throw new (0,
|
|
1343
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`excludeStatusIds must be a non-empty list of positive status ids (got ${JSON.stringify(opts.excludeStatusIds)})`, { operation: OP });
|
|
1342
1344
|
}
|
|
1343
1345
|
return { picklist: [], closedIds: closedIds2, source: "picklist", note: `closed = status ${closedIds2.join(", ")} \u2014 supplied by the caller` };
|
|
1344
1346
|
}
|
|
@@ -1346,7 +1348,7 @@ async function resolveTicketStatusSemantics(http, opts = {}) {
|
|
|
1346
1348
|
try {
|
|
1347
1349
|
fields = await readFields(http, opts.fresh === true);
|
|
1348
1350
|
} catch (e) {
|
|
1349
|
-
if (e instanceof
|
|
1351
|
+
if (e instanceof _chunkLLIB4JGKcjs.AutotaskError && e.code === "ABORTED") throw e;
|
|
1350
1352
|
return assumed();
|
|
1351
1353
|
}
|
|
1352
1354
|
const picklist = picklistOf(fields);
|
|
@@ -1382,30 +1384,30 @@ var LOCATION_LIMIT_MAX = 500;
|
|
|
1382
1384
|
function locationLimit(value) {
|
|
1383
1385
|
if (value === void 0) return PROFILE_PART_LIMIT;
|
|
1384
1386
|
if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
|
|
1385
|
-
throw new (0,
|
|
1387
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
|
|
1386
1388
|
}
|
|
1387
1389
|
return value;
|
|
1388
1390
|
}
|
|
1389
1391
|
function validateProjection(fields) {
|
|
1390
1392
|
if (fields === void 0) return {};
|
|
1391
1393
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
|
|
1392
|
-
throw new (0,
|
|
1394
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
|
|
1393
1395
|
}
|
|
1394
1396
|
const out = {};
|
|
1395
1397
|
for (const [part, list] of Object.entries(fields)) {
|
|
1396
1398
|
if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
|
|
1397
|
-
throw new (0,
|
|
1399
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
|
|
1398
1400
|
}
|
|
1399
1401
|
if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
|
|
1400
|
-
throw new (0,
|
|
1402
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
|
|
1401
1403
|
}
|
|
1402
1404
|
const names = [...new Set(list)];
|
|
1403
1405
|
const entity = PART_ENTITY[part];
|
|
1404
|
-
const known = _nullishCoalesce(
|
|
1406
|
+
const known = _nullishCoalesce(_chunkLLIB4JGKcjs.MODEL_FIELD_SETS[entity], () => ( []));
|
|
1405
1407
|
const unknown = names.filter((n) => !known.includes(n));
|
|
1406
1408
|
if (unknown.length > 0) {
|
|
1407
|
-
throw new (0,
|
|
1408
|
-
`fullProfile: fields.${part} has unknown field name(s) ${
|
|
1409
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
1410
|
+
`fullProfile: fields.${part} has unknown field name(s) ${_chunkLLIB4JGKcjs.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`
|
|
1409
1411
|
);
|
|
1410
1412
|
}
|
|
1411
1413
|
out[part] = names;
|
|
@@ -1422,7 +1424,7 @@ function project(items, names) {
|
|
|
1422
1424
|
function profilePartLimit(value, name) {
|
|
1423
1425
|
const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
|
|
1424
1426
|
if (!Number.isInteger(n) || n < 1) {
|
|
1425
|
-
throw new (0,
|
|
1427
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1426
1428
|
}
|
|
1427
1429
|
return n;
|
|
1428
1430
|
}
|
|
@@ -1434,7 +1436,7 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
|
|
|
1434
1436
|
body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
|
|
1435
1437
|
operation: "companies.fullProfile"
|
|
1436
1438
|
});
|
|
1437
|
-
return project(
|
|
1439
|
+
return project(_chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1438
1440
|
}
|
|
1439
1441
|
async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
1440
1442
|
const semantics = await resolveTicketStatusSemantics(http);
|
|
@@ -1451,7 +1453,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1451
1453
|
},
|
|
1452
1454
|
operation: "companies.fullProfile"
|
|
1453
1455
|
});
|
|
1454
|
-
return project(
|
|
1456
|
+
return project(_chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1455
1457
|
})();
|
|
1456
1458
|
const closedStatus = { closedIds: semantics.closedIds, source: semantics.source, note: semantics.note };
|
|
1457
1459
|
const partNote = semantics.source === "assumed" ? OPEN_TICKETS_NOTE : semantics.note;
|
|
@@ -1463,7 +1465,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1463
1465
|
closedStatus
|
|
1464
1466
|
};
|
|
1465
1467
|
if (openRows.length === 0) {
|
|
1466
|
-
const stamp =
|
|
1468
|
+
const stamp = _chunkLLIB4JGKcjs.blindStampFor.call(void 0, _optionalChain([_chunkLLIB4JGKcjs.BLIND_SURFACE_STAMPS, 'access', _24 => _24["tickets"], 'optionalAccess', _25 => _25.query]), [{ field: "companyID", op: "eq", value: companyID }, openLeaf]);
|
|
1467
1469
|
if (stamp !== void 0) {
|
|
1468
1470
|
openTickets = {
|
|
1469
1471
|
items: openRows,
|
|
@@ -1478,7 +1480,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1478
1480
|
return openTickets;
|
|
1479
1481
|
}
|
|
1480
1482
|
async function addProfileNames(http, company, openTickets, projects, result, opts) {
|
|
1481
|
-
const builder =
|
|
1483
|
+
const builder = _chunkLLIB4JGKcjs.createNamePlan.call(void 0, _chunkLLIB4JGKcjs.TICKET_LABEL_FIELDS);
|
|
1482
1484
|
const c = company;
|
|
1483
1485
|
builder.addResource(c["ownerResourceID"]);
|
|
1484
1486
|
builder.addResource(c["createdByResourceID"]);
|
|
@@ -1495,20 +1497,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1495
1497
|
builder.addResource(r["creatorResourceID"]);
|
|
1496
1498
|
builder.addFk("contract", r["contractID"]);
|
|
1497
1499
|
}
|
|
1498
|
-
const names = await
|
|
1500
|
+
const names = await _chunkLLIB4JGKcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1499
1501
|
const companyRow = { ...company };
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1503
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
|
|
1502
1504
|
result.company = companyRow;
|
|
1503
1505
|
result.openTickets = {
|
|
1504
1506
|
...openTickets,
|
|
1505
1507
|
items: openTickets.items.map((row) => {
|
|
1506
1508
|
const r = { ...row };
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
for (const f of
|
|
1509
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1510
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1511
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1512
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1513
|
+
for (const f of _chunkLLIB4JGKcjs.TICKET_LABEL_FIELDS) _chunkLLIB4JGKcjs.addLabelSibling.call(void 0, r, f, names);
|
|
1512
1514
|
return r;
|
|
1513
1515
|
})
|
|
1514
1516
|
};
|
|
@@ -1516,9 +1518,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1516
1518
|
...result.projects,
|
|
1517
1519
|
items: result.projects.items.map((row) => {
|
|
1518
1520
|
const r = { ...row };
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1521
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1522
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1523
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1522
1524
|
return r;
|
|
1523
1525
|
})
|
|
1524
1526
|
};
|
|
@@ -1531,7 +1533,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1531
1533
|
const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
|
|
1532
1534
|
const locLimit = locationLimit(opts.locationLimit);
|
|
1533
1535
|
const proj = validateProjection(opts.fields);
|
|
1534
|
-
const companyID =
|
|
1536
|
+
const companyID = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
1535
1537
|
const company = await resource.get(companyID);
|
|
1536
1538
|
const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
|
|
1537
1539
|
const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
|
|
@@ -1578,7 +1580,7 @@ var UNBILLED_WORK_OPT_KEYS = [
|
|
|
1578
1580
|
var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
|
|
1579
1581
|
function validateUnbilledWorkOptions(companyId, opts) {
|
|
1580
1582
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1581
|
-
throw new (0,
|
|
1583
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
1582
1584
|
`unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
1583
1585
|
{ operation: "companies.unbilledWork" }
|
|
1584
1586
|
);
|
|
@@ -1607,7 +1609,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1607
1609
|
try {
|
|
1608
1610
|
limit = clampLimit(opts.limit);
|
|
1609
1611
|
} catch (err) {
|
|
1610
|
-
problems.push(err instanceof
|
|
1612
|
+
problems.push(err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1611
1613
|
limit = 50;
|
|
1612
1614
|
}
|
|
1613
1615
|
if (source === "date_range") {
|
|
@@ -1622,9 +1624,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1622
1624
|
problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
|
|
1623
1625
|
} else {
|
|
1624
1626
|
try {
|
|
1625
|
-
|
|
1627
|
+
_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1626
1628
|
} catch (err) {
|
|
1627
|
-
problems.push(err instanceof
|
|
1629
|
+
problems.push(err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
|
|
1628
1630
|
}
|
|
1629
1631
|
}
|
|
1630
1632
|
}
|
|
@@ -1634,20 +1636,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1634
1636
|
} else {
|
|
1635
1637
|
opts.ticketIds.forEach((tid, i) => {
|
|
1636
1638
|
try {
|
|
1637
|
-
|
|
1639
|
+
_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1638
1640
|
} catch (err) {
|
|
1639
|
-
problems.push(err instanceof
|
|
1641
|
+
problems.push(err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1640
1642
|
}
|
|
1641
1643
|
});
|
|
1642
1644
|
}
|
|
1643
1645
|
}
|
|
1644
1646
|
try {
|
|
1645
|
-
|
|
1647
|
+
_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1646
1648
|
} catch (err) {
|
|
1647
|
-
problems.push(err instanceof
|
|
1649
|
+
problems.push(err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
|
|
1648
1650
|
}
|
|
1649
1651
|
if (problems.length > 0) {
|
|
1650
|
-
throw new (0,
|
|
1652
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
1651
1653
|
`unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
1652
1654
|
- ` + problems.join("\n- "),
|
|
1653
1655
|
{ operation: "companies.unbilledWork" }
|
|
@@ -1676,7 +1678,7 @@ function capJoinSet(ids2, cap) {
|
|
|
1676
1678
|
}
|
|
1677
1679
|
function unbilledWorkPartStatus(key, conditions, items) {
|
|
1678
1680
|
if (items.length !== 0) return { status: "ok" };
|
|
1679
|
-
const stamp =
|
|
1681
|
+
const stamp = _chunkLLIB4JGKcjs.blindStampFor.call(void 0, _optionalChain([_chunkLLIB4JGKcjs.BLIND_SURFACE_STAMPS, 'access', _26 => _26[key], 'optionalAccess', _27 => _27.query]), conditions);
|
|
1680
1682
|
if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
|
|
1681
1683
|
return {
|
|
1682
1684
|
status: "ok",
|
|
@@ -1696,7 +1698,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1696
1698
|
parentStatus = "ok";
|
|
1697
1699
|
companyIds.push(num(parent.id));
|
|
1698
1700
|
} catch (err) {
|
|
1699
|
-
if (err instanceof
|
|
1701
|
+
if (err instanceof _chunkLLIB4JGKcjs.NotFoundError) parent = null;
|
|
1700
1702
|
else throw err;
|
|
1701
1703
|
}
|
|
1702
1704
|
}
|
|
@@ -1734,14 +1736,14 @@ async function readBillingPart(http, v, companyIds) {
|
|
|
1734
1736
|
if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
|
|
1735
1737
|
if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
|
|
1736
1738
|
}
|
|
1737
|
-
const billingFields =
|
|
1739
|
+
const billingFields = _chunkLLIB4JGKcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
|
|
1738
1740
|
const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
|
|
1739
1741
|
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP2, billingIncludeFields);
|
|
1740
1742
|
let billingItems = billingRaw.items;
|
|
1741
1743
|
let billingNoteCharsTruncated = 0;
|
|
1742
1744
|
if (v.includeNotes) {
|
|
1743
|
-
const noteFields = (_nullishCoalesce(
|
|
1744
|
-
[billingItems, billingNoteCharsTruncated] =
|
|
1745
|
+
const noteFields = (_nullishCoalesce(_chunkLLIB4JGKcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1746
|
+
[billingItems, billingNoteCharsTruncated] = _chunkLLIB4JGKcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
|
|
1745
1747
|
}
|
|
1746
1748
|
const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
|
|
1747
1749
|
const billingItemsPart = {
|
|
@@ -1785,7 +1787,7 @@ async function readTimePart(http, v, join) {
|
|
|
1785
1787
|
let cappedItems = entries;
|
|
1786
1788
|
let noteCharsTruncated = 0;
|
|
1787
1789
|
if (v.includeNotes) {
|
|
1788
|
-
[cappedItems, noteCharsTruncated] =
|
|
1790
|
+
[cappedItems, noteCharsTruncated] = _chunkLLIB4JGKcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
|
|
1789
1791
|
}
|
|
1790
1792
|
const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
|
|
1791
1793
|
timePart = {
|
|
@@ -1873,7 +1875,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
|
|
|
1873
1875
|
}
|
|
1874
1876
|
async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
1875
1877
|
const v = validateUnbilledWorkOptions(companyId, opts);
|
|
1876
|
-
const id =
|
|
1878
|
+
const id = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1877
1879
|
const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
|
|
1878
1880
|
const join = await readJoinSets(http, companyIds, v);
|
|
1879
1881
|
const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
|
|
@@ -1900,7 +1902,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1900
1902
|
}
|
|
1901
1903
|
|
|
1902
1904
|
// src/resources/companies.ts
|
|
1903
|
-
var CompaniesResource = class extends
|
|
1905
|
+
var CompaniesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
1904
1906
|
constructor(http, pageSize) {
|
|
1905
1907
|
super(http, {
|
|
1906
1908
|
key: "companies",
|
|
@@ -2007,7 +2009,7 @@ var CompaniesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
2007
2009
|
};
|
|
2008
2010
|
|
|
2009
2011
|
// src/resources/company_alerts.ts
|
|
2010
|
-
var CompanyAlertsResource = class extends
|
|
2012
|
+
var CompanyAlertsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2011
2013
|
constructor(http, pageSize) {
|
|
2012
2014
|
super(http, {
|
|
2013
2015
|
key: "company_alerts",
|
|
@@ -2073,7 +2075,7 @@ var CompanyAlertsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
2073
2075
|
};
|
|
2074
2076
|
|
|
2075
2077
|
// src/resources/company_locations.ts
|
|
2076
|
-
var CompanyLocationsResource = class extends
|
|
2078
|
+
var CompanyLocationsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2077
2079
|
constructor(http, pageSize) {
|
|
2078
2080
|
super(http, {
|
|
2079
2081
|
key: "company_locations",
|
|
@@ -2144,7 +2146,7 @@ var CompanyLocationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
2144
2146
|
};
|
|
2145
2147
|
|
|
2146
2148
|
// src/resources/company_notes.ts
|
|
2147
|
-
var CompanyNotesResource = class extends
|
|
2149
|
+
var CompanyNotesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2148
2150
|
constructor(http, pageSize) {
|
|
2149
2151
|
super(http, {
|
|
2150
2152
|
key: "company_notes",
|
|
@@ -2209,7 +2211,7 @@ var CompanyNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
2209
2211
|
};
|
|
2210
2212
|
|
|
2211
2213
|
// src/resources/company_site_configurations.ts
|
|
2212
|
-
var CompanySiteConfigurationsResource = class extends
|
|
2214
|
+
var CompanySiteConfigurationsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2213
2215
|
constructor(http, pageSize) {
|
|
2214
2216
|
super(http, {
|
|
2215
2217
|
key: "company_site_configurations",
|
|
@@ -2260,7 +2262,7 @@ var CompanySiteConfigurationsResource = class extends _chunkD5IVS6GYcjs.BaseReso
|
|
|
2260
2262
|
};
|
|
2261
2263
|
|
|
2262
2264
|
// src/resources/company_webhooks.ts
|
|
2263
|
-
var CompanyWebhooksResource = class extends
|
|
2265
|
+
var CompanyWebhooksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2264
2266
|
constructor(http, pageSize) {
|
|
2265
2267
|
super(http, {
|
|
2266
2268
|
key: "company_webhooks",
|
|
@@ -2336,7 +2338,7 @@ var CompanyWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
2336
2338
|
};
|
|
2337
2339
|
|
|
2338
2340
|
// src/resources/configuration_item_billing_product_associations.ts
|
|
2339
|
-
var ConfigurationItemBillingProductAssociationsResource = class extends
|
|
2341
|
+
var ConfigurationItemBillingProductAssociationsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2340
2342
|
constructor(http, pageSize) {
|
|
2341
2343
|
super(http, {
|
|
2342
2344
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2402,7 +2404,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkD5
|
|
|
2402
2404
|
};
|
|
2403
2405
|
|
|
2404
2406
|
// src/resources/configuration_item_categories.ts
|
|
2405
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2407
|
+
var ConfigurationItemCategoriesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2406
2408
|
constructor(http, pageSize) {
|
|
2407
2409
|
super(http, {
|
|
2408
2410
|
key: "configuration_item_categories",
|
|
@@ -2469,7 +2471,7 @@ var ConfigurationItemCategoriesResource = class extends _chunkD5IVS6GYcjs.BaseRe
|
|
|
2469
2471
|
};
|
|
2470
2472
|
|
|
2471
2473
|
// src/resources/configuration_item_category_udf_associations.ts
|
|
2472
|
-
var ConfigurationItemCategoryUdfAssociationsResource = class extends
|
|
2474
|
+
var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2473
2475
|
constructor(http, pageSize) {
|
|
2474
2476
|
super(http, {
|
|
2475
2477
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2535,7 +2537,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkD5IVS
|
|
|
2535
2537
|
};
|
|
2536
2538
|
|
|
2537
2539
|
// src/resources/configuration_item_dns_records.ts
|
|
2538
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2540
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2539
2541
|
constructor(http, pageSize) {
|
|
2540
2542
|
super(http, {
|
|
2541
2543
|
key: "configuration_item_dns_records",
|
|
@@ -2584,7 +2586,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkD5IVS6GYcjs.BaseRe
|
|
|
2584
2586
|
};
|
|
2585
2587
|
|
|
2586
2588
|
// src/resources/configuration_item_notes.ts
|
|
2587
|
-
var ConfigurationItemNotesResource = class extends
|
|
2589
|
+
var ConfigurationItemNotesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2588
2590
|
constructor(http, pageSize) {
|
|
2589
2591
|
super(http, {
|
|
2590
2592
|
key: "configuration_item_notes",
|
|
@@ -2643,7 +2645,7 @@ var ConfigurationItemNotesResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
2643
2645
|
};
|
|
2644
2646
|
|
|
2645
2647
|
// src/resources/configuration_item_related_items.ts
|
|
2646
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2648
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2647
2649
|
constructor(http, pageSize) {
|
|
2648
2650
|
super(http, {
|
|
2649
2651
|
key: "configuration_item_related_items",
|
|
@@ -2704,16 +2706,16 @@ async function fetchRecord(http, path, label, readOpts) {
|
|
|
2704
2706
|
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _32 => _32.maxRetries]) });
|
|
2705
2707
|
const body = res;
|
|
2706
2708
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
2707
|
-
throw new (0,
|
|
2709
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
2708
2710
|
}
|
|
2709
2711
|
return body.item;
|
|
2710
2712
|
}
|
|
2711
2713
|
async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
2712
|
-
const numericSource =
|
|
2714
|
+
const numericSource = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2713
2715
|
if (_optionalChain([opts, 'optionalAccess', _33 => _33.destinationCompanyId]) === void 0) {
|
|
2714
|
-
throw new (0,
|
|
2716
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2715
2717
|
}
|
|
2716
|
-
const destId =
|
|
2718
|
+
const destId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2717
2719
|
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
|
|
2718
2720
|
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
2719
2721
|
const body = { ...source };
|
|
@@ -2723,20 +2725,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2723
2725
|
body.companyID = destId;
|
|
2724
2726
|
body.isActive = true;
|
|
2725
2727
|
if (opts.newReferenceTitle !== void 0) {
|
|
2726
|
-
if (opts.newReferenceTitle.trim() === "") throw new (0,
|
|
2728
|
+
if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
|
|
2727
2729
|
body.referenceTitle = opts.newReferenceTitle.trim();
|
|
2728
2730
|
}
|
|
2729
2731
|
if (opts.lastModifiedDate !== void 0) {
|
|
2730
2732
|
const current = source.lastModifiedDate;
|
|
2731
2733
|
if (current !== opts.lastModifiedDate) {
|
|
2732
|
-
throw new (0,
|
|
2734
|
+
throw new (0, _chunkLLIB4JGKcjs.StaleObjectError)(
|
|
2733
2735
|
`moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
|
|
2734
2736
|
{ operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
|
|
2735
2737
|
);
|
|
2736
2738
|
}
|
|
2737
2739
|
}
|
|
2738
2740
|
if (opts.dryRun === true) {
|
|
2739
|
-
return
|
|
2741
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
2740
2742
|
operation: "configuration_items.moveConfigurationItem",
|
|
2741
2743
|
method: "POST",
|
|
2742
2744
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2761,7 +2763,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2761
2763
|
const createdBody = created;
|
|
2762
2764
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2763
2765
|
if (typeof newId !== "number") {
|
|
2764
|
-
throw new (0,
|
|
2766
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2765
2767
|
}
|
|
2766
2768
|
let sourceDeactivated = false;
|
|
2767
2769
|
if (opts.deactivateSource !== false) {
|
|
@@ -2780,7 +2782,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2780
2782
|
function profilePartLimit2(value, name) {
|
|
2781
2783
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2782
2784
|
if (!Number.isInteger(n) || n < 1) {
|
|
2783
|
-
throw new (0,
|
|
2785
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2784
2786
|
}
|
|
2785
2787
|
return n;
|
|
2786
2788
|
}
|
|
@@ -2796,14 +2798,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
|
|
|
2796
2798
|
});
|
|
2797
2799
|
const body = res;
|
|
2798
2800
|
if (body === null || !("item" in body)) {
|
|
2799
|
-
throw new (0,
|
|
2801
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2800
2802
|
}
|
|
2801
2803
|
if (body.item === null || body.item === void 0) {
|
|
2802
|
-
throw new (0,
|
|
2804
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2803
2805
|
}
|
|
2804
2806
|
return body.item;
|
|
2805
2807
|
} catch (err) {
|
|
2806
|
-
if (err instanceof
|
|
2808
|
+
if (err instanceof _chunkLLIB4JGKcjs.NotFoundError) return null;
|
|
2807
2809
|
throw err;
|
|
2808
2810
|
}
|
|
2809
2811
|
}
|
|
@@ -2815,7 +2817,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2815
2817
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2816
2818
|
operation: "configuration_items.profile"
|
|
2817
2819
|
});
|
|
2818
|
-
return
|
|
2820
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
2819
2821
|
}
|
|
2820
2822
|
async function profile(resource, id, opts = {}, http) {
|
|
2821
2823
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2827,7 +2829,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2827
2829
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2828
2830
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2829
2831
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2830
|
-
const wallQuirk = _optionalChain([
|
|
2832
|
+
const wallQuirk = _optionalChain([_chunkLLIB4JGKcjs.RELATIONSHIP_MAP, 'access', _34 => _34["configuration_items"], 'optionalAccess', _35 => _35.zoneFacts, 'optionalAccess', _36 => _36.quirks, 'optionalAccess', _37 => _37.find, 'call', _38 => _38((q) => q.startsWith("product wall"))]);
|
|
2831
2833
|
const productAssociations = {
|
|
2832
2834
|
items: associations,
|
|
2833
2835
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2851,11 +2853,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2851
2853
|
}
|
|
2852
2854
|
};
|
|
2853
2855
|
if (opts.names === true) {
|
|
2854
|
-
const builder =
|
|
2856
|
+
const builder = _chunkLLIB4JGKcjs.createNamePlan.call(void 0, );
|
|
2855
2857
|
builder.addFk("contract", root["contractID"]);
|
|
2856
|
-
const names = await
|
|
2858
|
+
const names = await _chunkLLIB4JGKcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2857
2859
|
const ciRow = { ...ci };
|
|
2858
|
-
|
|
2860
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2859
2861
|
result.ci = ciRow;
|
|
2860
2862
|
result.names = names.section;
|
|
2861
2863
|
}
|
|
@@ -2863,7 +2865,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2863
2865
|
}
|
|
2864
2866
|
|
|
2865
2867
|
// src/resources/configuration_items.ts
|
|
2866
|
-
var ConfigurationItemsResource = class extends
|
|
2868
|
+
var ConfigurationItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2867
2869
|
constructor(http, pageSize) {
|
|
2868
2870
|
super(http, {
|
|
2869
2871
|
key: "configuration_items",
|
|
@@ -2952,7 +2954,7 @@ var ConfigurationItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
2952
2954
|
};
|
|
2953
2955
|
|
|
2954
2956
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2955
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
2957
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
2956
2958
|
constructor(http, pageSize) {
|
|
2957
2959
|
super(http, {
|
|
2958
2960
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -3015,7 +3017,7 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkD5
|
|
|
3015
3017
|
};
|
|
3016
3018
|
|
|
3017
3019
|
// src/resources/configuration_item_types.ts
|
|
3018
|
-
var ConfigurationItemTypesResource = class extends
|
|
3020
|
+
var ConfigurationItemTypesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3019
3021
|
constructor(http, pageSize) {
|
|
3020
3022
|
super(http, {
|
|
3021
3023
|
key: "configuration_item_types",
|
|
@@ -3089,7 +3091,7 @@ var ConfigurationItemTypesResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
3089
3091
|
};
|
|
3090
3092
|
|
|
3091
3093
|
// src/resources/configuration_item_webhooks.ts
|
|
3092
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
3094
|
+
var ConfigurationItemWebhooksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3093
3095
|
constructor(http, pageSize) {
|
|
3094
3096
|
super(http, {
|
|
3095
3097
|
key: "configuration_item_webhooks",
|
|
@@ -3165,7 +3167,7 @@ var ConfigurationItemWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseReso
|
|
|
3165
3167
|
};
|
|
3166
3168
|
|
|
3167
3169
|
// src/resources/contact_group_contacts.ts
|
|
3168
|
-
var ContactGroupContactsResource = class extends
|
|
3170
|
+
var ContactGroupContactsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3169
3171
|
constructor(http, pageSize) {
|
|
3170
3172
|
super(http, {
|
|
3171
3173
|
key: "contact_group_contacts",
|
|
@@ -3219,7 +3221,7 @@ var ContactGroupContactsResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
3219
3221
|
};
|
|
3220
3222
|
|
|
3221
3223
|
// src/resources/contact_groups.ts
|
|
3222
|
-
var ContactGroupsResource = class extends
|
|
3224
|
+
var ContactGroupsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3223
3225
|
constructor(http, pageSize) {
|
|
3224
3226
|
super(http, {
|
|
3225
3227
|
key: "contact_groups",
|
|
@@ -3297,22 +3299,22 @@ async function fetchRecord2(http, path, label, readOpts) {
|
|
|
3297
3299
|
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _44 => _44.maxRetries]) });
|
|
3298
3300
|
const body = res;
|
|
3299
3301
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3300
|
-
throw new (0,
|
|
3302
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3301
3303
|
}
|
|
3302
3304
|
return body.item;
|
|
3303
3305
|
}
|
|
3304
3306
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3305
|
-
const sourceId =
|
|
3306
|
-
const destId =
|
|
3307
|
+
const sourceId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3308
|
+
const destId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3307
3309
|
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
|
|
3308
3310
|
const companyID = source.companyID;
|
|
3309
3311
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3310
|
-
throw new (0,
|
|
3312
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3311
3313
|
}
|
|
3312
3314
|
if (opts.lastModifiedDate !== void 0) {
|
|
3313
3315
|
const current = source.lastModifiedDate;
|
|
3314
3316
|
if (current !== opts.lastModifiedDate) {
|
|
3315
|
-
throw new (0,
|
|
3317
|
+
throw new (0, _chunkLLIB4JGKcjs.StaleObjectError)(
|
|
3316
3318
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3317
3319
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3318
3320
|
);
|
|
@@ -3334,10 +3336,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3334
3336
|
},
|
|
3335
3337
|
operation: "contacts.moveToCompany"
|
|
3336
3338
|
});
|
|
3337
|
-
const items =
|
|
3339
|
+
const items = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
3338
3340
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3339
3341
|
if (clash !== void 0) {
|
|
3340
|
-
throw new (0,
|
|
3342
|
+
throw new (0, _chunkLLIB4JGKcjs.ConflictError)(
|
|
3341
3343
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3342
3344
|
{ resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3343
3345
|
);
|
|
@@ -3351,7 +3353,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3351
3353
|
if (opts.dryRun === true) {
|
|
3352
3354
|
const warnings = [];
|
|
3353
3355
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3354
|
-
return
|
|
3356
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
3355
3357
|
operation: "contacts.moveToCompany",
|
|
3356
3358
|
method: "POST",
|
|
3357
3359
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3377,7 +3379,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3377
3379
|
const createdBody = created;
|
|
3378
3380
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3379
3381
|
if (typeof newId !== "number") {
|
|
3380
|
-
throw new (0,
|
|
3382
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3381
3383
|
}
|
|
3382
3384
|
let sourceDeleted = false;
|
|
3383
3385
|
if (opts.deleteSource === true) {
|
|
@@ -3396,7 +3398,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3396
3398
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3397
3399
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3398
3400
|
var DEDUP_LIMIT = 10;
|
|
3399
|
-
var CompanyNotFoundError = class extends
|
|
3401
|
+
var CompanyNotFoundError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
3400
3402
|
constructor(message, options = {}) {
|
|
3401
3403
|
super(message, {
|
|
3402
3404
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3407,7 +3409,7 @@ var CompanyNotFoundError = class extends _chunkD5IVS6GYcjs.AutotaskError {
|
|
|
3407
3409
|
this.name = "CompanyNotFoundError";
|
|
3408
3410
|
}
|
|
3409
3411
|
};
|
|
3410
|
-
var ContactCreateFailedError = class extends
|
|
3412
|
+
var ContactCreateFailedError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
3411
3413
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3412
3414
|
|
|
3413
3415
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3417,25 +3419,25 @@ var ContactCreateFailedError = class extends _chunkD5IVS6GYcjs.AutotaskError {
|
|
|
3417
3419
|
}
|
|
3418
3420
|
};
|
|
3419
3421
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3420
|
-
const cid =
|
|
3422
|
+
const cid = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3421
3423
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3422
|
-
throw new (0,
|
|
3424
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
3423
3425
|
`upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
|
|
3424
3426
|
{ operation: OP_UPSERT_EMAIL }
|
|
3425
3427
|
);
|
|
3426
3428
|
}
|
|
3427
3429
|
if (extra !== void 0) {
|
|
3428
3430
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3429
|
-
throw new (0,
|
|
3431
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
3430
3432
|
`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)})`,
|
|
3431
3433
|
{ operation: OP_UPSERT_EMAIL }
|
|
3432
3434
|
);
|
|
3433
3435
|
}
|
|
3434
3436
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3435
|
-
throw new (0,
|
|
3437
|
+
throw new (0, _chunkLLIB4JGKcjs.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 });
|
|
3436
3438
|
}
|
|
3437
3439
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3438
|
-
throw new (0,
|
|
3440
|
+
throw new (0, _chunkLLIB4JGKcjs.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 });
|
|
3439
3441
|
}
|
|
3440
3442
|
}
|
|
3441
3443
|
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
|
|
@@ -3456,7 +3458,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3456
3458
|
const match = q.items[0];
|
|
3457
3459
|
if (match !== void 0) {
|
|
3458
3460
|
if (opts.dryRun === true) {
|
|
3459
|
-
return
|
|
3461
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
3460
3462
|
{
|
|
3461
3463
|
operation: OP_UPSERT_EMAIL,
|
|
3462
3464
|
method: "POST",
|
|
@@ -3486,7 +3488,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3486
3488
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3487
3489
|
};
|
|
3488
3490
|
if (opts.dryRun === true) {
|
|
3489
|
-
return
|
|
3491
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
3490
3492
|
{
|
|
3491
3493
|
operation: OP_UPSERT_EMAIL,
|
|
3492
3494
|
method: "POST",
|
|
@@ -3509,8 +3511,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3509
3511
|
const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
|
|
3510
3512
|
return { id: created.id, created: true };
|
|
3511
3513
|
} catch (err) {
|
|
3512
|
-
if (!
|
|
3513
|
-
const named = (_nullishCoalesce(
|
|
3514
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3515
|
+
const named = (_nullishCoalesce(_chunkLLIB4JGKcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3514
3516
|
const seen = /* @__PURE__ */ new Set();
|
|
3515
3517
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3516
3518
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3524,7 +3526,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3524
3526
|
}
|
|
3525
3527
|
continue;
|
|
3526
3528
|
}
|
|
3527
|
-
const detail =
|
|
3529
|
+
const detail = _chunkLLIB4JGKcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3528
3530
|
throw new ContactCreateFailedError(
|
|
3529
3531
|
`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}` : ""}`,
|
|
3530
3532
|
unique,
|
|
@@ -3541,7 +3543,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3541
3543
|
}
|
|
3542
3544
|
|
|
3543
3545
|
// src/resources/contacts.ts
|
|
3544
|
-
var ContactsResource = class extends
|
|
3546
|
+
var ContactsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3545
3547
|
constructor(http, pageSize) {
|
|
3546
3548
|
super(http, {
|
|
3547
3549
|
key: "contacts",
|
|
@@ -3633,7 +3635,7 @@ var ContactsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
3633
3635
|
};
|
|
3634
3636
|
|
|
3635
3637
|
// src/resources/contact_webhooks.ts
|
|
3636
|
-
var ContactWebhooksResource = class extends
|
|
3638
|
+
var ContactWebhooksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3637
3639
|
constructor(http, pageSize) {
|
|
3638
3640
|
super(http, {
|
|
3639
3641
|
key: "contact_webhooks",
|
|
@@ -3709,7 +3711,7 @@ var ContactWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
3709
3711
|
};
|
|
3710
3712
|
|
|
3711
3713
|
// src/resources/contract_billing_rules.ts
|
|
3712
|
-
var ContractBillingRulesResource = class extends
|
|
3714
|
+
var ContractBillingRulesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3713
3715
|
constructor(http, pageSize) {
|
|
3714
3716
|
super(http, {
|
|
3715
3717
|
key: "contract_billing_rules",
|
|
@@ -3775,7 +3777,7 @@ var ContractBillingRulesResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
3775
3777
|
};
|
|
3776
3778
|
|
|
3777
3779
|
// src/resources/contract_block_hour_factors.ts
|
|
3778
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3780
|
+
var ContractBlockHourFactorsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3779
3781
|
constructor(http, pageSize) {
|
|
3780
3782
|
super(http, {
|
|
3781
3783
|
key: "contract_block_hour_factors",
|
|
@@ -3834,7 +3836,7 @@ var ContractBlockHourFactorsResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
3834
3836
|
};
|
|
3835
3837
|
|
|
3836
3838
|
// src/resources/contract_blocks.ts
|
|
3837
|
-
var ContractBlocksResource = class extends
|
|
3839
|
+
var ContractBlocksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3838
3840
|
constructor(http, pageSize) {
|
|
3839
3841
|
super(http, {
|
|
3840
3842
|
key: "contract_blocks",
|
|
@@ -3893,7 +3895,7 @@ var ContractBlocksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
3893
3895
|
};
|
|
3894
3896
|
|
|
3895
3897
|
// src/resources/contract_charges.ts
|
|
3896
|
-
var ContractChargesResource = class extends
|
|
3898
|
+
var ContractChargesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3897
3899
|
constructor(http, pageSize) {
|
|
3898
3900
|
super(http, {
|
|
3899
3901
|
key: "contract_charges",
|
|
@@ -3964,7 +3966,7 @@ var ContractChargesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
3964
3966
|
};
|
|
3965
3967
|
|
|
3966
3968
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3967
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
3969
|
+
var ContractExclusionBillingCodesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
3968
3970
|
constructor(http, pageSize) {
|
|
3969
3971
|
super(http, {
|
|
3970
3972
|
key: "contract_exclusion_billing_codes",
|
|
@@ -4021,7 +4023,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkD5IVS6GYcjs.Base
|
|
|
4021
4023
|
};
|
|
4022
4024
|
|
|
4023
4025
|
// src/resources/contract_exclusion_roles.ts
|
|
4024
|
-
var ContractExclusionRolesResource = class extends
|
|
4026
|
+
var ContractExclusionRolesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4025
4027
|
constructor(http, pageSize) {
|
|
4026
4028
|
super(http, {
|
|
4027
4029
|
key: "contract_exclusion_roles",
|
|
@@ -4078,7 +4080,7 @@ var ContractExclusionRolesResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
4078
4080
|
};
|
|
4079
4081
|
|
|
4080
4082
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
4081
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
4083
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4082
4084
|
constructor(http, pageSize) {
|
|
4083
4085
|
super(http, {
|
|
4084
4086
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -4135,7 +4137,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkD5IVS6GYcjs.
|
|
|
4135
4137
|
};
|
|
4136
4138
|
|
|
4137
4139
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
4138
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
4140
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4139
4141
|
constructor(http, pageSize) {
|
|
4140
4142
|
super(http, {
|
|
4141
4143
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -4192,7 +4194,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkD5IVS6GY
|
|
|
4192
4194
|
};
|
|
4193
4195
|
|
|
4194
4196
|
// src/resources/contract_exclusion_sets.ts
|
|
4195
|
-
var ContractExclusionSetsResource = class extends
|
|
4197
|
+
var ContractExclusionSetsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4196
4198
|
constructor(http, pageSize) {
|
|
4197
4199
|
super(http, {
|
|
4198
4200
|
key: "contract_exclusion_sets",
|
|
@@ -4266,7 +4268,7 @@ var ContractExclusionSetsResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
4266
4268
|
};
|
|
4267
4269
|
|
|
4268
4270
|
// src/resources/contract_milestones.ts
|
|
4269
|
-
var ContractMilestonesResource = class extends
|
|
4271
|
+
var ContractMilestonesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4270
4272
|
constructor(http, pageSize) {
|
|
4271
4273
|
super(http, {
|
|
4272
4274
|
key: "contract_milestones",
|
|
@@ -4325,7 +4327,7 @@ var ContractMilestonesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
4325
4327
|
};
|
|
4326
4328
|
|
|
4327
4329
|
// src/resources/contract_notes.ts
|
|
4328
|
-
var ContractNotesResource = class extends
|
|
4330
|
+
var ContractNotesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4329
4331
|
constructor(http, pageSize) {
|
|
4330
4332
|
super(http, {
|
|
4331
4333
|
key: "contract_notes",
|
|
@@ -4384,7 +4386,7 @@ var ContractNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
4384
4386
|
};
|
|
4385
4387
|
|
|
4386
4388
|
// src/resources/contract_rates.ts
|
|
4387
|
-
var ContractRatesResource = class extends
|
|
4389
|
+
var ContractRatesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4388
4390
|
constructor(http, pageSize) {
|
|
4389
4391
|
super(http, {
|
|
4390
4392
|
key: "contract_rates",
|
|
@@ -4443,7 +4445,7 @@ var ContractRatesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
4443
4445
|
};
|
|
4444
4446
|
|
|
4445
4447
|
// src/resources/contract_retainers.ts
|
|
4446
|
-
var ContractRetainersResource = class extends
|
|
4448
|
+
var ContractRetainersResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4447
4449
|
constructor(http, pageSize) {
|
|
4448
4450
|
super(http, {
|
|
4449
4451
|
key: "contract_retainers",
|
|
@@ -4502,7 +4504,7 @@ var ContractRetainersResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
4502
4504
|
};
|
|
4503
4505
|
|
|
4504
4506
|
// src/resources/contract_role_costs.ts
|
|
4505
|
-
var ContractRoleCostsResource = class extends
|
|
4507
|
+
var ContractRoleCostsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4506
4508
|
constructor(http, pageSize) {
|
|
4507
4509
|
super(http, {
|
|
4508
4510
|
key: "contract_role_costs",
|
|
@@ -4561,7 +4563,7 @@ var ContractRoleCostsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
4561
4563
|
};
|
|
4562
4564
|
|
|
4563
4565
|
// src/resources/contract_service_adjustments.ts
|
|
4564
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4566
|
+
var ContractServiceAdjustmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4565
4567
|
constructor(http, pageSize) {
|
|
4566
4568
|
super(http, {
|
|
4567
4569
|
key: "contract_service_adjustments",
|
|
@@ -4595,7 +4597,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkD5IVS6GYcjs.BaseRes
|
|
|
4595
4597
|
};
|
|
4596
4598
|
|
|
4597
4599
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4598
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4600
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4599
4601
|
constructor(http, pageSize) {
|
|
4600
4602
|
super(http, {
|
|
4601
4603
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4629,7 +4631,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkD5IVS6GYcjs.B
|
|
|
4629
4631
|
};
|
|
4630
4632
|
|
|
4631
4633
|
// src/resources/contract_service_bundles.ts
|
|
4632
|
-
var ContractServiceBundlesResource = class extends
|
|
4634
|
+
var ContractServiceBundlesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4633
4635
|
constructor(http, pageSize) {
|
|
4634
4636
|
super(http, {
|
|
4635
4637
|
key: "contract_service_bundles",
|
|
@@ -4688,7 +4690,7 @@ var ContractServiceBundlesResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
4688
4690
|
};
|
|
4689
4691
|
|
|
4690
4692
|
// src/resources/contract_service_bundle_units.ts
|
|
4691
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4693
|
+
var ContractServiceBundleUnitsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4692
4694
|
constructor(http, pageSize) {
|
|
4693
4695
|
super(http, {
|
|
4694
4696
|
key: "contract_service_bundle_units",
|
|
@@ -4730,7 +4732,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkD5IVS6GYcjs.BaseRes
|
|
|
4730
4732
|
};
|
|
4731
4733
|
|
|
4732
4734
|
// src/resources/contract_services.ts
|
|
4733
|
-
var ContractServicesResource = class extends
|
|
4735
|
+
var ContractServicesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4734
4736
|
constructor(http, pageSize) {
|
|
4735
4737
|
super(http, {
|
|
4736
4738
|
key: "contract_services",
|
|
@@ -4789,7 +4791,7 @@ var ContractServicesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
4789
4791
|
};
|
|
4790
4792
|
|
|
4791
4793
|
// src/resources/contract_service_units.ts
|
|
4792
|
-
var ContractServiceUnitsResource = class extends
|
|
4794
|
+
var ContractServiceUnitsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
4793
4795
|
constructor(http, pageSize) {
|
|
4794
4796
|
super(http, {
|
|
4795
4797
|
key: "contract_service_units",
|
|
@@ -4830,6 +4832,42 @@ var ContractServiceUnitsResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
4830
4832
|
}
|
|
4831
4833
|
};
|
|
4832
4834
|
|
|
4835
|
+
// src/resources/special/contracts/lineOfBusiness.ts
|
|
4836
|
+
var OP3 = "contracts.lineOfBusiness";
|
|
4837
|
+
function positiveId(value, name) {
|
|
4838
|
+
const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
|
|
4839
|
+
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
4840
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(OP3 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP3 });
|
|
4841
|
+
}
|
|
4842
|
+
return n;
|
|
4843
|
+
}
|
|
4844
|
+
async function lineOfBusiness(resource, contractIdIn, http, associationIdIn) {
|
|
4845
|
+
const contractId = positiveId(contractIdIn, "contractId");
|
|
4846
|
+
let associationId;
|
|
4847
|
+
let associationSource;
|
|
4848
|
+
if (associationIdIn !== void 0) {
|
|
4849
|
+
associationId = positiveId(associationIdIn, "associationId");
|
|
4850
|
+
associationSource = "argument";
|
|
4851
|
+
} else {
|
|
4852
|
+
associationSource = "contract";
|
|
4853
|
+
const contract = await resource.get(contractId);
|
|
4854
|
+
associationId = _chunkLLIB4JGKcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
|
|
4855
|
+
}
|
|
4856
|
+
if (associationId === void 0) {
|
|
4857
|
+
return {
|
|
4858
|
+
contractId,
|
|
4859
|
+
associationSource,
|
|
4860
|
+
association: null,
|
|
4861
|
+
organizationalLevel2: null,
|
|
4862
|
+
organizationalLevel1: null,
|
|
4863
|
+
markers: { association: "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
4864
|
+
};
|
|
4865
|
+
}
|
|
4866
|
+
const chain = await _chunkLLIB4JGKcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP3, onError: "propagate" });
|
|
4867
|
+
const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
|
|
4868
|
+
return { contractId, associationSource, association, organizationalLevel2, organizationalLevel1, markers };
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4833
4871
|
// src/resources/special/contracts/profitability.constants.ts
|
|
4834
4872
|
var PROFITABILITY_OPT_KEYS = [
|
|
4835
4873
|
"dateFrom",
|
|
@@ -5057,7 +5095,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
|
|
|
5057
5095
|
// src/resources/special/contracts/profitability.validate.ts
|
|
5058
5096
|
function validateProfitabilityOptions(contractId, opts) {
|
|
5059
5097
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
5060
|
-
throw new (0,
|
|
5098
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
5061
5099
|
`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})`,
|
|
5062
5100
|
{ operation: "contracts.profitability" }
|
|
5063
5101
|
);
|
|
@@ -5134,12 +5172,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
5134
5172
|
}
|
|
5135
5173
|
}
|
|
5136
5174
|
try {
|
|
5137
|
-
|
|
5175
|
+
_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5138
5176
|
} catch (err) {
|
|
5139
|
-
problems.push(err instanceof
|
|
5177
|
+
problems.push(err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
5140
5178
|
}
|
|
5141
5179
|
if (problems.length > 0) {
|
|
5142
|
-
throw new (0,
|
|
5180
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
5143
5181
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
5144
5182
|
- ` + problems.join("\n- "),
|
|
5145
5183
|
{ operation: "contracts.profitability" }
|
|
@@ -5188,23 +5226,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5188
5226
|
const byKey = /* @__PURE__ */ new Map();
|
|
5189
5227
|
const misses = [];
|
|
5190
5228
|
const notes = [];
|
|
5191
|
-
for (let c = 0; c < unique.length; c +=
|
|
5192
|
-
const chunk = unique.slice(c, c +
|
|
5229
|
+
for (let c = 0; c < unique.length; c += _chunkLLIB4JGKcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
5230
|
+
const chunk = unique.slice(c, c + _chunkLLIB4JGKcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
5193
5231
|
const chunkKeys = new Set(chunk);
|
|
5194
5232
|
try {
|
|
5195
5233
|
const body = {
|
|
5196
|
-
MaxRecords:
|
|
5234
|
+
MaxRecords: _chunkLLIB4JGKcjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
5197
5235
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
5198
5236
|
IncludeFields: fields
|
|
5199
5237
|
};
|
|
5200
5238
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
5201
|
-
const { items: rows } =
|
|
5239
|
+
const { items: rows } = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, operation);
|
|
5202
5240
|
for (const row of rows) {
|
|
5203
5241
|
const k = num(row.id);
|
|
5204
5242
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
5205
5243
|
}
|
|
5206
5244
|
} catch (err) {
|
|
5207
|
-
const code = err instanceof
|
|
5245
|
+
const code = err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
5208
5246
|
for (const k of chunk) {
|
|
5209
5247
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
5210
5248
|
}
|
|
@@ -5214,11 +5252,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5214
5252
|
for (const k of queryMissed) {
|
|
5215
5253
|
try {
|
|
5216
5254
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
5217
|
-
byKey.set(k,
|
|
5255
|
+
byKey.set(k, _chunkLLIB4JGKcjs.unwrapItem.call(void 0, res, k, operation, entity));
|
|
5218
5256
|
} catch (err) {
|
|
5219
|
-
if (err instanceof
|
|
5257
|
+
if (err instanceof _chunkLLIB4JGKcjs.NotFoundError) {
|
|
5220
5258
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
5221
|
-
} else if (err instanceof
|
|
5259
|
+
} else if (err instanceof _chunkLLIB4JGKcjs.AutotaskError) {
|
|
5222
5260
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
5223
5261
|
} else {
|
|
5224
5262
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -5272,7 +5310,7 @@ async function degradable(read) {
|
|
|
5272
5310
|
try {
|
|
5273
5311
|
return await read();
|
|
5274
5312
|
} catch (err) {
|
|
5275
|
-
if (!(err instanceof
|
|
5313
|
+
if (!(err instanceof _chunkLLIB4JGKcjs.AutotaskError)) throw err;
|
|
5276
5314
|
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
5277
5315
|
}
|
|
5278
5316
|
}
|
|
@@ -5292,15 +5330,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
|
|
|
5292
5330
|
status: st.status,
|
|
5293
5331
|
blindSurface: st.blindSurface,
|
|
5294
5332
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
5295
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5333
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkLLIB4JGKcjs.EMPTY_REASON_STAMPS, 'access', _52 => _52[key], 'optionalAccess', _53 => _53.query]) : void 0
|
|
5296
5334
|
};
|
|
5297
5335
|
};
|
|
5298
5336
|
function appendWiresNote(wires, note) {
|
|
5299
5337
|
wires.note = (wires.note ? wires.note + " | " : "") + note;
|
|
5300
5338
|
}
|
|
5301
5339
|
function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
5302
|
-
const
|
|
5303
|
-
const id =
|
|
5340
|
+
const OP11 = PROFITABILITY_OP;
|
|
5341
|
+
const id = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5304
5342
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
5305
5343
|
const wires = { issued: 0, requests: 0, budget };
|
|
5306
5344
|
const toExcl = dayAfter(v.dateTo);
|
|
@@ -5311,19 +5349,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
|
5311
5349
|
} };
|
|
5312
5350
|
const readPart = (path, conditions, fields) => {
|
|
5313
5351
|
wires.issued += 1;
|
|
5314
|
-
return degradable(() => boundedPart(http, path, conditions, v.limit,
|
|
5352
|
+
return degradable(() => boundedPart(http, path, conditions, v.limit, OP11, fields));
|
|
5315
5353
|
};
|
|
5316
5354
|
const truncatedMonths = {};
|
|
5317
5355
|
const windowedPart = async (name, key, path, cond, fields, dateField) => {
|
|
5318
5356
|
const first = await readPart(path, cond, fields);
|
|
5319
5357
|
if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
|
|
5320
|
-
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit,
|
|
5358
|
+
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP11, fields, dateField, v.dateFrom, v.dateTo, wires));
|
|
5321
5359
|
if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
|
|
5322
5360
|
const { truncatedMonths: tm, ...part } = wp;
|
|
5323
5361
|
truncatedMonths[name] = tm;
|
|
5324
5362
|
return { part, rows: wp.items };
|
|
5325
5363
|
};
|
|
5326
|
-
return { v, OP:
|
|
5364
|
+
return { v, OP: OP11, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
|
|
5327
5365
|
}
|
|
5328
5366
|
|
|
5329
5367
|
// src/resources/special/contracts/profitability.stages.ts
|
|
@@ -5338,12 +5376,12 @@ async function fetchCustomer(ctx, companyID) {
|
|
|
5338
5376
|
path: `/V1.0/Companies/${companyID}`,
|
|
5339
5377
|
operation: ctx.OP
|
|
5340
5378
|
});
|
|
5341
|
-
const item =
|
|
5379
|
+
const item = _chunkLLIB4JGKcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
|
|
5342
5380
|
customer = _nullishCoalesce(item, () => ( null));
|
|
5343
5381
|
customerStatus = "ok";
|
|
5344
5382
|
} catch (err) {
|
|
5345
|
-
if (!(err instanceof
|
|
5346
|
-
if (!(err instanceof
|
|
5383
|
+
if (!(err instanceof _chunkLLIB4JGKcjs.AutotaskError)) throw err;
|
|
5384
|
+
if (!(err instanceof _chunkLLIB4JGKcjs.NotFoundError)) {
|
|
5347
5385
|
customerStatus = "absent";
|
|
5348
5386
|
customerAbsent = err.code;
|
|
5349
5387
|
}
|
|
@@ -5359,7 +5397,7 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5359
5397
|
try {
|
|
5360
5398
|
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _54 => _54.get, 'call', async _55 => _55("contractType"), 'optionalAccess', async _56 => _56.get, 'call', async _57 => _57(contractType)]), async () => ( null));
|
|
5361
5399
|
} catch (err) {
|
|
5362
|
-
if (!(err instanceof
|
|
5400
|
+
if (!(err instanceof _chunkLLIB4JGKcjs.AutotaskError)) throw err;
|
|
5363
5401
|
}
|
|
5364
5402
|
}
|
|
5365
5403
|
const contractTypeKnown = contractTypeLabel !== null;
|
|
@@ -5421,8 +5459,8 @@ async function fetchInvoices(ctx, billingRows) {
|
|
|
5421
5459
|
if (invoiceIds.length === 0) {
|
|
5422
5460
|
return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
|
|
5423
5461
|
}
|
|
5424
|
-
const capped = capJoinSet2(invoiceIds,
|
|
5425
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${
|
|
5462
|
+
const capped = capJoinSet2(invoiceIds, _chunkLLIB4JGKcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5463
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunkLLIB4JGKcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5426
5464
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
|
|
5427
5465
|
ctx.wires.issued += 1;
|
|
5428
5466
|
return {
|
|
@@ -5468,7 +5506,7 @@ async function readOpenStatusSet(ctx) {
|
|
|
5468
5506
|
}
|
|
5469
5507
|
}
|
|
5470
5508
|
} catch (err) {
|
|
5471
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof
|
|
5509
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkLLIB4JGKcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5472
5510
|
}
|
|
5473
5511
|
return { openStatusSet, statusNote };
|
|
5474
5512
|
}
|
|
@@ -5491,8 +5529,8 @@ async function fetchResources(ctx, entries) {
|
|
|
5491
5529
|
if (resourceIds.length === 0) {
|
|
5492
5530
|
return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
|
|
5493
5531
|
}
|
|
5494
|
-
const capped = capJoinSet2(resourceIds,
|
|
5495
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${
|
|
5532
|
+
const capped = capJoinSet2(resourceIds, _chunkLLIB4JGKcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5533
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunkLLIB4JGKcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5496
5534
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
|
|
5497
5535
|
ctx.wires.issued += 1;
|
|
5498
5536
|
for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
|
|
@@ -5559,7 +5597,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
|
|
|
5559
5597
|
try {
|
|
5560
5598
|
return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
|
|
5561
5599
|
} catch (err) {
|
|
5562
|
-
if (!(err instanceof
|
|
5600
|
+
if (!(err instanceof _chunkLLIB4JGKcjs.AutotaskError)) throw err;
|
|
5563
5601
|
return null;
|
|
5564
5602
|
}
|
|
5565
5603
|
}
|
|
@@ -5576,7 +5614,7 @@ async function fetchSubscriptions(ctx, cis) {
|
|
|
5576
5614
|
cancelledSubs
|
|
5577
5615
|
};
|
|
5578
5616
|
}
|
|
5579
|
-
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0),
|
|
5617
|
+
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunkLLIB4JGKcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5580
5618
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5581
5619
|
const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5582
5620
|
const subscriptions = raw.items;
|
|
@@ -6261,7 +6299,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
6261
6299
|
}
|
|
6262
6300
|
|
|
6263
6301
|
// src/resources/contracts.ts
|
|
6264
|
-
var ContractsResource = class extends
|
|
6302
|
+
var ContractsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6265
6303
|
constructor(http, pageSize) {
|
|
6266
6304
|
super(http, {
|
|
6267
6305
|
key: "contracts",
|
|
@@ -6329,10 +6367,14 @@ var ContractsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6329
6367
|
profitability(id, opts) {
|
|
6330
6368
|
return profitability(this, id, opts, this.http);
|
|
6331
6369
|
}
|
|
6370
|
+
/** Node-parity special op (hand-written in src/resources/special/contracts.ts). */
|
|
6371
|
+
lineOfBusiness(contractId, associationId) {
|
|
6372
|
+
return lineOfBusiness(this, contractId, this.http, associationId);
|
|
6373
|
+
}
|
|
6332
6374
|
};
|
|
6333
6375
|
|
|
6334
6376
|
// src/resources/contract_ticket_purchases.ts
|
|
6335
|
-
var ContractTicketPurchasesResource = class extends
|
|
6377
|
+
var ContractTicketPurchasesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6336
6378
|
constructor(http, pageSize) {
|
|
6337
6379
|
super(http, {
|
|
6338
6380
|
key: "contract_ticket_purchases",
|
|
@@ -6391,7 +6433,7 @@ var ContractTicketPurchasesResource = class extends _chunkD5IVS6GYcjs.BaseResour
|
|
|
6391
6433
|
};
|
|
6392
6434
|
|
|
6393
6435
|
// src/resources/countries.ts
|
|
6394
|
-
var CountriesResource = class extends
|
|
6436
|
+
var CountriesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6395
6437
|
constructor(http, pageSize) {
|
|
6396
6438
|
super(http, {
|
|
6397
6439
|
key: "countries",
|
|
@@ -6450,7 +6492,7 @@ var CountriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6450
6492
|
};
|
|
6451
6493
|
|
|
6452
6494
|
// src/resources/currencies.ts
|
|
6453
|
-
var CurrenciesResource = class extends
|
|
6495
|
+
var CurrenciesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6454
6496
|
constructor(http, pageSize) {
|
|
6455
6497
|
super(http, {
|
|
6456
6498
|
key: "currencies",
|
|
@@ -6494,7 +6536,7 @@ var CurrenciesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6494
6536
|
};
|
|
6495
6537
|
|
|
6496
6538
|
// src/resources/departments.ts
|
|
6497
|
-
var DepartmentsResource = class extends
|
|
6539
|
+
var DepartmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6498
6540
|
constructor(http, pageSize) {
|
|
6499
6541
|
super(http, {
|
|
6500
6542
|
key: "departments",
|
|
@@ -6561,7 +6603,7 @@ var DepartmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6561
6603
|
};
|
|
6562
6604
|
|
|
6563
6605
|
// src/resources/domain_registrars.ts
|
|
6564
|
-
var DomainRegistrarsResource = class extends
|
|
6606
|
+
var DomainRegistrarsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6565
6607
|
constructor(http, pageSize) {
|
|
6566
6608
|
super(http, {
|
|
6567
6609
|
key: "domain_registrars",
|
|
@@ -6644,7 +6686,7 @@ var EntityInformationResource = class {
|
|
|
6644
6686
|
};
|
|
6645
6687
|
|
|
6646
6688
|
// src/resources/expense_item_attachments.ts
|
|
6647
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6689
|
+
var ExpenseItemAttachmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6648
6690
|
constructor(http, pageSize) {
|
|
6649
6691
|
super(http, {
|
|
6650
6692
|
key: "expense_item_attachments",
|
|
@@ -6706,7 +6748,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
6706
6748
|
};
|
|
6707
6749
|
|
|
6708
6750
|
// src/resources/expense_items.ts
|
|
6709
|
-
var ExpenseItemsResource = class extends
|
|
6751
|
+
var ExpenseItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6710
6752
|
constructor(http, pageSize) {
|
|
6711
6753
|
super(http, {
|
|
6712
6754
|
key: "expense_items",
|
|
@@ -6765,7 +6807,7 @@ var ExpenseItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6765
6807
|
};
|
|
6766
6808
|
|
|
6767
6809
|
// src/resources/expense_reports.ts
|
|
6768
|
-
var ExpenseReportsResource = class extends
|
|
6810
|
+
var ExpenseReportsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6769
6811
|
constructor(http, pageSize) {
|
|
6770
6812
|
super(http, {
|
|
6771
6813
|
key: "expense_reports",
|
|
@@ -6832,7 +6874,7 @@ var ExpenseReportsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6832
6874
|
};
|
|
6833
6875
|
|
|
6834
6876
|
// src/resources/holiday_sets.ts
|
|
6835
|
-
var HolidaySetsResource = class extends
|
|
6877
|
+
var HolidaySetsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6836
6878
|
constructor(http, pageSize) {
|
|
6837
6879
|
super(http, {
|
|
6838
6880
|
key: "holiday_sets",
|
|
@@ -6901,7 +6943,7 @@ var HolidaySetsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
6901
6943
|
};
|
|
6902
6944
|
|
|
6903
6945
|
// src/resources/holidays.ts
|
|
6904
|
-
var HolidaysResource = class extends
|
|
6946
|
+
var HolidaysResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
6905
6947
|
constructor(http, pageSize) {
|
|
6906
6948
|
super(http, {
|
|
6907
6949
|
key: "holidays",
|
|
@@ -6973,10 +7015,10 @@ var PATH_SUFFIX = {
|
|
|
6973
7015
|
transfer: "StockedItemsTransfer"
|
|
6974
7016
|
};
|
|
6975
7017
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6976
|
-
const numericParent =
|
|
7018
|
+
const numericParent = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6977
7019
|
const suffix = PATH_SUFFIX[kind];
|
|
6978
7020
|
if (opts.dryRun === true) {
|
|
6979
|
-
return
|
|
7021
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
6980
7022
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6981
7023
|
method: "POST",
|
|
6982
7024
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6993,11 +7035,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6993
7035
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6994
7036
|
maxRetries: opts.maxRetries
|
|
6995
7037
|
});
|
|
6996
|
-
return
|
|
7038
|
+
return _chunkLLIB4JGKcjs.unwrapOperation.call(void 0, res);
|
|
6997
7039
|
}
|
|
6998
7040
|
|
|
6999
7041
|
// src/resources/inventory_products.ts
|
|
7000
|
-
var InventoryProductsResource = class extends
|
|
7042
|
+
var InventoryProductsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7001
7043
|
constructor(http, pageSize) {
|
|
7002
7044
|
super(http, {
|
|
7003
7045
|
key: "inventory_products",
|
|
@@ -7079,7 +7121,7 @@ var InventoryProductsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7079
7121
|
|
|
7080
7122
|
// src/resources/special/invoices.ts
|
|
7081
7123
|
async function markup(_resource, id, format, http) {
|
|
7082
|
-
const numericId =
|
|
7124
|
+
const numericId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
7083
7125
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
7084
7126
|
const res = await http.request({
|
|
7085
7127
|
method: "GET",
|
|
@@ -7088,7 +7130,7 @@ async function markup(_resource, id, format, http) {
|
|
|
7088
7130
|
});
|
|
7089
7131
|
const body = res;
|
|
7090
7132
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
7091
|
-
throw new (0,
|
|
7133
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskError)(
|
|
7092
7134
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
7093
7135
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
|
|
7094
7136
|
);
|
|
@@ -7096,13 +7138,13 @@ async function markup(_resource, id, format, http) {
|
|
|
7096
7138
|
return body.invoiceMarkup;
|
|
7097
7139
|
}
|
|
7098
7140
|
async function pdf(_resource, id, http) {
|
|
7099
|
-
const numericId =
|
|
7141
|
+
const numericId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
7100
7142
|
const res = await http.request({
|
|
7101
7143
|
method: "GET",
|
|
7102
7144
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
7103
7145
|
operation: "invoices.pdf"
|
|
7104
7146
|
});
|
|
7105
|
-
return
|
|
7147
|
+
return _chunkLLIB4JGKcjs.decodeFileData.call(void 0, res);
|
|
7106
7148
|
}
|
|
7107
7149
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
7108
7150
|
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _76 => _76.now]), () => ( /* @__PURE__ */ new Date()));
|
|
@@ -7133,7 +7175,7 @@ async function customRange2(_resource, from, to, http, opts) {
|
|
|
7133
7175
|
}
|
|
7134
7176
|
|
|
7135
7177
|
// src/resources/invoices.ts
|
|
7136
|
-
var InvoicesResource = class extends
|
|
7178
|
+
var InvoicesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7137
7179
|
constructor(http, pageSize) {
|
|
7138
7180
|
super(http, {
|
|
7139
7181
|
key: "invoices",
|
|
@@ -7247,7 +7289,7 @@ var InvoicesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7247
7289
|
};
|
|
7248
7290
|
|
|
7249
7291
|
// src/resources/invoice_templates.ts
|
|
7250
|
-
var InvoiceTemplatesResource = class extends
|
|
7292
|
+
var InvoiceTemplatesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7251
7293
|
constructor(http, pageSize) {
|
|
7252
7294
|
super(http, {
|
|
7253
7295
|
key: "invoice_templates",
|
|
@@ -7291,7 +7333,7 @@ var ModulesResource = class {
|
|
|
7291
7333
|
};
|
|
7292
7334
|
|
|
7293
7335
|
// src/resources/notification_history.ts
|
|
7294
|
-
var NotificationHistoryResource = class extends
|
|
7336
|
+
var NotificationHistoryResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7295
7337
|
constructor(http, pageSize) {
|
|
7296
7338
|
super(http, {
|
|
7297
7339
|
key: "notification_history",
|
|
@@ -7330,7 +7372,7 @@ var NotificationHistoryResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7330
7372
|
};
|
|
7331
7373
|
|
|
7332
7374
|
// src/resources/opportunities.ts
|
|
7333
|
-
var OpportunitiesResource = class extends
|
|
7375
|
+
var OpportunitiesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7334
7376
|
constructor(http, pageSize) {
|
|
7335
7377
|
super(http, {
|
|
7336
7378
|
key: "opportunities",
|
|
@@ -7392,7 +7434,7 @@ var OpportunitiesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7392
7434
|
};
|
|
7393
7435
|
|
|
7394
7436
|
// src/resources/opportunity_attachments.ts
|
|
7395
|
-
var OpportunityAttachmentsResource = class extends
|
|
7437
|
+
var OpportunityAttachmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7396
7438
|
constructor(http, pageSize) {
|
|
7397
7439
|
super(http, {
|
|
7398
7440
|
key: "opportunity_attachments",
|
|
@@ -7454,7 +7496,7 @@ var OpportunityAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
7454
7496
|
};
|
|
7455
7497
|
|
|
7456
7498
|
// src/resources/opportunity_categories.ts
|
|
7457
|
-
var OpportunityCategoriesResource = class extends
|
|
7499
|
+
var OpportunityCategoriesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7458
7500
|
constructor(http, pageSize) {
|
|
7459
7501
|
super(http, {
|
|
7460
7502
|
key: "opportunity_categories",
|
|
@@ -7513,7 +7555,7 @@ var OpportunityCategoriesResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
7513
7555
|
};
|
|
7514
7556
|
|
|
7515
7557
|
// src/resources/organizational_level1s.ts
|
|
7516
|
-
var OrganizationalLevel1sResource = class extends
|
|
7558
|
+
var OrganizationalLevel1sResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7517
7559
|
constructor(http, pageSize) {
|
|
7518
7560
|
super(http, {
|
|
7519
7561
|
key: "organizational_level1s",
|
|
@@ -7564,7 +7606,7 @@ var OrganizationalLevel1sResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
7564
7606
|
};
|
|
7565
7607
|
|
|
7566
7608
|
// src/resources/organizational_level2s.ts
|
|
7567
|
-
var OrganizationalLevel2sResource = class extends
|
|
7609
|
+
var OrganizationalLevel2sResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7568
7610
|
constructor(http, pageSize) {
|
|
7569
7611
|
super(http, {
|
|
7570
7612
|
key: "organizational_level2s",
|
|
@@ -7615,7 +7657,7 @@ var OrganizationalLevel2sResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
7615
7657
|
};
|
|
7616
7658
|
|
|
7617
7659
|
// src/resources/organizational_level_associations.ts
|
|
7618
|
-
var OrganizationalLevelAssociationsResource = class extends
|
|
7660
|
+
var OrganizationalLevelAssociationsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7619
7661
|
constructor(http, pageSize) {
|
|
7620
7662
|
super(http, {
|
|
7621
7663
|
key: "organizational_level_associations",
|
|
@@ -7666,7 +7708,7 @@ var OrganizationalLevelAssociationsResource = class extends _chunkD5IVS6GYcjs.Ba
|
|
|
7666
7708
|
};
|
|
7667
7709
|
|
|
7668
7710
|
// src/resources/phases.ts
|
|
7669
|
-
var PhasesResource = class extends
|
|
7711
|
+
var PhasesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7670
7712
|
constructor(http, pageSize) {
|
|
7671
7713
|
super(http, {
|
|
7672
7714
|
key: "phases",
|
|
@@ -7725,7 +7767,7 @@ var PhasesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7725
7767
|
};
|
|
7726
7768
|
|
|
7727
7769
|
// src/resources/products.ts
|
|
7728
|
-
var ProductsResource = class extends
|
|
7770
|
+
var ProductsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7729
7771
|
constructor(http, pageSize) {
|
|
7730
7772
|
super(http, {
|
|
7731
7773
|
key: "products",
|
|
@@ -7792,7 +7834,7 @@ var ProductsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7792
7834
|
};
|
|
7793
7835
|
|
|
7794
7836
|
// src/resources/product_vendors.ts
|
|
7795
|
-
var ProductVendorsResource = class extends
|
|
7837
|
+
var ProductVendorsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7796
7838
|
constructor(http, pageSize) {
|
|
7797
7839
|
super(http, {
|
|
7798
7840
|
key: "product_vendors",
|
|
@@ -7851,7 +7893,7 @@ var ProductVendorsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7851
7893
|
};
|
|
7852
7894
|
|
|
7853
7895
|
// src/resources/project_charges.ts
|
|
7854
|
-
var ProjectChargesResource = class extends
|
|
7896
|
+
var ProjectChargesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7855
7897
|
constructor(http, pageSize) {
|
|
7856
7898
|
super(http, {
|
|
7857
7899
|
key: "project_charges",
|
|
@@ -7922,7 +7964,7 @@ var ProjectChargesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7922
7964
|
};
|
|
7923
7965
|
|
|
7924
7966
|
// src/resources/project_notes.ts
|
|
7925
|
-
var ProjectNotesResource = class extends
|
|
7967
|
+
var ProjectNotesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7926
7968
|
constructor(http, pageSize) {
|
|
7927
7969
|
super(http, {
|
|
7928
7970
|
key: "project_notes",
|
|
@@ -7981,7 +8023,7 @@ var ProjectNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
7981
8023
|
};
|
|
7982
8024
|
|
|
7983
8025
|
// src/resources/projects.ts
|
|
7984
|
-
var ProjectsResource = class extends
|
|
8026
|
+
var ProjectsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
7985
8027
|
constructor(http, pageSize) {
|
|
7986
8028
|
super(http, {
|
|
7987
8029
|
key: "projects",
|
|
@@ -8058,13 +8100,13 @@ var ProjectsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8058
8100
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
8059
8101
|
const result = { project: project2, company, opportunity, leadResource };
|
|
8060
8102
|
if (opts.names === true) {
|
|
8061
|
-
const builder =
|
|
8103
|
+
const builder = _chunkLLIB4JGKcjs.createNamePlan.call(void 0, );
|
|
8062
8104
|
builder.addResource(root["creatorResourceID"]);
|
|
8063
8105
|
builder.addFk("contract", root["contractID"]);
|
|
8064
|
-
const names = await
|
|
8106
|
+
const names = await _chunkLLIB4JGKcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
8065
8107
|
const row = { ...project2 };
|
|
8066
|
-
|
|
8067
|
-
|
|
8108
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
8109
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
8068
8110
|
result.project = row;
|
|
8069
8111
|
result.names = names.section;
|
|
8070
8112
|
}
|
|
@@ -8073,7 +8115,7 @@ var ProjectsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8073
8115
|
};
|
|
8074
8116
|
|
|
8075
8117
|
// src/resources/purchase_approvals.ts
|
|
8076
|
-
var PurchaseApprovalsResource = class extends
|
|
8118
|
+
var PurchaseApprovalsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8077
8119
|
constructor(http, pageSize) {
|
|
8078
8120
|
super(http, {
|
|
8079
8121
|
key: "purchase_approvals",
|
|
@@ -8127,7 +8169,7 @@ var PurchaseApprovalsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8127
8169
|
};
|
|
8128
8170
|
|
|
8129
8171
|
// src/resources/purchase_order_item_receiving.ts
|
|
8130
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
8172
|
+
var PurchaseOrderItemReceivingResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8131
8173
|
constructor(http, pageSize) {
|
|
8132
8174
|
super(http, {
|
|
8133
8175
|
key: "purchase_order_item_receiving",
|
|
@@ -8177,7 +8219,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkD5IVS6GYcjs.BaseRes
|
|
|
8177
8219
|
};
|
|
8178
8220
|
|
|
8179
8221
|
// src/resources/purchase_order_items.ts
|
|
8180
|
-
var PurchaseOrderItemsResource = class extends
|
|
8222
|
+
var PurchaseOrderItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8181
8223
|
constructor(http, pageSize) {
|
|
8182
8224
|
super(http, {
|
|
8183
8225
|
key: "purchase_order_items",
|
|
@@ -8236,7 +8278,7 @@ var PurchaseOrderItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8236
8278
|
};
|
|
8237
8279
|
|
|
8238
8280
|
// src/resources/purchase_orders.ts
|
|
8239
|
-
var PurchaseOrdersResource = class extends
|
|
8281
|
+
var PurchaseOrdersResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8240
8282
|
constructor(http, pageSize) {
|
|
8241
8283
|
super(http, {
|
|
8242
8284
|
key: "purchase_orders",
|
|
@@ -8298,7 +8340,7 @@ var PurchaseOrdersResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8298
8340
|
};
|
|
8299
8341
|
|
|
8300
8342
|
// src/resources/quote_items.ts
|
|
8301
|
-
var QuoteItemsResource = class extends
|
|
8343
|
+
var QuoteItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8302
8344
|
constructor(http, pageSize) {
|
|
8303
8345
|
super(http, {
|
|
8304
8346
|
key: "quote_items",
|
|
@@ -8369,7 +8411,7 @@ var QuoteItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8369
8411
|
};
|
|
8370
8412
|
|
|
8371
8413
|
// src/resources/quote_locations.ts
|
|
8372
|
-
var QuoteLocationsResource = class extends
|
|
8414
|
+
var QuoteLocationsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8373
8415
|
constructor(http, pageSize) {
|
|
8374
8416
|
super(http, {
|
|
8375
8417
|
key: "quote_locations",
|
|
@@ -8434,7 +8476,7 @@ var QuoteLocationsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8434
8476
|
};
|
|
8435
8477
|
|
|
8436
8478
|
// src/resources/quotes.ts
|
|
8437
|
-
var QuotesResource = class extends
|
|
8479
|
+
var QuotesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8438
8480
|
constructor(http, pageSize) {
|
|
8439
8481
|
super(http, {
|
|
8440
8482
|
key: "quotes",
|
|
@@ -8501,7 +8543,7 @@ var QuotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8501
8543
|
};
|
|
8502
8544
|
|
|
8503
8545
|
// src/resources/quote_templates.ts
|
|
8504
|
-
var QuoteTemplatesResource = class extends
|
|
8546
|
+
var QuoteTemplatesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8505
8547
|
constructor(http, pageSize) {
|
|
8506
8548
|
super(http, {
|
|
8507
8549
|
key: "quote_templates",
|
|
@@ -8545,7 +8587,7 @@ var QuoteTemplatesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8545
8587
|
};
|
|
8546
8588
|
|
|
8547
8589
|
// src/resources/resource_role_queues.ts
|
|
8548
|
-
var ResourceRoleQueuesResource = class extends
|
|
8590
|
+
var ResourceRoleQueuesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8549
8591
|
constructor(http, pageSize) {
|
|
8550
8592
|
super(http, {
|
|
8551
8593
|
key: "resource_role_queues",
|
|
@@ -8604,7 +8646,7 @@ var ResourceRoleQueuesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8604
8646
|
};
|
|
8605
8647
|
|
|
8606
8648
|
// src/resources/resource_roles.ts
|
|
8607
|
-
var ResourceRolesResource = class extends
|
|
8649
|
+
var ResourceRolesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8608
8650
|
constructor(http, pageSize) {
|
|
8609
8651
|
super(http, {
|
|
8610
8652
|
key: "resource_roles",
|
|
@@ -8646,7 +8688,7 @@ var ResourceRolesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8646
8688
|
};
|
|
8647
8689
|
|
|
8648
8690
|
// src/resources/resource_skills.ts
|
|
8649
|
-
var ResourceSkillsResource = class extends
|
|
8691
|
+
var ResourceSkillsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8650
8692
|
constructor(http, pageSize) {
|
|
8651
8693
|
super(http, {
|
|
8652
8694
|
key: "resource_skills",
|
|
@@ -8700,16 +8742,16 @@ var ResourceSkillsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8700
8742
|
var MAX_TRANSFER_IDS = 500;
|
|
8701
8743
|
function requirePositiveIds(ids2, label) {
|
|
8702
8744
|
if (!Array.isArray(ids2) || ids2.length === 0) {
|
|
8703
|
-
throw new (0,
|
|
8745
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8704
8746
|
}
|
|
8705
8747
|
if (ids2.length > MAX_TRANSFER_IDS) {
|
|
8706
|
-
throw new (0,
|
|
8748
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8707
8749
|
}
|
|
8708
8750
|
const out = [];
|
|
8709
8751
|
for (const raw of ids2) {
|
|
8710
|
-
const id =
|
|
8752
|
+
const id = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8711
8753
|
if (typeof id === "number" && id < 1) {
|
|
8712
|
-
throw new (0,
|
|
8754
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8713
8755
|
}
|
|
8714
8756
|
out.push(id);
|
|
8715
8757
|
}
|
|
@@ -8717,7 +8759,7 @@ function requirePositiveIds(ids2, label) {
|
|
|
8717
8759
|
}
|
|
8718
8760
|
async function whoAmI(_resource, userName, http) {
|
|
8719
8761
|
const user = userName.trim();
|
|
8720
|
-
if (user === "") throw new (0,
|
|
8762
|
+
if (user === "") throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8721
8763
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8722
8764
|
const res = await http.request({
|
|
8723
8765
|
method: "POST",
|
|
@@ -8726,11 +8768,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8726
8768
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8727
8769
|
operation: "resources.whoAmI"
|
|
8728
8770
|
});
|
|
8729
|
-
const matches =
|
|
8771
|
+
const matches = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
8730
8772
|
if (matches.length === 0) return null;
|
|
8731
8773
|
if (matches.length > 1) {
|
|
8732
8774
|
const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8733
|
-
throw new (0,
|
|
8775
|
+
throw new (0, _chunkLLIB4JGKcjs.ResolutionError)(
|
|
8734
8776
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8735
8777
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
8736
8778
|
);
|
|
@@ -8739,9 +8781,9 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8739
8781
|
}
|
|
8740
8782
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8741
8783
|
const ids2 = requirePositiveIds(companyIds, "transferOwnership");
|
|
8742
|
-
const destination =
|
|
8784
|
+
const destination = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8743
8785
|
if (typeof destination === "number" && destination < 1) {
|
|
8744
|
-
throw new (0,
|
|
8786
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8745
8787
|
}
|
|
8746
8788
|
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _88 => _88.dryRun]), () => ( true));
|
|
8747
8789
|
const changes = [];
|
|
@@ -8754,7 +8796,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8754
8796
|
operation: "resources.transferOwnership",
|
|
8755
8797
|
maxRetries: _optionalChain([opts, 'optionalAccess', _89 => _89.maxRetries])
|
|
8756
8798
|
});
|
|
8757
|
-
const company =
|
|
8799
|
+
const company = _chunkLLIB4JGKcjs.unwrapItem.call(void 0, res, id, void 0, "company");
|
|
8758
8800
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8759
8801
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8760
8802
|
if (!dryRun) {
|
|
@@ -8765,13 +8807,13 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8765
8807
|
operation: "resources.transferOwnership",
|
|
8766
8808
|
maxRetries: _optionalChain([opts, 'optionalAccess', _90 => _90.maxRetries])
|
|
8767
8809
|
});
|
|
8768
|
-
|
|
8810
|
+
_chunkLLIB4JGKcjs.unwrapOperation.call(void 0, update);
|
|
8769
8811
|
applied.push(id);
|
|
8770
8812
|
}
|
|
8771
8813
|
} catch (err) {
|
|
8772
|
-
if (!dryRun && err instanceof
|
|
8814
|
+
if (!dryRun && err instanceof _chunkLLIB4JGKcjs.AutotaskError) {
|
|
8773
8815
|
err.resourceIds = [id];
|
|
8774
|
-
err.details =
|
|
8816
|
+
err.details = _chunkLLIB4JGKcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
|
|
8775
8817
|
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).`;
|
|
8776
8818
|
}
|
|
8777
8819
|
throw err;
|
|
@@ -8780,7 +8822,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8780
8822
|
if (dryRun) {
|
|
8781
8823
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8782
8824
|
return {
|
|
8783
|
-
...
|
|
8825
|
+
..._chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
8784
8826
|
operation: "resources.transferOwnership",
|
|
8785
8827
|
method: "PUT",
|
|
8786
8828
|
path: "/V1.0/Companies",
|
|
@@ -8804,7 +8846,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8804
8846
|
}
|
|
8805
8847
|
|
|
8806
8848
|
// src/resources/resources.ts
|
|
8807
|
-
var ResourcesResource = class extends
|
|
8849
|
+
var ResourcesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8808
8850
|
|
|
8809
8851
|
constructor(http, clientConfig, pageSize) {
|
|
8810
8852
|
super(http, {
|
|
@@ -8877,7 +8919,7 @@ var ResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
8877
8919
|
|
|
8878
8920
|
// src/resources/special/resource_time_off_additional.ts
|
|
8879
8921
|
async function getByResource(_resource, resourceId, http) {
|
|
8880
|
-
const numericResource =
|
|
8922
|
+
const numericResource = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8881
8923
|
const res = await http.request({
|
|
8882
8924
|
method: "GET",
|
|
8883
8925
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8891,11 +8933,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8891
8933
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8892
8934
|
}
|
|
8893
8935
|
}
|
|
8894
|
-
return
|
|
8936
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8895
8937
|
}
|
|
8896
8938
|
|
|
8897
8939
|
// src/resources/resource_time_off_additional.ts
|
|
8898
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8940
|
+
var ResourceTimeOffAdditionalResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8899
8941
|
constructor(http, pageSize) {
|
|
8900
8942
|
super(http, {
|
|
8901
8943
|
key: "resource_time_off_additional",
|
|
@@ -8934,7 +8976,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkD5IVS6GYcjs.BaseReso
|
|
|
8934
8976
|
};
|
|
8935
8977
|
|
|
8936
8978
|
// src/resources/resource_time_off_approvers.ts
|
|
8937
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8979
|
+
var ResourceTimeOffApproversResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
8938
8980
|
constructor(http, pageSize) {
|
|
8939
8981
|
super(http, {
|
|
8940
8982
|
key: "resource_time_off_approvers",
|
|
@@ -8977,29 +9019,29 @@ var ResourceTimeOffApproversResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
8977
9019
|
|
|
8978
9020
|
// src/resources/special/resource_time_off_balances.ts
|
|
8979
9021
|
async function getByResource2(_resource, resourceId, http) {
|
|
8980
|
-
const numericResource =
|
|
9022
|
+
const numericResource = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8981
9023
|
const res = await http.request({
|
|
8982
9024
|
method: "GET",
|
|
8983
9025
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8984
9026
|
operation: "resource_time_off_balances.getByResource"
|
|
8985
9027
|
});
|
|
8986
|
-
return
|
|
9028
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8987
9029
|
}
|
|
8988
9030
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8989
|
-
const numericResource =
|
|
9031
|
+
const numericResource = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8990
9032
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8991
|
-
throw new (0,
|
|
9033
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8992
9034
|
}
|
|
8993
9035
|
const res = await http.request({
|
|
8994
9036
|
method: "GET",
|
|
8995
9037
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8996
9038
|
operation: "resource_time_off_balances.getByYear"
|
|
8997
9039
|
});
|
|
8998
|
-
return
|
|
9040
|
+
return _chunkLLIB4JGKcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
8999
9041
|
}
|
|
9000
9042
|
|
|
9001
9043
|
// src/resources/resource_time_off_balances.ts
|
|
9002
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
9044
|
+
var ResourceTimeOffBalancesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9003
9045
|
constructor(http, pageSize) {
|
|
9004
9046
|
super(http, {
|
|
9005
9047
|
key: "resource_time_off_balances",
|
|
@@ -9037,7 +9079,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkD5IVS6GYcjs.BaseResour
|
|
|
9037
9079
|
};
|
|
9038
9080
|
|
|
9039
9081
|
// src/resources/roles.ts
|
|
9040
|
-
var RolesResource = class extends
|
|
9082
|
+
var RolesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9041
9083
|
constructor(http, pageSize) {
|
|
9042
9084
|
super(http, {
|
|
9043
9085
|
key: "roles",
|
|
@@ -9104,7 +9146,7 @@ var RolesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9104
9146
|
};
|
|
9105
9147
|
|
|
9106
9148
|
// src/resources/sales_orders.ts
|
|
9107
|
-
var SalesOrdersResource = class extends
|
|
9149
|
+
var SalesOrdersResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9108
9150
|
constructor(http, pageSize) {
|
|
9109
9151
|
super(http, {
|
|
9110
9152
|
key: "sales_orders",
|
|
@@ -9147,7 +9189,7 @@ var SalesOrdersResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9147
9189
|
};
|
|
9148
9190
|
|
|
9149
9191
|
// src/resources/service_calls.ts
|
|
9150
|
-
var ServiceCallsResource = class extends
|
|
9192
|
+
var ServiceCallsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9151
9193
|
constructor(http, pageSize) {
|
|
9152
9194
|
super(http, {
|
|
9153
9195
|
key: "service_calls",
|
|
@@ -9216,7 +9258,7 @@ var ServiceCallsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9216
9258
|
};
|
|
9217
9259
|
|
|
9218
9260
|
// src/resources/service_call_task_resources.ts
|
|
9219
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
9261
|
+
var ServiceCallTaskResourcesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9220
9262
|
constructor(http, pageSize) {
|
|
9221
9263
|
super(http, {
|
|
9222
9264
|
key: "service_call_task_resources",
|
|
@@ -9273,7 +9315,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
9273
9315
|
};
|
|
9274
9316
|
|
|
9275
9317
|
// src/resources/service_call_tasks.ts
|
|
9276
|
-
var ServiceCallTasksResource = class extends
|
|
9318
|
+
var ServiceCallTasksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9277
9319
|
constructor(http, pageSize) {
|
|
9278
9320
|
super(http, {
|
|
9279
9321
|
key: "service_call_tasks",
|
|
@@ -9330,7 +9372,7 @@ var ServiceCallTasksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9330
9372
|
};
|
|
9331
9373
|
|
|
9332
9374
|
// src/resources/service_call_ticket_resources.ts
|
|
9333
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
9375
|
+
var ServiceCallTicketResourcesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9334
9376
|
constructor(http, pageSize) {
|
|
9335
9377
|
super(http, {
|
|
9336
9378
|
key: "service_call_ticket_resources",
|
|
@@ -9387,7 +9429,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkD5IVS6GYcjs.BaseRes
|
|
|
9387
9429
|
};
|
|
9388
9430
|
|
|
9389
9431
|
// src/resources/service_call_tickets.ts
|
|
9390
|
-
var ServiceCallTicketsResource = class extends
|
|
9432
|
+
var ServiceCallTicketsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9391
9433
|
constructor(http, pageSize) {
|
|
9392
9434
|
super(http, {
|
|
9393
9435
|
key: "service_call_tickets",
|
|
@@ -9444,7 +9486,7 @@ var ServiceCallTicketsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9444
9486
|
};
|
|
9445
9487
|
|
|
9446
9488
|
// src/resources/service_level_agreement_results.ts
|
|
9447
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
9489
|
+
var ServiceLevelAgreementResultsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9448
9490
|
constructor(http, pageSize) {
|
|
9449
9491
|
super(http, {
|
|
9450
9492
|
key: "service_level_agreement_results",
|
|
@@ -9483,7 +9525,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkD5IVS6GYcjs.BaseR
|
|
|
9483
9525
|
};
|
|
9484
9526
|
|
|
9485
9527
|
// src/resources/services.ts
|
|
9486
|
-
var ServicesResource = class extends
|
|
9528
|
+
var ServicesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9487
9529
|
constructor(http, pageSize) {
|
|
9488
9530
|
super(http, {
|
|
9489
9531
|
key: "services",
|
|
@@ -9551,7 +9593,7 @@ var ServicesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9551
9593
|
};
|
|
9552
9594
|
|
|
9553
9595
|
// src/resources/skills.ts
|
|
9554
|
-
var SkillsResource = class extends
|
|
9596
|
+
var SkillsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9555
9597
|
constructor(http, pageSize) {
|
|
9556
9598
|
super(http, {
|
|
9557
9599
|
key: "skills",
|
|
@@ -9595,7 +9637,7 @@ var SkillsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9595
9637
|
};
|
|
9596
9638
|
|
|
9597
9639
|
// src/resources/subscription_periods.ts
|
|
9598
|
-
var SubscriptionPeriodsResource = class extends
|
|
9640
|
+
var SubscriptionPeriodsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9599
9641
|
constructor(http, pageSize) {
|
|
9600
9642
|
super(http, {
|
|
9601
9643
|
key: "subscription_periods",
|
|
@@ -9634,7 +9676,7 @@ var SubscriptionPeriodsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9634
9676
|
};
|
|
9635
9677
|
|
|
9636
9678
|
// src/resources/subscriptions.ts
|
|
9637
|
-
var SubscriptionsResource = class extends
|
|
9679
|
+
var SubscriptionsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9638
9680
|
constructor(http, pageSize) {
|
|
9639
9681
|
super(http, {
|
|
9640
9682
|
key: "subscriptions",
|
|
@@ -9703,7 +9745,7 @@ var SubscriptionsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9703
9745
|
};
|
|
9704
9746
|
|
|
9705
9747
|
// src/resources/survey_results.ts
|
|
9706
|
-
var SurveyResultsResource = class extends
|
|
9748
|
+
var SurveyResultsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9707
9749
|
constructor(http, pageSize) {
|
|
9708
9750
|
super(http, {
|
|
9709
9751
|
key: "survey_results",
|
|
@@ -9742,7 +9784,7 @@ var SurveyResultsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9742
9784
|
};
|
|
9743
9785
|
|
|
9744
9786
|
// src/resources/surveys.ts
|
|
9745
|
-
var SurveysResource = class extends
|
|
9787
|
+
var SurveysResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9746
9788
|
constructor(http, pageSize) {
|
|
9747
9789
|
super(http, {
|
|
9748
9790
|
key: "surveys",
|
|
@@ -9786,7 +9828,7 @@ var SurveysResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9786
9828
|
};
|
|
9787
9829
|
|
|
9788
9830
|
// src/resources/tag_aliases.ts
|
|
9789
|
-
var TagAliasesResource = class extends
|
|
9831
|
+
var TagAliasesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9790
9832
|
constructor(http, pageSize) {
|
|
9791
9833
|
super(http, {
|
|
9792
9834
|
key: "tag_aliases",
|
|
@@ -9843,7 +9885,7 @@ var TagAliasesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9843
9885
|
};
|
|
9844
9886
|
|
|
9845
9887
|
// src/resources/tag_groups.ts
|
|
9846
|
-
var TagGroupsResource = class extends
|
|
9888
|
+
var TagGroupsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9847
9889
|
constructor(http, pageSize) {
|
|
9848
9890
|
super(http, {
|
|
9849
9891
|
key: "tag_groups",
|
|
@@ -9912,7 +9954,7 @@ var TagGroupsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9912
9954
|
};
|
|
9913
9955
|
|
|
9914
9956
|
// src/resources/tags.ts
|
|
9915
|
-
var TagsResource = class extends
|
|
9957
|
+
var TagsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9916
9958
|
constructor(http, pageSize) {
|
|
9917
9959
|
super(http, {
|
|
9918
9960
|
key: "tags",
|
|
@@ -9981,7 +10023,7 @@ var TagsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
9981
10023
|
};
|
|
9982
10024
|
|
|
9983
10025
|
// src/resources/task_secondary_resources.ts
|
|
9984
|
-
var TaskSecondaryResourcesResource = class extends
|
|
10026
|
+
var TaskSecondaryResourcesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
9985
10027
|
constructor(http, pageSize) {
|
|
9986
10028
|
super(http, {
|
|
9987
10029
|
key: "task_secondary_resources",
|
|
@@ -10038,7 +10080,7 @@ var TaskSecondaryResourcesResource = class extends _chunkD5IVS6GYcjs.BaseResourc
|
|
|
10038
10080
|
};
|
|
10039
10081
|
|
|
10040
10082
|
// src/resources/tasks.ts
|
|
10041
|
-
var TasksResource = class extends
|
|
10083
|
+
var TasksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10042
10084
|
constructor(http, pageSize) {
|
|
10043
10085
|
super(http, {
|
|
10044
10086
|
key: "tasks",
|
|
@@ -10102,7 +10144,7 @@ var TasksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
10102
10144
|
};
|
|
10103
10145
|
|
|
10104
10146
|
// src/resources/tax_regions.ts
|
|
10105
|
-
var TaxRegionsResource = class extends
|
|
10147
|
+
var TaxRegionsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10106
10148
|
constructor(http, pageSize) {
|
|
10107
10149
|
super(http, {
|
|
10108
10150
|
key: "tax_regions",
|
|
@@ -10177,7 +10219,7 @@ var ThresholdInformationResource = class {
|
|
|
10177
10219
|
};
|
|
10178
10220
|
|
|
10179
10221
|
// src/resources/ticket_additional_configuration_items.ts
|
|
10180
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
10222
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10181
10223
|
constructor(http, pageSize) {
|
|
10182
10224
|
super(http, {
|
|
10183
10225
|
key: "ticket_additional_configuration_items",
|
|
@@ -10234,7 +10276,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkD5IVS6GYcjs
|
|
|
10234
10276
|
};
|
|
10235
10277
|
|
|
10236
10278
|
// src/resources/ticket_additional_contacts.ts
|
|
10237
|
-
var TicketAdditionalContactsResource = class extends
|
|
10279
|
+
var TicketAdditionalContactsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10238
10280
|
constructor(http, pageSize) {
|
|
10239
10281
|
super(http, {
|
|
10240
10282
|
key: "ticket_additional_contacts",
|
|
@@ -10291,7 +10333,7 @@ var TicketAdditionalContactsResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
10291
10333
|
};
|
|
10292
10334
|
|
|
10293
10335
|
// src/resources/ticket_attachments.ts
|
|
10294
|
-
var TicketAttachmentsResource = class extends
|
|
10336
|
+
var TicketAttachmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10295
10337
|
constructor(http, pageSize) {
|
|
10296
10338
|
super(http, {
|
|
10297
10339
|
key: "ticket_attachments",
|
|
@@ -10353,7 +10395,7 @@ var TicketAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
10353
10395
|
};
|
|
10354
10396
|
|
|
10355
10397
|
// src/resources/ticket_categories.ts
|
|
10356
|
-
var TicketCategoriesResource = class extends
|
|
10398
|
+
var TicketCategoriesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10357
10399
|
constructor(http, pageSize) {
|
|
10358
10400
|
super(http, {
|
|
10359
10401
|
key: "ticket_categories",
|
|
@@ -10412,7 +10454,7 @@ var TicketCategoriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
10412
10454
|
};
|
|
10413
10455
|
|
|
10414
10456
|
// src/resources/ticket_category_field_defaults.ts
|
|
10415
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
10457
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10416
10458
|
constructor(http, pageSize) {
|
|
10417
10459
|
super(http, {
|
|
10418
10460
|
key: "ticket_category_field_defaults",
|
|
@@ -10454,7 +10496,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkD5IVS6GYcjs.BaseRe
|
|
|
10454
10496
|
};
|
|
10455
10497
|
|
|
10456
10498
|
// src/resources/ticket_change_request_approvals.ts
|
|
10457
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
10499
|
+
var TicketChangeRequestApprovalsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10458
10500
|
constructor(http, pageSize) {
|
|
10459
10501
|
super(http, {
|
|
10460
10502
|
key: "ticket_change_request_approvals",
|
|
@@ -10514,10 +10556,10 @@ var TicketChangeRequestApprovalsResource = class extends _chunkD5IVS6GYcjs.BaseR
|
|
|
10514
10556
|
var _crypto = require('crypto');
|
|
10515
10557
|
var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
|
|
10516
10558
|
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";
|
|
10517
|
-
var refuse = (code, message, ids2, operation, extra = {}) => new (0,
|
|
10559
|
+
var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunkLLIB4JGKcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
|
|
10518
10560
|
async function queryRows(http, resource, filter, operation, retries) {
|
|
10519
10561
|
const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
|
|
10520
|
-
return
|
|
10562
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
10521
10563
|
}
|
|
10522
10564
|
function sameValue(a, b) {
|
|
10523
10565
|
if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
|
|
@@ -10537,7 +10579,7 @@ async function readTicket(http, id, retries, operation) {
|
|
|
10537
10579
|
const item = _optionalChain([res, 'optionalAccess', _98 => _98.item]);
|
|
10538
10580
|
return _nullishCoalesce(item, () => ( null));
|
|
10539
10581
|
} catch (e) {
|
|
10540
|
-
if (
|
|
10582
|
+
if (_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
10541
10583
|
throw e;
|
|
10542
10584
|
}
|
|
10543
10585
|
}
|
|
@@ -10558,7 +10600,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10558
10600
|
}
|
|
10559
10601
|
}
|
|
10560
10602
|
const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
|
|
10561
|
-
if (!Number.isFinite(cap) || cap < 0) throw new (0,
|
|
10603
|
+
if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
|
|
10562
10604
|
const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
|
|
10563
10605
|
if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
|
|
10564
10606
|
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") });
|
|
@@ -10601,17 +10643,17 @@ async function assertNoTwin(ctx, payload) {
|
|
|
10601
10643
|
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 });
|
|
10602
10644
|
}
|
|
10603
10645
|
}
|
|
10604
|
-
var statusOf = (e) =>
|
|
10646
|
+
var statusOf = (e) => _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
|
|
10605
10647
|
async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
10606
10648
|
const op = spec.operation;
|
|
10607
|
-
const sourceId = Number(
|
|
10608
|
-
const toTicketId = Number(
|
|
10649
|
+
const sourceId = Number(_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
|
|
10650
|
+
const toTicketId = Number(_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
|
|
10609
10651
|
if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
|
|
10610
|
-
throw new (0,
|
|
10652
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
|
|
10611
10653
|
}
|
|
10612
10654
|
const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
|
|
10613
10655
|
if (opts.dryRun === true) {
|
|
10614
|
-
return
|
|
10656
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
10615
10657
|
{
|
|
10616
10658
|
operation: op,
|
|
10617
10659
|
method: "POST",
|
|
@@ -10636,22 +10678,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10636
10678
|
let newId;
|
|
10637
10679
|
try {
|
|
10638
10680
|
const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
|
|
10639
|
-
newId = Number(
|
|
10681
|
+
newId = Number(_chunkLLIB4JGKcjs.unwrapOperation.call(void 0, created, op).id);
|
|
10640
10682
|
} catch (e) {
|
|
10641
10683
|
const status = statusOf(e);
|
|
10642
10684
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
10643
|
-
throw new (0,
|
|
10685
|
+
throw new (0, _chunkLLIB4JGKcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
|
|
10644
10686
|
}
|
|
10645
|
-
throw new (0,
|
|
10687
|
+
throw new (0, _chunkLLIB4JGKcjs.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 } });
|
|
10646
10688
|
}
|
|
10647
10689
|
const rollback = async (code, message) => {
|
|
10648
10690
|
try {
|
|
10649
10691
|
await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
|
|
10650
10692
|
} catch (re) {
|
|
10651
10693
|
const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
|
|
10652
|
-
throw new (0,
|
|
10694
|
+
throw new (0, _chunkLLIB4JGKcjs.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 } });
|
|
10653
10695
|
}
|
|
10654
|
-
throw new (0,
|
|
10696
|
+
throw new (0, _chunkLLIB4JGKcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
|
|
10655
10697
|
};
|
|
10656
10698
|
const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
|
|
10657
10699
|
if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
|
|
@@ -10680,33 +10722,33 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10680
10722
|
};
|
|
10681
10723
|
}
|
|
10682
10724
|
if (status === void 0) {
|
|
10683
|
-
throw new (0,
|
|
10725
|
+
throw new (0, _chunkLLIB4JGKcjs.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 } });
|
|
10684
10726
|
}
|
|
10685
10727
|
return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
|
|
10686
10728
|
}
|
|
10687
10729
|
return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
|
|
10688
10730
|
}
|
|
10689
10731
|
function uiLinkFor(http, entity, id) {
|
|
10690
|
-
return _nullishCoalesce(
|
|
10732
|
+
return _nullishCoalesce(_chunkLLIB4JGKcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
|
|
10691
10733
|
}
|
|
10692
10734
|
|
|
10693
10735
|
// src/resources/special/ticket_charges.ts
|
|
10694
|
-
var
|
|
10736
|
+
var OP4 = "ticket_charges.moveToTicket";
|
|
10695
10737
|
var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
|
|
10696
10738
|
var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
|
|
10697
10739
|
async function readCharge(http, id, retries) {
|
|
10698
|
-
const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }],
|
|
10740
|
+
const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP4, retries);
|
|
10699
10741
|
return _nullishCoalesce(rows[0], () => ( null));
|
|
10700
10742
|
}
|
|
10701
10743
|
async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
|
|
10702
10744
|
if (source.isBilled === true) {
|
|
10703
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
10745
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP4}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP4, {
|
|
10704
10746
|
manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
|
|
10705
10747
|
});
|
|
10706
10748
|
}
|
|
10707
10749
|
}
|
|
10708
10750
|
var SPEC = {
|
|
10709
|
-
operation:
|
|
10751
|
+
operation: OP4,
|
|
10710
10752
|
entity: "ticket_charge",
|
|
10711
10753
|
readSource: readCharge,
|
|
10712
10754
|
sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
|
|
@@ -10742,7 +10784,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
|
|
|
10742
10784
|
}
|
|
10743
10785
|
|
|
10744
10786
|
// src/resources/ticket_charges.ts
|
|
10745
|
-
var TicketChargesResource = class extends
|
|
10787
|
+
var TicketChargesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10746
10788
|
constructor(http, pageSize) {
|
|
10747
10789
|
super(http, {
|
|
10748
10790
|
key: "ticket_charges",
|
|
@@ -10817,7 +10859,7 @@ var TicketChargesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
10817
10859
|
};
|
|
10818
10860
|
|
|
10819
10861
|
// src/resources/ticket_checklist_items.ts
|
|
10820
|
-
var TicketChecklistItemsResource = class extends
|
|
10862
|
+
var TicketChecklistItemsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10821
10863
|
constructor(http, pageSize) {
|
|
10822
10864
|
super(http, {
|
|
10823
10865
|
key: "ticket_checklist_items",
|
|
@@ -10883,7 +10925,7 @@ var TicketChecklistItemsResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
10883
10925
|
};
|
|
10884
10926
|
|
|
10885
10927
|
// src/resources/ticket_checklist_libraries.ts
|
|
10886
|
-
var TicketChecklistLibrariesResource = class extends
|
|
10928
|
+
var TicketChecklistLibrariesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10887
10929
|
constructor(http, pageSize) {
|
|
10888
10930
|
super(http, {
|
|
10889
10931
|
key: "ticket_checklist_libraries",
|
|
@@ -10907,9 +10949,9 @@ var TicketChecklistLibrariesResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
10907
10949
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
10908
10950
|
* surface — no documents read op — and never issues the POST). */
|
|
10909
10951
|
async attachToDocument(documentID, data, opts = {}) {
|
|
10910
|
-
const n =
|
|
10952
|
+
const n = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
10911
10953
|
if (opts.dryRun === true) {
|
|
10912
|
-
return
|
|
10954
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
10913
10955
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10914
10956
|
method: "POST",
|
|
10915
10957
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -10927,7 +10969,7 @@ var TicketChecklistLibrariesResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
10927
10969
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10928
10970
|
maxRetries: opts.maxRetries
|
|
10929
10971
|
});
|
|
10930
|
-
return
|
|
10972
|
+
return _chunkLLIB4JGKcjs.unwrapOperation.call(void 0, res);
|
|
10931
10973
|
}
|
|
10932
10974
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
10933
10975
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10943,7 +10985,7 @@ var TicketChecklistLibrariesResource = class extends _chunkD5IVS6GYcjs.BaseResou
|
|
|
10943
10985
|
};
|
|
10944
10986
|
|
|
10945
10987
|
// src/resources/ticket_history.ts
|
|
10946
|
-
var TicketHistoryResource = class extends
|
|
10988
|
+
var TicketHistoryResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10947
10989
|
constructor(http, pageSize) {
|
|
10948
10990
|
super(http, {
|
|
10949
10991
|
key: "ticket_history",
|
|
@@ -10982,7 +11024,7 @@ var TicketHistoryResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
10982
11024
|
};
|
|
10983
11025
|
|
|
10984
11026
|
// src/resources/ticket_note_attachments.ts
|
|
10985
|
-
var TicketNoteAttachmentsResource = class extends
|
|
11027
|
+
var TicketNoteAttachmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
10986
11028
|
constructor(http, pageSize) {
|
|
10987
11029
|
super(http, {
|
|
10988
11030
|
key: "ticket_note_attachments",
|
|
@@ -11044,7 +11086,7 @@ var TicketNoteAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
11044
11086
|
};
|
|
11045
11087
|
|
|
11046
11088
|
// src/resources/ticket_notes.ts
|
|
11047
|
-
var TicketNotesResource = class extends
|
|
11089
|
+
var TicketNotesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
11048
11090
|
constructor(http, pageSize) {
|
|
11049
11091
|
super(http, {
|
|
11050
11092
|
key: "ticket_notes",
|
|
@@ -11103,7 +11145,7 @@ var TicketNotesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
11103
11145
|
};
|
|
11104
11146
|
|
|
11105
11147
|
// src/resources/ticket_note_webhooks.ts
|
|
11106
|
-
var TicketNoteWebhooksResource = class extends
|
|
11148
|
+
var TicketNoteWebhooksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
11107
11149
|
constructor(http, pageSize) {
|
|
11108
11150
|
super(http, {
|
|
11109
11151
|
key: "ticket_note_webhooks",
|
|
@@ -11179,7 +11221,7 @@ var TicketNoteWebhooksResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
11179
11221
|
};
|
|
11180
11222
|
|
|
11181
11223
|
// src/resources/ticket_secondary_resources.ts
|
|
11182
|
-
var TicketSecondaryResourcesResource = class extends
|
|
11224
|
+
var TicketSecondaryResourcesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
11183
11225
|
constructor(http, pageSize) {
|
|
11184
11226
|
super(http, {
|
|
11185
11227
|
key: "ticket_secondary_resources",
|
|
@@ -11244,9 +11286,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
11244
11286
|
});
|
|
11245
11287
|
const body = res;
|
|
11246
11288
|
if (body === null || !("item" in body)) {
|
|
11247
|
-
throw new (0,
|
|
11289
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
11248
11290
|
}
|
|
11249
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
11291
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
11250
11292
|
return body.item;
|
|
11251
11293
|
}
|
|
11252
11294
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -11257,7 +11299,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
11257
11299
|
body: { MaxRecords: maxRecords, filter },
|
|
11258
11300
|
operation
|
|
11259
11301
|
});
|
|
11260
|
-
return
|
|
11302
|
+
return _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res).items;
|
|
11261
11303
|
}
|
|
11262
11304
|
function truncate(text, limit) {
|
|
11263
11305
|
const full = _nullishCoalesce(text, () => ( ""));
|
|
@@ -11267,26 +11309,26 @@ function truncate(text, limit) {
|
|
|
11267
11309
|
|
|
11268
11310
|
// src/resources/special/tickets/childRead.ts
|
|
11269
11311
|
function isRouteUnavailable(err) {
|
|
11270
|
-
return
|
|
11312
|
+
return _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
11271
11313
|
}
|
|
11272
11314
|
function routeFact(route, path, err) {
|
|
11273
11315
|
return {
|
|
11274
11316
|
route,
|
|
11275
11317
|
path,
|
|
11276
|
-
httpStatus:
|
|
11318
|
+
httpStatus: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
11277
11319
|
};
|
|
11278
11320
|
}
|
|
11279
11321
|
function childDeclaresQuery(resourceKey) {
|
|
11280
|
-
return
|
|
11322
|
+
return _chunkEDVSWL32cjs.CAPABILITIES.some(
|
|
11281
11323
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
11282
11324
|
);
|
|
11283
11325
|
}
|
|
11284
11326
|
function planScopedPath(resourceKey, ticketId) {
|
|
11285
11327
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
11286
|
-
const entry =
|
|
11328
|
+
const entry = _chunkLLIB4JGKcjs.RELATIONSHIP_MAP[resourceKey];
|
|
11287
11329
|
const parent = entry === void 0 ? null : entry.parent;
|
|
11288
11330
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
11289
|
-
const parentPath = _optionalChain([
|
|
11331
|
+
const parentPath = _optionalChain([_chunkLLIB4JGKcjs.RELATIONSHIP_MAP, 'access', _102 => _102[parent.resource], 'optionalAccess', _103 => _103.path]);
|
|
11290
11332
|
if (parentPath === null || parentPath === void 0) return null;
|
|
11291
11333
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
11292
11334
|
}
|
|
@@ -11325,14 +11367,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
11325
11367
|
break;
|
|
11326
11368
|
}
|
|
11327
11369
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
11328
|
-
const { items: pageItems, pageDetails } =
|
|
11370
|
+
const { items: pageItems, pageDetails } = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, body, operation);
|
|
11329
11371
|
nextCursor = pageDetails.nextPageUrl;
|
|
11330
11372
|
pages += 1;
|
|
11331
11373
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
11332
11374
|
for (const row of window) if (accept(row)) items.push(row);
|
|
11333
11375
|
if (items.length >= limit) break;
|
|
11334
11376
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
11335
|
-
target =
|
|
11377
|
+
target = _chunkLLIB4JGKcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
11336
11378
|
}
|
|
11337
11379
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
11338
11380
|
return { items, capped };
|
|
@@ -11365,7 +11407,7 @@ var MS = 864e5;
|
|
|
11365
11407
|
var SLA_PAGE = 100;
|
|
11366
11408
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
11367
11409
|
void opts;
|
|
11368
|
-
const ticketId =
|
|
11410
|
+
const ticketId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
11369
11411
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
11370
11412
|
const rows = await ticketQueryItems(
|
|
11371
11413
|
http,
|
|
@@ -11390,9 +11432,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
11390
11432
|
async function summary(_resource, id, opts = {}, http) {
|
|
11391
11433
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
11392
11434
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
11393
|
-
throw new (0,
|
|
11435
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
11394
11436
|
}
|
|
11395
|
-
const ticketId =
|
|
11437
|
+
const ticketId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
11396
11438
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
11397
11439
|
const desc = truncate(ticket.description, limit);
|
|
11398
11440
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -11421,11 +11463,11 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
11421
11463
|
// src/resources/special/tickets/timeline.ts
|
|
11422
11464
|
function validateTimelineLimits(opts) {
|
|
11423
11465
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
11424
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
11466
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
11425
11467
|
const bounded = Math.min(limit, 500);
|
|
11426
11468
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
11427
11469
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
11428
|
-
throw new (0,
|
|
11470
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
11429
11471
|
}
|
|
11430
11472
|
return { bounded, textLimit };
|
|
11431
11473
|
}
|
|
@@ -11477,7 +11519,7 @@ function compareEventDates(a, b) {
|
|
|
11477
11519
|
}
|
|
11478
11520
|
async function timeline(_resource, id, opts = {}, http) {
|
|
11479
11521
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
11480
|
-
const ticketId =
|
|
11522
|
+
const ticketId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
11481
11523
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
11482
11524
|
const dateFilters = (field) => {
|
|
11483
11525
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11517,7 +11559,7 @@ async function timeline(_resource, id, opts = {}, http) {
|
|
|
11517
11559
|
}
|
|
11518
11560
|
|
|
11519
11561
|
// src/resources/special/tickets/errors.ts
|
|
11520
|
-
var QueueRequiredError = class extends
|
|
11562
|
+
var QueueRequiredError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
11521
11563
|
constructor(message, options = {}) {
|
|
11522
11564
|
super(message, {
|
|
11523
11565
|
code: "QUEUE_REQUIRED",
|
|
@@ -11528,13 +11570,13 @@ var QueueRequiredError = class extends _chunkD5IVS6GYcjs.AutotaskError {
|
|
|
11528
11570
|
this.name = "QueueRequiredError";
|
|
11529
11571
|
}
|
|
11530
11572
|
};
|
|
11531
|
-
var TicketResourceInvalidError = class extends
|
|
11573
|
+
var TicketResourceInvalidError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
11532
11574
|
constructor(message, options = {}) {
|
|
11533
11575
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11534
11576
|
this.name = "TicketResourceInvalidError";
|
|
11535
11577
|
}
|
|
11536
11578
|
};
|
|
11537
|
-
var TicketCreateValidationFailedError = class extends
|
|
11579
|
+
var TicketCreateValidationFailedError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
11538
11580
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
11539
11581
|
|
|
11540
11582
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -11543,7 +11585,7 @@ var TicketCreateValidationFailedError = class extends _chunkD5IVS6GYcjs.Autotask
|
|
|
11543
11585
|
this.vendorFields = vendorFields;
|
|
11544
11586
|
}
|
|
11545
11587
|
};
|
|
11546
|
-
var StatusUnknownError = class extends
|
|
11588
|
+
var StatusUnknownError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
11547
11589
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
11548
11590
|
|
|
11549
11591
|
constructor(message, options = {}) {
|
|
@@ -11557,7 +11599,7 @@ var StatusUnknownError = class extends _chunkD5IVS6GYcjs.AutotaskError {
|
|
|
11557
11599
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
11558
11600
|
}
|
|
11559
11601
|
};
|
|
11560
|
-
var StatusFieldsRequiredError = class extends
|
|
11602
|
+
var StatusFieldsRequiredError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
11561
11603
|
|
|
11562
11604
|
|
|
11563
11605
|
|
|
@@ -11580,14 +11622,14 @@ function isPositiveInt(v) {
|
|
|
11580
11622
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
11581
11623
|
}
|
|
11582
11624
|
function namedVendorFields(err) {
|
|
11583
|
-
if (!
|
|
11584
|
-
const entries = _nullishCoalesce(
|
|
11625
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
11626
|
+
const entries = _nullishCoalesce(_chunkLLIB4JGKcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
11585
11627
|
const out = /* @__PURE__ */ new Set();
|
|
11586
11628
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
11587
11629
|
return [...out];
|
|
11588
11630
|
}
|
|
11589
11631
|
function vendorDetailOf(err) {
|
|
11590
|
-
return
|
|
11632
|
+
return _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? _chunkLLIB4JGKcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
11591
11633
|
}
|
|
11592
11634
|
async function fetchItem(http, path, operation, readOpts) {
|
|
11593
11635
|
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _104 => _104.maxRetries]) });
|
|
@@ -11608,8 +11650,8 @@ function operationId(res) {
|
|
|
11608
11650
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
11609
11651
|
}
|
|
11610
11652
|
function discoveryMerge(err, body, defaults) {
|
|
11611
|
-
if (!
|
|
11612
|
-
const entries =
|
|
11653
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11654
|
+
const entries = _chunkLLIB4JGKcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11613
11655
|
if (entries === void 0) return null;
|
|
11614
11656
|
for (const entry of entries) {
|
|
11615
11657
|
const field = entry.field;
|
|
@@ -11621,7 +11663,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
11621
11663
|
}
|
|
11622
11664
|
function stepErrorText(code, err) {
|
|
11623
11665
|
const detail = vendorDetailOf(err);
|
|
11624
|
-
const base =
|
|
11666
|
+
const base = _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
11625
11667
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
11626
11668
|
}
|
|
11627
11669
|
|
|
@@ -11633,43 +11675,43 @@ var DEFAULT_PUBLISH = 1;
|
|
|
11633
11675
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
11634
11676
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
11635
11677
|
function validateOpenInput(params, note, assign) {
|
|
11636
|
-
const companyID =
|
|
11678
|
+
const companyID = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _106 => _106.companyID]), "params.companyID");
|
|
11637
11679
|
const title = _optionalChain([params, 'optionalAccess', _107 => _107.title]);
|
|
11638
11680
|
if (typeof title !== "string" || title.trim() === "") {
|
|
11639
|
-
throw new (0,
|
|
11681
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
11640
11682
|
}
|
|
11641
11683
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
11642
11684
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
11643
11685
|
if (!isPositiveInt(priority)) {
|
|
11644
|
-
throw new (0,
|
|
11686
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
11645
11687
|
}
|
|
11646
11688
|
if (!isPositiveInt(status)) {
|
|
11647
|
-
throw new (0,
|
|
11689
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
11648
11690
|
}
|
|
11649
11691
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
11650
|
-
throw new (0,
|
|
11692
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
11651
11693
|
}
|
|
11652
11694
|
if (note !== void 0) {
|
|
11653
11695
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
11654
|
-
throw new (0,
|
|
11696
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
11655
11697
|
}
|
|
11656
11698
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
11657
|
-
throw new (0,
|
|
11699
|
+
throw new (0, _chunkLLIB4JGKcjs.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 });
|
|
11658
11700
|
}
|
|
11659
11701
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
11660
|
-
throw new (0,
|
|
11702
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
11661
11703
|
}
|
|
11662
11704
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
11663
|
-
throw new (0,
|
|
11705
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
11664
11706
|
}
|
|
11665
11707
|
}
|
|
11666
|
-
const assignee = assign === void 0 ? void 0 :
|
|
11708
|
+
const assignee = assign === void 0 ? void 0 : _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
11667
11709
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
11668
|
-
throw new (0,
|
|
11710
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
11669
11711
|
}
|
|
11670
11712
|
const roleID = _optionalChain([assign, 'optionalAccess', _108 => _108.roleID]);
|
|
11671
11713
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
11672
|
-
throw new (0,
|
|
11714
|
+
throw new (0, _chunkLLIB4JGKcjs.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 });
|
|
11673
11715
|
}
|
|
11674
11716
|
return { companyID, title, priority, status, assignee, roleID };
|
|
11675
11717
|
}
|
|
@@ -11698,7 +11740,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
|
|
|
11698
11740
|
if (assign !== void 0) {
|
|
11699
11741
|
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).`);
|
|
11700
11742
|
}
|
|
11701
|
-
return
|
|
11743
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
11702
11744
|
{
|
|
11703
11745
|
operation: OP_OPEN,
|
|
11704
11746
|
method: "POST",
|
|
@@ -11738,8 +11780,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11738
11780
|
`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}` : ""}`,
|
|
11739
11781
|
{
|
|
11740
11782
|
operation: OP_OPEN,
|
|
11741
|
-
httpStatus:
|
|
11742
|
-
vendorError:
|
|
11783
|
+
httpStatus: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11784
|
+
vendorError: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
11743
11785
|
}
|
|
11744
11786
|
);
|
|
11745
11787
|
}
|
|
@@ -11754,8 +11796,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11754
11796
|
named,
|
|
11755
11797
|
{
|
|
11756
11798
|
operation: OP_OPEN,
|
|
11757
|
-
httpStatus:
|
|
11758
|
-
vendorError:
|
|
11799
|
+
httpStatus: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11800
|
+
vendorError: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11759
11801
|
resourceIds: [companyID],
|
|
11760
11802
|
details: { idRefs: [{ entity: "company", id: companyID }] }
|
|
11761
11803
|
}
|
|
@@ -11780,10 +11822,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
|
|
|
11780
11822
|
try {
|
|
11781
11823
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
11782
11824
|
if (current === null) {
|
|
11783
|
-
throw new (0,
|
|
11825
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11784
11826
|
}
|
|
11785
11827
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
11786
|
-
const merged =
|
|
11828
|
+
const merged = _chunkLLIB4JGKcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
11787
11829
|
merged.id = ticketId;
|
|
11788
11830
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
11789
11831
|
assigned = true;
|
|
@@ -11847,7 +11889,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11847
11889
|
const ids2 = await readLiveStatusSet(resource);
|
|
11848
11890
|
if (ids2.size > 0) liveStatus = ids2;
|
|
11849
11891
|
} catch (err) {
|
|
11850
|
-
if (!
|
|
11892
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11851
11893
|
}
|
|
11852
11894
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
11853
11895
|
_optionalChain([http, 'access', _109 => _109.fieldCache, 'optionalAccess', _110 => _110.invalidate, 'call', _111 => _111("tickets")]);
|
|
@@ -11857,7 +11899,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11857
11899
|
const freshIds = await readLiveStatusSet(resource);
|
|
11858
11900
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
11859
11901
|
} catch (err) {
|
|
11860
|
-
if (!
|
|
11902
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11861
11903
|
freshStatus = null;
|
|
11862
11904
|
reReadFailed = true;
|
|
11863
11905
|
}
|
|
@@ -11875,7 +11917,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11875
11917
|
return { guardDegraded: liveStatus === null };
|
|
11876
11918
|
}
|
|
11877
11919
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
11878
|
-
return
|
|
11920
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
11879
11921
|
{
|
|
11880
11922
|
operation: OP_STATUS,
|
|
11881
11923
|
method: "PUT",
|
|
@@ -11929,7 +11971,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11929
11971
|
if (mapEntry === void 0) {
|
|
11930
11972
|
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).`);
|
|
11931
11973
|
}
|
|
11932
|
-
return
|
|
11974
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
11933
11975
|
{
|
|
11934
11976
|
operation: OP_STATUS,
|
|
11935
11977
|
method: "PUT",
|
|
@@ -11949,7 +11991,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11949
11991
|
}
|
|
11950
11992
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
11951
11993
|
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _114 => _114.safeDefaults]), () => ( {}));
|
|
11952
|
-
const body =
|
|
11994
|
+
const body = _chunkLLIB4JGKcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
11953
11995
|
body.id = ticketId;
|
|
11954
11996
|
let merges = 0;
|
|
11955
11997
|
for (; ; ) {
|
|
@@ -11973,8 +12015,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11973
12015
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
11974
12016
|
{
|
|
11975
12017
|
operation: OP_STATUS,
|
|
11976
|
-
httpStatus:
|
|
11977
|
-
vendorError:
|
|
12018
|
+
httpStatus: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
12019
|
+
vendorError: _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11978
12020
|
resourceIds: [ticketId],
|
|
11979
12021
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
11980
12022
|
}
|
|
@@ -11987,7 +12029,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11987
12029
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
11988
12030
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11989
12031
|
if (verify === null) {
|
|
11990
|
-
throw new (0,
|
|
12032
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
11991
12033
|
code: "INVALID_RESPONSE",
|
|
11992
12034
|
category: "server",
|
|
11993
12035
|
operation: OP_STATUS,
|
|
@@ -11997,7 +12039,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11997
12039
|
}
|
|
11998
12040
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
11999
12041
|
if (finalStatus !== targetStatus) {
|
|
12000
|
-
throw new (0,
|
|
12042
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskError)(
|
|
12001
12043
|
`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)`,
|
|
12002
12044
|
{
|
|
12003
12045
|
code: "INVALID_RESPONSE",
|
|
@@ -12012,17 +12054,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
12012
12054
|
}
|
|
12013
12055
|
}
|
|
12014
12056
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
12015
|
-
const ticketId =
|
|
12057
|
+
const ticketId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
12016
12058
|
if (!isPositiveInt(targetStatus)) {
|
|
12017
|
-
throw new (0,
|
|
12059
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
12018
12060
|
}
|
|
12019
12061
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
12020
12062
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
12021
|
-
throw new (0,
|
|
12063
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
12022
12064
|
}
|
|
12023
12065
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
12024
12066
|
if (current === null) {
|
|
12025
|
-
throw new (0,
|
|
12067
|
+
throw new (0, _chunkLLIB4JGKcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
12026
12068
|
}
|
|
12027
12069
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
12028
12070
|
if (previousStatus === targetStatus) {
|
|
@@ -12042,7 +12084,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
12042
12084
|
function partLimit(value, name) {
|
|
12043
12085
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
12044
12086
|
if (!Number.isInteger(n) || n < 1) {
|
|
12045
|
-
throw new (0,
|
|
12087
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
12046
12088
|
}
|
|
12047
12089
|
return n;
|
|
12048
12090
|
}
|
|
@@ -12055,42 +12097,54 @@ function servedTextRecord(row, textField, limit) {
|
|
|
12055
12097
|
return out;
|
|
12056
12098
|
}
|
|
12057
12099
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
12058
|
-
const builder =
|
|
12100
|
+
const builder = _chunkLLIB4JGKcjs.createNamePlan.call(void 0, _chunkLLIB4JGKcjs.TICKET_LABEL_FIELDS);
|
|
12059
12101
|
const t = ctx.ticket;
|
|
12060
12102
|
builder.addResource(t["creatorResourceID"]);
|
|
12061
12103
|
builder.addFk("contract", t["contractID"]);
|
|
12062
12104
|
builder.addFk("billingCode", t["billingCodeID"]);
|
|
12063
12105
|
builder.addFk("role", t["assignedResourceRoleID"]);
|
|
12106
|
+
const ticketLobPointer = _chunkLLIB4JGKcjs.vendorId.call(void 0, t["organizationalLevelAssociationID"]);
|
|
12107
|
+
if (ticketLobPointer !== void 0) {
|
|
12108
|
+
builder.addLineOfBusiness(ticketLobPointer, { source: "ticket" });
|
|
12109
|
+
} else {
|
|
12110
|
+
builder.addLineOfBusinessFromContract(t["contractID"]);
|
|
12111
|
+
}
|
|
12064
12112
|
for (const e of entriesPart.items) {
|
|
12065
12113
|
builder.addResource(e["resourceID"]);
|
|
12066
12114
|
builder.addFk("role", e["roleID"]);
|
|
12067
12115
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
12068
12116
|
builder.addFk("contract", e["contractID"]);
|
|
12069
12117
|
}
|
|
12070
|
-
const names = await
|
|
12118
|
+
const names = await _chunkLLIB4JGKcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
12071
12119
|
const ticketRow = { ...ctx.ticket };
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
for (const f of
|
|
12120
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
12121
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
12122
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
12123
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
12124
|
+
for (const f of _chunkLLIB4JGKcjs.TICKET_LABEL_FIELDS) _chunkLLIB4JGKcjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
12077
12125
|
result.ticket = ticketRow;
|
|
12078
12126
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
12079
12127
|
const row = { ...e };
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12128
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
12129
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
12130
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
12131
|
+
_chunkLLIB4JGKcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
12084
12132
|
return row;
|
|
12085
12133
|
});
|
|
12086
12134
|
result.names = names.section;
|
|
12135
|
+
result.lineOfBusiness = _nullishCoalesce(names.lineOfBusiness, () => ( {
|
|
12136
|
+
association: null,
|
|
12137
|
+
organizationalLevel2: null,
|
|
12138
|
+
organizationalLevel1: null,
|
|
12139
|
+
markers: { association: "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
12140
|
+
}));
|
|
12087
12141
|
result.truncated = result.truncated || names.section.truncated;
|
|
12088
12142
|
}
|
|
12089
12143
|
async function fullContext(resource, id, opts = {}, http) {
|
|
12090
12144
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
12091
12145
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
12092
12146
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
12093
|
-
const ticketId =
|
|
12147
|
+
const ticketId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
12094
12148
|
const ctx = await resource.getContext(ticketId);
|
|
12095
12149
|
const op = "tickets.fullContext";
|
|
12096
12150
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -12148,16 +12202,16 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
12148
12202
|
}
|
|
12149
12203
|
|
|
12150
12204
|
// src/resources/special/tickets/forResource.ts
|
|
12151
|
-
var
|
|
12205
|
+
var OP5 = "tickets.forResource";
|
|
12152
12206
|
var TICKET_CHUNK = 100;
|
|
12153
12207
|
var LIMIT_DEFAULT = 100;
|
|
12154
12208
|
var LIMIT_MAX = 500;
|
|
12155
12209
|
var LINK_READ_CAP = 500;
|
|
12156
12210
|
var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
12157
|
-
function
|
|
12211
|
+
function positiveId2(value, name) {
|
|
12158
12212
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12159
12213
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12160
|
-
throw new (0,
|
|
12214
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP5}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP5 });
|
|
12161
12215
|
}
|
|
12162
12216
|
return n;
|
|
12163
12217
|
}
|
|
@@ -12167,28 +12221,28 @@ async function ticketPage(http, filter, maxRecords, fields) {
|
|
|
12167
12221
|
idempotent: true,
|
|
12168
12222
|
path: "/V1.0/Tickets/query",
|
|
12169
12223
|
body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
|
|
12170
|
-
operation:
|
|
12224
|
+
operation: OP5
|
|
12171
12225
|
});
|
|
12172
|
-
const page =
|
|
12226
|
+
const page = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, OP5);
|
|
12173
12227
|
return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
|
|
12174
12228
|
}
|
|
12175
12229
|
async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
12176
|
-
if (opts === null || typeof opts !== "object") throw new (0,
|
|
12177
|
-
const resourceID =
|
|
12230
|
+
if (opts === null || typeof opts !== "object") throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP5}: opts must be an object`, { operation: OP5 });
|
|
12231
|
+
const resourceID = positiveId2(resourceIDIn, "resourceID");
|
|
12178
12232
|
const scope = _nullishCoalesce(opts.scope, () => ( "both"));
|
|
12179
12233
|
if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
|
|
12180
|
-
throw new (0,
|
|
12234
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP5}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP5 });
|
|
12181
12235
|
}
|
|
12182
12236
|
if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
|
|
12183
|
-
throw new (0,
|
|
12237
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP5}: openOnly must be a boolean`, { operation: OP5 });
|
|
12184
12238
|
}
|
|
12185
12239
|
const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
|
|
12186
12240
|
if (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX) {
|
|
12187
|
-
throw new (0,
|
|
12241
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP5}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP5 });
|
|
12188
12242
|
}
|
|
12189
12243
|
const includeFields = _nullishCoalesce(opts.includeFields, () => ( []));
|
|
12190
12244
|
if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
|
|
12191
|
-
throw new (0,
|
|
12245
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP5}: includeFields must be a list of field names`, { operation: OP5 });
|
|
12192
12246
|
}
|
|
12193
12247
|
const openOnly = opts.openOnly === true;
|
|
12194
12248
|
const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS2, ...includeFields])];
|
|
@@ -12203,9 +12257,9 @@ async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
|
12203
12257
|
idempotent: true,
|
|
12204
12258
|
path: "/V1.0/TicketSecondaryResources/query",
|
|
12205
12259
|
body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
|
|
12206
|
-
operation:
|
|
12260
|
+
operation: OP5
|
|
12207
12261
|
});
|
|
12208
|
-
const page =
|
|
12262
|
+
const page = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, OP5);
|
|
12209
12263
|
for (const row of page.items) if (typeof row.ticketID === "number" && !linkIds.includes(row.ticketID)) linkIds.push(row.ticketID);
|
|
12210
12264
|
if (page.items.length >= LINK_READ_CAP || page.pageDetails.nextPageUrl !== null) capped = true;
|
|
12211
12265
|
}
|
|
@@ -12257,13 +12311,77 @@ async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
|
12257
12311
|
};
|
|
12258
12312
|
}
|
|
12259
12313
|
|
|
12314
|
+
// src/resources/special/tickets/lineOfBusiness.ts
|
|
12315
|
+
var OP6 = "tickets.lineOfBusiness";
|
|
12316
|
+
function positiveId3(value, name) {
|
|
12317
|
+
const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
|
|
12318
|
+
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12319
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(OP6 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP6 });
|
|
12320
|
+
}
|
|
12321
|
+
return n;
|
|
12322
|
+
}
|
|
12323
|
+
async function lineOfBusiness2(resource, ticketIdIn, http, associationIdIn) {
|
|
12324
|
+
const ticketId = positiveId3(ticketIdIn, "ticketId");
|
|
12325
|
+
let associationId;
|
|
12326
|
+
let associationSource = null;
|
|
12327
|
+
let contractId = null;
|
|
12328
|
+
let contractUnread = false;
|
|
12329
|
+
if (associationIdIn !== void 0) {
|
|
12330
|
+
associationId = positiveId3(associationIdIn, "associationId");
|
|
12331
|
+
associationSource = "argument";
|
|
12332
|
+
} else {
|
|
12333
|
+
const ticket = await resource.get(ticketId);
|
|
12334
|
+
associationId = _chunkLLIB4JGKcjs.vendorId.call(void 0, ticket.organizationalLevelAssociationID);
|
|
12335
|
+
if (associationId !== void 0) {
|
|
12336
|
+
associationSource = "ticket";
|
|
12337
|
+
} else {
|
|
12338
|
+
const contractRef = _chunkLLIB4JGKcjs.vendorId.call(void 0, ticket.contractID);
|
|
12339
|
+
if (contractRef !== void 0) {
|
|
12340
|
+
const client = http.client;
|
|
12341
|
+
if (client === void 0) {
|
|
12342
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(OP6 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP6 });
|
|
12343
|
+
}
|
|
12344
|
+
try {
|
|
12345
|
+
const contract = await client.contracts.get(contractRef);
|
|
12346
|
+
contractId = contractRef;
|
|
12347
|
+
associationId = _chunkLLIB4JGKcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
|
|
12348
|
+
if (associationId !== void 0) associationSource = "contract";
|
|
12349
|
+
} catch (e) {
|
|
12350
|
+
if (e instanceof _chunkLLIB4JGKcjs.NotFoundError) {
|
|
12351
|
+
contractId = contractRef;
|
|
12352
|
+
} else if (_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, e) && e.code !== "ABORTED") {
|
|
12353
|
+
contractId = contractRef;
|
|
12354
|
+
contractUnread = true;
|
|
12355
|
+
} else {
|
|
12356
|
+
throw e;
|
|
12357
|
+
}
|
|
12358
|
+
}
|
|
12359
|
+
}
|
|
12360
|
+
}
|
|
12361
|
+
}
|
|
12362
|
+
if (associationId === void 0) {
|
|
12363
|
+
return {
|
|
12364
|
+
ticketId,
|
|
12365
|
+
associationSource,
|
|
12366
|
+
contractId,
|
|
12367
|
+
association: null,
|
|
12368
|
+
organizationalLevel2: null,
|
|
12369
|
+
organizationalLevel1: null,
|
|
12370
|
+
markers: { association: contractUnread ? "unresolved" : "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
12371
|
+
};
|
|
12372
|
+
}
|
|
12373
|
+
const chain = await _chunkLLIB4JGKcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP6, onError: "propagate" });
|
|
12374
|
+
const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
|
|
12375
|
+
return { ticketId, associationSource, contractId, association, organizationalLevel2, organizationalLevel1, markers };
|
|
12376
|
+
}
|
|
12377
|
+
|
|
12260
12378
|
// src/resources/special/tickets/statusSemantics.ts
|
|
12261
12379
|
async function statusSemantics(_resource, opts = {}, http) {
|
|
12262
12380
|
return resolveTicketStatusSemantics(http, opts);
|
|
12263
12381
|
}
|
|
12264
12382
|
|
|
12265
12383
|
// src/resources/tickets.ts
|
|
12266
|
-
var TicketsResource = class extends
|
|
12384
|
+
var TicketsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
12267
12385
|
constructor(http, pageSize) {
|
|
12268
12386
|
super(http, {
|
|
12269
12387
|
key: "tickets",
|
|
@@ -12375,10 +12493,14 @@ var TicketsResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
12375
12493
|
forResource(resourceID, opts) {
|
|
12376
12494
|
return forResource(this, resourceID, this.http, opts);
|
|
12377
12495
|
}
|
|
12496
|
+
/** Node-parity special op (hand-written in src/resources/special/tickets.ts). */
|
|
12497
|
+
lineOfBusiness(ticketId, associationId) {
|
|
12498
|
+
return lineOfBusiness2(this, ticketId, this.http, associationId);
|
|
12499
|
+
}
|
|
12378
12500
|
};
|
|
12379
12501
|
|
|
12380
12502
|
// src/resources/ticket_webhooks.ts
|
|
12381
|
-
var TicketWebhooksResource = class extends
|
|
12503
|
+
var TicketWebhooksResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
12382
12504
|
constructor(http, pageSize) {
|
|
12383
12505
|
super(http, {
|
|
12384
12506
|
key: "ticket_webhooks",
|
|
@@ -12464,7 +12586,7 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
12464
12586
|
body: { MaxRecords: limit, filter },
|
|
12465
12587
|
operation
|
|
12466
12588
|
});
|
|
12467
|
-
const { items, pageDetails } =
|
|
12589
|
+
const { items, pageDetails } = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res);
|
|
12468
12590
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
12469
12591
|
}
|
|
12470
12592
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
@@ -12483,7 +12605,7 @@ async function customRange3(_resource, from, to, http, opts) {
|
|
|
12483
12605
|
const fromB = customRangeDay(from, "from", void 0, "customRange");
|
|
12484
12606
|
const toB = customRangeDay(to, "to", void 0, "customRange");
|
|
12485
12607
|
if (fromB.ms > toB.ms) {
|
|
12486
|
-
throw new (0,
|
|
12608
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
12487
12609
|
}
|
|
12488
12610
|
const toEndMs = toB.ms + DAY_MS2 - 1;
|
|
12489
12611
|
const filter = [
|
|
@@ -12503,12 +12625,12 @@ async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
|
12503
12625
|
return items;
|
|
12504
12626
|
}
|
|
12505
12627
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
12506
|
-
const
|
|
12507
|
-
if (_optionalChain([opts, 'optionalAccess', _123 => _123.tz]) !== void 0) validateZone(opts.tz,
|
|
12508
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
12509
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
12628
|
+
const OP11 = opLabel;
|
|
12629
|
+
if (_optionalChain([opts, 'optionalAccess', _123 => _123.tz]) !== void 0) validateZone(opts.tz, OP11);
|
|
12630
|
+
const fromB = customRangeDay(from, "from", void 0, OP11);
|
|
12631
|
+
const toB = customRangeDay(to, "to", void 0, OP11);
|
|
12510
12632
|
if (fromB.ms > toB.ms) {
|
|
12511
|
-
throw new (0,
|
|
12633
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP11}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP11 });
|
|
12512
12634
|
}
|
|
12513
12635
|
const windowToMs = toB.ms + DAY_MS2 - 1;
|
|
12514
12636
|
const filter = [
|
|
@@ -12519,7 +12641,7 @@ async function postedWithin(_resource, from, to, http, opts, opLabel = "time_ent
|
|
|
12519
12641
|
else if (_optionalChain([opts, 'optionalAccess', _125 => _125.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
12520
12642
|
if (_optionalChain([opts, 'optionalAccess', _126 => _126.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12521
12643
|
if (_optionalChain([opts, 'optionalAccess', _127 => _127.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
12522
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])),
|
|
12644
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])), OP11, http);
|
|
12523
12645
|
let postedCount = 0;
|
|
12524
12646
|
for (const item of items) {
|
|
12525
12647
|
const postedDate = item.postedDate;
|
|
@@ -12542,13 +12664,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
|
|
|
12542
12664
|
}
|
|
12543
12665
|
|
|
12544
12666
|
// src/resources/special/time_entries/errors.ts
|
|
12545
|
-
var ResourceInvalidError = class extends
|
|
12667
|
+
var ResourceInvalidError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
12546
12668
|
constructor(message, options = {}) {
|
|
12547
12669
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
12548
12670
|
this.name = "ResourceInvalidError";
|
|
12549
12671
|
}
|
|
12550
12672
|
};
|
|
12551
|
-
var AllocationCodeError = class extends
|
|
12673
|
+
var AllocationCodeError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
12552
12674
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
12553
12675
|
|
|
12554
12676
|
constructor(kind, message, options = {}) {
|
|
@@ -12557,7 +12679,7 @@ var AllocationCodeError = class extends _chunkD5IVS6GYcjs.AutotaskError {
|
|
|
12557
12679
|
this.kind = kind;
|
|
12558
12680
|
}
|
|
12559
12681
|
};
|
|
12560
|
-
var NoApplicableAllocationCodeError = class extends
|
|
12682
|
+
var NoApplicableAllocationCodeError = class extends _chunkLLIB4JGKcjs.AutotaskError {
|
|
12561
12683
|
/** The structured blocker details (filters tried + department sets). */
|
|
12562
12684
|
|
|
12563
12685
|
constructor(details, options = {}) {
|
|
@@ -12622,7 +12744,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12622
12744
|
let pages = 0;
|
|
12623
12745
|
for (; ; ) {
|
|
12624
12746
|
if (pages >= PAGE_GUARD) {
|
|
12625
|
-
throw new (0,
|
|
12747
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
12626
12748
|
code: "RESOLUTION_TRUNCATED",
|
|
12627
12749
|
category: "resolution",
|
|
12628
12750
|
operation,
|
|
@@ -12633,11 +12755,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12633
12755
|
const res = await http.request({
|
|
12634
12756
|
method: "POST",
|
|
12635
12757
|
idempotent: true,
|
|
12636
|
-
path: isFirst ? path :
|
|
12758
|
+
path: isFirst ? path : _chunkLLIB4JGKcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
12637
12759
|
body: { MaxRecords: pageSize, filter },
|
|
12638
12760
|
operation
|
|
12639
12761
|
});
|
|
12640
|
-
const { items: pageItems, pageDetails } =
|
|
12762
|
+
const { items: pageItems, pageDetails } = _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, operation);
|
|
12641
12763
|
items.push(...pageItems);
|
|
12642
12764
|
pages += 1;
|
|
12643
12765
|
if (items.length >= totalCap) break;
|
|
@@ -12729,7 +12851,7 @@ async function resolveCode(http, family, familyLabel2, pinnedId, departments, op
|
|
|
12729
12851
|
}
|
|
12730
12852
|
|
|
12731
12853
|
// src/resources/special/time_entries/createForResource.ts
|
|
12732
|
-
var
|
|
12854
|
+
var OP7 = "time_entries.createForResource";
|
|
12733
12855
|
var PARAM_KEYS = /* @__PURE__ */ new Set([
|
|
12734
12856
|
"internallAllocationCodeID",
|
|
12735
12857
|
"ticketID",
|
|
@@ -12754,7 +12876,7 @@ function windowDefaults(params) {
|
|
|
12754
12876
|
var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
|
|
12755
12877
|
var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
|
|
12756
12878
|
function validateCreateParams(params) {
|
|
12757
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
12879
|
+
const pin = (value, label) => typeof value === "number" ? _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
12758
12880
|
const pins = {
|
|
12759
12881
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
12760
12882
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -12763,32 +12885,32 @@ function validateCreateParams(params) {
|
|
|
12763
12885
|
};
|
|
12764
12886
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
12765
12887
|
if (pinCount > 1) {
|
|
12766
|
-
throw new (0,
|
|
12888
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
12767
12889
|
"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)",
|
|
12768
|
-
{ operation:
|
|
12890
|
+
{ operation: OP7 }
|
|
12769
12891
|
);
|
|
12770
12892
|
}
|
|
12771
12893
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
12772
|
-
throw new (0,
|
|
12894
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
12773
12895
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
12774
|
-
{ operation:
|
|
12896
|
+
{ operation: OP7 }
|
|
12775
12897
|
);
|
|
12776
12898
|
}
|
|
12777
12899
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
12778
|
-
throw new (0,
|
|
12900
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
12779
12901
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
12780
|
-
{ operation:
|
|
12902
|
+
{ operation: OP7 }
|
|
12781
12903
|
);
|
|
12782
12904
|
}
|
|
12783
12905
|
return pins;
|
|
12784
12906
|
}
|
|
12785
12907
|
async function assertResourceActive(http, rid) {
|
|
12786
|
-
const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`,
|
|
12908
|
+
const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP7);
|
|
12787
12909
|
if (rec === null) {
|
|
12788
12910
|
throw new ResourceInvalidError(`Resource ${rid} was not found \u2014 a time entry cannot attach to a missing resource`, {
|
|
12789
12911
|
resourceIds: [rid],
|
|
12790
12912
|
details: { idRefs: [{ entity: "resource", id: rid }] },
|
|
12791
|
-
operation:
|
|
12913
|
+
operation: OP7,
|
|
12792
12914
|
category: "not_found",
|
|
12793
12915
|
suggestedAction: "Resolve the resource id (resources.get / resources.search) and retry."
|
|
12794
12916
|
});
|
|
@@ -12797,7 +12919,7 @@ async function assertResourceActive(http, rid) {
|
|
|
12797
12919
|
throw new ResourceInvalidError(`Resource ${rid} is not active (isActive !== true) \u2014 the vendor would reject a time entry for an inactive resource`, {
|
|
12798
12920
|
resourceIds: [rid],
|
|
12799
12921
|
details: { idRefs: [{ entity: "resource", id: rid }] },
|
|
12800
|
-
operation:
|
|
12922
|
+
operation: OP7,
|
|
12801
12923
|
suggestedAction: "Activate the resource or pick an active one."
|
|
12802
12924
|
});
|
|
12803
12925
|
}
|
|
@@ -12807,11 +12929,11 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
|
|
|
12807
12929
|
const pinnedForCode = pins.code !== void 0 ? pins.code : pins.role;
|
|
12808
12930
|
let code = null;
|
|
12809
12931
|
const familiesTried = [];
|
|
12810
|
-
code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments,
|
|
12932
|
+
code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP7);
|
|
12811
12933
|
familiesTried.push({ family: familyOf(linkage), label: familyLabel(familyOf(linkage)), filters: [{ field: "useType", op: "eq", value: familyOf(linkage) }, { field: "isActive", op: "eq", value: true }] });
|
|
12812
12934
|
if (code === null && linkage === "task" && pins.role === void 0) {
|
|
12813
12935
|
usedLinkage = "internal";
|
|
12814
|
-
code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments,
|
|
12936
|
+
code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP7);
|
|
12815
12937
|
familiesTried.push({ family: USE_TYPE_INTERNAL, label: familyLabel(USE_TYPE_INTERNAL), filters: [{ field: "useType", op: "eq", value: USE_TYPE_INTERNAL }, { field: "isActive", op: "eq", value: true }] });
|
|
12816
12938
|
}
|
|
12817
12939
|
if (code === null) {
|
|
@@ -12821,7 +12943,7 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
|
|
|
12821
12943
|
families: familiesTried,
|
|
12822
12944
|
resourceDepartments: [...departments].sort((a, b) => a - b)
|
|
12823
12945
|
},
|
|
12824
|
-
{ operation:
|
|
12946
|
+
{ operation: OP7 }
|
|
12825
12947
|
);
|
|
12826
12948
|
}
|
|
12827
12949
|
const resolvedCode = codeInfo(code);
|
|
@@ -12858,9 +12980,9 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
|
|
|
12858
12980
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
12859
12981
|
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).");
|
|
12860
12982
|
}
|
|
12861
|
-
return
|
|
12983
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
12862
12984
|
{
|
|
12863
|
-
operation:
|
|
12985
|
+
operation: OP7,
|
|
12864
12986
|
method: "POST",
|
|
12865
12987
|
path: "/V1.0/TimeEntries",
|
|
12866
12988
|
ids: [rid],
|
|
@@ -12898,11 +13020,11 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12898
13020
|
};
|
|
12899
13021
|
} catch (err) {
|
|
12900
13022
|
lastError = err;
|
|
12901
|
-
const text =
|
|
13023
|
+
const text = _chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkLLIB4JGKcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
12902
13024
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
12903
13025
|
if (usedLinkage !== "internal" && gate3) {
|
|
12904
13026
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
12905
|
-
const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`,
|
|
13027
|
+
const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP7);
|
|
12906
13028
|
taskRoleFetched = true;
|
|
12907
13029
|
if (task !== null) pushLadder(task.assignedResourceRoleID);
|
|
12908
13030
|
}
|
|
@@ -12918,17 +13040,17 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12918
13040
|
throw err;
|
|
12919
13041
|
}
|
|
12920
13042
|
}
|
|
12921
|
-
if (
|
|
13043
|
+
if (_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, lastError)) {
|
|
12922
13044
|
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.`;
|
|
12923
13045
|
}
|
|
12924
13046
|
throw lastError;
|
|
12925
13047
|
}
|
|
12926
13048
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
12927
|
-
const rid =
|
|
13049
|
+
const rid = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
12928
13050
|
const pins = validateCreateParams(params);
|
|
12929
13051
|
await assertResourceActive(http, rid);
|
|
12930
13052
|
const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
|
|
12931
|
-
const roleRows = await resourceRoleRows(http, rid,
|
|
13053
|
+
const roleRows = await resourceRoleRows(http, rid, OP7);
|
|
12932
13054
|
const departments = roleRows.departments;
|
|
12933
13055
|
const { usedLinkage, resolvedCode } = await resolveAllocationCode(http, rid, linkage, pins, departments);
|
|
12934
13056
|
const defaults = windowDefaults(params);
|
|
@@ -12937,8 +13059,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
12937
13059
|
return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
|
|
12938
13060
|
}
|
|
12939
13061
|
function discoveryField(err, body, defaults) {
|
|
12940
|
-
if (!
|
|
12941
|
-
const entries =
|
|
13062
|
+
if (!_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
13063
|
+
const entries = _chunkLLIB4JGKcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
12942
13064
|
if (entries === void 0) return null;
|
|
12943
13065
|
for (const entry of entries) {
|
|
12944
13066
|
const field = entry.field;
|
|
@@ -12951,42 +13073,42 @@ function discoveryField(err, body, defaults) {
|
|
|
12951
13073
|
}
|
|
12952
13074
|
|
|
12953
13075
|
// src/resources/special/time_entries/move.ts
|
|
12954
|
-
var
|
|
13076
|
+
var OP8 = "time_entries.moveToTicket";
|
|
12955
13077
|
var COPY2 = ["resourceID", "roleID", "billingCodeID", "dateWorked", "startDateTime", "endDateTime", "hoursWorked", "offsetHours", "summaryNotes", "internalNotes", "isNonBillable", "showOnInvoice"];
|
|
12956
13078
|
var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundleID"];
|
|
12957
13079
|
async function readTimeEntry(http, id, retries) {
|
|
12958
13080
|
try {
|
|
12959
|
-
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation:
|
|
13081
|
+
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP8, maxRetries: retries });
|
|
12960
13082
|
return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _129 => _129.item]), () => ( null));
|
|
12961
13083
|
} catch (e) {
|
|
12962
|
-
if (
|
|
13084
|
+
if (_chunkLLIB4JGKcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
12963
13085
|
throw e;
|
|
12964
13086
|
}
|
|
12965
13087
|
}
|
|
12966
13088
|
async function checkSource2({ http, source, sourceId, toTicketId, retries }) {
|
|
12967
13089
|
const ids2 = { sourceId, toTicketId };
|
|
12968
13090
|
if (source.taskID !== null && source.taskID !== void 0) {
|
|
12969
|
-
throw refuse("MOVE_SOURCE_UNSUPPORTED", `${
|
|
13091
|
+
throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP8}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP8);
|
|
12970
13092
|
}
|
|
12971
13093
|
if (source.billingApprovalDateTime || source.billingApprovalResourceID || source.billingApprovalLevelMostRecent) {
|
|
12972
|
-
throw refuse("MOVE_BLOCKED_APPROVED", `${
|
|
13094
|
+
throw refuse("MOVE_BLOCKED_APPROVED", `${OP8}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
|
|
12973
13095
|
}
|
|
12974
13096
|
let billing;
|
|
12975
13097
|
try {
|
|
12976
|
-
billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }],
|
|
13098
|
+
billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP8, retries);
|
|
12977
13099
|
} catch (e3) {
|
|
12978
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
13100
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP8}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
|
|
12979
13101
|
}
|
|
12980
13102
|
if (billing.some((b) => b.invoiceID || b.postedDate)) {
|
|
12981
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
13103
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP8}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
|
|
12982
13104
|
}
|
|
12983
|
-
const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }],
|
|
13105
|
+
const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP8, retries);
|
|
12984
13106
|
if (attachments.length > 0) {
|
|
12985
|
-
throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${
|
|
13107
|
+
throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP8}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP8, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
|
|
12986
13108
|
}
|
|
12987
13109
|
}
|
|
12988
13110
|
var SPEC2 = {
|
|
12989
|
-
operation:
|
|
13111
|
+
operation: OP8,
|
|
12990
13112
|
entity: "time_entry",
|
|
12991
13113
|
readSource: readTimeEntry,
|
|
12992
13114
|
sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
|
|
@@ -13021,15 +13143,15 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
|
|
|
13021
13143
|
}
|
|
13022
13144
|
|
|
13023
13145
|
// src/resources/special/time_entries/approve.ts
|
|
13024
|
-
var
|
|
13146
|
+
var OP9 = "time_entries.approve";
|
|
13025
13147
|
var APPROVAL_LEVELS_PATH = "/V1.0/BillingItemApprovalLevels";
|
|
13026
13148
|
function toIso(value) {
|
|
13027
13149
|
if (value instanceof Date) {
|
|
13028
|
-
if (Number.isNaN(value.getTime())) throw new (0,
|
|
13150
|
+
if (Number.isNaN(value.getTime())) throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
|
|
13029
13151
|
return value.toISOString();
|
|
13030
13152
|
}
|
|
13031
13153
|
const parsed = new Date(value);
|
|
13032
|
-
if (Number.isNaN(parsed.getTime())) throw new (0,
|
|
13154
|
+
if (Number.isNaN(parsed.getTime())) throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
|
|
13033
13155
|
return parsed.toISOString();
|
|
13034
13156
|
}
|
|
13035
13157
|
function toNumber(value) {
|
|
@@ -13042,24 +13164,24 @@ function sameInstant(a, b) {
|
|
|
13042
13164
|
return !Number.isNaN(left) && left === right;
|
|
13043
13165
|
}
|
|
13044
13166
|
async function approve(resource, id, opts = {}, http) {
|
|
13045
|
-
const numericId = toNumber(
|
|
13167
|
+
const numericId = toNumber(_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id"));
|
|
13046
13168
|
if (opts.approvalLevel !== void 0 && (!Number.isInteger(opts.approvalLevel) || opts.approvalLevel < 1)) {
|
|
13047
|
-
throw new (0,
|
|
13169
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
|
|
13048
13170
|
}
|
|
13049
13171
|
const approvalLevel = _nullishCoalesce(opts.approvalLevel, () => ( 1));
|
|
13050
13172
|
const approvalDateTime = toIso(_nullishCoalesce(opts.approvalDateTime, () => ( /* @__PURE__ */ new Date())));
|
|
13051
13173
|
const entry = await resource.get(numericId);
|
|
13052
|
-
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(
|
|
13174
|
+
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
|
|
13053
13175
|
if (approvalResourceID === void 0) {
|
|
13054
|
-
throw new (0,
|
|
13176
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(
|
|
13055
13177
|
`time_entries.approve: time entry ${numericId} carries no resourceID and the caller supplied no approvalResourceID \u2014 the vendor requires an approving resource`
|
|
13056
13178
|
);
|
|
13057
13179
|
}
|
|
13058
13180
|
const body = { timeEntryID: numericId, approvalLevel, approvalResourceID, approvalDateTime };
|
|
13059
13181
|
if (opts.dryRun === true) {
|
|
13060
|
-
return
|
|
13182
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0,
|
|
13061
13183
|
{
|
|
13062
|
-
operation:
|
|
13184
|
+
operation: OP9,
|
|
13063
13185
|
method: "POST",
|
|
13064
13186
|
path: APPROVAL_LEVELS_PATH,
|
|
13065
13187
|
ids: [numericId],
|
|
@@ -13082,10 +13204,10 @@ async function approve(resource, id, opts = {}, http) {
|
|
|
13082
13204
|
method: "POST",
|
|
13083
13205
|
path: APPROVAL_LEVELS_PATH,
|
|
13084
13206
|
body,
|
|
13085
|
-
operation:
|
|
13207
|
+
operation: OP9,
|
|
13086
13208
|
maxRetries: opts.maxRetries
|
|
13087
13209
|
});
|
|
13088
|
-
const levelId = toNumber(
|
|
13210
|
+
const levelId = toNumber(_chunkLLIB4JGKcjs.parseIdentifier.call(void 0, _chunkLLIB4JGKcjs.unwrapOperation.call(void 0, created, OP9).id, "billingItemApprovalLevelID"));
|
|
13089
13211
|
await resource.update(
|
|
13090
13212
|
numericId,
|
|
13091
13213
|
{ billingApprovalDateTime: approvalDateTime, billingApprovalResourceID: approvalResourceID },
|
|
@@ -13108,28 +13230,28 @@ async function approve(resource, id, opts = {}, http) {
|
|
|
13108
13230
|
}
|
|
13109
13231
|
|
|
13110
13232
|
// src/resources/special/time_entries/recentTickets.ts
|
|
13111
|
-
var
|
|
13233
|
+
var OP10 = "time_entries.recentTickets";
|
|
13112
13234
|
var DAY_MS3 = 864e5;
|
|
13113
13235
|
var TICKET_CHUNK2 = 100;
|
|
13114
13236
|
var TICKET_FIELDS3 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
13115
|
-
function
|
|
13237
|
+
function positiveId4(value, name) {
|
|
13116
13238
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
13117
13239
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
13118
|
-
throw new (0,
|
|
13240
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP10}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP10 });
|
|
13119
13241
|
}
|
|
13120
13242
|
return n;
|
|
13121
13243
|
}
|
|
13122
13244
|
async function recentTickets(_resource, from, to, http, opts) {
|
|
13123
13245
|
if (opts === void 0 || opts === null || typeof opts !== "object") {
|
|
13124
|
-
throw new (0,
|
|
13246
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP10}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP10 });
|
|
13125
13247
|
}
|
|
13126
|
-
const resourceID =
|
|
13127
|
-
const companyID = opts.companyID === void 0 ? void 0 :
|
|
13128
|
-
if (opts.tz !== void 0) validateZone(opts.tz,
|
|
13129
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
13130
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
13248
|
+
const resourceID = positiveId4(opts.resourceID, "resourceID");
|
|
13249
|
+
const companyID = opts.companyID === void 0 ? void 0 : positiveId4(opts.companyID, "companyID");
|
|
13250
|
+
if (opts.tz !== void 0) validateZone(opts.tz, OP10);
|
|
13251
|
+
const fromB = customRangeDay(from, "from", void 0, OP10);
|
|
13252
|
+
const toB = customRangeDay(to, "to", void 0, OP10);
|
|
13131
13253
|
if (fromB.ms > toB.ms) {
|
|
13132
|
-
throw new (0,
|
|
13254
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)(`${OP10}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP10 });
|
|
13133
13255
|
}
|
|
13134
13256
|
const windowToMs = toB.ms + DAY_MS3 - 1;
|
|
13135
13257
|
const { items: entries, hasMore } = await queryTimeEntries(
|
|
@@ -13140,7 +13262,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13140
13262
|
{ field: "resourceID", op: "eq", value: resourceID }
|
|
13141
13263
|
],
|
|
13142
13264
|
clampWindowLimit(opts.limit),
|
|
13143
|
-
|
|
13265
|
+
OP10,
|
|
13144
13266
|
http
|
|
13145
13267
|
);
|
|
13146
13268
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -13166,9 +13288,9 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13166
13288
|
idempotent: true,
|
|
13167
13289
|
path: "/V1.0/Tickets/query",
|
|
13168
13290
|
body: { MaxRecords: TICKET_CHUNK2, filter, IncludeFields: TICKET_FIELDS3 },
|
|
13169
|
-
operation:
|
|
13291
|
+
operation: OP10
|
|
13170
13292
|
});
|
|
13171
|
-
for (const t of
|
|
13293
|
+
for (const t of _chunkLLIB4JGKcjs.unwrapItems.call(void 0, res, OP10).items) if (typeof t.id === "number") tickets.set(t.id, t);
|
|
13172
13294
|
}
|
|
13173
13295
|
const items = [];
|
|
13174
13296
|
const unresolvedTicketIDs = [];
|
|
@@ -13205,7 +13327,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13205
13327
|
}
|
|
13206
13328
|
|
|
13207
13329
|
// src/resources/time_entries.ts
|
|
13208
|
-
var TimeEntriesResource = class extends
|
|
13330
|
+
var TimeEntriesResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
13209
13331
|
constructor(http, pageSize) {
|
|
13210
13332
|
super(http, {
|
|
13211
13333
|
key: "time_entries",
|
|
@@ -13354,7 +13476,7 @@ var TimeEntriesResource = class extends _chunkD5IVS6GYcjs.BaseResource {
|
|
|
13354
13476
|
};
|
|
13355
13477
|
|
|
13356
13478
|
// src/resources/time_entry_attachments.ts
|
|
13357
|
-
var TimeEntryAttachmentsResource = class extends
|
|
13479
|
+
var TimeEntryAttachmentsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
13358
13480
|
constructor(http, pageSize) {
|
|
13359
13481
|
super(http, {
|
|
13360
13482
|
key: "time_entry_attachments",
|
|
@@ -13417,9 +13539,9 @@ var TimeEntryAttachmentsResource = class extends _chunkD5IVS6GYcjs.BaseResource
|
|
|
13417
13539
|
|
|
13418
13540
|
// src/resources/special/time_off_requests.ts
|
|
13419
13541
|
async function approve2(_resource, id, opts = {}, http) {
|
|
13420
|
-
const numericId =
|
|
13542
|
+
const numericId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
13421
13543
|
if (opts.dryRun === true) {
|
|
13422
|
-
return
|
|
13544
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
13423
13545
|
operation: "time_off_requests.approve",
|
|
13424
13546
|
method: "GET",
|
|
13425
13547
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -13435,16 +13557,16 @@ async function approve2(_resource, id, opts = {}, http) {
|
|
|
13435
13557
|
operation: "time_off_requests.approve",
|
|
13436
13558
|
maxRetries: opts.maxRetries
|
|
13437
13559
|
});
|
|
13438
|
-
return
|
|
13560
|
+
return _chunkLLIB4JGKcjs.unwrapOperation.call(void 0, res);
|
|
13439
13561
|
}
|
|
13440
13562
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
13441
|
-
const numericId =
|
|
13563
|
+
const numericId = _chunkLLIB4JGKcjs.parseIdentifier.call(void 0, id, "id");
|
|
13442
13564
|
const text = reason.trim();
|
|
13443
13565
|
if (text === "") {
|
|
13444
|
-
throw new (0,
|
|
13566
|
+
throw new (0, _chunkLLIB4JGKcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
13445
13567
|
}
|
|
13446
13568
|
if (opts.dryRun === true) {
|
|
13447
|
-
return
|
|
13569
|
+
return _chunkLLIB4JGKcjs.buildDryRunResult.call(void 0, {
|
|
13448
13570
|
operation: "time_off_requests.reject",
|
|
13449
13571
|
method: "POST",
|
|
13450
13572
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -13462,11 +13584,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
13462
13584
|
operation: "time_off_requests.reject",
|
|
13463
13585
|
maxRetries: opts.maxRetries
|
|
13464
13586
|
});
|
|
13465
|
-
return
|
|
13587
|
+
return _chunkLLIB4JGKcjs.unwrapOperation.call(void 0, res);
|
|
13466
13588
|
}
|
|
13467
13589
|
|
|
13468
13590
|
// src/resources/time_off_requests.ts
|
|
13469
|
-
var TimeOffRequestsResource = class extends
|
|
13591
|
+
var TimeOffRequestsResource = class extends _chunkLLIB4JGKcjs.BaseResource {
|
|
13470
13592
|
constructor(http, pageSize) {
|
|
13471
13593
|
super(http, {
|
|
13472
13594
|
key: "time_off_requests",
|