node-autotask 0.27.0 → 0.29.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 +49 -0
- package/MCP_TOOL_CATALOG.json +63 -8
- package/MCP_TOOL_MANIFEST.md +14 -11
- package/N8N_MCP_MANIFEST.json +84 -5
- package/N8N_MCP_MANIFEST.md +10 -7
- package/README.md +1 -2
- package/capabilities.json +1774 -1308
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-UHTZLUDE.cjs → chunk-APXBBN3D.cjs} +143 -143
- package/dist/{chunk-5GGCSRT4.cjs → chunk-BNIOQEKP.cjs} +840 -586
- package/dist/{chunk-ZJ4ONAQF.cjs → chunk-IKWHRUQ5.cjs} +97 -6
- package/dist/{chunk-42ZUISDH.js → chunk-KVT5V7SA.js} +93 -2
- package/dist/{chunk-5CC7LGNM.cjs → chunk-PY45RBQ2.cjs} +1773 -1307
- package/dist/{chunk-ZGTFVZL5.js → chunk-T4SZGOJB.js} +333 -79
- package/dist/{chunk-F7FVOXPQ.js → chunk-WKP442HS.js} +1773 -1307
- package/dist/{chunk-GURC52J7.js → chunk-X4TUU2Y6.js} +2 -2
- package/dist/{index-BIWy9m-a.d.ts → index-6_i-__sN.d.ts} +103 -3
- package/dist/{index-DQ9NgraW.d.cts → index-BGZ1Mhbh.d.cts} +105 -82
- package/dist/{index-DQ9NgraW.d.ts → index-BGZ1Mhbh.d.ts} +105 -82
- package/dist/{index-D4XYtn4s.d.cts → index-BZkfUU59.d.cts} +103 -3
- 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 +40 -3
- package/package.json +1 -1
|
@@ -38,13 +38,15 @@
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
var _chunkZJ4ONAQFcjs = require('./chunk-ZJ4ONAQF.cjs');
|
|
42
41
|
|
|
43
42
|
|
|
44
|
-
var
|
|
43
|
+
var _chunkIKWHRUQ5cjs = require('./chunk-IKWHRUQ5.cjs');
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var _chunkPY45RBQ2cjs = require('./chunk-PY45RBQ2.cjs');
|
|
45
47
|
|
|
46
48
|
// src/resources/appointments.ts
|
|
47
|
-
var AppointmentsResource = class extends
|
|
49
|
+
var AppointmentsResource = class extends _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.BaseResource {
|
|
133
135
|
constructor(http, pageSize) {
|
|
134
136
|
super(http, {
|
|
135
137
|
key: "billing_codes",
|
|
@@ -173,7 +175,7 @@ var BillingCodesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
173
175
|
};
|
|
174
176
|
|
|
175
177
|
// src/resources/billing_item_approval_levels.ts
|
|
176
|
-
var BillingItemApprovalLevelsResource = class extends
|
|
178
|
+
var BillingItemApprovalLevelsResource = class extends _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.BaseResource {
|
|
539
541
|
constructor(http, pageSize) {
|
|
540
542
|
super(http, {
|
|
541
543
|
key: "billing_items",
|
|
@@ -637,7 +639,7 @@ var BillingItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
637
639
|
};
|
|
638
640
|
|
|
639
641
|
// src/resources/change_request_links.ts
|
|
640
|
-
var ChangeRequestLinksResource = class extends
|
|
642
|
+
var ChangeRequestLinksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
641
643
|
constructor(http, pageSize) {
|
|
642
644
|
super(http, {
|
|
643
645
|
key: "change_request_links",
|
|
@@ -691,7 +693,7 @@ var ChangeRequestLinksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
691
693
|
};
|
|
692
694
|
|
|
693
695
|
// src/resources/checklist_libraries.ts
|
|
694
|
-
var ChecklistLibrariesResource = class extends
|
|
696
|
+
var ChecklistLibrariesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
695
697
|
constructor(http, pageSize) {
|
|
696
698
|
super(http, {
|
|
697
699
|
key: "checklist_libraries",
|
|
@@ -765,7 +767,7 @@ var ChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
765
767
|
};
|
|
766
768
|
|
|
767
769
|
// src/resources/checklist_library_checklist_items.ts
|
|
768
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
770
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunkIKWHRUQ5cjs.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 _chunkZJ4ONAQFcjs.Bas
|
|
|
831
833
|
};
|
|
832
834
|
|
|
833
835
|
// src/resources/classification_icons.ts
|
|
834
|
-
var ClassificationIconsResource = class extends
|
|
836
|
+
var ClassificationIconsResource = class extends _chunkIKWHRUQ5cjs.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 } = _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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: _chunkIKWHRUQ5cjs.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 } = _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
1084
|
+
const limit = opts.limit === void 0 ? 25 : _chunkIKWHRUQ5cjs.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: _chunkIKWHRUQ5cjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
1088
1090
|
operation: "companies.search"
|
|
1089
1091
|
});
|
|
1090
|
-
const hits =
|
|
1092
|
+
const hits = _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.AutotaskError {
|
|
1111
1113
|
constructor(message, options = {}) {
|
|
1112
1114
|
super(message, {
|
|
1113
1115
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1118,13 +1120,13 @@ var OwnerResourceRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
|
1118
1120
|
this.name = "OwnerResourceRequiredError";
|
|
1119
1121
|
}
|
|
1120
1122
|
};
|
|
1121
|
-
var CompanyResourceInvalidError = class extends
|
|
1123
|
+
var CompanyResourceInvalidError = class extends _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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, _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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 _chunkIKWHRUQ5cjs.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 (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1236
|
+
const named = (_nullishCoalesce(_chunkIKWHRUQ5cjs.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 = _chunkIKWHRUQ5cjs.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,
|
|
@@ -1291,6 +1293,82 @@ async function upsertByName(resource, companyName, params, opts, http) {
|
|
|
1291
1293
|
return createWithDiscovery(resource, body, owner, caveat, opts);
|
|
1292
1294
|
}
|
|
1293
1295
|
|
|
1296
|
+
// src/resources/special/_shared/ticketStatus.ts
|
|
1297
|
+
var ASSUMED_CLOSED_STATUS_ID = 5;
|
|
1298
|
+
var CLOSED_STATUS_LABELS = ["complete", "completed", "closed", "cancelled", "canceled", "resolved"];
|
|
1299
|
+
var OP = "tickets.statusSemantics";
|
|
1300
|
+
function picklistOf(fields) {
|
|
1301
|
+
if (!Array.isArray(fields)) return [];
|
|
1302
|
+
const status = fields.find((f) => typeof _optionalChain([f, 'optionalAccess', _19 => _19.name]) === "string" && f.name.toLowerCase() === "status");
|
|
1303
|
+
if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
|
|
1304
|
+
const out = [];
|
|
1305
|
+
for (const v of status.picklistValues) {
|
|
1306
|
+
const id = Number(_optionalChain([v, 'optionalAccess', _20 => _20.value]));
|
|
1307
|
+
if (!Number.isSafeInteger(id)) continue;
|
|
1308
|
+
out.push({ id, label: typeof v.label === "string" ? v.label : "" });
|
|
1309
|
+
}
|
|
1310
|
+
return out;
|
|
1311
|
+
}
|
|
1312
|
+
async function readFields(http, fresh) {
|
|
1313
|
+
const cache = http.fieldCache;
|
|
1314
|
+
const key = "tickets";
|
|
1315
|
+
if (!fresh && cache !== void 0) {
|
|
1316
|
+
const shared = cache.inflight(key, "fields");
|
|
1317
|
+
if (shared !== void 0) return await shared;
|
|
1318
|
+
const hit = cache.get(key, "fields");
|
|
1319
|
+
if (hit !== void 0) return hit;
|
|
1320
|
+
}
|
|
1321
|
+
const res = await http.request({ method: "GET", path: "/V1.0/Tickets/entityInformation/fields", operation: OP, maxRetries: 0 });
|
|
1322
|
+
const fields = _optionalChain([res, 'optionalAccess', _21 => _21.fields]);
|
|
1323
|
+
if (!Array.isArray(fields)) {
|
|
1324
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskError)("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
1325
|
+
}
|
|
1326
|
+
_optionalChain([cache, 'optionalAccess', _22 => _22.set, 'call', _23 => _23(key, "fields", fields)]);
|
|
1327
|
+
return fields;
|
|
1328
|
+
}
|
|
1329
|
+
function assumed(excludeStatusIds) {
|
|
1330
|
+
const closedIds = excludeStatusIds === void 0 ? [ASSUMED_CLOSED_STATUS_ID] : [...excludeStatusIds];
|
|
1331
|
+
return {
|
|
1332
|
+
picklist: [],
|
|
1333
|
+
closedIds,
|
|
1334
|
+
source: "assumed",
|
|
1335
|
+
assumedId: ASSUMED_CLOSED_STATUS_ID,
|
|
1336
|
+
note: `closed = status ${closedIds.join(", ")} \u2014 ASSUMED, not read from the tenant: the Tickets status picklist could not be resolved, so the historical id ${ASSUMED_CLOSED_STATUS_ID} stands in (fix: expose the Tickets field catalog to this API user, or pass excludeStatusIds)`
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
async function resolveTicketStatusSemantics(http, opts = {}) {
|
|
1340
|
+
if (opts.excludeStatusIds !== void 0) {
|
|
1341
|
+
const closedIds2 = [...new Set(opts.excludeStatusIds.map((id) => Number(id)))];
|
|
1342
|
+
if (closedIds2.length === 0 || closedIds2.some((id) => !Number.isSafeInteger(id) || id < 1)) {
|
|
1343
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`excludeStatusIds must be a non-empty list of positive status ids (got ${JSON.stringify(opts.excludeStatusIds)})`, { operation: OP });
|
|
1344
|
+
}
|
|
1345
|
+
return { picklist: [], closedIds: closedIds2, source: "picklist", note: `closed = status ${closedIds2.join(", ")} \u2014 supplied by the caller` };
|
|
1346
|
+
}
|
|
1347
|
+
let fields;
|
|
1348
|
+
try {
|
|
1349
|
+
fields = await readFields(http, opts.fresh === true);
|
|
1350
|
+
} catch (e) {
|
|
1351
|
+
if (e instanceof _chunkIKWHRUQ5cjs.AutotaskError && e.code === "ABORTED") throw e;
|
|
1352
|
+
return assumed();
|
|
1353
|
+
}
|
|
1354
|
+
const picklist = picklistOf(fields);
|
|
1355
|
+
const closedIds = picklist.filter((v) => CLOSED_STATUS_LABELS.includes(v.label.trim().toLowerCase())).map((v) => v.id);
|
|
1356
|
+
if (closedIds.length === 0) return assumed();
|
|
1357
|
+
const labels = picklist.filter((v) => closedIds.includes(v.id)).map((v) => `${v.id} ${v.label}`).join(", ");
|
|
1358
|
+
return {
|
|
1359
|
+
picklist,
|
|
1360
|
+
closedIds,
|
|
1361
|
+
source: "picklist",
|
|
1362
|
+
note: `closed = status not in [${closedIds.join(", ")}] (${labels}) \u2014 resolved from the tenant's Tickets status picklist`
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
function openStatusFilter(closedIds) {
|
|
1366
|
+
return closedIds.length === 1 ? { field: "status", op: "noteq", value: closedIds[0] } : { field: "status", op: "notIn", value: [...closedIds] };
|
|
1367
|
+
}
|
|
1368
|
+
function isClosedStatus(status, closedIds) {
|
|
1369
|
+
return typeof status === "number" && closedIds.includes(status);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1294
1372
|
// src/resources/special/companies/fullProfile.ts
|
|
1295
1373
|
var FULL_PROFILE_PROJECTABLE_PARTS = ["locations", "contacts", "notes", "projects", "openTickets"];
|
|
1296
1374
|
var PART_ENTITY = {
|
|
@@ -1300,36 +1378,36 @@ var PART_ENTITY = {
|
|
|
1300
1378
|
projects: "projects",
|
|
1301
1379
|
openTickets: "tickets"
|
|
1302
1380
|
};
|
|
1303
|
-
var OPEN_TICKETS_NOTE = "open = status != 5 (Complete) \u2014 the
|
|
1381
|
+
var OPEN_TICKETS_NOTE = "open = status != 5 (Complete) \u2014 ASSUMED: the tenant Tickets status picklist could not be read, so id 5 is the fallback closed id; tickets in any other status count as open";
|
|
1304
1382
|
var PROFILE_PART_LIMIT = 50;
|
|
1305
1383
|
var LOCATION_LIMIT_MAX = 500;
|
|
1306
1384
|
function locationLimit(value) {
|
|
1307
1385
|
if (value === void 0) return PROFILE_PART_LIMIT;
|
|
1308
1386
|
if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
|
|
1309
|
-
throw new (0,
|
|
1387
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
|
|
1310
1388
|
}
|
|
1311
1389
|
return value;
|
|
1312
1390
|
}
|
|
1313
1391
|
function validateProjection(fields) {
|
|
1314
1392
|
if (fields === void 0) return {};
|
|
1315
1393
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
|
|
1316
|
-
throw new (0,
|
|
1394
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
|
|
1317
1395
|
}
|
|
1318
1396
|
const out = {};
|
|
1319
1397
|
for (const [part, list] of Object.entries(fields)) {
|
|
1320
1398
|
if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
|
|
1321
|
-
throw new (0,
|
|
1399
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
|
|
1322
1400
|
}
|
|
1323
1401
|
if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
|
|
1324
|
-
throw new (0,
|
|
1402
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
|
|
1325
1403
|
}
|
|
1326
1404
|
const names = [...new Set(list)];
|
|
1327
1405
|
const entity = PART_ENTITY[part];
|
|
1328
|
-
const known = _nullishCoalesce(
|
|
1406
|
+
const known = _nullishCoalesce(_chunkIKWHRUQ5cjs.MODEL_FIELD_SETS[entity], () => ( []));
|
|
1329
1407
|
const unknown = names.filter((n) => !known.includes(n));
|
|
1330
1408
|
if (unknown.length > 0) {
|
|
1331
|
-
throw new (0,
|
|
1332
|
-
`fullProfile: fields.${part} has unknown field name(s) ${
|
|
1409
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
1410
|
+
`fullProfile: fields.${part} has unknown field name(s) ${_chunkIKWHRUQ5cjs.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`
|
|
1333
1411
|
);
|
|
1334
1412
|
}
|
|
1335
1413
|
out[part] = names;
|
|
@@ -1346,7 +1424,7 @@ function project(items, names) {
|
|
|
1346
1424
|
function profilePartLimit(value, name) {
|
|
1347
1425
|
const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
|
|
1348
1426
|
if (!Number.isInteger(n) || n < 1) {
|
|
1349
|
-
throw new (0,
|
|
1427
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1350
1428
|
}
|
|
1351
1429
|
return n;
|
|
1352
1430
|
}
|
|
@@ -1358,9 +1436,11 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
|
|
|
1358
1436
|
body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
|
|
1359
1437
|
operation: "companies.fullProfile"
|
|
1360
1438
|
});
|
|
1361
|
-
return project(
|
|
1439
|
+
return project(_chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1362
1440
|
}
|
|
1363
1441
|
async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
1442
|
+
const semantics = await resolveTicketStatusSemantics(http);
|
|
1443
|
+
const openLeaf = openStatusFilter(semantics.closedIds);
|
|
1364
1444
|
const openRows = await (async () => {
|
|
1365
1445
|
const res = await http.request({
|
|
1366
1446
|
method: "POST",
|
|
@@ -1368,30 +1448,31 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1368
1448
|
path: "/V1.0/Tickets/query",
|
|
1369
1449
|
body: {
|
|
1370
1450
|
MaxRecords: ticketLimit,
|
|
1371
|
-
filter: [{ field: "companyID", op: "eq", value: companyID },
|
|
1451
|
+
filter: [{ field: "companyID", op: "eq", value: companyID }, openLeaf],
|
|
1372
1452
|
...includeFields ? { IncludeFields: includeFields } : {}
|
|
1373
1453
|
},
|
|
1374
1454
|
operation: "companies.fullProfile"
|
|
1375
1455
|
});
|
|
1376
|
-
return project(
|
|
1456
|
+
return project(_chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1377
1457
|
})();
|
|
1458
|
+
const closedStatus = { closedIds: semantics.closedIds, source: semantics.source, note: semantics.note };
|
|
1459
|
+
const partNote = semantics.source === "assumed" ? OPEN_TICKETS_NOTE : semantics.note;
|
|
1378
1460
|
let openTickets = {
|
|
1379
1461
|
items: openRows,
|
|
1380
1462
|
capped: openRows.length >= ticketLimit,
|
|
1381
1463
|
blind: false,
|
|
1382
|
-
note:
|
|
1464
|
+
note: partNote,
|
|
1465
|
+
closedStatus
|
|
1383
1466
|
};
|
|
1384
1467
|
if (openRows.length === 0) {
|
|
1385
|
-
const stamp =
|
|
1386
|
-
{ field: "companyID", op: "eq", value: companyID },
|
|
1387
|
-
{ field: "status", op: "noteq", value: 5 }
|
|
1388
|
-
]);
|
|
1468
|
+
const stamp = _chunkIKWHRUQ5cjs.blindStampFor.call(void 0, _optionalChain([_chunkIKWHRUQ5cjs.BLIND_SURFACE_STAMPS, 'access', _24 => _24["tickets"], 'optionalAccess', _25 => _25.query]), [{ field: "companyID", op: "eq", value: companyID }, openLeaf]);
|
|
1389
1469
|
if (stamp !== void 0) {
|
|
1390
1470
|
openTickets = {
|
|
1391
1471
|
items: openRows,
|
|
1392
1472
|
capped: openRows.length >= ticketLimit,
|
|
1393
1473
|
blind: true,
|
|
1394
|
-
note: `${stamp.note} ${
|
|
1474
|
+
note: `${stamp.note} ${partNote}`,
|
|
1475
|
+
closedStatus,
|
|
1395
1476
|
blindSurface: stamp
|
|
1396
1477
|
};
|
|
1397
1478
|
}
|
|
@@ -1399,7 +1480,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1399
1480
|
return openTickets;
|
|
1400
1481
|
}
|
|
1401
1482
|
async function addProfileNames(http, company, openTickets, projects, result, opts) {
|
|
1402
|
-
const builder =
|
|
1483
|
+
const builder = _chunkIKWHRUQ5cjs.createNamePlan.call(void 0, _chunkIKWHRUQ5cjs.TICKET_LABEL_FIELDS);
|
|
1403
1484
|
const c = company;
|
|
1404
1485
|
builder.addResource(c["ownerResourceID"]);
|
|
1405
1486
|
builder.addResource(c["createdByResourceID"]);
|
|
@@ -1416,20 +1497,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1416
1497
|
builder.addResource(r["creatorResourceID"]);
|
|
1417
1498
|
builder.addFk("contract", r["contractID"]);
|
|
1418
1499
|
}
|
|
1419
|
-
const names = await
|
|
1500
|
+
const names = await _chunkIKWHRUQ5cjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1420
1501
|
const companyRow = { ...company };
|
|
1421
|
-
|
|
1422
|
-
|
|
1502
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1503
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
|
|
1423
1504
|
result.company = companyRow;
|
|
1424
1505
|
result.openTickets = {
|
|
1425
1506
|
...openTickets,
|
|
1426
1507
|
items: openTickets.items.map((row) => {
|
|
1427
1508
|
const r = { ...row };
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
for (const f of
|
|
1509
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1510
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1511
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1512
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1513
|
+
for (const f of _chunkIKWHRUQ5cjs.TICKET_LABEL_FIELDS) _chunkIKWHRUQ5cjs.addLabelSibling.call(void 0, r, f, names);
|
|
1433
1514
|
return r;
|
|
1434
1515
|
})
|
|
1435
1516
|
};
|
|
@@ -1437,9 +1518,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1437
1518
|
...result.projects,
|
|
1438
1519
|
items: result.projects.items.map((row) => {
|
|
1439
1520
|
const r = { ...row };
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1521
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1522
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1523
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1443
1524
|
return r;
|
|
1444
1525
|
})
|
|
1445
1526
|
};
|
|
@@ -1452,7 +1533,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1452
1533
|
const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
|
|
1453
1534
|
const locLimit = locationLimit(opts.locationLimit);
|
|
1454
1535
|
const proj = validateProjection(opts.fields);
|
|
1455
|
-
const companyID =
|
|
1536
|
+
const companyID = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
1456
1537
|
const company = await resource.get(companyID);
|
|
1457
1538
|
const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
|
|
1458
1539
|
const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
|
|
@@ -1499,7 +1580,7 @@ var UNBILLED_WORK_OPT_KEYS = [
|
|
|
1499
1580
|
var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
|
|
1500
1581
|
function validateUnbilledWorkOptions(companyId, opts) {
|
|
1501
1582
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1502
|
-
throw new (0,
|
|
1583
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
1503
1584
|
`unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
1504
1585
|
{ operation: "companies.unbilledWork" }
|
|
1505
1586
|
);
|
|
@@ -1528,7 +1609,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1528
1609
|
try {
|
|
1529
1610
|
limit = clampLimit(opts.limit);
|
|
1530
1611
|
} catch (err) {
|
|
1531
|
-
problems.push(err instanceof
|
|
1612
|
+
problems.push(err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1532
1613
|
limit = 50;
|
|
1533
1614
|
}
|
|
1534
1615
|
if (source === "date_range") {
|
|
@@ -1543,9 +1624,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1543
1624
|
problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
|
|
1544
1625
|
} else {
|
|
1545
1626
|
try {
|
|
1546
|
-
|
|
1627
|
+
_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1547
1628
|
} catch (err) {
|
|
1548
|
-
problems.push(err instanceof
|
|
1629
|
+
problems.push(err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
|
|
1549
1630
|
}
|
|
1550
1631
|
}
|
|
1551
1632
|
}
|
|
@@ -1555,20 +1636,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1555
1636
|
} else {
|
|
1556
1637
|
opts.ticketIds.forEach((tid, i) => {
|
|
1557
1638
|
try {
|
|
1558
|
-
|
|
1639
|
+
_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1559
1640
|
} catch (err) {
|
|
1560
|
-
problems.push(err instanceof
|
|
1641
|
+
problems.push(err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1561
1642
|
}
|
|
1562
1643
|
});
|
|
1563
1644
|
}
|
|
1564
1645
|
}
|
|
1565
1646
|
try {
|
|
1566
|
-
|
|
1647
|
+
_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1567
1648
|
} catch (err) {
|
|
1568
|
-
problems.push(err instanceof
|
|
1649
|
+
problems.push(err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
|
|
1569
1650
|
}
|
|
1570
1651
|
if (problems.length > 0) {
|
|
1571
|
-
throw new (0,
|
|
1652
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
1572
1653
|
`unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
1573
1654
|
- ` + problems.join("\n- "),
|
|
1574
1655
|
{ operation: "companies.unbilledWork" }
|
|
@@ -1589,7 +1670,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1589
1670
|
}
|
|
1590
1671
|
|
|
1591
1672
|
// src/resources/special/companies/unbilledWork.ts
|
|
1592
|
-
var
|
|
1673
|
+
var OP2 = "companies.unbilledWork";
|
|
1593
1674
|
function capJoinSet(ids2, cap) {
|
|
1594
1675
|
const sorted = [...new Set(ids2)].sort((a, b) => a - b);
|
|
1595
1676
|
if (sorted.length <= cap) return { ids: sorted, truncated: false };
|
|
@@ -1597,7 +1678,7 @@ function capJoinSet(ids2, cap) {
|
|
|
1597
1678
|
}
|
|
1598
1679
|
function unbilledWorkPartStatus(key, conditions, items) {
|
|
1599
1680
|
if (items.length !== 0) return { status: "ok" };
|
|
1600
|
-
const stamp =
|
|
1681
|
+
const stamp = _chunkIKWHRUQ5cjs.blindStampFor.call(void 0, _optionalChain([_chunkIKWHRUQ5cjs.BLIND_SURFACE_STAMPS, 'access', _26 => _26[key], 'optionalAccess', _27 => _27.query]), conditions);
|
|
1601
1682
|
if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
|
|
1602
1683
|
return {
|
|
1603
1684
|
status: "ok",
|
|
@@ -1617,7 +1698,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1617
1698
|
parentStatus = "ok";
|
|
1618
1699
|
companyIds.push(num(parent.id));
|
|
1619
1700
|
} catch (err) {
|
|
1620
|
-
if (err instanceof
|
|
1701
|
+
if (err instanceof _chunkIKWHRUQ5cjs.NotFoundError) parent = null;
|
|
1621
1702
|
else throw err;
|
|
1622
1703
|
}
|
|
1623
1704
|
}
|
|
@@ -1626,14 +1707,14 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1626
1707
|
}
|
|
1627
1708
|
async function readJoinSets(http, companyIds, v) {
|
|
1628
1709
|
const ticketsCond = [{ field: "companyID", op: "in", value: companyIds }];
|
|
1629
|
-
const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit,
|
|
1710
|
+
const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit, OP2);
|
|
1630
1711
|
const projectsCond = [{ field: "companyID", op: "in", value: companyIds }];
|
|
1631
|
-
const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit,
|
|
1712
|
+
const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit, OP2);
|
|
1632
1713
|
const projectIds = projectsRaw.items.map((p) => num(p.id)).filter((n) => n > 0);
|
|
1633
1714
|
let taskIds = [];
|
|
1634
1715
|
let tasksHasMore = false;
|
|
1635
1716
|
if (projectIds.length > 0) {
|
|
1636
|
-
const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit,
|
|
1717
|
+
const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit, OP2);
|
|
1637
1718
|
taskIds = tasksRaw.items.map((t) => num(t.id)).filter((n) => n > 0);
|
|
1638
1719
|
tasksHasMore = tasksRaw.hasMore;
|
|
1639
1720
|
}
|
|
@@ -1655,14 +1736,14 @@ async function readBillingPart(http, v, companyIds) {
|
|
|
1655
1736
|
if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
|
|
1656
1737
|
if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
|
|
1657
1738
|
}
|
|
1658
|
-
const billingFields =
|
|
1739
|
+
const billingFields = _chunkIKWHRUQ5cjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
|
|
1659
1740
|
const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
|
|
1660
|
-
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit,
|
|
1741
|
+
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP2, billingIncludeFields);
|
|
1661
1742
|
let billingItems = billingRaw.items;
|
|
1662
1743
|
let billingNoteCharsTruncated = 0;
|
|
1663
1744
|
if (v.includeNotes) {
|
|
1664
|
-
const noteFields = (_nullishCoalesce(
|
|
1665
|
-
[billingItems, billingNoteCharsTruncated] =
|
|
1745
|
+
const noteFields = (_nullishCoalesce(_chunkIKWHRUQ5cjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1746
|
+
[billingItems, billingNoteCharsTruncated] = _chunkIKWHRUQ5cjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
|
|
1666
1747
|
}
|
|
1667
1748
|
const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
|
|
1668
1749
|
const billingItemsPart = {
|
|
@@ -1701,12 +1782,12 @@ async function readTimePart(http, v, join) {
|
|
|
1701
1782
|
if (v.dateFrom !== void 0) timeConditions.push({ field: "dateWorked", op: "gte", value: v.dateFrom });
|
|
1702
1783
|
if (v.dateTo !== void 0) timeConditions.push({ field: "dateWorked", op: "lte", value: v.dateTo });
|
|
1703
1784
|
const timeFields = ["taskID", "ticketID", "hoursWorked", "dateWorked", "id", ...v.includeNotes ? ["summaryNotes"] : []];
|
|
1704
|
-
const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit,
|
|
1785
|
+
const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit, OP2, timeFields);
|
|
1705
1786
|
entries = raw.items;
|
|
1706
1787
|
let cappedItems = entries;
|
|
1707
1788
|
let noteCharsTruncated = 0;
|
|
1708
1789
|
if (v.includeNotes) {
|
|
1709
|
-
[cappedItems, noteCharsTruncated] =
|
|
1790
|
+
[cappedItems, noteCharsTruncated] = _chunkIKWHRUQ5cjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
|
|
1710
1791
|
}
|
|
1711
1792
|
const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
|
|
1712
1793
|
timePart = {
|
|
@@ -1794,7 +1875,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
|
|
|
1794
1875
|
}
|
|
1795
1876
|
async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
1796
1877
|
const v = validateUnbilledWorkOptions(companyId, opts);
|
|
1797
|
-
const id =
|
|
1878
|
+
const id = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1798
1879
|
const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
|
|
1799
1880
|
const join = await readJoinSets(http, companyIds, v);
|
|
1800
1881
|
const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
|
|
@@ -1821,7 +1902,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1821
1902
|
}
|
|
1822
1903
|
|
|
1823
1904
|
// src/resources/companies.ts
|
|
1824
|
-
var CompaniesResource = class extends
|
|
1905
|
+
var CompaniesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
1825
1906
|
constructor(http, pageSize) {
|
|
1826
1907
|
super(http, {
|
|
1827
1908
|
key: "companies",
|
|
@@ -1928,7 +2009,7 @@ var CompaniesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
1928
2009
|
};
|
|
1929
2010
|
|
|
1930
2011
|
// src/resources/company_alerts.ts
|
|
1931
|
-
var CompanyAlertsResource = class extends
|
|
2012
|
+
var CompanyAlertsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
1932
2013
|
constructor(http, pageSize) {
|
|
1933
2014
|
super(http, {
|
|
1934
2015
|
key: "company_alerts",
|
|
@@ -1994,7 +2075,7 @@ var CompanyAlertsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
1994
2075
|
};
|
|
1995
2076
|
|
|
1996
2077
|
// src/resources/company_locations.ts
|
|
1997
|
-
var CompanyLocationsResource = class extends
|
|
2078
|
+
var CompanyLocationsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
1998
2079
|
constructor(http, pageSize) {
|
|
1999
2080
|
super(http, {
|
|
2000
2081
|
key: "company_locations",
|
|
@@ -2060,12 +2141,12 @@ var CompanyLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
2060
2141
|
/** Search CompanyLocation records: bounded contains on name (no vendor free-text search exists);
|
|
2061
2142
|
* limit defaults to 25, max 500. */
|
|
2062
2143
|
async search(query, opts) {
|
|
2063
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2144
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _28 => _28.limit]) });
|
|
2064
2145
|
}
|
|
2065
2146
|
};
|
|
2066
2147
|
|
|
2067
2148
|
// src/resources/company_notes.ts
|
|
2068
|
-
var CompanyNotesResource = class extends
|
|
2149
|
+
var CompanyNotesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2069
2150
|
constructor(http, pageSize) {
|
|
2070
2151
|
super(http, {
|
|
2071
2152
|
key: "company_notes",
|
|
@@ -2125,12 +2206,12 @@ var CompanyNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
2125
2206
|
/** Search CompanyNote records: bounded contains on name (no vendor free-text search exists);
|
|
2126
2207
|
* limit defaults to 25, max 500. */
|
|
2127
2208
|
async search(query, opts) {
|
|
2128
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2209
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _29 => _29.limit]) });
|
|
2129
2210
|
}
|
|
2130
2211
|
};
|
|
2131
2212
|
|
|
2132
2213
|
// src/resources/company_site_configurations.ts
|
|
2133
|
-
var CompanySiteConfigurationsResource = class extends
|
|
2214
|
+
var CompanySiteConfigurationsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2134
2215
|
constructor(http, pageSize) {
|
|
2135
2216
|
super(http, {
|
|
2136
2217
|
key: "company_site_configurations",
|
|
@@ -2181,7 +2262,7 @@ var CompanySiteConfigurationsResource = class extends _chunkZJ4ONAQFcjs.BaseReso
|
|
|
2181
2262
|
};
|
|
2182
2263
|
|
|
2183
2264
|
// src/resources/company_webhooks.ts
|
|
2184
|
-
var CompanyWebhooksResource = class extends
|
|
2265
|
+
var CompanyWebhooksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2185
2266
|
constructor(http, pageSize) {
|
|
2186
2267
|
super(http, {
|
|
2187
2268
|
key: "company_webhooks",
|
|
@@ -2252,12 +2333,12 @@ var CompanyWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
2252
2333
|
/** Search CompanyWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
2253
2334
|
* limit defaults to 25, max 500. */
|
|
2254
2335
|
async search(query, opts) {
|
|
2255
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2336
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _30 => _30.limit]) });
|
|
2256
2337
|
}
|
|
2257
2338
|
};
|
|
2258
2339
|
|
|
2259
2340
|
// src/resources/configuration_item_billing_product_associations.ts
|
|
2260
|
-
var ConfigurationItemBillingProductAssociationsResource = class extends
|
|
2341
|
+
var ConfigurationItemBillingProductAssociationsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2261
2342
|
constructor(http, pageSize) {
|
|
2262
2343
|
super(http, {
|
|
2263
2344
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2323,7 +2404,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkZJ
|
|
|
2323
2404
|
};
|
|
2324
2405
|
|
|
2325
2406
|
// src/resources/configuration_item_categories.ts
|
|
2326
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2407
|
+
var ConfigurationItemCategoriesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2327
2408
|
constructor(http, pageSize) {
|
|
2328
2409
|
super(http, {
|
|
2329
2410
|
key: "configuration_item_categories",
|
|
@@ -2385,12 +2466,12 @@ var ConfigurationItemCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseRe
|
|
|
2385
2466
|
/** Search ConfigurationItemCategory records: bounded contains on name (no vendor free-text search exists);
|
|
2386
2467
|
* limit defaults to 25, max 500. */
|
|
2387
2468
|
async search(query, opts) {
|
|
2388
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2469
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _31 => _31.limit]) });
|
|
2389
2470
|
}
|
|
2390
2471
|
};
|
|
2391
2472
|
|
|
2392
2473
|
// src/resources/configuration_item_category_udf_associations.ts
|
|
2393
|
-
var ConfigurationItemCategoryUdfAssociationsResource = class extends
|
|
2474
|
+
var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2394
2475
|
constructor(http, pageSize) {
|
|
2395
2476
|
super(http, {
|
|
2396
2477
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2456,7 +2537,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkZJ4ON
|
|
|
2456
2537
|
};
|
|
2457
2538
|
|
|
2458
2539
|
// src/resources/configuration_item_dns_records.ts
|
|
2459
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2540
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2460
2541
|
constructor(http, pageSize) {
|
|
2461
2542
|
super(http, {
|
|
2462
2543
|
key: "configuration_item_dns_records",
|
|
@@ -2505,7 +2586,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkZJ4ONAQFcjs.BaseRe
|
|
|
2505
2586
|
};
|
|
2506
2587
|
|
|
2507
2588
|
// src/resources/configuration_item_notes.ts
|
|
2508
|
-
var ConfigurationItemNotesResource = class extends
|
|
2589
|
+
var ConfigurationItemNotesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2509
2590
|
constructor(http, pageSize) {
|
|
2510
2591
|
super(http, {
|
|
2511
2592
|
key: "configuration_item_notes",
|
|
@@ -2564,7 +2645,7 @@ var ConfigurationItemNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
2564
2645
|
};
|
|
2565
2646
|
|
|
2566
2647
|
// src/resources/configuration_item_related_items.ts
|
|
2567
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2648
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2568
2649
|
constructor(http, pageSize) {
|
|
2569
2650
|
super(http, {
|
|
2570
2651
|
key: "configuration_item_related_items",
|
|
@@ -2622,19 +2703,19 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkZJ4ONAQFcjs.Base
|
|
|
2622
2703
|
|
|
2623
2704
|
// src/resources/special/configuration_items.ts
|
|
2624
2705
|
async function fetchRecord(http, path, label, readOpts) {
|
|
2625
|
-
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
2706
|
+
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _32 => _32.maxRetries]) });
|
|
2626
2707
|
const body = res;
|
|
2627
2708
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
2628
|
-
throw new (0,
|
|
2709
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
2629
2710
|
}
|
|
2630
2711
|
return body.item;
|
|
2631
2712
|
}
|
|
2632
2713
|
async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
2633
|
-
const numericSource =
|
|
2634
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
2635
|
-
throw new (0,
|
|
2714
|
+
const numericSource = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2715
|
+
if (_optionalChain([opts, 'optionalAccess', _33 => _33.destinationCompanyId]) === void 0) {
|
|
2716
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2636
2717
|
}
|
|
2637
|
-
const destId =
|
|
2718
|
+
const destId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2638
2719
|
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
|
|
2639
2720
|
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
2640
2721
|
const body = { ...source };
|
|
@@ -2644,20 +2725,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2644
2725
|
body.companyID = destId;
|
|
2645
2726
|
body.isActive = true;
|
|
2646
2727
|
if (opts.newReferenceTitle !== void 0) {
|
|
2647
|
-
if (opts.newReferenceTitle.trim() === "") throw new (0,
|
|
2728
|
+
if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
|
|
2648
2729
|
body.referenceTitle = opts.newReferenceTitle.trim();
|
|
2649
2730
|
}
|
|
2650
2731
|
if (opts.lastModifiedDate !== void 0) {
|
|
2651
2732
|
const current = source.lastModifiedDate;
|
|
2652
2733
|
if (current !== opts.lastModifiedDate) {
|
|
2653
|
-
throw new (0,
|
|
2734
|
+
throw new (0, _chunkIKWHRUQ5cjs.StaleObjectError)(
|
|
2654
2735
|
`moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
|
|
2655
2736
|
{ operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
|
|
2656
2737
|
);
|
|
2657
2738
|
}
|
|
2658
2739
|
}
|
|
2659
2740
|
if (opts.dryRun === true) {
|
|
2660
|
-
return
|
|
2741
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
2661
2742
|
operation: "configuration_items.moveConfigurationItem",
|
|
2662
2743
|
method: "POST",
|
|
2663
2744
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2682,7 +2763,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2682
2763
|
const createdBody = created;
|
|
2683
2764
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2684
2765
|
if (typeof newId !== "number") {
|
|
2685
|
-
throw new (0,
|
|
2766
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2686
2767
|
}
|
|
2687
2768
|
let sourceDeactivated = false;
|
|
2688
2769
|
if (opts.deactivateSource !== false) {
|
|
@@ -2701,7 +2782,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2701
2782
|
function profilePartLimit2(value, name) {
|
|
2702
2783
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2703
2784
|
if (!Number.isInteger(n) || n < 1) {
|
|
2704
|
-
throw new (0,
|
|
2785
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2705
2786
|
}
|
|
2706
2787
|
return n;
|
|
2707
2788
|
}
|
|
@@ -2717,14 +2798,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
|
|
|
2717
2798
|
});
|
|
2718
2799
|
const body = res;
|
|
2719
2800
|
if (body === null || !("item" in body)) {
|
|
2720
|
-
throw new (0,
|
|
2801
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2721
2802
|
}
|
|
2722
2803
|
if (body.item === null || body.item === void 0) {
|
|
2723
|
-
throw new (0,
|
|
2804
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2724
2805
|
}
|
|
2725
2806
|
return body.item;
|
|
2726
2807
|
} catch (err) {
|
|
2727
|
-
if (err instanceof
|
|
2808
|
+
if (err instanceof _chunkIKWHRUQ5cjs.NotFoundError) return null;
|
|
2728
2809
|
throw err;
|
|
2729
2810
|
}
|
|
2730
2811
|
}
|
|
@@ -2736,7 +2817,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2736
2817
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2737
2818
|
operation: "configuration_items.profile"
|
|
2738
2819
|
});
|
|
2739
|
-
return
|
|
2820
|
+
return _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items;
|
|
2740
2821
|
}
|
|
2741
2822
|
async function profile(resource, id, opts = {}, http) {
|
|
2742
2823
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2748,7 +2829,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2748
2829
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2749
2830
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2750
2831
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2751
|
-
const wallQuirk = _optionalChain([
|
|
2832
|
+
const wallQuirk = _optionalChain([_chunkIKWHRUQ5cjs.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"))]);
|
|
2752
2833
|
const productAssociations = {
|
|
2753
2834
|
items: associations,
|
|
2754
2835
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2772,11 +2853,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2772
2853
|
}
|
|
2773
2854
|
};
|
|
2774
2855
|
if (opts.names === true) {
|
|
2775
|
-
const builder =
|
|
2856
|
+
const builder = _chunkIKWHRUQ5cjs.createNamePlan.call(void 0, );
|
|
2776
2857
|
builder.addFk("contract", root["contractID"]);
|
|
2777
|
-
const names = await
|
|
2858
|
+
const names = await _chunkIKWHRUQ5cjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2778
2859
|
const ciRow = { ...ci };
|
|
2779
|
-
|
|
2860
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2780
2861
|
result.ci = ciRow;
|
|
2781
2862
|
result.names = names.section;
|
|
2782
2863
|
}
|
|
@@ -2784,7 +2865,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2784
2865
|
}
|
|
2785
2866
|
|
|
2786
2867
|
// src/resources/configuration_items.ts
|
|
2787
|
-
var ConfigurationItemsResource = class extends
|
|
2868
|
+
var ConfigurationItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2788
2869
|
constructor(http, pageSize) {
|
|
2789
2870
|
super(http, {
|
|
2790
2871
|
key: "configuration_items",
|
|
@@ -2850,7 +2931,7 @@ var ConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
2850
2931
|
/** Search ConfigurationItem records: bounded contains on referenceTitle (no vendor free-text search exists);
|
|
2851
2932
|
* limit defaults to 25, max 500. */
|
|
2852
2933
|
async search(query, opts) {
|
|
2853
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2934
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _39 => _39.limit]) });
|
|
2854
2935
|
}
|
|
2855
2936
|
/** Get the ConfigurationItem with its primary context records in one call (each part a single-record
|
|
2856
2937
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
@@ -2873,7 +2954,7 @@ var ConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
2873
2954
|
};
|
|
2874
2955
|
|
|
2875
2956
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2876
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
2957
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2877
2958
|
constructor(http, pageSize) {
|
|
2878
2959
|
super(http, {
|
|
2879
2960
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -2931,12 +3012,12 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkZJ
|
|
|
2931
3012
|
/** Search ConfigurationItemSslSubjectAlternativeName records: bounded contains on name (no vendor free-text search exists);
|
|
2932
3013
|
* limit defaults to 25, max 500. */
|
|
2933
3014
|
async search(query, opts) {
|
|
2934
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3015
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _40 => _40.limit]) });
|
|
2935
3016
|
}
|
|
2936
3017
|
};
|
|
2937
3018
|
|
|
2938
3019
|
// src/resources/configuration_item_types.ts
|
|
2939
|
-
var ConfigurationItemTypesResource = class extends
|
|
3020
|
+
var ConfigurationItemTypesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
2940
3021
|
constructor(http, pageSize) {
|
|
2941
3022
|
super(http, {
|
|
2942
3023
|
key: "configuration_item_types",
|
|
@@ -3005,12 +3086,12 @@ var ConfigurationItemTypesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
3005
3086
|
/** Search ConfigurationItemType records: bounded contains on name (no vendor free-text search exists);
|
|
3006
3087
|
* limit defaults to 25, max 500. */
|
|
3007
3088
|
async search(query, opts) {
|
|
3008
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3089
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _41 => _41.limit]) });
|
|
3009
3090
|
}
|
|
3010
3091
|
};
|
|
3011
3092
|
|
|
3012
3093
|
// src/resources/configuration_item_webhooks.ts
|
|
3013
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
3094
|
+
var ConfigurationItemWebhooksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3014
3095
|
constructor(http, pageSize) {
|
|
3015
3096
|
super(http, {
|
|
3016
3097
|
key: "configuration_item_webhooks",
|
|
@@ -3081,12 +3162,12 @@ var ConfigurationItemWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseReso
|
|
|
3081
3162
|
/** Search ConfigurationItemWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
3082
3163
|
* limit defaults to 25, max 500. */
|
|
3083
3164
|
async search(query, opts) {
|
|
3084
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3165
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _42 => _42.limit]) });
|
|
3085
3166
|
}
|
|
3086
3167
|
};
|
|
3087
3168
|
|
|
3088
3169
|
// src/resources/contact_group_contacts.ts
|
|
3089
|
-
var ContactGroupContactsResource = class extends
|
|
3170
|
+
var ContactGroupContactsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3090
3171
|
constructor(http, pageSize) {
|
|
3091
3172
|
super(http, {
|
|
3092
3173
|
key: "contact_group_contacts",
|
|
@@ -3140,7 +3221,7 @@ var ContactGroupContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
3140
3221
|
};
|
|
3141
3222
|
|
|
3142
3223
|
// src/resources/contact_groups.ts
|
|
3143
|
-
var ContactGroupsResource = class extends
|
|
3224
|
+
var ContactGroupsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3144
3225
|
constructor(http, pageSize) {
|
|
3145
3226
|
super(http, {
|
|
3146
3227
|
key: "contact_groups",
|
|
@@ -3209,31 +3290,31 @@ var ContactGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
3209
3290
|
/** Search ContactGroups records: bounded contains on name (no vendor free-text search exists);
|
|
3210
3291
|
* limit defaults to 25, max 500. */
|
|
3211
3292
|
async search(query, opts) {
|
|
3212
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3293
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _43 => _43.limit]) });
|
|
3213
3294
|
}
|
|
3214
3295
|
};
|
|
3215
3296
|
|
|
3216
3297
|
// src/resources/special/contacts.ts
|
|
3217
3298
|
async function fetchRecord2(http, path, label, readOpts) {
|
|
3218
|
-
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
3299
|
+
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _44 => _44.maxRetries]) });
|
|
3219
3300
|
const body = res;
|
|
3220
3301
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3221
|
-
throw new (0,
|
|
3302
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3222
3303
|
}
|
|
3223
3304
|
return body.item;
|
|
3224
3305
|
}
|
|
3225
3306
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3226
|
-
const sourceId =
|
|
3227
|
-
const destId =
|
|
3307
|
+
const sourceId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3308
|
+
const destId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3228
3309
|
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
|
|
3229
3310
|
const companyID = source.companyID;
|
|
3230
3311
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3231
|
-
throw new (0,
|
|
3312
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3232
3313
|
}
|
|
3233
3314
|
if (opts.lastModifiedDate !== void 0) {
|
|
3234
3315
|
const current = source.lastModifiedDate;
|
|
3235
3316
|
if (current !== opts.lastModifiedDate) {
|
|
3236
|
-
throw new (0,
|
|
3317
|
+
throw new (0, _chunkIKWHRUQ5cjs.StaleObjectError)(
|
|
3237
3318
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3238
3319
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3239
3320
|
);
|
|
@@ -3255,10 +3336,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3255
3336
|
},
|
|
3256
3337
|
operation: "contacts.moveToCompany"
|
|
3257
3338
|
});
|
|
3258
|
-
const items =
|
|
3339
|
+
const items = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items;
|
|
3259
3340
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3260
3341
|
if (clash !== void 0) {
|
|
3261
|
-
throw new (0,
|
|
3342
|
+
throw new (0, _chunkIKWHRUQ5cjs.ConflictError)(
|
|
3262
3343
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3263
3344
|
{ resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3264
3345
|
);
|
|
@@ -3272,7 +3353,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3272
3353
|
if (opts.dryRun === true) {
|
|
3273
3354
|
const warnings = [];
|
|
3274
3355
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3275
|
-
return
|
|
3356
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
3276
3357
|
operation: "contacts.moveToCompany",
|
|
3277
3358
|
method: "POST",
|
|
3278
3359
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3298,7 +3379,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3298
3379
|
const createdBody = created;
|
|
3299
3380
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3300
3381
|
if (typeof newId !== "number") {
|
|
3301
|
-
throw new (0,
|
|
3382
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3302
3383
|
}
|
|
3303
3384
|
let sourceDeleted = false;
|
|
3304
3385
|
if (opts.deleteSource === true) {
|
|
@@ -3317,7 +3398,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3317
3398
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3318
3399
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3319
3400
|
var DEDUP_LIMIT = 10;
|
|
3320
|
-
var CompanyNotFoundError = class extends
|
|
3401
|
+
var CompanyNotFoundError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
3321
3402
|
constructor(message, options = {}) {
|
|
3322
3403
|
super(message, {
|
|
3323
3404
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3328,7 +3409,7 @@ var CompanyNotFoundError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
|
3328
3409
|
this.name = "CompanyNotFoundError";
|
|
3329
3410
|
}
|
|
3330
3411
|
};
|
|
3331
|
-
var ContactCreateFailedError = class extends
|
|
3412
|
+
var ContactCreateFailedError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
3332
3413
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3333
3414
|
|
|
3334
3415
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3338,25 +3419,25 @@ var ContactCreateFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
|
3338
3419
|
}
|
|
3339
3420
|
};
|
|
3340
3421
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3341
|
-
const cid =
|
|
3422
|
+
const cid = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3342
3423
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3343
|
-
throw new (0,
|
|
3424
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
3344
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)})`,
|
|
3345
3426
|
{ operation: OP_UPSERT_EMAIL }
|
|
3346
3427
|
);
|
|
3347
3428
|
}
|
|
3348
3429
|
if (extra !== void 0) {
|
|
3349
3430
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3350
|
-
throw new (0,
|
|
3431
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
3351
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)})`,
|
|
3352
3433
|
{ operation: OP_UPSERT_EMAIL }
|
|
3353
3434
|
);
|
|
3354
3435
|
}
|
|
3355
3436
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3356
|
-
throw new (0,
|
|
3437
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 });
|
|
3357
3438
|
}
|
|
3358
3439
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3359
|
-
throw new (0,
|
|
3440
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 });
|
|
3360
3441
|
}
|
|
3361
3442
|
}
|
|
3362
3443
|
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
|
|
@@ -3377,7 +3458,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3377
3458
|
const match = q.items[0];
|
|
3378
3459
|
if (match !== void 0) {
|
|
3379
3460
|
if (opts.dryRun === true) {
|
|
3380
|
-
return
|
|
3461
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
3381
3462
|
{
|
|
3382
3463
|
operation: OP_UPSERT_EMAIL,
|
|
3383
3464
|
method: "POST",
|
|
@@ -3398,16 +3479,16 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3398
3479
|
return { id: Number(match.id), created: false, existing: match };
|
|
3399
3480
|
}
|
|
3400
3481
|
const localPart = email.split("@")[0];
|
|
3401
|
-
const isActive = _optionalChain([extra, 'optionalAccess',
|
|
3482
|
+
const isActive = _optionalChain([extra, 'optionalAccess', _45 => _45.isActive]) === void 0 ? true : extra.isActive;
|
|
3402
3483
|
const body = {
|
|
3403
3484
|
emailAddress: email,
|
|
3404
3485
|
companyID: cid,
|
|
3405
|
-
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3406
|
-
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3486
|
+
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _46 => _46.firstName]), () => ( localPart)),
|
|
3487
|
+
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _47 => _47.lastName]), () => ( "Unknown")),
|
|
3407
3488
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3408
3489
|
};
|
|
3409
3490
|
if (opts.dryRun === true) {
|
|
3410
|
-
return
|
|
3491
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
3411
3492
|
{
|
|
3412
3493
|
operation: OP_UPSERT_EMAIL,
|
|
3413
3494
|
method: "POST",
|
|
@@ -3430,8 +3511,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3430
3511
|
const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
|
|
3431
3512
|
return { id: created.id, created: true };
|
|
3432
3513
|
} catch (err) {
|
|
3433
|
-
if (!
|
|
3434
|
-
const named = (_nullishCoalesce(
|
|
3514
|
+
if (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3515
|
+
const named = (_nullishCoalesce(_chunkIKWHRUQ5cjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3435
3516
|
const seen = /* @__PURE__ */ new Set();
|
|
3436
3517
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3437
3518
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3445,7 +3526,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3445
3526
|
}
|
|
3446
3527
|
continue;
|
|
3447
3528
|
}
|
|
3448
|
-
const detail =
|
|
3529
|
+
const detail = _chunkIKWHRUQ5cjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3449
3530
|
throw new ContactCreateFailedError(
|
|
3450
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}` : ""}`,
|
|
3451
3532
|
unique,
|
|
@@ -3462,7 +3543,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3462
3543
|
}
|
|
3463
3544
|
|
|
3464
3545
|
// src/resources/contacts.ts
|
|
3465
|
-
var ContactsResource = class extends
|
|
3546
|
+
var ContactsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3466
3547
|
constructor(http, pageSize) {
|
|
3467
3548
|
super(http, {
|
|
3468
3549
|
key: "contacts",
|
|
@@ -3533,7 +3614,7 @@ var ContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
3533
3614
|
/** Search Contact records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
3534
3615
|
* limit defaults to 25, max 500. */
|
|
3535
3616
|
async search(query, opts) {
|
|
3536
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3617
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _48 => _48.limit]) });
|
|
3537
3618
|
}
|
|
3538
3619
|
/** Get the Contact with its primary context records in one call (each part a single-record
|
|
3539
3620
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
@@ -3554,7 +3635,7 @@ var ContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
3554
3635
|
};
|
|
3555
3636
|
|
|
3556
3637
|
// src/resources/contact_webhooks.ts
|
|
3557
|
-
var ContactWebhooksResource = class extends
|
|
3638
|
+
var ContactWebhooksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3558
3639
|
constructor(http, pageSize) {
|
|
3559
3640
|
super(http, {
|
|
3560
3641
|
key: "contact_webhooks",
|
|
@@ -3625,12 +3706,12 @@ var ContactWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
3625
3706
|
/** Search ContactWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
3626
3707
|
* limit defaults to 25, max 500. */
|
|
3627
3708
|
async search(query, opts) {
|
|
3628
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3709
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _49 => _49.limit]) });
|
|
3629
3710
|
}
|
|
3630
3711
|
};
|
|
3631
3712
|
|
|
3632
3713
|
// src/resources/contract_billing_rules.ts
|
|
3633
|
-
var ContractBillingRulesResource = class extends
|
|
3714
|
+
var ContractBillingRulesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3634
3715
|
constructor(http, pageSize) {
|
|
3635
3716
|
super(http, {
|
|
3636
3717
|
key: "contract_billing_rules",
|
|
@@ -3696,7 +3777,7 @@ var ContractBillingRulesResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
3696
3777
|
};
|
|
3697
3778
|
|
|
3698
3779
|
// src/resources/contract_block_hour_factors.ts
|
|
3699
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3780
|
+
var ContractBlockHourFactorsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3700
3781
|
constructor(http, pageSize) {
|
|
3701
3782
|
super(http, {
|
|
3702
3783
|
key: "contract_block_hour_factors",
|
|
@@ -3755,7 +3836,7 @@ var ContractBlockHourFactorsResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
3755
3836
|
};
|
|
3756
3837
|
|
|
3757
3838
|
// src/resources/contract_blocks.ts
|
|
3758
|
-
var ContractBlocksResource = class extends
|
|
3839
|
+
var ContractBlocksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3759
3840
|
constructor(http, pageSize) {
|
|
3760
3841
|
super(http, {
|
|
3761
3842
|
key: "contract_blocks",
|
|
@@ -3814,7 +3895,7 @@ var ContractBlocksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
3814
3895
|
};
|
|
3815
3896
|
|
|
3816
3897
|
// src/resources/contract_charges.ts
|
|
3817
|
-
var ContractChargesResource = class extends
|
|
3898
|
+
var ContractChargesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3818
3899
|
constructor(http, pageSize) {
|
|
3819
3900
|
super(http, {
|
|
3820
3901
|
key: "contract_charges",
|
|
@@ -3880,12 +3961,12 @@ var ContractChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
3880
3961
|
/** Search ContractCharge records: bounded contains on name (no vendor free-text search exists);
|
|
3881
3962
|
* limit defaults to 25, max 500. */
|
|
3882
3963
|
async search(query, opts) {
|
|
3883
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3964
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _50 => _50.limit]) });
|
|
3884
3965
|
}
|
|
3885
3966
|
};
|
|
3886
3967
|
|
|
3887
3968
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3888
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
3969
|
+
var ContractExclusionBillingCodesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3889
3970
|
constructor(http, pageSize) {
|
|
3890
3971
|
super(http, {
|
|
3891
3972
|
key: "contract_exclusion_billing_codes",
|
|
@@ -3942,7 +4023,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkZJ4ONAQFcjs.Base
|
|
|
3942
4023
|
};
|
|
3943
4024
|
|
|
3944
4025
|
// src/resources/contract_exclusion_roles.ts
|
|
3945
|
-
var ContractExclusionRolesResource = class extends
|
|
4026
|
+
var ContractExclusionRolesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
3946
4027
|
constructor(http, pageSize) {
|
|
3947
4028
|
super(http, {
|
|
3948
4029
|
key: "contract_exclusion_roles",
|
|
@@ -3999,7 +4080,7 @@ var ContractExclusionRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
3999
4080
|
};
|
|
4000
4081
|
|
|
4001
4082
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
4002
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
4083
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4003
4084
|
constructor(http, pageSize) {
|
|
4004
4085
|
super(http, {
|
|
4005
4086
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -4056,7 +4137,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkZJ4ONAQFcjs.
|
|
|
4056
4137
|
};
|
|
4057
4138
|
|
|
4058
4139
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
4059
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
4140
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4060
4141
|
constructor(http, pageSize) {
|
|
4061
4142
|
super(http, {
|
|
4062
4143
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -4113,7 +4194,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkZJ4ONAQF
|
|
|
4113
4194
|
};
|
|
4114
4195
|
|
|
4115
4196
|
// src/resources/contract_exclusion_sets.ts
|
|
4116
|
-
var ContractExclusionSetsResource = class extends
|
|
4197
|
+
var ContractExclusionSetsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4117
4198
|
constructor(http, pageSize) {
|
|
4118
4199
|
super(http, {
|
|
4119
4200
|
key: "contract_exclusion_sets",
|
|
@@ -4182,12 +4263,12 @@ var ContractExclusionSetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
4182
4263
|
/** Search ContractExclusionSets records: bounded contains on name (no vendor free-text search exists);
|
|
4183
4264
|
* limit defaults to 25, max 500. */
|
|
4184
4265
|
async search(query, opts) {
|
|
4185
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
4266
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _51 => _51.limit]) });
|
|
4186
4267
|
}
|
|
4187
4268
|
};
|
|
4188
4269
|
|
|
4189
4270
|
// src/resources/contract_milestones.ts
|
|
4190
|
-
var ContractMilestonesResource = class extends
|
|
4271
|
+
var ContractMilestonesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4191
4272
|
constructor(http, pageSize) {
|
|
4192
4273
|
super(http, {
|
|
4193
4274
|
key: "contract_milestones",
|
|
@@ -4246,7 +4327,7 @@ var ContractMilestonesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
4246
4327
|
};
|
|
4247
4328
|
|
|
4248
4329
|
// src/resources/contract_notes.ts
|
|
4249
|
-
var ContractNotesResource = class extends
|
|
4330
|
+
var ContractNotesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4250
4331
|
constructor(http, pageSize) {
|
|
4251
4332
|
super(http, {
|
|
4252
4333
|
key: "contract_notes",
|
|
@@ -4305,7 +4386,7 @@ var ContractNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
4305
4386
|
};
|
|
4306
4387
|
|
|
4307
4388
|
// src/resources/contract_rates.ts
|
|
4308
|
-
var ContractRatesResource = class extends
|
|
4389
|
+
var ContractRatesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4309
4390
|
constructor(http, pageSize) {
|
|
4310
4391
|
super(http, {
|
|
4311
4392
|
key: "contract_rates",
|
|
@@ -4364,7 +4445,7 @@ var ContractRatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
4364
4445
|
};
|
|
4365
4446
|
|
|
4366
4447
|
// src/resources/contract_retainers.ts
|
|
4367
|
-
var ContractRetainersResource = class extends
|
|
4448
|
+
var ContractRetainersResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4368
4449
|
constructor(http, pageSize) {
|
|
4369
4450
|
super(http, {
|
|
4370
4451
|
key: "contract_retainers",
|
|
@@ -4423,7 +4504,7 @@ var ContractRetainersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
4423
4504
|
};
|
|
4424
4505
|
|
|
4425
4506
|
// src/resources/contract_role_costs.ts
|
|
4426
|
-
var ContractRoleCostsResource = class extends
|
|
4507
|
+
var ContractRoleCostsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4427
4508
|
constructor(http, pageSize) {
|
|
4428
4509
|
super(http, {
|
|
4429
4510
|
key: "contract_role_costs",
|
|
@@ -4482,7 +4563,7 @@ var ContractRoleCostsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
4482
4563
|
};
|
|
4483
4564
|
|
|
4484
4565
|
// src/resources/contract_service_adjustments.ts
|
|
4485
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4566
|
+
var ContractServiceAdjustmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4486
4567
|
constructor(http, pageSize) {
|
|
4487
4568
|
super(http, {
|
|
4488
4569
|
key: "contract_service_adjustments",
|
|
@@ -4516,7 +4597,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.BaseRes
|
|
|
4516
4597
|
};
|
|
4517
4598
|
|
|
4518
4599
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4519
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4600
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4520
4601
|
constructor(http, pageSize) {
|
|
4521
4602
|
super(http, {
|
|
4522
4603
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4550,7 +4631,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.B
|
|
|
4550
4631
|
};
|
|
4551
4632
|
|
|
4552
4633
|
// src/resources/contract_service_bundles.ts
|
|
4553
|
-
var ContractServiceBundlesResource = class extends
|
|
4634
|
+
var ContractServiceBundlesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4554
4635
|
constructor(http, pageSize) {
|
|
4555
4636
|
super(http, {
|
|
4556
4637
|
key: "contract_service_bundles",
|
|
@@ -4609,7 +4690,7 @@ var ContractServiceBundlesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
4609
4690
|
};
|
|
4610
4691
|
|
|
4611
4692
|
// src/resources/contract_service_bundle_units.ts
|
|
4612
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4693
|
+
var ContractServiceBundleUnitsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4613
4694
|
constructor(http, pageSize) {
|
|
4614
4695
|
super(http, {
|
|
4615
4696
|
key: "contract_service_bundle_units",
|
|
@@ -4651,7 +4732,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkZJ4ONAQFcjs.BaseRes
|
|
|
4651
4732
|
};
|
|
4652
4733
|
|
|
4653
4734
|
// src/resources/contract_services.ts
|
|
4654
|
-
var ContractServicesResource = class extends
|
|
4735
|
+
var ContractServicesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4655
4736
|
constructor(http, pageSize) {
|
|
4656
4737
|
super(http, {
|
|
4657
4738
|
key: "contract_services",
|
|
@@ -4710,7 +4791,7 @@ var ContractServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
4710
4791
|
};
|
|
4711
4792
|
|
|
4712
4793
|
// src/resources/contract_service_units.ts
|
|
4713
|
-
var ContractServiceUnitsResource = class extends
|
|
4794
|
+
var ContractServiceUnitsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
4714
4795
|
constructor(http, pageSize) {
|
|
4715
4796
|
super(http, {
|
|
4716
4797
|
key: "contract_service_units",
|
|
@@ -4978,7 +5059,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
|
|
|
4978
5059
|
// src/resources/special/contracts/profitability.validate.ts
|
|
4979
5060
|
function validateProfitabilityOptions(contractId, opts) {
|
|
4980
5061
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
4981
|
-
throw new (0,
|
|
5062
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
4982
5063
|
`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})`,
|
|
4983
5064
|
{ operation: "contracts.profitability" }
|
|
4984
5065
|
);
|
|
@@ -5055,12 +5136,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
5055
5136
|
}
|
|
5056
5137
|
}
|
|
5057
5138
|
try {
|
|
5058
|
-
|
|
5139
|
+
_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5059
5140
|
} catch (err) {
|
|
5060
|
-
problems.push(err instanceof
|
|
5141
|
+
problems.push(err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
5061
5142
|
}
|
|
5062
5143
|
if (problems.length > 0) {
|
|
5063
|
-
throw new (0,
|
|
5144
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
5064
5145
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
5065
5146
|
- ` + problems.join("\n- "),
|
|
5066
5147
|
{ operation: "contracts.profitability" }
|
|
@@ -5109,23 +5190,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5109
5190
|
const byKey = /* @__PURE__ */ new Map();
|
|
5110
5191
|
const misses = [];
|
|
5111
5192
|
const notes = [];
|
|
5112
|
-
for (let c = 0; c < unique.length; c +=
|
|
5113
|
-
const chunk = unique.slice(c, c +
|
|
5193
|
+
for (let c = 0; c < unique.length; c += _chunkIKWHRUQ5cjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
5194
|
+
const chunk = unique.slice(c, c + _chunkIKWHRUQ5cjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
5114
5195
|
const chunkKeys = new Set(chunk);
|
|
5115
5196
|
try {
|
|
5116
5197
|
const body = {
|
|
5117
|
-
MaxRecords:
|
|
5198
|
+
MaxRecords: _chunkIKWHRUQ5cjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
5118
5199
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
5119
5200
|
IncludeFields: fields
|
|
5120
5201
|
};
|
|
5121
5202
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
5122
|
-
const { items: rows } =
|
|
5203
|
+
const { items: rows } = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, operation);
|
|
5123
5204
|
for (const row of rows) {
|
|
5124
5205
|
const k = num(row.id);
|
|
5125
5206
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
5126
5207
|
}
|
|
5127
5208
|
} catch (err) {
|
|
5128
|
-
const code = err instanceof
|
|
5209
|
+
const code = err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
5129
5210
|
for (const k of chunk) {
|
|
5130
5211
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
5131
5212
|
}
|
|
@@ -5135,11 +5216,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5135
5216
|
for (const k of queryMissed) {
|
|
5136
5217
|
try {
|
|
5137
5218
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
5138
|
-
byKey.set(k,
|
|
5219
|
+
byKey.set(k, _chunkIKWHRUQ5cjs.unwrapItem.call(void 0, res, k, operation, entity));
|
|
5139
5220
|
} catch (err) {
|
|
5140
|
-
if (err instanceof
|
|
5221
|
+
if (err instanceof _chunkIKWHRUQ5cjs.NotFoundError) {
|
|
5141
5222
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
5142
|
-
} else if (err instanceof
|
|
5223
|
+
} else if (err instanceof _chunkIKWHRUQ5cjs.AutotaskError) {
|
|
5143
5224
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
5144
5225
|
} else {
|
|
5145
5226
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -5193,7 +5274,7 @@ async function degradable(read) {
|
|
|
5193
5274
|
try {
|
|
5194
5275
|
return await read();
|
|
5195
5276
|
} catch (err) {
|
|
5196
|
-
if (!(err instanceof
|
|
5277
|
+
if (!(err instanceof _chunkIKWHRUQ5cjs.AutotaskError)) throw err;
|
|
5197
5278
|
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
5198
5279
|
}
|
|
5199
5280
|
}
|
|
@@ -5213,15 +5294,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
|
|
|
5213
5294
|
status: st.status,
|
|
5214
5295
|
blindSurface: st.blindSurface,
|
|
5215
5296
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
5216
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5297
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkIKWHRUQ5cjs.EMPTY_REASON_STAMPS, 'access', _52 => _52[key], 'optionalAccess', _53 => _53.query]) : void 0
|
|
5217
5298
|
};
|
|
5218
5299
|
};
|
|
5219
5300
|
function appendWiresNote(wires, note) {
|
|
5220
5301
|
wires.note = (wires.note ? wires.note + " | " : "") + note;
|
|
5221
5302
|
}
|
|
5222
5303
|
function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
5223
|
-
const
|
|
5224
|
-
const id =
|
|
5304
|
+
const OP10 = PROFITABILITY_OP;
|
|
5305
|
+
const id = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5225
5306
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
5226
5307
|
const wires = { issued: 0, requests: 0, budget };
|
|
5227
5308
|
const toExcl = dayAfter(v.dateTo);
|
|
@@ -5232,19 +5313,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
|
5232
5313
|
} };
|
|
5233
5314
|
const readPart = (path, conditions, fields) => {
|
|
5234
5315
|
wires.issued += 1;
|
|
5235
|
-
return degradable(() => boundedPart(http, path, conditions, v.limit,
|
|
5316
|
+
return degradable(() => boundedPart(http, path, conditions, v.limit, OP10, fields));
|
|
5236
5317
|
};
|
|
5237
5318
|
const truncatedMonths = {};
|
|
5238
5319
|
const windowedPart = async (name, key, path, cond, fields, dateField) => {
|
|
5239
5320
|
const first = await readPart(path, cond, fields);
|
|
5240
5321
|
if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
|
|
5241
|
-
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit,
|
|
5322
|
+
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP10, fields, dateField, v.dateFrom, v.dateTo, wires));
|
|
5242
5323
|
if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
|
|
5243
5324
|
const { truncatedMonths: tm, ...part } = wp;
|
|
5244
5325
|
truncatedMonths[name] = tm;
|
|
5245
5326
|
return { part, rows: wp.items };
|
|
5246
5327
|
};
|
|
5247
|
-
return { v, OP:
|
|
5328
|
+
return { v, OP: OP10, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
|
|
5248
5329
|
}
|
|
5249
5330
|
|
|
5250
5331
|
// src/resources/special/contracts/profitability.stages.ts
|
|
@@ -5259,12 +5340,12 @@ async function fetchCustomer(ctx, companyID) {
|
|
|
5259
5340
|
path: `/V1.0/Companies/${companyID}`,
|
|
5260
5341
|
operation: ctx.OP
|
|
5261
5342
|
});
|
|
5262
|
-
const item =
|
|
5343
|
+
const item = _chunkIKWHRUQ5cjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
|
|
5263
5344
|
customer = _nullishCoalesce(item, () => ( null));
|
|
5264
5345
|
customerStatus = "ok";
|
|
5265
5346
|
} catch (err) {
|
|
5266
|
-
if (!(err instanceof
|
|
5267
|
-
if (!(err instanceof
|
|
5347
|
+
if (!(err instanceof _chunkIKWHRUQ5cjs.AutotaskError)) throw err;
|
|
5348
|
+
if (!(err instanceof _chunkIKWHRUQ5cjs.NotFoundError)) {
|
|
5268
5349
|
customerStatus = "absent";
|
|
5269
5350
|
customerAbsent = err.code;
|
|
5270
5351
|
}
|
|
@@ -5278,9 +5359,9 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5278
5359
|
if (contractType > 0) {
|
|
5279
5360
|
ctx.wires.issued += 1;
|
|
5280
5361
|
try {
|
|
5281
|
-
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async
|
|
5362
|
+
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));
|
|
5282
5363
|
} catch (err) {
|
|
5283
|
-
if (!(err instanceof
|
|
5364
|
+
if (!(err instanceof _chunkIKWHRUQ5cjs.AutotaskError)) throw err;
|
|
5284
5365
|
}
|
|
5285
5366
|
}
|
|
5286
5367
|
const contractTypeKnown = contractTypeLabel !== null;
|
|
@@ -5289,7 +5370,7 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5289
5370
|
return { contractTypeLabel, contractTypeKnown, isBlockHours, isTimeAndMaterials };
|
|
5290
5371
|
}
|
|
5291
5372
|
async function fetchRoot(ctx, resource) {
|
|
5292
|
-
const contractCached = _optionalChain([ctx, 'access',
|
|
5373
|
+
const contractCached = _optionalChain([ctx, 'access', _58 => _58.rawHttp, 'access', _59 => _59.readCache, 'optionalAccess', _60 => _60.get, 'call', _61 => _61(`/V1.0/Contracts/${ctx.id}`)]) !== void 0;
|
|
5293
5374
|
const contract = await resource.get(ctx.id);
|
|
5294
5375
|
ctx.wires.issued += 1;
|
|
5295
5376
|
if (!contractCached) ctx.wires.requests += 1;
|
|
@@ -5342,8 +5423,8 @@ async function fetchInvoices(ctx, billingRows) {
|
|
|
5342
5423
|
if (invoiceIds.length === 0) {
|
|
5343
5424
|
return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
|
|
5344
5425
|
}
|
|
5345
|
-
const capped = capJoinSet2(invoiceIds,
|
|
5346
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${
|
|
5426
|
+
const capped = capJoinSet2(invoiceIds, _chunkIKWHRUQ5cjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5427
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunkIKWHRUQ5cjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5347
5428
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
|
|
5348
5429
|
ctx.wires.issued += 1;
|
|
5349
5430
|
return {
|
|
@@ -5389,7 +5470,7 @@ async function readOpenStatusSet(ctx) {
|
|
|
5389
5470
|
}
|
|
5390
5471
|
}
|
|
5391
5472
|
} catch (err) {
|
|
5392
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof
|
|
5473
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkIKWHRUQ5cjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5393
5474
|
}
|
|
5394
5475
|
return { openStatusSet, statusNote };
|
|
5395
5476
|
}
|
|
@@ -5412,8 +5493,8 @@ async function fetchResources(ctx, entries) {
|
|
|
5412
5493
|
if (resourceIds.length === 0) {
|
|
5413
5494
|
return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
|
|
5414
5495
|
}
|
|
5415
|
-
const capped = capJoinSet2(resourceIds,
|
|
5416
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${
|
|
5496
|
+
const capped = capJoinSet2(resourceIds, _chunkIKWHRUQ5cjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5497
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunkIKWHRUQ5cjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5417
5498
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
|
|
5418
5499
|
ctx.wires.issued += 1;
|
|
5419
5500
|
for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
|
|
@@ -5480,7 +5561,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
|
|
|
5480
5561
|
try {
|
|
5481
5562
|
return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
|
|
5482
5563
|
} catch (err) {
|
|
5483
|
-
if (!(err instanceof
|
|
5564
|
+
if (!(err instanceof _chunkIKWHRUQ5cjs.AutotaskError)) throw err;
|
|
5484
5565
|
return null;
|
|
5485
5566
|
}
|
|
5486
5567
|
}
|
|
@@ -5497,17 +5578,17 @@ async function fetchSubscriptions(ctx, cis) {
|
|
|
5497
5578
|
cancelledSubs
|
|
5498
5579
|
};
|
|
5499
5580
|
}
|
|
5500
|
-
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0),
|
|
5581
|
+
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunkIKWHRUQ5cjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5501
5582
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5502
5583
|
const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5503
5584
|
const subscriptions = raw.items;
|
|
5504
5585
|
const labels = await readSubscriptionLabels(ctx, subscriptions);
|
|
5505
5586
|
for (const x of subscriptions) {
|
|
5506
5587
|
const sid = num(x["id"]);
|
|
5507
|
-
const periodLabel = _optionalChain([labels, 'optionalAccess',
|
|
5588
|
+
const periodLabel = _optionalChain([labels, 'optionalAccess', _62 => _62.get, 'call', _63 => _63("periodType"), 'optionalAccess', _64 => _64.get, 'call', _65 => _65(num(x["periodType"]))]);
|
|
5508
5589
|
subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
|
|
5509
5590
|
if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
|
|
5510
|
-
const statusLabel = _optionalChain([labels, 'optionalAccess',
|
|
5591
|
+
const statusLabel = _optionalChain([labels, 'optionalAccess', _66 => _66.get, 'call', _67 => _67("status"), 'optionalAccess', _68 => _68.get, 'call', _69 => _69(num(x["status"]))]);
|
|
5511
5592
|
const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num(x["status"]));
|
|
5512
5593
|
if (notActive) cancelledSubs.add(sid);
|
|
5513
5594
|
}
|
|
@@ -6182,7 +6263,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
6182
6263
|
}
|
|
6183
6264
|
|
|
6184
6265
|
// src/resources/contracts.ts
|
|
6185
|
-
var ContractsResource = class extends
|
|
6266
|
+
var ContractsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6186
6267
|
constructor(http, pageSize) {
|
|
6187
6268
|
super(http, {
|
|
6188
6269
|
key: "contracts",
|
|
@@ -6244,7 +6325,7 @@ var ContractsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6244
6325
|
/** Search Contract records: bounded contains on contractName (no vendor free-text search exists);
|
|
6245
6326
|
* limit defaults to 25, max 500. */
|
|
6246
6327
|
async search(query, opts) {
|
|
6247
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6328
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _70 => _70.limit]) });
|
|
6248
6329
|
}
|
|
6249
6330
|
/** Node-parity special op (hand-written in src/resources/special/contracts.ts). */
|
|
6250
6331
|
profitability(id, opts) {
|
|
@@ -6253,7 +6334,7 @@ var ContractsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6253
6334
|
};
|
|
6254
6335
|
|
|
6255
6336
|
// src/resources/contract_ticket_purchases.ts
|
|
6256
|
-
var ContractTicketPurchasesResource = class extends
|
|
6337
|
+
var ContractTicketPurchasesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6257
6338
|
constructor(http, pageSize) {
|
|
6258
6339
|
super(http, {
|
|
6259
6340
|
key: "contract_ticket_purchases",
|
|
@@ -6312,7 +6393,7 @@ var ContractTicketPurchasesResource = class extends _chunkZJ4ONAQFcjs.BaseResour
|
|
|
6312
6393
|
};
|
|
6313
6394
|
|
|
6314
6395
|
// src/resources/countries.ts
|
|
6315
|
-
var CountriesResource = class extends
|
|
6396
|
+
var CountriesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6316
6397
|
constructor(http, pageSize) {
|
|
6317
6398
|
super(http, {
|
|
6318
6399
|
key: "countries",
|
|
@@ -6366,12 +6447,12 @@ var CountriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6366
6447
|
/** Search Country records: bounded contains on name (no vendor free-text search exists);
|
|
6367
6448
|
* limit defaults to 25, max 500. */
|
|
6368
6449
|
async search(query, opts) {
|
|
6369
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6450
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _71 => _71.limit]) });
|
|
6370
6451
|
}
|
|
6371
6452
|
};
|
|
6372
6453
|
|
|
6373
6454
|
// src/resources/currencies.ts
|
|
6374
|
-
var CurrenciesResource = class extends
|
|
6455
|
+
var CurrenciesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6375
6456
|
constructor(http, pageSize) {
|
|
6376
6457
|
super(http, {
|
|
6377
6458
|
key: "currencies",
|
|
@@ -6410,12 +6491,12 @@ var CurrenciesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6410
6491
|
/** Search Currency records: bounded contains on name (no vendor free-text search exists);
|
|
6411
6492
|
* limit defaults to 25, max 500. */
|
|
6412
6493
|
async search(query, opts) {
|
|
6413
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6494
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _72 => _72.limit]) });
|
|
6414
6495
|
}
|
|
6415
6496
|
};
|
|
6416
6497
|
|
|
6417
6498
|
// src/resources/departments.ts
|
|
6418
|
-
var DepartmentsResource = class extends
|
|
6499
|
+
var DepartmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6419
6500
|
constructor(http, pageSize) {
|
|
6420
6501
|
super(http, {
|
|
6421
6502
|
key: "departments",
|
|
@@ -6477,12 +6558,12 @@ var DepartmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6477
6558
|
/** Search Department records: bounded contains on name (no vendor free-text search exists);
|
|
6478
6559
|
* limit defaults to 25, max 500. */
|
|
6479
6560
|
async search(query, opts) {
|
|
6480
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6561
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _73 => _73.limit]) });
|
|
6481
6562
|
}
|
|
6482
6563
|
};
|
|
6483
6564
|
|
|
6484
6565
|
// src/resources/domain_registrars.ts
|
|
6485
|
-
var DomainRegistrarsResource = class extends
|
|
6566
|
+
var DomainRegistrarsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6486
6567
|
constructor(http, pageSize) {
|
|
6487
6568
|
super(http, {
|
|
6488
6569
|
key: "domain_registrars",
|
|
@@ -6544,7 +6625,7 @@ var DomainRegistrarsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6544
6625
|
/** Search DomainRegistrar records: bounded contains on name (no vendor free-text search exists);
|
|
6545
6626
|
* limit defaults to 25, max 500. */
|
|
6546
6627
|
async search(query, opts) {
|
|
6547
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6628
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _74 => _74.limit]) });
|
|
6548
6629
|
}
|
|
6549
6630
|
};
|
|
6550
6631
|
|
|
@@ -6565,7 +6646,7 @@ var EntityInformationResource = class {
|
|
|
6565
6646
|
};
|
|
6566
6647
|
|
|
6567
6648
|
// src/resources/expense_item_attachments.ts
|
|
6568
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6649
|
+
var ExpenseItemAttachmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6569
6650
|
constructor(http, pageSize) {
|
|
6570
6651
|
super(http, {
|
|
6571
6652
|
key: "expense_item_attachments",
|
|
@@ -6627,7 +6708,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
6627
6708
|
};
|
|
6628
6709
|
|
|
6629
6710
|
// src/resources/expense_items.ts
|
|
6630
|
-
var ExpenseItemsResource = class extends
|
|
6711
|
+
var ExpenseItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6631
6712
|
constructor(http, pageSize) {
|
|
6632
6713
|
super(http, {
|
|
6633
6714
|
key: "expense_items",
|
|
@@ -6686,7 +6767,7 @@ var ExpenseItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6686
6767
|
};
|
|
6687
6768
|
|
|
6688
6769
|
// src/resources/expense_reports.ts
|
|
6689
|
-
var ExpenseReportsResource = class extends
|
|
6770
|
+
var ExpenseReportsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6690
6771
|
constructor(http, pageSize) {
|
|
6691
6772
|
super(http, {
|
|
6692
6773
|
key: "expense_reports",
|
|
@@ -6748,12 +6829,12 @@ var ExpenseReportsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6748
6829
|
/** Search ExpenseReport records: bounded contains on name (no vendor free-text search exists);
|
|
6749
6830
|
* limit defaults to 25, max 500. */
|
|
6750
6831
|
async search(query, opts) {
|
|
6751
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6832
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _75 => _75.limit]) });
|
|
6752
6833
|
}
|
|
6753
6834
|
};
|
|
6754
6835
|
|
|
6755
6836
|
// src/resources/holiday_sets.ts
|
|
6756
|
-
var HolidaySetsResource = class extends
|
|
6837
|
+
var HolidaySetsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6757
6838
|
constructor(http, pageSize) {
|
|
6758
6839
|
super(http, {
|
|
6759
6840
|
key: "holiday_sets",
|
|
@@ -6822,7 +6903,7 @@ var HolidaySetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
6822
6903
|
};
|
|
6823
6904
|
|
|
6824
6905
|
// src/resources/holidays.ts
|
|
6825
|
-
var HolidaysResource = class extends
|
|
6906
|
+
var HolidaysResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6826
6907
|
constructor(http, pageSize) {
|
|
6827
6908
|
super(http, {
|
|
6828
6909
|
key: "holidays",
|
|
@@ -6894,10 +6975,10 @@ var PATH_SUFFIX = {
|
|
|
6894
6975
|
transfer: "StockedItemsTransfer"
|
|
6895
6976
|
};
|
|
6896
6977
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6897
|
-
const numericParent =
|
|
6978
|
+
const numericParent = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6898
6979
|
const suffix = PATH_SUFFIX[kind];
|
|
6899
6980
|
if (opts.dryRun === true) {
|
|
6900
|
-
return
|
|
6981
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
6901
6982
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6902
6983
|
method: "POST",
|
|
6903
6984
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6914,11 +6995,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6914
6995
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6915
6996
|
maxRetries: opts.maxRetries
|
|
6916
6997
|
});
|
|
6917
|
-
return
|
|
6998
|
+
return _chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, res);
|
|
6918
6999
|
}
|
|
6919
7000
|
|
|
6920
7001
|
// src/resources/inventory_products.ts
|
|
6921
|
-
var InventoryProductsResource = class extends
|
|
7002
|
+
var InventoryProductsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
6922
7003
|
constructor(http, pageSize) {
|
|
6923
7004
|
super(http, {
|
|
6924
7005
|
key: "inventory_products",
|
|
@@ -7000,7 +7081,7 @@ var InventoryProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7000
7081
|
|
|
7001
7082
|
// src/resources/special/invoices.ts
|
|
7002
7083
|
async function markup(_resource, id, format, http) {
|
|
7003
|
-
const numericId =
|
|
7084
|
+
const numericId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
7004
7085
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
7005
7086
|
const res = await http.request({
|
|
7006
7087
|
method: "GET",
|
|
@@ -7009,7 +7090,7 @@ async function markup(_resource, id, format, http) {
|
|
|
7009
7090
|
});
|
|
7010
7091
|
const body = res;
|
|
7011
7092
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
7012
|
-
throw new (0,
|
|
7093
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskError)(
|
|
7013
7094
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
7014
7095
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
|
|
7015
7096
|
);
|
|
@@ -7017,44 +7098,44 @@ async function markup(_resource, id, format, http) {
|
|
|
7017
7098
|
return body.invoiceMarkup;
|
|
7018
7099
|
}
|
|
7019
7100
|
async function pdf(_resource, id, http) {
|
|
7020
|
-
const numericId =
|
|
7101
|
+
const numericId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
7021
7102
|
const res = await http.request({
|
|
7022
7103
|
method: "GET",
|
|
7023
7104
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
7024
7105
|
operation: "invoices.pdf"
|
|
7025
7106
|
});
|
|
7026
|
-
return
|
|
7107
|
+
return _chunkIKWHRUQ5cjs.decodeFileData.call(void 0, res);
|
|
7027
7108
|
}
|
|
7028
7109
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
7029
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
7030
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
7110
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _76 => _76.now]), () => ( /* @__PURE__ */ new Date()));
|
|
7111
|
+
const tz = _optionalChain([opts, 'optionalAccess', _77 => _77.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
|
|
7031
7112
|
return dateWindowQuery(
|
|
7032
7113
|
http,
|
|
7033
7114
|
"/V1.0/Invoices/query",
|
|
7034
7115
|
"invoiceDateTime",
|
|
7035
7116
|
kind,
|
|
7036
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
7117
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _78 => _78.limit])),
|
|
7037
7118
|
`invoices.${kind}`,
|
|
7038
7119
|
now,
|
|
7039
7120
|
tz
|
|
7040
7121
|
);
|
|
7041
7122
|
}
|
|
7042
7123
|
async function customRange2(_resource, from, to, http, opts) {
|
|
7043
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
7124
|
+
const zone = _optionalChain([opts, 'optionalAccess', _79 => _79.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
|
|
7044
7125
|
return customRangeQuery(
|
|
7045
7126
|
http,
|
|
7046
7127
|
"/V1.0/Invoices/query",
|
|
7047
7128
|
"invoiceDateTime",
|
|
7048
7129
|
from,
|
|
7049
7130
|
to,
|
|
7050
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
7131
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _80 => _80.limit])),
|
|
7051
7132
|
"invoices.customRange",
|
|
7052
7133
|
zone
|
|
7053
7134
|
);
|
|
7054
7135
|
}
|
|
7055
7136
|
|
|
7056
7137
|
// src/resources/invoices.ts
|
|
7057
|
-
var InvoicesResource = class extends
|
|
7138
|
+
var InvoicesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7058
7139
|
constructor(http, pageSize) {
|
|
7059
7140
|
super(http, {
|
|
7060
7141
|
key: "invoices",
|
|
@@ -7168,7 +7249,7 @@ var InvoicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7168
7249
|
};
|
|
7169
7250
|
|
|
7170
7251
|
// src/resources/invoice_templates.ts
|
|
7171
|
-
var InvoiceTemplatesResource = class extends
|
|
7252
|
+
var InvoiceTemplatesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7172
7253
|
constructor(http, pageSize) {
|
|
7173
7254
|
super(http, {
|
|
7174
7255
|
key: "invoice_templates",
|
|
@@ -7212,7 +7293,7 @@ var ModulesResource = class {
|
|
|
7212
7293
|
};
|
|
7213
7294
|
|
|
7214
7295
|
// src/resources/notification_history.ts
|
|
7215
|
-
var NotificationHistoryResource = class extends
|
|
7296
|
+
var NotificationHistoryResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7216
7297
|
constructor(http, pageSize) {
|
|
7217
7298
|
super(http, {
|
|
7218
7299
|
key: "notification_history",
|
|
@@ -7251,7 +7332,7 @@ var NotificationHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7251
7332
|
};
|
|
7252
7333
|
|
|
7253
7334
|
// src/resources/opportunities.ts
|
|
7254
|
-
var OpportunitiesResource = class extends
|
|
7335
|
+
var OpportunitiesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7255
7336
|
constructor(http, pageSize) {
|
|
7256
7337
|
super(http, {
|
|
7257
7338
|
key: "opportunities",
|
|
@@ -7313,7 +7394,7 @@ var OpportunitiesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7313
7394
|
};
|
|
7314
7395
|
|
|
7315
7396
|
// src/resources/opportunity_attachments.ts
|
|
7316
|
-
var OpportunityAttachmentsResource = class extends
|
|
7397
|
+
var OpportunityAttachmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7317
7398
|
constructor(http, pageSize) {
|
|
7318
7399
|
super(http, {
|
|
7319
7400
|
key: "opportunity_attachments",
|
|
@@ -7375,7 +7456,7 @@ var OpportunityAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
7375
7456
|
};
|
|
7376
7457
|
|
|
7377
7458
|
// src/resources/opportunity_categories.ts
|
|
7378
|
-
var OpportunityCategoriesResource = class extends
|
|
7459
|
+
var OpportunityCategoriesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7379
7460
|
constructor(http, pageSize) {
|
|
7380
7461
|
super(http, {
|
|
7381
7462
|
key: "opportunity_categories",
|
|
@@ -7429,12 +7510,12 @@ var OpportunityCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
7429
7510
|
/** Search OpportunityCategory records: bounded contains on name (no vendor free-text search exists);
|
|
7430
7511
|
* limit defaults to 25, max 500. */
|
|
7431
7512
|
async search(query, opts) {
|
|
7432
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7513
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
|
|
7433
7514
|
}
|
|
7434
7515
|
};
|
|
7435
7516
|
|
|
7436
7517
|
// src/resources/organizational_level1s.ts
|
|
7437
|
-
var OrganizationalLevel1sResource = class extends
|
|
7518
|
+
var OrganizationalLevel1sResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7438
7519
|
constructor(http, pageSize) {
|
|
7439
7520
|
super(http, {
|
|
7440
7521
|
key: "organizational_level1s",
|
|
@@ -7485,7 +7566,7 @@ var OrganizationalLevel1sResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
7485
7566
|
};
|
|
7486
7567
|
|
|
7487
7568
|
// src/resources/organizational_level2s.ts
|
|
7488
|
-
var OrganizationalLevel2sResource = class extends
|
|
7569
|
+
var OrganizationalLevel2sResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7489
7570
|
constructor(http, pageSize) {
|
|
7490
7571
|
super(http, {
|
|
7491
7572
|
key: "organizational_level2s",
|
|
@@ -7536,7 +7617,7 @@ var OrganizationalLevel2sResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
7536
7617
|
};
|
|
7537
7618
|
|
|
7538
7619
|
// src/resources/organizational_level_associations.ts
|
|
7539
|
-
var OrganizationalLevelAssociationsResource = class extends
|
|
7620
|
+
var OrganizationalLevelAssociationsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7540
7621
|
constructor(http, pageSize) {
|
|
7541
7622
|
super(http, {
|
|
7542
7623
|
key: "organizational_level_associations",
|
|
@@ -7587,7 +7668,7 @@ var OrganizationalLevelAssociationsResource = class extends _chunkZJ4ONAQFcjs.Ba
|
|
|
7587
7668
|
};
|
|
7588
7669
|
|
|
7589
7670
|
// src/resources/phases.ts
|
|
7590
|
-
var PhasesResource = class extends
|
|
7671
|
+
var PhasesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7591
7672
|
constructor(http, pageSize) {
|
|
7592
7673
|
super(http, {
|
|
7593
7674
|
key: "phases",
|
|
@@ -7646,7 +7727,7 @@ var PhasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7646
7727
|
};
|
|
7647
7728
|
|
|
7648
7729
|
// src/resources/products.ts
|
|
7649
|
-
var ProductsResource = class extends
|
|
7730
|
+
var ProductsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7650
7731
|
constructor(http, pageSize) {
|
|
7651
7732
|
super(http, {
|
|
7652
7733
|
key: "products",
|
|
@@ -7708,12 +7789,12 @@ var ProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7708
7789
|
/** Search Product records: bounded contains on name (no vendor free-text search exists);
|
|
7709
7790
|
* limit defaults to 25, max 500. */
|
|
7710
7791
|
async search(query, opts) {
|
|
7711
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7792
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
|
|
7712
7793
|
}
|
|
7713
7794
|
};
|
|
7714
7795
|
|
|
7715
7796
|
// src/resources/product_vendors.ts
|
|
7716
|
-
var ProductVendorsResource = class extends
|
|
7797
|
+
var ProductVendorsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7717
7798
|
constructor(http, pageSize) {
|
|
7718
7799
|
super(http, {
|
|
7719
7800
|
key: "product_vendors",
|
|
@@ -7772,7 +7853,7 @@ var ProductVendorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7772
7853
|
};
|
|
7773
7854
|
|
|
7774
7855
|
// src/resources/project_charges.ts
|
|
7775
|
-
var ProjectChargesResource = class extends
|
|
7856
|
+
var ProjectChargesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7776
7857
|
constructor(http, pageSize) {
|
|
7777
7858
|
super(http, {
|
|
7778
7859
|
key: "project_charges",
|
|
@@ -7838,12 +7919,12 @@ var ProjectChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7838
7919
|
/** Search ProjectCharge records: bounded contains on name (no vendor free-text search exists);
|
|
7839
7920
|
* limit defaults to 25, max 500. */
|
|
7840
7921
|
async search(query, opts) {
|
|
7841
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7922
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _83 => _83.limit]) });
|
|
7842
7923
|
}
|
|
7843
7924
|
};
|
|
7844
7925
|
|
|
7845
7926
|
// src/resources/project_notes.ts
|
|
7846
|
-
var ProjectNotesResource = class extends
|
|
7927
|
+
var ProjectNotesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7847
7928
|
constructor(http, pageSize) {
|
|
7848
7929
|
super(http, {
|
|
7849
7930
|
key: "project_notes",
|
|
@@ -7902,7 +7983,7 @@ var ProjectNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7902
7983
|
};
|
|
7903
7984
|
|
|
7904
7985
|
// src/resources/projects.ts
|
|
7905
|
-
var ProjectsResource = class extends
|
|
7986
|
+
var ProjectsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7906
7987
|
constructor(http, pageSize) {
|
|
7907
7988
|
super(http, {
|
|
7908
7989
|
key: "projects",
|
|
@@ -7964,7 +8045,7 @@ var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7964
8045
|
/** Search Project records: bounded contains on projectName (no vendor free-text search exists);
|
|
7965
8046
|
* limit defaults to 25, max 500. */
|
|
7966
8047
|
async search(query, opts) {
|
|
7967
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8048
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _84 => _84.limit]) });
|
|
7968
8049
|
}
|
|
7969
8050
|
/** Get the Project with its primary context records in one call (each part a single-record
|
|
7970
8051
|
* fetch; no sub-lists; absent/dangling references come back null). `names: true` (issue #77)
|
|
@@ -7979,13 +8060,13 @@ var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7979
8060
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
7980
8061
|
const result = { project: project2, company, opportunity, leadResource };
|
|
7981
8062
|
if (opts.names === true) {
|
|
7982
|
-
const builder =
|
|
8063
|
+
const builder = _chunkIKWHRUQ5cjs.createNamePlan.call(void 0, );
|
|
7983
8064
|
builder.addResource(root["creatorResourceID"]);
|
|
7984
8065
|
builder.addFk("contract", root["contractID"]);
|
|
7985
|
-
const names = await
|
|
8066
|
+
const names = await _chunkIKWHRUQ5cjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
7986
8067
|
const row = { ...project2 };
|
|
7987
|
-
|
|
7988
|
-
|
|
8068
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
8069
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
7989
8070
|
result.project = row;
|
|
7990
8071
|
result.names = names.section;
|
|
7991
8072
|
}
|
|
@@ -7994,7 +8075,7 @@ var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
7994
8075
|
};
|
|
7995
8076
|
|
|
7996
8077
|
// src/resources/purchase_approvals.ts
|
|
7997
|
-
var PurchaseApprovalsResource = class extends
|
|
8078
|
+
var PurchaseApprovalsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
7998
8079
|
constructor(http, pageSize) {
|
|
7999
8080
|
super(http, {
|
|
8000
8081
|
key: "purchase_approvals",
|
|
@@ -8048,7 +8129,7 @@ var PurchaseApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8048
8129
|
};
|
|
8049
8130
|
|
|
8050
8131
|
// src/resources/purchase_order_item_receiving.ts
|
|
8051
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
8132
|
+
var PurchaseOrderItemReceivingResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8052
8133
|
constructor(http, pageSize) {
|
|
8053
8134
|
super(http, {
|
|
8054
8135
|
key: "purchase_order_item_receiving",
|
|
@@ -8098,7 +8179,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkZJ4ONAQFcjs.BaseRes
|
|
|
8098
8179
|
};
|
|
8099
8180
|
|
|
8100
8181
|
// src/resources/purchase_order_items.ts
|
|
8101
|
-
var PurchaseOrderItemsResource = class extends
|
|
8182
|
+
var PurchaseOrderItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8102
8183
|
constructor(http, pageSize) {
|
|
8103
8184
|
super(http, {
|
|
8104
8185
|
key: "purchase_order_items",
|
|
@@ -8157,7 +8238,7 @@ var PurchaseOrderItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8157
8238
|
};
|
|
8158
8239
|
|
|
8159
8240
|
// src/resources/purchase_orders.ts
|
|
8160
|
-
var PurchaseOrdersResource = class extends
|
|
8241
|
+
var PurchaseOrdersResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8161
8242
|
constructor(http, pageSize) {
|
|
8162
8243
|
super(http, {
|
|
8163
8244
|
key: "purchase_orders",
|
|
@@ -8219,7 +8300,7 @@ var PurchaseOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8219
8300
|
};
|
|
8220
8301
|
|
|
8221
8302
|
// src/resources/quote_items.ts
|
|
8222
|
-
var QuoteItemsResource = class extends
|
|
8303
|
+
var QuoteItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8223
8304
|
constructor(http, pageSize) {
|
|
8224
8305
|
super(http, {
|
|
8225
8306
|
key: "quote_items",
|
|
@@ -8285,12 +8366,12 @@ var QuoteItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8285
8366
|
/** Search QuoteItem records: bounded contains on name (no vendor free-text search exists);
|
|
8286
8367
|
* limit defaults to 25, max 500. */
|
|
8287
8368
|
async search(query, opts) {
|
|
8288
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8369
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _85 => _85.limit]) });
|
|
8289
8370
|
}
|
|
8290
8371
|
};
|
|
8291
8372
|
|
|
8292
8373
|
// src/resources/quote_locations.ts
|
|
8293
|
-
var QuoteLocationsResource = class extends
|
|
8374
|
+
var QuoteLocationsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8294
8375
|
constructor(http, pageSize) {
|
|
8295
8376
|
super(http, {
|
|
8296
8377
|
key: "quote_locations",
|
|
@@ -8355,7 +8436,7 @@ var QuoteLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8355
8436
|
};
|
|
8356
8437
|
|
|
8357
8438
|
// src/resources/quotes.ts
|
|
8358
|
-
var QuotesResource = class extends
|
|
8439
|
+
var QuotesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8359
8440
|
constructor(http, pageSize) {
|
|
8360
8441
|
super(http, {
|
|
8361
8442
|
key: "quotes",
|
|
@@ -8417,12 +8498,12 @@ var QuotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8417
8498
|
/** Search Quote records: bounded contains on name (no vendor free-text search exists);
|
|
8418
8499
|
* limit defaults to 25, max 500. */
|
|
8419
8500
|
async search(query, opts) {
|
|
8420
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8501
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _86 => _86.limit]) });
|
|
8421
8502
|
}
|
|
8422
8503
|
};
|
|
8423
8504
|
|
|
8424
8505
|
// src/resources/quote_templates.ts
|
|
8425
|
-
var QuoteTemplatesResource = class extends
|
|
8506
|
+
var QuoteTemplatesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8426
8507
|
constructor(http, pageSize) {
|
|
8427
8508
|
super(http, {
|
|
8428
8509
|
key: "quote_templates",
|
|
@@ -8461,12 +8542,12 @@ var QuoteTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8461
8542
|
/** Search QuoteTemplate records: bounded contains on name (no vendor free-text search exists);
|
|
8462
8543
|
* limit defaults to 25, max 500. */
|
|
8463
8544
|
async search(query, opts) {
|
|
8464
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8545
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _87 => _87.limit]) });
|
|
8465
8546
|
}
|
|
8466
8547
|
};
|
|
8467
8548
|
|
|
8468
8549
|
// src/resources/resource_role_queues.ts
|
|
8469
|
-
var ResourceRoleQueuesResource = class extends
|
|
8550
|
+
var ResourceRoleQueuesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8470
8551
|
constructor(http, pageSize) {
|
|
8471
8552
|
super(http, {
|
|
8472
8553
|
key: "resource_role_queues",
|
|
@@ -8525,7 +8606,7 @@ var ResourceRoleQueuesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8525
8606
|
};
|
|
8526
8607
|
|
|
8527
8608
|
// src/resources/resource_roles.ts
|
|
8528
|
-
var ResourceRolesResource = class extends
|
|
8609
|
+
var ResourceRolesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8529
8610
|
constructor(http, pageSize) {
|
|
8530
8611
|
super(http, {
|
|
8531
8612
|
key: "resource_roles",
|
|
@@ -8567,7 +8648,7 @@ var ResourceRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8567
8648
|
};
|
|
8568
8649
|
|
|
8569
8650
|
// src/resources/resource_skills.ts
|
|
8570
|
-
var ResourceSkillsResource = class extends
|
|
8651
|
+
var ResourceSkillsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8571
8652
|
constructor(http, pageSize) {
|
|
8572
8653
|
super(http, {
|
|
8573
8654
|
key: "resource_skills",
|
|
@@ -8621,16 +8702,16 @@ var ResourceSkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8621
8702
|
var MAX_TRANSFER_IDS = 500;
|
|
8622
8703
|
function requirePositiveIds(ids2, label) {
|
|
8623
8704
|
if (!Array.isArray(ids2) || ids2.length === 0) {
|
|
8624
|
-
throw new (0,
|
|
8705
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8625
8706
|
}
|
|
8626
8707
|
if (ids2.length > MAX_TRANSFER_IDS) {
|
|
8627
|
-
throw new (0,
|
|
8708
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8628
8709
|
}
|
|
8629
8710
|
const out = [];
|
|
8630
8711
|
for (const raw of ids2) {
|
|
8631
|
-
const id =
|
|
8712
|
+
const id = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8632
8713
|
if (typeof id === "number" && id < 1) {
|
|
8633
|
-
throw new (0,
|
|
8714
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8634
8715
|
}
|
|
8635
8716
|
out.push(id);
|
|
8636
8717
|
}
|
|
@@ -8638,7 +8719,7 @@ function requirePositiveIds(ids2, label) {
|
|
|
8638
8719
|
}
|
|
8639
8720
|
async function whoAmI(_resource, userName, http) {
|
|
8640
8721
|
const user = userName.trim();
|
|
8641
|
-
if (user === "") throw new (0,
|
|
8722
|
+
if (user === "") throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8642
8723
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8643
8724
|
const res = await http.request({
|
|
8644
8725
|
method: "POST",
|
|
@@ -8647,11 +8728,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8647
8728
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8648
8729
|
operation: "resources.whoAmI"
|
|
8649
8730
|
});
|
|
8650
|
-
const matches =
|
|
8731
|
+
const matches = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items;
|
|
8651
8732
|
if (matches.length === 0) return null;
|
|
8652
8733
|
if (matches.length > 1) {
|
|
8653
8734
|
const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8654
|
-
throw new (0,
|
|
8735
|
+
throw new (0, _chunkIKWHRUQ5cjs.ResolutionError)(
|
|
8655
8736
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8656
8737
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
8657
8738
|
);
|
|
@@ -8660,11 +8741,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8660
8741
|
}
|
|
8661
8742
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8662
8743
|
const ids2 = requirePositiveIds(companyIds, "transferOwnership");
|
|
8663
|
-
const destination =
|
|
8744
|
+
const destination = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8664
8745
|
if (typeof destination === "number" && destination < 1) {
|
|
8665
|
-
throw new (0,
|
|
8746
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8666
8747
|
}
|
|
8667
|
-
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
8748
|
+
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _88 => _88.dryRun]), () => ( true));
|
|
8668
8749
|
const changes = [];
|
|
8669
8750
|
const applied = [];
|
|
8670
8751
|
for (const id of ids2) {
|
|
@@ -8673,9 +8754,9 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8673
8754
|
method: "GET",
|
|
8674
8755
|
path: `/V1.0/Companies/${id}`,
|
|
8675
8756
|
operation: "resources.transferOwnership",
|
|
8676
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8757
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _89 => _89.maxRetries])
|
|
8677
8758
|
});
|
|
8678
|
-
const company =
|
|
8759
|
+
const company = _chunkIKWHRUQ5cjs.unwrapItem.call(void 0, res, id, void 0, "company");
|
|
8679
8760
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8680
8761
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8681
8762
|
if (!dryRun) {
|
|
@@ -8684,15 +8765,15 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8684
8765
|
path: "/V1.0/Companies",
|
|
8685
8766
|
body: { id, ownerResourceID: destination },
|
|
8686
8767
|
operation: "resources.transferOwnership",
|
|
8687
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8768
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _90 => _90.maxRetries])
|
|
8688
8769
|
});
|
|
8689
|
-
|
|
8770
|
+
_chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, update);
|
|
8690
8771
|
applied.push(id);
|
|
8691
8772
|
}
|
|
8692
8773
|
} catch (err) {
|
|
8693
|
-
if (!dryRun && err instanceof
|
|
8774
|
+
if (!dryRun && err instanceof _chunkIKWHRUQ5cjs.AutotaskError) {
|
|
8694
8775
|
err.resourceIds = [id];
|
|
8695
|
-
err.details =
|
|
8776
|
+
err.details = _chunkIKWHRUQ5cjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
|
|
8696
8777
|
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).`;
|
|
8697
8778
|
}
|
|
8698
8779
|
throw err;
|
|
@@ -8701,7 +8782,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8701
8782
|
if (dryRun) {
|
|
8702
8783
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8703
8784
|
return {
|
|
8704
|
-
...
|
|
8785
|
+
..._chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
8705
8786
|
operation: "resources.transferOwnership",
|
|
8706
8787
|
method: "PUT",
|
|
8707
8788
|
path: "/V1.0/Companies",
|
|
@@ -8725,7 +8806,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8725
8806
|
}
|
|
8726
8807
|
|
|
8727
8808
|
// src/resources/resources.ts
|
|
8728
|
-
var ResourcesResource = class extends
|
|
8809
|
+
var ResourcesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8729
8810
|
|
|
8730
8811
|
constructor(http, clientConfig, pageSize) {
|
|
8731
8812
|
super(http, {
|
|
@@ -8784,7 +8865,7 @@ var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8784
8865
|
/** Search Resource records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
8785
8866
|
* limit defaults to 25, max 500. */
|
|
8786
8867
|
async search(query, opts) {
|
|
8787
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8868
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
|
|
8788
8869
|
}
|
|
8789
8870
|
/** Node-parity special op (hand-written in src/resources/special/resources.ts). */
|
|
8790
8871
|
transferOwnership(sourceResourceIds, destinationResourceId, opts = {}) {
|
|
@@ -8798,7 +8879,7 @@ var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
8798
8879
|
|
|
8799
8880
|
// src/resources/special/resource_time_off_additional.ts
|
|
8800
8881
|
async function getByResource(_resource, resourceId, http) {
|
|
8801
|
-
const numericResource =
|
|
8882
|
+
const numericResource = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8802
8883
|
const res = await http.request({
|
|
8803
8884
|
method: "GET",
|
|
8804
8885
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8812,11 +8893,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8812
8893
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8813
8894
|
}
|
|
8814
8895
|
}
|
|
8815
|
-
return
|
|
8896
|
+
return _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8816
8897
|
}
|
|
8817
8898
|
|
|
8818
8899
|
// src/resources/resource_time_off_additional.ts
|
|
8819
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8900
|
+
var ResourceTimeOffAdditionalResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8820
8901
|
constructor(http, pageSize) {
|
|
8821
8902
|
super(http, {
|
|
8822
8903
|
key: "resource_time_off_additional",
|
|
@@ -8855,7 +8936,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkZJ4ONAQFcjs.BaseReso
|
|
|
8855
8936
|
};
|
|
8856
8937
|
|
|
8857
8938
|
// src/resources/resource_time_off_approvers.ts
|
|
8858
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8939
|
+
var ResourceTimeOffApproversResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8859
8940
|
constructor(http, pageSize) {
|
|
8860
8941
|
super(http, {
|
|
8861
8942
|
key: "resource_time_off_approvers",
|
|
@@ -8898,29 +8979,29 @@ var ResourceTimeOffApproversResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
8898
8979
|
|
|
8899
8980
|
// src/resources/special/resource_time_off_balances.ts
|
|
8900
8981
|
async function getByResource2(_resource, resourceId, http) {
|
|
8901
|
-
const numericResource =
|
|
8982
|
+
const numericResource = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8902
8983
|
const res = await http.request({
|
|
8903
8984
|
method: "GET",
|
|
8904
8985
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8905
8986
|
operation: "resource_time_off_balances.getByResource"
|
|
8906
8987
|
});
|
|
8907
|
-
return
|
|
8988
|
+
return _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8908
8989
|
}
|
|
8909
8990
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8910
|
-
const numericResource =
|
|
8991
|
+
const numericResource = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8911
8992
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8912
|
-
throw new (0,
|
|
8993
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8913
8994
|
}
|
|
8914
8995
|
const res = await http.request({
|
|
8915
8996
|
method: "GET",
|
|
8916
8997
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8917
8998
|
operation: "resource_time_off_balances.getByYear"
|
|
8918
8999
|
});
|
|
8919
|
-
return
|
|
9000
|
+
return _chunkIKWHRUQ5cjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
8920
9001
|
}
|
|
8921
9002
|
|
|
8922
9003
|
// src/resources/resource_time_off_balances.ts
|
|
8923
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
9004
|
+
var ResourceTimeOffBalancesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8924
9005
|
constructor(http, pageSize) {
|
|
8925
9006
|
super(http, {
|
|
8926
9007
|
key: "resource_time_off_balances",
|
|
@@ -8958,7 +9039,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkZJ4ONAQFcjs.BaseResour
|
|
|
8958
9039
|
};
|
|
8959
9040
|
|
|
8960
9041
|
// src/resources/roles.ts
|
|
8961
|
-
var RolesResource = class extends
|
|
9042
|
+
var RolesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
8962
9043
|
constructor(http, pageSize) {
|
|
8963
9044
|
super(http, {
|
|
8964
9045
|
key: "roles",
|
|
@@ -9020,12 +9101,12 @@ var RolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9020
9101
|
/** Search Role records: bounded contains on name (no vendor free-text search exists);
|
|
9021
9102
|
* limit defaults to 25, max 500. */
|
|
9022
9103
|
async search(query, opts) {
|
|
9023
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9104
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
|
|
9024
9105
|
}
|
|
9025
9106
|
};
|
|
9026
9107
|
|
|
9027
9108
|
// src/resources/sales_orders.ts
|
|
9028
|
-
var SalesOrdersResource = class extends
|
|
9109
|
+
var SalesOrdersResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9029
9110
|
constructor(http, pageSize) {
|
|
9030
9111
|
super(http, {
|
|
9031
9112
|
key: "sales_orders",
|
|
@@ -9068,7 +9149,7 @@ var SalesOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9068
9149
|
};
|
|
9069
9150
|
|
|
9070
9151
|
// src/resources/service_calls.ts
|
|
9071
|
-
var ServiceCallsResource = class extends
|
|
9152
|
+
var ServiceCallsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9072
9153
|
constructor(http, pageSize) {
|
|
9073
9154
|
super(http, {
|
|
9074
9155
|
key: "service_calls",
|
|
@@ -9137,7 +9218,7 @@ var ServiceCallsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9137
9218
|
};
|
|
9138
9219
|
|
|
9139
9220
|
// src/resources/service_call_task_resources.ts
|
|
9140
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
9221
|
+
var ServiceCallTaskResourcesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9141
9222
|
constructor(http, pageSize) {
|
|
9142
9223
|
super(http, {
|
|
9143
9224
|
key: "service_call_task_resources",
|
|
@@ -9194,7 +9275,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
9194
9275
|
};
|
|
9195
9276
|
|
|
9196
9277
|
// src/resources/service_call_tasks.ts
|
|
9197
|
-
var ServiceCallTasksResource = class extends
|
|
9278
|
+
var ServiceCallTasksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9198
9279
|
constructor(http, pageSize) {
|
|
9199
9280
|
super(http, {
|
|
9200
9281
|
key: "service_call_tasks",
|
|
@@ -9251,7 +9332,7 @@ var ServiceCallTasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9251
9332
|
};
|
|
9252
9333
|
|
|
9253
9334
|
// src/resources/service_call_ticket_resources.ts
|
|
9254
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
9335
|
+
var ServiceCallTicketResourcesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9255
9336
|
constructor(http, pageSize) {
|
|
9256
9337
|
super(http, {
|
|
9257
9338
|
key: "service_call_ticket_resources",
|
|
@@ -9308,7 +9389,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseRes
|
|
|
9308
9389
|
};
|
|
9309
9390
|
|
|
9310
9391
|
// src/resources/service_call_tickets.ts
|
|
9311
|
-
var ServiceCallTicketsResource = class extends
|
|
9392
|
+
var ServiceCallTicketsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9312
9393
|
constructor(http, pageSize) {
|
|
9313
9394
|
super(http, {
|
|
9314
9395
|
key: "service_call_tickets",
|
|
@@ -9365,7 +9446,7 @@ var ServiceCallTicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9365
9446
|
};
|
|
9366
9447
|
|
|
9367
9448
|
// src/resources/service_level_agreement_results.ts
|
|
9368
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
9449
|
+
var ServiceLevelAgreementResultsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9369
9450
|
constructor(http, pageSize) {
|
|
9370
9451
|
super(http, {
|
|
9371
9452
|
key: "service_level_agreement_results",
|
|
@@ -9404,7 +9485,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkZJ4ONAQFcjs.BaseR
|
|
|
9404
9485
|
};
|
|
9405
9486
|
|
|
9406
9487
|
// src/resources/services.ts
|
|
9407
|
-
var ServicesResource = class extends
|
|
9488
|
+
var ServicesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9408
9489
|
constructor(http, pageSize) {
|
|
9409
9490
|
super(http, {
|
|
9410
9491
|
key: "services",
|
|
@@ -9467,12 +9548,12 @@ var ServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9467
9548
|
/** Search Service records: bounded contains on name (no vendor free-text search exists);
|
|
9468
9549
|
* limit defaults to 25, max 500. */
|
|
9469
9550
|
async search(query, opts) {
|
|
9470
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9551
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _93 => _93.limit]) });
|
|
9471
9552
|
}
|
|
9472
9553
|
};
|
|
9473
9554
|
|
|
9474
9555
|
// src/resources/skills.ts
|
|
9475
|
-
var SkillsResource = class extends
|
|
9556
|
+
var SkillsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9476
9557
|
constructor(http, pageSize) {
|
|
9477
9558
|
super(http, {
|
|
9478
9559
|
key: "skills",
|
|
@@ -9511,12 +9592,12 @@ var SkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9511
9592
|
/** Search Skill records: bounded contains on name (no vendor free-text search exists);
|
|
9512
9593
|
* limit defaults to 25, max 500. */
|
|
9513
9594
|
async search(query, opts) {
|
|
9514
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9595
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _94 => _94.limit]) });
|
|
9515
9596
|
}
|
|
9516
9597
|
};
|
|
9517
9598
|
|
|
9518
9599
|
// src/resources/subscription_periods.ts
|
|
9519
|
-
var SubscriptionPeriodsResource = class extends
|
|
9600
|
+
var SubscriptionPeriodsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9520
9601
|
constructor(http, pageSize) {
|
|
9521
9602
|
super(http, {
|
|
9522
9603
|
key: "subscription_periods",
|
|
@@ -9555,7 +9636,7 @@ var SubscriptionPeriodsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9555
9636
|
};
|
|
9556
9637
|
|
|
9557
9638
|
// src/resources/subscriptions.ts
|
|
9558
|
-
var SubscriptionsResource = class extends
|
|
9639
|
+
var SubscriptionsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9559
9640
|
constructor(http, pageSize) {
|
|
9560
9641
|
super(http, {
|
|
9561
9642
|
key: "subscriptions",
|
|
@@ -9624,7 +9705,7 @@ var SubscriptionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9624
9705
|
};
|
|
9625
9706
|
|
|
9626
9707
|
// src/resources/survey_results.ts
|
|
9627
|
-
var SurveyResultsResource = class extends
|
|
9708
|
+
var SurveyResultsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9628
9709
|
constructor(http, pageSize) {
|
|
9629
9710
|
super(http, {
|
|
9630
9711
|
key: "survey_results",
|
|
@@ -9663,7 +9744,7 @@ var SurveyResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9663
9744
|
};
|
|
9664
9745
|
|
|
9665
9746
|
// src/resources/surveys.ts
|
|
9666
|
-
var SurveysResource = class extends
|
|
9747
|
+
var SurveysResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9667
9748
|
constructor(http, pageSize) {
|
|
9668
9749
|
super(http, {
|
|
9669
9750
|
key: "surveys",
|
|
@@ -9702,12 +9783,12 @@ var SurveysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9702
9783
|
/** Search Survey records: bounded contains on name (no vendor free-text search exists);
|
|
9703
9784
|
* limit defaults to 25, max 500. */
|
|
9704
9785
|
async search(query, opts) {
|
|
9705
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9786
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
|
|
9706
9787
|
}
|
|
9707
9788
|
};
|
|
9708
9789
|
|
|
9709
9790
|
// src/resources/tag_aliases.ts
|
|
9710
|
-
var TagAliasesResource = class extends
|
|
9791
|
+
var TagAliasesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9711
9792
|
constructor(http, pageSize) {
|
|
9712
9793
|
super(http, {
|
|
9713
9794
|
key: "tag_aliases",
|
|
@@ -9764,7 +9845,7 @@ var TagAliasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9764
9845
|
};
|
|
9765
9846
|
|
|
9766
9847
|
// src/resources/tag_groups.ts
|
|
9767
|
-
var TagGroupsResource = class extends
|
|
9848
|
+
var TagGroupsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9768
9849
|
constructor(http, pageSize) {
|
|
9769
9850
|
super(http, {
|
|
9770
9851
|
key: "tag_groups",
|
|
@@ -9833,7 +9914,7 @@ var TagGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9833
9914
|
};
|
|
9834
9915
|
|
|
9835
9916
|
// src/resources/tags.ts
|
|
9836
|
-
var TagsResource = class extends
|
|
9917
|
+
var TagsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9837
9918
|
constructor(http, pageSize) {
|
|
9838
9919
|
super(http, {
|
|
9839
9920
|
key: "tags",
|
|
@@ -9902,7 +9983,7 @@ var TagsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
9902
9983
|
};
|
|
9903
9984
|
|
|
9904
9985
|
// src/resources/task_secondary_resources.ts
|
|
9905
|
-
var TaskSecondaryResourcesResource = class extends
|
|
9986
|
+
var TaskSecondaryResourcesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9906
9987
|
constructor(http, pageSize) {
|
|
9907
9988
|
super(http, {
|
|
9908
9989
|
key: "task_secondary_resources",
|
|
@@ -9959,7 +10040,7 @@ var TaskSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResourc
|
|
|
9959
10040
|
};
|
|
9960
10041
|
|
|
9961
10042
|
// src/resources/tasks.ts
|
|
9962
|
-
var TasksResource = class extends
|
|
10043
|
+
var TasksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
9963
10044
|
constructor(http, pageSize) {
|
|
9964
10045
|
super(http, {
|
|
9965
10046
|
key: "tasks",
|
|
@@ -10018,12 +10099,12 @@ var TasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
10018
10099
|
/** Search Task records: bounded contains on title (no vendor free-text search exists);
|
|
10019
10100
|
* limit defaults to 25, max 500. */
|
|
10020
10101
|
async search(query, opts) {
|
|
10021
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10102
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
|
|
10022
10103
|
}
|
|
10023
10104
|
};
|
|
10024
10105
|
|
|
10025
10106
|
// src/resources/tax_regions.ts
|
|
10026
|
-
var TaxRegionsResource = class extends
|
|
10107
|
+
var TaxRegionsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10027
10108
|
constructor(http, pageSize) {
|
|
10028
10109
|
super(http, {
|
|
10029
10110
|
key: "tax_regions",
|
|
@@ -10098,7 +10179,7 @@ var ThresholdInformationResource = class {
|
|
|
10098
10179
|
};
|
|
10099
10180
|
|
|
10100
10181
|
// src/resources/ticket_additional_configuration_items.ts
|
|
10101
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
10182
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10102
10183
|
constructor(http, pageSize) {
|
|
10103
10184
|
super(http, {
|
|
10104
10185
|
key: "ticket_additional_configuration_items",
|
|
@@ -10155,7 +10236,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs
|
|
|
10155
10236
|
};
|
|
10156
10237
|
|
|
10157
10238
|
// src/resources/ticket_additional_contacts.ts
|
|
10158
|
-
var TicketAdditionalContactsResource = class extends
|
|
10239
|
+
var TicketAdditionalContactsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10159
10240
|
constructor(http, pageSize) {
|
|
10160
10241
|
super(http, {
|
|
10161
10242
|
key: "ticket_additional_contacts",
|
|
@@ -10212,7 +10293,7 @@ var TicketAdditionalContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
10212
10293
|
};
|
|
10213
10294
|
|
|
10214
10295
|
// src/resources/ticket_attachments.ts
|
|
10215
|
-
var TicketAttachmentsResource = class extends
|
|
10296
|
+
var TicketAttachmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10216
10297
|
constructor(http, pageSize) {
|
|
10217
10298
|
super(http, {
|
|
10218
10299
|
key: "ticket_attachments",
|
|
@@ -10274,7 +10355,7 @@ var TicketAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
10274
10355
|
};
|
|
10275
10356
|
|
|
10276
10357
|
// src/resources/ticket_categories.ts
|
|
10277
|
-
var TicketCategoriesResource = class extends
|
|
10358
|
+
var TicketCategoriesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10278
10359
|
constructor(http, pageSize) {
|
|
10279
10360
|
super(http, {
|
|
10280
10361
|
key: "ticket_categories",
|
|
@@ -10328,12 +10409,12 @@ var TicketCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
10328
10409
|
/** Search TicketCategory records: bounded contains on name (no vendor free-text search exists);
|
|
10329
10410
|
* limit defaults to 25, max 500. */
|
|
10330
10411
|
async search(query, opts) {
|
|
10331
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10412
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _97 => _97.limit]) });
|
|
10332
10413
|
}
|
|
10333
10414
|
};
|
|
10334
10415
|
|
|
10335
10416
|
// src/resources/ticket_category_field_defaults.ts
|
|
10336
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
10417
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10337
10418
|
constructor(http, pageSize) {
|
|
10338
10419
|
super(http, {
|
|
10339
10420
|
key: "ticket_category_field_defaults",
|
|
@@ -10375,7 +10456,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkZJ4ONAQFcjs.BaseRe
|
|
|
10375
10456
|
};
|
|
10376
10457
|
|
|
10377
10458
|
// src/resources/ticket_change_request_approvals.ts
|
|
10378
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
10459
|
+
var TicketChangeRequestApprovalsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10379
10460
|
constructor(http, pageSize) {
|
|
10380
10461
|
super(http, {
|
|
10381
10462
|
key: "ticket_change_request_approvals",
|
|
@@ -10434,12 +10515,11 @@ var TicketChangeRequestApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseR
|
|
|
10434
10515
|
// src/resources/special/_shared/move-engine.ts
|
|
10435
10516
|
var _crypto = require('crypto');
|
|
10436
10517
|
var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
|
|
10437
|
-
var TICKET_COMPLETE_STATUS = 5;
|
|
10438
10518
|
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";
|
|
10439
|
-
var refuse = (code, message, ids2, operation, extra = {}) => new (0,
|
|
10519
|
+
var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunkIKWHRUQ5cjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
|
|
10440
10520
|
async function queryRows(http, resource, filter, operation, retries) {
|
|
10441
10521
|
const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
|
|
10442
|
-
return
|
|
10522
|
+
return _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items;
|
|
10443
10523
|
}
|
|
10444
10524
|
function sameValue(a, b) {
|
|
10445
10525
|
if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
|
|
@@ -10456,10 +10536,10 @@ function sameValue(a, b) {
|
|
|
10456
10536
|
async function readTicket(http, id, retries, operation) {
|
|
10457
10537
|
try {
|
|
10458
10538
|
const res = await http.request({ method: "GET", path: `/V1.0/Tickets/${id}`, operation, maxRetries: retries });
|
|
10459
|
-
const item = _optionalChain([res, 'optionalAccess',
|
|
10539
|
+
const item = _optionalChain([res, 'optionalAccess', _98 => _98.item]);
|
|
10460
10540
|
return _nullishCoalesce(item, () => ( null));
|
|
10461
10541
|
} catch (e) {
|
|
10462
|
-
if (
|
|
10542
|
+
if (_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
10463
10543
|
throw e;
|
|
10464
10544
|
}
|
|
10465
10545
|
}
|
|
@@ -10480,20 +10560,28 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10480
10560
|
}
|
|
10481
10561
|
}
|
|
10482
10562
|
const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
|
|
10483
|
-
if (!Number.isFinite(cap) || cap < 0) throw new (0,
|
|
10563
|
+
if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
|
|
10484
10564
|
const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
|
|
10485
10565
|
if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
|
|
10486
10566
|
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") });
|
|
10487
10567
|
}
|
|
10488
10568
|
const target = await readTicket(http, toTicketId, opts.maxRetries, op);
|
|
10489
10569
|
if (target === null) throw refuse("MOVE_TARGET_MISSING", `${op}: target ticket ${toTicketId} does not exist`, ids2, op);
|
|
10490
|
-
|
|
10491
|
-
|
|
10570
|
+
const closedStatus = await resolveTicketStatusSemantics(http);
|
|
10571
|
+
if (isClosedStatus(target.status, closedStatus.closedIds) || target.completedDate !== void 0 && target.completedDate !== null) {
|
|
10572
|
+
throw refuse(
|
|
10573
|
+
"MOVE_TARGET_CLOSED",
|
|
10574
|
+
`${op}: target ticket ${toTicketId} is closed (status in [${closedStatus.closedIds.join(", ")}] or completed) \u2014 closed ids ${closedStatus.source === "assumed" ? "ASSUMED (the tenant status picklist could not be read)" : "resolved from the tenant Tickets status picklist"}`,
|
|
10575
|
+
ids2,
|
|
10576
|
+
op,
|
|
10577
|
+
{ closedStatusIds: closedStatus.closedIds, closedStatusSource: closedStatus.source }
|
|
10578
|
+
);
|
|
10492
10579
|
}
|
|
10493
10580
|
const origin = await readTicket(http, sourceTicketId, opts.maxRetries, op);
|
|
10494
10581
|
const facts = {
|
|
10582
|
+
closedStatus: { closedIds: closedStatus.closedIds, source: closedStatus.source, note: closedStatus.note },
|
|
10495
10583
|
sourceTicketId,
|
|
10496
|
-
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess',
|
|
10584
|
+
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _99 => _99.companyID]), () => ( null)),
|
|
10497
10585
|
targetCompanyID: _nullishCoalesce(target.companyID, () => ( null)),
|
|
10498
10586
|
companyChanged: origin === null ? null : origin.companyID !== target.companyID,
|
|
10499
10587
|
contractChanged: origin === null ? null : (_nullishCoalesce(origin.contractID, () => ( null))) !== (_nullishCoalesce(target.contractID, () => ( null)))
|
|
@@ -10515,17 +10603,17 @@ async function assertNoTwin(ctx, payload) {
|
|
|
10515
10603
|
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 });
|
|
10516
10604
|
}
|
|
10517
10605
|
}
|
|
10518
|
-
var statusOf = (e) =>
|
|
10606
|
+
var statusOf = (e) => _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
|
|
10519
10607
|
async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
10520
10608
|
const op = spec.operation;
|
|
10521
|
-
const sourceId = Number(
|
|
10522
|
-
const toTicketId = Number(
|
|
10609
|
+
const sourceId = Number(_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
|
|
10610
|
+
const toTicketId = Number(_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
|
|
10523
10611
|
if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
|
|
10524
|
-
throw new (0,
|
|
10612
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
|
|
10525
10613
|
}
|
|
10526
10614
|
const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
|
|
10527
10615
|
if (opts.dryRun === true) {
|
|
10528
|
-
return
|
|
10616
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
10529
10617
|
{
|
|
10530
10618
|
operation: op,
|
|
10531
10619
|
method: "POST",
|
|
@@ -10550,22 +10638,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10550
10638
|
let newId;
|
|
10551
10639
|
try {
|
|
10552
10640
|
const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
|
|
10553
|
-
newId = Number(
|
|
10641
|
+
newId = Number(_chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, created, op).id);
|
|
10554
10642
|
} catch (e) {
|
|
10555
10643
|
const status = statusOf(e);
|
|
10556
10644
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
10557
|
-
throw new (0,
|
|
10645
|
+
throw new (0, _chunkIKWHRUQ5cjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
|
|
10558
10646
|
}
|
|
10559
|
-
throw new (0,
|
|
10647
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 } });
|
|
10560
10648
|
}
|
|
10561
10649
|
const rollback = async (code, message) => {
|
|
10562
10650
|
try {
|
|
10563
10651
|
await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
|
|
10564
10652
|
} catch (re) {
|
|
10565
10653
|
const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
|
|
10566
|
-
throw new (0,
|
|
10654
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 } });
|
|
10567
10655
|
}
|
|
10568
|
-
throw new (0,
|
|
10656
|
+
throw new (0, _chunkIKWHRUQ5cjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
|
|
10569
10657
|
};
|
|
10570
10658
|
const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
|
|
10571
10659
|
if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
|
|
@@ -10594,33 +10682,33 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10594
10682
|
};
|
|
10595
10683
|
}
|
|
10596
10684
|
if (status === void 0) {
|
|
10597
|
-
throw new (0,
|
|
10685
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 } });
|
|
10598
10686
|
}
|
|
10599
10687
|
return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
|
|
10600
10688
|
}
|
|
10601
10689
|
return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
|
|
10602
10690
|
}
|
|
10603
10691
|
function uiLinkFor(http, entity, id) {
|
|
10604
|
-
return _nullishCoalesce(
|
|
10692
|
+
return _nullishCoalesce(_chunkIKWHRUQ5cjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
|
|
10605
10693
|
}
|
|
10606
10694
|
|
|
10607
10695
|
// src/resources/special/ticket_charges.ts
|
|
10608
|
-
var
|
|
10696
|
+
var OP3 = "ticket_charges.moveToTicket";
|
|
10609
10697
|
var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
|
|
10610
10698
|
var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
|
|
10611
10699
|
async function readCharge(http, id, retries) {
|
|
10612
|
-
const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }],
|
|
10700
|
+
const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP3, retries);
|
|
10613
10701
|
return _nullishCoalesce(rows[0], () => ( null));
|
|
10614
10702
|
}
|
|
10615
10703
|
async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
|
|
10616
10704
|
if (source.isBilled === true) {
|
|
10617
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
10705
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP3}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP3, {
|
|
10618
10706
|
manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
|
|
10619
10707
|
});
|
|
10620
10708
|
}
|
|
10621
10709
|
}
|
|
10622
10710
|
var SPEC = {
|
|
10623
|
-
operation:
|
|
10711
|
+
operation: OP3,
|
|
10624
10712
|
entity: "ticket_charge",
|
|
10625
10713
|
readSource: readCharge,
|
|
10626
10714
|
sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
|
|
@@ -10656,7 +10744,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
|
|
|
10656
10744
|
}
|
|
10657
10745
|
|
|
10658
10746
|
// src/resources/ticket_charges.ts
|
|
10659
|
-
var TicketChargesResource = class extends
|
|
10747
|
+
var TicketChargesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10660
10748
|
constructor(http, pageSize) {
|
|
10661
10749
|
super(http, {
|
|
10662
10750
|
key: "ticket_charges",
|
|
@@ -10722,7 +10810,7 @@ var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
10722
10810
|
/** Search TicketCharge records: bounded contains on name (no vendor free-text search exists);
|
|
10723
10811
|
* limit defaults to 25, max 500. */
|
|
10724
10812
|
async search(query, opts) {
|
|
10725
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10813
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _100 => _100.limit]) });
|
|
10726
10814
|
}
|
|
10727
10815
|
/** Node-parity special op (hand-written in src/resources/special/ticket_charges.ts). */
|
|
10728
10816
|
moveToTicket(sourceId, toTicketId, opts = {}) {
|
|
@@ -10731,7 +10819,7 @@ var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
10731
10819
|
};
|
|
10732
10820
|
|
|
10733
10821
|
// src/resources/ticket_checklist_items.ts
|
|
10734
|
-
var TicketChecklistItemsResource = class extends
|
|
10822
|
+
var TicketChecklistItemsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10735
10823
|
constructor(http, pageSize) {
|
|
10736
10824
|
super(http, {
|
|
10737
10825
|
key: "ticket_checklist_items",
|
|
@@ -10797,7 +10885,7 @@ var TicketChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
10797
10885
|
};
|
|
10798
10886
|
|
|
10799
10887
|
// src/resources/ticket_checklist_libraries.ts
|
|
10800
|
-
var TicketChecklistLibrariesResource = class extends
|
|
10888
|
+
var TicketChecklistLibrariesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10801
10889
|
constructor(http, pageSize) {
|
|
10802
10890
|
super(http, {
|
|
10803
10891
|
key: "ticket_checklist_libraries",
|
|
@@ -10821,9 +10909,9 @@ var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
10821
10909
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
10822
10910
|
* surface — no documents read op — and never issues the POST). */
|
|
10823
10911
|
async attachToDocument(documentID, data, opts = {}) {
|
|
10824
|
-
const n =
|
|
10912
|
+
const n = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
10825
10913
|
if (opts.dryRun === true) {
|
|
10826
|
-
return
|
|
10914
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
10827
10915
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10828
10916
|
method: "POST",
|
|
10829
10917
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -10841,7 +10929,7 @@ var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
10841
10929
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10842
10930
|
maxRetries: opts.maxRetries
|
|
10843
10931
|
});
|
|
10844
|
-
return
|
|
10932
|
+
return _chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, res);
|
|
10845
10933
|
}
|
|
10846
10934
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
10847
10935
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10857,7 +10945,7 @@ var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResou
|
|
|
10857
10945
|
};
|
|
10858
10946
|
|
|
10859
10947
|
// src/resources/ticket_history.ts
|
|
10860
|
-
var TicketHistoryResource = class extends
|
|
10948
|
+
var TicketHistoryResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10861
10949
|
constructor(http, pageSize) {
|
|
10862
10950
|
super(http, {
|
|
10863
10951
|
key: "ticket_history",
|
|
@@ -10896,7 +10984,7 @@ var TicketHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
10896
10984
|
};
|
|
10897
10985
|
|
|
10898
10986
|
// src/resources/ticket_note_attachments.ts
|
|
10899
|
-
var TicketNoteAttachmentsResource = class extends
|
|
10987
|
+
var TicketNoteAttachmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10900
10988
|
constructor(http, pageSize) {
|
|
10901
10989
|
super(http, {
|
|
10902
10990
|
key: "ticket_note_attachments",
|
|
@@ -10958,7 +11046,7 @@ var TicketNoteAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
10958
11046
|
};
|
|
10959
11047
|
|
|
10960
11048
|
// src/resources/ticket_notes.ts
|
|
10961
|
-
var TicketNotesResource = class extends
|
|
11049
|
+
var TicketNotesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
10962
11050
|
constructor(http, pageSize) {
|
|
10963
11051
|
super(http, {
|
|
10964
11052
|
key: "ticket_notes",
|
|
@@ -11017,7 +11105,7 @@ var TicketNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
11017
11105
|
};
|
|
11018
11106
|
|
|
11019
11107
|
// src/resources/ticket_note_webhooks.ts
|
|
11020
|
-
var TicketNoteWebhooksResource = class extends
|
|
11108
|
+
var TicketNoteWebhooksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
11021
11109
|
constructor(http, pageSize) {
|
|
11022
11110
|
super(http, {
|
|
11023
11111
|
key: "ticket_note_webhooks",
|
|
@@ -11088,12 +11176,12 @@ var TicketNoteWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
11088
11176
|
/** Search TicketNoteWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
11089
11177
|
* limit defaults to 25, max 500. */
|
|
11090
11178
|
async search(query, opts) {
|
|
11091
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
11179
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _101 => _101.limit]) });
|
|
11092
11180
|
}
|
|
11093
11181
|
};
|
|
11094
11182
|
|
|
11095
11183
|
// src/resources/ticket_secondary_resources.ts
|
|
11096
|
-
var TicketSecondaryResourcesResource = class extends
|
|
11184
|
+
var TicketSecondaryResourcesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
11097
11185
|
constructor(http, pageSize) {
|
|
11098
11186
|
super(http, {
|
|
11099
11187
|
key: "ticket_secondary_resources",
|
|
@@ -11158,9 +11246,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
11158
11246
|
});
|
|
11159
11247
|
const body = res;
|
|
11160
11248
|
if (body === null || !("item" in body)) {
|
|
11161
|
-
throw new (0,
|
|
11249
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
11162
11250
|
}
|
|
11163
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
11251
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
11164
11252
|
return body.item;
|
|
11165
11253
|
}
|
|
11166
11254
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -11171,7 +11259,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
11171
11259
|
body: { MaxRecords: maxRecords, filter },
|
|
11172
11260
|
operation
|
|
11173
11261
|
});
|
|
11174
|
-
return
|
|
11262
|
+
return _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res).items;
|
|
11175
11263
|
}
|
|
11176
11264
|
function truncate(text, limit) {
|
|
11177
11265
|
const full = _nullishCoalesce(text, () => ( ""));
|
|
@@ -11181,26 +11269,26 @@ function truncate(text, limit) {
|
|
|
11181
11269
|
|
|
11182
11270
|
// src/resources/special/tickets/childRead.ts
|
|
11183
11271
|
function isRouteUnavailable(err) {
|
|
11184
|
-
return
|
|
11272
|
+
return _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
11185
11273
|
}
|
|
11186
11274
|
function routeFact(route, path, err) {
|
|
11187
11275
|
return {
|
|
11188
11276
|
route,
|
|
11189
11277
|
path,
|
|
11190
|
-
httpStatus:
|
|
11278
|
+
httpStatus: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
11191
11279
|
};
|
|
11192
11280
|
}
|
|
11193
11281
|
function childDeclaresQuery(resourceKey) {
|
|
11194
|
-
return
|
|
11282
|
+
return _chunkPY45RBQ2cjs.CAPABILITIES.some(
|
|
11195
11283
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
11196
11284
|
);
|
|
11197
11285
|
}
|
|
11198
11286
|
function planScopedPath(resourceKey, ticketId) {
|
|
11199
11287
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
11200
|
-
const entry =
|
|
11288
|
+
const entry = _chunkIKWHRUQ5cjs.RELATIONSHIP_MAP[resourceKey];
|
|
11201
11289
|
const parent = entry === void 0 ? null : entry.parent;
|
|
11202
11290
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
11203
|
-
const parentPath = _optionalChain([
|
|
11291
|
+
const parentPath = _optionalChain([_chunkIKWHRUQ5cjs.RELATIONSHIP_MAP, 'access', _102 => _102[parent.resource], 'optionalAccess', _103 => _103.path]);
|
|
11204
11292
|
if (parentPath === null || parentPath === void 0) return null;
|
|
11205
11293
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
11206
11294
|
}
|
|
@@ -11239,14 +11327,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
11239
11327
|
break;
|
|
11240
11328
|
}
|
|
11241
11329
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
11242
|
-
const { items: pageItems, pageDetails } =
|
|
11330
|
+
const { items: pageItems, pageDetails } = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, body, operation);
|
|
11243
11331
|
nextCursor = pageDetails.nextPageUrl;
|
|
11244
11332
|
pages += 1;
|
|
11245
11333
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
11246
11334
|
for (const row of window) if (accept(row)) items.push(row);
|
|
11247
11335
|
if (items.length >= limit) break;
|
|
11248
11336
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
11249
|
-
target =
|
|
11337
|
+
target = _chunkIKWHRUQ5cjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
11250
11338
|
}
|
|
11251
11339
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
11252
11340
|
return { items, capped };
|
|
@@ -11279,7 +11367,7 @@ var MS = 864e5;
|
|
|
11279
11367
|
var SLA_PAGE = 100;
|
|
11280
11368
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
11281
11369
|
void opts;
|
|
11282
|
-
const ticketId =
|
|
11370
|
+
const ticketId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
11283
11371
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
11284
11372
|
const rows = await ticketQueryItems(
|
|
11285
11373
|
http,
|
|
@@ -11304,9 +11392,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
11304
11392
|
async function summary(_resource, id, opts = {}, http) {
|
|
11305
11393
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
11306
11394
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
11307
|
-
throw new (0,
|
|
11395
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
11308
11396
|
}
|
|
11309
|
-
const ticketId =
|
|
11397
|
+
const ticketId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
11310
11398
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
11311
11399
|
const desc = truncate(ticket.description, limit);
|
|
11312
11400
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -11335,11 +11423,11 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
11335
11423
|
// src/resources/special/tickets/timeline.ts
|
|
11336
11424
|
function validateTimelineLimits(opts) {
|
|
11337
11425
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
11338
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
11426
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
11339
11427
|
const bounded = Math.min(limit, 500);
|
|
11340
11428
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
11341
11429
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
11342
|
-
throw new (0,
|
|
11430
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
11343
11431
|
}
|
|
11344
11432
|
return { bounded, textLimit };
|
|
11345
11433
|
}
|
|
@@ -11391,7 +11479,7 @@ function compareEventDates(a, b) {
|
|
|
11391
11479
|
}
|
|
11392
11480
|
async function timeline(_resource, id, opts = {}, http) {
|
|
11393
11481
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
11394
|
-
const ticketId =
|
|
11482
|
+
const ticketId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
11395
11483
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
11396
11484
|
const dateFilters = (field) => {
|
|
11397
11485
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11431,7 +11519,7 @@ async function timeline(_resource, id, opts = {}, http) {
|
|
|
11431
11519
|
}
|
|
11432
11520
|
|
|
11433
11521
|
// src/resources/special/tickets/errors.ts
|
|
11434
|
-
var QueueRequiredError = class extends
|
|
11522
|
+
var QueueRequiredError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
11435
11523
|
constructor(message, options = {}) {
|
|
11436
11524
|
super(message, {
|
|
11437
11525
|
code: "QUEUE_REQUIRED",
|
|
@@ -11442,13 +11530,13 @@ var QueueRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
|
11442
11530
|
this.name = "QueueRequiredError";
|
|
11443
11531
|
}
|
|
11444
11532
|
};
|
|
11445
|
-
var TicketResourceInvalidError = class extends
|
|
11533
|
+
var TicketResourceInvalidError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
11446
11534
|
constructor(message, options = {}) {
|
|
11447
11535
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11448
11536
|
this.name = "TicketResourceInvalidError";
|
|
11449
11537
|
}
|
|
11450
11538
|
};
|
|
11451
|
-
var TicketCreateValidationFailedError = class extends
|
|
11539
|
+
var TicketCreateValidationFailedError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
11452
11540
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
11453
11541
|
|
|
11454
11542
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -11457,7 +11545,7 @@ var TicketCreateValidationFailedError = class extends _chunkZJ4ONAQFcjs.Autotask
|
|
|
11457
11545
|
this.vendorFields = vendorFields;
|
|
11458
11546
|
}
|
|
11459
11547
|
};
|
|
11460
|
-
var StatusUnknownError = class extends
|
|
11548
|
+
var StatusUnknownError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
11461
11549
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
11462
11550
|
|
|
11463
11551
|
constructor(message, options = {}) {
|
|
@@ -11471,7 +11559,7 @@ var StatusUnknownError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
|
11471
11559
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
11472
11560
|
}
|
|
11473
11561
|
};
|
|
11474
|
-
var StatusFieldsRequiredError = class extends
|
|
11562
|
+
var StatusFieldsRequiredError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
11475
11563
|
|
|
11476
11564
|
|
|
11477
11565
|
|
|
@@ -11494,21 +11582,21 @@ function isPositiveInt(v) {
|
|
|
11494
11582
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
11495
11583
|
}
|
|
11496
11584
|
function namedVendorFields(err) {
|
|
11497
|
-
if (!
|
|
11498
|
-
const entries = _nullishCoalesce(
|
|
11585
|
+
if (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
11586
|
+
const entries = _nullishCoalesce(_chunkIKWHRUQ5cjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
11499
11587
|
const out = /* @__PURE__ */ new Set();
|
|
11500
11588
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
11501
11589
|
return [...out];
|
|
11502
11590
|
}
|
|
11503
11591
|
function vendorDetailOf(err) {
|
|
11504
|
-
return
|
|
11592
|
+
return _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? _chunkIKWHRUQ5cjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
11505
11593
|
}
|
|
11506
11594
|
async function fetchItem(http, path, operation, readOpts) {
|
|
11507
|
-
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11595
|
+
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _104 => _104.maxRetries]) });
|
|
11508
11596
|
return unwrapItemOrNull(res);
|
|
11509
11597
|
}
|
|
11510
11598
|
async function fetchItemUnredacted(http, path, operation, readOpts) {
|
|
11511
|
-
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11599
|
+
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _105 => _105.maxRetries]) });
|
|
11512
11600
|
return unwrapItemOrNull(res);
|
|
11513
11601
|
}
|
|
11514
11602
|
function unwrapItemOrNull(res) {
|
|
@@ -11522,8 +11610,8 @@ function operationId(res) {
|
|
|
11522
11610
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
11523
11611
|
}
|
|
11524
11612
|
function discoveryMerge(err, body, defaults) {
|
|
11525
|
-
if (!
|
|
11526
|
-
const entries =
|
|
11613
|
+
if (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11614
|
+
const entries = _chunkIKWHRUQ5cjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11527
11615
|
if (entries === void 0) return null;
|
|
11528
11616
|
for (const entry of entries) {
|
|
11529
11617
|
const field = entry.field;
|
|
@@ -11535,7 +11623,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
11535
11623
|
}
|
|
11536
11624
|
function stepErrorText(code, err) {
|
|
11537
11625
|
const detail = vendorDetailOf(err);
|
|
11538
|
-
const base =
|
|
11626
|
+
const base = _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
11539
11627
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
11540
11628
|
}
|
|
11541
11629
|
|
|
@@ -11547,43 +11635,43 @@ var DEFAULT_PUBLISH = 1;
|
|
|
11547
11635
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
11548
11636
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
11549
11637
|
function validateOpenInput(params, note, assign) {
|
|
11550
|
-
const companyID =
|
|
11551
|
-
const title = _optionalChain([params, 'optionalAccess',
|
|
11638
|
+
const companyID = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _106 => _106.companyID]), "params.companyID");
|
|
11639
|
+
const title = _optionalChain([params, 'optionalAccess', _107 => _107.title]);
|
|
11552
11640
|
if (typeof title !== "string" || title.trim() === "") {
|
|
11553
|
-
throw new (0,
|
|
11641
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
11554
11642
|
}
|
|
11555
11643
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
11556
11644
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
11557
11645
|
if (!isPositiveInt(priority)) {
|
|
11558
|
-
throw new (0,
|
|
11646
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
11559
11647
|
}
|
|
11560
11648
|
if (!isPositiveInt(status)) {
|
|
11561
|
-
throw new (0,
|
|
11649
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
11562
11650
|
}
|
|
11563
11651
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
11564
|
-
throw new (0,
|
|
11652
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
11565
11653
|
}
|
|
11566
11654
|
if (note !== void 0) {
|
|
11567
11655
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
11568
|
-
throw new (0,
|
|
11656
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
11569
11657
|
}
|
|
11570
11658
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
11571
|
-
throw new (0,
|
|
11659
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 });
|
|
11572
11660
|
}
|
|
11573
11661
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
11574
|
-
throw new (0,
|
|
11662
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
11575
11663
|
}
|
|
11576
11664
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
11577
|
-
throw new (0,
|
|
11665
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
11578
11666
|
}
|
|
11579
11667
|
}
|
|
11580
|
-
const assignee = assign === void 0 ? void 0 :
|
|
11668
|
+
const assignee = assign === void 0 ? void 0 : _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
11581
11669
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
11582
|
-
throw new (0,
|
|
11670
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
11583
11671
|
}
|
|
11584
|
-
const roleID = _optionalChain([assign, 'optionalAccess',
|
|
11672
|
+
const roleID = _optionalChain([assign, 'optionalAccess', _108 => _108.roleID]);
|
|
11585
11673
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
11586
|
-
throw new (0,
|
|
11674
|
+
throw new (0, _chunkIKWHRUQ5cjs.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 });
|
|
11587
11675
|
}
|
|
11588
11676
|
return { companyID, title, priority, status, assignee, roleID };
|
|
11589
11677
|
}
|
|
@@ -11612,7 +11700,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
|
|
|
11612
11700
|
if (assign !== void 0) {
|
|
11613
11701
|
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).`);
|
|
11614
11702
|
}
|
|
11615
|
-
return
|
|
11703
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
11616
11704
|
{
|
|
11617
11705
|
operation: OP_OPEN,
|
|
11618
11706
|
method: "POST",
|
|
@@ -11652,8 +11740,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11652
11740
|
`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}` : ""}`,
|
|
11653
11741
|
{
|
|
11654
11742
|
operation: OP_OPEN,
|
|
11655
|
-
httpStatus:
|
|
11656
|
-
vendorError:
|
|
11743
|
+
httpStatus: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11744
|
+
vendorError: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
11657
11745
|
}
|
|
11658
11746
|
);
|
|
11659
11747
|
}
|
|
@@ -11668,8 +11756,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11668
11756
|
named,
|
|
11669
11757
|
{
|
|
11670
11758
|
operation: OP_OPEN,
|
|
11671
|
-
httpStatus:
|
|
11672
|
-
vendorError:
|
|
11759
|
+
httpStatus: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11760
|
+
vendorError: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11673
11761
|
resourceIds: [companyID],
|
|
11674
11762
|
details: { idRefs: [{ entity: "company", id: companyID }] }
|
|
11675
11763
|
}
|
|
@@ -11694,10 +11782,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
|
|
|
11694
11782
|
try {
|
|
11695
11783
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
11696
11784
|
if (current === null) {
|
|
11697
|
-
throw new (0,
|
|
11785
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11698
11786
|
}
|
|
11699
11787
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
11700
|
-
const merged =
|
|
11788
|
+
const merged = _chunkIKWHRUQ5cjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
11701
11789
|
merged.id = ticketId;
|
|
11702
11790
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
11703
11791
|
assigned = true;
|
|
@@ -11761,17 +11849,17 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11761
11849
|
const ids2 = await readLiveStatusSet(resource);
|
|
11762
11850
|
if (ids2.size > 0) liveStatus = ids2;
|
|
11763
11851
|
} catch (err) {
|
|
11764
|
-
if (!
|
|
11852
|
+
if (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11765
11853
|
}
|
|
11766
11854
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
11767
|
-
_optionalChain([http, 'access',
|
|
11855
|
+
_optionalChain([http, 'access', _109 => _109.fieldCache, 'optionalAccess', _110 => _110.invalidate, 'call', _111 => _111("tickets")]);
|
|
11768
11856
|
let freshStatus = null;
|
|
11769
11857
|
let reReadFailed = false;
|
|
11770
11858
|
try {
|
|
11771
11859
|
const freshIds = await readLiveStatusSet(resource);
|
|
11772
11860
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
11773
11861
|
} catch (err) {
|
|
11774
|
-
if (!
|
|
11862
|
+
if (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11775
11863
|
freshStatus = null;
|
|
11776
11864
|
reReadFailed = true;
|
|
11777
11865
|
}
|
|
@@ -11789,7 +11877,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11789
11877
|
return { guardDegraded: liveStatus === null };
|
|
11790
11878
|
}
|
|
11791
11879
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
11792
|
-
return
|
|
11880
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
11793
11881
|
{
|
|
11794
11882
|
operation: OP_STATUS,
|
|
11795
11883
|
method: "PUT",
|
|
@@ -11820,7 +11908,7 @@ function resolveMergeData(ticketId, targetStatus, previousStatus, current, field
|
|
|
11820
11908
|
for (const field of mapEntry.requiredFields) {
|
|
11821
11909
|
if (mergeData[field] !== void 0) continue;
|
|
11822
11910
|
if (current[field] !== null && current[field] !== void 0) continue;
|
|
11823
|
-
const safe = _optionalChain([mapEntry, 'access',
|
|
11911
|
+
const safe = _optionalChain([mapEntry, 'access', _112 => _112.safeDefaults, 'optionalAccess', _113 => _113[field]]);
|
|
11824
11912
|
if (safe === void 0) {
|
|
11825
11913
|
throw new StatusFieldsRequiredError(
|
|
11826
11914
|
`changeStatus: status ${targetStatus} requires the field '${field}' and the live-discovered map has no proven-safe default for it \u2014 the op is safe-without-the-map (never a blind full update): supply the value in fields and retry`,
|
|
@@ -11843,7 +11931,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11843
11931
|
if (mapEntry === void 0) {
|
|
11844
11932
|
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).`);
|
|
11845
11933
|
}
|
|
11846
|
-
return
|
|
11934
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
11847
11935
|
{
|
|
11848
11936
|
operation: OP_STATUS,
|
|
11849
11937
|
method: "PUT",
|
|
@@ -11862,8 +11950,8 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11862
11950
|
);
|
|
11863
11951
|
}
|
|
11864
11952
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
11865
|
-
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess',
|
|
11866
|
-
const body =
|
|
11953
|
+
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _114 => _114.safeDefaults]), () => ( {}));
|
|
11954
|
+
const body = _chunkIKWHRUQ5cjs.mergePartialBody.call(void 0, current, mergeData);
|
|
11867
11955
|
body.id = ticketId;
|
|
11868
11956
|
let merges = 0;
|
|
11869
11957
|
for (; ; ) {
|
|
@@ -11887,8 +11975,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11887
11975
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
11888
11976
|
{
|
|
11889
11977
|
operation: OP_STATUS,
|
|
11890
|
-
httpStatus:
|
|
11891
|
-
vendorError:
|
|
11978
|
+
httpStatus: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11979
|
+
vendorError: _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11892
11980
|
resourceIds: [ticketId],
|
|
11893
11981
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
11894
11982
|
}
|
|
@@ -11901,7 +11989,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11901
11989
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
11902
11990
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11903
11991
|
if (verify === null) {
|
|
11904
|
-
throw new (0,
|
|
11992
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
11905
11993
|
code: "INVALID_RESPONSE",
|
|
11906
11994
|
category: "server",
|
|
11907
11995
|
operation: OP_STATUS,
|
|
@@ -11911,7 +11999,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11911
11999
|
}
|
|
11912
12000
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
11913
12001
|
if (finalStatus !== targetStatus) {
|
|
11914
|
-
throw new (0,
|
|
12002
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskError)(
|
|
11915
12003
|
`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)`,
|
|
11916
12004
|
{
|
|
11917
12005
|
code: "INVALID_RESPONSE",
|
|
@@ -11926,17 +12014,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11926
12014
|
}
|
|
11927
12015
|
}
|
|
11928
12016
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
11929
|
-
const ticketId =
|
|
12017
|
+
const ticketId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
11930
12018
|
if (!isPositiveInt(targetStatus)) {
|
|
11931
|
-
throw new (0,
|
|
12019
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
11932
12020
|
}
|
|
11933
12021
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
11934
12022
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
11935
|
-
throw new (0,
|
|
12023
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
11936
12024
|
}
|
|
11937
12025
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11938
12026
|
if (current === null) {
|
|
11939
|
-
throw new (0,
|
|
12027
|
+
throw new (0, _chunkIKWHRUQ5cjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11940
12028
|
}
|
|
11941
12029
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
11942
12030
|
if (previousStatus === targetStatus) {
|
|
@@ -11956,7 +12044,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
11956
12044
|
function partLimit(value, name) {
|
|
11957
12045
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
11958
12046
|
if (!Number.isInteger(n) || n < 1) {
|
|
11959
|
-
throw new (0,
|
|
12047
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
11960
12048
|
}
|
|
11961
12049
|
return n;
|
|
11962
12050
|
}
|
|
@@ -11969,42 +12057,49 @@ function servedTextRecord(row, textField, limit) {
|
|
|
11969
12057
|
return out;
|
|
11970
12058
|
}
|
|
11971
12059
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
11972
|
-
const builder =
|
|
12060
|
+
const builder = _chunkIKWHRUQ5cjs.createNamePlan.call(void 0, _chunkIKWHRUQ5cjs.TICKET_LABEL_FIELDS);
|
|
11973
12061
|
const t = ctx.ticket;
|
|
11974
12062
|
builder.addResource(t["creatorResourceID"]);
|
|
11975
12063
|
builder.addFk("contract", t["contractID"]);
|
|
11976
12064
|
builder.addFk("billingCode", t["billingCodeID"]);
|
|
11977
12065
|
builder.addFk("role", t["assignedResourceRoleID"]);
|
|
12066
|
+
builder.addLineOfBusiness(t["organizationalLevelAssociationID"]);
|
|
11978
12067
|
for (const e of entriesPart.items) {
|
|
11979
12068
|
builder.addResource(e["resourceID"]);
|
|
11980
12069
|
builder.addFk("role", e["roleID"]);
|
|
11981
12070
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
11982
12071
|
builder.addFk("contract", e["contractID"]);
|
|
11983
12072
|
}
|
|
11984
|
-
const names = await
|
|
12073
|
+
const names = await _chunkIKWHRUQ5cjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
11985
12074
|
const ticketRow = { ...ctx.ticket };
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
for (const f of
|
|
12075
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
12076
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
12077
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
12078
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
12079
|
+
for (const f of _chunkIKWHRUQ5cjs.TICKET_LABEL_FIELDS) _chunkIKWHRUQ5cjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
11991
12080
|
result.ticket = ticketRow;
|
|
11992
12081
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
11993
12082
|
const row = { ...e };
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
12083
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
12084
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
12085
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
12086
|
+
_chunkIKWHRUQ5cjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
11998
12087
|
return row;
|
|
11999
12088
|
});
|
|
12000
12089
|
result.names = names.section;
|
|
12090
|
+
result.lineOfBusiness = _nullishCoalesce(names.lineOfBusiness, () => ( {
|
|
12091
|
+
association: null,
|
|
12092
|
+
organizationalLevel2: null,
|
|
12093
|
+
organizationalLevel1: null,
|
|
12094
|
+
markers: { association: "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
12095
|
+
}));
|
|
12001
12096
|
result.truncated = result.truncated || names.section.truncated;
|
|
12002
12097
|
}
|
|
12003
12098
|
async function fullContext(resource, id, opts = {}, http) {
|
|
12004
12099
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
12005
12100
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
12006
12101
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
12007
|
-
const ticketId =
|
|
12102
|
+
const ticketId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
12008
12103
|
const ctx = await resource.getContext(ticketId);
|
|
12009
12104
|
const op = "tickets.fullContext";
|
|
12010
12105
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -12061,8 +12156,155 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
12061
12156
|
return result;
|
|
12062
12157
|
}
|
|
12063
12158
|
|
|
12159
|
+
// src/resources/special/tickets/forResource.ts
|
|
12160
|
+
var OP4 = "tickets.forResource";
|
|
12161
|
+
var TICKET_CHUNK = 100;
|
|
12162
|
+
var LIMIT_DEFAULT = 100;
|
|
12163
|
+
var LIMIT_MAX = 500;
|
|
12164
|
+
var LINK_READ_CAP = 500;
|
|
12165
|
+
var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
12166
|
+
function positiveId(value, name) {
|
|
12167
|
+
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12168
|
+
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12169
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP4}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP4 });
|
|
12170
|
+
}
|
|
12171
|
+
return n;
|
|
12172
|
+
}
|
|
12173
|
+
async function ticketPage(http, filter, maxRecords, fields) {
|
|
12174
|
+
const res = await http.request({
|
|
12175
|
+
method: "POST",
|
|
12176
|
+
idempotent: true,
|
|
12177
|
+
path: "/V1.0/Tickets/query",
|
|
12178
|
+
body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
|
|
12179
|
+
operation: OP4
|
|
12180
|
+
});
|
|
12181
|
+
const page = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, OP4);
|
|
12182
|
+
return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
|
|
12183
|
+
}
|
|
12184
|
+
async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
12185
|
+
if (opts === null || typeof opts !== "object") throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP4}: opts must be an object`, { operation: OP4 });
|
|
12186
|
+
const resourceID = positiveId(resourceIDIn, "resourceID");
|
|
12187
|
+
const scope = _nullishCoalesce(opts.scope, () => ( "both"));
|
|
12188
|
+
if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
|
|
12189
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP4}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP4 });
|
|
12190
|
+
}
|
|
12191
|
+
if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
|
|
12192
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP4}: openOnly must be a boolean`, { operation: OP4 });
|
|
12193
|
+
}
|
|
12194
|
+
const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
|
|
12195
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX) {
|
|
12196
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP4}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP4 });
|
|
12197
|
+
}
|
|
12198
|
+
const includeFields = _nullishCoalesce(opts.includeFields, () => ( []));
|
|
12199
|
+
if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
|
|
12200
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP4}: includeFields must be a list of field names`, { operation: OP4 });
|
|
12201
|
+
}
|
|
12202
|
+
const openOnly = opts.openOnly === true;
|
|
12203
|
+
const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS2, ...includeFields])];
|
|
12204
|
+
const closed = await resolveTicketStatusSemantics(http, opts.excludeStatusIds === void 0 ? {} : { excludeStatusIds: opts.excludeStatusIds });
|
|
12205
|
+
const closedStatus = { closedIds: closed.closedIds, source: closed.source, note: closed.note };
|
|
12206
|
+
const openLeaf = openOnly ? [openStatusFilter(closed.closedIds)] : [];
|
|
12207
|
+
const linkIds = [];
|
|
12208
|
+
let capped = false;
|
|
12209
|
+
if (scope !== "primary") {
|
|
12210
|
+
const res = await http.request({
|
|
12211
|
+
method: "POST",
|
|
12212
|
+
idempotent: true,
|
|
12213
|
+
path: "/V1.0/TicketSecondaryResources/query",
|
|
12214
|
+
body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
|
|
12215
|
+
operation: OP4
|
|
12216
|
+
});
|
|
12217
|
+
const page = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, OP4);
|
|
12218
|
+
for (const row of page.items) if (typeof row.ticketID === "number" && !linkIds.includes(row.ticketID)) linkIds.push(row.ticketID);
|
|
12219
|
+
if (page.items.length >= LINK_READ_CAP || page.pageDetails.nextPageUrl !== null) capped = true;
|
|
12220
|
+
}
|
|
12221
|
+
const primary = /* @__PURE__ */ new Map();
|
|
12222
|
+
if (scope !== "secondary") {
|
|
12223
|
+
const page = await ticketPage(http, [{ field: "assignedResourceID", op: "eq", value: resourceID }, ...openLeaf], limit, fields);
|
|
12224
|
+
if (page.more || page.rows.length >= limit) capped = true;
|
|
12225
|
+
for (const t of page.rows) if (typeof t.id === "number") primary.set(t.id, t);
|
|
12226
|
+
}
|
|
12227
|
+
const secondary = /* @__PURE__ */ new Map();
|
|
12228
|
+
const unresolvedIds = [];
|
|
12229
|
+
for (let c = 0; c < linkIds.length; c += TICKET_CHUNK) {
|
|
12230
|
+
const chunk = linkIds.slice(c, c + TICKET_CHUNK);
|
|
12231
|
+
const page = await ticketPage(http, [{ field: "id", op: "in", value: chunk }, ...openLeaf], chunk.length, fields);
|
|
12232
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12233
|
+
for (const t of page.rows) {
|
|
12234
|
+
if (typeof t.id !== "number") continue;
|
|
12235
|
+
secondary.set(t.id, t);
|
|
12236
|
+
seen.add(t.id);
|
|
12237
|
+
}
|
|
12238
|
+
for (const id of chunk) if (!seen.has(id)) unresolvedIds.push(id);
|
|
12239
|
+
}
|
|
12240
|
+
const merged = /* @__PURE__ */ new Map();
|
|
12241
|
+
for (const [id, t] of primary) merged.set(id, t);
|
|
12242
|
+
for (const [id, t] of secondary) if (!merged.has(id)) merged.set(id, t);
|
|
12243
|
+
let tickets = [...merged.values()];
|
|
12244
|
+
if (openOnly) tickets = tickets.filter((t) => !isClosedStatus(t.status, closed.closedIds));
|
|
12245
|
+
tickets.sort((a, b) => Number(a.id) - Number(b.id));
|
|
12246
|
+
if (tickets.length > limit) {
|
|
12247
|
+
tickets = tickets.slice(0, limit);
|
|
12248
|
+
capped = true;
|
|
12249
|
+
}
|
|
12250
|
+
const openCount = tickets.filter((t) => !isClosedStatus(t.status, closed.closedIds)).length;
|
|
12251
|
+
const primaryIds = [...primary.keys()].sort((a, b) => a - b);
|
|
12252
|
+
const secondaryIds = [...secondary.keys()].sort((a, b) => a - b);
|
|
12253
|
+
const both = primaryIds.filter((id) => secondary.has(id));
|
|
12254
|
+
return {
|
|
12255
|
+
resourceID,
|
|
12256
|
+
scope,
|
|
12257
|
+
openOnly,
|
|
12258
|
+
tickets,
|
|
12259
|
+
primaryIds,
|
|
12260
|
+
secondaryIds,
|
|
12261
|
+
bothIds: both,
|
|
12262
|
+
counts: { primary: primaryIds.length, secondary: secondaryIds.length, both: both.length, open: openCount },
|
|
12263
|
+
capped,
|
|
12264
|
+
unresolvedIds: unresolvedIds.sort((a, b) => a - b),
|
|
12265
|
+
closedStatus
|
|
12266
|
+
};
|
|
12267
|
+
}
|
|
12268
|
+
|
|
12269
|
+
// src/resources/special/tickets/lineOfBusiness.ts
|
|
12270
|
+
var OP5 = "tickets.lineOfBusiness";
|
|
12271
|
+
function positiveId2(value, name) {
|
|
12272
|
+
const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
|
|
12273
|
+
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12274
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(OP5 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP5 });
|
|
12275
|
+
}
|
|
12276
|
+
return n;
|
|
12277
|
+
}
|
|
12278
|
+
async function lineOfBusiness(resource, ticketIdIn, http, associationIdIn) {
|
|
12279
|
+
const ticketId = positiveId2(ticketIdIn, "ticketId");
|
|
12280
|
+
let associationId;
|
|
12281
|
+
if (associationIdIn !== void 0) {
|
|
12282
|
+
associationId = positiveId2(associationIdIn, "associationId");
|
|
12283
|
+
} else {
|
|
12284
|
+
const ticket = await resource.get(ticketId);
|
|
12285
|
+
associationId = _chunkIKWHRUQ5cjs.vendorId.call(void 0, ticket.organizationalLevelAssociationID);
|
|
12286
|
+
}
|
|
12287
|
+
if (associationId === void 0) {
|
|
12288
|
+
return {
|
|
12289
|
+
ticketId,
|
|
12290
|
+
association: null,
|
|
12291
|
+
organizationalLevel2: null,
|
|
12292
|
+
organizationalLevel1: null,
|
|
12293
|
+
markers: { association: "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
12294
|
+
};
|
|
12295
|
+
}
|
|
12296
|
+
const chain = await _chunkIKWHRUQ5cjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP5, onError: "propagate" });
|
|
12297
|
+
const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
|
|
12298
|
+
return { ticketId, association, organizationalLevel2, organizationalLevel1, markers };
|
|
12299
|
+
}
|
|
12300
|
+
|
|
12301
|
+
// src/resources/special/tickets/statusSemantics.ts
|
|
12302
|
+
async function statusSemantics(_resource, opts = {}, http) {
|
|
12303
|
+
return resolveTicketStatusSemantics(http, opts);
|
|
12304
|
+
}
|
|
12305
|
+
|
|
12064
12306
|
// src/resources/tickets.ts
|
|
12065
|
-
var TicketsResource = class extends
|
|
12307
|
+
var TicketsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
12066
12308
|
constructor(http, pageSize) {
|
|
12067
12309
|
super(http, {
|
|
12068
12310
|
key: "tickets",
|
|
@@ -12166,10 +12408,22 @@ var TicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
12166
12408
|
fullContext(id, opts) {
|
|
12167
12409
|
return fullContext(this, id, opts, this.http);
|
|
12168
12410
|
}
|
|
12411
|
+
/** Node-parity special op (hand-written in src/resources/special/tickets.ts). */
|
|
12412
|
+
statusSemantics(opts) {
|
|
12413
|
+
return statusSemantics(this, opts, this.http);
|
|
12414
|
+
}
|
|
12415
|
+
/** Node-parity special op (hand-written in src/resources/special/tickets.ts). */
|
|
12416
|
+
forResource(resourceID, opts) {
|
|
12417
|
+
return forResource(this, resourceID, this.http, opts);
|
|
12418
|
+
}
|
|
12419
|
+
/** Node-parity special op (hand-written in src/resources/special/tickets.ts). */
|
|
12420
|
+
lineOfBusiness(ticketId, associationId) {
|
|
12421
|
+
return lineOfBusiness(this, ticketId, this.http, associationId);
|
|
12422
|
+
}
|
|
12169
12423
|
};
|
|
12170
12424
|
|
|
12171
12425
|
// src/resources/ticket_webhooks.ts
|
|
12172
|
-
var TicketWebhooksResource = class extends
|
|
12426
|
+
var TicketWebhooksResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
12173
12427
|
constructor(http, pageSize) {
|
|
12174
12428
|
super(http, {
|
|
12175
12429
|
key: "ticket_webhooks",
|
|
@@ -12240,7 +12494,7 @@ var TicketWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
12240
12494
|
/** Search TicketWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
12241
12495
|
* limit defaults to 25, max 500. */
|
|
12242
12496
|
async search(query, opts) {
|
|
12243
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
12497
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _115 => _115.limit]) });
|
|
12244
12498
|
}
|
|
12245
12499
|
};
|
|
12246
12500
|
|
|
@@ -12255,62 +12509,62 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
12255
12509
|
body: { MaxRecords: limit, filter },
|
|
12256
12510
|
operation
|
|
12257
12511
|
});
|
|
12258
|
-
const { items, pageDetails } =
|
|
12512
|
+
const { items, pageDetails } = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res);
|
|
12259
12513
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
12260
12514
|
}
|
|
12261
12515
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
12262
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
12263
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
12516
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _116 => _116.now]), () => ( /* @__PURE__ */ new Date()));
|
|
12517
|
+
const tz = _optionalChain([opts, 'optionalAccess', _117 => _117.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
|
|
12264
12518
|
const { from, to } = dateOnlyWindowBounds(kind, now, tz);
|
|
12265
12519
|
const filter = [
|
|
12266
12520
|
{ field: "dateWorked", op: "gte", value: from },
|
|
12267
12521
|
{ field: "dateWorked", op: "lte", value: to }
|
|
12268
12522
|
];
|
|
12269
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12523
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _118 => _118.limit])), `time_entries.${kind}`, http);
|
|
12270
12524
|
return items;
|
|
12271
12525
|
}
|
|
12272
12526
|
async function customRange3(_resource, from, to, http, opts) {
|
|
12273
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12527
|
+
if (_optionalChain([opts, 'optionalAccess', _119 => _119.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
|
|
12274
12528
|
const fromB = customRangeDay(from, "from", void 0, "customRange");
|
|
12275
12529
|
const toB = customRangeDay(to, "to", void 0, "customRange");
|
|
12276
12530
|
if (fromB.ms > toB.ms) {
|
|
12277
|
-
throw new (0,
|
|
12531
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
12278
12532
|
}
|
|
12279
12533
|
const toEndMs = toB.ms + DAY_MS2 - 1;
|
|
12280
12534
|
const filter = [
|
|
12281
12535
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
12282
12536
|
{ field: "dateWorked", op: "lte", value: iso2(toEndMs) }
|
|
12283
12537
|
];
|
|
12284
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12538
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _120 => _120.limit])), "time_entries.customRange", http);
|
|
12285
12539
|
return items;
|
|
12286
12540
|
}
|
|
12287
12541
|
async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
12288
12542
|
const filter = [
|
|
12289
12543
|
{ field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
|
|
12290
12544
|
];
|
|
12291
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12545
|
+
if (_optionalChain([opts, 'optionalAccess', _121 => _121.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12292
12546
|
const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
|
|
12293
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12547
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _122 => _122.limit])), operation, http);
|
|
12294
12548
|
return items;
|
|
12295
12549
|
}
|
|
12296
12550
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
12297
|
-
const
|
|
12298
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12299
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
12300
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
12551
|
+
const OP10 = opLabel;
|
|
12552
|
+
if (_optionalChain([opts, 'optionalAccess', _123 => _123.tz]) !== void 0) validateZone(opts.tz, OP10);
|
|
12553
|
+
const fromB = customRangeDay(from, "from", void 0, OP10);
|
|
12554
|
+
const toB = customRangeDay(to, "to", void 0, OP10);
|
|
12301
12555
|
if (fromB.ms > toB.ms) {
|
|
12302
|
-
throw new (0,
|
|
12556
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP10}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP10 });
|
|
12303
12557
|
}
|
|
12304
12558
|
const windowToMs = toB.ms + DAY_MS2 - 1;
|
|
12305
12559
|
const filter = [
|
|
12306
12560
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
12307
12561
|
{ field: "dateWorked", op: "lte", value: iso2(windowToMs) }
|
|
12308
12562
|
];
|
|
12309
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12310
|
-
else if (_optionalChain([opts, 'optionalAccess',
|
|
12311
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12312
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12313
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12563
|
+
if (_optionalChain([opts, 'optionalAccess', _124 => _124.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
|
|
12564
|
+
else if (_optionalChain([opts, 'optionalAccess', _125 => _125.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
12565
|
+
if (_optionalChain([opts, 'optionalAccess', _126 => _126.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12566
|
+
if (_optionalChain([opts, 'optionalAccess', _127 => _127.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
12567
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])), OP10, http);
|
|
12314
12568
|
let postedCount = 0;
|
|
12315
12569
|
for (const item of items) {
|
|
12316
12570
|
const postedDate = item.postedDate;
|
|
@@ -12333,13 +12587,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
|
|
|
12333
12587
|
}
|
|
12334
12588
|
|
|
12335
12589
|
// src/resources/special/time_entries/errors.ts
|
|
12336
|
-
var ResourceInvalidError = class extends
|
|
12590
|
+
var ResourceInvalidError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
12337
12591
|
constructor(message, options = {}) {
|
|
12338
12592
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
12339
12593
|
this.name = "ResourceInvalidError";
|
|
12340
12594
|
}
|
|
12341
12595
|
};
|
|
12342
|
-
var AllocationCodeError = class extends
|
|
12596
|
+
var AllocationCodeError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
12343
12597
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
12344
12598
|
|
|
12345
12599
|
constructor(kind, message, options = {}) {
|
|
@@ -12348,7 +12602,7 @@ var AllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
|
12348
12602
|
this.kind = kind;
|
|
12349
12603
|
}
|
|
12350
12604
|
};
|
|
12351
|
-
var NoApplicableAllocationCodeError = class extends
|
|
12605
|
+
var NoApplicableAllocationCodeError = class extends _chunkIKWHRUQ5cjs.AutotaskError {
|
|
12352
12606
|
/** The structured blocker details (filters tried + department sets). */
|
|
12353
12607
|
|
|
12354
12608
|
constructor(details, options = {}) {
|
|
@@ -12413,7 +12667,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12413
12667
|
let pages = 0;
|
|
12414
12668
|
for (; ; ) {
|
|
12415
12669
|
if (pages >= PAGE_GUARD) {
|
|
12416
|
-
throw new (0,
|
|
12670
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
12417
12671
|
code: "RESOLUTION_TRUNCATED",
|
|
12418
12672
|
category: "resolution",
|
|
12419
12673
|
operation,
|
|
@@ -12424,11 +12678,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12424
12678
|
const res = await http.request({
|
|
12425
12679
|
method: "POST",
|
|
12426
12680
|
idempotent: true,
|
|
12427
|
-
path: isFirst ? path :
|
|
12681
|
+
path: isFirst ? path : _chunkIKWHRUQ5cjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
12428
12682
|
body: { MaxRecords: pageSize, filter },
|
|
12429
12683
|
operation
|
|
12430
12684
|
});
|
|
12431
|
-
const { items: pageItems, pageDetails } =
|
|
12685
|
+
const { items: pageItems, pageDetails } = _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, operation);
|
|
12432
12686
|
items.push(...pageItems);
|
|
12433
12687
|
pages += 1;
|
|
12434
12688
|
if (items.length >= totalCap) break;
|
|
@@ -12520,7 +12774,7 @@ async function resolveCode(http, family, familyLabel2, pinnedId, departments, op
|
|
|
12520
12774
|
}
|
|
12521
12775
|
|
|
12522
12776
|
// src/resources/special/time_entries/createForResource.ts
|
|
12523
|
-
var
|
|
12777
|
+
var OP6 = "time_entries.createForResource";
|
|
12524
12778
|
var PARAM_KEYS = /* @__PURE__ */ new Set([
|
|
12525
12779
|
"internallAllocationCodeID",
|
|
12526
12780
|
"ticketID",
|
|
@@ -12545,7 +12799,7 @@ function windowDefaults(params) {
|
|
|
12545
12799
|
var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
|
|
12546
12800
|
var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
|
|
12547
12801
|
function validateCreateParams(params) {
|
|
12548
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
12802
|
+
const pin = (value, label) => typeof value === "number" ? _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
12549
12803
|
const pins = {
|
|
12550
12804
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
12551
12805
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -12554,32 +12808,32 @@ function validateCreateParams(params) {
|
|
|
12554
12808
|
};
|
|
12555
12809
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
12556
12810
|
if (pinCount > 1) {
|
|
12557
|
-
throw new (0,
|
|
12811
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
12558
12812
|
"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)",
|
|
12559
|
-
{ operation:
|
|
12813
|
+
{ operation: OP6 }
|
|
12560
12814
|
);
|
|
12561
12815
|
}
|
|
12562
12816
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
12563
|
-
throw new (0,
|
|
12817
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
12564
12818
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
12565
|
-
{ operation:
|
|
12819
|
+
{ operation: OP6 }
|
|
12566
12820
|
);
|
|
12567
12821
|
}
|
|
12568
12822
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
12569
|
-
throw new (0,
|
|
12823
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
12570
12824
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
12571
|
-
{ operation:
|
|
12825
|
+
{ operation: OP6 }
|
|
12572
12826
|
);
|
|
12573
12827
|
}
|
|
12574
12828
|
return pins;
|
|
12575
12829
|
}
|
|
12576
12830
|
async function assertResourceActive(http, rid) {
|
|
12577
|
-
const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`,
|
|
12831
|
+
const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP6);
|
|
12578
12832
|
if (rec === null) {
|
|
12579
12833
|
throw new ResourceInvalidError(`Resource ${rid} was not found \u2014 a time entry cannot attach to a missing resource`, {
|
|
12580
12834
|
resourceIds: [rid],
|
|
12581
12835
|
details: { idRefs: [{ entity: "resource", id: rid }] },
|
|
12582
|
-
operation:
|
|
12836
|
+
operation: OP6,
|
|
12583
12837
|
category: "not_found",
|
|
12584
12838
|
suggestedAction: "Resolve the resource id (resources.get / resources.search) and retry."
|
|
12585
12839
|
});
|
|
@@ -12588,7 +12842,7 @@ async function assertResourceActive(http, rid) {
|
|
|
12588
12842
|
throw new ResourceInvalidError(`Resource ${rid} is not active (isActive !== true) \u2014 the vendor would reject a time entry for an inactive resource`, {
|
|
12589
12843
|
resourceIds: [rid],
|
|
12590
12844
|
details: { idRefs: [{ entity: "resource", id: rid }] },
|
|
12591
|
-
operation:
|
|
12845
|
+
operation: OP6,
|
|
12592
12846
|
suggestedAction: "Activate the resource or pick an active one."
|
|
12593
12847
|
});
|
|
12594
12848
|
}
|
|
@@ -12598,11 +12852,11 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
|
|
|
12598
12852
|
const pinnedForCode = pins.code !== void 0 ? pins.code : pins.role;
|
|
12599
12853
|
let code = null;
|
|
12600
12854
|
const familiesTried = [];
|
|
12601
|
-
code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments,
|
|
12855
|
+
code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP6);
|
|
12602
12856
|
familiesTried.push({ family: familyOf(linkage), label: familyLabel(familyOf(linkage)), filters: [{ field: "useType", op: "eq", value: familyOf(linkage) }, { field: "isActive", op: "eq", value: true }] });
|
|
12603
12857
|
if (code === null && linkage === "task" && pins.role === void 0) {
|
|
12604
12858
|
usedLinkage = "internal";
|
|
12605
|
-
code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments,
|
|
12859
|
+
code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP6);
|
|
12606
12860
|
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 }] });
|
|
12607
12861
|
}
|
|
12608
12862
|
if (code === null) {
|
|
@@ -12612,7 +12866,7 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
|
|
|
12612
12866
|
families: familiesTried,
|
|
12613
12867
|
resourceDepartments: [...departments].sort((a, b) => a - b)
|
|
12614
12868
|
},
|
|
12615
|
-
{ operation:
|
|
12869
|
+
{ operation: OP6 }
|
|
12616
12870
|
);
|
|
12617
12871
|
}
|
|
12618
12872
|
const resolvedCode = codeInfo(code);
|
|
@@ -12649,9 +12903,9 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
|
|
|
12649
12903
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
12650
12904
|
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).");
|
|
12651
12905
|
}
|
|
12652
|
-
return
|
|
12906
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
12653
12907
|
{
|
|
12654
|
-
operation:
|
|
12908
|
+
operation: OP6,
|
|
12655
12909
|
method: "POST",
|
|
12656
12910
|
path: "/V1.0/TimeEntries",
|
|
12657
12911
|
ids: [rid],
|
|
@@ -12689,11 +12943,11 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12689
12943
|
};
|
|
12690
12944
|
} catch (err) {
|
|
12691
12945
|
lastError = err;
|
|
12692
|
-
const text =
|
|
12946
|
+
const text = _chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkIKWHRUQ5cjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
12693
12947
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
12694
12948
|
if (usedLinkage !== "internal" && gate3) {
|
|
12695
12949
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
12696
|
-
const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`,
|
|
12950
|
+
const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP6);
|
|
12697
12951
|
taskRoleFetched = true;
|
|
12698
12952
|
if (task !== null) pushLadder(task.assignedResourceRoleID);
|
|
12699
12953
|
}
|
|
@@ -12709,17 +12963,17 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12709
12963
|
throw err;
|
|
12710
12964
|
}
|
|
12711
12965
|
}
|
|
12712
|
-
if (
|
|
12966
|
+
if (_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, lastError)) {
|
|
12713
12967
|
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.`;
|
|
12714
12968
|
}
|
|
12715
12969
|
throw lastError;
|
|
12716
12970
|
}
|
|
12717
12971
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
12718
|
-
const rid =
|
|
12972
|
+
const rid = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
12719
12973
|
const pins = validateCreateParams(params);
|
|
12720
12974
|
await assertResourceActive(http, rid);
|
|
12721
12975
|
const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
|
|
12722
|
-
const roleRows = await resourceRoleRows(http, rid,
|
|
12976
|
+
const roleRows = await resourceRoleRows(http, rid, OP6);
|
|
12723
12977
|
const departments = roleRows.departments;
|
|
12724
12978
|
const { usedLinkage, resolvedCode } = await resolveAllocationCode(http, rid, linkage, pins, departments);
|
|
12725
12979
|
const defaults = windowDefaults(params);
|
|
@@ -12728,8 +12982,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
12728
12982
|
return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
|
|
12729
12983
|
}
|
|
12730
12984
|
function discoveryField(err, body, defaults) {
|
|
12731
|
-
if (!
|
|
12732
|
-
const entries =
|
|
12985
|
+
if (!_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
12986
|
+
const entries = _chunkIKWHRUQ5cjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
12733
12987
|
if (entries === void 0) return null;
|
|
12734
12988
|
for (const entry of entries) {
|
|
12735
12989
|
const field = entry.field;
|
|
@@ -12742,42 +12996,42 @@ function discoveryField(err, body, defaults) {
|
|
|
12742
12996
|
}
|
|
12743
12997
|
|
|
12744
12998
|
// src/resources/special/time_entries/move.ts
|
|
12745
|
-
var
|
|
12999
|
+
var OP7 = "time_entries.moveToTicket";
|
|
12746
13000
|
var COPY2 = ["resourceID", "roleID", "billingCodeID", "dateWorked", "startDateTime", "endDateTime", "hoursWorked", "offsetHours", "summaryNotes", "internalNotes", "isNonBillable", "showOnInvoice"];
|
|
12747
13001
|
var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundleID"];
|
|
12748
13002
|
async function readTimeEntry(http, id, retries) {
|
|
12749
13003
|
try {
|
|
12750
|
-
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation:
|
|
12751
|
-
return _nullishCoalesce(_optionalChain([res, 'optionalAccess',
|
|
13004
|
+
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP7, maxRetries: retries });
|
|
13005
|
+
return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _129 => _129.item]), () => ( null));
|
|
12752
13006
|
} catch (e) {
|
|
12753
|
-
if (
|
|
13007
|
+
if (_chunkIKWHRUQ5cjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
12754
13008
|
throw e;
|
|
12755
13009
|
}
|
|
12756
13010
|
}
|
|
12757
13011
|
async function checkSource2({ http, source, sourceId, toTicketId, retries }) {
|
|
12758
13012
|
const ids2 = { sourceId, toTicketId };
|
|
12759
13013
|
if (source.taskID !== null && source.taskID !== void 0) {
|
|
12760
|
-
throw refuse("MOVE_SOURCE_UNSUPPORTED", `${
|
|
13014
|
+
throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP7}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP7);
|
|
12761
13015
|
}
|
|
12762
13016
|
if (source.billingApprovalDateTime || source.billingApprovalResourceID || source.billingApprovalLevelMostRecent) {
|
|
12763
|
-
throw refuse("MOVE_BLOCKED_APPROVED", `${
|
|
13017
|
+
throw refuse("MOVE_BLOCKED_APPROVED", `${OP7}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP7, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
|
|
12764
13018
|
}
|
|
12765
13019
|
let billing;
|
|
12766
13020
|
try {
|
|
12767
|
-
billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }],
|
|
13021
|
+
billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP7, retries);
|
|
12768
13022
|
} catch (e3) {
|
|
12769
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
13023
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP7}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP7, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
|
|
12770
13024
|
}
|
|
12771
13025
|
if (billing.some((b) => b.invoiceID || b.postedDate)) {
|
|
12772
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
13026
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP7}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP7, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
|
|
12773
13027
|
}
|
|
12774
|
-
const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }],
|
|
13028
|
+
const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP7, retries);
|
|
12775
13029
|
if (attachments.length > 0) {
|
|
12776
|
-
throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${
|
|
13030
|
+
throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP7}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP7, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
|
|
12777
13031
|
}
|
|
12778
13032
|
}
|
|
12779
13033
|
var SPEC2 = {
|
|
12780
|
-
operation:
|
|
13034
|
+
operation: OP7,
|
|
12781
13035
|
entity: "time_entry",
|
|
12782
13036
|
readSource: readTimeEntry,
|
|
12783
13037
|
sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
|
|
@@ -12812,15 +13066,15 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
|
|
|
12812
13066
|
}
|
|
12813
13067
|
|
|
12814
13068
|
// src/resources/special/time_entries/approve.ts
|
|
12815
|
-
var
|
|
13069
|
+
var OP8 = "time_entries.approve";
|
|
12816
13070
|
var APPROVAL_LEVELS_PATH = "/V1.0/BillingItemApprovalLevels";
|
|
12817
13071
|
function toIso(value) {
|
|
12818
13072
|
if (value instanceof Date) {
|
|
12819
|
-
if (Number.isNaN(value.getTime())) throw new (0,
|
|
13073
|
+
if (Number.isNaN(value.getTime())) throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
|
|
12820
13074
|
return value.toISOString();
|
|
12821
13075
|
}
|
|
12822
13076
|
const parsed = new Date(value);
|
|
12823
|
-
if (Number.isNaN(parsed.getTime())) throw new (0,
|
|
13077
|
+
if (Number.isNaN(parsed.getTime())) throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
|
|
12824
13078
|
return parsed.toISOString();
|
|
12825
13079
|
}
|
|
12826
13080
|
function toNumber(value) {
|
|
@@ -12833,24 +13087,24 @@ function sameInstant(a, b) {
|
|
|
12833
13087
|
return !Number.isNaN(left) && left === right;
|
|
12834
13088
|
}
|
|
12835
13089
|
async function approve(resource, id, opts = {}, http) {
|
|
12836
|
-
const numericId = toNumber(
|
|
13090
|
+
const numericId = toNumber(_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id"));
|
|
12837
13091
|
if (opts.approvalLevel !== void 0 && (!Number.isInteger(opts.approvalLevel) || opts.approvalLevel < 1)) {
|
|
12838
|
-
throw new (0,
|
|
13092
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
|
|
12839
13093
|
}
|
|
12840
13094
|
const approvalLevel = _nullishCoalesce(opts.approvalLevel, () => ( 1));
|
|
12841
13095
|
const approvalDateTime = toIso(_nullishCoalesce(opts.approvalDateTime, () => ( /* @__PURE__ */ new Date())));
|
|
12842
13096
|
const entry = await resource.get(numericId);
|
|
12843
|
-
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(
|
|
13097
|
+
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
|
|
12844
13098
|
if (approvalResourceID === void 0) {
|
|
12845
|
-
throw new (0,
|
|
13099
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(
|
|
12846
13100
|
`time_entries.approve: time entry ${numericId} carries no resourceID and the caller supplied no approvalResourceID \u2014 the vendor requires an approving resource`
|
|
12847
13101
|
);
|
|
12848
13102
|
}
|
|
12849
13103
|
const body = { timeEntryID: numericId, approvalLevel, approvalResourceID, approvalDateTime };
|
|
12850
13104
|
if (opts.dryRun === true) {
|
|
12851
|
-
return
|
|
13105
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0,
|
|
12852
13106
|
{
|
|
12853
|
-
operation:
|
|
13107
|
+
operation: OP8,
|
|
12854
13108
|
method: "POST",
|
|
12855
13109
|
path: APPROVAL_LEVELS_PATH,
|
|
12856
13110
|
ids: [numericId],
|
|
@@ -12873,10 +13127,10 @@ async function approve(resource, id, opts = {}, http) {
|
|
|
12873
13127
|
method: "POST",
|
|
12874
13128
|
path: APPROVAL_LEVELS_PATH,
|
|
12875
13129
|
body,
|
|
12876
|
-
operation:
|
|
13130
|
+
operation: OP8,
|
|
12877
13131
|
maxRetries: opts.maxRetries
|
|
12878
13132
|
});
|
|
12879
|
-
const levelId = toNumber(
|
|
13133
|
+
const levelId = toNumber(_chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, _chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, created, OP8).id, "billingItemApprovalLevelID"));
|
|
12880
13134
|
await resource.update(
|
|
12881
13135
|
numericId,
|
|
12882
13136
|
{ billingApprovalDateTime: approvalDateTime, billingApprovalResourceID: approvalResourceID },
|
|
@@ -12899,28 +13153,28 @@ async function approve(resource, id, opts = {}, http) {
|
|
|
12899
13153
|
}
|
|
12900
13154
|
|
|
12901
13155
|
// src/resources/special/time_entries/recentTickets.ts
|
|
12902
|
-
var
|
|
13156
|
+
var OP9 = "time_entries.recentTickets";
|
|
12903
13157
|
var DAY_MS3 = 864e5;
|
|
12904
|
-
var
|
|
12905
|
-
var
|
|
12906
|
-
function
|
|
13158
|
+
var TICKET_CHUNK2 = 100;
|
|
13159
|
+
var TICKET_FIELDS3 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
13160
|
+
function positiveId3(value, name) {
|
|
12907
13161
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12908
13162
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12909
|
-
throw new (0,
|
|
13163
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP9}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP9 });
|
|
12910
13164
|
}
|
|
12911
13165
|
return n;
|
|
12912
13166
|
}
|
|
12913
13167
|
async function recentTickets(_resource, from, to, http, opts) {
|
|
12914
13168
|
if (opts === void 0 || opts === null || typeof opts !== "object") {
|
|
12915
|
-
throw new (0,
|
|
13169
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP9}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP9 });
|
|
12916
13170
|
}
|
|
12917
|
-
const resourceID =
|
|
12918
|
-
const companyID = opts.companyID === void 0 ? void 0 :
|
|
12919
|
-
if (opts.tz !== void 0) validateZone(opts.tz,
|
|
12920
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
12921
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
13171
|
+
const resourceID = positiveId3(opts.resourceID, "resourceID");
|
|
13172
|
+
const companyID = opts.companyID === void 0 ? void 0 : positiveId3(opts.companyID, "companyID");
|
|
13173
|
+
if (opts.tz !== void 0) validateZone(opts.tz, OP9);
|
|
13174
|
+
const fromB = customRangeDay(from, "from", void 0, OP9);
|
|
13175
|
+
const toB = customRangeDay(to, "to", void 0, OP9);
|
|
12922
13176
|
if (fromB.ms > toB.ms) {
|
|
12923
|
-
throw new (0,
|
|
13177
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)(`${OP9}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP9 });
|
|
12924
13178
|
}
|
|
12925
13179
|
const windowToMs = toB.ms + DAY_MS3 - 1;
|
|
12926
13180
|
const { items: entries, hasMore } = await queryTimeEntries(
|
|
@@ -12931,7 +13185,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12931
13185
|
{ field: "resourceID", op: "eq", value: resourceID }
|
|
12932
13186
|
],
|
|
12933
13187
|
clampWindowLimit(opts.limit),
|
|
12934
|
-
|
|
13188
|
+
OP9,
|
|
12935
13189
|
http
|
|
12936
13190
|
);
|
|
12937
13191
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -12949,17 +13203,17 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12949
13203
|
}
|
|
12950
13204
|
const ids2 = [...groups.keys()];
|
|
12951
13205
|
const tickets = /* @__PURE__ */ new Map();
|
|
12952
|
-
for (let c = 0; c < ids2.length; c +=
|
|
12953
|
-
const chunk = ids2.slice(c, c +
|
|
13206
|
+
for (let c = 0; c < ids2.length; c += TICKET_CHUNK2) {
|
|
13207
|
+
const chunk = ids2.slice(c, c + TICKET_CHUNK2);
|
|
12954
13208
|
const filter = [{ field: "id", op: "in", value: chunk }];
|
|
12955
13209
|
const res = await http.request({
|
|
12956
13210
|
method: "POST",
|
|
12957
13211
|
idempotent: true,
|
|
12958
13212
|
path: "/V1.0/Tickets/query",
|
|
12959
|
-
body: { MaxRecords:
|
|
12960
|
-
operation:
|
|
13213
|
+
body: { MaxRecords: TICKET_CHUNK2, filter, IncludeFields: TICKET_FIELDS3 },
|
|
13214
|
+
operation: OP9
|
|
12961
13215
|
});
|
|
12962
|
-
for (const t of
|
|
13216
|
+
for (const t of _chunkIKWHRUQ5cjs.unwrapItems.call(void 0, res, OP9).items) if (typeof t.id === "number") tickets.set(t.id, t);
|
|
12963
13217
|
}
|
|
12964
13218
|
const items = [];
|
|
12965
13219
|
const unresolvedTicketIDs = [];
|
|
@@ -12967,17 +13221,17 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12967
13221
|
for (const [ticketID, g] of groups) {
|
|
12968
13222
|
const t = tickets.get(ticketID);
|
|
12969
13223
|
if (t === void 0) unresolvedTicketIDs.push(ticketID);
|
|
12970
|
-
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess',
|
|
13224
|
+
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _130 => _130.companyID]) !== companyID) {
|
|
12971
13225
|
if (t !== void 0) excludedTickets += 1;
|
|
12972
13226
|
continue;
|
|
12973
13227
|
}
|
|
12974
13228
|
items.push({
|
|
12975
13229
|
ticketID,
|
|
12976
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12977
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12978
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12979
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12980
|
-
..._optionalChain([t, 'optionalAccess',
|
|
13230
|
+
..._optionalChain([t, 'optionalAccess', _131 => _131.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
|
|
13231
|
+
..._optionalChain([t, 'optionalAccess', _132 => _132.title]) !== void 0 ? { title: t.title } : {},
|
|
13232
|
+
..._optionalChain([t, 'optionalAccess', _133 => _133.status]) !== void 0 ? { status: t.status } : {},
|
|
13233
|
+
..._optionalChain([t, 'optionalAccess', _134 => _134.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
|
|
13234
|
+
..._optionalChain([t, 'optionalAccess', _135 => _135.companyID]) !== void 0 ? { companyID: t.companyID } : {},
|
|
12981
13235
|
entryCount: g.entryCount,
|
|
12982
13236
|
totalHours: Math.round(g.totalHours * 100) / 100,
|
|
12983
13237
|
lastWorked: g.lastWorked
|
|
@@ -12996,7 +13250,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12996
13250
|
}
|
|
12997
13251
|
|
|
12998
13252
|
// src/resources/time_entries.ts
|
|
12999
|
-
var TimeEntriesResource = class extends
|
|
13253
|
+
var TimeEntriesResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
13000
13254
|
constructor(http, pageSize) {
|
|
13001
13255
|
super(http, {
|
|
13002
13256
|
key: "time_entries",
|
|
@@ -13145,7 +13399,7 @@ var TimeEntriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
|
13145
13399
|
};
|
|
13146
13400
|
|
|
13147
13401
|
// src/resources/time_entry_attachments.ts
|
|
13148
|
-
var TimeEntryAttachmentsResource = class extends
|
|
13402
|
+
var TimeEntryAttachmentsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
13149
13403
|
constructor(http, pageSize) {
|
|
13150
13404
|
super(http, {
|
|
13151
13405
|
key: "time_entry_attachments",
|
|
@@ -13208,9 +13462,9 @@ var TimeEntryAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource
|
|
|
13208
13462
|
|
|
13209
13463
|
// src/resources/special/time_off_requests.ts
|
|
13210
13464
|
async function approve2(_resource, id, opts = {}, http) {
|
|
13211
|
-
const numericId =
|
|
13465
|
+
const numericId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
13212
13466
|
if (opts.dryRun === true) {
|
|
13213
|
-
return
|
|
13467
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
13214
13468
|
operation: "time_off_requests.approve",
|
|
13215
13469
|
method: "GET",
|
|
13216
13470
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -13226,16 +13480,16 @@ async function approve2(_resource, id, opts = {}, http) {
|
|
|
13226
13480
|
operation: "time_off_requests.approve",
|
|
13227
13481
|
maxRetries: opts.maxRetries
|
|
13228
13482
|
});
|
|
13229
|
-
return
|
|
13483
|
+
return _chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, res);
|
|
13230
13484
|
}
|
|
13231
13485
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
13232
|
-
const numericId =
|
|
13486
|
+
const numericId = _chunkIKWHRUQ5cjs.parseIdentifier.call(void 0, id, "id");
|
|
13233
13487
|
const text = reason.trim();
|
|
13234
13488
|
if (text === "") {
|
|
13235
|
-
throw new (0,
|
|
13489
|
+
throw new (0, _chunkIKWHRUQ5cjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
13236
13490
|
}
|
|
13237
13491
|
if (opts.dryRun === true) {
|
|
13238
|
-
return
|
|
13492
|
+
return _chunkIKWHRUQ5cjs.buildDryRunResult.call(void 0, {
|
|
13239
13493
|
operation: "time_off_requests.reject",
|
|
13240
13494
|
method: "POST",
|
|
13241
13495
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -13253,11 +13507,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
13253
13507
|
operation: "time_off_requests.reject",
|
|
13254
13508
|
maxRetries: opts.maxRetries
|
|
13255
13509
|
});
|
|
13256
|
-
return
|
|
13510
|
+
return _chunkIKWHRUQ5cjs.unwrapOperation.call(void 0, res);
|
|
13257
13511
|
}
|
|
13258
13512
|
|
|
13259
13513
|
// src/resources/time_off_requests.ts
|
|
13260
|
-
var TimeOffRequestsResource = class extends
|
|
13514
|
+
var TimeOffRequestsResource = class extends _chunkIKWHRUQ5cjs.BaseResource {
|
|
13261
13515
|
constructor(http, pageSize) {
|
|
13262
13516
|
super(http, {
|
|
13263
13517
|
key: "time_off_requests",
|