node-autotask 0.32.0 → 0.33.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 +15 -0
- package/MCP_TOOL_CATALOG.json +27 -8
- package/MCP_TOOL_MANIFEST.md +14 -13
- package/N8N_MCP_MANIFEST.json +38 -12
- package/N8N_MCP_MANIFEST.md +10 -9
- package/README.md +1 -1
- package/capabilities.json +1448 -1307
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-QCB4LYKD.cjs → chunk-3LAZZT7V.cjs} +143 -143
- package/dist/{chunk-IKPFR6K2.cjs → chunk-4QN43TRP.cjs} +73 -48
- package/dist/{chunk-FVHPN7ZR.js → chunk-5DS6F6GF.js} +241 -91
- package/dist/{chunk-T6EDJRLT.js → chunk-7WNE5MPG.js} +2 -2
- package/dist/{chunk-R6HLJCI2.js → chunk-MFDQHFGJ.js} +26 -1
- package/dist/{chunk-FTF2FEQ6.cjs → chunk-OO67MRHN.cjs} +765 -615
- package/dist/{chunk-DCTHO7CQ.cjs → chunk-SP2SJJZX.cjs} +1447 -1306
- package/dist/{chunk-M2EGFPGF.js → chunk-VKE56TTN.js} +1447 -1306
- package/dist/{index-Cw4aNNMo.d.ts → index-BaeMHZPk.d.ts} +87 -1
- package/dist/{index-OkbCWcef.d.cts → index-Cq0VsfSz.d.cts} +87 -1
- package/dist/index.cjs +23 -23
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/operations/index.cjs +120 -133
- package/dist/operations/index.d.cts +2 -2
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +3 -16
- package/dist/pool.cjs +9 -9
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +3 -3
- package/docs/API.md +1 -1
- package/package.json +2 -1
|
@@ -40,13 +40,14 @@
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var _chunkIKPFR6K2cjs = require('./chunk-IKPFR6K2.cjs');
|
|
44
43
|
|
|
44
|
+
var _chunk4QN43TRPcjs = require('./chunk-4QN43TRP.cjs');
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
var _chunkSP2SJJZXcjs = require('./chunk-SP2SJJZX.cjs');
|
|
47
48
|
|
|
48
49
|
// src/resources/appointments.ts
|
|
49
|
-
var AppointmentsResource = class extends
|
|
50
|
+
var AppointmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
50
51
|
constructor(http, pageSize) {
|
|
51
52
|
super(http, {
|
|
52
53
|
key: "appointments",
|
|
@@ -131,7 +132,7 @@ var AuthenticateResource = class {
|
|
|
131
132
|
};
|
|
132
133
|
|
|
133
134
|
// src/resources/billing_codes.ts
|
|
134
|
-
var BillingCodesResource = class extends
|
|
135
|
+
var BillingCodesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
135
136
|
constructor(http, pageSize) {
|
|
136
137
|
super(http, {
|
|
137
138
|
key: "billing_codes",
|
|
@@ -175,7 +176,7 @@ var BillingCodesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
175
176
|
};
|
|
176
177
|
|
|
177
178
|
// src/resources/billing_item_approval_levels.ts
|
|
178
|
-
var BillingItemApprovalLevelsResource = class extends
|
|
179
|
+
var BillingItemApprovalLevelsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
179
180
|
constructor(http, pageSize) {
|
|
180
181
|
super(http, {
|
|
181
182
|
key: "billing_item_approval_levels",
|
|
@@ -217,7 +218,7 @@ var MAX_LIMIT = 500;
|
|
|
217
218
|
function clampWindowLimit(limit) {
|
|
218
219
|
const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
|
|
219
220
|
if (!Number.isInteger(n) || n < 1) {
|
|
220
|
-
throw new (0,
|
|
221
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
221
222
|
}
|
|
222
223
|
return Math.min(n, MAX_LIMIT);
|
|
223
224
|
}
|
|
@@ -263,7 +264,7 @@ function wallParts(tz, ms) {
|
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
|
|
266
|
-
throw new (0,
|
|
267
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
|
|
267
268
|
}
|
|
268
269
|
return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
|
|
269
270
|
}
|
|
@@ -273,11 +274,11 @@ function tzOffsetMs(tz, ms) {
|
|
|
273
274
|
}
|
|
274
275
|
function localDayStartMs(y, m, d, tz) {
|
|
275
276
|
if (tz === void 0) return Date.UTC(y, m - 1, d);
|
|
276
|
-
const
|
|
277
|
-
const offset = tzOffsetMs(tz,
|
|
278
|
-
let start =
|
|
277
|
+
const candidate2 = Date.UTC(y, m - 1, d);
|
|
278
|
+
const offset = tzOffsetMs(tz, candidate2);
|
|
279
|
+
let start = candidate2 - offset;
|
|
279
280
|
if (tzOffsetMs(tz, start) !== offset) {
|
|
280
|
-
start =
|
|
281
|
+
start = candidate2 - tzOffsetMs(tz, start);
|
|
281
282
|
}
|
|
282
283
|
const p = wallParts(tz, start);
|
|
283
284
|
if (p.d !== d) start += 864e5 - ((p.h * 60 + p.mi) * 60 + p.s) * 1e3;
|
|
@@ -290,7 +291,7 @@ function localDayEndMs(y, m, d, tz) {
|
|
|
290
291
|
}
|
|
291
292
|
function validateZone(tz, opName = "dateWindow") {
|
|
292
293
|
if (typeof tz !== "string" || tz.length === 0) {
|
|
293
|
-
throw new (0,
|
|
294
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
294
295
|
`${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
295
296
|
{ operation: opName }
|
|
296
297
|
);
|
|
@@ -298,7 +299,7 @@ function validateZone(tz, opName = "dateWindow") {
|
|
|
298
299
|
try {
|
|
299
300
|
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
300
301
|
} catch (e2) {
|
|
301
|
-
throw new (0,
|
|
302
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
302
303
|
`${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
303
304
|
{ operation: opName }
|
|
304
305
|
);
|
|
@@ -458,13 +459,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
|
|
|
458
459
|
body: { MaxRecords: limit, filter },
|
|
459
460
|
operation
|
|
460
461
|
});
|
|
461
|
-
return
|
|
462
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
462
463
|
}
|
|
463
464
|
var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
|
|
464
465
|
function customRangeDay(value, label, zone, opName) {
|
|
465
466
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
466
467
|
if (!m) {
|
|
467
|
-
throw new (0,
|
|
468
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
468
469
|
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)})`,
|
|
469
470
|
{ operation: opName }
|
|
470
471
|
);
|
|
@@ -476,7 +477,7 @@ function customRangeDay(value, label, zone, opName) {
|
|
|
476
477
|
const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
|
|
477
478
|
const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
|
|
478
479
|
if (!Number.isFinite(ms)) {
|
|
479
|
-
throw new (0,
|
|
480
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
480
481
|
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)})`,
|
|
481
482
|
{ operation: opName }
|
|
482
483
|
);
|
|
@@ -488,7 +489,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
488
489
|
const fromB = customRangeDay(from, "from", void 0, operation);
|
|
489
490
|
const toB = customRangeDay(to, "to", void 0, operation);
|
|
490
491
|
if (fromB.ms > toB.ms) {
|
|
491
|
-
throw new (0,
|
|
492
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
492
493
|
`${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
|
|
493
494
|
{ operation }
|
|
494
495
|
);
|
|
@@ -505,7 +506,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
505
506
|
body: { MaxRecords: limit, filter },
|
|
506
507
|
operation
|
|
507
508
|
});
|
|
508
|
-
return
|
|
509
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
509
510
|
}
|
|
510
511
|
|
|
511
512
|
// src/resources/special/billing_items.ts
|
|
@@ -538,7 +539,7 @@ async function customRange(_resource, from, to, http, opts) {
|
|
|
538
539
|
}
|
|
539
540
|
|
|
540
541
|
// src/resources/billing_items.ts
|
|
541
|
-
var BillingItemsResource = class extends
|
|
542
|
+
var BillingItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
542
543
|
constructor(http, pageSize) {
|
|
543
544
|
super(http, {
|
|
544
545
|
key: "billing_items",
|
|
@@ -640,7 +641,7 @@ var BillingItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
640
641
|
};
|
|
641
642
|
|
|
642
643
|
// src/resources/change_request_links.ts
|
|
643
|
-
var ChangeRequestLinksResource = class extends
|
|
644
|
+
var ChangeRequestLinksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
644
645
|
constructor(http, pageSize) {
|
|
645
646
|
super(http, {
|
|
646
647
|
key: "change_request_links",
|
|
@@ -694,7 +695,7 @@ var ChangeRequestLinksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
694
695
|
};
|
|
695
696
|
|
|
696
697
|
// src/resources/checklist_libraries.ts
|
|
697
|
-
var ChecklistLibrariesResource = class extends
|
|
698
|
+
var ChecklistLibrariesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
698
699
|
constructor(http, pageSize) {
|
|
699
700
|
super(http, {
|
|
700
701
|
key: "checklist_libraries",
|
|
@@ -768,7 +769,7 @@ var ChecklistLibrariesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
768
769
|
};
|
|
769
770
|
|
|
770
771
|
// src/resources/checklist_library_checklist_items.ts
|
|
771
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
772
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
772
773
|
constructor(http, pageSize) {
|
|
773
774
|
super(http, {
|
|
774
775
|
key: "checklist_library_checklist_items",
|
|
@@ -834,7 +835,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkIKPFR6K2cjs.Bas
|
|
|
834
835
|
};
|
|
835
836
|
|
|
836
837
|
// src/resources/classification_icons.ts
|
|
837
|
-
var ClassificationIconsResource = class extends
|
|
838
|
+
var ClassificationIconsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
838
839
|
constructor(http, pageSize) {
|
|
839
840
|
super(http, {
|
|
840
841
|
key: "classification_icons",
|
|
@@ -941,7 +942,7 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
|
|
|
941
942
|
body,
|
|
942
943
|
operation
|
|
943
944
|
});
|
|
944
|
-
const { items, pageDetails } =
|
|
945
|
+
const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, operation);
|
|
945
946
|
const capped = items.length >= limit;
|
|
946
947
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
947
948
|
}
|
|
@@ -951,7 +952,7 @@ var DEFAULT_LIMIT2 = 25;
|
|
|
951
952
|
var MAX_LIMIT2 = 500;
|
|
952
953
|
function clampLimit(limit) {
|
|
953
954
|
const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
|
|
954
|
-
if (!Number.isInteger(n) || n < 1) throw new (0,
|
|
955
|
+
if (!Number.isInteger(n) || n < 1) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
955
956
|
return Math.min(n, MAX_LIMIT2);
|
|
956
957
|
}
|
|
957
958
|
|
|
@@ -964,7 +965,7 @@ async function queryCompanies(http, filter, limit) {
|
|
|
964
965
|
body: { MaxRecords: limit, filter },
|
|
965
966
|
operation: "companies.searchByDomain"
|
|
966
967
|
});
|
|
967
|
-
return
|
|
968
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
968
969
|
}
|
|
969
970
|
async function queryContacts(http, filter, limit) {
|
|
970
971
|
const res = await http.request({
|
|
@@ -974,7 +975,7 @@ async function queryContacts(http, filter, limit) {
|
|
|
974
975
|
body: { MaxRecords: limit, filter },
|
|
975
976
|
operation: "companies.searchByDomain"
|
|
976
977
|
});
|
|
977
|
-
return
|
|
978
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
978
979
|
}
|
|
979
980
|
async function fetchCompanies(http, ids2, limit) {
|
|
980
981
|
const out = [];
|
|
@@ -989,7 +990,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
989
990
|
const item = body && "item" in body ? body.item : null;
|
|
990
991
|
if (item) out.push(item);
|
|
991
992
|
} catch (err) {
|
|
992
|
-
if (err instanceof
|
|
993
|
+
if (err instanceof _chunk4QN43TRPcjs.NotFoundError) continue;
|
|
993
994
|
throw err;
|
|
994
995
|
}
|
|
995
996
|
}
|
|
@@ -997,7 +998,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
997
998
|
}
|
|
998
999
|
async function searchByDomain(_resource, domain, opts = {}, http) {
|
|
999
1000
|
const text = domain.trim();
|
|
1000
|
-
if (text === "") throw new (0,
|
|
1001
|
+
if (text === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("searchByDomain: empty domain");
|
|
1001
1002
|
const limit = clampLimit(opts.limit);
|
|
1002
1003
|
const filter = [{ field: "webAddress", op: "contains", value: text }];
|
|
1003
1004
|
const direct = await queryCompanies(http, filter, limit);
|
|
@@ -1011,7 +1012,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
|
|
|
1011
1012
|
const email = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.email, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
|
|
1012
1013
|
const website = _nullishCoalesce(_optionalChain([identity, 'access', _15 => _15.website, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]), () => ( ""));
|
|
1013
1014
|
if (name === "" && email === "" && website === "") {
|
|
1014
|
-
throw new (0,
|
|
1015
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
|
|
1015
1016
|
}
|
|
1016
1017
|
const limit = clampLimit(opts.limit);
|
|
1017
1018
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -1040,23 +1041,23 @@ async function familyChildPage(http, parentID) {
|
|
|
1040
1041
|
path: "/V1.0/Companies/query",
|
|
1041
1042
|
body: {
|
|
1042
1043
|
MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
|
|
1043
|
-
filter:
|
|
1044
|
+
filter: _chunk4QN43TRPcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
|
|
1044
1045
|
},
|
|
1045
1046
|
operation: "companies.search"
|
|
1046
1047
|
});
|
|
1047
|
-
const { items, pageDetails } =
|
|
1048
|
+
const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "companies.search");
|
|
1048
1049
|
return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
|
|
1049
1050
|
}
|
|
1050
1051
|
function assertSearchWithDetailOpts(opts) {
|
|
1051
1052
|
if (opts === void 0) return;
|
|
1052
1053
|
if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
|
|
1053
|
-
throw new (0,
|
|
1054
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
|
|
1054
1055
|
operation: "companies.searchWithDetail"
|
|
1055
1056
|
});
|
|
1056
1057
|
}
|
|
1057
1058
|
for (const key of Object.keys(opts)) {
|
|
1058
1059
|
if (key !== "limit") {
|
|
1059
|
-
throw new (0,
|
|
1060
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
1060
1061
|
`companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
|
|
1061
1062
|
{ operation: "companies.searchWithDetail" }
|
|
1062
1063
|
);
|
|
@@ -1065,32 +1066,32 @@ function assertSearchWithDetailOpts(opts) {
|
|
|
1065
1066
|
}
|
|
1066
1067
|
async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
1067
1068
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1068
|
-
throw new (0,
|
|
1069
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
|
|
1069
1070
|
}
|
|
1070
1071
|
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
1071
1072
|
if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
|
|
1072
|
-
throw new (0,
|
|
1073
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
1073
1074
|
`companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
|
|
1074
1075
|
{ operation: "companies.search" }
|
|
1075
1076
|
);
|
|
1076
1077
|
}
|
|
1077
1078
|
}
|
|
1078
1079
|
if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
|
|
1079
|
-
throw new (0,
|
|
1080
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
|
|
1080
1081
|
operation: "companies.search"
|
|
1081
1082
|
});
|
|
1082
1083
|
}
|
|
1083
1084
|
const text = query.trim();
|
|
1084
|
-
if (text === "") throw new (0,
|
|
1085
|
-
const limit = opts.limit === void 0 ? 25 :
|
|
1085
|
+
if (text === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
1086
|
+
const limit = opts.limit === void 0 ? 25 : _chunk4QN43TRPcjs.clampPageSize.call(void 0, opts.limit);
|
|
1086
1087
|
const res = await http.request({
|
|
1087
1088
|
method: "POST",
|
|
1088
1089
|
idempotent: true,
|
|
1089
1090
|
path: "/V1.0/Companies/query",
|
|
1090
|
-
body: { MaxRecords: limit, filter:
|
|
1091
|
+
body: { MaxRecords: limit, filter: _chunk4QN43TRPcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
1091
1092
|
operation: "companies.search"
|
|
1092
1093
|
});
|
|
1093
|
-
const hits =
|
|
1094
|
+
const hits = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "companies.search").items;
|
|
1094
1095
|
if (opts.includeFamily !== true) return hits;
|
|
1095
1096
|
const rows = [];
|
|
1096
1097
|
for (const hit of hits) {
|
|
@@ -1110,7 +1111,7 @@ async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
|
1110
1111
|
}
|
|
1111
1112
|
|
|
1112
1113
|
// src/resources/special/companies/errors.ts
|
|
1113
|
-
var OwnerResourceRequiredError = class extends
|
|
1114
|
+
var OwnerResourceRequiredError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
1114
1115
|
constructor(message, options = {}) {
|
|
1115
1116
|
super(message, {
|
|
1116
1117
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1121,13 +1122,13 @@ var OwnerResourceRequiredError = class extends _chunkIKPFR6K2cjs.AutotaskError {
|
|
|
1121
1122
|
this.name = "OwnerResourceRequiredError";
|
|
1122
1123
|
}
|
|
1123
1124
|
};
|
|
1124
|
-
var CompanyResourceInvalidError = class extends
|
|
1125
|
+
var CompanyResourceInvalidError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
1125
1126
|
constructor(message, options = {}) {
|
|
1126
1127
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
1127
1128
|
this.name = "CompanyResourceInvalidError";
|
|
1128
1129
|
}
|
|
1129
1130
|
};
|
|
1130
|
-
var CompanyCreateFailedError = class extends
|
|
1131
|
+
var CompanyCreateFailedError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
1131
1132
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
1132
1133
|
|
|
1133
1134
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -1146,23 +1147,23 @@ var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumer
|
|
|
1146
1147
|
var SAFE_COMPANY_CREATE_DEFAULTS = {};
|
|
1147
1148
|
function validateUpsertInput(companyName, params) {
|
|
1148
1149
|
if (typeof companyName !== "string" || companyName.trim() === "") {
|
|
1149
|
-
throw new (0,
|
|
1150
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
|
|
1150
1151
|
}
|
|
1151
1152
|
if (typeof _optionalChain([params, 'optionalAccess', _18 => _18.phone]) !== "string" || params.phone.trim() === "") {
|
|
1152
|
-
throw new (0,
|
|
1153
|
+
throw new (0, _chunk4QN43TRPcjs.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 });
|
|
1153
1154
|
}
|
|
1154
1155
|
const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
|
|
1155
1156
|
if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
|
|
1156
|
-
throw new (0,
|
|
1157
|
+
throw new (0, _chunk4QN43TRPcjs.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 });
|
|
1157
1158
|
}
|
|
1158
1159
|
const owner = params.ownerResourceID;
|
|
1159
1160
|
if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
|
|
1160
|
-
throw new (0,
|
|
1161
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
|
|
1161
1162
|
}
|
|
1162
1163
|
return { companyType, owner };
|
|
1163
1164
|
}
|
|
1164
1165
|
function existsDryRun(http, companyName, match) {
|
|
1165
|
-
return
|
|
1166
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
1166
1167
|
{
|
|
1167
1168
|
operation: OP_UPSERT_NAME,
|
|
1168
1169
|
method: "POST",
|
|
@@ -1188,7 +1189,7 @@ function createDryRun(http, body, owner) {
|
|
|
1188
1189
|
"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"
|
|
1189
1190
|
);
|
|
1190
1191
|
}
|
|
1191
|
-
return
|
|
1192
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
1192
1193
|
{
|
|
1193
1194
|
operation: OP_UPSERT_NAME,
|
|
1194
1195
|
method: "POST",
|
|
@@ -1233,8 +1234,8 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1233
1234
|
sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
|
|
1234
1235
|
};
|
|
1235
1236
|
} catch (err) {
|
|
1236
|
-
if (!
|
|
1237
|
-
const named = (_nullishCoalesce(
|
|
1237
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1238
|
+
const named = (_nullishCoalesce(_chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
1238
1239
|
const seen = /* @__PURE__ */ new Set();
|
|
1239
1240
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
1240
1241
|
const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -1248,7 +1249,7 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1248
1249
|
}
|
|
1249
1250
|
continue;
|
|
1250
1251
|
}
|
|
1251
|
-
const detail =
|
|
1252
|
+
const detail = _chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
1252
1253
|
throw new CompanyCreateFailedError(
|
|
1253
1254
|
`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}` : ""}`,
|
|
1254
1255
|
unique,
|
|
@@ -1322,7 +1323,7 @@ async function readFields(http, fresh) {
|
|
|
1322
1323
|
const res = await http.request({ method: "GET", path: "/V1.0/Tickets/entityInformation/fields", operation: OP, maxRetries: 0 });
|
|
1323
1324
|
const fields = _optionalChain([res, 'optionalAccess', _21 => _21.fields]);
|
|
1324
1325
|
if (!Array.isArray(fields)) {
|
|
1325
|
-
throw new (0,
|
|
1326
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskError)("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
1326
1327
|
}
|
|
1327
1328
|
_optionalChain([cache, 'optionalAccess', _22 => _22.set, 'call', _23 => _23(key, "fields", fields)]);
|
|
1328
1329
|
return fields;
|
|
@@ -1341,7 +1342,7 @@ async function resolveTicketStatusSemantics(http, opts = {}) {
|
|
|
1341
1342
|
if (opts.excludeStatusIds !== void 0) {
|
|
1342
1343
|
const closedIds2 = [...new Set(opts.excludeStatusIds.map((id) => Number(id)))];
|
|
1343
1344
|
if (closedIds2.length === 0 || closedIds2.some((id) => !Number.isSafeInteger(id) || id < 1)) {
|
|
1344
|
-
throw new (0,
|
|
1345
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`excludeStatusIds must be a non-empty list of positive status ids (got ${JSON.stringify(opts.excludeStatusIds)})`, { operation: OP });
|
|
1345
1346
|
}
|
|
1346
1347
|
return { picklist: [], closedIds: closedIds2, source: "picklist", note: `closed = status ${closedIds2.join(", ")} \u2014 supplied by the caller` };
|
|
1347
1348
|
}
|
|
@@ -1349,7 +1350,7 @@ async function resolveTicketStatusSemantics(http, opts = {}) {
|
|
|
1349
1350
|
try {
|
|
1350
1351
|
fields = await readFields(http, opts.fresh === true);
|
|
1351
1352
|
} catch (e) {
|
|
1352
|
-
if (e instanceof
|
|
1353
|
+
if (e instanceof _chunk4QN43TRPcjs.AutotaskError && e.code === "ABORTED") throw e;
|
|
1353
1354
|
return assumed();
|
|
1354
1355
|
}
|
|
1355
1356
|
const picklist = picklistOf(fields);
|
|
@@ -1385,30 +1386,30 @@ var LOCATION_LIMIT_MAX = 500;
|
|
|
1385
1386
|
function locationLimit(value) {
|
|
1386
1387
|
if (value === void 0) return PROFILE_PART_LIMIT;
|
|
1387
1388
|
if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
|
|
1388
|
-
throw new (0,
|
|
1389
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
|
|
1389
1390
|
}
|
|
1390
1391
|
return value;
|
|
1391
1392
|
}
|
|
1392
1393
|
function validateProjection(fields) {
|
|
1393
1394
|
if (fields === void 0) return {};
|
|
1394
1395
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
|
|
1395
|
-
throw new (0,
|
|
1396
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
|
|
1396
1397
|
}
|
|
1397
1398
|
const out = {};
|
|
1398
1399
|
for (const [part, list] of Object.entries(fields)) {
|
|
1399
1400
|
if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
|
|
1400
|
-
throw new (0,
|
|
1401
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
|
|
1401
1402
|
}
|
|
1402
1403
|
if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
|
|
1403
|
-
throw new (0,
|
|
1404
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
|
|
1404
1405
|
}
|
|
1405
1406
|
const names = [...new Set(list)];
|
|
1406
1407
|
const entity = PART_ENTITY[part];
|
|
1407
|
-
const known = _nullishCoalesce(
|
|
1408
|
+
const known = _nullishCoalesce(_chunk4QN43TRPcjs.MODEL_FIELD_SETS[entity], () => ( []));
|
|
1408
1409
|
const unknown = names.filter((n) => !known.includes(n));
|
|
1409
1410
|
if (unknown.length > 0) {
|
|
1410
|
-
throw new (0,
|
|
1411
|
-
`fullProfile: fields.${part} has unknown field name(s) ${
|
|
1411
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
1412
|
+
`fullProfile: fields.${part} has unknown field name(s) ${_chunk4QN43TRPcjs.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`
|
|
1412
1413
|
);
|
|
1413
1414
|
}
|
|
1414
1415
|
out[part] = names;
|
|
@@ -1425,7 +1426,7 @@ function project(items, names) {
|
|
|
1425
1426
|
function profilePartLimit(value, name) {
|
|
1426
1427
|
const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
|
|
1427
1428
|
if (!Number.isInteger(n) || n < 1) {
|
|
1428
|
-
throw new (0,
|
|
1429
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1429
1430
|
}
|
|
1430
1431
|
return n;
|
|
1431
1432
|
}
|
|
@@ -1437,7 +1438,7 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
|
|
|
1437
1438
|
body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
|
|
1438
1439
|
operation: "companies.fullProfile"
|
|
1439
1440
|
});
|
|
1440
|
-
return project(
|
|
1441
|
+
return project(_chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1441
1442
|
}
|
|
1442
1443
|
async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
1443
1444
|
const semantics = await resolveTicketStatusSemantics(http);
|
|
@@ -1454,7 +1455,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1454
1455
|
},
|
|
1455
1456
|
operation: "companies.fullProfile"
|
|
1456
1457
|
});
|
|
1457
|
-
return project(
|
|
1458
|
+
return project(_chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1458
1459
|
})();
|
|
1459
1460
|
const closedStatus = { closedIds: semantics.closedIds, source: semantics.source, note: semantics.note };
|
|
1460
1461
|
const partNote = semantics.source === "assumed" ? OPEN_TICKETS_NOTE : semantics.note;
|
|
@@ -1466,7 +1467,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1466
1467
|
closedStatus
|
|
1467
1468
|
};
|
|
1468
1469
|
if (openRows.length === 0) {
|
|
1469
|
-
const stamp =
|
|
1470
|
+
const stamp = _chunk4QN43TRPcjs.blindStampFor.call(void 0, _optionalChain([_chunk4QN43TRPcjs.BLIND_SURFACE_STAMPS, 'access', _24 => _24["tickets"], 'optionalAccess', _25 => _25.query]), [{ field: "companyID", op: "eq", value: companyID }, openLeaf]);
|
|
1470
1471
|
if (stamp !== void 0) {
|
|
1471
1472
|
openTickets = {
|
|
1472
1473
|
items: openRows,
|
|
@@ -1481,7 +1482,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1481
1482
|
return openTickets;
|
|
1482
1483
|
}
|
|
1483
1484
|
async function addProfileNames(http, company, openTickets, projects, result, opts) {
|
|
1484
|
-
const builder =
|
|
1485
|
+
const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS);
|
|
1485
1486
|
const c = company;
|
|
1486
1487
|
builder.addResource(c["ownerResourceID"]);
|
|
1487
1488
|
builder.addResource(c["createdByResourceID"]);
|
|
@@ -1498,20 +1499,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1498
1499
|
builder.addResource(r["creatorResourceID"]);
|
|
1499
1500
|
builder.addFk("contract", r["contractID"]);
|
|
1500
1501
|
}
|
|
1501
|
-
const names = await
|
|
1502
|
+
const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1502
1503
|
const companyRow = { ...company };
|
|
1503
|
-
|
|
1504
|
-
|
|
1504
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1505
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
|
|
1505
1506
|
result.company = companyRow;
|
|
1506
1507
|
result.openTickets = {
|
|
1507
1508
|
...openTickets,
|
|
1508
1509
|
items: openTickets.items.map((row) => {
|
|
1509
1510
|
const r = { ...row };
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
for (const f of
|
|
1511
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1512
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1513
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1514
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1515
|
+
for (const f of _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS) _chunk4QN43TRPcjs.addLabelSibling.call(void 0, r, f, names);
|
|
1515
1516
|
return r;
|
|
1516
1517
|
})
|
|
1517
1518
|
};
|
|
@@ -1519,9 +1520,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1519
1520
|
...result.projects,
|
|
1520
1521
|
items: result.projects.items.map((row) => {
|
|
1521
1522
|
const r = { ...row };
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1523
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1524
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1525
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1525
1526
|
return r;
|
|
1526
1527
|
})
|
|
1527
1528
|
};
|
|
@@ -1534,7 +1535,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1534
1535
|
const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
|
|
1535
1536
|
const locLimit = locationLimit(opts.locationLimit);
|
|
1536
1537
|
const proj = validateProjection(opts.fields);
|
|
1537
|
-
const companyID =
|
|
1538
|
+
const companyID = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
1538
1539
|
const company = await resource.get(companyID);
|
|
1539
1540
|
const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
|
|
1540
1541
|
const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
|
|
@@ -1561,6 +1562,151 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1561
1562
|
return result;
|
|
1562
1563
|
}
|
|
1563
1564
|
|
|
1565
|
+
// src/resources/special/companies/prepareCrmWrite.ts
|
|
1566
|
+
var FREEMAIL = /* @__PURE__ */ new Set(["gmail.com", "googlemail.com", "outlook.com", "hotmail.com", "live.com", "yahoo.com", "yahoo.com.au", "icloud.com", "bigpond.com", "optusnet.com.au", "me.com", "proton.me", "protonmail.com"]);
|
|
1567
|
+
var LIMIT = 10;
|
|
1568
|
+
var OP2 = "companies.prepareCrmWrite";
|
|
1569
|
+
async function readRows(http, path, filter) {
|
|
1570
|
+
const res = await http.request({ method: "POST", idempotent: true, path, body: { MaxRecords: LIMIT * 5, filter }, operation: OP2 });
|
|
1571
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
1572
|
+
}
|
|
1573
|
+
var str = (v) => typeof v === "string" && v !== "" ? v : null;
|
|
1574
|
+
var bool = (v) => typeof v === "boolean" ? v : null;
|
|
1575
|
+
var norm = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, " ").replace(/\b(pty|ltd|limited|inc|llc)\b/g, "").replace(/\s+/g, " ").trim();
|
|
1576
|
+
function domainOf(input) {
|
|
1577
|
+
if (!input) return null;
|
|
1578
|
+
const host = _nullishCoalesce(input.trim().toLowerCase().replace(/^[a-z]+:\/\//, "").replace(/^.*@/, "").replace(/^www\./, "").split(/[/?#:]/)[0], () => ( ""));
|
|
1579
|
+
return host.includes(".") && !FREEMAIL.has(host) ? host : null;
|
|
1580
|
+
}
|
|
1581
|
+
function candidate(r) {
|
|
1582
|
+
return { id: r.id, companyName: str(r.companyName), webAddress: str(r.webAddress), phone: str(r.phone), isActive: bool(r.isActive) };
|
|
1583
|
+
}
|
|
1584
|
+
function has(v) {
|
|
1585
|
+
return v !== void 0 && v !== null && v !== "";
|
|
1586
|
+
}
|
|
1587
|
+
async function prepareCrmWrite(resource, input, http) {
|
|
1588
|
+
const intents = ["create_company", "add_contact", "update_contact", "update_company"];
|
|
1589
|
+
if (!input || !intents.includes(input.intent)) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`prepareCrmWrite: intent must be one of ${intents.join(", ")}`);
|
|
1590
|
+
const co = _nullishCoalesce(input.company, () => ( {}));
|
|
1591
|
+
const ct = _nullishCoalesce(input.contact, () => ( {}));
|
|
1592
|
+
const caveats = [
|
|
1593
|
+
"Companies, resources and countries are blind surfaces on some tenants: a miss is not proof a record is absent, and owner / country candidates are lookups, not lists.",
|
|
1594
|
+
"Company name matching is `contains` (exact names ranked first); there is no semantic search in the SDK."
|
|
1595
|
+
];
|
|
1596
|
+
const needsInput = [];
|
|
1597
|
+
let candidates = [];
|
|
1598
|
+
let matchedBy = null;
|
|
1599
|
+
let searched = false;
|
|
1600
|
+
if (has(co.id)) {
|
|
1601
|
+
searched = true;
|
|
1602
|
+
const rows = await readRows(http, "/V1.0/Companies/query", [{ field: "id", op: "eq", value: co.id }]);
|
|
1603
|
+
candidates = rows.map(candidate);
|
|
1604
|
+
matchedBy = candidates.length ? "id" : null;
|
|
1605
|
+
}
|
|
1606
|
+
const domain = _nullishCoalesce(_nullishCoalesce(domainOf(co.domain), () => ( domainOf(co.website))), () => ( domainOf(ct.emailAddress)));
|
|
1607
|
+
if (candidates.length === 0 && domain) {
|
|
1608
|
+
searched = true;
|
|
1609
|
+
candidates = (await resource.searchByDomain(domain, { limit: LIMIT })).map((c) => candidate(c));
|
|
1610
|
+
matchedBy = candidates.length ? "domain" : null;
|
|
1611
|
+
}
|
|
1612
|
+
if (candidates.length === 0 && has(co.companyName)) {
|
|
1613
|
+
searched = true;
|
|
1614
|
+
const rows = (await resource.searchByIdentity({ companyName: co.companyName }, { limit: LIMIT })).map((c) => candidate(c));
|
|
1615
|
+
const want = norm(co.companyName);
|
|
1616
|
+
const exact = rows.filter((r) => r.companyName !== null && norm(r.companyName) === want);
|
|
1617
|
+
candidates = exact.length ? exact : rows;
|
|
1618
|
+
matchedBy = candidates.length ? exact.length ? "name_exact" : "name_contains" : null;
|
|
1619
|
+
}
|
|
1620
|
+
const status = !searched ? "not_searched" : candidates.length === 0 ? "none" : candidates.length === 1 ? "matched" : "ambiguous";
|
|
1621
|
+
const companyID = status === "matched" ? candidates[0].id : null;
|
|
1622
|
+
const company = { status, matchedBy, candidates };
|
|
1623
|
+
if (status === "ambiguous") {
|
|
1624
|
+
needsInput.push({ field: "company", why: `${candidates.length} companies match; choose one`, source: "policy", lookup: { candidates: candidates.map((c) => ({ id: c.id, companyName: c.companyName })) }, research: "ask" });
|
|
1625
|
+
}
|
|
1626
|
+
if (status === "none" && input.intent !== "create_company") {
|
|
1627
|
+
needsInput.push({ field: "company", why: "no company matched; give a company id, name or domain, or use intent create_company (a miss is not proof of absence)", source: "policy", research: "ask" });
|
|
1628
|
+
}
|
|
1629
|
+
if (status === "not_searched" && input.intent !== "create_company") {
|
|
1630
|
+
needsInput.push({ field: "company", why: "give a company id, name, domain/website or a contact email to search by", source: "policy", research: "ask" });
|
|
1631
|
+
}
|
|
1632
|
+
let locations = null;
|
|
1633
|
+
if (companyID !== null) {
|
|
1634
|
+
const rows = await readRows(http, "/V1.0/CompanyLocations/query", [{ field: "companyID", op: "eq", value: companyID }]);
|
|
1635
|
+
const items = rows.map((r) => ({ id: r.id, name: str(r.name), isPrimary: bool(r.isPrimary), isActive: bool(r.isActive), city: str(r.city), state: str(r.state), postalCode: str(r.postalCode) }));
|
|
1636
|
+
const active = items.filter((l) => l.isActive !== false);
|
|
1637
|
+
const m = active.filter((l) => has(ct.city) && _optionalChain([l, 'access', _26 => _26.city, 'optionalAccess', _27 => _27.toLowerCase, 'call', _28 => _28()]) === String(ct.city).toLowerCase() || has(ct.postalCode) && l.postalCode === String(ct.postalCode));
|
|
1638
|
+
const pick = has(ct.companyLocationID) ? { rule: "matched", locationID: ct.companyLocationID } : active.length === 1 ? { rule: "single", locationID: active[0].id } : active.length > 1 && m.length === 1 ? { rule: "matched", locationID: m[0].id } : active.length > 1 ? { rule: "ask", locationID: null } : { rule: "none", locationID: null };
|
|
1639
|
+
locations = { items, pick };
|
|
1640
|
+
if (input.intent === "add_contact" && pick.locationID === null) {
|
|
1641
|
+
needsInput.push({
|
|
1642
|
+
field: "companyLocationID",
|
|
1643
|
+
why: active.length > 1 ? "the company has several active locations; do not guess" : "the company has no active location; create or reactivate one first",
|
|
1644
|
+
source: "policy",
|
|
1645
|
+
lookup: { candidates: active.map((l) => ({ id: l.id, name: l.name, isPrimary: l.isPrimary })) },
|
|
1646
|
+
research: "ask"
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
let contacts = null;
|
|
1651
|
+
if (input.intent !== "create_company" && (has(ct.emailAddress) || has(ct.firstName) && has(ct.lastName) || has(ct.id))) {
|
|
1652
|
+
const pickFields = (r) => ({ id: r.id, firstName: r.firstName, lastName: r.lastName, emailAddress: r.emailAddress, companyID: r.companyID, companyLocationID: r.companyLocationID, isActive: r.isActive });
|
|
1653
|
+
let rows = [];
|
|
1654
|
+
let by = null;
|
|
1655
|
+
if (has(ct.id)) rows = await readRows(http, "/V1.0/Contacts/query", [{ field: "id", op: "eq", value: ct.id }]);
|
|
1656
|
+
else if (has(ct.emailAddress)) {
|
|
1657
|
+
rows = await readRows(http, "/V1.0/Contacts/query", [{ field: "emailAddress", op: "eq", value: ct.emailAddress }]);
|
|
1658
|
+
by = rows.length ? "email" : null;
|
|
1659
|
+
}
|
|
1660
|
+
if (rows.length === 0 && has(ct.firstName) && has(ct.lastName)) {
|
|
1661
|
+
const f = [{ field: "firstName", op: "eq", value: ct.firstName }, { field: "lastName", op: "eq", value: ct.lastName }];
|
|
1662
|
+
if (companyID !== null) f.push({ field: "companyID", op: "eq", value: companyID });
|
|
1663
|
+
rows = await readRows(http, "/V1.0/Contacts/query", f);
|
|
1664
|
+
by = rows.length ? "name" : null;
|
|
1665
|
+
}
|
|
1666
|
+
contacts = { duplicates: rows.slice(0, LIMIT).map(pickFields), matchedBy: by };
|
|
1667
|
+
if (input.intent === "update_contact" && rows.length === 0) {
|
|
1668
|
+
needsInput.push({ field: "contact", why: "no contact matched; give a contact id or email", source: "policy", research: "ask" });
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
if (input.intent === "create_company" && status !== "matched") {
|
|
1672
|
+
const eff = _chunk4QN43TRPcjs.effectiveRequiredFields.call(void 0, null, _optionalChain([_chunk4QN43TRPcjs.RELATIONSHIP_MAP, 'access', _29 => _29.companies, 'optionalAccess', _30 => _30.zoneFacts]));
|
|
1673
|
+
const research = (f) => ["companyType", "ownerResourceID", "countryID"].includes(f) ? "lookup" : "web_if_available_else_ask";
|
|
1674
|
+
const lookups = {
|
|
1675
|
+
companyType: { via: "operations.fieldCatalog", resource: "companies", field: "companyType", labels: true, note: "map the user wording to one returned label; never hardcode ids" },
|
|
1676
|
+
ownerResourceID: { via: "resources.get / the staff resolver", note: "owners cannot be enumerated on a blind surface: take a known resource id and confirm it with resources.get" },
|
|
1677
|
+
countryID: { via: "countries.query", note: "resolve the country name to an id; never guess" }
|
|
1678
|
+
};
|
|
1679
|
+
const wanted = [
|
|
1680
|
+
...eff.fields.filter((f) => f !== "isActive").map((f) => [f, "live-proven"]),
|
|
1681
|
+
...["address1", "city", "state", "postalCode", "countryID"].map((f) => [f, "policy"])
|
|
1682
|
+
];
|
|
1683
|
+
for (const [f, source] of wanted) {
|
|
1684
|
+
if (has(co[f]) || needsInput.some((n) => n.field === f)) continue;
|
|
1685
|
+
needsInput.push({ field: f, why: source === "policy" ? `CRM policy: a new company needs ${f} (the vendor auto-creates a "Primary Address" location from it)` : `the vendor requires ${f} to create a company`, source, ...lookups[f] ? { lookup: lookups[f] } : {}, research: research(f) });
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
if (input.intent === "add_contact") {
|
|
1689
|
+
for (const f of ["firstName", "lastName"]) if (!has(ct[f])) needsInput.push({ field: f, why: `the vendor requires contact ${f}`, source: "live-proven", research: "ask" });
|
|
1690
|
+
if (!has(ct.emailAddress) && !has(ct.phone) && !has(ct.mobilePhone)) needsInput.push({ field: "emailAddress", why: "CRM policy: a contact needs an email or a phone number", source: "policy", research: "ask" });
|
|
1691
|
+
}
|
|
1692
|
+
let next = null;
|
|
1693
|
+
const isInactive = (d) => d.isActive === false || d.isActive === 0;
|
|
1694
|
+
const dups = _nullishCoalesce(_optionalChain([contacts, 'optionalAccess', _31 => _31.duplicates]), () => ( []));
|
|
1695
|
+
const sameCompany = companyID === null ? dups : dups.filter((d) => d.companyID === companyID);
|
|
1696
|
+
const elsewhere = companyID === null ? [] : dups.filter((d) => d.companyID !== companyID && !isInactive(d));
|
|
1697
|
+
if (input.intent === "add_contact" && sameCompany.length === 0 && elsewhere.length > 0) {
|
|
1698
|
+
needsInput.push({ field: "contact", why: `a contact with this ${_nullishCoalesce(_optionalChain([contacts, 'optionalAccess', _32 => _32.matchedBy]), () => ( "identity"))} is active at another company: update it, move it with contacts.moveToCompany, or confirm a second record`, source: "policy", lookup: { duplicates: elsewhere }, research: "ask" });
|
|
1699
|
+
}
|
|
1700
|
+
if (needsInput.length === 0) {
|
|
1701
|
+
const dup = sameCompany[0];
|
|
1702
|
+
if (input.intent === "create_company") next = status === "matched" ? { operation: "companies.update", note: "the company already exists: update it instead of creating" } : { operation: "companies.create", note: 'then re-run with intent add_contact: the vendor auto-creates a "Primary Address" location (rename it with company_locations.update; locations cannot be deleted via the API)' };
|
|
1703
|
+
else if (input.intent === "add_contact") next = dup ? { operation: "contacts.update", note: `a contact already matches by ${_nullishCoalesce(_optionalChain([contacts, 'optionalAccess', _33 => _33.matchedBy]), () => ( "id"))} (id ${String(dup.id)}): update it, or move it with contacts.moveToCompany if it belongs to another company` } : { operation: "contacts.create", note: `set companyID ${String(companyID)} and companyLocationID ${String(_optionalChain([locations, 'optionalAccess', _34 => _34.pick, 'access', _35 => _35.locationID]))}` };
|
|
1704
|
+
else if (input.intent === "update_contact") next = { operation: "contacts.update", note: "send only the changed fields" };
|
|
1705
|
+
else next = { operation: "companies.update", note: "send only the changed fields" };
|
|
1706
|
+
}
|
|
1707
|
+
return { intent: input.intent, company, locations, contacts, needsInput, next, caveats };
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1564
1710
|
// src/resources/special/companies/unbilledWorkTypes.ts
|
|
1565
1711
|
var UNBILLED_WORK_NOTE_CHARS_DEFAULT = 400;
|
|
1566
1712
|
var UNBILLED_WORK_JOIN_SET_CAP = 300;
|
|
@@ -1581,7 +1727,7 @@ var UNBILLED_WORK_OPT_KEYS = [
|
|
|
1581
1727
|
var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
|
|
1582
1728
|
function validateUnbilledWorkOptions(companyId, opts) {
|
|
1583
1729
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1584
|
-
throw new (0,
|
|
1730
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
1585
1731
|
`unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
1586
1732
|
{ operation: "companies.unbilledWork" }
|
|
1587
1733
|
);
|
|
@@ -1610,7 +1756,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1610
1756
|
try {
|
|
1611
1757
|
limit = clampLimit(opts.limit);
|
|
1612
1758
|
} catch (err) {
|
|
1613
|
-
problems.push(err instanceof
|
|
1759
|
+
problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1614
1760
|
limit = 50;
|
|
1615
1761
|
}
|
|
1616
1762
|
if (source === "date_range") {
|
|
@@ -1625,9 +1771,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1625
1771
|
problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
|
|
1626
1772
|
} else {
|
|
1627
1773
|
try {
|
|
1628
|
-
|
|
1774
|
+
_chunk4QN43TRPcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1629
1775
|
} catch (err) {
|
|
1630
|
-
problems.push(err instanceof
|
|
1776
|
+
problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
|
|
1631
1777
|
}
|
|
1632
1778
|
}
|
|
1633
1779
|
}
|
|
@@ -1637,20 +1783,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1637
1783
|
} else {
|
|
1638
1784
|
opts.ticketIds.forEach((tid, i) => {
|
|
1639
1785
|
try {
|
|
1640
|
-
|
|
1786
|
+
_chunk4QN43TRPcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1641
1787
|
} catch (err) {
|
|
1642
|
-
problems.push(err instanceof
|
|
1788
|
+
problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1643
1789
|
}
|
|
1644
1790
|
});
|
|
1645
1791
|
}
|
|
1646
1792
|
}
|
|
1647
1793
|
try {
|
|
1648
|
-
|
|
1794
|
+
_chunk4QN43TRPcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1649
1795
|
} catch (err) {
|
|
1650
|
-
problems.push(err instanceof
|
|
1796
|
+
problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
|
|
1651
1797
|
}
|
|
1652
1798
|
if (problems.length > 0) {
|
|
1653
|
-
throw new (0,
|
|
1799
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
1654
1800
|
`unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
1655
1801
|
- ` + problems.join("\n- "),
|
|
1656
1802
|
{ operation: "companies.unbilledWork" }
|
|
@@ -1671,7 +1817,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1671
1817
|
}
|
|
1672
1818
|
|
|
1673
1819
|
// src/resources/special/companies/unbilledWork.ts
|
|
1674
|
-
var
|
|
1820
|
+
var OP3 = "companies.unbilledWork";
|
|
1675
1821
|
function capJoinSet(ids2, cap) {
|
|
1676
1822
|
const sorted = [...new Set(ids2)].sort((a, b) => a - b);
|
|
1677
1823
|
if (sorted.length <= cap) return { ids: sorted, truncated: false };
|
|
@@ -1679,7 +1825,7 @@ function capJoinSet(ids2, cap) {
|
|
|
1679
1825
|
}
|
|
1680
1826
|
function unbilledWorkPartStatus(key, conditions, items) {
|
|
1681
1827
|
if (items.length !== 0) return { status: "ok" };
|
|
1682
|
-
const stamp =
|
|
1828
|
+
const stamp = _chunk4QN43TRPcjs.blindStampFor.call(void 0, _optionalChain([_chunk4QN43TRPcjs.BLIND_SURFACE_STAMPS, 'access', _36 => _36[key], 'optionalAccess', _37 => _37.query]), conditions);
|
|
1683
1829
|
if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
|
|
1684
1830
|
return {
|
|
1685
1831
|
status: "ok",
|
|
@@ -1699,7 +1845,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1699
1845
|
parentStatus = "ok";
|
|
1700
1846
|
companyIds.push(num(parent.id));
|
|
1701
1847
|
} catch (err) {
|
|
1702
|
-
if (err instanceof
|
|
1848
|
+
if (err instanceof _chunk4QN43TRPcjs.NotFoundError) parent = null;
|
|
1703
1849
|
else throw err;
|
|
1704
1850
|
}
|
|
1705
1851
|
}
|
|
@@ -1708,14 +1854,14 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1708
1854
|
}
|
|
1709
1855
|
async function readJoinSets(http, companyIds, v) {
|
|
1710
1856
|
const ticketsCond = [{ field: "companyID", op: "in", value: companyIds }];
|
|
1711
|
-
const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit,
|
|
1857
|
+
const ticketsRaw = await boundedPart(http, "/V1.0/Tickets/query", ticketsCond, v.limit, OP3);
|
|
1712
1858
|
const projectsCond = [{ field: "companyID", op: "in", value: companyIds }];
|
|
1713
|
-
const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit,
|
|
1859
|
+
const projectsRaw = await boundedPart(http, "/V1.0/Projects/query", projectsCond, v.limit, OP3);
|
|
1714
1860
|
const projectIds = projectsRaw.items.map((p) => num(p.id)).filter((n) => n > 0);
|
|
1715
1861
|
let taskIds = [];
|
|
1716
1862
|
let tasksHasMore = false;
|
|
1717
1863
|
if (projectIds.length > 0) {
|
|
1718
|
-
const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit,
|
|
1864
|
+
const tasksRaw = await boundedPart(http, "/V1.0/Tasks/query", [{ field: "projectID", op: "in", value: projectIds }], v.limit, OP3);
|
|
1719
1865
|
taskIds = tasksRaw.items.map((t) => num(t.id)).filter((n) => n > 0);
|
|
1720
1866
|
tasksHasMore = tasksRaw.hasMore;
|
|
1721
1867
|
}
|
|
@@ -1737,14 +1883,14 @@ async function readBillingPart(http, v, companyIds) {
|
|
|
1737
1883
|
if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
|
|
1738
1884
|
if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
|
|
1739
1885
|
}
|
|
1740
|
-
const billingFields =
|
|
1886
|
+
const billingFields = _chunk4QN43TRPcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
|
|
1741
1887
|
const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
|
|
1742
|
-
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit,
|
|
1888
|
+
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP3, billingIncludeFields);
|
|
1743
1889
|
let billingItems = billingRaw.items;
|
|
1744
1890
|
let billingNoteCharsTruncated = 0;
|
|
1745
1891
|
if (v.includeNotes) {
|
|
1746
|
-
const noteFields = (_nullishCoalesce(
|
|
1747
|
-
[billingItems, billingNoteCharsTruncated] =
|
|
1892
|
+
const noteFields = (_nullishCoalesce(_chunk4QN43TRPcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1893
|
+
[billingItems, billingNoteCharsTruncated] = _chunk4QN43TRPcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
|
|
1748
1894
|
}
|
|
1749
1895
|
const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
|
|
1750
1896
|
const billingItemsPart = {
|
|
@@ -1783,12 +1929,12 @@ async function readTimePart(http, v, join) {
|
|
|
1783
1929
|
if (v.dateFrom !== void 0) timeConditions.push({ field: "dateWorked", op: "gte", value: v.dateFrom });
|
|
1784
1930
|
if (v.dateTo !== void 0) timeConditions.push({ field: "dateWorked", op: "lte", value: v.dateTo });
|
|
1785
1931
|
const timeFields = ["taskID", "ticketID", "hoursWorked", "dateWorked", "id", ...v.includeNotes ? ["summaryNotes"] : []];
|
|
1786
|
-
const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit,
|
|
1932
|
+
const raw = await boundedPart(http, "/V1.0/TimeEntries/query", timeConditions, v.limit, OP3, timeFields);
|
|
1787
1933
|
entries = raw.items;
|
|
1788
1934
|
let cappedItems = entries;
|
|
1789
1935
|
let noteCharsTruncated = 0;
|
|
1790
1936
|
if (v.includeNotes) {
|
|
1791
|
-
[cappedItems, noteCharsTruncated] =
|
|
1937
|
+
[cappedItems, noteCharsTruncated] = _chunk4QN43TRPcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
|
|
1792
1938
|
}
|
|
1793
1939
|
const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
|
|
1794
1940
|
timePart = {
|
|
@@ -1876,7 +2022,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
|
|
|
1876
2022
|
}
|
|
1877
2023
|
async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
1878
2024
|
const v = validateUnbilledWorkOptions(companyId, opts);
|
|
1879
|
-
const id =
|
|
2025
|
+
const id = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1880
2026
|
const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
|
|
1881
2027
|
const join = await readJoinSets(http, companyIds, v);
|
|
1882
2028
|
const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
|
|
@@ -1903,7 +2049,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1903
2049
|
}
|
|
1904
2050
|
|
|
1905
2051
|
// src/resources/companies.ts
|
|
1906
|
-
var CompaniesResource = class extends
|
|
2052
|
+
var CompaniesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
1907
2053
|
constructor(http, pageSize) {
|
|
1908
2054
|
super(http, {
|
|
1909
2055
|
key: "companies",
|
|
@@ -2007,10 +2153,14 @@ var CompaniesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2007
2153
|
unbilledWork(id, opts) {
|
|
2008
2154
|
return unbilledWork(this, id, opts, this.http);
|
|
2009
2155
|
}
|
|
2156
|
+
/** Node-parity special op (hand-written in src/resources/special/companies.ts). */
|
|
2157
|
+
prepareCrmWrite(input) {
|
|
2158
|
+
return prepareCrmWrite(this, input, this.http);
|
|
2159
|
+
}
|
|
2010
2160
|
};
|
|
2011
2161
|
|
|
2012
2162
|
// src/resources/company_alerts.ts
|
|
2013
|
-
var CompanyAlertsResource = class extends
|
|
2163
|
+
var CompanyAlertsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2014
2164
|
constructor(http, pageSize) {
|
|
2015
2165
|
super(http, {
|
|
2016
2166
|
key: "company_alerts",
|
|
@@ -2076,7 +2226,7 @@ var CompanyAlertsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2076
2226
|
};
|
|
2077
2227
|
|
|
2078
2228
|
// src/resources/company_locations.ts
|
|
2079
|
-
var CompanyLocationsResource = class extends
|
|
2229
|
+
var CompanyLocationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2080
2230
|
constructor(http, pageSize) {
|
|
2081
2231
|
super(http, {
|
|
2082
2232
|
key: "company_locations",
|
|
@@ -2142,12 +2292,12 @@ var CompanyLocationsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2142
2292
|
/** Search CompanyLocation records: bounded contains on name (no vendor free-text search exists);
|
|
2143
2293
|
* limit defaults to 25, max 500. */
|
|
2144
2294
|
async search(query, opts) {
|
|
2145
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2295
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _38 => _38.limit]) });
|
|
2146
2296
|
}
|
|
2147
2297
|
};
|
|
2148
2298
|
|
|
2149
2299
|
// src/resources/company_notes.ts
|
|
2150
|
-
var CompanyNotesResource = class extends
|
|
2300
|
+
var CompanyNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2151
2301
|
constructor(http, pageSize) {
|
|
2152
2302
|
super(http, {
|
|
2153
2303
|
key: "company_notes",
|
|
@@ -2207,12 +2357,12 @@ var CompanyNotesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2207
2357
|
/** Search CompanyNote records: bounded contains on name (no vendor free-text search exists);
|
|
2208
2358
|
* limit defaults to 25, max 500. */
|
|
2209
2359
|
async search(query, opts) {
|
|
2210
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2360
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _39 => _39.limit]) });
|
|
2211
2361
|
}
|
|
2212
2362
|
};
|
|
2213
2363
|
|
|
2214
2364
|
// src/resources/company_site_configurations.ts
|
|
2215
|
-
var CompanySiteConfigurationsResource = class extends
|
|
2365
|
+
var CompanySiteConfigurationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2216
2366
|
constructor(http, pageSize) {
|
|
2217
2367
|
super(http, {
|
|
2218
2368
|
key: "company_site_configurations",
|
|
@@ -2263,7 +2413,7 @@ var CompanySiteConfigurationsResource = class extends _chunkIKPFR6K2cjs.BaseReso
|
|
|
2263
2413
|
};
|
|
2264
2414
|
|
|
2265
2415
|
// src/resources/company_webhooks.ts
|
|
2266
|
-
var CompanyWebhooksResource = class extends
|
|
2416
|
+
var CompanyWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2267
2417
|
constructor(http, pageSize) {
|
|
2268
2418
|
super(http, {
|
|
2269
2419
|
key: "company_webhooks",
|
|
@@ -2334,12 +2484,12 @@ var CompanyWebhooksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2334
2484
|
/** Search CompanyWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
2335
2485
|
* limit defaults to 25, max 500. */
|
|
2336
2486
|
async search(query, opts) {
|
|
2337
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2487
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _40 => _40.limit]) });
|
|
2338
2488
|
}
|
|
2339
2489
|
};
|
|
2340
2490
|
|
|
2341
2491
|
// src/resources/configuration_item_billing_product_associations.ts
|
|
2342
|
-
var ConfigurationItemBillingProductAssociationsResource = class extends
|
|
2492
|
+
var ConfigurationItemBillingProductAssociationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2343
2493
|
constructor(http, pageSize) {
|
|
2344
2494
|
super(http, {
|
|
2345
2495
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2405,7 +2555,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkIK
|
|
|
2405
2555
|
};
|
|
2406
2556
|
|
|
2407
2557
|
// src/resources/configuration_item_categories.ts
|
|
2408
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2558
|
+
var ConfigurationItemCategoriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2409
2559
|
constructor(http, pageSize) {
|
|
2410
2560
|
super(http, {
|
|
2411
2561
|
key: "configuration_item_categories",
|
|
@@ -2467,12 +2617,12 @@ var ConfigurationItemCategoriesResource = class extends _chunkIKPFR6K2cjs.BaseRe
|
|
|
2467
2617
|
/** Search ConfigurationItemCategory records: bounded contains on name (no vendor free-text search exists);
|
|
2468
2618
|
* limit defaults to 25, max 500. */
|
|
2469
2619
|
async search(query, opts) {
|
|
2470
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
2620
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _41 => _41.limit]) });
|
|
2471
2621
|
}
|
|
2472
2622
|
};
|
|
2473
2623
|
|
|
2474
2624
|
// src/resources/configuration_item_category_udf_associations.ts
|
|
2475
|
-
var ConfigurationItemCategoryUdfAssociationsResource = class extends
|
|
2625
|
+
var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2476
2626
|
constructor(http, pageSize) {
|
|
2477
2627
|
super(http, {
|
|
2478
2628
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2538,7 +2688,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkIKPFR
|
|
|
2538
2688
|
};
|
|
2539
2689
|
|
|
2540
2690
|
// src/resources/configuration_item_dns_records.ts
|
|
2541
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2691
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2542
2692
|
constructor(http, pageSize) {
|
|
2543
2693
|
super(http, {
|
|
2544
2694
|
key: "configuration_item_dns_records",
|
|
@@ -2587,7 +2737,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkIKPFR6K2cjs.BaseRe
|
|
|
2587
2737
|
};
|
|
2588
2738
|
|
|
2589
2739
|
// src/resources/configuration_item_notes.ts
|
|
2590
|
-
var ConfigurationItemNotesResource = class extends
|
|
2740
|
+
var ConfigurationItemNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2591
2741
|
constructor(http, pageSize) {
|
|
2592
2742
|
super(http, {
|
|
2593
2743
|
key: "configuration_item_notes",
|
|
@@ -2646,7 +2796,7 @@ var ConfigurationItemNotesResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
2646
2796
|
};
|
|
2647
2797
|
|
|
2648
2798
|
// src/resources/configuration_item_related_items.ts
|
|
2649
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2799
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2650
2800
|
constructor(http, pageSize) {
|
|
2651
2801
|
super(http, {
|
|
2652
2802
|
key: "configuration_item_related_items",
|
|
@@ -2704,19 +2854,19 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkIKPFR6K2cjs.Base
|
|
|
2704
2854
|
|
|
2705
2855
|
// src/resources/special/configuration_items.ts
|
|
2706
2856
|
async function fetchRecord(http, path, label, readOpts) {
|
|
2707
|
-
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
2857
|
+
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _42 => _42.maxRetries]) });
|
|
2708
2858
|
const body = res;
|
|
2709
2859
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
2710
|
-
throw new (0,
|
|
2860
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
2711
2861
|
}
|
|
2712
2862
|
return body.item;
|
|
2713
2863
|
}
|
|
2714
2864
|
async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
2715
|
-
const numericSource =
|
|
2716
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
2717
|
-
throw new (0,
|
|
2865
|
+
const numericSource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2866
|
+
if (_optionalChain([opts, 'optionalAccess', _43 => _43.destinationCompanyId]) === void 0) {
|
|
2867
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2718
2868
|
}
|
|
2719
|
-
const destId =
|
|
2869
|
+
const destId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2720
2870
|
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
|
|
2721
2871
|
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
2722
2872
|
const body = { ...source };
|
|
@@ -2726,20 +2876,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2726
2876
|
body.companyID = destId;
|
|
2727
2877
|
body.isActive = true;
|
|
2728
2878
|
if (opts.newReferenceTitle !== void 0) {
|
|
2729
|
-
if (opts.newReferenceTitle.trim() === "") throw new (0,
|
|
2879
|
+
if (opts.newReferenceTitle.trim() === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
|
|
2730
2880
|
body.referenceTitle = opts.newReferenceTitle.trim();
|
|
2731
2881
|
}
|
|
2732
2882
|
if (opts.lastModifiedDate !== void 0) {
|
|
2733
2883
|
const current = source.lastModifiedDate;
|
|
2734
2884
|
if (current !== opts.lastModifiedDate) {
|
|
2735
|
-
throw new (0,
|
|
2885
|
+
throw new (0, _chunk4QN43TRPcjs.StaleObjectError)(
|
|
2736
2886
|
`moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
|
|
2737
2887
|
{ operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
|
|
2738
2888
|
);
|
|
2739
2889
|
}
|
|
2740
2890
|
}
|
|
2741
2891
|
if (opts.dryRun === true) {
|
|
2742
|
-
return
|
|
2892
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
2743
2893
|
operation: "configuration_items.moveConfigurationItem",
|
|
2744
2894
|
method: "POST",
|
|
2745
2895
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2764,7 +2914,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2764
2914
|
const createdBody = created;
|
|
2765
2915
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2766
2916
|
if (typeof newId !== "number") {
|
|
2767
|
-
throw new (0,
|
|
2917
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2768
2918
|
}
|
|
2769
2919
|
let sourceDeactivated = false;
|
|
2770
2920
|
if (opts.deactivateSource !== false) {
|
|
@@ -2783,7 +2933,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2783
2933
|
function profilePartLimit2(value, name) {
|
|
2784
2934
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2785
2935
|
if (!Number.isInteger(n) || n < 1) {
|
|
2786
|
-
throw new (0,
|
|
2936
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2787
2937
|
}
|
|
2788
2938
|
return n;
|
|
2789
2939
|
}
|
|
@@ -2799,14 +2949,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
|
|
|
2799
2949
|
});
|
|
2800
2950
|
const body = res;
|
|
2801
2951
|
if (body === null || !("item" in body)) {
|
|
2802
|
-
throw new (0,
|
|
2952
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2803
2953
|
}
|
|
2804
2954
|
if (body.item === null || body.item === void 0) {
|
|
2805
|
-
throw new (0,
|
|
2955
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2806
2956
|
}
|
|
2807
2957
|
return body.item;
|
|
2808
2958
|
} catch (err) {
|
|
2809
|
-
if (err instanceof
|
|
2959
|
+
if (err instanceof _chunk4QN43TRPcjs.NotFoundError) return null;
|
|
2810
2960
|
throw err;
|
|
2811
2961
|
}
|
|
2812
2962
|
}
|
|
@@ -2818,7 +2968,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2818
2968
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2819
2969
|
operation: "configuration_items.profile"
|
|
2820
2970
|
});
|
|
2821
|
-
return
|
|
2971
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
2822
2972
|
}
|
|
2823
2973
|
async function profile(resource, id, opts = {}, http) {
|
|
2824
2974
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2830,7 +2980,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2830
2980
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2831
2981
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2832
2982
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2833
|
-
const wallQuirk = _optionalChain([
|
|
2983
|
+
const wallQuirk = _optionalChain([_chunk4QN43TRPcjs.RELATIONSHIP_MAP, 'access', _44 => _44["configuration_items"], 'optionalAccess', _45 => _45.zoneFacts, 'optionalAccess', _46 => _46.quirks, 'optionalAccess', _47 => _47.find, 'call', _48 => _48((q) => q.startsWith("product wall"))]);
|
|
2834
2984
|
const productAssociations = {
|
|
2835
2985
|
items: associations,
|
|
2836
2986
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2854,11 +3004,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2854
3004
|
}
|
|
2855
3005
|
};
|
|
2856
3006
|
if (opts.names === true) {
|
|
2857
|
-
const builder =
|
|
3007
|
+
const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, );
|
|
2858
3008
|
builder.addFk("contract", root["contractID"]);
|
|
2859
|
-
const names = await
|
|
3009
|
+
const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2860
3010
|
const ciRow = { ...ci };
|
|
2861
|
-
|
|
3011
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2862
3012
|
result.ci = ciRow;
|
|
2863
3013
|
result.names = names.section;
|
|
2864
3014
|
}
|
|
@@ -2866,7 +3016,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2866
3016
|
}
|
|
2867
3017
|
|
|
2868
3018
|
// src/resources/configuration_items.ts
|
|
2869
|
-
var ConfigurationItemsResource = class extends
|
|
3019
|
+
var ConfigurationItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2870
3020
|
constructor(http, pageSize) {
|
|
2871
3021
|
super(http, {
|
|
2872
3022
|
key: "configuration_items",
|
|
@@ -2932,7 +3082,7 @@ var ConfigurationItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2932
3082
|
/** Search ConfigurationItem records: bounded contains on referenceTitle (no vendor free-text search exists);
|
|
2933
3083
|
* limit defaults to 25, max 500. */
|
|
2934
3084
|
async search(query, opts) {
|
|
2935
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3085
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _49 => _49.limit]) });
|
|
2936
3086
|
}
|
|
2937
3087
|
/** Get the ConfigurationItem with its primary context records in one call (each part a single-record
|
|
2938
3088
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
@@ -2955,7 +3105,7 @@ var ConfigurationItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
2955
3105
|
};
|
|
2956
3106
|
|
|
2957
3107
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2958
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
3108
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
2959
3109
|
constructor(http, pageSize) {
|
|
2960
3110
|
super(http, {
|
|
2961
3111
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -3013,12 +3163,12 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkIK
|
|
|
3013
3163
|
/** Search ConfigurationItemSslSubjectAlternativeName records: bounded contains on name (no vendor free-text search exists);
|
|
3014
3164
|
* limit defaults to 25, max 500. */
|
|
3015
3165
|
async search(query, opts) {
|
|
3016
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3166
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _50 => _50.limit]) });
|
|
3017
3167
|
}
|
|
3018
3168
|
};
|
|
3019
3169
|
|
|
3020
3170
|
// src/resources/configuration_item_types.ts
|
|
3021
|
-
var ConfigurationItemTypesResource = class extends
|
|
3171
|
+
var ConfigurationItemTypesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3022
3172
|
constructor(http, pageSize) {
|
|
3023
3173
|
super(http, {
|
|
3024
3174
|
key: "configuration_item_types",
|
|
@@ -3087,12 +3237,12 @@ var ConfigurationItemTypesResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
3087
3237
|
/** Search ConfigurationItemType records: bounded contains on name (no vendor free-text search exists);
|
|
3088
3238
|
* limit defaults to 25, max 500. */
|
|
3089
3239
|
async search(query, opts) {
|
|
3090
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3240
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _51 => _51.limit]) });
|
|
3091
3241
|
}
|
|
3092
3242
|
};
|
|
3093
3243
|
|
|
3094
3244
|
// src/resources/configuration_item_webhooks.ts
|
|
3095
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
3245
|
+
var ConfigurationItemWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3096
3246
|
constructor(http, pageSize) {
|
|
3097
3247
|
super(http, {
|
|
3098
3248
|
key: "configuration_item_webhooks",
|
|
@@ -3163,12 +3313,12 @@ var ConfigurationItemWebhooksResource = class extends _chunkIKPFR6K2cjs.BaseReso
|
|
|
3163
3313
|
/** Search ConfigurationItemWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
3164
3314
|
* limit defaults to 25, max 500. */
|
|
3165
3315
|
async search(query, opts) {
|
|
3166
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3316
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _52 => _52.limit]) });
|
|
3167
3317
|
}
|
|
3168
3318
|
};
|
|
3169
3319
|
|
|
3170
3320
|
// src/resources/contact_group_contacts.ts
|
|
3171
|
-
var ContactGroupContactsResource = class extends
|
|
3321
|
+
var ContactGroupContactsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3172
3322
|
constructor(http, pageSize) {
|
|
3173
3323
|
super(http, {
|
|
3174
3324
|
key: "contact_group_contacts",
|
|
@@ -3222,7 +3372,7 @@ var ContactGroupContactsResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
3222
3372
|
};
|
|
3223
3373
|
|
|
3224
3374
|
// src/resources/contact_groups.ts
|
|
3225
|
-
var ContactGroupsResource = class extends
|
|
3375
|
+
var ContactGroupsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3226
3376
|
constructor(http, pageSize) {
|
|
3227
3377
|
super(http, {
|
|
3228
3378
|
key: "contact_groups",
|
|
@@ -3291,31 +3441,31 @@ var ContactGroupsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
3291
3441
|
/** Search ContactGroups records: bounded contains on name (no vendor free-text search exists);
|
|
3292
3442
|
* limit defaults to 25, max 500. */
|
|
3293
3443
|
async search(query, opts) {
|
|
3294
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3444
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _53 => _53.limit]) });
|
|
3295
3445
|
}
|
|
3296
3446
|
};
|
|
3297
3447
|
|
|
3298
3448
|
// src/resources/special/contacts.ts
|
|
3299
3449
|
async function fetchRecord2(http, path, label, readOpts) {
|
|
3300
|
-
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
3450
|
+
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _54 => _54.maxRetries]) });
|
|
3301
3451
|
const body = res;
|
|
3302
3452
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3303
|
-
throw new (0,
|
|
3453
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3304
3454
|
}
|
|
3305
3455
|
return body.item;
|
|
3306
3456
|
}
|
|
3307
3457
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3308
|
-
const sourceId =
|
|
3309
|
-
const destId =
|
|
3458
|
+
const sourceId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3459
|
+
const destId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3310
3460
|
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
|
|
3311
3461
|
const companyID = source.companyID;
|
|
3312
3462
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3313
|
-
throw new (0,
|
|
3463
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3314
3464
|
}
|
|
3315
3465
|
if (opts.lastModifiedDate !== void 0) {
|
|
3316
3466
|
const current = source.lastModifiedDate;
|
|
3317
3467
|
if (current !== opts.lastModifiedDate) {
|
|
3318
|
-
throw new (0,
|
|
3468
|
+
throw new (0, _chunk4QN43TRPcjs.StaleObjectError)(
|
|
3319
3469
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3320
3470
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3321
3471
|
);
|
|
@@ -3337,10 +3487,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3337
3487
|
},
|
|
3338
3488
|
operation: "contacts.moveToCompany"
|
|
3339
3489
|
});
|
|
3340
|
-
const items =
|
|
3490
|
+
const items = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
3341
3491
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3342
3492
|
if (clash !== void 0) {
|
|
3343
|
-
throw new (0,
|
|
3493
|
+
throw new (0, _chunk4QN43TRPcjs.ConflictError)(
|
|
3344
3494
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3345
3495
|
{ resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3346
3496
|
);
|
|
@@ -3354,7 +3504,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3354
3504
|
if (opts.dryRun === true) {
|
|
3355
3505
|
const warnings = [];
|
|
3356
3506
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3357
|
-
return
|
|
3507
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
3358
3508
|
operation: "contacts.moveToCompany",
|
|
3359
3509
|
method: "POST",
|
|
3360
3510
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3380,7 +3530,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3380
3530
|
const createdBody = created;
|
|
3381
3531
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3382
3532
|
if (typeof newId !== "number") {
|
|
3383
|
-
throw new (0,
|
|
3533
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3384
3534
|
}
|
|
3385
3535
|
let sourceDeleted = false;
|
|
3386
3536
|
if (opts.deleteSource === true) {
|
|
@@ -3399,7 +3549,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3399
3549
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3400
3550
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3401
3551
|
var DEDUP_LIMIT = 10;
|
|
3402
|
-
var CompanyNotFoundError = class extends
|
|
3552
|
+
var CompanyNotFoundError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
3403
3553
|
constructor(message, options = {}) {
|
|
3404
3554
|
super(message, {
|
|
3405
3555
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3410,7 +3560,7 @@ var CompanyNotFoundError = class extends _chunkIKPFR6K2cjs.AutotaskError {
|
|
|
3410
3560
|
this.name = "CompanyNotFoundError";
|
|
3411
3561
|
}
|
|
3412
3562
|
};
|
|
3413
|
-
var ContactCreateFailedError = class extends
|
|
3563
|
+
var ContactCreateFailedError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
3414
3564
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3415
3565
|
|
|
3416
3566
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3420,25 +3570,25 @@ var ContactCreateFailedError = class extends _chunkIKPFR6K2cjs.AutotaskError {
|
|
|
3420
3570
|
}
|
|
3421
3571
|
};
|
|
3422
3572
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3423
|
-
const cid =
|
|
3573
|
+
const cid = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3424
3574
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3425
|
-
throw new (0,
|
|
3575
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
3426
3576
|
`upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
|
|
3427
3577
|
{ operation: OP_UPSERT_EMAIL }
|
|
3428
3578
|
);
|
|
3429
3579
|
}
|
|
3430
3580
|
if (extra !== void 0) {
|
|
3431
3581
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3432
|
-
throw new (0,
|
|
3582
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
3433
3583
|
`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)})`,
|
|
3434
3584
|
{ operation: OP_UPSERT_EMAIL }
|
|
3435
3585
|
);
|
|
3436
3586
|
}
|
|
3437
3587
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3438
|
-
throw new (0,
|
|
3588
|
+
throw new (0, _chunk4QN43TRPcjs.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 });
|
|
3439
3589
|
}
|
|
3440
3590
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3441
|
-
throw new (0,
|
|
3591
|
+
throw new (0, _chunk4QN43TRPcjs.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 });
|
|
3442
3592
|
}
|
|
3443
3593
|
}
|
|
3444
3594
|
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
|
|
@@ -3459,7 +3609,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3459
3609
|
const match = q.items[0];
|
|
3460
3610
|
if (match !== void 0) {
|
|
3461
3611
|
if (opts.dryRun === true) {
|
|
3462
|
-
return
|
|
3612
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
3463
3613
|
{
|
|
3464
3614
|
operation: OP_UPSERT_EMAIL,
|
|
3465
3615
|
method: "POST",
|
|
@@ -3480,16 +3630,16 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3480
3630
|
return { id: Number(match.id), created: false, existing: match };
|
|
3481
3631
|
}
|
|
3482
3632
|
const localPart = email.split("@")[0];
|
|
3483
|
-
const isActive = _optionalChain([extra, 'optionalAccess',
|
|
3633
|
+
const isActive = _optionalChain([extra, 'optionalAccess', _55 => _55.isActive]) === void 0 ? true : extra.isActive;
|
|
3484
3634
|
const body = {
|
|
3485
3635
|
emailAddress: email,
|
|
3486
3636
|
companyID: cid,
|
|
3487
|
-
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3488
|
-
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3637
|
+
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _56 => _56.firstName]), () => ( localPart)),
|
|
3638
|
+
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _57 => _57.lastName]), () => ( "Unknown")),
|
|
3489
3639
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3490
3640
|
};
|
|
3491
3641
|
if (opts.dryRun === true) {
|
|
3492
|
-
return
|
|
3642
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
3493
3643
|
{
|
|
3494
3644
|
operation: OP_UPSERT_EMAIL,
|
|
3495
3645
|
method: "POST",
|
|
@@ -3512,8 +3662,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3512
3662
|
const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
|
|
3513
3663
|
return { id: created.id, created: true };
|
|
3514
3664
|
} catch (err) {
|
|
3515
|
-
if (!
|
|
3516
|
-
const named = (_nullishCoalesce(
|
|
3665
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3666
|
+
const named = (_nullishCoalesce(_chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3517
3667
|
const seen = /* @__PURE__ */ new Set();
|
|
3518
3668
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3519
3669
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3527,7 +3677,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3527
3677
|
}
|
|
3528
3678
|
continue;
|
|
3529
3679
|
}
|
|
3530
|
-
const detail =
|
|
3680
|
+
const detail = _chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3531
3681
|
throw new ContactCreateFailedError(
|
|
3532
3682
|
`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}` : ""}`,
|
|
3533
3683
|
unique,
|
|
@@ -3544,7 +3694,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3544
3694
|
}
|
|
3545
3695
|
|
|
3546
3696
|
// src/resources/contacts.ts
|
|
3547
|
-
var ContactsResource = class extends
|
|
3697
|
+
var ContactsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3548
3698
|
constructor(http, pageSize) {
|
|
3549
3699
|
super(http, {
|
|
3550
3700
|
key: "contacts",
|
|
@@ -3615,7 +3765,7 @@ var ContactsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
3615
3765
|
/** Search Contact records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
3616
3766
|
* limit defaults to 25, max 500. */
|
|
3617
3767
|
async search(query, opts) {
|
|
3618
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3768
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _58 => _58.limit]) });
|
|
3619
3769
|
}
|
|
3620
3770
|
/** Get the Contact with its primary context records in one call (each part a single-record
|
|
3621
3771
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
@@ -3636,7 +3786,7 @@ var ContactsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
3636
3786
|
};
|
|
3637
3787
|
|
|
3638
3788
|
// src/resources/contact_webhooks.ts
|
|
3639
|
-
var ContactWebhooksResource = class extends
|
|
3789
|
+
var ContactWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3640
3790
|
constructor(http, pageSize) {
|
|
3641
3791
|
super(http, {
|
|
3642
3792
|
key: "contact_webhooks",
|
|
@@ -3707,12 +3857,12 @@ var ContactWebhooksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
3707
3857
|
/** Search ContactWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
3708
3858
|
* limit defaults to 25, max 500. */
|
|
3709
3859
|
async search(query, opts) {
|
|
3710
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
3860
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _59 => _59.limit]) });
|
|
3711
3861
|
}
|
|
3712
3862
|
};
|
|
3713
3863
|
|
|
3714
3864
|
// src/resources/contract_billing_rules.ts
|
|
3715
|
-
var ContractBillingRulesResource = class extends
|
|
3865
|
+
var ContractBillingRulesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3716
3866
|
constructor(http, pageSize) {
|
|
3717
3867
|
super(http, {
|
|
3718
3868
|
key: "contract_billing_rules",
|
|
@@ -3778,7 +3928,7 @@ var ContractBillingRulesResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
3778
3928
|
};
|
|
3779
3929
|
|
|
3780
3930
|
// src/resources/contract_block_hour_factors.ts
|
|
3781
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3931
|
+
var ContractBlockHourFactorsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3782
3932
|
constructor(http, pageSize) {
|
|
3783
3933
|
super(http, {
|
|
3784
3934
|
key: "contract_block_hour_factors",
|
|
@@ -3837,7 +3987,7 @@ var ContractBlockHourFactorsResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
3837
3987
|
};
|
|
3838
3988
|
|
|
3839
3989
|
// src/resources/contract_blocks.ts
|
|
3840
|
-
var ContractBlocksResource = class extends
|
|
3990
|
+
var ContractBlocksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3841
3991
|
constructor(http, pageSize) {
|
|
3842
3992
|
super(http, {
|
|
3843
3993
|
key: "contract_blocks",
|
|
@@ -3896,7 +4046,7 @@ var ContractBlocksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
3896
4046
|
};
|
|
3897
4047
|
|
|
3898
4048
|
// src/resources/contract_charges.ts
|
|
3899
|
-
var ContractChargesResource = class extends
|
|
4049
|
+
var ContractChargesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3900
4050
|
constructor(http, pageSize) {
|
|
3901
4051
|
super(http, {
|
|
3902
4052
|
key: "contract_charges",
|
|
@@ -3962,12 +4112,12 @@ var ContractChargesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
3962
4112
|
/** Search ContractCharge records: bounded contains on name (no vendor free-text search exists);
|
|
3963
4113
|
* limit defaults to 25, max 500. */
|
|
3964
4114
|
async search(query, opts) {
|
|
3965
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
4115
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _60 => _60.limit]) });
|
|
3966
4116
|
}
|
|
3967
4117
|
};
|
|
3968
4118
|
|
|
3969
4119
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3970
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
4120
|
+
var ContractExclusionBillingCodesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
3971
4121
|
constructor(http, pageSize) {
|
|
3972
4122
|
super(http, {
|
|
3973
4123
|
key: "contract_exclusion_billing_codes",
|
|
@@ -4024,7 +4174,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkIKPFR6K2cjs.Base
|
|
|
4024
4174
|
};
|
|
4025
4175
|
|
|
4026
4176
|
// src/resources/contract_exclusion_roles.ts
|
|
4027
|
-
var ContractExclusionRolesResource = class extends
|
|
4177
|
+
var ContractExclusionRolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4028
4178
|
constructor(http, pageSize) {
|
|
4029
4179
|
super(http, {
|
|
4030
4180
|
key: "contract_exclusion_roles",
|
|
@@ -4081,7 +4231,7 @@ var ContractExclusionRolesResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
4081
4231
|
};
|
|
4082
4232
|
|
|
4083
4233
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
4084
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
4234
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4085
4235
|
constructor(http, pageSize) {
|
|
4086
4236
|
super(http, {
|
|
4087
4237
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -4138,7 +4288,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkIKPFR6K2cjs.
|
|
|
4138
4288
|
};
|
|
4139
4289
|
|
|
4140
4290
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
4141
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
4291
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4142
4292
|
constructor(http, pageSize) {
|
|
4143
4293
|
super(http, {
|
|
4144
4294
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -4195,7 +4345,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkIKPFR6K2
|
|
|
4195
4345
|
};
|
|
4196
4346
|
|
|
4197
4347
|
// src/resources/contract_exclusion_sets.ts
|
|
4198
|
-
var ContractExclusionSetsResource = class extends
|
|
4348
|
+
var ContractExclusionSetsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4199
4349
|
constructor(http, pageSize) {
|
|
4200
4350
|
super(http, {
|
|
4201
4351
|
key: "contract_exclusion_sets",
|
|
@@ -4264,12 +4414,12 @@ var ContractExclusionSetsResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
4264
4414
|
/** Search ContractExclusionSets records: bounded contains on name (no vendor free-text search exists);
|
|
4265
4415
|
* limit defaults to 25, max 500. */
|
|
4266
4416
|
async search(query, opts) {
|
|
4267
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
4417
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _61 => _61.limit]) });
|
|
4268
4418
|
}
|
|
4269
4419
|
};
|
|
4270
4420
|
|
|
4271
4421
|
// src/resources/contract_milestones.ts
|
|
4272
|
-
var ContractMilestonesResource = class extends
|
|
4422
|
+
var ContractMilestonesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4273
4423
|
constructor(http, pageSize) {
|
|
4274
4424
|
super(http, {
|
|
4275
4425
|
key: "contract_milestones",
|
|
@@ -4328,7 +4478,7 @@ var ContractMilestonesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
4328
4478
|
};
|
|
4329
4479
|
|
|
4330
4480
|
// src/resources/contract_notes.ts
|
|
4331
|
-
var ContractNotesResource = class extends
|
|
4481
|
+
var ContractNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4332
4482
|
constructor(http, pageSize) {
|
|
4333
4483
|
super(http, {
|
|
4334
4484
|
key: "contract_notes",
|
|
@@ -4387,7 +4537,7 @@ var ContractNotesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
4387
4537
|
};
|
|
4388
4538
|
|
|
4389
4539
|
// src/resources/contract_rates.ts
|
|
4390
|
-
var ContractRatesResource = class extends
|
|
4540
|
+
var ContractRatesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4391
4541
|
constructor(http, pageSize) {
|
|
4392
4542
|
super(http, {
|
|
4393
4543
|
key: "contract_rates",
|
|
@@ -4446,7 +4596,7 @@ var ContractRatesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
4446
4596
|
};
|
|
4447
4597
|
|
|
4448
4598
|
// src/resources/contract_retainers.ts
|
|
4449
|
-
var ContractRetainersResource = class extends
|
|
4599
|
+
var ContractRetainersResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4450
4600
|
constructor(http, pageSize) {
|
|
4451
4601
|
super(http, {
|
|
4452
4602
|
key: "contract_retainers",
|
|
@@ -4505,7 +4655,7 @@ var ContractRetainersResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
4505
4655
|
};
|
|
4506
4656
|
|
|
4507
4657
|
// src/resources/contract_role_costs.ts
|
|
4508
|
-
var ContractRoleCostsResource = class extends
|
|
4658
|
+
var ContractRoleCostsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4509
4659
|
constructor(http, pageSize) {
|
|
4510
4660
|
super(http, {
|
|
4511
4661
|
key: "contract_role_costs",
|
|
@@ -4564,7 +4714,7 @@ var ContractRoleCostsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
4564
4714
|
};
|
|
4565
4715
|
|
|
4566
4716
|
// src/resources/contract_service_adjustments.ts
|
|
4567
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4717
|
+
var ContractServiceAdjustmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4568
4718
|
constructor(http, pageSize) {
|
|
4569
4719
|
super(http, {
|
|
4570
4720
|
key: "contract_service_adjustments",
|
|
@@ -4598,7 +4748,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkIKPFR6K2cjs.BaseRes
|
|
|
4598
4748
|
};
|
|
4599
4749
|
|
|
4600
4750
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4601
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4751
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4602
4752
|
constructor(http, pageSize) {
|
|
4603
4753
|
super(http, {
|
|
4604
4754
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4632,7 +4782,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkIKPFR6K2cjs.B
|
|
|
4632
4782
|
};
|
|
4633
4783
|
|
|
4634
4784
|
// src/resources/contract_service_bundles.ts
|
|
4635
|
-
var ContractServiceBundlesResource = class extends
|
|
4785
|
+
var ContractServiceBundlesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4636
4786
|
constructor(http, pageSize) {
|
|
4637
4787
|
super(http, {
|
|
4638
4788
|
key: "contract_service_bundles",
|
|
@@ -4691,7 +4841,7 @@ var ContractServiceBundlesResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
4691
4841
|
};
|
|
4692
4842
|
|
|
4693
4843
|
// src/resources/contract_service_bundle_units.ts
|
|
4694
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4844
|
+
var ContractServiceBundleUnitsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4695
4845
|
constructor(http, pageSize) {
|
|
4696
4846
|
super(http, {
|
|
4697
4847
|
key: "contract_service_bundle_units",
|
|
@@ -4733,7 +4883,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkIKPFR6K2cjs.BaseRes
|
|
|
4733
4883
|
};
|
|
4734
4884
|
|
|
4735
4885
|
// src/resources/contract_services.ts
|
|
4736
|
-
var ContractServicesResource = class extends
|
|
4886
|
+
var ContractServicesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4737
4887
|
constructor(http, pageSize) {
|
|
4738
4888
|
super(http, {
|
|
4739
4889
|
key: "contract_services",
|
|
@@ -4792,7 +4942,7 @@ var ContractServicesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
4792
4942
|
};
|
|
4793
4943
|
|
|
4794
4944
|
// src/resources/contract_service_units.ts
|
|
4795
|
-
var ContractServiceUnitsResource = class extends
|
|
4945
|
+
var ContractServiceUnitsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
4796
4946
|
constructor(http, pageSize) {
|
|
4797
4947
|
super(http, {
|
|
4798
4948
|
key: "contract_service_units",
|
|
@@ -4834,11 +4984,11 @@ var ContractServiceUnitsResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
4834
4984
|
};
|
|
4835
4985
|
|
|
4836
4986
|
// src/resources/special/contracts/lineOfBusiness.ts
|
|
4837
|
-
var
|
|
4987
|
+
var OP4 = "contracts.lineOfBusiness";
|
|
4838
4988
|
function positiveId(value, name) {
|
|
4839
4989
|
const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
|
|
4840
4990
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
4841
|
-
throw new (0,
|
|
4991
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(OP4 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP4 });
|
|
4842
4992
|
}
|
|
4843
4993
|
return n;
|
|
4844
4994
|
}
|
|
@@ -4852,7 +5002,7 @@ async function lineOfBusiness(resource, contractIdIn, http, associationIdIn) {
|
|
|
4852
5002
|
} else {
|
|
4853
5003
|
associationSource = "contract";
|
|
4854
5004
|
const contract = await resource.get(contractId);
|
|
4855
|
-
associationId =
|
|
5005
|
+
associationId = _chunk4QN43TRPcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
|
|
4856
5006
|
}
|
|
4857
5007
|
if (associationId === void 0) {
|
|
4858
5008
|
return {
|
|
@@ -4864,7 +5014,7 @@ async function lineOfBusiness(resource, contractIdIn, http, associationIdIn) {
|
|
|
4864
5014
|
markers: { association: "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
4865
5015
|
};
|
|
4866
5016
|
}
|
|
4867
|
-
const chain = await
|
|
5017
|
+
const chain = await _chunk4QN43TRPcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP4, onError: "propagate" });
|
|
4868
5018
|
const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
|
|
4869
5019
|
return { contractId, associationSource, association, organizationalLevel2, organizationalLevel1, markers };
|
|
4870
5020
|
}
|
|
@@ -5096,7 +5246,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
|
|
|
5096
5246
|
// src/resources/special/contracts/profitability.validate.ts
|
|
5097
5247
|
function validateProfitabilityOptions(contractId, opts) {
|
|
5098
5248
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
5099
|
-
throw new (0,
|
|
5249
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
5100
5250
|
`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})`,
|
|
5101
5251
|
{ operation: "contracts.profitability" }
|
|
5102
5252
|
);
|
|
@@ -5173,12 +5323,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
5173
5323
|
}
|
|
5174
5324
|
}
|
|
5175
5325
|
try {
|
|
5176
|
-
|
|
5326
|
+
_chunk4QN43TRPcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5177
5327
|
} catch (err) {
|
|
5178
|
-
problems.push(err instanceof
|
|
5328
|
+
problems.push(err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
5179
5329
|
}
|
|
5180
5330
|
if (problems.length > 0) {
|
|
5181
|
-
throw new (0,
|
|
5331
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
5182
5332
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
5183
5333
|
- ` + problems.join("\n- "),
|
|
5184
5334
|
{ operation: "contracts.profitability" }
|
|
@@ -5227,23 +5377,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5227
5377
|
const byKey = /* @__PURE__ */ new Map();
|
|
5228
5378
|
const misses = [];
|
|
5229
5379
|
const notes = [];
|
|
5230
|
-
for (let c = 0; c < unique.length; c +=
|
|
5231
|
-
const chunk = unique.slice(c, c +
|
|
5380
|
+
for (let c = 0; c < unique.length; c += _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
5381
|
+
const chunk = unique.slice(c, c + _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
5232
5382
|
const chunkKeys = new Set(chunk);
|
|
5233
5383
|
try {
|
|
5234
5384
|
const body = {
|
|
5235
|
-
MaxRecords:
|
|
5385
|
+
MaxRecords: _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
5236
5386
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
5237
5387
|
IncludeFields: fields
|
|
5238
5388
|
};
|
|
5239
5389
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
5240
|
-
const { items: rows } =
|
|
5390
|
+
const { items: rows } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, operation);
|
|
5241
5391
|
for (const row of rows) {
|
|
5242
5392
|
const k = num(row.id);
|
|
5243
5393
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
5244
5394
|
}
|
|
5245
5395
|
} catch (err) {
|
|
5246
|
-
const code = err instanceof
|
|
5396
|
+
const code = err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
5247
5397
|
for (const k of chunk) {
|
|
5248
5398
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
5249
5399
|
}
|
|
@@ -5253,11 +5403,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5253
5403
|
for (const k of queryMissed) {
|
|
5254
5404
|
try {
|
|
5255
5405
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
5256
|
-
byKey.set(k,
|
|
5406
|
+
byKey.set(k, _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, k, operation, entity));
|
|
5257
5407
|
} catch (err) {
|
|
5258
|
-
if (err instanceof
|
|
5408
|
+
if (err instanceof _chunk4QN43TRPcjs.NotFoundError) {
|
|
5259
5409
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
5260
|
-
} else if (err instanceof
|
|
5410
|
+
} else if (err instanceof _chunk4QN43TRPcjs.AutotaskError) {
|
|
5261
5411
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
5262
5412
|
} else {
|
|
5263
5413
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -5311,7 +5461,7 @@ async function degradable(read) {
|
|
|
5311
5461
|
try {
|
|
5312
5462
|
return await read();
|
|
5313
5463
|
} catch (err) {
|
|
5314
|
-
if (!(err instanceof
|
|
5464
|
+
if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
|
|
5315
5465
|
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
5316
5466
|
}
|
|
5317
5467
|
}
|
|
@@ -5331,15 +5481,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
|
|
|
5331
5481
|
status: st.status,
|
|
5332
5482
|
blindSurface: st.blindSurface,
|
|
5333
5483
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
5334
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5484
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunk4QN43TRPcjs.EMPTY_REASON_STAMPS, 'access', _62 => _62[key], 'optionalAccess', _63 => _63.query]) : void 0
|
|
5335
5485
|
};
|
|
5336
5486
|
};
|
|
5337
5487
|
function appendWiresNote(wires, note) {
|
|
5338
5488
|
wires.note = (wires.note ? wires.note + " | " : "") + note;
|
|
5339
5489
|
}
|
|
5340
5490
|
function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
5341
|
-
const
|
|
5342
|
-
const id =
|
|
5491
|
+
const OP12 = PROFITABILITY_OP;
|
|
5492
|
+
const id = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5343
5493
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
5344
5494
|
const wires = { issued: 0, requests: 0, budget };
|
|
5345
5495
|
const toExcl = dayAfter(v.dateTo);
|
|
@@ -5350,19 +5500,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
|
5350
5500
|
} };
|
|
5351
5501
|
const readPart = (path, conditions, fields) => {
|
|
5352
5502
|
wires.issued += 1;
|
|
5353
|
-
return degradable(() => boundedPart(http, path, conditions, v.limit,
|
|
5503
|
+
return degradable(() => boundedPart(http, path, conditions, v.limit, OP12, fields));
|
|
5354
5504
|
};
|
|
5355
5505
|
const truncatedMonths = {};
|
|
5356
5506
|
const windowedPart = async (name, key, path, cond, fields, dateField) => {
|
|
5357
5507
|
const first = await readPart(path, cond, fields);
|
|
5358
5508
|
if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
|
|
5359
|
-
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit,
|
|
5509
|
+
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP12, fields, dateField, v.dateFrom, v.dateTo, wires));
|
|
5360
5510
|
if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
|
|
5361
5511
|
const { truncatedMonths: tm, ...part } = wp;
|
|
5362
5512
|
truncatedMonths[name] = tm;
|
|
5363
5513
|
return { part, rows: wp.items };
|
|
5364
5514
|
};
|
|
5365
|
-
return { v, OP:
|
|
5515
|
+
return { v, OP: OP12, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
|
|
5366
5516
|
}
|
|
5367
5517
|
|
|
5368
5518
|
// src/resources/special/contracts/profitability.stages.ts
|
|
@@ -5377,12 +5527,12 @@ async function fetchCustomer(ctx, companyID) {
|
|
|
5377
5527
|
path: `/V1.0/Companies/${companyID}`,
|
|
5378
5528
|
operation: ctx.OP
|
|
5379
5529
|
});
|
|
5380
|
-
const item =
|
|
5530
|
+
const item = _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
|
|
5381
5531
|
customer = _nullishCoalesce(item, () => ( null));
|
|
5382
5532
|
customerStatus = "ok";
|
|
5383
5533
|
} catch (err) {
|
|
5384
|
-
if (!(err instanceof
|
|
5385
|
-
if (!(err instanceof
|
|
5534
|
+
if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
|
|
5535
|
+
if (!(err instanceof _chunk4QN43TRPcjs.NotFoundError)) {
|
|
5386
5536
|
customerStatus = "absent";
|
|
5387
5537
|
customerAbsent = err.code;
|
|
5388
5538
|
}
|
|
@@ -5396,9 +5546,9 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5396
5546
|
if (contractType > 0) {
|
|
5397
5547
|
ctx.wires.issued += 1;
|
|
5398
5548
|
try {
|
|
5399
|
-
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async
|
|
5549
|
+
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _64 => _64.get, 'call', async _65 => _65("contractType"), 'optionalAccess', async _66 => _66.get, 'call', async _67 => _67(contractType)]), async () => ( null));
|
|
5400
5550
|
} catch (err) {
|
|
5401
|
-
if (!(err instanceof
|
|
5551
|
+
if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
|
|
5402
5552
|
}
|
|
5403
5553
|
}
|
|
5404
5554
|
const contractTypeKnown = contractTypeLabel !== null;
|
|
@@ -5407,7 +5557,7 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5407
5557
|
return { contractTypeLabel, contractTypeKnown, isBlockHours, isTimeAndMaterials };
|
|
5408
5558
|
}
|
|
5409
5559
|
async function fetchRoot(ctx, resource) {
|
|
5410
|
-
const contractCached = _optionalChain([ctx, 'access',
|
|
5560
|
+
const contractCached = _optionalChain([ctx, 'access', _68 => _68.rawHttp, 'access', _69 => _69.readCache, 'optionalAccess', _70 => _70.get, 'call', _71 => _71(`/V1.0/Contracts/${ctx.id}`)]) !== void 0;
|
|
5411
5561
|
const contract = await resource.get(ctx.id);
|
|
5412
5562
|
ctx.wires.issued += 1;
|
|
5413
5563
|
if (!contractCached) ctx.wires.requests += 1;
|
|
@@ -5460,8 +5610,8 @@ async function fetchInvoices(ctx, billingRows) {
|
|
|
5460
5610
|
if (invoiceIds.length === 0) {
|
|
5461
5611
|
return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
|
|
5462
5612
|
}
|
|
5463
|
-
const capped = capJoinSet2(invoiceIds,
|
|
5464
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${
|
|
5613
|
+
const capped = capJoinSet2(invoiceIds, _chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5614
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5465
5615
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
|
|
5466
5616
|
ctx.wires.issued += 1;
|
|
5467
5617
|
return {
|
|
@@ -5507,7 +5657,7 @@ async function readOpenStatusSet(ctx) {
|
|
|
5507
5657
|
}
|
|
5508
5658
|
}
|
|
5509
5659
|
} catch (err) {
|
|
5510
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof
|
|
5660
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunk4QN43TRPcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5511
5661
|
}
|
|
5512
5662
|
return { openStatusSet, statusNote };
|
|
5513
5663
|
}
|
|
@@ -5530,8 +5680,8 @@ async function fetchResources(ctx, entries) {
|
|
|
5530
5680
|
if (resourceIds.length === 0) {
|
|
5531
5681
|
return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
|
|
5532
5682
|
}
|
|
5533
|
-
const capped = capJoinSet2(resourceIds,
|
|
5534
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${
|
|
5683
|
+
const capped = capJoinSet2(resourceIds, _chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5684
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5535
5685
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
|
|
5536
5686
|
ctx.wires.issued += 1;
|
|
5537
5687
|
for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
|
|
@@ -5598,7 +5748,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
|
|
|
5598
5748
|
try {
|
|
5599
5749
|
return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
|
|
5600
5750
|
} catch (err) {
|
|
5601
|
-
if (!(err instanceof
|
|
5751
|
+
if (!(err instanceof _chunk4QN43TRPcjs.AutotaskError)) throw err;
|
|
5602
5752
|
return null;
|
|
5603
5753
|
}
|
|
5604
5754
|
}
|
|
@@ -5615,17 +5765,17 @@ async function fetchSubscriptions(ctx, cis) {
|
|
|
5615
5765
|
cancelledSubs
|
|
5616
5766
|
};
|
|
5617
5767
|
}
|
|
5618
|
-
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0),
|
|
5768
|
+
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunk4QN43TRPcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5619
5769
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5620
5770
|
const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5621
5771
|
const subscriptions = raw.items;
|
|
5622
5772
|
const labels = await readSubscriptionLabels(ctx, subscriptions);
|
|
5623
5773
|
for (const x of subscriptions) {
|
|
5624
5774
|
const sid = num(x["id"]);
|
|
5625
|
-
const periodLabel = _optionalChain([labels, 'optionalAccess',
|
|
5775
|
+
const periodLabel = _optionalChain([labels, 'optionalAccess', _72 => _72.get, 'call', _73 => _73("periodType"), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(num(x["periodType"]))]);
|
|
5626
5776
|
subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
|
|
5627
5777
|
if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
|
|
5628
|
-
const statusLabel = _optionalChain([labels, 'optionalAccess',
|
|
5778
|
+
const statusLabel = _optionalChain([labels, 'optionalAccess', _76 => _76.get, 'call', _77 => _77("status"), 'optionalAccess', _78 => _78.get, 'call', _79 => _79(num(x["status"]))]);
|
|
5629
5779
|
const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num(x["status"]));
|
|
5630
5780
|
if (notActive) cancelledSubs.add(sid);
|
|
5631
5781
|
}
|
|
@@ -6300,7 +6450,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
6300
6450
|
}
|
|
6301
6451
|
|
|
6302
6452
|
// src/resources/contracts.ts
|
|
6303
|
-
var ContractsResource = class extends
|
|
6453
|
+
var ContractsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6304
6454
|
constructor(http, pageSize) {
|
|
6305
6455
|
super(http, {
|
|
6306
6456
|
key: "contracts",
|
|
@@ -6362,7 +6512,7 @@ var ContractsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6362
6512
|
/** Search Contract records: bounded contains on contractName (no vendor free-text search exists);
|
|
6363
6513
|
* limit defaults to 25, max 500. */
|
|
6364
6514
|
async search(query, opts) {
|
|
6365
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6515
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _80 => _80.limit]) });
|
|
6366
6516
|
}
|
|
6367
6517
|
/** Node-parity special op (hand-written in src/resources/special/contracts.ts). */
|
|
6368
6518
|
profitability(id, opts) {
|
|
@@ -6375,7 +6525,7 @@ var ContractsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6375
6525
|
};
|
|
6376
6526
|
|
|
6377
6527
|
// src/resources/contract_ticket_purchases.ts
|
|
6378
|
-
var ContractTicketPurchasesResource = class extends
|
|
6528
|
+
var ContractTicketPurchasesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6379
6529
|
constructor(http, pageSize) {
|
|
6380
6530
|
super(http, {
|
|
6381
6531
|
key: "contract_ticket_purchases",
|
|
@@ -6434,7 +6584,7 @@ var ContractTicketPurchasesResource = class extends _chunkIKPFR6K2cjs.BaseResour
|
|
|
6434
6584
|
};
|
|
6435
6585
|
|
|
6436
6586
|
// src/resources/countries.ts
|
|
6437
|
-
var CountriesResource = class extends
|
|
6587
|
+
var CountriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6438
6588
|
constructor(http, pageSize) {
|
|
6439
6589
|
super(http, {
|
|
6440
6590
|
key: "countries",
|
|
@@ -6488,12 +6638,12 @@ var CountriesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6488
6638
|
/** Search Country records: bounded contains on name (no vendor free-text search exists);
|
|
6489
6639
|
* limit defaults to 25, max 500. */
|
|
6490
6640
|
async search(query, opts) {
|
|
6491
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6641
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
|
|
6492
6642
|
}
|
|
6493
6643
|
};
|
|
6494
6644
|
|
|
6495
6645
|
// src/resources/currencies.ts
|
|
6496
|
-
var CurrenciesResource = class extends
|
|
6646
|
+
var CurrenciesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6497
6647
|
constructor(http, pageSize) {
|
|
6498
6648
|
super(http, {
|
|
6499
6649
|
key: "currencies",
|
|
@@ -6532,12 +6682,12 @@ var CurrenciesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6532
6682
|
/** Search Currency records: bounded contains on name (no vendor free-text search exists);
|
|
6533
6683
|
* limit defaults to 25, max 500. */
|
|
6534
6684
|
async search(query, opts) {
|
|
6535
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6685
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
|
|
6536
6686
|
}
|
|
6537
6687
|
};
|
|
6538
6688
|
|
|
6539
6689
|
// src/resources/departments.ts
|
|
6540
|
-
var DepartmentsResource = class extends
|
|
6690
|
+
var DepartmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6541
6691
|
constructor(http, pageSize) {
|
|
6542
6692
|
super(http, {
|
|
6543
6693
|
key: "departments",
|
|
@@ -6599,12 +6749,12 @@ var DepartmentsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6599
6749
|
/** Search Department records: bounded contains on name (no vendor free-text search exists);
|
|
6600
6750
|
* limit defaults to 25, max 500. */
|
|
6601
6751
|
async search(query, opts) {
|
|
6602
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6752
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _83 => _83.limit]) });
|
|
6603
6753
|
}
|
|
6604
6754
|
};
|
|
6605
6755
|
|
|
6606
6756
|
// src/resources/domain_registrars.ts
|
|
6607
|
-
var DomainRegistrarsResource = class extends
|
|
6757
|
+
var DomainRegistrarsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6608
6758
|
constructor(http, pageSize) {
|
|
6609
6759
|
super(http, {
|
|
6610
6760
|
key: "domain_registrars",
|
|
@@ -6666,7 +6816,7 @@ var DomainRegistrarsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6666
6816
|
/** Search DomainRegistrar records: bounded contains on name (no vendor free-text search exists);
|
|
6667
6817
|
* limit defaults to 25, max 500. */
|
|
6668
6818
|
async search(query, opts) {
|
|
6669
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6819
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _84 => _84.limit]) });
|
|
6670
6820
|
}
|
|
6671
6821
|
};
|
|
6672
6822
|
|
|
@@ -6687,7 +6837,7 @@ var EntityInformationResource = class {
|
|
|
6687
6837
|
};
|
|
6688
6838
|
|
|
6689
6839
|
// src/resources/expense_item_attachments.ts
|
|
6690
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6840
|
+
var ExpenseItemAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6691
6841
|
constructor(http, pageSize) {
|
|
6692
6842
|
super(http, {
|
|
6693
6843
|
key: "expense_item_attachments",
|
|
@@ -6749,7 +6899,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
6749
6899
|
};
|
|
6750
6900
|
|
|
6751
6901
|
// src/resources/expense_items.ts
|
|
6752
|
-
var ExpenseItemsResource = class extends
|
|
6902
|
+
var ExpenseItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6753
6903
|
constructor(http, pageSize) {
|
|
6754
6904
|
super(http, {
|
|
6755
6905
|
key: "expense_items",
|
|
@@ -6808,7 +6958,7 @@ var ExpenseItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6808
6958
|
};
|
|
6809
6959
|
|
|
6810
6960
|
// src/resources/expense_reports.ts
|
|
6811
|
-
var ExpenseReportsResource = class extends
|
|
6961
|
+
var ExpenseReportsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6812
6962
|
constructor(http, pageSize) {
|
|
6813
6963
|
super(http, {
|
|
6814
6964
|
key: "expense_reports",
|
|
@@ -6870,12 +7020,12 @@ var ExpenseReportsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6870
7020
|
/** Search ExpenseReport records: bounded contains on name (no vendor free-text search exists);
|
|
6871
7021
|
* limit defaults to 25, max 500. */
|
|
6872
7022
|
async search(query, opts) {
|
|
6873
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7023
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _85 => _85.limit]) });
|
|
6874
7024
|
}
|
|
6875
7025
|
};
|
|
6876
7026
|
|
|
6877
7027
|
// src/resources/holiday_sets.ts
|
|
6878
|
-
var HolidaySetsResource = class extends
|
|
7028
|
+
var HolidaySetsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6879
7029
|
constructor(http, pageSize) {
|
|
6880
7030
|
super(http, {
|
|
6881
7031
|
key: "holiday_sets",
|
|
@@ -6944,7 +7094,7 @@ var HolidaySetsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
6944
7094
|
};
|
|
6945
7095
|
|
|
6946
7096
|
// src/resources/holidays.ts
|
|
6947
|
-
var HolidaysResource = class extends
|
|
7097
|
+
var HolidaysResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
6948
7098
|
constructor(http, pageSize) {
|
|
6949
7099
|
super(http, {
|
|
6950
7100
|
key: "holidays",
|
|
@@ -7016,10 +7166,10 @@ var PATH_SUFFIX = {
|
|
|
7016
7166
|
transfer: "StockedItemsTransfer"
|
|
7017
7167
|
};
|
|
7018
7168
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
7019
|
-
const numericParent =
|
|
7169
|
+
const numericParent = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
7020
7170
|
const suffix = PATH_SUFFIX[kind];
|
|
7021
7171
|
if (opts.dryRun === true) {
|
|
7022
|
-
return
|
|
7172
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
7023
7173
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
7024
7174
|
method: "POST",
|
|
7025
7175
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -7036,11 +7186,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
7036
7186
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
7037
7187
|
maxRetries: opts.maxRetries
|
|
7038
7188
|
});
|
|
7039
|
-
return
|
|
7189
|
+
return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
|
|
7040
7190
|
}
|
|
7041
7191
|
|
|
7042
7192
|
// src/resources/inventory_products.ts
|
|
7043
|
-
var InventoryProductsResource = class extends
|
|
7193
|
+
var InventoryProductsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7044
7194
|
constructor(http, pageSize) {
|
|
7045
7195
|
super(http, {
|
|
7046
7196
|
key: "inventory_products",
|
|
@@ -7122,7 +7272,7 @@ var InventoryProductsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7122
7272
|
|
|
7123
7273
|
// src/resources/special/invoices.ts
|
|
7124
7274
|
async function markup(_resource, id, format, http) {
|
|
7125
|
-
const numericId =
|
|
7275
|
+
const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
7126
7276
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
7127
7277
|
const res = await http.request({
|
|
7128
7278
|
method: "GET",
|
|
@@ -7131,7 +7281,7 @@ async function markup(_resource, id, format, http) {
|
|
|
7131
7281
|
});
|
|
7132
7282
|
const body = res;
|
|
7133
7283
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
7134
|
-
throw new (0,
|
|
7284
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskError)(
|
|
7135
7285
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
7136
7286
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
|
|
7137
7287
|
);
|
|
@@ -7139,44 +7289,44 @@ async function markup(_resource, id, format, http) {
|
|
|
7139
7289
|
return body.invoiceMarkup;
|
|
7140
7290
|
}
|
|
7141
7291
|
async function pdf(_resource, id, http) {
|
|
7142
|
-
const numericId =
|
|
7292
|
+
const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
7143
7293
|
const res = await http.request({
|
|
7144
7294
|
method: "GET",
|
|
7145
7295
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
7146
7296
|
operation: "invoices.pdf"
|
|
7147
7297
|
});
|
|
7148
|
-
return
|
|
7298
|
+
return _chunk4QN43TRPcjs.decodeFileData.call(void 0, res);
|
|
7149
7299
|
}
|
|
7150
7300
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
7151
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
7152
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
7301
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _86 => _86.now]), () => ( /* @__PURE__ */ new Date()));
|
|
7302
|
+
const tz = _optionalChain([opts, 'optionalAccess', _87 => _87.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
|
|
7153
7303
|
return dateWindowQuery(
|
|
7154
7304
|
http,
|
|
7155
7305
|
"/V1.0/Invoices/query",
|
|
7156
7306
|
"invoiceDateTime",
|
|
7157
7307
|
kind,
|
|
7158
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
7308
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _88 => _88.limit])),
|
|
7159
7309
|
`invoices.${kind}`,
|
|
7160
7310
|
now,
|
|
7161
7311
|
tz
|
|
7162
7312
|
);
|
|
7163
7313
|
}
|
|
7164
7314
|
async function customRange2(_resource, from, to, http, opts) {
|
|
7165
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
7315
|
+
const zone = _optionalChain([opts, 'optionalAccess', _89 => _89.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
|
|
7166
7316
|
return customRangeQuery(
|
|
7167
7317
|
http,
|
|
7168
7318
|
"/V1.0/Invoices/query",
|
|
7169
7319
|
"invoiceDateTime",
|
|
7170
7320
|
from,
|
|
7171
7321
|
to,
|
|
7172
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
7322
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _90 => _90.limit])),
|
|
7173
7323
|
"invoices.customRange",
|
|
7174
7324
|
zone
|
|
7175
7325
|
);
|
|
7176
7326
|
}
|
|
7177
7327
|
|
|
7178
7328
|
// src/resources/invoices.ts
|
|
7179
|
-
var InvoicesResource = class extends
|
|
7329
|
+
var InvoicesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7180
7330
|
constructor(http, pageSize) {
|
|
7181
7331
|
super(http, {
|
|
7182
7332
|
key: "invoices",
|
|
@@ -7290,7 +7440,7 @@ var InvoicesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7290
7440
|
};
|
|
7291
7441
|
|
|
7292
7442
|
// src/resources/invoice_templates.ts
|
|
7293
|
-
var InvoiceTemplatesResource = class extends
|
|
7443
|
+
var InvoiceTemplatesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7294
7444
|
constructor(http, pageSize) {
|
|
7295
7445
|
super(http, {
|
|
7296
7446
|
key: "invoice_templates",
|
|
@@ -7334,7 +7484,7 @@ var ModulesResource = class {
|
|
|
7334
7484
|
};
|
|
7335
7485
|
|
|
7336
7486
|
// src/resources/notification_history.ts
|
|
7337
|
-
var NotificationHistoryResource = class extends
|
|
7487
|
+
var NotificationHistoryResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7338
7488
|
constructor(http, pageSize) {
|
|
7339
7489
|
super(http, {
|
|
7340
7490
|
key: "notification_history",
|
|
@@ -7373,7 +7523,7 @@ var NotificationHistoryResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7373
7523
|
};
|
|
7374
7524
|
|
|
7375
7525
|
// src/resources/opportunities.ts
|
|
7376
|
-
var OpportunitiesResource = class extends
|
|
7526
|
+
var OpportunitiesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7377
7527
|
constructor(http, pageSize) {
|
|
7378
7528
|
super(http, {
|
|
7379
7529
|
key: "opportunities",
|
|
@@ -7435,7 +7585,7 @@ var OpportunitiesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7435
7585
|
};
|
|
7436
7586
|
|
|
7437
7587
|
// src/resources/opportunity_attachments.ts
|
|
7438
|
-
var OpportunityAttachmentsResource = class extends
|
|
7588
|
+
var OpportunityAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7439
7589
|
constructor(http, pageSize) {
|
|
7440
7590
|
super(http, {
|
|
7441
7591
|
key: "opportunity_attachments",
|
|
@@ -7497,7 +7647,7 @@ var OpportunityAttachmentsResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
7497
7647
|
};
|
|
7498
7648
|
|
|
7499
7649
|
// src/resources/opportunity_categories.ts
|
|
7500
|
-
var OpportunityCategoriesResource = class extends
|
|
7650
|
+
var OpportunityCategoriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7501
7651
|
constructor(http, pageSize) {
|
|
7502
7652
|
super(http, {
|
|
7503
7653
|
key: "opportunity_categories",
|
|
@@ -7551,12 +7701,12 @@ var OpportunityCategoriesResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
7551
7701
|
/** Search OpportunityCategory records: bounded contains on name (no vendor free-text search exists);
|
|
7552
7702
|
* limit defaults to 25, max 500. */
|
|
7553
7703
|
async search(query, opts) {
|
|
7554
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7704
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
|
|
7555
7705
|
}
|
|
7556
7706
|
};
|
|
7557
7707
|
|
|
7558
7708
|
// src/resources/organizational_level1s.ts
|
|
7559
|
-
var OrganizationalLevel1sResource = class extends
|
|
7709
|
+
var OrganizationalLevel1sResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7560
7710
|
constructor(http, pageSize) {
|
|
7561
7711
|
super(http, {
|
|
7562
7712
|
key: "organizational_level1s",
|
|
@@ -7607,7 +7757,7 @@ var OrganizationalLevel1sResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
7607
7757
|
};
|
|
7608
7758
|
|
|
7609
7759
|
// src/resources/organizational_level2s.ts
|
|
7610
|
-
var OrganizationalLevel2sResource = class extends
|
|
7760
|
+
var OrganizationalLevel2sResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7611
7761
|
constructor(http, pageSize) {
|
|
7612
7762
|
super(http, {
|
|
7613
7763
|
key: "organizational_level2s",
|
|
@@ -7658,7 +7808,7 @@ var OrganizationalLevel2sResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
7658
7808
|
};
|
|
7659
7809
|
|
|
7660
7810
|
// src/resources/organizational_level_associations.ts
|
|
7661
|
-
var OrganizationalLevelAssociationsResource = class extends
|
|
7811
|
+
var OrganizationalLevelAssociationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7662
7812
|
constructor(http, pageSize) {
|
|
7663
7813
|
super(http, {
|
|
7664
7814
|
key: "organizational_level_associations",
|
|
@@ -7709,7 +7859,7 @@ var OrganizationalLevelAssociationsResource = class extends _chunkIKPFR6K2cjs.Ba
|
|
|
7709
7859
|
};
|
|
7710
7860
|
|
|
7711
7861
|
// src/resources/phases.ts
|
|
7712
|
-
var PhasesResource = class extends
|
|
7862
|
+
var PhasesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7713
7863
|
constructor(http, pageSize) {
|
|
7714
7864
|
super(http, {
|
|
7715
7865
|
key: "phases",
|
|
@@ -7768,7 +7918,7 @@ var PhasesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7768
7918
|
};
|
|
7769
7919
|
|
|
7770
7920
|
// src/resources/products.ts
|
|
7771
|
-
var ProductsResource = class extends
|
|
7921
|
+
var ProductsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7772
7922
|
constructor(http, pageSize) {
|
|
7773
7923
|
super(http, {
|
|
7774
7924
|
key: "products",
|
|
@@ -7830,12 +7980,12 @@ var ProductsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7830
7980
|
/** Search Product records: bounded contains on name (no vendor free-text search exists);
|
|
7831
7981
|
* limit defaults to 25, max 500. */
|
|
7832
7982
|
async search(query, opts) {
|
|
7833
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7983
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
|
|
7834
7984
|
}
|
|
7835
7985
|
};
|
|
7836
7986
|
|
|
7837
7987
|
// src/resources/product_vendors.ts
|
|
7838
|
-
var ProductVendorsResource = class extends
|
|
7988
|
+
var ProductVendorsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7839
7989
|
constructor(http, pageSize) {
|
|
7840
7990
|
super(http, {
|
|
7841
7991
|
key: "product_vendors",
|
|
@@ -7894,7 +8044,7 @@ var ProductVendorsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7894
8044
|
};
|
|
7895
8045
|
|
|
7896
8046
|
// src/resources/project_charges.ts
|
|
7897
|
-
var ProjectChargesResource = class extends
|
|
8047
|
+
var ProjectChargesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7898
8048
|
constructor(http, pageSize) {
|
|
7899
8049
|
super(http, {
|
|
7900
8050
|
key: "project_charges",
|
|
@@ -7960,12 +8110,12 @@ var ProjectChargesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
7960
8110
|
/** Search ProjectCharge records: bounded contains on name (no vendor free-text search exists);
|
|
7961
8111
|
* limit defaults to 25, max 500. */
|
|
7962
8112
|
async search(query, opts) {
|
|
7963
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8113
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _93 => _93.limit]) });
|
|
7964
8114
|
}
|
|
7965
8115
|
};
|
|
7966
8116
|
|
|
7967
8117
|
// src/resources/project_notes.ts
|
|
7968
|
-
var ProjectNotesResource = class extends
|
|
8118
|
+
var ProjectNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
7969
8119
|
constructor(http, pageSize) {
|
|
7970
8120
|
super(http, {
|
|
7971
8121
|
key: "project_notes",
|
|
@@ -8024,7 +8174,7 @@ var ProjectNotesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8024
8174
|
};
|
|
8025
8175
|
|
|
8026
8176
|
// src/resources/projects.ts
|
|
8027
|
-
var ProjectsResource = class extends
|
|
8177
|
+
var ProjectsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8028
8178
|
constructor(http, pageSize) {
|
|
8029
8179
|
super(http, {
|
|
8030
8180
|
key: "projects",
|
|
@@ -8086,7 +8236,7 @@ var ProjectsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8086
8236
|
/** Search Project records: bounded contains on projectName (no vendor free-text search exists);
|
|
8087
8237
|
* limit defaults to 25, max 500. */
|
|
8088
8238
|
async search(query, opts) {
|
|
8089
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8239
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _94 => _94.limit]) });
|
|
8090
8240
|
}
|
|
8091
8241
|
/** Get the Project with its primary context records in one call (each part a single-record
|
|
8092
8242
|
* fetch; no sub-lists; absent/dangling references come back null). `names: true` (issue #77)
|
|
@@ -8101,13 +8251,13 @@ var ProjectsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8101
8251
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
8102
8252
|
const result = { project: project2, company, opportunity, leadResource };
|
|
8103
8253
|
if (opts.names === true) {
|
|
8104
|
-
const builder =
|
|
8254
|
+
const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, );
|
|
8105
8255
|
builder.addResource(root["creatorResourceID"]);
|
|
8106
8256
|
builder.addFk("contract", root["contractID"]);
|
|
8107
|
-
const names = await
|
|
8257
|
+
const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
8108
8258
|
const row = { ...project2 };
|
|
8109
|
-
|
|
8110
|
-
|
|
8259
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
8260
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
8111
8261
|
result.project = row;
|
|
8112
8262
|
result.names = names.section;
|
|
8113
8263
|
}
|
|
@@ -8116,7 +8266,7 @@ var ProjectsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8116
8266
|
};
|
|
8117
8267
|
|
|
8118
8268
|
// src/resources/purchase_approvals.ts
|
|
8119
|
-
var PurchaseApprovalsResource = class extends
|
|
8269
|
+
var PurchaseApprovalsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8120
8270
|
constructor(http, pageSize) {
|
|
8121
8271
|
super(http, {
|
|
8122
8272
|
key: "purchase_approvals",
|
|
@@ -8170,7 +8320,7 @@ var PurchaseApprovalsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8170
8320
|
};
|
|
8171
8321
|
|
|
8172
8322
|
// src/resources/purchase_order_item_receiving.ts
|
|
8173
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
8323
|
+
var PurchaseOrderItemReceivingResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8174
8324
|
constructor(http, pageSize) {
|
|
8175
8325
|
super(http, {
|
|
8176
8326
|
key: "purchase_order_item_receiving",
|
|
@@ -8220,7 +8370,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkIKPFR6K2cjs.BaseRes
|
|
|
8220
8370
|
};
|
|
8221
8371
|
|
|
8222
8372
|
// src/resources/purchase_order_items.ts
|
|
8223
|
-
var PurchaseOrderItemsResource = class extends
|
|
8373
|
+
var PurchaseOrderItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8224
8374
|
constructor(http, pageSize) {
|
|
8225
8375
|
super(http, {
|
|
8226
8376
|
key: "purchase_order_items",
|
|
@@ -8279,7 +8429,7 @@ var PurchaseOrderItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8279
8429
|
};
|
|
8280
8430
|
|
|
8281
8431
|
// src/resources/purchase_orders.ts
|
|
8282
|
-
var PurchaseOrdersResource = class extends
|
|
8432
|
+
var PurchaseOrdersResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8283
8433
|
constructor(http, pageSize) {
|
|
8284
8434
|
super(http, {
|
|
8285
8435
|
key: "purchase_orders",
|
|
@@ -8341,7 +8491,7 @@ var PurchaseOrdersResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8341
8491
|
};
|
|
8342
8492
|
|
|
8343
8493
|
// src/resources/quote_items.ts
|
|
8344
|
-
var QuoteItemsResource = class extends
|
|
8494
|
+
var QuoteItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8345
8495
|
constructor(http, pageSize) {
|
|
8346
8496
|
super(http, {
|
|
8347
8497
|
key: "quote_items",
|
|
@@ -8407,12 +8557,12 @@ var QuoteItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8407
8557
|
/** Search QuoteItem records: bounded contains on name (no vendor free-text search exists);
|
|
8408
8558
|
* limit defaults to 25, max 500. */
|
|
8409
8559
|
async search(query, opts) {
|
|
8410
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8560
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
|
|
8411
8561
|
}
|
|
8412
8562
|
};
|
|
8413
8563
|
|
|
8414
8564
|
// src/resources/quote_locations.ts
|
|
8415
|
-
var QuoteLocationsResource = class extends
|
|
8565
|
+
var QuoteLocationsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8416
8566
|
constructor(http, pageSize) {
|
|
8417
8567
|
super(http, {
|
|
8418
8568
|
key: "quote_locations",
|
|
@@ -8477,7 +8627,7 @@ var QuoteLocationsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8477
8627
|
};
|
|
8478
8628
|
|
|
8479
8629
|
// src/resources/quotes.ts
|
|
8480
|
-
var QuotesResource = class extends
|
|
8630
|
+
var QuotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8481
8631
|
constructor(http, pageSize) {
|
|
8482
8632
|
super(http, {
|
|
8483
8633
|
key: "quotes",
|
|
@@ -8539,12 +8689,12 @@ var QuotesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8539
8689
|
/** Search Quote records: bounded contains on name (no vendor free-text search exists);
|
|
8540
8690
|
* limit defaults to 25, max 500. */
|
|
8541
8691
|
async search(query, opts) {
|
|
8542
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8692
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
|
|
8543
8693
|
}
|
|
8544
8694
|
};
|
|
8545
8695
|
|
|
8546
8696
|
// src/resources/quote_templates.ts
|
|
8547
|
-
var QuoteTemplatesResource = class extends
|
|
8697
|
+
var QuoteTemplatesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8548
8698
|
constructor(http, pageSize) {
|
|
8549
8699
|
super(http, {
|
|
8550
8700
|
key: "quote_templates",
|
|
@@ -8583,12 +8733,12 @@ var QuoteTemplatesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8583
8733
|
/** Search QuoteTemplate records: bounded contains on name (no vendor free-text search exists);
|
|
8584
8734
|
* limit defaults to 25, max 500. */
|
|
8585
8735
|
async search(query, opts) {
|
|
8586
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8736
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _97 => _97.limit]) });
|
|
8587
8737
|
}
|
|
8588
8738
|
};
|
|
8589
8739
|
|
|
8590
8740
|
// src/resources/resource_role_queues.ts
|
|
8591
|
-
var ResourceRoleQueuesResource = class extends
|
|
8741
|
+
var ResourceRoleQueuesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8592
8742
|
constructor(http, pageSize) {
|
|
8593
8743
|
super(http, {
|
|
8594
8744
|
key: "resource_role_queues",
|
|
@@ -8647,7 +8797,7 @@ var ResourceRoleQueuesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8647
8797
|
};
|
|
8648
8798
|
|
|
8649
8799
|
// src/resources/resource_roles.ts
|
|
8650
|
-
var ResourceRolesResource = class extends
|
|
8800
|
+
var ResourceRolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8651
8801
|
constructor(http, pageSize) {
|
|
8652
8802
|
super(http, {
|
|
8653
8803
|
key: "resource_roles",
|
|
@@ -8689,7 +8839,7 @@ var ResourceRolesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8689
8839
|
};
|
|
8690
8840
|
|
|
8691
8841
|
// src/resources/resource_skills.ts
|
|
8692
|
-
var ResourceSkillsResource = class extends
|
|
8842
|
+
var ResourceSkillsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8693
8843
|
constructor(http, pageSize) {
|
|
8694
8844
|
super(http, {
|
|
8695
8845
|
key: "resource_skills",
|
|
@@ -8743,16 +8893,16 @@ var ResourceSkillsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8743
8893
|
var MAX_TRANSFER_IDS = 500;
|
|
8744
8894
|
function requirePositiveIds(ids2, label) {
|
|
8745
8895
|
if (!Array.isArray(ids2) || ids2.length === 0) {
|
|
8746
|
-
throw new (0,
|
|
8896
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8747
8897
|
}
|
|
8748
8898
|
if (ids2.length > MAX_TRANSFER_IDS) {
|
|
8749
|
-
throw new (0,
|
|
8899
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8750
8900
|
}
|
|
8751
8901
|
const out = [];
|
|
8752
8902
|
for (const raw of ids2) {
|
|
8753
|
-
const id =
|
|
8903
|
+
const id = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8754
8904
|
if (typeof id === "number" && id < 1) {
|
|
8755
|
-
throw new (0,
|
|
8905
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8756
8906
|
}
|
|
8757
8907
|
out.push(id);
|
|
8758
8908
|
}
|
|
@@ -8760,7 +8910,7 @@ function requirePositiveIds(ids2, label) {
|
|
|
8760
8910
|
}
|
|
8761
8911
|
async function whoAmI(_resource, userName, http) {
|
|
8762
8912
|
const user = userName.trim();
|
|
8763
|
-
if (user === "") throw new (0,
|
|
8913
|
+
if (user === "") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8764
8914
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8765
8915
|
const res = await http.request({
|
|
8766
8916
|
method: "POST",
|
|
@@ -8769,11 +8919,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8769
8919
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8770
8920
|
operation: "resources.whoAmI"
|
|
8771
8921
|
});
|
|
8772
|
-
const matches =
|
|
8922
|
+
const matches = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
8773
8923
|
if (matches.length === 0) return null;
|
|
8774
8924
|
if (matches.length > 1) {
|
|
8775
8925
|
const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8776
|
-
throw new (0,
|
|
8926
|
+
throw new (0, _chunk4QN43TRPcjs.ResolutionError)(
|
|
8777
8927
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8778
8928
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
8779
8929
|
);
|
|
@@ -8782,11 +8932,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8782
8932
|
}
|
|
8783
8933
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8784
8934
|
const ids2 = requirePositiveIds(companyIds, "transferOwnership");
|
|
8785
|
-
const destination =
|
|
8935
|
+
const destination = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8786
8936
|
if (typeof destination === "number" && destination < 1) {
|
|
8787
|
-
throw new (0,
|
|
8937
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8788
8938
|
}
|
|
8789
|
-
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
8939
|
+
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _98 => _98.dryRun]), () => ( true));
|
|
8790
8940
|
const changes = [];
|
|
8791
8941
|
const applied = [];
|
|
8792
8942
|
for (const id of ids2) {
|
|
@@ -8795,9 +8945,9 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8795
8945
|
method: "GET",
|
|
8796
8946
|
path: `/V1.0/Companies/${id}`,
|
|
8797
8947
|
operation: "resources.transferOwnership",
|
|
8798
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8948
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _99 => _99.maxRetries])
|
|
8799
8949
|
});
|
|
8800
|
-
const company =
|
|
8950
|
+
const company = _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, id, void 0, "company");
|
|
8801
8951
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8802
8952
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8803
8953
|
if (!dryRun) {
|
|
@@ -8806,15 +8956,15 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8806
8956
|
path: "/V1.0/Companies",
|
|
8807
8957
|
body: { id, ownerResourceID: destination },
|
|
8808
8958
|
operation: "resources.transferOwnership",
|
|
8809
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8959
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _100 => _100.maxRetries])
|
|
8810
8960
|
});
|
|
8811
|
-
|
|
8961
|
+
_chunk4QN43TRPcjs.unwrapOperation.call(void 0, update);
|
|
8812
8962
|
applied.push(id);
|
|
8813
8963
|
}
|
|
8814
8964
|
} catch (err) {
|
|
8815
|
-
if (!dryRun && err instanceof
|
|
8965
|
+
if (!dryRun && err instanceof _chunk4QN43TRPcjs.AutotaskError) {
|
|
8816
8966
|
err.resourceIds = [id];
|
|
8817
|
-
err.details =
|
|
8967
|
+
err.details = _chunk4QN43TRPcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
|
|
8818
8968
|
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).`;
|
|
8819
8969
|
}
|
|
8820
8970
|
throw err;
|
|
@@ -8823,7 +8973,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8823
8973
|
if (dryRun) {
|
|
8824
8974
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8825
8975
|
return {
|
|
8826
|
-
...
|
|
8976
|
+
..._chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
8827
8977
|
operation: "resources.transferOwnership",
|
|
8828
8978
|
method: "PUT",
|
|
8829
8979
|
path: "/V1.0/Companies",
|
|
@@ -8847,7 +8997,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8847
8997
|
}
|
|
8848
8998
|
|
|
8849
8999
|
// src/resources/resources.ts
|
|
8850
|
-
var ResourcesResource = class extends
|
|
9000
|
+
var ResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8851
9001
|
|
|
8852
9002
|
constructor(http, clientConfig, pageSize) {
|
|
8853
9003
|
super(http, {
|
|
@@ -8906,7 +9056,7 @@ var ResourcesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8906
9056
|
/** Search Resource records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
8907
9057
|
* limit defaults to 25, max 500. */
|
|
8908
9058
|
async search(query, opts) {
|
|
8909
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9059
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _101 => _101.limit]) });
|
|
8910
9060
|
}
|
|
8911
9061
|
/** Node-parity special op (hand-written in src/resources/special/resources.ts). */
|
|
8912
9062
|
transferOwnership(sourceResourceIds, destinationResourceId, opts = {}) {
|
|
@@ -8920,7 +9070,7 @@ var ResourcesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
8920
9070
|
|
|
8921
9071
|
// src/resources/special/resource_time_off_additional.ts
|
|
8922
9072
|
async function getByResource(_resource, resourceId, http) {
|
|
8923
|
-
const numericResource =
|
|
9073
|
+
const numericResource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8924
9074
|
const res = await http.request({
|
|
8925
9075
|
method: "GET",
|
|
8926
9076
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8934,11 +9084,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8934
9084
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8935
9085
|
}
|
|
8936
9086
|
}
|
|
8937
|
-
return
|
|
9087
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8938
9088
|
}
|
|
8939
9089
|
|
|
8940
9090
|
// src/resources/resource_time_off_additional.ts
|
|
8941
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
9091
|
+
var ResourceTimeOffAdditionalResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8942
9092
|
constructor(http, pageSize) {
|
|
8943
9093
|
super(http, {
|
|
8944
9094
|
key: "resource_time_off_additional",
|
|
@@ -8977,7 +9127,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkIKPFR6K2cjs.BaseReso
|
|
|
8977
9127
|
};
|
|
8978
9128
|
|
|
8979
9129
|
// src/resources/resource_time_off_approvers.ts
|
|
8980
|
-
var ResourceTimeOffApproversResource = class extends
|
|
9130
|
+
var ResourceTimeOffApproversResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
8981
9131
|
constructor(http, pageSize) {
|
|
8982
9132
|
super(http, {
|
|
8983
9133
|
key: "resource_time_off_approvers",
|
|
@@ -9020,29 +9170,29 @@ var ResourceTimeOffApproversResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
9020
9170
|
|
|
9021
9171
|
// src/resources/special/resource_time_off_balances.ts
|
|
9022
9172
|
async function getByResource2(_resource, resourceId, http) {
|
|
9023
|
-
const numericResource =
|
|
9173
|
+
const numericResource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
9024
9174
|
const res = await http.request({
|
|
9025
9175
|
method: "GET",
|
|
9026
9176
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
9027
9177
|
operation: "resource_time_off_balances.getByResource"
|
|
9028
9178
|
});
|
|
9029
|
-
return
|
|
9179
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
9030
9180
|
}
|
|
9031
9181
|
async function getByYear(_resource, resourceId, year, http) {
|
|
9032
|
-
const numericResource =
|
|
9182
|
+
const numericResource = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
9033
9183
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
9034
|
-
throw new (0,
|
|
9184
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
9035
9185
|
}
|
|
9036
9186
|
const res = await http.request({
|
|
9037
9187
|
method: "GET",
|
|
9038
9188
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
9039
9189
|
operation: "resource_time_off_balances.getByYear"
|
|
9040
9190
|
});
|
|
9041
|
-
return
|
|
9191
|
+
return _chunk4QN43TRPcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
9042
9192
|
}
|
|
9043
9193
|
|
|
9044
9194
|
// src/resources/resource_time_off_balances.ts
|
|
9045
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
9195
|
+
var ResourceTimeOffBalancesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9046
9196
|
constructor(http, pageSize) {
|
|
9047
9197
|
super(http, {
|
|
9048
9198
|
key: "resource_time_off_balances",
|
|
@@ -9080,7 +9230,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkIKPFR6K2cjs.BaseResour
|
|
|
9080
9230
|
};
|
|
9081
9231
|
|
|
9082
9232
|
// src/resources/roles.ts
|
|
9083
|
-
var RolesResource = class extends
|
|
9233
|
+
var RolesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9084
9234
|
constructor(http, pageSize) {
|
|
9085
9235
|
super(http, {
|
|
9086
9236
|
key: "roles",
|
|
@@ -9142,12 +9292,12 @@ var RolesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9142
9292
|
/** Search Role records: bounded contains on name (no vendor free-text search exists);
|
|
9143
9293
|
* limit defaults to 25, max 500. */
|
|
9144
9294
|
async search(query, opts) {
|
|
9145
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9295
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _102 => _102.limit]) });
|
|
9146
9296
|
}
|
|
9147
9297
|
};
|
|
9148
9298
|
|
|
9149
9299
|
// src/resources/sales_orders.ts
|
|
9150
|
-
var SalesOrdersResource = class extends
|
|
9300
|
+
var SalesOrdersResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9151
9301
|
constructor(http, pageSize) {
|
|
9152
9302
|
super(http, {
|
|
9153
9303
|
key: "sales_orders",
|
|
@@ -9190,7 +9340,7 @@ var SalesOrdersResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9190
9340
|
};
|
|
9191
9341
|
|
|
9192
9342
|
// src/resources/service_calls.ts
|
|
9193
|
-
var ServiceCallsResource = class extends
|
|
9343
|
+
var ServiceCallsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9194
9344
|
constructor(http, pageSize) {
|
|
9195
9345
|
super(http, {
|
|
9196
9346
|
key: "service_calls",
|
|
@@ -9259,7 +9409,7 @@ var ServiceCallsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9259
9409
|
};
|
|
9260
9410
|
|
|
9261
9411
|
// src/resources/service_call_task_resources.ts
|
|
9262
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
9412
|
+
var ServiceCallTaskResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9263
9413
|
constructor(http, pageSize) {
|
|
9264
9414
|
super(http, {
|
|
9265
9415
|
key: "service_call_task_resources",
|
|
@@ -9316,7 +9466,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
9316
9466
|
};
|
|
9317
9467
|
|
|
9318
9468
|
// src/resources/service_call_tasks.ts
|
|
9319
|
-
var ServiceCallTasksResource = class extends
|
|
9469
|
+
var ServiceCallTasksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9320
9470
|
constructor(http, pageSize) {
|
|
9321
9471
|
super(http, {
|
|
9322
9472
|
key: "service_call_tasks",
|
|
@@ -9373,7 +9523,7 @@ var ServiceCallTasksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9373
9523
|
};
|
|
9374
9524
|
|
|
9375
9525
|
// src/resources/service_call_ticket_resources.ts
|
|
9376
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
9526
|
+
var ServiceCallTicketResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9377
9527
|
constructor(http, pageSize) {
|
|
9378
9528
|
super(http, {
|
|
9379
9529
|
key: "service_call_ticket_resources",
|
|
@@ -9430,7 +9580,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkIKPFR6K2cjs.BaseRes
|
|
|
9430
9580
|
};
|
|
9431
9581
|
|
|
9432
9582
|
// src/resources/service_call_tickets.ts
|
|
9433
|
-
var ServiceCallTicketsResource = class extends
|
|
9583
|
+
var ServiceCallTicketsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9434
9584
|
constructor(http, pageSize) {
|
|
9435
9585
|
super(http, {
|
|
9436
9586
|
key: "service_call_tickets",
|
|
@@ -9487,7 +9637,7 @@ var ServiceCallTicketsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9487
9637
|
};
|
|
9488
9638
|
|
|
9489
9639
|
// src/resources/service_level_agreement_results.ts
|
|
9490
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
9640
|
+
var ServiceLevelAgreementResultsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9491
9641
|
constructor(http, pageSize) {
|
|
9492
9642
|
super(http, {
|
|
9493
9643
|
key: "service_level_agreement_results",
|
|
@@ -9526,7 +9676,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkIKPFR6K2cjs.BaseR
|
|
|
9526
9676
|
};
|
|
9527
9677
|
|
|
9528
9678
|
// src/resources/services.ts
|
|
9529
|
-
var ServicesResource = class extends
|
|
9679
|
+
var ServicesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9530
9680
|
constructor(http, pageSize) {
|
|
9531
9681
|
super(http, {
|
|
9532
9682
|
key: "services",
|
|
@@ -9589,12 +9739,12 @@ var ServicesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9589
9739
|
/** Search Service records: bounded contains on name (no vendor free-text search exists);
|
|
9590
9740
|
* limit defaults to 25, max 500. */
|
|
9591
9741
|
async search(query, opts) {
|
|
9592
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9742
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _103 => _103.limit]) });
|
|
9593
9743
|
}
|
|
9594
9744
|
};
|
|
9595
9745
|
|
|
9596
9746
|
// src/resources/skills.ts
|
|
9597
|
-
var SkillsResource = class extends
|
|
9747
|
+
var SkillsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9598
9748
|
constructor(http, pageSize) {
|
|
9599
9749
|
super(http, {
|
|
9600
9750
|
key: "skills",
|
|
@@ -9633,12 +9783,12 @@ var SkillsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9633
9783
|
/** Search Skill records: bounded contains on name (no vendor free-text search exists);
|
|
9634
9784
|
* limit defaults to 25, max 500. */
|
|
9635
9785
|
async search(query, opts) {
|
|
9636
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9786
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _104 => _104.limit]) });
|
|
9637
9787
|
}
|
|
9638
9788
|
};
|
|
9639
9789
|
|
|
9640
9790
|
// src/resources/subscription_periods.ts
|
|
9641
|
-
var SubscriptionPeriodsResource = class extends
|
|
9791
|
+
var SubscriptionPeriodsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9642
9792
|
constructor(http, pageSize) {
|
|
9643
9793
|
super(http, {
|
|
9644
9794
|
key: "subscription_periods",
|
|
@@ -9677,7 +9827,7 @@ var SubscriptionPeriodsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9677
9827
|
};
|
|
9678
9828
|
|
|
9679
9829
|
// src/resources/subscriptions.ts
|
|
9680
|
-
var SubscriptionsResource = class extends
|
|
9830
|
+
var SubscriptionsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9681
9831
|
constructor(http, pageSize) {
|
|
9682
9832
|
super(http, {
|
|
9683
9833
|
key: "subscriptions",
|
|
@@ -9746,7 +9896,7 @@ var SubscriptionsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9746
9896
|
};
|
|
9747
9897
|
|
|
9748
9898
|
// src/resources/survey_results.ts
|
|
9749
|
-
var SurveyResultsResource = class extends
|
|
9899
|
+
var SurveyResultsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9750
9900
|
constructor(http, pageSize) {
|
|
9751
9901
|
super(http, {
|
|
9752
9902
|
key: "survey_results",
|
|
@@ -9785,7 +9935,7 @@ var SurveyResultsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9785
9935
|
};
|
|
9786
9936
|
|
|
9787
9937
|
// src/resources/surveys.ts
|
|
9788
|
-
var SurveysResource = class extends
|
|
9938
|
+
var SurveysResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9789
9939
|
constructor(http, pageSize) {
|
|
9790
9940
|
super(http, {
|
|
9791
9941
|
key: "surveys",
|
|
@@ -9824,12 +9974,12 @@ var SurveysResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9824
9974
|
/** Search Survey records: bounded contains on name (no vendor free-text search exists);
|
|
9825
9975
|
* limit defaults to 25, max 500. */
|
|
9826
9976
|
async search(query, opts) {
|
|
9827
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9977
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _105 => _105.limit]) });
|
|
9828
9978
|
}
|
|
9829
9979
|
};
|
|
9830
9980
|
|
|
9831
9981
|
// src/resources/tag_aliases.ts
|
|
9832
|
-
var TagAliasesResource = class extends
|
|
9982
|
+
var TagAliasesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9833
9983
|
constructor(http, pageSize) {
|
|
9834
9984
|
super(http, {
|
|
9835
9985
|
key: "tag_aliases",
|
|
@@ -9886,7 +10036,7 @@ var TagAliasesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9886
10036
|
};
|
|
9887
10037
|
|
|
9888
10038
|
// src/resources/tag_groups.ts
|
|
9889
|
-
var TagGroupsResource = class extends
|
|
10039
|
+
var TagGroupsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9890
10040
|
constructor(http, pageSize) {
|
|
9891
10041
|
super(http, {
|
|
9892
10042
|
key: "tag_groups",
|
|
@@ -9955,7 +10105,7 @@ var TagGroupsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
9955
10105
|
};
|
|
9956
10106
|
|
|
9957
10107
|
// src/resources/tags.ts
|
|
9958
|
-
var TagsResource = class extends
|
|
10108
|
+
var TagsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
9959
10109
|
constructor(http, pageSize) {
|
|
9960
10110
|
super(http, {
|
|
9961
10111
|
key: "tags",
|
|
@@ -10024,7 +10174,7 @@ var TagsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
10024
10174
|
};
|
|
10025
10175
|
|
|
10026
10176
|
// src/resources/task_secondary_resources.ts
|
|
10027
|
-
var TaskSecondaryResourcesResource = class extends
|
|
10177
|
+
var TaskSecondaryResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10028
10178
|
constructor(http, pageSize) {
|
|
10029
10179
|
super(http, {
|
|
10030
10180
|
key: "task_secondary_resources",
|
|
@@ -10081,7 +10231,7 @@ var TaskSecondaryResourcesResource = class extends _chunkIKPFR6K2cjs.BaseResourc
|
|
|
10081
10231
|
};
|
|
10082
10232
|
|
|
10083
10233
|
// src/resources/tasks.ts
|
|
10084
|
-
var TasksResource = class extends
|
|
10234
|
+
var TasksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10085
10235
|
constructor(http, pageSize) {
|
|
10086
10236
|
super(http, {
|
|
10087
10237
|
key: "tasks",
|
|
@@ -10140,12 +10290,12 @@ var TasksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
10140
10290
|
/** Search Task records: bounded contains on title (no vendor free-text search exists);
|
|
10141
10291
|
* limit defaults to 25, max 500. */
|
|
10142
10292
|
async search(query, opts) {
|
|
10143
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10293
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _106 => _106.limit]) });
|
|
10144
10294
|
}
|
|
10145
10295
|
};
|
|
10146
10296
|
|
|
10147
10297
|
// src/resources/tax_regions.ts
|
|
10148
|
-
var TaxRegionsResource = class extends
|
|
10298
|
+
var TaxRegionsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10149
10299
|
constructor(http, pageSize) {
|
|
10150
10300
|
super(http, {
|
|
10151
10301
|
key: "tax_regions",
|
|
@@ -10220,7 +10370,7 @@ var ThresholdInformationResource = class {
|
|
|
10220
10370
|
};
|
|
10221
10371
|
|
|
10222
10372
|
// src/resources/ticket_additional_configuration_items.ts
|
|
10223
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
10373
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10224
10374
|
constructor(http, pageSize) {
|
|
10225
10375
|
super(http, {
|
|
10226
10376
|
key: "ticket_additional_configuration_items",
|
|
@@ -10277,7 +10427,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkIKPFR6K2cjs
|
|
|
10277
10427
|
};
|
|
10278
10428
|
|
|
10279
10429
|
// src/resources/ticket_additional_contacts.ts
|
|
10280
|
-
var TicketAdditionalContactsResource = class extends
|
|
10430
|
+
var TicketAdditionalContactsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10281
10431
|
constructor(http, pageSize) {
|
|
10282
10432
|
super(http, {
|
|
10283
10433
|
key: "ticket_additional_contacts",
|
|
@@ -10334,7 +10484,7 @@ var TicketAdditionalContactsResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
10334
10484
|
};
|
|
10335
10485
|
|
|
10336
10486
|
// src/resources/ticket_attachments.ts
|
|
10337
|
-
var TicketAttachmentsResource = class extends
|
|
10487
|
+
var TicketAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10338
10488
|
constructor(http, pageSize) {
|
|
10339
10489
|
super(http, {
|
|
10340
10490
|
key: "ticket_attachments",
|
|
@@ -10396,7 +10546,7 @@ var TicketAttachmentsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
10396
10546
|
};
|
|
10397
10547
|
|
|
10398
10548
|
// src/resources/ticket_categories.ts
|
|
10399
|
-
var TicketCategoriesResource = class extends
|
|
10549
|
+
var TicketCategoriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10400
10550
|
constructor(http, pageSize) {
|
|
10401
10551
|
super(http, {
|
|
10402
10552
|
key: "ticket_categories",
|
|
@@ -10450,12 +10600,12 @@ var TicketCategoriesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
10450
10600
|
/** Search TicketCategory records: bounded contains on name (no vendor free-text search exists);
|
|
10451
10601
|
* limit defaults to 25, max 500. */
|
|
10452
10602
|
async search(query, opts) {
|
|
10453
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10603
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _107 => _107.limit]) });
|
|
10454
10604
|
}
|
|
10455
10605
|
};
|
|
10456
10606
|
|
|
10457
10607
|
// src/resources/ticket_category_field_defaults.ts
|
|
10458
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
10608
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10459
10609
|
constructor(http, pageSize) {
|
|
10460
10610
|
super(http, {
|
|
10461
10611
|
key: "ticket_category_field_defaults",
|
|
@@ -10497,7 +10647,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkIKPFR6K2cjs.BaseRe
|
|
|
10497
10647
|
};
|
|
10498
10648
|
|
|
10499
10649
|
// src/resources/ticket_change_request_approvals.ts
|
|
10500
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
10650
|
+
var TicketChangeRequestApprovalsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10501
10651
|
constructor(http, pageSize) {
|
|
10502
10652
|
super(http, {
|
|
10503
10653
|
key: "ticket_change_request_approvals",
|
|
@@ -10557,10 +10707,10 @@ var TicketChangeRequestApprovalsResource = class extends _chunkIKPFR6K2cjs.BaseR
|
|
|
10557
10707
|
var _crypto = require('crypto');
|
|
10558
10708
|
var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
|
|
10559
10709
|
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";
|
|
10560
|
-
var refuse = (code, message, ids2, operation, extra = {}) => new (0,
|
|
10710
|
+
var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunk4QN43TRPcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
|
|
10561
10711
|
async function queryRows(http, resource, filter, operation, retries) {
|
|
10562
10712
|
const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
|
|
10563
|
-
return
|
|
10713
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
10564
10714
|
}
|
|
10565
10715
|
function sameValue(a, b) {
|
|
10566
10716
|
if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
|
|
@@ -10577,10 +10727,10 @@ function sameValue(a, b) {
|
|
|
10577
10727
|
async function readTicket(http, id, retries, operation) {
|
|
10578
10728
|
try {
|
|
10579
10729
|
const res = await http.request({ method: "GET", path: `/V1.0/Tickets/${id}`, operation, maxRetries: retries });
|
|
10580
|
-
const item = _optionalChain([res, 'optionalAccess',
|
|
10730
|
+
const item = _optionalChain([res, 'optionalAccess', _108 => _108.item]);
|
|
10581
10731
|
return _nullishCoalesce(item, () => ( null));
|
|
10582
10732
|
} catch (e) {
|
|
10583
|
-
if (
|
|
10733
|
+
if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
10584
10734
|
throw e;
|
|
10585
10735
|
}
|
|
10586
10736
|
}
|
|
@@ -10601,7 +10751,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10601
10751
|
}
|
|
10602
10752
|
}
|
|
10603
10753
|
const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
|
|
10604
|
-
if (!Number.isFinite(cap) || cap < 0) throw new (0,
|
|
10754
|
+
if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
|
|
10605
10755
|
const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
|
|
10606
10756
|
if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
|
|
10607
10757
|
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") });
|
|
@@ -10622,7 +10772,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10622
10772
|
const facts = {
|
|
10623
10773
|
closedStatus: { closedIds: closedStatus.closedIds, source: closedStatus.source, note: closedStatus.note },
|
|
10624
10774
|
sourceTicketId,
|
|
10625
|
-
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess',
|
|
10775
|
+
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _109 => _109.companyID]), () => ( null)),
|
|
10626
10776
|
targetCompanyID: _nullishCoalesce(target.companyID, () => ( null)),
|
|
10627
10777
|
companyChanged: origin === null ? null : origin.companyID !== target.companyID,
|
|
10628
10778
|
contractChanged: origin === null ? null : (_nullishCoalesce(origin.contractID, () => ( null))) !== (_nullishCoalesce(target.contractID, () => ( null)))
|
|
@@ -10644,17 +10794,17 @@ async function assertNoTwin(ctx, payload) {
|
|
|
10644
10794
|
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 });
|
|
10645
10795
|
}
|
|
10646
10796
|
}
|
|
10647
|
-
var statusOf = (e) =>
|
|
10797
|
+
var statusOf = (e) => _chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
|
|
10648
10798
|
async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
10649
10799
|
const op = spec.operation;
|
|
10650
|
-
const sourceId = Number(
|
|
10651
|
-
const toTicketId = Number(
|
|
10800
|
+
const sourceId = Number(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
|
|
10801
|
+
const toTicketId = Number(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
|
|
10652
10802
|
if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
|
|
10653
|
-
throw new (0,
|
|
10803
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
|
|
10654
10804
|
}
|
|
10655
10805
|
const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
|
|
10656
10806
|
if (opts.dryRun === true) {
|
|
10657
|
-
return
|
|
10807
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
10658
10808
|
{
|
|
10659
10809
|
operation: op,
|
|
10660
10810
|
method: "POST",
|
|
@@ -10679,22 +10829,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10679
10829
|
let newId;
|
|
10680
10830
|
try {
|
|
10681
10831
|
const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
|
|
10682
|
-
newId = Number(
|
|
10832
|
+
newId = Number(_chunk4QN43TRPcjs.unwrapOperation.call(void 0, created, op).id);
|
|
10683
10833
|
} catch (e) {
|
|
10684
10834
|
const status = statusOf(e);
|
|
10685
10835
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
10686
|
-
throw new (0,
|
|
10836
|
+
throw new (0, _chunk4QN43TRPcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
|
|
10687
10837
|
}
|
|
10688
|
-
throw new (0,
|
|
10838
|
+
throw new (0, _chunk4QN43TRPcjs.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 } });
|
|
10689
10839
|
}
|
|
10690
10840
|
const rollback = async (code, message) => {
|
|
10691
10841
|
try {
|
|
10692
10842
|
await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
|
|
10693
10843
|
} catch (re) {
|
|
10694
10844
|
const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
|
|
10695
|
-
throw new (0,
|
|
10845
|
+
throw new (0, _chunk4QN43TRPcjs.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 } });
|
|
10696
10846
|
}
|
|
10697
|
-
throw new (0,
|
|
10847
|
+
throw new (0, _chunk4QN43TRPcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
|
|
10698
10848
|
};
|
|
10699
10849
|
const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
|
|
10700
10850
|
if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
|
|
@@ -10723,33 +10873,33 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10723
10873
|
};
|
|
10724
10874
|
}
|
|
10725
10875
|
if (status === void 0) {
|
|
10726
|
-
throw new (0,
|
|
10876
|
+
throw new (0, _chunk4QN43TRPcjs.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 } });
|
|
10727
10877
|
}
|
|
10728
10878
|
return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
|
|
10729
10879
|
}
|
|
10730
10880
|
return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
|
|
10731
10881
|
}
|
|
10732
10882
|
function uiLinkFor(http, entity, id) {
|
|
10733
|
-
return _nullishCoalesce(
|
|
10883
|
+
return _nullishCoalesce(_chunk4QN43TRPcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
|
|
10734
10884
|
}
|
|
10735
10885
|
|
|
10736
10886
|
// src/resources/special/ticket_charges.ts
|
|
10737
|
-
var
|
|
10887
|
+
var OP5 = "ticket_charges.moveToTicket";
|
|
10738
10888
|
var COPY = ["name", "description", "chargeType", "billingCodeID", "productID", "unitQuantity", "unitCost", "unitPrice", "datePurchased", "isBillableToCompany", "notes", "purchaseOrderNumber", "internalPurchaseOrderNumber"];
|
|
10739
10889
|
var CONTRACT_SCOPED = ["contractServiceID", "contractServiceBundleID"];
|
|
10740
10890
|
async function readCharge(http, id, retries) {
|
|
10741
|
-
const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }],
|
|
10891
|
+
const rows = await queryRows(http, "TicketCharges", [{ field: "id", op: "eq", value: id }], OP5, retries);
|
|
10742
10892
|
return _nullishCoalesce(rows[0], () => ( null));
|
|
10743
10893
|
}
|
|
10744
10894
|
async function checkSource({ http, source, sourceId, sourceTicketId, toTicketId }) {
|
|
10745
10895
|
if (source.isBilled === true) {
|
|
10746
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
10896
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP5}: ticket charge ${sourceId} is billed \u2014 move it in the Autotask UI`, { sourceId, toTicketId }, OP5, {
|
|
10747
10897
|
manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "tickets", sourceTicketId), reason: "billed charges are not moved by the API (the ticket link opens its charges)" }
|
|
10748
10898
|
});
|
|
10749
10899
|
}
|
|
10750
10900
|
}
|
|
10751
10901
|
var SPEC = {
|
|
10752
|
-
operation:
|
|
10902
|
+
operation: OP5,
|
|
10753
10903
|
entity: "ticket_charge",
|
|
10754
10904
|
readSource: readCharge,
|
|
10755
10905
|
sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
|
|
@@ -10785,7 +10935,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
|
|
|
10785
10935
|
}
|
|
10786
10936
|
|
|
10787
10937
|
// src/resources/ticket_charges.ts
|
|
10788
|
-
var TicketChargesResource = class extends
|
|
10938
|
+
var TicketChargesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10789
10939
|
constructor(http, pageSize) {
|
|
10790
10940
|
super(http, {
|
|
10791
10941
|
key: "ticket_charges",
|
|
@@ -10851,7 +11001,7 @@ var TicketChargesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
10851
11001
|
/** Search TicketCharge records: bounded contains on name (no vendor free-text search exists);
|
|
10852
11002
|
* limit defaults to 25, max 500. */
|
|
10853
11003
|
async search(query, opts) {
|
|
10854
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
11004
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _110 => _110.limit]) });
|
|
10855
11005
|
}
|
|
10856
11006
|
/** Node-parity special op (hand-written in src/resources/special/ticket_charges.ts). */
|
|
10857
11007
|
moveToTicket(sourceId, toTicketId, opts = {}) {
|
|
@@ -10860,7 +11010,7 @@ var TicketChargesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
10860
11010
|
};
|
|
10861
11011
|
|
|
10862
11012
|
// src/resources/ticket_checklist_items.ts
|
|
10863
|
-
var TicketChecklistItemsResource = class extends
|
|
11013
|
+
var TicketChecklistItemsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10864
11014
|
constructor(http, pageSize) {
|
|
10865
11015
|
super(http, {
|
|
10866
11016
|
key: "ticket_checklist_items",
|
|
@@ -10926,7 +11076,7 @@ var TicketChecklistItemsResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
10926
11076
|
};
|
|
10927
11077
|
|
|
10928
11078
|
// src/resources/ticket_checklist_libraries.ts
|
|
10929
|
-
var TicketChecklistLibrariesResource = class extends
|
|
11079
|
+
var TicketChecklistLibrariesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10930
11080
|
constructor(http, pageSize) {
|
|
10931
11081
|
super(http, {
|
|
10932
11082
|
key: "ticket_checklist_libraries",
|
|
@@ -10950,9 +11100,9 @@ var TicketChecklistLibrariesResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
10950
11100
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
10951
11101
|
* surface — no documents read op — and never issues the POST). */
|
|
10952
11102
|
async attachToDocument(documentID, data, opts = {}) {
|
|
10953
|
-
const n =
|
|
11103
|
+
const n = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
10954
11104
|
if (opts.dryRun === true) {
|
|
10955
|
-
return
|
|
11105
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
10956
11106
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10957
11107
|
method: "POST",
|
|
10958
11108
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -10970,7 +11120,7 @@ var TicketChecklistLibrariesResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
10970
11120
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10971
11121
|
maxRetries: opts.maxRetries
|
|
10972
11122
|
});
|
|
10973
|
-
return
|
|
11123
|
+
return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
|
|
10974
11124
|
}
|
|
10975
11125
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
10976
11126
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10986,7 +11136,7 @@ var TicketChecklistLibrariesResource = class extends _chunkIKPFR6K2cjs.BaseResou
|
|
|
10986
11136
|
};
|
|
10987
11137
|
|
|
10988
11138
|
// src/resources/ticket_history.ts
|
|
10989
|
-
var TicketHistoryResource = class extends
|
|
11139
|
+
var TicketHistoryResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
10990
11140
|
constructor(http, pageSize) {
|
|
10991
11141
|
super(http, {
|
|
10992
11142
|
key: "ticket_history",
|
|
@@ -11025,7 +11175,7 @@ var TicketHistoryResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
11025
11175
|
};
|
|
11026
11176
|
|
|
11027
11177
|
// src/resources/ticket_note_attachments.ts
|
|
11028
|
-
var TicketNoteAttachmentsResource = class extends
|
|
11178
|
+
var TicketNoteAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
11029
11179
|
constructor(http, pageSize) {
|
|
11030
11180
|
super(http, {
|
|
11031
11181
|
key: "ticket_note_attachments",
|
|
@@ -11087,7 +11237,7 @@ var TicketNoteAttachmentsResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
11087
11237
|
};
|
|
11088
11238
|
|
|
11089
11239
|
// src/resources/ticket_notes.ts
|
|
11090
|
-
var TicketNotesResource = class extends
|
|
11240
|
+
var TicketNotesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
11091
11241
|
constructor(http, pageSize) {
|
|
11092
11242
|
super(http, {
|
|
11093
11243
|
key: "ticket_notes",
|
|
@@ -11146,7 +11296,7 @@ var TicketNotesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
11146
11296
|
};
|
|
11147
11297
|
|
|
11148
11298
|
// src/resources/ticket_note_webhooks.ts
|
|
11149
|
-
var TicketNoteWebhooksResource = class extends
|
|
11299
|
+
var TicketNoteWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
11150
11300
|
constructor(http, pageSize) {
|
|
11151
11301
|
super(http, {
|
|
11152
11302
|
key: "ticket_note_webhooks",
|
|
@@ -11217,12 +11367,12 @@ var TicketNoteWebhooksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
11217
11367
|
/** Search TicketNoteWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
11218
11368
|
* limit defaults to 25, max 500. */
|
|
11219
11369
|
async search(query, opts) {
|
|
11220
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
11370
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _111 => _111.limit]) });
|
|
11221
11371
|
}
|
|
11222
11372
|
};
|
|
11223
11373
|
|
|
11224
11374
|
// src/resources/ticket_secondary_resources.ts
|
|
11225
|
-
var TicketSecondaryResourcesResource = class extends
|
|
11375
|
+
var TicketSecondaryResourcesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
11226
11376
|
constructor(http, pageSize) {
|
|
11227
11377
|
super(http, {
|
|
11228
11378
|
key: "ticket_secondary_resources",
|
|
@@ -11287,9 +11437,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
11287
11437
|
});
|
|
11288
11438
|
const body = res;
|
|
11289
11439
|
if (body === null || !("item" in body)) {
|
|
11290
|
-
throw new (0,
|
|
11440
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
11291
11441
|
}
|
|
11292
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
11442
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
11293
11443
|
return body.item;
|
|
11294
11444
|
}
|
|
11295
11445
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -11300,7 +11450,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
11300
11450
|
body: { MaxRecords: maxRecords, filter },
|
|
11301
11451
|
operation
|
|
11302
11452
|
});
|
|
11303
|
-
return
|
|
11453
|
+
return _chunk4QN43TRPcjs.unwrapItems.call(void 0, res).items;
|
|
11304
11454
|
}
|
|
11305
11455
|
function truncate(text, limit) {
|
|
11306
11456
|
const full = _nullishCoalesce(text, () => ( ""));
|
|
@@ -11310,26 +11460,26 @@ function truncate(text, limit) {
|
|
|
11310
11460
|
|
|
11311
11461
|
// src/resources/special/tickets/childRead.ts
|
|
11312
11462
|
function isRouteUnavailable(err) {
|
|
11313
|
-
return
|
|
11463
|
+
return _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
11314
11464
|
}
|
|
11315
11465
|
function routeFact(route, path, err) {
|
|
11316
11466
|
return {
|
|
11317
11467
|
route,
|
|
11318
11468
|
path,
|
|
11319
|
-
httpStatus:
|
|
11469
|
+
httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
11320
11470
|
};
|
|
11321
11471
|
}
|
|
11322
11472
|
function childDeclaresQuery(resourceKey) {
|
|
11323
|
-
return
|
|
11473
|
+
return _chunkSP2SJJZXcjs.CAPABILITIES.some(
|
|
11324
11474
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
11325
11475
|
);
|
|
11326
11476
|
}
|
|
11327
11477
|
function planScopedPath(resourceKey, ticketId) {
|
|
11328
11478
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
11329
|
-
const entry =
|
|
11479
|
+
const entry = _chunk4QN43TRPcjs.RELATIONSHIP_MAP[resourceKey];
|
|
11330
11480
|
const parent = entry === void 0 ? null : entry.parent;
|
|
11331
11481
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
11332
|
-
const parentPath = _optionalChain([
|
|
11482
|
+
const parentPath = _optionalChain([_chunk4QN43TRPcjs.RELATIONSHIP_MAP, 'access', _112 => _112[parent.resource], 'optionalAccess', _113 => _113.path]);
|
|
11333
11483
|
if (parentPath === null || parentPath === void 0) return null;
|
|
11334
11484
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
11335
11485
|
}
|
|
@@ -11368,14 +11518,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
11368
11518
|
break;
|
|
11369
11519
|
}
|
|
11370
11520
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
11371
|
-
const { items: pageItems, pageDetails } =
|
|
11521
|
+
const { items: pageItems, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, body, operation);
|
|
11372
11522
|
nextCursor = pageDetails.nextPageUrl;
|
|
11373
11523
|
pages += 1;
|
|
11374
11524
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
11375
11525
|
for (const row of window) if (accept(row)) items.push(row);
|
|
11376
11526
|
if (items.length >= limit) break;
|
|
11377
11527
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
11378
|
-
target =
|
|
11528
|
+
target = _chunk4QN43TRPcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
11379
11529
|
}
|
|
11380
11530
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
11381
11531
|
return { items, capped };
|
|
@@ -11408,7 +11558,7 @@ var MS = 864e5;
|
|
|
11408
11558
|
var SLA_PAGE = 100;
|
|
11409
11559
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
11410
11560
|
void opts;
|
|
11411
|
-
const ticketId =
|
|
11561
|
+
const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
11412
11562
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
11413
11563
|
const rows = await ticketQueryItems(
|
|
11414
11564
|
http,
|
|
@@ -11418,12 +11568,12 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
11418
11568
|
"tickets.slaHealthCheck"
|
|
11419
11569
|
);
|
|
11420
11570
|
const slas = rows.map((row) => {
|
|
11421
|
-
const
|
|
11571
|
+
const bool2 = (v) => typeof v === "boolean" ? v : null;
|
|
11422
11572
|
const num2 = (v) => typeof v === "number" ? v : null;
|
|
11423
11573
|
const milestones = [
|
|
11424
|
-
{ name: "firstResponse", met:
|
|
11425
|
-
{ name: "resolution", met:
|
|
11426
|
-
{ name: "resolutionPlan", met:
|
|
11574
|
+
{ name: "firstResponse", met: bool2(row.isFirstResponseMet), elapsedHours: num2(row.firstResponseElapsedHours) },
|
|
11575
|
+
{ name: "resolution", met: bool2(row.isResolutionMet), elapsedHours: num2(row.resolutionElapsedHours) },
|
|
11576
|
+
{ name: "resolutionPlan", met: bool2(row.isResolutionPlanMet), elapsedHours: num2(row.resolutionPlanElapsedHours) }
|
|
11427
11577
|
];
|
|
11428
11578
|
return { id: Number(row.id), name: _nullishCoalesce(row.serviceLevelAgreementName, () => ( null)), milestones };
|
|
11429
11579
|
});
|
|
@@ -11433,19 +11583,19 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
11433
11583
|
async function summary(_resource, id, opts = {}, http) {
|
|
11434
11584
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
11435
11585
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
11436
|
-
throw new (0,
|
|
11586
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
11437
11587
|
}
|
|
11438
|
-
const ticketId =
|
|
11588
|
+
const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
11439
11589
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
11440
11590
|
const desc = truncate(ticket.description, limit);
|
|
11441
11591
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
11442
11592
|
const ageDays = typeof ticket.createDate === "string" && ticket.createDate !== "" ? Math.max(0, Math.floor((now.getTime() - Date.parse(ticket.createDate)) / MS)) : null;
|
|
11443
11593
|
const pick = (v) => typeof v === "number" ? v : null;
|
|
11444
|
-
const
|
|
11594
|
+
const str2 = (v) => typeof v === "string" && v !== "" ? v : null;
|
|
11445
11595
|
return {
|
|
11446
11596
|
ticketId,
|
|
11447
|
-
ticketNumber:
|
|
11448
|
-
title:
|
|
11597
|
+
ticketNumber: str2(ticket.ticketNumber),
|
|
11598
|
+
title: str2(ticket.title),
|
|
11449
11599
|
description: desc.value,
|
|
11450
11600
|
descriptionLength: desc.length,
|
|
11451
11601
|
descriptionTruncated: desc.truncated,
|
|
@@ -11455,8 +11605,8 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
11455
11605
|
contactID: pick(ticket.contactID),
|
|
11456
11606
|
assignedResourceID: pick(ticket.assignedResourceID),
|
|
11457
11607
|
projectID: pick(ticket.projectID),
|
|
11458
|
-
createDate:
|
|
11459
|
-
dueDateTime:
|
|
11608
|
+
createDate: str2(ticket.createDate),
|
|
11609
|
+
dueDateTime: str2(ticket.dueDateTime),
|
|
11460
11610
|
ageDays
|
|
11461
11611
|
};
|
|
11462
11612
|
}
|
|
@@ -11464,11 +11614,11 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
11464
11614
|
// src/resources/special/tickets/timeline.ts
|
|
11465
11615
|
function validateTimelineLimits(opts) {
|
|
11466
11616
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
11467
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
11617
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
11468
11618
|
const bounded = Math.min(limit, 500);
|
|
11469
11619
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
11470
11620
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
11471
|
-
throw new (0,
|
|
11621
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
11472
11622
|
}
|
|
11473
11623
|
return { bounded, textLimit };
|
|
11474
11624
|
}
|
|
@@ -11520,7 +11670,7 @@ function compareEventDates(a, b) {
|
|
|
11520
11670
|
}
|
|
11521
11671
|
async function timeline(_resource, id, opts = {}, http) {
|
|
11522
11672
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
11523
|
-
const ticketId =
|
|
11673
|
+
const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
11524
11674
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
11525
11675
|
const dateFilters = (field) => {
|
|
11526
11676
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11560,7 +11710,7 @@ async function timeline(_resource, id, opts = {}, http) {
|
|
|
11560
11710
|
}
|
|
11561
11711
|
|
|
11562
11712
|
// src/resources/special/tickets/errors.ts
|
|
11563
|
-
var QueueRequiredError = class extends
|
|
11713
|
+
var QueueRequiredError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
11564
11714
|
constructor(message, options = {}) {
|
|
11565
11715
|
super(message, {
|
|
11566
11716
|
code: "QUEUE_REQUIRED",
|
|
@@ -11571,13 +11721,13 @@ var QueueRequiredError = class extends _chunkIKPFR6K2cjs.AutotaskError {
|
|
|
11571
11721
|
this.name = "QueueRequiredError";
|
|
11572
11722
|
}
|
|
11573
11723
|
};
|
|
11574
|
-
var TicketResourceInvalidError = class extends
|
|
11724
|
+
var TicketResourceInvalidError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
11575
11725
|
constructor(message, options = {}) {
|
|
11576
11726
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11577
11727
|
this.name = "TicketResourceInvalidError";
|
|
11578
11728
|
}
|
|
11579
11729
|
};
|
|
11580
|
-
var TicketCreateValidationFailedError = class extends
|
|
11730
|
+
var TicketCreateValidationFailedError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
11581
11731
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
11582
11732
|
|
|
11583
11733
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -11586,7 +11736,7 @@ var TicketCreateValidationFailedError = class extends _chunkIKPFR6K2cjs.Autotask
|
|
|
11586
11736
|
this.vendorFields = vendorFields;
|
|
11587
11737
|
}
|
|
11588
11738
|
};
|
|
11589
|
-
var StatusUnknownError = class extends
|
|
11739
|
+
var StatusUnknownError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
11590
11740
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
11591
11741
|
|
|
11592
11742
|
constructor(message, options = {}) {
|
|
@@ -11600,7 +11750,7 @@ var StatusUnknownError = class extends _chunkIKPFR6K2cjs.AutotaskError {
|
|
|
11600
11750
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
11601
11751
|
}
|
|
11602
11752
|
};
|
|
11603
|
-
var StatusFieldsRequiredError = class extends
|
|
11753
|
+
var StatusFieldsRequiredError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
11604
11754
|
|
|
11605
11755
|
|
|
11606
11756
|
|
|
@@ -11623,21 +11773,21 @@ function isPositiveInt(v) {
|
|
|
11623
11773
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
11624
11774
|
}
|
|
11625
11775
|
function namedVendorFields(err) {
|
|
11626
|
-
if (!
|
|
11627
|
-
const entries = _nullishCoalesce(
|
|
11776
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
11777
|
+
const entries = _nullishCoalesce(_chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
11628
11778
|
const out = /* @__PURE__ */ new Set();
|
|
11629
11779
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
11630
11780
|
return [...out];
|
|
11631
11781
|
}
|
|
11632
11782
|
function vendorDetailOf(err) {
|
|
11633
|
-
return
|
|
11783
|
+
return _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? _chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
11634
11784
|
}
|
|
11635
11785
|
async function fetchItem(http, path, operation, readOpts) {
|
|
11636
|
-
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11786
|
+
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _114 => _114.maxRetries]) });
|
|
11637
11787
|
return unwrapItemOrNull(res);
|
|
11638
11788
|
}
|
|
11639
11789
|
async function fetchItemUnredacted(http, path, operation, readOpts) {
|
|
11640
|
-
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11790
|
+
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _115 => _115.maxRetries]) });
|
|
11641
11791
|
return unwrapItemOrNull(res);
|
|
11642
11792
|
}
|
|
11643
11793
|
function unwrapItemOrNull(res) {
|
|
@@ -11651,8 +11801,8 @@ function operationId(res) {
|
|
|
11651
11801
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
11652
11802
|
}
|
|
11653
11803
|
function discoveryMerge(err, body, defaults) {
|
|
11654
|
-
if (!
|
|
11655
|
-
const entries =
|
|
11804
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11805
|
+
const entries = _chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11656
11806
|
if (entries === void 0) return null;
|
|
11657
11807
|
for (const entry of entries) {
|
|
11658
11808
|
const field = entry.field;
|
|
@@ -11664,7 +11814,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
11664
11814
|
}
|
|
11665
11815
|
function stepErrorText(code, err) {
|
|
11666
11816
|
const detail = vendorDetailOf(err);
|
|
11667
|
-
const base =
|
|
11817
|
+
const base = _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
11668
11818
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
11669
11819
|
}
|
|
11670
11820
|
|
|
@@ -11676,43 +11826,43 @@ var DEFAULT_PUBLISH = 1;
|
|
|
11676
11826
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
11677
11827
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
11678
11828
|
function validateOpenInput(params, note, assign) {
|
|
11679
|
-
const companyID =
|
|
11680
|
-
const title = _optionalChain([params, 'optionalAccess',
|
|
11829
|
+
const companyID = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _116 => _116.companyID]), "params.companyID");
|
|
11830
|
+
const title = _optionalChain([params, 'optionalAccess', _117 => _117.title]);
|
|
11681
11831
|
if (typeof title !== "string" || title.trim() === "") {
|
|
11682
|
-
throw new (0,
|
|
11832
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
11683
11833
|
}
|
|
11684
11834
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
11685
11835
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
11686
11836
|
if (!isPositiveInt(priority)) {
|
|
11687
|
-
throw new (0,
|
|
11837
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
11688
11838
|
}
|
|
11689
11839
|
if (!isPositiveInt(status)) {
|
|
11690
|
-
throw new (0,
|
|
11840
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
11691
11841
|
}
|
|
11692
11842
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
11693
|
-
throw new (0,
|
|
11843
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
11694
11844
|
}
|
|
11695
11845
|
if (note !== void 0) {
|
|
11696
11846
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
11697
|
-
throw new (0,
|
|
11847
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
11698
11848
|
}
|
|
11699
11849
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
11700
|
-
throw new (0,
|
|
11850
|
+
throw new (0, _chunk4QN43TRPcjs.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 });
|
|
11701
11851
|
}
|
|
11702
11852
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
11703
|
-
throw new (0,
|
|
11853
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
11704
11854
|
}
|
|
11705
11855
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
11706
|
-
throw new (0,
|
|
11856
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
11707
11857
|
}
|
|
11708
11858
|
}
|
|
11709
|
-
const assignee = assign === void 0 ? void 0 :
|
|
11859
|
+
const assignee = assign === void 0 ? void 0 : _chunk4QN43TRPcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
11710
11860
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
11711
|
-
throw new (0,
|
|
11861
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
11712
11862
|
}
|
|
11713
|
-
const roleID = _optionalChain([assign, 'optionalAccess',
|
|
11863
|
+
const roleID = _optionalChain([assign, 'optionalAccess', _118 => _118.roleID]);
|
|
11714
11864
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
11715
|
-
throw new (0,
|
|
11865
|
+
throw new (0, _chunk4QN43TRPcjs.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 });
|
|
11716
11866
|
}
|
|
11717
11867
|
return { companyID, title, priority, status, assignee, roleID };
|
|
11718
11868
|
}
|
|
@@ -11741,7 +11891,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
|
|
|
11741
11891
|
if (assign !== void 0) {
|
|
11742
11892
|
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).`);
|
|
11743
11893
|
}
|
|
11744
|
-
return
|
|
11894
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
11745
11895
|
{
|
|
11746
11896
|
operation: OP_OPEN,
|
|
11747
11897
|
method: "POST",
|
|
@@ -11781,8 +11931,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11781
11931
|
`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}` : ""}`,
|
|
11782
11932
|
{
|
|
11783
11933
|
operation: OP_OPEN,
|
|
11784
|
-
httpStatus:
|
|
11785
|
-
vendorError:
|
|
11934
|
+
httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11935
|
+
vendorError: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
11786
11936
|
}
|
|
11787
11937
|
);
|
|
11788
11938
|
}
|
|
@@ -11797,8 +11947,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11797
11947
|
named,
|
|
11798
11948
|
{
|
|
11799
11949
|
operation: OP_OPEN,
|
|
11800
|
-
httpStatus:
|
|
11801
|
-
vendorError:
|
|
11950
|
+
httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11951
|
+
vendorError: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11802
11952
|
resourceIds: [companyID],
|
|
11803
11953
|
details: { idRefs: [{ entity: "company", id: companyID }] }
|
|
11804
11954
|
}
|
|
@@ -11823,10 +11973,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
|
|
|
11823
11973
|
try {
|
|
11824
11974
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
11825
11975
|
if (current === null) {
|
|
11826
|
-
throw new (0,
|
|
11976
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11827
11977
|
}
|
|
11828
11978
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
11829
|
-
const merged =
|
|
11979
|
+
const merged = _chunk4QN43TRPcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
11830
11980
|
merged.id = ticketId;
|
|
11831
11981
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
11832
11982
|
assigned = true;
|
|
@@ -11890,17 +12040,17 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11890
12040
|
const ids2 = await readLiveStatusSet(resource);
|
|
11891
12041
|
if (ids2.size > 0) liveStatus = ids2;
|
|
11892
12042
|
} catch (err) {
|
|
11893
|
-
if (!
|
|
12043
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11894
12044
|
}
|
|
11895
12045
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
11896
|
-
_optionalChain([http, 'access',
|
|
12046
|
+
_optionalChain([http, 'access', _119 => _119.fieldCache, 'optionalAccess', _120 => _120.invalidate, 'call', _121 => _121("tickets")]);
|
|
11897
12047
|
let freshStatus = null;
|
|
11898
12048
|
let reReadFailed = false;
|
|
11899
12049
|
try {
|
|
11900
12050
|
const freshIds = await readLiveStatusSet(resource);
|
|
11901
12051
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
11902
12052
|
} catch (err) {
|
|
11903
|
-
if (!
|
|
12053
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11904
12054
|
freshStatus = null;
|
|
11905
12055
|
reReadFailed = true;
|
|
11906
12056
|
}
|
|
@@ -11918,7 +12068,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11918
12068
|
return { guardDegraded: liveStatus === null };
|
|
11919
12069
|
}
|
|
11920
12070
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
11921
|
-
return
|
|
12071
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
11922
12072
|
{
|
|
11923
12073
|
operation: OP_STATUS,
|
|
11924
12074
|
method: "PUT",
|
|
@@ -11949,7 +12099,7 @@ function resolveMergeData(ticketId, targetStatus, previousStatus, current, field
|
|
|
11949
12099
|
for (const field of mapEntry.requiredFields) {
|
|
11950
12100
|
if (mergeData[field] !== void 0) continue;
|
|
11951
12101
|
if (current[field] !== null && current[field] !== void 0) continue;
|
|
11952
|
-
const safe = _optionalChain([mapEntry, 'access',
|
|
12102
|
+
const safe = _optionalChain([mapEntry, 'access', _122 => _122.safeDefaults, 'optionalAccess', _123 => _123[field]]);
|
|
11953
12103
|
if (safe === void 0) {
|
|
11954
12104
|
throw new StatusFieldsRequiredError(
|
|
11955
12105
|
`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`,
|
|
@@ -11972,7 +12122,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11972
12122
|
if (mapEntry === void 0) {
|
|
11973
12123
|
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).`);
|
|
11974
12124
|
}
|
|
11975
|
-
return
|
|
12125
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
11976
12126
|
{
|
|
11977
12127
|
operation: OP_STATUS,
|
|
11978
12128
|
method: "PUT",
|
|
@@ -11991,8 +12141,8 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11991
12141
|
);
|
|
11992
12142
|
}
|
|
11993
12143
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
11994
|
-
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess',
|
|
11995
|
-
const body =
|
|
12144
|
+
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _124 => _124.safeDefaults]), () => ( {}));
|
|
12145
|
+
const body = _chunk4QN43TRPcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
11996
12146
|
body.id = ticketId;
|
|
11997
12147
|
let merges = 0;
|
|
11998
12148
|
for (; ; ) {
|
|
@@ -12016,8 +12166,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
12016
12166
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
12017
12167
|
{
|
|
12018
12168
|
operation: OP_STATUS,
|
|
12019
|
-
httpStatus:
|
|
12020
|
-
vendorError:
|
|
12169
|
+
httpStatus: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
12170
|
+
vendorError: _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
12021
12171
|
resourceIds: [ticketId],
|
|
12022
12172
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
12023
12173
|
}
|
|
@@ -12030,7 +12180,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
12030
12180
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
12031
12181
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
12032
12182
|
if (verify === null) {
|
|
12033
|
-
throw new (0,
|
|
12183
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
12034
12184
|
code: "INVALID_RESPONSE",
|
|
12035
12185
|
category: "server",
|
|
12036
12186
|
operation: OP_STATUS,
|
|
@@ -12040,7 +12190,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
12040
12190
|
}
|
|
12041
12191
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
12042
12192
|
if (finalStatus !== targetStatus) {
|
|
12043
|
-
throw new (0,
|
|
12193
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskError)(
|
|
12044
12194
|
`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)`,
|
|
12045
12195
|
{
|
|
12046
12196
|
code: "INVALID_RESPONSE",
|
|
@@ -12055,17 +12205,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
12055
12205
|
}
|
|
12056
12206
|
}
|
|
12057
12207
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
12058
|
-
const ticketId =
|
|
12208
|
+
const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
12059
12209
|
if (!isPositiveInt(targetStatus)) {
|
|
12060
|
-
throw new (0,
|
|
12210
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
12061
12211
|
}
|
|
12062
12212
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
12063
12213
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
12064
|
-
throw new (0,
|
|
12214
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
12065
12215
|
}
|
|
12066
12216
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
12067
12217
|
if (current === null) {
|
|
12068
|
-
throw new (0,
|
|
12218
|
+
throw new (0, _chunk4QN43TRPcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
12069
12219
|
}
|
|
12070
12220
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
12071
12221
|
if (previousStatus === targetStatus) {
|
|
@@ -12085,7 +12235,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
12085
12235
|
function partLimit(value, name) {
|
|
12086
12236
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
12087
12237
|
if (!Number.isInteger(n) || n < 1) {
|
|
12088
|
-
throw new (0,
|
|
12238
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
12089
12239
|
}
|
|
12090
12240
|
return n;
|
|
12091
12241
|
}
|
|
@@ -12098,13 +12248,13 @@ function servedTextRecord(row, textField, limit) {
|
|
|
12098
12248
|
return out;
|
|
12099
12249
|
}
|
|
12100
12250
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
12101
|
-
const builder =
|
|
12251
|
+
const builder = _chunk4QN43TRPcjs.createNamePlan.call(void 0, _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS);
|
|
12102
12252
|
const t = ctx.ticket;
|
|
12103
12253
|
builder.addResource(t["creatorResourceID"]);
|
|
12104
12254
|
builder.addFk("contract", t["contractID"]);
|
|
12105
12255
|
builder.addFk("billingCode", t["billingCodeID"]);
|
|
12106
12256
|
builder.addFk("role", t["assignedResourceRoleID"]);
|
|
12107
|
-
const ticketLobPointer =
|
|
12257
|
+
const ticketLobPointer = _chunk4QN43TRPcjs.vendorId.call(void 0, t["organizationalLevelAssociationID"]);
|
|
12108
12258
|
if (ticketLobPointer !== void 0) {
|
|
12109
12259
|
builder.addLineOfBusiness(ticketLobPointer, { source: "ticket" });
|
|
12110
12260
|
} else {
|
|
@@ -12116,20 +12266,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
|
12116
12266
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
12117
12267
|
builder.addFk("contract", e["contractID"]);
|
|
12118
12268
|
}
|
|
12119
|
-
const names = await
|
|
12269
|
+
const names = await _chunk4QN43TRPcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
12120
12270
|
const ticketRow = { ...ctx.ticket };
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
for (const f of
|
|
12271
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
12272
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
12273
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
12274
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
12275
|
+
for (const f of _chunk4QN43TRPcjs.TICKET_LABEL_FIELDS) _chunk4QN43TRPcjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
12126
12276
|
result.ticket = ticketRow;
|
|
12127
12277
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
12128
12278
|
const row = { ...e };
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12279
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
12280
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
12281
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
12282
|
+
_chunk4QN43TRPcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
12133
12283
|
return row;
|
|
12134
12284
|
});
|
|
12135
12285
|
result.names = names.section;
|
|
@@ -12145,7 +12295,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
12145
12295
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
12146
12296
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
12147
12297
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
12148
|
-
const ticketId =
|
|
12298
|
+
const ticketId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
12149
12299
|
const ctx = await resource.getContext(ticketId);
|
|
12150
12300
|
const op = "tickets.fullContext";
|
|
12151
12301
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -12203,7 +12353,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
12203
12353
|
}
|
|
12204
12354
|
|
|
12205
12355
|
// src/resources/special/tickets/forResource.ts
|
|
12206
|
-
var
|
|
12356
|
+
var OP6 = "tickets.forResource";
|
|
12207
12357
|
var TICKET_CHUNK = 100;
|
|
12208
12358
|
var LIMIT_DEFAULT = 100;
|
|
12209
12359
|
var LIMIT_MAX = 500;
|
|
@@ -12212,7 +12362,7 @@ var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResource
|
|
|
12212
12362
|
function positiveId2(value, name) {
|
|
12213
12363
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12214
12364
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12215
|
-
throw new (0,
|
|
12365
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP6 });
|
|
12216
12366
|
}
|
|
12217
12367
|
return n;
|
|
12218
12368
|
}
|
|
@@ -12222,28 +12372,28 @@ async function ticketPage(http, filter, maxRecords, fields) {
|
|
|
12222
12372
|
idempotent: true,
|
|
12223
12373
|
path: "/V1.0/Tickets/query",
|
|
12224
12374
|
body: { MaxRecords: maxRecords, filter, IncludeFields: fields },
|
|
12225
|
-
operation:
|
|
12375
|
+
operation: OP6
|
|
12226
12376
|
});
|
|
12227
|
-
const page =
|
|
12377
|
+
const page = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, OP6);
|
|
12228
12378
|
return { rows: page.items, more: page.pageDetails.nextPageUrl !== null };
|
|
12229
12379
|
}
|
|
12230
12380
|
async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
12231
|
-
if (opts === null || typeof opts !== "object") throw new (0,
|
|
12381
|
+
if (opts === null || typeof opts !== "object") throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: opts must be an object`, { operation: OP6 });
|
|
12232
12382
|
const resourceID = positiveId2(resourceIDIn, "resourceID");
|
|
12233
12383
|
const scope = _nullishCoalesce(opts.scope, () => ( "both"));
|
|
12234
12384
|
if (scope !== "primary" && scope !== "secondary" && scope !== "both") {
|
|
12235
|
-
throw new (0,
|
|
12385
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: scope must be 'primary', 'secondary' or 'both' (got ${JSON.stringify(opts.scope)})`, { operation: OP6 });
|
|
12236
12386
|
}
|
|
12237
12387
|
if (opts.openOnly !== void 0 && typeof opts.openOnly !== "boolean") {
|
|
12238
|
-
throw new (0,
|
|
12388
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: openOnly must be a boolean`, { operation: OP6 });
|
|
12239
12389
|
}
|
|
12240
12390
|
const limit = opts.limit === void 0 ? LIMIT_DEFAULT : opts.limit;
|
|
12241
12391
|
if (!Number.isInteger(limit) || limit < 1 || limit > LIMIT_MAX) {
|
|
12242
|
-
throw new (0,
|
|
12392
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: limit must be an integer 1-${LIMIT_MAX} (got ${String(opts.limit)})`, { operation: OP6 });
|
|
12243
12393
|
}
|
|
12244
12394
|
const includeFields = _nullishCoalesce(opts.includeFields, () => ( []));
|
|
12245
12395
|
if (!Array.isArray(includeFields) || includeFields.some((f) => typeof f !== "string" || f.length === 0)) {
|
|
12246
|
-
throw new (0,
|
|
12396
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP6}: includeFields must be a list of field names`, { operation: OP6 });
|
|
12247
12397
|
}
|
|
12248
12398
|
const openOnly = opts.openOnly === true;
|
|
12249
12399
|
const fields = [.../* @__PURE__ */ new Set([...TICKET_FIELDS2, ...includeFields])];
|
|
@@ -12258,9 +12408,9 @@ async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
|
12258
12408
|
idempotent: true,
|
|
12259
12409
|
path: "/V1.0/TicketSecondaryResources/query",
|
|
12260
12410
|
body: { MaxRecords: LINK_READ_CAP, filter: [{ field: "resourceID", op: "eq", value: resourceID }], IncludeFields: ["ticketID"] },
|
|
12261
|
-
operation:
|
|
12411
|
+
operation: OP6
|
|
12262
12412
|
});
|
|
12263
|
-
const page =
|
|
12413
|
+
const page = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, OP6);
|
|
12264
12414
|
for (const row of page.items) if (typeof row.ticketID === "number" && !linkIds.includes(row.ticketID)) linkIds.push(row.ticketID);
|
|
12265
12415
|
if (page.items.length >= LINK_READ_CAP || page.pageDetails.nextPageUrl !== null) capped = true;
|
|
12266
12416
|
}
|
|
@@ -12313,11 +12463,11 @@ async function forResource(_resource, resourceIDIn, http, opts = {}) {
|
|
|
12313
12463
|
}
|
|
12314
12464
|
|
|
12315
12465
|
// src/resources/special/tickets/lineOfBusiness.ts
|
|
12316
|
-
var
|
|
12466
|
+
var OP7 = "tickets.lineOfBusiness";
|
|
12317
12467
|
function positiveId3(value, name) {
|
|
12318
12468
|
const n = typeof value === "string" && /^[0-9]+$/.test(value.trim()) ? Number(value) : value;
|
|
12319
12469
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12320
|
-
throw new (0,
|
|
12470
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(OP7 + ": " + name + " must be a positive integer id (got " + String(value) + ")", { operation: OP7 });
|
|
12321
12471
|
}
|
|
12322
12472
|
return n;
|
|
12323
12473
|
}
|
|
@@ -12332,25 +12482,25 @@ async function lineOfBusiness2(resource, ticketIdIn, http, associationIdIn) {
|
|
|
12332
12482
|
associationSource = "argument";
|
|
12333
12483
|
} else {
|
|
12334
12484
|
const ticket = await resource.get(ticketId);
|
|
12335
|
-
associationId =
|
|
12485
|
+
associationId = _chunk4QN43TRPcjs.vendorId.call(void 0, ticket.organizationalLevelAssociationID);
|
|
12336
12486
|
if (associationId !== void 0) {
|
|
12337
12487
|
associationSource = "ticket";
|
|
12338
12488
|
} else {
|
|
12339
|
-
const contractRef =
|
|
12489
|
+
const contractRef = _chunk4QN43TRPcjs.vendorId.call(void 0, ticket.contractID);
|
|
12340
12490
|
if (contractRef !== void 0) {
|
|
12341
12491
|
const client = http.client;
|
|
12342
12492
|
if (client === void 0) {
|
|
12343
|
-
throw new (0,
|
|
12493
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(OP7 + ": the transport is not wired to an AutotaskClient (the composite must run through the client)", { operation: OP7 });
|
|
12344
12494
|
}
|
|
12345
12495
|
try {
|
|
12346
12496
|
const contract = await client.contracts.get(contractRef);
|
|
12347
12497
|
contractId = contractRef;
|
|
12348
|
-
associationId =
|
|
12498
|
+
associationId = _chunk4QN43TRPcjs.vendorId.call(void 0, contract.organizationalLevelAssociationID);
|
|
12349
12499
|
if (associationId !== void 0) associationSource = "contract";
|
|
12350
12500
|
} catch (e) {
|
|
12351
|
-
if (e instanceof
|
|
12501
|
+
if (e instanceof _chunk4QN43TRPcjs.NotFoundError) {
|
|
12352
12502
|
contractId = contractRef;
|
|
12353
|
-
} else if (
|
|
12503
|
+
} else if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) && e.code !== "ABORTED") {
|
|
12354
12504
|
contractId = contractRef;
|
|
12355
12505
|
contractUnread = true;
|
|
12356
12506
|
} else {
|
|
@@ -12371,7 +12521,7 @@ async function lineOfBusiness2(resource, ticketIdIn, http, associationIdIn) {
|
|
|
12371
12521
|
markers: { association: contractUnread ? "unresolved" : "missing", organizationalLevel2: "missing", organizationalLevel1: "missing" }
|
|
12372
12522
|
};
|
|
12373
12523
|
}
|
|
12374
|
-
const chain = await
|
|
12524
|
+
const chain = await _chunk4QN43TRPcjs.resolveLineOfBusinessChain.call(void 0, http, associationId, { budget: 3, operation: OP7, onError: "propagate" });
|
|
12375
12525
|
const { association, organizationalLevel2, organizationalLevel1, markers } = chain.lineOfBusiness;
|
|
12376
12526
|
return { ticketId, associationSource, contractId, association, organizationalLevel2, organizationalLevel1, markers };
|
|
12377
12527
|
}
|
|
@@ -12382,7 +12532,7 @@ async function statusSemantics(_resource, opts = {}, http) {
|
|
|
12382
12532
|
}
|
|
12383
12533
|
|
|
12384
12534
|
// src/resources/tickets.ts
|
|
12385
|
-
var TicketsResource = class extends
|
|
12535
|
+
var TicketsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
12386
12536
|
constructor(http, pageSize) {
|
|
12387
12537
|
super(http, {
|
|
12388
12538
|
key: "tickets",
|
|
@@ -12501,7 +12651,7 @@ var TicketsResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
12501
12651
|
};
|
|
12502
12652
|
|
|
12503
12653
|
// src/resources/ticket_webhooks.ts
|
|
12504
|
-
var TicketWebhooksResource = class extends
|
|
12654
|
+
var TicketWebhooksResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
12505
12655
|
constructor(http, pageSize) {
|
|
12506
12656
|
super(http, {
|
|
12507
12657
|
key: "ticket_webhooks",
|
|
@@ -12572,7 +12722,7 @@ var TicketWebhooksResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
12572
12722
|
/** Search TicketWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
12573
12723
|
* limit defaults to 25, max 500. */
|
|
12574
12724
|
async search(query, opts) {
|
|
12575
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
12725
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _125 => _125.limit]) });
|
|
12576
12726
|
}
|
|
12577
12727
|
};
|
|
12578
12728
|
|
|
@@ -12582,8 +12732,8 @@ async function postedStateOf(http, entries, op) {
|
|
|
12582
12732
|
const states = /* @__PURE__ */ new Map();
|
|
12583
12733
|
const ids2 = [...new Set(entries.map((e) => e.id))];
|
|
12584
12734
|
let incomplete = false;
|
|
12585
|
-
for (let c = 0; c < ids2.length; c +=
|
|
12586
|
-
const chunk = ids2.slice(c, c +
|
|
12735
|
+
for (let c = 0; c < ids2.length; c += _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
12736
|
+
const chunk = ids2.slice(c, c + _chunk4QN43TRPcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
12587
12737
|
const res = await http.request({
|
|
12588
12738
|
method: "POST",
|
|
12589
12739
|
idempotent: true,
|
|
@@ -12591,7 +12741,7 @@ async function postedStateOf(http, entries, op) {
|
|
|
12591
12741
|
body: { MaxRecords: 500, IncludeFields: ["id", "timeEntryID"], filter: [{ field: "timeEntryID", op: "in", value: chunk }] },
|
|
12592
12742
|
operation: op
|
|
12593
12743
|
});
|
|
12594
|
-
const { items, pageDetails } =
|
|
12744
|
+
const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res);
|
|
12595
12745
|
const billed = new Set(items.map((i) => i.timeEntryID));
|
|
12596
12746
|
const more = pageDetails.nextPageUrl != null;
|
|
12597
12747
|
if (more) incomplete = true;
|
|
@@ -12614,77 +12764,77 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
12614
12764
|
body: { MaxRecords: limit, filter },
|
|
12615
12765
|
operation
|
|
12616
12766
|
});
|
|
12617
|
-
const { items, pageDetails } =
|
|
12767
|
+
const { items, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res);
|
|
12618
12768
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
12619
12769
|
}
|
|
12620
12770
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
12621
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
12622
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
12771
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _126 => _126.now]), () => ( /* @__PURE__ */ new Date()));
|
|
12772
|
+
const tz = _optionalChain([opts, 'optionalAccess', _127 => _127.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
|
|
12623
12773
|
const { from, to } = dateOnlyWindowBounds(kind, now, tz);
|
|
12624
12774
|
const filter = [
|
|
12625
12775
|
{ field: "dateWorked", op: "gte", value: from },
|
|
12626
12776
|
{ field: "dateWorked", op: "lte", value: to }
|
|
12627
12777
|
];
|
|
12628
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12778
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _128 => _128.limit])), `time_entries.${kind}`, http);
|
|
12629
12779
|
return items;
|
|
12630
12780
|
}
|
|
12631
12781
|
async function customRange3(_resource, from, to, http, opts) {
|
|
12632
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12782
|
+
if (_optionalChain([opts, 'optionalAccess', _129 => _129.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
|
|
12633
12783
|
const fromB = customRangeDay(from, "from", void 0, "customRange");
|
|
12634
12784
|
const toB = customRangeDay(to, "to", void 0, "customRange");
|
|
12635
12785
|
if (fromB.ms > toB.ms) {
|
|
12636
|
-
throw new (0,
|
|
12786
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
12637
12787
|
}
|
|
12638
12788
|
const toEndMs = toB.ms + DAY_MS2 - 1;
|
|
12639
12789
|
const filter = [
|
|
12640
12790
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
12641
12791
|
{ field: "dateWorked", op: "lte", value: iso2(toEndMs) }
|
|
12642
12792
|
];
|
|
12643
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12793
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _130 => _130.limit])), "time_entries.customRange", http);
|
|
12644
12794
|
return items;
|
|
12645
12795
|
}
|
|
12646
12796
|
async function postedStateQuery(_resource, mode, http, opts) {
|
|
12647
12797
|
const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
|
|
12648
12798
|
const window = { from: null, to: null };
|
|
12649
12799
|
const filter = [];
|
|
12650
|
-
const fromB = _optionalChain([opts, 'optionalAccess',
|
|
12651
|
-
const toB = _optionalChain([opts, 'optionalAccess',
|
|
12800
|
+
const fromB = _optionalChain([opts, 'optionalAccess', _131 => _131.dateFrom]) === void 0 ? void 0 : customRangeDay(opts.dateFrom, "from", void 0, operation);
|
|
12801
|
+
const toB = _optionalChain([opts, 'optionalAccess', _132 => _132.dateTo]) === void 0 ? void 0 : customRangeDay(opts.dateTo, "to", void 0, operation);
|
|
12652
12802
|
if (fromB && toB && fromB.ms > toB.ms) {
|
|
12653
|
-
throw new (0,
|
|
12803
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${operation}: dateFrom (${iso2(fromB.ms)}) must not be after dateTo (${iso2(toB.ms)})`, { operation });
|
|
12654
12804
|
}
|
|
12655
12805
|
if (fromB) filter.push({ field: "dateWorked", op: "gte", value: window.from = iso2(fromB.ms) });
|
|
12656
12806
|
if (toB) filter.push({ field: "dateWorked", op: "lte", value: window.to = iso2(toB.ms + DAY_MS2 - 1) });
|
|
12657
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12658
|
-
const read = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12807
|
+
if (_optionalChain([opts, 'optionalAccess', _133 => _133.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12808
|
+
const read = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _134 => _134.limit])), operation, http);
|
|
12659
12809
|
const { states, incomplete } = await postedStateOf(http, read.items, operation);
|
|
12660
12810
|
const items = read.items.filter((e) => states.get(e.id) === mode);
|
|
12661
12811
|
const approvedCount = items.filter(isApproved).length;
|
|
12662
12812
|
return { items, hasMore: read.hasMore || incomplete, window, approvedCount, unapprovedCount: items.length - approvedCount };
|
|
12663
12813
|
}
|
|
12664
12814
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
12665
|
-
const
|
|
12666
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12667
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
12668
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
12815
|
+
const OP12 = opLabel;
|
|
12816
|
+
if (_optionalChain([opts, 'optionalAccess', _135 => _135.tz]) !== void 0) validateZone(opts.tz, OP12);
|
|
12817
|
+
const fromB = customRangeDay(from, "from", void 0, OP12);
|
|
12818
|
+
const toB = customRangeDay(to, "to", void 0, OP12);
|
|
12669
12819
|
if (fromB.ms > toB.ms) {
|
|
12670
|
-
throw new (0,
|
|
12820
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP12}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP12 });
|
|
12671
12821
|
}
|
|
12672
12822
|
const windowToMs = toB.ms + DAY_MS2 - 1;
|
|
12673
12823
|
const filter = [
|
|
12674
12824
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
12675
12825
|
{ field: "dateWorked", op: "lte", value: iso2(windowToMs) }
|
|
12676
12826
|
];
|
|
12677
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12678
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12679
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12680
|
-
const { states, incomplete } = await postedStateOf(http, items,
|
|
12827
|
+
if (_optionalChain([opts, 'optionalAccess', _136 => _136.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12828
|
+
if (_optionalChain([opts, 'optionalAccess', _137 => _137.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
12829
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _138 => _138.limit])), OP12, http);
|
|
12830
|
+
const { states, incomplete } = await postedStateOf(http, items, OP12);
|
|
12681
12831
|
let postedCount = 0;
|
|
12682
12832
|
let unpostedCount = 0;
|
|
12683
12833
|
for (const state of states.values()) {
|
|
12684
12834
|
if (state === "posted") postedCount += 1;
|
|
12685
12835
|
else unpostedCount += 1;
|
|
12686
12836
|
}
|
|
12687
|
-
const keep = _optionalChain([opts, 'optionalAccess',
|
|
12837
|
+
const keep = _optionalChain([opts, 'optionalAccess', _139 => _139.posted]) === void 0 ? void 0 : opts.posted ? "posted" : "unposted";
|
|
12688
12838
|
return {
|
|
12689
12839
|
items: keep === void 0 ? items : items.filter((e) => states.get(e.id) === keep),
|
|
12690
12840
|
postedCount,
|
|
@@ -12700,13 +12850,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
|
|
|
12700
12850
|
}
|
|
12701
12851
|
|
|
12702
12852
|
// src/resources/special/time_entries/errors.ts
|
|
12703
|
-
var ResourceInvalidError = class extends
|
|
12853
|
+
var ResourceInvalidError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
12704
12854
|
constructor(message, options = {}) {
|
|
12705
12855
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
12706
12856
|
this.name = "ResourceInvalidError";
|
|
12707
12857
|
}
|
|
12708
12858
|
};
|
|
12709
|
-
var AllocationCodeError = class extends
|
|
12859
|
+
var AllocationCodeError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
12710
12860
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
12711
12861
|
|
|
12712
12862
|
constructor(kind, message, options = {}) {
|
|
@@ -12715,7 +12865,7 @@ var AllocationCodeError = class extends _chunkIKPFR6K2cjs.AutotaskError {
|
|
|
12715
12865
|
this.kind = kind;
|
|
12716
12866
|
}
|
|
12717
12867
|
};
|
|
12718
|
-
var NoApplicableAllocationCodeError = class extends
|
|
12868
|
+
var NoApplicableAllocationCodeError = class extends _chunk4QN43TRPcjs.AutotaskError {
|
|
12719
12869
|
/** The structured blocker details (filters tried + department sets). */
|
|
12720
12870
|
|
|
12721
12871
|
constructor(details, options = {}) {
|
|
@@ -12780,7 +12930,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12780
12930
|
let pages = 0;
|
|
12781
12931
|
for (; ; ) {
|
|
12782
12932
|
if (pages >= PAGE_GUARD) {
|
|
12783
|
-
throw new (0,
|
|
12933
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
12784
12934
|
code: "RESOLUTION_TRUNCATED",
|
|
12785
12935
|
category: "resolution",
|
|
12786
12936
|
operation,
|
|
@@ -12791,11 +12941,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12791
12941
|
const res = await http.request({
|
|
12792
12942
|
method: "POST",
|
|
12793
12943
|
idempotent: true,
|
|
12794
|
-
path: isFirst ? path :
|
|
12944
|
+
path: isFirst ? path : _chunk4QN43TRPcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
12795
12945
|
body: { MaxRecords: pageSize, filter },
|
|
12796
12946
|
operation
|
|
12797
12947
|
});
|
|
12798
|
-
const { items: pageItems, pageDetails } =
|
|
12948
|
+
const { items: pageItems, pageDetails } = _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, operation);
|
|
12799
12949
|
items.push(...pageItems);
|
|
12800
12950
|
pages += 1;
|
|
12801
12951
|
if (items.length >= totalCap) break;
|
|
@@ -12887,7 +13037,7 @@ async function resolveCode(http, family, familyLabel2, pinnedId, departments, op
|
|
|
12887
13037
|
}
|
|
12888
13038
|
|
|
12889
13039
|
// src/resources/special/time_entries/createForResource.ts
|
|
12890
|
-
var
|
|
13040
|
+
var OP8 = "time_entries.createForResource";
|
|
12891
13041
|
var PARAM_KEYS = /* @__PURE__ */ new Set([
|
|
12892
13042
|
"internallAllocationCodeID",
|
|
12893
13043
|
"ticketID",
|
|
@@ -12912,7 +13062,7 @@ function windowDefaults(params) {
|
|
|
12912
13062
|
var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
|
|
12913
13063
|
var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
|
|
12914
13064
|
function validateCreateParams(params) {
|
|
12915
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
13065
|
+
const pin = (value, label) => typeof value === "number" ? _chunk4QN43TRPcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
12916
13066
|
const pins = {
|
|
12917
13067
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
12918
13068
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -12921,32 +13071,32 @@ function validateCreateParams(params) {
|
|
|
12921
13071
|
};
|
|
12922
13072
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
12923
13073
|
if (pinCount > 1) {
|
|
12924
|
-
throw new (0,
|
|
13074
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
12925
13075
|
"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)",
|
|
12926
|
-
{ operation:
|
|
13076
|
+
{ operation: OP8 }
|
|
12927
13077
|
);
|
|
12928
13078
|
}
|
|
12929
13079
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
12930
|
-
throw new (0,
|
|
13080
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
12931
13081
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
12932
|
-
{ operation:
|
|
13082
|
+
{ operation: OP8 }
|
|
12933
13083
|
);
|
|
12934
13084
|
}
|
|
12935
13085
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
12936
|
-
throw new (0,
|
|
13086
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
12937
13087
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
12938
|
-
{ operation:
|
|
13088
|
+
{ operation: OP8 }
|
|
12939
13089
|
);
|
|
12940
13090
|
}
|
|
12941
13091
|
return pins;
|
|
12942
13092
|
}
|
|
12943
13093
|
async function assertResourceActive(http, rid) {
|
|
12944
|
-
const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`,
|
|
13094
|
+
const rec = await fetchItem2(http, `/V1.0/Resources/${rid}`, OP8);
|
|
12945
13095
|
if (rec === null) {
|
|
12946
13096
|
throw new ResourceInvalidError(`Resource ${rid} was not found \u2014 a time entry cannot attach to a missing resource`, {
|
|
12947
13097
|
resourceIds: [rid],
|
|
12948
13098
|
details: { idRefs: [{ entity: "resource", id: rid }] },
|
|
12949
|
-
operation:
|
|
13099
|
+
operation: OP8,
|
|
12950
13100
|
category: "not_found",
|
|
12951
13101
|
suggestedAction: "Resolve the resource id (resources.get / resources.search) and retry."
|
|
12952
13102
|
});
|
|
@@ -12955,7 +13105,7 @@ async function assertResourceActive(http, rid) {
|
|
|
12955
13105
|
throw new ResourceInvalidError(`Resource ${rid} is not active (isActive !== true) \u2014 the vendor would reject a time entry for an inactive resource`, {
|
|
12956
13106
|
resourceIds: [rid],
|
|
12957
13107
|
details: { idRefs: [{ entity: "resource", id: rid }] },
|
|
12958
|
-
operation:
|
|
13108
|
+
operation: OP8,
|
|
12959
13109
|
suggestedAction: "Activate the resource or pick an active one."
|
|
12960
13110
|
});
|
|
12961
13111
|
}
|
|
@@ -12965,11 +13115,11 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
|
|
|
12965
13115
|
const pinnedForCode = pins.code !== void 0 ? pins.code : pins.role;
|
|
12966
13116
|
let code = null;
|
|
12967
13117
|
const familiesTried = [];
|
|
12968
|
-
code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments,
|
|
13118
|
+
code = await resolveCode(http, familyOf(linkage), familyLabel(familyOf(linkage)), pinnedForCode, departments, OP8);
|
|
12969
13119
|
familiesTried.push({ family: familyOf(linkage), label: familyLabel(familyOf(linkage)), filters: [{ field: "useType", op: "eq", value: familyOf(linkage) }, { field: "isActive", op: "eq", value: true }] });
|
|
12970
13120
|
if (code === null && linkage === "task" && pins.role === void 0) {
|
|
12971
13121
|
usedLinkage = "internal";
|
|
12972
|
-
code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments,
|
|
13122
|
+
code = await resolveCode(http, USE_TYPE_INTERNAL, familyLabel(USE_TYPE_INTERNAL), void 0, departments, OP8);
|
|
12973
13123
|
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 }] });
|
|
12974
13124
|
}
|
|
12975
13125
|
if (code === null) {
|
|
@@ -12979,7 +13129,7 @@ async function resolveAllocationCode(http, rid, linkage, pins, departments) {
|
|
|
12979
13129
|
families: familiesTried,
|
|
12980
13130
|
resourceDepartments: [...departments].sort((a, b) => a - b)
|
|
12981
13131
|
},
|
|
12982
|
-
{ operation:
|
|
13132
|
+
{ operation: OP8 }
|
|
12983
13133
|
);
|
|
12984
13134
|
}
|
|
12985
13135
|
const resolvedCode = codeInfo(code);
|
|
@@ -13016,9 +13166,9 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
|
|
|
13016
13166
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
13017
13167
|
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).");
|
|
13018
13168
|
}
|
|
13019
|
-
return
|
|
13169
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
13020
13170
|
{
|
|
13021
|
-
operation:
|
|
13171
|
+
operation: OP8,
|
|
13022
13172
|
method: "POST",
|
|
13023
13173
|
path: "/V1.0/TimeEntries",
|
|
13024
13174
|
ids: [rid],
|
|
@@ -13056,11 +13206,11 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
13056
13206
|
};
|
|
13057
13207
|
} catch (err) {
|
|
13058
13208
|
lastError = err;
|
|
13059
|
-
const text =
|
|
13209
|
+
const text = _chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunk4QN43TRPcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
13060
13210
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
13061
13211
|
if (usedLinkage !== "internal" && gate3) {
|
|
13062
13212
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
13063
|
-
const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`,
|
|
13213
|
+
const task = await fetchItem2(http, `/V1.0/Tasks/${pins.task}`, OP8);
|
|
13064
13214
|
taskRoleFetched = true;
|
|
13065
13215
|
if (task !== null) pushLadder(task.assignedResourceRoleID);
|
|
13066
13216
|
}
|
|
@@ -13076,17 +13226,17 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
13076
13226
|
throw err;
|
|
13077
13227
|
}
|
|
13078
13228
|
}
|
|
13079
|
-
if (
|
|
13229
|
+
if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, lastError)) {
|
|
13080
13230
|
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.`;
|
|
13081
13231
|
}
|
|
13082
13232
|
throw lastError;
|
|
13083
13233
|
}
|
|
13084
13234
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
13085
|
-
const rid =
|
|
13235
|
+
const rid = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
13086
13236
|
const pins = validateCreateParams(params);
|
|
13087
13237
|
await assertResourceActive(http, rid);
|
|
13088
13238
|
const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
|
|
13089
|
-
const roleRows = await resourceRoleRows(http, rid,
|
|
13239
|
+
const roleRows = await resourceRoleRows(http, rid, OP8);
|
|
13090
13240
|
const departments = roleRows.departments;
|
|
13091
13241
|
const { usedLinkage, resolvedCode } = await resolveAllocationCode(http, rid, linkage, pins, departments);
|
|
13092
13242
|
const defaults = windowDefaults(params);
|
|
@@ -13095,8 +13245,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
13095
13245
|
return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
|
|
13096
13246
|
}
|
|
13097
13247
|
function discoveryField(err, body, defaults) {
|
|
13098
|
-
if (!
|
|
13099
|
-
const entries =
|
|
13248
|
+
if (!_chunk4QN43TRPcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
13249
|
+
const entries = _chunk4QN43TRPcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
13100
13250
|
if (entries === void 0) return null;
|
|
13101
13251
|
for (const entry of entries) {
|
|
13102
13252
|
const field = entry.field;
|
|
@@ -13109,42 +13259,42 @@ function discoveryField(err, body, defaults) {
|
|
|
13109
13259
|
}
|
|
13110
13260
|
|
|
13111
13261
|
// src/resources/special/time_entries/move.ts
|
|
13112
|
-
var
|
|
13262
|
+
var OP9 = "time_entries.moveToTicket";
|
|
13113
13263
|
var COPY2 = ["resourceID", "roleID", "billingCodeID", "dateWorked", "startDateTime", "endDateTime", "hoursWorked", "offsetHours", "summaryNotes", "internalNotes", "isNonBillable", "showOnInvoice"];
|
|
13114
13264
|
var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundleID"];
|
|
13115
13265
|
async function readTimeEntry(http, id, retries) {
|
|
13116
13266
|
try {
|
|
13117
|
-
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation:
|
|
13118
|
-
return _nullishCoalesce(_optionalChain([res, 'optionalAccess',
|
|
13267
|
+
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP9, maxRetries: retries });
|
|
13268
|
+
return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _140 => _140.item]), () => ( null));
|
|
13119
13269
|
} catch (e) {
|
|
13120
|
-
if (
|
|
13270
|
+
if (_chunk4QN43TRPcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
13121
13271
|
throw e;
|
|
13122
13272
|
}
|
|
13123
13273
|
}
|
|
13124
13274
|
async function checkSource2({ http, source, sourceId, toTicketId, retries }) {
|
|
13125
13275
|
const ids2 = { sourceId, toTicketId };
|
|
13126
13276
|
if (source.taskID !== null && source.taskID !== void 0) {
|
|
13127
|
-
throw refuse("MOVE_SOURCE_UNSUPPORTED", `${
|
|
13277
|
+
throw refuse("MOVE_SOURCE_UNSUPPORTED", `${OP9}: time entry ${sourceId} is on a task \u2014 only ticket time entries are moved`, ids2, OP9);
|
|
13128
13278
|
}
|
|
13129
13279
|
if (source.billingApprovalDateTime || source.billingApprovalResourceID || source.billingApprovalLevelMostRecent) {
|
|
13130
|
-
throw refuse("MOVE_BLOCKED_APPROVED", `${
|
|
13280
|
+
throw refuse("MOVE_BLOCKED_APPROVED", `${OP9}: time entry ${sourceId} has billing approval set \u2014 move it in the Autotask UI`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "approved entries are not moved by the API" } });
|
|
13131
13281
|
}
|
|
13132
13282
|
let billing;
|
|
13133
13283
|
try {
|
|
13134
|
-
billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }],
|
|
13284
|
+
billing = await queryRows(http, "BillingItems", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP9, retries);
|
|
13135
13285
|
} catch (e3) {
|
|
13136
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
13286
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP9}: the billing items of time entry ${sourceId} could not be read \u2014 refused (fails closed)`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billing state unreadable" } });
|
|
13137
13287
|
}
|
|
13138
13288
|
if (billing.some((b) => b.invoiceID || b.postedDate)) {
|
|
13139
|
-
throw refuse("MOVE_BLOCKED_BILLED", `${
|
|
13289
|
+
throw refuse("MOVE_BLOCKED_BILLED", `${OP9}: time entry ${sourceId} is billed or posted \u2014 move it in the Autotask UI`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "billed entries are not moved by the API" } });
|
|
13140
13290
|
}
|
|
13141
|
-
const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }],
|
|
13291
|
+
const attachments = await queryRows(http, "TimeEntryAttachments", [{ field: "timeEntryID", op: "eq", value: sourceId }], OP9, retries);
|
|
13142
13292
|
if (attachments.length > 0) {
|
|
13143
|
-
throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${
|
|
13293
|
+
throw refuse("MOVE_BLOCKED_ATTACHMENTS", `${OP9}: time entry ${sourceId} has attachments, which a delete would destroy \u2014 move it in the Autotask UI`, ids2, OP9, { manualAction: { action: "delete_source", uiLink: uiLinkFor(http, "time_entries", sourceId), reason: "entries with attachments are not moved by the API" } });
|
|
13144
13294
|
}
|
|
13145
13295
|
}
|
|
13146
13296
|
var SPEC2 = {
|
|
13147
|
-
operation:
|
|
13297
|
+
operation: OP9,
|
|
13148
13298
|
entity: "time_entry",
|
|
13149
13299
|
readSource: readTimeEntry,
|
|
13150
13300
|
sourceTicketId: (s) => typeof s.ticketID === "number" ? s.ticketID : null,
|
|
@@ -13179,15 +13329,15 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
|
|
|
13179
13329
|
}
|
|
13180
13330
|
|
|
13181
13331
|
// src/resources/special/time_entries/approve.ts
|
|
13182
|
-
var
|
|
13332
|
+
var OP10 = "time_entries.approve";
|
|
13183
13333
|
var APPROVAL_LEVELS_PATH = "/V1.0/BillingItemApprovalLevels";
|
|
13184
13334
|
function toIso(value) {
|
|
13185
13335
|
if (value instanceof Date) {
|
|
13186
|
-
if (Number.isNaN(value.getTime())) throw new (0,
|
|
13336
|
+
if (Number.isNaN(value.getTime())) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
|
|
13187
13337
|
return value.toISOString();
|
|
13188
13338
|
}
|
|
13189
13339
|
const parsed = new Date(value);
|
|
13190
|
-
if (Number.isNaN(parsed.getTime())) throw new (0,
|
|
13340
|
+
if (Number.isNaN(parsed.getTime())) throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
|
|
13191
13341
|
return parsed.toISOString();
|
|
13192
13342
|
}
|
|
13193
13343
|
function toNumber(value) {
|
|
@@ -13200,24 +13350,24 @@ function sameInstant(a, b) {
|
|
|
13200
13350
|
return !Number.isNaN(left) && left === right;
|
|
13201
13351
|
}
|
|
13202
13352
|
async function approve(resource, id, opts = {}, http) {
|
|
13203
|
-
const numericId = toNumber(
|
|
13353
|
+
const numericId = toNumber(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id"));
|
|
13204
13354
|
if (opts.approvalLevel !== void 0 && (!Number.isInteger(opts.approvalLevel) || opts.approvalLevel < 1)) {
|
|
13205
|
-
throw new (0,
|
|
13355
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
|
|
13206
13356
|
}
|
|
13207
13357
|
const approvalLevel = _nullishCoalesce(opts.approvalLevel, () => ( 1));
|
|
13208
13358
|
const approvalDateTime = toIso(_nullishCoalesce(opts.approvalDateTime, () => ( /* @__PURE__ */ new Date())));
|
|
13209
13359
|
const entry = await resource.get(numericId);
|
|
13210
|
-
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(
|
|
13360
|
+
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
|
|
13211
13361
|
if (approvalResourceID === void 0) {
|
|
13212
|
-
throw new (0,
|
|
13362
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(
|
|
13213
13363
|
`time_entries.approve: time entry ${numericId} carries no resourceID and the caller supplied no approvalResourceID \u2014 the vendor requires an approving resource`
|
|
13214
13364
|
);
|
|
13215
13365
|
}
|
|
13216
13366
|
const body = { timeEntryID: numericId, approvalLevel, approvalResourceID, approvalDateTime };
|
|
13217
13367
|
if (opts.dryRun === true) {
|
|
13218
|
-
return
|
|
13368
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0,
|
|
13219
13369
|
{
|
|
13220
|
-
operation:
|
|
13370
|
+
operation: OP10,
|
|
13221
13371
|
method: "POST",
|
|
13222
13372
|
path: APPROVAL_LEVELS_PATH,
|
|
13223
13373
|
ids: [numericId],
|
|
@@ -13240,10 +13390,10 @@ async function approve(resource, id, opts = {}, http) {
|
|
|
13240
13390
|
method: "POST",
|
|
13241
13391
|
path: APPROVAL_LEVELS_PATH,
|
|
13242
13392
|
body,
|
|
13243
|
-
operation:
|
|
13393
|
+
operation: OP10,
|
|
13244
13394
|
maxRetries: opts.maxRetries
|
|
13245
13395
|
});
|
|
13246
|
-
const levelId = toNumber(
|
|
13396
|
+
const levelId = toNumber(_chunk4QN43TRPcjs.parseIdentifier.call(void 0, _chunk4QN43TRPcjs.unwrapOperation.call(void 0, created, OP10).id, "billingItemApprovalLevelID"));
|
|
13247
13397
|
await resource.update(
|
|
13248
13398
|
numericId,
|
|
13249
13399
|
{ billingApprovalDateTime: approvalDateTime, billingApprovalResourceID: approvalResourceID },
|
|
@@ -13266,28 +13416,28 @@ async function approve(resource, id, opts = {}, http) {
|
|
|
13266
13416
|
}
|
|
13267
13417
|
|
|
13268
13418
|
// src/resources/special/time_entries/recentTickets.ts
|
|
13269
|
-
var
|
|
13419
|
+
var OP11 = "time_entries.recentTickets";
|
|
13270
13420
|
var DAY_MS3 = 864e5;
|
|
13271
13421
|
var TICKET_CHUNK2 = 100;
|
|
13272
13422
|
var TICKET_FIELDS3 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
13273
13423
|
function positiveId4(value, name) {
|
|
13274
13424
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
13275
13425
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
13276
|
-
throw new (0,
|
|
13426
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP11}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP11 });
|
|
13277
13427
|
}
|
|
13278
13428
|
return n;
|
|
13279
13429
|
}
|
|
13280
13430
|
async function recentTickets(_resource, from, to, http, opts) {
|
|
13281
13431
|
if (opts === void 0 || opts === null || typeof opts !== "object") {
|
|
13282
|
-
throw new (0,
|
|
13432
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP11}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP11 });
|
|
13283
13433
|
}
|
|
13284
13434
|
const resourceID = positiveId4(opts.resourceID, "resourceID");
|
|
13285
13435
|
const companyID = opts.companyID === void 0 ? void 0 : positiveId4(opts.companyID, "companyID");
|
|
13286
|
-
if (opts.tz !== void 0) validateZone(opts.tz,
|
|
13287
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
13288
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
13436
|
+
if (opts.tz !== void 0) validateZone(opts.tz, OP11);
|
|
13437
|
+
const fromB = customRangeDay(from, "from", void 0, OP11);
|
|
13438
|
+
const toB = customRangeDay(to, "to", void 0, OP11);
|
|
13289
13439
|
if (fromB.ms > toB.ms) {
|
|
13290
|
-
throw new (0,
|
|
13440
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)(`${OP11}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP11 });
|
|
13291
13441
|
}
|
|
13292
13442
|
const windowToMs = toB.ms + DAY_MS3 - 1;
|
|
13293
13443
|
const { items: entries, hasMore } = await queryTimeEntries(
|
|
@@ -13298,7 +13448,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13298
13448
|
{ field: "resourceID", op: "eq", value: resourceID }
|
|
13299
13449
|
],
|
|
13300
13450
|
clampWindowLimit(opts.limit),
|
|
13301
|
-
|
|
13451
|
+
OP11,
|
|
13302
13452
|
http
|
|
13303
13453
|
);
|
|
13304
13454
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -13324,9 +13474,9 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13324
13474
|
idempotent: true,
|
|
13325
13475
|
path: "/V1.0/Tickets/query",
|
|
13326
13476
|
body: { MaxRecords: TICKET_CHUNK2, filter, IncludeFields: TICKET_FIELDS3 },
|
|
13327
|
-
operation:
|
|
13477
|
+
operation: OP11
|
|
13328
13478
|
});
|
|
13329
|
-
for (const t of
|
|
13479
|
+
for (const t of _chunk4QN43TRPcjs.unwrapItems.call(void 0, res, OP11).items) if (typeof t.id === "number") tickets.set(t.id, t);
|
|
13330
13480
|
}
|
|
13331
13481
|
const items = [];
|
|
13332
13482
|
const unresolvedTicketIDs = [];
|
|
@@ -13334,17 +13484,17 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13334
13484
|
for (const [ticketID, g] of groups) {
|
|
13335
13485
|
const t = tickets.get(ticketID);
|
|
13336
13486
|
if (t === void 0) unresolvedTicketIDs.push(ticketID);
|
|
13337
|
-
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess',
|
|
13487
|
+
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _141 => _141.companyID]) !== companyID) {
|
|
13338
13488
|
if (t !== void 0) excludedTickets += 1;
|
|
13339
13489
|
continue;
|
|
13340
13490
|
}
|
|
13341
13491
|
items.push({
|
|
13342
13492
|
ticketID,
|
|
13343
|
-
..._optionalChain([t, 'optionalAccess',
|
|
13344
|
-
..._optionalChain([t, 'optionalAccess',
|
|
13345
|
-
..._optionalChain([t, 'optionalAccess',
|
|
13346
|
-
..._optionalChain([t, 'optionalAccess',
|
|
13347
|
-
..._optionalChain([t, 'optionalAccess',
|
|
13493
|
+
..._optionalChain([t, 'optionalAccess', _142 => _142.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
|
|
13494
|
+
..._optionalChain([t, 'optionalAccess', _143 => _143.title]) !== void 0 ? { title: t.title } : {},
|
|
13495
|
+
..._optionalChain([t, 'optionalAccess', _144 => _144.status]) !== void 0 ? { status: t.status } : {},
|
|
13496
|
+
..._optionalChain([t, 'optionalAccess', _145 => _145.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
|
|
13497
|
+
..._optionalChain([t, 'optionalAccess', _146 => _146.companyID]) !== void 0 ? { companyID: t.companyID } : {},
|
|
13348
13498
|
entryCount: g.entryCount,
|
|
13349
13499
|
totalHours: Math.round(g.totalHours * 100) / 100,
|
|
13350
13500
|
lastWorked: g.lastWorked
|
|
@@ -13363,7 +13513,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
13363
13513
|
}
|
|
13364
13514
|
|
|
13365
13515
|
// src/resources/time_entries.ts
|
|
13366
|
-
var TimeEntriesResource = class extends
|
|
13516
|
+
var TimeEntriesResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
13367
13517
|
constructor(http, pageSize) {
|
|
13368
13518
|
super(http, {
|
|
13369
13519
|
key: "time_entries",
|
|
@@ -13512,7 +13662,7 @@ var TimeEntriesResource = class extends _chunkIKPFR6K2cjs.BaseResource {
|
|
|
13512
13662
|
};
|
|
13513
13663
|
|
|
13514
13664
|
// src/resources/time_entry_attachments.ts
|
|
13515
|
-
var TimeEntryAttachmentsResource = class extends
|
|
13665
|
+
var TimeEntryAttachmentsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
13516
13666
|
constructor(http, pageSize) {
|
|
13517
13667
|
super(http, {
|
|
13518
13668
|
key: "time_entry_attachments",
|
|
@@ -13575,9 +13725,9 @@ var TimeEntryAttachmentsResource = class extends _chunkIKPFR6K2cjs.BaseResource
|
|
|
13575
13725
|
|
|
13576
13726
|
// src/resources/special/time_off_requests.ts
|
|
13577
13727
|
async function approve2(_resource, id, opts = {}, http) {
|
|
13578
|
-
const numericId =
|
|
13728
|
+
const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
13579
13729
|
if (opts.dryRun === true) {
|
|
13580
|
-
return
|
|
13730
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
13581
13731
|
operation: "time_off_requests.approve",
|
|
13582
13732
|
method: "GET",
|
|
13583
13733
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -13593,16 +13743,16 @@ async function approve2(_resource, id, opts = {}, http) {
|
|
|
13593
13743
|
operation: "time_off_requests.approve",
|
|
13594
13744
|
maxRetries: opts.maxRetries
|
|
13595
13745
|
});
|
|
13596
|
-
return
|
|
13746
|
+
return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
|
|
13597
13747
|
}
|
|
13598
13748
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
13599
|
-
const numericId =
|
|
13749
|
+
const numericId = _chunk4QN43TRPcjs.parseIdentifier.call(void 0, id, "id");
|
|
13600
13750
|
const text = reason.trim();
|
|
13601
13751
|
if (text === "") {
|
|
13602
|
-
throw new (0,
|
|
13752
|
+
throw new (0, _chunk4QN43TRPcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
13603
13753
|
}
|
|
13604
13754
|
if (opts.dryRun === true) {
|
|
13605
|
-
return
|
|
13755
|
+
return _chunk4QN43TRPcjs.buildDryRunResult.call(void 0, {
|
|
13606
13756
|
operation: "time_off_requests.reject",
|
|
13607
13757
|
method: "POST",
|
|
13608
13758
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -13620,11 +13770,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
13620
13770
|
operation: "time_off_requests.reject",
|
|
13621
13771
|
maxRetries: opts.maxRetries
|
|
13622
13772
|
});
|
|
13623
|
-
return
|
|
13773
|
+
return _chunk4QN43TRPcjs.unwrapOperation.call(void 0, res);
|
|
13624
13774
|
}
|
|
13625
13775
|
|
|
13626
13776
|
// src/resources/time_off_requests.ts
|
|
13627
|
-
var TimeOffRequestsResource = class extends
|
|
13777
|
+
var TimeOffRequestsResource = class extends _chunk4QN43TRPcjs.BaseResource {
|
|
13628
13778
|
constructor(http, pageSize) {
|
|
13629
13779
|
super(http, {
|
|
13630
13780
|
key: "time_off_requests",
|