node-autotask 0.25.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 +61 -0
- package/MCP_TOOL_CATALOG.json +1063 -30
- package/MCP_TOOL_MANIFEST.md +82 -24
- package/N8N_MCP_MANIFEST.json +39 -8
- package/N8N_MCP_MANIFEST.md +9 -8
- package/README.md +11 -9
- package/capabilities.json +16956 -10596
- package/capabilities.schema.json +125 -0
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-VUGZKP33.js → chunk-42ZUISDH.js} +997 -136
- package/dist/{chunk-WBMRACCV.cjs → chunk-5CC7LGNM.cjs} +16955 -10595
- package/dist/{chunk-Z5L7Q33V.cjs → chunk-5GGCSRT4.cjs} +947 -493
- package/dist/{chunk-EFR2XWRX.js → chunk-F7FVOXPQ.js} +16955 -10595
- package/dist/{chunk-XUB3S6AM.js → chunk-GURC52J7.js} +26 -2
- package/dist/{chunk-FKJ77K6Z.cjs → chunk-UHTZLUDE.cjs} +159 -135
- package/dist/{chunk-6PIJ6AZG.js → chunk-ZGTFVZL5.js} +478 -24
- package/dist/{chunk-2H7YI54B.cjs → chunk-ZJ4ONAQF.cjs} +1084 -223
- package/dist/{index-CZ94y401.d.ts → index-BIWy9m-a.d.ts} +414 -49
- package/dist/{index-C0OwQhon.d.cts → index-D4XYtn4s.d.cts} +414 -49
- package/dist/{index-BVtycq-6.d.cts → index-DQ9NgraW.d.cts} +322 -1
- package/dist/{index-BVtycq-6.d.ts → index-DQ9NgraW.d.ts} +322 -1
- package/dist/index.cjs +46 -24
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +28 -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 +21 -5
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +20 -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 +3 -3
- /package/dist/{chunk-FLB2X6O5.cjs → chunk-IXF7AKOJ.cjs} +0 -0
- /package/dist/{chunk-DMMMWO6A.js → chunk-RMG55JTF.js} +0 -0
- /package/dist/{chunk-IDPB4N2Q.cjs → chunk-SDYRQFGL.cjs} +0 -0
- /package/dist/{chunk-UPQIUWOS.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H
|
|
|
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 _chunk2H7YI54Bcjs.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 _chunk2H7YI
|
|
|
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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H
|
|
|
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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.
|
|
|
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 _chunk2H7YI54B
|
|
|
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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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 _chunk2H7YI54Bcjs.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",
|
|
@@ -6334,8 +6370,52 @@ var CountriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6334
6370
|
}
|
|
6335
6371
|
};
|
|
6336
6372
|
|
|
6373
|
+
// src/resources/currencies.ts
|
|
6374
|
+
var CurrenciesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6375
|
+
constructor(http, pageSize) {
|
|
6376
|
+
super(http, {
|
|
6377
|
+
key: "currencies",
|
|
6378
|
+
resourcePath: "/V1.0/Currencies",
|
|
6379
|
+
deletable: false,
|
|
6380
|
+
udfCapable: false,
|
|
6381
|
+
searchFields: ["name"]
|
|
6382
|
+
}, pageSize);
|
|
6383
|
+
}
|
|
6384
|
+
/** Query Currency records with the G3 filter surface (server-side JSON filter). */
|
|
6385
|
+
query(params) {
|
|
6386
|
+
return this.queryItems(params);
|
|
6387
|
+
}
|
|
6388
|
+
/** Get every Currency record (the MCP-preferred read; 1000-page guarded). */
|
|
6389
|
+
async queryAll(params) {
|
|
6390
|
+
return this.queryAllItems(params);
|
|
6391
|
+
}
|
|
6392
|
+
/** Count matching records (queryCount envelope unwrapped to a plain number). */
|
|
6393
|
+
async count(params) {
|
|
6394
|
+
return this.countGlobal(params);
|
|
6395
|
+
}
|
|
6396
|
+
/** Get one record by id (item envelope; item: null → NotFoundError). */
|
|
6397
|
+
async get(id) {
|
|
6398
|
+
return this.getGlobal(id);
|
|
6399
|
+
}
|
|
6400
|
+
/** Resolve a Currency from a numeric id (or, where the vendor indexes a primary text field,
|
|
6401
|
+
* from an exact match on name). A numeric id miss throws NOT_FOUND; a complete
|
|
6402
|
+
* non-match returns null; ambiguity throws RESOLUTION_AMBIGUOUS (candidate ids) and a
|
|
6403
|
+
* cap-tripped bounded client scan throws RESOLUTION_TRUNCATED (never a silent null).
|
|
6404
|
+
* The compact shape is the structural alias of the full record; `expand: true` is the
|
|
6405
|
+
* type-level escape hatch. */
|
|
6406
|
+
async resolve(identifier, opts = {}) {
|
|
6407
|
+
void opts;
|
|
6408
|
+
return this.resolveBase(identifier);
|
|
6409
|
+
}
|
|
6410
|
+
/** Search Currency records: bounded contains on name (no vendor free-text search exists);
|
|
6411
|
+
* limit defaults to 25, max 500. */
|
|
6412
|
+
async search(query, opts) {
|
|
6413
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _67 => _67.limit]) });
|
|
6414
|
+
}
|
|
6415
|
+
};
|
|
6416
|
+
|
|
6337
6417
|
// src/resources/departments.ts
|
|
6338
|
-
var DepartmentsResource = class extends
|
|
6418
|
+
var DepartmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6339
6419
|
constructor(http, pageSize) {
|
|
6340
6420
|
super(http, {
|
|
6341
6421
|
key: "departments",
|
|
@@ -6397,12 +6477,12 @@ var DepartmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6397
6477
|
/** Search Department records: bounded contains on name (no vendor free-text search exists);
|
|
6398
6478
|
* limit defaults to 25, max 500. */
|
|
6399
6479
|
async search(query, opts) {
|
|
6400
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6480
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _68 => _68.limit]) });
|
|
6401
6481
|
}
|
|
6402
6482
|
};
|
|
6403
6483
|
|
|
6404
6484
|
// src/resources/domain_registrars.ts
|
|
6405
|
-
var DomainRegistrarsResource = class extends
|
|
6485
|
+
var DomainRegistrarsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6406
6486
|
constructor(http, pageSize) {
|
|
6407
6487
|
super(http, {
|
|
6408
6488
|
key: "domain_registrars",
|
|
@@ -6464,7 +6544,7 @@ var DomainRegistrarsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6464
6544
|
/** Search DomainRegistrar records: bounded contains on name (no vendor free-text search exists);
|
|
6465
6545
|
* limit defaults to 25, max 500. */
|
|
6466
6546
|
async search(query, opts) {
|
|
6467
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6547
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _69 => _69.limit]) });
|
|
6468
6548
|
}
|
|
6469
6549
|
};
|
|
6470
6550
|
|
|
@@ -6485,7 +6565,7 @@ var EntityInformationResource = class {
|
|
|
6485
6565
|
};
|
|
6486
6566
|
|
|
6487
6567
|
// src/resources/expense_item_attachments.ts
|
|
6488
|
-
var ExpenseItemAttachmentsResource = class extends
|
|
6568
|
+
var ExpenseItemAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6489
6569
|
constructor(http, pageSize) {
|
|
6490
6570
|
super(http, {
|
|
6491
6571
|
key: "expense_item_attachments",
|
|
@@ -6547,7 +6627,7 @@ var ExpenseItemAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResourc
|
|
|
6547
6627
|
};
|
|
6548
6628
|
|
|
6549
6629
|
// src/resources/expense_items.ts
|
|
6550
|
-
var ExpenseItemsResource = class extends
|
|
6630
|
+
var ExpenseItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6551
6631
|
constructor(http, pageSize) {
|
|
6552
6632
|
super(http, {
|
|
6553
6633
|
key: "expense_items",
|
|
@@ -6606,7 +6686,7 @@ var ExpenseItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6606
6686
|
};
|
|
6607
6687
|
|
|
6608
6688
|
// src/resources/expense_reports.ts
|
|
6609
|
-
var ExpenseReportsResource = class extends
|
|
6689
|
+
var ExpenseReportsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6610
6690
|
constructor(http, pageSize) {
|
|
6611
6691
|
super(http, {
|
|
6612
6692
|
key: "expense_reports",
|
|
@@ -6668,12 +6748,12 @@ var ExpenseReportsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6668
6748
|
/** Search ExpenseReport records: bounded contains on name (no vendor free-text search exists);
|
|
6669
6749
|
* limit defaults to 25, max 500. */
|
|
6670
6750
|
async search(query, opts) {
|
|
6671
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
6751
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _70 => _70.limit]) });
|
|
6672
6752
|
}
|
|
6673
6753
|
};
|
|
6674
6754
|
|
|
6675
6755
|
// src/resources/holiday_sets.ts
|
|
6676
|
-
var HolidaySetsResource = class extends
|
|
6756
|
+
var HolidaySetsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6677
6757
|
constructor(http, pageSize) {
|
|
6678
6758
|
super(http, {
|
|
6679
6759
|
key: "holiday_sets",
|
|
@@ -6742,7 +6822,7 @@ var HolidaySetsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6742
6822
|
};
|
|
6743
6823
|
|
|
6744
6824
|
// src/resources/holidays.ts
|
|
6745
|
-
var HolidaysResource = class extends
|
|
6825
|
+
var HolidaysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6746
6826
|
constructor(http, pageSize) {
|
|
6747
6827
|
super(http, {
|
|
6748
6828
|
key: "holidays",
|
|
@@ -6814,10 +6894,10 @@ var PATH_SUFFIX = {
|
|
|
6814
6894
|
transfer: "StockedItemsTransfer"
|
|
6815
6895
|
};
|
|
6816
6896
|
async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
6817
|
-
const numericParent =
|
|
6897
|
+
const numericParent = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, parentId, "parentId");
|
|
6818
6898
|
const suffix = PATH_SUFFIX[kind];
|
|
6819
6899
|
if (opts.dryRun === true) {
|
|
6820
|
-
return
|
|
6900
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
6821
6901
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6822
6902
|
method: "POST",
|
|
6823
6903
|
path: `/V1.0/InventoryProducts/${numericParent}/${suffix}`,
|
|
@@ -6834,11 +6914,11 @@ async function stockedItems(_resource, kind, parentId, data, opts = {}, http) {
|
|
|
6834
6914
|
operation: `inventory_products.stockedItems${suffix.slice("StockedItems".length)}`,
|
|
6835
6915
|
maxRetries: opts.maxRetries
|
|
6836
6916
|
});
|
|
6837
|
-
return
|
|
6917
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
6838
6918
|
}
|
|
6839
6919
|
|
|
6840
6920
|
// src/resources/inventory_products.ts
|
|
6841
|
-
var InventoryProductsResource = class extends
|
|
6921
|
+
var InventoryProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6842
6922
|
constructor(http, pageSize) {
|
|
6843
6923
|
super(http, {
|
|
6844
6924
|
key: "inventory_products",
|
|
@@ -6920,7 +7000,7 @@ var InventoryProductsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
6920
7000
|
|
|
6921
7001
|
// src/resources/special/invoices.ts
|
|
6922
7002
|
async function markup(_resource, id, format, http) {
|
|
6923
|
-
const numericId =
|
|
7003
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
6924
7004
|
const suffix = format === "html" ? "InvoiceMarkupHtml" : "InvoiceMarkupXml";
|
|
6925
7005
|
const res = await http.request({
|
|
6926
7006
|
method: "GET",
|
|
@@ -6929,7 +7009,7 @@ async function markup(_resource, id, format, http) {
|
|
|
6929
7009
|
});
|
|
6930
7010
|
const body = res;
|
|
6931
7011
|
if (body === null || typeof body !== "object" || typeof body.invoiceMarkup !== "string") {
|
|
6932
|
-
throw new (0,
|
|
7012
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(
|
|
6933
7013
|
`Expected the InvoiceMarkupResultModel envelope { invoiceMarkup: string } for invoice ${numericId}; got a different shape`,
|
|
6934
7014
|
{ code: "INVALID_RESPONSE", category: "server", resourceIds: [numericId], details: { idRefs: [{ entity: "invoice", id: numericId }] } }
|
|
6935
7015
|
);
|
|
@@ -6937,44 +7017,44 @@ async function markup(_resource, id, format, http) {
|
|
|
6937
7017
|
return body.invoiceMarkup;
|
|
6938
7018
|
}
|
|
6939
7019
|
async function pdf(_resource, id, http) {
|
|
6940
|
-
const numericId =
|
|
7020
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
6941
7021
|
const res = await http.request({
|
|
6942
7022
|
method: "GET",
|
|
6943
7023
|
path: `/V1.0/Invoices/${numericId}/InvoicePdf`,
|
|
6944
7024
|
operation: "invoices.pdf"
|
|
6945
7025
|
});
|
|
6946
|
-
return
|
|
7026
|
+
return _chunkZJ4ONAQFcjs.decodeFileData.call(void 0, res);
|
|
6947
7027
|
}
|
|
6948
7028
|
async function windowQuery2(_resource, kind, http, opts) {
|
|
6949
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
6950
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
7029
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _71 => _71.now]), () => ( /* @__PURE__ */ new Date()));
|
|
7030
|
+
const tz = _optionalChain([opts, 'optionalAccess', _72 => _72.tz]) === void 0 ? void 0 : validateZone(opts.tz, `invoices.${kind}`);
|
|
6951
7031
|
return dateWindowQuery(
|
|
6952
7032
|
http,
|
|
6953
7033
|
"/V1.0/Invoices/query",
|
|
6954
7034
|
"invoiceDateTime",
|
|
6955
7035
|
kind,
|
|
6956
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
7036
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _73 => _73.limit])),
|
|
6957
7037
|
`invoices.${kind}`,
|
|
6958
7038
|
now,
|
|
6959
7039
|
tz
|
|
6960
7040
|
);
|
|
6961
7041
|
}
|
|
6962
7042
|
async function customRange2(_resource, from, to, http, opts) {
|
|
6963
|
-
const zone = _optionalChain([opts, 'optionalAccess',
|
|
7043
|
+
const zone = _optionalChain([opts, 'optionalAccess', _74 => _74.tz]) === void 0 ? void 0 : validateZone(opts.tz, "invoices.customRange");
|
|
6964
7044
|
return customRangeQuery(
|
|
6965
7045
|
http,
|
|
6966
7046
|
"/V1.0/Invoices/query",
|
|
6967
7047
|
"invoiceDateTime",
|
|
6968
7048
|
from,
|
|
6969
7049
|
to,
|
|
6970
|
-
clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
7050
|
+
clampWindowLimit(_optionalChain([opts, 'optionalAccess', _75 => _75.limit])),
|
|
6971
7051
|
"invoices.customRange",
|
|
6972
7052
|
zone
|
|
6973
7053
|
);
|
|
6974
7054
|
}
|
|
6975
7055
|
|
|
6976
7056
|
// src/resources/invoices.ts
|
|
6977
|
-
var InvoicesResource = class extends
|
|
7057
|
+
var InvoicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
6978
7058
|
constructor(http, pageSize) {
|
|
6979
7059
|
super(http, {
|
|
6980
7060
|
key: "invoices",
|
|
@@ -7087,6 +7167,34 @@ var InvoicesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7087
7167
|
}
|
|
7088
7168
|
};
|
|
7089
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
|
+
|
|
7090
7198
|
// src/resources/modules.ts
|
|
7091
7199
|
var ModulesResource = class {
|
|
7092
7200
|
|
|
@@ -7104,7 +7212,7 @@ var ModulesResource = class {
|
|
|
7104
7212
|
};
|
|
7105
7213
|
|
|
7106
7214
|
// src/resources/notification_history.ts
|
|
7107
|
-
var NotificationHistoryResource = class extends
|
|
7215
|
+
var NotificationHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7108
7216
|
constructor(http, pageSize) {
|
|
7109
7217
|
super(http, {
|
|
7110
7218
|
key: "notification_history",
|
|
@@ -7143,7 +7251,7 @@ var NotificationHistoryResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7143
7251
|
};
|
|
7144
7252
|
|
|
7145
7253
|
// src/resources/opportunities.ts
|
|
7146
|
-
var OpportunitiesResource = class extends
|
|
7254
|
+
var OpportunitiesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7147
7255
|
constructor(http, pageSize) {
|
|
7148
7256
|
super(http, {
|
|
7149
7257
|
key: "opportunities",
|
|
@@ -7205,7 +7313,7 @@ var OpportunitiesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7205
7313
|
};
|
|
7206
7314
|
|
|
7207
7315
|
// src/resources/opportunity_attachments.ts
|
|
7208
|
-
var OpportunityAttachmentsResource = class extends
|
|
7316
|
+
var OpportunityAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7209
7317
|
constructor(http, pageSize) {
|
|
7210
7318
|
super(http, {
|
|
7211
7319
|
key: "opportunity_attachments",
|
|
@@ -7267,7 +7375,7 @@ var OpportunityAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResourc
|
|
|
7267
7375
|
};
|
|
7268
7376
|
|
|
7269
7377
|
// src/resources/opportunity_categories.ts
|
|
7270
|
-
var OpportunityCategoriesResource = class extends
|
|
7378
|
+
var OpportunityCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7271
7379
|
constructor(http, pageSize) {
|
|
7272
7380
|
super(http, {
|
|
7273
7381
|
key: "opportunity_categories",
|
|
@@ -7321,12 +7429,165 @@ var OpportunityCategoriesResource = class extends _chunk2H7YI54Bcjs.BaseResource
|
|
|
7321
7429
|
/** Search OpportunityCategory records: bounded contains on name (no vendor free-text search exists);
|
|
7322
7430
|
* limit defaults to 25, max 500. */
|
|
7323
7431
|
async search(query, opts) {
|
|
7324
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7432
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _76 => _76.limit]) });
|
|
7433
|
+
}
|
|
7434
|
+
};
|
|
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);
|
|
7325
7586
|
}
|
|
7326
7587
|
};
|
|
7327
7588
|
|
|
7328
7589
|
// src/resources/phases.ts
|
|
7329
|
-
var PhasesResource = class extends
|
|
7590
|
+
var PhasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7330
7591
|
constructor(http, pageSize) {
|
|
7331
7592
|
super(http, {
|
|
7332
7593
|
key: "phases",
|
|
@@ -7385,7 +7646,7 @@ var PhasesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7385
7646
|
};
|
|
7386
7647
|
|
|
7387
7648
|
// src/resources/products.ts
|
|
7388
|
-
var ProductsResource = class extends
|
|
7649
|
+
var ProductsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7389
7650
|
constructor(http, pageSize) {
|
|
7390
7651
|
super(http, {
|
|
7391
7652
|
key: "products",
|
|
@@ -7447,12 +7708,12 @@ var ProductsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7447
7708
|
/** Search Product records: bounded contains on name (no vendor free-text search exists);
|
|
7448
7709
|
* limit defaults to 25, max 500. */
|
|
7449
7710
|
async search(query, opts) {
|
|
7450
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7711
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _77 => _77.limit]) });
|
|
7451
7712
|
}
|
|
7452
7713
|
};
|
|
7453
7714
|
|
|
7454
7715
|
// src/resources/product_vendors.ts
|
|
7455
|
-
var ProductVendorsResource = class extends
|
|
7716
|
+
var ProductVendorsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7456
7717
|
constructor(http, pageSize) {
|
|
7457
7718
|
super(http, {
|
|
7458
7719
|
key: "product_vendors",
|
|
@@ -7511,7 +7772,7 @@ var ProductVendorsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7511
7772
|
};
|
|
7512
7773
|
|
|
7513
7774
|
// src/resources/project_charges.ts
|
|
7514
|
-
var ProjectChargesResource = class extends
|
|
7775
|
+
var ProjectChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7515
7776
|
constructor(http, pageSize) {
|
|
7516
7777
|
super(http, {
|
|
7517
7778
|
key: "project_charges",
|
|
@@ -7577,12 +7838,12 @@ var ProjectChargesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7577
7838
|
/** Search ProjectCharge records: bounded contains on name (no vendor free-text search exists);
|
|
7578
7839
|
* limit defaults to 25, max 500. */
|
|
7579
7840
|
async search(query, opts) {
|
|
7580
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7841
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _78 => _78.limit]) });
|
|
7581
7842
|
}
|
|
7582
7843
|
};
|
|
7583
7844
|
|
|
7584
7845
|
// src/resources/project_notes.ts
|
|
7585
|
-
var ProjectNotesResource = class extends
|
|
7846
|
+
var ProjectNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7586
7847
|
constructor(http, pageSize) {
|
|
7587
7848
|
super(http, {
|
|
7588
7849
|
key: "project_notes",
|
|
@@ -7641,7 +7902,7 @@ var ProjectNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7641
7902
|
};
|
|
7642
7903
|
|
|
7643
7904
|
// src/resources/projects.ts
|
|
7644
|
-
var ProjectsResource = class extends
|
|
7905
|
+
var ProjectsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7645
7906
|
constructor(http, pageSize) {
|
|
7646
7907
|
super(http, {
|
|
7647
7908
|
key: "projects",
|
|
@@ -7703,7 +7964,7 @@ var ProjectsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7703
7964
|
/** Search Project records: bounded contains on projectName (no vendor free-text search exists);
|
|
7704
7965
|
* limit defaults to 25, max 500. */
|
|
7705
7966
|
async search(query, opts) {
|
|
7706
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
7967
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _79 => _79.limit]) });
|
|
7707
7968
|
}
|
|
7708
7969
|
/** Get the Project with its primary context records in one call (each part a single-record
|
|
7709
7970
|
* fetch; no sub-lists; absent/dangling references come back null). `names: true` (issue #77)
|
|
@@ -7718,13 +7979,13 @@ var ProjectsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7718
7979
|
const leadResource = await this.contextFetch("/V1.0/Resources", root["projectLeadResourceID"]);
|
|
7719
7980
|
const result = { project: project2, company, opportunity, leadResource };
|
|
7720
7981
|
if (opts.names === true) {
|
|
7721
|
-
const builder =
|
|
7982
|
+
const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, );
|
|
7722
7983
|
builder.addResource(root["creatorResourceID"]);
|
|
7723
7984
|
builder.addFk("contract", root["contractID"]);
|
|
7724
|
-
const names = await
|
|
7985
|
+
const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
7725
7986
|
const row = { ...project2 };
|
|
7726
|
-
|
|
7727
|
-
|
|
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));
|
|
7728
7989
|
result.project = row;
|
|
7729
7990
|
result.names = names.section;
|
|
7730
7991
|
}
|
|
@@ -7733,7 +7994,7 @@ var ProjectsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7733
7994
|
};
|
|
7734
7995
|
|
|
7735
7996
|
// src/resources/purchase_approvals.ts
|
|
7736
|
-
var PurchaseApprovalsResource = class extends
|
|
7997
|
+
var PurchaseApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7737
7998
|
constructor(http, pageSize) {
|
|
7738
7999
|
super(http, {
|
|
7739
8000
|
key: "purchase_approvals",
|
|
@@ -7787,7 +8048,7 @@ var PurchaseApprovalsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7787
8048
|
};
|
|
7788
8049
|
|
|
7789
8050
|
// src/resources/purchase_order_item_receiving.ts
|
|
7790
|
-
var PurchaseOrderItemReceivingResource = class extends
|
|
8051
|
+
var PurchaseOrderItemReceivingResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7791
8052
|
constructor(http, pageSize) {
|
|
7792
8053
|
super(http, {
|
|
7793
8054
|
key: "purchase_order_item_receiving",
|
|
@@ -7837,7 +8098,7 @@ var PurchaseOrderItemReceivingResource = class extends _chunk2H7YI54Bcjs.BaseRes
|
|
|
7837
8098
|
};
|
|
7838
8099
|
|
|
7839
8100
|
// src/resources/purchase_order_items.ts
|
|
7840
|
-
var PurchaseOrderItemsResource = class extends
|
|
8101
|
+
var PurchaseOrderItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7841
8102
|
constructor(http, pageSize) {
|
|
7842
8103
|
super(http, {
|
|
7843
8104
|
key: "purchase_order_items",
|
|
@@ -7896,7 +8157,7 @@ var PurchaseOrderItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7896
8157
|
};
|
|
7897
8158
|
|
|
7898
8159
|
// src/resources/purchase_orders.ts
|
|
7899
|
-
var PurchaseOrdersResource = class extends
|
|
8160
|
+
var PurchaseOrdersResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7900
8161
|
constructor(http, pageSize) {
|
|
7901
8162
|
super(http, {
|
|
7902
8163
|
key: "purchase_orders",
|
|
@@ -7958,7 +8219,7 @@ var PurchaseOrdersResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
7958
8219
|
};
|
|
7959
8220
|
|
|
7960
8221
|
// src/resources/quote_items.ts
|
|
7961
|
-
var QuoteItemsResource = class extends
|
|
8222
|
+
var QuoteItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
7962
8223
|
constructor(http, pageSize) {
|
|
7963
8224
|
super(http, {
|
|
7964
8225
|
key: "quote_items",
|
|
@@ -8024,12 +8285,12 @@ var QuoteItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8024
8285
|
/** Search QuoteItem records: bounded contains on name (no vendor free-text search exists);
|
|
8025
8286
|
* limit defaults to 25, max 500. */
|
|
8026
8287
|
async search(query, opts) {
|
|
8027
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8288
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _80 => _80.limit]) });
|
|
8028
8289
|
}
|
|
8029
8290
|
};
|
|
8030
8291
|
|
|
8031
8292
|
// src/resources/quote_locations.ts
|
|
8032
|
-
var QuoteLocationsResource = class extends
|
|
8293
|
+
var QuoteLocationsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8033
8294
|
constructor(http, pageSize) {
|
|
8034
8295
|
super(http, {
|
|
8035
8296
|
key: "quote_locations",
|
|
@@ -8094,7 +8355,7 @@ var QuoteLocationsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8094
8355
|
};
|
|
8095
8356
|
|
|
8096
8357
|
// src/resources/quotes.ts
|
|
8097
|
-
var QuotesResource = class extends
|
|
8358
|
+
var QuotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8098
8359
|
constructor(http, pageSize) {
|
|
8099
8360
|
super(http, {
|
|
8100
8361
|
key: "quotes",
|
|
@@ -8156,12 +8417,12 @@ var QuotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8156
8417
|
/** Search Quote records: bounded contains on name (no vendor free-text search exists);
|
|
8157
8418
|
* limit defaults to 25, max 500. */
|
|
8158
8419
|
async search(query, opts) {
|
|
8159
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8420
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _81 => _81.limit]) });
|
|
8160
8421
|
}
|
|
8161
8422
|
};
|
|
8162
8423
|
|
|
8163
8424
|
// src/resources/quote_templates.ts
|
|
8164
|
-
var QuoteTemplatesResource = class extends
|
|
8425
|
+
var QuoteTemplatesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8165
8426
|
constructor(http, pageSize) {
|
|
8166
8427
|
super(http, {
|
|
8167
8428
|
key: "quote_templates",
|
|
@@ -8200,12 +8461,12 @@ var QuoteTemplatesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8200
8461
|
/** Search QuoteTemplate records: bounded contains on name (no vendor free-text search exists);
|
|
8201
8462
|
* limit defaults to 25, max 500. */
|
|
8202
8463
|
async search(query, opts) {
|
|
8203
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8464
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _82 => _82.limit]) });
|
|
8204
8465
|
}
|
|
8205
8466
|
};
|
|
8206
8467
|
|
|
8207
8468
|
// src/resources/resource_role_queues.ts
|
|
8208
|
-
var ResourceRoleQueuesResource = class extends
|
|
8469
|
+
var ResourceRoleQueuesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8209
8470
|
constructor(http, pageSize) {
|
|
8210
8471
|
super(http, {
|
|
8211
8472
|
key: "resource_role_queues",
|
|
@@ -8264,7 +8525,7 @@ var ResourceRoleQueuesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8264
8525
|
};
|
|
8265
8526
|
|
|
8266
8527
|
// src/resources/resource_roles.ts
|
|
8267
|
-
var ResourceRolesResource = class extends
|
|
8528
|
+
var ResourceRolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8268
8529
|
constructor(http, pageSize) {
|
|
8269
8530
|
super(http, {
|
|
8270
8531
|
key: "resource_roles",
|
|
@@ -8306,7 +8567,7 @@ var ResourceRolesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8306
8567
|
};
|
|
8307
8568
|
|
|
8308
8569
|
// src/resources/resource_skills.ts
|
|
8309
|
-
var ResourceSkillsResource = class extends
|
|
8570
|
+
var ResourceSkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8310
8571
|
constructor(http, pageSize) {
|
|
8311
8572
|
super(http, {
|
|
8312
8573
|
key: "resource_skills",
|
|
@@ -8360,16 +8621,16 @@ var ResourceSkillsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8360
8621
|
var MAX_TRANSFER_IDS = 500;
|
|
8361
8622
|
function requirePositiveIds(ids2, label) {
|
|
8362
8623
|
if (!Array.isArray(ids2) || ids2.length === 0) {
|
|
8363
|
-
throw new (0,
|
|
8624
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: at least one positive integer id is required`);
|
|
8364
8625
|
}
|
|
8365
8626
|
if (ids2.length > MAX_TRANSFER_IDS) {
|
|
8366
|
-
throw new (0,
|
|
8627
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: at most ${MAX_TRANSFER_IDS} ids are accepted (bounded fan-out)`);
|
|
8367
8628
|
}
|
|
8368
8629
|
const out = [];
|
|
8369
8630
|
for (const raw of ids2) {
|
|
8370
|
-
const id =
|
|
8631
|
+
const id = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, raw, `${label} id`);
|
|
8371
8632
|
if (typeof id === "number" && id < 1) {
|
|
8372
|
-
throw new (0,
|
|
8633
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${label}: every id must be a positive integer (got ${String(raw)})`);
|
|
8373
8634
|
}
|
|
8374
8635
|
out.push(id);
|
|
8375
8636
|
}
|
|
@@ -8377,7 +8638,7 @@ function requirePositiveIds(ids2, label) {
|
|
|
8377
8638
|
}
|
|
8378
8639
|
async function whoAmI(_resource, userName, http) {
|
|
8379
8640
|
const user = userName.trim();
|
|
8380
|
-
if (user === "") throw new (0,
|
|
8641
|
+
if (user === "") throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("whoAmI: the configured UserName is empty");
|
|
8381
8642
|
const value = user.includes("@") ? _nullishCoalesce(user.split("@")[0], () => ( "")) : user;
|
|
8382
8643
|
const res = await http.request({
|
|
8383
8644
|
method: "POST",
|
|
@@ -8386,11 +8647,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8386
8647
|
body: { MaxRecords: 2, filter: [{ field: "userName", op: "eq", value }] },
|
|
8387
8648
|
operation: "resources.whoAmI"
|
|
8388
8649
|
});
|
|
8389
|
-
const matches =
|
|
8650
|
+
const matches = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
8390
8651
|
if (matches.length === 0) return null;
|
|
8391
8652
|
if (matches.length > 1) {
|
|
8392
8653
|
const ids2 = matches.map((m) => m.id).filter((id) => typeof id === "number");
|
|
8393
|
-
throw new (0,
|
|
8654
|
+
throw new (0, _chunkZJ4ONAQFcjs.ResolutionError)(
|
|
8394
8655
|
`whoAmI: "${value}" is ambiguous (matched ${matches.length} resources)`,
|
|
8395
8656
|
{ code: "RESOLUTION_AMBIGUOUS", resourceIds: ids2, details: { idRefs: ids2.map((cid) => ({ entity: "resource", id: cid })) } }
|
|
8396
8657
|
);
|
|
@@ -8399,11 +8660,11 @@ async function whoAmI(_resource, userName, http) {
|
|
|
8399
8660
|
}
|
|
8400
8661
|
async function transferOwnership(_resource, companyIds, destinationResourceId, http, opts) {
|
|
8401
8662
|
const ids2 = requirePositiveIds(companyIds, "transferOwnership");
|
|
8402
|
-
const destination =
|
|
8663
|
+
const destination = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, destinationResourceId, "destinationResourceId");
|
|
8403
8664
|
if (typeof destination === "number" && destination < 1) {
|
|
8404
|
-
throw new (0,
|
|
8665
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("transferOwnership: destinationResourceId must be a positive integer");
|
|
8405
8666
|
}
|
|
8406
|
-
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
8667
|
+
const dryRun = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _83 => _83.dryRun]), () => ( true));
|
|
8407
8668
|
const changes = [];
|
|
8408
8669
|
const applied = [];
|
|
8409
8670
|
for (const id of ids2) {
|
|
@@ -8412,9 +8673,9 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8412
8673
|
method: "GET",
|
|
8413
8674
|
path: `/V1.0/Companies/${id}`,
|
|
8414
8675
|
operation: "resources.transferOwnership",
|
|
8415
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8676
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _84 => _84.maxRetries])
|
|
8416
8677
|
});
|
|
8417
|
-
const company =
|
|
8678
|
+
const company = _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, id, void 0, "company");
|
|
8418
8679
|
const current = typeof company.ownerResourceID === "number" ? company.ownerResourceID : null;
|
|
8419
8680
|
changes.push({ id, fromOwnerResourceID: current, toOwnerResourceID: destination });
|
|
8420
8681
|
if (!dryRun) {
|
|
@@ -8423,15 +8684,15 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8423
8684
|
path: "/V1.0/Companies",
|
|
8424
8685
|
body: { id, ownerResourceID: destination },
|
|
8425
8686
|
operation: "resources.transferOwnership",
|
|
8426
|
-
maxRetries: _optionalChain([opts, 'optionalAccess',
|
|
8687
|
+
maxRetries: _optionalChain([opts, 'optionalAccess', _85 => _85.maxRetries])
|
|
8427
8688
|
});
|
|
8428
|
-
|
|
8689
|
+
_chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, update);
|
|
8429
8690
|
applied.push(id);
|
|
8430
8691
|
}
|
|
8431
8692
|
} catch (err) {
|
|
8432
|
-
if (!dryRun && err instanceof
|
|
8693
|
+
if (!dryRun && err instanceof _chunkZJ4ONAQFcjs.AutotaskError) {
|
|
8433
8694
|
err.resourceIds = [id];
|
|
8434
|
-
err.details =
|
|
8695
|
+
err.details = _chunkZJ4ONAQFcjs.mergeDetails.call(void 0, err.details, { idRefs: [{ entity: "company", id }] });
|
|
8435
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).`;
|
|
8436
8697
|
}
|
|
8437
8698
|
throw err;
|
|
@@ -8440,7 +8701,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8440
8701
|
if (dryRun) {
|
|
8441
8702
|
const anyChange = changes.some((c) => c.fromOwnerResourceID !== c.toOwnerResourceID);
|
|
8442
8703
|
return {
|
|
8443
|
-
...
|
|
8704
|
+
..._chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
8444
8705
|
operation: "resources.transferOwnership",
|
|
8445
8706
|
method: "PUT",
|
|
8446
8707
|
path: "/V1.0/Companies",
|
|
@@ -8464,7 +8725,7 @@ async function transferOwnership(_resource, companyIds, destinationResourceId, h
|
|
|
8464
8725
|
}
|
|
8465
8726
|
|
|
8466
8727
|
// src/resources/resources.ts
|
|
8467
|
-
var ResourcesResource = class extends
|
|
8728
|
+
var ResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8468
8729
|
|
|
8469
8730
|
constructor(http, clientConfig, pageSize) {
|
|
8470
8731
|
super(http, {
|
|
@@ -8523,7 +8784,7 @@ var ResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8523
8784
|
/** Search Resource records: bounded contains on firstName + lastName (no vendor free-text search exists);
|
|
8524
8785
|
* limit defaults to 25, max 500. */
|
|
8525
8786
|
async search(query, opts) {
|
|
8526
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
8787
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _86 => _86.limit]) });
|
|
8527
8788
|
}
|
|
8528
8789
|
/** Node-parity special op (hand-written in src/resources/special/resources.ts). */
|
|
8529
8790
|
transferOwnership(sourceResourceIds, destinationResourceId, opts = {}) {
|
|
@@ -8537,7 +8798,7 @@ var ResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8537
8798
|
|
|
8538
8799
|
// src/resources/special/resource_time_off_additional.ts
|
|
8539
8800
|
async function getByResource(_resource, resourceId, http) {
|
|
8540
|
-
const numericResource =
|
|
8801
|
+
const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8541
8802
|
const res = await http.request({
|
|
8542
8803
|
method: "GET",
|
|
8543
8804
|
path: `/V1.0/Resources/${numericResource}/TimeOffAdditional`,
|
|
@@ -8551,11 +8812,11 @@ async function getByResource(_resource, resourceId, http) {
|
|
|
8551
8812
|
if (typeof item === "object" && !Array.isArray(item)) return [item];
|
|
8552
8813
|
}
|
|
8553
8814
|
}
|
|
8554
|
-
return
|
|
8815
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "resource_time_off_additional.getByResource").items;
|
|
8555
8816
|
}
|
|
8556
8817
|
|
|
8557
8818
|
// src/resources/resource_time_off_additional.ts
|
|
8558
|
-
var ResourceTimeOffAdditionalResource = class extends
|
|
8819
|
+
var ResourceTimeOffAdditionalResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8559
8820
|
constructor(http, pageSize) {
|
|
8560
8821
|
super(http, {
|
|
8561
8822
|
key: "resource_time_off_additional",
|
|
@@ -8594,7 +8855,7 @@ var ResourceTimeOffAdditionalResource = class extends _chunk2H7YI54Bcjs.BaseReso
|
|
|
8594
8855
|
};
|
|
8595
8856
|
|
|
8596
8857
|
// src/resources/resource_time_off_approvers.ts
|
|
8597
|
-
var ResourceTimeOffApproversResource = class extends
|
|
8858
|
+
var ResourceTimeOffApproversResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8598
8859
|
constructor(http, pageSize) {
|
|
8599
8860
|
super(http, {
|
|
8600
8861
|
key: "resource_time_off_approvers",
|
|
@@ -8637,29 +8898,29 @@ var ResourceTimeOffApproversResource = class extends _chunk2H7YI54Bcjs.BaseResou
|
|
|
8637
8898
|
|
|
8638
8899
|
// src/resources/special/resource_time_off_balances.ts
|
|
8639
8900
|
async function getByResource2(_resource, resourceId, http) {
|
|
8640
|
-
const numericResource =
|
|
8901
|
+
const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8641
8902
|
const res = await http.request({
|
|
8642
8903
|
method: "GET",
|
|
8643
8904
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances`,
|
|
8644
8905
|
operation: "resource_time_off_balances.getByResource"
|
|
8645
8906
|
});
|
|
8646
|
-
return
|
|
8907
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, "resource_time_off_balances.getByResource").items;
|
|
8647
8908
|
}
|
|
8648
8909
|
async function getByYear(_resource, resourceId, year, http) {
|
|
8649
|
-
const numericResource =
|
|
8910
|
+
const numericResource = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceId, "resourceId");
|
|
8650
8911
|
if (!Number.isSafeInteger(year) || year < 1) {
|
|
8651
|
-
throw new (0,
|
|
8912
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("getByYear: year must be a positive integer");
|
|
8652
8913
|
}
|
|
8653
8914
|
const res = await http.request({
|
|
8654
8915
|
method: "GET",
|
|
8655
8916
|
path: `/V1.0/Resources/${numericResource}/TimeOffBalances/${year}`,
|
|
8656
8917
|
operation: "resource_time_off_balances.getByYear"
|
|
8657
8918
|
});
|
|
8658
|
-
return
|
|
8919
|
+
return _chunkZJ4ONAQFcjs.unwrapItem.call(void 0, res, year, "resource_time_off_balances.getByYear", "resource_time_off_balance");
|
|
8659
8920
|
}
|
|
8660
8921
|
|
|
8661
8922
|
// src/resources/resource_time_off_balances.ts
|
|
8662
|
-
var ResourceTimeOffBalancesResource = class extends
|
|
8923
|
+
var ResourceTimeOffBalancesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8663
8924
|
constructor(http, pageSize) {
|
|
8664
8925
|
super(http, {
|
|
8665
8926
|
key: "resource_time_off_balances",
|
|
@@ -8697,7 +8958,7 @@ var ResourceTimeOffBalancesResource = class extends _chunk2H7YI54Bcjs.BaseResour
|
|
|
8697
8958
|
};
|
|
8698
8959
|
|
|
8699
8960
|
// src/resources/roles.ts
|
|
8700
|
-
var RolesResource = class extends
|
|
8961
|
+
var RolesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8701
8962
|
constructor(http, pageSize) {
|
|
8702
8963
|
super(http, {
|
|
8703
8964
|
key: "roles",
|
|
@@ -8759,12 +9020,55 @@ var RolesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8759
9020
|
/** Search Role records: bounded contains on name (no vendor free-text search exists);
|
|
8760
9021
|
* limit defaults to 25, max 500. */
|
|
8761
9022
|
async search(query, opts) {
|
|
8762
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9023
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _87 => _87.limit]) });
|
|
9024
|
+
}
|
|
9025
|
+
};
|
|
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);
|
|
8763
9067
|
}
|
|
8764
9068
|
};
|
|
8765
9069
|
|
|
8766
9070
|
// src/resources/service_calls.ts
|
|
8767
|
-
var ServiceCallsResource = class extends
|
|
9071
|
+
var ServiceCallsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8768
9072
|
constructor(http, pageSize) {
|
|
8769
9073
|
super(http, {
|
|
8770
9074
|
key: "service_calls",
|
|
@@ -8833,7 +9137,7 @@ var ServiceCallsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8833
9137
|
};
|
|
8834
9138
|
|
|
8835
9139
|
// src/resources/service_call_task_resources.ts
|
|
8836
|
-
var ServiceCallTaskResourcesResource = class extends
|
|
9140
|
+
var ServiceCallTaskResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8837
9141
|
constructor(http, pageSize) {
|
|
8838
9142
|
super(http, {
|
|
8839
9143
|
key: "service_call_task_resources",
|
|
@@ -8890,7 +9194,7 @@ var ServiceCallTaskResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResou
|
|
|
8890
9194
|
};
|
|
8891
9195
|
|
|
8892
9196
|
// src/resources/service_call_tasks.ts
|
|
8893
|
-
var ServiceCallTasksResource = class extends
|
|
9197
|
+
var ServiceCallTasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8894
9198
|
constructor(http, pageSize) {
|
|
8895
9199
|
super(http, {
|
|
8896
9200
|
key: "service_call_tasks",
|
|
@@ -8947,7 +9251,7 @@ var ServiceCallTasksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
8947
9251
|
};
|
|
8948
9252
|
|
|
8949
9253
|
// src/resources/service_call_ticket_resources.ts
|
|
8950
|
-
var ServiceCallTicketResourcesResource = class extends
|
|
9254
|
+
var ServiceCallTicketResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
8951
9255
|
constructor(http, pageSize) {
|
|
8952
9256
|
super(http, {
|
|
8953
9257
|
key: "service_call_ticket_resources",
|
|
@@ -9004,7 +9308,7 @@ var ServiceCallTicketResourcesResource = class extends _chunk2H7YI54Bcjs.BaseRes
|
|
|
9004
9308
|
};
|
|
9005
9309
|
|
|
9006
9310
|
// src/resources/service_call_tickets.ts
|
|
9007
|
-
var ServiceCallTicketsResource = class extends
|
|
9311
|
+
var ServiceCallTicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9008
9312
|
constructor(http, pageSize) {
|
|
9009
9313
|
super(http, {
|
|
9010
9314
|
key: "service_call_tickets",
|
|
@@ -9061,7 +9365,7 @@ var ServiceCallTicketsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9061
9365
|
};
|
|
9062
9366
|
|
|
9063
9367
|
// src/resources/service_level_agreement_results.ts
|
|
9064
|
-
var ServiceLevelAgreementResultsResource = class extends
|
|
9368
|
+
var ServiceLevelAgreementResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9065
9369
|
constructor(http, pageSize) {
|
|
9066
9370
|
super(http, {
|
|
9067
9371
|
key: "service_level_agreement_results",
|
|
@@ -9100,7 +9404,7 @@ var ServiceLevelAgreementResultsResource = class extends _chunk2H7YI54Bcjs.BaseR
|
|
|
9100
9404
|
};
|
|
9101
9405
|
|
|
9102
9406
|
// src/resources/services.ts
|
|
9103
|
-
var ServicesResource = class extends
|
|
9407
|
+
var ServicesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9104
9408
|
constructor(http, pageSize) {
|
|
9105
9409
|
super(http, {
|
|
9106
9410
|
key: "services",
|
|
@@ -9163,12 +9467,12 @@ var ServicesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9163
9467
|
/** Search Service records: bounded contains on name (no vendor free-text search exists);
|
|
9164
9468
|
* limit defaults to 25, max 500. */
|
|
9165
9469
|
async search(query, opts) {
|
|
9166
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9470
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _88 => _88.limit]) });
|
|
9167
9471
|
}
|
|
9168
9472
|
};
|
|
9169
9473
|
|
|
9170
9474
|
// src/resources/skills.ts
|
|
9171
|
-
var SkillsResource = class extends
|
|
9475
|
+
var SkillsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9172
9476
|
constructor(http, pageSize) {
|
|
9173
9477
|
super(http, {
|
|
9174
9478
|
key: "skills",
|
|
@@ -9207,12 +9511,12 @@ var SkillsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9207
9511
|
/** Search Skill records: bounded contains on name (no vendor free-text search exists);
|
|
9208
9512
|
* limit defaults to 25, max 500. */
|
|
9209
9513
|
async search(query, opts) {
|
|
9210
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9514
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _89 => _89.limit]) });
|
|
9211
9515
|
}
|
|
9212
9516
|
};
|
|
9213
9517
|
|
|
9214
9518
|
// src/resources/subscription_periods.ts
|
|
9215
|
-
var SubscriptionPeriodsResource = class extends
|
|
9519
|
+
var SubscriptionPeriodsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9216
9520
|
constructor(http, pageSize) {
|
|
9217
9521
|
super(http, {
|
|
9218
9522
|
key: "subscription_periods",
|
|
@@ -9251,7 +9555,7 @@ var SubscriptionPeriodsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9251
9555
|
};
|
|
9252
9556
|
|
|
9253
9557
|
// src/resources/subscriptions.ts
|
|
9254
|
-
var SubscriptionsResource = class extends
|
|
9558
|
+
var SubscriptionsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9255
9559
|
constructor(http, pageSize) {
|
|
9256
9560
|
super(http, {
|
|
9257
9561
|
key: "subscriptions",
|
|
@@ -9320,7 +9624,7 @@ var SubscriptionsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9320
9624
|
};
|
|
9321
9625
|
|
|
9322
9626
|
// src/resources/survey_results.ts
|
|
9323
|
-
var SurveyResultsResource = class extends
|
|
9627
|
+
var SurveyResultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9324
9628
|
constructor(http, pageSize) {
|
|
9325
9629
|
super(http, {
|
|
9326
9630
|
key: "survey_results",
|
|
@@ -9359,7 +9663,7 @@ var SurveyResultsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9359
9663
|
};
|
|
9360
9664
|
|
|
9361
9665
|
// src/resources/surveys.ts
|
|
9362
|
-
var SurveysResource = class extends
|
|
9666
|
+
var SurveysResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9363
9667
|
constructor(http, pageSize) {
|
|
9364
9668
|
super(http, {
|
|
9365
9669
|
key: "surveys",
|
|
@@ -9398,12 +9702,12 @@ var SurveysResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9398
9702
|
/** Search Survey records: bounded contains on name (no vendor free-text search exists);
|
|
9399
9703
|
* limit defaults to 25, max 500. */
|
|
9400
9704
|
async search(query, opts) {
|
|
9401
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
9705
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _90 => _90.limit]) });
|
|
9402
9706
|
}
|
|
9403
9707
|
};
|
|
9404
9708
|
|
|
9405
9709
|
// src/resources/tag_aliases.ts
|
|
9406
|
-
var TagAliasesResource = class extends
|
|
9710
|
+
var TagAliasesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9407
9711
|
constructor(http, pageSize) {
|
|
9408
9712
|
super(http, {
|
|
9409
9713
|
key: "tag_aliases",
|
|
@@ -9460,7 +9764,7 @@ var TagAliasesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9460
9764
|
};
|
|
9461
9765
|
|
|
9462
9766
|
// src/resources/tag_groups.ts
|
|
9463
|
-
var TagGroupsResource = class extends
|
|
9767
|
+
var TagGroupsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9464
9768
|
constructor(http, pageSize) {
|
|
9465
9769
|
super(http, {
|
|
9466
9770
|
key: "tag_groups",
|
|
@@ -9529,7 +9833,7 @@ var TagGroupsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9529
9833
|
};
|
|
9530
9834
|
|
|
9531
9835
|
// src/resources/tags.ts
|
|
9532
|
-
var TagsResource = class extends
|
|
9836
|
+
var TagsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9533
9837
|
constructor(http, pageSize) {
|
|
9534
9838
|
super(http, {
|
|
9535
9839
|
key: "tags",
|
|
@@ -9598,7 +9902,7 @@ var TagsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9598
9902
|
};
|
|
9599
9903
|
|
|
9600
9904
|
// src/resources/task_secondary_resources.ts
|
|
9601
|
-
var TaskSecondaryResourcesResource = class extends
|
|
9905
|
+
var TaskSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9602
9906
|
constructor(http, pageSize) {
|
|
9603
9907
|
super(http, {
|
|
9604
9908
|
key: "task_secondary_resources",
|
|
@@ -9655,7 +9959,7 @@ var TaskSecondaryResourcesResource = class extends _chunk2H7YI54Bcjs.BaseResourc
|
|
|
9655
9959
|
};
|
|
9656
9960
|
|
|
9657
9961
|
// src/resources/tasks.ts
|
|
9658
|
-
var TasksResource = class extends
|
|
9962
|
+
var TasksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9659
9963
|
constructor(http, pageSize) {
|
|
9660
9964
|
super(http, {
|
|
9661
9965
|
key: "tasks",
|
|
@@ -9714,7 +10018,58 @@ var TasksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9714
10018
|
/** Search Task records: bounded contains on title (no vendor free-text search exists);
|
|
9715
10019
|
* limit defaults to 25, max 500. */
|
|
9716
10020
|
async search(query, opts) {
|
|
9717
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10021
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _91 => _91.limit]) });
|
|
10022
|
+
}
|
|
10023
|
+
};
|
|
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);
|
|
9718
10073
|
}
|
|
9719
10074
|
};
|
|
9720
10075
|
|
|
@@ -9743,7 +10098,7 @@ var ThresholdInformationResource = class {
|
|
|
9743
10098
|
};
|
|
9744
10099
|
|
|
9745
10100
|
// src/resources/ticket_additional_configuration_items.ts
|
|
9746
|
-
var TicketAdditionalConfigurationItemsResource = class extends
|
|
10101
|
+
var TicketAdditionalConfigurationItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9747
10102
|
constructor(http, pageSize) {
|
|
9748
10103
|
super(http, {
|
|
9749
10104
|
key: "ticket_additional_configuration_items",
|
|
@@ -9800,7 +10155,7 @@ var TicketAdditionalConfigurationItemsResource = class extends _chunk2H7YI54Bcjs
|
|
|
9800
10155
|
};
|
|
9801
10156
|
|
|
9802
10157
|
// src/resources/ticket_additional_contacts.ts
|
|
9803
|
-
var TicketAdditionalContactsResource = class extends
|
|
10158
|
+
var TicketAdditionalContactsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9804
10159
|
constructor(http, pageSize) {
|
|
9805
10160
|
super(http, {
|
|
9806
10161
|
key: "ticket_additional_contacts",
|
|
@@ -9857,7 +10212,7 @@ var TicketAdditionalContactsResource = class extends _chunk2H7YI54Bcjs.BaseResou
|
|
|
9857
10212
|
};
|
|
9858
10213
|
|
|
9859
10214
|
// src/resources/ticket_attachments.ts
|
|
9860
|
-
var TicketAttachmentsResource = class extends
|
|
10215
|
+
var TicketAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9861
10216
|
constructor(http, pageSize) {
|
|
9862
10217
|
super(http, {
|
|
9863
10218
|
key: "ticket_attachments",
|
|
@@ -9919,7 +10274,7 @@ var TicketAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9919
10274
|
};
|
|
9920
10275
|
|
|
9921
10276
|
// src/resources/ticket_categories.ts
|
|
9922
|
-
var TicketCategoriesResource = class extends
|
|
10277
|
+
var TicketCategoriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9923
10278
|
constructor(http, pageSize) {
|
|
9924
10279
|
super(http, {
|
|
9925
10280
|
key: "ticket_categories",
|
|
@@ -9973,12 +10328,12 @@ var TicketCategoriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
9973
10328
|
/** Search TicketCategory records: bounded contains on name (no vendor free-text search exists);
|
|
9974
10329
|
* limit defaults to 25, max 500. */
|
|
9975
10330
|
async search(query, opts) {
|
|
9976
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10331
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _92 => _92.limit]) });
|
|
9977
10332
|
}
|
|
9978
10333
|
};
|
|
9979
10334
|
|
|
9980
10335
|
// src/resources/ticket_category_field_defaults.ts
|
|
9981
|
-
var TicketCategoryFieldDefaultsResource = class extends
|
|
10336
|
+
var TicketCategoryFieldDefaultsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
9982
10337
|
constructor(http, pageSize) {
|
|
9983
10338
|
super(http, {
|
|
9984
10339
|
key: "ticket_category_field_defaults",
|
|
@@ -10020,7 +10375,7 @@ var TicketCategoryFieldDefaultsResource = class extends _chunk2H7YI54Bcjs.BaseRe
|
|
|
10020
10375
|
};
|
|
10021
10376
|
|
|
10022
10377
|
// src/resources/ticket_change_request_approvals.ts
|
|
10023
|
-
var TicketChangeRequestApprovalsResource = class extends
|
|
10378
|
+
var TicketChangeRequestApprovalsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10024
10379
|
constructor(http, pageSize) {
|
|
10025
10380
|
super(http, {
|
|
10026
10381
|
key: "ticket_change_request_approvals",
|
|
@@ -10081,10 +10436,10 @@ var _crypto = require('crypto');
|
|
|
10081
10436
|
var MOVE_SOURCE_AGE_DEFAULT_DAYS = 14;
|
|
10082
10437
|
var TICKET_COMPLETE_STATUS = 5;
|
|
10083
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";
|
|
10084
|
-
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 } });
|
|
10085
10440
|
async function queryRows(http, resource, filter, operation, retries) {
|
|
10086
10441
|
const res = await http.request({ method: "POST", idempotent: true, path: `/V1.0/${resource}/query`, body: { MaxRecords: 5, filter }, operation, maxRetries: retries });
|
|
10087
|
-
return
|
|
10442
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
10088
10443
|
}
|
|
10089
10444
|
function sameValue(a, b) {
|
|
10090
10445
|
if (a === null || a === void 0 || a === "") return b === null || b === void 0 || b === "";
|
|
@@ -10101,10 +10456,10 @@ function sameValue(a, b) {
|
|
|
10101
10456
|
async function readTicket(http, id, retries, operation) {
|
|
10102
10457
|
try {
|
|
10103
10458
|
const res = await http.request({ method: "GET", path: `/V1.0/Tickets/${id}`, operation, maxRetries: retries });
|
|
10104
|
-
const item = _optionalChain([res, 'optionalAccess',
|
|
10459
|
+
const item = _optionalChain([res, 'optionalAccess', _93 => _93.item]);
|
|
10105
10460
|
return _nullishCoalesce(item, () => ( null));
|
|
10106
10461
|
} catch (e) {
|
|
10107
|
-
if (
|
|
10462
|
+
if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
10108
10463
|
throw e;
|
|
10109
10464
|
}
|
|
10110
10465
|
}
|
|
@@ -10125,7 +10480,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10125
10480
|
}
|
|
10126
10481
|
}
|
|
10127
10482
|
const cap = opts.maxSourceAgeDays === void 0 ? MOVE_SOURCE_AGE_DEFAULT_DAYS : Math.min(MOVE_SOURCE_AGE_DEFAULT_DAYS, opts.maxSourceAgeDays);
|
|
10128
|
-
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`);
|
|
10129
10484
|
const when = Date.parse(String(_nullishCoalesce(source[spec.dateField], () => ( ""))));
|
|
10130
10485
|
if (!Number.isFinite(when) || Date.now() - when > cap * 864e5) {
|
|
10131
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") });
|
|
@@ -10138,7 +10493,7 @@ async function preview(http, spec, sourceId, toTicketId, opts) {
|
|
|
10138
10493
|
const origin = await readTicket(http, sourceTicketId, opts.maxRetries, op);
|
|
10139
10494
|
const facts = {
|
|
10140
10495
|
sourceTicketId,
|
|
10141
|
-
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess',
|
|
10496
|
+
sourceCompanyID: _nullishCoalesce(_optionalChain([origin, 'optionalAccess', _94 => _94.companyID]), () => ( null)),
|
|
10142
10497
|
targetCompanyID: _nullishCoalesce(target.companyID, () => ( null)),
|
|
10143
10498
|
companyChanged: origin === null ? null : origin.companyID !== target.companyID,
|
|
10144
10499
|
contractChanged: origin === null ? null : (_nullishCoalesce(origin.contractID, () => ( null))) !== (_nullishCoalesce(target.contractID, () => ( null)))
|
|
@@ -10160,17 +10515,17 @@ async function assertNoTwin(ctx, payload) {
|
|
|
10160
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 });
|
|
10161
10516
|
}
|
|
10162
10517
|
}
|
|
10163
|
-
var statusOf = (e) =>
|
|
10518
|
+
var statusOf = (e) => _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) ? e.httpStatus : void 0;
|
|
10164
10519
|
async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
10165
10520
|
const op = spec.operation;
|
|
10166
|
-
const sourceId = Number(
|
|
10167
|
-
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"));
|
|
10168
10523
|
if (!Number.isSafeInteger(sourceId) || !Number.isSafeInteger(toTicketId)) {
|
|
10169
|
-
throw new (0,
|
|
10524
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${op}: sourceId and toTicketId must be safe integers`);
|
|
10170
10525
|
}
|
|
10171
10526
|
const { ctx, payload } = await preview(http, spec, sourceId, toTicketId, opts);
|
|
10172
10527
|
if (opts.dryRun === true) {
|
|
10173
|
-
return
|
|
10528
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
10174
10529
|
{
|
|
10175
10530
|
operation: op,
|
|
10176
10531
|
method: "POST",
|
|
@@ -10195,22 +10550,22 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10195
10550
|
let newId;
|
|
10196
10551
|
try {
|
|
10197
10552
|
const created = await http.request({ method: "POST", path: spec.createPath(toTicketId), body: payload, operation: op, maxRetries: 0 });
|
|
10198
|
-
newId = Number(
|
|
10553
|
+
newId = Number(_chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, created, op).id);
|
|
10199
10554
|
} catch (e) {
|
|
10200
10555
|
const status = statusOf(e);
|
|
10201
10556
|
if (status !== void 0 && status >= 400 && status < 500) {
|
|
10202
|
-
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 } });
|
|
10203
10558
|
}
|
|
10204
|
-
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 } });
|
|
10205
10560
|
}
|
|
10206
10561
|
const rollback = async (code, message) => {
|
|
10207
10562
|
try {
|
|
10208
10563
|
await http.request({ method: "DELETE", path: spec.deletePath(newId, toTicketId), operation: op, maxRetries: 0 });
|
|
10209
10564
|
} catch (re) {
|
|
10210
10565
|
const unreadable = statusOf(re) === void 0 || (_nullishCoalesce(statusOf(re), () => ( 0))) >= 500;
|
|
10211
|
-
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 } });
|
|
10212
10567
|
}
|
|
10213
|
-
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 } });
|
|
10214
10569
|
};
|
|
10215
10570
|
const fresh = await spec.readById(http, newId, toTicketId).catch(() => null);
|
|
10216
10571
|
if (fresh === null) return rollback("MOVE_VERIFY_FAILED", "the new record could not be read back");
|
|
@@ -10239,14 +10594,14 @@ async function runMove(http, spec, sourceIdIn, toTicketIn, opts = {}) {
|
|
|
10239
10594
|
};
|
|
10240
10595
|
}
|
|
10241
10596
|
if (status === void 0) {
|
|
10242
|
-
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 } });
|
|
10243
10598
|
}
|
|
10244
10599
|
return rollback("MOVE_SOURCE_DELETE_FAILED", `the source delete failed (HTTP ${status})`);
|
|
10245
10600
|
}
|
|
10246
10601
|
return { status: "moved", sourceId, newId, correlationId, snapshot: ctx.source, facts: ctx.facts };
|
|
10247
10602
|
}
|
|
10248
10603
|
function uiLinkFor(http, entity, id) {
|
|
10249
|
-
return _nullishCoalesce(
|
|
10604
|
+
return _nullishCoalesce(_chunkZJ4ONAQFcjs.buildUiLink.call(void 0, { entity, id, baseUrl: http.baseUrl }), () => ( null));
|
|
10250
10605
|
}
|
|
10251
10606
|
|
|
10252
10607
|
// src/resources/special/ticket_charges.ts
|
|
@@ -10301,7 +10656,7 @@ function moveToTicket(_resource, sourceId, toTicketId, opts, http) {
|
|
|
10301
10656
|
}
|
|
10302
10657
|
|
|
10303
10658
|
// src/resources/ticket_charges.ts
|
|
10304
|
-
var TicketChargesResource = class extends
|
|
10659
|
+
var TicketChargesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10305
10660
|
constructor(http, pageSize) {
|
|
10306
10661
|
super(http, {
|
|
10307
10662
|
key: "ticket_charges",
|
|
@@ -10367,7 +10722,7 @@ var TicketChargesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
10367
10722
|
/** Search TicketCharge records: bounded contains on name (no vendor free-text search exists);
|
|
10368
10723
|
* limit defaults to 25, max 500. */
|
|
10369
10724
|
async search(query, opts) {
|
|
10370
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
10725
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _95 => _95.limit]) });
|
|
10371
10726
|
}
|
|
10372
10727
|
/** Node-parity special op (hand-written in src/resources/special/ticket_charges.ts). */
|
|
10373
10728
|
moveToTicket(sourceId, toTicketId, opts = {}) {
|
|
@@ -10376,7 +10731,7 @@ var TicketChargesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
10376
10731
|
};
|
|
10377
10732
|
|
|
10378
10733
|
// src/resources/ticket_checklist_items.ts
|
|
10379
|
-
var TicketChecklistItemsResource = class extends
|
|
10734
|
+
var TicketChecklistItemsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10380
10735
|
constructor(http, pageSize) {
|
|
10381
10736
|
super(http, {
|
|
10382
10737
|
key: "ticket_checklist_items",
|
|
@@ -10442,7 +10797,7 @@ var TicketChecklistItemsResource = class extends _chunk2H7YI54Bcjs.BaseResource
|
|
|
10442
10797
|
};
|
|
10443
10798
|
|
|
10444
10799
|
// src/resources/ticket_checklist_libraries.ts
|
|
10445
|
-
var TicketChecklistLibrariesResource = class extends
|
|
10800
|
+
var TicketChecklistLibrariesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10446
10801
|
constructor(http, pageSize) {
|
|
10447
10802
|
super(http, {
|
|
10448
10803
|
key: "ticket_checklist_libraries",
|
|
@@ -10466,9 +10821,9 @@ var TicketChecklistLibrariesResource = class extends _chunk2H7YI54Bcjs.BaseResou
|
|
|
10466
10821
|
* `dryRun: true` returns the pinned envelope (document existence is unverifiable in the MVP
|
|
10467
10822
|
* surface — no documents read op — and never issues the POST). */
|
|
10468
10823
|
async attachToDocument(documentID, data, opts = {}) {
|
|
10469
|
-
const n =
|
|
10824
|
+
const n = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, documentID, "documentID");
|
|
10470
10825
|
if (opts.dryRun === true) {
|
|
10471
|
-
return
|
|
10826
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
10472
10827
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10473
10828
|
method: "POST",
|
|
10474
10829
|
path: `/V1.0/Documents/${n}/ChecklistLibraries`,
|
|
@@ -10486,7 +10841,7 @@ var TicketChecklistLibrariesResource = class extends _chunk2H7YI54Bcjs.BaseResou
|
|
|
10486
10841
|
operation: "ticket_checklist_libraries.attachToDocument",
|
|
10487
10842
|
maxRetries: opts.maxRetries
|
|
10488
10843
|
});
|
|
10489
|
-
return
|
|
10844
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
10490
10845
|
}
|
|
10491
10846
|
/** Resolve a TicketChecklistLibrary from a numeric id (or, where the vendor indexes a primary text field,
|
|
10492
10847
|
* from a numeric id — this resource has no primary text field). A numeric id miss throws NOT_FOUND;
|
|
@@ -10502,7 +10857,7 @@ var TicketChecklistLibrariesResource = class extends _chunk2H7YI54Bcjs.BaseResou
|
|
|
10502
10857
|
};
|
|
10503
10858
|
|
|
10504
10859
|
// src/resources/ticket_history.ts
|
|
10505
|
-
var TicketHistoryResource = class extends
|
|
10860
|
+
var TicketHistoryResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10506
10861
|
constructor(http, pageSize) {
|
|
10507
10862
|
super(http, {
|
|
10508
10863
|
key: "ticket_history",
|
|
@@ -10541,7 +10896,7 @@ var TicketHistoryResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
10541
10896
|
};
|
|
10542
10897
|
|
|
10543
10898
|
// src/resources/ticket_note_attachments.ts
|
|
10544
|
-
var TicketNoteAttachmentsResource = class extends
|
|
10899
|
+
var TicketNoteAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10545
10900
|
constructor(http, pageSize) {
|
|
10546
10901
|
super(http, {
|
|
10547
10902
|
key: "ticket_note_attachments",
|
|
@@ -10603,7 +10958,7 @@ var TicketNoteAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource
|
|
|
10603
10958
|
};
|
|
10604
10959
|
|
|
10605
10960
|
// src/resources/ticket_notes.ts
|
|
10606
|
-
var TicketNotesResource = class extends
|
|
10961
|
+
var TicketNotesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10607
10962
|
constructor(http, pageSize) {
|
|
10608
10963
|
super(http, {
|
|
10609
10964
|
key: "ticket_notes",
|
|
@@ -10662,7 +11017,7 @@ var TicketNotesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
10662
11017
|
};
|
|
10663
11018
|
|
|
10664
11019
|
// src/resources/ticket_note_webhooks.ts
|
|
10665
|
-
var TicketNoteWebhooksResource = class extends
|
|
11020
|
+
var TicketNoteWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10666
11021
|
constructor(http, pageSize) {
|
|
10667
11022
|
super(http, {
|
|
10668
11023
|
key: "ticket_note_webhooks",
|
|
@@ -10733,12 +11088,12 @@ var TicketNoteWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
10733
11088
|
/** Search TicketNoteWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
10734
11089
|
* limit defaults to 25, max 500. */
|
|
10735
11090
|
async search(query, opts) {
|
|
10736
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
11091
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _96 => _96.limit]) });
|
|
10737
11092
|
}
|
|
10738
11093
|
};
|
|
10739
11094
|
|
|
10740
11095
|
// src/resources/ticket_secondary_resources.ts
|
|
10741
|
-
var TicketSecondaryResourcesResource = class extends
|
|
11096
|
+
var TicketSecondaryResourcesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
10742
11097
|
constructor(http, pageSize) {
|
|
10743
11098
|
super(http, {
|
|
10744
11099
|
key: "ticket_secondary_resources",
|
|
@@ -10803,9 +11158,9 @@ async function fetchTicket(http, id, operation) {
|
|
|
10803
11158
|
});
|
|
10804
11159
|
const body = res;
|
|
10805
11160
|
if (body === null || !("item" in body)) {
|
|
10806
|
-
throw new (0,
|
|
11161
|
+
throw new (0, _chunkZJ4ONAQFcjs.NotFoundError)(`Ticket ${id} not found (unexpected envelope shape)`, { resourceIds: [id], details: { idRefs: [{ entity: "ticket", id }] } });
|
|
10807
11162
|
}
|
|
10808
|
-
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 }] } });
|
|
10809
11164
|
return body.item;
|
|
10810
11165
|
}
|
|
10811
11166
|
async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
@@ -10816,7 +11171,7 @@ async function ticketQueryItems(http, path, filter, maxRecords, operation) {
|
|
|
10816
11171
|
body: { MaxRecords: maxRecords, filter },
|
|
10817
11172
|
operation
|
|
10818
11173
|
});
|
|
10819
|
-
return
|
|
11174
|
+
return _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res).items;
|
|
10820
11175
|
}
|
|
10821
11176
|
function truncate(text, limit) {
|
|
10822
11177
|
const full = _nullishCoalesce(text, () => ( ""));
|
|
@@ -10826,26 +11181,26 @@ function truncate(text, limit) {
|
|
|
10826
11181
|
|
|
10827
11182
|
// src/resources/special/tickets/childRead.ts
|
|
10828
11183
|
function isRouteUnavailable(err) {
|
|
10829
|
-
return
|
|
11184
|
+
return _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) && (err.httpStatus === 404 || err.httpStatus === 500);
|
|
10830
11185
|
}
|
|
10831
11186
|
function routeFact(route, path, err) {
|
|
10832
11187
|
return {
|
|
10833
11188
|
route,
|
|
10834
11189
|
path,
|
|
10835
|
-
httpStatus:
|
|
11190
|
+
httpStatus: _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) && typeof err.httpStatus === "number" ? err.httpStatus : null
|
|
10836
11191
|
};
|
|
10837
11192
|
}
|
|
10838
11193
|
function childDeclaresQuery(resourceKey) {
|
|
10839
|
-
return
|
|
11194
|
+
return _chunk5CC7LGNMcjs.CAPABILITIES.some(
|
|
10840
11195
|
(c) => c.id === `${resourceKey}.query` && (c.status === "implemented" || c.status === "tested")
|
|
10841
11196
|
);
|
|
10842
11197
|
}
|
|
10843
11198
|
function planScopedPath(resourceKey, ticketId) {
|
|
10844
11199
|
if (!childDeclaresQuery(resourceKey)) return null;
|
|
10845
|
-
const entry =
|
|
11200
|
+
const entry = _chunkZJ4ONAQFcjs.RELATIONSHIP_MAP[resourceKey];
|
|
10846
11201
|
const parent = entry === void 0 ? null : entry.parent;
|
|
10847
11202
|
if (parent === null || parent.resource !== "tickets" || parent.segment === null || parent.field === null) return null;
|
|
10848
|
-
const parentPath = _optionalChain([
|
|
11203
|
+
const parentPath = _optionalChain([_chunkZJ4ONAQFcjs.RELATIONSHIP_MAP, 'access', _97 => _97[parent.resource], 'optionalAccess', _98 => _98.path]);
|
|
10849
11204
|
if (parentPath === null || parentPath === void 0) return null;
|
|
10850
11205
|
return `/V1.0/${parentPath}/${ticketId}/${parent.segment}`;
|
|
10851
11206
|
}
|
|
@@ -10884,14 +11239,14 @@ async function scopedCollectionRead(http, startPath, limit, operation, accept) {
|
|
|
10884
11239
|
break;
|
|
10885
11240
|
}
|
|
10886
11241
|
const body = await http.request({ method: "GET", path: target, operation });
|
|
10887
|
-
const { items: pageItems, pageDetails } =
|
|
11242
|
+
const { items: pageItems, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, body, operation);
|
|
10888
11243
|
nextCursor = pageDetails.nextPageUrl;
|
|
10889
11244
|
pages += 1;
|
|
10890
11245
|
const window = pageItems.slice(0, Math.max(0, limit - items.length));
|
|
10891
11246
|
for (const row of window) if (accept(row)) items.push(row);
|
|
10892
11247
|
if (items.length >= limit) break;
|
|
10893
11248
|
if (nextCursor === null || pageItems.length === 0) break;
|
|
10894
|
-
target =
|
|
11249
|
+
target = _chunkZJ4ONAQFcjs.cursorToPath.call(void 0, http.baseUrl, nextCursor);
|
|
10895
11250
|
}
|
|
10896
11251
|
const capped = items.length >= limit || guard && nextCursor !== null;
|
|
10897
11252
|
return { items, capped };
|
|
@@ -10924,7 +11279,7 @@ var MS = 864e5;
|
|
|
10924
11279
|
var SLA_PAGE = 100;
|
|
10925
11280
|
async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
10926
11281
|
void opts;
|
|
10927
|
-
const ticketId =
|
|
11282
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
10928
11283
|
await fetchTicket(http, ticketId, "tickets.slaHealthCheck");
|
|
10929
11284
|
const rows = await ticketQueryItems(
|
|
10930
11285
|
http,
|
|
@@ -10949,9 +11304,9 @@ async function slaHealthCheck(_resource, id, opts = {}, http) {
|
|
|
10949
11304
|
async function summary(_resource, id, opts = {}, http) {
|
|
10950
11305
|
const limit = opts.summaryTextLimit === void 0 ? 500 : Math.trunc(opts.summaryTextLimit);
|
|
10951
11306
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
10952
|
-
throw new (0,
|
|
11307
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`summaryTextLimit must be an integer >= 1 (got ${String(opts.summaryTextLimit)})`);
|
|
10953
11308
|
}
|
|
10954
|
-
const ticketId =
|
|
11309
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
10955
11310
|
const ticket = await fetchTicket(http, ticketId, "tickets.summary");
|
|
10956
11311
|
const desc = truncate(ticket.description, limit);
|
|
10957
11312
|
const now = _nullishCoalesce(opts.now, () => ( /* @__PURE__ */ new Date()));
|
|
@@ -10980,11 +11335,11 @@ async function summary(_resource, id, opts = {}, http) {
|
|
|
10980
11335
|
// src/resources/special/tickets/timeline.ts
|
|
10981
11336
|
function validateTimelineLimits(opts) {
|
|
10982
11337
|
const limit = opts.limit === void 0 ? 100 : Math.trunc(opts.limit);
|
|
10983
|
-
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)})`);
|
|
10984
11339
|
const bounded = Math.min(limit, 500);
|
|
10985
11340
|
const textLimit = opts.textLimit === void 0 ? 500 : Math.trunc(opts.textLimit);
|
|
10986
11341
|
if (!Number.isInteger(textLimit) || textLimit < 1) {
|
|
10987
|
-
throw new (0,
|
|
11342
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`textLimit must be an integer >= 1 (got ${String(opts.textLimit)})`);
|
|
10988
11343
|
}
|
|
10989
11344
|
return { bounded, textLimit };
|
|
10990
11345
|
}
|
|
@@ -11036,7 +11391,7 @@ function compareEventDates(a, b) {
|
|
|
11036
11391
|
}
|
|
11037
11392
|
async function timeline(_resource, id, opts = {}, http) {
|
|
11038
11393
|
const { bounded, textLimit } = validateTimelineLimits(opts);
|
|
11039
|
-
const ticketId =
|
|
11394
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
11040
11395
|
await fetchTicket(http, ticketId, "tickets.timeline");
|
|
11041
11396
|
const dateFilters = (field) => {
|
|
11042
11397
|
const f = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11076,7 +11431,7 @@ async function timeline(_resource, id, opts = {}, http) {
|
|
|
11076
11431
|
}
|
|
11077
11432
|
|
|
11078
11433
|
// src/resources/special/tickets/errors.ts
|
|
11079
|
-
var QueueRequiredError = class extends
|
|
11434
|
+
var QueueRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11080
11435
|
constructor(message, options = {}) {
|
|
11081
11436
|
super(message, {
|
|
11082
11437
|
code: "QUEUE_REQUIRED",
|
|
@@ -11087,13 +11442,13 @@ var QueueRequiredError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
|
11087
11442
|
this.name = "QueueRequiredError";
|
|
11088
11443
|
}
|
|
11089
11444
|
};
|
|
11090
|
-
var TicketResourceInvalidError = class extends
|
|
11445
|
+
var TicketResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11091
11446
|
constructor(message, options = {}) {
|
|
11092
11447
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11093
11448
|
this.name = "TicketResourceInvalidError";
|
|
11094
11449
|
}
|
|
11095
11450
|
};
|
|
11096
|
-
var TicketCreateValidationFailedError = class extends
|
|
11451
|
+
var TicketCreateValidationFailedError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11097
11452
|
/** The vendor-named fields (empty when the 500 body named nothing parseable). */
|
|
11098
11453
|
|
|
11099
11454
|
constructor(message, vendorFields, options = {}) {
|
|
@@ -11102,7 +11457,7 @@ var TicketCreateValidationFailedError = class extends _chunk2H7YI54Bcjs.Autotask
|
|
|
11102
11457
|
this.vendorFields = vendorFields;
|
|
11103
11458
|
}
|
|
11104
11459
|
};
|
|
11105
|
-
var StatusUnknownError = class extends
|
|
11460
|
+
var StatusUnknownError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11106
11461
|
/** The live picklist size (the message names it; the values + labels are via operations.fieldCatalog with labels: true). */
|
|
11107
11462
|
|
|
11108
11463
|
constructor(message, options = {}) {
|
|
@@ -11116,7 +11471,7 @@ var StatusUnknownError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
|
11116
11471
|
this.picklistCount = _nullishCoalesce(options.picklistCount, () => ( 0));
|
|
11117
11472
|
}
|
|
11118
11473
|
};
|
|
11119
|
-
var StatusFieldsRequiredError = class extends
|
|
11474
|
+
var StatusFieldsRequiredError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11120
11475
|
|
|
11121
11476
|
|
|
11122
11477
|
|
|
@@ -11139,21 +11494,21 @@ function isPositiveInt(v) {
|
|
|
11139
11494
|
return typeof v === "number" && Number.isInteger(v) && v > 0;
|
|
11140
11495
|
}
|
|
11141
11496
|
function namedVendorFields(err) {
|
|
11142
|
-
if (!
|
|
11143
|
-
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), () => ( []));
|
|
11144
11499
|
const out = /* @__PURE__ */ new Set();
|
|
11145
11500
|
for (const e of entries) if (e.field !== void 0) out.add(e.field);
|
|
11146
11501
|
return [...out];
|
|
11147
11502
|
}
|
|
11148
11503
|
function vendorDetailOf(err) {
|
|
11149
|
-
return
|
|
11504
|
+
return _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? _chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError) : void 0;
|
|
11150
11505
|
}
|
|
11151
11506
|
async function fetchItem(http, path, operation, readOpts) {
|
|
11152
|
-
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11507
|
+
const res = await http.request({ method: "GET", path, operation, maxRetries: _optionalChain([readOpts, 'optionalAccess', _99 => _99.maxRetries]) });
|
|
11153
11508
|
return unwrapItemOrNull(res);
|
|
11154
11509
|
}
|
|
11155
11510
|
async function fetchItemUnredacted(http, path, operation, readOpts) {
|
|
11156
|
-
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess',
|
|
11511
|
+
const res = await http.request({ method: "GET", path, operation, skipResponseRedaction: true, maxRetries: _optionalChain([readOpts, 'optionalAccess', _100 => _100.maxRetries]) });
|
|
11157
11512
|
return unwrapItemOrNull(res);
|
|
11158
11513
|
}
|
|
11159
11514
|
function unwrapItemOrNull(res) {
|
|
@@ -11167,8 +11522,8 @@ function operationId(res) {
|
|
|
11167
11522
|
return typeof body.itemId === "number" ? body.itemId : typeof body.id === "number" ? body.id : void 0;
|
|
11168
11523
|
}
|
|
11169
11524
|
function discoveryMerge(err, body, defaults) {
|
|
11170
|
-
if (!
|
|
11171
|
-
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);
|
|
11172
11527
|
if (entries === void 0) return null;
|
|
11173
11528
|
for (const entry of entries) {
|
|
11174
11529
|
const field = entry.field;
|
|
@@ -11180,7 +11535,7 @@ function discoveryMerge(err, body, defaults) {
|
|
|
11180
11535
|
}
|
|
11181
11536
|
function stepErrorText(code, err) {
|
|
11182
11537
|
const detail = vendorDetailOf(err);
|
|
11183
|
-
const base =
|
|
11538
|
+
const base = _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? err.message : String(err);
|
|
11184
11539
|
return detail ? `${code}: ${detail}` : `${code}: ${base}`;
|
|
11185
11540
|
}
|
|
11186
11541
|
|
|
@@ -11192,43 +11547,43 @@ var DEFAULT_PUBLISH = 1;
|
|
|
11192
11547
|
var PUBLISH_VALUES = /* @__PURE__ */ new Set([1, 2, 4]);
|
|
11193
11548
|
var SAFE_TICKET_CREATE_DEFAULTS = {};
|
|
11194
11549
|
function validateOpenInput(params, note, assign) {
|
|
11195
|
-
const companyID =
|
|
11196
|
-
const title = _optionalChain([params, 'optionalAccess',
|
|
11550
|
+
const companyID = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, _optionalChain([params, 'optionalAccess', _101 => _101.companyID]), "params.companyID");
|
|
11551
|
+
const title = _optionalChain([params, 'optionalAccess', _102 => _102.title]);
|
|
11197
11552
|
if (typeof title !== "string" || title.trim() === "") {
|
|
11198
|
-
throw new (0,
|
|
11553
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("openWithNoteAndAssign: params.title is required (a non-empty string)", { operation: OP_OPEN });
|
|
11199
11554
|
}
|
|
11200
11555
|
const priority = _nullishCoalesce(params.priority, () => ( DEFAULT_TICKET_PRIORITY));
|
|
11201
11556
|
const status = _nullishCoalesce(params.status, () => ( DEFAULT_TICKET_STATUS));
|
|
11202
11557
|
if (!isPositiveInt(priority)) {
|
|
11203
|
-
throw new (0,
|
|
11558
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.priority must be a positive integer (got ${String(params.priority)})`, { operation: OP_OPEN });
|
|
11204
11559
|
}
|
|
11205
11560
|
if (!isPositiveInt(status)) {
|
|
11206
|
-
throw new (0,
|
|
11561
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.status must be a positive integer (got ${String(params.status)})`, { operation: OP_OPEN });
|
|
11207
11562
|
}
|
|
11208
11563
|
if (params.queueID !== void 0 && !isPositiveInt(params.queueID)) {
|
|
11209
|
-
throw new (0,
|
|
11564
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: params.queueID must be a positive integer (got ${String(params.queueID)})`, { operation: OP_OPEN });
|
|
11210
11565
|
}
|
|
11211
11566
|
if (note !== void 0) {
|
|
11212
11567
|
if (typeof note.description !== "string" || note.description.trim() === "") {
|
|
11213
|
-
throw new (0,
|
|
11568
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("openWithNoteAndAssign: note.description is required (a non-empty string)", { operation: OP_OPEN });
|
|
11214
11569
|
}
|
|
11215
11570
|
if (typeof note.title !== "string" || note.title.trim() === "") {
|
|
11216
|
-
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 });
|
|
11217
11572
|
}
|
|
11218
11573
|
if (note.noteType !== void 0 && !isPositiveInt(note.noteType)) {
|
|
11219
|
-
throw new (0,
|
|
11574
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: note.noteType must be a positive integer (got ${String(note.noteType)})`, { operation: OP_OPEN });
|
|
11220
11575
|
}
|
|
11221
11576
|
if (note.publish !== void 0 && !PUBLISH_VALUES.has(note.publish)) {
|
|
11222
|
-
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 });
|
|
11223
11578
|
}
|
|
11224
11579
|
}
|
|
11225
|
-
const assignee = assign === void 0 ? void 0 :
|
|
11580
|
+
const assignee = assign === void 0 ? void 0 : _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, assign.resourceID, "assign.resourceID");
|
|
11226
11581
|
if (assign !== void 0 && assignee !== void 0 && (typeof assignee === "number" ? assignee < 1 : false)) {
|
|
11227
|
-
throw new (0,
|
|
11582
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`openWithNoteAndAssign: assign.resourceID must be a positive integer (got ${String(assignee)})`, { operation: OP_OPEN });
|
|
11228
11583
|
}
|
|
11229
|
-
const roleID = _optionalChain([assign, 'optionalAccess',
|
|
11584
|
+
const roleID = _optionalChain([assign, 'optionalAccess', _103 => _103.roleID]);
|
|
11230
11585
|
if (assign !== void 0 && !isPositiveInt(roleID)) {
|
|
11231
|
-
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 });
|
|
11232
11587
|
}
|
|
11233
11588
|
return { companyID, title, priority, status, assignee, roleID };
|
|
11234
11589
|
}
|
|
@@ -11257,7 +11612,7 @@ function openDryRun(http, v, params, assign, body, noteBody) {
|
|
|
11257
11612
|
if (assign !== void 0) {
|
|
11258
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).`);
|
|
11259
11614
|
}
|
|
11260
|
-
return
|
|
11615
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
11261
11616
|
{
|
|
11262
11617
|
operation: OP_OPEN,
|
|
11263
11618
|
method: "POST",
|
|
@@ -11297,8 +11652,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11297
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}` : ""}`,
|
|
11298
11653
|
{
|
|
11299
11654
|
operation: OP_OPEN,
|
|
11300
|
-
httpStatus:
|
|
11301
|
-
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
|
|
11302
11657
|
}
|
|
11303
11658
|
);
|
|
11304
11659
|
}
|
|
@@ -11313,8 +11668,8 @@ async function createTicketWithDiscovery(resource, params, companyID, body, step
|
|
|
11313
11668
|
named,
|
|
11314
11669
|
{
|
|
11315
11670
|
operation: OP_OPEN,
|
|
11316
|
-
httpStatus:
|
|
11317
|
-
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,
|
|
11318
11673
|
resourceIds: [companyID],
|
|
11319
11674
|
details: { idRefs: [{ entity: "company", id: companyID }] }
|
|
11320
11675
|
}
|
|
@@ -11339,10 +11694,10 @@ async function assignStep(http, ticketId, assignee, roleID, opts, steps) {
|
|
|
11339
11694
|
try {
|
|
11340
11695
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_OPEN, { maxRetries: opts.maxRetries });
|
|
11341
11696
|
if (current === null) {
|
|
11342
|
-
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 }] } });
|
|
11343
11698
|
}
|
|
11344
11699
|
ticketNumber = typeof current.ticketNumber === "string" ? current.ticketNumber : null;
|
|
11345
|
-
const merged =
|
|
11700
|
+
const merged = _chunkZJ4ONAQFcjs.mergePartialBody.call(void 0, current, { id: ticketId, assignedResourceID: assignee, assignedResourceRoleID: roleID });
|
|
11346
11701
|
merged.id = ticketId;
|
|
11347
11702
|
await http.request({ method: "PUT", path: "/V1.0/Tickets", body: merged, operation: OP_OPEN, maxRetries: opts.maxRetries });
|
|
11348
11703
|
assigned = true;
|
|
@@ -11406,17 +11761,17 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11406
11761
|
const ids2 = await readLiveStatusSet(resource);
|
|
11407
11762
|
if (ids2.size > 0) liveStatus = ids2;
|
|
11408
11763
|
} catch (err) {
|
|
11409
|
-
if (!
|
|
11764
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11410
11765
|
}
|
|
11411
11766
|
if (liveStatus !== null && !liveStatus.has(targetStatus)) {
|
|
11412
|
-
_optionalChain([http, 'access',
|
|
11767
|
+
_optionalChain([http, 'access', _104 => _104.fieldCache, 'optionalAccess', _105 => _105.invalidate, 'call', _106 => _106("tickets")]);
|
|
11413
11768
|
let freshStatus = null;
|
|
11414
11769
|
let reReadFailed = false;
|
|
11415
11770
|
try {
|
|
11416
11771
|
const freshIds = await readLiveStatusSet(resource);
|
|
11417
11772
|
if (freshIds.size > 0) freshStatus = freshIds;
|
|
11418
11773
|
} catch (err) {
|
|
11419
|
-
if (!
|
|
11774
|
+
if (!_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
11420
11775
|
freshStatus = null;
|
|
11421
11776
|
reReadFailed = true;
|
|
11422
11777
|
}
|
|
@@ -11434,7 +11789,7 @@ async function guardTargetStatus(resource, http, targetStatus) {
|
|
|
11434
11789
|
return { guardDegraded: liveStatus === null };
|
|
11435
11790
|
}
|
|
11436
11791
|
function noChangeDryRun(http, ticketId, targetStatus, guardDegraded) {
|
|
11437
|
-
return
|
|
11792
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
11438
11793
|
{
|
|
11439
11794
|
operation: OP_STATUS,
|
|
11440
11795
|
method: "PUT",
|
|
@@ -11465,7 +11820,7 @@ function resolveMergeData(ticketId, targetStatus, previousStatus, current, field
|
|
|
11465
11820
|
for (const field of mapEntry.requiredFields) {
|
|
11466
11821
|
if (mergeData[field] !== void 0) continue;
|
|
11467
11822
|
if (current[field] !== null && current[field] !== void 0) continue;
|
|
11468
|
-
const safe = _optionalChain([mapEntry, 'access',
|
|
11823
|
+
const safe = _optionalChain([mapEntry, 'access', _107 => _107.safeDefaults, 'optionalAccess', _108 => _108[field]]);
|
|
11469
11824
|
if (safe === void 0) {
|
|
11470
11825
|
throw new StatusFieldsRequiredError(
|
|
11471
11826
|
`changeStatus: status ${targetStatus} requires the field '${field}' and the live-discovered map has no proven-safe default for it \u2014 the op is safe-without-the-map (never a blind full update): supply the value in fields and retry`,
|
|
@@ -11488,7 +11843,7 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11488
11843
|
if (mapEntry === void 0) {
|
|
11489
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).`);
|
|
11490
11845
|
}
|
|
11491
|
-
return
|
|
11846
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
11492
11847
|
{
|
|
11493
11848
|
operation: OP_STATUS,
|
|
11494
11849
|
method: "PUT",
|
|
@@ -11507,8 +11862,8 @@ function mergeDryRun(http, ticketId, targetStatus, guardDegraded, filled, mapEnt
|
|
|
11507
11862
|
);
|
|
11508
11863
|
}
|
|
11509
11864
|
async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStatus, current, mergeData, mapEntry, filled, opts) {
|
|
11510
|
-
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess',
|
|
11511
|
-
const body =
|
|
11865
|
+
const safeDefaults = _nullishCoalesce(_optionalChain([mapEntry, 'optionalAccess', _109 => _109.safeDefaults]), () => ( {}));
|
|
11866
|
+
const body = _chunkZJ4ONAQFcjs.mergePartialBody.call(void 0, current, mergeData);
|
|
11512
11867
|
body.id = ticketId;
|
|
11513
11868
|
let merges = 0;
|
|
11514
11869
|
for (; ; ) {
|
|
@@ -11532,8 +11887,8 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11532
11887
|
{ vendorFields: named, currentStatus: previousStatus, targetStatus, currentValues },
|
|
11533
11888
|
{
|
|
11534
11889
|
operation: OP_STATUS,
|
|
11535
|
-
httpStatus:
|
|
11536
|
-
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,
|
|
11537
11892
|
resourceIds: [ticketId],
|
|
11538
11893
|
details: { idRefs: [{ entity: "ticket", id: ticketId }] }
|
|
11539
11894
|
}
|
|
@@ -11546,7 +11901,7 @@ async function putStatusWithDiscovery(http, ticketId, targetStatus, previousStat
|
|
|
11546
11901
|
async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
11547
11902
|
const verify = await fetchItem(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11548
11903
|
if (verify === null) {
|
|
11549
|
-
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)`, {
|
|
11550
11905
|
code: "INVALID_RESPONSE",
|
|
11551
11906
|
category: "server",
|
|
11552
11907
|
operation: OP_STATUS,
|
|
@@ -11556,7 +11911,7 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11556
11911
|
}
|
|
11557
11912
|
const finalStatus = typeof verify.status === "number" ? verify.status : null;
|
|
11558
11913
|
if (finalStatus !== targetStatus) {
|
|
11559
|
-
throw new (0,
|
|
11914
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(
|
|
11560
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)`,
|
|
11561
11916
|
{
|
|
11562
11917
|
code: "INVALID_RESPONSE",
|
|
@@ -11571,17 +11926,17 @@ async function verifyStatusApplied(http, ticketId, targetStatus, opts) {
|
|
|
11571
11926
|
}
|
|
11572
11927
|
}
|
|
11573
11928
|
async function changeStatus(resource, id, targetStatus, fields, opts, http) {
|
|
11574
|
-
const ticketId =
|
|
11929
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
11575
11930
|
if (!isPositiveInt(targetStatus)) {
|
|
11576
|
-
throw new (0,
|
|
11931
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`changeStatus: targetStatus must be a positive integer (got ${String(targetStatus)})`, { operation: OP_STATUS });
|
|
11577
11932
|
}
|
|
11578
11933
|
const { guardDegraded } = await guardTargetStatus(resource, http, targetStatus);
|
|
11579
11934
|
if (fields !== void 0 && (typeof fields !== "object" || fields === null || Array.isArray(fields))) {
|
|
11580
|
-
throw new (0,
|
|
11935
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("changeStatus: fields must be a plain object of ticket fields (or omitted)", { operation: OP_STATUS });
|
|
11581
11936
|
}
|
|
11582
11937
|
const current = await fetchItemUnredacted(http, `/V1.0/Tickets/${ticketId}`, OP_STATUS, { maxRetries: opts.maxRetries });
|
|
11583
11938
|
if (current === null) {
|
|
11584
|
-
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 }] } });
|
|
11585
11940
|
}
|
|
11586
11941
|
const previousStatus = typeof current.status === "number" ? current.status : null;
|
|
11587
11942
|
if (previousStatus === targetStatus) {
|
|
@@ -11601,7 +11956,7 @@ var DEFAULT_PART_LIMIT = 50;
|
|
|
11601
11956
|
function partLimit(value, name) {
|
|
11602
11957
|
const n = value === void 0 ? DEFAULT_PART_LIMIT : Math.trunc(value);
|
|
11603
11958
|
if (!Number.isInteger(n) || n < 1) {
|
|
11604
|
-
throw new (0,
|
|
11959
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`fullContext: ${name} must be an integer >= 1 (got ${String(value)})`);
|
|
11605
11960
|
}
|
|
11606
11961
|
return n;
|
|
11607
11962
|
}
|
|
@@ -11614,7 +11969,7 @@ function servedTextRecord(row, textField, limit) {
|
|
|
11614
11969
|
return out;
|
|
11615
11970
|
}
|
|
11616
11971
|
async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
11617
|
-
const builder =
|
|
11972
|
+
const builder = _chunkZJ4ONAQFcjs.createNamePlan.call(void 0, _chunkZJ4ONAQFcjs.TICKET_LABEL_FIELDS);
|
|
11618
11973
|
const t = ctx.ticket;
|
|
11619
11974
|
builder.addResource(t["creatorResourceID"]);
|
|
11620
11975
|
builder.addFk("contract", t["contractID"]);
|
|
@@ -11626,20 +11981,20 @@ async function addCompositeNames(http, ctx, entriesPart, result, opts) {
|
|
|
11626
11981
|
builder.addFk("billingCode", e["billingCodeID"]);
|
|
11627
11982
|
builder.addFk("contract", e["contractID"]);
|
|
11628
11983
|
}
|
|
11629
|
-
const names = await
|
|
11984
|
+
const names = await _chunkZJ4ONAQFcjs.resolveCompositeNames.call(void 0, http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
11630
11985
|
const ticketRow = { ...ctx.ticket };
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
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);
|
|
11636
11991
|
result.ticket = ticketRow;
|
|
11637
11992
|
result.timeEntries.items = entriesPart.items.map((e) => {
|
|
11638
11993
|
const row = { ...e };
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
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));
|
|
11643
11998
|
return row;
|
|
11644
11999
|
});
|
|
11645
12000
|
result.names = names.section;
|
|
@@ -11649,7 +12004,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11649
12004
|
const noteLimit = partLimit(opts.noteLimit, "noteLimit");
|
|
11650
12005
|
const timeEntryLimit = partLimit(opts.timeEntryLimit, "timeEntryLimit");
|
|
11651
12006
|
const textLimit = partLimit(opts.textLimit, "textLimit");
|
|
11652
|
-
const ticketId =
|
|
12007
|
+
const ticketId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
11653
12008
|
const ctx = await resource.getContext(ticketId);
|
|
11654
12009
|
const op = "tickets.fullContext";
|
|
11655
12010
|
const ticketFilter = [{ field: "ticketID", op: "eq", value: ticketId }];
|
|
@@ -11707,7 +12062,7 @@ async function fullContext(resource, id, opts = {}, http) {
|
|
|
11707
12062
|
}
|
|
11708
12063
|
|
|
11709
12064
|
// src/resources/tickets.ts
|
|
11710
|
-
var TicketsResource = class extends
|
|
12065
|
+
var TicketsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
11711
12066
|
constructor(http, pageSize) {
|
|
11712
12067
|
super(http, {
|
|
11713
12068
|
key: "tickets",
|
|
@@ -11814,7 +12169,7 @@ var TicketsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
11814
12169
|
};
|
|
11815
12170
|
|
|
11816
12171
|
// src/resources/ticket_webhooks.ts
|
|
11817
|
-
var TicketWebhooksResource = class extends
|
|
12172
|
+
var TicketWebhooksResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
11818
12173
|
constructor(http, pageSize) {
|
|
11819
12174
|
super(http, {
|
|
11820
12175
|
key: "ticket_webhooks",
|
|
@@ -11885,7 +12240,7 @@ var TicketWebhooksResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
11885
12240
|
/** Search TicketWebhook records: bounded contains on name (no vendor free-text search exists);
|
|
11886
12241
|
* limit defaults to 25, max 500. */
|
|
11887
12242
|
async search(query, opts) {
|
|
11888
|
-
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess',
|
|
12243
|
+
return this.searchBase(query, { limit: _optionalChain([opts, 'optionalAccess', _110 => _110.limit]) });
|
|
11889
12244
|
}
|
|
11890
12245
|
};
|
|
11891
12246
|
|
|
@@ -11900,62 +12255,62 @@ async function queryTimeEntries(_resource, filter, limit, operation, http) {
|
|
|
11900
12255
|
body: { MaxRecords: limit, filter },
|
|
11901
12256
|
operation
|
|
11902
12257
|
});
|
|
11903
|
-
const { items, pageDetails } =
|
|
12258
|
+
const { items, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res);
|
|
11904
12259
|
return { items, hasMore: pageDetails.nextPageUrl != null };
|
|
11905
12260
|
}
|
|
11906
12261
|
async function windowQuery3(_resource, kind, http, opts) {
|
|
11907
|
-
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
11908
|
-
const tz = _optionalChain([opts, 'optionalAccess',
|
|
12262
|
+
const now = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _111 => _111.now]), () => ( /* @__PURE__ */ new Date()));
|
|
12263
|
+
const tz = _optionalChain([opts, 'optionalAccess', _112 => _112.tz]) === void 0 ? void 0 : validateZone(opts.tz, `time_entries.${kind}`);
|
|
11909
12264
|
const { from, to } = dateOnlyWindowBounds(kind, now, tz);
|
|
11910
12265
|
const filter = [
|
|
11911
12266
|
{ field: "dateWorked", op: "gte", value: from },
|
|
11912
12267
|
{ field: "dateWorked", op: "lte", value: to }
|
|
11913
12268
|
];
|
|
11914
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12269
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _113 => _113.limit])), `time_entries.${kind}`, http);
|
|
11915
12270
|
return items;
|
|
11916
12271
|
}
|
|
11917
12272
|
async function customRange3(_resource, from, to, http, opts) {
|
|
11918
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12273
|
+
if (_optionalChain([opts, 'optionalAccess', _114 => _114.tz]) !== void 0) validateZone(opts.tz, "time_entries.customRange");
|
|
11919
12274
|
const fromB = customRangeDay(from, "from", void 0, "customRange");
|
|
11920
12275
|
const toB = customRangeDay(to, "to", void 0, "customRange");
|
|
11921
12276
|
if (fromB.ms > toB.ms) {
|
|
11922
|
-
throw new (0,
|
|
12277
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("customRange: from must not be after to");
|
|
11923
12278
|
}
|
|
11924
12279
|
const toEndMs = toB.ms + DAY_MS2 - 1;
|
|
11925
12280
|
const filter = [
|
|
11926
12281
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11927
12282
|
{ field: "dateWorked", op: "lte", value: iso2(toEndMs) }
|
|
11928
12283
|
];
|
|
11929
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12284
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _115 => _115.limit])), "time_entries.customRange", http);
|
|
11930
12285
|
return items;
|
|
11931
12286
|
}
|
|
11932
12287
|
async function postedDateStatusQuery(_resource, mode, http, opts) {
|
|
11933
12288
|
const filter = [
|
|
11934
12289
|
{ field: "postedDate", op: mode === "posted" ? "exist" : "notExist" }
|
|
11935
12290
|
];
|
|
11936
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
12291
|
+
if (_optionalChain([opts, 'optionalAccess', _116 => _116.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
11937
12292
|
const operation = mode === "posted" ? "time_entries.getPosted" : "time_entries.getUnposted";
|
|
11938
|
-
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12293
|
+
const { items } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _117 => _117.limit])), operation, http);
|
|
11939
12294
|
return items;
|
|
11940
12295
|
}
|
|
11941
12296
|
async function postedWithin(_resource, from, to, http, opts, opLabel = "time_entries.postedWithin") {
|
|
11942
|
-
const
|
|
11943
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11944
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
11945
|
-
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);
|
|
11946
12301
|
if (fromB.ms > toB.ms) {
|
|
11947
|
-
throw new (0,
|
|
12302
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP7}: from (${iso2(fromB.ms)}) must not be after to (${iso2(toB.ms)})`, { operation: OP7 });
|
|
11948
12303
|
}
|
|
11949
12304
|
const windowToMs = toB.ms + DAY_MS2 - 1;
|
|
11950
12305
|
const filter = [
|
|
11951
12306
|
{ field: "dateWorked", op: "gte", value: iso2(fromB.ms) },
|
|
11952
12307
|
{ field: "dateWorked", op: "lte", value: iso2(windowToMs) }
|
|
11953
12308
|
];
|
|
11954
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11955
|
-
else if (_optionalChain([opts, 'optionalAccess',
|
|
11956
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11957
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
11958
|
-
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess',
|
|
12309
|
+
if (_optionalChain([opts, 'optionalAccess', _119 => _119.posted]) === true) filter.push({ field: "postedDate", op: "exist" });
|
|
12310
|
+
else if (_optionalChain([opts, 'optionalAccess', _120 => _120.posted]) === false) filter.push({ field: "postedDate", op: "notExist" });
|
|
12311
|
+
if (_optionalChain([opts, 'optionalAccess', _121 => _121.ticketID]) !== void 0) filter.push({ field: "ticketID", op: "eq", value: opts.ticketID });
|
|
12312
|
+
if (_optionalChain([opts, 'optionalAccess', _122 => _122.resourceID]) !== void 0) filter.push({ field: "resourceID", op: "eq", value: opts.resourceID });
|
|
12313
|
+
const { items, hasMore } = await queryTimeEntries(_resource, filter, clampWindowLimit(_optionalChain([opts, 'optionalAccess', _123 => _123.limit])), OP7, http);
|
|
11959
12314
|
let postedCount = 0;
|
|
11960
12315
|
for (const item of items) {
|
|
11961
12316
|
const postedDate = item.postedDate;
|
|
@@ -11978,13 +12333,13 @@ async function dateWorkedWindow(resource, from, to, http, opts) {
|
|
|
11978
12333
|
}
|
|
11979
12334
|
|
|
11980
12335
|
// src/resources/special/time_entries/errors.ts
|
|
11981
|
-
var ResourceInvalidError = class extends
|
|
12336
|
+
var ResourceInvalidError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11982
12337
|
constructor(message, options = {}) {
|
|
11983
12338
|
super(message, { code: "RESOURCE_INVALID", category: "validation", ...options });
|
|
11984
12339
|
this.name = "ResourceInvalidError";
|
|
11985
12340
|
}
|
|
11986
12341
|
};
|
|
11987
|
-
var AllocationCodeError = class extends
|
|
12342
|
+
var AllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11988
12343
|
/** The failure kind (the machine code is `ALLOCATION_CODE_<KIND>`). */
|
|
11989
12344
|
|
|
11990
12345
|
constructor(kind, message, options = {}) {
|
|
@@ -11993,7 +12348,7 @@ var AllocationCodeError = class extends _chunk2H7YI54Bcjs.AutotaskError {
|
|
|
11993
12348
|
this.kind = kind;
|
|
11994
12349
|
}
|
|
11995
12350
|
};
|
|
11996
|
-
var NoApplicableAllocationCodeError = class extends
|
|
12351
|
+
var NoApplicableAllocationCodeError = class extends _chunkZJ4ONAQFcjs.AutotaskError {
|
|
11997
12352
|
/** The structured blocker details (filters tried + department sets). */
|
|
11998
12353
|
|
|
11999
12354
|
constructor(details, options = {}) {
|
|
@@ -12058,7 +12413,7 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12058
12413
|
let pages = 0;
|
|
12059
12414
|
for (; ; ) {
|
|
12060
12415
|
if (pages >= PAGE_GUARD) {
|
|
12061
|
-
throw new (0,
|
|
12416
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskError)(`createForResource: the ${path} walk hit the ${PAGE_GUARD}-page guard`, {
|
|
12062
12417
|
code: "RESOLUTION_TRUNCATED",
|
|
12063
12418
|
category: "resolution",
|
|
12064
12419
|
operation,
|
|
@@ -12069,11 +12424,11 @@ async function boundedQuery(http, path, filter, totalCap, operation) {
|
|
|
12069
12424
|
const res = await http.request({
|
|
12070
12425
|
method: "POST",
|
|
12071
12426
|
idempotent: true,
|
|
12072
|
-
path: isFirst ? path :
|
|
12427
|
+
path: isFirst ? path : _chunkZJ4ONAQFcjs.cursorToPath.call(void 0, http.baseUrl, cursor),
|
|
12073
12428
|
body: { MaxRecords: pageSize, filter },
|
|
12074
12429
|
operation
|
|
12075
12430
|
});
|
|
12076
|
-
const { items: pageItems, pageDetails } =
|
|
12431
|
+
const { items: pageItems, pageDetails } = _chunkZJ4ONAQFcjs.unwrapItems.call(void 0, res, operation);
|
|
12077
12432
|
items.push(...pageItems);
|
|
12078
12433
|
pages += 1;
|
|
12079
12434
|
if (items.length >= totalCap) break;
|
|
@@ -12190,7 +12545,7 @@ function windowDefaults(params) {
|
|
|
12190
12545
|
var familyOf = (l) => l === "internal" ? USE_TYPE_INTERNAL : USE_TYPE_GENERAL;
|
|
12191
12546
|
var familyLabel = (f) => f === USE_TYPE_GENERAL ? "General Allocation Code" : "Internal Allocation Code";
|
|
12192
12547
|
function validateCreateParams(params) {
|
|
12193
|
-
const pin = (value, label) => typeof value === "number" ?
|
|
12548
|
+
const pin = (value, label) => typeof value === "number" ? _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, value, label) : void 0;
|
|
12194
12549
|
const pins = {
|
|
12195
12550
|
code: pin(params.internallAllocationCodeID, "internallAllocationCodeID"),
|
|
12196
12551
|
ticket: pin(params.ticketID, "ticketID"),
|
|
@@ -12199,19 +12554,19 @@ function validateCreateParams(params) {
|
|
|
12199
12554
|
};
|
|
12200
12555
|
const pinCount = [pins.code, pins.ticket, pins.task].filter((v) => v !== void 0).length;
|
|
12201
12556
|
if (pinCount > 1) {
|
|
12202
|
-
throw new (0,
|
|
12557
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12203
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)",
|
|
12204
12559
|
{ operation: OP3 }
|
|
12205
12560
|
);
|
|
12206
12561
|
}
|
|
12207
12562
|
if (pins.role !== void 0 && pins.code !== void 0) {
|
|
12208
|
-
throw new (0,
|
|
12563
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12209
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",
|
|
12210
12565
|
{ operation: OP3 }
|
|
12211
12566
|
);
|
|
12212
12567
|
}
|
|
12213
12568
|
if (params.hoursWorked !== void 0 && (typeof params.hoursWorked !== "number" || !Number.isFinite(params.hoursWorked) || params.hoursWorked <= 0)) {
|
|
12214
|
-
throw new (0,
|
|
12569
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(
|
|
12215
12570
|
`createForResource: hoursWorked must be a positive finite number (got ${String(params.hoursWorked)})`,
|
|
12216
12571
|
{ operation: OP3 }
|
|
12217
12572
|
);
|
|
@@ -12294,7 +12649,7 @@ function createDryRun2(http, rid, body, linkage, usedLinkage, resolvedCode) {
|
|
|
12294
12649
|
if (usedLinkage === "internal" && linkage === "task") {
|
|
12295
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).");
|
|
12296
12651
|
}
|
|
12297
|
-
return
|
|
12652
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0,
|
|
12298
12653
|
{
|
|
12299
12654
|
operation: OP3,
|
|
12300
12655
|
method: "POST",
|
|
@@ -12334,7 +12689,7 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12334
12689
|
};
|
|
12335
12690
|
} catch (err) {
|
|
12336
12691
|
lastError = err;
|
|
12337
|
-
const text =
|
|
12692
|
+
const text = _chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, err) ? `${_nullishCoalesce(_chunkZJ4ONAQFcjs.formatVendorDetail.call(void 0, err.vendorError), () => ( ""))} ${err.message}` : "";
|
|
12338
12693
|
const gate3 = ROLE_REJECTION_PATTERN.test(text);
|
|
12339
12694
|
if (usedLinkage !== "internal" && gate3) {
|
|
12340
12695
|
if (!taskRoleFetched && usedLinkage === "task" && pins.task !== void 0) {
|
|
@@ -12354,13 +12709,13 @@ async function createWithAttempts(resource, http, opts, body, defaults, pins, us
|
|
|
12354
12709
|
throw err;
|
|
12355
12710
|
}
|
|
12356
12711
|
}
|
|
12357
|
-
if (
|
|
12712
|
+
if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, lastError)) {
|
|
12358
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.`;
|
|
12359
12714
|
}
|
|
12360
12715
|
throw lastError;
|
|
12361
12716
|
}
|
|
12362
12717
|
async function createForResource(resource, resourceID, params, opts = {}, http) {
|
|
12363
|
-
const rid =
|
|
12718
|
+
const rid = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, resourceID, "resourceID");
|
|
12364
12719
|
const pins = validateCreateParams(params);
|
|
12365
12720
|
await assertResourceActive(http, rid);
|
|
12366
12721
|
const linkage = pins.code !== void 0 ? "internal" : pins.ticket !== void 0 ? "ticket" : pins.task !== void 0 ? "task" : "internal";
|
|
@@ -12373,8 +12728,8 @@ async function createForResource(resource, resourceID, params, opts = {}, http)
|
|
|
12373
12728
|
return createWithAttempts(resource, http, opts, body, defaults, pins, usedLinkage, resolvedCode, roleRows);
|
|
12374
12729
|
}
|
|
12375
12730
|
function discoveryField(err, body, defaults) {
|
|
12376
|
-
if (!
|
|
12377
|
-
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);
|
|
12378
12733
|
if (entries === void 0) return null;
|
|
12379
12734
|
for (const entry of entries) {
|
|
12380
12735
|
const field = entry.field;
|
|
@@ -12393,9 +12748,9 @@ var CONTRACT_SCOPED2 = ["contractID", "contractServiceID", "contractServiceBundl
|
|
|
12393
12748
|
async function readTimeEntry(http, id, retries) {
|
|
12394
12749
|
try {
|
|
12395
12750
|
const res = await http.request({ method: "GET", path: `/V1.0/TimeEntries/${id}`, operation: OP4, maxRetries: retries });
|
|
12396
|
-
return _nullishCoalesce(_optionalChain([res, 'optionalAccess',
|
|
12751
|
+
return _nullishCoalesce(_optionalChain([res, 'optionalAccess', _124 => _124.item]), () => ( null));
|
|
12397
12752
|
} catch (e) {
|
|
12398
|
-
if (
|
|
12753
|
+
if (_chunkZJ4ONAQFcjs.isAutotaskError.call(void 0, e) && (e.httpStatus === 404 || e.code === "NOT_FOUND")) return null;
|
|
12399
12754
|
throw e;
|
|
12400
12755
|
}
|
|
12401
12756
|
}
|
|
@@ -12456,29 +12811,116 @@ function moveToTicket2(_resource, sourceId, toTicketId, opts, http) {
|
|
|
12456
12811
|
return runMove(http, SPEC2, sourceId, toTicketId, opts);
|
|
12457
12812
|
}
|
|
12458
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
|
+
|
|
12459
12901
|
// src/resources/special/time_entries/recentTickets.ts
|
|
12460
|
-
var
|
|
12902
|
+
var OP6 = "time_entries.recentTickets";
|
|
12461
12903
|
var DAY_MS3 = 864e5;
|
|
12462
12904
|
var TICKET_CHUNK = 100;
|
|
12463
12905
|
var TICKET_FIELDS2 = ["id", "ticketNumber", "title", "status", "assignedResourceID", "companyID"];
|
|
12464
12906
|
function positiveId(value, name) {
|
|
12465
12907
|
const n = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : value;
|
|
12466
12908
|
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1) {
|
|
12467
|
-
throw new (0,
|
|
12909
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: ${name} must be a positive integer id (got ${String(value)})`, { operation: OP6 });
|
|
12468
12910
|
}
|
|
12469
12911
|
return n;
|
|
12470
12912
|
}
|
|
12471
12913
|
async function recentTickets(_resource, from, to, http, opts) {
|
|
12472
12914
|
if (opts === void 0 || opts === null || typeof opts !== "object") {
|
|
12473
|
-
throw new (0,
|
|
12915
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: opts { resourceID, companyID?, tz?, limit? } is required`, { operation: OP6 });
|
|
12474
12916
|
}
|
|
12475
12917
|
const resourceID = positiveId(opts.resourceID, "resourceID");
|
|
12476
12918
|
const companyID = opts.companyID === void 0 ? void 0 : positiveId(opts.companyID, "companyID");
|
|
12477
|
-
if (opts.tz !== void 0) validateZone(opts.tz,
|
|
12478
|
-
const fromB = customRangeDay(from, "from", void 0,
|
|
12479
|
-
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);
|
|
12480
12922
|
if (fromB.ms > toB.ms) {
|
|
12481
|
-
throw new (0,
|
|
12923
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)(`${OP6}: from (${isoUtc(fromB.ms)}) must not be after to (${isoUtc(toB.ms)})`, { operation: OP6 });
|
|
12482
12924
|
}
|
|
12483
12925
|
const windowToMs = toB.ms + DAY_MS3 - 1;
|
|
12484
12926
|
const { items: entries, hasMore } = await queryTimeEntries(
|
|
@@ -12489,7 +12931,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12489
12931
|
{ field: "resourceID", op: "eq", value: resourceID }
|
|
12490
12932
|
],
|
|
12491
12933
|
clampWindowLimit(opts.limit),
|
|
12492
|
-
|
|
12934
|
+
OP6,
|
|
12493
12935
|
http
|
|
12494
12936
|
);
|
|
12495
12937
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -12515,9 +12957,9 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12515
12957
|
idempotent: true,
|
|
12516
12958
|
path: "/V1.0/Tickets/query",
|
|
12517
12959
|
body: { MaxRecords: TICKET_CHUNK, filter, IncludeFields: TICKET_FIELDS2 },
|
|
12518
|
-
operation:
|
|
12960
|
+
operation: OP6
|
|
12519
12961
|
});
|
|
12520
|
-
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);
|
|
12521
12963
|
}
|
|
12522
12964
|
const items = [];
|
|
12523
12965
|
const unresolvedTicketIDs = [];
|
|
@@ -12525,17 +12967,17 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12525
12967
|
for (const [ticketID, g] of groups) {
|
|
12526
12968
|
const t = tickets.get(ticketID);
|
|
12527
12969
|
if (t === void 0) unresolvedTicketIDs.push(ticketID);
|
|
12528
|
-
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess',
|
|
12970
|
+
if (companyID !== void 0 && _optionalChain([t, 'optionalAccess', _125 => _125.companyID]) !== companyID) {
|
|
12529
12971
|
if (t !== void 0) excludedTickets += 1;
|
|
12530
12972
|
continue;
|
|
12531
12973
|
}
|
|
12532
12974
|
items.push({
|
|
12533
12975
|
ticketID,
|
|
12534
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12535
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12536
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12537
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12538
|
-
..._optionalChain([t, 'optionalAccess',
|
|
12976
|
+
..._optionalChain([t, 'optionalAccess', _126 => _126.ticketNumber]) !== void 0 ? { ticketNumber: t.ticketNumber } : {},
|
|
12977
|
+
..._optionalChain([t, 'optionalAccess', _127 => _127.title]) !== void 0 ? { title: t.title } : {},
|
|
12978
|
+
..._optionalChain([t, 'optionalAccess', _128 => _128.status]) !== void 0 ? { status: t.status } : {},
|
|
12979
|
+
..._optionalChain([t, 'optionalAccess', _129 => _129.assignedResourceID]) !== void 0 ? { assignedResourceID: t.assignedResourceID } : {},
|
|
12980
|
+
..._optionalChain([t, 'optionalAccess', _130 => _130.companyID]) !== void 0 ? { companyID: t.companyID } : {},
|
|
12539
12981
|
entryCount: g.entryCount,
|
|
12540
12982
|
totalHours: Math.round(g.totalHours * 100) / 100,
|
|
12541
12983
|
lastWorked: g.lastWorked
|
|
@@ -12554,7 +12996,7 @@ async function recentTickets(_resource, from, to, http, opts) {
|
|
|
12554
12996
|
}
|
|
12555
12997
|
|
|
12556
12998
|
// src/resources/time_entries.ts
|
|
12557
|
-
var TimeEntriesResource = class extends
|
|
12999
|
+
var TimeEntriesResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
12558
13000
|
constructor(http, pageSize) {
|
|
12559
13001
|
super(http, {
|
|
12560
13002
|
key: "time_entries",
|
|
@@ -12621,6 +13063,10 @@ var TimeEntriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
12621
13063
|
return this.resolveBase(identifier);
|
|
12622
13064
|
}
|
|
12623
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). */
|
|
12624
13070
|
createForResource(resourceID, params, opts = {}) {
|
|
12625
13071
|
return createForResource(this, resourceID, params, opts, this.http);
|
|
12626
13072
|
}
|
|
@@ -12699,7 +13145,7 @@ var TimeEntriesResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
12699
13145
|
};
|
|
12700
13146
|
|
|
12701
13147
|
// src/resources/time_entry_attachments.ts
|
|
12702
|
-
var TimeEntryAttachmentsResource = class extends
|
|
13148
|
+
var TimeEntryAttachmentsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
12703
13149
|
constructor(http, pageSize) {
|
|
12704
13150
|
super(http, {
|
|
12705
13151
|
key: "time_entry_attachments",
|
|
@@ -12761,10 +13207,10 @@ var TimeEntryAttachmentsResource = class extends _chunk2H7YI54Bcjs.BaseResource
|
|
|
12761
13207
|
};
|
|
12762
13208
|
|
|
12763
13209
|
// src/resources/special/time_off_requests.ts
|
|
12764
|
-
async function
|
|
12765
|
-
const numericId =
|
|
13210
|
+
async function approve2(_resource, id, opts = {}, http) {
|
|
13211
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
12766
13212
|
if (opts.dryRun === true) {
|
|
12767
|
-
return
|
|
13213
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
12768
13214
|
operation: "time_off_requests.approve",
|
|
12769
13215
|
method: "GET",
|
|
12770
13216
|
path: `/V1.0/TimeOffRequests/${numericId}/Approve`,
|
|
@@ -12780,16 +13226,16 @@ async function approve(_resource, id, opts = {}, http) {
|
|
|
12780
13226
|
operation: "time_off_requests.approve",
|
|
12781
13227
|
maxRetries: opts.maxRetries
|
|
12782
13228
|
});
|
|
12783
|
-
return
|
|
13229
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
12784
13230
|
}
|
|
12785
13231
|
async function reject(_resource, id, reason, opts = {}, http) {
|
|
12786
|
-
const numericId =
|
|
13232
|
+
const numericId = _chunkZJ4ONAQFcjs.parseIdentifier.call(void 0, id, "id");
|
|
12787
13233
|
const text = reason.trim();
|
|
12788
13234
|
if (text === "") {
|
|
12789
|
-
throw new (0,
|
|
13235
|
+
throw new (0, _chunkZJ4ONAQFcjs.AutotaskConfigError)("reject: a non-empty reason is required (vendor TimeOffRequestRejectModel)");
|
|
12790
13236
|
}
|
|
12791
13237
|
if (opts.dryRun === true) {
|
|
12792
|
-
return
|
|
13238
|
+
return _chunkZJ4ONAQFcjs.buildDryRunResult.call(void 0, {
|
|
12793
13239
|
operation: "time_off_requests.reject",
|
|
12794
13240
|
method: "POST",
|
|
12795
13241
|
path: `/V1.0/TimeOffRequests/${numericId}/Reject`,
|
|
@@ -12807,11 +13253,11 @@ async function reject(_resource, id, reason, opts = {}, http) {
|
|
|
12807
13253
|
operation: "time_off_requests.reject",
|
|
12808
13254
|
maxRetries: opts.maxRetries
|
|
12809
13255
|
});
|
|
12810
|
-
return
|
|
13256
|
+
return _chunkZJ4ONAQFcjs.unwrapOperation.call(void 0, res);
|
|
12811
13257
|
}
|
|
12812
13258
|
|
|
12813
13259
|
// src/resources/time_off_requests.ts
|
|
12814
|
-
var TimeOffRequestsResource = class extends
|
|
13260
|
+
var TimeOffRequestsResource = class extends _chunkZJ4ONAQFcjs.BaseResource {
|
|
12815
13261
|
constructor(http, pageSize) {
|
|
12816
13262
|
super(http, {
|
|
12817
13263
|
key: "time_off_requests",
|
|
@@ -12849,7 +13295,7 @@ var TimeOffRequestsResource = class extends _chunk2H7YI54Bcjs.BaseResource {
|
|
|
12849
13295
|
}
|
|
12850
13296
|
/** Node-parity special op (hand-written in src/resources/special/time_off_requests.ts). */
|
|
12851
13297
|
approve(id, opts = {}) {
|
|
12852
|
-
return
|
|
13298
|
+
return approve2(this, id, opts, this.http);
|
|
12853
13299
|
}
|
|
12854
13300
|
/** Node-parity special op (hand-written in src/resources/special/time_off_requests.ts). */
|
|
12855
13301
|
reject(id, reason, opts = {}) {
|
|
@@ -13046,4 +13492,12 @@ var ZoneInformationResource = class {
|
|
|
13046
13492
|
|
|
13047
13493
|
|
|
13048
13494
|
|
|
13049
|
-
|
|
13495
|
+
|
|
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;
|