node-autotask 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/MCP_TOOL_CATALOG.json +921 -30
- package/MCP_TOOL_MANIFEST.md +69 -16
- package/N8N_MCP_MANIFEST.json +39 -8
- package/N8N_MCP_MANIFEST.md +9 -8
- package/README.md +11 -9
- package/capabilities.json +13316 -7733
- package/capabilities.schema.json +125 -0
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-SSUECUVN.js → chunk-42ZUISDH.js} +947 -128
- package/dist/{chunk-WM6E5O55.cjs → chunk-5CC7LGNM.cjs} +13315 -7732
- package/dist/{chunk-SG4LIVMG.cjs → chunk-5GGCSRT4.cjs} +848 -439
- package/dist/{chunk-QXWIQ67O.js → chunk-F7FVOXPQ.js} +13315 -7732
- package/dist/{chunk-7DOSJS6S.js → chunk-GURC52J7.js} +23 -2
- package/dist/{chunk-5OGJTS2E.cjs → chunk-UHTZLUDE.cjs} +157 -136
- package/dist/{chunk-VVQ6NJYZ.js → chunk-ZGTFVZL5.js} +433 -24
- package/dist/{chunk-HQGE4WAV.cjs → chunk-ZJ4ONAQF.cjs} +1054 -235
- package/dist/{index-CKYr0unq.d.cts → index-BIWy9m-a.d.ts} +379 -49
- package/dist/{index-C8QH3BkP.d.ts → index-D4XYtn4s.d.cts} +379 -49
- package/dist/{index-1zBdJIEy.d.cts → index-DQ9NgraW.d.cts} +281 -1
- package/dist/{index-1zBdJIEy.d.ts → index-DQ9NgraW.d.ts} +281 -1
- package/dist/index.cjs +44 -24
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +26 -6
- package/dist/operations/index.cjs +147 -120
- package/dist/operations/index.d.cts +136 -7
- package/dist/operations/index.d.ts +136 -7
- package/dist/operations/index.js +33 -6
- package/dist/pool.cjs +42 -9
- package/dist/pool.d.cts +14 -3
- package/dist/pool.d.ts +14 -3
- package/dist/pool.js +38 -5
- package/dist/resources/index.cjs +19 -5
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +18 -4
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/docs/API.md +207 -9
- package/examples/mcp/schemas.ts +16 -7
- package/package.json +1 -1
- /package/dist/{chunk-S643FDOR.cjs → chunk-IXF7AKOJ.cjs} +0 -0
- /package/dist/{chunk-2TWKEB2L.js → chunk-RMG55JTF.js} +0 -0
- /package/dist/{chunk-W3K5BEVY.cjs → chunk-SDYRQFGL.cjs} +0 -0
- /package/dist/{chunk-EBCHCNPK.js → chunk-WLTLB2ND.js} +0 -0
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
var
|
|
41
|
+
var _chunkZJ4ONAQFcjs = require('./chunk-ZJ4ONAQF.cjs');
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
var
|
|
44
|
+
var _chunk5CC7LGNMcjs = require('./chunk-5CC7LGNM.cjs');
|
|
45
45
|
|
|
46
46
|
// src/resources/appointments.ts
|
|
47
|
-
var AppointmentsResource = class extends
|
|
47
|
+
var AppointmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
48
48
|
constructor(http, pageSize) {
|
|
49
49
|
super(http, {
|
|
50
50
|
key: "appointments",
|
|
@@ -129,7 +129,7 @@ var AuthenticateResource = class {
|
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
// src/resources/billing_codes.ts
|
|
132
|
-
var BillingCodesResource = class extends
|
|
132
|
+
var BillingCodesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
133
133
|
constructor(http, pageSize) {
|
|
134
134
|
super(http, {
|
|
135
135
|
key: "billing_codes",
|
|
@@ -172,6 +172,42 @@ var BillingCodesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
// src/resources/billing_item_approval_levels.ts
|
|
176
|
+
var BillingItemApprovalLevelsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
177
|
+
constructor(http, pageSize) {
|
|
178
|
+
super(http, {
|
|
179
|
+
key: "billing_item_approval_levels",
|
|
180
|
+
resourcePath: "/V1.0/BillingItemApprovalLevels",
|
|
181
|
+
deletable: false,
|
|
182
|
+
udfCapable: false
|
|
183
|
+
}, pageSize);
|
|
184
|
+
}
|
|
185
|
+
/** Query BillingItemApprovalLevel records with the G3 filter surface (server-side JSON filter). */
|
|
186
|
+
query(params) {
|
|
187
|
+
return this.queryItems(params);
|
|
188
|
+
}
|
|
189
|
+
/** Get every BillingItemApprovalLevel record (the MCP-preferred read; 1000-page guarded). */
|
|
190
|
+
async queryAll(params) {
|
|
191
|
+
return this.queryAllItems(params);
|
|
192
|
+
}
|
|
193
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
194
|
+
async count(params) {
|
|
195
|
+
return this.countGlobal(params);
|
|
196
|
+
}
|
|
197
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
198
|
+
async get(id) {
|
|
199
|
+
return this.getGlobal(id);
|
|
200
|
+
}
|
|
201
|
+
/** Create a record (OperationResultModel → { id}). `dryRun: true` returns the
|
|
202
|
+
* pinned envelope (section 19.3) and never issues the create. A 2xx that is not the
|
|
203
|
+
* specced envelope runs the plan-pinned marker recovery (issue #13 — one bounded read;
|
|
204
|
+
* `recoverIdFromMarker: false` restores the pre-recovery behaviour). */
|
|
205
|
+
async create(data, opts = {}) {
|
|
206
|
+
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
207
|
+
return this.createGlobal(data, opts);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
175
211
|
// src/resources/special/dateWindow.ts
|
|
176
212
|
var DAY_MS = 864e5;
|
|
177
213
|
var DEFAULT_LIMIT = 500;
|
|
@@ -179,7 +215,7 @@ var MAX_LIMIT = 500;
|
|
|
179
215
|
function clampWindowLimit(limit) {
|
|
180
216
|
const n = limit === void 0 ? DEFAULT_LIMIT : Math.trunc(limit);
|
|
181
217
|
if (!Number.isInteger(n) || n < 1) {
|
|
182
|
-
throw new (0,
|
|
218
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
183
219
|
}
|
|
184
220
|
return Math.min(n, MAX_LIMIT);
|
|
185
221
|
}
|
|
@@ -225,7 +261,7 @@ function wallParts(tz, ms) {
|
|
|
225
261
|
}
|
|
226
262
|
}
|
|
227
263
|
if (weekday < 0 || [w.y, w.m, w.d, w.h, w.mi, w.s].some((v) => v === void 0 || Number.isNaN(v))) {
|
|
228
|
-
throw new (0,
|
|
264
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`dateWindow: could not read the wall-clock parts for timezone "${tz}" (the Intl format returned an incomplete or unmapped part)`);
|
|
229
265
|
}
|
|
230
266
|
return { y: w.y, m: w.m, d: w.d, h: w.h, mi: w.mi, s: w.s, weekday };
|
|
231
267
|
}
|
|
@@ -252,7 +288,7 @@ function localDayEndMs(y, m, d, tz) {
|
|
|
252
288
|
}
|
|
253
289
|
function validateZone(tz, opName = "dateWindow") {
|
|
254
290
|
if (typeof tz !== "string" || tz.length === 0) {
|
|
255
|
-
throw new (0,
|
|
291
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
256
292
|
`${opName}: tz must be a non-empty IANA timezone string (got ${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
257
293
|
{ operation: opName }
|
|
258
294
|
);
|
|
@@ -260,7 +296,7 @@ function validateZone(tz, opName = "dateWindow") {
|
|
|
260
296
|
try {
|
|
261
297
|
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
262
298
|
} catch (e2) {
|
|
263
|
-
throw new (0,
|
|
299
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
264
300
|
`${opName}: tz is not a valid IANA timezone (${JSON.stringify(tz)}; e.g. 'Australia/Sydney' \u2014 omitted tz = UTC)`,
|
|
265
301
|
{ operation: opName }
|
|
266
302
|
);
|
|
@@ -420,13 +456,13 @@ async function dateWindowQuery(http, path, field, kind, limit, operation, now, t
|
|
|
420
456
|
body: { MaxRecords: limit, filter },
|
|
421
457
|
operation
|
|
422
458
|
});
|
|
423
|
-
return
|
|
459
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
424
460
|
}
|
|
425
461
|
var isoUtc = (ms) => new Date(ms).toISOString().slice(0, 19) + "Z";
|
|
426
462
|
function customRangeDay(value, label, zone, opName) {
|
|
427
463
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
428
464
|
if (!m) {
|
|
429
|
-
throw new (0,
|
|
465
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
430
466
|
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)})`,
|
|
431
467
|
{ operation: opName }
|
|
432
468
|
);
|
|
@@ -438,7 +474,7 @@ function customRangeDay(value, label, zone, opName) {
|
|
|
438
474
|
const real = probe.getUTCFullYear() === y && probe.getUTCMonth() === mo - 1 && probe.getUTCDate() === d;
|
|
439
475
|
const ms = !real ? NaN : zone === void 0 ? Date.UTC(y, mo - 1, d) : localDayStartMs(y, mo, d, zone);
|
|
440
476
|
if (!Number.isFinite(ms)) {
|
|
441
|
-
throw new (0,
|
|
477
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
442
478
|
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)})`,
|
|
443
479
|
{ operation: opName }
|
|
444
480
|
);
|
|
@@ -449,7 +485,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
449
485
|
const fromB = customRangeDay(from, "from", zone, operation);
|
|
450
486
|
const toB = customRangeDay(to, "to", zone, operation);
|
|
451
487
|
if (fromB.ms > toB.ms) {
|
|
452
|
-
throw new (0,
|
|
488
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
453
489
|
`${operation}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`,
|
|
454
490
|
{ operation }
|
|
455
491
|
);
|
|
@@ -466,7 +502,7 @@ async function customRangeQuery(http, path, field, from, to, limit, operation, z
|
|
|
466
502
|
body: { MaxRecords: limit, filter },
|
|
467
503
|
operation
|
|
468
504
|
});
|
|
469
|
-
return
|
|
505
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
470
506
|
}
|
|
471
507
|
|
|
472
508
|
// src/resources/special/billing_items.ts
|
|
@@ -499,7 +535,7 @@ async function customRange(_resource, from, to, http, opts) {
|
|
|
499
535
|
}
|
|
500
536
|
|
|
501
537
|
// src/resources/billing_items.ts
|
|
502
|
-
var BillingItemsResource = class extends
|
|
538
|
+
var BillingItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
503
539
|
constructor(http, pageSize) {
|
|
504
540
|
super(http, {
|
|
505
541
|
key: "billing_items",
|
|
@@ -601,7 +637,7 @@ var BillingItemsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
601
637
|
};
|
|
602
638
|
|
|
603
639
|
// src/resources/change_request_links.ts
|
|
604
|
-
var ChangeRequestLinksResource = class extends
|
|
640
|
+
var ChangeRequestLinksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
605
641
|
constructor(http, pageSize) {
|
|
606
642
|
super(http, {
|
|
607
643
|
key: "change_request_links",
|
|
@@ -655,7 +691,7 @@ var ChangeRequestLinksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
655
691
|
};
|
|
656
692
|
|
|
657
693
|
// src/resources/checklist_libraries.ts
|
|
658
|
-
var ChecklistLibrariesResource = class extends
|
|
694
|
+
var ChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
659
695
|
constructor(http, pageSize) {
|
|
660
696
|
super(http, {
|
|
661
697
|
key: "checklist_libraries",
|
|
@@ -729,7 +765,7 @@ var ChecklistLibrariesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
729
765
|
};
|
|
730
766
|
|
|
731
767
|
// src/resources/checklist_library_checklist_items.ts
|
|
732
|
-
var ChecklistLibraryChecklistItemsResource = class extends
|
|
768
|
+
var ChecklistLibraryChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
733
769
|
constructor(http, pageSize) {
|
|
734
770
|
super(http, {
|
|
735
771
|
key: "checklist_library_checklist_items",
|
|
@@ -795,7 +831,7 @@ var ChecklistLibraryChecklistItemsResource = class extends _chunkHQGE4WAVcjs.Bas
|
|
|
795
831
|
};
|
|
796
832
|
|
|
797
833
|
// src/resources/classification_icons.ts
|
|
798
|
-
var ClassificationIconsResource = class extends
|
|
834
|
+
var ClassificationIconsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
799
835
|
constructor(http, pageSize) {
|
|
800
836
|
super(http, {
|
|
801
837
|
key: "classification_icons",
|
|
@@ -902,7 +938,7 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
|
|
|
902
938
|
body,
|
|
903
939
|
operation
|
|
904
940
|
});
|
|
905
|
-
const { items, pageDetails } =
|
|
941
|
+
const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
|
|
906
942
|
const capped = items.length >= limit;
|
|
907
943
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
908
944
|
}
|
|
@@ -912,7 +948,7 @@ var DEFAULT_LIMIT2 = 25;
|
|
|
912
948
|
var MAX_LIMIT2 = 500;
|
|
913
949
|
function clampLimit(limit) {
|
|
914
950
|
const n = limit === void 0 ? DEFAULT_LIMIT2 : Math.trunc(limit);
|
|
915
|
-
if (!Number.isInteger(n) || n < 1) throw new (0,
|
|
951
|
+
if (!Number.isInteger(n) || n < 1) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(limit)})`);
|
|
916
952
|
return Math.min(n, MAX_LIMIT2);
|
|
917
953
|
}
|
|
918
954
|
|
|
@@ -925,7 +961,7 @@ async function queryCompanies(http, filter, limit) {
|
|
|
925
961
|
body: { MaxRecords: limit, filter },
|
|
926
962
|
operation: "companies.searchByDomain"
|
|
927
963
|
});
|
|
928
|
-
return
|
|
964
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
929
965
|
}
|
|
930
966
|
async function queryContacts(http, filter, limit) {
|
|
931
967
|
const res = await http.request({
|
|
@@ -935,7 +971,7 @@ async function queryContacts(http, filter, limit) {
|
|
|
935
971
|
body: { MaxRecords: limit, filter },
|
|
936
972
|
operation: "companies.searchByDomain"
|
|
937
973
|
});
|
|
938
|
-
return
|
|
974
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
939
975
|
}
|
|
940
976
|
async function fetchCompanies(http, ids2, limit) {
|
|
941
977
|
const out = [];
|
|
@@ -950,7 +986,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
950
986
|
const item = body && "item" in body ? body.item : null;
|
|
951
987
|
if (item) out.push(item);
|
|
952
988
|
} catch (err) {
|
|
953
|
-
if (err instanceof
|
|
989
|
+
if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) continue;
|
|
954
990
|
throw err;
|
|
955
991
|
}
|
|
956
992
|
}
|
|
@@ -958,7 +994,7 @@ async function fetchCompanies(http, ids2, limit) {
|
|
|
958
994
|
}
|
|
959
995
|
async function searchByDomain(_resource, domain, opts = {}, http) {
|
|
960
996
|
const text = domain.trim();
|
|
961
|
-
if (text === "") throw new (0,
|
|
997
|
+
if (text === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("searchByDomain: empty domain");
|
|
962
998
|
const limit = clampLimit(opts.limit);
|
|
963
999
|
const filter = [{ field: "webAddress", op: "contains", value: text }];
|
|
964
1000
|
const direct = await queryCompanies(http, filter, limit);
|
|
@@ -972,7 +1008,7 @@ async function searchByIdentity(_resource, identity, opts = {}, http) {
|
|
|
972
1008
|
const email = _nullishCoalesce(_optionalChain([identity, 'access', _12 => _12.email, 'optionalAccess', _13 => _13.trim, 'call', _14 => _14()]), () => ( ""));
|
|
973
1009
|
const website = _nullishCoalesce(_optionalChain([identity, 'access', _15 => _15.website, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17()]), () => ( ""));
|
|
974
1010
|
if (name === "" && email === "" && website === "") {
|
|
975
|
-
throw new (0,
|
|
1011
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("searchByIdentity: at least one of companyName / email / website is required");
|
|
976
1012
|
}
|
|
977
1013
|
const limit = clampLimit(opts.limit);
|
|
978
1014
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -1001,23 +1037,23 @@ async function familyChildPage(http, parentID) {
|
|
|
1001
1037
|
path: "/V1.0/Companies/query",
|
|
1002
1038
|
body: {
|
|
1003
1039
|
MaxRecords: COMPANIES_FAMILY_CHILD_CAP,
|
|
1004
|
-
filter:
|
|
1040
|
+
filter: _chunkZJ4ONAQFcjs.buildFilter.call(void 0, [{ field: "parentCompanyID", op: "eq", value: parentID }]).filter
|
|
1005
1041
|
},
|
|
1006
1042
|
operation: "companies.search"
|
|
1007
1043
|
});
|
|
1008
|
-
const { items, pageDetails } =
|
|
1044
|
+
const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "companies.search");
|
|
1009
1045
|
return { rows: items, hasNext: pageDetails.nextPageUrl !== null };
|
|
1010
1046
|
}
|
|
1011
1047
|
function assertSearchWithDetailOpts(opts) {
|
|
1012
1048
|
if (opts === void 0) return;
|
|
1013
1049
|
if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
|
|
1014
|
-
throw new (0,
|
|
1050
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("companies.searchWithDetail: opts must be an object { limit?: number }", {
|
|
1015
1051
|
operation: "companies.searchWithDetail"
|
|
1016
1052
|
});
|
|
1017
1053
|
}
|
|
1018
1054
|
for (const key of Object.keys(opts)) {
|
|
1019
1055
|
if (key !== "limit") {
|
|
1020
|
-
throw new (0,
|
|
1056
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
1021
1057
|
`companies.searchWithDetail: unknown opts key "${key}" \u2014 the bag is closed: limit (includeFamily is a companies.search option)`,
|
|
1022
1058
|
{ operation: "companies.searchWithDetail" }
|
|
1023
1059
|
);
|
|
@@ -1026,32 +1062,32 @@ function assertSearchWithDetailOpts(opts) {
|
|
|
1026
1062
|
}
|
|
1027
1063
|
async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
1028
1064
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1029
|
-
throw new (0,
|
|
1065
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("companies.search: opts must be an object { limit?: number, includeFamily?: boolean }");
|
|
1030
1066
|
}
|
|
1031
1067
|
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
1032
1068
|
if (!COMPANY_SEARCH_OPT_KEYS.includes(key)) {
|
|
1033
|
-
throw new (0,
|
|
1069
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
1034
1070
|
`companies.search: unknown opts key "${key}" \u2014 the bag is closed: ${COMPANY_SEARCH_OPT_KEYS.join(", ")}`,
|
|
1035
1071
|
{ operation: "companies.search" }
|
|
1036
1072
|
);
|
|
1037
1073
|
}
|
|
1038
1074
|
}
|
|
1039
1075
|
if (opts.includeFamily !== void 0 && typeof opts.includeFamily !== "boolean") {
|
|
1040
|
-
throw new (0,
|
|
1076
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`companies.search: opts.includeFamily must be a boolean (got ${String(opts.includeFamily)})`, {
|
|
1041
1077
|
operation: "companies.search"
|
|
1042
1078
|
});
|
|
1043
1079
|
}
|
|
1044
1080
|
const text = query.trim();
|
|
1045
|
-
if (text === "") throw new (0,
|
|
1046
|
-
const limit = opts.limit === void 0 ? 25 :
|
|
1081
|
+
if (text === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("search: empty query", { operation: "companies.search" });
|
|
1082
|
+
const limit = opts.limit === void 0 ? 25 : _chunkZJ4ONAQFcjs.clampPageSize.call(void 0, opts.limit);
|
|
1047
1083
|
const res = await http.request({
|
|
1048
1084
|
method: "POST",
|
|
1049
1085
|
idempotent: true,
|
|
1050
1086
|
path: "/V1.0/Companies/query",
|
|
1051
|
-
body: { MaxRecords: limit, filter:
|
|
1087
|
+
body: { MaxRecords: limit, filter: _chunkZJ4ONAQFcjs.buildFilter.call(void 0, [{ field: "companyName", op: "contains", value: text }]).filter },
|
|
1052
1088
|
operation: "companies.search"
|
|
1053
1089
|
});
|
|
1054
|
-
const hits =
|
|
1090
|
+
const hits = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "companies.search").items;
|
|
1055
1091
|
if (opts.includeFamily !== true) return hits;
|
|
1056
1092
|
const rows = [];
|
|
1057
1093
|
for (const hit of hits) {
|
|
@@ -1071,7 +1107,7 @@ async function searchWithFamily(_resource, query, opts = {}, http) {
|
|
|
1071
1107
|
}
|
|
1072
1108
|
|
|
1073
1109
|
// src/resources/special/companies/errors.ts
|
|
1074
|
-
var OwnerResourceRequiredError = class extends
|
|
1110
|
+
var OwnerResourceRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
1075
1111
|
constructor(message, options = {}) {
|
|
1076
1112
|
super(message, {
|
|
1077
1113
|
code: "OWNER_RESOURCE_REQUIRED",
|
|
@@ -1082,13 +1118,13 @@ var OwnerResourceRequiredError = class extends _chunkHQGE4WAVcjs.AutotaskError {
|
|
|
1082
1118
|
this.name = "OwnerResourceRequiredError";
|
|
1083
1119
|
}
|
|
1084
1120
|
};
|
|
1085
|
-
var CompanyResourceInvalidError = class extends
|
|
1121
|
+
var CompanyResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
1086
1122
|
constructor(message, options = {}) {
|
|
1087
1123
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
1088
1124
|
this.name = "CompanyResourceInvalidError";
|
|
1089
1125
|
}
|
|
1090
1126
|
};
|
|
1091
|
-
var CompanyCreateFailedError = class extends
|
|
1127
|
+
var CompanyCreateFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
1092
1128
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
1093
1129
|
|
|
1094
1130
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -1107,23 +1143,23 @@ var BLIND_SURFACE_CAVEAT = "dedup only covers companies this API user can enumer
|
|
|
1107
1143
|
var SAFE_COMPANY_CREATE_DEFAULTS = {};
|
|
1108
1144
|
function validateUpsertInput(companyName, params) {
|
|
1109
1145
|
if (typeof companyName !== "string" || companyName.trim() === "") {
|
|
1110
|
-
throw new (0,
|
|
1146
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("upsertByName: companyName is required (a non-empty string)", { operation: OP_UPSERT_NAME });
|
|
1111
1147
|
}
|
|
1112
1148
|
if (typeof _optionalChain([params, 'optionalAccess', _18 => _18.phone]) !== "string" || params.phone.trim() === "") {
|
|
1113
|
-
throw new (0,
|
|
1149
|
+
throw new (0, _chunkZJ4ONAQFcjs.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 });
|
|
1114
1150
|
}
|
|
1115
1151
|
const companyType = _nullishCoalesce(params.companyType, () => ( DEFAULT_COMPANY_TYPE));
|
|
1116
1152
|
if (typeof companyType !== "number" || !Number.isSafeInteger(companyType) || companyType < 1) {
|
|
1117
|
-
throw new (0,
|
|
1153
|
+
throw new (0, _chunkZJ4ONAQFcjs.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 });
|
|
1118
1154
|
}
|
|
1119
1155
|
const owner = params.ownerResourceID;
|
|
1120
1156
|
if (owner !== void 0 && (typeof owner !== "number" || !Number.isSafeInteger(owner) || owner < 1)) {
|
|
1121
|
-
throw new (0,
|
|
1157
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`upsertByName: params.ownerResourceID must be a positive integer (got ${String(owner)})`, { operation: OP_UPSERT_NAME });
|
|
1122
1158
|
}
|
|
1123
1159
|
return { companyType, owner };
|
|
1124
1160
|
}
|
|
1125
1161
|
function existsDryRun(http, companyName, match) {
|
|
1126
|
-
return
|
|
1162
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
1127
1163
|
{
|
|
1128
1164
|
operation: OP_UPSERT_NAME,
|
|
1129
1165
|
method: "POST",
|
|
@@ -1149,7 +1185,7 @@ function createDryRun(http, body, owner) {
|
|
|
1149
1185
|
"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"
|
|
1150
1186
|
);
|
|
1151
1187
|
}
|
|
1152
|
-
return
|
|
1188
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
1153
1189
|
{
|
|
1154
1190
|
operation: OP_UPSERT_NAME,
|
|
1155
1191
|
method: "POST",
|
|
@@ -1194,8 +1230,8 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1194
1230
|
sideEffects: ['vendor auto-creates a "Primary Address" location under the new company (UI-only cleanup \u2014 the delete 405 gap, \xA711.5)']
|
|
1195
1231
|
};
|
|
1196
1232
|
} catch (err) {
|
|
1197
|
-
if (!
|
|
1198
|
-
const named = (_nullishCoalesce(
|
|
1233
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
1234
|
+
const named = (_nullishCoalesce(_chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
1199
1235
|
const seen = /* @__PURE__ */ new Set();
|
|
1200
1236
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
1201
1237
|
const hasDefault = unique.some((f) => SAFE_COMPANY_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -1209,7 +1245,7 @@ async function createWithDiscovery(resource, body, owner, caveat, opts) {
|
|
|
1209
1245
|
}
|
|
1210
1246
|
continue;
|
|
1211
1247
|
}
|
|
1212
|
-
const detail =
|
|
1248
|
+
const detail = _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
1213
1249
|
throw new CompanyCreateFailedError(
|
|
1214
1250
|
`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}` : ""}`,
|
|
1215
1251
|
unique,
|
|
@@ -1270,30 +1306,30 @@ var LOCATION_LIMIT_MAX = 500;
|
|
|
1270
1306
|
function locationLimit(value) {
|
|
1271
1307
|
if (value === void 0) return PROFILE_PART_LIMIT;
|
|
1272
1308
|
if (!Number.isInteger(value) || value < 1 || value > LOCATION_LIMIT_MAX) {
|
|
1273
|
-
throw new (0,
|
|
1309
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: locationLimit must be an integer 1-${LOCATION_LIMIT_MAX} (got ${String(value)})`);
|
|
1274
1310
|
}
|
|
1275
1311
|
return value;
|
|
1276
1312
|
}
|
|
1277
1313
|
function validateProjection(fields) {
|
|
1278
1314
|
if (fields === void 0) return {};
|
|
1279
1315
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields)) {
|
|
1280
|
-
throw new (0,
|
|
1316
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("fullProfile: fields must be an object keyed by part name");
|
|
1281
1317
|
}
|
|
1282
1318
|
const out = {};
|
|
1283
1319
|
for (const [part, list] of Object.entries(fields)) {
|
|
1284
1320
|
if (!FULL_PROFILE_PROJECTABLE_PARTS.includes(part)) {
|
|
1285
|
-
throw new (0,
|
|
1321
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: fields has unknown part "${part.slice(0, 40)}" \u2014 projectable parts: ${FULL_PROFILE_PROJECTABLE_PARTS.join(", ")}`);
|
|
1286
1322
|
}
|
|
1287
1323
|
if (!Array.isArray(list) || list.length === 0 || list.some((n) => typeof n !== "string" || n.length === 0)) {
|
|
1288
|
-
throw new (0,
|
|
1324
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: fields.${part} must be a non-empty array of field-name strings`);
|
|
1289
1325
|
}
|
|
1290
1326
|
const names = [...new Set(list)];
|
|
1291
1327
|
const entity = PART_ENTITY[part];
|
|
1292
|
-
const known = _nullishCoalesce(
|
|
1328
|
+
const known = _nullishCoalesce(_chunkZJ4ONAQFcjs.MODEL_FIELD_SETS[entity], () => ( []));
|
|
1293
1329
|
const unknown = names.filter((n) => !known.includes(n));
|
|
1294
1330
|
if (unknown.length > 0) {
|
|
1295
|
-
throw new (0,
|
|
1296
|
-
`fullProfile: fields.${part} has unknown field name(s) ${
|
|
1331
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
1332
|
+
`fullProfile: fields.${part} has unknown field name(s) ${_chunkZJ4ONAQFcjs.formatUnknownNameList.call(void 0, unknown)} against the vendored spec for ${entity} (${known.length} fields; operations.fieldCatalog resources: ["${entity}"] lists the live set) \u2014 no request was issued`
|
|
1297
1333
|
);
|
|
1298
1334
|
}
|
|
1299
1335
|
out[part] = names;
|
|
@@ -1310,7 +1346,7 @@ function project(items, names) {
|
|
|
1310
1346
|
function profilePartLimit(value, name) {
|
|
1311
1347
|
const n = value === void 0 ? PROFILE_PART_LIMIT : Math.trunc(value);
|
|
1312
1348
|
if (!Number.isInteger(n) || n < 1) {
|
|
1313
|
-
throw new (0,
|
|
1349
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullProfile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
1314
1350
|
}
|
|
1315
1351
|
return n;
|
|
1316
1352
|
}
|
|
@@ -1322,7 +1358,7 @@ async function scopedCompanyQuery(http, path, companyID, limit, includeFields) {
|
|
|
1322
1358
|
body: { MaxRecords: limit, filter: [{ field: "companyID", op: "eq", value: companyID }], ...includeFields ? { IncludeFields: includeFields } : {} },
|
|
1323
1359
|
operation: "companies.fullProfile"
|
|
1324
1360
|
});
|
|
1325
|
-
return project(
|
|
1361
|
+
return project(_chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1326
1362
|
}
|
|
1327
1363
|
async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
1328
1364
|
const openRows = await (async () => {
|
|
@@ -1337,7 +1373,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1337
1373
|
},
|
|
1338
1374
|
operation: "companies.fullProfile"
|
|
1339
1375
|
});
|
|
1340
|
-
return project(
|
|
1376
|
+
return project(_chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items, includeFields);
|
|
1341
1377
|
})();
|
|
1342
1378
|
let openTickets = {
|
|
1343
1379
|
items: openRows,
|
|
@@ -1346,7 +1382,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1346
1382
|
note: OPEN_TICKETS_NOTE
|
|
1347
1383
|
};
|
|
1348
1384
|
if (openRows.length === 0) {
|
|
1349
|
-
const stamp =
|
|
1385
|
+
const stamp = _chunkZJ4ONAQFcjs.blindStampFor.call(void 0, _optionalChain([_chunkZJ4ONAQFcjs.BLIND_SURFACE_STAMPS, 'access', _19 => _19["tickets"], 'optionalAccess', _20 => _20.query]), [
|
|
1350
1386
|
{ field: "companyID", op: "eq", value: companyID },
|
|
1351
1387
|
{ field: "status", op: "noteq", value: 5 }
|
|
1352
1388
|
]);
|
|
@@ -1363,7 +1399,7 @@ async function readOpenTickets(http, companyID, ticketLimit, includeFields) {
|
|
|
1363
1399
|
return openTickets;
|
|
1364
1400
|
}
|
|
1365
1401
|
async function addProfileNames(http, company, openTickets, projects, result, opts) {
|
|
1366
|
-
const builder =
|
|
1402
|
+
const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS);
|
|
1367
1403
|
const c = company;
|
|
1368
1404
|
builder.addResource(c["ownerResourceID"]);
|
|
1369
1405
|
builder.addResource(c["createdByResourceID"]);
|
|
@@ -1380,20 +1416,20 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1380
1416
|
builder.addResource(r["creatorResourceID"]);
|
|
1381
1417
|
builder.addFk("contract", r["contractID"]);
|
|
1382
1418
|
}
|
|
1383
|
-
const names = await
|
|
1419
|
+
const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
1384
1420
|
const companyRow = { ...company };
|
|
1385
|
-
|
|
1386
|
-
|
|
1421
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, companyRow, "ownerResourceID", (v) => names.resourceName(v));
|
|
1422
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, companyRow, "createdByResourceID", (v) => names.resourceName(v));
|
|
1387
1423
|
result.company = companyRow;
|
|
1388
1424
|
result.openTickets = {
|
|
1389
1425
|
...openTickets,
|
|
1390
1426
|
items: openTickets.items.map((row) => {
|
|
1391
1427
|
const r = { ...row };
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
for (const f of
|
|
1428
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1429
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1430
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
1431
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
1432
|
+
for (const f of _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS) _chunkZJ4ONAQFcjs.addLabelSibling.call(void 0, r, f, names);
|
|
1397
1433
|
return r;
|
|
1398
1434
|
})
|
|
1399
1435
|
};
|
|
@@ -1401,9 +1437,9 @@ async function addProfileNames(http, company, openTickets, projects, result, opt
|
|
|
1401
1437
|
...result.projects,
|
|
1402
1438
|
items: result.projects.items.map((row) => {
|
|
1403
1439
|
const r = { ...row };
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1440
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "projectLeadResourceID", (v) => names.resourceName(v));
|
|
1441
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "creatorResourceID", (v) => names.resourceName(v));
|
|
1442
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, r, "contractID", (v) => names.recordName("contract", v));
|
|
1407
1443
|
return r;
|
|
1408
1444
|
})
|
|
1409
1445
|
};
|
|
@@ -1416,7 +1452,7 @@ async function fullProfile(resource, id, opts = {}, http) {
|
|
|
1416
1452
|
const projectLimit = profilePartLimit(opts.projectLimit, "projectLimit");
|
|
1417
1453
|
const locLimit = locationLimit(opts.locationLimit);
|
|
1418
1454
|
const proj = validateProjection(opts.fields);
|
|
1419
|
-
const companyID =
|
|
1455
|
+
const companyID = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
1420
1456
|
const company = await resource.get(companyID);
|
|
1421
1457
|
const locations = await scopedCompanyQuery(http, "/V1.0/CompanyLocations/query", companyID, locLimit, proj.locations);
|
|
1422
1458
|
const contacts = await scopedCompanyQuery(http, "/V1.0/Contacts/query", companyID, contactLimit, proj.contacts);
|
|
@@ -1463,7 +1499,7 @@ var UNBILLED_WORK_OPT_KEYS = [
|
|
|
1463
1499
|
var UNBILLED_WORK_SOURCE_SET = ["posted_uninvoiced", "invoice", "date_range", "tickets"];
|
|
1464
1500
|
function validateUnbilledWorkOptions(companyId, opts) {
|
|
1465
1501
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1466
|
-
throw new (0,
|
|
1502
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
1467
1503
|
`unbilledWork: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
1468
1504
|
{ operation: "companies.unbilledWork" }
|
|
1469
1505
|
);
|
|
@@ -1492,7 +1528,7 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1492
1528
|
try {
|
|
1493
1529
|
limit = clampLimit(opts.limit);
|
|
1494
1530
|
} catch (err) {
|
|
1495
|
-
problems.push(err instanceof
|
|
1531
|
+
problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : `limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
1496
1532
|
limit = 50;
|
|
1497
1533
|
}
|
|
1498
1534
|
if (source === "date_range") {
|
|
@@ -1507,9 +1543,9 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1507
1543
|
problems.push('invoiceId is required (the vendor invoice id) when source is "invoice"');
|
|
1508
1544
|
} else {
|
|
1509
1545
|
try {
|
|
1510
|
-
|
|
1546
|
+
_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, opts.invoiceId, "opts.invoiceId");
|
|
1511
1547
|
} catch (err) {
|
|
1512
|
-
problems.push(err instanceof
|
|
1548
|
+
problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : "invoiceId must be a vendor numeric id");
|
|
1513
1549
|
}
|
|
1514
1550
|
}
|
|
1515
1551
|
}
|
|
@@ -1519,20 +1555,20 @@ function validateUnbilledWorkOptions(companyId, opts) {
|
|
|
1519
1555
|
} else {
|
|
1520
1556
|
opts.ticketIds.forEach((tid, i) => {
|
|
1521
1557
|
try {
|
|
1522
|
-
|
|
1558
|
+
_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, tid, `opts.ticketIds[${i}]`);
|
|
1523
1559
|
} catch (err) {
|
|
1524
|
-
problems.push(err instanceof
|
|
1560
|
+
problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : `ticketIds[${i}] must be a vendor numeric id`);
|
|
1525
1561
|
}
|
|
1526
1562
|
});
|
|
1527
1563
|
}
|
|
1528
1564
|
}
|
|
1529
1565
|
try {
|
|
1530
|
-
|
|
1566
|
+
_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1531
1567
|
} catch (err) {
|
|
1532
|
-
problems.push(err instanceof
|
|
1568
|
+
problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : "companyId must be a vendor numeric id");
|
|
1533
1569
|
}
|
|
1534
1570
|
if (problems.length > 0) {
|
|
1535
|
-
throw new (0,
|
|
1571
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
1536
1572
|
`unbilledWork: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
1537
1573
|
- ` + problems.join("\n- "),
|
|
1538
1574
|
{ operation: "companies.unbilledWork" }
|
|
@@ -1561,7 +1597,7 @@ function capJoinSet(ids2, cap) {
|
|
|
1561
1597
|
}
|
|
1562
1598
|
function unbilledWorkPartStatus(key, conditions, items) {
|
|
1563
1599
|
if (items.length !== 0) return { status: "ok" };
|
|
1564
|
-
const stamp =
|
|
1600
|
+
const stamp = _chunkZJ4ONAQFcjs.blindStampFor.call(void 0, _optionalChain([_chunkZJ4ONAQFcjs.BLIND_SURFACE_STAMPS, 'access', _21 => _21[key], 'optionalAccess', _22 => _22.query]), conditions);
|
|
1565
1601
|
if (stamp !== void 0) return { status: "blind", blindSurface: stamp, note: stamp.note };
|
|
1566
1602
|
return {
|
|
1567
1603
|
status: "ok",
|
|
@@ -1581,7 +1617,7 @@ async function readCompanyAndParent(resource, id, includeParent) {
|
|
|
1581
1617
|
parentStatus = "ok";
|
|
1582
1618
|
companyIds.push(num(parent.id));
|
|
1583
1619
|
} catch (err) {
|
|
1584
|
-
if (err instanceof
|
|
1620
|
+
if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) parent = null;
|
|
1585
1621
|
else throw err;
|
|
1586
1622
|
}
|
|
1587
1623
|
}
|
|
@@ -1619,14 +1655,14 @@ async function readBillingPart(http, v, companyIds) {
|
|
|
1619
1655
|
if (v.dateFrom !== void 0) billingConditions.push({ field: "itemDate", op: "gte", value: v.dateFrom });
|
|
1620
1656
|
if (v.dateTo !== void 0) billingConditions.push({ field: "itemDate", op: "lte", value: v.dateTo });
|
|
1621
1657
|
}
|
|
1622
|
-
const billingFields =
|
|
1658
|
+
const billingFields = _chunkZJ4ONAQFcjs.resolveFieldsPreset.call(void 0, "billing_join", "billing_items");
|
|
1623
1659
|
const billingIncludeFields = [...billingFields, "id", ...v.includeNotes ? ["description"] : []];
|
|
1624
1660
|
const billingRaw = await boundedPart(http, "/V1.0/BillingItems/query", billingConditions, v.limit, OP, billingIncludeFields);
|
|
1625
1661
|
let billingItems = billingRaw.items;
|
|
1626
1662
|
let billingNoteCharsTruncated = 0;
|
|
1627
1663
|
if (v.includeNotes) {
|
|
1628
|
-
const noteFields = (_nullishCoalesce(
|
|
1629
|
-
[billingItems, billingNoteCharsTruncated] =
|
|
1664
|
+
const noteFields = (_nullishCoalesce(_chunkZJ4ONAQFcjs.UNTRUSTED_FIELDS_BY_RESOURCE["billing_items"], () => ( []))).filter((f) => billingIncludeFields.includes(f));
|
|
1665
|
+
[billingItems, billingNoteCharsTruncated] = _chunkZJ4ONAQFcjs.truncateNoteChars.call(void 0, billingRaw.items, v.noteChars, noteFields);
|
|
1630
1666
|
}
|
|
1631
1667
|
const billingSt = unbilledWorkPartStatus("billing_items", billingConditions, billingRaw.items);
|
|
1632
1668
|
const billingItemsPart = {
|
|
@@ -1670,7 +1706,7 @@ async function readTimePart(http, v, join) {
|
|
|
1670
1706
|
let cappedItems = entries;
|
|
1671
1707
|
let noteCharsTruncated = 0;
|
|
1672
1708
|
if (v.includeNotes) {
|
|
1673
|
-
[cappedItems, noteCharsTruncated] =
|
|
1709
|
+
[cappedItems, noteCharsTruncated] = _chunkZJ4ONAQFcjs.truncateNoteChars.call(void 0, entries, v.noteChars, ["summaryNotes"]);
|
|
1674
1710
|
}
|
|
1675
1711
|
const st = unbilledWorkPartStatus("time_entries", timeConditions, entries);
|
|
1676
1712
|
timePart = {
|
|
@@ -1758,7 +1794,7 @@ function unpostedAndWarnings(v, billingItems, entries, entryByTimeId) {
|
|
|
1758
1794
|
}
|
|
1759
1795
|
async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
1760
1796
|
const v = validateUnbilledWorkOptions(companyId, opts);
|
|
1761
|
-
const id =
|
|
1797
|
+
const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, companyId, "companyId");
|
|
1762
1798
|
const { company, parent, parentStatus, companyIds } = await readCompanyAndParent(resource, id, v.includeParent);
|
|
1763
1799
|
const join = await readJoinSets(http, companyIds, v);
|
|
1764
1800
|
const { billingItems, billingSt, billingItemsPart } = await readBillingPart(http, v, companyIds);
|
|
@@ -1785,7 +1821,7 @@ async function unbilledWork(resource, companyId, opts = {}, http) {
|
|
|
1785
1821
|
}
|
|
1786
1822
|
|
|
1787
1823
|
// src/resources/companies.ts
|
|
1788
|
-
var CompaniesResource = class extends
|
|
1824
|
+
var CompaniesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
1789
1825
|
constructor(http, pageSize) {
|
|
1790
1826
|
super(http, {
|
|
1791
1827
|
key: "companies",
|
|
@@ -1892,7 +1928,7 @@ var CompaniesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
1892
1928
|
};
|
|
1893
1929
|
|
|
1894
1930
|
// src/resources/company_alerts.ts
|
|
1895
|
-
var CompanyAlertsResource = class extends
|
|
1931
|
+
var CompanyAlertsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
1896
1932
|
constructor(http, pageSize) {
|
|
1897
1933
|
super(http, {
|
|
1898
1934
|
key: "company_alerts",
|
|
@@ -1958,7 +1994,7 @@ var CompanyAlertsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
1958
1994
|
};
|
|
1959
1995
|
|
|
1960
1996
|
// src/resources/company_locations.ts
|
|
1961
|
-
var CompanyLocationsResource = class extends
|
|
1997
|
+
var CompanyLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
1962
1998
|
constructor(http, pageSize) {
|
|
1963
1999
|
super(http, {
|
|
1964
2000
|
key: "company_locations",
|
|
@@ -2029,7 +2065,7 @@ var CompanyLocationsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
2029
2065
|
};
|
|
2030
2066
|
|
|
2031
2067
|
// src/resources/company_notes.ts
|
|
2032
|
-
var CompanyNotesResource = class extends
|
|
2068
|
+
var CompanyNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2033
2069
|
constructor(http, pageSize) {
|
|
2034
2070
|
super(http, {
|
|
2035
2071
|
key: "company_notes",
|
|
@@ -2094,7 +2130,7 @@ var CompanyNotesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
2094
2130
|
};
|
|
2095
2131
|
|
|
2096
2132
|
// src/resources/company_site_configurations.ts
|
|
2097
|
-
var CompanySiteConfigurationsResource = class extends
|
|
2133
|
+
var CompanySiteConfigurationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2098
2134
|
constructor(http, pageSize) {
|
|
2099
2135
|
super(http, {
|
|
2100
2136
|
key: "company_site_configurations",
|
|
@@ -2145,7 +2181,7 @@ var CompanySiteConfigurationsResource = class extends _chunkHQGE4WAVcjs.BaseReso
|
|
|
2145
2181
|
};
|
|
2146
2182
|
|
|
2147
2183
|
// src/resources/company_webhooks.ts
|
|
2148
|
-
var CompanyWebhooksResource = class extends
|
|
2184
|
+
var CompanyWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2149
2185
|
constructor(http, pageSize) {
|
|
2150
2186
|
super(http, {
|
|
2151
2187
|
key: "company_webhooks",
|
|
@@ -2221,7 +2257,7 @@ var CompanyWebhooksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
2221
2257
|
};
|
|
2222
2258
|
|
|
2223
2259
|
// src/resources/configuration_item_billing_product_associations.ts
|
|
2224
|
-
var ConfigurationItemBillingProductAssociationsResource = class extends
|
|
2260
|
+
var ConfigurationItemBillingProductAssociationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2225
2261
|
constructor(http, pageSize) {
|
|
2226
2262
|
super(http, {
|
|
2227
2263
|
key: "configuration_item_billing_product_associations",
|
|
@@ -2287,7 +2323,7 @@ var ConfigurationItemBillingProductAssociationsResource = class extends _chunkHQ
|
|
|
2287
2323
|
};
|
|
2288
2324
|
|
|
2289
2325
|
// src/resources/configuration_item_categories.ts
|
|
2290
|
-
var ConfigurationItemCategoriesResource = class extends
|
|
2326
|
+
var ConfigurationItemCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2291
2327
|
constructor(http, pageSize) {
|
|
2292
2328
|
super(http, {
|
|
2293
2329
|
key: "configuration_item_categories",
|
|
@@ -2354,7 +2390,7 @@ var ConfigurationItemCategoriesResource = class extends _chunkHQGE4WAVcjs.BaseRe
|
|
|
2354
2390
|
};
|
|
2355
2391
|
|
|
2356
2392
|
// src/resources/configuration_item_category_udf_associations.ts
|
|
2357
|
-
var ConfigurationItemCategoryUdfAssociationsResource = class extends
|
|
2393
|
+
var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2358
2394
|
constructor(http, pageSize) {
|
|
2359
2395
|
super(http, {
|
|
2360
2396
|
key: "configuration_item_category_udf_associations",
|
|
@@ -2420,7 +2456,7 @@ var ConfigurationItemCategoryUdfAssociationsResource = class extends _chunkHQGE4
|
|
|
2420
2456
|
};
|
|
2421
2457
|
|
|
2422
2458
|
// src/resources/configuration_item_dns_records.ts
|
|
2423
|
-
var ConfigurationItemDnsRecordsResource = class extends
|
|
2459
|
+
var ConfigurationItemDnsRecordsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2424
2460
|
constructor(http, pageSize) {
|
|
2425
2461
|
super(http, {
|
|
2426
2462
|
key: "configuration_item_dns_records",
|
|
@@ -2469,7 +2505,7 @@ var ConfigurationItemDnsRecordsResource = class extends _chunkHQGE4WAVcjs.BaseRe
|
|
|
2469
2505
|
};
|
|
2470
2506
|
|
|
2471
2507
|
// src/resources/configuration_item_notes.ts
|
|
2472
|
-
var ConfigurationItemNotesResource = class extends
|
|
2508
|
+
var ConfigurationItemNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2473
2509
|
constructor(http, pageSize) {
|
|
2474
2510
|
super(http, {
|
|
2475
2511
|
key: "configuration_item_notes",
|
|
@@ -2528,7 +2564,7 @@ var ConfigurationItemNotesResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
2528
2564
|
};
|
|
2529
2565
|
|
|
2530
2566
|
// src/resources/configuration_item_related_items.ts
|
|
2531
|
-
var ConfigurationItemRelatedItemsResource = class extends
|
|
2567
|
+
var ConfigurationItemRelatedItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2532
2568
|
constructor(http, pageSize) {
|
|
2533
2569
|
super(http, {
|
|
2534
2570
|
key: "configuration_item_related_items",
|
|
@@ -2589,16 +2625,16 @@ async function fetchRecord(http, path, label, readOpts) {
|
|
|
2589
2625
|
const res = await http.request({ method: "GET", path, operation: "configuration_items.moveConfigurationItem", maxRetries: _optionalChain([readOpts, 'optionalAccess', _27 => _27.maxRetries]) });
|
|
2590
2626
|
const body = res;
|
|
2591
2627
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
2592
|
-
throw new (0,
|
|
2628
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
2593
2629
|
}
|
|
2594
2630
|
return body.item;
|
|
2595
2631
|
}
|
|
2596
2632
|
async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
2597
|
-
const numericSource =
|
|
2633
|
+
const numericSource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, sourceId, "sourceId");
|
|
2598
2634
|
if (_optionalChain([opts, 'optionalAccess', _28 => _28.destinationCompanyId]) === void 0) {
|
|
2599
|
-
throw new (0,
|
|
2635
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("moveConfigurationItem: destinationCompanyId is required");
|
|
2600
2636
|
}
|
|
2601
|
-
const destId =
|
|
2637
|
+
const destId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, opts.destinationCompanyId, "destinationCompanyId");
|
|
2602
2638
|
const source = await fetchRecord(http, `/V1.0/ConfigurationItems/${numericSource}`, `Configuration item ${numericSource}`, { maxRetries: opts.maxRetries });
|
|
2603
2639
|
await fetchRecord(http, `/V1.0/Companies/${destId}`, `Company ${destId}`, { maxRetries: opts.maxRetries });
|
|
2604
2640
|
const body = { ...source };
|
|
@@ -2608,20 +2644,20 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2608
2644
|
body.companyID = destId;
|
|
2609
2645
|
body.isActive = true;
|
|
2610
2646
|
if (opts.newReferenceTitle !== void 0) {
|
|
2611
|
-
if (opts.newReferenceTitle.trim() === "") throw new (0,
|
|
2647
|
+
if (opts.newReferenceTitle.trim() === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("moveConfigurationItem: newReferenceTitle must be non-empty");
|
|
2612
2648
|
body.referenceTitle = opts.newReferenceTitle.trim();
|
|
2613
2649
|
}
|
|
2614
2650
|
if (opts.lastModifiedDate !== void 0) {
|
|
2615
2651
|
const current = source.lastModifiedDate;
|
|
2616
2652
|
if (current !== opts.lastModifiedDate) {
|
|
2617
|
-
throw new (0,
|
|
2653
|
+
throw new (0, _chunkZJ4ONAQFcjs.StaleObjectError)(
|
|
2618
2654
|
`moveConfigurationItem: source item ${numericSource} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${_nullishCoalesce(current, () => ( "unknown"))})`,
|
|
2619
2655
|
{ operation: "configuration_items.moveConfigurationItem", resourceIds: [numericSource], details: { idRefs: [{ entity: "configuration_item", id: numericSource }] } }
|
|
2620
2656
|
);
|
|
2621
2657
|
}
|
|
2622
2658
|
}
|
|
2623
2659
|
if (opts.dryRun === true) {
|
|
2624
|
-
return
|
|
2660
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
2625
2661
|
operation: "configuration_items.moveConfigurationItem",
|
|
2626
2662
|
method: "POST",
|
|
2627
2663
|
path: "/V1.0/ConfigurationItems",
|
|
@@ -2646,7 +2682,7 @@ async function moveConfigurationItem(_resource, sourceId, opts, http) {
|
|
|
2646
2682
|
const createdBody = created;
|
|
2647
2683
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
2648
2684
|
if (typeof newId !== "number") {
|
|
2649
|
-
throw new (0,
|
|
2685
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("moveConfigurationItem: vendor create response has no itemId");
|
|
2650
2686
|
}
|
|
2651
2687
|
let sourceDeactivated = false;
|
|
2652
2688
|
if (opts.deactivateSource !== false) {
|
|
@@ -2665,7 +2701,7 @@ var PROFILE_PART_LIMIT2 = 50;
|
|
|
2665
2701
|
function profilePartLimit2(value, name) {
|
|
2666
2702
|
const n = value === void 0 ? PROFILE_PART_LIMIT2 : Math.trunc(value);
|
|
2667
2703
|
if (!Number.isInteger(n) || n < 1) {
|
|
2668
|
-
throw new (0,
|
|
2704
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`profile: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
2669
2705
|
}
|
|
2670
2706
|
return n;
|
|
2671
2707
|
}
|
|
@@ -2681,14 +2717,14 @@ async function contextFetchPart(http, entityPath, referenceId, entity) {
|
|
|
2681
2717
|
});
|
|
2682
2718
|
const body = res;
|
|
2683
2719
|
if (body === null || !("item" in body)) {
|
|
2684
|
-
throw new (0,
|
|
2720
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`context part not found (unexpected envelope shape)`, { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2685
2721
|
}
|
|
2686
2722
|
if (body.item === null || body.item === void 0) {
|
|
2687
|
-
throw new (0,
|
|
2723
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)("context part not found", { resourceIds: [referenceId], details: { idRefs: [{ entity, id: referenceId }] } });
|
|
2688
2724
|
}
|
|
2689
2725
|
return body.item;
|
|
2690
2726
|
} catch (err) {
|
|
2691
|
-
if (err instanceof
|
|
2727
|
+
if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) return null;
|
|
2692
2728
|
throw err;
|
|
2693
2729
|
}
|
|
2694
2730
|
}
|
|
@@ -2700,7 +2736,7 @@ async function ciScopedQuery(http, path, itemID, limit) {
|
|
|
2700
2736
|
body: { MaxRecords: limit, filter: [{ field: "configurationItemID", op: "eq", value: itemID }] },
|
|
2701
2737
|
operation: "configuration_items.profile"
|
|
2702
2738
|
});
|
|
2703
|
-
return
|
|
2739
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
2704
2740
|
}
|
|
2705
2741
|
async function profile(resource, id, opts = {}, http) {
|
|
2706
2742
|
const noteLimit = profilePartLimit2(opts.noteLimit, "noteLimit");
|
|
@@ -2712,7 +2748,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2712
2748
|
const notes = await ciScopedQuery(http, "/V1.0/ConfigurationItemNotes/query", id, noteLimit);
|
|
2713
2749
|
const relatedItems = await ciScopedQuery(http, "/V1.0/ConfigurationItemRelatedItems/query", id, relatedLimit);
|
|
2714
2750
|
const associations = await ciScopedQuery(http, "/V1.0/ConfigurationItemBillingProductAssociations/query", id, PROFILE_PART_LIMIT2);
|
|
2715
|
-
const wallQuirk = _optionalChain([
|
|
2751
|
+
const wallQuirk = _optionalChain([_chunkZJ4ONAQFcjs.RELATIONSHIP_MAP, 'access', _29 => _29["configuration_items"], 'optionalAccess', _30 => _30.zoneFacts, 'optionalAccess', _31 => _31.quirks, 'optionalAccess', _32 => _32.find, 'call', _33 => _33((q) => q.startsWith("product wall"))]);
|
|
2716
2752
|
const productAssociations = {
|
|
2717
2753
|
items: associations,
|
|
2718
2754
|
capped: associations.length >= PROFILE_PART_LIMIT2,
|
|
@@ -2736,11 +2772,11 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2736
2772
|
}
|
|
2737
2773
|
};
|
|
2738
2774
|
if (opts.names === true) {
|
|
2739
|
-
const builder =
|
|
2775
|
+
const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, );
|
|
2740
2776
|
builder.addFk("contract", root["contractID"]);
|
|
2741
|
-
const names = await
|
|
2777
|
+
const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
2742
2778
|
const ciRow = { ...ci };
|
|
2743
|
-
|
|
2779
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ciRow, "contractID", (v) => names.recordName("contract", v));
|
|
2744
2780
|
result.ci = ciRow;
|
|
2745
2781
|
result.names = names.section;
|
|
2746
2782
|
}
|
|
@@ -2748,7 +2784,7 @@ async function profile(resource, id, opts = {}, http) {
|
|
|
2748
2784
|
}
|
|
2749
2785
|
|
|
2750
2786
|
// src/resources/configuration_items.ts
|
|
2751
|
-
var ConfigurationItemsResource = class extends
|
|
2787
|
+
var ConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2752
2788
|
constructor(http, pageSize) {
|
|
2753
2789
|
super(http, {
|
|
2754
2790
|
key: "configuration_items",
|
|
@@ -2837,7 +2873,7 @@ var ConfigurationItemsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
2837
2873
|
};
|
|
2838
2874
|
|
|
2839
2875
|
// src/resources/configuration_item_ssl_subject_alternative_names.ts
|
|
2840
|
-
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends
|
|
2876
|
+
var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2841
2877
|
constructor(http, pageSize) {
|
|
2842
2878
|
super(http, {
|
|
2843
2879
|
key: "configuration_item_ssl_subject_alternative_names",
|
|
@@ -2900,7 +2936,7 @@ var ConfigurationItemSslSubjectAlternativeNamesResource = class extends _chunkHQ
|
|
|
2900
2936
|
};
|
|
2901
2937
|
|
|
2902
2938
|
// src/resources/configuration_item_types.ts
|
|
2903
|
-
var ConfigurationItemTypesResource = class extends
|
|
2939
|
+
var ConfigurationItemTypesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2904
2940
|
constructor(http, pageSize) {
|
|
2905
2941
|
super(http, {
|
|
2906
2942
|
key: "configuration_item_types",
|
|
@@ -2974,7 +3010,7 @@ var ConfigurationItemTypesResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
2974
3010
|
};
|
|
2975
3011
|
|
|
2976
3012
|
// src/resources/configuration_item_webhooks.ts
|
|
2977
|
-
var ConfigurationItemWebhooksResource = class extends
|
|
3013
|
+
var ConfigurationItemWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
2978
3014
|
constructor(http, pageSize) {
|
|
2979
3015
|
super(http, {
|
|
2980
3016
|
key: "configuration_item_webhooks",
|
|
@@ -3050,7 +3086,7 @@ var ConfigurationItemWebhooksResource = class extends _chunkHQGE4WAVcjs.BaseReso
|
|
|
3050
3086
|
};
|
|
3051
3087
|
|
|
3052
3088
|
// src/resources/contact_group_contacts.ts
|
|
3053
|
-
var ContactGroupContactsResource = class extends
|
|
3089
|
+
var ContactGroupContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3054
3090
|
constructor(http, pageSize) {
|
|
3055
3091
|
super(http, {
|
|
3056
3092
|
key: "contact_group_contacts",
|
|
@@ -3104,7 +3140,7 @@ var ContactGroupContactsResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
3104
3140
|
};
|
|
3105
3141
|
|
|
3106
3142
|
// src/resources/contact_groups.ts
|
|
3107
|
-
var ContactGroupsResource = class extends
|
|
3143
|
+
var ContactGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3108
3144
|
constructor(http, pageSize) {
|
|
3109
3145
|
super(http, {
|
|
3110
3146
|
key: "contact_groups",
|
|
@@ -3182,22 +3218,22 @@ async function fetchRecord2(http, path, label, readOpts) {
|
|
|
3182
3218
|
const res = await http.request({ method: "GET", path, operation: "contacts.moveToCompany", maxRetries: _optionalChain([readOpts, 'optionalAccess', _39 => _39.maxRetries]) });
|
|
3183
3219
|
const body = res;
|
|
3184
3220
|
if (body === null || !("item" in body) || body.item === null || body.item === void 0) {
|
|
3185
|
-
throw new (0,
|
|
3221
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`${label} not found`, { code: "NOT_FOUND", category: "not_found" });
|
|
3186
3222
|
}
|
|
3187
3223
|
return body.item;
|
|
3188
3224
|
}
|
|
3189
3225
|
async function moveToCompany(_resource, sourceContactId, destinationCompanyId, opts = {}, http) {
|
|
3190
|
-
const sourceId =
|
|
3191
|
-
const destId =
|
|
3226
|
+
const sourceId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, sourceContactId, "sourceContactId");
|
|
3227
|
+
const destId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, destinationCompanyId, "destinationCompanyId");
|
|
3192
3228
|
const source = await fetchRecord2(http, `/V1.0/Contacts/${sourceId}`, `Contact ${sourceId}`, { maxRetries: opts.maxRetries });
|
|
3193
3229
|
const companyID = source.companyID;
|
|
3194
3230
|
if (typeof companyID !== "number" || companyID < 0) {
|
|
3195
|
-
throw new (0,
|
|
3231
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Contact ${sourceId} has no companyID (cannot scope the source delete)`);
|
|
3196
3232
|
}
|
|
3197
3233
|
if (opts.lastModifiedDate !== void 0) {
|
|
3198
3234
|
const current = source.lastModifiedDate;
|
|
3199
3235
|
if (current !== opts.lastModifiedDate) {
|
|
3200
|
-
throw new (0,
|
|
3236
|
+
throw new (0, _chunkZJ4ONAQFcjs.StaleObjectError)(
|
|
3201
3237
|
`moveToCompany: source contact ${sourceId} was modified since the snapshot (expected lastModifiedDate ${opts.lastModifiedDate}, current ${typeof current === "string" ? current : "unknown"})`,
|
|
3202
3238
|
{ operation: "contacts.moveToCompany", resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3203
3239
|
);
|
|
@@ -3219,10 +3255,10 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3219
3255
|
},
|
|
3220
3256
|
operation: "contacts.moveToCompany"
|
|
3221
3257
|
});
|
|
3222
|
-
const items =
|
|
3258
|
+
const items = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
3223
3259
|
const clash = items.find((c) => String(c.id) !== String(sourceId));
|
|
3224
3260
|
if (clash !== void 0) {
|
|
3225
|
-
throw new (0,
|
|
3261
|
+
throw new (0, _chunkZJ4ONAQFcjs.ConflictError)(
|
|
3226
3262
|
`Contact email "${email}" already exists under company ${destId} (contact ${String(clash.id)}); aborting the move`,
|
|
3227
3263
|
{ resourceIds: [sourceId, destId], details: { idRefs: [{ entity: "contact", id: sourceId }, { entity: "company", id: destId }] } }
|
|
3228
3264
|
);
|
|
@@ -3236,7 +3272,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3236
3272
|
if (opts.dryRun === true) {
|
|
3237
3273
|
const warnings = [];
|
|
3238
3274
|
if (opts.deleteSource === true) warnings.push("the source contact will be deleted after the move");
|
|
3239
|
-
return
|
|
3275
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
3240
3276
|
operation: "contacts.moveToCompany",
|
|
3241
3277
|
method: "POST",
|
|
3242
3278
|
path: `/V1.0/Companies/${destId}/Contacts`,
|
|
@@ -3262,7 +3298,7 @@ async function moveToCompany(_resource, sourceContactId, destinationCompanyId, o
|
|
|
3262
3298
|
const createdBody = created;
|
|
3263
3299
|
const newId = createdBody !== null ? _nullishCoalesce(createdBody.itemId, () => ( createdBody.id)) : void 0;
|
|
3264
3300
|
if (typeof newId !== "number") {
|
|
3265
|
-
throw new (0,
|
|
3301
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("contacts.moveToCompany: vendor create response has no itemId");
|
|
3266
3302
|
}
|
|
3267
3303
|
let sourceDeleted = false;
|
|
3268
3304
|
if (opts.deleteSource === true) {
|
|
@@ -3281,7 +3317,7 @@ var UPSERT_MAX_DISCOVERY_MERGES = 3;
|
|
|
3281
3317
|
var EMAIL_SHAPE = /^.+@.+/;
|
|
3282
3318
|
var SAFE_CONTACT_CREATE_DEFAULTS = {};
|
|
3283
3319
|
var DEDUP_LIMIT = 10;
|
|
3284
|
-
var CompanyNotFoundError = class extends
|
|
3320
|
+
var CompanyNotFoundError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
3285
3321
|
constructor(message, options = {}) {
|
|
3286
3322
|
super(message, {
|
|
3287
3323
|
code: "COMPANY_NOT_FOUND",
|
|
@@ -3292,7 +3328,7 @@ var CompanyNotFoundError = class extends _chunkHQGE4WAVcjs.AutotaskError {
|
|
|
3292
3328
|
this.name = "CompanyNotFoundError";
|
|
3293
3329
|
}
|
|
3294
3330
|
};
|
|
3295
|
-
var ContactCreateFailedError = class extends
|
|
3331
|
+
var ContactCreateFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
3296
3332
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
3297
3333
|
|
|
3298
3334
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -3302,25 +3338,25 @@ var ContactCreateFailedError = class extends _chunkHQGE4WAVcjs.AutotaskError {
|
|
|
3302
3338
|
}
|
|
3303
3339
|
};
|
|
3304
3340
|
async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
3305
|
-
const cid =
|
|
3341
|
+
const cid = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, companyID, "companyID");
|
|
3306
3342
|
if (typeof email !== "string" || !EMAIL_SHAPE.test(email)) {
|
|
3307
|
-
throw new (0,
|
|
3343
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
3308
3344
|
`upsertByEmail: email must be a non-empty string with the @ shape (a non-empty local part + a non-empty domain; got ${JSON.stringify(email)})`,
|
|
3309
3345
|
{ operation: OP_UPSERT_EMAIL }
|
|
3310
3346
|
);
|
|
3311
3347
|
}
|
|
3312
3348
|
if (extra !== void 0) {
|
|
3313
3349
|
if (extra.isActive !== void 0 && typeof extra.isActive !== "boolean" && extra.isActive !== 0 && extra.isActive !== 1) {
|
|
3314
|
-
throw new (0,
|
|
3350
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
3315
3351
|
`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)})`,
|
|
3316
3352
|
{ operation: OP_UPSERT_EMAIL }
|
|
3317
3353
|
);
|
|
3318
3354
|
}
|
|
3319
3355
|
if (extra.firstName !== void 0 && (typeof extra.firstName !== "string" || extra.firstName === "")) {
|
|
3320
|
-
throw new (0,
|
|
3356
|
+
throw new (0, _chunkZJ4ONAQFcjs.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 });
|
|
3321
3357
|
}
|
|
3322
3358
|
if (extra.lastName !== void 0 && typeof extra.lastName !== "string") {
|
|
3323
|
-
throw new (0,
|
|
3359
|
+
throw new (0, _chunkZJ4ONAQFcjs.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 });
|
|
3324
3360
|
}
|
|
3325
3361
|
}
|
|
3326
3362
|
const parentRes = await http.request({ method: "GET", path: `/V1.0/Companies/${cid}`, operation: OP_UPSERT_EMAIL, maxRetries: opts.maxRetries });
|
|
@@ -3341,7 +3377,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3341
3377
|
const match = q.items[0];
|
|
3342
3378
|
if (match !== void 0) {
|
|
3343
3379
|
if (opts.dryRun === true) {
|
|
3344
|
-
return
|
|
3380
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
3345
3381
|
{
|
|
3346
3382
|
operation: OP_UPSERT_EMAIL,
|
|
3347
3383
|
method: "POST",
|
|
@@ -3371,7 +3407,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3371
3407
|
isActive: typeof isActive === "boolean" ? isActive ? 1 : 0 : isActive
|
|
3372
3408
|
};
|
|
3373
3409
|
if (opts.dryRun === true) {
|
|
3374
|
-
return
|
|
3410
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
3375
3411
|
{
|
|
3376
3412
|
operation: OP_UPSERT_EMAIL,
|
|
3377
3413
|
method: "POST",
|
|
@@ -3394,8 +3430,8 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3394
3430
|
const created = await resource.create(cid, body, { maxRetries: opts.maxRetries });
|
|
3395
3431
|
return { id: created.id, created: true };
|
|
3396
3432
|
} catch (err) {
|
|
3397
|
-
if (!
|
|
3398
|
-
const named = (_nullishCoalesce(
|
|
3433
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) throw err;
|
|
3434
|
+
const named = (_nullishCoalesce(_chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []))).map((e) => e.field).filter((f) => f !== void 0);
|
|
3399
3435
|
const seen = /* @__PURE__ */ new Set();
|
|
3400
3436
|
const unique = [...named].filter((f) => seen.has(f) ? false : (seen.add(f), true));
|
|
3401
3437
|
const hasDefault = unique.some((f) => SAFE_CONTACT_CREATE_DEFAULTS[f] !== void 0);
|
|
@@ -3409,7 +3445,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3409
3445
|
}
|
|
3410
3446
|
continue;
|
|
3411
3447
|
}
|
|
3412
|
-
const detail =
|
|
3448
|
+
const detail = _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError);
|
|
3413
3449
|
throw new ContactCreateFailedError(
|
|
3414
3450
|
`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}` : ""}`,
|
|
3415
3451
|
unique,
|
|
@@ -3426,7 +3462,7 @@ async function upsertByEmail(resource, companyID, email, extra, opts, http) {
|
|
|
3426
3462
|
}
|
|
3427
3463
|
|
|
3428
3464
|
// src/resources/contacts.ts
|
|
3429
|
-
var ContactsResource = class extends
|
|
3465
|
+
var ContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3430
3466
|
constructor(http, pageSize) {
|
|
3431
3467
|
super(http, {
|
|
3432
3468
|
key: "contacts",
|
|
@@ -3518,7 +3554,7 @@ var ContactsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
3518
3554
|
};
|
|
3519
3555
|
|
|
3520
3556
|
// src/resources/contact_webhooks.ts
|
|
3521
|
-
var ContactWebhooksResource = class extends
|
|
3557
|
+
var ContactWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3522
3558
|
constructor(http, pageSize) {
|
|
3523
3559
|
super(http, {
|
|
3524
3560
|
key: "contact_webhooks",
|
|
@@ -3594,7 +3630,7 @@ var ContactWebhooksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
3594
3630
|
};
|
|
3595
3631
|
|
|
3596
3632
|
// src/resources/contract_billing_rules.ts
|
|
3597
|
-
var ContractBillingRulesResource = class extends
|
|
3633
|
+
var ContractBillingRulesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3598
3634
|
constructor(http, pageSize) {
|
|
3599
3635
|
super(http, {
|
|
3600
3636
|
key: "contract_billing_rules",
|
|
@@ -3660,7 +3696,7 @@ var ContractBillingRulesResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
3660
3696
|
};
|
|
3661
3697
|
|
|
3662
3698
|
// src/resources/contract_block_hour_factors.ts
|
|
3663
|
-
var ContractBlockHourFactorsResource = class extends
|
|
3699
|
+
var ContractBlockHourFactorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3664
3700
|
constructor(http, pageSize) {
|
|
3665
3701
|
super(http, {
|
|
3666
3702
|
key: "contract_block_hour_factors",
|
|
@@ -3719,7 +3755,7 @@ var ContractBlockHourFactorsResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
3719
3755
|
};
|
|
3720
3756
|
|
|
3721
3757
|
// src/resources/contract_blocks.ts
|
|
3722
|
-
var ContractBlocksResource = class extends
|
|
3758
|
+
var ContractBlocksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3723
3759
|
constructor(http, pageSize) {
|
|
3724
3760
|
super(http, {
|
|
3725
3761
|
key: "contract_blocks",
|
|
@@ -3778,7 +3814,7 @@ var ContractBlocksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
3778
3814
|
};
|
|
3779
3815
|
|
|
3780
3816
|
// src/resources/contract_charges.ts
|
|
3781
|
-
var ContractChargesResource = class extends
|
|
3817
|
+
var ContractChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3782
3818
|
constructor(http, pageSize) {
|
|
3783
3819
|
super(http, {
|
|
3784
3820
|
key: "contract_charges",
|
|
@@ -3849,7 +3885,7 @@ var ContractChargesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
3849
3885
|
};
|
|
3850
3886
|
|
|
3851
3887
|
// src/resources/contract_exclusion_billing_codes.ts
|
|
3852
|
-
var ContractExclusionBillingCodesResource = class extends
|
|
3888
|
+
var ContractExclusionBillingCodesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3853
3889
|
constructor(http, pageSize) {
|
|
3854
3890
|
super(http, {
|
|
3855
3891
|
key: "contract_exclusion_billing_codes",
|
|
@@ -3906,7 +3942,7 @@ var ContractExclusionBillingCodesResource = class extends _chunkHQGE4WAVcjs.Base
|
|
|
3906
3942
|
};
|
|
3907
3943
|
|
|
3908
3944
|
// src/resources/contract_exclusion_roles.ts
|
|
3909
|
-
var ContractExclusionRolesResource = class extends
|
|
3945
|
+
var ContractExclusionRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3910
3946
|
constructor(http, pageSize) {
|
|
3911
3947
|
super(http, {
|
|
3912
3948
|
key: "contract_exclusion_roles",
|
|
@@ -3963,7 +3999,7 @@ var ContractExclusionRolesResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
3963
3999
|
};
|
|
3964
4000
|
|
|
3965
4001
|
// src/resources/contract_exclusion_set_excluded_roles.ts
|
|
3966
|
-
var ContractExclusionSetExcludedRolesResource = class extends
|
|
4002
|
+
var ContractExclusionSetExcludedRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
3967
4003
|
constructor(http, pageSize) {
|
|
3968
4004
|
super(http, {
|
|
3969
4005
|
key: "contract_exclusion_set_excluded_roles",
|
|
@@ -4020,7 +4056,7 @@ var ContractExclusionSetExcludedRolesResource = class extends _chunkHQGE4WAVcjs.
|
|
|
4020
4056
|
};
|
|
4021
4057
|
|
|
4022
4058
|
// src/resources/contract_exclusion_set_excluded_work_types.ts
|
|
4023
|
-
var ContractExclusionSetExcludedWorkTypesResource = class extends
|
|
4059
|
+
var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4024
4060
|
constructor(http, pageSize) {
|
|
4025
4061
|
super(http, {
|
|
4026
4062
|
key: "contract_exclusion_set_excluded_work_types",
|
|
@@ -4077,7 +4113,7 @@ var ContractExclusionSetExcludedWorkTypesResource = class extends _chunkHQGE4WAV
|
|
|
4077
4113
|
};
|
|
4078
4114
|
|
|
4079
4115
|
// src/resources/contract_exclusion_sets.ts
|
|
4080
|
-
var ContractExclusionSetsResource = class extends
|
|
4116
|
+
var ContractExclusionSetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4081
4117
|
constructor(http, pageSize) {
|
|
4082
4118
|
super(http, {
|
|
4083
4119
|
key: "contract_exclusion_sets",
|
|
@@ -4151,7 +4187,7 @@ var ContractExclusionSetsResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
4151
4187
|
};
|
|
4152
4188
|
|
|
4153
4189
|
// src/resources/contract_milestones.ts
|
|
4154
|
-
var ContractMilestonesResource = class extends
|
|
4190
|
+
var ContractMilestonesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4155
4191
|
constructor(http, pageSize) {
|
|
4156
4192
|
super(http, {
|
|
4157
4193
|
key: "contract_milestones",
|
|
@@ -4210,7 +4246,7 @@ var ContractMilestonesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
4210
4246
|
};
|
|
4211
4247
|
|
|
4212
4248
|
// src/resources/contract_notes.ts
|
|
4213
|
-
var ContractNotesResource = class extends
|
|
4249
|
+
var ContractNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4214
4250
|
constructor(http, pageSize) {
|
|
4215
4251
|
super(http, {
|
|
4216
4252
|
key: "contract_notes",
|
|
@@ -4269,7 +4305,7 @@ var ContractNotesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
4269
4305
|
};
|
|
4270
4306
|
|
|
4271
4307
|
// src/resources/contract_rates.ts
|
|
4272
|
-
var ContractRatesResource = class extends
|
|
4308
|
+
var ContractRatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4273
4309
|
constructor(http, pageSize) {
|
|
4274
4310
|
super(http, {
|
|
4275
4311
|
key: "contract_rates",
|
|
@@ -4328,7 +4364,7 @@ var ContractRatesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
4328
4364
|
};
|
|
4329
4365
|
|
|
4330
4366
|
// src/resources/contract_retainers.ts
|
|
4331
|
-
var ContractRetainersResource = class extends
|
|
4367
|
+
var ContractRetainersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4332
4368
|
constructor(http, pageSize) {
|
|
4333
4369
|
super(http, {
|
|
4334
4370
|
key: "contract_retainers",
|
|
@@ -4387,7 +4423,7 @@ var ContractRetainersResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
4387
4423
|
};
|
|
4388
4424
|
|
|
4389
4425
|
// src/resources/contract_role_costs.ts
|
|
4390
|
-
var ContractRoleCostsResource = class extends
|
|
4426
|
+
var ContractRoleCostsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4391
4427
|
constructor(http, pageSize) {
|
|
4392
4428
|
super(http, {
|
|
4393
4429
|
key: "contract_role_costs",
|
|
@@ -4446,7 +4482,7 @@ var ContractRoleCostsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
4446
4482
|
};
|
|
4447
4483
|
|
|
4448
4484
|
// src/resources/contract_service_adjustments.ts
|
|
4449
|
-
var ContractServiceAdjustmentsResource = class extends
|
|
4485
|
+
var ContractServiceAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4450
4486
|
constructor(http, pageSize) {
|
|
4451
4487
|
super(http, {
|
|
4452
4488
|
key: "contract_service_adjustments",
|
|
@@ -4480,7 +4516,7 @@ var ContractServiceAdjustmentsResource = class extends _chunkHQGE4WAVcjs.BaseRes
|
|
|
4480
4516
|
};
|
|
4481
4517
|
|
|
4482
4518
|
// src/resources/contract_service_bundle_adjustments.ts
|
|
4483
|
-
var ContractServiceBundleAdjustmentsResource = class extends
|
|
4519
|
+
var ContractServiceBundleAdjustmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4484
4520
|
constructor(http, pageSize) {
|
|
4485
4521
|
super(http, {
|
|
4486
4522
|
key: "contract_service_bundle_adjustments",
|
|
@@ -4514,7 +4550,7 @@ var ContractServiceBundleAdjustmentsResource = class extends _chunkHQGE4WAVcjs.B
|
|
|
4514
4550
|
};
|
|
4515
4551
|
|
|
4516
4552
|
// src/resources/contract_service_bundles.ts
|
|
4517
|
-
var ContractServiceBundlesResource = class extends
|
|
4553
|
+
var ContractServiceBundlesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4518
4554
|
constructor(http, pageSize) {
|
|
4519
4555
|
super(http, {
|
|
4520
4556
|
key: "contract_service_bundles",
|
|
@@ -4573,7 +4609,7 @@ var ContractServiceBundlesResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
4573
4609
|
};
|
|
4574
4610
|
|
|
4575
4611
|
// src/resources/contract_service_bundle_units.ts
|
|
4576
|
-
var ContractServiceBundleUnitsResource = class extends
|
|
4612
|
+
var ContractServiceBundleUnitsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4577
4613
|
constructor(http, pageSize) {
|
|
4578
4614
|
super(http, {
|
|
4579
4615
|
key: "contract_service_bundle_units",
|
|
@@ -4615,7 +4651,7 @@ var ContractServiceBundleUnitsResource = class extends _chunkHQGE4WAVcjs.BaseRes
|
|
|
4615
4651
|
};
|
|
4616
4652
|
|
|
4617
4653
|
// src/resources/contract_services.ts
|
|
4618
|
-
var ContractServicesResource = class extends
|
|
4654
|
+
var ContractServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4619
4655
|
constructor(http, pageSize) {
|
|
4620
4656
|
super(http, {
|
|
4621
4657
|
key: "contract_services",
|
|
@@ -4674,7 +4710,7 @@ var ContractServicesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
4674
4710
|
};
|
|
4675
4711
|
|
|
4676
4712
|
// src/resources/contract_service_units.ts
|
|
4677
|
-
var ContractServiceUnitsResource = class extends
|
|
4713
|
+
var ContractServiceUnitsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
4678
4714
|
constructor(http, pageSize) {
|
|
4679
4715
|
super(http, {
|
|
4680
4716
|
key: "contract_service_units",
|
|
@@ -4942,7 +4978,7 @@ function buildCostRateResolution(ctx, entries, entryResolution) {
|
|
|
4942
4978
|
// src/resources/special/contracts/profitability.validate.ts
|
|
4943
4979
|
function validateProfitabilityOptions(contractId, opts) {
|
|
4944
4980
|
if (opts === void 0 || (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
4945
|
-
throw new (0,
|
|
4981
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
4946
4982
|
`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})`,
|
|
4947
4983
|
{ operation: "contracts.profitability" }
|
|
4948
4984
|
);
|
|
@@ -5019,12 +5055,12 @@ function validateProfitabilityOptions(contractId, opts) {
|
|
|
5019
5055
|
}
|
|
5020
5056
|
}
|
|
5021
5057
|
try {
|
|
5022
|
-
|
|
5058
|
+
_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5023
5059
|
} catch (err) {
|
|
5024
|
-
problems.push(err instanceof
|
|
5060
|
+
problems.push(err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.message : "contractId must be a vendor numeric id");
|
|
5025
5061
|
}
|
|
5026
5062
|
if (problems.length > 0) {
|
|
5027
|
-
throw new (0,
|
|
5063
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
5028
5064
|
`profitability: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
5029
5065
|
- ` + problems.join("\n- "),
|
|
5030
5066
|
{ operation: "contracts.profitability" }
|
|
@@ -5073,23 +5109,23 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5073
5109
|
const byKey = /* @__PURE__ */ new Map();
|
|
5074
5110
|
const misses = [];
|
|
5075
5111
|
const notes = [];
|
|
5076
|
-
for (let c = 0; c < unique.length; c +=
|
|
5077
|
-
const chunk = unique.slice(c, c +
|
|
5112
|
+
for (let c = 0; c < unique.length; c += _chunkZJ4ONAQFcjs.FETCH_BY_IDS_CHUNK_SIZE) {
|
|
5113
|
+
const chunk = unique.slice(c, c + _chunkZJ4ONAQFcjs.FETCH_BY_IDS_CHUNK_SIZE);
|
|
5078
5114
|
const chunkKeys = new Set(chunk);
|
|
5079
5115
|
try {
|
|
5080
5116
|
const body = {
|
|
5081
|
-
MaxRecords:
|
|
5117
|
+
MaxRecords: _chunkZJ4ONAQFcjs.FETCH_BY_IDS_CHUNK_SIZE,
|
|
5082
5118
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
5083
5119
|
IncludeFields: fields
|
|
5084
5120
|
};
|
|
5085
5121
|
const res = await http.request({ method: "POST", idempotent: true, path: `${entityPath}/query`, body, operation });
|
|
5086
|
-
const { items: rows } =
|
|
5122
|
+
const { items: rows } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
|
|
5087
5123
|
for (const row of rows) {
|
|
5088
5124
|
const k = num(row.id);
|
|
5089
5125
|
if (k > 0 && chunkKeys.has(k)) byKey.set(k, row);
|
|
5090
5126
|
}
|
|
5091
5127
|
} catch (err) {
|
|
5092
|
-
const code = err instanceof
|
|
5128
|
+
const code = err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.code : "SERVER_ERROR";
|
|
5093
5129
|
for (const k of chunk) {
|
|
5094
5130
|
if (!byKey.has(k) && !misses.some((m) => m.id === k)) misses.push({ id: k, code, message: err instanceof Error ? err.message : String(err) });
|
|
5095
5131
|
}
|
|
@@ -5099,11 +5135,11 @@ async function fetchByIdsPart(http, entityPath, ids2, fields, operation, entity)
|
|
|
5099
5135
|
for (const k of queryMissed) {
|
|
5100
5136
|
try {
|
|
5101
5137
|
const res = await http.request({ method: "GET", path: `${entityPath}/${k}`, operation });
|
|
5102
|
-
byKey.set(k,
|
|
5138
|
+
byKey.set(k, _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, k, operation, entity));
|
|
5103
5139
|
} catch (err) {
|
|
5104
|
-
if (err instanceof
|
|
5140
|
+
if (err instanceof _chunkZJ4ONAQFcjs.NotFoundError) {
|
|
5105
5141
|
misses.push({ id: k, code: "NOT_FOUND", message: err.message });
|
|
5106
|
-
} else if (err instanceof
|
|
5142
|
+
} else if (err instanceof _chunkZJ4ONAQFcjs.AutotaskError) {
|
|
5107
5143
|
misses.push({ id: k, code: err.code, message: err.message });
|
|
5108
5144
|
} else {
|
|
5109
5145
|
misses.push({ id: k, code: "SERVER_ERROR", message: err instanceof Error ? err.message : String(err) });
|
|
@@ -5157,7 +5193,7 @@ async function degradable(read) {
|
|
|
5157
5193
|
try {
|
|
5158
5194
|
return await read();
|
|
5159
5195
|
} catch (err) {
|
|
5160
|
-
if (!(err instanceof
|
|
5196
|
+
if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
|
|
5161
5197
|
return { items: [], capped: false, hasMore: false, absent: err.code, absentMessage: err.message };
|
|
5162
5198
|
}
|
|
5163
5199
|
}
|
|
@@ -5177,15 +5213,15 @@ var stampPart = (key, raw, conditions, extraNotes) => {
|
|
|
5177
5213
|
status: st.status,
|
|
5178
5214
|
blindSurface: st.blindSurface,
|
|
5179
5215
|
note: [st.note, ..._nullishCoalesce(extraNotes, () => ( []))].filter(Boolean).join(" | ") || void 0,
|
|
5180
|
-
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([
|
|
5216
|
+
emptyReason: raw.items.length === 0 && st.status === "ok" ? _optionalChain([_chunkZJ4ONAQFcjs.EMPTY_REASON_STAMPS, 'access', _47 => _47[key], 'optionalAccess', _48 => _48.query]) : void 0
|
|
5181
5217
|
};
|
|
5182
5218
|
};
|
|
5183
5219
|
function appendWiresNote(wires, note) {
|
|
5184
5220
|
wires.note = (wires.note ? wires.note + " | " : "") + note;
|
|
5185
5221
|
}
|
|
5186
5222
|
function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
5187
|
-
const
|
|
5188
|
-
const id =
|
|
5223
|
+
const OP7 = PROFITABILITY_OP;
|
|
5224
|
+
const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, contractId, "contractId");
|
|
5189
5225
|
const idNum = typeof id === "number" ? id : Number(id);
|
|
5190
5226
|
const wires = { issued: 0, requests: 0, budget };
|
|
5191
5227
|
const toExcl = dayAfter(v.dateTo);
|
|
@@ -5196,19 +5232,19 @@ function makeFetchCtx(rawHttp, v, contractId, budget) {
|
|
|
5196
5232
|
} };
|
|
5197
5233
|
const readPart = (path, conditions, fields) => {
|
|
5198
5234
|
wires.issued += 1;
|
|
5199
|
-
return degradable(() => boundedPart(http, path, conditions, v.limit,
|
|
5235
|
+
return degradable(() => boundedPart(http, path, conditions, v.limit, OP7, fields));
|
|
5200
5236
|
};
|
|
5201
5237
|
const truncatedMonths = {};
|
|
5202
5238
|
const windowedPart = async (name, key, path, cond, fields, dateField) => {
|
|
5203
5239
|
const first = await readPart(path, cond, fields);
|
|
5204
5240
|
if (first.absent !== void 0 || !first.hasMore) return { part: stampPart(key, first, cond), rows: first.items };
|
|
5205
|
-
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit,
|
|
5241
|
+
const wp = await degradable(() => expandByMonth(http, path, cond, v.limit, OP7, fields, dateField, v.dateFrom, v.dateTo, wires));
|
|
5206
5242
|
if (!("truncatedMonths" in wp)) return { part: stampPart(key, wp, cond), rows: [] };
|
|
5207
5243
|
const { truncatedMonths: tm, ...part } = wp;
|
|
5208
5244
|
truncatedMonths[name] = tm;
|
|
5209
5245
|
return { part, rows: wp.items };
|
|
5210
5246
|
};
|
|
5211
|
-
return { v, OP:
|
|
5247
|
+
return { v, OP: OP7, id, idNum, rawHttp, http, wires, windowOn, readPart, windowedPart, truncatedMonths };
|
|
5212
5248
|
}
|
|
5213
5249
|
|
|
5214
5250
|
// src/resources/special/contracts/profitability.stages.ts
|
|
@@ -5223,12 +5259,12 @@ async function fetchCustomer(ctx, companyID) {
|
|
|
5223
5259
|
path: `/V1.0/Companies/${companyID}`,
|
|
5224
5260
|
operation: ctx.OP
|
|
5225
5261
|
});
|
|
5226
|
-
const item =
|
|
5262
|
+
const item = _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, companyID, ctx.OP, "company");
|
|
5227
5263
|
customer = _nullishCoalesce(item, () => ( null));
|
|
5228
5264
|
customerStatus = "ok";
|
|
5229
5265
|
} catch (err) {
|
|
5230
|
-
if (!(err instanceof
|
|
5231
|
-
if (!(err instanceof
|
|
5266
|
+
if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
|
|
5267
|
+
if (!(err instanceof _chunkZJ4ONAQFcjs.NotFoundError)) {
|
|
5232
5268
|
customerStatus = "absent";
|
|
5233
5269
|
customerAbsent = err.code;
|
|
5234
5270
|
}
|
|
@@ -5244,7 +5280,7 @@ async function resolveContractType(ctx, contractType) {
|
|
|
5244
5280
|
try {
|
|
5245
5281
|
contractTypeLabel = await _asyncNullishCoalesce(await _asyncOptionalChain([(await readPicklists(ctx.http, "/V1.0/Contracts", ctx.OP)), 'access', async _49 => _49.get, 'call', async _50 => _50("contractType"), 'optionalAccess', async _51 => _51.get, 'call', async _52 => _52(contractType)]), async () => ( null));
|
|
5246
5282
|
} catch (err) {
|
|
5247
|
-
if (!(err instanceof
|
|
5283
|
+
if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
|
|
5248
5284
|
}
|
|
5249
5285
|
}
|
|
5250
5286
|
const contractTypeKnown = contractTypeLabel !== null;
|
|
@@ -5306,8 +5342,8 @@ async function fetchInvoices(ctx, billingRows) {
|
|
|
5306
5342
|
if (invoiceIds.length === 0) {
|
|
5307
5343
|
return { invoicesPart: skipPart("skipped: the billing part has no invoiceIDs (zero wire)"), invoices: [] };
|
|
5308
5344
|
}
|
|
5309
|
-
const capped = capJoinSet2(invoiceIds,
|
|
5310
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${
|
|
5345
|
+
const capped = capJoinSet2(invoiceIds, _chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5346
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `invoiceJoinTruncated: the join set is capped at ${_chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} invoice ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5311
5347
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Invoices", capped.ids, ["id", "invoiceNumber", "invoiceTotal", "paidDate", "isVoided", "dueDate"], ctx.OP, "invoice");
|
|
5312
5348
|
ctx.wires.issued += 1;
|
|
5313
5349
|
return {
|
|
@@ -5353,7 +5389,7 @@ async function readOpenStatusSet(ctx) {
|
|
|
5353
5389
|
}
|
|
5354
5390
|
}
|
|
5355
5391
|
} catch (err) {
|
|
5356
|
-
statusNote = `the tickets.status field catalog read failed (${err instanceof
|
|
5392
|
+
statusNote = `the tickets.status field catalog read failed (${err instanceof _chunkZJ4ONAQFcjs.AutotaskError ? err.code : "SERVER_ERROR"}: ${err instanceof Error ? err.message : String(err)}) \u2014 the open-status labels are unavailable`;
|
|
5357
5393
|
}
|
|
5358
5394
|
return { openStatusSet, statusNote };
|
|
5359
5395
|
}
|
|
@@ -5376,8 +5412,8 @@ async function fetchResources(ctx, entries) {
|
|
|
5376
5412
|
if (resourceIds.length === 0) {
|
|
5377
5413
|
return { resourcesPart: skipPart("skipped: the time part has no resourceIDs (zero wire)"), resources: [], resourceMissIds };
|
|
5378
5414
|
}
|
|
5379
|
-
const capped = capJoinSet2(resourceIds,
|
|
5380
|
-
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${
|
|
5415
|
+
const capped = capJoinSet2(resourceIds, _chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5416
|
+
if (capped.truncated) appendWiresNote(ctx.wires, `resourceJoinTruncated: the join set is capped at ${_chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS} of ${capped.total} resource ids (the fetch-by-ids cap) \u2014 the figures cover the returned set only`);
|
|
5381
5417
|
const fb = await fetchByIdsPart(ctx.http, "/V1.0/Resources", capped.ids, ["id", "internalCost", "firstName", "lastName", "isActive", "userType"], ctx.OP, "resource");
|
|
5382
5418
|
ctx.wires.issued += 1;
|
|
5383
5419
|
for (const m of fb.misses) if (m.code === "NOT_FOUND") resourceMissIds.add(m.id);
|
|
@@ -5444,7 +5480,7 @@ async function readSubscriptionLabels(ctx, subscriptions) {
|
|
|
5444
5480
|
try {
|
|
5445
5481
|
return await readPicklists(ctx.http, "/V1.0/Subscriptions", ctx.OP);
|
|
5446
5482
|
} catch (err) {
|
|
5447
|
-
if (!(err instanceof
|
|
5483
|
+
if (!(err instanceof _chunkZJ4ONAQFcjs.AutotaskError)) throw err;
|
|
5448
5484
|
return null;
|
|
5449
5485
|
}
|
|
5450
5486
|
}
|
|
@@ -5461,7 +5497,7 @@ async function fetchSubscriptions(ctx, cis) {
|
|
|
5461
5497
|
cancelledSubs
|
|
5462
5498
|
};
|
|
5463
5499
|
}
|
|
5464
|
-
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0),
|
|
5500
|
+
const ciIds = capJoinSet2(cis.map((c) => num(c["id"])).filter((n) => n > 0), _chunkZJ4ONAQFcjs.FETCH_BY_IDS_MAX_ITEMS);
|
|
5465
5501
|
const subCond = [{ field: "configurationItemID", op: "in", value: ciIds.ids }];
|
|
5466
5502
|
const raw = await ctx.readPart("/V1.0/Subscriptions/query", subCond, ["id", "subscriptionName", "configurationItemID", "periodCost", "periodPrice", "periodType", "effectiveDate", "expirationDate", "status", "totalCost"]);
|
|
5467
5503
|
const subscriptions = raw.items;
|
|
@@ -6146,7 +6182,7 @@ async function profitability(resource, contractId, opts, rawHttp) {
|
|
|
6146
6182
|
}
|
|
6147
6183
|
|
|
6148
6184
|
// src/resources/contracts.ts
|
|
6149
|
-
var ContractsResource = class extends
|
|
6185
|
+
var ContractsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6150
6186
|
constructor(http, pageSize) {
|
|
6151
6187
|
super(http, {
|
|
6152
6188
|
key: "contracts",
|
|
@@ -6217,7 +6253,7 @@ var ContractsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6217
6253
|
};
|
|
6218
6254
|
|
|
6219
6255
|
// src/resources/contract_ticket_purchases.ts
|
|
6220
|
-
var ContractTicketPurchasesResource = class extends
|
|
6256
|
+
var ContractTicketPurchasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6221
6257
|
constructor(http, pageSize) {
|
|
6222
6258
|
super(http, {
|
|
6223
6259
|
key: "contract_ticket_purchases",
|
|
@@ -6276,7 +6312,7 @@ var ContractTicketPurchasesResource = class extends _chunkHQGE4WAVcjs.BaseResour
|
|
|
6276
6312
|
};
|
|
6277
6313
|
|
|
6278
6314
|
// src/resources/countries.ts
|
|
6279
|
-
var CountriesResource = class extends
|
|
6315
|
+
var CountriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6280
6316
|
constructor(http, pageSize) {
|
|
6281
6317
|
super(http, {
|
|
6282
6318
|
key: "countries",
|
|
@@ -6335,7 +6371,7 @@ var CountriesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6335
6371
|
};
|
|
6336
6372
|
|
|
6337
6373
|
// src/resources/currencies.ts
|
|
6338
|
-
var CurrenciesResource = class extends
|
|
6374
|
+
var CurrenciesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6339
6375
|
constructor(http, pageSize) {
|
|
6340
6376
|
super(http, {
|
|
6341
6377
|
key: "currencies",
|
|
@@ -6379,7 +6415,7 @@ var CurrenciesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6379
6415
|
};
|
|
6380
6416
|
|
|
6381
6417
|
// src/resources/departments.ts
|
|
6382
|
-
var DepartmentsResource = class extends
|
|
6418
|
+
var DepartmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6383
6419
|
constructor(http, pageSize) {
|
|
6384
6420
|
super(http, {
|
|
6385
6421
|
key: "departments",
|
|
@@ -6446,7 +6482,7 @@ var DepartmentsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6446
6482
|
};
|
|
6447
6483
|
|
|
6448
6484
|
// src/resources/domain_registrars.ts
|
|
6449
|
-
var DomainRegistrarsResource = class extends
|
|
6485
|
+
var DomainRegistrarsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6450
6486
|
constructor(http, pageSize) {
|
|
6451
6487
|
super(http, {
|
|
6452
6488
|
key: "domain_registrars",
|
|
@@ -6529,7 +6565,7 @@ var EntityInformationResource = class {
|
|
|
6529
6565
|
};
|
|
6530
6566
|
|
|
6531
6567
|
// src/resources/expense_item_attachments.ts
|
|
6532
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6568
|
+
var ExpenseItemAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6533
6569
|
constructor(http, pageSize) {
|
|
6534
6570
|
super(http, {
|
|
6535
6571
|
key: "expense_item_attachments",
|
|
@@ -6591,7 +6627,7 @@ var ExpenseItemAttachmentsResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
6591
6627
|
};
|
|
6592
6628
|
|
|
6593
6629
|
// src/resources/expense_items.ts
|
|
6594
|
-
var ExpenseItemsResource = class extends
|
|
6630
|
+
var ExpenseItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6595
6631
|
constructor(http, pageSize) {
|
|
6596
6632
|
super(http, {
|
|
6597
6633
|
key: "expense_items",
|
|
@@ -6650,7 +6686,7 @@ var ExpenseItemsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6650
6686
|
};
|
|
6651
6687
|
|
|
6652
6688
|
// src/resources/expense_reports.ts
|
|
6653
|
-
var ExpenseReportsResource = class extends
|
|
6689
|
+
var ExpenseReportsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6654
6690
|
constructor(http, pageSize) {
|
|
6655
6691
|
super(http, {
|
|
6656
6692
|
key: "expense_reports",
|
|
@@ -6717,7 +6753,7 @@ var ExpenseReportsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6717
6753
|
};
|
|
6718
6754
|
|
|
6719
6755
|
// src/resources/holiday_sets.ts
|
|
6720
|
-
var HolidaySetsResource = class extends
|
|
6756
|
+
var HolidaySetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6721
6757
|
constructor(http, pageSize) {
|
|
6722
6758
|
super(http, {
|
|
6723
6759
|
key: "holiday_sets",
|
|
@@ -6786,7 +6822,7 @@ var HolidaySetsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6786
6822
|
};
|
|
6787
6823
|
|
|
6788
6824
|
// src/resources/holidays.ts
|
|
6789
|
-
var HolidaysResource = class extends
|
|
6825
|
+
var HolidaysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6790
6826
|
constructor(http, pageSize) {
|
|
6791
6827
|
super(http, {
|
|
6792
6828
|
key: "holidays",
|
|
@@ -6858,10 +6894,10 @@ var PATH_SUFFIX = {
|
|
|
6858
6894
|
transfer: "StockedItemsTransfer"
|
|
6859
6895
|
};
|
|
6860
6896
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6861
|
-
const numericParent =
|
|
6897
|
+
const numericParent = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6862
6898
|
const suffix = PATH_SUFFIX[kind];
|
|
6863
6899
|
if (opts.dryRun === true) {
|
|
6864
|
-
return
|
|
6900
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
6865
6901
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6866
6902
|
method: "POST",
|
|
6867
6903
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6878,11 +6914,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6878
6914
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6879
6915
|
maxRetries: opts.maxRetries
|
|
6880
6916
|
});
|
|
6881
|
-
return
|
|
6917
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
6882
6918
|
}
|
|
6883
6919
|
|
|
6884
6920
|
// src/resources/inventory_products.ts
|
|
6885
|
-
var InventoryProductsResource = class extends
|
|
6921
|
+
var InventoryProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6886
6922
|
constructor(http, pageSize) {
|
|
6887
6923
|
super(http, {
|
|
6888
6924
|
key: "inventory_products",
|
|
@@ -6964,7 +7000,7 @@ var InventoryProductsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
6964
7000
|
|
|
6965
7001
|
// src/resources/special/invoices.ts
|
|
6966
7002
|
async function markup(_resource, id, format, http) {
|
|
6967
|
-
const numericId =
|
|
7003
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
6968
7004
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
6969
7005
|
const res = await http.request({
|
|
6970
7006
|
method: "GET",
|
|
@@ -6973,7 +7009,7 @@ async function markup(_resource, id, format, http) {
|
|
|
6973
7009
|
});
|
|
6974
7010
|
const body = res;
|
|
6975
7011
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
6976
|
-
throw new (0,
|
|
7012
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(
|
|
6977
7013
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
6978
7014
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
|
|
6979
7015
|
);
|
|
@@ -6981,13 +7017,13 @@ async function markup(_resource, id, format, http) {
|
|
|
6981
7017
|
return body.invoiceMarkup;
|
|
6982
7018
|
}
|
|
6983
7019
|
async function pdf(_resource, id, http) {
|
|
6984
|
-
const numericId =
|
|
7020
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
6985
7021
|
const res = await http.request({
|
|
6986
7022
|
method: "GET",
|
|
6987
7023
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
6988
7024
|
operation: "invoices.pdf"
|
|
6989
7025
|
});
|
|
6990
|
-
return
|
|
7026
|
+
return _chunkZJ4ONAQFcjs.decodeFileData.call(void 0, res);
|
|
6991
7027
|
}
|
|
6992
7028
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
6993
7029
|
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _71 => _71.now]), () => ( /* @__PURE__ */ new Date()));
|
|
@@ -7018,7 +7054,7 @@ async function customRange2(_resource, from, to, http, opts) {
|
|
|
7018
7054
|
}
|
|
7019
7055
|
|
|
7020
7056
|
// src/resources/invoices.ts
|
|
7021
|
-
var InvoicesResource = class extends
|
|
7057
|
+
var InvoicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7022
7058
|
constructor(http, pageSize) {
|
|
7023
7059
|
super(http, {
|
|
7024
7060
|
key: "invoices",
|
|
@@ -7131,6 +7167,34 @@ var InvoicesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7131
7167
|
}
|
|
7132
7168
|
};
|
|
7133
7169
|
|
|
7170
|
+
// src/resources/invoice_templates.ts
|
|
7171
|
+
var InvoiceTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7172
|
+
constructor(http, pageSize) {
|
|
7173
|
+
super(http, {
|
|
7174
|
+
key: "invoice_templates",
|
|
7175
|
+
resourcePath: "/V1.0/InvoiceTemplates",
|
|
7176
|
+
deletable: false,
|
|
7177
|
+
udfCapable: false
|
|
7178
|
+
}, pageSize);
|
|
7179
|
+
}
|
|
7180
|
+
/** Query InvoiceTemplate records with the G3 filter surface (server-side JSON filter). */
|
|
7181
|
+
query(params) {
|
|
7182
|
+
return this.queryItems(params);
|
|
7183
|
+
}
|
|
7184
|
+
/** Get every InvoiceTemplate record (the MCP-preferred read; 1000-page guarded). */
|
|
7185
|
+
async queryAll(params) {
|
|
7186
|
+
return this.queryAllItems(params);
|
|
7187
|
+
}
|
|
7188
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
7189
|
+
async count(params) {
|
|
7190
|
+
return this.countGlobal(params);
|
|
7191
|
+
}
|
|
7192
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
7193
|
+
async get(id) {
|
|
7194
|
+
return this.getGlobal(id);
|
|
7195
|
+
}
|
|
7196
|
+
};
|
|
7197
|
+
|
|
7134
7198
|
// src/resources/modules.ts
|
|
7135
7199
|
var ModulesResource = class {
|
|
7136
7200
|
|
|
@@ -7148,7 +7212,7 @@ var ModulesResource = class {
|
|
|
7148
7212
|
};
|
|
7149
7213
|
|
|
7150
7214
|
// src/resources/notification_history.ts
|
|
7151
|
-
var NotificationHistoryResource = class extends
|
|
7215
|
+
var NotificationHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7152
7216
|
constructor(http, pageSize) {
|
|
7153
7217
|
super(http, {
|
|
7154
7218
|
key: "notification_history",
|
|
@@ -7187,7 +7251,7 @@ var NotificationHistoryResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7187
7251
|
};
|
|
7188
7252
|
|
|
7189
7253
|
// src/resources/opportunities.ts
|
|
7190
|
-
var OpportunitiesResource = class extends
|
|
7254
|
+
var OpportunitiesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7191
7255
|
constructor(http, pageSize) {
|
|
7192
7256
|
super(http, {
|
|
7193
7257
|
key: "opportunities",
|
|
@@ -7249,7 +7313,7 @@ var OpportunitiesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7249
7313
|
};
|
|
7250
7314
|
|
|
7251
7315
|
// src/resources/opportunity_attachments.ts
|
|
7252
|
-
var OpportunityAttachmentsResource = class extends
|
|
7316
|
+
var OpportunityAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7253
7317
|
constructor(http, pageSize) {
|
|
7254
7318
|
super(http, {
|
|
7255
7319
|
key: "opportunity_attachments",
|
|
@@ -7311,7 +7375,7 @@ var OpportunityAttachmentsResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
7311
7375
|
};
|
|
7312
7376
|
|
|
7313
7377
|
// src/resources/opportunity_categories.ts
|
|
7314
|
-
var OpportunityCategoriesResource = class extends
|
|
7378
|
+
var OpportunityCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7315
7379
|
constructor(http, pageSize) {
|
|
7316
7380
|
super(http, {
|
|
7317
7381
|
key: "opportunity_categories",
|
|
@@ -7369,8 +7433,161 @@ var OpportunityCategoriesResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
7369
7433
|
}
|
|
7370
7434
|
};
|
|
7371
7435
|
|
|
7436
|
+
// src/resources/organizational_level1s.ts
|
|
7437
|
+
var OrganizationalLevel1sResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7438
|
+
constructor(http, pageSize) {
|
|
7439
|
+
super(http, {
|
|
7440
|
+
key: "organizational_level1s",
|
|
7441
|
+
resourcePath: "/V1.0/OrganizationalLevel1s",
|
|
7442
|
+
deletable: false,
|
|
7443
|
+
udfCapable: false,
|
|
7444
|
+
collectionUpdate: true
|
|
7445
|
+
// D1: the spec's item path is GET-only — confirmed updates PUT the collection (id in the body)
|
|
7446
|
+
}, pageSize);
|
|
7447
|
+
}
|
|
7448
|
+
/** Query OrganizationalLevel1 records with the G3 filter surface (server-side JSON filter). */
|
|
7449
|
+
query(params) {
|
|
7450
|
+
return this.queryItems(params);
|
|
7451
|
+
}
|
|
7452
|
+
/** Get every OrganizationalLevel1 record (the MCP-preferred read; 1000-page guarded). */
|
|
7453
|
+
async queryAll(params) {
|
|
7454
|
+
return this.queryAllItems(params);
|
|
7455
|
+
}
|
|
7456
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
7457
|
+
async count(params) {
|
|
7458
|
+
return this.countGlobal(params);
|
|
7459
|
+
}
|
|
7460
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
7461
|
+
async get(id) {
|
|
7462
|
+
return this.getGlobal(id);
|
|
7463
|
+
}
|
|
7464
|
+
/** Create a record (OperationResultModel → { id}). `dryRun: true` returns the
|
|
7465
|
+
* pinned envelope (section 19.3) and never issues the create. A 2xx that is not the
|
|
7466
|
+
* specced envelope runs the plan-pinned marker recovery (issue #13 — one bounded read;
|
|
7467
|
+
* `recoverIdFromMarker: false` restores the pre-recovery behaviour). */
|
|
7468
|
+
async create(data, opts = {}) {
|
|
7469
|
+
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
7470
|
+
return this.createGlobal(data, opts);
|
|
7471
|
+
}
|
|
7472
|
+
/** Update a record (PUT on the COLLECTION — the vendored spec's item path is GET-only; the vendor
|
|
7473
|
+
* keys the record by the id in the body). The vendor validates the FULL model on this route (V2), so a
|
|
7474
|
+
* partial body is merged into the CURRENT record first: one fresh GET (which also serves the
|
|
7475
|
+
* stale-object guard's read) then the collection PUT of the merged model — an explicit null in the
|
|
7476
|
+
* caller body sends null; an omitted field keeps the current value. `raw: true` in the opts bag sends
|
|
7477
|
+
* the body as-is (full model or intentional partial — the compatibility escape hatch; no merge read).
|
|
7478
|
+
* `dryRun: true` returns the pinned envelope whose `data` is the merged body (the exact confirmed
|
|
7479
|
+
* wire) with the best-effort diff, from that same single read; a caller-supplied lastModifiedDate that
|
|
7480
|
+
* mismatches the vendor's current value throws STALE_OBJECT before the mutation. */
|
|
7481
|
+
async update(id, data, opts = {}) {
|
|
7482
|
+
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts);
|
|
7483
|
+
return this.updateGlobal(id, data, opts);
|
|
7484
|
+
}
|
|
7485
|
+
};
|
|
7486
|
+
|
|
7487
|
+
// src/resources/organizational_level2s.ts
|
|
7488
|
+
var OrganizationalLevel2sResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7489
|
+
constructor(http, pageSize) {
|
|
7490
|
+
super(http, {
|
|
7491
|
+
key: "organizational_level2s",
|
|
7492
|
+
resourcePath: "/V1.0/OrganizationalLevel2s",
|
|
7493
|
+
deletable: false,
|
|
7494
|
+
udfCapable: false,
|
|
7495
|
+
collectionUpdate: true
|
|
7496
|
+
// D1: the spec's item path is GET-only — confirmed updates PUT the collection (id in the body)
|
|
7497
|
+
}, pageSize);
|
|
7498
|
+
}
|
|
7499
|
+
/** Query OrganizationalLevel2 records with the G3 filter surface (server-side JSON filter). */
|
|
7500
|
+
query(params) {
|
|
7501
|
+
return this.queryItems(params);
|
|
7502
|
+
}
|
|
7503
|
+
/** Get every OrganizationalLevel2 record (the MCP-preferred read; 1000-page guarded). */
|
|
7504
|
+
async queryAll(params) {
|
|
7505
|
+
return this.queryAllItems(params);
|
|
7506
|
+
}
|
|
7507
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
7508
|
+
async count(params) {
|
|
7509
|
+
return this.countGlobal(params);
|
|
7510
|
+
}
|
|
7511
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
7512
|
+
async get(id) {
|
|
7513
|
+
return this.getGlobal(id);
|
|
7514
|
+
}
|
|
7515
|
+
/** Create a record (OperationResultModel → { id}). `dryRun: true` returns the
|
|
7516
|
+
* pinned envelope (section 19.3) and never issues the create. A 2xx that is not the
|
|
7517
|
+
* specced envelope runs the plan-pinned marker recovery (issue #13 — one bounded read;
|
|
7518
|
+
* `recoverIdFromMarker: false` restores the pre-recovery behaviour). */
|
|
7519
|
+
async create(data, opts = {}) {
|
|
7520
|
+
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
7521
|
+
return this.createGlobal(data, opts);
|
|
7522
|
+
}
|
|
7523
|
+
/** Update a record (PUT on the COLLECTION — the vendored spec's item path is GET-only; the vendor
|
|
7524
|
+
* keys the record by the id in the body). The vendor validates the FULL model on this route (V2), so a
|
|
7525
|
+
* partial body is merged into the CURRENT record first: one fresh GET (which also serves the
|
|
7526
|
+
* stale-object guard's read) then the collection PUT of the merged model — an explicit null in the
|
|
7527
|
+
* caller body sends null; an omitted field keeps the current value. `raw: true` in the opts bag sends
|
|
7528
|
+
* the body as-is (full model or intentional partial — the compatibility escape hatch; no merge read).
|
|
7529
|
+
* `dryRun: true` returns the pinned envelope whose `data` is the merged body (the exact confirmed
|
|
7530
|
+
* wire) with the best-effort diff, from that same single read; a caller-supplied lastModifiedDate that
|
|
7531
|
+
* mismatches the vendor's current value throws STALE_OBJECT before the mutation. */
|
|
7532
|
+
async update(id, data, opts = {}) {
|
|
7533
|
+
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts);
|
|
7534
|
+
return this.updateGlobal(id, data, opts);
|
|
7535
|
+
}
|
|
7536
|
+
};
|
|
7537
|
+
|
|
7538
|
+
// src/resources/organizational_level_associations.ts
|
|
7539
|
+
var OrganizationalLevelAssociationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7540
|
+
constructor(http, pageSize) {
|
|
7541
|
+
super(http, {
|
|
7542
|
+
key: "organizational_level_associations",
|
|
7543
|
+
resourcePath: "/V1.0/OrganizationalLevelAssociations",
|
|
7544
|
+
deletable: false,
|
|
7545
|
+
udfCapable: false,
|
|
7546
|
+
collectionUpdate: true
|
|
7547
|
+
// D1: the spec's item path is GET-only — confirmed updates PUT the collection (id in the body)
|
|
7548
|
+
}, pageSize);
|
|
7549
|
+
}
|
|
7550
|
+
/** Query OrganizationalLevelAssociation records with the G3 filter surface (server-side JSON filter). */
|
|
7551
|
+
query(params) {
|
|
7552
|
+
return this.queryItems(params);
|
|
7553
|
+
}
|
|
7554
|
+
/** Get every OrganizationalLevelAssociation record (the MCP-preferred read; 1000-page guarded). */
|
|
7555
|
+
async queryAll(params) {
|
|
7556
|
+
return this.queryAllItems(params);
|
|
7557
|
+
}
|
|
7558
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
7559
|
+
async count(params) {
|
|
7560
|
+
return this.countGlobal(params);
|
|
7561
|
+
}
|
|
7562
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
7563
|
+
async get(id) {
|
|
7564
|
+
return this.getGlobal(id);
|
|
7565
|
+
}
|
|
7566
|
+
/** Create a record (OperationResultModel → { id}). `dryRun: true` returns the
|
|
7567
|
+
* pinned envelope (section 19.3) and never issues the create. A 2xx that is not the
|
|
7568
|
+
* specced envelope runs the plan-pinned marker recovery (issue #13 — one bounded read;
|
|
7569
|
+
* `recoverIdFromMarker: false` restores the pre-recovery behaviour). */
|
|
7570
|
+
async create(data, opts = {}) {
|
|
7571
|
+
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
7572
|
+
return this.createGlobal(data, opts);
|
|
7573
|
+
}
|
|
7574
|
+
/** Update a record (PUT on the COLLECTION — the vendored spec's item path is GET-only; the vendor
|
|
7575
|
+
* keys the record by the id in the body). The vendor validates the FULL model on this route (V2), so a
|
|
7576
|
+
* partial body is merged into the CURRENT record first: one fresh GET (which also serves the
|
|
7577
|
+
* stale-object guard's read) then the collection PUT of the merged model — an explicit null in the
|
|
7578
|
+
* caller body sends null; an omitted field keeps the current value. `raw: true` in the opts bag sends
|
|
7579
|
+
* the body as-is (full model or intentional partial — the compatibility escape hatch; no merge read).
|
|
7580
|
+
* `dryRun: true` returns the pinned envelope whose `data` is the merged body (the exact confirmed
|
|
7581
|
+
* wire) with the best-effort diff, from that same single read; a caller-supplied lastModifiedDate that
|
|
7582
|
+
* mismatches the vendor's current value throws STALE_OBJECT before the mutation. */
|
|
7583
|
+
async update(id, data, opts = {}) {
|
|
7584
|
+
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts);
|
|
7585
|
+
return this.updateGlobal(id, data, opts);
|
|
7586
|
+
}
|
|
7587
|
+
};
|
|
7588
|
+
|
|
7372
7589
|
// src/resources/phases.ts
|
|
7373
|
-
var PhasesResource = class extends
|
|
7590
|
+
var PhasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7374
7591
|
constructor(http, pageSize) {
|
|
7375
7592
|
super(http, {
|
|
7376
7593
|
key: "phases",
|
|
@@ -7429,7 +7646,7 @@ var PhasesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7429
7646
|
};
|
|
7430
7647
|
|
|
7431
7648
|
// src/resources/products.ts
|
|
7432
|
-
var ProductsResource = class extends
|
|
7649
|
+
var ProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7433
7650
|
constructor(http, pageSize) {
|
|
7434
7651
|
super(http, {
|
|
7435
7652
|
key: "products",
|
|
@@ -7496,7 +7713,7 @@ var ProductsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7496
7713
|
};
|
|
7497
7714
|
|
|
7498
7715
|
// src/resources/product_vendors.ts
|
|
7499
|
-
var ProductVendorsResource = class extends
|
|
7716
|
+
var ProductVendorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7500
7717
|
constructor(http, pageSize) {
|
|
7501
7718
|
super(http, {
|
|
7502
7719
|
key: "product_vendors",
|
|
@@ -7555,7 +7772,7 @@ var ProductVendorsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7555
7772
|
};
|
|
7556
7773
|
|
|
7557
7774
|
// src/resources/project_charges.ts
|
|
7558
|
-
var ProjectChargesResource = class extends
|
|
7775
|
+
var ProjectChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7559
7776
|
constructor(http, pageSize) {
|
|
7560
7777
|
super(http, {
|
|
7561
7778
|
key: "project_charges",
|
|
@@ -7626,7 +7843,7 @@ var ProjectChargesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7626
7843
|
};
|
|
7627
7844
|
|
|
7628
7845
|
// src/resources/project_notes.ts
|
|
7629
|
-
var ProjectNotesResource = class extends
|
|
7846
|
+
var ProjectNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7630
7847
|
constructor(http, pageSize) {
|
|
7631
7848
|
super(http, {
|
|
7632
7849
|
key: "project_notes",
|
|
@@ -7685,7 +7902,7 @@ var ProjectNotesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7685
7902
|
};
|
|
7686
7903
|
|
|
7687
7904
|
// src/resources/projects.ts
|
|
7688
|
-
var ProjectsResource = class extends
|
|
7905
|
+
var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7689
7906
|
constructor(http, pageSize) {
|
|
7690
7907
|
super(http, {
|
|
7691
7908
|
key: "projects",
|
|
@@ -7762,13 +7979,13 @@ var ProjectsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7762
7979
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
7763
7980
|
const result = { project: project2, company, opportunity, leadResource };
|
|
7764
7981
|
if (opts.names === true) {
|
|
7765
|
-
const builder =
|
|
7982
|
+
const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, );
|
|
7766
7983
|
builder.addResource(root["creatorResourceID"]);
|
|
7767
7984
|
builder.addFk("contract", root["contractID"]);
|
|
7768
|
-
const names = await
|
|
7985
|
+
const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
7769
7986
|
const row = { ...project2 };
|
|
7770
|
-
|
|
7771
|
-
|
|
7987
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "creatorResourceID", (v) => names.resourceName(v));
|
|
7988
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
7772
7989
|
result.project = row;
|
|
7773
7990
|
result.names = names.section;
|
|
7774
7991
|
}
|
|
@@ -7777,7 +7994,7 @@ var ProjectsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7777
7994
|
};
|
|
7778
7995
|
|
|
7779
7996
|
// src/resources/purchase_approvals.ts
|
|
7780
|
-
var PurchaseApprovalsResource = class extends
|
|
7997
|
+
var PurchaseApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7781
7998
|
constructor(http, pageSize) {
|
|
7782
7999
|
super(http, {
|
|
7783
8000
|
key: "purchase_approvals",
|
|
@@ -7831,7 +8048,7 @@ var PurchaseApprovalsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7831
8048
|
};
|
|
7832
8049
|
|
|
7833
8050
|
// src/resources/purchase_order_item_receiving.ts
|
|
7834
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
8051
|
+
var PurchaseOrderItemReceivingResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7835
8052
|
constructor(http, pageSize) {
|
|
7836
8053
|
super(http, {
|
|
7837
8054
|
key: "purchase_order_item_receiving",
|
|
@@ -7881,7 +8098,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunkHQGE4WAVcjs.BaseRes
|
|
|
7881
8098
|
};
|
|
7882
8099
|
|
|
7883
8100
|
// src/resources/purchase_order_items.ts
|
|
7884
|
-
var PurchaseOrderItemsResource = class extends
|
|
8101
|
+
var PurchaseOrderItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7885
8102
|
constructor(http, pageSize) {
|
|
7886
8103
|
super(http, {
|
|
7887
8104
|
key: "purchase_order_items",
|
|
@@ -7940,7 +8157,7 @@ var PurchaseOrderItemsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
7940
8157
|
};
|
|
7941
8158
|
|
|
7942
8159
|
// src/resources/purchase_orders.ts
|
|
7943
|
-
var PurchaseOrdersResource = class extends
|
|
8160
|
+
var PurchaseOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7944
8161
|
constructor(http, pageSize) {
|
|
7945
8162
|
super(http, {
|
|
7946
8163
|
key: "purchase_orders",
|
|
@@ -8002,7 +8219,7 @@ var PurchaseOrdersResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8002
8219
|
};
|
|
8003
8220
|
|
|
8004
8221
|
// src/resources/quote_items.ts
|
|
8005
|
-
var QuoteItemsResource = class extends
|
|
8222
|
+
var QuoteItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8006
8223
|
constructor(http, pageSize) {
|
|
8007
8224
|
super(http, {
|
|
8008
8225
|
key: "quote_items",
|
|
@@ -8073,7 +8290,7 @@ var QuoteItemsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8073
8290
|
};
|
|
8074
8291
|
|
|
8075
8292
|
// src/resources/quote_locations.ts
|
|
8076
|
-
var QuoteLocationsResource = class extends
|
|
8293
|
+
var QuoteLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8077
8294
|
constructor(http, pageSize) {
|
|
8078
8295
|
super(http, {
|
|
8079
8296
|
key: "quote_locations",
|
|
@@ -8138,7 +8355,7 @@ var QuoteLocationsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8138
8355
|
};
|
|
8139
8356
|
|
|
8140
8357
|
// src/resources/quotes.ts
|
|
8141
|
-
var QuotesResource = class extends
|
|
8358
|
+
var QuotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8142
8359
|
constructor(http, pageSize) {
|
|
8143
8360
|
super(http, {
|
|
8144
8361
|
key: "quotes",
|
|
@@ -8205,7 +8422,7 @@ var QuotesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8205
8422
|
};
|
|
8206
8423
|
|
|
8207
8424
|
// src/resources/quote_templates.ts
|
|
8208
|
-
var QuoteTemplatesResource = class extends
|
|
8425
|
+
var QuoteTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8209
8426
|
constructor(http, pageSize) {
|
|
8210
8427
|
super(http, {
|
|
8211
8428
|
key: "quote_templates",
|
|
@@ -8249,7 +8466,7 @@ var QuoteTemplatesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8249
8466
|
};
|
|
8250
8467
|
|
|
8251
8468
|
// src/resources/resource_role_queues.ts
|
|
8252
|
-
var ResourceRoleQueuesResource = class extends
|
|
8469
|
+
var ResourceRoleQueuesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8253
8470
|
constructor(http, pageSize) {
|
|
8254
8471
|
super(http, {
|
|
8255
8472
|
key: "resource_role_queues",
|
|
@@ -8308,7 +8525,7 @@ var ResourceRoleQueuesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8308
8525
|
};
|
|
8309
8526
|
|
|
8310
8527
|
// src/resources/resource_roles.ts
|
|
8311
|
-
var ResourceRolesResource = class extends
|
|
8528
|
+
var ResourceRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8312
8529
|
constructor(http, pageSize) {
|
|
8313
8530
|
super(http, {
|
|
8314
8531
|
key: "resource_roles",
|
|
@@ -8350,7 +8567,7 @@ var ResourceRolesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8350
8567
|
};
|
|
8351
8568
|
|
|
8352
8569
|
// src/resources/resource_skills.ts
|
|
8353
|
-
var ResourceSkillsResource = class extends
|
|
8570
|
+
var ResourceSkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8354
8571
|
constructor(http, pageSize) {
|
|
8355
8572
|
super(http, {
|
|
8356
8573
|
key: "resource_skills",
|
|
@@ -8404,16 +8621,16 @@ var ResourceSkillsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8404
8621
|
var MAX_TRANSFER_IDS = 500;
|
|
8405
8622
|
function requirePositiveIds(ids2, label) {
|
|
8406
8623
|
if (!Array.isArray(ids2) || ids2.length === 0) {
|
|
8407
|
-
throw new (0,
|
|
8624
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8408
8625
|
}
|
|
8409
8626
|
if (ids2.length > MAX_TRANSFER_IDS) {
|
|
8410
|
-
throw new (0,
|
|
8627
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8411
8628
|
}
|
|
8412
8629
|
const out = [];
|
|
8413
8630
|
for (const raw of ids2) {
|
|
8414
|
-
const id =
|
|
8631
|
+
const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8415
8632
|
if (typeof id === "number" && id < 1) {
|
|
8416
|
-
throw new (0,
|
|
8633
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8417
8634
|
}
|
|
8418
8635
|
out.push(id);
|
|
8419
8636
|
}
|
|
@@ -8421,7 +8638,7 @@ function requirePositiveIds(ids2, label) {
|
|
|
8421
8638
|
}
|
|
8422
8639
|
async function whoAmI(_resource, userName, http) {
|
|
8423
8640
|
const user = userName.trim();
|
|
8424
|
-
if (user === "") throw new (0,
|
|
8641
|
+
if (user === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8425
8642
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8426
8643
|
const res = await http.request({
|
|
8427
8644
|
method: "POST",
|
|
@@ -8430,11 +8647,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8430
8647
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8431
8648
|
operation: "resources.whoAmI"
|
|
8432
8649
|
});
|
|
8433
|
-
const matches =
|
|
8650
|
+
const matches = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
8434
8651
|
if (matches.length === 0) return null;
|
|
8435
8652
|
if (matches.length > 1) {
|
|
8436
8653
|
const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8437
|
-
throw new (0,
|
|
8654
|
+
throw new (0, _chunkZJ4ONAQFcjs.ResolutionError)(
|
|
8438
8655
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8439
8656
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
8440
8657
|
);
|
|
@@ -8443,9 +8660,9 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8443
8660
|
}
|
|
8444
8661
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8445
8662
|
const ids2 = requirePositiveIds(companyIds, "transferOwnership");
|
|
8446
|
-
const destination =
|
|
8663
|
+
const destination = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8447
8664
|
if (typeof destination === "number" && destination < 1) {
|
|
8448
|
-
throw new (0,
|
|
8665
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8449
8666
|
}
|
|
8450
8667
|
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _83 => _83.dryRun]), () => ( true));
|
|
8451
8668
|
const changes = [];
|
|
@@ -8458,7 +8675,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8458
8675
|
operation: "resources.transferOwnership",
|
|
8459
8676
|
maxRetries: _optionalChain([opts, 'optionalAccess', _84 => _84.maxRetries])
|
|
8460
8677
|
});
|
|
8461
|
-
const company =
|
|
8678
|
+
const company = _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, id, void 0, "company");
|
|
8462
8679
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8463
8680
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8464
8681
|
if (!dryRun) {
|
|
@@ -8469,13 +8686,13 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8469
8686
|
operation: "resources.transferOwnership",
|
|
8470
8687
|
maxRetries: _optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries])
|
|
8471
8688
|
});
|
|
8472
|
-
|
|
8689
|
+
_chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, update);
|
|
8473
8690
|
applied.push(id);
|
|
8474
8691
|
}
|
|
8475
8692
|
} catch (err) {
|
|
8476
|
-
if (!dryRun && err instanceof
|
|
8693
|
+
if (!dryRun && err instanceof _chunkZJ4ONAQFcjs.AutotaskError) {
|
|
8477
8694
|
err.resourceIds = [id];
|
|
8478
|
-
err.details =
|
|
8695
|
+
err.details = _chunkZJ4ONAQFcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
|
|
8479
8696
|
err.suggestedAction = `Partial transfer: ${applied.length} of ${ids2.length} companies were re-owned (ids: ${applied.join(", ") || "none"}); id ${id} failed. Re-run transferOwnership for the remaining ids (from ${id} on).`;
|
|
8480
8697
|
}
|
|
8481
8698
|
throw err;
|
|
@@ -8484,7 +8701,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8484
8701
|
if (dryRun) {
|
|
8485
8702
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8486
8703
|
return {
|
|
8487
|
-
...
|
|
8704
|
+
..._chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
8488
8705
|
operation: "resources.transferOwnership",
|
|
8489
8706
|
method: "PUT",
|
|
8490
8707
|
path: "/V1.0/Companies",
|
|
@@ -8508,7 +8725,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8508
8725
|
}
|
|
8509
8726
|
|
|
8510
8727
|
// src/resources/resources.ts
|
|
8511
|
-
var ResourcesResource = class extends
|
|
8728
|
+
var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8512
8729
|
|
|
8513
8730
|
constructor(http, clientConfig, pageSize) {
|
|
8514
8731
|
super(http, {
|
|
@@ -8581,7 +8798,7 @@ var ResourcesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8581
8798
|
|
|
8582
8799
|
// src/resources/special/resource_time_off_additional.ts
|
|
8583
8800
|
async function getByResource(_resource, resourceId, http) {
|
|
8584
|
-
const numericResource =
|
|
8801
|
+
const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8585
8802
|
const res = await http.request({
|
|
8586
8803
|
method: "GET",
|
|
8587
8804
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8595,11 +8812,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8595
8812
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8596
8813
|
}
|
|
8597
8814
|
}
|
|
8598
|
-
return
|
|
8815
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8599
8816
|
}
|
|
8600
8817
|
|
|
8601
8818
|
// src/resources/resource_time_off_additional.ts
|
|
8602
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8819
|
+
var ResourceTimeOffAdditionalResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8603
8820
|
constructor(http, pageSize) {
|
|
8604
8821
|
super(http, {
|
|
8605
8822
|
key: "resource_time_off_additional",
|
|
@@ -8638,7 +8855,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunkHQGE4WAVcjs.BaseReso
|
|
|
8638
8855
|
};
|
|
8639
8856
|
|
|
8640
8857
|
// src/resources/resource_time_off_approvers.ts
|
|
8641
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8858
|
+
var ResourceTimeOffApproversResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8642
8859
|
constructor(http, pageSize) {
|
|
8643
8860
|
super(http, {
|
|
8644
8861
|
key: "resource_time_off_approvers",
|
|
@@ -8681,29 +8898,29 @@ var ResourceTimeOffApproversResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
8681
8898
|
|
|
8682
8899
|
// src/resources/special/resource_time_off_balances.ts
|
|
8683
8900
|
async function getByResource2(_resource, resourceId, http) {
|
|
8684
|
-
const numericResource =
|
|
8901
|
+
const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8685
8902
|
const res = await http.request({
|
|
8686
8903
|
method: "GET",
|
|
8687
8904
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8688
8905
|
operation: "resource_time_off_balances.getByResource"
|
|
8689
8906
|
});
|
|
8690
|
-
return
|
|
8907
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8691
8908
|
}
|
|
8692
8909
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8693
|
-
const numericResource =
|
|
8910
|
+
const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8694
8911
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8695
|
-
throw new (0,
|
|
8912
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8696
8913
|
}
|
|
8697
8914
|
const res = await http.request({
|
|
8698
8915
|
method: "GET",
|
|
8699
8916
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8700
8917
|
operation: "resource_time_off_balances.getByYear"
|
|
8701
8918
|
});
|
|
8702
|
-
return
|
|
8919
|
+
return _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
8703
8920
|
}
|
|
8704
8921
|
|
|
8705
8922
|
// src/resources/resource_time_off_balances.ts
|
|
8706
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
8923
|
+
var ResourceTimeOffBalancesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8707
8924
|
constructor(http, pageSize) {
|
|
8708
8925
|
super(http, {
|
|
8709
8926
|
key: "resource_time_off_balances",
|
|
@@ -8741,7 +8958,7 @@ var ResourceTimeOffBalancesResource = class extends _chunkHQGE4WAVcjs.BaseResour
|
|
|
8741
8958
|
};
|
|
8742
8959
|
|
|
8743
8960
|
// src/resources/roles.ts
|
|
8744
|
-
var RolesResource = class extends
|
|
8961
|
+
var RolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8745
8962
|
constructor(http, pageSize) {
|
|
8746
8963
|
super(http, {
|
|
8747
8964
|
key: "roles",
|
|
@@ -8807,8 +9024,51 @@ var RolesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8807
9024
|
}
|
|
8808
9025
|
};
|
|
8809
9026
|
|
|
9027
|
+
// src/resources/sales_orders.ts
|
|
9028
|
+
var SalesOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9029
|
+
constructor(http, pageSize) {
|
|
9030
|
+
super(http, {
|
|
9031
|
+
key: "sales_orders",
|
|
9032
|
+
resourcePath: "/V1.0/SalesOrders",
|
|
9033
|
+
deletable: false,
|
|
9034
|
+
udfCapable: true,
|
|
9035
|
+
collectionUpdate: true
|
|
9036
|
+
// D1: the spec's item path is GET-only — confirmed updates PUT the collection (id in the body)
|
|
9037
|
+
}, pageSize);
|
|
9038
|
+
}
|
|
9039
|
+
/** Query SalesOrder records with the G3 filter surface (server-side JSON filter). */
|
|
9040
|
+
query(params) {
|
|
9041
|
+
return this.queryItems(params);
|
|
9042
|
+
}
|
|
9043
|
+
/** Get every SalesOrder record (the MCP-preferred read; 1000-page guarded). */
|
|
9044
|
+
async queryAll(params) {
|
|
9045
|
+
return this.queryAllItems(params);
|
|
9046
|
+
}
|
|
9047
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
9048
|
+
async count(params) {
|
|
9049
|
+
return this.countGlobal(params);
|
|
9050
|
+
}
|
|
9051
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
9052
|
+
async get(id) {
|
|
9053
|
+
return this.getGlobal(id);
|
|
9054
|
+
}
|
|
9055
|
+
/** Update a record (PUT on the COLLECTION — the vendored spec's item path is GET-only; the vendor
|
|
9056
|
+
* keys the record by the id in the body). The vendor validates the FULL model on this route (V2), so a
|
|
9057
|
+
* partial body is merged into the CURRENT record first: one fresh GET (which also serves the
|
|
9058
|
+
* stale-object guard's read) then the collection PUT of the merged model — an explicit null in the
|
|
9059
|
+
* caller body sends null; an omitted field keeps the current value. `raw: true` in the opts bag sends
|
|
9060
|
+
* the body as-is (full model or intentional partial — the compatibility escape hatch; no merge read).
|
|
9061
|
+
* `dryRun: true` returns the pinned envelope whose `data` is the merged body (the exact confirmed
|
|
9062
|
+
* wire) with the best-effort diff, from that same single read; a caller-supplied lastModifiedDate that
|
|
9063
|
+
* mismatches the vendor's current value throws STALE_OBJECT before the mutation. */
|
|
9064
|
+
async update(id, data, opts = {}) {
|
|
9065
|
+
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts);
|
|
9066
|
+
return this.updateGlobal(id, data, opts);
|
|
9067
|
+
}
|
|
9068
|
+
};
|
|
9069
|
+
|
|
8810
9070
|
// src/resources/service_calls.ts
|
|
8811
|
-
var ServiceCallsResource = class extends
|
|
9071
|
+
var ServiceCallsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8812
9072
|
constructor(http, pageSize) {
|
|
8813
9073
|
super(http, {
|
|
8814
9074
|
key: "service_calls",
|
|
@@ -8877,7 +9137,7 @@ var ServiceCallsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8877
9137
|
};
|
|
8878
9138
|
|
|
8879
9139
|
// src/resources/service_call_task_resources.ts
|
|
8880
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
9140
|
+
var ServiceCallTaskResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8881
9141
|
constructor(http, pageSize) {
|
|
8882
9142
|
super(http, {
|
|
8883
9143
|
key: "service_call_task_resources",
|
|
@@ -8934,7 +9194,7 @@ var ServiceCallTaskResourcesResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
8934
9194
|
};
|
|
8935
9195
|
|
|
8936
9196
|
// src/resources/service_call_tasks.ts
|
|
8937
|
-
var ServiceCallTasksResource = class extends
|
|
9197
|
+
var ServiceCallTasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8938
9198
|
constructor(http, pageSize) {
|
|
8939
9199
|
super(http, {
|
|
8940
9200
|
key: "service_call_tasks",
|
|
@@ -8991,7 +9251,7 @@ var ServiceCallTasksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
8991
9251
|
};
|
|
8992
9252
|
|
|
8993
9253
|
// src/resources/service_call_ticket_resources.ts
|
|
8994
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
9254
|
+
var ServiceCallTicketResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8995
9255
|
constructor(http, pageSize) {
|
|
8996
9256
|
super(http, {
|
|
8997
9257
|
key: "service_call_ticket_resources",
|
|
@@ -9048,7 +9308,7 @@ var ServiceCallTicketResourcesResource = class extends _chunkHQGE4WAVcjs.BaseRes
|
|
|
9048
9308
|
};
|
|
9049
9309
|
|
|
9050
9310
|
// src/resources/service_call_tickets.ts
|
|
9051
|
-
var ServiceCallTicketsResource = class extends
|
|
9311
|
+
var ServiceCallTicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9052
9312
|
constructor(http, pageSize) {
|
|
9053
9313
|
super(http, {
|
|
9054
9314
|
key: "service_call_tickets",
|
|
@@ -9105,7 +9365,7 @@ var ServiceCallTicketsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9105
9365
|
};
|
|
9106
9366
|
|
|
9107
9367
|
// src/resources/service_level_agreement_results.ts
|
|
9108
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
9368
|
+
var ServiceLevelAgreementResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9109
9369
|
constructor(http, pageSize) {
|
|
9110
9370
|
super(http, {
|
|
9111
9371
|
key: "service_level_agreement_results",
|
|
@@ -9144,7 +9404,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunkHQGE4WAVcjs.BaseR
|
|
|
9144
9404
|
};
|
|
9145
9405
|
|
|
9146
9406
|
// src/resources/services.ts
|
|
9147
|
-
var ServicesResource = class extends
|
|
9407
|
+
var ServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9148
9408
|
constructor(http, pageSize) {
|
|
9149
9409
|
super(http, {
|
|
9150
9410
|
key: "services",
|
|
@@ -9212,7 +9472,7 @@ var ServicesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9212
9472
|
};
|
|
9213
9473
|
|
|
9214
9474
|
// src/resources/skills.ts
|
|
9215
|
-
var SkillsResource = class extends
|
|
9475
|
+
var SkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9216
9476
|
constructor(http, pageSize) {
|
|
9217
9477
|
super(http, {
|
|
9218
9478
|
key: "skills",
|
|
@@ -9256,7 +9516,7 @@ var SkillsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9256
9516
|
};
|
|
9257
9517
|
|
|
9258
9518
|
// src/resources/subscription_periods.ts
|
|
9259
|
-
var SubscriptionPeriodsResource = class extends
|
|
9519
|
+
var SubscriptionPeriodsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9260
9520
|
constructor(http, pageSize) {
|
|
9261
9521
|
super(http, {
|
|
9262
9522
|
key: "subscription_periods",
|
|
@@ -9295,7 +9555,7 @@ var SubscriptionPeriodsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9295
9555
|
};
|
|
9296
9556
|
|
|
9297
9557
|
// src/resources/subscriptions.ts
|
|
9298
|
-
var SubscriptionsResource = class extends
|
|
9558
|
+
var SubscriptionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9299
9559
|
constructor(http, pageSize) {
|
|
9300
9560
|
super(http, {
|
|
9301
9561
|
key: "subscriptions",
|
|
@@ -9364,7 +9624,7 @@ var SubscriptionsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9364
9624
|
};
|
|
9365
9625
|
|
|
9366
9626
|
// src/resources/survey_results.ts
|
|
9367
|
-
var SurveyResultsResource = class extends
|
|
9627
|
+
var SurveyResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9368
9628
|
constructor(http, pageSize) {
|
|
9369
9629
|
super(http, {
|
|
9370
9630
|
key: "survey_results",
|
|
@@ -9403,7 +9663,7 @@ var SurveyResultsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9403
9663
|
};
|
|
9404
9664
|
|
|
9405
9665
|
// src/resources/surveys.ts
|
|
9406
|
-
var SurveysResource = class extends
|
|
9666
|
+
var SurveysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9407
9667
|
constructor(http, pageSize) {
|
|
9408
9668
|
super(http, {
|
|
9409
9669
|
key: "surveys",
|
|
@@ -9447,7 +9707,7 @@ var SurveysResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9447
9707
|
};
|
|
9448
9708
|
|
|
9449
9709
|
// src/resources/tag_aliases.ts
|
|
9450
|
-
var TagAliasesResource = class extends
|
|
9710
|
+
var TagAliasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9451
9711
|
constructor(http, pageSize) {
|
|
9452
9712
|
super(http, {
|
|
9453
9713
|
key: "tag_aliases",
|
|
@@ -9504,7 +9764,7 @@ var TagAliasesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9504
9764
|
};
|
|
9505
9765
|
|
|
9506
9766
|
// src/resources/tag_groups.ts
|
|
9507
|
-
var TagGroupsResource = class extends
|
|
9767
|
+
var TagGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9508
9768
|
constructor(http, pageSize) {
|
|
9509
9769
|
super(http, {
|
|
9510
9770
|
key: "tag_groups",
|
|
@@ -9573,7 +9833,7 @@ var TagGroupsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9573
9833
|
};
|
|
9574
9834
|
|
|
9575
9835
|
// src/resources/tags.ts
|
|
9576
|
-
var TagsResource = class extends
|
|
9836
|
+
var TagsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9577
9837
|
constructor(http, pageSize) {
|
|
9578
9838
|
super(http, {
|
|
9579
9839
|
key: "tags",
|
|
@@ -9642,7 +9902,7 @@ var TagsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9642
9902
|
};
|
|
9643
9903
|
|
|
9644
9904
|
// src/resources/task_secondary_resources.ts
|
|
9645
|
-
var TaskSecondaryResourcesResource = class extends
|
|
9905
|
+
var TaskSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9646
9906
|
constructor(http, pageSize) {
|
|
9647
9907
|
super(http, {
|
|
9648
9908
|
key: "task_secondary_resources",
|
|
@@ -9699,7 +9959,7 @@ var TaskSecondaryResourcesResource = class extends _chunkHQGE4WAVcjs.BaseResourc
|
|
|
9699
9959
|
};
|
|
9700
9960
|
|
|
9701
9961
|
// src/resources/tasks.ts
|
|
9702
|
-
var TasksResource = class extends
|
|
9962
|
+
var TasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9703
9963
|
constructor(http, pageSize) {
|
|
9704
9964
|
super(http, {
|
|
9705
9965
|
key: "tasks",
|
|
@@ -9762,6 +10022,57 @@ var TasksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9762
10022
|
}
|
|
9763
10023
|
};
|
|
9764
10024
|
|
|
10025
|
+
// src/resources/tax_regions.ts
|
|
10026
|
+
var TaxRegionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10027
|
+
constructor(http, pageSize) {
|
|
10028
|
+
super(http, {
|
|
10029
|
+
key: "tax_regions",
|
|
10030
|
+
resourcePath: "/V1.0/TaxRegions",
|
|
10031
|
+
deletable: false,
|
|
10032
|
+
udfCapable: false,
|
|
10033
|
+
collectionUpdate: true
|
|
10034
|
+
// D1: the spec's item path is GET-only — confirmed updates PUT the collection (id in the body)
|
|
10035
|
+
}, pageSize);
|
|
10036
|
+
}
|
|
10037
|
+
/** Query TaxRegion records with the G3 filter surface (server-side JSON filter). */
|
|
10038
|
+
query(params) {
|
|
10039
|
+
return this.queryItems(params);
|
|
10040
|
+
}
|
|
10041
|
+
/** Get every TaxRegion record (the MCP-preferred read; 1000-page guarded). */
|
|
10042
|
+
async queryAll(params) {
|
|
10043
|
+
return this.queryAllItems(params);
|
|
10044
|
+
}
|
|
10045
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
10046
|
+
async count(params) {
|
|
10047
|
+
return this.countGlobal(params);
|
|
10048
|
+
}
|
|
10049
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
10050
|
+
async get(id) {
|
|
10051
|
+
return this.getGlobal(id);
|
|
10052
|
+
}
|
|
10053
|
+
/** Create a record (OperationResultModel → { id}). `dryRun: true` returns the
|
|
10054
|
+
* pinned envelope (section 19.3) and never issues the create. A 2xx that is not the
|
|
10055
|
+
* specced envelope runs the plan-pinned marker recovery (issue #13 — one bounded read;
|
|
10056
|
+
* `recoverIdFromMarker: false` restores the pre-recovery behaviour). */
|
|
10057
|
+
async create(data, opts = {}) {
|
|
10058
|
+
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
10059
|
+
return this.createGlobal(data, opts);
|
|
10060
|
+
}
|
|
10061
|
+
/** Update a record (PUT on the COLLECTION — the vendored spec's item path is GET-only; the vendor
|
|
10062
|
+
* keys the record by the id in the body). The vendor validates the FULL model on this route (V2), so a
|
|
10063
|
+
* partial body is merged into the CURRENT record first: one fresh GET (which also serves the
|
|
10064
|
+
* stale-object guard's read) then the collection PUT of the merged model — an explicit null in the
|
|
10065
|
+
* caller body sends null; an omitted field keeps the current value. `raw: true` in the opts bag sends
|
|
10066
|
+
* the body as-is (full model or intentional partial — the compatibility escape hatch; no merge read).
|
|
10067
|
+
* `dryRun: true` returns the pinned envelope whose `data` is the merged body (the exact confirmed
|
|
10068
|
+
* wire) with the best-effort diff, from that same single read; a caller-supplied lastModifiedDate that
|
|
10069
|
+
* mismatches the vendor's current value throws STALE_OBJECT before the mutation. */
|
|
10070
|
+
async update(id, data, opts = {}) {
|
|
10071
|
+
if (opts.dryRun === true) return this.runUpdateDryRun(id, data, opts);
|
|
10072
|
+
return this.updateGlobal(id, data, opts);
|
|
10073
|
+
}
|
|
10074
|
+
};
|
|
10075
|
+
|
|
9765
10076
|
// src/resources/threshold_information.ts
|
|
9766
10077
|
var ThresholdInformationResource = class {
|
|
9767
10078
|
|
|
@@ -9787,7 +10098,7 @@ var ThresholdInformationResource = class {
|
|
|
9787
10098
|
};
|
|
9788
10099
|
|
|
9789
10100
|
// src/resources/ticket_additional_configuration_items.ts
|
|
9790
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
10101
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9791
10102
|
constructor(http, pageSize) {
|
|
9792
10103
|
super(http, {
|
|
9793
10104
|
key: "ticket_additional_configuration_items",
|
|
@@ -9844,7 +10155,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunkHQGE4WAVcjs
|
|
|
9844
10155
|
};
|
|
9845
10156
|
|
|
9846
10157
|
// src/resources/ticket_additional_contacts.ts
|
|
9847
|
-
var TicketAdditionalContactsResource = class extends
|
|
10158
|
+
var TicketAdditionalContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9848
10159
|
constructor(http, pageSize) {
|
|
9849
10160
|
super(http, {
|
|
9850
10161
|
key: "ticket_additional_contacts",
|
|
@@ -9901,7 +10212,7 @@ var TicketAdditionalContactsResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
9901
10212
|
};
|
|
9902
10213
|
|
|
9903
10214
|
// src/resources/ticket_attachments.ts
|
|
9904
|
-
var TicketAttachmentsResource = class extends
|
|
10215
|
+
var TicketAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9905
10216
|
constructor(http, pageSize) {
|
|
9906
10217
|
super(http, {
|
|
9907
10218
|
key: "ticket_attachments",
|
|
@@ -9963,7 +10274,7 @@ var TicketAttachmentsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
9963
10274
|
};
|
|
9964
10275
|
|
|
9965
10276
|
// src/resources/ticket_categories.ts
|
|
9966
|
-
var TicketCategoriesResource = class extends
|
|
10277
|
+
var TicketCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9967
10278
|
constructor(http, pageSize) {
|
|
9968
10279
|
super(http, {
|
|
9969
10280
|
key: "ticket_categories",
|
|
@@ -10022,7 +10333,7 @@ var TicketCategoriesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
10022
10333
|
};
|
|
10023
10334
|
|
|
10024
10335
|
// src/resources/ticket_category_field_defaults.ts
|
|
10025
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
10336
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10026
10337
|
constructor(http, pageSize) {
|
|
10027
10338
|
super(http, {
|
|
10028
10339
|
key: "ticket_category_field_defaults",
|
|
@@ -10064,7 +10375,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunkHQGE4WAVcjs.BaseRe
|
|
|
10064
10375
|
};
|
|
10065
10376
|
|
|
10066
10377
|
// src/resources/ticket_change_request_approvals.ts
|
|
10067
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
10378
|
+
var TicketChangeRequestApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10068
10379
|
constructor(http, pageSize) {
|
|
10069
10380
|
super(http, {
|
|
10070
10381
|
key: "ticket_change_request_approvals",
|
|
@@ -10125,10 +10436,10 @@ var _crypto = require('crypto');
|
|
|
10125
10436
|
var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
|
|
10126
10437
|
var TICKET_COMPLETE_STATUS = 5;
|
|
10127
10438
|
var MOVE_EFFECTS_NOTE = "Create then delete: the new record gets a fresh create date and creator; creating/deleting may trigger notifications, SLA and workflow rules the API cannot suppress; vendor acceptance of the create is not validated by a dry run";
|
|
10128
|
-
var refuse = (code, message, ids2, operation, extra = {}) => new (0,
|
|
10439
|
+
var refuse = (code, message, ids2, operation, extra = {}) => new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(message, { code, operation, details: { status: "failed", ...ids2, ...extra } });
|
|
10129
10440
|
async function queryRows(http, resource, filter, operation, retries) {
|
|
10130
10441
|
const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
|
|
10131
|
-
return
|
|
10442
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
10132
10443
|
}
|
|
10133
10444
|
function sameValue(a, b) {
|
|
10134
10445
|
if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
|
|
@@ -10148,7 +10459,7 @@ async function readTicket(http, id, retries, operation) {
|
|
|
10148
10459
|
const item = _optionalChain([res, 'optionalAccess', _93 => _93.item]);
|
|
10149
10460
|
return _nullishCoalesce(item, () => ( null));
|
|
10150
10461
|
} catch (e) {
|
|
10151
|
-
if (
|
|
10462
|
+
if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
10152
10463
|
throw e;
|
|
10153
10464
|
}
|
|
10154
10465
|
}
|
|
@@ -10169,7 +10480,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10169
10480
|
}
|
|
10170
10481
|
}
|
|
10171
10482
|
const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
|
|
10172
|
-
if (!Number.isFinite(cap) || cap < 0) throw new (0,
|
|
10483
|
+
if (!Number.isFinite(cap) || cap < 0) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${op}: maxSourceAgeDays must be a number >= 0`);
|
|
10173
10484
|
const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
|
|
10174
10485
|
if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
|
|
10175
10486
|
throw refuse("MOVE_SOURCE_TOO_OLD", `${op}: source ${spec.entity} ${sourceId} is older than ${cap} day(s) (or undated) \u2014 move it in the Autotask UI`, ids2, op, { manualAction: manualFor(http, spec, source, "older than the move age limit") });
|
|
@@ -10204,17 +10515,17 @@ async function assertNoTwin(ctx, payload) {
|
|
|
10204
10515
|
throw refuse("MOVE_TARGET_HAS_TWIN", `${ctx.spec.operation}: target ticket ${ctx.toTicketId} already has an equivalent ${ctx.spec.entity} (id ${String(rows[0].id)}) \u2014 a duplicate or resumed move`, { sourceId: ctx.sourceId, toTicketId: ctx.toTicketId }, ctx.spec.operation, { twinId: rows[0].id });
|
|
10205
10516
|
}
|
|
10206
10517
|
}
|
|
10207
|
-
var statusOf = (e) =>
|
|
10518
|
+
var statusOf = (e) => _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
|
|
10208
10519
|
async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
10209
10520
|
const op = spec.operation;
|
|
10210
|
-
const sourceId = Number(
|
|
10211
|
-
const toTicketId = Number(
|
|
10521
|
+
const sourceId = Number(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, sourceIdIn, "sourceId"));
|
|
10522
|
+
const toTicketId = Number(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, toTicketIn, "toTicketId"));
|
|
10212
10523
|
if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
|
|
10213
|
-
throw new (0,
|
|
10524
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
|
|
10214
10525
|
}
|
|
10215
10526
|
const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
|
|
10216
10527
|
if (opts.dryRun === true) {
|
|
10217
|
-
return
|
|
10528
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
10218
10529
|
{
|
|
10219
10530
|
operation: op,
|
|
10220
10531
|
method: "POST",
|
|
@@ -10239,22 +10550,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10239
10550
|
let newId;
|
|
10240
10551
|
try {
|
|
10241
10552
|
const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
|
|
10242
|
-
newId = Number(
|
|
10553
|
+
newId = Number(_chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, created, op).id);
|
|
10243
10554
|
} catch (e) {
|
|
10244
10555
|
const status = statusOf(e);
|
|
10245
10556
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
10246
|
-
throw new (0,
|
|
10557
|
+
throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: the vendor refused the create \u2014 nothing changed`, { code: "MOVE_CREATE_REFUSED", operation: op, httpStatus: status, details: { status: "failed", ...ids2 } });
|
|
10247
10558
|
}
|
|
10248
|
-
throw new (0,
|
|
10559
|
+
throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: the create outcome is unknown (never resent) \u2014 check the target ticket for a new ${spec.entity} before retrying; the twin check blocks a second create`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2 } });
|
|
10249
10560
|
}
|
|
10250
10561
|
const rollback = async (code, message) => {
|
|
10251
10562
|
try {
|
|
10252
10563
|
await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
|
|
10253
10564
|
} catch (re) {
|
|
10254
10565
|
const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
|
|
10255
|
-
throw new (0,
|
|
10566
|
+
throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: ${message}; rolling back the new ${spec.entity} ${newId} FAILED \u2014 both records exist`, { code: unreadable ? "MOVE_UNKNOWN" : "MOVE_PARTIAL", operation: op, details: { status: unreadable ? "unknown" : "partial", ...ids2, newId, reason: code } });
|
|
10256
10567
|
}
|
|
10257
|
-
throw new (0,
|
|
10568
|
+
throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: ${message}; the new ${spec.entity} ${newId} was rolled back, the source is unchanged`, { code, operation: op, details: { status: "failed", ...ids2, newId } });
|
|
10258
10569
|
};
|
|
10259
10570
|
const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
|
|
10260
10571
|
if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
|
|
@@ -10283,14 +10594,14 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10283
10594
|
};
|
|
10284
10595
|
}
|
|
10285
10596
|
if (status === void 0) {
|
|
10286
|
-
throw new (0,
|
|
10597
|
+
throw new (0, _chunkZJ4ONAQFcjs.MoveRefusedError)(`${op}: the source delete outcome is unknown (never resent) \u2014 re-read the source: absent means the move completed`, { code: "MOVE_UNKNOWN", operation: op, details: { status: "unknown", ...ids2, newId } });
|
|
10287
10598
|
}
|
|
10288
10599
|
return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
|
|
10289
10600
|
}
|
|
10290
10601
|
return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
|
|
10291
10602
|
}
|
|
10292
10603
|
function uiLinkFor(http, entity, id) {
|
|
10293
|
-
return _nullishCoalesce(
|
|
10604
|
+
return _nullishCoalesce(_chunkZJ4ONAQFcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
|
|
10294
10605
|
}
|
|
10295
10606
|
|
|
10296
10607
|
// src/resources/special/ticket_charges.ts
|
|
@@ -10345,7 +10656,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
|
|
|
10345
10656
|
}
|
|
10346
10657
|
|
|
10347
10658
|
// src/resources/ticket_charges.ts
|
|
10348
|
-
var TicketChargesResource = class extends
|
|
10659
|
+
var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10349
10660
|
constructor(http, pageSize) {
|
|
10350
10661
|
super(http, {
|
|
10351
10662
|
key: "ticket_charges",
|
|
@@ -10420,7 +10731,7 @@ var TicketChargesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
10420
10731
|
};
|
|
10421
10732
|
|
|
10422
10733
|
// src/resources/ticket_checklist_items.ts
|
|
10423
|
-
var TicketChecklistItemsResource = class extends
|
|
10734
|
+
var TicketChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10424
10735
|
constructor(http, pageSize) {
|
|
10425
10736
|
super(http, {
|
|
10426
10737
|
key: "ticket_checklist_items",
|
|
@@ -10486,7 +10797,7 @@ var TicketChecklistItemsResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
10486
10797
|
};
|
|
10487
10798
|
|
|
10488
10799
|
// src/resources/ticket_checklist_libraries.ts
|
|
10489
|
-
var TicketChecklistLibrariesResource = class extends
|
|
10800
|
+
var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10490
10801
|
constructor(http, pageSize) {
|
|
10491
10802
|
super(http, {
|
|
10492
10803
|
key: "ticket_checklist_libraries",
|
|
@@ -10510,9 +10821,9 @@ var TicketChecklistLibrariesResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
10510
10821
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
10511
10822
|
* surface — no documents read op — and never issues the POST). */
|
|
10512
10823
|
async attachToDocument(documentID, data, opts = {}) {
|
|
10513
|
-
const n =
|
|
10824
|
+
const n = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
10514
10825
|
if (opts.dryRun === true) {
|
|
10515
|
-
return
|
|
10826
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
10516
10827
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10517
10828
|
method: "POST",
|
|
10518
10829
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -10530,7 +10841,7 @@ var TicketChecklistLibrariesResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
10530
10841
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10531
10842
|
maxRetries: opts.maxRetries
|
|
10532
10843
|
});
|
|
10533
|
-
return
|
|
10844
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
10534
10845
|
}
|
|
10535
10846
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
10536
10847
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10546,7 +10857,7 @@ var TicketChecklistLibrariesResource = class extends _chunkHQGE4WAVcjs.BaseResou
|
|
|
10546
10857
|
};
|
|
10547
10858
|
|
|
10548
10859
|
// src/resources/ticket_history.ts
|
|
10549
|
-
var TicketHistoryResource = class extends
|
|
10860
|
+
var TicketHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10550
10861
|
constructor(http, pageSize) {
|
|
10551
10862
|
super(http, {
|
|
10552
10863
|
key: "ticket_history",
|
|
@@ -10585,7 +10896,7 @@ var TicketHistoryResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
10585
10896
|
};
|
|
10586
10897
|
|
|
10587
10898
|
// src/resources/ticket_note_attachments.ts
|
|
10588
|
-
var TicketNoteAttachmentsResource = class extends
|
|
10899
|
+
var TicketNoteAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10589
10900
|
constructor(http, pageSize) {
|
|
10590
10901
|
super(http, {
|
|
10591
10902
|
key: "ticket_note_attachments",
|
|
@@ -10647,7 +10958,7 @@ var TicketNoteAttachmentsResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
10647
10958
|
};
|
|
10648
10959
|
|
|
10649
10960
|
// src/resources/ticket_notes.ts
|
|
10650
|
-
var TicketNotesResource = class extends
|
|
10961
|
+
var TicketNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10651
10962
|
constructor(http, pageSize) {
|
|
10652
10963
|
super(http, {
|
|
10653
10964
|
key: "ticket_notes",
|
|
@@ -10706,7 +11017,7 @@ var TicketNotesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
10706
11017
|
};
|
|
10707
11018
|
|
|
10708
11019
|
// src/resources/ticket_note_webhooks.ts
|
|
10709
|
-
var TicketNoteWebhooksResource = class extends
|
|
11020
|
+
var TicketNoteWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10710
11021
|
constructor(http, pageSize) {
|
|
10711
11022
|
super(http, {
|
|
10712
11023
|
key: "ticket_note_webhooks",
|
|
@@ -10782,7 +11093,7 @@ var TicketNoteWebhooksResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
10782
11093
|
};
|
|
10783
11094
|
|
|
10784
11095
|
// src/resources/ticket_secondary_resources.ts
|
|
10785
|
-
var TicketSecondaryResourcesResource = class extends
|
|
11096
|
+
var TicketSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10786
11097
|
constructor(http, pageSize) {
|
|
10787
11098
|
super(http, {
|
|
10788
11099
|
key: "ticket_secondary_resources",
|
|
@@ -10847,9 +11158,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
10847
11158
|
});
|
|
10848
11159
|
const body = res;
|
|
10849
11160
|
if (body === null || !("item" in body)) {
|
|
10850
|
-
throw new (0,
|
|
11161
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
10851
11162
|
}
|
|
10852
|
-
if (body.item === null || body.item === void 0) throw new (0,
|
|
11163
|
+
if (body.item === null || body.item === void 0) throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Ticket ${id} not found`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
10853
11164
|
return body.item;
|
|
10854
11165
|
}
|
|
10855
11166
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -10860,7 +11171,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
10860
11171
|
body: { MaxRecords: maxRecords, filter },
|
|
10861
11172
|
operation
|
|
10862
11173
|
});
|
|
10863
|
-
return
|
|
11174
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
10864
11175
|
}
|
|
10865
11176
|
function truncate(text, limit) {
|
|
10866
11177
|
const full = _nullishCoalesce(text, () => ( ""));
|
|
@@ -10870,26 +11181,26 @@ function truncate(text, limit) {
|
|
|
10870
11181
|
|
|
10871
11182
|
// src/resources/special/tickets/childRead.ts
|
|
10872
11183
|
function isRouteUnavailable(err) {
|
|
10873
|
-
return
|
|
11184
|
+
return _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
10874
11185
|
}
|
|
10875
11186
|
function routeFact(route, path, err) {
|
|
10876
11187
|
return {
|
|
10877
11188
|
route,
|
|
10878
11189
|
path,
|
|
10879
|
-
httpStatus:
|
|
11190
|
+
httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
10880
11191
|
};
|
|
10881
11192
|
}
|
|
10882
11193
|
function childDeclaresQuery(resourceKey) {
|
|
10883
|
-
return
|
|
11194
|
+
return _chunk5CC7LGNMcjs.CAPABILITIES.some(
|
|
10884
11195
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
10885
11196
|
);
|
|
10886
11197
|
}
|
|
10887
11198
|
function planScopedPath(resourceKey, ticketId) {
|
|
10888
11199
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
10889
|
-
const entry =
|
|
11200
|
+
const entry = _chunkZJ4ONAQFcjs.RELATIONSHIP_MAP[resourceKey];
|
|
10890
11201
|
const parent = entry === void 0 ? null : entry.parent;
|
|
10891
11202
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
10892
|
-
const parentPath = _optionalChain([
|
|
11203
|
+
const parentPath = _optionalChain([_chunkZJ4ONAQFcjs.RELATIONSHIP_MAP, 'access', _97 => _97[parent.resource], 'optionalAccess', _98 => _98.path]);
|
|
10893
11204
|
if (parentPath === null || parentPath === void 0) return null;
|
|
10894
11205
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
10895
11206
|
}
|
|
@@ -10928,14 +11239,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
10928
11239
|
break;
|
|
10929
11240
|
}
|
|
10930
11241
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
10931
|
-
const { items: pageItems, pageDetails } =
|
|
11242
|
+
const { items: pageItems, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, body, operation);
|
|
10932
11243
|
nextCursor = pageDetails.nextPageUrl;
|
|
10933
11244
|
pages += 1;
|
|
10934
11245
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
10935
11246
|
for (const row of window) if (accept(row)) items.push(row);
|
|
10936
11247
|
if (items.length >= limit) break;
|
|
10937
11248
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
10938
|
-
target =
|
|
11249
|
+
target = _chunkZJ4ONAQFcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
10939
11250
|
}
|
|
10940
11251
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
10941
11252
|
return { items, capped };
|
|
@@ -10968,7 +11279,7 @@ var MS = 864e5;
|
|
|
10968
11279
|
var SLA_PAGE = 100;
|
|
10969
11280
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
10970
11281
|
void opts;
|
|
10971
|
-
const ticketId =
|
|
11282
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
10972
11283
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
10973
11284
|
const rows = await ticketQueryItems(
|
|
10974
11285
|
http,
|
|
@@ -10993,9 +11304,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
10993
11304
|
async function summary(_resource, id, opts = {}, http) {
|
|
10994
11305
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
10995
11306
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
10996
|
-
throw new (0,
|
|
11307
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
10997
11308
|
}
|
|
10998
|
-
const ticketId =
|
|
11309
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
10999
11310
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
11000
11311
|
const desc = truncate(ticket.description, limit);
|
|
11001
11312
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -11024,11 +11335,11 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
11024
11335
|
// src/resources/special/tickets/timeline.ts
|
|
11025
11336
|
function validateTimelineLimits(opts) {
|
|
11026
11337
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
11027
|
-
if (!Number.isInteger(limit) || limit < 1) throw new (0,
|
|
11338
|
+
if (!Number.isInteger(limit) || limit < 1) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`limit must be an integer >= 1 (got ${String(opts.limit)})`);
|
|
11028
11339
|
const bounded = Math.min(limit, 500);
|
|
11029
11340
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
11030
11341
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
11031
|
-
throw new (0,
|
|
11342
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
11032
11343
|
}
|
|
11033
11344
|
return { bounded, textLimit };
|
|
11034
11345
|
}
|
|
@@ -11080,7 +11391,7 @@ function compareEventDates(a, b) {
|
|
|
11080
11391
|
}
|
|
11081
11392
|
async function timeline(_resource, id, opts = {}, http) {
|
|
11082
11393
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
11083
|
-
const ticketId =
|
|
11394
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
11084
11395
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
11085
11396
|
const dateFilters = (field) => {
|
|
11086
11397
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11120,7 +11431,7 @@ async function timeline(_resource, id, opts = {}, http) {
|
|
|
11120
11431
|
}
|
|
11121
11432
|
|
|
11122
11433
|
// src/resources/special/tickets/errors.ts
|
|
11123
|
-
var QueueRequiredError = class extends
|
|
11434
|
+
var QueueRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11124
11435
|
constructor(message, options = {}) {
|
|
11125
11436
|
super(message, {
|
|
11126
11437
|
code: "QUEUE_REQUIRED",
|
|
@@ -11131,13 +11442,13 @@ var QueueRequiredError = class extends _chunkHQGE4WAVcjs.AutotaskError {
|
|
|
11131
11442
|
this.name = "QueueRequiredError";
|
|
11132
11443
|
}
|
|
11133
11444
|
};
|
|
11134
|
-
var TicketResourceInvalidError = class extends
|
|
11445
|
+
var TicketResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11135
11446
|
constructor(message, options = {}) {
|
|
11136
11447
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11137
11448
|
this.name = "TicketResourceInvalidError";
|
|
11138
11449
|
}
|
|
11139
11450
|
};
|
|
11140
|
-
var TicketCreateValidationFailedError = class extends
|
|
11451
|
+
var TicketCreateValidationFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11141
11452
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
11142
11453
|
|
|
11143
11454
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -11146,7 +11457,7 @@ var TicketCreateValidationFailedError = class extends _chunkHQGE4WAVcjs.Autotask
|
|
|
11146
11457
|
this.vendorFields = vendorFields;
|
|
11147
11458
|
}
|
|
11148
11459
|
};
|
|
11149
|
-
var StatusUnknownError = class extends
|
|
11460
|
+
var StatusUnknownError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11150
11461
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
11151
11462
|
|
|
11152
11463
|
constructor(message, options = {}) {
|
|
@@ -11160,7 +11471,7 @@ var StatusUnknownError = class extends _chunkHQGE4WAVcjs.AutotaskError {
|
|
|
11160
11471
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
11161
11472
|
}
|
|
11162
11473
|
};
|
|
11163
|
-
var StatusFieldsRequiredError = class extends
|
|
11474
|
+
var StatusFieldsRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11164
11475
|
|
|
11165
11476
|
|
|
11166
11477
|
|
|
@@ -11183,14 +11494,14 @@ function isPositiveInt(v) {
|
|
|
11183
11494
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
11184
11495
|
}
|
|
11185
11496
|
function namedVendorFields(err) {
|
|
11186
|
-
if (!
|
|
11187
|
-
const entries = _nullishCoalesce(
|
|
11497
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return [];
|
|
11498
|
+
const entries = _nullishCoalesce(_chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError), () => ( []));
|
|
11188
11499
|
const out = /* @__PURE__ */ new Set();
|
|
11189
11500
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
11190
11501
|
return [...out];
|
|
11191
11502
|
}
|
|
11192
11503
|
function vendorDetailOf(err) {
|
|
11193
|
-
return
|
|
11504
|
+
return _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
11194
11505
|
}
|
|
11195
11506
|
async function fetchItem(http, path, operation, readOpts) {
|
|
11196
11507
|
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _99 => _99.maxRetries]) });
|
|
@@ -11211,8 +11522,8 @@ function operationId(res) {
|
|
|
11211
11522
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
11212
11523
|
}
|
|
11213
11524
|
function discoveryMerge(err, body, defaults) {
|
|
11214
|
-
if (!
|
|
11215
|
-
const entries =
|
|
11525
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
11526
|
+
const entries = _chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
11216
11527
|
if (entries === void 0) return null;
|
|
11217
11528
|
for (const entry of entries) {
|
|
11218
11529
|
const field = entry.field;
|
|
@@ -11224,7 +11535,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
11224
11535
|
}
|
|
11225
11536
|
function stepErrorText(code, err) {
|
|
11226
11537
|
const detail = vendorDetailOf(err);
|
|
11227
|
-
const base =
|
|
11538
|
+
const base = _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
11228
11539
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
11229
11540
|
}
|
|
11230
11541
|
|
|
@@ -11236,43 +11547,43 @@ var DEFAULT_PUBLISH = 1;
|
|
|
11236
11547
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
11237
11548
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
11238
11549
|
function validateOpenInput(params, note, assign) {
|
|
11239
|
-
const companyID =
|
|
11550
|
+
const companyID = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _101 => _101.companyID]), "params.companyID");
|
|
11240
11551
|
const title = _optionalChain([params, 'optionalAccess', _102 => _102.title]);
|
|
11241
11552
|
if (typeof title !== "string" || title.trim() === "") {
|
|
11242
|
-
throw new (0,
|
|
11553
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
11243
11554
|
}
|
|
11244
11555
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
11245
11556
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
11246
11557
|
if (!isPositiveInt(priority)) {
|
|
11247
|
-
throw new (0,
|
|
11558
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
11248
11559
|
}
|
|
11249
11560
|
if (!isPositiveInt(status)) {
|
|
11250
|
-
throw new (0,
|
|
11561
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
11251
11562
|
}
|
|
11252
11563
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
11253
|
-
throw new (0,
|
|
11564
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
11254
11565
|
}
|
|
11255
11566
|
if (note !== void 0) {
|
|
11256
11567
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
11257
|
-
throw new (0,
|
|
11568
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
11258
11569
|
}
|
|
11259
11570
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
11260
|
-
throw new (0,
|
|
11571
|
+
throw new (0, _chunkZJ4ONAQFcjs.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 });
|
|
11261
11572
|
}
|
|
11262
11573
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
11263
|
-
throw new (0,
|
|
11574
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
11264
11575
|
}
|
|
11265
11576
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
11266
|
-
throw new (0,
|
|
11577
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.publish must be an integer picklist value 1/2/4 (got ${String(note.publish)} \u2014 NOT a boolean)`, { operation: OP_OPEN });
|
|
11267
11578
|
}
|
|
11268
11579
|
}
|
|
11269
|
-
const assignee = assign === void 0 ? void 0 :
|
|
11580
|
+
const assignee = assign === void 0 ? void 0 : _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
11270
11581
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
11271
|
-
throw new (0,
|
|
11582
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
11272
11583
|
}
|
|
11273
11584
|
const roleID = _optionalChain([assign, 'optionalAccess', _103 => _103.roleID]);
|
|
11274
11585
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
11275
|
-
throw new (0,
|
|
11586
|
+
throw new (0, _chunkZJ4ONAQFcjs.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 });
|
|
11276
11587
|
}
|
|
11277
11588
|
return { companyID, title, priority, status, assignee, roleID };
|
|
11278
11589
|
}
|
|
@@ -11301,7 +11612,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
|
|
|
11301
11612
|
if (assign !== void 0) {
|
|
11302
11613
|
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).`);
|
|
11303
11614
|
}
|
|
11304
|
-
return
|
|
11615
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
11305
11616
|
{
|
|
11306
11617
|
operation: OP_OPEN,
|
|
11307
11618
|
method: "POST",
|
|
@@ -11341,8 +11652,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11341
11652
|
`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}` : ""}`,
|
|
11342
11653
|
{
|
|
11343
11654
|
operation: OP_OPEN,
|
|
11344
|
-
httpStatus:
|
|
11345
|
-
vendorError:
|
|
11655
|
+
httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11656
|
+
vendorError: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0
|
|
11346
11657
|
}
|
|
11347
11658
|
);
|
|
11348
11659
|
}
|
|
@@ -11357,8 +11668,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11357
11668
|
named,
|
|
11358
11669
|
{
|
|
11359
11670
|
operation: OP_OPEN,
|
|
11360
|
-
httpStatus:
|
|
11361
|
-
vendorError:
|
|
11671
|
+
httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11672
|
+
vendorError: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11362
11673
|
resourceIds: [companyID],
|
|
11363
11674
|
details: { idRefs: [{ entity: "company", id: companyID }] }
|
|
11364
11675
|
}
|
|
@@ -11383,10 +11694,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
|
|
|
11383
11694
|
try {
|
|
11384
11695
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
11385
11696
|
if (current === null) {
|
|
11386
|
-
throw new (0,
|
|
11697
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`openWithNoteAndAssign: ticket ${ticketId} vanished between the create and the assign merge read`, { operation: OP_OPEN, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11387
11698
|
}
|
|
11388
11699
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
11389
|
-
const merged =
|
|
11700
|
+
const merged = _chunkZJ4ONAQFcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
11390
11701
|
merged.id = ticketId;
|
|
11391
11702
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
11392
11703
|
assigned = true;
|
|
@@ -11450,7 +11761,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11450
11761
|
const ids2 = await readLiveStatusSet(resource);
|
|
11451
11762
|
if (ids2.size > 0) liveStatus = ids2;
|
|
11452
11763
|
} catch (err) {
|
|
11453
|
-
if (!
|
|
11764
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11454
11765
|
}
|
|
11455
11766
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
11456
11767
|
_optionalChain([http, 'access', _104 => _104.fieldCache, 'optionalAccess', _105 => _105.invalidate, 'call', _106 => _106("tickets")]);
|
|
@@ -11460,7 +11771,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11460
11771
|
const freshIds = await readLiveStatusSet(resource);
|
|
11461
11772
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
11462
11773
|
} catch (err) {
|
|
11463
|
-
if (!
|
|
11774
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11464
11775
|
freshStatus = null;
|
|
11465
11776
|
reReadFailed = true;
|
|
11466
11777
|
}
|
|
@@ -11478,7 +11789,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11478
11789
|
return { guardDegraded: liveStatus === null };
|
|
11479
11790
|
}
|
|
11480
11791
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
11481
|
-
return
|
|
11792
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
11482
11793
|
{
|
|
11483
11794
|
operation: OP_STATUS,
|
|
11484
11795
|
method: "PUT",
|
|
@@ -11532,7 +11843,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11532
11843
|
if (mapEntry === void 0) {
|
|
11533
11844
|
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).`);
|
|
11534
11845
|
}
|
|
11535
|
-
return
|
|
11846
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
11536
11847
|
{
|
|
11537
11848
|
operation: OP_STATUS,
|
|
11538
11849
|
method: "PUT",
|
|
@@ -11552,7 +11863,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11552
11863
|
}
|
|
11553
11864
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
11554
11865
|
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _109 => _109.safeDefaults]), () => ( {}));
|
|
11555
|
-
const body =
|
|
11866
|
+
const body = _chunkZJ4ONAQFcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
11556
11867
|
body.id = ticketId;
|
|
11557
11868
|
let merges = 0;
|
|
11558
11869
|
for (; ; ) {
|
|
@@ -11576,8 +11887,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11576
11887
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
11577
11888
|
{
|
|
11578
11889
|
operation: OP_STATUS,
|
|
11579
|
-
httpStatus:
|
|
11580
|
-
vendorError:
|
|
11890
|
+
httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.httpStatus : void 0,
|
|
11891
|
+
vendorError: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.vendorError : void 0,
|
|
11581
11892
|
resourceIds: [ticketId],
|
|
11582
11893
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
11583
11894
|
}
|
|
@@ -11590,7 +11901,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11590
11901
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
11591
11902
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11592
11903
|
if (verify === null) {
|
|
11593
|
-
throw new (0,
|
|
11904
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(`changeStatus: the post-PUT read-back found no ticket ${ticketId} (the PUT 200ed but the record is gone)`, {
|
|
11594
11905
|
code: "INVALID_RESPONSE",
|
|
11595
11906
|
category: "server",
|
|
11596
11907
|
operation: OP_STATUS,
|
|
@@ -11600,7 +11911,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11600
11911
|
}
|
|
11601
11912
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
11602
11913
|
if (finalStatus !== targetStatus) {
|
|
11603
|
-
throw new (0,
|
|
11914
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(
|
|
11604
11915
|
`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)`,
|
|
11605
11916
|
{
|
|
11606
11917
|
code: "INVALID_RESPONSE",
|
|
@@ -11615,17 +11926,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11615
11926
|
}
|
|
11616
11927
|
}
|
|
11617
11928
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
11618
|
-
const ticketId =
|
|
11929
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
11619
11930
|
if (!isPositiveInt(targetStatus)) {
|
|
11620
|
-
throw new (0,
|
|
11931
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
11621
11932
|
}
|
|
11622
11933
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
11623
11934
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
11624
|
-
throw new (0,
|
|
11935
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
11625
11936
|
}
|
|
11626
11937
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11627
11938
|
if (current === null) {
|
|
11628
|
-
throw new (0,
|
|
11939
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`changeStatus: ticket ${ticketId} was not found (tickets.get returned item: null)`, { operation: OP_STATUS, resourceIds: [ticketId], details: { idRefs: [{ entity: "ticket", id: ticketId }] } });
|
|
11629
11940
|
}
|
|
11630
11941
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
11631
11942
|
if (previousStatus === targetStatus) {
|
|
@@ -11645,7 +11956,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
11645
11956
|
function partLimit(value, name) {
|
|
11646
11957
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
11647
11958
|
if (!Number.isInteger(n) || n < 1) {
|
|
11648
|
-
throw new (0,
|
|
11959
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
11649
11960
|
}
|
|
11650
11961
|
return n;
|
|
11651
11962
|
}
|
|
@@ -11658,7 +11969,7 @@ function servedTextRecord(row, textField, limit) {
|
|
|
11658
11969
|
return out;
|
|
11659
11970
|
}
|
|
11660
11971
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
11661
|
-
const builder =
|
|
11972
|
+
const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS);
|
|
11662
11973
|
const t = ctx.ticket;
|
|
11663
11974
|
builder.addResource(t["creatorResourceID"]);
|
|
11664
11975
|
builder.addFk("contract", t["contractID"]);
|
|
@@ -11670,20 +11981,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
|
11670
11981
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
11671
11982
|
builder.addFk("contract", e["contractID"]);
|
|
11672
11983
|
}
|
|
11673
|
-
const names = await
|
|
11984
|
+
const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
11674
11985
|
const ticketRow = { ...ctx.ticket };
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
for (const f of
|
|
11986
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "creatorResourceID", (v) => names.resourceName(v));
|
|
11987
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "contractID", (v) => names.recordName("contract", v));
|
|
11988
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11989
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, ticketRow, "assignedResourceRoleID", (v) => names.recordName("role", v));
|
|
11990
|
+
for (const f of _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS) _chunkZJ4ONAQFcjs.addLabelSibling.call(void 0, ticketRow, f, names);
|
|
11680
11991
|
result.ticket = ticketRow;
|
|
11681
11992
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
11682
11993
|
const row = { ...e };
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11994
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "resourceID", (v) => names.resourceName(v));
|
|
11995
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "roleID", (v) => names.recordName("role", v));
|
|
11996
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "billingCodeID", (v) => names.recordName("billingCode", v));
|
|
11997
|
+
_chunkZJ4ONAQFcjs.addNameSibling.call(void 0, row, "contractID", (v) => names.recordName("contract", v));
|
|
11687
11998
|
return row;
|
|
11688
11999
|
});
|
|
11689
12000
|
result.names = names.section;
|
|
@@ -11693,7 +12004,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11693
12004
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
11694
12005
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
11695
12006
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
11696
|
-
const ticketId =
|
|
12007
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
11697
12008
|
const ctx = await resource.getContext(ticketId);
|
|
11698
12009
|
const op = "tickets.fullContext";
|
|
11699
12010
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11751,7 +12062,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11751
12062
|
}
|
|
11752
12063
|
|
|
11753
12064
|
// src/resources/tickets.ts
|
|
11754
|
-
var TicketsResource = class extends
|
|
12065
|
+
var TicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
11755
12066
|
constructor(http, pageSize) {
|
|
11756
12067
|
super(http, {
|
|
11757
12068
|
key: "tickets",
|
|
@@ -11858,7 +12169,7 @@ var TicketsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
11858
12169
|
};
|
|
11859
12170
|
|
|
11860
12171
|
// src/resources/ticket_webhooks.ts
|
|
11861
|
-
var TicketWebhooksResource = class extends
|
|
12172
|
+
var TicketWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
11862
12173
|
constructor(http, pageSize) {
|
|
11863
12174
|
super(http, {
|
|
11864
12175
|
key: "ticket_webhooks",
|
|
@@ -11944,7 +12255,7 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
11944
12255
|
body: { MaxRecords: limit, filter },
|
|
11945
12256
|
operation
|
|
11946
12257
|
});
|
|
11947
|
-
const { items, pageDetails } =
|
|
12258
|
+
const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res);
|
|
11948
12259
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
11949
12260
|
}
|
|
11950
12261
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
@@ -11963,7 +12274,7 @@ async function customRange3(_resource, from, to, http, opts) {
|
|
|
11963
12274
|
const fromB = customRangeDay(from, "from", void 0, "customRange");
|
|
11964
12275
|
const toB = customRangeDay(to, "to", void 0, "customRange");
|
|
11965
12276
|
if (fromB.ms > toB.ms) {
|
|
11966
|
-
throw new (0,
|
|
12277
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
11967
12278
|
}
|
|
11968
12279
|
const toEndMs = toB.ms + DAY_MS2 - 1;
|
|
11969
12280
|
const filter = [
|
|
@@ -11983,12 +12294,12 @@ async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
|
11983
12294
|
return items;
|
|
11984
12295
|
}
|
|
11985
12296
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
11986
|
-
const
|
|
11987
|
-
if (_optionalChain([opts, 'optionalAccess', _118 => _118.tz]) !== void 0) validateZone(opts.tz,
|
|
11988
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
11989
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
12297
|
+
const OP7 = opLabel;
|
|
12298
|
+
if (_optionalChain([opts, 'optionalAccess', _118 => _118.tz]) !== void 0) validateZone(opts.tz, OP7);
|
|
12299
|
+
const fromB = customRangeDay(from, "from", void 0, OP7);
|
|
12300
|
+
const toB = customRangeDay(to, "to", void 0, OP7);
|
|
11990
12301
|
if (fromB.ms > toB.ms) {
|
|
11991
|
-
throw new (0,
|
|
12302
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP7}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP7 });
|
|
11992
12303
|
}
|
|
11993
12304
|
const windowToMs = toB.ms + DAY_MS2 - 1;
|
|
11994
12305
|
const filter = [
|
|
@@ -11999,7 +12310,7 @@ async function postedWithin(_resource, from, to, http, opts, opLabel = "time_ent
|
|
|
11999
12310
|
else if (_optionalChain([opts, 'optionalAccess', _120 => _120.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
12000
12311
|
if (_optionalChain([opts, 'optionalAccess', _121 => _121.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12001
12312
|
if (_optionalChain([opts, 'optionalAccess', _122 => _122.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
12002
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _123 => _123.limit])),
|
|
12313
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _123 => _123.limit])), OP7, http);
|
|
12003
12314
|
let postedCount = 0;
|
|
12004
12315
|
for (const item of items) {
|
|
12005
12316
|
const postedDate = item.postedDate;
|
|
@@ -12022,13 +12333,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
|
|
|
12022
12333
|
}
|
|
12023
12334
|
|
|
12024
12335
|
// src/resources/special/time_entries/errors.ts
|
|
12025
|
-
var ResourceInvalidError = class extends
|
|
12336
|
+
var ResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
12026
12337
|
constructor(message, options = {}) {
|
|
12027
12338
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
12028
12339
|
this.name = "ResourceInvalidError";
|
|
12029
12340
|
}
|
|
12030
12341
|
};
|
|
12031
|
-
var AllocationCodeError = class extends
|
|
12342
|
+
var AllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
12032
12343
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
12033
12344
|
|
|
12034
12345
|
constructor(kind, message, options = {}) {
|
|
@@ -12037,7 +12348,7 @@ var AllocationCodeError = class extends _chunkHQGE4WAVcjs.AutotaskError {
|
|
|
12037
12348
|
this.kind = kind;
|
|
12038
12349
|
}
|
|
12039
12350
|
};
|
|
12040
|
-
var NoApplicableAllocationCodeError = class extends
|
|
12351
|
+
var NoApplicableAllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
12041
12352
|
/** The structured blocker details (filters tried + department sets). */
|
|
12042
12353
|
|
|
12043
12354
|
constructor(details, options = {}) {
|
|
@@ -12102,7 +12413,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12102
12413
|
let pages = 0;
|
|
12103
12414
|
for (; ; ) {
|
|
12104
12415
|
if (pages >= PAGE_GUARD) {
|
|
12105
|
-
throw new (0,
|
|
12416
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
12106
12417
|
code: "RESOLUTION_TRUNCATED",
|
|
12107
12418
|
category: "resolution",
|
|
12108
12419
|
operation,
|
|
@@ -12113,11 +12424,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12113
12424
|
const res = await http.request({
|
|
12114
12425
|
method: "POST",
|
|
12115
12426
|
idempotent: true,
|
|
12116
|
-
path: isFirst ? path :
|
|
12427
|
+
path: isFirst ? path : _chunkZJ4ONAQFcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
12117
12428
|
body: { MaxRecords: pageSize, filter },
|
|
12118
12429
|
operation
|
|
12119
12430
|
});
|
|
12120
|
-
const { items: pageItems, pageDetails } =
|
|
12431
|
+
const { items: pageItems, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
|
|
12121
12432
|
items.push(...pageItems);
|
|
12122
12433
|
pages += 1;
|
|
12123
12434
|
if (items.length >= totalCap) break;
|
|
@@ -12234,7 +12545,7 @@ function windowDefaults(params) {
|
|
|
12234
12545
|
var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
|
|
12235
12546
|
var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
|
|
12236
12547
|
function validateCreateParams(params) {
|
|
12237
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
12548
|
+
const pin = (value, label) => typeof value === "number" ? _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
12238
12549
|
const pins = {
|
|
12239
12550
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
12240
12551
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -12243,19 +12554,19 @@ function validateCreateParams(params) {
|
|
|
12243
12554
|
};
|
|
12244
12555
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
12245
12556
|
if (pinCount > 1) {
|
|
12246
|
-
throw new (0,
|
|
12557
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12247
12558
|
"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)",
|
|
12248
12559
|
{ operation: OP3 }
|
|
12249
12560
|
);
|
|
12250
12561
|
}
|
|
12251
12562
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
12252
|
-
throw new (0,
|
|
12563
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12253
12564
|
"createForResource: a pinned roleID is only meaningful with the task/ticket linkage (internallAllocationCodeID pins the internal linkage and owns the code) \u2014 drop one",
|
|
12254
12565
|
{ operation: OP3 }
|
|
12255
12566
|
);
|
|
12256
12567
|
}
|
|
12257
12568
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
12258
|
-
throw new (0,
|
|
12569
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12259
12570
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
12260
12571
|
{ operation: OP3 }
|
|
12261
12572
|
);
|
|
@@ -12338,7 +12649,7 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
|
|
|
12338
12649
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
12339
12650
|
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).");
|
|
12340
12651
|
}
|
|
12341
|
-
return
|
|
12652
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
12342
12653
|
{
|
|
12343
12654
|
operation: OP3,
|
|
12344
12655
|
method: "POST",
|
|
@@ -12378,7 +12689,7 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12378
12689
|
};
|
|
12379
12690
|
} catch (err) {
|
|
12380
12691
|
lastError = err;
|
|
12381
|
-
const text =
|
|
12692
|
+
const text = _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
12382
12693
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
12383
12694
|
if (usedLinkage !== "internal" && gate3) {
|
|
12384
12695
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
@@ -12398,13 +12709,13 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12398
12709
|
throw err;
|
|
12399
12710
|
}
|
|
12400
12711
|
}
|
|
12401
|
-
if (
|
|
12712
|
+
if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, lastError)) {
|
|
12402
12713
|
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.`;
|
|
12403
12714
|
}
|
|
12404
12715
|
throw lastError;
|
|
12405
12716
|
}
|
|
12406
12717
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
12407
|
-
const rid =
|
|
12718
|
+
const rid = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
12408
12719
|
const pins = validateCreateParams(params);
|
|
12409
12720
|
await assertResourceActive(http, rid);
|
|
12410
12721
|
const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
|
|
@@ -12417,8 +12728,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
12417
12728
|
return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
|
|
12418
12729
|
}
|
|
12419
12730
|
function discoveryField(err, body, defaults) {
|
|
12420
|
-
if (!
|
|
12421
|
-
const entries =
|
|
12731
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.vendorError === void 0) return null;
|
|
12732
|
+
const entries = _chunkZJ4ONAQFcjs.parseVendorErrors.call(void 0, err.vendorError);
|
|
12422
12733
|
if (entries === void 0) return null;
|
|
12423
12734
|
for (const entry of entries) {
|
|
12424
12735
|
const field = entry.field;
|
|
@@ -12439,7 +12750,7 @@ async function readTimeEntry(http, id, retries) {
|
|
|
12439
12750
|
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP4, maxRetries: retries });
|
|
12440
12751
|
return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _124 => _124.item]), () => ( null));
|
|
12441
12752
|
} catch (e) {
|
|
12442
|
-
if (
|
|
12753
|
+
if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
12443
12754
|
throw e;
|
|
12444
12755
|
}
|
|
12445
12756
|
}
|
|
@@ -12500,29 +12811,116 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
|
|
|
12500
12811
|
return runMove(http, SPEC2, sourceId, toTicketId, opts);
|
|
12501
12812
|
}
|
|
12502
12813
|
|
|
12814
|
+
// src/resources/special/time_entries/approve.ts
|
|
12815
|
+
var OP5 = "time_entries.approve";
|
|
12816
|
+
var APPROVAL_LEVELS_PATH = "/V1.0/BillingItemApprovalLevels";
|
|
12817
|
+
function toIso(value) {
|
|
12818
|
+
if (value instanceof Date) {
|
|
12819
|
+
if (Number.isNaN(value.getTime())) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("time_entries.approve: approvalDateTime is an invalid Date");
|
|
12820
|
+
return value.toISOString();
|
|
12821
|
+
}
|
|
12822
|
+
const parsed = new Date(value);
|
|
12823
|
+
if (Number.isNaN(parsed.getTime())) throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`time_entries.approve: approvalDateTime "${value}" is not a parseable date`);
|
|
12824
|
+
return parsed.toISOString();
|
|
12825
|
+
}
|
|
12826
|
+
function toNumber(value) {
|
|
12827
|
+
return typeof value === "number" ? value : Number(value);
|
|
12828
|
+
}
|
|
12829
|
+
function sameInstant(a, b) {
|
|
12830
|
+
if (typeof a !== "string" || a === "") return false;
|
|
12831
|
+
const left = new Date(a).getTime();
|
|
12832
|
+
const right = new Date(b).getTime();
|
|
12833
|
+
return !Number.isNaN(left) && left === right;
|
|
12834
|
+
}
|
|
12835
|
+
async function approve(resource, id, opts = {}, http) {
|
|
12836
|
+
const numericId = toNumber(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id"));
|
|
12837
|
+
if (opts.approvalLevel !== void 0 && (!Number.isInteger(opts.approvalLevel) || opts.approvalLevel < 1)) {
|
|
12838
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`time_entries.approve: approvalLevel must be a positive integer (got ${String(opts.approvalLevel)})`);
|
|
12839
|
+
}
|
|
12840
|
+
const approvalLevel = _nullishCoalesce(opts.approvalLevel, () => ( 1));
|
|
12841
|
+
const approvalDateTime = toIso(_nullishCoalesce(opts.approvalDateTime, () => ( /* @__PURE__ */ new Date())));
|
|
12842
|
+
const entry = await resource.get(numericId);
|
|
12843
|
+
const approvalResourceID = opts.approvalResourceID === void 0 ? entry.resourceID : toNumber(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, opts.approvalResourceID, "approvalResourceID"));
|
|
12844
|
+
if (approvalResourceID === void 0) {
|
|
12845
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12846
|
+
`time_entries.approve: time entry ${numericId} carries no resourceID and the caller supplied no approvalResourceID \u2014 the vendor requires an approving resource`
|
|
12847
|
+
);
|
|
12848
|
+
}
|
|
12849
|
+
const body = { timeEntryID: numericId, approvalLevel, approvalResourceID, approvalDateTime };
|
|
12850
|
+
if (opts.dryRun === true) {
|
|
12851
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
12852
|
+
{
|
|
12853
|
+
operation: OP5,
|
|
12854
|
+
method: "POST",
|
|
12855
|
+
path: APPROVAL_LEVELS_PATH,
|
|
12856
|
+
ids: [numericId],
|
|
12857
|
+
checks: [
|
|
12858
|
+
{ name: "input-validation", ok: true },
|
|
12859
|
+
{ name: "time-entry-exists", ok: true }
|
|
12860
|
+
],
|
|
12861
|
+
impact: { affected: 1, scope: "single-record", reversible: false },
|
|
12862
|
+
warnings: [
|
|
12863
|
+
"two calls: POST the BillingItemApprovalLevels record, then PUT the time entry (billingApprovalDateTime + billingApprovalResourceID) \u2014 the vendor sets BillingApprovalLevelMostRecent from the create but not these two fields",
|
|
12864
|
+
"approval is not posting: the API exposes no post action on BillingItems, so the entry stays unposted until a vendor workflow posts it",
|
|
12865
|
+
`approvalResourceID ${approvalResourceID} is not existence-checked by the dry run`
|
|
12866
|
+
],
|
|
12867
|
+
data: body
|
|
12868
|
+
},
|
|
12869
|
+
{ redactPersonalData: http.redactPersonalData }
|
|
12870
|
+
);
|
|
12871
|
+
}
|
|
12872
|
+
const created = await http.request({
|
|
12873
|
+
method: "POST",
|
|
12874
|
+
path: APPROVAL_LEVELS_PATH,
|
|
12875
|
+
body,
|
|
12876
|
+
operation: OP5,
|
|
12877
|
+
maxRetries: opts.maxRetries
|
|
12878
|
+
});
|
|
12879
|
+
const levelId = toNumber(_chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, created, OP5).id, "billingItemApprovalLevelID"));
|
|
12880
|
+
await resource.update(
|
|
12881
|
+
numericId,
|
|
12882
|
+
{ billingApprovalDateTime: approvalDateTime, billingApprovalResourceID: approvalResourceID },
|
|
12883
|
+
{ maxRetries: opts.maxRetries, lastModifiedDate: _nullishCoalesce(opts.lastModifiedDate, () => ( entry.lastModifiedDateTime)) }
|
|
12884
|
+
);
|
|
12885
|
+
const fresh = await resource.get(numericId);
|
|
12886
|
+
const persisted = sameInstant(fresh.billingApprovalDateTime, approvalDateTime) && fresh.billingApprovalResourceID === approvalResourceID;
|
|
12887
|
+
return {
|
|
12888
|
+
timeEntryID: numericId,
|
|
12889
|
+
billingItemApprovalLevelID: levelId,
|
|
12890
|
+
approvalLevel,
|
|
12891
|
+
approvalResourceID,
|
|
12892
|
+
approvalDateTime,
|
|
12893
|
+
billingApprovalLevelMostRecent: _nullishCoalesce(fresh.billingApprovalLevelMostRecent, () => ( null)),
|
|
12894
|
+
billingApprovalDateTime: _nullishCoalesce(fresh.billingApprovalDateTime, () => ( null)),
|
|
12895
|
+
billingApprovalResourceID: _nullishCoalesce(fresh.billingApprovalResourceID, () => ( null)),
|
|
12896
|
+
status: persisted ? "approved" : "approval_fields_not_persisted",
|
|
12897
|
+
persisted
|
|
12898
|
+
};
|
|
12899
|
+
}
|
|
12900
|
+
|
|
12503
12901
|
// src/resources/special/time_entries/recentTickets.ts
|
|
12504
|
-
var
|
|
12902
|
+
var OP6 = "time_entries.recentTickets";
|
|
12505
12903
|
var DAY_MS3 = 864e5;
|
|
12506
12904
|
var TICKET_CHUNK = 100;
|
|
12507
12905
|
var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
12508
12906
|
function positiveId(value, name) {
|
|
12509
12907
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12510
12908
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12511
|
-
throw new (0,
|
|
12909
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP6 });
|
|
12512
12910
|
}
|
|
12513
12911
|
return n;
|
|
12514
12912
|
}
|
|
12515
12913
|
async function recentTickets(_resource, from, to, http, opts) {
|
|
12516
12914
|
if (opts === void 0 || opts === null || typeof opts !== "object") {
|
|
12517
|
-
throw new (0,
|
|
12915
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP6 });
|
|
12518
12916
|
}
|
|
12519
12917
|
const resourceID = positiveId(opts.resourceID, "resourceID");
|
|
12520
12918
|
const companyID = opts.companyID === void 0 ? void 0 : positiveId(opts.companyID, "companyID");
|
|
12521
|
-
if (opts.tz !== void 0) validateZone(opts.tz,
|
|
12522
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
12523
|
-
const toB = customRangeDay(to, "to", void 0,
|
|
12919
|
+
if (opts.tz !== void 0) validateZone(opts.tz, OP6);
|
|
12920
|
+
const fromB = customRangeDay(from, "from", void 0, OP6);
|
|
12921
|
+
const toB = customRangeDay(to, "to", void 0, OP6);
|
|
12524
12922
|
if (fromB.ms > toB.ms) {
|
|
12525
|
-
throw new (0,
|
|
12923
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP6 });
|
|
12526
12924
|
}
|
|
12527
12925
|
const windowToMs = toB.ms + DAY_MS3 - 1;
|
|
12528
12926
|
const { items: entries, hasMore } = await queryTimeEntries(
|
|
@@ -12533,7 +12931,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12533
12931
|
{ field: "resourceID", op: "eq", value: resourceID }
|
|
12534
12932
|
],
|
|
12535
12933
|
clampWindowLimit(opts.limit),
|
|
12536
|
-
|
|
12934
|
+
OP6,
|
|
12537
12935
|
http
|
|
12538
12936
|
);
|
|
12539
12937
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -12559,9 +12957,9 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12559
12957
|
idempotent: true,
|
|
12560
12958
|
path: "/V1.0/Tickets/query",
|
|
12561
12959
|
body: { MaxRecords: TICKET_CHUNK, filter, IncludeFields: TICKET_FIELDS2 },
|
|
12562
|
-
operation:
|
|
12960
|
+
operation: OP6
|
|
12563
12961
|
});
|
|
12564
|
-
for (const t of
|
|
12962
|
+
for (const t of _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, OP6).items) if (typeof t.id === "number") tickets.set(t.id, t);
|
|
12565
12963
|
}
|
|
12566
12964
|
const items = [];
|
|
12567
12965
|
const unresolvedTicketIDs = [];
|
|
@@ -12598,7 +12996,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12598
12996
|
}
|
|
12599
12997
|
|
|
12600
12998
|
// src/resources/time_entries.ts
|
|
12601
|
-
var TimeEntriesResource = class extends
|
|
12999
|
+
var TimeEntriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
12602
13000
|
constructor(http, pageSize) {
|
|
12603
13001
|
super(http, {
|
|
12604
13002
|
key: "time_entries",
|
|
@@ -12665,6 +13063,10 @@ var TimeEntriesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
12665
13063
|
return this.resolveBase(identifier);
|
|
12666
13064
|
}
|
|
12667
13065
|
/** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
|
|
13066
|
+
approve(id, opts = {}) {
|
|
13067
|
+
return approve(this, id, opts, this.http);
|
|
13068
|
+
}
|
|
13069
|
+
/** Node-parity special op (hand-written in src/resources/special/time_entries.ts). */
|
|
12668
13070
|
createForResource(resourceID, params, opts = {}) {
|
|
12669
13071
|
return createForResource(this, resourceID, params, opts, this.http);
|
|
12670
13072
|
}
|
|
@@ -12743,7 +13145,7 @@ var TimeEntriesResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
12743
13145
|
};
|
|
12744
13146
|
|
|
12745
13147
|
// src/resources/time_entry_attachments.ts
|
|
12746
|
-
var TimeEntryAttachmentsResource = class extends
|
|
13148
|
+
var TimeEntryAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
12747
13149
|
constructor(http, pageSize) {
|
|
12748
13150
|
super(http, {
|
|
12749
13151
|
key: "time_entry_attachments",
|
|
@@ -12805,10 +13207,10 @@ var TimeEntryAttachmentsResource = class extends _chunkHQGE4WAVcjs.BaseResource
|
|
|
12805
13207
|
};
|
|
12806
13208
|
|
|
12807
13209
|
// src/resources/special/time_off_requests.ts
|
|
12808
|
-
async function
|
|
12809
|
-
const numericId =
|
|
13210
|
+
async function approve2(_resource, id, opts = {}, http) {
|
|
13211
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
12810
13212
|
if (opts.dryRun === true) {
|
|
12811
|
-
return
|
|
13213
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
12812
13214
|
operation: "time_off_requests.approve",
|
|
12813
13215
|
method: "GET",
|
|
12814
13216
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -12824,16 +13226,16 @@ async function approve(_resource, id, opts = {}, http) {
|
|
|
12824
13226
|
operation: "time_off_requests.approve",
|
|
12825
13227
|
maxRetries: opts.maxRetries
|
|
12826
13228
|
});
|
|
12827
|
-
return
|
|
13229
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
12828
13230
|
}
|
|
12829
13231
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
12830
|
-
const numericId =
|
|
13232
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
12831
13233
|
const text = reason.trim();
|
|
12832
13234
|
if (text === "") {
|
|
12833
|
-
throw new (0,
|
|
13235
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
12834
13236
|
}
|
|
12835
13237
|
if (opts.dryRun === true) {
|
|
12836
|
-
return
|
|
13238
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
12837
13239
|
operation: "time_off_requests.reject",
|
|
12838
13240
|
method: "POST",
|
|
12839
13241
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -12851,11 +13253,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
12851
13253
|
operation: "time_off_requests.reject",
|
|
12852
13254
|
maxRetries: opts.maxRetries
|
|
12853
13255
|
});
|
|
12854
|
-
return
|
|
13256
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
12855
13257
|
}
|
|
12856
13258
|
|
|
12857
13259
|
// src/resources/time_off_requests.ts
|
|
12858
|
-
var TimeOffRequestsResource = class extends
|
|
13260
|
+
var TimeOffRequestsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
12859
13261
|
constructor(http, pageSize) {
|
|
12860
13262
|
super(http, {
|
|
12861
13263
|
key: "time_off_requests",
|
|
@@ -12893,7 +13295,7 @@ var TimeOffRequestsResource = class extends _chunkHQGE4WAVcjs.BaseResource {
|
|
|
12893
13295
|
}
|
|
12894
13296
|
/** Node-parity special op (hand-written in src/resources/special/time_off_requests.ts). */
|
|
12895
13297
|
approve(id, opts = {}) {
|
|
12896
|
-
return
|
|
13298
|
+
return approve2(this, id, opts, this.http);
|
|
12897
13299
|
}
|
|
12898
13300
|
/** Node-parity special op (hand-written in src/resources/special/time_off_requests.ts). */
|
|
12899
13301
|
reject(id, reason, opts = {}) {
|
|
@@ -13091,4 +13493,11 @@ var ZoneInformationResource = class {
|
|
|
13091
13493
|
|
|
13092
13494
|
|
|
13093
13495
|
|
|
13094
|
-
|
|
13496
|
+
|
|
13497
|
+
|
|
13498
|
+
|
|
13499
|
+
|
|
13500
|
+
|
|
13501
|
+
|
|
13502
|
+
|
|
13503
|
+
exports.AppointmentsResource = AppointmentsResource; exports.AuthenticateResource = AuthenticateResource; exports.BillingCodesResource = BillingCodesResource; exports.BillingItemApprovalLevelsResource = BillingItemApprovalLevelsResource; exports.BillingItemsResource = BillingItemsResource; exports.ChangeRequestLinksResource = ChangeRequestLinksResource; exports.ChecklistLibrariesResource = ChecklistLibrariesResource; exports.ChecklistLibraryChecklistItemsResource = ChecklistLibraryChecklistItemsResource; exports.ClassificationIconsResource = ClassificationIconsResource; exports.CompaniesResource = CompaniesResource; exports.CompanyAlertsResource = CompanyAlertsResource; exports.CompanyLocationsResource = CompanyLocationsResource; exports.CompanyNotesResource = CompanyNotesResource; exports.CompanySiteConfigurationsResource = CompanySiteConfigurationsResource; exports.CompanyWebhooksResource = CompanyWebhooksResource; exports.ConfigurationItemBillingProductAssociationsResource = ConfigurationItemBillingProductAssociationsResource; exports.ConfigurationItemCategoriesResource = ConfigurationItemCategoriesResource; exports.ConfigurationItemCategoryUdfAssociationsResource = ConfigurationItemCategoryUdfAssociationsResource; exports.ConfigurationItemDnsRecordsResource = ConfigurationItemDnsRecordsResource; exports.ConfigurationItemNotesResource = ConfigurationItemNotesResource; exports.ConfigurationItemRelatedItemsResource = ConfigurationItemRelatedItemsResource; exports.ConfigurationItemsResource = ConfigurationItemsResource; exports.ConfigurationItemSslSubjectAlternativeNamesResource = ConfigurationItemSslSubjectAlternativeNamesResource; exports.ConfigurationItemTypesResource = ConfigurationItemTypesResource; exports.ConfigurationItemWebhooksResource = ConfigurationItemWebhooksResource; exports.ContactGroupContactsResource = ContactGroupContactsResource; exports.ContactGroupsResource = ContactGroupsResource; exports.ContactsResource = ContactsResource; exports.ContactWebhooksResource = ContactWebhooksResource; exports.ContractBillingRulesResource = ContractBillingRulesResource; exports.ContractBlockHourFactorsResource = ContractBlockHourFactorsResource; exports.ContractBlocksResource = ContractBlocksResource; exports.ContractChargesResource = ContractChargesResource; exports.ContractExclusionBillingCodesResource = ContractExclusionBillingCodesResource; exports.ContractExclusionRolesResource = ContractExclusionRolesResource; exports.ContractExclusionSetExcludedRolesResource = ContractExclusionSetExcludedRolesResource; exports.ContractExclusionSetExcludedWorkTypesResource = ContractExclusionSetExcludedWorkTypesResource; exports.ContractExclusionSetsResource = ContractExclusionSetsResource; exports.ContractMilestonesResource = ContractMilestonesResource; exports.ContractNotesResource = ContractNotesResource; exports.ContractRatesResource = ContractRatesResource; exports.ContractRetainersResource = ContractRetainersResource; exports.ContractRoleCostsResource = ContractRoleCostsResource; exports.ContractServiceAdjustmentsResource = ContractServiceAdjustmentsResource; exports.ContractServiceBundleAdjustmentsResource = ContractServiceBundleAdjustmentsResource; exports.ContractServiceBundlesResource = ContractServiceBundlesResource; exports.ContractServiceBundleUnitsResource = ContractServiceBundleUnitsResource; exports.ContractServicesResource = ContractServicesResource; exports.ContractServiceUnitsResource = ContractServiceUnitsResource; exports.ContractsResource = ContractsResource; exports.ContractTicketPurchasesResource = ContractTicketPurchasesResource; exports.CountriesResource = CountriesResource; exports.CurrenciesResource = CurrenciesResource; exports.DepartmentsResource = DepartmentsResource; exports.DomainRegistrarsResource = DomainRegistrarsResource; exports.EntityInformationResource = EntityInformationResource; exports.ExpenseItemAttachmentsResource = ExpenseItemAttachmentsResource; exports.ExpenseItemsResource = ExpenseItemsResource; exports.ExpenseReportsResource = ExpenseReportsResource; exports.HolidaySetsResource = HolidaySetsResource; exports.HolidaysResource = HolidaysResource; exports.InventoryProductsResource = InventoryProductsResource; exports.InvoicesResource = InvoicesResource; exports.InvoiceTemplatesResource = InvoiceTemplatesResource; exports.ModulesResource = ModulesResource; exports.NotificationHistoryResource = NotificationHistoryResource; exports.OpportunitiesResource = OpportunitiesResource; exports.OpportunityAttachmentsResource = OpportunityAttachmentsResource; exports.OpportunityCategoriesResource = OpportunityCategoriesResource; exports.OrganizationalLevel1sResource = OrganizationalLevel1sResource; exports.OrganizationalLevel2sResource = OrganizationalLevel2sResource; exports.OrganizationalLevelAssociationsResource = OrganizationalLevelAssociationsResource; exports.PhasesResource = PhasesResource; exports.ProductsResource = ProductsResource; exports.ProductVendorsResource = ProductVendorsResource; exports.ProjectChargesResource = ProjectChargesResource; exports.ProjectNotesResource = ProjectNotesResource; exports.ProjectsResource = ProjectsResource; exports.PurchaseApprovalsResource = PurchaseApprovalsResource; exports.PurchaseOrderItemReceivingResource = PurchaseOrderItemReceivingResource; exports.PurchaseOrderItemsResource = PurchaseOrderItemsResource; exports.PurchaseOrdersResource = PurchaseOrdersResource; exports.QuoteItemsResource = QuoteItemsResource; exports.QuoteLocationsResource = QuoteLocationsResource; exports.QuotesResource = QuotesResource; exports.QuoteTemplatesResource = QuoteTemplatesResource; exports.ResourceRoleQueuesResource = ResourceRoleQueuesResource; exports.ResourceRolesResource = ResourceRolesResource; exports.ResourceSkillsResource = ResourceSkillsResource; exports.ResourcesResource = ResourcesResource; exports.ResourceTimeOffAdditionalResource = ResourceTimeOffAdditionalResource; exports.ResourceTimeOffApproversResource = ResourceTimeOffApproversResource; exports.ResourceTimeOffBalancesResource = ResourceTimeOffBalancesResource; exports.RolesResource = RolesResource; exports.SalesOrdersResource = SalesOrdersResource; exports.ServiceCallsResource = ServiceCallsResource; exports.ServiceCallTaskResourcesResource = ServiceCallTaskResourcesResource; exports.ServiceCallTasksResource = ServiceCallTasksResource; exports.ServiceCallTicketResourcesResource = ServiceCallTicketResourcesResource; exports.ServiceCallTicketsResource = ServiceCallTicketsResource; exports.ServiceLevelAgreementResultsResource = ServiceLevelAgreementResultsResource; exports.ServicesResource = ServicesResource; exports.SkillsResource = SkillsResource; exports.SubscriptionPeriodsResource = SubscriptionPeriodsResource; exports.SubscriptionsResource = SubscriptionsResource; exports.SurveyResultsResource = SurveyResultsResource; exports.SurveysResource = SurveysResource; exports.TagAliasesResource = TagAliasesResource; exports.TagGroupsResource = TagGroupsResource; exports.TagsResource = TagsResource; exports.TaskSecondaryResourcesResource = TaskSecondaryResourcesResource; exports.TasksResource = TasksResource; exports.TaxRegionsResource = TaxRegionsResource; exports.ThresholdInformationResource = ThresholdInformationResource; exports.TicketAdditionalConfigurationItemsResource = TicketAdditionalConfigurationItemsResource; exports.TicketAdditionalContactsResource = TicketAdditionalContactsResource; exports.TicketAttachmentsResource = TicketAttachmentsResource; exports.TicketCategoriesResource = TicketCategoriesResource; exports.TicketCategoryFieldDefaultsResource = TicketCategoryFieldDefaultsResource; exports.TicketChangeRequestApprovalsResource = TicketChangeRequestApprovalsResource; exports.TicketChargesResource = TicketChargesResource; exports.TicketChecklistItemsResource = TicketChecklistItemsResource; exports.TicketChecklistLibrariesResource = TicketChecklistLibrariesResource; exports.TicketHistoryResource = TicketHistoryResource; exports.TicketNoteAttachmentsResource = TicketNoteAttachmentsResource; exports.TicketNotesResource = TicketNotesResource; exports.TicketNoteWebhooksResource = TicketNoteWebhooksResource; exports.TicketSecondaryResourcesResource = TicketSecondaryResourcesResource; exports.TicketsResource = TicketsResource; exports.TicketWebhooksResource = TicketWebhooksResource; exports.TimeEntriesResource = TimeEntriesResource; exports.TimeEntryAttachmentsResource = TimeEntryAttachmentsResource; exports.TimeOffRequestsResource = TimeOffRequestsResource; exports.VersionInformationResource = VersionInformationResource; exports.VersionResource = VersionResource; exports.ZoneInformationResource = ZoneInformationResource;
|