node-autotask 0.72.0 → 0.73.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 +14 -0
- package/MCP_TOOL_CATALOG.json +49 -8
- package/README.md +1 -1
- package/capabilities.json +139 -7
- package/dist/capabilities-data.js +138 -6
- package/dist/capabilities.cjs +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-HJVTA7SI.cjs → chunk-CKIKNZEB.cjs} +30 -30
- package/dist/{chunk-KVC5DZAP.cjs → chunk-CWSXFVF2.cjs} +88 -16
- package/dist/{chunk-A4IRIYZ5.js → chunk-L4J5EDCU.js} +2 -2
- package/dist/{chunk-K33DPJFK.js → chunk-PNMEXWYR.js} +3 -3
- package/dist/{chunk-F2TYZKJS.js → chunk-RFH4VBMX.js} +126 -2
- package/dist/{chunk-V5UGW6KZ.cjs → chunk-STUQU7AX.cjs} +301 -177
- package/dist/{chunk-EGG2RGL5.js → chunk-VHN5B7OQ.js} +82 -12
- package/dist/{chunk-SPME362B.cjs → chunk-VHNWLON6.cjs} +3 -3
- package/dist/{index-BXnhBnhN.d.cts → index-CGp16Cdm.d.cts} +9 -20
- package/dist/{index-BXnhBnhN.d.ts → index-CGp16Cdm.d.ts} +9 -20
- package/dist/{index-DxfspQR1.d.ts → index-Dv8d9p_J.d.ts} +164 -4
- package/dist/{index-CqsY5YHt.d.cts → index-MUM-uBX1.d.cts} +164 -4
- package/dist/index.cjs +84 -84
- package/dist/index.d.cts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +5 -5
- package/dist/operations/index.cjs +51 -51
- package/dist/operations/index.d.cts +5 -6
- package/dist/operations/index.d.ts +5 -6
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +12 -12
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +27 -27
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/API.md +2 -2
- package/docs/N8N-ADAPTER.md +1 -1
- package/package.json +1 -1
- package/dist/base-CHMATPq0.d.cts +0 -145
- package/dist/base-CHMATPq0.d.ts +0 -145
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVHNWLON6_cjs = require('./chunk-VHNWLON6.cjs');
|
|
4
4
|
var chunkBD4AUGCJ_cjs = require('./chunk-BD4AUGCJ.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
@@ -7132,6 +7132,25 @@ var RELATIONSHIP_MAP = {
|
|
|
7132
7132
|
"update": false,
|
|
7133
7133
|
"delete": false
|
|
7134
7134
|
}
|
|
7135
|
+
},
|
|
7136
|
+
{
|
|
7137
|
+
"resource": "time_off_requests",
|
|
7138
|
+
"apiEntity": "TimeOffRequest",
|
|
7139
|
+
"parentField": "resourceID",
|
|
7140
|
+
"parentSegment": "TimeOffRequests",
|
|
7141
|
+
"tier": "extended",
|
|
7142
|
+
"workflowResource": false,
|
|
7143
|
+
"specialOps": [
|
|
7144
|
+
"approve",
|
|
7145
|
+
"reject"
|
|
7146
|
+
],
|
|
7147
|
+
"searchCovers": null,
|
|
7148
|
+
"scopedOps": {
|
|
7149
|
+
"create": true,
|
|
7150
|
+
"query": true,
|
|
7151
|
+
"update": true,
|
|
7152
|
+
"delete": false
|
|
7153
|
+
}
|
|
7135
7154
|
}
|
|
7136
7155
|
],
|
|
7137
7156
|
"naturalKeys": {
|
|
@@ -9197,11 +9216,15 @@ var RELATIONSHIP_MAP = {
|
|
|
9197
9216
|
"apiEntity": "TimeOffRequest",
|
|
9198
9217
|
"kind": "entity",
|
|
9199
9218
|
"path": "TimeOffRequests",
|
|
9200
|
-
"parentScoped":
|
|
9219
|
+
"parentScoped": true,
|
|
9201
9220
|
"tier": "extended",
|
|
9202
9221
|
"workflowResource": false,
|
|
9203
9222
|
"group": "B",
|
|
9204
|
-
"parent":
|
|
9223
|
+
"parent": {
|
|
9224
|
+
"resource": "resources",
|
|
9225
|
+
"segment": "TimeOffRequests",
|
|
9226
|
+
"field": "resourceID"
|
|
9227
|
+
},
|
|
9205
9228
|
"children": [],
|
|
9206
9229
|
"naturalKeys": {
|
|
9207
9230
|
"hasSearch": false,
|
|
@@ -9209,8 +9232,31 @@ var RELATIONSHIP_MAP = {
|
|
|
9209
9232
|
"findBy": []
|
|
9210
9233
|
},
|
|
9211
9234
|
"blindSurfaces": null,
|
|
9212
|
-
"zoneFacts":
|
|
9213
|
-
|
|
9235
|
+
"zoneFacts": {
|
|
9236
|
+
"createGuidance": {
|
|
9237
|
+
"createOp": "time_off_requests.create",
|
|
9238
|
+
"parentScoped": true,
|
|
9239
|
+
"liveProvenPrefix": [],
|
|
9240
|
+
"unproven": true,
|
|
9241
|
+
"blocker": {
|
|
9242
|
+
"kind": "unknown",
|
|
9243
|
+
"message": "Submission is documented but has not been verified; the status must resolve uniquely to Submitted in exposed field metadata. Permissions and request fields remain subject to vendor validation.",
|
|
9244
|
+
"remedy": "Read time_off_requests.getFieldInfo to select Submitted, then preview with a known resource and valid leave request fields."
|
|
9245
|
+
},
|
|
9246
|
+
"vendorEvidence": [
|
|
9247
|
+
"Specification: POST /V1.0/Resources/{parentId}/TimeOffRequests returns OperationResultModel.",
|
|
9248
|
+
"Official TimeOffRequests entity documentation: create accepts Submitted only; https://autotask.net/help/developerhelp/Content/APIs/REST/Entities/TimeOffRequestsEntity.htm. No live validation performed."
|
|
9249
|
+
],
|
|
9250
|
+
"deleteBoundary": {
|
|
9251
|
+
"available": false,
|
|
9252
|
+
"note": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting."
|
|
9253
|
+
}
|
|
9254
|
+
}
|
|
9255
|
+
},
|
|
9256
|
+
"deleteBoundary": {
|
|
9257
|
+
"note": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting.",
|
|
9258
|
+
"proof": "spec-derived"
|
|
9259
|
+
},
|
|
9214
9260
|
"markerField": null
|
|
9215
9261
|
},
|
|
9216
9262
|
"inventory_products": {
|
|
@@ -9839,7 +9885,8 @@ var DELETE_BOUNDARY_NOTES = {
|
|
|
9839
9885
|
"tickets": "the vendor defines no DELETE for tickets (spec-derived: the vendored api-docs.json defines no DELETE on the entity's paths) \u2014 a create cannot be undone through the API; cleanup is UI-only.",
|
|
9840
9886
|
"user_defined_field_definitions": "the vendor defines no DELETE for user_defined_field_definitions (spec-derived: the vendored api-docs.json defines no DELETE on the entity's paths) \u2014 a UDF definition cannot be deleted through the API; deactivation is via isActive (vendor soft-removal); hard cleanup is UI-only.",
|
|
9841
9887
|
"user_defined_field_list_items": "the vendor defines no DELETE for user_defined_field_list_items (spec-derived: the vendored api-docs.json defines no DELETE on the standalone or parent-scoped ListItems paths) \u2014 a picklist value cannot be deleted through the API; deactivation is via isActive (vendor soft-removal); hard cleanup is UI-only.",
|
|
9842
|
-
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API."
|
|
9888
|
+
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
|
|
9889
|
+
"time_off_requests": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting."
|
|
9843
9890
|
};
|
|
9844
9891
|
var RESPONSE_DRIFT_MARKERS = {
|
|
9845
9892
|
"ticket_checklist_libraries": {
|
|
@@ -13790,6 +13837,26 @@ var CREATE_GUIDANCE = {
|
|
|
13790
13837
|
"note": null
|
|
13791
13838
|
}
|
|
13792
13839
|
},
|
|
13840
|
+
{
|
|
13841
|
+
"resource": "time_off_requests",
|
|
13842
|
+
"createOp": "time_off_requests.create",
|
|
13843
|
+
"parentScoped": true,
|
|
13844
|
+
"liveProvenPrefix": [],
|
|
13845
|
+
"unproven": true,
|
|
13846
|
+
"blocker": {
|
|
13847
|
+
"kind": "unknown",
|
|
13848
|
+
"message": "Submission is documented but has not been verified; the status must resolve uniquely to Submitted in exposed field metadata. Permissions and request fields remain subject to vendor validation.",
|
|
13849
|
+
"remedy": "Read time_off_requests.getFieldInfo to select Submitted, then preview with a known resource and valid leave request fields."
|
|
13850
|
+
},
|
|
13851
|
+
"vendorEvidence": [
|
|
13852
|
+
"Specification: POST /V1.0/Resources/{parentId}/TimeOffRequests returns OperationResultModel.",
|
|
13853
|
+
"Official TimeOffRequests entity documentation: create accepts Submitted only; https://autotask.net/help/developerhelp/Content/APIs/REST/Entities/TimeOffRequestsEntity.htm. No live validation performed."
|
|
13854
|
+
],
|
|
13855
|
+
"deleteBoundary": {
|
|
13856
|
+
"available": false,
|
|
13857
|
+
"note": "The vendor defines no DELETE for time-off requests; cancel through time_off_requests.update using the Canceled status from exposed field metadata. Cancellation is leave management, not timesheet unposting."
|
|
13858
|
+
}
|
|
13859
|
+
},
|
|
13793
13860
|
{
|
|
13794
13861
|
"resource": "user_defined_field_definitions",
|
|
13795
13862
|
"createOp": "user_defined_field_definitions.create",
|
|
@@ -13839,7 +13906,7 @@ var CREATE_GUIDANCE = {
|
|
|
13839
13906
|
}
|
|
13840
13907
|
],
|
|
13841
13908
|
"counts": {
|
|
13842
|
-
"total":
|
|
13909
|
+
"total": 103,
|
|
13843
13910
|
"byKind": {
|
|
13844
13911
|
"ok": 41,
|
|
13845
13912
|
"blind-reference": 16,
|
|
@@ -13849,7 +13916,7 @@ var CREATE_GUIDANCE = {
|
|
|
13849
13916
|
"resource-role-pair": 2,
|
|
13850
13917
|
"delete-absent": 0,
|
|
13851
13918
|
"non-mutable": 0,
|
|
13852
|
-
"unknown":
|
|
13919
|
+
"unknown": 27
|
|
13853
13920
|
}
|
|
13854
13921
|
}
|
|
13855
13922
|
};
|
|
@@ -16453,7 +16520,7 @@ async function capabilitySets() {
|
|
|
16453
16520
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
16454
16521
|
const udfCapable = /* @__PURE__ */ new Set();
|
|
16455
16522
|
const resources = /* @__PURE__ */ new Set();
|
|
16456
|
-
for (const rec of await
|
|
16523
|
+
for (const rec of await chunkVHNWLON6_cjs.loadCapabilityRecords()) {
|
|
16457
16524
|
if (rec.resource === "operations") continue;
|
|
16458
16525
|
resources.add(rec.resource);
|
|
16459
16526
|
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
@@ -16464,7 +16531,7 @@ async function capabilitySets() {
|
|
|
16464
16531
|
var derivedIndexPromise = null;
|
|
16465
16532
|
function derivedIndexLoad() {
|
|
16466
16533
|
if (derivedIndexPromise === null) {
|
|
16467
|
-
derivedIndexPromise =
|
|
16534
|
+
derivedIndexPromise = chunkVHNWLON6_cjs.loadCapabilityRecords().then((records) => {
|
|
16468
16535
|
const index = /* @__PURE__ */ new Map();
|
|
16469
16536
|
for (const rec of records) {
|
|
16470
16537
|
const declared = rec.metadata?.derivedFields;
|
|
@@ -19631,6 +19698,9 @@ var MutationBase = class extends MetaBase {
|
|
|
19631
19698
|
checks.push({ name: "duplicate-detection", ok: existingId === void 0 });
|
|
19632
19699
|
}
|
|
19633
19700
|
const warnings = existingId !== void 0 ? [`duplicate match on ${dedupFields.join(", ")} (id ${existingId}); the create would be skipped`] : [];
|
|
19701
|
+
const wouldCreate = existingId === void 0 && checks.every((check) => check.ok);
|
|
19702
|
+
const deleteBoundaryNote = wouldCreate ? DELETE_BOUNDARY_NOTES[this.config.key] : void 0;
|
|
19703
|
+
if (deleteBoundaryNote !== void 0) warnings.push(deleteBoundaryNote);
|
|
19634
19704
|
return buildDryRunResult({
|
|
19635
19705
|
operation: `${this.config.key}.createIfNotExists`,
|
|
19636
19706
|
method: "POST",
|
|
@@ -19638,7 +19708,7 @@ var MutationBase = class extends MetaBase {
|
|
|
19638
19708
|
ids: existingId !== void 0 ? [existingId] : [],
|
|
19639
19709
|
checks,
|
|
19640
19710
|
warnings,
|
|
19641
|
-
impact: { affected: 1, scope: "single-record", reversible:
|
|
19711
|
+
impact: { affected: 1, scope: "single-record", reversible: !wouldCreate || this.config.deletable !== false && DELETE_BOUNDARY_NOTES[this.config.key] === void 0 },
|
|
19642
19712
|
data
|
|
19643
19713
|
}, { redactPersonalData: this.http.redactPersonalData });
|
|
19644
19714
|
}
|
|
@@ -19750,7 +19820,7 @@ var MutationBase = class extends MetaBase {
|
|
|
19750
19820
|
path,
|
|
19751
19821
|
ids: [],
|
|
19752
19822
|
checks,
|
|
19753
|
-
impact: { affected: 1, scope: "single-record", reversible:
|
|
19823
|
+
impact: { affected: 1, scope: "single-record", reversible: !checks.every((check) => check.ok) || this.config.deletable !== false && deleteBoundaryNote === void 0 },
|
|
19754
19824
|
warnings,
|
|
19755
19825
|
data
|
|
19756
19826
|
}, { redactPersonalData: this.http.redactPersonalData });
|
|
@@ -23403,7 +23473,7 @@ function dateBucketLabel(value, bucket) {
|
|
|
23403
23473
|
var queryResourceKeysPromise = null;
|
|
23404
23474
|
function queryResourceKeys() {
|
|
23405
23475
|
if (queryResourceKeysPromise === null) {
|
|
23406
|
-
queryResourceKeysPromise =
|
|
23476
|
+
queryResourceKeysPromise = chunkVHNWLON6_cjs.loadCapabilityRecords().then((records) => {
|
|
23407
23477
|
const s = /* @__PURE__ */ new Set();
|
|
23408
23478
|
for (const rec of records) if (rec.operation === "query") s.add(rec.resource);
|
|
23409
23479
|
return s;
|
|
@@ -23525,7 +23595,7 @@ function parseTopAndLimit(opts, problems) {
|
|
|
23525
23595
|
return { top, limit };
|
|
23526
23596
|
}
|
|
23527
23597
|
async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
23528
|
-
const records = resourceKey === void 0 ? [] : await
|
|
23598
|
+
const records = resourceKey === void 0 ? [] : await chunkVHNWLON6_cjs.loadCapabilityRecords();
|
|
23529
23599
|
const record = resourceKey === void 0 ? void 0 : records.find((r) => r.resource === resourceKey && r.operation === "query");
|
|
23530
23600
|
if (record === void 0) return void 0;
|
|
23531
23601
|
const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
|
|
@@ -23870,7 +23940,7 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
|
|
|
23870
23940
|
continue;
|
|
23871
23941
|
}
|
|
23872
23942
|
const rel = RELATIONSHIP_MAP[resourceKey];
|
|
23873
|
-
if (rel !== void 0 && rel.parentScoped) {
|
|
23943
|
+
if (rel !== void 0 && rel.parentScoped && resourceKey !== "time_off_requests") {
|
|
23874
23944
|
problems.push(
|
|
23875
23945
|
`${at}.resource: "${resourceKey}" is a parent-scoped child \u2014 its get needs (parentId, id); ${opName} takes single numeric ids of TOP-LEVEL records (scoped reads: client.${camelKey(resourceKey)}.get(parentId, id))`
|
|
23876
23946
|
);
|
|
@@ -24170,7 +24240,7 @@ async function uiLink(client, input) {
|
|
|
24170
24240
|
var indexPromise = null;
|
|
24171
24241
|
function operationIndex() {
|
|
24172
24242
|
if (indexPromise === null) {
|
|
24173
|
-
indexPromise =
|
|
24243
|
+
indexPromise = chunkVHNWLON6_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
|
|
24174
24244
|
}
|
|
24175
24245
|
return indexPromise;
|
|
24176
24246
|
}
|
|
@@ -28842,7 +28912,9 @@ exports.invokeReadPages = invokeReadPages;
|
|
|
28842
28912
|
exports.invokeWrite = invokeWrite;
|
|
28843
28913
|
exports.isAutotaskError = isAutotaskError;
|
|
28844
28914
|
exports.isClosedStatus = isClosedStatus;
|
|
28915
|
+
exports.isDateYMD = isDateYMD;
|
|
28845
28916
|
exports.isDeterministicVendor500 = isDeterministicVendor500;
|
|
28917
|
+
exports.isRecord = isRecord2;
|
|
28846
28918
|
exports.joinedCompositePart = joinedCompositePart;
|
|
28847
28919
|
exports.mergeDetails = mergeDetails;
|
|
28848
28920
|
exports.mergePartialBody = mergePartialBody;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigurationItemsResource, ContactsResource, InventoryProductsResource, QuotesResource, ResourceTimeOffAdditionalResource, ResourceTimeOffBalancesResource, ResourcesResource, ServiceCallsResource, TicketChargesResource, TicketsResource, TimeOffRequestsResource, AuthenticateResource, EntityInformationResource, ModulesResource, ThresholdInformationResource, VersionResource, VersionInformationResource, ZoneInformationResource } from './chunk-
|
|
2
|
-
import { resolveConfig, HttpClient, SIMPLE_RESOURCES, GenericResource, CompaniesResource, ContractsResource, InvoicesResource, TimeEntriesResource, runWithSignal, runBounded } from './chunk-
|
|
1
|
+
import { ConfigurationItemsResource, ContactsResource, InventoryProductsResource, QuotesResource, ResourceTimeOffAdditionalResource, ResourceTimeOffBalancesResource, ResourcesResource, ServiceCallsResource, TicketChargesResource, TicketsResource, TimeOffRequestsResource, AuthenticateResource, EntityInformationResource, ModulesResource, ThresholdInformationResource, VersionResource, VersionInformationResource, ZoneInformationResource } from './chunk-RFH4VBMX.js';
|
|
2
|
+
import { resolveConfig, HttpClient, SIMPLE_RESOURCES, GenericResource, CompaniesResource, ContractsResource, InvoicesResource, TimeEntriesResource, runWithSignal, runBounded } from './chunk-VHN5B7OQ.js';
|
|
3
3
|
|
|
4
4
|
// src/client.ts
|
|
5
5
|
var AutotaskClient = class {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/capabilities.ts
|
|
2
2
|
var CAPABILITY_PLAN_HASHES = {
|
|
3
|
-
"B": "
|
|
4
|
-
"A": "
|
|
5
|
-
"operations": "
|
|
3
|
+
"B": "3dfaa99bd81e843635bafd242e5229270f259de68c6a32d483a6640402f3b187",
|
|
4
|
+
"A": "3dfaa99bd81e843635bafd242e5229270f259de68c6a32d483a6640402f3b187",
|
|
5
|
+
"operations": "3dfaa99bd81e843635bafd242e5229270f259de68c6a32d483a6640402f3b187"
|
|
6
6
|
};
|
|
7
7
|
var cached = null;
|
|
8
8
|
function loadCapabilities() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GenericResource, readTasks, parseIdentifier, AutotaskConfigError, StaleObjectError, buildDryRunResult, createNamePlan, resolveCompositeNames, addNameSibling, NotFoundError, unwrapItems, ConflictError, clientOf, compositePartLimit, invokeRead, compositePart, openTicketsOfPart, unwrapOperation, unwrapItem, ResolutionError, joinedCompositePart, runMove, resolveTicketStatusSemantics, openStatusFilter, isClosedStatus, vendorId,
|
|
2
|
-
import { loadCapabilityRecords } from './chunk-
|
|
1
|
+
import { GenericResource, readTasks, OperationNotSupportedError, parseIdentifier, AutotaskConfigError, isRecord, isDateYMD, isAutotaskError, RateLimitError, MaintenanceError, AutotaskError, StaleObjectError, buildDryRunResult, createNamePlan, resolveCompositeNames, addNameSibling, NotFoundError, unwrapItems, ConflictError, clientOf, compositePartLimit, invokeRead, compositePart, openTicketsOfPart, unwrapOperation, unwrapItem, ResolutionError, joinedCompositePart, runMove, resolveTicketStatusSemantics, openStatusFilter, isClosedStatus, vendorId, resolveLineOfBusinessChain, cachedRecordGet, uiLinkFor, refuse, queryRows, mergePartialBody, TICKET_LABEL_FIELDS, addLabelSibling, parseVendorErrors, RELATIONSHIP_MAP, cursorToPath } from './chunk-VHN5B7OQ.js';
|
|
2
|
+
import { loadCapabilityRecords } from './chunk-PNMEXWYR.js';
|
|
3
3
|
|
|
4
4
|
// src/resources/special/configuration_items.ts
|
|
5
5
|
async function fetchRecord(http, path, label, readOpts) {
|
|
@@ -1842,10 +1842,134 @@ var TimeOffRequestsResource = class extends GenericResource {
|
|
|
1842
1842
|
super(http, {
|
|
1843
1843
|
key: "time_off_requests",
|
|
1844
1844
|
resourcePath: "/V1.0/TimeOffRequests",
|
|
1845
|
+
parentScopedPath: "/V1.0/Resources/{parentId}/TimeOffRequests",
|
|
1846
|
+
parentPath: "/V1.0/Resources",
|
|
1847
|
+
parentField: "resourceID",
|
|
1848
|
+
staleField: "lastModifiedDateTime",
|
|
1849
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
1850
|
+
helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
1845
1851
|
deletable: false,
|
|
1846
1852
|
udfCapable: false
|
|
1847
1853
|
}, pageSize);
|
|
1848
1854
|
}
|
|
1855
|
+
async get(id, opts) {
|
|
1856
|
+
if (typeof opts === "number" || typeof opts === "string") {
|
|
1857
|
+
throw new OperationNotSupportedError("time_off_requests", "get");
|
|
1858
|
+
}
|
|
1859
|
+
return super.get(id, opts);
|
|
1860
|
+
}
|
|
1861
|
+
async create(a, b, c = {}) {
|
|
1862
|
+
if (typeof a !== "number" && typeof a !== "string") throw new OperationNotSupportedError("time_off_requests", "create");
|
|
1863
|
+
const parentId = parseIdentifier(a, "parentId");
|
|
1864
|
+
if (typeof parentId !== "number") throw this.writeError("create", "parentId cannot be represented safely in the numeric resourceID create body; this is an SDK create-body limit, not a vendor record-id maximum");
|
|
1865
|
+
const data = this.writePayload(b, "create");
|
|
1866
|
+
if (data.resourceID !== void 0 && data.resourceID !== parentId) throw this.writeError("create", "resourceID must equal parentId");
|
|
1867
|
+
const fields = await this.guardWriteStatus(data.status, "Submitted", "create");
|
|
1868
|
+
this.guardChoice(fields, "timeOffRequestType", data.timeOffRequestType, "create");
|
|
1869
|
+
return super.create(parentId, { ...data, resourceID: parentId }, c);
|
|
1870
|
+
}
|
|
1871
|
+
async update(a, b, c, d = {}) {
|
|
1872
|
+
if (typeof b !== "number" && typeof b !== "string") throw new OperationNotSupportedError("time_off_requests", "update");
|
|
1873
|
+
const parentId = parseIdentifier(a, "parentId");
|
|
1874
|
+
const id = parseIdentifier(b, "id");
|
|
1875
|
+
const data = this.writePayload(c, "update");
|
|
1876
|
+
await this.guardWriteStatus(data.status, "Canceled", "update");
|
|
1877
|
+
if (d.dryRun === true) {
|
|
1878
|
+
const preview = await this.runUpdateDryRun(id, data, d, parentId);
|
|
1879
|
+
if (!preview.wouldApply) return preview;
|
|
1880
|
+
return {
|
|
1881
|
+
...preview,
|
|
1882
|
+
impact: { ...preview.impact, reversible: false },
|
|
1883
|
+
warnings: [...preview.warnings, "A canceled time-off request cannot be restored through the public API."]
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
const current = await this.getScopedRaw(parentId, id, true);
|
|
1887
|
+
this.staleObjectCheck(current, d, "time_off_requests.update");
|
|
1888
|
+
return this.updateScopedRaw(parentId, id, data, d);
|
|
1889
|
+
}
|
|
1890
|
+
async getScopedRaw(parentId, id, fresh = false) {
|
|
1891
|
+
const current = await super.getScopedRaw(parentId, id, fresh);
|
|
1892
|
+
if (current.resourceID === void 0 || parseIdentifier(current.resourceID, "resourceID") !== parentId) {
|
|
1893
|
+
throw this.writeError("update", "the current request resourceID must match parentId");
|
|
1894
|
+
}
|
|
1895
|
+
if (parseIdentifier(current.id, "id") !== id) {
|
|
1896
|
+
throw this.writeError("update", "the current request id must match the requested id");
|
|
1897
|
+
}
|
|
1898
|
+
return current;
|
|
1899
|
+
}
|
|
1900
|
+
async createIfNotExists(..._args) {
|
|
1901
|
+
throw new OperationNotSupportedError("time_off_requests", "createIfNotExists");
|
|
1902
|
+
}
|
|
1903
|
+
// Cancellation permits status only; never replace a full model through PUT fallback.
|
|
1904
|
+
putFallbackEligible(_err) {
|
|
1905
|
+
return false;
|
|
1906
|
+
}
|
|
1907
|
+
writeError(operation, detail) {
|
|
1908
|
+
return new AutotaskConfigError(`time_off_requests.${operation}: ${detail}`, { operation: `time_off_requests.${operation}` });
|
|
1909
|
+
}
|
|
1910
|
+
writePayload(value, operation) {
|
|
1911
|
+
if (!isRecord(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) throw this.writeError(operation, "supply a plain object");
|
|
1912
|
+
const allowed = operation === "create" ? ["hours", "requestDate", "resourceID", "status", "timeOffRequestType"] : ["status"];
|
|
1913
|
+
for (const key of Object.keys(value)) if (!allowed.includes(key)) throw this.writeError(operation, operation === "update" ? "cancellation accepts status only" : `${key} is not a supported create field`);
|
|
1914
|
+
if (typeof value.status !== "number" || !Number.isSafeInteger(value.status)) throw this.writeError(operation, "status must be a numeric picklist id");
|
|
1915
|
+
if (operation === "create") {
|
|
1916
|
+
if (typeof value.hours !== "number" || !Number.isFinite(value.hours) || value.hours < -24 || value.hours > 24) throw this.writeError(operation, "hours must be a finite decimal in the documented range -24 to 24");
|
|
1917
|
+
const date = value.requestDate;
|
|
1918
|
+
if (typeof date !== "string" || !isDateYMD(date.slice(0, 10)) || date.length !== 10 && (!/^T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(date.slice(10)) || !Number.isFinite(Date.parse(date)))) {
|
|
1919
|
+
throw this.writeError(operation, "requestDate must be an ISO calendar date or timestamp for the single requested day");
|
|
1920
|
+
}
|
|
1921
|
+
if (typeof value.timeOffRequestType !== "number" || !Number.isSafeInteger(value.timeOffRequestType)) throw this.writeError(operation, "timeOffRequestType must be a numeric picklist id");
|
|
1922
|
+
if (value.resourceID !== void 0) {
|
|
1923
|
+
if (typeof value.resourceID !== "number") throw this.writeError(operation, "resourceID must be a numeric identifier");
|
|
1924
|
+
parseIdentifier(value.resourceID, "resourceID");
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
return { ...value, status: value.status };
|
|
1928
|
+
}
|
|
1929
|
+
async guardWriteStatus(status, label, operation) {
|
|
1930
|
+
let fields;
|
|
1931
|
+
try {
|
|
1932
|
+
fields = await this.cachedMeta("fields", `${this.resourcePath}/entityInformation/fields`, "time_off_requests.getFieldInfo", (body) => this.unwrapFields(body, "FieldInformationResultModel"), true);
|
|
1933
|
+
} catch (error) {
|
|
1934
|
+
if (isAutotaskError(error) && error.code === "ABORTED") throw error;
|
|
1935
|
+
if ((error instanceof RateLimitError || error instanceof MaintenanceError) && error.notSent === true) throw error;
|
|
1936
|
+
const detail = `status requires readable current field metadata for ${label}`;
|
|
1937
|
+
if (!isAutotaskError(error)) throw this.writeError(operation, detail);
|
|
1938
|
+
const safe = new AutotaskError(`time_off_requests.${operation}: ${detail}`, {
|
|
1939
|
+
code: error.code,
|
|
1940
|
+
category: error.category,
|
|
1941
|
+
correlationId: error.correlationId,
|
|
1942
|
+
httpStatus: error.httpStatus,
|
|
1943
|
+
nextAction: error.nextAction,
|
|
1944
|
+
operation: error.operation,
|
|
1945
|
+
retryable: error.retryable,
|
|
1946
|
+
suggestedAction: error.suggestedAction,
|
|
1947
|
+
url: error.url,
|
|
1948
|
+
...error instanceof MaintenanceError ? { details: {
|
|
1949
|
+
since: error.details?.since,
|
|
1950
|
+
retryAfterMs: error.details?.retryAfterMs
|
|
1951
|
+
} } : {}
|
|
1952
|
+
});
|
|
1953
|
+
Object.setPrototypeOf(safe, Object.getPrototypeOf(error));
|
|
1954
|
+
safe.name = error.name;
|
|
1955
|
+
if (error instanceof RateLimitError || error instanceof MaintenanceError) {
|
|
1956
|
+
Object.assign(safe, { retryAfter: error.retryAfter, notSent: error.notSent });
|
|
1957
|
+
}
|
|
1958
|
+
throw safe;
|
|
1959
|
+
}
|
|
1960
|
+
this.guardChoice(fields, "status", status, operation, label);
|
|
1961
|
+
return fields;
|
|
1962
|
+
}
|
|
1963
|
+
guardChoice(fields, name, id, operation, label) {
|
|
1964
|
+
const unavailable = () => this.writeError(operation, `${name} requires an unambiguous active exposed ${label ?? "request-type"} picklist value; inspect time_off_requests.getFieldInfo`);
|
|
1965
|
+
const rows = fields.filter((field) => isRecord(field) && field.name === name);
|
|
1966
|
+
if (rows.length !== 1 || rows[0].isPickList !== true || !Array.isArray(rows[0].picklistValues)) throw unavailable();
|
|
1967
|
+
const values = rows[0].picklistValues;
|
|
1968
|
+
const numeric = (value) => isRecord(value) && typeof value.value === "string" && /^-?\d+$/.test(value.value) && Number.isSafeInteger(Number(value.value));
|
|
1969
|
+
const named = label === void 0 ? values.filter((value) => numeric(value) && Number(value.value) === id) : values.filter((value) => isRecord(value) && typeof value.label === "string" && value.label.trim().toLowerCase() === label.toLowerCase());
|
|
1970
|
+
if (named.length !== 1 || !numeric(named[0]) || named[0].isActive !== true || Number(named[0].value) !== id) throw unavailable();
|
|
1971
|
+
if (values.filter((value) => numeric(value) && Number(value.value) === id).length !== 1) throw unavailable();
|
|
1972
|
+
}
|
|
1849
1973
|
/** Node-parity special op (hand-written in src/resources/special/time_off_requests.ts). */
|
|
1850
1974
|
approve(id, opts = {}) {
|
|
1851
1975
|
return approve(this, id, opts);
|