node-autotask 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MCP_TOOL_CATALOG.json +1 -1
- package/MCP_TOOL_MANIFEST.md +2 -2
- package/N8N_MCP_MANIFEST.json +2 -2
- package/N8N_MCP_MANIFEST.md +3 -3
- package/capabilities.json +5 -5
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-TELBX6HK.cjs → chunk-36PG2IU2.cjs} +767 -583
- package/dist/{chunk-JKZVCFRY.cjs → chunk-CSRCMBZ2.cjs} +4 -4
- package/dist/{chunk-5N6DYKXO.cjs → chunk-IHRXVIUU.cjs} +2 -2
- package/dist/{chunk-4A6XLQHE.js → chunk-NACI2NDF.js} +4 -4
- package/dist/{chunk-MY7ZSXY3.js → chunk-P35GFG2H.js} +357 -173
- package/dist/{chunk-SRJI5XUZ.cjs → chunk-PGQIGE63.cjs} +135 -135
- package/dist/{chunk-3WIDDEHP.js → chunk-PPTAMCFA.js} +2 -2
- package/dist/{chunk-GD4JRPYF.js → chunk-ZOA5HUFX.js} +1 -1
- package/dist/{index-D8I6taEo.d.cts → index-DZfd9Gt7.d.cts} +67 -16
- package/dist/{index-uAxAcRol.d.ts → index-UilX3PFL.d.ts} +67 -16
- package/dist/index.cjs +20 -20
- 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 +103 -103
- package/dist/operations/index.d.cts +2 -2
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +8 -8
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +3 -3
- package/docs/API.md +157 -48
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkIHRXVIUUcjs = require('./chunk-IHRXVIUU.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunkCSRCMBZ2cjs = require('./chunk-CSRCMBZ2.cjs');
|
|
40
40
|
|
|
41
41
|
// src/resources/appointments.ts
|
|
42
|
-
var AppointmentsResource = class extends
|
|
42
|
+
var AppointmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
43
43
|
constructor(http, pageSize) {
|
|
44
44
|
super(http, {
|
|
45
45
|
key: "appointments",
|
|
@@ -124,7 +124,7 @@ var AuthenticateResource = class {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
// src/resources/billing_codes.ts
|
|
127
|
-
var BillingCodesResource = class extends
|
|
127
|
+
var BillingCodesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
128
128
|
constructor(http, pageSize) {
|
|
129
129
|
super(http, {
|
|
130
130
|
key: "billing_codes",
|
|
@@ -174,7 +174,7 @@ var MAX_LIMIT = 500;
|
|
|
174
174
|
function clampWindowLimit(limit) {
|
|
175
175
|
const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
|
|
176
176
|
if (!Number.isInteger(n) || n < 1) {
|
|
177
|
-
throw new (0,
|
|
177
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
178
178
|
}
|
|
179
179
|
return Math.min(n, MAX_LIMIT);
|
|
180
180
|
}
|
|
@@ -220,7 +220,7 @@ function wallParts(tz, ms) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
|
|
223
|
-
throw new (0,
|
|
223
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
|
|
224
224
|
}
|
|
225
225
|
return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
|
|
226
226
|
}
|
|
@@ -247,7 +247,7 @@ function localDayEndMs(y, m, d, tz) {
|
|
|
247
247
|
}
|
|
248
248
|
function validateZone(tz, opName = "dateWindow") {
|
|
249
249
|
if (typeof tz !== "string" || tz.length === 0) {
|
|
250
|
-
throw new (0,
|
|
250
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
251
251
|
`${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
252
252
|
{ operation: opName }
|
|
253
253
|
);
|
|
@@ -255,7 +255,7 @@ function validateZone(tz, opName = "dateWindow") {
|
|
|
255
255
|
try {
|
|
256
256
|
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
257
257
|
} catch (e2) {
|
|
258
|
-
throw new (0,
|
|
258
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
259
259
|
`${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
260
260
|
{ operation: opName }
|
|
261
261
|
);
|
|
@@ -407,13 +407,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
|
|
|
407
407
|
body: { MaxRecords: limit, filter },
|
|
408
408
|
operation
|
|
409
409
|
});
|
|
410
|
-
return
|
|
410
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
411
411
|
}
|
|
412
412
|
var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
|
|
413
413
|
function customRangeDay(value, label, zone, opName) {
|
|
414
414
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
415
415
|
if (!m) {
|
|
416
|
-
throw new (0,
|
|
416
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
417
417
|
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)})`,
|
|
418
418
|
{ operation: opName }
|
|
419
419
|
);
|
|
@@ -425,7 +425,7 @@ function customRangeDay(value, label, zone, opName) {
|
|
|
425
425
|
const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
|
|
426
426
|
const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
|
|
427
427
|
if (!Number.isFinite(ms)) {
|
|
428
|
-
throw new (0,
|
|
428
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
429
429
|
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)})`,
|
|
430
430
|
{ operation: opName }
|
|
431
431
|
);
|
|
@@ -436,7 +436,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
436
436
|
const fromB = customRangeDay(from, "from", zone, operation);
|
|
437
437
|
const toB = customRangeDay(to, "to", zone, operation);
|
|
438
438
|
if (fromB.ms > toB.ms) {
|
|
439
|
-
throw new (0,
|
|
439
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
440
440
|
`${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
|
|
441
441
|
{ operation }
|
|
442
442
|
);
|
|
@@ -453,7 +453,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
453
453
|
body: { MaxRecords: limit, filter },
|
|
454
454
|
operation
|
|
455
455
|
});
|
|
456
|
-
return
|
|
456
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
// src/resources/special/billing_items.ts
|
|
@@ -486,7 +486,7 @@ async function customRange(_resource, from, to, http, opts) {
|
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
// src/resources/billing_items.ts
|
|
489
|
-
var BillingItemsResource = class extends
|
|
489
|
+
var BillingItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
490
490
|
constructor(http, pageSize) {
|
|
491
491
|
super(http, {
|
|
492
492
|
key: "billing_items",
|
|
@@ -588,7 +588,7 @@ var BillingItemsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
588
588
|
};
|
|
589
589
|
|
|
590
590
|
// src/resources/change_request_links.ts
|
|
591
|
-
var ChangeRequestLinksResource = class extends
|
|
591
|
+
var ChangeRequestLinksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
592
592
|
constructor(http, pageSize) {
|
|
593
593
|
super(http, {
|
|
594
594
|
key: "change_request_links",
|
|
@@ -642,7 +642,7 @@ var ChangeRequestLinksResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
642
642
|
};
|
|
643
643
|
|
|
644
644
|
// src/resources/checklist_libraries.ts
|
|
645
|
-
var ChecklistLibrariesResource = class extends
|
|
645
|
+
var ChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
646
646
|
constructor(http, pageSize) {
|
|
647
647
|
super(http, {
|
|
648
648
|
key: "checklist_libraries",
|
|
@@ -716,7 +716,7 @@ var ChecklistLibrariesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
716
716
|
};
|
|
717
717
|
|
|
718
718
|
// src/resources/checklist_library_checklist_items.ts
|
|
719
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
719
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
720
720
|
constructor(http, pageSize) {
|
|
721
721
|
super(http, {
|
|
722
722
|
key: "checklist_library_checklist_items",
|
|
@@ -782,7 +782,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunk5N6DYKXOcjs.Bas
|
|
|
782
782
|
};
|
|
783
783
|
|
|
784
784
|
// src/resources/classification_icons.ts
|
|
785
|
-
var ClassificationIconsResource = class extends
|
|
785
|
+
var ClassificationIconsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
786
786
|
constructor(http, pageSize) {
|
|
787
787
|
super(http, {
|
|
788
788
|
key: "classification_icons",
|
|
@@ -830,7 +830,7 @@ var DEFAULT_LIMIT2 = 25;
|
|
|
830
830
|
var MAX_LIMIT2 = 500;
|
|
831
831
|
function clampLimit(limit) {
|
|
832
832
|
const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
|
|
833
|
-
if (!Number.isInteger(n) || n < 1) throw new (0,
|
|
833
|
+
if (!Number.isInteger(n) || n < 1) throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
834
834
|
return Math.min(n, MAX_LIMIT2);
|
|
835
835
|
}
|
|
836
836
|
async function queryCompanies(http, filter, limit) {
|
|
@@ -841,7 +841,7 @@ async function queryCompanies(http, filter, limit) {
|
|
|
841
841
|
body: { MaxRecords: limit, filter },
|
|
842
842
|
operation: "companies.searchByDomain"
|
|
843
843
|
});
|
|
844
|
-
return
|
|
844
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
845
845
|
}
|
|
846
846
|
async function queryContacts(http, filter, limit) {
|
|
847
847
|
const res = await http.request({
|
|
@@ -851,7 +851,7 @@ async function queryContacts(http, filter, limit) {
|
|
|
851
851
|
body: { MaxRecords: limit, filter },
|
|
852
852
|
operation: "companies.searchByDomain"
|
|
853
853
|
});
|
|
854
|
-
return
|
|
854
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
855
855
|
}
|
|
856
856
|
async function fetchCompanies(http, ids, limit) {
|
|
857
857
|
const out = [];
|
|
@@ -866,7 +866,7 @@ async function fetchCompanies(http, ids, limit) {
|
|
|
866
866
|
const item = body && "item" in body ? body.item : null;
|
|
867
867
|
if (item) out.push(item);
|
|
868
868
|
} catch (err) {
|
|
869
|
-
if (err instanceof
|
|
869
|
+
if (err instanceof _chunkIHRXVIUUcjs.NotFoundError) continue;
|
|
870
870
|
throw err;
|
|
871
871
|
}
|
|
872
872
|
}
|
|
@@ -874,7 +874,7 @@ async function fetchCompanies(http, ids, limit) {
|
|
|
874
874
|
}
|
|
875
875
|
async function searchByDomain(_resource, domain, opts = {}, http) {
|
|
876
876
|
const text = domain.trim();
|
|
877
|
-
if (text === "") throw new (0,
|
|
877
|
+
if (text === "") throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("searchByDomain: empty domain");
|
|
878
878
|
const limit = clampLimit(opts.limit);
|
|
879
879
|
const filter = [{ field: "webAddress", op: "contains", value: text }];
|
|
880
880
|
const direct = await queryCompanies(http, filter, limit);
|
|
@@ -888,7 +888,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
|
|
|
888
888
|
const email = _nullishCoalesce(_optionalChain([identity, 'access', _9 => _9.email, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]), () => ( ""));
|
|
889
889
|
const website = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.website, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
|
|
890
890
|
if (name === "" && email === "" && website === "") {
|
|
891
|
-
throw new (0,
|
|
891
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
|
|
892
892
|
}
|
|
893
893
|
const limit = clampLimit(opts.limit);
|
|
894
894
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -915,23 +915,23 @@ async function familyChildPage(http, parentID) {
|
|
|
915
915
|
path: "/V1.0/Companies/query",
|
|
916
916
|
body: {
|
|
917
917
|
MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
|
|
918
|
-
filter:
|
|
918
|
+
filter: _chunkIHRXVIUUcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
|
|
919
919
|
},
|
|
920
920
|
operation: "companies.search"
|
|
921
921
|
});
|
|
922
|
-
const { items, pageDetails } =
|
|
922
|
+
const { items, pageDetails } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, "companies.search");
|
|
923
923
|
return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
|
|
924
924
|
}
|
|
925
925
|
function assertSearchWithDetailOpts(opts) {
|
|
926
926
|
if (opts === void 0) return;
|
|
927
927
|
if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
|
|
928
|
-
throw new (0,
|
|
928
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
|
|
929
929
|
operation: "companies.searchWithDetail"
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
932
|
for (const key of Object.keys(opts)) {
|
|
933
933
|
if (key !== "limit") {
|
|
934
|
-
throw new (0,
|
|
934
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
935
935
|
`companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
|
|
936
936
|
{ operation: "companies.searchWithDetail" }
|
|
937
937
|
);
|
|
@@ -940,32 +940,32 @@ function assertSearchWithDetailOpts(opts) {
|
|
|
940
940
|
}
|
|
941
941
|
async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
942
942
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
943
|
-
throw new (0,
|
|
943
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
|
|
944
944
|
}
|
|
945
945
|
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
946
946
|
if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
|
|
947
|
-
throw new (0,
|
|
947
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
948
948
|
`companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
|
|
949
949
|
{ operation: "companies.search" }
|
|
950
950
|
);
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
953
|
if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
|
|
954
|
-
throw new (0,
|
|
954
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
|
|
955
955
|
operation: "companies.search"
|
|
956
956
|
});
|
|
957
957
|
}
|
|
958
958
|
const text = query.trim();
|
|
959
|
-
if (text === "") throw new (0,
|
|
960
|
-
const limit = opts.limit === void 0 ? 25 :
|
|
959
|
+
if (text === "") throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
960
|
+
const limit = opts.limit === void 0 ? 25 : _chunkIHRXVIUUcjs.clampPageSize.call(void 0, opts.limit);
|
|
961
961
|
const res = await http.request({
|
|
962
962
|
method: "POST",
|
|
963
963
|
idempotent: true,
|
|
964
964
|
path: "/V1.0/Companies/query",
|
|
965
|
-
body: { MaxRecords: limit, filter:
|
|
965
|
+
body: { MaxRecords: limit, filter: _chunkIHRXVIUUcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
966
966
|
operation: "companies.search"
|
|
967
967
|
});
|
|
968
|
-
const hits =
|
|
968
|
+
const hits = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, "companies.search").items;
|
|
969
969
|
if (opts.includeFamily !== true) return hits;
|
|
970
970
|
const rows = [];
|
|
971
971
|
for (const hit of hits) {
|
|
@@ -989,7 +989,7 @@ var DEFAULT_COMPANY_TYPE = 1;
|
|
|
989
989
|
var DEDUP_NAME_LIMIT = 10;
|
|
990
990
|
var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumerate (the unowned surface is blind); a same-name company outside that scope is not detected";
|
|
991
991
|
var SAFE_COMPANY_CREATE_DEFAULTS = {};
|
|
992
|
-
var OwnerResourceRequiredError = class extends
|
|
992
|
+
var OwnerResourceRequiredError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
993
993
|
constructor(message, options = {}) {
|
|
994
994
|
super(message, {
|
|
995
995
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1000,13 +1000,13 @@ var OwnerResourceRequiredError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
1000
1000
|
this.name = "OwnerResourceRequiredError";
|
|
1001
1001
|
}
|
|
1002
1002
|
};
|
|
1003
|
-
var CompanyResourceInvalidError = class extends
|
|
1003
|
+
var CompanyResourceInvalidError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
1004
1004
|
constructor(message, options = {}) {
|
|
1005
1005
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
1006
1006
|
this.name = "CompanyResourceInvalidError";
|
|
1007
1007
|
}
|
|
1008
1008
|
};
|
|
1009
|
-
var CompanyCreateFailedError = class extends
|
|
1009
|
+
var CompanyCreateFailedError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
1010
1010
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
1011
1011
|
|
|
1012
1012
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -1017,18 +1017,18 @@ var CompanyCreateFailedError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
1017
1017
|
};
|
|
1018
1018
|
async function upsertByName(resource, companyName, params, opts, http) {
|
|
1019
1019
|
if (typeof companyName !== "string" || companyName.trim() === "") {
|
|
1020
|
-
throw new (0,
|
|
1020
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
|
|
1021
1021
|
}
|
|
1022
1022
|
if (typeof _optionalChain([params, 'optionalAccess', _15 => _15.phone]) !== "string" || params.phone.trim() === "") {
|
|
1023
|
-
throw new (0,
|
|
1023
|
+
throw new (0, _chunkIHRXVIUUcjs.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 });
|
|
1024
1024
|
}
|
|
1025
1025
|
const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
|
|
1026
1026
|
if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
|
|
1027
|
-
throw new (0,
|
|
1027
|
+
throw new (0, _chunkIHRXVIUUcjs.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 });
|
|
1028
1028
|
}
|
|
1029
1029
|
const owner = params.ownerResourceID;
|
|
1030
1030
|
if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
|
|
1031
|
-
throw new (0,
|
|
1031
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
|
|
1032
1032
|
}
|
|
1033
1033
|
const q = await resource.queryBounded({ filter: [{ field: "companyName", op: "eq", value: companyName }], limit: DEDUP_NAME_LIMIT });
|
|
1034
1034
|
const caveat = {
|
|
@@ -1039,7 +1039,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
|
|
|
1039
1039
|
const match = q.items[0];
|
|
1040
1040
|
if (match !== void 0) {
|
|
1041
1041
|
if (opts.dryRun === true) {
|
|
1042
|
-
return
|
|
1042
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
1043
1043
|
{
|
|
1044
1044
|
operation: OP_UPSERT_NAME,
|
|
1045
1045
|
method: "POST",
|
|
@@ -1074,7 +1074,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
|
|
|
1074
1074
|
"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"
|
|
1075
1075
|
);
|
|
1076
1076
|
}
|
|
1077
|
-
return
|
|
1077
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
1078
1078
|
{
|
|
1079
1079
|
operation: OP_UPSERT_NAME,
|
|
1080
1080
|
method: "POST",
|
|
@@ -1122,8 +1122,8 @@ async function upsertByName(resource, companyName, params, opts, http) {
|
|
|
1122
1122
|
sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
|
|
1123
1123
|
};
|
|
1124
1124
|
} catch (err) {
|
|
1125
|
-
if (!
|
|
1126
|
-
const named = (_nullishCoalesce(
|
|
1125
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1126
|
+
const named = (_nullishCoalesce(_chunkIHRXVIUUcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
1127
1127
|
const seen = /* @__PURE__ */ new Set();
|
|
1128
1128
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
1129
1129
|
const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -1137,7 +1137,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
continue;
|
|
1139
1139
|
}
|
|
1140
|
-
const detail =
|
|
1140
|
+
const detail = _chunkIHRXVIUUcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
1141
1141
|
throw new CompanyCreateFailedError(
|
|
1142
1142
|
`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}` : ""}`,
|
|
1143
1143
|
unique,
|
|
@@ -1156,7 +1156,7 @@ var PROFILE_PART_LIMIT = 50;
|
|
|
1156
1156
|
function profilePartLimit(value, name) {
|
|
1157
1157
|
const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
|
|
1158
1158
|
if (!Number.isInteger(n) || n < 1) {
|
|
1159
|
-
throw new (0,
|
|
1159
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1160
1160
|
}
|
|
1161
1161
|
return n;
|
|
1162
1162
|
}
|
|
@@ -1168,14 +1168,14 @@ async function scopedCompanyQuery(http, path, companyID, limit) {
|
|
|
1168
1168
|
body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }] },
|
|
1169
1169
|
operation: "companies.fullProfile"
|
|
1170
1170
|
});
|
|
1171
|
-
return
|
|
1171
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
1172
1172
|
}
|
|
1173
1173
|
async function fullProfile(resource, id, opts = {}, http) {
|
|
1174
1174
|
const contactLimit = profilePartLimit(opts.contactLimit, "contactLimit");
|
|
1175
1175
|
const noteLimit = profilePartLimit(opts.noteLimit, "noteLimit");
|
|
1176
1176
|
const ticketLimit = profilePartLimit(opts.ticketLimit, "ticketLimit");
|
|
1177
1177
|
const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
|
|
1178
|
-
const companyID =
|
|
1178
|
+
const companyID = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
1179
1179
|
const company = await resource.get(companyID);
|
|
1180
1180
|
const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, PROFILE_PART_LIMIT);
|
|
1181
1181
|
const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit);
|
|
@@ -1192,7 +1192,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1192
1192
|
},
|
|
1193
1193
|
operation: "companies.fullProfile"
|
|
1194
1194
|
});
|
|
1195
|
-
return
|
|
1195
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
1196
1196
|
})();
|
|
1197
1197
|
let openTickets = {
|
|
1198
1198
|
items: openRows,
|
|
@@ -1201,7 +1201,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1201
1201
|
note: OPEN_TICKETS_NOTE
|
|
1202
1202
|
};
|
|
1203
1203
|
if (openRows.length === 0) {
|
|
1204
|
-
const stamp =
|
|
1204
|
+
const stamp = _chunkIHRXVIUUcjs.blindStampFor.call(void 0, _optionalChain([_chunkIHRXVIUUcjs.BLIND_SURFACE_STAMPS, 'access', _16 => _16["tickets"], 'optionalAccess', _17 => _17.query]), [
|
|
1205
1205
|
{ field: "companyID", op: "eq", value: companyID },
|
|
1206
1206
|
{ field: "status", op: "noteq", value: 5 }
|
|
1207
1207
|
]);
|
|
@@ -1232,7 +1232,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
};
|
|
1234
1234
|
if (opts.names === true) {
|
|
1235
|
-
const builder =
|
|
1235
|
+
const builder = _chunkIHRXVIUUcjs.createNamePlan.call(void 0, _chunkIHRXVIUUcjs.TICKET_LABEL_FIELDS);
|
|
1236
1236
|
const c = company;
|
|
1237
1237
|
builder.addResource(c["ownerResourceID"]);
|
|
1238
1238
|
builder.addResource(c["createdByResourceID"]);
|
|
@@ -1249,20 +1249,20 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1249
1249
|
builder.addResource(r["creatorResourceID"]);
|
|
1250
1250
|
builder.addFk("contract", r["contractID"]);
|
|
1251
1251
|
}
|
|
1252
|
-
const names = await
|
|
1252
|
+
const names = await _chunkIHRXVIUUcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1253
1253
|
const companyRow = { ...company };
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1255
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
|
|
1256
1256
|
result.company = companyRow;
|
|
1257
1257
|
result.openTickets = {
|
|
1258
1258
|
...openTickets,
|
|
1259
1259
|
items: openTickets.items.map((row) => {
|
|
1260
1260
|
const r = { ...row };
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
for (const f of
|
|
1261
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1262
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1263
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1264
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1265
|
+
for (const f of _chunkIHRXVIUUcjs.TICKET_LABEL_FIELDS) _chunkIHRXVIUUcjs.addLabelSibling.call(void 0, r, f, names);
|
|
1266
1266
|
return r;
|
|
1267
1267
|
})
|
|
1268
1268
|
};
|
|
@@ -1270,9 +1270,9 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1270
1270
|
...result.projects,
|
|
1271
1271
|
items: result.projects.items.map((row) => {
|
|
1272
1272
|
const r = { ...row };
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1273
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1274
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1275
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1276
1276
|
return r;
|
|
1277
1277
|
})
|
|
1278
1278
|
};
|
|
@@ -1304,7 +1304,7 @@ function isDateYMD(v) {
|
|
|
1304
1304
|
}
|
|
1305
1305
|
function validateUnbilledWorkOptions(companyId, opts) {
|
|
1306
1306
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1307
|
-
throw new (0,
|
|
1307
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
1308
1308
|
`unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
1309
1309
|
{ operation: "companies.unbilledWork" }
|
|
1310
1310
|
);
|
|
@@ -1333,7 +1333,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1333
1333
|
try {
|
|
1334
1334
|
limit = clampLimit(opts.limit);
|
|
1335
1335
|
} catch (err) {
|
|
1336
|
-
problems.push(err instanceof
|
|
1336
|
+
problems.push(err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1337
1337
|
limit = 50;
|
|
1338
1338
|
}
|
|
1339
1339
|
if (source === "date_range") {
|
|
@@ -1348,9 +1348,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1348
1348
|
problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
|
|
1349
1349
|
} else {
|
|
1350
1350
|
try {
|
|
1351
|
-
|
|
1351
|
+
_chunkIHRXVIUUcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1352
1352
|
} catch (err) {
|
|
1353
|
-
problems.push(err instanceof
|
|
1353
|
+
problems.push(err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
@@ -1360,20 +1360,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1360
1360
|
} else {
|
|
1361
1361
|
opts.ticketIds.forEach((tid, i) => {
|
|
1362
1362
|
try {
|
|
1363
|
-
|
|
1363
|
+
_chunkIHRXVIUUcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1364
1364
|
} catch (err) {
|
|
1365
|
-
problems.push(err instanceof
|
|
1365
|
+
problems.push(err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1366
1366
|
}
|
|
1367
1367
|
});
|
|
1368
1368
|
}
|
|
1369
1369
|
}
|
|
1370
1370
|
try {
|
|
1371
|
-
|
|
1371
|
+
_chunkIHRXVIUUcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1372
1372
|
} catch (err) {
|
|
1373
|
-
problems.push(err instanceof
|
|
1373
|
+
problems.push(err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
|
|
1374
1374
|
}
|
|
1375
1375
|
if (problems.length > 0) {
|
|
1376
|
-
throw new (0,
|
|
1376
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
1377
1377
|
`unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
1378
1378
|
- ` + problems.join("\n- "),
|
|
1379
1379
|
{ operation: "companies.unbilledWork" }
|
|
@@ -1402,7 +1402,7 @@ async function boundedPart(http, path, conditions, limit, includeFields) {
|
|
|
1402
1402
|
body,
|
|
1403
1403
|
operation: "companies.unbilledWork"
|
|
1404
1404
|
});
|
|
1405
|
-
const { items, pageDetails } =
|
|
1405
|
+
const { items, pageDetails } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, "companies.unbilledWork");
|
|
1406
1406
|
const capped = items.length >= limit;
|
|
1407
1407
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
1408
1408
|
}
|
|
@@ -1413,7 +1413,7 @@ function capJoinSet(ids, cap) {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
function unbilledWorkPartStatus(key, conditions, items) {
|
|
1415
1415
|
if (items.length !== 0) return { status: "ok" };
|
|
1416
|
-
const stamp =
|
|
1416
|
+
const stamp = _chunkIHRXVIUUcjs.blindStampFor.call(void 0, _optionalChain([_chunkIHRXVIUUcjs.BLIND_SURFACE_STAMPS, 'access', _18 => _18[key], 'optionalAccess', _19 => _19.query]), conditions);
|
|
1417
1417
|
if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
|
|
1418
1418
|
return {
|
|
1419
1419
|
status: "ok",
|
|
@@ -1422,7 +1422,7 @@ function unbilledWorkPartStatus(key, conditions, items) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
1424
1424
|
const v = validateUnbilledWorkOptions(companyId, opts);
|
|
1425
|
-
const id =
|
|
1425
|
+
const id = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1426
1426
|
const company = await resource.get(id);
|
|
1427
1427
|
const companyIds = [num(company.id)];
|
|
1428
1428
|
let parent = null;
|
|
@@ -1435,7 +1435,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1435
1435
|
parentStatus = "ok";
|
|
1436
1436
|
companyIds.push(num(parent.id));
|
|
1437
1437
|
} catch (err) {
|
|
1438
|
-
if (err instanceof
|
|
1438
|
+
if (err instanceof _chunkIHRXVIUUcjs.NotFoundError) parent = null;
|
|
1439
1439
|
else throw err;
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
@@ -1467,7 +1467,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1467
1467
|
if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
|
|
1468
1468
|
if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
|
|
1469
1469
|
}
|
|
1470
|
-
const billingFields =
|
|
1470
|
+
const billingFields = _chunkIHRXVIUUcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
|
|
1471
1471
|
const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
|
|
1472
1472
|
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, billingIncludeFields);
|
|
1473
1473
|
const taskCap = capJoinSet(taskIds, UNBILLED_WORK_JOIN_SET_CAP);
|
|
@@ -1499,7 +1499,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1499
1499
|
let cappedItems = entries;
|
|
1500
1500
|
let noteCharsTruncated = 0;
|
|
1501
1501
|
if (v.includeNotes) {
|
|
1502
|
-
[cappedItems, noteCharsTruncated] =
|
|
1502
|
+
[cappedItems, noteCharsTruncated] = _chunkIHRXVIUUcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
|
|
1503
1503
|
}
|
|
1504
1504
|
const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
|
|
1505
1505
|
timePart = {
|
|
@@ -1514,8 +1514,8 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1514
1514
|
let billingItems = billingRaw.items;
|
|
1515
1515
|
let billingNoteCharsTruncated = 0;
|
|
1516
1516
|
if (v.includeNotes) {
|
|
1517
|
-
const noteFields = (_nullishCoalesce(
|
|
1518
|
-
[billingItems, billingNoteCharsTruncated] =
|
|
1517
|
+
const noteFields = (_nullishCoalesce(_chunkIHRXVIUUcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1518
|
+
[billingItems, billingNoteCharsTruncated] = _chunkIHRXVIUUcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
|
|
1519
1519
|
}
|
|
1520
1520
|
const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
|
|
1521
1521
|
const billingItemsPart = {
|
|
@@ -1612,7 +1612,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
|
|
1614
1614
|
// src/resources/companies.ts
|
|
1615
|
-
var CompaniesResource = class extends
|
|
1615
|
+
var CompaniesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
1616
1616
|
constructor(http, pageSize) {
|
|
1617
1617
|
super(http, {
|
|
1618
1618
|
key: "companies",
|
|
@@ -1719,7 +1719,7 @@ var CompaniesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
1719
1719
|
};
|
|
1720
1720
|
|
|
1721
1721
|
// src/resources/company_alerts.ts
|
|
1722
|
-
var CompanyAlertsResource = class extends
|
|
1722
|
+
var CompanyAlertsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
1723
1723
|
constructor(http, pageSize) {
|
|
1724
1724
|
super(http, {
|
|
1725
1725
|
key: "company_alerts",
|
|
@@ -1785,7 +1785,7 @@ var CompanyAlertsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
1785
1785
|
};
|
|
1786
1786
|
|
|
1787
1787
|
// src/resources/company_locations.ts
|
|
1788
|
-
var CompanyLocationsResource = class extends
|
|
1788
|
+
var CompanyLocationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
1789
1789
|
constructor(http, pageSize) {
|
|
1790
1790
|
super(http, {
|
|
1791
1791
|
key: "company_locations",
|
|
@@ -1856,7 +1856,7 @@ var CompanyLocationsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
1856
1856
|
};
|
|
1857
1857
|
|
|
1858
1858
|
// src/resources/company_notes.ts
|
|
1859
|
-
var CompanyNotesResource = class extends
|
|
1859
|
+
var CompanyNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
1860
1860
|
constructor(http, pageSize) {
|
|
1861
1861
|
super(http, {
|
|
1862
1862
|
key: "company_notes",
|
|
@@ -1921,7 +1921,7 @@ var CompanyNotesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
1921
1921
|
};
|
|
1922
1922
|
|
|
1923
1923
|
// src/resources/company_site_configurations.ts
|
|
1924
|
-
var CompanySiteConfigurationsResource = class extends
|
|
1924
|
+
var CompanySiteConfigurationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
1925
1925
|
constructor(http, pageSize) {
|
|
1926
1926
|
super(http, {
|
|
1927
1927
|
key: "company_site_configurations",
|
|
@@ -1972,7 +1972,7 @@ var CompanySiteConfigurationsResource = class extends _chunk5N6DYKXOcjs.BaseReso
|
|
|
1972
1972
|
};
|
|
1973
1973
|
|
|
1974
1974
|
// src/resources/company_webhooks.ts
|
|
1975
|
-
var CompanyWebhooksResource = class extends
|
|
1975
|
+
var CompanyWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
1976
1976
|
constructor(http, pageSize) {
|
|
1977
1977
|
super(http, {
|
|
1978
1978
|
key: "company_webhooks",
|
|
@@ -2048,7 +2048,7 @@ var CompanyWebhooksResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
2048
2048
|
};
|
|
2049
2049
|
|
|
2050
2050
|
// src/resources/configuration_item_billing_product_associations.ts
|
|
2051
|
-
var ConfigurationItemBillingProductAssociationsResource = class extends
|
|
2051
|
+
var ConfigurationItemBillingProductAssociationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2052
2052
|
constructor(http, pageSize) {
|
|
2053
2053
|
super(http, {
|
|
2054
2054
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2114,7 +2114,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunk5N
|
|
|
2114
2114
|
};
|
|
2115
2115
|
|
|
2116
2116
|
// src/resources/configuration_item_categories.ts
|
|
2117
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2117
|
+
var ConfigurationItemCategoriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2118
2118
|
constructor(http, pageSize) {
|
|
2119
2119
|
super(http, {
|
|
2120
2120
|
key: "configuration_item_categories",
|
|
@@ -2181,7 +2181,7 @@ var ConfigurationItemCategoriesResource = class extends _chunk5N6DYKXOcjs.BaseRe
|
|
|
2181
2181
|
};
|
|
2182
2182
|
|
|
2183
2183
|
// src/resources/configuration_item_category_udf_associations.ts
|
|
2184
|
-
var ConfigurationItemCategoryUdfAssociationsResource = class extends
|
|
2184
|
+
var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2185
2185
|
constructor(http, pageSize) {
|
|
2186
2186
|
super(http, {
|
|
2187
2187
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2247,7 +2247,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunk5N6DY
|
|
|
2247
2247
|
};
|
|
2248
2248
|
|
|
2249
2249
|
// src/resources/configuration_item_dns_records.ts
|
|
2250
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2250
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2251
2251
|
constructor(http, pageSize) {
|
|
2252
2252
|
super(http, {
|
|
2253
2253
|
key: "configuration_item_dns_records",
|
|
@@ -2296,7 +2296,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunk5N6DYKXOcjs.BaseRe
|
|
|
2296
2296
|
};
|
|
2297
2297
|
|
|
2298
2298
|
// src/resources/configuration_item_notes.ts
|
|
2299
|
-
var ConfigurationItemNotesResource = class extends
|
|
2299
|
+
var ConfigurationItemNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2300
2300
|
constructor(http, pageSize) {
|
|
2301
2301
|
super(http, {
|
|
2302
2302
|
key: "configuration_item_notes",
|
|
@@ -2355,7 +2355,7 @@ var ConfigurationItemNotesResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
2355
2355
|
};
|
|
2356
2356
|
|
|
2357
2357
|
// src/resources/configuration_item_related_items.ts
|
|
2358
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2358
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2359
2359
|
constructor(http, pageSize) {
|
|
2360
2360
|
super(http, {
|
|
2361
2361
|
key: "configuration_item_related_items",
|
|
@@ -2416,16 +2416,16 @@ async function fetchRecord(http, path, label) {
|
|
|
2416
2416
|
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem" });
|
|
2417
2417
|
const body = res;
|
|
2418
2418
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
2419
|
-
throw new (0,
|
|
2419
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
2420
2420
|
}
|
|
2421
2421
|
return body.item;
|
|
2422
2422
|
}
|
|
2423
2423
|
async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
2424
|
-
const numericSource =
|
|
2424
|
+
const numericSource = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2425
2425
|
if (_optionalChain([opts, 'optionalAccess', _20 => _20.destinationCompanyId]) === void 0) {
|
|
2426
|
-
throw new (0,
|
|
2426
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2427
2427
|
}
|
|
2428
|
-
const destId =
|
|
2428
|
+
const destId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2429
2429
|
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`);
|
|
2430
2430
|
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`);
|
|
2431
2431
|
const body = { ...source };
|
|
@@ -2435,20 +2435,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2435
2435
|
body.companyID = destId;
|
|
2436
2436
|
body.isActive = true;
|
|
2437
2437
|
if (opts.newReferenceTitle !== void 0) {
|
|
2438
|
-
if (opts.newReferenceTitle.trim() === "") throw new (0,
|
|
2438
|
+
if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
|
|
2439
2439
|
body.referenceTitle = opts.newReferenceTitle.trim();
|
|
2440
2440
|
}
|
|
2441
2441
|
if (opts.lastModifiedDate !== void 0) {
|
|
2442
2442
|
const current = source.lastModifiedDate;
|
|
2443
2443
|
if (current !== opts.lastModifiedDate) {
|
|
2444
|
-
throw new (0,
|
|
2444
|
+
throw new (0, _chunkIHRXVIUUcjs.StaleObjectError)(
|
|
2445
2445
|
`moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
|
|
2446
2446
|
{ operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource] }
|
|
2447
2447
|
);
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
2450
|
if (opts.dryRun === true) {
|
|
2451
|
-
return
|
|
2451
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
2452
2452
|
operation: "configuration_items.moveConfigurationItem",
|
|
2453
2453
|
method: "POST",
|
|
2454
2454
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2472,7 +2472,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2472
2472
|
const createdBody = created;
|
|
2473
2473
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2474
2474
|
if (typeof newId !== "number") {
|
|
2475
|
-
throw new (0,
|
|
2475
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2476
2476
|
}
|
|
2477
2477
|
let sourceDeactivated = false;
|
|
2478
2478
|
if (opts.deactivateSource !== false) {
|
|
@@ -2490,7 +2490,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2490
2490
|
function profilePartLimit2(value, name) {
|
|
2491
2491
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2492
2492
|
if (!Number.isInteger(n) || n < 1) {
|
|
2493
|
-
throw new (0,
|
|
2493
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2494
2494
|
}
|
|
2495
2495
|
return n;
|
|
2496
2496
|
}
|
|
@@ -2506,14 +2506,14 @@ async function contextFetchPart(http, entityPath, referenceId) {
|
|
|
2506
2506
|
});
|
|
2507
2507
|
const body = res;
|
|
2508
2508
|
if (body === null || !("item" in body)) {
|
|
2509
|
-
throw new (0,
|
|
2509
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId] });
|
|
2510
2510
|
}
|
|
2511
2511
|
if (body.item === null || body.item === void 0) {
|
|
2512
|
-
throw new (0,
|
|
2512
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)("context part not found", { resourceIds: [referenceId] });
|
|
2513
2513
|
}
|
|
2514
2514
|
return body.item;
|
|
2515
2515
|
} catch (err) {
|
|
2516
|
-
if (err instanceof
|
|
2516
|
+
if (err instanceof _chunkIHRXVIUUcjs.NotFoundError) return null;
|
|
2517
2517
|
throw err;
|
|
2518
2518
|
}
|
|
2519
2519
|
}
|
|
@@ -2525,7 +2525,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2525
2525
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2526
2526
|
operation: "configuration_items.profile"
|
|
2527
2527
|
});
|
|
2528
|
-
return
|
|
2528
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
2529
2529
|
}
|
|
2530
2530
|
async function profile(resource, id, opts = {}, http) {
|
|
2531
2531
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2537,7 +2537,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2537
2537
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2538
2538
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2539
2539
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2540
|
-
const wallQuirk = _optionalChain([
|
|
2540
|
+
const wallQuirk = _optionalChain([_chunkIHRXVIUUcjs.RELATIONSHIP_MAP, 'access', _21 => _21["configuration_items"], 'optionalAccess', _22 => _22.zoneFacts, 'optionalAccess', _23 => _23.quirks, 'optionalAccess', _24 => _24.find, 'call', _25 => _25((q) => q.startsWith("product wall"))]);
|
|
2541
2541
|
const productAssociations = {
|
|
2542
2542
|
items: associations,
|
|
2543
2543
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2561,11 +2561,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2561
2561
|
}
|
|
2562
2562
|
};
|
|
2563
2563
|
if (opts.names === true) {
|
|
2564
|
-
const builder =
|
|
2564
|
+
const builder = _chunkIHRXVIUUcjs.createNamePlan.call(void 0, );
|
|
2565
2565
|
builder.addFk("contract", root["contractID"]);
|
|
2566
|
-
const names = await
|
|
2566
|
+
const names = await _chunkIHRXVIUUcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2567
2567
|
const ciRow = { ...ci };
|
|
2568
|
-
|
|
2568
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2569
2569
|
result.ci = ciRow;
|
|
2570
2570
|
result.names = names.section;
|
|
2571
2571
|
}
|
|
@@ -2573,7 +2573,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2573
2573
|
}
|
|
2574
2574
|
|
|
2575
2575
|
// src/resources/configuration_items.ts
|
|
2576
|
-
var ConfigurationItemsResource = class extends
|
|
2576
|
+
var ConfigurationItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2577
2577
|
constructor(http, pageSize) {
|
|
2578
2578
|
super(http, {
|
|
2579
2579
|
key: "configuration_items",
|
|
@@ -2662,7 +2662,7 @@ var ConfigurationItemsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
2662
2662
|
};
|
|
2663
2663
|
|
|
2664
2664
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2665
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
2665
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2666
2666
|
constructor(http, pageSize) {
|
|
2667
2667
|
super(http, {
|
|
2668
2668
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -2725,7 +2725,7 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunk5N
|
|
|
2725
2725
|
};
|
|
2726
2726
|
|
|
2727
2727
|
// src/resources/configuration_item_types.ts
|
|
2728
|
-
var ConfigurationItemTypesResource = class extends
|
|
2728
|
+
var ConfigurationItemTypesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2729
2729
|
constructor(http, pageSize) {
|
|
2730
2730
|
super(http, {
|
|
2731
2731
|
key: "configuration_item_types",
|
|
@@ -2799,7 +2799,7 @@ var ConfigurationItemTypesResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
2799
2799
|
};
|
|
2800
2800
|
|
|
2801
2801
|
// src/resources/configuration_item_webhooks.ts
|
|
2802
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
2802
|
+
var ConfigurationItemWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2803
2803
|
constructor(http, pageSize) {
|
|
2804
2804
|
super(http, {
|
|
2805
2805
|
key: "configuration_item_webhooks",
|
|
@@ -2875,7 +2875,7 @@ var ConfigurationItemWebhooksResource = class extends _chunk5N6DYKXOcjs.BaseReso
|
|
|
2875
2875
|
};
|
|
2876
2876
|
|
|
2877
2877
|
// src/resources/contact_group_contacts.ts
|
|
2878
|
-
var ContactGroupContactsResource = class extends
|
|
2878
|
+
var ContactGroupContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2879
2879
|
constructor(http, pageSize) {
|
|
2880
2880
|
super(http, {
|
|
2881
2881
|
key: "contact_group_contacts",
|
|
@@ -2929,7 +2929,7 @@ var ContactGroupContactsResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
2929
2929
|
};
|
|
2930
2930
|
|
|
2931
2931
|
// src/resources/contact_groups.ts
|
|
2932
|
-
var ContactGroupsResource = class extends
|
|
2932
|
+
var ContactGroupsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
2933
2933
|
constructor(http, pageSize) {
|
|
2934
2934
|
super(http, {
|
|
2935
2935
|
key: "contact_groups",
|
|
@@ -3007,22 +3007,22 @@ async function fetchRecord2(http, path, label) {
|
|
|
3007
3007
|
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany" });
|
|
3008
3008
|
const body = res;
|
|
3009
3009
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3010
|
-
throw new (0,
|
|
3010
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3011
3011
|
}
|
|
3012
3012
|
return body.item;
|
|
3013
3013
|
}
|
|
3014
3014
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3015
|
-
const sourceId =
|
|
3016
|
-
const destId =
|
|
3015
|
+
const sourceId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3016
|
+
const destId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3017
3017
|
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`);
|
|
3018
3018
|
const companyID = source.companyID;
|
|
3019
3019
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3020
|
-
throw new (0,
|
|
3020
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3021
3021
|
}
|
|
3022
3022
|
if (opts.lastModifiedDate !== void 0) {
|
|
3023
3023
|
const current = source.lastModifiedDate;
|
|
3024
3024
|
if (current !== opts.lastModifiedDate) {
|
|
3025
|
-
throw new (0,
|
|
3025
|
+
throw new (0, _chunkIHRXVIUUcjs.StaleObjectError)(
|
|
3026
3026
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3027
3027
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId] }
|
|
3028
3028
|
);
|
|
@@ -3044,10 +3044,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3044
3044
|
},
|
|
3045
3045
|
operation: "contacts.moveToCompany"
|
|
3046
3046
|
});
|
|
3047
|
-
const items =
|
|
3047
|
+
const items = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
3048
3048
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3049
3049
|
if (clash !== void 0) {
|
|
3050
|
-
throw new (0,
|
|
3050
|
+
throw new (0, _chunkIHRXVIUUcjs.ConflictError)(
|
|
3051
3051
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3052
3052
|
{ resourceIds: [sourceId, destId] }
|
|
3053
3053
|
);
|
|
@@ -3061,7 +3061,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3061
3061
|
if (opts.dryRun === true) {
|
|
3062
3062
|
const warnings = [];
|
|
3063
3063
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3064
|
-
return
|
|
3064
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
3065
3065
|
operation: "contacts.moveToCompany",
|
|
3066
3066
|
method: "POST",
|
|
3067
3067
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3086,7 +3086,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3086
3086
|
const createdBody = created;
|
|
3087
3087
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3088
3088
|
if (typeof newId !== "number") {
|
|
3089
|
-
throw new (0,
|
|
3089
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3090
3090
|
}
|
|
3091
3091
|
let sourceDeleted = false;
|
|
3092
3092
|
if (opts.deleteSource === true) {
|
|
@@ -3104,7 +3104,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3104
3104
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3105
3105
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3106
3106
|
var DEDUP_LIMIT = 10;
|
|
3107
|
-
var CompanyNotFoundError = class extends
|
|
3107
|
+
var CompanyNotFoundError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
3108
3108
|
constructor(message, options = {}) {
|
|
3109
3109
|
super(message, {
|
|
3110
3110
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3115,7 +3115,7 @@ var CompanyNotFoundError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
3115
3115
|
this.name = "CompanyNotFoundError";
|
|
3116
3116
|
}
|
|
3117
3117
|
};
|
|
3118
|
-
var ContactCreateFailedError = class extends
|
|
3118
|
+
var ContactCreateFailedError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
3119
3119
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3120
3120
|
|
|
3121
3121
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3125,25 +3125,25 @@ var ContactCreateFailedError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
3125
3125
|
}
|
|
3126
3126
|
};
|
|
3127
3127
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3128
|
-
const cid =
|
|
3128
|
+
const cid = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3129
3129
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3130
|
-
throw new (0,
|
|
3130
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
3131
3131
|
`upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
|
|
3132
3132
|
{ operation: OP_UPSERT_EMAIL }
|
|
3133
3133
|
);
|
|
3134
3134
|
}
|
|
3135
3135
|
if (extra !== void 0) {
|
|
3136
3136
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3137
|
-
throw new (0,
|
|
3137
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
3138
3138
|
`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)})`,
|
|
3139
3139
|
{ operation: OP_UPSERT_EMAIL }
|
|
3140
3140
|
);
|
|
3141
3141
|
}
|
|
3142
3142
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3143
|
-
throw new (0,
|
|
3143
|
+
throw new (0, _chunkIHRXVIUUcjs.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 });
|
|
3144
3144
|
}
|
|
3145
3145
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3146
|
-
throw new (0,
|
|
3146
|
+
throw new (0, _chunkIHRXVIUUcjs.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 });
|
|
3147
3147
|
}
|
|
3148
3148
|
}
|
|
3149
3149
|
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL });
|
|
@@ -3164,7 +3164,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3164
3164
|
const match = q.items[0];
|
|
3165
3165
|
if (match !== void 0) {
|
|
3166
3166
|
if (opts.dryRun === true) {
|
|
3167
|
-
return
|
|
3167
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
3168
3168
|
{
|
|
3169
3169
|
operation: OP_UPSERT_EMAIL,
|
|
3170
3170
|
method: "POST",
|
|
@@ -3194,7 +3194,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3194
3194
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3195
3195
|
};
|
|
3196
3196
|
if (opts.dryRun === true) {
|
|
3197
|
-
return
|
|
3197
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
3198
3198
|
{
|
|
3199
3199
|
operation: OP_UPSERT_EMAIL,
|
|
3200
3200
|
method: "POST",
|
|
@@ -3217,8 +3217,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3217
3217
|
const created = await resource.create(cid, body, {});
|
|
3218
3218
|
return { id: created.id, created: true };
|
|
3219
3219
|
} catch (err) {
|
|
3220
|
-
if (!
|
|
3221
|
-
const named = (_nullishCoalesce(
|
|
3220
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3221
|
+
const named = (_nullishCoalesce(_chunkIHRXVIUUcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3222
3222
|
const seen = /* @__PURE__ */ new Set();
|
|
3223
3223
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3224
3224
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3232,7 +3232,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3232
3232
|
}
|
|
3233
3233
|
continue;
|
|
3234
3234
|
}
|
|
3235
|
-
const detail =
|
|
3235
|
+
const detail = _chunkIHRXVIUUcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3236
3236
|
throw new ContactCreateFailedError(
|
|
3237
3237
|
`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}` : ""}`,
|
|
3238
3238
|
unique,
|
|
@@ -3248,7 +3248,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3248
3248
|
}
|
|
3249
3249
|
|
|
3250
3250
|
// src/resources/contacts.ts
|
|
3251
|
-
var ContactsResource = class extends
|
|
3251
|
+
var ContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3252
3252
|
constructor(http, pageSize) {
|
|
3253
3253
|
super(http, {
|
|
3254
3254
|
key: "contacts",
|
|
@@ -3340,7 +3340,7 @@ var ContactsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
3340
3340
|
};
|
|
3341
3341
|
|
|
3342
3342
|
// src/resources/contact_webhooks.ts
|
|
3343
|
-
var ContactWebhooksResource = class extends
|
|
3343
|
+
var ContactWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3344
3344
|
constructor(http, pageSize) {
|
|
3345
3345
|
super(http, {
|
|
3346
3346
|
key: "contact_webhooks",
|
|
@@ -3416,7 +3416,7 @@ var ContactWebhooksResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
3416
3416
|
};
|
|
3417
3417
|
|
|
3418
3418
|
// src/resources/contract_billing_rules.ts
|
|
3419
|
-
var ContractBillingRulesResource = class extends
|
|
3419
|
+
var ContractBillingRulesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3420
3420
|
constructor(http, pageSize) {
|
|
3421
3421
|
super(http, {
|
|
3422
3422
|
key: "contract_billing_rules",
|
|
@@ -3482,7 +3482,7 @@ var ContractBillingRulesResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
3482
3482
|
};
|
|
3483
3483
|
|
|
3484
3484
|
// src/resources/contract_block_hour_factors.ts
|
|
3485
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3485
|
+
var ContractBlockHourFactorsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3486
3486
|
constructor(http, pageSize) {
|
|
3487
3487
|
super(http, {
|
|
3488
3488
|
key: "contract_block_hour_factors",
|
|
@@ -3541,7 +3541,7 @@ var ContractBlockHourFactorsResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
3541
3541
|
};
|
|
3542
3542
|
|
|
3543
3543
|
// src/resources/contract_blocks.ts
|
|
3544
|
-
var ContractBlocksResource = class extends
|
|
3544
|
+
var ContractBlocksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3545
3545
|
constructor(http, pageSize) {
|
|
3546
3546
|
super(http, {
|
|
3547
3547
|
key: "contract_blocks",
|
|
@@ -3600,7 +3600,7 @@ var ContractBlocksResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
3600
3600
|
};
|
|
3601
3601
|
|
|
3602
3602
|
// src/resources/contract_charges.ts
|
|
3603
|
-
var ContractChargesResource = class extends
|
|
3603
|
+
var ContractChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3604
3604
|
constructor(http, pageSize) {
|
|
3605
3605
|
super(http, {
|
|
3606
3606
|
key: "contract_charges",
|
|
@@ -3671,7 +3671,7 @@ var ContractChargesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
3671
3671
|
};
|
|
3672
3672
|
|
|
3673
3673
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3674
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
3674
|
+
var ContractExclusionBillingCodesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3675
3675
|
constructor(http, pageSize) {
|
|
3676
3676
|
super(http, {
|
|
3677
3677
|
key: "contract_exclusion_billing_codes",
|
|
@@ -3728,7 +3728,7 @@ var ContractExclusionBillingCodesResource = class extends _chunk5N6DYKXOcjs.Base
|
|
|
3728
3728
|
};
|
|
3729
3729
|
|
|
3730
3730
|
// src/resources/contract_exclusion_roles.ts
|
|
3731
|
-
var ContractExclusionRolesResource = class extends
|
|
3731
|
+
var ContractExclusionRolesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3732
3732
|
constructor(http, pageSize) {
|
|
3733
3733
|
super(http, {
|
|
3734
3734
|
key: "contract_exclusion_roles",
|
|
@@ -3785,7 +3785,7 @@ var ContractExclusionRolesResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
3785
3785
|
};
|
|
3786
3786
|
|
|
3787
3787
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
3788
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
3788
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3789
3789
|
constructor(http, pageSize) {
|
|
3790
3790
|
super(http, {
|
|
3791
3791
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -3842,7 +3842,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunk5N6DYKXOcjs.
|
|
|
3842
3842
|
};
|
|
3843
3843
|
|
|
3844
3844
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
3845
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
3845
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3846
3846
|
constructor(http, pageSize) {
|
|
3847
3847
|
super(http, {
|
|
3848
3848
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -3899,7 +3899,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunk5N6DYKXO
|
|
|
3899
3899
|
};
|
|
3900
3900
|
|
|
3901
3901
|
// src/resources/contract_exclusion_sets.ts
|
|
3902
|
-
var ContractExclusionSetsResource = class extends
|
|
3902
|
+
var ContractExclusionSetsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3903
3903
|
constructor(http, pageSize) {
|
|
3904
3904
|
super(http, {
|
|
3905
3905
|
key: "contract_exclusion_sets",
|
|
@@ -3973,7 +3973,7 @@ var ContractExclusionSetsResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
3973
3973
|
};
|
|
3974
3974
|
|
|
3975
3975
|
// src/resources/contract_milestones.ts
|
|
3976
|
-
var ContractMilestonesResource = class extends
|
|
3976
|
+
var ContractMilestonesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
3977
3977
|
constructor(http, pageSize) {
|
|
3978
3978
|
super(http, {
|
|
3979
3979
|
key: "contract_milestones",
|
|
@@ -4032,7 +4032,7 @@ var ContractMilestonesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
4032
4032
|
};
|
|
4033
4033
|
|
|
4034
4034
|
// src/resources/contract_notes.ts
|
|
4035
|
-
var ContractNotesResource = class extends
|
|
4035
|
+
var ContractNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4036
4036
|
constructor(http, pageSize) {
|
|
4037
4037
|
super(http, {
|
|
4038
4038
|
key: "contract_notes",
|
|
@@ -4091,7 +4091,7 @@ var ContractNotesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
4091
4091
|
};
|
|
4092
4092
|
|
|
4093
4093
|
// src/resources/contract_rates.ts
|
|
4094
|
-
var ContractRatesResource = class extends
|
|
4094
|
+
var ContractRatesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4095
4095
|
constructor(http, pageSize) {
|
|
4096
4096
|
super(http, {
|
|
4097
4097
|
key: "contract_rates",
|
|
@@ -4150,7 +4150,7 @@ var ContractRatesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
4150
4150
|
};
|
|
4151
4151
|
|
|
4152
4152
|
// src/resources/contract_retainers.ts
|
|
4153
|
-
var ContractRetainersResource = class extends
|
|
4153
|
+
var ContractRetainersResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4154
4154
|
constructor(http, pageSize) {
|
|
4155
4155
|
super(http, {
|
|
4156
4156
|
key: "contract_retainers",
|
|
@@ -4209,7 +4209,7 @@ var ContractRetainersResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
4209
4209
|
};
|
|
4210
4210
|
|
|
4211
4211
|
// src/resources/contract_role_costs.ts
|
|
4212
|
-
var ContractRoleCostsResource = class extends
|
|
4212
|
+
var ContractRoleCostsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4213
4213
|
constructor(http, pageSize) {
|
|
4214
4214
|
super(http, {
|
|
4215
4215
|
key: "contract_role_costs",
|
|
@@ -4268,7 +4268,7 @@ var ContractRoleCostsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
4268
4268
|
};
|
|
4269
4269
|
|
|
4270
4270
|
// src/resources/contract_service_adjustments.ts
|
|
4271
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4271
|
+
var ContractServiceAdjustmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4272
4272
|
constructor(http, pageSize) {
|
|
4273
4273
|
super(http, {
|
|
4274
4274
|
key: "contract_service_adjustments",
|
|
@@ -4302,7 +4302,7 @@ var ContractServiceAdjustmentsResource = class extends _chunk5N6DYKXOcjs.BaseRes
|
|
|
4302
4302
|
};
|
|
4303
4303
|
|
|
4304
4304
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4305
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4305
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4306
4306
|
constructor(http, pageSize) {
|
|
4307
4307
|
super(http, {
|
|
4308
4308
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4336,7 +4336,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunk5N6DYKXOcjs.B
|
|
|
4336
4336
|
};
|
|
4337
4337
|
|
|
4338
4338
|
// src/resources/contract_service_bundles.ts
|
|
4339
|
-
var ContractServiceBundlesResource = class extends
|
|
4339
|
+
var ContractServiceBundlesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4340
4340
|
constructor(http, pageSize) {
|
|
4341
4341
|
super(http, {
|
|
4342
4342
|
key: "contract_service_bundles",
|
|
@@ -4395,7 +4395,7 @@ var ContractServiceBundlesResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
4395
4395
|
};
|
|
4396
4396
|
|
|
4397
4397
|
// src/resources/contract_service_bundle_units.ts
|
|
4398
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4398
|
+
var ContractServiceBundleUnitsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4399
4399
|
constructor(http, pageSize) {
|
|
4400
4400
|
super(http, {
|
|
4401
4401
|
key: "contract_service_bundle_units",
|
|
@@ -4437,7 +4437,7 @@ var ContractServiceBundleUnitsResource = class extends _chunk5N6DYKXOcjs.BaseRes
|
|
|
4437
4437
|
};
|
|
4438
4438
|
|
|
4439
4439
|
// src/resources/contract_services.ts
|
|
4440
|
-
var ContractServicesResource = class extends
|
|
4440
|
+
var ContractServicesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4441
4441
|
constructor(http, pageSize) {
|
|
4442
4442
|
super(http, {
|
|
4443
4443
|
key: "contract_services",
|
|
@@ -4496,7 +4496,7 @@ var ContractServicesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
4496
4496
|
};
|
|
4497
4497
|
|
|
4498
4498
|
// src/resources/contract_service_units.ts
|
|
4499
|
-
var ContractServiceUnitsResource = class extends
|
|
4499
|
+
var ContractServiceUnitsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
4500
4500
|
constructor(http, pageSize) {
|
|
4501
4501
|
super(http, {
|
|
4502
4502
|
key: "contract_service_units",
|
|
@@ -4561,7 +4561,15 @@ var PROFITABILITY_MAX_WINDOW_MONTHS = 36;
|
|
|
4561
4561
|
var RECURRING_DRIFT_EPSILON = 5e-3;
|
|
4562
4562
|
var ESTIMATE_DEVIATION_THRESHOLD_PCT = 10;
|
|
4563
4563
|
var CLOSED_STATUS_LABEL_RE = /resolved|completed|cancelled|canceled|closed|deleted/i;
|
|
4564
|
-
var PROFITABILITY_WIRE_BUDGET =
|
|
4564
|
+
var PROFITABILITY_WIRE_BUDGET = 21;
|
|
4565
|
+
var BLOCK_HOURS_LABEL_RE = /block\s*hours?/i;
|
|
4566
|
+
var TIME_AND_MATERIALS_LABEL_RE = /time.*materials?/i;
|
|
4567
|
+
var NOT_ACTIVE_LABEL_RE = /cancel|inactive/i;
|
|
4568
|
+
var SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS = /* @__PURE__ */ new Set([2, 3]);
|
|
4569
|
+
var PERIOD_TYPE_MONTHLY_FACTOR = { 2: 1, 3: 1 / 3, 4: 1 / 6, 5: 1 / 12 };
|
|
4570
|
+
var PERIOD_TYPE_ONE_TIME = 1;
|
|
4571
|
+
var SERVICE_LINE_FKS = ["contractServiceID", "contractServiceBundleID", "contractServicePeriodID", "contractServiceBundlePeriodID", "contractServiceAdjustmentID", "contractServiceBundleAdjustmentID"];
|
|
4572
|
+
var CHARGE_LINE_FKS = ["contractChargeID", "ticketChargeID", "projectChargeID"];
|
|
4565
4573
|
var DATE_RE2 = /^\d{4}-\d{2}-\d{2}$/;
|
|
4566
4574
|
function num2(v) {
|
|
4567
4575
|
return typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
@@ -4597,17 +4605,81 @@ function monthsBetween(dateFrom, dateTo) {
|
|
|
4597
4605
|
}
|
|
4598
4606
|
return out;
|
|
4599
4607
|
}
|
|
4608
|
+
function dayAfter(date) {
|
|
4609
|
+
return new Date(Date.parse(date) + 864e5).toISOString().slice(0, 10);
|
|
4610
|
+
}
|
|
4600
4611
|
function monthBounds(month, dateFrom, dateTo) {
|
|
4601
4612
|
const y = Number(month.slice(0, 4));
|
|
4602
4613
|
const m = Number(month.slice(5, 7));
|
|
4603
4614
|
const first = `${month}-01`;
|
|
4604
|
-
const
|
|
4605
|
-
const
|
|
4615
|
+
const nextFirst = new Date(Date.UTC(y, m, 1)).toISOString().slice(0, 10);
|
|
4616
|
+
const toExcl = dayAfter(dateTo);
|
|
4606
4617
|
return {
|
|
4607
4618
|
start: first > dateFrom ? first : dateFrom,
|
|
4608
|
-
|
|
4619
|
+
endExclusive: nextFirst < toExcl ? nextFirst : toExcl
|
|
4609
4620
|
};
|
|
4610
4621
|
}
|
|
4622
|
+
function chargeCost(charge) {
|
|
4623
|
+
const ext = charge["extendedCost"];
|
|
4624
|
+
const fromUnits = num2(charge["unitCost"]) * num2(charge["unitQuantity"]);
|
|
4625
|
+
if (typeof ext === "number" && Number.isFinite(ext) && !(ext === 0 && fromUnits !== 0)) return ext;
|
|
4626
|
+
return fromUnits;
|
|
4627
|
+
}
|
|
4628
|
+
function isOneTimePeriod(periodType, label) {
|
|
4629
|
+
return label !== void 0 ? /one[\s-]*time/i.test(label) : periodType === PERIOD_TYPE_ONE_TIME;
|
|
4630
|
+
}
|
|
4631
|
+
function periodMonthlyFactor(periodType, label) {
|
|
4632
|
+
if (label !== void 0) {
|
|
4633
|
+
if (/semi/i.test(label)) return 1 / 6;
|
|
4634
|
+
if (/quarter/i.test(label)) return 1 / 3;
|
|
4635
|
+
if (/annual|year/i.test(label)) return 1 / 12;
|
|
4636
|
+
if (/month/i.test(label)) return 1;
|
|
4637
|
+
return null;
|
|
4638
|
+
}
|
|
4639
|
+
return typeof periodType === "number" ? _nullishCoalesce(PERIOD_TYPE_MONTHLY_FACTOR[periodType], () => ( null)) : null;
|
|
4640
|
+
}
|
|
4641
|
+
var BILLING_ITEM_TYPE_KIND = {
|
|
4642
|
+
1: "labour",
|
|
4643
|
+
2: "labour",
|
|
4644
|
+
3: "charges",
|
|
4645
|
+
4: "expenses",
|
|
4646
|
+
5: "other",
|
|
4647
|
+
6: "recurring",
|
|
4648
|
+
7: "charges",
|
|
4649
|
+
8: "other"
|
|
4650
|
+
};
|
|
4651
|
+
function billingLineType(item) {
|
|
4652
|
+
const byType = BILLING_ITEM_TYPE_KIND[num2(item["billingItemType"])];
|
|
4653
|
+
if (byType !== void 0) return byType;
|
|
4654
|
+
if (num2(item["timeEntryID"]) > 0) return "labour";
|
|
4655
|
+
if (num2(item["expenseItemID"]) > 0) return "expenses";
|
|
4656
|
+
if (CHARGE_LINE_FKS.some((k) => num2(item[k]) > 0)) return "charges";
|
|
4657
|
+
if (SERVICE_LINE_FKS.some((k) => num2(item[k]) > 0)) return "recurring";
|
|
4658
|
+
return "other";
|
|
4659
|
+
}
|
|
4660
|
+
function internalAmount(row, internalKey, localKey) {
|
|
4661
|
+
const v = row[internalKey];
|
|
4662
|
+
return typeof v === "number" && Number.isFinite(v) ? v : num2(row[localKey]);
|
|
4663
|
+
}
|
|
4664
|
+
function cents(v) {
|
|
4665
|
+
return v === null ? null : Math.round(v * 100) / 100;
|
|
4666
|
+
}
|
|
4667
|
+
async function readPicklists(http, entityPath, operation) {
|
|
4668
|
+
const res = await http.request({ method: "GET", path: `${entityPath}/entityInformation/fields`, operation });
|
|
4669
|
+
const body = typeof res === "object" && res !== null ? res : {};
|
|
4670
|
+
const fields = Array.isArray(body["fields"]) ? body["fields"] : [];
|
|
4671
|
+
const out = /* @__PURE__ */ new Map();
|
|
4672
|
+
for (const f of fields) {
|
|
4673
|
+
if (f["isPickList"] !== true || typeof f["name"] !== "string" || !Array.isArray(f["picklistValues"])) continue;
|
|
4674
|
+
const values = /* @__PURE__ */ new Map();
|
|
4675
|
+
for (const p of f["picklistValues"]) {
|
|
4676
|
+
const id = typeof p["value"] === "string" ? Number.parseInt(p["value"], 10) : Number.NaN;
|
|
4677
|
+
if (Number.isFinite(id)) values.set(id, String(_nullishCoalesce(p["label"], () => ( ""))));
|
|
4678
|
+
}
|
|
4679
|
+
out.set(f["name"], values);
|
|
4680
|
+
}
|
|
4681
|
+
return out;
|
|
4682
|
+
}
|
|
4611
4683
|
function dateToDay(v) {
|
|
4612
4684
|
if (typeof v !== "string" || v.length < 10) return null;
|
|
4613
4685
|
const d = Date.parse(v.slice(0, 10));
|
|
@@ -4615,7 +4687,7 @@ function dateToDay(v) {
|
|
|
4615
4687
|
}
|
|
4616
4688
|
function validateProfitabilityOptions(contractId, opts) {
|
|
4617
4689
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
4618
|
-
throw new (0,
|
|
4690
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
4619
4691
|
`profitability: opts must be the options object (got ${opts === void 0 ? "undefined" : Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
4620
4692
|
{ operation: "contracts.profitability" }
|
|
4621
4693
|
);
|
|
@@ -4692,12 +4764,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
4692
4764
|
}
|
|
4693
4765
|
}
|
|
4694
4766
|
try {
|
|
4695
|
-
|
|
4767
|
+
_chunkIHRXVIUUcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
4696
4768
|
} catch (err) {
|
|
4697
|
-
problems.push(err instanceof
|
|
4769
|
+
problems.push(err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
4698
4770
|
}
|
|
4699
4771
|
if (problems.length > 0) {
|
|
4700
|
-
throw new (0,
|
|
4772
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
4701
4773
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
4702
4774
|
- ` + problems.join("\n- "),
|
|
4703
4775
|
{ operation: "contracts.profitability" }
|
|
@@ -4727,7 +4799,7 @@ async function boundedPart2(http, path, conditions, limit, operation, includeFie
|
|
|
4727
4799
|
body,
|
|
4728
4800
|
operation
|
|
4729
4801
|
});
|
|
4730
|
-
const { items, pageDetails } =
|
|
4802
|
+
const { items, pageDetails } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, operation);
|
|
4731
4803
|
const capped = items.length >= limit;
|
|
4732
4804
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
4733
4805
|
}
|
|
@@ -4741,23 +4813,23 @@ async function fetchByIdsPart(http, entityPath, ids, fields, operation) {
|
|
|
4741
4813
|
const byKey = /* @__PURE__ */ new Map();
|
|
4742
4814
|
const misses = [];
|
|
4743
4815
|
const notes = [];
|
|
4744
|
-
for (let c = 0; c < unique.length; c +=
|
|
4745
|
-
const chunk = unique.slice(c, c +
|
|
4816
|
+
for (let c = 0; c < unique.length; c += _chunkIHRXVIUUcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
4817
|
+
const chunk = unique.slice(c, c + _chunkIHRXVIUUcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
4746
4818
|
const chunkKeys = new Set(chunk);
|
|
4747
4819
|
try {
|
|
4748
4820
|
const body = {
|
|
4749
|
-
MaxRecords:
|
|
4821
|
+
MaxRecords: _chunkIHRXVIUUcjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
4750
4822
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
4751
4823
|
IncludeFields: fields
|
|
4752
4824
|
};
|
|
4753
4825
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
4754
|
-
const { items: rows } =
|
|
4826
|
+
const { items: rows } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, operation);
|
|
4755
4827
|
for (const row of rows) {
|
|
4756
4828
|
const k = num2(row.id);
|
|
4757
4829
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
4758
4830
|
}
|
|
4759
4831
|
} catch (err) {
|
|
4760
|
-
const code = err instanceof
|
|
4832
|
+
const code = err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
4761
4833
|
for (const k of chunk) {
|
|
4762
4834
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
4763
4835
|
}
|
|
@@ -4767,11 +4839,11 @@ async function fetchByIdsPart(http, entityPath, ids, fields, operation) {
|
|
|
4767
4839
|
for (const k of queryMissed) {
|
|
4768
4840
|
try {
|
|
4769
4841
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
4770
|
-
byKey.set(k,
|
|
4842
|
+
byKey.set(k, _chunkIHRXVIUUcjs.unwrapItem.call(void 0, res, k, operation));
|
|
4771
4843
|
} catch (err) {
|
|
4772
|
-
if (err instanceof
|
|
4844
|
+
if (err instanceof _chunkIHRXVIUUcjs.NotFoundError) {
|
|
4773
4845
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
4774
|
-
} else if (err instanceof
|
|
4846
|
+
} else if (err instanceof _chunkIHRXVIUUcjs.AutotaskError) {
|
|
4775
4847
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
4776
4848
|
} else {
|
|
4777
4849
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -4873,7 +4945,7 @@ async function expandByMonth(http, path, fullWindowCond, limit, operation, field
|
|
|
4873
4945
|
const cond = [
|
|
4874
4946
|
...fullWindowCond.filter((c) => c.field !== dateField),
|
|
4875
4947
|
{ field: dateField, op: "gte", value: b.start },
|
|
4876
|
-
{ field: dateField, op: "
|
|
4948
|
+
{ field: dateField, op: "lt", value: b.endExclusive }
|
|
4877
4949
|
];
|
|
4878
4950
|
const page = await boundedPart2(http, path, cond, limit, operation, fields);
|
|
4879
4951
|
wires.issued += 1;
|
|
@@ -4888,7 +4960,15 @@ async function expandByMonth(http, path, fullWindowCond, limit, operation, field
|
|
|
4888
4960
|
}
|
|
4889
4961
|
const partNote = `per-month windowing fired: ${months.length} month read(s) added after the full-window page carried a live cursor (no cursor walk \u2014 the single-page house rule)` + (fullMonths.length > 0 ? ` | month ${fullMonths.join(", ")} hit the limit of ${limit} \u2014 figures cover the returned rows only; widen with a narrower window or higher limit` : "");
|
|
4890
4962
|
wires.note = (wires.note ? wires.note + " | " : "") + partNote;
|
|
4891
|
-
return { items: all, capped: cappedMonths.length > 0, hasMore: fullMonths.length > 0, note: partNote, status: "ok" };
|
|
4963
|
+
return { items: all, capped: cappedMonths.length > 0, hasMore: fullMonths.length > 0, note: partNote, status: "ok", truncatedMonths: fullMonths };
|
|
4964
|
+
}
|
|
4965
|
+
async function degradable(read) {
|
|
4966
|
+
try {
|
|
4967
|
+
return await read();
|
|
4968
|
+
} catch (err) {
|
|
4969
|
+
if (!(err instanceof _chunkIHRXVIUUcjs.AutotaskError)) throw err;
|
|
4970
|
+
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
4971
|
+
}
|
|
4892
4972
|
}
|
|
4893
4973
|
function fmtHours(h) {
|
|
4894
4974
|
const r = Math.round(h * 100) / 100;
|
|
@@ -4904,16 +4984,29 @@ function pctOrNa(r) {
|
|
|
4904
4984
|
function dedupeSortCap(ids, limit) {
|
|
4905
4985
|
return [...new Set(ids)].sort((a, b) => Number(a) - Number(b)).slice(0, limit);
|
|
4906
4986
|
}
|
|
4907
|
-
async function profitability(resource, contractId, opts,
|
|
4987
|
+
async function profitability(resource, contractId, opts, rawHttp) {
|
|
4908
4988
|
const v = validateProfitabilityOptions(contractId, _nullishCoalesce(opts, () => ( {})));
|
|
4909
4989
|
const OP2 = "contracts.profitability";
|
|
4910
|
-
const id =
|
|
4990
|
+
const id = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
4911
4991
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
4912
|
-
const wires = { issued: 0, budget: PROFITABILITY_WIRE_BUDGET };
|
|
4992
|
+
const wires = { issued: 0, requests: 0, budget: PROFITABILITY_WIRE_BUDGET };
|
|
4913
4993
|
const asOf = (/* @__PURE__ */ new Date()).toISOString();
|
|
4914
4994
|
const asOfMs = Date.parse(asOf);
|
|
4995
|
+
const toExcl = dayAfter(v.dateTo);
|
|
4996
|
+
const windowOn = (field) => [{ field, op: "gte", value: v.dateFrom }, { field, op: "lt", value: toExcl }];
|
|
4997
|
+
const http = { request: (o) => {
|
|
4998
|
+
wires.requests += 1;
|
|
4999
|
+
return rawHttp.request(o);
|
|
5000
|
+
} };
|
|
5001
|
+
const readPart = (path, conditions, fields) => {
|
|
5002
|
+
wires.issued += 1;
|
|
5003
|
+
return degradable(() => boundedPart2(http, path, conditions, v.limit, OP2, fields));
|
|
5004
|
+
};
|
|
4915
5005
|
const skipPart = (note) => ({ items: [], capped: false, hasMore: false, status: "skipped", note });
|
|
4916
5006
|
const stampPart = (key, raw, conditions, extraNotes) => {
|
|
5007
|
+
if (raw.absent !== void 0) {
|
|
5008
|
+
return { items: [], capped: false, hasMore: false, status: "absent", absent: raw.absent, note: `absent: the read failed (${raw.absent}: ${_nullishCoalesce(raw.absentMessage, () => ( ""))}) \u2014 the monthly figures it feeds carry it in coverage_gaps` };
|
|
5009
|
+
}
|
|
4917
5010
|
const st = unbilledWorkPartStatus(key, conditions, raw.items);
|
|
4918
5011
|
return {
|
|
4919
5012
|
items: raw.items,
|
|
@@ -4922,15 +5015,29 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
4922
5015
|
status: st.status,
|
|
4923
5016
|
blindSurface: st.blindSurface,
|
|
4924
5017
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
4925
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5018
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkIHRXVIUUcjs.EMPTY_REASON_STAMPS, 'access', _29 => _29[key], 'optionalAccess', _30 => _30.query]) : void 0
|
|
4926
5019
|
};
|
|
4927
5020
|
};
|
|
5021
|
+
const truncatedMonths = {};
|
|
5022
|
+
const windowedPart = async (name, key, path, cond, fields, dateField) => {
|
|
5023
|
+
const first = await readPart(path, cond, fields);
|
|
5024
|
+
if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
|
|
5025
|
+
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP2, fields, dateField, v.dateFrom, v.dateTo, wires));
|
|
5026
|
+
if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
|
|
5027
|
+
const { truncatedMonths: tm, ...part } = wp;
|
|
5028
|
+
truncatedMonths[name] = tm;
|
|
5029
|
+
return { part, rows: wp.items };
|
|
5030
|
+
};
|
|
5031
|
+
const contractCached = _optionalChain([rawHttp, 'access', _31 => _31.readCache, 'optionalAccess', _32 => _32.get, 'call', _33 => _33(`/V1.0/Contracts/${id}`)]) !== void 0;
|
|
4928
5032
|
const contract = await resource.get(id);
|
|
4929
5033
|
wires.issued += 1;
|
|
5034
|
+
if (!contractCached) wires.requests += 1;
|
|
4930
5035
|
const contractRow = contract;
|
|
4931
5036
|
const companyID = num2(contractRow["companyID"]);
|
|
5037
|
+
const contractType = num2(contractRow["contractType"]);
|
|
4932
5038
|
let customer = null;
|
|
4933
5039
|
let customerStatus = "skipped";
|
|
5040
|
+
let customerAbsent;
|
|
4934
5041
|
if (companyID > 0) {
|
|
4935
5042
|
try {
|
|
4936
5043
|
const res = await http.request({
|
|
@@ -4938,98 +5045,97 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
4938
5045
|
path: `/V1.0/Companies/${companyID}`,
|
|
4939
5046
|
operation: OP2
|
|
4940
5047
|
});
|
|
4941
|
-
const item =
|
|
5048
|
+
const item = _chunkIHRXVIUUcjs.unwrapItem.call(void 0, res, companyID, OP2);
|
|
4942
5049
|
customer = _nullishCoalesce(item, () => ( null));
|
|
4943
5050
|
customerStatus = "ok";
|
|
4944
5051
|
} catch (err) {
|
|
4945
|
-
if (!(err instanceof
|
|
5052
|
+
if (!(err instanceof _chunkIHRXVIUUcjs.AutotaskError)) throw err;
|
|
5053
|
+
if (!(err instanceof _chunkIHRXVIUUcjs.NotFoundError)) {
|
|
5054
|
+
customerStatus = "absent";
|
|
5055
|
+
customerAbsent = err.code;
|
|
5056
|
+
}
|
|
4946
5057
|
}
|
|
4947
5058
|
wires.issued += 1;
|
|
4948
5059
|
}
|
|
5060
|
+
let contractTypeLabel = null;
|
|
5061
|
+
if (contractType > 0) {
|
|
5062
|
+
wires.issued += 1;
|
|
5063
|
+
try {
|
|
5064
|
+
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(http, "/V1.0/Contracts", OP2)), 'access', async _34 => _34.get, 'call', async _35 => _35("contractType"), 'optionalAccess', async _36 => _36.get, 'call', async _37 => _37(contractType)]), async () => ( null));
|
|
5065
|
+
} catch (err) {
|
|
5066
|
+
if (!(err instanceof _chunkIHRXVIUUcjs.AutotaskError)) throw err;
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5069
|
+
const contractTypeKnown = contractTypeLabel !== null;
|
|
5070
|
+
const isBlockHours = contractTypeKnown && BLOCK_HOURS_LABEL_RE.test(contractTypeLabel);
|
|
5071
|
+
const isTimeAndMaterials = contractTypeKnown && TIME_AND_MATERIALS_LABEL_RE.test(contractTypeLabel);
|
|
4949
5072
|
const servicesCond = [{ field: "contractID", op: "eq", value: id }];
|
|
4950
|
-
const servicesRaw = await
|
|
4951
|
-
|
|
4952
|
-
const
|
|
4953
|
-
const
|
|
4954
|
-
wires.issued += 1;
|
|
5073
|
+
const servicesRaw = await readPart("/V1.0/ContractServices/query", servicesCond, ["id", "serviceID", "unitPrice", "unitCost", "internalCurrencyUnitPrice", "internalDescription"]);
|
|
5074
|
+
const unitsCond = [{ field: "contractID", op: "eq", value: id }, ...windowOn("startDate")];
|
|
5075
|
+
const units = await windowedPart("contractServiceUnits", "contract_service_units", "/V1.0/ContractServiceUnits/query", unitsCond, ["id", "contractServiceID", "serviceID", "units", "price", "cost", "internalCurrencyPrice", "startDate", "endDate", "approveAndPostDate"], "startDate");
|
|
5076
|
+
const unitRows = units.rows;
|
|
4955
5077
|
let chargesPart;
|
|
4956
5078
|
let charges = [];
|
|
4957
5079
|
let chargesCond = [];
|
|
4958
5080
|
if (v.includeRecurringCosts) {
|
|
4959
|
-
chargesCond = [{ field: "contractID", op: "eq", value: id },
|
|
4960
|
-
const raw = await
|
|
4961
|
-
wires.issued += 1;
|
|
5081
|
+
chargesCond = [{ field: "contractID", op: "eq", value: id }, ...windowOn("datePurchased")];
|
|
5082
|
+
const raw = await readPart("/V1.0/ContractCharges/query", chargesCond, ["id", "chargeType", "billableAmount", "extendedCost", "unitCost", "unitPrice", "unitQuantity", "datePurchased", "isBilled", "status", "contractServiceID"]);
|
|
4962
5083
|
charges = raw.items;
|
|
4963
5084
|
chargesPart = stampPart("contract_charges", raw, chargesCond);
|
|
4964
5085
|
} else {
|
|
4965
5086
|
chargesPart = skipPart("skipped: includeRecurringCosts is false (zero wire)");
|
|
4966
5087
|
}
|
|
4967
5088
|
const roleCostsCond = [{ field: "contractID", op: "eq", value: id }];
|
|
4968
|
-
const roleCostsRaw = await
|
|
4969
|
-
wires.issued += 1;
|
|
5089
|
+
const roleCostsRaw = await readPart("/V1.0/ContractRoleCosts/query", roleCostsCond, ["id", "rate", "resourceID", "roleID"]);
|
|
4970
5090
|
const ratesCond = [{ field: "contractID", op: "eq", value: id }];
|
|
4971
|
-
const ratesRaw = await
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
let billingItems;
|
|
4978
|
-
let billingRows = [];
|
|
4979
|
-
if (!billingFirst.hasMore) {
|
|
4980
|
-
const st = unbilledWorkPartStatus("billing_items", billingCond(), billingFirst.items);
|
|
4981
|
-
billingRows = billingFirst.items;
|
|
4982
|
-
billingItems = { items: billingFirst.items, capped: billingFirst.capped, hasMore: false, status: st.status, blindSurface: st.blindSurface, note: st.note, emptyReason: billingFirst.items.length === 0 && st.status === "ok" ? _optionalChain([_chunk5N6DYKXOcjs.EMPTY_REASON_STAMPS, 'access', _31 => _31.billing_items, 'optionalAccess', _32 => _32.query]) : void 0 };
|
|
5091
|
+
const ratesRaw = await readPart("/V1.0/ContractRates/query", ratesCond, ["id", "roleID", "contractHourlyRate", "internalCurrencyContractHourlyRate"]);
|
|
5092
|
+
let blocksPart;
|
|
5093
|
+
if (!isBlockHours) {
|
|
5094
|
+
blocksPart = skipPart(
|
|
5095
|
+
contractTypeKnown ? `skipped: not a Block Hours contract (contractType ${contractType} "${contractTypeLabel}") \u2014 included hours apply to hour blocks only (zero wire)` : `skipped: the contract type is unknown (contractType ${contractType || "absent"}; label unresolved) \u2014 included hours are not evaluable (zero wire)`
|
|
5096
|
+
);
|
|
4983
5097
|
} else {
|
|
4984
|
-
const
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
}
|
|
5098
|
+
const blocksCond = [{ field: "contractID", op: "eq", value: id }];
|
|
5099
|
+
const raw = await readPart("/V1.0/ContractBlocks/query", blocksCond, ["id", "datePurchased", "startDate", "endDate", "hours", "hoursApproved", "status", "isPaid"]);
|
|
5100
|
+
blocksPart = stampPart("contract_blocks", raw, blocksCond);
|
|
5101
|
+
}
|
|
5102
|
+
const billingCond = [{ field: "contractID", op: "eq", value: id }, ...windowOn("itemDate")];
|
|
5103
|
+
const billingFields = ["id", "invoiceID", "timeEntryID", "ticketID", "ourCost", "quantity", "rate", "extendedPrice", "internalCurrencyExtendedPrice", "itemDate", "postedDate", "nonBillable", "billingCodeID", "billingItemType", "expenseItemID", ...SERVICE_LINE_FKS, ...CHARGE_LINE_FKS];
|
|
5104
|
+
const billing = await windowedPart("billingItems", "billing_items", "/V1.0/BillingItems/query", billingCond, billingFields, "itemDate");
|
|
5105
|
+
const billingItems = billing.part;
|
|
5106
|
+
const billingRows = billing.rows;
|
|
4988
5107
|
const invoiceIds = [...new Set(billingRows.map((b) => num2(b["invoiceID"])).filter((n) => n > 0))];
|
|
4989
5108
|
let invoicesPart;
|
|
4990
5109
|
let invoices = [];
|
|
4991
5110
|
if (invoiceIds.length === 0) {
|
|
4992
5111
|
invoicesPart = skipPart("skipped: the billing part has no invoiceIDs (zero wire)");
|
|
4993
5112
|
} else {
|
|
4994
|
-
const capped = capJoinSet2(invoiceIds,
|
|
4995
|
-
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `invoiceJoinTruncated: the join set is capped at ${
|
|
5113
|
+
const capped = capJoinSet2(invoiceIds, _chunkIHRXVIUUcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5114
|
+
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `invoiceJoinTruncated: the join set is capped at ${_chunkIHRXVIUUcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
|
|
4996
5115
|
const fb = await fetchByIdsPart(http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], OP2);
|
|
4997
5116
|
wires.issued += 1;
|
|
4998
5117
|
invoices = fb.items;
|
|
4999
5118
|
invoicesPart = { items: fb.items, capped: capped.truncated, hasMore: capped.truncated, status: "ok", note: fb.notes.join(" | ") || void 0 };
|
|
5000
5119
|
}
|
|
5001
|
-
const timeCond =
|
|
5120
|
+
const timeCond = [{ field: "contractID", op: "eq", value: id }, ...windowOn("dateWorked")];
|
|
5002
5121
|
const timeFields = ["id", "ticketID", "taskID", "resourceID", "roleID", "hoursWorked", "hoursToBill", "dateWorked", "startDateTime", "endDateTime", "isNonBillable", "timeEntryType", "billingCodeID", "createDateTime"];
|
|
5003
|
-
const
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
let entries = [];
|
|
5007
|
-
if (!timeFirst.hasMore) {
|
|
5008
|
-
const st = unbilledWorkPartStatus("time_entries", timeCond(), timeFirst.items);
|
|
5009
|
-
entries = timeFirst.items;
|
|
5010
|
-
timeEntries = { items: timeFirst.items, capped: timeFirst.capped, hasMore: false, status: st.status, blindSurface: st.blindSurface, note: st.note, emptyReason: timeFirst.items.length === 0 && st.status === "ok" ? _optionalChain([_chunk5N6DYKXOcjs.EMPTY_REASON_STAMPS, 'access', _33 => _33.time_entries, 'optionalAccess', _34 => _34.query]) : void 0 };
|
|
5011
|
-
} else {
|
|
5012
|
-
const wp = await expandByMonth(http, "/V1.0/TimeEntries/query", timeCond(), v.limit, OP2, timeFields, "dateWorked", v.dateFrom, v.dateTo, wires);
|
|
5013
|
-
entries = wp.items;
|
|
5014
|
-
timeEntries = { ...wp, items: wp.items, note: wp.note };
|
|
5015
|
-
}
|
|
5122
|
+
const time = await windowedPart("timeEntries", "time_entries", "/V1.0/TimeEntries/query", timeCond, timeFields, "dateWorked");
|
|
5123
|
+
const timeEntries = time.part;
|
|
5124
|
+
const entries = time.rows;
|
|
5016
5125
|
const ticketFields = ["id", "ticketNumber", "title", "status", "ticketCategory", "contractID", "createDate", "resolvedDateTime", "completedDate", "lastActivityDate", "dueDateTime"];
|
|
5017
|
-
const
|
|
5018
|
-
const
|
|
5019
|
-
|
|
5126
|
+
const createdInWindow = [{ field: "contractID", op: "eq", value: id }, ...windowOn("createDate")];
|
|
5127
|
+
const refTicketIds = capJoinSet2(entries.map((e) => num2(e["ticketID"])).filter((n) => n > 0), v.maxTicketsForJoin);
|
|
5128
|
+
const ticketsActCond = refTicketIds.ids.length === 0 ? createdInWindow : [{ op: "or", items: [{ op: "and", items: createdInWindow }, { field: "id", op: "in", value: refTicketIds.ids }] }];
|
|
5129
|
+
const ticketsActRaw = await readPart("/V1.0/Tickets/query", ticketsActCond, ticketFields);
|
|
5020
5130
|
let openStatusSet = null;
|
|
5021
5131
|
let statusNote;
|
|
5132
|
+
wires.issued += 1;
|
|
5022
5133
|
try {
|
|
5023
|
-
const
|
|
5024
|
-
|
|
5025
|
-
const body = typeof res === "object" && res !== null ? res : {};
|
|
5026
|
-
const fields = Array.isArray(body["fields"]) ? body["fields"] : [];
|
|
5027
|
-
const statusRow = fields.find((f) => f["name"] === "status" && f["isPickList"] === true);
|
|
5028
|
-
const values = statusRow && Array.isArray(statusRow["picklistValues"]) ? statusRow["picklistValues"] : [];
|
|
5029
|
-
if (values.length === 0) {
|
|
5134
|
+
const values = (await readPicklists(http, "/V1.0/Tickets", OP2)).get("status");
|
|
5135
|
+
if (values === void 0 || values.size === 0) {
|
|
5030
5136
|
statusNote = "the tickets.status picklist is not exposed to this API user \u2014 the open-status labels are unavailable";
|
|
5031
5137
|
} else {
|
|
5032
|
-
const open = values.filter((
|
|
5138
|
+
const open = [...values].filter(([, label]) => !CLOSED_STATUS_LABEL_RE.test(label)).map(([v2]) => v2);
|
|
5033
5139
|
if (open.length === 0) {
|
|
5034
5140
|
statusNote = "every tickets.status picklist label is closed-class \u2014 no open statuses exist in this tenant";
|
|
5035
5141
|
} else {
|
|
@@ -5037,8 +5143,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5037
5143
|
}
|
|
5038
5144
|
}
|
|
5039
5145
|
} catch (err) {
|
|
5040
|
-
|
|
5041
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunk5N6DYKXOcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5146
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkIHRXVIUUcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5042
5147
|
}
|
|
5043
5148
|
let ticketsOpenPart;
|
|
5044
5149
|
let openTickets = [];
|
|
@@ -5046,8 +5151,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5046
5151
|
ticketsOpenPart = skipPart(`skipped: ${statusNote} (zero wire)`);
|
|
5047
5152
|
} else {
|
|
5048
5153
|
const openCond = [{ field: "contractID", op: "eq", value: id }, { field: "status", op: "in", value: [...openStatusSet] }];
|
|
5049
|
-
const raw = await
|
|
5050
|
-
wires.issued += 1;
|
|
5154
|
+
const raw = await readPart("/V1.0/Tickets/query", openCond, ticketFields);
|
|
5051
5155
|
openTickets = raw.items;
|
|
5052
5156
|
ticketsOpenPart = stampPart("tickets", raw, openCond, ["openStatusHeuristic: true (the open set is the tenant picklist minus the closed-class labels)"]);
|
|
5053
5157
|
}
|
|
@@ -5058,8 +5162,8 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5058
5162
|
if (resourceIds.length === 0) {
|
|
5059
5163
|
resourcesPart = skipPart("skipped: the time part has no resourceIDs (zero wire)");
|
|
5060
5164
|
} else {
|
|
5061
|
-
const capped = capJoinSet2(resourceIds,
|
|
5062
|
-
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `resourceJoinTruncated: the join set is capped at ${
|
|
5165
|
+
const capped = capJoinSet2(resourceIds, _chunkIHRXVIUUcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5166
|
+
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `resourceJoinTruncated: the join set is capped at ${_chunkIHRXVIUUcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
|
|
5063
5167
|
const fb = await fetchByIdsPart(http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], OP2);
|
|
5064
5168
|
wires.issued += 1;
|
|
5065
5169
|
resources = fb.items;
|
|
@@ -5071,16 +5175,16 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5071
5175
|
const k = num2(t["id"]);
|
|
5072
5176
|
if (k > 0 && !fetchedTickets.has(k)) fetchedTickets.set(k, t);
|
|
5073
5177
|
}
|
|
5074
|
-
const
|
|
5178
|
+
const contractTickets = [...fetchedTickets.values()].filter((t) => num2(t["contractID"]) === idNum);
|
|
5179
|
+
const ticketJoin = capJoinSet2(contractTickets.map((t) => num2(t["id"])), v.maxTicketsForJoin);
|
|
5075
5180
|
const joinNote = ticketJoin.truncated ? `the ticket join set is capped at ${v.maxTicketsForJoin} of ${ticketJoin.total} ids \u2014 the expenses + the miscoding probe cover the returned join set only` : void 0;
|
|
5076
5181
|
let expensesPart;
|
|
5077
5182
|
let expenses = [];
|
|
5078
5183
|
if (ticketJoin.ids.length === 0) {
|
|
5079
5184
|
expensesPart = skipPart("skipped: the contract has no fetched tickets to join against (an empty join set is NOT evidence of no expenses \u2014 zero wire)");
|
|
5080
5185
|
} else {
|
|
5081
|
-
const expCond = [{ field: "ticketID", op: "in", value: ticketJoin.ids },
|
|
5082
|
-
const raw = await
|
|
5083
|
-
wires.issued += 1;
|
|
5186
|
+
const expCond = [{ field: "ticketID", op: "in", value: ticketJoin.ids }, ...windowOn("expenseDate")];
|
|
5187
|
+
const raw = await readPart("/V1.0/ExpenseItems/query", expCond, ["id", "expenseDate", "expenseCategory", "paymentType", "expenseCurrencyExpenseAmount", "internalCurrencyExpenseAmount", "ticketID"]);
|
|
5084
5188
|
expenses = raw.items;
|
|
5085
5189
|
expensesPart = stampPart("expense_items", raw, expCond, joinNote === void 0 ? void 0 : [joinNote]);
|
|
5086
5190
|
}
|
|
@@ -5092,45 +5196,69 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5092
5196
|
const probeCond = [
|
|
5093
5197
|
{ field: "ticketID", op: "in", value: ticketJoin.ids },
|
|
5094
5198
|
{ op: "or", items: [{ field: "contractID", op: "noteq", value: id }, { field: "contractID", op: "notExist" }] },
|
|
5095
|
-
|
|
5096
|
-
{ field: "dateWorked", op: "lte", value: v.dateTo }
|
|
5199
|
+
...windowOn("dateWorked")
|
|
5097
5200
|
];
|
|
5098
|
-
const raw = await
|
|
5099
|
-
wires.issued += 1;
|
|
5201
|
+
const raw = await readPart("/V1.0/TimeEntries/query", probeCond, ["id", "ticketID", "contractID", "resourceID", "hoursWorked", "dateWorked"]);
|
|
5100
5202
|
probeRows = raw.items;
|
|
5101
5203
|
probePart = stampPart("time_entries", raw, probeCond, joinNote === void 0 ? void 0 : [joinNote]);
|
|
5102
5204
|
}
|
|
5103
5205
|
let configurationItemsPart;
|
|
5104
5206
|
let cis = [];
|
|
5105
|
-
let ciCond = [];
|
|
5106
5207
|
if (!v.includeRecurringCosts) {
|
|
5107
5208
|
configurationItemsPart = skipPart("skipped: includeRecurringCosts is false (zero wire)");
|
|
5108
|
-
} else if (companyID <= 0) {
|
|
5109
|
-
configurationItemsPart = skipPart("skipped: the contract carries no companyID \u2014 the CI join has no root (zero wire)");
|
|
5110
5209
|
} else {
|
|
5111
|
-
ciCond = [{ field: "
|
|
5112
|
-
const raw = await
|
|
5113
|
-
wires.issued += 1;
|
|
5210
|
+
const ciCond = [{ field: "contractID", op: "eq", value: id }];
|
|
5211
|
+
const raw = await readPart("/V1.0/ConfigurationItems/query", ciCond, ["id", "configurationItemName", "status", "contractID"]);
|
|
5114
5212
|
cis = raw.items;
|
|
5115
5213
|
configurationItemsPart = stampPart("configuration_items", raw, ciCond);
|
|
5116
5214
|
}
|
|
5117
5215
|
let subscriptionsPart;
|
|
5118
5216
|
let subscriptions = [];
|
|
5217
|
+
const subFactor = /* @__PURE__ */ new Map();
|
|
5218
|
+
const oneTimeSubs = /* @__PURE__ */ new Set();
|
|
5219
|
+
const cancelledSubs = /* @__PURE__ */ new Set();
|
|
5119
5220
|
if (cis.length === 0) {
|
|
5120
5221
|
subscriptionsPart = skipPart("skipped: the CI join found no configuration items \u2014 the subscriptions part is not evaluable (zero wire)");
|
|
5121
5222
|
} else {
|
|
5122
|
-
const ciIds = capJoinSet2(cis.map((c) => num2(c["id"])).filter((n) => n > 0),
|
|
5223
|
+
const ciIds = capJoinSet2(cis.map((c) => num2(c["id"])).filter((n) => n > 0), _chunkIHRXVIUUcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5123
5224
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5124
|
-
const raw = await
|
|
5125
|
-
wires.issued += 1;
|
|
5225
|
+
const raw = await readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5126
5226
|
subscriptions = raw.items;
|
|
5127
|
-
|
|
5227
|
+
let labels = null;
|
|
5228
|
+
if (subscriptions.length > 0) {
|
|
5229
|
+
wires.issued += 1;
|
|
5230
|
+
try {
|
|
5231
|
+
labels = await readPicklists(http, "/V1.0/Subscriptions", OP2);
|
|
5232
|
+
} catch (err) {
|
|
5233
|
+
if (!(err instanceof _chunkIHRXVIUUcjs.AutotaskError)) throw err;
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
for (const x of subscriptions) {
|
|
5237
|
+
const sid = num2(x["id"]);
|
|
5238
|
+
const periodLabel = _optionalChain([labels, 'optionalAccess', _38 => _38.get, 'call', _39 => _39("periodType"), 'optionalAccess', _40 => _40.get, 'call', _41 => _41(num2(x["periodType"]))]);
|
|
5239
|
+
subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
|
|
5240
|
+
if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
|
|
5241
|
+
const statusLabel = _optionalChain([labels, 'optionalAccess', _42 => _42.get, 'call', _43 => _43("status"), 'optionalAccess', _44 => _44.get, 'call', _45 => _45(num2(x["status"]))]);
|
|
5242
|
+
const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num2(x["status"]));
|
|
5243
|
+
if (notActive) cancelledSubs.add(sid);
|
|
5244
|
+
}
|
|
5245
|
+
const unknownPeriods = [...new Set(subscriptions.filter((x) => subFactor.get(num2(x["id"])) === null && !oneTimeSubs.has(num2(x["id"]))).map((x) => String(_nullishCoalesce(x["periodType"], () => ( "absent")))))];
|
|
5246
|
+
subscriptionsPart = stampPart("subscriptions", raw, subCond, [
|
|
5247
|
+
"scope: the subscriptions on the CIs this contract covers \u2014 periodCost prorated to a month by periodType into tooling_cost.vendor, REPORTED but NOT folded into total_cost/profit/margin (subscriptions bill outside the contract)",
|
|
5248
|
+
...subscriptions.length > 0 && labels === null ? ["the Subscriptions field catalog read failed \u2014 the verified id maps apply (periodType 1 One-Time, 2 Monthly, 3 Quarterly, 4 Semi-Annual, 5 Yearly; status 2 Cancelled / 3 Inactive excluded)"] : [],
|
|
5249
|
+
...cancelledSubs.size > 0 ? [`${cancelledSubs.size} not-active (cancelled/inactive) subscription(s) excluded from tooling_cost.vendor`] : [],
|
|
5250
|
+
...oneTimeSubs.size > 0 ? [`${oneTimeSubs.size} one-time subscription(s): periodCost booked whole in the effectiveDate month, never prorated`] : [],
|
|
5251
|
+
...unknownPeriods.length > 0 ? [`unrecognised periodType ${unknownPeriods.join(", ")} \u2014 those subscriptions are excluded from tooling_cost.vendor (not prorated)`] : []
|
|
5252
|
+
]);
|
|
5128
5253
|
}
|
|
5129
5254
|
const servicesPart = stampPart("contract_services", servicesRaw, servicesCond);
|
|
5130
|
-
const unitsPart =
|
|
5255
|
+
const unitsPart = units.part;
|
|
5131
5256
|
const roleCostsPart = stampPart("contract_role_costs", roleCostsRaw, roleCostsCond);
|
|
5132
5257
|
const ratesPart = stampPart("contract_rates", ratesRaw, ratesCond);
|
|
5133
|
-
const ticketsActivityPart = stampPart("tickets", ticketsActRaw, ticketsActCond,
|
|
5258
|
+
const ticketsActivityPart = stampPart("tickets", ticketsActRaw, ticketsActCond, [
|
|
5259
|
+
...ticketsActRaw.hasMore ? [`${fetchedTickets.size} ticket(s) returned of possibly more \u2014 the checks cover the returned set only`] : [],
|
|
5260
|
+
...refTicketIds.truncated ? [`the time-referenced ticket ids are capped at ${v.maxTicketsForJoin} of ${refTicketIds.total} \u2014 the rest read as ticket_not_in_fetched_set`] : []
|
|
5261
|
+
]);
|
|
5134
5262
|
const billedByEntryId = /* @__PURE__ */ new Map();
|
|
5135
5263
|
for (const b of billingRows) {
|
|
5136
5264
|
const te = num2(b["timeEntryID"]);
|
|
@@ -5171,56 +5299,92 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5171
5299
|
bucket.hours += hoursOf(e);
|
|
5172
5300
|
bucket.cost += _nullishCoalesce(r.cost, () => ( 0));
|
|
5173
5301
|
}
|
|
5302
|
+
for (const b of Object.values(sources)) b.cost = cents(b.cost);
|
|
5174
5303
|
const unresolvedHours = sources.missing.hours;
|
|
5175
5304
|
if (unresolvedHours > 0) resolutionNotes.push(`${fmtHours(unresolvedHours)} hours unresolved (missing rate) \u2014 total_cost is a lower bound`);
|
|
5176
5305
|
const costRateResolution = { method: v.method, sources, unresolvedHours, notes: resolutionNotes };
|
|
5177
5306
|
const months = monthsBetween(v.dateFrom, v.dateTo);
|
|
5178
5307
|
const monthOf = (date) => typeof date === "string" && DATE_RE2.test(`${date}`.slice(0, 10)) ? date.slice(0, 7) : null;
|
|
5179
5308
|
const inMonth = (date, m) => monthOf(date) === m;
|
|
5180
|
-
const
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
};
|
|
5185
|
-
const serviceById = new Map(servicesRaw.items.map((s) => [num2(s["id"]), s]));
|
|
5186
|
-
const expectedBasis = servicesRaw.items.length > 0 || unitsRaw.items.length > 0;
|
|
5187
|
-
const expectedIn = (m) => {
|
|
5188
|
-
let total = 0;
|
|
5189
|
-
for (const u of unitsRaw.items) {
|
|
5190
|
-
if (!unitEffectiveIn(u, m)) continue;
|
|
5191
|
-
const svc = serviceById.get(num2(u["contractServiceID"]));
|
|
5192
|
-
if (svc === void 0) continue;
|
|
5193
|
-
total += num2(svc["unitPrice"]) * num2(u["units"]);
|
|
5194
|
-
}
|
|
5195
|
-
return total;
|
|
5196
|
-
};
|
|
5309
|
+
const unitIn = (unit, m) => inMonth(unit["startDate"], m);
|
|
5310
|
+
const lineRevenue = (b) => internalAmount(b, "internalCurrencyExtendedPrice", "extendedPrice");
|
|
5311
|
+
const expectedBasis = unitsPart.status !== "absent" && (servicesRaw.items.length > 0 || unitRows.length > 0);
|
|
5312
|
+
const expectedIn = (m) => unitRows.filter((u) => unitIn(u, m)).reduce((a, u) => a + internalAmount(u, "internalCurrencyPrice", "price"), 0);
|
|
5197
5313
|
const recurringIn = (m) => {
|
|
5198
5314
|
if (!v.includeRecurringCosts) return 0;
|
|
5199
5315
|
let total = 0;
|
|
5200
|
-
for (const c of charges) if (inMonth(c["datePurchased"], m)) total +=
|
|
5201
|
-
for (const u of
|
|
5316
|
+
for (const c of charges) if (inMonth(c["datePurchased"], m)) total += chargeCost(c);
|
|
5317
|
+
for (const u of unitRows) if (unitIn(u, m)) total += num2(u["cost"]);
|
|
5202
5318
|
return total;
|
|
5203
5319
|
};
|
|
5204
5320
|
const invoicesById = new Map(invoices.map((i) => [num2(i["id"]), i]));
|
|
5321
|
+
const billedServiceIn = (m) => {
|
|
5322
|
+
let billed = 0;
|
|
5323
|
+
const ids = [];
|
|
5324
|
+
for (const b of billingRows) {
|
|
5325
|
+
if (!inMonth(b["itemDate"], m) || billingLineType(b) !== "recurring") continue;
|
|
5326
|
+
const invId = num2(b["invoiceID"]);
|
|
5327
|
+
const inv = invId > 0 ? invoicesById.get(invId) : void 0;
|
|
5328
|
+
if (inv === void 0 || inv["isVoided"] === true) continue;
|
|
5329
|
+
billed += lineRevenue(b);
|
|
5330
|
+
ids.push(num2(b["id"]));
|
|
5331
|
+
}
|
|
5332
|
+
return { billed, ids };
|
|
5333
|
+
};
|
|
5334
|
+
const contractRateByRole = /* @__PURE__ */ new Map();
|
|
5335
|
+
for (const r of ratesRaw.items) {
|
|
5336
|
+
const rate = typeof r["internalCurrencyContractHourlyRate"] === "number" ? r["internalCurrencyContractHourlyRate"] : r["contractHourlyRate"];
|
|
5337
|
+
if (num2(r["roleID"]) > 0 && typeof rate === "number" && Number.isFinite(rate)) contractRateByRole.set(num2(r["roleID"]), rate);
|
|
5338
|
+
}
|
|
5339
|
+
const monthlyParts = [
|
|
5340
|
+
["contractServiceUnits", unitsPart],
|
|
5341
|
+
["contractCharges", chargesPart],
|
|
5342
|
+
["contractRoleCosts", roleCostsPart],
|
|
5343
|
+
["billingItems", billingItems],
|
|
5344
|
+
["timeEntries", timeEntries],
|
|
5345
|
+
["expenses", expensesPart],
|
|
5346
|
+
["subscriptions", subscriptionsPart]
|
|
5347
|
+
];
|
|
5348
|
+
const coverageGaps = (m) => {
|
|
5349
|
+
const gaps = [];
|
|
5350
|
+
for (const [name, p] of monthlyParts) {
|
|
5351
|
+
if (p.status === "absent") gaps.push(`${name}: absent (${p.absent})`);
|
|
5352
|
+
else if (truncatedMonths[name] !== void 0) {
|
|
5353
|
+
if (truncatedMonths[name].includes(m)) gaps.push(`${name}: truncated at limit ${v.limit}`);
|
|
5354
|
+
} else if (p.hasMore) gaps.push(`${name}: capped at limit ${v.limit}`);
|
|
5355
|
+
}
|
|
5356
|
+
return gaps;
|
|
5357
|
+
};
|
|
5205
5358
|
const monthly = [];
|
|
5206
5359
|
for (let mi = 0; mi < months.length; mi++) {
|
|
5207
5360
|
const m = months[mi];
|
|
5208
5361
|
const mBilling = billingRows.filter((b) => inMonth(b["itemDate"], m));
|
|
5209
5362
|
let revenueInvoiced = 0;
|
|
5210
5363
|
let revenueVoided = 0;
|
|
5211
|
-
|
|
5364
|
+
let postedUninvoiced = 0;
|
|
5365
|
+
const byType = { recurring: 0, labour: 0, charges: 0, expenses: 0, other: 0 };
|
|
5366
|
+
let unresolvedInvoice = 0;
|
|
5367
|
+
let unresolvedLines = 0;
|
|
5212
5368
|
for (const b of mBilling) {
|
|
5213
5369
|
const invId = num2(b["invoiceID"]);
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5370
|
+
if (invId <= 0) {
|
|
5371
|
+
postedUninvoiced += lineRevenue(b);
|
|
5372
|
+
continue;
|
|
5373
|
+
}
|
|
5374
|
+
const inv = invoicesById.get(invId);
|
|
5375
|
+
if (inv === void 0) {
|
|
5376
|
+
unresolvedInvoice += lineRevenue(b);
|
|
5377
|
+
unresolvedLines += 1;
|
|
5378
|
+
continue;
|
|
5379
|
+
}
|
|
5380
|
+
if (inv["isVoided"] === true) revenueVoided += lineRevenue(b);
|
|
5217
5381
|
else {
|
|
5218
|
-
revenueInvoiced +=
|
|
5219
|
-
|
|
5382
|
+
revenueInvoiced += lineRevenue(b);
|
|
5383
|
+
byType[billingLineType(b)] += lineRevenue(b);
|
|
5220
5384
|
}
|
|
5221
5385
|
}
|
|
5222
5386
|
const expected = v.includeUnbilledRevenue && expectedBasis ? expectedIn(m) : null;
|
|
5223
|
-
const expectedUnbilled = expected === null ? 0 : Math.max(0, expected -
|
|
5387
|
+
const expectedUnbilled = expected === null ? 0 : Math.max(0, expected - billedServiceIn(m).billed);
|
|
5224
5388
|
const mEntries = entries.filter((e) => inMonth(e["dateWorked"], m));
|
|
5225
5389
|
let labourHours = 0;
|
|
5226
5390
|
let labourTotal = 0;
|
|
@@ -5230,7 +5394,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5230
5394
|
rateSources.missing = { entries: 0, hours: 0, cost: 0 };
|
|
5231
5395
|
for (const e of mEntries) {
|
|
5232
5396
|
const r = entryResolution.get(num2(e["id"]));
|
|
5233
|
-
labourHours +=
|
|
5397
|
+
labourHours += hoursOf(e);
|
|
5234
5398
|
const bucket = rateSources[r.source];
|
|
5235
5399
|
bucket.entries += 1;
|
|
5236
5400
|
bucket.hours += hoursOf(e);
|
|
@@ -5238,39 +5402,68 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5238
5402
|
if (r.source === "missing") unresolved += hoursOf(e);
|
|
5239
5403
|
else labourTotal += _nullishCoalesce(r.cost, () => ( 0));
|
|
5240
5404
|
}
|
|
5241
|
-
|
|
5405
|
+
const unposted = mEntries.filter((e) => e["isNonBillable"] !== true && !billedByEntryId.has(num2(e["id"])));
|
|
5406
|
+
const unpostedHours = unposted.reduce((a, e) => a + Math.max(0, num2(e["hoursToBill"])), 0);
|
|
5407
|
+
let unpostedTime;
|
|
5408
|
+
if (!contractTypeKnown) {
|
|
5409
|
+
unpostedTime = { entries: unposted.length, hours: unpostedHours, value: null, absent: "CONTRACT_TYPE_UNKNOWN" };
|
|
5410
|
+
} else if (!isTimeAndMaterials) {
|
|
5411
|
+
unpostedTime = { entries: unposted.length, hours: unpostedHours, value: null, absent: "NOT_TIME_AND_MATERIALS_CONTRACT" };
|
|
5412
|
+
} else if (unposted.some((e) => !contractRateByRole.has(num2(e["roleID"])))) {
|
|
5413
|
+
unpostedTime = { entries: unposted.length, hours: unpostedHours, value: null, absent: "NO_CONTRACT_RATE" };
|
|
5414
|
+
} else {
|
|
5415
|
+
const value = unposted.reduce((a, e) => a + Math.max(0, num2(e["hoursToBill"])) * contractRateByRole.get(num2(e["roleID"])), 0);
|
|
5416
|
+
unpostedTime = { entries: unposted.length, hours: unpostedHours, value };
|
|
5417
|
+
}
|
|
5418
|
+
let toolingVendor = subscriptionsPart.status === "skipped" || subscriptionsPart.status === "absent" ? null : 0;
|
|
5242
5419
|
if (toolingVendor !== null) {
|
|
5243
5420
|
for (const s of subscriptions) {
|
|
5244
5421
|
const eff = _nullishCoalesce(monthOf(s["effectiveDate"]), () => ( "0000-00"));
|
|
5245
5422
|
const exp = _nullishCoalesce(monthOf(s["expirationDate"]), () => ( "9999-99"));
|
|
5246
|
-
|
|
5423
|
+
const sid = num2(s["id"]);
|
|
5424
|
+
if (cancelledSubs.has(sid)) continue;
|
|
5425
|
+
if (oneTimeSubs.has(sid)) {
|
|
5426
|
+
if (eff === m) toolingVendor += num2(s["periodCost"]);
|
|
5427
|
+
continue;
|
|
5428
|
+
}
|
|
5429
|
+
const factor = _nullishCoalesce(subFactor.get(sid), () => ( null));
|
|
5430
|
+
if (factor !== null && eff <= m && m <= exp) toolingVendor += num2(s["periodCost"]) * factor;
|
|
5247
5431
|
}
|
|
5248
5432
|
}
|
|
5249
5433
|
const callerSupplied = _nullishCoalesce(v.externalMonthlyCosts[mi], () => ( 0));
|
|
5250
5434
|
const recurring = recurringIn(m);
|
|
5251
5435
|
let expenseCost = 0;
|
|
5252
|
-
for (const x of expenses) if (inMonth(x["expenseDate"], m)) expenseCost += num2(x["
|
|
5253
|
-
const totalCost = labourTotal +
|
|
5436
|
+
for (const x of expenses) if (inMonth(x["expenseDate"], m)) expenseCost += num2(x["internalCurrencyExpenseAmount"]);
|
|
5437
|
+
const totalCost = labourTotal + callerSupplied + recurring + expenseCost;
|
|
5254
5438
|
const profit = revenueInvoiced - totalCost;
|
|
5255
5439
|
const margin = revenueInvoiced > 0 ? profit / revenueInvoiced : null;
|
|
5256
|
-
const
|
|
5440
|
+
const nonLabour = totalCost - labourTotal;
|
|
5257
5441
|
const resolvedHours = mEntries.filter((e) => entryResolution.get(num2(e["id"])).source !== "missing").reduce((a, e) => a + hoursOf(e), 0);
|
|
5258
|
-
const
|
|
5442
|
+
const avgRate = resolvedHours > 0 ? labourTotal / resolvedHours : 0;
|
|
5443
|
+
const breakEven = avgRate > 0 ? Math.max(0, (revenueInvoiced - nonLabour) / avgRate) : null;
|
|
5444
|
+
for (const b of Object.values(rateSources)) b.cost = cents(b.cost);
|
|
5445
|
+
const gaps = coverageGaps(m);
|
|
5446
|
+
if (unresolvedLines > 0) gaps.push(`invoices: ${unresolvedLines} line(s) on unresolved invoices`);
|
|
5259
5447
|
monthly.push({
|
|
5260
5448
|
month: m,
|
|
5261
|
-
revenue_invoiced: revenueInvoiced,
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5449
|
+
revenue_invoiced: cents(revenueInvoiced),
|
|
5450
|
+
revenue_by_type: { recurring: cents(byType.recurring), labour: cents(byType.labour), charges: cents(byType.charges), expenses: cents(byType.expenses), other: cents(byType.other) },
|
|
5451
|
+
revenue_voided_excluded: cents(revenueVoided),
|
|
5452
|
+
revenue_posted_uninvoiced: cents(postedUninvoiced),
|
|
5453
|
+
revenue_unresolved_invoice: cents(unresolvedInvoice),
|
|
5454
|
+
revenue_expected: cents(expected),
|
|
5455
|
+
revenue_expected_unbilled: cents(expectedUnbilled),
|
|
5456
|
+
unposted_time: { ...unpostedTime, value: cents(unpostedTime.value) },
|
|
5265
5457
|
labour_hours: labourHours,
|
|
5266
|
-
labour_cost: { total: labourTotal, unresolvedHours: unresolved, rateSources },
|
|
5267
|
-
tooling_cost: { vendor: toolingVendor, caller_supplied: callerSupplied },
|
|
5268
|
-
recurring_cost: recurring,
|
|
5269
|
-
expense_cost: expenseCost,
|
|
5270
|
-
total_cost: totalCost,
|
|
5271
|
-
profit,
|
|
5458
|
+
labour_cost: { total: cents(labourTotal), unresolvedHours: unresolved, rateSources },
|
|
5459
|
+
tooling_cost: { vendor: cents(toolingVendor), caller_supplied: cents(callerSupplied) },
|
|
5460
|
+
recurring_cost: cents(recurring),
|
|
5461
|
+
expense_cost: cents(expenseCost),
|
|
5462
|
+
total_cost: cents(totalCost),
|
|
5463
|
+
profit: cents(profit),
|
|
5272
5464
|
margin,
|
|
5273
|
-
break_even_hours: breakEven
|
|
5465
|
+
break_even_hours: breakEven,
|
|
5466
|
+
coverage_gaps: gaps
|
|
5274
5467
|
});
|
|
5275
5468
|
}
|
|
5276
5469
|
const warnings = [];
|
|
@@ -5334,13 +5527,13 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5334
5527
|
const mA = months[i - 1];
|
|
5335
5528
|
const mB = months[i];
|
|
5336
5529
|
for (const c of charges) {
|
|
5337
|
-
const cA = inMonth(c["datePurchased"], mA) ?
|
|
5338
|
-
const cB = inMonth(c["datePurchased"], mB) ?
|
|
5530
|
+
const cA = inMonth(c["datePurchased"], mA) ? chargeCost(c) : 0;
|
|
5531
|
+
const cB = inMonth(c["datePurchased"], mB) ? chargeCost(c) : 0;
|
|
5339
5532
|
if (Math.abs(cB - cA) > 0) driftIds.add(num2(c["id"]));
|
|
5340
5533
|
}
|
|
5341
|
-
for (const u of
|
|
5342
|
-
const cA =
|
|
5343
|
-
const cB =
|
|
5534
|
+
for (const u of unitRows) {
|
|
5535
|
+
const cA = unitIn(u, mA) ? num2(u["cost"]) : 0;
|
|
5536
|
+
const cB = unitIn(u, mB) ? num2(u["cost"]) : 0;
|
|
5344
5537
|
if (Math.abs(cB - cA) > 0) driftIds.add(num2(u["id"]));
|
|
5345
5538
|
}
|
|
5346
5539
|
}
|
|
@@ -5348,22 +5541,10 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5348
5541
|
warnings.push({ code: "recurring_cost_drift", count: driftCount, sample_ids: dedupeSortCap([...driftIds], v.limit) });
|
|
5349
5542
|
let expectedUnbilledCount = 0;
|
|
5350
5543
|
const expectedUnbilledSamples = [];
|
|
5351
|
-
if (v.includeUnbilledRevenue) {
|
|
5352
|
-
for (
|
|
5353
|
-
const
|
|
5354
|
-
|
|
5355
|
-
if (expected === null) continue;
|
|
5356
|
-
const mBilling = billingRows.filter((b) => inMonth(b["itemDate"], m));
|
|
5357
|
-
let billed = 0;
|
|
5358
|
-
const ids = [];
|
|
5359
|
-
for (const b of mBilling) {
|
|
5360
|
-
const invId = num2(b["invoiceID"]);
|
|
5361
|
-
const inv = invId > 0 ? invoicesById.get(invId) : void 0;
|
|
5362
|
-
if (inv === void 0 || inv["isVoided"] === true) continue;
|
|
5363
|
-
billed += num2(b["extendedPrice"]);
|
|
5364
|
-
ids.push(num2(b["id"]));
|
|
5365
|
-
}
|
|
5366
|
-
if (expected > billed + 5e-3) {
|
|
5544
|
+
if (v.includeUnbilledRevenue && expectedBasis) {
|
|
5545
|
+
for (const m of months) {
|
|
5546
|
+
const { billed, ids } = billedServiceIn(m);
|
|
5547
|
+
if (expectedIn(m) > billed + 5e-3) {
|
|
5367
5548
|
expectedUnbilledCount += 1;
|
|
5368
5549
|
for (const i of ids) expectedUnbilledSamples.push(i);
|
|
5369
5550
|
}
|
|
@@ -5379,7 +5560,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5379
5560
|
});
|
|
5380
5561
|
const stale = [];
|
|
5381
5562
|
if (openStatusSet !== null) {
|
|
5382
|
-
for (const t of
|
|
5563
|
+
for (const t of contractTickets) {
|
|
5383
5564
|
const status = t["status"];
|
|
5384
5565
|
if (typeof status !== "number" || !openStatusSet.has(status)) continue;
|
|
5385
5566
|
const lastDay = dateToDay(t["lastActivityDate"]);
|
|
@@ -5431,7 +5612,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5431
5612
|
for (const x of expenses) {
|
|
5432
5613
|
const t = num2(x["ticketID"]);
|
|
5433
5614
|
if (t <= 0) continue;
|
|
5434
|
-
expenseByTicket.set(t, (_nullishCoalesce(expenseByTicket.get(t), () => ( 0))) + num2(x["
|
|
5615
|
+
expenseByTicket.set(t, (_nullishCoalesce(expenseByTicket.get(t), () => ( 0))) + num2(x["internalCurrencyExpenseAmount"]));
|
|
5435
5616
|
}
|
|
5436
5617
|
const ticketCost = (t) => {
|
|
5437
5618
|
const tid = num2(t["id"]);
|
|
@@ -5440,7 +5621,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5440
5621
|
for (const e of es) cost += _nullishCoalesce(entryResolution.get(num2(e["id"])).cost, () => ( 0));
|
|
5441
5622
|
return cost;
|
|
5442
5623
|
};
|
|
5443
|
-
const ticketHours = (t) => (_nullishCoalesce(entriesByTicket.get(num2(t["id"])), () => ( []))).reduce((a, e) => a +
|
|
5624
|
+
const ticketHours = (t) => (_nullishCoalesce(entriesByTicket.get(num2(t["id"])), () => ( []))).reduce((a, e) => a + hoursOf(e), 0);
|
|
5444
5625
|
const allTickets = [...fetchedTickets.values()];
|
|
5445
5626
|
const activityCategories = [];
|
|
5446
5627
|
if (v.groupByActivity) {
|
|
@@ -5458,7 +5639,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5458
5639
|
for (const t of tickets) {
|
|
5459
5640
|
const es = _nullishCoalesce(entriesByTicket.get(num2(t["id"])), () => ( []));
|
|
5460
5641
|
entryCount += es.length;
|
|
5461
|
-
hours += es.reduce((a, e) => a +
|
|
5642
|
+
hours += es.reduce((a, e) => a + hoursOf(e), 0);
|
|
5462
5643
|
cost += ticketCost(t);
|
|
5463
5644
|
}
|
|
5464
5645
|
activityCategories.push({
|
|
@@ -5466,7 +5647,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5466
5647
|
ticketCount: tickets.length,
|
|
5467
5648
|
entryCount,
|
|
5468
5649
|
hours,
|
|
5469
|
-
cost,
|
|
5650
|
+
cost: cents(cost),
|
|
5470
5651
|
sample_ticketNumbers: dedupeSortCap(tickets.map((t) => num2(t["ticketNumber"])).filter((n) => n > 0), v.limit)
|
|
5471
5652
|
});
|
|
5472
5653
|
}
|
|
@@ -5478,7 +5659,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5478
5659
|
title: typeof t["title"] === "string" ? t["title"] : "",
|
|
5479
5660
|
status: typeof t["status"] === "number" ? t["status"] : null,
|
|
5480
5661
|
hours: ticketHours(t),
|
|
5481
|
-
cost: ticketCost(t),
|
|
5662
|
+
cost: cents(ticketCost(t)),
|
|
5482
5663
|
lastActivityDate: typeof t["lastActivityDate"] === "string" ? t["lastActivityDate"] : null
|
|
5483
5664
|
})).sort((a, b) => b.cost - a.cost || a.ticketId - b.ticketId).slice(0, v.limit);
|
|
5484
5665
|
const miscoding = /* @__PURE__ */ new Map();
|
|
@@ -5494,7 +5675,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5494
5675
|
const possibleMiscoding = [...miscoding.values()].sort((a, b) => a.entryId - b.entryId).slice(0, v.limit);
|
|
5495
5676
|
const openRenewal = [];
|
|
5496
5677
|
if (openStatusSet !== null) {
|
|
5497
|
-
for (const t of
|
|
5678
|
+
for (const t of contractTickets) {
|
|
5498
5679
|
const status = t["status"];
|
|
5499
5680
|
if (typeof status !== "number" || !openStatusSet.has(status)) continue;
|
|
5500
5681
|
const last = t["lastActivityDate"];
|
|
@@ -5515,7 +5696,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5515
5696
|
id: num2(s["id"]),
|
|
5516
5697
|
label: typeof s["subscriptionName"] === "string" && s["subscriptionName"] !== "" ? s["subscriptionName"] : `subscription ${num2(s["id"])}`,
|
|
5517
5698
|
date: typeof s["expirationDate"] === "string" ? s["expirationDate"].slice(0, 10) : null,
|
|
5518
|
-
detail: `periodType: ${typeof s["periodType"] === "
|
|
5699
|
+
detail: `periodType: ${typeof s["periodType"] === "number" ? s["periodType"] : "unknown"} (period cost ${fmtNum(num2(s["periodCost"]))}${cancelledSubs.has(num2(s["id"])) ? " \u2014 not active, not in tooling_cost.vendor" : oneTimeSubs.has(num2(s["id"])) ? " \u2014 one-time, booked in its effective month" : subFactor.get(num2(s["id"])) == null ? " \u2014 unrecognised period, not in tooling_cost.vendor" : `, ${fmtNum(num2(s["periodCost"]) * subFactor.get(num2(s["id"])))}/month`})`
|
|
5519
5700
|
});
|
|
5520
5701
|
}
|
|
5521
5702
|
const contractEndDay = dateToDay(contractRow["endDate"]);
|
|
@@ -5528,31 +5709,32 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5528
5709
|
detail: `the contract ends ${String(contractRow["endDate"]).slice(0, 10)}`
|
|
5529
5710
|
});
|
|
5530
5711
|
}
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
const
|
|
5536
|
-
if (included === 0 && worked === 0) continue;
|
|
5537
|
-
const left = included - worked;
|
|
5538
|
-
const my = Number(m.slice(0, 4));
|
|
5539
|
-
const mm = Number(m.slice(5, 7));
|
|
5540
|
-
const lastDay = new Date(Date.UTC(my, mm, 0)).getUTCDate();
|
|
5712
|
+
const blocks = blocksPart.items;
|
|
5713
|
+
for (const b of blocks) {
|
|
5714
|
+
const purchased = num2(b["hours"]);
|
|
5715
|
+
const approved = num2(b["hoursApproved"]);
|
|
5716
|
+
const left = purchased - approved;
|
|
5541
5717
|
openRenewal.push({
|
|
5542
5718
|
kind: "included_hours_burn",
|
|
5543
|
-
id:
|
|
5544
|
-
label: `
|
|
5545
|
-
date:
|
|
5546
|
-
detail: `${fmtHours(
|
|
5719
|
+
id: num2(b["id"]),
|
|
5720
|
+
label: `hour block ${num2(b["id"])}`,
|
|
5721
|
+
date: typeof b["endDate"] === "string" ? b["endDate"].slice(0, 10) : null,
|
|
5722
|
+
detail: `${fmtHours(approved)} h approved of ${fmtHours(purchased)} h purchased (${left >= 0 ? `${fmtHours(left)} h left` : `${fmtHours(Math.abs(left))} h over`})`
|
|
5547
5723
|
});
|
|
5548
5724
|
}
|
|
5725
|
+
const purchasedHours = blocks.reduce((a, b) => a + num2(b["hours"]), 0);
|
|
5726
|
+
const approvedHours = blocks.reduce((a, b) => a + num2(b["hoursApproved"]), 0);
|
|
5727
|
+
const includedHours = !contractTypeKnown ? { value: null, absent: "CONTRACT_TYPE_UNKNOWN" } : !isBlockHours ? { value: null, absent: "NOT_BLOCK_HOURS_CONTRACT" } : blocksPart.status === "absent" ? { value: null, absent: blocksPart.absent } : { value: { purchased: purchasedHours, approved: approvedHours, remaining: purchasedHours - approvedHours } };
|
|
5549
5728
|
return {
|
|
5550
5729
|
contract,
|
|
5551
5730
|
customer,
|
|
5731
|
+
...customerAbsent !== void 0 ? { customerAbsent } : {},
|
|
5732
|
+
contract_type: contractTypeKnown ? { id: contractType, label: contractTypeLabel } : { id: contractType > 0 ? contractType : null, label: null, absent: "CONTRACT_TYPE_UNKNOWN" },
|
|
5733
|
+
included_hours: includedHours,
|
|
5552
5734
|
period: { dateFrom: v.dateFrom, dateTo: v.dateTo, months, asOf },
|
|
5553
5735
|
currency: {
|
|
5554
5736
|
companyCurrencyID: customer && typeof customer["currencyID"] === "number" ? customer["currencyID"] : null,
|
|
5555
|
-
note: "
|
|
5737
|
+
note: "single-currency P&L in the INTERNAL currency: revenue is billing items internalCurrencyExtendedPrice and service units internalCurrencyPrice (each falling back to the local field when absent), unposted value the internalCurrencyContractHourlyRate; costs are internal (ourCost/role cost/internalCost, charge extendedCost, unit cost, internalCurrencyExpenseAmount). companyCurrencyID is the customer context stamp only"
|
|
5556
5738
|
},
|
|
5557
5739
|
monthly,
|
|
5558
5740
|
activity_categories: activityCategories,
|
|
@@ -5569,6 +5751,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5569
5751
|
contractCharges: chargesPart.status,
|
|
5570
5752
|
contractRoleCosts: roleCostsPart.status,
|
|
5571
5753
|
contractRates: ratesPart.status,
|
|
5754
|
+
contractBlocks: blocksPart.status,
|
|
5572
5755
|
billingItems: billingItems.status,
|
|
5573
5756
|
invoices: invoicesPart.status,
|
|
5574
5757
|
timeEntries: timeEntries.status,
|
|
@@ -5585,6 +5768,7 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5585
5768
|
contractCharges: chargesPart,
|
|
5586
5769
|
contractRoleCosts: roleCostsPart,
|
|
5587
5770
|
contractRates: ratesPart,
|
|
5771
|
+
contractBlocks: blocksPart,
|
|
5588
5772
|
billingItems,
|
|
5589
5773
|
invoices: invoicesPart,
|
|
5590
5774
|
timeEntries,
|
|
@@ -5595,12 +5779,12 @@ async function profitability(resource, contractId, opts, http) {
|
|
|
5595
5779
|
miscodingProbe: probePart,
|
|
5596
5780
|
configurationItems: configurationItemsPart,
|
|
5597
5781
|
subscriptions: subscriptionsPart,
|
|
5598
|
-
wires: { issued: wires.issued, budget: wires.budget, note: wires.note }
|
|
5782
|
+
wires: { issued: wires.issued, requests: wires.requests, budget: wires.budget, note: wires.note }
|
|
5599
5783
|
};
|
|
5600
5784
|
}
|
|
5601
5785
|
|
|
5602
5786
|
// src/resources/contracts.ts
|
|
5603
|
-
var ContractsResource = class extends
|
|
5787
|
+
var ContractsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
5604
5788
|
constructor(http, pageSize) {
|
|
5605
5789
|
super(http, {
|
|
5606
5790
|
key: "contracts",
|
|
@@ -5671,7 +5855,7 @@ var ContractsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
5671
5855
|
};
|
|
5672
5856
|
|
|
5673
5857
|
// src/resources/contract_ticket_purchases.ts
|
|
5674
|
-
var ContractTicketPurchasesResource = class extends
|
|
5858
|
+
var ContractTicketPurchasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
5675
5859
|
constructor(http, pageSize) {
|
|
5676
5860
|
super(http, {
|
|
5677
5861
|
key: "contract_ticket_purchases",
|
|
@@ -5730,7 +5914,7 @@ var ContractTicketPurchasesResource = class extends _chunk5N6DYKXOcjs.BaseResour
|
|
|
5730
5914
|
};
|
|
5731
5915
|
|
|
5732
5916
|
// src/resources/countries.ts
|
|
5733
|
-
var CountriesResource = class extends
|
|
5917
|
+
var CountriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
5734
5918
|
constructor(http, pageSize) {
|
|
5735
5919
|
super(http, {
|
|
5736
5920
|
key: "countries",
|
|
@@ -5789,7 +5973,7 @@ var CountriesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
5789
5973
|
};
|
|
5790
5974
|
|
|
5791
5975
|
// src/resources/departments.ts
|
|
5792
|
-
var DepartmentsResource = class extends
|
|
5976
|
+
var DepartmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
5793
5977
|
constructor(http, pageSize) {
|
|
5794
5978
|
super(http, {
|
|
5795
5979
|
key: "departments",
|
|
@@ -5856,7 +6040,7 @@ var DepartmentsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
5856
6040
|
};
|
|
5857
6041
|
|
|
5858
6042
|
// src/resources/domain_registrars.ts
|
|
5859
|
-
var DomainRegistrarsResource = class extends
|
|
6043
|
+
var DomainRegistrarsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
5860
6044
|
constructor(http, pageSize) {
|
|
5861
6045
|
super(http, {
|
|
5862
6046
|
key: "domain_registrars",
|
|
@@ -5939,7 +6123,7 @@ var EntityInformationResource = class {
|
|
|
5939
6123
|
};
|
|
5940
6124
|
|
|
5941
6125
|
// src/resources/expense_item_attachments.ts
|
|
5942
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6126
|
+
var ExpenseItemAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
5943
6127
|
constructor(http, pageSize) {
|
|
5944
6128
|
super(http, {
|
|
5945
6129
|
key: "expense_item_attachments",
|
|
@@ -6001,7 +6185,7 @@ var ExpenseItemAttachmentsResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
6001
6185
|
};
|
|
6002
6186
|
|
|
6003
6187
|
// src/resources/expense_items.ts
|
|
6004
|
-
var ExpenseItemsResource = class extends
|
|
6188
|
+
var ExpenseItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6005
6189
|
constructor(http, pageSize) {
|
|
6006
6190
|
super(http, {
|
|
6007
6191
|
key: "expense_items",
|
|
@@ -6060,7 +6244,7 @@ var ExpenseItemsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6060
6244
|
};
|
|
6061
6245
|
|
|
6062
6246
|
// src/resources/expense_reports.ts
|
|
6063
|
-
var ExpenseReportsResource = class extends
|
|
6247
|
+
var ExpenseReportsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6064
6248
|
constructor(http, pageSize) {
|
|
6065
6249
|
super(http, {
|
|
6066
6250
|
key: "expense_reports",
|
|
@@ -6127,7 +6311,7 @@ var ExpenseReportsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6127
6311
|
};
|
|
6128
6312
|
|
|
6129
6313
|
// src/resources/holiday_sets.ts
|
|
6130
|
-
var HolidaySetsResource = class extends
|
|
6314
|
+
var HolidaySetsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6131
6315
|
constructor(http, pageSize) {
|
|
6132
6316
|
super(http, {
|
|
6133
6317
|
key: "holiday_sets",
|
|
@@ -6196,7 +6380,7 @@ var HolidaySetsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6196
6380
|
};
|
|
6197
6381
|
|
|
6198
6382
|
// src/resources/holidays.ts
|
|
6199
|
-
var HolidaysResource = class extends
|
|
6383
|
+
var HolidaysResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6200
6384
|
constructor(http, pageSize) {
|
|
6201
6385
|
super(http, {
|
|
6202
6386
|
key: "holidays",
|
|
@@ -6268,10 +6452,10 @@ var PATH_SUFFIX = {
|
|
|
6268
6452
|
transfer: "StockedItemsTransfer"
|
|
6269
6453
|
};
|
|
6270
6454
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6271
|
-
const numericParent =
|
|
6455
|
+
const numericParent = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6272
6456
|
const suffix = PATH_SUFFIX[kind];
|
|
6273
6457
|
if (opts.dryRun === true) {
|
|
6274
|
-
return
|
|
6458
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
6275
6459
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6276
6460
|
method: "POST",
|
|
6277
6461
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6287,11 +6471,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6287
6471
|
body: data,
|
|
6288
6472
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`
|
|
6289
6473
|
});
|
|
6290
|
-
return
|
|
6474
|
+
return _chunkIHRXVIUUcjs.unwrapOperation.call(void 0, res);
|
|
6291
6475
|
}
|
|
6292
6476
|
|
|
6293
6477
|
// src/resources/inventory_products.ts
|
|
6294
|
-
var InventoryProductsResource = class extends
|
|
6478
|
+
var InventoryProductsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6295
6479
|
constructor(http, pageSize) {
|
|
6296
6480
|
super(http, {
|
|
6297
6481
|
key: "inventory_products",
|
|
@@ -6373,7 +6557,7 @@ var InventoryProductsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6373
6557
|
|
|
6374
6558
|
// src/resources/special/invoices.ts
|
|
6375
6559
|
async function markup(_resource, id, format, http) {
|
|
6376
|
-
const numericId =
|
|
6560
|
+
const numericId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
6377
6561
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
6378
6562
|
const res = await http.request({
|
|
6379
6563
|
method: "GET",
|
|
@@ -6382,7 +6566,7 @@ async function markup(_resource, id, format, http) {
|
|
|
6382
6566
|
});
|
|
6383
6567
|
const body = res;
|
|
6384
6568
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
6385
|
-
throw new (0,
|
|
6569
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskError)(
|
|
6386
6570
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
6387
6571
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId] }
|
|
6388
6572
|
);
|
|
@@ -6390,44 +6574,44 @@ async function markup(_resource, id, format, http) {
|
|
|
6390
6574
|
return body.invoiceMarkup;
|
|
6391
6575
|
}
|
|
6392
6576
|
async function pdf(_resource, id, http) {
|
|
6393
|
-
const numericId =
|
|
6577
|
+
const numericId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
6394
6578
|
const res = await http.request({
|
|
6395
6579
|
method: "GET",
|
|
6396
6580
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
6397
6581
|
operation: "invoices.pdf"
|
|
6398
6582
|
});
|
|
6399
|
-
return
|
|
6583
|
+
return _chunkIHRXVIUUcjs.decodeFileData.call(void 0, res);
|
|
6400
6584
|
}
|
|
6401
6585
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
6402
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
6403
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
6586
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _46 => _46.now]), () => ( /* @__PURE__ */ new Date()));
|
|
6587
|
+
const tz = _optionalChain([opts, 'optionalAccess', _47 => _47.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
|
|
6404
6588
|
return dateWindowQuery(
|
|
6405
6589
|
http,
|
|
6406
6590
|
"/V1.0/Invoices/query",
|
|
6407
6591
|
"invoiceDateTime",
|
|
6408
6592
|
kind,
|
|
6409
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
6593
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _48 => _48.limit])),
|
|
6410
6594
|
`invoices.${kind}`,
|
|
6411
6595
|
now,
|
|
6412
6596
|
tz
|
|
6413
6597
|
);
|
|
6414
6598
|
}
|
|
6415
6599
|
async function customRange2(_resource, from, to, http, opts) {
|
|
6416
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
6600
|
+
const zone = _optionalChain([opts, 'optionalAccess', _49 => _49.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
|
|
6417
6601
|
return customRangeQuery(
|
|
6418
6602
|
http,
|
|
6419
6603
|
"/V1.0/Invoices/query",
|
|
6420
6604
|
"invoiceDateTime",
|
|
6421
6605
|
from,
|
|
6422
6606
|
to,
|
|
6423
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
6607
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _50 => _50.limit])),
|
|
6424
6608
|
"invoices.customRange",
|
|
6425
6609
|
zone
|
|
6426
6610
|
);
|
|
6427
6611
|
}
|
|
6428
6612
|
|
|
6429
6613
|
// src/resources/invoices.ts
|
|
6430
|
-
var InvoicesResource = class extends
|
|
6614
|
+
var InvoicesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6431
6615
|
constructor(http, pageSize) {
|
|
6432
6616
|
super(http, {
|
|
6433
6617
|
key: "invoices",
|
|
@@ -6557,7 +6741,7 @@ var ModulesResource = class {
|
|
|
6557
6741
|
};
|
|
6558
6742
|
|
|
6559
6743
|
// src/resources/notification_history.ts
|
|
6560
|
-
var NotificationHistoryResource = class extends
|
|
6744
|
+
var NotificationHistoryResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6561
6745
|
constructor(http, pageSize) {
|
|
6562
6746
|
super(http, {
|
|
6563
6747
|
key: "notification_history",
|
|
@@ -6596,7 +6780,7 @@ var NotificationHistoryResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6596
6780
|
};
|
|
6597
6781
|
|
|
6598
6782
|
// src/resources/opportunities.ts
|
|
6599
|
-
var OpportunitiesResource = class extends
|
|
6783
|
+
var OpportunitiesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6600
6784
|
constructor(http, pageSize) {
|
|
6601
6785
|
super(http, {
|
|
6602
6786
|
key: "opportunities",
|
|
@@ -6658,7 +6842,7 @@ var OpportunitiesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6658
6842
|
};
|
|
6659
6843
|
|
|
6660
6844
|
// src/resources/opportunity_attachments.ts
|
|
6661
|
-
var OpportunityAttachmentsResource = class extends
|
|
6845
|
+
var OpportunityAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6662
6846
|
constructor(http, pageSize) {
|
|
6663
6847
|
super(http, {
|
|
6664
6848
|
key: "opportunity_attachments",
|
|
@@ -6720,7 +6904,7 @@ var OpportunityAttachmentsResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
6720
6904
|
};
|
|
6721
6905
|
|
|
6722
6906
|
// src/resources/opportunity_categories.ts
|
|
6723
|
-
var OpportunityCategoriesResource = class extends
|
|
6907
|
+
var OpportunityCategoriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6724
6908
|
constructor(http, pageSize) {
|
|
6725
6909
|
super(http, {
|
|
6726
6910
|
key: "opportunity_categories",
|
|
@@ -6779,7 +6963,7 @@ var OpportunityCategoriesResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
6779
6963
|
};
|
|
6780
6964
|
|
|
6781
6965
|
// src/resources/phases.ts
|
|
6782
|
-
var PhasesResource = class extends
|
|
6966
|
+
var PhasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6783
6967
|
constructor(http, pageSize) {
|
|
6784
6968
|
super(http, {
|
|
6785
6969
|
key: "phases",
|
|
@@ -6838,7 +7022,7 @@ var PhasesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6838
7022
|
};
|
|
6839
7023
|
|
|
6840
7024
|
// src/resources/products.ts
|
|
6841
|
-
var ProductsResource = class extends
|
|
7025
|
+
var ProductsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6842
7026
|
constructor(http, pageSize) {
|
|
6843
7027
|
super(http, {
|
|
6844
7028
|
key: "products",
|
|
@@ -6905,7 +7089,7 @@ var ProductsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6905
7089
|
};
|
|
6906
7090
|
|
|
6907
7091
|
// src/resources/product_vendors.ts
|
|
6908
|
-
var ProductVendorsResource = class extends
|
|
7092
|
+
var ProductVendorsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6909
7093
|
constructor(http, pageSize) {
|
|
6910
7094
|
super(http, {
|
|
6911
7095
|
key: "product_vendors",
|
|
@@ -6964,7 +7148,7 @@ var ProductVendorsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
6964
7148
|
};
|
|
6965
7149
|
|
|
6966
7150
|
// src/resources/project_charges.ts
|
|
6967
|
-
var ProjectChargesResource = class extends
|
|
7151
|
+
var ProjectChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
6968
7152
|
constructor(http, pageSize) {
|
|
6969
7153
|
super(http, {
|
|
6970
7154
|
key: "project_charges",
|
|
@@ -7035,7 +7219,7 @@ var ProjectChargesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7035
7219
|
};
|
|
7036
7220
|
|
|
7037
7221
|
// src/resources/project_notes.ts
|
|
7038
|
-
var ProjectNotesResource = class extends
|
|
7222
|
+
var ProjectNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7039
7223
|
constructor(http, pageSize) {
|
|
7040
7224
|
super(http, {
|
|
7041
7225
|
key: "project_notes",
|
|
@@ -7094,7 +7278,7 @@ var ProjectNotesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7094
7278
|
};
|
|
7095
7279
|
|
|
7096
7280
|
// src/resources/projects.ts
|
|
7097
|
-
var ProjectsResource = class extends
|
|
7281
|
+
var ProjectsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7098
7282
|
constructor(http, pageSize) {
|
|
7099
7283
|
super(http, {
|
|
7100
7284
|
key: "projects",
|
|
@@ -7171,13 +7355,13 @@ var ProjectsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7171
7355
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
7172
7356
|
const result = { project, company, opportunity, leadResource };
|
|
7173
7357
|
if (opts.names === true) {
|
|
7174
|
-
const builder =
|
|
7358
|
+
const builder = _chunkIHRXVIUUcjs.createNamePlan.call(void 0, );
|
|
7175
7359
|
builder.addResource(root["creatorResourceID"]);
|
|
7176
7360
|
builder.addFk("contract", root["contractID"]);
|
|
7177
|
-
const names = await
|
|
7361
|
+
const names = await _chunkIHRXVIUUcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
7178
7362
|
const row = { ...project };
|
|
7179
|
-
|
|
7180
|
-
|
|
7363
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
7364
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
7181
7365
|
result.project = row;
|
|
7182
7366
|
result.names = names.section;
|
|
7183
7367
|
}
|
|
@@ -7186,7 +7370,7 @@ var ProjectsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7186
7370
|
};
|
|
7187
7371
|
|
|
7188
7372
|
// src/resources/purchase_approvals.ts
|
|
7189
|
-
var PurchaseApprovalsResource = class extends
|
|
7373
|
+
var PurchaseApprovalsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7190
7374
|
constructor(http, pageSize) {
|
|
7191
7375
|
super(http, {
|
|
7192
7376
|
key: "purchase_approvals",
|
|
@@ -7240,7 +7424,7 @@ var PurchaseApprovalsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7240
7424
|
};
|
|
7241
7425
|
|
|
7242
7426
|
// src/resources/purchase_order_item_receiving.ts
|
|
7243
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
7427
|
+
var PurchaseOrderItemReceivingResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7244
7428
|
constructor(http, pageSize) {
|
|
7245
7429
|
super(http, {
|
|
7246
7430
|
key: "purchase_order_item_receiving",
|
|
@@ -7290,7 +7474,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunk5N6DYKXOcjs.BaseRes
|
|
|
7290
7474
|
};
|
|
7291
7475
|
|
|
7292
7476
|
// src/resources/purchase_order_items.ts
|
|
7293
|
-
var PurchaseOrderItemsResource = class extends
|
|
7477
|
+
var PurchaseOrderItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7294
7478
|
constructor(http, pageSize) {
|
|
7295
7479
|
super(http, {
|
|
7296
7480
|
key: "purchase_order_items",
|
|
@@ -7349,7 +7533,7 @@ var PurchaseOrderItemsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7349
7533
|
};
|
|
7350
7534
|
|
|
7351
7535
|
// src/resources/purchase_orders.ts
|
|
7352
|
-
var PurchaseOrdersResource = class extends
|
|
7536
|
+
var PurchaseOrdersResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7353
7537
|
constructor(http, pageSize) {
|
|
7354
7538
|
super(http, {
|
|
7355
7539
|
key: "purchase_orders",
|
|
@@ -7411,7 +7595,7 @@ var PurchaseOrdersResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7411
7595
|
};
|
|
7412
7596
|
|
|
7413
7597
|
// src/resources/quote_items.ts
|
|
7414
|
-
var QuoteItemsResource = class extends
|
|
7598
|
+
var QuoteItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7415
7599
|
constructor(http, pageSize) {
|
|
7416
7600
|
super(http, {
|
|
7417
7601
|
key: "quote_items",
|
|
@@ -7482,7 +7666,7 @@ var QuoteItemsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7482
7666
|
};
|
|
7483
7667
|
|
|
7484
7668
|
// src/resources/quote_locations.ts
|
|
7485
|
-
var QuoteLocationsResource = class extends
|
|
7669
|
+
var QuoteLocationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7486
7670
|
constructor(http, pageSize) {
|
|
7487
7671
|
super(http, {
|
|
7488
7672
|
key: "quote_locations",
|
|
@@ -7547,7 +7731,7 @@ var QuoteLocationsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7547
7731
|
};
|
|
7548
7732
|
|
|
7549
7733
|
// src/resources/quotes.ts
|
|
7550
|
-
var QuotesResource = class extends
|
|
7734
|
+
var QuotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7551
7735
|
constructor(http, pageSize) {
|
|
7552
7736
|
super(http, {
|
|
7553
7737
|
key: "quotes",
|
|
@@ -7614,7 +7798,7 @@ var QuotesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7614
7798
|
};
|
|
7615
7799
|
|
|
7616
7800
|
// src/resources/quote_templates.ts
|
|
7617
|
-
var QuoteTemplatesResource = class extends
|
|
7801
|
+
var QuoteTemplatesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7618
7802
|
constructor(http, pageSize) {
|
|
7619
7803
|
super(http, {
|
|
7620
7804
|
key: "quote_templates",
|
|
@@ -7658,7 +7842,7 @@ var QuoteTemplatesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7658
7842
|
};
|
|
7659
7843
|
|
|
7660
7844
|
// src/resources/resource_role_queues.ts
|
|
7661
|
-
var ResourceRoleQueuesResource = class extends
|
|
7845
|
+
var ResourceRoleQueuesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7662
7846
|
constructor(http, pageSize) {
|
|
7663
7847
|
super(http, {
|
|
7664
7848
|
key: "resource_role_queues",
|
|
@@ -7717,7 +7901,7 @@ var ResourceRoleQueuesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7717
7901
|
};
|
|
7718
7902
|
|
|
7719
7903
|
// src/resources/resource_roles.ts
|
|
7720
|
-
var ResourceRolesResource = class extends
|
|
7904
|
+
var ResourceRolesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7721
7905
|
constructor(http, pageSize) {
|
|
7722
7906
|
super(http, {
|
|
7723
7907
|
key: "resource_roles",
|
|
@@ -7759,7 +7943,7 @@ var ResourceRolesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7759
7943
|
};
|
|
7760
7944
|
|
|
7761
7945
|
// src/resources/resource_skills.ts
|
|
7762
|
-
var ResourceSkillsResource = class extends
|
|
7946
|
+
var ResourceSkillsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7763
7947
|
constructor(http, pageSize) {
|
|
7764
7948
|
super(http, {
|
|
7765
7949
|
key: "resource_skills",
|
|
@@ -7813,16 +7997,16 @@ var ResourceSkillsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7813
7997
|
var MAX_TRANSFER_IDS = 500;
|
|
7814
7998
|
function requirePositiveIds(ids, label) {
|
|
7815
7999
|
if (!Array.isArray(ids) || ids.length === 0) {
|
|
7816
|
-
throw new (0,
|
|
8000
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
7817
8001
|
}
|
|
7818
8002
|
if (ids.length > MAX_TRANSFER_IDS) {
|
|
7819
|
-
throw new (0,
|
|
8003
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
7820
8004
|
}
|
|
7821
8005
|
const out = [];
|
|
7822
8006
|
for (const raw of ids) {
|
|
7823
|
-
const id =
|
|
8007
|
+
const id = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
7824
8008
|
if (typeof id === "number" && id < 1) {
|
|
7825
|
-
throw new (0,
|
|
8009
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
7826
8010
|
}
|
|
7827
8011
|
out.push(id);
|
|
7828
8012
|
}
|
|
@@ -7830,7 +8014,7 @@ function requirePositiveIds(ids, label) {
|
|
|
7830
8014
|
}
|
|
7831
8015
|
async function whoAmI(_resource, userName, http) {
|
|
7832
8016
|
const user = userName.trim();
|
|
7833
|
-
if (user === "") throw new (0,
|
|
8017
|
+
if (user === "") throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
7834
8018
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
7835
8019
|
const res = await http.request({
|
|
7836
8020
|
method: "POST",
|
|
@@ -7839,11 +8023,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
7839
8023
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
7840
8024
|
operation: "resources.whoAmI"
|
|
7841
8025
|
});
|
|
7842
|
-
const matches =
|
|
8026
|
+
const matches = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
7843
8027
|
if (matches.length === 0) return null;
|
|
7844
8028
|
if (matches.length > 1) {
|
|
7845
8029
|
const ids = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
7846
|
-
throw new (0,
|
|
8030
|
+
throw new (0, _chunkIHRXVIUUcjs.ResolutionError)(
|
|
7847
8031
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
7848
8032
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids }
|
|
7849
8033
|
);
|
|
@@ -7852,11 +8036,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
7852
8036
|
}
|
|
7853
8037
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
7854
8038
|
const ids = requirePositiveIds(companyIds, "transferOwnership");
|
|
7855
|
-
const destination =
|
|
8039
|
+
const destination = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
7856
8040
|
if (typeof destination === "number" && destination < 1) {
|
|
7857
|
-
throw new (0,
|
|
8041
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
7858
8042
|
}
|
|
7859
|
-
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
8043
|
+
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _51 => _51.dryRun]), () => ( true));
|
|
7860
8044
|
const changes = [];
|
|
7861
8045
|
const applied = [];
|
|
7862
8046
|
for (const id of ids) {
|
|
@@ -7866,7 +8050,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
7866
8050
|
path: `/V1.0/Companies/${id}`,
|
|
7867
8051
|
operation: "resources.transferOwnership"
|
|
7868
8052
|
});
|
|
7869
|
-
const company =
|
|
8053
|
+
const company = _chunkIHRXVIUUcjs.unwrapItem.call(void 0, res, id);
|
|
7870
8054
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
7871
8055
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
7872
8056
|
if (!dryRun) {
|
|
@@ -7876,11 +8060,11 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
7876
8060
|
body: { id, ownerResourceID: destination },
|
|
7877
8061
|
operation: "resources.transferOwnership"
|
|
7878
8062
|
});
|
|
7879
|
-
|
|
8063
|
+
_chunkIHRXVIUUcjs.unwrapOperation.call(void 0, update);
|
|
7880
8064
|
applied.push(id);
|
|
7881
8065
|
}
|
|
7882
8066
|
} catch (err) {
|
|
7883
|
-
if (!dryRun && err instanceof
|
|
8067
|
+
if (!dryRun && err instanceof _chunkIHRXVIUUcjs.AutotaskError) {
|
|
7884
8068
|
err.resourceIds = [id];
|
|
7885
8069
|
err.suggestedAction = `Partial transfer: ${applied.length} of ${ids.length} companies were re-owned (ids: ${applied.join(", ") || "none"}); id ${id} failed. Re-run transferOwnership for the remaining ids (from ${id} on).`;
|
|
7886
8070
|
}
|
|
@@ -7890,7 +8074,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
7890
8074
|
if (dryRun) {
|
|
7891
8075
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
7892
8076
|
return {
|
|
7893
|
-
...
|
|
8077
|
+
..._chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
7894
8078
|
operation: "resources.transferOwnership",
|
|
7895
8079
|
method: "PUT",
|
|
7896
8080
|
path: "/V1.0/Companies",
|
|
@@ -7914,7 +8098,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
7914
8098
|
}
|
|
7915
8099
|
|
|
7916
8100
|
// src/resources/resources.ts
|
|
7917
|
-
var ResourcesResource = class extends
|
|
8101
|
+
var ResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
7918
8102
|
|
|
7919
8103
|
constructor(http, clientConfig, pageSize) {
|
|
7920
8104
|
super(http, {
|
|
@@ -7987,7 +8171,7 @@ var ResourcesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
7987
8171
|
|
|
7988
8172
|
// src/resources/special/resource_time_off_additional.ts
|
|
7989
8173
|
async function getByResource(_resource, resourceId, http) {
|
|
7990
|
-
const numericResource =
|
|
8174
|
+
const numericResource = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
7991
8175
|
const res = await http.request({
|
|
7992
8176
|
method: "GET",
|
|
7993
8177
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8001,11 +8185,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8001
8185
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8002
8186
|
}
|
|
8003
8187
|
}
|
|
8004
|
-
return
|
|
8188
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8005
8189
|
}
|
|
8006
8190
|
|
|
8007
8191
|
// src/resources/resource_time_off_additional.ts
|
|
8008
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8192
|
+
var ResourceTimeOffAdditionalResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8009
8193
|
constructor(http, pageSize) {
|
|
8010
8194
|
super(http, {
|
|
8011
8195
|
key: "resource_time_off_additional",
|
|
@@ -8044,7 +8228,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunk5N6DYKXOcjs.BaseReso
|
|
|
8044
8228
|
};
|
|
8045
8229
|
|
|
8046
8230
|
// src/resources/resource_time_off_approvers.ts
|
|
8047
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8231
|
+
var ResourceTimeOffApproversResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8048
8232
|
constructor(http, pageSize) {
|
|
8049
8233
|
super(http, {
|
|
8050
8234
|
key: "resource_time_off_approvers",
|
|
@@ -8087,29 +8271,29 @@ var ResourceTimeOffApproversResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
8087
8271
|
|
|
8088
8272
|
// src/resources/special/resource_time_off_balances.ts
|
|
8089
8273
|
async function getByResource2(_resource, resourceId, http) {
|
|
8090
|
-
const numericResource =
|
|
8274
|
+
const numericResource = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8091
8275
|
const res = await http.request({
|
|
8092
8276
|
method: "GET",
|
|
8093
8277
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8094
8278
|
operation: "resource_time_off_balances.getByResource"
|
|
8095
8279
|
});
|
|
8096
|
-
return
|
|
8280
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8097
8281
|
}
|
|
8098
8282
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8099
|
-
const numericResource =
|
|
8283
|
+
const numericResource = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8100
8284
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8101
|
-
throw new (0,
|
|
8285
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8102
8286
|
}
|
|
8103
8287
|
const res = await http.request({
|
|
8104
8288
|
method: "GET",
|
|
8105
8289
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8106
8290
|
operation: "resource_time_off_balances.getByYear"
|
|
8107
8291
|
});
|
|
8108
|
-
return
|
|
8292
|
+
return _chunkIHRXVIUUcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear");
|
|
8109
8293
|
}
|
|
8110
8294
|
|
|
8111
8295
|
// src/resources/resource_time_off_balances.ts
|
|
8112
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
8296
|
+
var ResourceTimeOffBalancesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8113
8297
|
constructor(http, pageSize) {
|
|
8114
8298
|
super(http, {
|
|
8115
8299
|
key: "resource_time_off_balances",
|
|
@@ -8147,7 +8331,7 @@ var ResourceTimeOffBalancesResource = class extends _chunk5N6DYKXOcjs.BaseResour
|
|
|
8147
8331
|
};
|
|
8148
8332
|
|
|
8149
8333
|
// src/resources/roles.ts
|
|
8150
|
-
var RolesResource = class extends
|
|
8334
|
+
var RolesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8151
8335
|
constructor(http, pageSize) {
|
|
8152
8336
|
super(http, {
|
|
8153
8337
|
key: "roles",
|
|
@@ -8214,7 +8398,7 @@ var RolesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8214
8398
|
};
|
|
8215
8399
|
|
|
8216
8400
|
// src/resources/service_calls.ts
|
|
8217
|
-
var ServiceCallsResource = class extends
|
|
8401
|
+
var ServiceCallsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8218
8402
|
constructor(http, pageSize) {
|
|
8219
8403
|
super(http, {
|
|
8220
8404
|
key: "service_calls",
|
|
@@ -8283,7 +8467,7 @@ var ServiceCallsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8283
8467
|
};
|
|
8284
8468
|
|
|
8285
8469
|
// src/resources/service_call_task_resources.ts
|
|
8286
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
8470
|
+
var ServiceCallTaskResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8287
8471
|
constructor(http, pageSize) {
|
|
8288
8472
|
super(http, {
|
|
8289
8473
|
key: "service_call_task_resources",
|
|
@@ -8340,7 +8524,7 @@ var ServiceCallTaskResourcesResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
8340
8524
|
};
|
|
8341
8525
|
|
|
8342
8526
|
// src/resources/service_call_tasks.ts
|
|
8343
|
-
var ServiceCallTasksResource = class extends
|
|
8527
|
+
var ServiceCallTasksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8344
8528
|
constructor(http, pageSize) {
|
|
8345
8529
|
super(http, {
|
|
8346
8530
|
key: "service_call_tasks",
|
|
@@ -8397,7 +8581,7 @@ var ServiceCallTasksResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8397
8581
|
};
|
|
8398
8582
|
|
|
8399
8583
|
// src/resources/service_call_ticket_resources.ts
|
|
8400
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
8584
|
+
var ServiceCallTicketResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8401
8585
|
constructor(http, pageSize) {
|
|
8402
8586
|
super(http, {
|
|
8403
8587
|
key: "service_call_ticket_resources",
|
|
@@ -8454,7 +8638,7 @@ var ServiceCallTicketResourcesResource = class extends _chunk5N6DYKXOcjs.BaseRes
|
|
|
8454
8638
|
};
|
|
8455
8639
|
|
|
8456
8640
|
// src/resources/service_call_tickets.ts
|
|
8457
|
-
var ServiceCallTicketsResource = class extends
|
|
8641
|
+
var ServiceCallTicketsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8458
8642
|
constructor(http, pageSize) {
|
|
8459
8643
|
super(http, {
|
|
8460
8644
|
key: "service_call_tickets",
|
|
@@ -8511,7 +8695,7 @@ var ServiceCallTicketsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8511
8695
|
};
|
|
8512
8696
|
|
|
8513
8697
|
// src/resources/service_level_agreement_results.ts
|
|
8514
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
8698
|
+
var ServiceLevelAgreementResultsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8515
8699
|
constructor(http, pageSize) {
|
|
8516
8700
|
super(http, {
|
|
8517
8701
|
key: "service_level_agreement_results",
|
|
@@ -8550,7 +8734,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunk5N6DYKXOcjs.BaseR
|
|
|
8550
8734
|
};
|
|
8551
8735
|
|
|
8552
8736
|
// src/resources/services.ts
|
|
8553
|
-
var ServicesResource = class extends
|
|
8737
|
+
var ServicesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8554
8738
|
constructor(http, pageSize) {
|
|
8555
8739
|
super(http, {
|
|
8556
8740
|
key: "services",
|
|
@@ -8618,7 +8802,7 @@ var ServicesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8618
8802
|
};
|
|
8619
8803
|
|
|
8620
8804
|
// src/resources/skills.ts
|
|
8621
|
-
var SkillsResource = class extends
|
|
8805
|
+
var SkillsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8622
8806
|
constructor(http, pageSize) {
|
|
8623
8807
|
super(http, {
|
|
8624
8808
|
key: "skills",
|
|
@@ -8662,7 +8846,7 @@ var SkillsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8662
8846
|
};
|
|
8663
8847
|
|
|
8664
8848
|
// src/resources/subscription_periods.ts
|
|
8665
|
-
var SubscriptionPeriodsResource = class extends
|
|
8849
|
+
var SubscriptionPeriodsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8666
8850
|
constructor(http, pageSize) {
|
|
8667
8851
|
super(http, {
|
|
8668
8852
|
key: "subscription_periods",
|
|
@@ -8701,7 +8885,7 @@ var SubscriptionPeriodsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8701
8885
|
};
|
|
8702
8886
|
|
|
8703
8887
|
// src/resources/subscriptions.ts
|
|
8704
|
-
var SubscriptionsResource = class extends
|
|
8888
|
+
var SubscriptionsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8705
8889
|
constructor(http, pageSize) {
|
|
8706
8890
|
super(http, {
|
|
8707
8891
|
key: "subscriptions",
|
|
@@ -8770,7 +8954,7 @@ var SubscriptionsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8770
8954
|
};
|
|
8771
8955
|
|
|
8772
8956
|
// src/resources/survey_results.ts
|
|
8773
|
-
var SurveyResultsResource = class extends
|
|
8957
|
+
var SurveyResultsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8774
8958
|
constructor(http, pageSize) {
|
|
8775
8959
|
super(http, {
|
|
8776
8960
|
key: "survey_results",
|
|
@@ -8809,7 +8993,7 @@ var SurveyResultsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8809
8993
|
};
|
|
8810
8994
|
|
|
8811
8995
|
// src/resources/surveys.ts
|
|
8812
|
-
var SurveysResource = class extends
|
|
8996
|
+
var SurveysResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8813
8997
|
constructor(http, pageSize) {
|
|
8814
8998
|
super(http, {
|
|
8815
8999
|
key: "surveys",
|
|
@@ -8853,7 +9037,7 @@ var SurveysResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8853
9037
|
};
|
|
8854
9038
|
|
|
8855
9039
|
// src/resources/tag_aliases.ts
|
|
8856
|
-
var TagAliasesResource = class extends
|
|
9040
|
+
var TagAliasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8857
9041
|
constructor(http, pageSize) {
|
|
8858
9042
|
super(http, {
|
|
8859
9043
|
key: "tag_aliases",
|
|
@@ -8910,7 +9094,7 @@ var TagAliasesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8910
9094
|
};
|
|
8911
9095
|
|
|
8912
9096
|
// src/resources/tag_groups.ts
|
|
8913
|
-
var TagGroupsResource = class extends
|
|
9097
|
+
var TagGroupsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8914
9098
|
constructor(http, pageSize) {
|
|
8915
9099
|
super(http, {
|
|
8916
9100
|
key: "tag_groups",
|
|
@@ -8979,7 +9163,7 @@ var TagGroupsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
8979
9163
|
};
|
|
8980
9164
|
|
|
8981
9165
|
// src/resources/tags.ts
|
|
8982
|
-
var TagsResource = class extends
|
|
9166
|
+
var TagsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
8983
9167
|
constructor(http, pageSize) {
|
|
8984
9168
|
super(http, {
|
|
8985
9169
|
key: "tags",
|
|
@@ -9048,7 +9232,7 @@ var TagsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9048
9232
|
};
|
|
9049
9233
|
|
|
9050
9234
|
// src/resources/task_secondary_resources.ts
|
|
9051
|
-
var TaskSecondaryResourcesResource = class extends
|
|
9235
|
+
var TaskSecondaryResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9052
9236
|
constructor(http, pageSize) {
|
|
9053
9237
|
super(http, {
|
|
9054
9238
|
key: "task_secondary_resources",
|
|
@@ -9105,7 +9289,7 @@ var TaskSecondaryResourcesResource = class extends _chunk5N6DYKXOcjs.BaseResourc
|
|
|
9105
9289
|
};
|
|
9106
9290
|
|
|
9107
9291
|
// src/resources/tasks.ts
|
|
9108
|
-
var TasksResource = class extends
|
|
9292
|
+
var TasksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9109
9293
|
constructor(http, pageSize) {
|
|
9110
9294
|
super(http, {
|
|
9111
9295
|
key: "tasks",
|
|
@@ -9193,7 +9377,7 @@ var ThresholdInformationResource = class {
|
|
|
9193
9377
|
};
|
|
9194
9378
|
|
|
9195
9379
|
// src/resources/ticket_additional_configuration_items.ts
|
|
9196
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
9380
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9197
9381
|
constructor(http, pageSize) {
|
|
9198
9382
|
super(http, {
|
|
9199
9383
|
key: "ticket_additional_configuration_items",
|
|
@@ -9250,7 +9434,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunk5N6DYKXOcjs
|
|
|
9250
9434
|
};
|
|
9251
9435
|
|
|
9252
9436
|
// src/resources/ticket_additional_contacts.ts
|
|
9253
|
-
var TicketAdditionalContactsResource = class extends
|
|
9437
|
+
var TicketAdditionalContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9254
9438
|
constructor(http, pageSize) {
|
|
9255
9439
|
super(http, {
|
|
9256
9440
|
key: "ticket_additional_contacts",
|
|
@@ -9307,7 +9491,7 @@ var TicketAdditionalContactsResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
9307
9491
|
};
|
|
9308
9492
|
|
|
9309
9493
|
// src/resources/ticket_attachments.ts
|
|
9310
|
-
var TicketAttachmentsResource = class extends
|
|
9494
|
+
var TicketAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9311
9495
|
constructor(http, pageSize) {
|
|
9312
9496
|
super(http, {
|
|
9313
9497
|
key: "ticket_attachments",
|
|
@@ -9369,7 +9553,7 @@ var TicketAttachmentsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9369
9553
|
};
|
|
9370
9554
|
|
|
9371
9555
|
// src/resources/ticket_categories.ts
|
|
9372
|
-
var TicketCategoriesResource = class extends
|
|
9556
|
+
var TicketCategoriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9373
9557
|
constructor(http, pageSize) {
|
|
9374
9558
|
super(http, {
|
|
9375
9559
|
key: "ticket_categories",
|
|
@@ -9428,7 +9612,7 @@ var TicketCategoriesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9428
9612
|
};
|
|
9429
9613
|
|
|
9430
9614
|
// src/resources/ticket_category_field_defaults.ts
|
|
9431
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
9615
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9432
9616
|
constructor(http, pageSize) {
|
|
9433
9617
|
super(http, {
|
|
9434
9618
|
key: "ticket_category_field_defaults",
|
|
@@ -9470,7 +9654,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunk5N6DYKXOcjs.BaseRe
|
|
|
9470
9654
|
};
|
|
9471
9655
|
|
|
9472
9656
|
// src/resources/ticket_change_request_approvals.ts
|
|
9473
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
9657
|
+
var TicketChangeRequestApprovalsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9474
9658
|
constructor(http, pageSize) {
|
|
9475
9659
|
super(http, {
|
|
9476
9660
|
key: "ticket_change_request_approvals",
|
|
@@ -9527,7 +9711,7 @@ var TicketChangeRequestApprovalsResource = class extends _chunk5N6DYKXOcjs.BaseR
|
|
|
9527
9711
|
};
|
|
9528
9712
|
|
|
9529
9713
|
// src/resources/ticket_charges.ts
|
|
9530
|
-
var TicketChargesResource = class extends
|
|
9714
|
+
var TicketChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9531
9715
|
constructor(http, pageSize) {
|
|
9532
9716
|
super(http, {
|
|
9533
9717
|
key: "ticket_charges",
|
|
@@ -9598,7 +9782,7 @@ var TicketChargesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9598
9782
|
};
|
|
9599
9783
|
|
|
9600
9784
|
// src/resources/ticket_checklist_items.ts
|
|
9601
|
-
var TicketChecklistItemsResource = class extends
|
|
9785
|
+
var TicketChecklistItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9602
9786
|
constructor(http, pageSize) {
|
|
9603
9787
|
super(http, {
|
|
9604
9788
|
key: "ticket_checklist_items",
|
|
@@ -9664,7 +9848,7 @@ var TicketChecklistItemsResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
9664
9848
|
};
|
|
9665
9849
|
|
|
9666
9850
|
// src/resources/ticket_checklist_libraries.ts
|
|
9667
|
-
var TicketChecklistLibrariesResource = class extends
|
|
9851
|
+
var TicketChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9668
9852
|
constructor(http, pageSize) {
|
|
9669
9853
|
super(http, {
|
|
9670
9854
|
key: "ticket_checklist_libraries",
|
|
@@ -9688,9 +9872,9 @@ var TicketChecklistLibrariesResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
9688
9872
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
9689
9873
|
* surface — no documents read op — and never issues the POST). */
|
|
9690
9874
|
async attachToDocument(documentID, data, opts = {}) {
|
|
9691
|
-
const n =
|
|
9875
|
+
const n = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
9692
9876
|
if (opts.dryRun === true) {
|
|
9693
|
-
return
|
|
9877
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
9694
9878
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
9695
9879
|
method: "POST",
|
|
9696
9880
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -9707,7 +9891,7 @@ var TicketChecklistLibrariesResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
9707
9891
|
body: { ...data },
|
|
9708
9892
|
operation: "ticket_checklist_libraries.attachToDocument"
|
|
9709
9893
|
});
|
|
9710
|
-
return
|
|
9894
|
+
return _chunkIHRXVIUUcjs.unwrapOperation.call(void 0, res);
|
|
9711
9895
|
}
|
|
9712
9896
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
9713
9897
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9723,7 +9907,7 @@ var TicketChecklistLibrariesResource = class extends _chunk5N6DYKXOcjs.BaseResou
|
|
|
9723
9907
|
};
|
|
9724
9908
|
|
|
9725
9909
|
// src/resources/ticket_history.ts
|
|
9726
|
-
var TicketHistoryResource = class extends
|
|
9910
|
+
var TicketHistoryResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9727
9911
|
constructor(http, pageSize) {
|
|
9728
9912
|
super(http, {
|
|
9729
9913
|
key: "ticket_history",
|
|
@@ -9762,7 +9946,7 @@ var TicketHistoryResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9762
9946
|
};
|
|
9763
9947
|
|
|
9764
9948
|
// src/resources/ticket_note_attachments.ts
|
|
9765
|
-
var TicketNoteAttachmentsResource = class extends
|
|
9949
|
+
var TicketNoteAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9766
9950
|
constructor(http, pageSize) {
|
|
9767
9951
|
super(http, {
|
|
9768
9952
|
key: "ticket_note_attachments",
|
|
@@ -9824,7 +10008,7 @@ var TicketNoteAttachmentsResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
9824
10008
|
};
|
|
9825
10009
|
|
|
9826
10010
|
// src/resources/ticket_notes.ts
|
|
9827
|
-
var TicketNotesResource = class extends
|
|
10011
|
+
var TicketNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9828
10012
|
constructor(http, pageSize) {
|
|
9829
10013
|
super(http, {
|
|
9830
10014
|
key: "ticket_notes",
|
|
@@ -9883,7 +10067,7 @@ var TicketNotesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9883
10067
|
};
|
|
9884
10068
|
|
|
9885
10069
|
// src/resources/ticket_note_webhooks.ts
|
|
9886
|
-
var TicketNoteWebhooksResource = class extends
|
|
10070
|
+
var TicketNoteWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9887
10071
|
constructor(http, pageSize) {
|
|
9888
10072
|
super(http, {
|
|
9889
10073
|
key: "ticket_note_webhooks",
|
|
@@ -9959,7 +10143,7 @@ var TicketNoteWebhooksResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
9959
10143
|
};
|
|
9960
10144
|
|
|
9961
10145
|
// src/resources/ticket_secondary_resources.ts
|
|
9962
|
-
var TicketSecondaryResourcesResource = class extends
|
|
10146
|
+
var TicketSecondaryResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
9963
10147
|
constructor(http, pageSize) {
|
|
9964
10148
|
super(http, {
|
|
9965
10149
|
key: "ticket_secondary_resources",
|
|
@@ -10026,9 +10210,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
10026
10210
|
});
|
|
10027
10211
|
const body = res;
|
|
10028
10212
|
if (body === null || !("item" in body)) {
|
|
10029
|
-
throw new (0,
|
|
10213
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id] });
|
|
10030
10214
|
}
|
|
10031
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
10215
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id] });
|
|
10032
10216
|
return body.item;
|
|
10033
10217
|
}
|
|
10034
10218
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -10039,29 +10223,29 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
10039
10223
|
body: { MaxRecords: maxRecords, filter },
|
|
10040
10224
|
operation
|
|
10041
10225
|
});
|
|
10042
|
-
return
|
|
10226
|
+
return _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res).items;
|
|
10043
10227
|
}
|
|
10044
10228
|
function isRouteUnavailable(err) {
|
|
10045
|
-
return
|
|
10229
|
+
return _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
10046
10230
|
}
|
|
10047
10231
|
function routeFact(route, path, err) {
|
|
10048
10232
|
return {
|
|
10049
10233
|
route,
|
|
10050
10234
|
path,
|
|
10051
|
-
httpStatus:
|
|
10235
|
+
httpStatus: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
10052
10236
|
};
|
|
10053
10237
|
}
|
|
10054
10238
|
function childDeclaresQuery(resourceKey) {
|
|
10055
|
-
return
|
|
10239
|
+
return _chunkCSRCMBZ2cjs.CAPABILITIES.some(
|
|
10056
10240
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
10057
10241
|
);
|
|
10058
10242
|
}
|
|
10059
10243
|
function planScopedPath(resourceKey, ticketId) {
|
|
10060
10244
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
10061
|
-
const entry =
|
|
10245
|
+
const entry = _chunkIHRXVIUUcjs.RELATIONSHIP_MAP[resourceKey];
|
|
10062
10246
|
const parent = entry === void 0 ? null : entry.parent;
|
|
10063
10247
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
10064
|
-
const parentPath = _optionalChain([
|
|
10248
|
+
const parentPath = _optionalChain([_chunkIHRXVIUUcjs.RELATIONSHIP_MAP, 'access', _52 => _52[parent.resource], 'optionalAccess', _53 => _53.path]);
|
|
10065
10249
|
if (parentPath === null || parentPath === void 0) return null;
|
|
10066
10250
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
10067
10251
|
}
|
|
@@ -10100,14 +10284,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
10100
10284
|
break;
|
|
10101
10285
|
}
|
|
10102
10286
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
10103
|
-
const { items: pageItems, pageDetails } =
|
|
10287
|
+
const { items: pageItems, pageDetails } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, body, operation);
|
|
10104
10288
|
nextCursor = pageDetails.nextPageUrl;
|
|
10105
10289
|
pages += 1;
|
|
10106
10290
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
10107
10291
|
for (const row of window) if (accept(row)) items.push(row);
|
|
10108
10292
|
if (items.length >= limit) break;
|
|
10109
10293
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
10110
|
-
target =
|
|
10294
|
+
target = _chunkIHRXVIUUcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
10111
10295
|
}
|
|
10112
10296
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
10113
10297
|
return { items, capped };
|
|
@@ -10141,7 +10325,7 @@ function truncate(text, limit) {
|
|
|
10141
10325
|
}
|
|
10142
10326
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
10143
10327
|
void opts;
|
|
10144
|
-
const ticketId =
|
|
10328
|
+
const ticketId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
10145
10329
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
10146
10330
|
const rows = await ticketQueryItems(
|
|
10147
10331
|
http,
|
|
@@ -10166,9 +10350,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
10166
10350
|
async function summary(_resource, id, opts = {}, http) {
|
|
10167
10351
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
10168
10352
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
10169
|
-
throw new (0,
|
|
10353
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
10170
10354
|
}
|
|
10171
|
-
const ticketId =
|
|
10355
|
+
const ticketId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
10172
10356
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
10173
10357
|
const desc = truncate(ticket.description, limit);
|
|
10174
10358
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -10195,13 +10379,13 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
10195
10379
|
}
|
|
10196
10380
|
async function timeline(_resource, id, opts = {}, http) {
|
|
10197
10381
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
10198
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
10382
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
10199
10383
|
const bounded = Math.min(limit, 500);
|
|
10200
10384
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
10201
10385
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
10202
|
-
throw new (0,
|
|
10386
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
10203
10387
|
}
|
|
10204
|
-
const ticketId =
|
|
10388
|
+
const ticketId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
10205
10389
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
10206
10390
|
const dateFilters = (field) => {
|
|
10207
10391
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -10288,14 +10472,14 @@ function isPositiveInt(v) {
|
|
|
10288
10472
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
10289
10473
|
}
|
|
10290
10474
|
function namedVendorFields(err) {
|
|
10291
|
-
if (!
|
|
10292
|
-
const entries = _nullishCoalesce(
|
|
10475
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
10476
|
+
const entries = _nullishCoalesce(_chunkIHRXVIUUcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
10293
10477
|
const out = /* @__PURE__ */ new Set();
|
|
10294
10478
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
10295
10479
|
return [...out];
|
|
10296
10480
|
}
|
|
10297
10481
|
function vendorDetailOf(err) {
|
|
10298
|
-
return
|
|
10482
|
+
return _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? _chunkIHRXVIUUcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
10299
10483
|
}
|
|
10300
10484
|
async function fetchItem(http, path, operation) {
|
|
10301
10485
|
const res = await http.request({ method: "GET", path, operation });
|
|
@@ -10316,8 +10500,8 @@ function operationId(res) {
|
|
|
10316
10500
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
10317
10501
|
}
|
|
10318
10502
|
function discoveryMerge(err, body, defaults) {
|
|
10319
|
-
if (!
|
|
10320
|
-
const entries =
|
|
10503
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
10504
|
+
const entries = _chunkIHRXVIUUcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
10321
10505
|
if (entries === void 0) return null;
|
|
10322
10506
|
for (const entry of entries) {
|
|
10323
10507
|
const field = entry.field;
|
|
@@ -10329,7 +10513,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
10329
10513
|
}
|
|
10330
10514
|
function stepErrorText(code, err) {
|
|
10331
10515
|
const detail = vendorDetailOf(err);
|
|
10332
|
-
const base =
|
|
10516
|
+
const base = _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
10333
10517
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
10334
10518
|
}
|
|
10335
10519
|
var DEFAULT_TICKET_PRIORITY = 3;
|
|
@@ -10338,7 +10522,7 @@ var DEFAULT_NOTE_TYPE = 1;
|
|
|
10338
10522
|
var DEFAULT_PUBLISH = 1;
|
|
10339
10523
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
10340
10524
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
10341
|
-
var QueueRequiredError = class extends
|
|
10525
|
+
var QueueRequiredError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
10342
10526
|
constructor(message, options = {}) {
|
|
10343
10527
|
super(message, {
|
|
10344
10528
|
code: "QUEUE_REQUIRED",
|
|
@@ -10349,13 +10533,13 @@ var QueueRequiredError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
10349
10533
|
this.name = "QueueRequiredError";
|
|
10350
10534
|
}
|
|
10351
10535
|
};
|
|
10352
|
-
var TicketResourceInvalidError = class extends
|
|
10536
|
+
var TicketResourceInvalidError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
10353
10537
|
constructor(message, options = {}) {
|
|
10354
10538
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
10355
10539
|
this.name = "TicketResourceInvalidError";
|
|
10356
10540
|
}
|
|
10357
10541
|
};
|
|
10358
|
-
var TicketCreateValidationFailedError = class extends
|
|
10542
|
+
var TicketCreateValidationFailedError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
10359
10543
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
10360
10544
|
|
|
10361
10545
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -10365,43 +10549,43 @@ var TicketCreateValidationFailedError = class extends _chunk5N6DYKXOcjs.Autotask
|
|
|
10365
10549
|
}
|
|
10366
10550
|
};
|
|
10367
10551
|
async function openWithNoteAndAssign(resource, params, note, assign, opts, http) {
|
|
10368
|
-
const companyID =
|
|
10369
|
-
const title = _optionalChain([params, 'optionalAccess',
|
|
10552
|
+
const companyID = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _54 => _54.companyID]), "params.companyID");
|
|
10553
|
+
const title = _optionalChain([params, 'optionalAccess', _55 => _55.title]);
|
|
10370
10554
|
if (typeof title !== "string" || title.trim() === "") {
|
|
10371
|
-
throw new (0,
|
|
10555
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
10372
10556
|
}
|
|
10373
10557
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
10374
10558
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
10375
10559
|
if (!isPositiveInt(priority)) {
|
|
10376
|
-
throw new (0,
|
|
10560
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
10377
10561
|
}
|
|
10378
10562
|
if (!isPositiveInt(status)) {
|
|
10379
|
-
throw new (0,
|
|
10563
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
10380
10564
|
}
|
|
10381
10565
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
10382
|
-
throw new (0,
|
|
10566
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
10383
10567
|
}
|
|
10384
10568
|
if (note !== void 0) {
|
|
10385
10569
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
10386
|
-
throw new (0,
|
|
10570
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
10387
10571
|
}
|
|
10388
10572
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
10389
|
-
throw new (0,
|
|
10573
|
+
throw new (0, _chunkIHRXVIUUcjs.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 });
|
|
10390
10574
|
}
|
|
10391
10575
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
10392
|
-
throw new (0,
|
|
10576
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
10393
10577
|
}
|
|
10394
10578
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
10395
|
-
throw new (0,
|
|
10579
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
10396
10580
|
}
|
|
10397
10581
|
}
|
|
10398
|
-
const assignee = assign === void 0 ? void 0 :
|
|
10582
|
+
const assignee = assign === void 0 ? void 0 : _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
10399
10583
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
10400
|
-
throw new (0,
|
|
10584
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
10401
10585
|
}
|
|
10402
|
-
const roleID = _optionalChain([assign, 'optionalAccess',
|
|
10586
|
+
const roleID = _optionalChain([assign, 'optionalAccess', _56 => _56.roleID]);
|
|
10403
10587
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
10404
|
-
throw new (0,
|
|
10588
|
+
throw new (0, _chunkIHRXVIUUcjs.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 });
|
|
10405
10589
|
}
|
|
10406
10590
|
if (assign !== void 0 && assignee !== void 0) {
|
|
10407
10591
|
const rid = assignee;
|
|
@@ -10436,7 +10620,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10436
10620
|
if (assign !== void 0) {
|
|
10437
10621
|
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).`);
|
|
10438
10622
|
}
|
|
10439
|
-
return
|
|
10623
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
10440
10624
|
{
|
|
10441
10625
|
operation: OP_OPEN,
|
|
10442
10626
|
method: "POST",
|
|
@@ -10478,8 +10662,8 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10478
10662
|
`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}` : ""}`,
|
|
10479
10663
|
{
|
|
10480
10664
|
operation: OP_OPEN,
|
|
10481
|
-
httpStatus:
|
|
10482
|
-
vendorError:
|
|
10665
|
+
httpStatus: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
10666
|
+
vendorError: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
10483
10667
|
}
|
|
10484
10668
|
);
|
|
10485
10669
|
}
|
|
@@ -10494,8 +10678,8 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10494
10678
|
named,
|
|
10495
10679
|
{
|
|
10496
10680
|
operation: OP_OPEN,
|
|
10497
|
-
httpStatus:
|
|
10498
|
-
vendorError:
|
|
10681
|
+
httpStatus: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
10682
|
+
vendorError: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
10499
10683
|
resourceIds: [companyID]
|
|
10500
10684
|
}
|
|
10501
10685
|
);
|
|
@@ -10517,10 +10701,10 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10517
10701
|
try {
|
|
10518
10702
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN);
|
|
10519
10703
|
if (current === null) {
|
|
10520
|
-
throw new (0,
|
|
10704
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId] });
|
|
10521
10705
|
}
|
|
10522
10706
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
10523
|
-
const merged =
|
|
10707
|
+
const merged = _chunkIHRXVIUUcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
10524
10708
|
merged.id = ticketId;
|
|
10525
10709
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN });
|
|
10526
10710
|
assigned = true;
|
|
@@ -10541,7 +10725,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10541
10725
|
var STATUS_REQUIRED_FIELDS = {
|
|
10542
10726
|
// <discovery output lands here — e.g. 8: { requiredFields: ['dueDateTime'], safeDefaults: { dueDateTime: '<now>' } }>
|
|
10543
10727
|
};
|
|
10544
|
-
var StatusUnknownError = class extends
|
|
10728
|
+
var StatusUnknownError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
10545
10729
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
10546
10730
|
|
|
10547
10731
|
constructor(message, options = {}) {
|
|
@@ -10555,7 +10739,7 @@ var StatusUnknownError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
10555
10739
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
10556
10740
|
}
|
|
10557
10741
|
};
|
|
10558
|
-
var StatusFieldsRequiredError = class extends
|
|
10742
|
+
var StatusFieldsRequiredError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
10559
10743
|
|
|
10560
10744
|
|
|
10561
10745
|
|
|
@@ -10584,26 +10768,26 @@ async function readLiveStatusSet(resource) {
|
|
|
10584
10768
|
}
|
|
10585
10769
|
var GUARD_DEGRADED_WARNING = "the tenant's live status picklist metadata was unavailable (the local guard is degraded for this call \u2014 the W-A4 wall or a metadata failure); the vendor's own validation is the final authority on the status value";
|
|
10586
10770
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
10587
|
-
const ticketId =
|
|
10771
|
+
const ticketId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
10588
10772
|
if (!isPositiveInt(targetStatus)) {
|
|
10589
|
-
throw new (0,
|
|
10773
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
10590
10774
|
}
|
|
10591
10775
|
let liveStatus = null;
|
|
10592
10776
|
try {
|
|
10593
10777
|
const ids = await readLiveStatusSet(resource);
|
|
10594
10778
|
if (ids.size > 0) liveStatus = ids;
|
|
10595
10779
|
} catch (err) {
|
|
10596
|
-
if (!
|
|
10780
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
10597
10781
|
}
|
|
10598
10782
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
10599
|
-
_optionalChain([http, 'access',
|
|
10783
|
+
_optionalChain([http, 'access', _57 => _57.fieldCache, 'optionalAccess', _58 => _58.invalidate, 'call', _59 => _59("tickets")]);
|
|
10600
10784
|
let freshStatus = null;
|
|
10601
10785
|
let reReadFailed = false;
|
|
10602
10786
|
try {
|
|
10603
10787
|
const freshIds = await readLiveStatusSet(resource);
|
|
10604
10788
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
10605
10789
|
} catch (err) {
|
|
10606
|
-
if (!
|
|
10790
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
10607
10791
|
freshStatus = null;
|
|
10608
10792
|
reReadFailed = true;
|
|
10609
10793
|
}
|
|
@@ -10620,16 +10804,16 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10620
10804
|
}
|
|
10621
10805
|
const guardDegraded = liveStatus === null;
|
|
10622
10806
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
10623
|
-
throw new (0,
|
|
10807
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
10624
10808
|
}
|
|
10625
10809
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS);
|
|
10626
10810
|
if (current === null) {
|
|
10627
|
-
throw new (0,
|
|
10811
|
+
throw new (0, _chunkIHRXVIUUcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId] });
|
|
10628
10812
|
}
|
|
10629
10813
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
10630
10814
|
if (previousStatus === targetStatus) {
|
|
10631
10815
|
if (opts.dryRun === true) {
|
|
10632
|
-
return
|
|
10816
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
10633
10817
|
{
|
|
10634
10818
|
operation: OP_STATUS,
|
|
10635
10819
|
method: "PUT",
|
|
@@ -10662,7 +10846,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10662
10846
|
for (const field of mapEntry.requiredFields) {
|
|
10663
10847
|
if (mergeData[field] !== void 0) continue;
|
|
10664
10848
|
if (current[field] !== null && current[field] !== void 0) continue;
|
|
10665
|
-
const safe = _optionalChain([mapEntry, 'access',
|
|
10849
|
+
const safe = _optionalChain([mapEntry, 'access', _60 => _60.safeDefaults, 'optionalAccess', _61 => _61[field]]);
|
|
10666
10850
|
if (safe === void 0) {
|
|
10667
10851
|
throw new StatusFieldsRequiredError(
|
|
10668
10852
|
`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`,
|
|
@@ -10683,7 +10867,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10683
10867
|
if (mapEntry === void 0) {
|
|
10684
10868
|
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).`);
|
|
10685
10869
|
}
|
|
10686
|
-
return
|
|
10870
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
10687
10871
|
{
|
|
10688
10872
|
operation: OP_STATUS,
|
|
10689
10873
|
method: "PUT",
|
|
@@ -10701,8 +10885,8 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10701
10885
|
{ redactPersonalData: http.redactPersonalData }
|
|
10702
10886
|
);
|
|
10703
10887
|
}
|
|
10704
|
-
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess',
|
|
10705
|
-
const body =
|
|
10888
|
+
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _62 => _62.safeDefaults]), () => ( {}));
|
|
10889
|
+
const body = _chunkIHRXVIUUcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
10706
10890
|
body.id = ticketId;
|
|
10707
10891
|
let merges = 0;
|
|
10708
10892
|
for (; ; ) {
|
|
@@ -10726,8 +10910,8 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10726
10910
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
10727
10911
|
{
|
|
10728
10912
|
operation: OP_STATUS,
|
|
10729
|
-
httpStatus:
|
|
10730
|
-
vendorError:
|
|
10913
|
+
httpStatus: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
10914
|
+
vendorError: _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
10731
10915
|
resourceIds: [ticketId]
|
|
10732
10916
|
}
|
|
10733
10917
|
);
|
|
@@ -10737,7 +10921,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10737
10921
|
}
|
|
10738
10922
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS);
|
|
10739
10923
|
if (verify === null) {
|
|
10740
|
-
throw new (0,
|
|
10924
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
10741
10925
|
code: "INVALID_RESPONSE",
|
|
10742
10926
|
category: "server",
|
|
10743
10927
|
operation: OP_STATUS,
|
|
@@ -10746,7 +10930,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10746
10930
|
}
|
|
10747
10931
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
10748
10932
|
if (finalStatus !== targetStatus) {
|
|
10749
|
-
throw new (0,
|
|
10933
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskError)(
|
|
10750
10934
|
`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)`,
|
|
10751
10935
|
{
|
|
10752
10936
|
code: "INVALID_RESPONSE",
|
|
@@ -10764,7 +10948,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
10764
10948
|
function partLimit(value, name) {
|
|
10765
10949
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
10766
10950
|
if (!Number.isInteger(n) || n < 1) {
|
|
10767
|
-
throw new (0,
|
|
10951
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
10768
10952
|
}
|
|
10769
10953
|
return n;
|
|
10770
10954
|
}
|
|
@@ -10780,7 +10964,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
10780
10964
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
10781
10965
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
10782
10966
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
10783
|
-
const ticketId =
|
|
10967
|
+
const ticketId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
10784
10968
|
const ctx = await resource.getContext(ticketId);
|
|
10785
10969
|
const op = "tickets.fullContext";
|
|
10786
10970
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -10834,7 +11018,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
10834
11018
|
result.truncated = result.truncated || part.capped || historyRows.some((h) => h.detailTruncated === true);
|
|
10835
11019
|
}
|
|
10836
11020
|
if (opts.names === true) {
|
|
10837
|
-
const builder =
|
|
11021
|
+
const builder = _chunkIHRXVIUUcjs.createNamePlan.call(void 0, _chunkIHRXVIUUcjs.TICKET_LABEL_FIELDS);
|
|
10838
11022
|
const t = ctx.ticket;
|
|
10839
11023
|
builder.addResource(t["creatorResourceID"]);
|
|
10840
11024
|
builder.addFk("contract", t["contractID"]);
|
|
@@ -10846,20 +11030,20 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
10846
11030
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
10847
11031
|
builder.addFk("contract", e["contractID"]);
|
|
10848
11032
|
}
|
|
10849
|
-
const names = await
|
|
11033
|
+
const names = await _chunkIHRXVIUUcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
10850
11034
|
const ticketRow = { ...ctx.ticket };
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
for (const f of
|
|
11035
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
11036
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
11037
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11038
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
11039
|
+
for (const f of _chunkIHRXVIUUcjs.TICKET_LABEL_FIELDS) _chunkIHRXVIUUcjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
10856
11040
|
result.ticket = ticketRow;
|
|
10857
11041
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
10858
11042
|
const row = { ...e };
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
11043
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
11044
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
11045
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11046
|
+
_chunkIHRXVIUUcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
10863
11047
|
return row;
|
|
10864
11048
|
});
|
|
10865
11049
|
result.names = names.section;
|
|
@@ -10869,7 +11053,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
10869
11053
|
}
|
|
10870
11054
|
|
|
10871
11055
|
// src/resources/tickets.ts
|
|
10872
|
-
var TicketsResource = class extends
|
|
11056
|
+
var TicketsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
10873
11057
|
constructor(http, pageSize) {
|
|
10874
11058
|
super(http, {
|
|
10875
11059
|
key: "tickets",
|
|
@@ -10975,7 +11159,7 @@ var TicketsResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
10975
11159
|
};
|
|
10976
11160
|
|
|
10977
11161
|
// src/resources/ticket_webhooks.ts
|
|
10978
|
-
var TicketWebhooksResource = class extends
|
|
11162
|
+
var TicketWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
10979
11163
|
constructor(http, pageSize) {
|
|
10980
11164
|
super(http, {
|
|
10981
11165
|
key: "ticket_webhooks",
|
|
@@ -11061,62 +11245,62 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
11061
11245
|
body: { MaxRecords: limit, filter },
|
|
11062
11246
|
operation
|
|
11063
11247
|
});
|
|
11064
|
-
const { items, pageDetails } =
|
|
11248
|
+
const { items, pageDetails } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res);
|
|
11065
11249
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
11066
11250
|
}
|
|
11067
11251
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
11068
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
11069
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
11252
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _63 => _63.now]), () => ( /* @__PURE__ */ new Date()));
|
|
11253
|
+
const tz = _optionalChain([opts, 'optionalAccess', _64 => _64.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
|
|
11070
11254
|
const { from, to } = dateWindowBounds(kind, now, tz);
|
|
11071
11255
|
const filter = [
|
|
11072
11256
|
{ field: "dateWorked", op: "gte", value: from },
|
|
11073
11257
|
{ field: "dateWorked", op: "lte", value: to }
|
|
11074
11258
|
];
|
|
11075
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11259
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _65 => _65.limit])), `time_entries.${kind}`, http);
|
|
11076
11260
|
return items;
|
|
11077
11261
|
}
|
|
11078
11262
|
async function customRange3(_resource, from, to, http, opts) {
|
|
11079
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
11263
|
+
const zone = _optionalChain([opts, 'optionalAccess', _66 => _66.tz]) === void 0 ? void 0 : validateZone(opts.tz, "time_entries.customRange");
|
|
11080
11264
|
const fromB = customRangeDay(from, "from", zone, "customRange");
|
|
11081
11265
|
const toB = customRangeDay(to, "to", zone, "customRange");
|
|
11082
11266
|
if (fromB.ms > toB.ms) {
|
|
11083
|
-
throw new (0,
|
|
11267
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
11084
11268
|
}
|
|
11085
11269
|
const toEndMs = zone === void 0 ? toB.ms + DAY_MS2 - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
|
|
11086
11270
|
const filter = [
|
|
11087
11271
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11088
11272
|
{ field: "dateWorked", op: "lte", value: iso2(toEndMs) }
|
|
11089
11273
|
];
|
|
11090
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11274
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _67 => _67.limit])), "time_entries.customRange", http);
|
|
11091
11275
|
return items;
|
|
11092
11276
|
}
|
|
11093
11277
|
async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
11094
11278
|
const filter = [
|
|
11095
11279
|
{ field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
|
|
11096
11280
|
];
|
|
11097
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11281
|
+
if (_optionalChain([opts, 'optionalAccess', _68 => _68.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11098
11282
|
const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
|
|
11099
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11283
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _69 => _69.limit])), operation, http);
|
|
11100
11284
|
return items;
|
|
11101
11285
|
}
|
|
11102
11286
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
11103
11287
|
const OP2 = opLabel;
|
|
11104
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
11288
|
+
const zone = _optionalChain([opts, 'optionalAccess', _70 => _70.tz]) === void 0 ? void 0 : validateZone(opts.tz, OP2);
|
|
11105
11289
|
const fromB = customRangeDay(from, "from", zone, OP2);
|
|
11106
11290
|
const toB = customRangeDay(to, "to", zone, OP2);
|
|
11107
11291
|
if (fromB.ms > toB.ms) {
|
|
11108
|
-
throw new (0,
|
|
11292
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(`${OP2}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP2 });
|
|
11109
11293
|
}
|
|
11110
11294
|
const windowToMs = zone === void 0 ? toB.ms + DAY_MS2 - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
|
|
11111
11295
|
const filter = [
|
|
11112
11296
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11113
11297
|
{ field: "dateWorked", op: "lte", value: iso2(windowToMs) }
|
|
11114
11298
|
];
|
|
11115
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11116
|
-
else if (_optionalChain([opts, 'optionalAccess',
|
|
11117
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11118
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11119
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11299
|
+
if (_optionalChain([opts, 'optionalAccess', _71 => _71.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
|
|
11300
|
+
else if (_optionalChain([opts, 'optionalAccess', _72 => _72.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
11301
|
+
if (_optionalChain([opts, 'optionalAccess', _73 => _73.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11302
|
+
if (_optionalChain([opts, 'optionalAccess', _74 => _74.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
11303
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _75 => _75.limit])), OP2, http);
|
|
11120
11304
|
let postedCount = 0;
|
|
11121
11305
|
for (const item of items) {
|
|
11122
11306
|
const postedDate = item.postedDate;
|
|
@@ -11172,13 +11356,13 @@ var LINKAGE_OWNED_FIELDS = /* @__PURE__ */ new Set([
|
|
|
11172
11356
|
"roleID"
|
|
11173
11357
|
]);
|
|
11174
11358
|
var TIME_WINDOW_FIELDS = /* @__PURE__ */ new Set(["dateWorked", "startDateTime", "endDateTime", "hoursWorked"]);
|
|
11175
|
-
var ResourceInvalidError = class extends
|
|
11359
|
+
var ResourceInvalidError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
11176
11360
|
constructor(message, options = {}) {
|
|
11177
11361
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11178
11362
|
this.name = "ResourceInvalidError";
|
|
11179
11363
|
}
|
|
11180
11364
|
};
|
|
11181
|
-
var AllocationCodeError = class extends
|
|
11365
|
+
var AllocationCodeError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
11182
11366
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
11183
11367
|
|
|
11184
11368
|
constructor(kind, message, options = {}) {
|
|
@@ -11187,7 +11371,7 @@ var AllocationCodeError = class extends _chunk5N6DYKXOcjs.AutotaskError {
|
|
|
11187
11371
|
this.kind = kind;
|
|
11188
11372
|
}
|
|
11189
11373
|
};
|
|
11190
|
-
var NoApplicableAllocationCodeError = class extends
|
|
11374
|
+
var NoApplicableAllocationCodeError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
11191
11375
|
/** The structured blocker details (filters tried + department sets). */
|
|
11192
11376
|
|
|
11193
11377
|
constructor(details, options = {}) {
|
|
@@ -11213,7 +11397,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
11213
11397
|
let pages = 0;
|
|
11214
11398
|
for (; ; ) {
|
|
11215
11399
|
if (pages >= PAGE_GUARD) {
|
|
11216
|
-
throw new (0,
|
|
11400
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
11217
11401
|
code: "RESOLUTION_TRUNCATED",
|
|
11218
11402
|
category: "resolution",
|
|
11219
11403
|
operation,
|
|
@@ -11224,11 +11408,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
11224
11408
|
const res = await http.request({
|
|
11225
11409
|
method: "POST",
|
|
11226
11410
|
idempotent: true,
|
|
11227
|
-
path: isFirst ? path :
|
|
11411
|
+
path: isFirst ? path : _chunkIHRXVIUUcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
11228
11412
|
body: { MaxRecords: pageSize, filter },
|
|
11229
11413
|
operation
|
|
11230
11414
|
});
|
|
11231
|
-
const { items: pageItems, pageDetails } =
|
|
11415
|
+
const { items: pageItems, pageDetails } = _chunkIHRXVIUUcjs.unwrapItems.call(void 0, res, operation);
|
|
11232
11416
|
items.push(...pageItems);
|
|
11233
11417
|
pages += 1;
|
|
11234
11418
|
if (items.length >= totalCap) break;
|
|
@@ -11341,8 +11525,8 @@ function windowDefaults(params) {
|
|
|
11341
11525
|
};
|
|
11342
11526
|
}
|
|
11343
11527
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
11344
|
-
const rid =
|
|
11345
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
11528
|
+
const rid = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
11529
|
+
const pin = (value, label) => typeof value === "number" ? _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
11346
11530
|
const pins = {
|
|
11347
11531
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
11348
11532
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -11351,19 +11535,19 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11351
11535
|
};
|
|
11352
11536
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
11353
11537
|
if (pinCount > 1) {
|
|
11354
|
-
throw new (0,
|
|
11538
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
11355
11539
|
"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)",
|
|
11356
11540
|
{ operation: OP }
|
|
11357
11541
|
);
|
|
11358
11542
|
}
|
|
11359
11543
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
11360
|
-
throw new (0,
|
|
11544
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
11361
11545
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
11362
11546
|
{ operation: OP }
|
|
11363
11547
|
);
|
|
11364
11548
|
}
|
|
11365
11549
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
11366
|
-
throw new (0,
|
|
11550
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)(
|
|
11367
11551
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
11368
11552
|
{ operation: OP }
|
|
11369
11553
|
);
|
|
@@ -11440,7 +11624,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11440
11624
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
11441
11625
|
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).");
|
|
11442
11626
|
}
|
|
11443
|
-
return
|
|
11627
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0,
|
|
11444
11628
|
{
|
|
11445
11629
|
operation: OP,
|
|
11446
11630
|
method: "POST",
|
|
@@ -11479,7 +11663,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11479
11663
|
};
|
|
11480
11664
|
} catch (err) {
|
|
11481
11665
|
lastError = err;
|
|
11482
|
-
const text =
|
|
11666
|
+
const text = _chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkIHRXVIUUcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
11483
11667
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
11484
11668
|
if (usedLinkage !== "internal" && gate3) {
|
|
11485
11669
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
@@ -11499,14 +11683,14 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11499
11683
|
throw err;
|
|
11500
11684
|
}
|
|
11501
11685
|
}
|
|
11502
|
-
if (
|
|
11686
|
+
if (_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, lastError)) {
|
|
11503
11687
|
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.`;
|
|
11504
11688
|
}
|
|
11505
11689
|
throw lastError;
|
|
11506
11690
|
}
|
|
11507
11691
|
function discoveryField(err, body, defaults) {
|
|
11508
|
-
if (!
|
|
11509
|
-
const entries =
|
|
11692
|
+
if (!_chunkIHRXVIUUcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11693
|
+
const entries = _chunkIHRXVIUUcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11510
11694
|
if (entries === void 0) return null;
|
|
11511
11695
|
for (const entry of entries) {
|
|
11512
11696
|
const field = entry.field;
|
|
@@ -11519,7 +11703,7 @@ function discoveryField(err, body, defaults) {
|
|
|
11519
11703
|
}
|
|
11520
11704
|
|
|
11521
11705
|
// src/resources/time_entries.ts
|
|
11522
|
-
var TimeEntriesResource = class extends
|
|
11706
|
+
var TimeEntriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
11523
11707
|
constructor(http, pageSize) {
|
|
11524
11708
|
super(http, {
|
|
11525
11709
|
key: "time_entries",
|
|
@@ -11656,7 +11840,7 @@ var TimeEntriesResource = class extends _chunk5N6DYKXOcjs.BaseResource {
|
|
|
11656
11840
|
};
|
|
11657
11841
|
|
|
11658
11842
|
// src/resources/time_entry_attachments.ts
|
|
11659
|
-
var TimeEntryAttachmentsResource = class extends
|
|
11843
|
+
var TimeEntryAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
11660
11844
|
constructor(http, pageSize) {
|
|
11661
11845
|
super(http, {
|
|
11662
11846
|
key: "time_entry_attachments",
|
|
@@ -11719,9 +11903,9 @@ var TimeEntryAttachmentsResource = class extends _chunk5N6DYKXOcjs.BaseResource
|
|
|
11719
11903
|
|
|
11720
11904
|
// src/resources/special/time_off_requests.ts
|
|
11721
11905
|
async function approve(_resource, id, opts = {}, http) {
|
|
11722
|
-
const numericId =
|
|
11906
|
+
const numericId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
11723
11907
|
if (opts.dryRun === true) {
|
|
11724
|
-
return
|
|
11908
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
11725
11909
|
operation: "time_off_requests.approve",
|
|
11726
11910
|
method: "GET",
|
|
11727
11911
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -11736,16 +11920,16 @@ async function approve(_resource, id, opts = {}, http) {
|
|
|
11736
11920
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
11737
11921
|
operation: "time_off_requests.approve"
|
|
11738
11922
|
});
|
|
11739
|
-
return
|
|
11923
|
+
return _chunkIHRXVIUUcjs.unwrapOperation.call(void 0, res);
|
|
11740
11924
|
}
|
|
11741
11925
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
11742
|
-
const numericId =
|
|
11926
|
+
const numericId = _chunkIHRXVIUUcjs.parseIdentifier.call(void 0, id, "id");
|
|
11743
11927
|
const text = reason.trim();
|
|
11744
11928
|
if (text === "") {
|
|
11745
|
-
throw new (0,
|
|
11929
|
+
throw new (0, _chunkIHRXVIUUcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
11746
11930
|
}
|
|
11747
11931
|
if (opts.dryRun === true) {
|
|
11748
|
-
return
|
|
11932
|
+
return _chunkIHRXVIUUcjs.buildDryRunResult.call(void 0, {
|
|
11749
11933
|
operation: "time_off_requests.reject",
|
|
11750
11934
|
method: "POST",
|
|
11751
11935
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -11762,11 +11946,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
11762
11946
|
body: { timeOffRequestID: numericId, reason: text },
|
|
11763
11947
|
operation: "time_off_requests.reject"
|
|
11764
11948
|
});
|
|
11765
|
-
return
|
|
11949
|
+
return _chunkIHRXVIUUcjs.unwrapOperation.call(void 0, res);
|
|
11766
11950
|
}
|
|
11767
11951
|
|
|
11768
11952
|
// src/resources/time_off_requests.ts
|
|
11769
|
-
var TimeOffRequestsResource = class extends
|
|
11953
|
+
var TimeOffRequestsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
11770
11954
|
constructor(http, pageSize) {
|
|
11771
11955
|
super(http, {
|
|
11772
11956
|
key: "time_off_requests",
|