node-autotask 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +36 -7
- package/MCP_TOOL_CATALOG.json +4 -3
- package/MCP_TOOL_MANIFEST.md +5 -5
- package/N8N_MCP_MANIFEST.json +2 -2
- package/N8N_MCP_MANIFEST.md +3 -3
- package/README.md +6 -5
- package/capabilities.json +3537 -4144
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.d.cts +8 -4
- package/dist/capabilities.d.ts +8 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-PPTAMCFA.js → chunk-2ZZOTJ2C.js} +2 -2
- package/dist/{chunk-36PG2IU2.cjs → chunk-5QMXECLN.cjs} +594 -574
- package/dist/{chunk-CSRCMBZ2.cjs → chunk-EWMG3HHU.cjs} +3536 -4143
- package/dist/{chunk-PGQIGE63.cjs → chunk-FCJUM42E.cjs} +135 -135
- package/dist/{chunk-P35GFG2H.js → chunk-IYN2BHVW.js} +172 -152
- package/dist/{chunk-NACI2NDF.js → chunk-JIDR3NPV.js} +3536 -4143
- package/dist/{chunk-ZOA5HUFX.js → chunk-KA6UU26H.js} +35 -23
- package/dist/{chunk-IHRXVIUU.cjs → chunk-XSIY3WRR.cjs} +40 -28
- package/dist/{index-DZfd9Gt7.d.cts → index-oiwPuJOG.d.cts} +100 -36
- package/dist/{index-UilX3PFL.d.ts → index-zt1KXThi.d.ts} +100 -36
- package/dist/index.cjs +62 -20
- package/dist/index.d.cts +83 -3
- package/dist/index.d.ts +83 -3
- package/dist/index.js +47 -5
- package/dist/operations/index.cjs +110 -107
- package/dist/operations/index.d.cts +9 -2
- package/dist/operations/index.d.ts +9 -2
- package/dist/operations/index.js +9 -6
- 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/dist/untrusted.cjs +3 -1
- package/dist/untrusted.d.cts +9 -4
- package/dist/untrusted.d.ts +9 -4
- package/dist/untrusted.js +3 -1
- package/docs/API.md +146 -28
- package/docs/LIVE-TESTING.md +1 -1
- package/package.json +2 -2
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkXSIY3WRRcjs = require('./chunk-XSIY3WRR.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunkEWMG3HHUcjs = require('./chunk-EWMG3HHU.cjs');
|
|
40
40
|
|
|
41
41
|
// src/resources/appointments.ts
|
|
42
|
-
var AppointmentsResource = class extends
|
|
42
|
+
var AppointmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
43
43
|
constructor(http, pageSize) {
|
|
44
44
|
super(http, {
|
|
45
45
|
key: "appointments",
|
|
@@ -92,7 +92,7 @@ var AppointmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
92
92
|
async delete(id, opts = {}) {
|
|
93
93
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
94
94
|
await this.guardStaleBeforeMutation(id, opts, "appointments.delete");
|
|
95
|
-
return this.deleteGlobal(id);
|
|
95
|
+
return this.deleteGlobal(id, opts);
|
|
96
96
|
}
|
|
97
97
|
/** Resolve a Appointment from a numeric id (or, where the vendor indexes a primary text field,
|
|
98
98
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -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 _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.BaseResource {
|
|
490
490
|
constructor(http, pageSize) {
|
|
491
491
|
super(http, {
|
|
492
492
|
key: "billing_items",
|
|
@@ -588,7 +588,7 @@ var BillingItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
588
588
|
};
|
|
589
589
|
|
|
590
590
|
// src/resources/change_request_links.ts
|
|
591
|
-
var ChangeRequestLinksResource = class extends
|
|
591
|
+
var ChangeRequestLinksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
592
592
|
constructor(http, pageSize) {
|
|
593
593
|
super(http, {
|
|
594
594
|
key: "change_request_links",
|
|
@@ -626,7 +626,7 @@ var ChangeRequestLinksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
626
626
|
async delete(id, opts = {}) {
|
|
627
627
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
628
628
|
await this.guardStaleBeforeMutation(id, opts, "change_request_links.delete");
|
|
629
|
-
return this.deleteGlobal(id);
|
|
629
|
+
return this.deleteGlobal(id, opts);
|
|
630
630
|
}
|
|
631
631
|
/** Resolve a ChangeRequestLink from a numeric id (or, where the vendor indexes a primary text field,
|
|
632
632
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -642,7 +642,7 @@ var ChangeRequestLinksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
642
642
|
};
|
|
643
643
|
|
|
644
644
|
// src/resources/checklist_libraries.ts
|
|
645
|
-
var ChecklistLibrariesResource = class extends
|
|
645
|
+
var ChecklistLibrariesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
646
646
|
constructor(http, pageSize) {
|
|
647
647
|
super(http, {
|
|
648
648
|
key: "checklist_libraries",
|
|
@@ -696,7 +696,7 @@ var ChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
696
696
|
async delete(id, opts = {}) {
|
|
697
697
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
698
698
|
await this.guardStaleBeforeMutation(id, opts, "checklist_libraries.delete");
|
|
699
|
-
return this.deleteGlobal(id);
|
|
699
|
+
return this.deleteGlobal(id, opts);
|
|
700
700
|
}
|
|
701
701
|
/** Resolve a ChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
702
702
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -716,7 +716,7 @@ var ChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
716
716
|
};
|
|
717
717
|
|
|
718
718
|
// src/resources/checklist_library_checklist_items.ts
|
|
719
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
719
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
720
720
|
constructor(http, pageSize) {
|
|
721
721
|
super(http, {
|
|
722
722
|
key: "checklist_library_checklist_items",
|
|
@@ -759,14 +759,14 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkIHRXVIUUcjs.Bas
|
|
|
759
759
|
async update(parentId, id, data, opts = {}) {
|
|
760
760
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
761
761
|
await this.guardStaleBeforeMutation(id, opts, "checklist_library_checklist_items.update", parentId);
|
|
762
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
762
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
763
763
|
}
|
|
764
764
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
765
765
|
* envelope and never issues the delete. */
|
|
766
766
|
async delete(parentId, id, opts = {}) {
|
|
767
767
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
768
768
|
await this.guardStaleBeforeMutation(id, opts, "checklist_library_checklist_items.delete", parentId);
|
|
769
|
-
return this.deleteScopedRaw(parentId, id);
|
|
769
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
770
770
|
}
|
|
771
771
|
/** Resolve a ChecklistLibraryChecklistItem from a numeric id (or, where the vendor indexes a primary text field,
|
|
772
772
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -782,7 +782,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkIHRXVIUUcjs.Bas
|
|
|
782
782
|
};
|
|
783
783
|
|
|
784
784
|
// src/resources/classification_icons.ts
|
|
785
|
-
var ClassificationIconsResource = class extends
|
|
785
|
+
var ClassificationIconsResource = class extends _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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: _chunkXSIY3WRRcjs.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 } = _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
960
|
+
const limit = opts.limit === void 0 ? 25 : _chunkXSIY3WRRcjs.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: _chunkXSIY3WRRcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
966
966
|
operation: "companies.search"
|
|
967
967
|
});
|
|
968
|
-
const hits =
|
|
968
|
+
const hits = _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.AutotaskError {
|
|
993
993
|
constructor(message, options = {}) {
|
|
994
994
|
super(message, {
|
|
995
995
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1000,13 +1000,13 @@ var OwnerResourceRequiredError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
|
1000
1000
|
this.name = "OwnerResourceRequiredError";
|
|
1001
1001
|
}
|
|
1002
1002
|
};
|
|
1003
|
-
var CompanyResourceInvalidError = class extends
|
|
1003
|
+
var CompanyResourceInvalidError = class extends _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 _chunkIHRXVIUUcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
1078
1078
|
{
|
|
1079
1079
|
operation: OP_UPSERT_NAME,
|
|
1080
1080
|
method: "POST",
|
|
@@ -1114,7 +1114,7 @@ async function upsertByName(resource, companyName, params, opts, http) {
|
|
|
1114
1114
|
let merges = 0;
|
|
1115
1115
|
for (; ; ) {
|
|
1116
1116
|
try {
|
|
1117
|
-
const created = await resource.create(body, {});
|
|
1117
|
+
const created = await resource.create(body, { maxRetries: opts.maxRetries });
|
|
1118
1118
|
return {
|
|
1119
1119
|
id: created.id,
|
|
1120
1120
|
created: true,
|
|
@@ -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 (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1126
|
+
const named = (_nullishCoalesce(_chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.blindStampFor.call(void 0, _optionalChain([_chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.createNamePlan.call(void 0, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1253
1253
|
const companyRow = { ...company };
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1255
|
+
_chunkXSIY3WRRcjs.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
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1262
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1263
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1264
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1265
|
+
for (const f of _chunkXSIY3WRRcjs.TICKET_LABEL_FIELDS) _chunkXSIY3WRRcjs.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
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1274
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1275
|
+
_chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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
|
+
_chunkXSIY3WRRcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1352
1352
|
} catch (err) {
|
|
1353
|
-
problems.push(err instanceof
|
|
1353
|
+
problems.push(err instanceof _chunkXSIY3WRRcjs.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
|
+
_chunkXSIY3WRRcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1364
1364
|
} catch (err) {
|
|
1365
|
-
problems.push(err instanceof
|
|
1365
|
+
problems.push(err instanceof _chunkXSIY3WRRcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1366
1366
|
}
|
|
1367
1367
|
});
|
|
1368
1368
|
}
|
|
1369
1369
|
}
|
|
1370
1370
|
try {
|
|
1371
|
-
|
|
1371
|
+
_chunkXSIY3WRRcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1372
1372
|
} catch (err) {
|
|
1373
|
-
problems.push(err instanceof
|
|
1373
|
+
problems.push(err instanceof _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 } = _chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.blindStampFor.call(void 0, _optionalChain([_chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.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 = _chunkXSIY3WRRcjs.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] = _chunkXSIY3WRRcjs.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(_chunkXSIY3WRRcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1518
|
+
[billingItems, billingNoteCharsTruncated] = _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.BaseResource {
|
|
1616
1616
|
constructor(http, pageSize) {
|
|
1617
1617
|
super(http, {
|
|
1618
1618
|
key: "companies",
|
|
@@ -1719,7 +1719,7 @@ var CompaniesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1719
1719
|
};
|
|
1720
1720
|
|
|
1721
1721
|
// src/resources/company_alerts.ts
|
|
1722
|
-
var CompanyAlertsResource = class extends
|
|
1722
|
+
var CompanyAlertsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
1723
1723
|
constructor(http, pageSize) {
|
|
1724
1724
|
super(http, {
|
|
1725
1725
|
key: "company_alerts",
|
|
@@ -1762,14 +1762,14 @@ var CompanyAlertsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1762
1762
|
async update(parentId, id, data, opts = {}) {
|
|
1763
1763
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
1764
1764
|
await this.guardStaleBeforeMutation(id, opts, "company_alerts.update", parentId);
|
|
1765
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
1765
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
1766
1766
|
}
|
|
1767
1767
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
1768
1768
|
* envelope and never issues the delete. */
|
|
1769
1769
|
async delete(parentId, id, opts = {}) {
|
|
1770
1770
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
1771
1771
|
await this.guardStaleBeforeMutation(id, opts, "company_alerts.delete", parentId);
|
|
1772
|
-
return this.deleteScopedRaw(parentId, id);
|
|
1772
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
1773
1773
|
}
|
|
1774
1774
|
/** Resolve a CompanyAlert from a numeric id (or, where the vendor indexes a primary text field,
|
|
1775
1775
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -1785,7 +1785,7 @@ var CompanyAlertsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1785
1785
|
};
|
|
1786
1786
|
|
|
1787
1787
|
// src/resources/company_locations.ts
|
|
1788
|
-
var CompanyLocationsResource = class extends
|
|
1788
|
+
var CompanyLocationsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
1789
1789
|
constructor(http, pageSize) {
|
|
1790
1790
|
super(http, {
|
|
1791
1791
|
key: "company_locations",
|
|
@@ -1829,14 +1829,14 @@ var CompanyLocationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1829
1829
|
async update(parentId, id, data, opts = {}) {
|
|
1830
1830
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
1831
1831
|
await this.guardStaleBeforeMutation(id, opts, "company_locations.update", parentId);
|
|
1832
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
1832
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
1833
1833
|
}
|
|
1834
1834
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
1835
1835
|
* envelope and never issues the delete. */
|
|
1836
1836
|
async delete(parentId, id, opts = {}) {
|
|
1837
1837
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
1838
1838
|
await this.guardStaleBeforeMutation(id, opts, "company_locations.delete", parentId);
|
|
1839
|
-
return this.deleteScopedRaw(parentId, id);
|
|
1839
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
1840
1840
|
}
|
|
1841
1841
|
/** Resolve a CompanyLocation from a numeric id (or, where the vendor indexes a primary text field,
|
|
1842
1842
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -1856,7 +1856,7 @@ var CompanyLocationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1856
1856
|
};
|
|
1857
1857
|
|
|
1858
1858
|
// src/resources/company_notes.ts
|
|
1859
|
-
var CompanyNotesResource = class extends
|
|
1859
|
+
var CompanyNotesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
1860
1860
|
constructor(http, pageSize) {
|
|
1861
1861
|
super(http, {
|
|
1862
1862
|
key: "company_notes",
|
|
@@ -1901,7 +1901,7 @@ var CompanyNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1901
1901
|
async update(parentId, id, data, opts = {}) {
|
|
1902
1902
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
1903
1903
|
await this.guardStaleBeforeMutation(id, opts, "company_notes.update", parentId);
|
|
1904
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
1904
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
1905
1905
|
}
|
|
1906
1906
|
/** Resolve a CompanyNote from a numeric id (or, where the vendor indexes a primary text field,
|
|
1907
1907
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -1921,7 +1921,7 @@ var CompanyNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
1921
1921
|
};
|
|
1922
1922
|
|
|
1923
1923
|
// src/resources/company_site_configurations.ts
|
|
1924
|
-
var CompanySiteConfigurationsResource = class extends
|
|
1924
|
+
var CompanySiteConfigurationsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
1925
1925
|
constructor(http, pageSize) {
|
|
1926
1926
|
super(http, {
|
|
1927
1927
|
key: "company_site_configurations",
|
|
@@ -1956,7 +1956,7 @@ var CompanySiteConfigurationsResource = class extends _chunkIHRXVIUUcjs.BaseReso
|
|
|
1956
1956
|
async update(parentId, id, data, opts = {}) {
|
|
1957
1957
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
1958
1958
|
await this.guardStaleBeforeMutation(id, opts, "company_site_configurations.update", parentId);
|
|
1959
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
1959
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
1960
1960
|
}
|
|
1961
1961
|
/** Resolve a CompanySiteConfigurations from a numeric id (or, where the vendor indexes a primary text field,
|
|
1962
1962
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -1972,7 +1972,7 @@ var CompanySiteConfigurationsResource = class extends _chunkIHRXVIUUcjs.BaseReso
|
|
|
1972
1972
|
};
|
|
1973
1973
|
|
|
1974
1974
|
// src/resources/company_webhooks.ts
|
|
1975
|
-
var CompanyWebhooksResource = class extends
|
|
1975
|
+
var CompanyWebhooksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
1976
1976
|
constructor(http, pageSize) {
|
|
1977
1977
|
super(http, {
|
|
1978
1978
|
key: "company_webhooks",
|
|
@@ -2028,7 +2028,7 @@ var CompanyWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
2028
2028
|
async delete(id, opts = {}) {
|
|
2029
2029
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
2030
2030
|
await this.guardStaleBeforeMutation(id, opts, "company_webhooks.delete");
|
|
2031
|
-
return this.deleteGlobal(id);
|
|
2031
|
+
return this.deleteGlobal(id, opts);
|
|
2032
2032
|
}
|
|
2033
2033
|
/** Resolve a CompanyWebhook from a numeric id (or, where the vendor indexes a primary text field,
|
|
2034
2034
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -2048,7 +2048,7 @@ var CompanyWebhooksResource = class extends _chunkIHRXVIUUcjs.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 _chunkXSIY3WRRcjs.BaseResource {
|
|
2052
2052
|
constructor(http, pageSize) {
|
|
2053
2053
|
super(http, {
|
|
2054
2054
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2091,14 +2091,14 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkIH
|
|
|
2091
2091
|
async update(parentId, id, data, opts = {}) {
|
|
2092
2092
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
2093
2093
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_billing_product_associations.update", parentId);
|
|
2094
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
2094
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
2095
2095
|
}
|
|
2096
2096
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
2097
2097
|
* envelope and never issues the delete. */
|
|
2098
2098
|
async delete(parentId, id, opts = {}) {
|
|
2099
2099
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
2100
2100
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_billing_product_associations.delete", parentId);
|
|
2101
|
-
return this.deleteScopedRaw(parentId, id);
|
|
2101
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
2102
2102
|
}
|
|
2103
2103
|
/** Resolve a ConfigurationItemBillingProductAssociations from a numeric id (or, where the vendor indexes a primary text field,
|
|
2104
2104
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -2114,7 +2114,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkIH
|
|
|
2114
2114
|
};
|
|
2115
2115
|
|
|
2116
2116
|
// src/resources/configuration_item_categories.ts
|
|
2117
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2117
|
+
var ConfigurationItemCategoriesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2118
2118
|
constructor(http, pageSize) {
|
|
2119
2119
|
super(http, {
|
|
2120
2120
|
key: "configuration_item_categories",
|
|
@@ -2181,7 +2181,7 @@ var ConfigurationItemCategoriesResource = class extends _chunkIHRXVIUUcjs.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 _chunkXSIY3WRRcjs.BaseResource {
|
|
2185
2185
|
constructor(http, pageSize) {
|
|
2186
2186
|
super(http, {
|
|
2187
2187
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2224,14 +2224,14 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkIHRXV
|
|
|
2224
2224
|
async update(parentId, id, data, opts = {}) {
|
|
2225
2225
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
2226
2226
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_category_udf_associations.update", parentId);
|
|
2227
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
2227
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
2228
2228
|
}
|
|
2229
2229
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
2230
2230
|
* envelope and never issues the delete. */
|
|
2231
2231
|
async delete(parentId, id, opts = {}) {
|
|
2232
2232
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
2233
2233
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_category_udf_associations.delete", parentId);
|
|
2234
|
-
return this.deleteScopedRaw(parentId, id);
|
|
2234
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
2235
2235
|
}
|
|
2236
2236
|
/** Resolve a ConfigurationItemCategoryUdfAssociation from a numeric id (or, where the vendor indexes a primary text field,
|
|
2237
2237
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -2247,7 +2247,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkIHRXV
|
|
|
2247
2247
|
};
|
|
2248
2248
|
|
|
2249
2249
|
// src/resources/configuration_item_dns_records.ts
|
|
2250
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2250
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2251
2251
|
constructor(http, pageSize) {
|
|
2252
2252
|
super(http, {
|
|
2253
2253
|
key: "configuration_item_dns_records",
|
|
@@ -2280,7 +2280,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkIHRXVIUUcjs.BaseRe
|
|
|
2280
2280
|
async delete(parentId, id, opts = {}) {
|
|
2281
2281
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
2282
2282
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_dns_records.delete", parentId);
|
|
2283
|
-
return this.deleteScopedRaw(parentId, id);
|
|
2283
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
2284
2284
|
}
|
|
2285
2285
|
/** Resolve a ConfigurationItemDnsRecord from a numeric id (or, where the vendor indexes a primary text field,
|
|
2286
2286
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -2296,7 +2296,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkIHRXVIUUcjs.BaseRe
|
|
|
2296
2296
|
};
|
|
2297
2297
|
|
|
2298
2298
|
// src/resources/configuration_item_notes.ts
|
|
2299
|
-
var ConfigurationItemNotesResource = class extends
|
|
2299
|
+
var ConfigurationItemNotesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2300
2300
|
constructor(http, pageSize) {
|
|
2301
2301
|
super(http, {
|
|
2302
2302
|
key: "configuration_item_notes",
|
|
@@ -2339,7 +2339,7 @@ var ConfigurationItemNotesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
2339
2339
|
async update(parentId, id, data, opts = {}) {
|
|
2340
2340
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
2341
2341
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_notes.update", parentId);
|
|
2342
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
2342
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
2343
2343
|
}
|
|
2344
2344
|
/** Resolve a ConfigurationItemNote from a numeric id (or, where the vendor indexes a primary text field,
|
|
2345
2345
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -2355,7 +2355,7 @@ var ConfigurationItemNotesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
2355
2355
|
};
|
|
2356
2356
|
|
|
2357
2357
|
// src/resources/configuration_item_related_items.ts
|
|
2358
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2358
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2359
2359
|
constructor(http, pageSize) {
|
|
2360
2360
|
super(http, {
|
|
2361
2361
|
key: "configuration_item_related_items",
|
|
@@ -2396,7 +2396,7 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkIHRXVIUUcjs.Base
|
|
|
2396
2396
|
async delete(parentId, id, opts = {}) {
|
|
2397
2397
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
2398
2398
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_related_items.delete", parentId);
|
|
2399
|
-
return this.deleteScopedRaw(parentId, id);
|
|
2399
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
2400
2400
|
}
|
|
2401
2401
|
/** Resolve a ConfigurationItemRelatedItem from a numeric id (or, where the vendor indexes a primary text field,
|
|
2402
2402
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -2412,22 +2412,22 @@ var ConfigurationItemRelatedItemsResource = class extends _chunkIHRXVIUUcjs.Base
|
|
|
2412
2412
|
};
|
|
2413
2413
|
|
|
2414
2414
|
// src/resources/special/configuration_items.ts
|
|
2415
|
-
async function fetchRecord(http, path, label) {
|
|
2416
|
-
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem" });
|
|
2415
|
+
async function fetchRecord(http, path, label, readOpts) {
|
|
2416
|
+
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _20 => _20.maxRetries]) });
|
|
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, _chunkXSIY3WRRcjs.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 =
|
|
2425
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
2426
|
-
throw new (0,
|
|
2424
|
+
const numericSource = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2425
|
+
if (_optionalChain([opts, 'optionalAccess', _21 => _21.destinationCompanyId]) === void 0) {
|
|
2426
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2427
2427
|
}
|
|
2428
|
-
const destId =
|
|
2429
|
-
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}
|
|
2430
|
-
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}
|
|
2428
|
+
const destId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2429
|
+
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
|
|
2430
|
+
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
2431
2431
|
const body = { ...source };
|
|
2432
2432
|
delete body.id;
|
|
2433
2433
|
delete body.soapParentPropertyId;
|
|
@@ -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, _chunkXSIY3WRRcjs.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, _chunkXSIY3WRRcjs.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 _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
2452
2452
|
operation: "configuration_items.moveConfigurationItem",
|
|
2453
2453
|
method: "POST",
|
|
2454
2454
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2467,12 +2467,13 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2467
2467
|
method: "POST",
|
|
2468
2468
|
path: "/V1.0/ConfigurationItems",
|
|
2469
2469
|
body,
|
|
2470
|
-
operation: "configuration_items.moveConfigurationItem"
|
|
2470
|
+
operation: "configuration_items.moveConfigurationItem",
|
|
2471
|
+
maxRetries: opts.maxRetries
|
|
2471
2472
|
});
|
|
2472
2473
|
const createdBody = created;
|
|
2473
2474
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2474
2475
|
if (typeof newId !== "number") {
|
|
2475
|
-
throw new (0,
|
|
2476
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2476
2477
|
}
|
|
2477
2478
|
let sourceDeactivated = false;
|
|
2478
2479
|
if (opts.deactivateSource !== false) {
|
|
@@ -2480,7 +2481,8 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2480
2481
|
method: "PUT",
|
|
2481
2482
|
path: "/V1.0/ConfigurationItems",
|
|
2482
2483
|
body: { id: numericSource, isActive: false },
|
|
2483
|
-
operation: "configuration_items.moveConfigurationItem"
|
|
2484
|
+
operation: "configuration_items.moveConfigurationItem",
|
|
2485
|
+
maxRetries: opts.maxRetries
|
|
2484
2486
|
});
|
|
2485
2487
|
sourceDeactivated = true;
|
|
2486
2488
|
}
|
|
@@ -2490,7 +2492,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2490
2492
|
function profilePartLimit2(value, name) {
|
|
2491
2493
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2492
2494
|
if (!Number.isInteger(n) || n < 1) {
|
|
2493
|
-
throw new (0,
|
|
2495
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2494
2496
|
}
|
|
2495
2497
|
return n;
|
|
2496
2498
|
}
|
|
@@ -2506,14 +2508,14 @@ async function contextFetchPart(http, entityPath, referenceId) {
|
|
|
2506
2508
|
});
|
|
2507
2509
|
const body = res;
|
|
2508
2510
|
if (body === null || !("item" in body)) {
|
|
2509
|
-
throw new (0,
|
|
2511
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId] });
|
|
2510
2512
|
}
|
|
2511
2513
|
if (body.item === null || body.item === void 0) {
|
|
2512
|
-
throw new (0,
|
|
2514
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)("context part not found", { resourceIds: [referenceId] });
|
|
2513
2515
|
}
|
|
2514
2516
|
return body.item;
|
|
2515
2517
|
} catch (err) {
|
|
2516
|
-
if (err instanceof
|
|
2518
|
+
if (err instanceof _chunkXSIY3WRRcjs.NotFoundError) return null;
|
|
2517
2519
|
throw err;
|
|
2518
2520
|
}
|
|
2519
2521
|
}
|
|
@@ -2525,7 +2527,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2525
2527
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2526
2528
|
operation: "configuration_items.profile"
|
|
2527
2529
|
});
|
|
2528
|
-
return
|
|
2530
|
+
return _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res).items;
|
|
2529
2531
|
}
|
|
2530
2532
|
async function profile(resource, id, opts = {}, http) {
|
|
2531
2533
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2537,7 +2539,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2537
2539
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2538
2540
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2539
2541
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2540
|
-
const wallQuirk = _optionalChain([
|
|
2542
|
+
const wallQuirk = _optionalChain([_chunkXSIY3WRRcjs.RELATIONSHIP_MAP, 'access', _22 => _22["configuration_items"], 'optionalAccess', _23 => _23.zoneFacts, 'optionalAccess', _24 => _24.quirks, 'optionalAccess', _25 => _25.find, 'call', _26 => _26((q) => q.startsWith("product wall"))]);
|
|
2541
2543
|
const productAssociations = {
|
|
2542
2544
|
items: associations,
|
|
2543
2545
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2561,11 +2563,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2561
2563
|
}
|
|
2562
2564
|
};
|
|
2563
2565
|
if (opts.names === true) {
|
|
2564
|
-
const builder =
|
|
2566
|
+
const builder = _chunkXSIY3WRRcjs.createNamePlan.call(void 0, );
|
|
2565
2567
|
builder.addFk("contract", root["contractID"]);
|
|
2566
|
-
const names = await
|
|
2568
|
+
const names = await _chunkXSIY3WRRcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2567
2569
|
const ciRow = { ...ci };
|
|
2568
|
-
|
|
2570
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2569
2571
|
result.ci = ciRow;
|
|
2570
2572
|
result.names = names.section;
|
|
2571
2573
|
}
|
|
@@ -2573,7 +2575,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2573
2575
|
}
|
|
2574
2576
|
|
|
2575
2577
|
// src/resources/configuration_items.ts
|
|
2576
|
-
var ConfigurationItemsResource = class extends
|
|
2578
|
+
var ConfigurationItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2577
2579
|
constructor(http, pageSize) {
|
|
2578
2580
|
super(http, {
|
|
2579
2581
|
key: "configuration_items",
|
|
@@ -2662,7 +2664,7 @@ var ConfigurationItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
2662
2664
|
};
|
|
2663
2665
|
|
|
2664
2666
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2665
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
2667
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2666
2668
|
constructor(http, pageSize) {
|
|
2667
2669
|
super(http, {
|
|
2668
2670
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -2698,14 +2700,14 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkIH
|
|
|
2698
2700
|
async update(parentId, id, data, opts = {}) {
|
|
2699
2701
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
2700
2702
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_ssl_subject_alternative_names.update", parentId);
|
|
2701
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
2703
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
2702
2704
|
}
|
|
2703
2705
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
2704
2706
|
* envelope and never issues the delete. */
|
|
2705
2707
|
async delete(parentId, id, opts = {}) {
|
|
2706
2708
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
2707
2709
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_ssl_subject_alternative_names.delete", parentId);
|
|
2708
|
-
return this.deleteScopedRaw(parentId, id);
|
|
2710
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
2709
2711
|
}
|
|
2710
2712
|
/** Resolve a ConfigurationItemSslSubjectAlternativeName from a numeric id (or, where the vendor indexes a primary text field,
|
|
2711
2713
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -2725,7 +2727,7 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkIH
|
|
|
2725
2727
|
};
|
|
2726
2728
|
|
|
2727
2729
|
// src/resources/configuration_item_types.ts
|
|
2728
|
-
var ConfigurationItemTypesResource = class extends
|
|
2730
|
+
var ConfigurationItemTypesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2729
2731
|
constructor(http, pageSize) {
|
|
2730
2732
|
super(http, {
|
|
2731
2733
|
key: "configuration_item_types",
|
|
@@ -2779,7 +2781,7 @@ var ConfigurationItemTypesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
2779
2781
|
async delete(id, opts = {}) {
|
|
2780
2782
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
2781
2783
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_types.delete");
|
|
2782
|
-
return this.deleteGlobal(id);
|
|
2784
|
+
return this.deleteGlobal(id, opts);
|
|
2783
2785
|
}
|
|
2784
2786
|
/** Resolve a ConfigurationItemType from a numeric id (or, where the vendor indexes a primary text field,
|
|
2785
2787
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -2799,7 +2801,7 @@ var ConfigurationItemTypesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
2799
2801
|
};
|
|
2800
2802
|
|
|
2801
2803
|
// src/resources/configuration_item_webhooks.ts
|
|
2802
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
2804
|
+
var ConfigurationItemWebhooksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2803
2805
|
constructor(http, pageSize) {
|
|
2804
2806
|
super(http, {
|
|
2805
2807
|
key: "configuration_item_webhooks",
|
|
@@ -2855,7 +2857,7 @@ var ConfigurationItemWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseReso
|
|
|
2855
2857
|
async delete(id, opts = {}) {
|
|
2856
2858
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
2857
2859
|
await this.guardStaleBeforeMutation(id, opts, "configuration_item_webhooks.delete");
|
|
2858
|
-
return this.deleteGlobal(id);
|
|
2860
|
+
return this.deleteGlobal(id, opts);
|
|
2859
2861
|
}
|
|
2860
2862
|
/** Resolve a ConfigurationItemWebhook from a numeric id (or, where the vendor indexes a primary text field,
|
|
2861
2863
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -2875,7 +2877,7 @@ var ConfigurationItemWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseReso
|
|
|
2875
2877
|
};
|
|
2876
2878
|
|
|
2877
2879
|
// src/resources/contact_group_contacts.ts
|
|
2878
|
-
var ContactGroupContactsResource = class extends
|
|
2880
|
+
var ContactGroupContactsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2879
2881
|
constructor(http, pageSize) {
|
|
2880
2882
|
super(http, {
|
|
2881
2883
|
key: "contact_group_contacts",
|
|
@@ -2913,7 +2915,7 @@ var ContactGroupContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
2913
2915
|
async delete(id, opts = {}) {
|
|
2914
2916
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
2915
2917
|
await this.guardStaleBeforeMutation(id, opts, "contact_group_contacts.delete");
|
|
2916
|
-
return this.deleteGlobal(id);
|
|
2918
|
+
return this.deleteGlobal(id, opts);
|
|
2917
2919
|
}
|
|
2918
2920
|
/** Resolve a ContactGroupContacts from a numeric id (or, where the vendor indexes a primary text field,
|
|
2919
2921
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -2929,7 +2931,7 @@ var ContactGroupContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
2929
2931
|
};
|
|
2930
2932
|
|
|
2931
2933
|
// src/resources/contact_groups.ts
|
|
2932
|
-
var ContactGroupsResource = class extends
|
|
2934
|
+
var ContactGroupsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
2933
2935
|
constructor(http, pageSize) {
|
|
2934
2936
|
super(http, {
|
|
2935
2937
|
key: "contact_groups",
|
|
@@ -2983,7 +2985,7 @@ var ContactGroupsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
2983
2985
|
async delete(id, opts = {}) {
|
|
2984
2986
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
2985
2987
|
await this.guardStaleBeforeMutation(id, opts, "contact_groups.delete");
|
|
2986
|
-
return this.deleteGlobal(id);
|
|
2988
|
+
return this.deleteGlobal(id, opts);
|
|
2987
2989
|
}
|
|
2988
2990
|
/** Resolve a ContactGroups from a numeric id (or, where the vendor indexes a primary text field,
|
|
2989
2991
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -3003,32 +3005,32 @@ var ContactGroupsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3003
3005
|
};
|
|
3004
3006
|
|
|
3005
3007
|
// src/resources/special/contacts.ts
|
|
3006
|
-
async function fetchRecord2(http, path, label) {
|
|
3007
|
-
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany" });
|
|
3008
|
+
async function fetchRecord2(http, path, label, readOpts) {
|
|
3009
|
+
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _27 => _27.maxRetries]) });
|
|
3008
3010
|
const body = res;
|
|
3009
3011
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3010
|
-
throw new (0,
|
|
3012
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3011
3013
|
}
|
|
3012
3014
|
return body.item;
|
|
3013
3015
|
}
|
|
3014
3016
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3015
|
-
const sourceId =
|
|
3016
|
-
const destId =
|
|
3017
|
-
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}
|
|
3017
|
+
const sourceId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3018
|
+
const destId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3019
|
+
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
|
|
3018
3020
|
const companyID = source.companyID;
|
|
3019
3021
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3020
|
-
throw new (0,
|
|
3022
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3021
3023
|
}
|
|
3022
3024
|
if (opts.lastModifiedDate !== void 0) {
|
|
3023
3025
|
const current = source.lastModifiedDate;
|
|
3024
3026
|
if (current !== opts.lastModifiedDate) {
|
|
3025
|
-
throw new (0,
|
|
3027
|
+
throw new (0, _chunkXSIY3WRRcjs.StaleObjectError)(
|
|
3026
3028
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3027
3029
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId] }
|
|
3028
3030
|
);
|
|
3029
3031
|
}
|
|
3030
3032
|
}
|
|
3031
|
-
await fetchRecord2(http, `/V1.0/Companies/${destId}`, `Company ${destId}
|
|
3033
|
+
await fetchRecord2(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
3032
3034
|
const email = typeof source.emailAddress === "string" ? source.emailAddress : "";
|
|
3033
3035
|
if (email !== "") {
|
|
3034
3036
|
const res = await http.request({
|
|
@@ -3044,10 +3046,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3044
3046
|
},
|
|
3045
3047
|
operation: "contacts.moveToCompany"
|
|
3046
3048
|
});
|
|
3047
|
-
const items =
|
|
3049
|
+
const items = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res).items;
|
|
3048
3050
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3049
3051
|
if (clash !== void 0) {
|
|
3050
|
-
throw new (0,
|
|
3052
|
+
throw new (0, _chunkXSIY3WRRcjs.ConflictError)(
|
|
3051
3053
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3052
3054
|
{ resourceIds: [sourceId, destId] }
|
|
3053
3055
|
);
|
|
@@ -3061,7 +3063,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3061
3063
|
if (opts.dryRun === true) {
|
|
3062
3064
|
const warnings = [];
|
|
3063
3065
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3064
|
-
return
|
|
3066
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
3065
3067
|
operation: "contacts.moveToCompany",
|
|
3066
3068
|
method: "POST",
|
|
3067
3069
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3081,19 +3083,21 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3081
3083
|
method: "POST",
|
|
3082
3084
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
3083
3085
|
body,
|
|
3084
|
-
operation: "contacts.moveToCompany"
|
|
3086
|
+
operation: "contacts.moveToCompany",
|
|
3087
|
+
maxRetries: opts.maxRetries
|
|
3085
3088
|
});
|
|
3086
3089
|
const createdBody = created;
|
|
3087
3090
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3088
3091
|
if (typeof newId !== "number") {
|
|
3089
|
-
throw new (0,
|
|
3092
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3090
3093
|
}
|
|
3091
3094
|
let sourceDeleted = false;
|
|
3092
3095
|
if (opts.deleteSource === true) {
|
|
3093
3096
|
await http.request({
|
|
3094
3097
|
method: "DELETE",
|
|
3095
3098
|
path: `/V1.0/Companies/${companyID}/Contacts/${sourceId}`,
|
|
3096
|
-
operation: "contacts.moveToCompany"
|
|
3099
|
+
operation: "contacts.moveToCompany",
|
|
3100
|
+
maxRetries: opts.maxRetries
|
|
3097
3101
|
});
|
|
3098
3102
|
sourceDeleted = true;
|
|
3099
3103
|
}
|
|
@@ -3104,7 +3108,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3104
3108
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3105
3109
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3106
3110
|
var DEDUP_LIMIT = 10;
|
|
3107
|
-
var CompanyNotFoundError = class extends
|
|
3111
|
+
var CompanyNotFoundError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
3108
3112
|
constructor(message, options = {}) {
|
|
3109
3113
|
super(message, {
|
|
3110
3114
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3115,7 +3119,7 @@ var CompanyNotFoundError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
|
3115
3119
|
this.name = "CompanyNotFoundError";
|
|
3116
3120
|
}
|
|
3117
3121
|
};
|
|
3118
|
-
var ContactCreateFailedError = class extends
|
|
3122
|
+
var ContactCreateFailedError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
3119
3123
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3120
3124
|
|
|
3121
3125
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3125,28 +3129,28 @@ var ContactCreateFailedError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
|
3125
3129
|
}
|
|
3126
3130
|
};
|
|
3127
3131
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3128
|
-
const cid =
|
|
3132
|
+
const cid = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3129
3133
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3130
|
-
throw new (0,
|
|
3134
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
3131
3135
|
`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
3136
|
{ operation: OP_UPSERT_EMAIL }
|
|
3133
3137
|
);
|
|
3134
3138
|
}
|
|
3135
3139
|
if (extra !== void 0) {
|
|
3136
3140
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3137
|
-
throw new (0,
|
|
3141
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
3138
3142
|
`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
3143
|
{ operation: OP_UPSERT_EMAIL }
|
|
3140
3144
|
);
|
|
3141
3145
|
}
|
|
3142
3146
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3143
|
-
throw new (0,
|
|
3147
|
+
throw new (0, _chunkXSIY3WRRcjs.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
3148
|
}
|
|
3145
3149
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3146
|
-
throw new (0,
|
|
3150
|
+
throw new (0, _chunkXSIY3WRRcjs.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
3151
|
}
|
|
3148
3152
|
}
|
|
3149
|
-
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL });
|
|
3153
|
+
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
|
|
3150
3154
|
const parentBody = parentRes;
|
|
3151
3155
|
if (parentBody === null || !("item" in parentBody) || parentBody.item === null || parentBody.item === void 0) {
|
|
3152
3156
|
throw new CompanyNotFoundError(
|
|
@@ -3164,7 +3168,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3164
3168
|
const match = q.items[0];
|
|
3165
3169
|
if (match !== void 0) {
|
|
3166
3170
|
if (opts.dryRun === true) {
|
|
3167
|
-
return
|
|
3171
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
3168
3172
|
{
|
|
3169
3173
|
operation: OP_UPSERT_EMAIL,
|
|
3170
3174
|
method: "POST",
|
|
@@ -3185,16 +3189,16 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3185
3189
|
return { id: Number(match.id), created: false, existing: match };
|
|
3186
3190
|
}
|
|
3187
3191
|
const localPart = email.split("@")[0];
|
|
3188
|
-
const isActive = _optionalChain([extra, 'optionalAccess',
|
|
3192
|
+
const isActive = _optionalChain([extra, 'optionalAccess', _28 => _28.isActive]) === void 0 ? true : extra.isActive;
|
|
3189
3193
|
const body = {
|
|
3190
3194
|
emailAddress: email,
|
|
3191
3195
|
companyID: cid,
|
|
3192
|
-
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3193
|
-
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
3196
|
+
firstName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _29 => _29.firstName]), () => ( localPart)),
|
|
3197
|
+
lastName: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _30 => _30.lastName]), () => ( "Unknown")),
|
|
3194
3198
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3195
3199
|
};
|
|
3196
3200
|
if (opts.dryRun === true) {
|
|
3197
|
-
return
|
|
3201
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
3198
3202
|
{
|
|
3199
3203
|
operation: OP_UPSERT_EMAIL,
|
|
3200
3204
|
method: "POST",
|
|
@@ -3214,11 +3218,11 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3214
3218
|
let merges = 0;
|
|
3215
3219
|
for (; ; ) {
|
|
3216
3220
|
try {
|
|
3217
|
-
const created = await resource.create(cid, body, {});
|
|
3221
|
+
const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
|
|
3218
3222
|
return { id: created.id, created: true };
|
|
3219
3223
|
} catch (err) {
|
|
3220
|
-
if (!
|
|
3221
|
-
const named = (_nullishCoalesce(
|
|
3224
|
+
if (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3225
|
+
const named = (_nullishCoalesce(_chunkXSIY3WRRcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3222
3226
|
const seen = /* @__PURE__ */ new Set();
|
|
3223
3227
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3224
3228
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3232,7 +3236,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3232
3236
|
}
|
|
3233
3237
|
continue;
|
|
3234
3238
|
}
|
|
3235
|
-
const detail =
|
|
3239
|
+
const detail = _chunkXSIY3WRRcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3236
3240
|
throw new ContactCreateFailedError(
|
|
3237
3241
|
`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
3242
|
unique,
|
|
@@ -3248,7 +3252,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3248
3252
|
}
|
|
3249
3253
|
|
|
3250
3254
|
// src/resources/contacts.ts
|
|
3251
|
-
var ContactsResource = class extends
|
|
3255
|
+
var ContactsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3252
3256
|
constructor(http, pageSize) {
|
|
3253
3257
|
super(http, {
|
|
3254
3258
|
key: "contacts",
|
|
@@ -3293,14 +3297,14 @@ var ContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3293
3297
|
async update(parentId, id, data, opts = {}) {
|
|
3294
3298
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
3295
3299
|
await this.guardStaleBeforeMutation(id, opts, "contacts.update", parentId);
|
|
3296
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
3300
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
3297
3301
|
}
|
|
3298
3302
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
3299
3303
|
* envelope and never issues the delete. */
|
|
3300
3304
|
async delete(parentId, id, opts = {}) {
|
|
3301
3305
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3302
3306
|
await this.guardStaleBeforeMutation(id, opts, "contacts.delete", parentId);
|
|
3303
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3307
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3304
3308
|
}
|
|
3305
3309
|
/** Resolve a Contact from a numeric id (or, where the vendor indexes a primary text field,
|
|
3306
3310
|
* from an exact match on firstName / lastName). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -3340,7 +3344,7 @@ var ContactsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3340
3344
|
};
|
|
3341
3345
|
|
|
3342
3346
|
// src/resources/contact_webhooks.ts
|
|
3343
|
-
var ContactWebhooksResource = class extends
|
|
3347
|
+
var ContactWebhooksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3344
3348
|
constructor(http, pageSize) {
|
|
3345
3349
|
super(http, {
|
|
3346
3350
|
key: "contact_webhooks",
|
|
@@ -3396,7 +3400,7 @@ var ContactWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3396
3400
|
async delete(id, opts = {}) {
|
|
3397
3401
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
3398
3402
|
await this.guardStaleBeforeMutation(id, opts, "contact_webhooks.delete");
|
|
3399
|
-
return this.deleteGlobal(id);
|
|
3403
|
+
return this.deleteGlobal(id, opts);
|
|
3400
3404
|
}
|
|
3401
3405
|
/** Resolve a ContactWebhook from a numeric id (or, where the vendor indexes a primary text field,
|
|
3402
3406
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -3416,7 +3420,7 @@ var ContactWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3416
3420
|
};
|
|
3417
3421
|
|
|
3418
3422
|
// src/resources/contract_billing_rules.ts
|
|
3419
|
-
var ContractBillingRulesResource = class extends
|
|
3423
|
+
var ContractBillingRulesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3420
3424
|
constructor(http, pageSize) {
|
|
3421
3425
|
super(http, {
|
|
3422
3426
|
key: "contract_billing_rules",
|
|
@@ -3459,14 +3463,14 @@ var ContractBillingRulesResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
3459
3463
|
async update(parentId, id, data, opts = {}) {
|
|
3460
3464
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
3461
3465
|
await this.guardStaleBeforeMutation(id, opts, "contract_billing_rules.update", parentId);
|
|
3462
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
3466
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
3463
3467
|
}
|
|
3464
3468
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
3465
3469
|
* envelope and never issues the delete. */
|
|
3466
3470
|
async delete(parentId, id, opts = {}) {
|
|
3467
3471
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3468
3472
|
await this.guardStaleBeforeMutation(id, opts, "contract_billing_rules.delete", parentId);
|
|
3469
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3473
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3470
3474
|
}
|
|
3471
3475
|
/** Resolve a ContractBillingRule from a numeric id (or, where the vendor indexes a primary text field,
|
|
3472
3476
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3482,7 +3486,7 @@ var ContractBillingRulesResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
3482
3486
|
};
|
|
3483
3487
|
|
|
3484
3488
|
// src/resources/contract_block_hour_factors.ts
|
|
3485
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3489
|
+
var ContractBlockHourFactorsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3486
3490
|
constructor(http, pageSize) {
|
|
3487
3491
|
super(http, {
|
|
3488
3492
|
key: "contract_block_hour_factors",
|
|
@@ -3525,7 +3529,7 @@ var ContractBlockHourFactorsResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
3525
3529
|
async update(parentId, id, data, opts = {}) {
|
|
3526
3530
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
3527
3531
|
await this.guardStaleBeforeMutation(id, opts, "contract_block_hour_factors.update", parentId);
|
|
3528
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
3532
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
3529
3533
|
}
|
|
3530
3534
|
/** Resolve a ContractBlockHourFactor from a numeric id (or, where the vendor indexes a primary text field,
|
|
3531
3535
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3541,7 +3545,7 @@ var ContractBlockHourFactorsResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
3541
3545
|
};
|
|
3542
3546
|
|
|
3543
3547
|
// src/resources/contract_blocks.ts
|
|
3544
|
-
var ContractBlocksResource = class extends
|
|
3548
|
+
var ContractBlocksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3545
3549
|
constructor(http, pageSize) {
|
|
3546
3550
|
super(http, {
|
|
3547
3551
|
key: "contract_blocks",
|
|
@@ -3584,7 +3588,7 @@ var ContractBlocksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3584
3588
|
async update(parentId, id, data, opts = {}) {
|
|
3585
3589
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
3586
3590
|
await this.guardStaleBeforeMutation(id, opts, "contract_blocks.update", parentId);
|
|
3587
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
3591
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
3588
3592
|
}
|
|
3589
3593
|
/** Resolve a ContractBlock from a numeric id (or, where the vendor indexes a primary text field,
|
|
3590
3594
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3600,7 +3604,7 @@ var ContractBlocksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3600
3604
|
};
|
|
3601
3605
|
|
|
3602
3606
|
// src/resources/contract_charges.ts
|
|
3603
|
-
var ContractChargesResource = class extends
|
|
3607
|
+
var ContractChargesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3604
3608
|
constructor(http, pageSize) {
|
|
3605
3609
|
super(http, {
|
|
3606
3610
|
key: "contract_charges",
|
|
@@ -3644,14 +3648,14 @@ var ContractChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3644
3648
|
async update(parentId, id, data, opts = {}) {
|
|
3645
3649
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
3646
3650
|
await this.guardStaleBeforeMutation(id, opts, "contract_charges.update", parentId);
|
|
3647
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
3651
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
3648
3652
|
}
|
|
3649
3653
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
3650
3654
|
* envelope and never issues the delete. */
|
|
3651
3655
|
async delete(parentId, id, opts = {}) {
|
|
3652
3656
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3653
3657
|
await this.guardStaleBeforeMutation(id, opts, "contract_charges.delete", parentId);
|
|
3654
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3658
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3655
3659
|
}
|
|
3656
3660
|
/** Resolve a ContractCharge from a numeric id (or, where the vendor indexes a primary text field,
|
|
3657
3661
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -3671,7 +3675,7 @@ var ContractChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
3671
3675
|
};
|
|
3672
3676
|
|
|
3673
3677
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3674
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
3678
|
+
var ContractExclusionBillingCodesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3675
3679
|
constructor(http, pageSize) {
|
|
3676
3680
|
super(http, {
|
|
3677
3681
|
key: "contract_exclusion_billing_codes",
|
|
@@ -3712,7 +3716,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkIHRXVIUUcjs.Base
|
|
|
3712
3716
|
async delete(parentId, id, opts = {}) {
|
|
3713
3717
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3714
3718
|
await this.guardStaleBeforeMutation(id, opts, "contract_exclusion_billing_codes.delete", parentId);
|
|
3715
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3719
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3716
3720
|
}
|
|
3717
3721
|
/** Resolve a ContractExclusionBillingCode from a numeric id (or, where the vendor indexes a primary text field,
|
|
3718
3722
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3728,7 +3732,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkIHRXVIUUcjs.Base
|
|
|
3728
3732
|
};
|
|
3729
3733
|
|
|
3730
3734
|
// src/resources/contract_exclusion_roles.ts
|
|
3731
|
-
var ContractExclusionRolesResource = class extends
|
|
3735
|
+
var ContractExclusionRolesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3732
3736
|
constructor(http, pageSize) {
|
|
3733
3737
|
super(http, {
|
|
3734
3738
|
key: "contract_exclusion_roles",
|
|
@@ -3769,7 +3773,7 @@ var ContractExclusionRolesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
3769
3773
|
async delete(parentId, id, opts = {}) {
|
|
3770
3774
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3771
3775
|
await this.guardStaleBeforeMutation(id, opts, "contract_exclusion_roles.delete", parentId);
|
|
3772
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3776
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3773
3777
|
}
|
|
3774
3778
|
/** Resolve a ContractExclusionRoles from a numeric id (or, where the vendor indexes a primary text field,
|
|
3775
3779
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3785,7 +3789,7 @@ var ContractExclusionRolesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
3785
3789
|
};
|
|
3786
3790
|
|
|
3787
3791
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
3788
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
3792
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3789
3793
|
constructor(http, pageSize) {
|
|
3790
3794
|
super(http, {
|
|
3791
3795
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -3826,7 +3830,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkIHRXVIUUcjs.
|
|
|
3826
3830
|
async delete(parentId, id, opts = {}) {
|
|
3827
3831
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3828
3832
|
await this.guardStaleBeforeMutation(id, opts, "contract_exclusion_set_excluded_roles.delete", parentId);
|
|
3829
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3833
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3830
3834
|
}
|
|
3831
3835
|
/** Resolve a ContractExclusionSetExcludedRoles from a numeric id (or, where the vendor indexes a primary text field,
|
|
3832
3836
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3842,7 +3846,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkIHRXVIUUcjs.
|
|
|
3842
3846
|
};
|
|
3843
3847
|
|
|
3844
3848
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
3845
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
3849
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3846
3850
|
constructor(http, pageSize) {
|
|
3847
3851
|
super(http, {
|
|
3848
3852
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -3883,7 +3887,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkIHRXVIUU
|
|
|
3883
3887
|
async delete(parentId, id, opts = {}) {
|
|
3884
3888
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
3885
3889
|
await this.guardStaleBeforeMutation(id, opts, "contract_exclusion_set_excluded_work_types.delete", parentId);
|
|
3886
|
-
return this.deleteScopedRaw(parentId, id);
|
|
3890
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
3887
3891
|
}
|
|
3888
3892
|
/** Resolve a ContractExclusionSetExcludedWorkTypes from a numeric id (or, where the vendor indexes a primary text field,
|
|
3889
3893
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -3899,7 +3903,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkIHRXVIUU
|
|
|
3899
3903
|
};
|
|
3900
3904
|
|
|
3901
3905
|
// src/resources/contract_exclusion_sets.ts
|
|
3902
|
-
var ContractExclusionSetsResource = class extends
|
|
3906
|
+
var ContractExclusionSetsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3903
3907
|
constructor(http, pageSize) {
|
|
3904
3908
|
super(http, {
|
|
3905
3909
|
key: "contract_exclusion_sets",
|
|
@@ -3953,7 +3957,7 @@ var ContractExclusionSetsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
3953
3957
|
async delete(id, opts = {}) {
|
|
3954
3958
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
3955
3959
|
await this.guardStaleBeforeMutation(id, opts, "contract_exclusion_sets.delete");
|
|
3956
|
-
return this.deleteGlobal(id);
|
|
3960
|
+
return this.deleteGlobal(id, opts);
|
|
3957
3961
|
}
|
|
3958
3962
|
/** Resolve a ContractExclusionSets from a numeric id (or, where the vendor indexes a primary text field,
|
|
3959
3963
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -3973,7 +3977,7 @@ var ContractExclusionSetsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
3973
3977
|
};
|
|
3974
3978
|
|
|
3975
3979
|
// src/resources/contract_milestones.ts
|
|
3976
|
-
var ContractMilestonesResource = class extends
|
|
3980
|
+
var ContractMilestonesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
3977
3981
|
constructor(http, pageSize) {
|
|
3978
3982
|
super(http, {
|
|
3979
3983
|
key: "contract_milestones",
|
|
@@ -4016,7 +4020,7 @@ var ContractMilestonesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4016
4020
|
async update(parentId, id, data, opts = {}) {
|
|
4017
4021
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4018
4022
|
await this.guardStaleBeforeMutation(id, opts, "contract_milestones.update", parentId);
|
|
4019
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4023
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4020
4024
|
}
|
|
4021
4025
|
/** Resolve a ContractMilestone from a numeric id (or, where the vendor indexes a primary text field,
|
|
4022
4026
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4032,7 +4036,7 @@ var ContractMilestonesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4032
4036
|
};
|
|
4033
4037
|
|
|
4034
4038
|
// src/resources/contract_notes.ts
|
|
4035
|
-
var ContractNotesResource = class extends
|
|
4039
|
+
var ContractNotesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4036
4040
|
constructor(http, pageSize) {
|
|
4037
4041
|
super(http, {
|
|
4038
4042
|
key: "contract_notes",
|
|
@@ -4075,7 +4079,7 @@ var ContractNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4075
4079
|
async update(parentId, id, data, opts = {}) {
|
|
4076
4080
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4077
4081
|
await this.guardStaleBeforeMutation(id, opts, "contract_notes.update", parentId);
|
|
4078
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4082
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4079
4083
|
}
|
|
4080
4084
|
/** Resolve a ContractNote from a numeric id (or, where the vendor indexes a primary text field,
|
|
4081
4085
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4091,7 +4095,7 @@ var ContractNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4091
4095
|
};
|
|
4092
4096
|
|
|
4093
4097
|
// src/resources/contract_rates.ts
|
|
4094
|
-
var ContractRatesResource = class extends
|
|
4098
|
+
var ContractRatesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4095
4099
|
constructor(http, pageSize) {
|
|
4096
4100
|
super(http, {
|
|
4097
4101
|
key: "contract_rates",
|
|
@@ -4134,7 +4138,7 @@ var ContractRatesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4134
4138
|
async update(parentId, id, data, opts = {}) {
|
|
4135
4139
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4136
4140
|
await this.guardStaleBeforeMutation(id, opts, "contract_rates.update", parentId);
|
|
4137
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4141
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4138
4142
|
}
|
|
4139
4143
|
/** Resolve a ContractRate from a numeric id (or, where the vendor indexes a primary text field,
|
|
4140
4144
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4150,7 +4154,7 @@ var ContractRatesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4150
4154
|
};
|
|
4151
4155
|
|
|
4152
4156
|
// src/resources/contract_retainers.ts
|
|
4153
|
-
var ContractRetainersResource = class extends
|
|
4157
|
+
var ContractRetainersResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4154
4158
|
constructor(http, pageSize) {
|
|
4155
4159
|
super(http, {
|
|
4156
4160
|
key: "contract_retainers",
|
|
@@ -4193,7 +4197,7 @@ var ContractRetainersResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4193
4197
|
async update(parentId, id, data, opts = {}) {
|
|
4194
4198
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4195
4199
|
await this.guardStaleBeforeMutation(id, opts, "contract_retainers.update", parentId);
|
|
4196
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4200
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4197
4201
|
}
|
|
4198
4202
|
/** Resolve a ContractRetainers from a numeric id (or, where the vendor indexes a primary text field,
|
|
4199
4203
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4209,7 +4213,7 @@ var ContractRetainersResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4209
4213
|
};
|
|
4210
4214
|
|
|
4211
4215
|
// src/resources/contract_role_costs.ts
|
|
4212
|
-
var ContractRoleCostsResource = class extends
|
|
4216
|
+
var ContractRoleCostsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4213
4217
|
constructor(http, pageSize) {
|
|
4214
4218
|
super(http, {
|
|
4215
4219
|
key: "contract_role_costs",
|
|
@@ -4252,7 +4256,7 @@ var ContractRoleCostsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4252
4256
|
async update(parentId, id, data, opts = {}) {
|
|
4253
4257
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4254
4258
|
await this.guardStaleBeforeMutation(id, opts, "contract_role_costs.update", parentId);
|
|
4255
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4259
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4256
4260
|
}
|
|
4257
4261
|
/** Resolve a ContractRoleCosts from a numeric id (or, where the vendor indexes a primary text field,
|
|
4258
4262
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4268,7 +4272,7 @@ var ContractRoleCostsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4268
4272
|
};
|
|
4269
4273
|
|
|
4270
4274
|
// src/resources/contract_service_adjustments.ts
|
|
4271
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4275
|
+
var ContractServiceAdjustmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4272
4276
|
constructor(http, pageSize) {
|
|
4273
4277
|
super(http, {
|
|
4274
4278
|
key: "contract_service_adjustments",
|
|
@@ -4302,7 +4306,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkIHRXVIUUcjs.BaseRes
|
|
|
4302
4306
|
};
|
|
4303
4307
|
|
|
4304
4308
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4305
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4309
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4306
4310
|
constructor(http, pageSize) {
|
|
4307
4311
|
super(http, {
|
|
4308
4312
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4336,7 +4340,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkIHRXVIUUcjs.B
|
|
|
4336
4340
|
};
|
|
4337
4341
|
|
|
4338
4342
|
// src/resources/contract_service_bundles.ts
|
|
4339
|
-
var ContractServiceBundlesResource = class extends
|
|
4343
|
+
var ContractServiceBundlesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4340
4344
|
constructor(http, pageSize) {
|
|
4341
4345
|
super(http, {
|
|
4342
4346
|
key: "contract_service_bundles",
|
|
@@ -4379,7 +4383,7 @@ var ContractServiceBundlesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
4379
4383
|
async update(parentId, id, data, opts = {}) {
|
|
4380
4384
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4381
4385
|
await this.guardStaleBeforeMutation(id, opts, "contract_service_bundles.update", parentId);
|
|
4382
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4386
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4383
4387
|
}
|
|
4384
4388
|
/** Resolve a ContractServiceBundle from a numeric id (or, where the vendor indexes a primary text field,
|
|
4385
4389
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4395,7 +4399,7 @@ var ContractServiceBundlesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
4395
4399
|
};
|
|
4396
4400
|
|
|
4397
4401
|
// src/resources/contract_service_bundle_units.ts
|
|
4398
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4402
|
+
var ContractServiceBundleUnitsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4399
4403
|
constructor(http, pageSize) {
|
|
4400
4404
|
super(http, {
|
|
4401
4405
|
key: "contract_service_bundle_units",
|
|
@@ -4437,7 +4441,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkIHRXVIUUcjs.BaseRes
|
|
|
4437
4441
|
};
|
|
4438
4442
|
|
|
4439
4443
|
// src/resources/contract_services.ts
|
|
4440
|
-
var ContractServicesResource = class extends
|
|
4444
|
+
var ContractServicesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4441
4445
|
constructor(http, pageSize) {
|
|
4442
4446
|
super(http, {
|
|
4443
4447
|
key: "contract_services",
|
|
@@ -4480,7 +4484,7 @@ var ContractServicesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4480
4484
|
async update(parentId, id, data, opts = {}) {
|
|
4481
4485
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
4482
4486
|
await this.guardStaleBeforeMutation(id, opts, "contract_services.update", parentId);
|
|
4483
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
4487
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
4484
4488
|
}
|
|
4485
4489
|
/** Resolve a ContractService from a numeric id (or, where the vendor indexes a primary text field,
|
|
4486
4490
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -4496,7 +4500,7 @@ var ContractServicesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
4496
4500
|
};
|
|
4497
4501
|
|
|
4498
4502
|
// src/resources/contract_service_units.ts
|
|
4499
|
-
var ContractServiceUnitsResource = class extends
|
|
4503
|
+
var ContractServiceUnitsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
4500
4504
|
constructor(http, pageSize) {
|
|
4501
4505
|
super(http, {
|
|
4502
4506
|
key: "contract_service_units",
|
|
@@ -4549,7 +4553,8 @@ var PROFITABILITY_OPT_KEYS = [
|
|
|
4549
4553
|
"groupByActivity",
|
|
4550
4554
|
"staleAfterDays",
|
|
4551
4555
|
"maxTicketsForJoin",
|
|
4552
|
-
"limit"
|
|
4556
|
+
"limit",
|
|
4557
|
+
"includeRows"
|
|
4553
4558
|
];
|
|
4554
4559
|
var LABOUR_METHOD_SET = [
|
|
4555
4560
|
"billing_item_our_cost",
|
|
@@ -4687,8 +4692,8 @@ function dateToDay(v) {
|
|
|
4687
4692
|
}
|
|
4688
4693
|
function validateProfitabilityOptions(contractId, opts) {
|
|
4689
4694
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
4690
|
-
throw new (0,
|
|
4691
|
-
`profitability: opts
|
|
4695
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
4696
|
+
`profitability: opts is required \u2014 the options object with dateFrom and dateTo (YYYY-MM-DD) (got ${opts === void 0 ? "undefined" : Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
4692
4697
|
{ operation: "contracts.profitability" }
|
|
4693
4698
|
);
|
|
4694
4699
|
}
|
|
@@ -4728,7 +4733,7 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
4728
4733
|
if (method === "provided" && rate === null) {
|
|
4729
4734
|
problems.push(`labourRatePerHour is required (finite number >= 0) when labourCostMethod is "provided" (got ${String(opts.labourRatePerHour)})`);
|
|
4730
4735
|
}
|
|
4731
|
-
for (const key of ["includeRecurringCosts", "includeUnbilledRevenue", "groupByActivity"]) {
|
|
4736
|
+
for (const key of ["includeRecurringCosts", "includeUnbilledRevenue", "groupByActivity", "includeRows"]) {
|
|
4732
4737
|
const v = opts[key];
|
|
4733
4738
|
if (v !== void 0 && typeof v !== "boolean") problems.push(`${key} must be a boolean (got ${String(v)})`);
|
|
4734
4739
|
}
|
|
@@ -4764,12 +4769,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
4764
4769
|
}
|
|
4765
4770
|
}
|
|
4766
4771
|
try {
|
|
4767
|
-
|
|
4772
|
+
_chunkXSIY3WRRcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
4768
4773
|
} catch (err) {
|
|
4769
|
-
problems.push(err instanceof
|
|
4774
|
+
problems.push(err instanceof _chunkXSIY3WRRcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
4770
4775
|
}
|
|
4771
4776
|
if (problems.length > 0) {
|
|
4772
|
-
throw new (0,
|
|
4777
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
4773
4778
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
4774
4779
|
- ` + problems.join("\n- "),
|
|
4775
4780
|
{ operation: "contracts.profitability" }
|
|
@@ -4786,7 +4791,8 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
4786
4791
|
groupByActivity: _nullishCoalesce(opts.groupByActivity, () => ( true)),
|
|
4787
4792
|
staleAfterDays: stale,
|
|
4788
4793
|
maxTicketsForJoin: mtj,
|
|
4789
|
-
limit
|
|
4794
|
+
limit,
|
|
4795
|
+
includeRows: _nullishCoalesce(opts.includeRows, () => ( false))
|
|
4790
4796
|
};
|
|
4791
4797
|
}
|
|
4792
4798
|
async function boundedPart2(http, path, conditions, limit, operation, includeFields) {
|
|
@@ -4799,7 +4805,7 @@ async function boundedPart2(http, path, conditions, limit, operation, includeFie
|
|
|
4799
4805
|
body,
|
|
4800
4806
|
operation
|
|
4801
4807
|
});
|
|
4802
|
-
const { items, pageDetails } =
|
|
4808
|
+
const { items, pageDetails } = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res, operation);
|
|
4803
4809
|
const capped = items.length >= limit;
|
|
4804
4810
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
4805
4811
|
}
|
|
@@ -4813,23 +4819,23 @@ async function fetchByIdsPart(http, entityPath, ids, fields, operation) {
|
|
|
4813
4819
|
const byKey = /* @__PURE__ */ new Map();
|
|
4814
4820
|
const misses = [];
|
|
4815
4821
|
const notes = [];
|
|
4816
|
-
for (let c = 0; c < unique.length; c +=
|
|
4817
|
-
const chunk = unique.slice(c, c +
|
|
4822
|
+
for (let c = 0; c < unique.length; c += _chunkXSIY3WRRcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
4823
|
+
const chunk = unique.slice(c, c + _chunkXSIY3WRRcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
4818
4824
|
const chunkKeys = new Set(chunk);
|
|
4819
4825
|
try {
|
|
4820
4826
|
const body = {
|
|
4821
|
-
MaxRecords:
|
|
4827
|
+
MaxRecords: _chunkXSIY3WRRcjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
4822
4828
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
4823
4829
|
IncludeFields: fields
|
|
4824
4830
|
};
|
|
4825
4831
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
4826
|
-
const { items: rows } =
|
|
4832
|
+
const { items: rows } = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res, operation);
|
|
4827
4833
|
for (const row of rows) {
|
|
4828
4834
|
const k = num2(row.id);
|
|
4829
4835
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
4830
4836
|
}
|
|
4831
4837
|
} catch (err) {
|
|
4832
|
-
const code = err instanceof
|
|
4838
|
+
const code = err instanceof _chunkXSIY3WRRcjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
4833
4839
|
for (const k of chunk) {
|
|
4834
4840
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
4835
4841
|
}
|
|
@@ -4839,11 +4845,11 @@ async function fetchByIdsPart(http, entityPath, ids, fields, operation) {
|
|
|
4839
4845
|
for (const k of queryMissed) {
|
|
4840
4846
|
try {
|
|
4841
4847
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
4842
|
-
byKey.set(k,
|
|
4848
|
+
byKey.set(k, _chunkXSIY3WRRcjs.unwrapItem.call(void 0, res, k, operation));
|
|
4843
4849
|
} catch (err) {
|
|
4844
|
-
if (err instanceof
|
|
4850
|
+
if (err instanceof _chunkXSIY3WRRcjs.NotFoundError) {
|
|
4845
4851
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
4846
|
-
} else if (err instanceof
|
|
4852
|
+
} else if (err instanceof _chunkXSIY3WRRcjs.AutotaskError) {
|
|
4847
4853
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
4848
4854
|
} else {
|
|
4849
4855
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -4966,7 +4972,7 @@ async function degradable(read) {
|
|
|
4966
4972
|
try {
|
|
4967
4973
|
return await read();
|
|
4968
4974
|
} catch (err) {
|
|
4969
|
-
if (!(err instanceof
|
|
4975
|
+
if (!(err instanceof _chunkXSIY3WRRcjs.AutotaskError)) throw err;
|
|
4970
4976
|
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
4971
4977
|
}
|
|
4972
4978
|
}
|
|
@@ -4985,9 +4991,9 @@ function dedupeSortCap(ids, limit) {
|
|
|
4985
4991
|
return [...new Set(ids)].sort((a, b) => Number(a) - Number(b)).slice(0, limit);
|
|
4986
4992
|
}
|
|
4987
4993
|
async function profitability(resource, contractId, opts, rawHttp) {
|
|
4988
|
-
const v = validateProfitabilityOptions(contractId,
|
|
4994
|
+
const v = validateProfitabilityOptions(contractId, opts);
|
|
4989
4995
|
const OP2 = "contracts.profitability";
|
|
4990
|
-
const id =
|
|
4996
|
+
const id = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
4991
4997
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
4992
4998
|
const wires = { issued: 0, requests: 0, budget: PROFITABILITY_WIRE_BUDGET };
|
|
4993
4999
|
const asOf = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -5015,7 +5021,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5015
5021
|
status: st.status,
|
|
5016
5022
|
blindSurface: st.blindSurface,
|
|
5017
5023
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
5018
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5024
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkXSIY3WRRcjs.EMPTY_REASON_STAMPS, 'access', _31 => _31[key], 'optionalAccess', _32 => _32.query]) : void 0
|
|
5019
5025
|
};
|
|
5020
5026
|
};
|
|
5021
5027
|
const truncatedMonths = {};
|
|
@@ -5028,7 +5034,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5028
5034
|
truncatedMonths[name] = tm;
|
|
5029
5035
|
return { part, rows: wp.items };
|
|
5030
5036
|
};
|
|
5031
|
-
const contractCached = _optionalChain([rawHttp, 'access',
|
|
5037
|
+
const contractCached = _optionalChain([rawHttp, 'access', _33 => _33.readCache, 'optionalAccess', _34 => _34.get, 'call', _35 => _35(`/V1.0/Contracts/${id}`)]) !== void 0;
|
|
5032
5038
|
const contract = await resource.get(id);
|
|
5033
5039
|
wires.issued += 1;
|
|
5034
5040
|
if (!contractCached) wires.requests += 1;
|
|
@@ -5045,12 +5051,12 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5045
5051
|
path: `/V1.0/Companies/${companyID}`,
|
|
5046
5052
|
operation: OP2
|
|
5047
5053
|
});
|
|
5048
|
-
const item =
|
|
5054
|
+
const item = _chunkXSIY3WRRcjs.unwrapItem.call(void 0, res, companyID, OP2);
|
|
5049
5055
|
customer = _nullishCoalesce(item, () => ( null));
|
|
5050
5056
|
customerStatus = "ok";
|
|
5051
5057
|
} catch (err) {
|
|
5052
|
-
if (!(err instanceof
|
|
5053
|
-
if (!(err instanceof
|
|
5058
|
+
if (!(err instanceof _chunkXSIY3WRRcjs.AutotaskError)) throw err;
|
|
5059
|
+
if (!(err instanceof _chunkXSIY3WRRcjs.NotFoundError)) {
|
|
5054
5060
|
customerStatus = "absent";
|
|
5055
5061
|
customerAbsent = err.code;
|
|
5056
5062
|
}
|
|
@@ -5061,9 +5067,9 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5061
5067
|
if (contractType > 0) {
|
|
5062
5068
|
wires.issued += 1;
|
|
5063
5069
|
try {
|
|
5064
|
-
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(http, "/V1.0/Contracts", OP2)), 'access', async
|
|
5070
|
+
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(http, "/V1.0/Contracts", OP2)), 'access', async _36 => _36.get, 'call', async _37 => _37("contractType"), 'optionalAccess', async _38 => _38.get, 'call', async _39 => _39(contractType)]), async () => ( null));
|
|
5065
5071
|
} catch (err) {
|
|
5066
|
-
if (!(err instanceof
|
|
5072
|
+
if (!(err instanceof _chunkXSIY3WRRcjs.AutotaskError)) throw err;
|
|
5067
5073
|
}
|
|
5068
5074
|
}
|
|
5069
5075
|
const contractTypeKnown = contractTypeLabel !== null;
|
|
@@ -5110,8 +5116,8 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5110
5116
|
if (invoiceIds.length === 0) {
|
|
5111
5117
|
invoicesPart = skipPart("skipped: the billing part has no invoiceIDs (zero wire)");
|
|
5112
5118
|
} else {
|
|
5113
|
-
const capped = capJoinSet2(invoiceIds,
|
|
5114
|
-
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `invoiceJoinTruncated: the join set is capped at ${
|
|
5119
|
+
const capped = capJoinSet2(invoiceIds, _chunkXSIY3WRRcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5120
|
+
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `invoiceJoinTruncated: the join set is capped at ${_chunkXSIY3WRRcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
|
|
5115
5121
|
const fb = await fetchByIdsPart(http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], OP2);
|
|
5116
5122
|
wires.issued += 1;
|
|
5117
5123
|
invoices = fb.items;
|
|
@@ -5143,7 +5149,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5143
5149
|
}
|
|
5144
5150
|
}
|
|
5145
5151
|
} catch (err) {
|
|
5146
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof
|
|
5152
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkXSIY3WRRcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5147
5153
|
}
|
|
5148
5154
|
let ticketsOpenPart;
|
|
5149
5155
|
let openTickets = [];
|
|
@@ -5162,8 +5168,8 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5162
5168
|
if (resourceIds.length === 0) {
|
|
5163
5169
|
resourcesPart = skipPart("skipped: the time part has no resourceIDs (zero wire)");
|
|
5164
5170
|
} else {
|
|
5165
|
-
const capped = capJoinSet2(resourceIds,
|
|
5166
|
-
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `resourceJoinTruncated: the join set is capped at ${
|
|
5171
|
+
const capped = capJoinSet2(resourceIds, _chunkXSIY3WRRcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5172
|
+
if (capped.truncated) wires.note = (wires.note ? wires.note + " | " : "") + `resourceJoinTruncated: the join set is capped at ${_chunkXSIY3WRRcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`;
|
|
5167
5173
|
const fb = await fetchByIdsPart(http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], OP2);
|
|
5168
5174
|
wires.issued += 1;
|
|
5169
5175
|
resources = fb.items;
|
|
@@ -5220,7 +5226,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5220
5226
|
if (cis.length === 0) {
|
|
5221
5227
|
subscriptionsPart = skipPart("skipped: the CI join found no configuration items \u2014 the subscriptions part is not evaluable (zero wire)");
|
|
5222
5228
|
} else {
|
|
5223
|
-
const ciIds = capJoinSet2(cis.map((c) => num2(c["id"])).filter((n) => n > 0),
|
|
5229
|
+
const ciIds = capJoinSet2(cis.map((c) => num2(c["id"])).filter((n) => n > 0), _chunkXSIY3WRRcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5224
5230
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5225
5231
|
const raw = await readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5226
5232
|
subscriptions = raw.items;
|
|
@@ -5230,15 +5236,15 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5230
5236
|
try {
|
|
5231
5237
|
labels = await readPicklists(http, "/V1.0/Subscriptions", OP2);
|
|
5232
5238
|
} catch (err) {
|
|
5233
|
-
if (!(err instanceof
|
|
5239
|
+
if (!(err instanceof _chunkXSIY3WRRcjs.AutotaskError)) throw err;
|
|
5234
5240
|
}
|
|
5235
5241
|
}
|
|
5236
5242
|
for (const x of subscriptions) {
|
|
5237
5243
|
const sid = num2(x["id"]);
|
|
5238
|
-
const periodLabel = _optionalChain([labels, 'optionalAccess',
|
|
5244
|
+
const periodLabel = _optionalChain([labels, 'optionalAccess', _40 => _40.get, 'call', _41 => _41("periodType"), 'optionalAccess', _42 => _42.get, 'call', _43 => _43(num2(x["periodType"]))]);
|
|
5239
5245
|
subFactor.set(sid, periodMonthlyFactor(x["periodType"], periodLabel));
|
|
5240
5246
|
if (isOneTimePeriod(x["periodType"], periodLabel)) oneTimeSubs.add(sid);
|
|
5241
|
-
const statusLabel = _optionalChain([labels, 'optionalAccess',
|
|
5247
|
+
const statusLabel = _optionalChain([labels, 'optionalAccess', _44 => _44.get, 'call', _45 => _45("status"), 'optionalAccess', _46 => _46.get, 'call', _47 => _47(num2(x["status"]))]);
|
|
5242
5248
|
const notActive = statusLabel !== void 0 ? NOT_ACTIVE_LABEL_RE.test(statusLabel) : labels === null && SUBSCRIPTION_NOT_ACTIVE_STATUS_IDS.has(num2(x["status"]));
|
|
5243
5249
|
if (notActive) cancelledSubs.add(sid);
|
|
5244
5250
|
}
|
|
@@ -5403,17 +5409,20 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5403
5409
|
else labourTotal += _nullishCoalesce(r.cost, () => ( 0));
|
|
5404
5410
|
}
|
|
5405
5411
|
const unposted = mEntries.filter((e) => e["isNonBillable"] !== true && !billedByEntryId.has(num2(e["id"])));
|
|
5406
|
-
const
|
|
5412
|
+
const hoursMissing = unposted.some((e) => typeof e["hoursToBill"] !== "number" || !Number.isFinite(e["hoursToBill"]));
|
|
5413
|
+
const hoursPart = hoursMissing ? { entries: unposted.length, hours: null, hoursAbsent: "HOURS_TO_BILL_MISSING" } : { entries: unposted.length, hours: unposted.reduce((a, e) => a + Math.max(0, num2(e["hoursToBill"])), 0) };
|
|
5407
5414
|
let unpostedTime;
|
|
5408
5415
|
if (!contractTypeKnown) {
|
|
5409
|
-
unpostedTime = {
|
|
5416
|
+
unpostedTime = { ...hoursPart, value: null, absent: "CONTRACT_TYPE_UNKNOWN" };
|
|
5410
5417
|
} else if (!isTimeAndMaterials) {
|
|
5411
|
-
unpostedTime = {
|
|
5418
|
+
unpostedTime = { ...hoursPart, value: null, absent: "NOT_TIME_AND_MATERIALS_CONTRACT" };
|
|
5412
5419
|
} else if (unposted.some((e) => !contractRateByRole.has(num2(e["roleID"])))) {
|
|
5413
|
-
unpostedTime = {
|
|
5420
|
+
unpostedTime = { ...hoursPart, value: null, absent: "NO_CONTRACT_RATE" };
|
|
5421
|
+
} else if (hoursMissing) {
|
|
5422
|
+
unpostedTime = { ...hoursPart, value: null, absent: "HOURS_TO_BILL_MISSING" };
|
|
5414
5423
|
} else {
|
|
5415
5424
|
const value = unposted.reduce((a, e) => a + Math.max(0, num2(e["hoursToBill"])) * contractRateByRole.get(num2(e["roleID"])), 0);
|
|
5416
|
-
unpostedTime = {
|
|
5425
|
+
unpostedTime = { ...hoursPart, value };
|
|
5417
5426
|
}
|
|
5418
5427
|
let toolingVendor = subscriptionsPart.status === "skipped" || subscriptionsPart.status === "absent" ? null : 0;
|
|
5419
5428
|
if (toolingVendor !== null) {
|
|
@@ -5725,6 +5734,11 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5725
5734
|
const purchasedHours = blocks.reduce((a, b) => a + num2(b["hours"]), 0);
|
|
5726
5735
|
const approvedHours = blocks.reduce((a, b) => a + num2(b["hoursApproved"]), 0);
|
|
5727
5736
|
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 } };
|
|
5737
|
+
const rows = (part) => {
|
|
5738
|
+
if (v.includeRows) return part;
|
|
5739
|
+
const { items, ...stamps } = part;
|
|
5740
|
+
return { ...stamps, rows_fetched: items.length };
|
|
5741
|
+
};
|
|
5728
5742
|
return {
|
|
5729
5743
|
contract,
|
|
5730
5744
|
customer,
|
|
@@ -5763,28 +5777,28 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
5763
5777
|
configurationItems: configurationItemsPart.status,
|
|
5764
5778
|
subscriptions: subscriptionsPart.status
|
|
5765
5779
|
},
|
|
5766
|
-
contractServices: servicesPart,
|
|
5767
|
-
contractServiceUnits: unitsPart,
|
|
5768
|
-
contractCharges: chargesPart,
|
|
5769
|
-
contractRoleCosts: roleCostsPart,
|
|
5770
|
-
contractRates: ratesPart,
|
|
5771
|
-
contractBlocks: blocksPart,
|
|
5772
|
-
billingItems,
|
|
5773
|
-
invoices: invoicesPart,
|
|
5774
|
-
timeEntries,
|
|
5775
|
-
ticketsActivity: ticketsActivityPart,
|
|
5776
|
-
ticketsOpen: ticketsOpenPart,
|
|
5777
|
-
resources: resourcesPart,
|
|
5778
|
-
expenses: expensesPart,
|
|
5779
|
-
miscodingProbe: probePart,
|
|
5780
|
-
configurationItems: configurationItemsPart,
|
|
5781
|
-
subscriptions: subscriptionsPart,
|
|
5780
|
+
contractServices: rows(servicesPart),
|
|
5781
|
+
contractServiceUnits: rows(unitsPart),
|
|
5782
|
+
contractCharges: rows(chargesPart),
|
|
5783
|
+
contractRoleCosts: rows(roleCostsPart),
|
|
5784
|
+
contractRates: rows(ratesPart),
|
|
5785
|
+
contractBlocks: rows(blocksPart),
|
|
5786
|
+
billingItems: rows(billingItems),
|
|
5787
|
+
invoices: rows(invoicesPart),
|
|
5788
|
+
timeEntries: rows(timeEntries),
|
|
5789
|
+
ticketsActivity: rows(ticketsActivityPart),
|
|
5790
|
+
ticketsOpen: rows(ticketsOpenPart),
|
|
5791
|
+
resources: rows(resourcesPart),
|
|
5792
|
+
expenses: rows(expensesPart),
|
|
5793
|
+
miscodingProbe: rows(probePart),
|
|
5794
|
+
configurationItems: rows(configurationItemsPart),
|
|
5795
|
+
subscriptions: rows(subscriptionsPart),
|
|
5782
5796
|
wires: { issued: wires.issued, requests: wires.requests, budget: wires.budget, note: wires.note }
|
|
5783
5797
|
};
|
|
5784
5798
|
}
|
|
5785
5799
|
|
|
5786
5800
|
// src/resources/contracts.ts
|
|
5787
|
-
var ContractsResource = class extends
|
|
5801
|
+
var ContractsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
5788
5802
|
constructor(http, pageSize) {
|
|
5789
5803
|
super(http, {
|
|
5790
5804
|
key: "contracts",
|
|
@@ -5855,7 +5869,7 @@ var ContractsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
5855
5869
|
};
|
|
5856
5870
|
|
|
5857
5871
|
// src/resources/contract_ticket_purchases.ts
|
|
5858
|
-
var ContractTicketPurchasesResource = class extends
|
|
5872
|
+
var ContractTicketPurchasesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
5859
5873
|
constructor(http, pageSize) {
|
|
5860
5874
|
super(http, {
|
|
5861
5875
|
key: "contract_ticket_purchases",
|
|
@@ -5898,7 +5912,7 @@ var ContractTicketPurchasesResource = class extends _chunkIHRXVIUUcjs.BaseResour
|
|
|
5898
5912
|
async update(parentId, id, data, opts = {}) {
|
|
5899
5913
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
5900
5914
|
await this.guardStaleBeforeMutation(id, opts, "contract_ticket_purchases.update", parentId);
|
|
5901
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
5915
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
5902
5916
|
}
|
|
5903
5917
|
/** Resolve a ContractTicketPurchases from a numeric id (or, where the vendor indexes a primary text field,
|
|
5904
5918
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -5914,7 +5928,7 @@ var ContractTicketPurchasesResource = class extends _chunkIHRXVIUUcjs.BaseResour
|
|
|
5914
5928
|
};
|
|
5915
5929
|
|
|
5916
5930
|
// src/resources/countries.ts
|
|
5917
|
-
var CountriesResource = class extends
|
|
5931
|
+
var CountriesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
5918
5932
|
constructor(http, pageSize) {
|
|
5919
5933
|
super(http, {
|
|
5920
5934
|
key: "countries",
|
|
@@ -5973,7 +5987,7 @@ var CountriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
5973
5987
|
};
|
|
5974
5988
|
|
|
5975
5989
|
// src/resources/departments.ts
|
|
5976
|
-
var DepartmentsResource = class extends
|
|
5990
|
+
var DepartmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
5977
5991
|
constructor(http, pageSize) {
|
|
5978
5992
|
super(http, {
|
|
5979
5993
|
key: "departments",
|
|
@@ -6040,7 +6054,7 @@ var DepartmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6040
6054
|
};
|
|
6041
6055
|
|
|
6042
6056
|
// src/resources/domain_registrars.ts
|
|
6043
|
-
var DomainRegistrarsResource = class extends
|
|
6057
|
+
var DomainRegistrarsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6044
6058
|
constructor(http, pageSize) {
|
|
6045
6059
|
super(http, {
|
|
6046
6060
|
key: "domain_registrars",
|
|
@@ -6123,7 +6137,7 @@ var EntityInformationResource = class {
|
|
|
6123
6137
|
};
|
|
6124
6138
|
|
|
6125
6139
|
// src/resources/expense_item_attachments.ts
|
|
6126
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6140
|
+
var ExpenseItemAttachmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6127
6141
|
constructor(http, pageSize) {
|
|
6128
6142
|
super(http, {
|
|
6129
6143
|
key: "expense_item_attachments",
|
|
@@ -6165,7 +6179,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
6165
6179
|
async delete(parentId, id, opts = {}) {
|
|
6166
6180
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
6167
6181
|
await this.guardStaleBeforeMutation(id, opts, "expense_item_attachments.delete", parentId);
|
|
6168
|
-
return this.deleteScopedModel(parentId, id);
|
|
6182
|
+
return this.deleteScopedModel(parentId, id, opts);
|
|
6169
6183
|
}
|
|
6170
6184
|
/** Download the attachment bytes (GET .../{id}/data; node-proven path, quirk #9) → Buffer. */
|
|
6171
6185
|
async download(parentId, id) {
|
|
@@ -6185,7 +6199,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
6185
6199
|
};
|
|
6186
6200
|
|
|
6187
6201
|
// src/resources/expense_items.ts
|
|
6188
|
-
var ExpenseItemsResource = class extends
|
|
6202
|
+
var ExpenseItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6189
6203
|
constructor(http, pageSize) {
|
|
6190
6204
|
super(http, {
|
|
6191
6205
|
key: "expense_items",
|
|
@@ -6228,7 +6242,7 @@ var ExpenseItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6228
6242
|
async update(parentId, id, data, opts = {}) {
|
|
6229
6243
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
6230
6244
|
await this.guardStaleBeforeMutation(id, opts, "expense_items.update", parentId);
|
|
6231
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
6245
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
6232
6246
|
}
|
|
6233
6247
|
/** Resolve a ExpenseItem from a numeric id (or, where the vendor indexes a primary text field,
|
|
6234
6248
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -6244,7 +6258,7 @@ var ExpenseItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6244
6258
|
};
|
|
6245
6259
|
|
|
6246
6260
|
// src/resources/expense_reports.ts
|
|
6247
|
-
var ExpenseReportsResource = class extends
|
|
6261
|
+
var ExpenseReportsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6248
6262
|
constructor(http, pageSize) {
|
|
6249
6263
|
super(http, {
|
|
6250
6264
|
key: "expense_reports",
|
|
@@ -6311,7 +6325,7 @@ var ExpenseReportsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6311
6325
|
};
|
|
6312
6326
|
|
|
6313
6327
|
// src/resources/holiday_sets.ts
|
|
6314
|
-
var HolidaySetsResource = class extends
|
|
6328
|
+
var HolidaySetsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6315
6329
|
constructor(http, pageSize) {
|
|
6316
6330
|
super(http, {
|
|
6317
6331
|
key: "holiday_sets",
|
|
@@ -6364,7 +6378,7 @@ var HolidaySetsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6364
6378
|
async delete(id, opts = {}) {
|
|
6365
6379
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
6366
6380
|
await this.guardStaleBeforeMutation(id, opts, "holiday_sets.delete");
|
|
6367
|
-
return this.deleteGlobal(id);
|
|
6381
|
+
return this.deleteGlobal(id, opts);
|
|
6368
6382
|
}
|
|
6369
6383
|
/** Resolve a HolidaySet from a numeric id (or, where the vendor indexes a primary text field,
|
|
6370
6384
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -6380,7 +6394,7 @@ var HolidaySetsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6380
6394
|
};
|
|
6381
6395
|
|
|
6382
6396
|
// src/resources/holidays.ts
|
|
6383
|
-
var HolidaysResource = class extends
|
|
6397
|
+
var HolidaysResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6384
6398
|
constructor(http, pageSize) {
|
|
6385
6399
|
super(http, {
|
|
6386
6400
|
key: "holidays",
|
|
@@ -6423,14 +6437,14 @@ var HolidaysResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6423
6437
|
async update(parentId, id, data, opts = {}) {
|
|
6424
6438
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
6425
6439
|
await this.guardStaleBeforeMutation(id, opts, "holidays.update", parentId);
|
|
6426
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
6440
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
6427
6441
|
}
|
|
6428
6442
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
6429
6443
|
* envelope and never issues the delete. */
|
|
6430
6444
|
async delete(parentId, id, opts = {}) {
|
|
6431
6445
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
6432
6446
|
await this.guardStaleBeforeMutation(id, opts, "holidays.delete", parentId);
|
|
6433
|
-
return this.deleteScopedRaw(parentId, id);
|
|
6447
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
6434
6448
|
}
|
|
6435
6449
|
/** Resolve a Holiday from a numeric id (or, where the vendor indexes a primary text field,
|
|
6436
6450
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -6452,10 +6466,10 @@ var PATH_SUFFIX = {
|
|
|
6452
6466
|
transfer: "StockedItemsTransfer"
|
|
6453
6467
|
};
|
|
6454
6468
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6455
|
-
const numericParent =
|
|
6469
|
+
const numericParent = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6456
6470
|
const suffix = PATH_SUFFIX[kind];
|
|
6457
6471
|
if (opts.dryRun === true) {
|
|
6458
|
-
return
|
|
6472
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
6459
6473
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6460
6474
|
method: "POST",
|
|
6461
6475
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6469,13 +6483,14 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6469
6483
|
method: "POST",
|
|
6470
6484
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
6471
6485
|
body: data,
|
|
6472
|
-
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}
|
|
6486
|
+
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6487
|
+
maxRetries: opts.maxRetries
|
|
6473
6488
|
});
|
|
6474
|
-
return
|
|
6489
|
+
return _chunkXSIY3WRRcjs.unwrapOperation.call(void 0, res);
|
|
6475
6490
|
}
|
|
6476
6491
|
|
|
6477
6492
|
// src/resources/inventory_products.ts
|
|
6478
|
-
var InventoryProductsResource = class extends
|
|
6493
|
+
var InventoryProductsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6479
6494
|
constructor(http, pageSize) {
|
|
6480
6495
|
super(http, {
|
|
6481
6496
|
key: "inventory_products",
|
|
@@ -6528,7 +6543,7 @@ var InventoryProductsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6528
6543
|
async delete(id, opts = {}) {
|
|
6529
6544
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
6530
6545
|
await this.guardStaleBeforeMutation(id, opts, "inventory_products.delete");
|
|
6531
|
-
return this.deleteGlobal(id);
|
|
6546
|
+
return this.deleteGlobal(id, opts);
|
|
6532
6547
|
}
|
|
6533
6548
|
/** Resolve a InventoryProduct from a numeric id (or, where the vendor indexes a primary text field,
|
|
6534
6549
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -6557,7 +6572,7 @@ var InventoryProductsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6557
6572
|
|
|
6558
6573
|
// src/resources/special/invoices.ts
|
|
6559
6574
|
async function markup(_resource, id, format, http) {
|
|
6560
|
-
const numericId =
|
|
6575
|
+
const numericId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
6561
6576
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
6562
6577
|
const res = await http.request({
|
|
6563
6578
|
method: "GET",
|
|
@@ -6566,7 +6581,7 @@ async function markup(_resource, id, format, http) {
|
|
|
6566
6581
|
});
|
|
6567
6582
|
const body = res;
|
|
6568
6583
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
6569
|
-
throw new (0,
|
|
6584
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskError)(
|
|
6570
6585
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
6571
6586
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId] }
|
|
6572
6587
|
);
|
|
@@ -6574,44 +6589,44 @@ async function markup(_resource, id, format, http) {
|
|
|
6574
6589
|
return body.invoiceMarkup;
|
|
6575
6590
|
}
|
|
6576
6591
|
async function pdf(_resource, id, http) {
|
|
6577
|
-
const numericId =
|
|
6592
|
+
const numericId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
6578
6593
|
const res = await http.request({
|
|
6579
6594
|
method: "GET",
|
|
6580
6595
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
6581
6596
|
operation: "invoices.pdf"
|
|
6582
6597
|
});
|
|
6583
|
-
return
|
|
6598
|
+
return _chunkXSIY3WRRcjs.decodeFileData.call(void 0, res);
|
|
6584
6599
|
}
|
|
6585
6600
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
6586
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
6587
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
6601
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _48 => _48.now]), () => ( /* @__PURE__ */ new Date()));
|
|
6602
|
+
const tz = _optionalChain([opts, 'optionalAccess', _49 => _49.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
|
|
6588
6603
|
return dateWindowQuery(
|
|
6589
6604
|
http,
|
|
6590
6605
|
"/V1.0/Invoices/query",
|
|
6591
6606
|
"invoiceDateTime",
|
|
6592
6607
|
kind,
|
|
6593
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
6608
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _50 => _50.limit])),
|
|
6594
6609
|
`invoices.${kind}`,
|
|
6595
6610
|
now,
|
|
6596
6611
|
tz
|
|
6597
6612
|
);
|
|
6598
6613
|
}
|
|
6599
6614
|
async function customRange2(_resource, from, to, http, opts) {
|
|
6600
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
6615
|
+
const zone = _optionalChain([opts, 'optionalAccess', _51 => _51.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
|
|
6601
6616
|
return customRangeQuery(
|
|
6602
6617
|
http,
|
|
6603
6618
|
"/V1.0/Invoices/query",
|
|
6604
6619
|
"invoiceDateTime",
|
|
6605
6620
|
from,
|
|
6606
6621
|
to,
|
|
6607
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
6622
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _52 => _52.limit])),
|
|
6608
6623
|
"invoices.customRange",
|
|
6609
6624
|
zone
|
|
6610
6625
|
);
|
|
6611
6626
|
}
|
|
6612
6627
|
|
|
6613
6628
|
// src/resources/invoices.ts
|
|
6614
|
-
var InvoicesResource = class extends
|
|
6629
|
+
var InvoicesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6615
6630
|
constructor(http, pageSize) {
|
|
6616
6631
|
super(http, {
|
|
6617
6632
|
key: "invoices",
|
|
@@ -6741,7 +6756,7 @@ var ModulesResource = class {
|
|
|
6741
6756
|
};
|
|
6742
6757
|
|
|
6743
6758
|
// src/resources/notification_history.ts
|
|
6744
|
-
var NotificationHistoryResource = class extends
|
|
6759
|
+
var NotificationHistoryResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6745
6760
|
constructor(http, pageSize) {
|
|
6746
6761
|
super(http, {
|
|
6747
6762
|
key: "notification_history",
|
|
@@ -6780,7 +6795,7 @@ var NotificationHistoryResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6780
6795
|
};
|
|
6781
6796
|
|
|
6782
6797
|
// src/resources/opportunities.ts
|
|
6783
|
-
var OpportunitiesResource = class extends
|
|
6798
|
+
var OpportunitiesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6784
6799
|
constructor(http, pageSize) {
|
|
6785
6800
|
super(http, {
|
|
6786
6801
|
key: "opportunities",
|
|
@@ -6842,7 +6857,7 @@ var OpportunitiesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
6842
6857
|
};
|
|
6843
6858
|
|
|
6844
6859
|
// src/resources/opportunity_attachments.ts
|
|
6845
|
-
var OpportunityAttachmentsResource = class extends
|
|
6860
|
+
var OpportunityAttachmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6846
6861
|
constructor(http, pageSize) {
|
|
6847
6862
|
super(http, {
|
|
6848
6863
|
key: "opportunity_attachments",
|
|
@@ -6884,7 +6899,7 @@ var OpportunityAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
6884
6899
|
async delete(parentId, id, opts = {}) {
|
|
6885
6900
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
6886
6901
|
await this.guardStaleBeforeMutation(id, opts, "opportunity_attachments.delete", parentId);
|
|
6887
|
-
return this.deleteScopedModel(parentId, id);
|
|
6902
|
+
return this.deleteScopedModel(parentId, id, opts);
|
|
6888
6903
|
}
|
|
6889
6904
|
/** Download the attachment bytes (GET .../{id}/data; node-proven path, quirk #9) → Buffer. */
|
|
6890
6905
|
async download(parentId, id) {
|
|
@@ -6904,7 +6919,7 @@ var OpportunityAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
6904
6919
|
};
|
|
6905
6920
|
|
|
6906
6921
|
// src/resources/opportunity_categories.ts
|
|
6907
|
-
var OpportunityCategoriesResource = class extends
|
|
6922
|
+
var OpportunityCategoriesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6908
6923
|
constructor(http, pageSize) {
|
|
6909
6924
|
super(http, {
|
|
6910
6925
|
key: "opportunity_categories",
|
|
@@ -6963,7 +6978,7 @@ var OpportunityCategoriesResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
6963
6978
|
};
|
|
6964
6979
|
|
|
6965
6980
|
// src/resources/phases.ts
|
|
6966
|
-
var PhasesResource = class extends
|
|
6981
|
+
var PhasesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
6967
6982
|
constructor(http, pageSize) {
|
|
6968
6983
|
super(http, {
|
|
6969
6984
|
key: "phases",
|
|
@@ -7006,7 +7021,7 @@ var PhasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7006
7021
|
async update(parentId, id, data, opts = {}) {
|
|
7007
7022
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7008
7023
|
await this.guardStaleBeforeMutation(id, opts, "phases.update", parentId);
|
|
7009
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7024
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7010
7025
|
}
|
|
7011
7026
|
/** Resolve a Phase from a numeric id (or, where the vendor indexes a primary text field,
|
|
7012
7027
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -7022,7 +7037,7 @@ var PhasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7022
7037
|
};
|
|
7023
7038
|
|
|
7024
7039
|
// src/resources/products.ts
|
|
7025
|
-
var ProductsResource = class extends
|
|
7040
|
+
var ProductsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7026
7041
|
constructor(http, pageSize) {
|
|
7027
7042
|
super(http, {
|
|
7028
7043
|
key: "products",
|
|
@@ -7089,7 +7104,7 @@ var ProductsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7089
7104
|
};
|
|
7090
7105
|
|
|
7091
7106
|
// src/resources/product_vendors.ts
|
|
7092
|
-
var ProductVendorsResource = class extends
|
|
7107
|
+
var ProductVendorsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7093
7108
|
constructor(http, pageSize) {
|
|
7094
7109
|
super(http, {
|
|
7095
7110
|
key: "product_vendors",
|
|
@@ -7132,7 +7147,7 @@ var ProductVendorsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7132
7147
|
async update(parentId, id, data, opts = {}) {
|
|
7133
7148
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7134
7149
|
await this.guardStaleBeforeMutation(id, opts, "product_vendors.update", parentId);
|
|
7135
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7150
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7136
7151
|
}
|
|
7137
7152
|
/** Resolve a ProductVendors from a numeric id (or, where the vendor indexes a primary text field,
|
|
7138
7153
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -7148,7 +7163,7 @@ var ProductVendorsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7148
7163
|
};
|
|
7149
7164
|
|
|
7150
7165
|
// src/resources/project_charges.ts
|
|
7151
|
-
var ProjectChargesResource = class extends
|
|
7166
|
+
var ProjectChargesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7152
7167
|
constructor(http, pageSize) {
|
|
7153
7168
|
super(http, {
|
|
7154
7169
|
key: "project_charges",
|
|
@@ -7192,14 +7207,14 @@ var ProjectChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7192
7207
|
async update(parentId, id, data, opts = {}) {
|
|
7193
7208
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7194
7209
|
await this.guardStaleBeforeMutation(id, opts, "project_charges.update", parentId);
|
|
7195
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7210
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7196
7211
|
}
|
|
7197
7212
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
7198
7213
|
* envelope and never issues the delete. */
|
|
7199
7214
|
async delete(parentId, id, opts = {}) {
|
|
7200
7215
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
7201
7216
|
await this.guardStaleBeforeMutation(id, opts, "project_charges.delete", parentId);
|
|
7202
|
-
return this.deleteScopedRaw(parentId, id);
|
|
7217
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
7203
7218
|
}
|
|
7204
7219
|
/** Resolve a ProjectCharge from a numeric id (or, where the vendor indexes a primary text field,
|
|
7205
7220
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -7219,7 +7234,7 @@ var ProjectChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7219
7234
|
};
|
|
7220
7235
|
|
|
7221
7236
|
// src/resources/project_notes.ts
|
|
7222
|
-
var ProjectNotesResource = class extends
|
|
7237
|
+
var ProjectNotesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7223
7238
|
constructor(http, pageSize) {
|
|
7224
7239
|
super(http, {
|
|
7225
7240
|
key: "project_notes",
|
|
@@ -7262,7 +7277,7 @@ var ProjectNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7262
7277
|
async update(parentId, id, data, opts = {}) {
|
|
7263
7278
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7264
7279
|
await this.guardStaleBeforeMutation(id, opts, "project_notes.update", parentId);
|
|
7265
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7280
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7266
7281
|
}
|
|
7267
7282
|
/** Resolve a ProjectNote from a numeric id (or, where the vendor indexes a primary text field,
|
|
7268
7283
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -7278,7 +7293,7 @@ var ProjectNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7278
7293
|
};
|
|
7279
7294
|
|
|
7280
7295
|
// src/resources/projects.ts
|
|
7281
|
-
var ProjectsResource = class extends
|
|
7296
|
+
var ProjectsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7282
7297
|
constructor(http, pageSize) {
|
|
7283
7298
|
super(http, {
|
|
7284
7299
|
key: "projects",
|
|
@@ -7355,13 +7370,13 @@ var ProjectsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7355
7370
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
7356
7371
|
const result = { project, company, opportunity, leadResource };
|
|
7357
7372
|
if (opts.names === true) {
|
|
7358
|
-
const builder =
|
|
7373
|
+
const builder = _chunkXSIY3WRRcjs.createNamePlan.call(void 0, );
|
|
7359
7374
|
builder.addResource(root["creatorResourceID"]);
|
|
7360
7375
|
builder.addFk("contract", root["contractID"]);
|
|
7361
|
-
const names = await
|
|
7376
|
+
const names = await _chunkXSIY3WRRcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
7362
7377
|
const row = { ...project };
|
|
7363
|
-
|
|
7364
|
-
|
|
7378
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
7379
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
7365
7380
|
result.project = row;
|
|
7366
7381
|
result.names = names.section;
|
|
7367
7382
|
}
|
|
@@ -7370,7 +7385,7 @@ var ProjectsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7370
7385
|
};
|
|
7371
7386
|
|
|
7372
7387
|
// src/resources/purchase_approvals.ts
|
|
7373
|
-
var PurchaseApprovalsResource = class extends
|
|
7388
|
+
var PurchaseApprovalsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7374
7389
|
constructor(http, pageSize) {
|
|
7375
7390
|
super(http, {
|
|
7376
7391
|
key: "purchase_approvals",
|
|
@@ -7424,7 +7439,7 @@ var PurchaseApprovalsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7424
7439
|
};
|
|
7425
7440
|
|
|
7426
7441
|
// src/resources/purchase_order_item_receiving.ts
|
|
7427
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
7442
|
+
var PurchaseOrderItemReceivingResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7428
7443
|
constructor(http, pageSize) {
|
|
7429
7444
|
super(http, {
|
|
7430
7445
|
key: "purchase_order_item_receiving",
|
|
@@ -7474,7 +7489,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkIHRXVIUUcjs.BaseRes
|
|
|
7474
7489
|
};
|
|
7475
7490
|
|
|
7476
7491
|
// src/resources/purchase_order_items.ts
|
|
7477
|
-
var PurchaseOrderItemsResource = class extends
|
|
7492
|
+
var PurchaseOrderItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7478
7493
|
constructor(http, pageSize) {
|
|
7479
7494
|
super(http, {
|
|
7480
7495
|
key: "purchase_order_items",
|
|
@@ -7517,7 +7532,7 @@ var PurchaseOrderItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7517
7532
|
async update(parentId, id, data, opts = {}) {
|
|
7518
7533
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7519
7534
|
await this.guardStaleBeforeMutation(id, opts, "purchase_order_items.update", parentId);
|
|
7520
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7535
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7521
7536
|
}
|
|
7522
7537
|
/** Resolve a PurchaseOrderItems from a numeric id (or, where the vendor indexes a primary text field,
|
|
7523
7538
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -7533,7 +7548,7 @@ var PurchaseOrderItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7533
7548
|
};
|
|
7534
7549
|
|
|
7535
7550
|
// src/resources/purchase_orders.ts
|
|
7536
|
-
var PurchaseOrdersResource = class extends
|
|
7551
|
+
var PurchaseOrdersResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7537
7552
|
constructor(http, pageSize) {
|
|
7538
7553
|
super(http, {
|
|
7539
7554
|
key: "purchase_orders",
|
|
@@ -7595,7 +7610,7 @@ var PurchaseOrdersResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7595
7610
|
};
|
|
7596
7611
|
|
|
7597
7612
|
// src/resources/quote_items.ts
|
|
7598
|
-
var QuoteItemsResource = class extends
|
|
7613
|
+
var QuoteItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7599
7614
|
constructor(http, pageSize) {
|
|
7600
7615
|
super(http, {
|
|
7601
7616
|
key: "quote_items",
|
|
@@ -7639,14 +7654,14 @@ var QuoteItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7639
7654
|
async update(parentId, id, data, opts = {}) {
|
|
7640
7655
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7641
7656
|
await this.guardStaleBeforeMutation(id, opts, "quote_items.update", parentId);
|
|
7642
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7657
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7643
7658
|
}
|
|
7644
7659
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
7645
7660
|
* envelope and never issues the delete. */
|
|
7646
7661
|
async delete(parentId, id, opts = {}) {
|
|
7647
7662
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
7648
7663
|
await this.guardStaleBeforeMutation(id, opts, "quote_items.delete", parentId);
|
|
7649
|
-
return this.deleteScopedRaw(parentId, id);
|
|
7664
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
7650
7665
|
}
|
|
7651
7666
|
/** Resolve a QuoteItem from a numeric id (or, where the vendor indexes a primary text field,
|
|
7652
7667
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -7666,7 +7681,7 @@ var QuoteItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7666
7681
|
};
|
|
7667
7682
|
|
|
7668
7683
|
// src/resources/quote_locations.ts
|
|
7669
|
-
var QuoteLocationsResource = class extends
|
|
7684
|
+
var QuoteLocationsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7670
7685
|
constructor(http, pageSize) {
|
|
7671
7686
|
super(http, {
|
|
7672
7687
|
key: "quote_locations",
|
|
@@ -7731,7 +7746,7 @@ var QuoteLocationsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7731
7746
|
};
|
|
7732
7747
|
|
|
7733
7748
|
// src/resources/quotes.ts
|
|
7734
|
-
var QuotesResource = class extends
|
|
7749
|
+
var QuotesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7735
7750
|
constructor(http, pageSize) {
|
|
7736
7751
|
super(http, {
|
|
7737
7752
|
key: "quotes",
|
|
@@ -7798,7 +7813,7 @@ var QuotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7798
7813
|
};
|
|
7799
7814
|
|
|
7800
7815
|
// src/resources/quote_templates.ts
|
|
7801
|
-
var QuoteTemplatesResource = class extends
|
|
7816
|
+
var QuoteTemplatesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7802
7817
|
constructor(http, pageSize) {
|
|
7803
7818
|
super(http, {
|
|
7804
7819
|
key: "quote_templates",
|
|
@@ -7842,7 +7857,7 @@ var QuoteTemplatesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7842
7857
|
};
|
|
7843
7858
|
|
|
7844
7859
|
// src/resources/resource_role_queues.ts
|
|
7845
|
-
var ResourceRoleQueuesResource = class extends
|
|
7860
|
+
var ResourceRoleQueuesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7846
7861
|
constructor(http, pageSize) {
|
|
7847
7862
|
super(http, {
|
|
7848
7863
|
key: "resource_role_queues",
|
|
@@ -7885,7 +7900,7 @@ var ResourceRoleQueuesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7885
7900
|
async update(parentId, id, data, opts = {}) {
|
|
7886
7901
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7887
7902
|
await this.guardStaleBeforeMutation(id, opts, "resource_role_queues.update", parentId);
|
|
7888
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7903
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7889
7904
|
}
|
|
7890
7905
|
/** Resolve a ResourceRoleQueue from a numeric id (or, where the vendor indexes a primary text field,
|
|
7891
7906
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -7901,7 +7916,7 @@ var ResourceRoleQueuesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7901
7916
|
};
|
|
7902
7917
|
|
|
7903
7918
|
// src/resources/resource_roles.ts
|
|
7904
|
-
var ResourceRolesResource = class extends
|
|
7919
|
+
var ResourceRolesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7905
7920
|
constructor(http, pageSize) {
|
|
7906
7921
|
super(http, {
|
|
7907
7922
|
key: "resource_roles",
|
|
@@ -7943,7 +7958,7 @@ var ResourceRolesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7943
7958
|
};
|
|
7944
7959
|
|
|
7945
7960
|
// src/resources/resource_skills.ts
|
|
7946
|
-
var ResourceSkillsResource = class extends
|
|
7961
|
+
var ResourceSkillsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
7947
7962
|
constructor(http, pageSize) {
|
|
7948
7963
|
super(http, {
|
|
7949
7964
|
key: "resource_skills",
|
|
@@ -7978,7 +7993,7 @@ var ResourceSkillsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7978
7993
|
async update(parentId, id, data, opts = {}) {
|
|
7979
7994
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
7980
7995
|
await this.guardStaleBeforeMutation(id, opts, "resource_skills.update", parentId);
|
|
7981
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
7996
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
7982
7997
|
}
|
|
7983
7998
|
/** Resolve a ResourceSkill from a numeric id (or, where the vendor indexes a primary text field,
|
|
7984
7999
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -7997,16 +8012,16 @@ var ResourceSkillsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
7997
8012
|
var MAX_TRANSFER_IDS = 500;
|
|
7998
8013
|
function requirePositiveIds(ids, label) {
|
|
7999
8014
|
if (!Array.isArray(ids) || ids.length === 0) {
|
|
8000
|
-
throw new (0,
|
|
8015
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8001
8016
|
}
|
|
8002
8017
|
if (ids.length > MAX_TRANSFER_IDS) {
|
|
8003
|
-
throw new (0,
|
|
8018
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8004
8019
|
}
|
|
8005
8020
|
const out = [];
|
|
8006
8021
|
for (const raw of ids) {
|
|
8007
|
-
const id =
|
|
8022
|
+
const id = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8008
8023
|
if (typeof id === "number" && id < 1) {
|
|
8009
|
-
throw new (0,
|
|
8024
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8010
8025
|
}
|
|
8011
8026
|
out.push(id);
|
|
8012
8027
|
}
|
|
@@ -8014,7 +8029,7 @@ function requirePositiveIds(ids, label) {
|
|
|
8014
8029
|
}
|
|
8015
8030
|
async function whoAmI(_resource, userName, http) {
|
|
8016
8031
|
const user = userName.trim();
|
|
8017
|
-
if (user === "") throw new (0,
|
|
8032
|
+
if (user === "") throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8018
8033
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8019
8034
|
const res = await http.request({
|
|
8020
8035
|
method: "POST",
|
|
@@ -8023,11 +8038,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8023
8038
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8024
8039
|
operation: "resources.whoAmI"
|
|
8025
8040
|
});
|
|
8026
|
-
const matches =
|
|
8041
|
+
const matches = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res).items;
|
|
8027
8042
|
if (matches.length === 0) return null;
|
|
8028
8043
|
if (matches.length > 1) {
|
|
8029
8044
|
const ids = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8030
|
-
throw new (0,
|
|
8045
|
+
throw new (0, _chunkXSIY3WRRcjs.ResolutionError)(
|
|
8031
8046
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8032
8047
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids }
|
|
8033
8048
|
);
|
|
@@ -8036,11 +8051,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8036
8051
|
}
|
|
8037
8052
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8038
8053
|
const ids = requirePositiveIds(companyIds, "transferOwnership");
|
|
8039
|
-
const destination =
|
|
8054
|
+
const destination = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8040
8055
|
if (typeof destination === "number" && destination < 1) {
|
|
8041
|
-
throw new (0,
|
|
8056
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8042
8057
|
}
|
|
8043
|
-
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
8058
|
+
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _53 => _53.dryRun]), () => ( true));
|
|
8044
8059
|
const changes = [];
|
|
8045
8060
|
const applied = [];
|
|
8046
8061
|
for (const id of ids) {
|
|
@@ -8048,9 +8063,10 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8048
8063
|
const res = await http.request({
|
|
8049
8064
|
method: "GET",
|
|
8050
8065
|
path: `/V1.0/Companies/${id}`,
|
|
8051
|
-
operation: "resources.transferOwnership"
|
|
8066
|
+
operation: "resources.transferOwnership",
|
|
8067
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _54 => _54.maxRetries])
|
|
8052
8068
|
});
|
|
8053
|
-
const company =
|
|
8069
|
+
const company = _chunkXSIY3WRRcjs.unwrapItem.call(void 0, res, id);
|
|
8054
8070
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8055
8071
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8056
8072
|
if (!dryRun) {
|
|
@@ -8058,13 +8074,14 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8058
8074
|
method: "PUT",
|
|
8059
8075
|
path: "/V1.0/Companies",
|
|
8060
8076
|
body: { id, ownerResourceID: destination },
|
|
8061
|
-
operation: "resources.transferOwnership"
|
|
8077
|
+
operation: "resources.transferOwnership",
|
|
8078
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _55 => _55.maxRetries])
|
|
8062
8079
|
});
|
|
8063
|
-
|
|
8080
|
+
_chunkXSIY3WRRcjs.unwrapOperation.call(void 0, update);
|
|
8064
8081
|
applied.push(id);
|
|
8065
8082
|
}
|
|
8066
8083
|
} catch (err) {
|
|
8067
|
-
if (!dryRun && err instanceof
|
|
8084
|
+
if (!dryRun && err instanceof _chunkXSIY3WRRcjs.AutotaskError) {
|
|
8068
8085
|
err.resourceIds = [id];
|
|
8069
8086
|
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).`;
|
|
8070
8087
|
}
|
|
@@ -8074,7 +8091,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8074
8091
|
if (dryRun) {
|
|
8075
8092
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8076
8093
|
return {
|
|
8077
|
-
...
|
|
8094
|
+
..._chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
8078
8095
|
operation: "resources.transferOwnership",
|
|
8079
8096
|
method: "PUT",
|
|
8080
8097
|
path: "/V1.0/Companies",
|
|
@@ -8098,7 +8115,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8098
8115
|
}
|
|
8099
8116
|
|
|
8100
8117
|
// src/resources/resources.ts
|
|
8101
|
-
var ResourcesResource = class extends
|
|
8118
|
+
var ResourcesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8102
8119
|
|
|
8103
8120
|
constructor(http, clientConfig, pageSize) {
|
|
8104
8121
|
super(http, {
|
|
@@ -8171,7 +8188,7 @@ var ResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8171
8188
|
|
|
8172
8189
|
// src/resources/special/resource_time_off_additional.ts
|
|
8173
8190
|
async function getByResource(_resource, resourceId, http) {
|
|
8174
|
-
const numericResource =
|
|
8191
|
+
const numericResource = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8175
8192
|
const res = await http.request({
|
|
8176
8193
|
method: "GET",
|
|
8177
8194
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8185,11 +8202,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8185
8202
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8186
8203
|
}
|
|
8187
8204
|
}
|
|
8188
|
-
return
|
|
8205
|
+
return _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8189
8206
|
}
|
|
8190
8207
|
|
|
8191
8208
|
// src/resources/resource_time_off_additional.ts
|
|
8192
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8209
|
+
var ResourceTimeOffAdditionalResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8193
8210
|
constructor(http, pageSize) {
|
|
8194
8211
|
super(http, {
|
|
8195
8212
|
key: "resource_time_off_additional",
|
|
@@ -8208,7 +8225,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkIHRXVIUUcjs.BaseReso
|
|
|
8208
8225
|
async update(parentId, id, data, opts = {}) {
|
|
8209
8226
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
8210
8227
|
await this.guardStaleBeforeMutation(id, opts, "resource_time_off_additional.update", parentId);
|
|
8211
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
8228
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
8212
8229
|
}
|
|
8213
8230
|
/** Resolve a ResourceTimeOffAdditional from a numeric id (or, where the vendor indexes a primary text field,
|
|
8214
8231
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8228,7 +8245,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkIHRXVIUUcjs.BaseReso
|
|
|
8228
8245
|
};
|
|
8229
8246
|
|
|
8230
8247
|
// src/resources/resource_time_off_approvers.ts
|
|
8231
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8248
|
+
var ResourceTimeOffApproversResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8232
8249
|
constructor(http, pageSize) {
|
|
8233
8250
|
super(http, {
|
|
8234
8251
|
key: "resource_time_off_approvers",
|
|
@@ -8271,29 +8288,29 @@ var ResourceTimeOffApproversResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
8271
8288
|
|
|
8272
8289
|
// src/resources/special/resource_time_off_balances.ts
|
|
8273
8290
|
async function getByResource2(_resource, resourceId, http) {
|
|
8274
|
-
const numericResource =
|
|
8291
|
+
const numericResource = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8275
8292
|
const res = await http.request({
|
|
8276
8293
|
method: "GET",
|
|
8277
8294
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8278
8295
|
operation: "resource_time_off_balances.getByResource"
|
|
8279
8296
|
});
|
|
8280
|
-
return
|
|
8297
|
+
return _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8281
8298
|
}
|
|
8282
8299
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8283
|
-
const numericResource =
|
|
8300
|
+
const numericResource = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8284
8301
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8285
|
-
throw new (0,
|
|
8302
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8286
8303
|
}
|
|
8287
8304
|
const res = await http.request({
|
|
8288
8305
|
method: "GET",
|
|
8289
8306
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8290
8307
|
operation: "resource_time_off_balances.getByYear"
|
|
8291
8308
|
});
|
|
8292
|
-
return
|
|
8309
|
+
return _chunkXSIY3WRRcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear");
|
|
8293
8310
|
}
|
|
8294
8311
|
|
|
8295
8312
|
// src/resources/resource_time_off_balances.ts
|
|
8296
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
8313
|
+
var ResourceTimeOffBalancesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8297
8314
|
constructor(http, pageSize) {
|
|
8298
8315
|
super(http, {
|
|
8299
8316
|
key: "resource_time_off_balances",
|
|
@@ -8331,7 +8348,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkIHRXVIUUcjs.BaseResour
|
|
|
8331
8348
|
};
|
|
8332
8349
|
|
|
8333
8350
|
// src/resources/roles.ts
|
|
8334
|
-
var RolesResource = class extends
|
|
8351
|
+
var RolesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8335
8352
|
constructor(http, pageSize) {
|
|
8336
8353
|
super(http, {
|
|
8337
8354
|
key: "roles",
|
|
@@ -8398,7 +8415,7 @@ var RolesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8398
8415
|
};
|
|
8399
8416
|
|
|
8400
8417
|
// src/resources/service_calls.ts
|
|
8401
|
-
var ServiceCallsResource = class extends
|
|
8418
|
+
var ServiceCallsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8402
8419
|
constructor(http, pageSize) {
|
|
8403
8420
|
super(http, {
|
|
8404
8421
|
key: "service_calls",
|
|
@@ -8451,7 +8468,7 @@ var ServiceCallsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8451
8468
|
async delete(id, opts = {}) {
|
|
8452
8469
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
8453
8470
|
await this.guardStaleBeforeMutation(id, opts, "service_calls.delete");
|
|
8454
|
-
return this.deleteGlobal(id);
|
|
8471
|
+
return this.deleteGlobal(id, opts);
|
|
8455
8472
|
}
|
|
8456
8473
|
/** Resolve a ServiceCall from a numeric id (or, where the vendor indexes a primary text field,
|
|
8457
8474
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8467,7 +8484,7 @@ var ServiceCallsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8467
8484
|
};
|
|
8468
8485
|
|
|
8469
8486
|
// src/resources/service_call_task_resources.ts
|
|
8470
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
8487
|
+
var ServiceCallTaskResourcesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8471
8488
|
constructor(http, pageSize) {
|
|
8472
8489
|
super(http, {
|
|
8473
8490
|
key: "service_call_task_resources",
|
|
@@ -8508,7 +8525,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
8508
8525
|
async delete(parentId, id, opts = {}) {
|
|
8509
8526
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
8510
8527
|
await this.guardStaleBeforeMutation(id, opts, "service_call_task_resources.delete", parentId);
|
|
8511
|
-
return this.deleteScopedRaw(parentId, id);
|
|
8528
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
8512
8529
|
}
|
|
8513
8530
|
/** Resolve a ServiceCallTaskResource from a numeric id (or, where the vendor indexes a primary text field,
|
|
8514
8531
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8524,7 +8541,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
8524
8541
|
};
|
|
8525
8542
|
|
|
8526
8543
|
// src/resources/service_call_tasks.ts
|
|
8527
|
-
var ServiceCallTasksResource = class extends
|
|
8544
|
+
var ServiceCallTasksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8528
8545
|
constructor(http, pageSize) {
|
|
8529
8546
|
super(http, {
|
|
8530
8547
|
key: "service_call_tasks",
|
|
@@ -8565,7 +8582,7 @@ var ServiceCallTasksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8565
8582
|
async delete(parentId, id, opts = {}) {
|
|
8566
8583
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
8567
8584
|
await this.guardStaleBeforeMutation(id, opts, "service_call_tasks.delete", parentId);
|
|
8568
|
-
return this.deleteScopedRaw(parentId, id);
|
|
8585
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
8569
8586
|
}
|
|
8570
8587
|
/** Resolve a ServiceCallTask from a numeric id (or, where the vendor indexes a primary text field,
|
|
8571
8588
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8581,7 +8598,7 @@ var ServiceCallTasksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8581
8598
|
};
|
|
8582
8599
|
|
|
8583
8600
|
// src/resources/service_call_ticket_resources.ts
|
|
8584
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
8601
|
+
var ServiceCallTicketResourcesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8585
8602
|
constructor(http, pageSize) {
|
|
8586
8603
|
super(http, {
|
|
8587
8604
|
key: "service_call_ticket_resources",
|
|
@@ -8622,7 +8639,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkIHRXVIUUcjs.BaseRes
|
|
|
8622
8639
|
async delete(parentId, id, opts = {}) {
|
|
8623
8640
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
8624
8641
|
await this.guardStaleBeforeMutation(id, opts, "service_call_ticket_resources.delete", parentId);
|
|
8625
|
-
return this.deleteScopedRaw(parentId, id);
|
|
8642
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
8626
8643
|
}
|
|
8627
8644
|
/** Resolve a ServiceCallTicketResource from a numeric id (or, where the vendor indexes a primary text field,
|
|
8628
8645
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8638,7 +8655,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkIHRXVIUUcjs.BaseRes
|
|
|
8638
8655
|
};
|
|
8639
8656
|
|
|
8640
8657
|
// src/resources/service_call_tickets.ts
|
|
8641
|
-
var ServiceCallTicketsResource = class extends
|
|
8658
|
+
var ServiceCallTicketsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8642
8659
|
constructor(http, pageSize) {
|
|
8643
8660
|
super(http, {
|
|
8644
8661
|
key: "service_call_tickets",
|
|
@@ -8679,7 +8696,7 @@ var ServiceCallTicketsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8679
8696
|
async delete(parentId, id, opts = {}) {
|
|
8680
8697
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
8681
8698
|
await this.guardStaleBeforeMutation(id, opts, "service_call_tickets.delete", parentId);
|
|
8682
|
-
return this.deleteScopedRaw(parentId, id);
|
|
8699
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
8683
8700
|
}
|
|
8684
8701
|
/** Resolve a ServiceCallTicket from a numeric id (or, where the vendor indexes a primary text field,
|
|
8685
8702
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8695,7 +8712,7 @@ var ServiceCallTicketsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8695
8712
|
};
|
|
8696
8713
|
|
|
8697
8714
|
// src/resources/service_level_agreement_results.ts
|
|
8698
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
8715
|
+
var ServiceLevelAgreementResultsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8699
8716
|
constructor(http, pageSize) {
|
|
8700
8717
|
super(http, {
|
|
8701
8718
|
key: "service_level_agreement_results",
|
|
@@ -8734,7 +8751,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkIHRXVIUUcjs.BaseR
|
|
|
8734
8751
|
};
|
|
8735
8752
|
|
|
8736
8753
|
// src/resources/services.ts
|
|
8737
|
-
var ServicesResource = class extends
|
|
8754
|
+
var ServicesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8738
8755
|
constructor(http, pageSize) {
|
|
8739
8756
|
super(http, {
|
|
8740
8757
|
key: "services",
|
|
@@ -8802,7 +8819,7 @@ var ServicesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8802
8819
|
};
|
|
8803
8820
|
|
|
8804
8821
|
// src/resources/skills.ts
|
|
8805
|
-
var SkillsResource = class extends
|
|
8822
|
+
var SkillsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8806
8823
|
constructor(http, pageSize) {
|
|
8807
8824
|
super(http, {
|
|
8808
8825
|
key: "skills",
|
|
@@ -8846,7 +8863,7 @@ var SkillsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8846
8863
|
};
|
|
8847
8864
|
|
|
8848
8865
|
// src/resources/subscription_periods.ts
|
|
8849
|
-
var SubscriptionPeriodsResource = class extends
|
|
8866
|
+
var SubscriptionPeriodsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8850
8867
|
constructor(http, pageSize) {
|
|
8851
8868
|
super(http, {
|
|
8852
8869
|
key: "subscription_periods",
|
|
@@ -8885,7 +8902,7 @@ var SubscriptionPeriodsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8885
8902
|
};
|
|
8886
8903
|
|
|
8887
8904
|
// src/resources/subscriptions.ts
|
|
8888
|
-
var SubscriptionsResource = class extends
|
|
8905
|
+
var SubscriptionsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8889
8906
|
constructor(http, pageSize) {
|
|
8890
8907
|
super(http, {
|
|
8891
8908
|
key: "subscriptions",
|
|
@@ -8938,7 +8955,7 @@ var SubscriptionsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8938
8955
|
async delete(id, opts = {}) {
|
|
8939
8956
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
8940
8957
|
await this.guardStaleBeforeMutation(id, opts, "subscriptions.delete");
|
|
8941
|
-
return this.deleteGlobal(id);
|
|
8958
|
+
return this.deleteGlobal(id, opts);
|
|
8942
8959
|
}
|
|
8943
8960
|
/** Resolve a Subscription from a numeric id (or, where the vendor indexes a primary text field,
|
|
8944
8961
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -8954,7 +8971,7 @@ var SubscriptionsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8954
8971
|
};
|
|
8955
8972
|
|
|
8956
8973
|
// src/resources/survey_results.ts
|
|
8957
|
-
var SurveyResultsResource = class extends
|
|
8974
|
+
var SurveyResultsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8958
8975
|
constructor(http, pageSize) {
|
|
8959
8976
|
super(http, {
|
|
8960
8977
|
key: "survey_results",
|
|
@@ -8993,7 +9010,7 @@ var SurveyResultsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
8993
9010
|
};
|
|
8994
9011
|
|
|
8995
9012
|
// src/resources/surveys.ts
|
|
8996
|
-
var SurveysResource = class extends
|
|
9013
|
+
var SurveysResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
8997
9014
|
constructor(http, pageSize) {
|
|
8998
9015
|
super(http, {
|
|
8999
9016
|
key: "surveys",
|
|
@@ -9037,7 +9054,7 @@ var SurveysResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9037
9054
|
};
|
|
9038
9055
|
|
|
9039
9056
|
// src/resources/tag_aliases.ts
|
|
9040
|
-
var TagAliasesResource = class extends
|
|
9057
|
+
var TagAliasesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9041
9058
|
constructor(http, pageSize) {
|
|
9042
9059
|
super(http, {
|
|
9043
9060
|
key: "tag_aliases",
|
|
@@ -9078,7 +9095,7 @@ var TagAliasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9078
9095
|
async delete(parentId, id, opts = {}) {
|
|
9079
9096
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9080
9097
|
await this.guardStaleBeforeMutation(id, opts, "tag_aliases.delete", parentId);
|
|
9081
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9098
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9082
9099
|
}
|
|
9083
9100
|
/** Resolve a TagAlias from a numeric id (or, where the vendor indexes a primary text field,
|
|
9084
9101
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9094,7 +9111,7 @@ var TagAliasesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9094
9111
|
};
|
|
9095
9112
|
|
|
9096
9113
|
// src/resources/tag_groups.ts
|
|
9097
|
-
var TagGroupsResource = class extends
|
|
9114
|
+
var TagGroupsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9098
9115
|
constructor(http, pageSize) {
|
|
9099
9116
|
super(http, {
|
|
9100
9117
|
key: "tag_groups",
|
|
@@ -9147,7 +9164,7 @@ var TagGroupsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9147
9164
|
async delete(id, opts = {}) {
|
|
9148
9165
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
9149
9166
|
await this.guardStaleBeforeMutation(id, opts, "tag_groups.delete");
|
|
9150
|
-
return this.deleteGlobal(id);
|
|
9167
|
+
return this.deleteGlobal(id, opts);
|
|
9151
9168
|
}
|
|
9152
9169
|
/** Resolve a TagGroup from a numeric id (or, where the vendor indexes a primary text field,
|
|
9153
9170
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9163,7 +9180,7 @@ var TagGroupsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9163
9180
|
};
|
|
9164
9181
|
|
|
9165
9182
|
// src/resources/tags.ts
|
|
9166
|
-
var TagsResource = class extends
|
|
9183
|
+
var TagsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9167
9184
|
constructor(http, pageSize) {
|
|
9168
9185
|
super(http, {
|
|
9169
9186
|
key: "tags",
|
|
@@ -9216,7 +9233,7 @@ var TagsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9216
9233
|
async delete(id, opts = {}) {
|
|
9217
9234
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
9218
9235
|
await this.guardStaleBeforeMutation(id, opts, "tags.delete");
|
|
9219
|
-
return this.deleteGlobal(id);
|
|
9236
|
+
return this.deleteGlobal(id, opts);
|
|
9220
9237
|
}
|
|
9221
9238
|
/** Resolve a Tag from a numeric id (or, where the vendor indexes a primary text field,
|
|
9222
9239
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9232,7 +9249,7 @@ var TagsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9232
9249
|
};
|
|
9233
9250
|
|
|
9234
9251
|
// src/resources/task_secondary_resources.ts
|
|
9235
|
-
var TaskSecondaryResourcesResource = class extends
|
|
9252
|
+
var TaskSecondaryResourcesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9236
9253
|
constructor(http, pageSize) {
|
|
9237
9254
|
super(http, {
|
|
9238
9255
|
key: "task_secondary_resources",
|
|
@@ -9273,7 +9290,7 @@ var TaskSecondaryResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
9273
9290
|
async delete(parentId, id, opts = {}) {
|
|
9274
9291
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9275
9292
|
await this.guardStaleBeforeMutation(id, opts, "task_secondary_resources.delete", parentId);
|
|
9276
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9293
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9277
9294
|
}
|
|
9278
9295
|
/** Resolve a TaskSecondaryResource from a numeric id (or, where the vendor indexes a primary text field,
|
|
9279
9296
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9289,7 +9306,7 @@ var TaskSecondaryResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResourc
|
|
|
9289
9306
|
};
|
|
9290
9307
|
|
|
9291
9308
|
// src/resources/tasks.ts
|
|
9292
|
-
var TasksResource = class extends
|
|
9309
|
+
var TasksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9293
9310
|
constructor(http, pageSize) {
|
|
9294
9311
|
super(http, {
|
|
9295
9312
|
key: "tasks",
|
|
@@ -9333,7 +9350,7 @@ var TasksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9333
9350
|
async update(parentId, id, data, opts = {}) {
|
|
9334
9351
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
9335
9352
|
await this.guardStaleBeforeMutation(id, opts, "tasks.update", parentId);
|
|
9336
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
9353
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
9337
9354
|
}
|
|
9338
9355
|
/** Resolve a Task from a numeric id (or, where the vendor indexes a primary text field,
|
|
9339
9356
|
* from an exact match on title). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -9377,7 +9394,7 @@ var ThresholdInformationResource = class {
|
|
|
9377
9394
|
};
|
|
9378
9395
|
|
|
9379
9396
|
// src/resources/ticket_additional_configuration_items.ts
|
|
9380
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
9397
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9381
9398
|
constructor(http, pageSize) {
|
|
9382
9399
|
super(http, {
|
|
9383
9400
|
key: "ticket_additional_configuration_items",
|
|
@@ -9418,7 +9435,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkIHRXVIUUcjs
|
|
|
9418
9435
|
async delete(parentId, id, opts = {}) {
|
|
9419
9436
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9420
9437
|
await this.guardStaleBeforeMutation(id, opts, "ticket_additional_configuration_items.delete", parentId);
|
|
9421
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9438
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9422
9439
|
}
|
|
9423
9440
|
/** Resolve a TicketAdditionalConfigurationItem from a numeric id (or, where the vendor indexes a primary text field,
|
|
9424
9441
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9434,7 +9451,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkIHRXVIUUcjs
|
|
|
9434
9451
|
};
|
|
9435
9452
|
|
|
9436
9453
|
// src/resources/ticket_additional_contacts.ts
|
|
9437
|
-
var TicketAdditionalContactsResource = class extends
|
|
9454
|
+
var TicketAdditionalContactsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9438
9455
|
constructor(http, pageSize) {
|
|
9439
9456
|
super(http, {
|
|
9440
9457
|
key: "ticket_additional_contacts",
|
|
@@ -9475,7 +9492,7 @@ var TicketAdditionalContactsResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
9475
9492
|
async delete(parentId, id, opts = {}) {
|
|
9476
9493
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9477
9494
|
await this.guardStaleBeforeMutation(id, opts, "ticket_additional_contacts.delete", parentId);
|
|
9478
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9495
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9479
9496
|
}
|
|
9480
9497
|
/** Resolve a TicketAdditionalContact from a numeric id (or, where the vendor indexes a primary text field,
|
|
9481
9498
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9491,7 +9508,7 @@ var TicketAdditionalContactsResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
9491
9508
|
};
|
|
9492
9509
|
|
|
9493
9510
|
// src/resources/ticket_attachments.ts
|
|
9494
|
-
var TicketAttachmentsResource = class extends
|
|
9511
|
+
var TicketAttachmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9495
9512
|
constructor(http, pageSize) {
|
|
9496
9513
|
super(http, {
|
|
9497
9514
|
key: "ticket_attachments",
|
|
@@ -9533,7 +9550,7 @@ var TicketAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9533
9550
|
async delete(parentId, id, opts = {}) {
|
|
9534
9551
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9535
9552
|
await this.guardStaleBeforeMutation(id, opts, "ticket_attachments.delete", parentId);
|
|
9536
|
-
return this.deleteScopedModel(parentId, id);
|
|
9553
|
+
return this.deleteScopedModel(parentId, id, opts);
|
|
9537
9554
|
}
|
|
9538
9555
|
/** Download the attachment bytes (GET .../{id}/data; node-proven path, quirk #9) → Buffer. */
|
|
9539
9556
|
async download(parentId, id) {
|
|
@@ -9553,7 +9570,7 @@ var TicketAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9553
9570
|
};
|
|
9554
9571
|
|
|
9555
9572
|
// src/resources/ticket_categories.ts
|
|
9556
|
-
var TicketCategoriesResource = class extends
|
|
9573
|
+
var TicketCategoriesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9557
9574
|
constructor(http, pageSize) {
|
|
9558
9575
|
super(http, {
|
|
9559
9576
|
key: "ticket_categories",
|
|
@@ -9612,7 +9629,7 @@ var TicketCategoriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9612
9629
|
};
|
|
9613
9630
|
|
|
9614
9631
|
// src/resources/ticket_category_field_defaults.ts
|
|
9615
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
9632
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9616
9633
|
constructor(http, pageSize) {
|
|
9617
9634
|
super(http, {
|
|
9618
9635
|
key: "ticket_category_field_defaults",
|
|
@@ -9654,7 +9671,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkIHRXVIUUcjs.BaseRe
|
|
|
9654
9671
|
};
|
|
9655
9672
|
|
|
9656
9673
|
// src/resources/ticket_change_request_approvals.ts
|
|
9657
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
9674
|
+
var TicketChangeRequestApprovalsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9658
9675
|
constructor(http, pageSize) {
|
|
9659
9676
|
super(http, {
|
|
9660
9677
|
key: "ticket_change_request_approvals",
|
|
@@ -9695,7 +9712,7 @@ var TicketChangeRequestApprovalsResource = class extends _chunkIHRXVIUUcjs.BaseR
|
|
|
9695
9712
|
async delete(parentId, id, opts = {}) {
|
|
9696
9713
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9697
9714
|
await this.guardStaleBeforeMutation(id, opts, "ticket_change_request_approvals.delete", parentId);
|
|
9698
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9715
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9699
9716
|
}
|
|
9700
9717
|
/** Resolve a TicketChangeRequestApproval from a numeric id (or, where the vendor indexes a primary text field,
|
|
9701
9718
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9711,7 +9728,7 @@ var TicketChangeRequestApprovalsResource = class extends _chunkIHRXVIUUcjs.BaseR
|
|
|
9711
9728
|
};
|
|
9712
9729
|
|
|
9713
9730
|
// src/resources/ticket_charges.ts
|
|
9714
|
-
var TicketChargesResource = class extends
|
|
9731
|
+
var TicketChargesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9715
9732
|
constructor(http, pageSize) {
|
|
9716
9733
|
super(http, {
|
|
9717
9734
|
key: "ticket_charges",
|
|
@@ -9755,14 +9772,14 @@ var TicketChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9755
9772
|
async update(parentId, id, data, opts = {}) {
|
|
9756
9773
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
9757
9774
|
await this.guardStaleBeforeMutation(id, opts, "ticket_charges.update", parentId);
|
|
9758
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
9775
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
9759
9776
|
}
|
|
9760
9777
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
9761
9778
|
* envelope and never issues the delete. */
|
|
9762
9779
|
async delete(parentId, id, opts = {}) {
|
|
9763
9780
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9764
9781
|
await this.guardStaleBeforeMutation(id, opts, "ticket_charges.delete", parentId);
|
|
9765
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9782
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9766
9783
|
}
|
|
9767
9784
|
/** Resolve a TicketCharge from a numeric id (or, where the vendor indexes a primary text field,
|
|
9768
9785
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -9782,7 +9799,7 @@ var TicketChargesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9782
9799
|
};
|
|
9783
9800
|
|
|
9784
9801
|
// src/resources/ticket_checklist_items.ts
|
|
9785
|
-
var TicketChecklistItemsResource = class extends
|
|
9802
|
+
var TicketChecklistItemsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9786
9803
|
constructor(http, pageSize) {
|
|
9787
9804
|
super(http, {
|
|
9788
9805
|
key: "ticket_checklist_items",
|
|
@@ -9825,14 +9842,14 @@ var TicketChecklistItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
9825
9842
|
async update(parentId, id, data, opts = {}) {
|
|
9826
9843
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
9827
9844
|
await this.guardStaleBeforeMutation(id, opts, "ticket_checklist_items.update", parentId);
|
|
9828
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
9845
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
9829
9846
|
}
|
|
9830
9847
|
/** Delete a record under the parent (OperationResultModel → { id}). `dryRun: true` returns the pinned
|
|
9831
9848
|
* envelope and never issues the delete. */
|
|
9832
9849
|
async delete(parentId, id, opts = {}) {
|
|
9833
9850
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9834
9851
|
await this.guardStaleBeforeMutation(id, opts, "ticket_checklist_items.delete", parentId);
|
|
9835
|
-
return this.deleteScopedRaw(parentId, id);
|
|
9852
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
9836
9853
|
}
|
|
9837
9854
|
/** Resolve a TicketChecklistItem from a numeric id (or, where the vendor indexes a primary text field,
|
|
9838
9855
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9848,7 +9865,7 @@ var TicketChecklistItemsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
9848
9865
|
};
|
|
9849
9866
|
|
|
9850
9867
|
// src/resources/ticket_checklist_libraries.ts
|
|
9851
|
-
var TicketChecklistLibrariesResource = class extends
|
|
9868
|
+
var TicketChecklistLibrariesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9852
9869
|
constructor(http, pageSize) {
|
|
9853
9870
|
super(http, {
|
|
9854
9871
|
key: "ticket_checklist_libraries",
|
|
@@ -9872,9 +9889,9 @@ var TicketChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
9872
9889
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
9873
9890
|
* surface — no documents read op — and never issues the POST). */
|
|
9874
9891
|
async attachToDocument(documentID, data, opts = {}) {
|
|
9875
|
-
const n =
|
|
9892
|
+
const n = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
9876
9893
|
if (opts.dryRun === true) {
|
|
9877
|
-
return
|
|
9894
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
9878
9895
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
9879
9896
|
method: "POST",
|
|
9880
9897
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -9889,9 +9906,10 @@ var TicketChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
9889
9906
|
method: "POST",
|
|
9890
9907
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
9891
9908
|
body: { ...data },
|
|
9892
|
-
operation: "ticket_checklist_libraries.attachToDocument"
|
|
9909
|
+
operation: "ticket_checklist_libraries.attachToDocument",
|
|
9910
|
+
maxRetries: opts.maxRetries
|
|
9893
9911
|
});
|
|
9894
|
-
return
|
|
9912
|
+
return _chunkXSIY3WRRcjs.unwrapOperation.call(void 0, res);
|
|
9895
9913
|
}
|
|
9896
9914
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
9897
9915
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -9907,7 +9925,7 @@ var TicketChecklistLibrariesResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
9907
9925
|
};
|
|
9908
9926
|
|
|
9909
9927
|
// src/resources/ticket_history.ts
|
|
9910
|
-
var TicketHistoryResource = class extends
|
|
9928
|
+
var TicketHistoryResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9911
9929
|
constructor(http, pageSize) {
|
|
9912
9930
|
super(http, {
|
|
9913
9931
|
key: "ticket_history",
|
|
@@ -9946,7 +9964,7 @@ var TicketHistoryResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
9946
9964
|
};
|
|
9947
9965
|
|
|
9948
9966
|
// src/resources/ticket_note_attachments.ts
|
|
9949
|
-
var TicketNoteAttachmentsResource = class extends
|
|
9967
|
+
var TicketNoteAttachmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
9950
9968
|
constructor(http, pageSize) {
|
|
9951
9969
|
super(http, {
|
|
9952
9970
|
key: "ticket_note_attachments",
|
|
@@ -9988,7 +10006,7 @@ var TicketNoteAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
9988
10006
|
async delete(parentId, id, opts = {}) {
|
|
9989
10007
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
9990
10008
|
await this.guardStaleBeforeMutation(id, opts, "ticket_note_attachments.delete", parentId);
|
|
9991
|
-
return this.deleteScopedModel(parentId, id);
|
|
10009
|
+
return this.deleteScopedModel(parentId, id, opts);
|
|
9992
10010
|
}
|
|
9993
10011
|
/** Download the attachment bytes (GET .../{id}/data; node-proven path, quirk #9) → Buffer. */
|
|
9994
10012
|
async download(parentId, id) {
|
|
@@ -10008,7 +10026,7 @@ var TicketNoteAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
10008
10026
|
};
|
|
10009
10027
|
|
|
10010
10028
|
// src/resources/ticket_notes.ts
|
|
10011
|
-
var TicketNotesResource = class extends
|
|
10029
|
+
var TicketNotesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
10012
10030
|
constructor(http, pageSize) {
|
|
10013
10031
|
super(http, {
|
|
10014
10032
|
key: "ticket_notes",
|
|
@@ -10051,7 +10069,7 @@ var TicketNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
10051
10069
|
async update(parentId, id, data, opts = {}) {
|
|
10052
10070
|
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts, parentId);
|
|
10053
10071
|
await this.guardStaleBeforeMutation(id, opts, "ticket_notes.update", parentId);
|
|
10054
|
-
return this.updateScopedRaw(parentId, id, data);
|
|
10072
|
+
return this.updateScopedRaw(parentId, id, data, opts);
|
|
10055
10073
|
}
|
|
10056
10074
|
/** Resolve a TicketNote from a numeric id (or, where the vendor indexes a primary text field,
|
|
10057
10075
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10067,7 +10085,7 @@ var TicketNotesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
10067
10085
|
};
|
|
10068
10086
|
|
|
10069
10087
|
// src/resources/ticket_note_webhooks.ts
|
|
10070
|
-
var TicketNoteWebhooksResource = class extends
|
|
10088
|
+
var TicketNoteWebhooksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
10071
10089
|
constructor(http, pageSize) {
|
|
10072
10090
|
super(http, {
|
|
10073
10091
|
key: "ticket_note_webhooks",
|
|
@@ -10123,7 +10141,7 @@ var TicketNoteWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
10123
10141
|
async delete(id, opts = {}) {
|
|
10124
10142
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
10125
10143
|
await this.guardStaleBeforeMutation(id, opts, "ticket_note_webhooks.delete");
|
|
10126
|
-
return this.deleteGlobal(id);
|
|
10144
|
+
return this.deleteGlobal(id, opts);
|
|
10127
10145
|
}
|
|
10128
10146
|
/** Resolve a TicketNoteWebhook from a numeric id (or, where the vendor indexes a primary text field,
|
|
10129
10147
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -10143,7 +10161,7 @@ var TicketNoteWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
10143
10161
|
};
|
|
10144
10162
|
|
|
10145
10163
|
// src/resources/ticket_secondary_resources.ts
|
|
10146
|
-
var TicketSecondaryResourcesResource = class extends
|
|
10164
|
+
var TicketSecondaryResourcesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
10147
10165
|
constructor(http, pageSize) {
|
|
10148
10166
|
super(http, {
|
|
10149
10167
|
key: "ticket_secondary_resources",
|
|
@@ -10184,7 +10202,7 @@ var TicketSecondaryResourcesResource = class extends _chunkIHRXVIUUcjs.BaseResou
|
|
|
10184
10202
|
async delete(parentId, id, opts = {}) {
|
|
10185
10203
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
10186
10204
|
await this.guardStaleBeforeMutation(id, opts, "ticket_secondary_resources.delete", parentId);
|
|
10187
|
-
return this.deleteScopedRaw(parentId, id);
|
|
10205
|
+
return this.deleteScopedRaw(parentId, id, opts);
|
|
10188
10206
|
}
|
|
10189
10207
|
/** Resolve a TicketSecondaryResource from a numeric id (or, where the vendor indexes a primary text field,
|
|
10190
10208
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10210,9 +10228,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
10210
10228
|
});
|
|
10211
10229
|
const body = res;
|
|
10212
10230
|
if (body === null || !("item" in body)) {
|
|
10213
|
-
throw new (0,
|
|
10231
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id] });
|
|
10214
10232
|
}
|
|
10215
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
10233
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id] });
|
|
10216
10234
|
return body.item;
|
|
10217
10235
|
}
|
|
10218
10236
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -10223,29 +10241,29 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
10223
10241
|
body: { MaxRecords: maxRecords, filter },
|
|
10224
10242
|
operation
|
|
10225
10243
|
});
|
|
10226
|
-
return
|
|
10244
|
+
return _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res).items;
|
|
10227
10245
|
}
|
|
10228
10246
|
function isRouteUnavailable(err) {
|
|
10229
|
-
return
|
|
10247
|
+
return _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
10230
10248
|
}
|
|
10231
10249
|
function routeFact(route, path, err) {
|
|
10232
10250
|
return {
|
|
10233
10251
|
route,
|
|
10234
10252
|
path,
|
|
10235
|
-
httpStatus:
|
|
10253
|
+
httpStatus: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
10236
10254
|
};
|
|
10237
10255
|
}
|
|
10238
10256
|
function childDeclaresQuery(resourceKey) {
|
|
10239
|
-
return
|
|
10257
|
+
return _chunkEWMG3HHUcjs.CAPABILITIES.some(
|
|
10240
10258
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
10241
10259
|
);
|
|
10242
10260
|
}
|
|
10243
10261
|
function planScopedPath(resourceKey, ticketId) {
|
|
10244
10262
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
10245
|
-
const entry =
|
|
10263
|
+
const entry = _chunkXSIY3WRRcjs.RELATIONSHIP_MAP[resourceKey];
|
|
10246
10264
|
const parent = entry === void 0 ? null : entry.parent;
|
|
10247
10265
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
10248
|
-
const parentPath = _optionalChain([
|
|
10266
|
+
const parentPath = _optionalChain([_chunkXSIY3WRRcjs.RELATIONSHIP_MAP, 'access', _56 => _56[parent.resource], 'optionalAccess', _57 => _57.path]);
|
|
10249
10267
|
if (parentPath === null || parentPath === void 0) return null;
|
|
10250
10268
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
10251
10269
|
}
|
|
@@ -10284,14 +10302,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
10284
10302
|
break;
|
|
10285
10303
|
}
|
|
10286
10304
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
10287
|
-
const { items: pageItems, pageDetails } =
|
|
10305
|
+
const { items: pageItems, pageDetails } = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, body, operation);
|
|
10288
10306
|
nextCursor = pageDetails.nextPageUrl;
|
|
10289
10307
|
pages += 1;
|
|
10290
10308
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
10291
10309
|
for (const row of window) if (accept(row)) items.push(row);
|
|
10292
10310
|
if (items.length >= limit) break;
|
|
10293
10311
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
10294
|
-
target =
|
|
10312
|
+
target = _chunkXSIY3WRRcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
10295
10313
|
}
|
|
10296
10314
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
10297
10315
|
return { items, capped };
|
|
@@ -10325,7 +10343,7 @@ function truncate(text, limit) {
|
|
|
10325
10343
|
}
|
|
10326
10344
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
10327
10345
|
void opts;
|
|
10328
|
-
const ticketId =
|
|
10346
|
+
const ticketId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
10329
10347
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
10330
10348
|
const rows = await ticketQueryItems(
|
|
10331
10349
|
http,
|
|
@@ -10350,9 +10368,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
10350
10368
|
async function summary(_resource, id, opts = {}, http) {
|
|
10351
10369
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
10352
10370
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
10353
|
-
throw new (0,
|
|
10371
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
10354
10372
|
}
|
|
10355
|
-
const ticketId =
|
|
10373
|
+
const ticketId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
10356
10374
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
10357
10375
|
const desc = truncate(ticket.description, limit);
|
|
10358
10376
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -10379,13 +10397,13 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
10379
10397
|
}
|
|
10380
10398
|
async function timeline(_resource, id, opts = {}, http) {
|
|
10381
10399
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
10382
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
10400
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
10383
10401
|
const bounded = Math.min(limit, 500);
|
|
10384
10402
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
10385
10403
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
10386
|
-
throw new (0,
|
|
10404
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
10387
10405
|
}
|
|
10388
|
-
const ticketId =
|
|
10406
|
+
const ticketId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
10389
10407
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
10390
10408
|
const dateFilters = (field) => {
|
|
10391
10409
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -10472,21 +10490,21 @@ function isPositiveInt(v) {
|
|
|
10472
10490
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
10473
10491
|
}
|
|
10474
10492
|
function namedVendorFields(err) {
|
|
10475
|
-
if (!
|
|
10476
|
-
const entries = _nullishCoalesce(
|
|
10493
|
+
if (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
10494
|
+
const entries = _nullishCoalesce(_chunkXSIY3WRRcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
10477
10495
|
const out = /* @__PURE__ */ new Set();
|
|
10478
10496
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
10479
10497
|
return [...out];
|
|
10480
10498
|
}
|
|
10481
10499
|
function vendorDetailOf(err) {
|
|
10482
|
-
return
|
|
10500
|
+
return _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? _chunkXSIY3WRRcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
10483
10501
|
}
|
|
10484
|
-
async function fetchItem(http, path, operation) {
|
|
10485
|
-
const res = await http.request({ method: "GET", path, operation });
|
|
10502
|
+
async function fetchItem(http, path, operation, readOpts) {
|
|
10503
|
+
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _58 => _58.maxRetries]) });
|
|
10486
10504
|
return unwrapItemOrNull(res);
|
|
10487
10505
|
}
|
|
10488
|
-
async function fetchItemUnredacted(http, path, operation) {
|
|
10489
|
-
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true });
|
|
10506
|
+
async function fetchItemUnredacted(http, path, operation, readOpts) {
|
|
10507
|
+
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _59 => _59.maxRetries]) });
|
|
10490
10508
|
return unwrapItemOrNull(res);
|
|
10491
10509
|
}
|
|
10492
10510
|
function unwrapItemOrNull(res) {
|
|
@@ -10500,8 +10518,8 @@ function operationId(res) {
|
|
|
10500
10518
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
10501
10519
|
}
|
|
10502
10520
|
function discoveryMerge(err, body, defaults) {
|
|
10503
|
-
if (!
|
|
10504
|
-
const entries =
|
|
10521
|
+
if (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
10522
|
+
const entries = _chunkXSIY3WRRcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
10505
10523
|
if (entries === void 0) return null;
|
|
10506
10524
|
for (const entry of entries) {
|
|
10507
10525
|
const field = entry.field;
|
|
@@ -10513,7 +10531,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
10513
10531
|
}
|
|
10514
10532
|
function stepErrorText(code, err) {
|
|
10515
10533
|
const detail = vendorDetailOf(err);
|
|
10516
|
-
const base =
|
|
10534
|
+
const base = _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
10517
10535
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
10518
10536
|
}
|
|
10519
10537
|
var DEFAULT_TICKET_PRIORITY = 3;
|
|
@@ -10522,7 +10540,7 @@ var DEFAULT_NOTE_TYPE = 1;
|
|
|
10522
10540
|
var DEFAULT_PUBLISH = 1;
|
|
10523
10541
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
10524
10542
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
10525
|
-
var QueueRequiredError = class extends
|
|
10543
|
+
var QueueRequiredError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
10526
10544
|
constructor(message, options = {}) {
|
|
10527
10545
|
super(message, {
|
|
10528
10546
|
code: "QUEUE_REQUIRED",
|
|
@@ -10533,13 +10551,13 @@ var QueueRequiredError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
|
10533
10551
|
this.name = "QueueRequiredError";
|
|
10534
10552
|
}
|
|
10535
10553
|
};
|
|
10536
|
-
var TicketResourceInvalidError = class extends
|
|
10554
|
+
var TicketResourceInvalidError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
10537
10555
|
constructor(message, options = {}) {
|
|
10538
10556
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
10539
10557
|
this.name = "TicketResourceInvalidError";
|
|
10540
10558
|
}
|
|
10541
10559
|
};
|
|
10542
|
-
var TicketCreateValidationFailedError = class extends
|
|
10560
|
+
var TicketCreateValidationFailedError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
10543
10561
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
10544
10562
|
|
|
10545
10563
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -10549,47 +10567,47 @@ var TicketCreateValidationFailedError = class extends _chunkIHRXVIUUcjs.Autotask
|
|
|
10549
10567
|
}
|
|
10550
10568
|
};
|
|
10551
10569
|
async function openWithNoteAndAssign(resource, params, note, assign, opts, http) {
|
|
10552
|
-
const companyID =
|
|
10553
|
-
const title = _optionalChain([params, 'optionalAccess',
|
|
10570
|
+
const companyID = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _60 => _60.companyID]), "params.companyID");
|
|
10571
|
+
const title = _optionalChain([params, 'optionalAccess', _61 => _61.title]);
|
|
10554
10572
|
if (typeof title !== "string" || title.trim() === "") {
|
|
10555
|
-
throw new (0,
|
|
10573
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
10556
10574
|
}
|
|
10557
10575
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
10558
10576
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
10559
10577
|
if (!isPositiveInt(priority)) {
|
|
10560
|
-
throw new (0,
|
|
10578
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
10561
10579
|
}
|
|
10562
10580
|
if (!isPositiveInt(status)) {
|
|
10563
|
-
throw new (0,
|
|
10581
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
10564
10582
|
}
|
|
10565
10583
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
10566
|
-
throw new (0,
|
|
10584
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
10567
10585
|
}
|
|
10568
10586
|
if (note !== void 0) {
|
|
10569
10587
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
10570
|
-
throw new (0,
|
|
10588
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
10571
10589
|
}
|
|
10572
10590
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
10573
|
-
throw new (0,
|
|
10591
|
+
throw new (0, _chunkXSIY3WRRcjs.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 });
|
|
10574
10592
|
}
|
|
10575
10593
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
10576
|
-
throw new (0,
|
|
10594
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
10577
10595
|
}
|
|
10578
10596
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
10579
|
-
throw new (0,
|
|
10597
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
10580
10598
|
}
|
|
10581
10599
|
}
|
|
10582
|
-
const assignee = assign === void 0 ? void 0 :
|
|
10600
|
+
const assignee = assign === void 0 ? void 0 : _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
10583
10601
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
10584
|
-
throw new (0,
|
|
10602
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
10585
10603
|
}
|
|
10586
|
-
const roleID = _optionalChain([assign, 'optionalAccess',
|
|
10604
|
+
const roleID = _optionalChain([assign, 'optionalAccess', _62 => _62.roleID]);
|
|
10587
10605
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
10588
|
-
throw new (0,
|
|
10606
|
+
throw new (0, _chunkXSIY3WRRcjs.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 });
|
|
10589
10607
|
}
|
|
10590
10608
|
if (assign !== void 0 && assignee !== void 0) {
|
|
10591
10609
|
const rid = assignee;
|
|
10592
|
-
const rec = await fetchItem(http, `/V1.0/Resources/${rid}`, OP_OPEN);
|
|
10610
|
+
const rec = await fetchItem(http, `/V1.0/Resources/${rid}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
10593
10611
|
if (rec === null) {
|
|
10594
10612
|
throw new TicketResourceInvalidError(
|
|
10595
10613
|
`openWithNoteAndAssign: assignee resource ${assignee} was not found (resources.get returned item: null \u2014 the resources table is blind to the API user; get is the authority)`,
|
|
@@ -10620,7 +10638,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10620
10638
|
if (assign !== void 0) {
|
|
10621
10639
|
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).`);
|
|
10622
10640
|
}
|
|
10623
|
-
return
|
|
10641
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
10624
10642
|
{
|
|
10625
10643
|
operation: OP_OPEN,
|
|
10626
10644
|
method: "POST",
|
|
@@ -10662,8 +10680,8 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10662
10680
|
`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}` : ""}`,
|
|
10663
10681
|
{
|
|
10664
10682
|
operation: OP_OPEN,
|
|
10665
|
-
httpStatus:
|
|
10666
|
-
vendorError:
|
|
10683
|
+
httpStatus: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
10684
|
+
vendorError: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
10667
10685
|
}
|
|
10668
10686
|
);
|
|
10669
10687
|
}
|
|
@@ -10678,8 +10696,8 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10678
10696
|
named,
|
|
10679
10697
|
{
|
|
10680
10698
|
operation: OP_OPEN,
|
|
10681
|
-
httpStatus:
|
|
10682
|
-
vendorError:
|
|
10699
|
+
httpStatus: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
10700
|
+
vendorError: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
10683
10701
|
resourceIds: [companyID]
|
|
10684
10702
|
}
|
|
10685
10703
|
);
|
|
@@ -10688,7 +10706,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10688
10706
|
let noteId = null;
|
|
10689
10707
|
if (noteBody !== null) {
|
|
10690
10708
|
try {
|
|
10691
|
-
const res = await http.request({ method: "POST", path: `/V1.0/Tickets/${ticketId}/Notes`, body: noteBody, operation: OP_OPEN });
|
|
10709
|
+
const res = await http.request({ method: "POST", path: `/V1.0/Tickets/${ticketId}/Notes`, body: noteBody, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
10692
10710
|
noteId = _nullishCoalesce(operationId(res), () => ( null));
|
|
10693
10711
|
steps.push({ name: "note", ok: true });
|
|
10694
10712
|
} catch (err) {
|
|
@@ -10699,14 +10717,14 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10699
10717
|
let ticketNumber = null;
|
|
10700
10718
|
if (assign !== void 0) {
|
|
10701
10719
|
try {
|
|
10702
|
-
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN);
|
|
10720
|
+
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
10703
10721
|
if (current === null) {
|
|
10704
|
-
throw new (0,
|
|
10722
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId] });
|
|
10705
10723
|
}
|
|
10706
10724
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
10707
|
-
const merged =
|
|
10725
|
+
const merged = _chunkXSIY3WRRcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
10708
10726
|
merged.id = ticketId;
|
|
10709
|
-
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN });
|
|
10727
|
+
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
10710
10728
|
assigned = true;
|
|
10711
10729
|
steps.push({ name: "assign", ok: true });
|
|
10712
10730
|
} catch (err) {
|
|
@@ -10725,7 +10743,7 @@ async function openWithNoteAndAssign(resource, params, note, assign, opts, http)
|
|
|
10725
10743
|
var STATUS_REQUIRED_FIELDS = {
|
|
10726
10744
|
// <discovery output lands here — e.g. 8: { requiredFields: ['dueDateTime'], safeDefaults: { dueDateTime: '<now>' } }>
|
|
10727
10745
|
};
|
|
10728
|
-
var StatusUnknownError = class extends
|
|
10746
|
+
var StatusUnknownError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
10729
10747
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
10730
10748
|
|
|
10731
10749
|
constructor(message, options = {}) {
|
|
@@ -10739,7 +10757,7 @@ var StatusUnknownError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
|
10739
10757
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
10740
10758
|
}
|
|
10741
10759
|
};
|
|
10742
|
-
var StatusFieldsRequiredError = class extends
|
|
10760
|
+
var StatusFieldsRequiredError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
10743
10761
|
|
|
10744
10762
|
|
|
10745
10763
|
|
|
@@ -10768,26 +10786,26 @@ async function readLiveStatusSet(resource) {
|
|
|
10768
10786
|
}
|
|
10769
10787
|
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";
|
|
10770
10788
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
10771
|
-
const ticketId =
|
|
10789
|
+
const ticketId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
10772
10790
|
if (!isPositiveInt(targetStatus)) {
|
|
10773
|
-
throw new (0,
|
|
10791
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
10774
10792
|
}
|
|
10775
10793
|
let liveStatus = null;
|
|
10776
10794
|
try {
|
|
10777
10795
|
const ids = await readLiveStatusSet(resource);
|
|
10778
10796
|
if (ids.size > 0) liveStatus = ids;
|
|
10779
10797
|
} catch (err) {
|
|
10780
|
-
if (!
|
|
10798
|
+
if (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
10781
10799
|
}
|
|
10782
10800
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
10783
|
-
_optionalChain([http, 'access',
|
|
10801
|
+
_optionalChain([http, 'access', _63 => _63.fieldCache, 'optionalAccess', _64 => _64.invalidate, 'call', _65 => _65("tickets")]);
|
|
10784
10802
|
let freshStatus = null;
|
|
10785
10803
|
let reReadFailed = false;
|
|
10786
10804
|
try {
|
|
10787
10805
|
const freshIds = await readLiveStatusSet(resource);
|
|
10788
10806
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
10789
10807
|
} catch (err) {
|
|
10790
|
-
if (!
|
|
10808
|
+
if (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
10791
10809
|
freshStatus = null;
|
|
10792
10810
|
reReadFailed = true;
|
|
10793
10811
|
}
|
|
@@ -10804,16 +10822,16 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10804
10822
|
}
|
|
10805
10823
|
const guardDegraded = liveStatus === null;
|
|
10806
10824
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
10807
|
-
throw new (0,
|
|
10825
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
10808
10826
|
}
|
|
10809
|
-
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS);
|
|
10827
|
+
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
10810
10828
|
if (current === null) {
|
|
10811
|
-
throw new (0,
|
|
10829
|
+
throw new (0, _chunkXSIY3WRRcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId] });
|
|
10812
10830
|
}
|
|
10813
10831
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
10814
10832
|
if (previousStatus === targetStatus) {
|
|
10815
10833
|
if (opts.dryRun === true) {
|
|
10816
|
-
return
|
|
10834
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
10817
10835
|
{
|
|
10818
10836
|
operation: OP_STATUS,
|
|
10819
10837
|
method: "PUT",
|
|
@@ -10846,7 +10864,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10846
10864
|
for (const field of mapEntry.requiredFields) {
|
|
10847
10865
|
if (mergeData[field] !== void 0) continue;
|
|
10848
10866
|
if (current[field] !== null && current[field] !== void 0) continue;
|
|
10849
|
-
const safe = _optionalChain([mapEntry, 'access',
|
|
10867
|
+
const safe = _optionalChain([mapEntry, 'access', _66 => _66.safeDefaults, 'optionalAccess', _67 => _67[field]]);
|
|
10850
10868
|
if (safe === void 0) {
|
|
10851
10869
|
throw new StatusFieldsRequiredError(
|
|
10852
10870
|
`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`,
|
|
@@ -10867,7 +10885,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10867
10885
|
if (mapEntry === void 0) {
|
|
10868
10886
|
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).`);
|
|
10869
10887
|
}
|
|
10870
|
-
return
|
|
10888
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
10871
10889
|
{
|
|
10872
10890
|
operation: OP_STATUS,
|
|
10873
10891
|
method: "PUT",
|
|
@@ -10885,13 +10903,13 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10885
10903
|
{ redactPersonalData: http.redactPersonalData }
|
|
10886
10904
|
);
|
|
10887
10905
|
}
|
|
10888
|
-
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess',
|
|
10889
|
-
const body =
|
|
10906
|
+
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _68 => _68.safeDefaults]), () => ( {}));
|
|
10907
|
+
const body = _chunkXSIY3WRRcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
10890
10908
|
body.id = ticketId;
|
|
10891
10909
|
let merges = 0;
|
|
10892
10910
|
for (; ; ) {
|
|
10893
10911
|
try {
|
|
10894
|
-
await http.request({ method: "PUT", path: "/V1.0/Tickets", body, operation: OP_STATUS });
|
|
10912
|
+
await http.request({ method: "PUT", path: "/V1.0/Tickets", body, operation: OP_STATUS, maxRetries: opts.maxRetries });
|
|
10895
10913
|
break;
|
|
10896
10914
|
} catch (err) {
|
|
10897
10915
|
const named = namedVendorFields(err);
|
|
@@ -10910,8 +10928,8 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10910
10928
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
10911
10929
|
{
|
|
10912
10930
|
operation: OP_STATUS,
|
|
10913
|
-
httpStatus:
|
|
10914
|
-
vendorError:
|
|
10931
|
+
httpStatus: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
10932
|
+
vendorError: _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
10915
10933
|
resourceIds: [ticketId]
|
|
10916
10934
|
}
|
|
10917
10935
|
);
|
|
@@ -10919,9 +10937,9 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10919
10937
|
throw err;
|
|
10920
10938
|
}
|
|
10921
10939
|
}
|
|
10922
|
-
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS);
|
|
10940
|
+
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
10923
10941
|
if (verify === null) {
|
|
10924
|
-
throw new (0,
|
|
10942
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
10925
10943
|
code: "INVALID_RESPONSE",
|
|
10926
10944
|
category: "server",
|
|
10927
10945
|
operation: OP_STATUS,
|
|
@@ -10930,7 +10948,7 @@ async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
|
10930
10948
|
}
|
|
10931
10949
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
10932
10950
|
if (finalStatus !== targetStatus) {
|
|
10933
|
-
throw new (0,
|
|
10951
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskError)(
|
|
10934
10952
|
`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)`,
|
|
10935
10953
|
{
|
|
10936
10954
|
code: "INVALID_RESPONSE",
|
|
@@ -10948,7 +10966,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
10948
10966
|
function partLimit(value, name) {
|
|
10949
10967
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
10950
10968
|
if (!Number.isInteger(n) || n < 1) {
|
|
10951
|
-
throw new (0,
|
|
10969
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
10952
10970
|
}
|
|
10953
10971
|
return n;
|
|
10954
10972
|
}
|
|
@@ -10964,7 +10982,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
10964
10982
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
10965
10983
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
10966
10984
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
10967
|
-
const ticketId =
|
|
10985
|
+
const ticketId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
10968
10986
|
const ctx = await resource.getContext(ticketId);
|
|
10969
10987
|
const op = "tickets.fullContext";
|
|
10970
10988
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11018,7 +11036,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11018
11036
|
result.truncated = result.truncated || part.capped || historyRows.some((h) => h.detailTruncated === true);
|
|
11019
11037
|
}
|
|
11020
11038
|
if (opts.names === true) {
|
|
11021
|
-
const builder =
|
|
11039
|
+
const builder = _chunkXSIY3WRRcjs.createNamePlan.call(void 0, _chunkXSIY3WRRcjs.TICKET_LABEL_FIELDS);
|
|
11022
11040
|
const t = ctx.ticket;
|
|
11023
11041
|
builder.addResource(t["creatorResourceID"]);
|
|
11024
11042
|
builder.addFk("contract", t["contractID"]);
|
|
@@ -11030,20 +11048,20 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11030
11048
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
11031
11049
|
builder.addFk("contract", e["contractID"]);
|
|
11032
11050
|
}
|
|
11033
|
-
const names = await
|
|
11051
|
+
const names = await _chunkXSIY3WRRcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
11034
11052
|
const ticketRow = { ...ctx.ticket };
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
for (const f of
|
|
11053
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
11054
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
11055
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11056
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
11057
|
+
for (const f of _chunkXSIY3WRRcjs.TICKET_LABEL_FIELDS) _chunkXSIY3WRRcjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
11040
11058
|
result.ticket = ticketRow;
|
|
11041
11059
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
11042
11060
|
const row = { ...e };
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11061
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
11062
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
11063
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11064
|
+
_chunkXSIY3WRRcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
11047
11065
|
return row;
|
|
11048
11066
|
});
|
|
11049
11067
|
result.names = names.section;
|
|
@@ -11053,7 +11071,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11053
11071
|
}
|
|
11054
11072
|
|
|
11055
11073
|
// src/resources/tickets.ts
|
|
11056
|
-
var TicketsResource = class extends
|
|
11074
|
+
var TicketsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
11057
11075
|
constructor(http, pageSize) {
|
|
11058
11076
|
super(http, {
|
|
11059
11077
|
key: "tickets",
|
|
@@ -11159,7 +11177,7 @@ var TicketsResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
11159
11177
|
};
|
|
11160
11178
|
|
|
11161
11179
|
// src/resources/ticket_webhooks.ts
|
|
11162
|
-
var TicketWebhooksResource = class extends
|
|
11180
|
+
var TicketWebhooksResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
11163
11181
|
constructor(http, pageSize) {
|
|
11164
11182
|
super(http, {
|
|
11165
11183
|
key: "ticket_webhooks",
|
|
@@ -11215,7 +11233,7 @@ var TicketWebhooksResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
11215
11233
|
async delete(id, opts = {}) {
|
|
11216
11234
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
11217
11235
|
await this.guardStaleBeforeMutation(id, opts, "ticket_webhooks.delete");
|
|
11218
|
-
return this.deleteGlobal(id);
|
|
11236
|
+
return this.deleteGlobal(id, opts);
|
|
11219
11237
|
}
|
|
11220
11238
|
/** Resolve a TicketWebhook from a numeric id (or, where the vendor indexes a primary text field,
|
|
11221
11239
|
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
@@ -11245,62 +11263,62 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
11245
11263
|
body: { MaxRecords: limit, filter },
|
|
11246
11264
|
operation
|
|
11247
11265
|
});
|
|
11248
|
-
const { items, pageDetails } =
|
|
11266
|
+
const { items, pageDetails } = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res);
|
|
11249
11267
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
11250
11268
|
}
|
|
11251
11269
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
11252
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
11253
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
11270
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _69 => _69.now]), () => ( /* @__PURE__ */ new Date()));
|
|
11271
|
+
const tz = _optionalChain([opts, 'optionalAccess', _70 => _70.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
|
|
11254
11272
|
const { from, to } = dateWindowBounds(kind, now, tz);
|
|
11255
11273
|
const filter = [
|
|
11256
11274
|
{ field: "dateWorked", op: "gte", value: from },
|
|
11257
11275
|
{ field: "dateWorked", op: "lte", value: to }
|
|
11258
11276
|
];
|
|
11259
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11277
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _71 => _71.limit])), `time_entries.${kind}`, http);
|
|
11260
11278
|
return items;
|
|
11261
11279
|
}
|
|
11262
11280
|
async function customRange3(_resource, from, to, http, opts) {
|
|
11263
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
11281
|
+
const zone = _optionalChain([opts, 'optionalAccess', _72 => _72.tz]) === void 0 ? void 0 : validateZone(opts.tz, "time_entries.customRange");
|
|
11264
11282
|
const fromB = customRangeDay(from, "from", zone, "customRange");
|
|
11265
11283
|
const toB = customRangeDay(to, "to", zone, "customRange");
|
|
11266
11284
|
if (fromB.ms > toB.ms) {
|
|
11267
|
-
throw new (0,
|
|
11285
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
11268
11286
|
}
|
|
11269
11287
|
const toEndMs = zone === void 0 ? toB.ms + DAY_MS2 - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
|
|
11270
11288
|
const filter = [
|
|
11271
11289
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11272
11290
|
{ field: "dateWorked", op: "lte", value: iso2(toEndMs) }
|
|
11273
11291
|
];
|
|
11274
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11292
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _73 => _73.limit])), "time_entries.customRange", http);
|
|
11275
11293
|
return items;
|
|
11276
11294
|
}
|
|
11277
11295
|
async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
11278
11296
|
const filter = [
|
|
11279
11297
|
{ field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
|
|
11280
11298
|
];
|
|
11281
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11299
|
+
if (_optionalChain([opts, 'optionalAccess', _74 => _74.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11282
11300
|
const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
|
|
11283
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11301
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _75 => _75.limit])), operation, http);
|
|
11284
11302
|
return items;
|
|
11285
11303
|
}
|
|
11286
11304
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
11287
11305
|
const OP2 = opLabel;
|
|
11288
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
11306
|
+
const zone = _optionalChain([opts, 'optionalAccess', _76 => _76.tz]) === void 0 ? void 0 : validateZone(opts.tz, OP2);
|
|
11289
11307
|
const fromB = customRangeDay(from, "from", zone, OP2);
|
|
11290
11308
|
const toB = customRangeDay(to, "to", zone, OP2);
|
|
11291
11309
|
if (fromB.ms > toB.ms) {
|
|
11292
|
-
throw new (0,
|
|
11310
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(`${OP2}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP2 });
|
|
11293
11311
|
}
|
|
11294
11312
|
const windowToMs = zone === void 0 ? toB.ms + DAY_MS2 - 1 : localDayEndMs(toB.y, toB.mo, toB.d, zone);
|
|
11295
11313
|
const filter = [
|
|
11296
11314
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11297
11315
|
{ field: "dateWorked", op: "lte", value: iso2(windowToMs) }
|
|
11298
11316
|
];
|
|
11299
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11300
|
-
else if (_optionalChain([opts, 'optionalAccess',
|
|
11301
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11302
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11303
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
11317
|
+
if (_optionalChain([opts, 'optionalAccess', _77 => _77.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
|
|
11318
|
+
else if (_optionalChain([opts, 'optionalAccess', _78 => _78.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
11319
|
+
if (_optionalChain([opts, 'optionalAccess', _79 => _79.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11320
|
+
if (_optionalChain([opts, 'optionalAccess', _80 => _80.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
11321
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _81 => _81.limit])), OP2, http);
|
|
11304
11322
|
let postedCount = 0;
|
|
11305
11323
|
for (const item of items) {
|
|
11306
11324
|
const postedDate = item.postedDate;
|
|
@@ -11356,13 +11374,13 @@ var LINKAGE_OWNED_FIELDS = /* @__PURE__ */ new Set([
|
|
|
11356
11374
|
"roleID"
|
|
11357
11375
|
]);
|
|
11358
11376
|
var TIME_WINDOW_FIELDS = /* @__PURE__ */ new Set(["dateWorked", "startDateTime", "endDateTime", "hoursWorked"]);
|
|
11359
|
-
var ResourceInvalidError = class extends
|
|
11377
|
+
var ResourceInvalidError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
11360
11378
|
constructor(message, options = {}) {
|
|
11361
11379
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11362
11380
|
this.name = "ResourceInvalidError";
|
|
11363
11381
|
}
|
|
11364
11382
|
};
|
|
11365
|
-
var AllocationCodeError = class extends
|
|
11383
|
+
var AllocationCodeError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
11366
11384
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
11367
11385
|
|
|
11368
11386
|
constructor(kind, message, options = {}) {
|
|
@@ -11371,7 +11389,7 @@ var AllocationCodeError = class extends _chunkIHRXVIUUcjs.AutotaskError {
|
|
|
11371
11389
|
this.kind = kind;
|
|
11372
11390
|
}
|
|
11373
11391
|
};
|
|
11374
|
-
var NoApplicableAllocationCodeError = class extends
|
|
11392
|
+
var NoApplicableAllocationCodeError = class extends _chunkXSIY3WRRcjs.AutotaskError {
|
|
11375
11393
|
/** The structured blocker details (filters tried + department sets). */
|
|
11376
11394
|
|
|
11377
11395
|
constructor(details, options = {}) {
|
|
@@ -11397,7 +11415,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
11397
11415
|
let pages = 0;
|
|
11398
11416
|
for (; ; ) {
|
|
11399
11417
|
if (pages >= PAGE_GUARD) {
|
|
11400
|
-
throw new (0,
|
|
11418
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
11401
11419
|
code: "RESOLUTION_TRUNCATED",
|
|
11402
11420
|
category: "resolution",
|
|
11403
11421
|
operation,
|
|
@@ -11408,11 +11426,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
11408
11426
|
const res = await http.request({
|
|
11409
11427
|
method: "POST",
|
|
11410
11428
|
idempotent: true,
|
|
11411
|
-
path: isFirst ? path :
|
|
11429
|
+
path: isFirst ? path : _chunkXSIY3WRRcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
11412
11430
|
body: { MaxRecords: pageSize, filter },
|
|
11413
11431
|
operation
|
|
11414
11432
|
});
|
|
11415
|
-
const { items: pageItems, pageDetails } =
|
|
11433
|
+
const { items: pageItems, pageDetails } = _chunkXSIY3WRRcjs.unwrapItems.call(void 0, res, operation);
|
|
11416
11434
|
items.push(...pageItems);
|
|
11417
11435
|
pages += 1;
|
|
11418
11436
|
if (items.length >= totalCap) break;
|
|
@@ -11525,8 +11543,8 @@ function windowDefaults(params) {
|
|
|
11525
11543
|
};
|
|
11526
11544
|
}
|
|
11527
11545
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
11528
|
-
const rid =
|
|
11529
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
11546
|
+
const rid = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
11547
|
+
const pin = (value, label) => typeof value === "number" ? _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
11530
11548
|
const pins = {
|
|
11531
11549
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
11532
11550
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -11535,19 +11553,19 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11535
11553
|
};
|
|
11536
11554
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
11537
11555
|
if (pinCount > 1) {
|
|
11538
|
-
throw new (0,
|
|
11556
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
11539
11557
|
"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)",
|
|
11540
11558
|
{ operation: OP }
|
|
11541
11559
|
);
|
|
11542
11560
|
}
|
|
11543
11561
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
11544
|
-
throw new (0,
|
|
11562
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
11545
11563
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
11546
11564
|
{ operation: OP }
|
|
11547
11565
|
);
|
|
11548
11566
|
}
|
|
11549
11567
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
11550
|
-
throw new (0,
|
|
11568
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)(
|
|
11551
11569
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
11552
11570
|
{ operation: OP }
|
|
11553
11571
|
);
|
|
@@ -11624,7 +11642,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11624
11642
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
11625
11643
|
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).");
|
|
11626
11644
|
}
|
|
11627
|
-
return
|
|
11645
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0,
|
|
11628
11646
|
{
|
|
11629
11647
|
operation: OP,
|
|
11630
11648
|
method: "POST",
|
|
@@ -11653,7 +11671,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11653
11671
|
for (let attempt = 1; attempt <= MAX_CREATE_ATTEMPTS; attempt += 1) {
|
|
11654
11672
|
if (usedLinkage !== "internal") body.roleID = roleCandidates[Math.min(attempt, roleCandidates.length) - 1];
|
|
11655
11673
|
try {
|
|
11656
|
-
const created = await resource.create(body, {});
|
|
11674
|
+
const created = await resource.create(body, { maxRetries: opts.maxRetries });
|
|
11657
11675
|
return {
|
|
11658
11676
|
id: created.id,
|
|
11659
11677
|
linkage: usedLinkage,
|
|
@@ -11663,7 +11681,7 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11663
11681
|
};
|
|
11664
11682
|
} catch (err) {
|
|
11665
11683
|
lastError = err;
|
|
11666
|
-
const text =
|
|
11684
|
+
const text = _chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkXSIY3WRRcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
11667
11685
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
11668
11686
|
if (usedLinkage !== "internal" && gate3) {
|
|
11669
11687
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
@@ -11683,14 +11701,14 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
11683
11701
|
throw err;
|
|
11684
11702
|
}
|
|
11685
11703
|
}
|
|
11686
|
-
if (
|
|
11704
|
+
if (_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, lastError)) {
|
|
11687
11705
|
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.`;
|
|
11688
11706
|
}
|
|
11689
11707
|
throw lastError;
|
|
11690
11708
|
}
|
|
11691
11709
|
function discoveryField(err, body, defaults) {
|
|
11692
|
-
if (!
|
|
11693
|
-
const entries =
|
|
11710
|
+
if (!_chunkXSIY3WRRcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11711
|
+
const entries = _chunkXSIY3WRRcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11694
11712
|
if (entries === void 0) return null;
|
|
11695
11713
|
for (const entry of entries) {
|
|
11696
11714
|
const field = entry.field;
|
|
@@ -11703,7 +11721,7 @@ function discoveryField(err, body, defaults) {
|
|
|
11703
11721
|
}
|
|
11704
11722
|
|
|
11705
11723
|
// src/resources/time_entries.ts
|
|
11706
|
-
var TimeEntriesResource = class extends
|
|
11724
|
+
var TimeEntriesResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
11707
11725
|
constructor(http, pageSize) {
|
|
11708
11726
|
super(http, {
|
|
11709
11727
|
key: "time_entries",
|
|
@@ -11756,7 +11774,7 @@ var TimeEntriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
11756
11774
|
async delete(id, opts = {}) {
|
|
11757
11775
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts);
|
|
11758
11776
|
await this.guardStaleBeforeMutation(id, opts, "time_entries.delete");
|
|
11759
|
-
return this.deleteGlobal(id);
|
|
11777
|
+
return this.deleteGlobal(id, opts);
|
|
11760
11778
|
}
|
|
11761
11779
|
/** Resolve a TimeEntry from a numeric id (or, where the vendor indexes a primary text field,
|
|
11762
11780
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -11840,7 +11858,7 @@ var TimeEntriesResource = class extends _chunkIHRXVIUUcjs.BaseResource {
|
|
|
11840
11858
|
};
|
|
11841
11859
|
|
|
11842
11860
|
// src/resources/time_entry_attachments.ts
|
|
11843
|
-
var TimeEntryAttachmentsResource = class extends
|
|
11861
|
+
var TimeEntryAttachmentsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
11844
11862
|
constructor(http, pageSize) {
|
|
11845
11863
|
super(http, {
|
|
11846
11864
|
key: "time_entry_attachments",
|
|
@@ -11882,7 +11900,7 @@ var TimeEntryAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
11882
11900
|
async delete(parentId, id, opts = {}) {
|
|
11883
11901
|
if (opts.dryRun === true) return this.runDeleteDryRun(id, opts, parentId);
|
|
11884
11902
|
await this.guardStaleBeforeMutation(id, opts, "time_entry_attachments.delete", parentId);
|
|
11885
|
-
return this.deleteScopedModel(parentId, id);
|
|
11903
|
+
return this.deleteScopedModel(parentId, id, opts);
|
|
11886
11904
|
}
|
|
11887
11905
|
/** Download the attachment bytes (GET .../{id}/data; node-proven path, quirk #9) → Buffer. */
|
|
11888
11906
|
async download(parentId, id) {
|
|
@@ -11903,9 +11921,9 @@ var TimeEntryAttachmentsResource = class extends _chunkIHRXVIUUcjs.BaseResource
|
|
|
11903
11921
|
|
|
11904
11922
|
// src/resources/special/time_off_requests.ts
|
|
11905
11923
|
async function approve(_resource, id, opts = {}, http) {
|
|
11906
|
-
const numericId =
|
|
11924
|
+
const numericId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
11907
11925
|
if (opts.dryRun === true) {
|
|
11908
|
-
return
|
|
11926
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
11909
11927
|
operation: "time_off_requests.approve",
|
|
11910
11928
|
method: "GET",
|
|
11911
11929
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -11918,18 +11936,19 @@ async function approve(_resource, id, opts = {}, http) {
|
|
|
11918
11936
|
const res = await http.request({
|
|
11919
11937
|
method: "GET",
|
|
11920
11938
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
11921
|
-
operation: "time_off_requests.approve"
|
|
11939
|
+
operation: "time_off_requests.approve",
|
|
11940
|
+
maxRetries: opts.maxRetries
|
|
11922
11941
|
});
|
|
11923
|
-
return
|
|
11942
|
+
return _chunkXSIY3WRRcjs.unwrapOperation.call(void 0, res);
|
|
11924
11943
|
}
|
|
11925
11944
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
11926
|
-
const numericId =
|
|
11945
|
+
const numericId = _chunkXSIY3WRRcjs.parseIdentifier.call(void 0, id, "id");
|
|
11927
11946
|
const text = reason.trim();
|
|
11928
11947
|
if (text === "") {
|
|
11929
|
-
throw new (0,
|
|
11948
|
+
throw new (0, _chunkXSIY3WRRcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
11930
11949
|
}
|
|
11931
11950
|
if (opts.dryRun === true) {
|
|
11932
|
-
return
|
|
11951
|
+
return _chunkXSIY3WRRcjs.buildDryRunResult.call(void 0, {
|
|
11933
11952
|
operation: "time_off_requests.reject",
|
|
11934
11953
|
method: "POST",
|
|
11935
11954
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -11944,13 +11963,14 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
11944
11963
|
method: "POST",
|
|
11945
11964
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
11946
11965
|
body: { timeOffRequestID: numericId, reason: text },
|
|
11947
|
-
operation: "time_off_requests.reject"
|
|
11966
|
+
operation: "time_off_requests.reject",
|
|
11967
|
+
maxRetries: opts.maxRetries
|
|
11948
11968
|
});
|
|
11949
|
-
return
|
|
11969
|
+
return _chunkXSIY3WRRcjs.unwrapOperation.call(void 0, res);
|
|
11950
11970
|
}
|
|
11951
11971
|
|
|
11952
11972
|
// src/resources/time_off_requests.ts
|
|
11953
|
-
var TimeOffRequestsResource = class extends
|
|
11973
|
+
var TimeOffRequestsResource = class extends _chunkXSIY3WRRcjs.BaseResource {
|
|
11954
11974
|
constructor(http, pageSize) {
|
|
11955
11975
|
super(http, {
|
|
11956
11976
|
key: "time_off_requests",
|