node-autotask 0.87.0 → 0.88.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 +4 -0
- package/MCP_TOOL_CATALOG.json +152 -9
- package/README.md +1 -1
- package/capabilities.json +546 -26
- package/dist/capabilities-data.js +545 -25
- package/dist/capabilities.cjs +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-RU4ECNQN.cjs → chunk-AB326MJO.cjs} +200 -200
- package/dist/{chunk-BD4AUGCJ.cjs → chunk-CM5O672I.cjs} +5 -4
- package/dist/{chunk-HUA4WB4N.cjs → chunk-ESKQAINP.cjs} +31 -30
- package/dist/{chunk-CUZJJCI5.cjs → chunk-GEFUSYH5.cjs} +325 -165
- package/dist/{chunk-GAFG7RHG.js → chunk-K72PPAAD.js} +312 -152
- package/dist/{chunk-NXSQXXNK.js → chunk-LGOJ2HBH.js} +3 -2
- package/dist/{chunk-G57Q7OAC.js → chunk-QKRHKLVY.js} +2 -2
- package/dist/{chunk-YVNGUGG6.cjs → chunk-SHJ7EOBW.cjs} +3 -3
- package/dist/{chunk-7NKB4UXV.js → chunk-X6VWD6WW.js} +5 -4
- package/dist/{chunk-EXNDYJPG.js → chunk-ZADTVF6M.js} +3 -3
- package/dist/{index-CsL5gGJo.d.ts → index-BFgZJsqx.d.ts} +13 -7
- package/dist/{index-Cxfr_DOD.d.cts → index-D0KHVqoO.d.cts} +29 -1
- package/dist/{index-Cxfr_DOD.d.ts → index-D0KHVqoO.d.ts} +29 -1
- package/dist/{index-DGiua9uK.d.cts → index-DsA1-2GA.d.cts} +13 -7
- package/dist/index.cjs +90 -87
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +9 -6
- package/dist/operations/index.cjs +53 -53
- package/dist/operations/index.d.cts +4 -4
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +3 -3
- package/dist/pool.cjs +13 -13
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +5 -5
- package/dist/resources/index.cjs +28 -28
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +4 -4
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/untrusted.cjs +11 -11
- package/dist/untrusted.d.cts +1 -1
- package/dist/untrusted.d.ts +1 -1
- package/dist/untrusted.js +1 -1
- package/docs/API.md +6 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { loadCapabilityRecords } from './chunk-
|
|
2
|
-
import { NoopLogger, REDACTED, deepMarkUntrusted, wrapUntrusted } from './chunk-
|
|
1
|
+
import { loadCapabilityRecords } from './chunk-ZADTVF6M.js';
|
|
2
|
+
import { NoopLogger, REDACTED, deepMarkUntrusted, wrapUntrusted } from './chunk-X6VWD6WW.js';
|
|
3
3
|
import { randomUUID, createHash } from 'crypto';
|
|
4
4
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
5
5
|
|
|
@@ -10936,6 +10936,59 @@ var RELATIONSHIP_MAP = {
|
|
|
10936
10936
|
},
|
|
10937
10937
|
"deleteBoundary": null,
|
|
10938
10938
|
"markerField": null
|
|
10939
|
+
},
|
|
10940
|
+
"inventory_locations": {
|
|
10941
|
+
"resource": "inventory_locations",
|
|
10942
|
+
"apiEntity": "InventoryLocation",
|
|
10943
|
+
"kind": "entity",
|
|
10944
|
+
"path": "InventoryLocations",
|
|
10945
|
+
"parentScoped": false,
|
|
10946
|
+
"tier": "extended",
|
|
10947
|
+
"workflowResource": false,
|
|
10948
|
+
"group": "A",
|
|
10949
|
+
"parent": null,
|
|
10950
|
+
"children": [],
|
|
10951
|
+
"naturalKeys": {
|
|
10952
|
+
"hasSearch": false,
|
|
10953
|
+
"searchCovers": null,
|
|
10954
|
+
"findBy": []
|
|
10955
|
+
},
|
|
10956
|
+
"blindSurfaces": null,
|
|
10957
|
+
"zoneFacts": {
|
|
10958
|
+
"createRequiredSet": [
|
|
10959
|
+
"locationName",
|
|
10960
|
+
"isActive"
|
|
10961
|
+
],
|
|
10962
|
+
"createGuidance": {
|
|
10963
|
+
"createOp": "inventory_locations.create",
|
|
10964
|
+
"parentScoped": false,
|
|
10965
|
+
"liveProvenPrefix": [],
|
|
10966
|
+
"unproven": true,
|
|
10967
|
+
"blocker": {
|
|
10968
|
+
"kind": "unknown",
|
|
10969
|
+
"message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
|
|
10970
|
+
"remedy": "Read current metadata, supply locationName and isActive, and preview first.",
|
|
10971
|
+
"requires": {
|
|
10972
|
+
"allOf": [
|
|
10973
|
+
"locationName",
|
|
10974
|
+
"isActive"
|
|
10975
|
+
]
|
|
10976
|
+
}
|
|
10977
|
+
},
|
|
10978
|
+
"vendorEvidence": [
|
|
10979
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
|
|
10980
|
+
],
|
|
10981
|
+
"deleteBoundary": {
|
|
10982
|
+
"available": false,
|
|
10983
|
+
"note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
10984
|
+
}
|
|
10985
|
+
}
|
|
10986
|
+
},
|
|
10987
|
+
"deleteBoundary": {
|
|
10988
|
+
"note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API.",
|
|
10989
|
+
"proof": "spec-derived"
|
|
10990
|
+
},
|
|
10991
|
+
"markerField": null
|
|
10939
10992
|
}
|
|
10940
10993
|
};
|
|
10941
10994
|
var BLIND_SURFACE_STAMPS = {
|
|
@@ -11047,7 +11100,8 @@ var DELETE_BOUNDARY_NOTES = {
|
|
|
11047
11100
|
"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.",
|
|
11048
11101
|
"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.",
|
|
11049
11102
|
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
|
|
11050
|
-
"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."
|
|
11103
|
+
"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.",
|
|
11104
|
+
"inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
11051
11105
|
};
|
|
11052
11106
|
var RESPONSE_DRIFT_MARKERS = {
|
|
11053
11107
|
"ticket_checklist_libraries": {
|
|
@@ -12483,6 +12537,15 @@ var EMPTY_REASON_STAMPS = {
|
|
|
12483
12537
|
"authority": null,
|
|
12484
12538
|
"remedy": "verify the created record by id (ticket_checklist_libraries.get) \u2014 the create may have succeeded despite the drifted envelope"
|
|
12485
12539
|
}
|
|
12540
|
+
},
|
|
12541
|
+
"inventory_locations": {
|
|
12542
|
+
"get": {
|
|
12543
|
+
"surface": "inventory_locations.get",
|
|
12544
|
+
"kind": "tenant-empty-for-user",
|
|
12545
|
+
"note": "No inventory location at this ID was visible to this API user. This is INCONCLUSIVE about tenant inventory because visibility may be limited by Inventory module access and permissions.",
|
|
12546
|
+
"authority": "inventory_locations.get",
|
|
12547
|
+
"remedy": "Verify the ID and check View permission, Inventory access and Inventory Manage Locations with an authorized user."
|
|
12548
|
+
}
|
|
12486
12549
|
}
|
|
12487
12550
|
};
|
|
12488
12551
|
var POINTER_NOTES = {
|
|
@@ -13965,6 +14028,31 @@ var CREATE_GUIDANCE = {
|
|
|
13965
14028
|
"note": null
|
|
13966
14029
|
}
|
|
13967
14030
|
},
|
|
14031
|
+
{
|
|
14032
|
+
"resource": "inventory_locations",
|
|
14033
|
+
"createOp": "inventory_locations.create",
|
|
14034
|
+
"parentScoped": false,
|
|
14035
|
+
"liveProvenPrefix": [],
|
|
14036
|
+
"unproven": true,
|
|
14037
|
+
"blocker": {
|
|
14038
|
+
"kind": "unknown",
|
|
14039
|
+
"message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
|
|
14040
|
+
"remedy": "Read current metadata, supply locationName and isActive, and preview first.",
|
|
14041
|
+
"requires": {
|
|
14042
|
+
"allOf": [
|
|
14043
|
+
"locationName",
|
|
14044
|
+
"isActive"
|
|
14045
|
+
]
|
|
14046
|
+
}
|
|
14047
|
+
},
|
|
14048
|
+
"vendorEvidence": [
|
|
14049
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
|
|
14050
|
+
],
|
|
14051
|
+
"deleteBoundary": {
|
|
14052
|
+
"available": false,
|
|
14053
|
+
"note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
14054
|
+
}
|
|
14055
|
+
},
|
|
13968
14056
|
{
|
|
13969
14057
|
"resource": "inventory_products",
|
|
13970
14058
|
"createOp": "inventory_products.create",
|
|
@@ -15545,7 +15633,7 @@ var CREATE_GUIDANCE = {
|
|
|
15545
15633
|
}
|
|
15546
15634
|
],
|
|
15547
15635
|
"counts": {
|
|
15548
|
-
"total":
|
|
15636
|
+
"total": 117,
|
|
15549
15637
|
"byKind": {
|
|
15550
15638
|
"ok": 41,
|
|
15551
15639
|
"blind-reference": 16,
|
|
@@ -15555,7 +15643,7 @@ var CREATE_GUIDANCE = {
|
|
|
15555
15643
|
"resource-role-pair": 2,
|
|
15556
15644
|
"delete-absent": 0,
|
|
15557
15645
|
"non-mutable": 0,
|
|
15558
|
-
"unknown":
|
|
15646
|
+
"unknown": 41
|
|
15559
15647
|
}
|
|
15560
15648
|
}
|
|
15561
15649
|
};
|
|
@@ -16334,6 +16422,9 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
|
|
|
16334
16422
|
"keywords",
|
|
16335
16423
|
"referenceLink",
|
|
16336
16424
|
"title"
|
|
16425
|
+
],
|
|
16426
|
+
"inventory_locations": [
|
|
16427
|
+
"locationName"
|
|
16337
16428
|
]
|
|
16338
16429
|
};
|
|
16339
16430
|
|
|
@@ -16792,22 +16883,25 @@ function auditReadTarget(path, operation) {
|
|
|
16792
16883
|
function isKnowledgeBaseRootResource(resource) {
|
|
16793
16884
|
return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
|
|
16794
16885
|
}
|
|
16795
|
-
|
|
16796
|
-
|
|
16797
|
-
|
|
16886
|
+
function isExactRecordResource(resource) {
|
|
16887
|
+
return resource === "inventory_locations" || isKnowledgeBaseRootResource(resource);
|
|
16888
|
+
}
|
|
16889
|
+
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
16890
|
+
function exactRecordResponseTarget(path, method, operation) {
|
|
16891
|
+
const match = EXACT_RECORD_PATH.exec(path);
|
|
16798
16892
|
if (match === null) return void 0;
|
|
16799
16893
|
const suffix = match[1]?.toLowerCase();
|
|
16800
16894
|
if (suffix === "query/count") return suffix;
|
|
16801
16895
|
if (suffix?.startsWith("query")) return "query";
|
|
16802
16896
|
if (suffix !== void 0 && !isAuditDecimalId(suffix)) {
|
|
16803
|
-
throw new AutotaskConfigError("
|
|
16897
|
+
throw new AutotaskConfigError("Record ID must be a non-negative signed 64-bit integer.", { operation });
|
|
16804
16898
|
}
|
|
16805
16899
|
return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
|
|
16806
16900
|
}
|
|
16807
16901
|
function isNonNegativeInt64(id) {
|
|
16808
16902
|
return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
|
|
16809
16903
|
}
|
|
16810
|
-
function
|
|
16904
|
+
function validateExactRecordResponse(body, target, path, method, requestBody, operation) {
|
|
16811
16905
|
const invalid = (message) => {
|
|
16812
16906
|
throw new AutotaskError(message, { code: "INVALID_RESPONSE", category: "server", operation, suggestedAction: INVALID_SHAPE_ACTION });
|
|
16813
16907
|
};
|
|
@@ -16817,15 +16911,15 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
|
|
|
16817
16911
|
}
|
|
16818
16912
|
if (target === "query") {
|
|
16819
16913
|
if (!isRecord2(body) || !Array.isArray(body.items) || !isRecord2(body.pageDetails)) {
|
|
16820
|
-
return invalid("Expected a
|
|
16914
|
+
return invalid("Expected a query page with paging details");
|
|
16821
16915
|
}
|
|
16822
|
-
if (!body.items.every(hasExactRecordId)) invalid("Expected valid record IDs in the
|
|
16916
|
+
if (!body.items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
|
|
16823
16917
|
if (body.pageDetails.count !== body.items.length) {
|
|
16824
|
-
invalid("The
|
|
16918
|
+
invalid("The page record count did not match its rows");
|
|
16825
16919
|
}
|
|
16826
16920
|
const cursor = body.pageDetails.nextPageUrl;
|
|
16827
16921
|
if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
|
|
16828
|
-
invalid("Expected a valid
|
|
16922
|
+
invalid("Expected a valid query cursor or an explicit end of results");
|
|
16829
16923
|
}
|
|
16830
16924
|
return;
|
|
16831
16925
|
}
|
|
@@ -16833,7 +16927,7 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
|
|
|
16833
16927
|
const expectedId = parts.at(-1);
|
|
16834
16928
|
if (target === "mutation") {
|
|
16835
16929
|
const id = isRecord2(body) ? body.itemId === void 0 ? body.id : body.itemId : void 0;
|
|
16836
|
-
if (!isNonNegativeInt64(id)) invalid("Expected a valid
|
|
16930
|
+
if (!isNonNegativeInt64(id)) invalid("Expected a valid mutation receipt");
|
|
16837
16931
|
const expected = method === "DELETE" ? expectedId : isRecord2(requestBody) ? requestBody.id : void 0;
|
|
16838
16932
|
if (expected !== void 0 && String(id) !== String(expected)) {
|
|
16839
16933
|
invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
|
|
@@ -16843,9 +16937,10 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
|
|
|
16843
16937
|
const item = isRecord2(body) ? body.item : void 0;
|
|
16844
16938
|
if (item === null) return;
|
|
16845
16939
|
if (!isRecord2(item) || !isNonNegativeInt64(item.id)) {
|
|
16846
|
-
return invalid("Expected
|
|
16940
|
+
return invalid("Expected an item envelope with a valid record ID");
|
|
16847
16941
|
}
|
|
16848
|
-
const
|
|
16942
|
+
const entity = parts.at(-2)?.toLowerCase();
|
|
16943
|
+
const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
|
|
16849
16944
|
if (String(item.id) !== expectedId) {
|
|
16850
16945
|
throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
|
|
16851
16946
|
}
|
|
@@ -16859,16 +16954,16 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
|
|
|
16859
16954
|
}
|
|
16860
16955
|
}
|
|
16861
16956
|
}
|
|
16862
|
-
function
|
|
16957
|
+
function serializeExactRecordUpdate(body, operation) {
|
|
16863
16958
|
if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
|
|
16864
16959
|
if (!isAuditDecimalId(body.id)) {
|
|
16865
|
-
throw new AutotaskConfigError("
|
|
16960
|
+
throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
|
|
16866
16961
|
}
|
|
16867
16962
|
const { rawJSON } = JSON;
|
|
16868
16963
|
return JSON.stringify({ ...body, id: rawJSON(body.id) });
|
|
16869
16964
|
}
|
|
16870
|
-
function decodeResponseJson(text, auditTarget,
|
|
16871
|
-
const target = auditTarget ??
|
|
16965
|
+
function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
16966
|
+
const target = auditTarget ?? recordTarget;
|
|
16872
16967
|
if (target === void 0) return JSON.parse(text);
|
|
16873
16968
|
if (target === "query/count") {
|
|
16874
16969
|
return JSON.parse(text, (key, value, context) => key === "queryCount" && typeof value === "number" && !isAuditDecimalId(context?.source ?? "") ? null : value);
|
|
@@ -16928,9 +17023,9 @@ function attachEmptyReasonDetails(err) {
|
|
|
16928
17023
|
const resource = err.operation.slice(0, dot);
|
|
16929
17024
|
const op = err.operation.slice(dot + 1);
|
|
16930
17025
|
const surface = err.operation;
|
|
16931
|
-
const stamp = EMPTY_REASON_STAMPS[resource]?.[op];
|
|
16932
|
-
const pointer = POINTER_NOTES[surface];
|
|
16933
17026
|
const isGetMiss = err instanceof NotFoundError && op === "get";
|
|
17027
|
+
const stamp = op !== "get" || isGetMiss ? EMPTY_REASON_STAMPS[resource]?.[op] : void 0;
|
|
17028
|
+
const pointer = POINTER_NOTES[surface];
|
|
16934
17029
|
if (stamp === void 0 && pointer === void 0 && !isGetMiss) return;
|
|
16935
17030
|
err.details = { ...err.details ?? {} };
|
|
16936
17031
|
if (stamp !== void 0) {
|
|
@@ -17042,7 +17137,7 @@ function normalizeZoneBase(raw) {
|
|
|
17042
17137
|
return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
|
|
17043
17138
|
}
|
|
17044
17139
|
function canReResolveZone(reResolveZoneOn401, zone, opts) {
|
|
17045
|
-
if (!reResolveZoneOn401) return false;
|
|
17140
|
+
if (!reResolveZoneOn401 || opts.checkedBaseUrl !== void 0) return false;
|
|
17046
17141
|
if (zone === void 0 || zone === "other") return false;
|
|
17047
17142
|
if (!opts.path.startsWith("/") || /^https?:\/\//i.test(opts.path)) return false;
|
|
17048
17143
|
return true;
|
|
@@ -17435,6 +17530,7 @@ var HttpClient = class {
|
|
|
17435
17530
|
if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
|
|
17436
17531
|
this.gate(s, false);
|
|
17437
17532
|
if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
|
|
17533
|
+
this.assertCheckedBase(opts);
|
|
17438
17534
|
const admission = admitHourlyAttempt(s.url, this.hourly, Date.now());
|
|
17439
17535
|
if (!admission.admitted) {
|
|
17440
17536
|
releaseCurrent();
|
|
@@ -17511,13 +17607,13 @@ var HttpClient = class {
|
|
|
17511
17607
|
}
|
|
17512
17608
|
let parsed;
|
|
17513
17609
|
try {
|
|
17514
|
-
parsed = decodeResponseJson(text, s.auditTarget, s.
|
|
17610
|
+
parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget);
|
|
17515
17611
|
} catch {
|
|
17516
17612
|
return this.handleNonJson2xx(s, res, status, text);
|
|
17517
17613
|
}
|
|
17518
17614
|
validateAuditResponse(parsed, s.auditTarget, opts.operation);
|
|
17519
|
-
if (s.
|
|
17520
|
-
|
|
17615
|
+
if (s.recordTarget !== void 0) {
|
|
17616
|
+
validateExactRecordResponse(parsed, s.recordTarget, decodeURIComponent(opts.path), method, opts.body, opts.operation);
|
|
17521
17617
|
}
|
|
17522
17618
|
return {
|
|
17523
17619
|
done: true,
|
|
@@ -17704,6 +17800,13 @@ var HttpClient = class {
|
|
|
17704
17800
|
this.readCache?.clear();
|
|
17705
17801
|
if (/\/V1\.0\/Companies(?:\/[^/]+)?(?:\?|$)/i.test(opts.path)) invalidateCompanyIndex(this);
|
|
17706
17802
|
}
|
|
17803
|
+
assertCheckedBase(opts) {
|
|
17804
|
+
const baseUrl = this.baseUrl;
|
|
17805
|
+
if (opts.checkedBaseUrl !== void 0 && opts.checkedBaseUrl !== baseUrl) {
|
|
17806
|
+
throw new AutotaskConfigError("The Autotask zone changed after preflight. Preview or check the target again.", { operation: opts.operation });
|
|
17807
|
+
}
|
|
17808
|
+
return baseUrl;
|
|
17809
|
+
}
|
|
17707
17810
|
/**
|
|
17708
17811
|
* One request: build URL/headers, apply the whole-call deadline, retry
|
|
17709
17812
|
* idempotent methods on 429/5xx, map failures to the typed errors.
|
|
@@ -17711,8 +17814,9 @@ var HttpClient = class {
|
|
|
17711
17814
|
*/
|
|
17712
17815
|
async request(opts) {
|
|
17713
17816
|
const method = opts.method;
|
|
17714
|
-
const
|
|
17715
|
-
const
|
|
17817
|
+
const baseUrl = this.assertCheckedBase(opts);
|
|
17818
|
+
const url = buildUrl(baseUrl, opts.path, opts.query);
|
|
17819
|
+
const wirePath = url.slice(baseUrl.length);
|
|
17716
17820
|
const path = wirePath.split("?", 1)[0];
|
|
17717
17821
|
const route = decodeURIComponent(path);
|
|
17718
17822
|
const auditTarget = auditReadTarget(route, opts.operation);
|
|
@@ -17722,13 +17826,14 @@ var HttpClient = class {
|
|
|
17722
17826
|
const queryRoute = /\/query(?:\/|$)/i.test(route);
|
|
17723
17827
|
const getQuery = method === "GET" && queryRoute && requestUrl.search !== "";
|
|
17724
17828
|
if (getQuery) assertGetQueryUrlLength(url);
|
|
17725
|
-
const
|
|
17726
|
-
const
|
|
17727
|
-
const bodyText =
|
|
17829
|
+
const recordTarget = exactRecordResponseTarget(route, method, opts.operation);
|
|
17830
|
+
const exactRecordUpdate = recordTarget === "mutation" && (method === "PUT" || method === "PATCH");
|
|
17831
|
+
const bodyText = exactRecordUpdate && opts.body !== void 0 ? serializeExactRecordUpdate(opts.body, opts.operation) : opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
|
|
17728
17832
|
if (queryRoute) {
|
|
17729
17833
|
const audit = auditTarget === "query" || auditTarget === "query/count";
|
|
17730
|
-
const
|
|
17731
|
-
const
|
|
17834
|
+
const exactRecord = recordTarget === "query" || recordTarget === "query/count";
|
|
17835
|
+
const recordLabel = /^\/v1\.0\/InventoryLocations\//i.test(route) ? "inventory location" : "Knowledge Base record";
|
|
17836
|
+
const exactIdLabel = audit ? "audit log" : exactRecord ? recordLabel : void 0;
|
|
17732
17837
|
assertQueryFilters(opts, requestUrl, bodyText, exactIdLabel);
|
|
17733
17838
|
}
|
|
17734
17839
|
opts = { ...opts, path };
|
|
@@ -17744,7 +17849,7 @@ var HttpClient = class {
|
|
|
17744
17849
|
getQuery,
|
|
17745
17850
|
method,
|
|
17746
17851
|
auditTarget,
|
|
17747
|
-
|
|
17852
|
+
recordTarget,
|
|
17748
17853
|
url,
|
|
17749
17854
|
headers,
|
|
17750
17855
|
bodyText,
|
|
@@ -18325,13 +18430,13 @@ async function runBounded(fn, items, opts) {
|
|
|
18325
18430
|
const results = new Array(items.length);
|
|
18326
18431
|
let next = 0;
|
|
18327
18432
|
let failure;
|
|
18328
|
-
const
|
|
18433
|
+
const fail4 = (error, index) => {
|
|
18329
18434
|
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
18330
18435
|
};
|
|
18331
18436
|
const worker = async () => {
|
|
18332
18437
|
while (failure === void 0 && next < items.length) {
|
|
18333
18438
|
if (signal?.aborted) {
|
|
18334
|
-
|
|
18439
|
+
fail4(signal.reason, -1);
|
|
18335
18440
|
return;
|
|
18336
18441
|
}
|
|
18337
18442
|
const i = next++;
|
|
@@ -18341,7 +18446,7 @@ async function runBounded(fn, items, opts) {
|
|
|
18341
18446
|
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
18342
18447
|
} catch (error) {
|
|
18343
18448
|
if (settle) results[i] = { status: "rejected", reason: error };
|
|
18344
|
-
else
|
|
18449
|
+
else fail4(error, i);
|
|
18345
18450
|
}
|
|
18346
18451
|
}
|
|
18347
18452
|
};
|
|
@@ -19690,6 +19795,23 @@ function notPersistedFields(sent, stored) {
|
|
|
19690
19795
|
return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== REDACTED && !same(value, stored[key])).map(([key]) => key);
|
|
19691
19796
|
}
|
|
19692
19797
|
|
|
19798
|
+
// src/resources/special/inventoryLocations.ts
|
|
19799
|
+
var fail = (message) => {
|
|
19800
|
+
throw new AutotaskConfigError(`inventory_locations: ${message}`);
|
|
19801
|
+
};
|
|
19802
|
+
function admitInventoryLocation(value, creating) {
|
|
19803
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
19804
|
+
const body = { ...value };
|
|
19805
|
+
for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
|
|
19806
|
+
if ((creating || Object.hasOwn(body, "locationName")) && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail("locationName is required and must be a nonblank string of at most 50 characters");
|
|
19807
|
+
if ((creating || Object.hasOwn(body, "isActive")) && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
|
|
19808
|
+
if (!creating && !Object.keys(body).length) fail("update must contain locationName or isActive");
|
|
19809
|
+
return body;
|
|
19810
|
+
}
|
|
19811
|
+
function checkInventoryLocationCurrent(value, current) {
|
|
19812
|
+
if (value.isActive === false && current.isDefault !== false) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
|
|
19813
|
+
}
|
|
19814
|
+
|
|
19693
19815
|
// src/resources/base/types.ts
|
|
19694
19816
|
var BOUNDED_QUERY_DEFAULT_LIMIT = 500;
|
|
19695
19817
|
var BOUNDED_QUERY_MAX_LIMIT = 2500;
|
|
@@ -19856,6 +19978,7 @@ var MODEL_FIELD_SETS = {
|
|
|
19856
19978
|
"expense_reports": ["id", "amountDue", "approvedDate", "approverID", "departmentNumber", "internalCurrencyCashAdvanceAmount", "internalCurrencyExpenseTotal", "name", "organizationalLevelAssociationID", "quickBooksReferenceNumber", "reimbursementCurrencyAmountDue", "reimbursementCurrencyCashAdvanceAmount", "reimbursementCurrencyID", "rejectionReason", "status", "submit", "submitDate", "submitterID", "weekEnding"],
|
|
19857
19979
|
"holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
|
|
19858
19980
|
"holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
|
|
19981
|
+
"inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
|
|
19859
19982
|
"inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
|
|
19860
19983
|
"invoice_templates": ["id", "coveredByBlockRetainerContractLabel", "coveredByRecurringServiceFixedPricePerTicketContractLabel", "currencyNegativeFormat", "currencyPositiveFormat", "dateFormat", "displayFixedPriceContractLabor", "displayRecurringServiceContractLabor", "displaySeparateLineItemForEachTax", "displayTaxCategory", "displayTaxCategorySuperscripts", "displayZeroAmountRecurringServicesAndBundles", "groupBy", "itemizeItemsInEachGroup", "itemizeServicesAndBundles", "name", "nonBillableLaborLabel", "numberFormat", "pageLayout", "pageNumberFormat", "paymentTerms", "rateCostExpression", "showGridHeader", "showVerticalGridLines", "sortBy", "timeFormat"],
|
|
19861
19984
|
"invoices": ["id", "batchID", "comments", "companyID", "createDateTime", "creatorResourceID", "dueDate", "fromDate", "invoiceDateTime", "invoiceEditorTemplateID", "invoiceNumber", "invoiceTotal", "isVoided", "orderNumber", "paidDate", "paymentTerm", "taxGroup", "taxRegionName", "toDate", "totalTaxValue", "voidedByResourceID", "voidedDate", "webServiceDate"],
|
|
@@ -20095,21 +20218,21 @@ function validateRelationLeaves(resourceKey, conditions, op) {
|
|
|
20095
20218
|
assertUndottedUdfField(c, op);
|
|
20096
20219
|
const field = c.field;
|
|
20097
20220
|
const [rel, sub, ...rest] = field.split(".");
|
|
20098
|
-
const
|
|
20221
|
+
const fail4 = (why) => {
|
|
20099
20222
|
throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
|
|
20100
20223
|
operation: op,
|
|
20101
20224
|
suggestedAction: valid.length > 0 ? `Use ${valid.map((r) => `${r}.<${RELATION_TARGETS[r].resource} field>`).join(" or ")} (one hop; field names from operations.fieldCatalog).` : `${resourceKey} has no relation filters; filter on its own fields.`
|
|
20102
20225
|
});
|
|
20103
20226
|
};
|
|
20104
20227
|
if (selfPrefixes(resourceKey).includes(rel)) {
|
|
20105
|
-
if (rest.length > 0 || !sub)
|
|
20228
|
+
if (rest.length > 0 || !sub) fail4("is not <resource>.<field> (multi-hop relations are not supported)");
|
|
20106
20229
|
continue;
|
|
20107
20230
|
}
|
|
20108
|
-
if (rest.length > 0 || !sub)
|
|
20109
|
-
if (!valid.includes(rel))
|
|
20231
|
+
if (rest.length > 0 || !sub) fail4("is not <relation>.<field> (multi-hop relations are not supported)");
|
|
20232
|
+
if (!valid.includes(rel)) fail4(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
|
|
20110
20233
|
const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
|
|
20111
20234
|
if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
|
|
20112
|
-
|
|
20235
|
+
fail4(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
|
|
20113
20236
|
}
|
|
20114
20237
|
}
|
|
20115
20238
|
};
|
|
@@ -20437,7 +20560,7 @@ var QueryBase = class {
|
|
|
20437
20560
|
}
|
|
20438
20561
|
continueAcrossEmptyPage() {
|
|
20439
20562
|
const { key } = this.config;
|
|
20440
|
-
return isAuditLogResource(key) ||
|
|
20563
|
+
return isAuditLogResource(key) || isExactRecordResource(key);
|
|
20441
20564
|
}
|
|
20442
20565
|
/** @internal */
|
|
20443
20566
|
readPage(body, page, pageSize, state2) {
|
|
@@ -20834,7 +20957,7 @@ var QueryBase = class {
|
|
|
20834
20957
|
}
|
|
20835
20958
|
if (total <= BOUNDED_QUERY_MAX_LIMIT) {
|
|
20836
20959
|
const { items: items2, pages: pages3, guard: guard2, sliced: sliced2, cursor: cursor2 } = await this.walkBounded(params, total);
|
|
20837
|
-
if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.
|
|
20960
|
+
if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.hasCompleteExactRecordWindow(items2, total)) {
|
|
20838
20961
|
throw this.latestWindowIncompleteError(total);
|
|
20839
20962
|
}
|
|
20840
20963
|
return this.finishLatest(items2, latest, pages3);
|
|
@@ -20843,11 +20966,11 @@ var QueryBase = class {
|
|
|
20843
20966
|
probes += 1;
|
|
20844
20967
|
if (probes > LATEST_MAX_COUNT_PROBES) throw this.latestThresholdUnresolvedError();
|
|
20845
20968
|
};
|
|
20846
|
-
const
|
|
20847
|
-
let lo =
|
|
20969
|
+
const exactRecord = isExactRecordResource(this.config.key);
|
|
20970
|
+
let lo = exactRecord ? -1n : 0n;
|
|
20848
20971
|
let hi;
|
|
20849
20972
|
let aboveThreshold = 0;
|
|
20850
|
-
if (isAuditLogResource(this.config.key) ||
|
|
20973
|
+
if (isAuditLogResource(this.config.key) || exactRecord) {
|
|
20851
20974
|
hi = BigInt(MAX_AUDIT_ID);
|
|
20852
20975
|
} else {
|
|
20853
20976
|
for (let t = 1n; ; t = t << 1n) {
|
|
@@ -20868,17 +20991,17 @@ var QueryBase = class {
|
|
|
20868
20991
|
aboveThreshold = above;
|
|
20869
20992
|
} else lo = mid;
|
|
20870
20993
|
}
|
|
20871
|
-
if (
|
|
20994
|
+
if (exactRecord && aboveThreshold !== latest) throw this.latestWindowIncompleteError(latest + 1);
|
|
20872
20995
|
const windowValue = hi <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(hi) : hi.toString();
|
|
20873
20996
|
const window = [...baseConds, { op: "gte", field: "id", value: windowValue }];
|
|
20874
20997
|
const { items, pages: pages2, guard, sliced, cursor } = await this.walkBounded({ ...params, filter: window }, latest + 1);
|
|
20875
|
-
if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.
|
|
20998
|
+
if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.hasCompleteExactRecordWindow(items, latest + 1, hi)) {
|
|
20876
20999
|
throw this.latestWindowIncompleteError(latest + 1);
|
|
20877
21000
|
}
|
|
20878
21001
|
return this.finishLatest(items, latest, pages2);
|
|
20879
21002
|
}
|
|
20880
|
-
|
|
20881
|
-
if (!
|
|
21003
|
+
hasCompleteExactRecordWindow(items, expected, minimum) {
|
|
21004
|
+
if (!isExactRecordResource(this.config.key)) return true;
|
|
20882
21005
|
if (items.length !== expected) return false;
|
|
20883
21006
|
const ids2 = items.map((item) => String(item.id));
|
|
20884
21007
|
if (new Set(ids2).size !== expected) return false;
|
|
@@ -21025,10 +21148,12 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21025
21148
|
return cachedMetadataGet(this.http, this.config.key, kind, path, operation, unwrap, fresh, maxRetries);
|
|
21026
21149
|
}
|
|
21027
21150
|
/** `GET /V1.0/<E>/{id}` → `{ item }` unwrapped (`item: null` → NotFoundError). */
|
|
21028
|
-
async getGlobal(id, fresh = false, maxRetries) {
|
|
21151
|
+
async getGlobal(id, fresh = false, maxRetries, checkedBaseUrl) {
|
|
21029
21152
|
const numeric2 = parseIdentifier(id, "id");
|
|
21030
|
-
const
|
|
21031
|
-
|
|
21153
|
+
const path = `${this.resourcePath}/${numeric2}`;
|
|
21154
|
+
const operation = `${this.config.key}.get`;
|
|
21155
|
+
const res = checkedBaseUrl === void 0 ? await this.cachedGet(path, operation, fresh, maxRetries) : await this.http.request({ method: "GET", path, operation, maxRetries, checkedBaseUrl });
|
|
21156
|
+
return unwrapItem(res, numeric2, operation, this.entityName);
|
|
21032
21157
|
}
|
|
21033
21158
|
/**
|
|
21034
21159
|
* V2 merge read: a FRESH single-record GET that skips response redaction
|
|
@@ -21545,26 +21670,26 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21545
21670
|
|
|
21546
21671
|
// src/resources/special/knowledgeBaseCategories.ts
|
|
21547
21672
|
function admitKnowledgeBaseCategory(data, creating, staleToken) {
|
|
21548
|
-
const
|
|
21673
|
+
const fail4 = (message) => {
|
|
21549
21674
|
throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
|
|
21550
21675
|
};
|
|
21551
|
-
if (!creating && staleToken !== void 0)
|
|
21552
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
21676
|
+
if (!creating && staleToken !== void 0) fail4("no documented stale timestamp is available");
|
|
21677
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
21553
21678
|
const body = { ...data };
|
|
21554
|
-
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field))
|
|
21679
|
+
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail4(`${field} is not a writable KnowledgeBaseCategories field`);
|
|
21555
21680
|
for (const [field, max] of [["name", 50], ["description", 1e3]]) {
|
|
21556
21681
|
const value = body[field];
|
|
21557
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > max))
|
|
21682
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail4(`${field} must be a string of at most ${max} characters`);
|
|
21558
21683
|
}
|
|
21559
|
-
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === ""))
|
|
21560
|
-
if (creating && body.parentCategoryID === void 0)
|
|
21684
|
+
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail4("name is required");
|
|
21685
|
+
if (creating && body.parentCategoryID === void 0) fail4("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
|
|
21561
21686
|
const parent = body.parentCategoryID;
|
|
21562
21687
|
if (parent !== void 0) {
|
|
21563
|
-
if (typeof parent !== "number") return
|
|
21688
|
+
if (typeof parent !== "number") return fail4("parentCategoryID must be a numeric identifier");
|
|
21564
21689
|
parseIdentifier(parent, "parentCategoryID");
|
|
21565
|
-
if (parent > 2147483647)
|
|
21690
|
+
if (parent > 2147483647) fail4("parentCategoryID must fit a signed 32-bit integer");
|
|
21566
21691
|
}
|
|
21567
|
-
if (!creating && !Object.values(body).some((value) => value !== void 0))
|
|
21692
|
+
if (!creating && !Object.values(body).some((value) => value !== void 0)) fail4("update must contain a writable field");
|
|
21568
21693
|
return body;
|
|
21569
21694
|
}
|
|
21570
21695
|
function categoryReplacement(body) {
|
|
@@ -21578,45 +21703,45 @@ function categoryReplacement(body) {
|
|
|
21578
21703
|
}
|
|
21579
21704
|
|
|
21580
21705
|
// src/resources/special/knowledgeBaseArticles.ts
|
|
21581
|
-
function
|
|
21706
|
+
function fail2(detail) {
|
|
21582
21707
|
throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
|
|
21583
21708
|
}
|
|
21584
21709
|
function reference(value, name) {
|
|
21585
|
-
if (typeof value !== "number")
|
|
21710
|
+
if (typeof value !== "number") fail2(`${name} must be a numeric identifier`);
|
|
21586
21711
|
parseIdentifier(value, name);
|
|
21587
|
-
if (value > 2147483647)
|
|
21712
|
+
if (value > 2147483647) fail2(`${name} must fit a signed 32-bit integer`);
|
|
21588
21713
|
return value;
|
|
21589
21714
|
}
|
|
21590
21715
|
function articleParent(value) {
|
|
21591
21716
|
const parent = parseIdentifier(value, "parentId");
|
|
21592
|
-
if (typeof parent !== "number" || parent > 2147483647)
|
|
21593
|
-
if (parent === 0)
|
|
21717
|
+
if (typeof parent !== "number" || parent > 2147483647) fail2("parentId must fit a signed 32-bit category identifier");
|
|
21718
|
+
if (parent === 0) fail2("parentId must name an article category");
|
|
21594
21719
|
return parent;
|
|
21595
21720
|
}
|
|
21596
21721
|
function admitArticle(data, parentId, creating) {
|
|
21597
21722
|
const parent = articleParent(parentId);
|
|
21598
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
21723
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
|
|
21599
21724
|
const body = { ...data };
|
|
21600
21725
|
const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
|
|
21601
21726
|
for (const key of Object.keys(body)) {
|
|
21602
|
-
if (!allowed.includes(key))
|
|
21727
|
+
if (!allowed.includes(key)) fail2(`${key} is not a writable article root field`);
|
|
21603
21728
|
if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
|
|
21604
21729
|
}
|
|
21605
21730
|
for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
|
|
21606
|
-
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max))
|
|
21607
|
-
}
|
|
21608
|
-
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim()))
|
|
21609
|
-
if (!creating && Object.hasOwn(body, "articleCategoryID"))
|
|
21610
|
-
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent))
|
|
21611
|
-
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647))
|
|
21612
|
-
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean")
|
|
21613
|
-
if (!creating && !Object.keys(body).length)
|
|
21731
|
+
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail2(`${field} must be a string of at most ${max} characters`);
|
|
21732
|
+
}
|
|
21733
|
+
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail2("title is required and cannot be blank");
|
|
21734
|
+
if (!creating && Object.hasOwn(body, "articleCategoryID")) fail2("articleCategoryID is read-only after creation");
|
|
21735
|
+
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail2("articleCategoryID must match parentId");
|
|
21736
|
+
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647)) fail2("publish must be an int32 from current field metadata");
|
|
21737
|
+
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail2("isActive must be boolean");
|
|
21738
|
+
if (!creating && !Object.keys(body).length) fail2("update must contain a writable field");
|
|
21614
21739
|
return body;
|
|
21615
21740
|
}
|
|
21616
21741
|
async function guardArticle(http, parentId, id, maxRetries) {
|
|
21617
21742
|
const parent = articleParent(parentId);
|
|
21618
21743
|
const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
|
|
21619
|
-
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target))))
|
|
21744
|
+
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail2("id must name an article within the signed 64-bit range");
|
|
21620
21745
|
unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
|
|
21621
21746
|
if (target !== void 0) {
|
|
21622
21747
|
return unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}/KnowledgeBaseArticles/${target}`, operation: "knowledge_base_articles.get", maxRetries }), target, "knowledge_base_articles.get", "article");
|
|
@@ -21625,7 +21750,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
|
|
|
21625
21750
|
}
|
|
21626
21751
|
function assertArticlePublish(data, fields) {
|
|
21627
21752
|
if (!Object.hasOwn(data, "publish")) return;
|
|
21628
|
-
const unavailable = () =>
|
|
21753
|
+
const unavailable = () => fail2("publish requires an unambiguous active value in current field metadata");
|
|
21629
21754
|
if (!Array.isArray(fields)) unavailable();
|
|
21630
21755
|
const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
|
|
21631
21756
|
if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
|
|
@@ -21831,23 +21956,27 @@ var MutationBase = class extends MetaBase {
|
|
|
21831
21956
|
* write already happened, so a failed read-back is reported on the result
|
|
21832
21957
|
* (`persistedCheckFailed`: the error code, or `UNKNOWN (<error name>)`), never thrown.
|
|
21833
21958
|
*/
|
|
21834
|
-
async withPersistedCheck(result, data, opts, id, parentId) {
|
|
21959
|
+
async withPersistedCheck(result, data, opts, id, parentId, checkedBaseUrl) {
|
|
21835
21960
|
if (opts.verifyPersisted !== true) return result;
|
|
21836
|
-
const maxRetries =
|
|
21961
|
+
const maxRetries = isExactRecordResource(this.config.key) ? opts.maxRetries : void 0;
|
|
21837
21962
|
try {
|
|
21838
|
-
const stored = parentId === void 0 ? await this.getGlobal(id, true, maxRetries) : this.config.attachmentGet === true ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true, maxRetries);
|
|
21839
|
-
|
|
21963
|
+
const stored = parentId === void 0 ? await this.getGlobal(id, true, maxRetries, checkedBaseUrl) : this.config.attachmentGet === true ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true, maxRetries);
|
|
21964
|
+
const submitted = data;
|
|
21965
|
+
const persisted = stored;
|
|
21966
|
+
const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
21967
|
+
return { ...result, notPersisted };
|
|
21840
21968
|
} catch (err) {
|
|
21841
21969
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
21842
21970
|
}
|
|
21843
21971
|
}
|
|
21844
|
-
async updateGlobal(id, data, opts = {}, method = "PUT") {
|
|
21972
|
+
async updateGlobal(id, data, opts = {}, method = "PUT", checkedBaseUrl) {
|
|
21845
21973
|
const numeric2 = parseIdentifier(id, "id");
|
|
21846
21974
|
const operation = `${this.config.key}.update`;
|
|
21847
21975
|
let body = this.normalizeMutationBody(data);
|
|
21848
|
-
const
|
|
21976
|
+
const partialCollection = checkedBaseUrl !== void 0;
|
|
21977
|
+
const collectionUpdate = partialCollection || this.config.collectionUpdate === true;
|
|
21849
21978
|
if (collectionUpdate) {
|
|
21850
|
-
if (opts.raw !== true) {
|
|
21979
|
+
if (!partialCollection && opts.raw !== true) {
|
|
21851
21980
|
let current;
|
|
21852
21981
|
try {
|
|
21853
21982
|
current = await this.getGlobalUnredacted(numeric2, { maxRetries: opts.maxRetries });
|
|
@@ -21871,7 +22000,9 @@ var MutationBase = class extends MetaBase {
|
|
|
21871
22000
|
path: collectionUpdate ? this.resourcePath : `${this.resourcePath}/${numeric2}`,
|
|
21872
22001
|
body,
|
|
21873
22002
|
operation,
|
|
21874
|
-
maxRetries: opts.maxRetries
|
|
22003
|
+
maxRetries: opts.maxRetries,
|
|
22004
|
+
// The preflight facts must be checked again before any later PATCH.
|
|
22005
|
+
...partialCollection ? { maintenanceMaxWaitMs: 0, checkedBaseUrl } : {}
|
|
21875
22006
|
});
|
|
21876
22007
|
} catch (err) {
|
|
21877
22008
|
if (method === "PATCH" || !this.putFallbackEligible(err)) throw err;
|
|
@@ -21898,7 +22029,7 @@ var MutationBase = class extends MetaBase {
|
|
|
21898
22029
|
}
|
|
21899
22030
|
return this.withPersistedCheck(unwrapOperation(retry, operation), data, opts, numeric2);
|
|
21900
22031
|
}
|
|
21901
|
-
return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2);
|
|
22032
|
+
return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2, void 0, checkedBaseUrl);
|
|
21902
22033
|
}
|
|
21903
22034
|
/** `DELETE /V1.0/<E>/{id}` → `{ id }` (OperationResultModel). A blank 2xx
|
|
21904
22035
|
* (204 / empty body) is a valid vendor delete answer — synthesize the
|
|
@@ -22208,21 +22339,22 @@ var MutationBase = class extends MetaBase {
|
|
|
22208
22339
|
* check (mismatch throws STALE_OBJECT) and the best-effort `diff`. NO
|
|
22209
22340
|
* mutating request is issued.
|
|
22210
22341
|
*/
|
|
22211
|
-
async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord) {
|
|
22342
|
+
async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord, partialCollection) {
|
|
22212
22343
|
const operation = `${this.config.key}.update`;
|
|
22213
22344
|
const checks = [];
|
|
22214
22345
|
const warnings = [];
|
|
22215
22346
|
checks.push({ name: "input-validation", ok: isRecord2(data) && Object.keys(data).length > 0 });
|
|
22216
22347
|
const scopedUpdate = parentId !== void 0 && this.config.parentScopedPath !== void 0;
|
|
22217
|
-
const collectionUpdate = scopedUpdate || this.config.collectionUpdate === true;
|
|
22348
|
+
const collectionUpdate = scopedUpdate || partialCollection !== void 0 || this.config.collectionUpdate === true;
|
|
22218
22349
|
const path = scopedUpdate ? this.scopedCollectionPath(parentId) : collectionUpdate ? this.resourcePath : `${this.resourcePath}/${id}`;
|
|
22219
|
-
const method = scopedUpdate ? "PATCH" : "PUT";
|
|
22350
|
+
const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
|
|
22220
22351
|
let current;
|
|
22221
22352
|
try {
|
|
22222
|
-
current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" ? opts.maxRetries : void 0) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
|
|
22353
|
+
current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" || partialCollection !== void 0 ? opts.maxRetries : void 0) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
|
|
22223
22354
|
} catch (err) {
|
|
22224
22355
|
if (err instanceof NotFoundError) {
|
|
22225
|
-
const
|
|
22356
|
+
const reasons = EMPTY_REASON_STAMPS[this.config.key];
|
|
22357
|
+
const updateReason = reasons?.update ?? (partialCollection === void 0 ? void 0 : reasons?.get);
|
|
22226
22358
|
checks.push({
|
|
22227
22359
|
name: "current-record-exists",
|
|
22228
22360
|
ok: false,
|
|
@@ -22237,18 +22369,19 @@ var MutationBase = class extends MetaBase {
|
|
|
22237
22369
|
checks,
|
|
22238
22370
|
impact: { affected: 1, scope: "single-record", reversible: true },
|
|
22239
22371
|
warnings,
|
|
22240
|
-
data,
|
|
22372
|
+
data: partialCollection === void 0 ? data : { ...data, id },
|
|
22241
22373
|
...updateReason !== void 0 ? { emptyReason: updateReason } : {}
|
|
22242
22374
|
}, { redactPersonalData: this.http.redactPersonalData });
|
|
22243
22375
|
}
|
|
22244
22376
|
throw err;
|
|
22245
22377
|
}
|
|
22246
22378
|
checks.push({ name: "current-record-exists", ok: true });
|
|
22379
|
+
partialCollection?.checkCurrent(current);
|
|
22247
22380
|
if (this.staleObjectCheck(current, opts, operation)) {
|
|
22248
22381
|
checks.push({ name: "stale-check", ok: true });
|
|
22249
22382
|
}
|
|
22250
22383
|
let envelopeData = data;
|
|
22251
|
-
if (this.config.key === "knowledge_base_articles") {
|
|
22384
|
+
if (partialCollection !== void 0 || this.config.key === "knowledge_base_articles") {
|
|
22252
22385
|
envelopeData = { ...this.normalizeMutationBody(data), id };
|
|
22253
22386
|
} else if (parentId === void 0 && this.config.collectionUpdate === true && opts.raw !== true) {
|
|
22254
22387
|
const merged = mergePartialBody(current, this.normalizeMutationBody(data));
|
|
@@ -22325,34 +22458,34 @@ var BaseResource = class extends MutationBase {
|
|
|
22325
22458
|
};
|
|
22326
22459
|
|
|
22327
22460
|
// src/resources/special/taskPredecessors.ts
|
|
22328
|
-
function
|
|
22461
|
+
function fail3(detail) {
|
|
22329
22462
|
throw new AutotaskConfigError(`task_predecessors: ${detail}`);
|
|
22330
22463
|
}
|
|
22331
22464
|
function numeric(value, field) {
|
|
22332
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
22465
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail3(`${field} must be a positive numeric identifier`);
|
|
22333
22466
|
return value;
|
|
22334
22467
|
}
|
|
22335
22468
|
function predecessorParent(value) {
|
|
22336
22469
|
const parent = parseIdentifier(value, "parentId");
|
|
22337
|
-
if (parent === 0)
|
|
22470
|
+
if (parent === 0) fail3("parentId must name a successor task");
|
|
22338
22471
|
return parent;
|
|
22339
22472
|
}
|
|
22340
22473
|
function assertPredecessorBinding(value, parentId, id) {
|
|
22341
|
-
if (!isRecord2(value))
|
|
22342
|
-
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId)))
|
|
22474
|
+
if (!isRecord2(value)) fail3("the returned record must establish id and successorTaskID parent");
|
|
22475
|
+
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId))) fail3("the returned record must match id and successorTaskID parent");
|
|
22343
22476
|
}
|
|
22344
22477
|
function admitTaskPredecessor(data, parentId, creating) {
|
|
22345
22478
|
const parent = predecessorParent(parentId);
|
|
22346
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22479
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
|
|
22347
22480
|
const payload = { ...data };
|
|
22348
22481
|
const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
|
|
22349
|
-
if (Object.keys(payload).some((key) => !allowed.includes(key)))
|
|
22350
|
-
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647))
|
|
22482
|
+
if (Object.keys(payload).some((key) => !allowed.includes(key))) fail3(creating ? "only predecessorTaskID, successorTaskID and lagDays are writable on create" : "only lagDays can be updated");
|
|
22483
|
+
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647)) fail3("lagDays must be an int32 integer");
|
|
22351
22484
|
if (creating) {
|
|
22352
22485
|
const successor = numeric(payload.successorTaskID, "successorTaskID");
|
|
22353
22486
|
const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
|
|
22354
|
-
if (String(successor) !== String(parent))
|
|
22355
|
-
if (predecessor === successor)
|
|
22487
|
+
if (String(successor) !== String(parent)) fail3("successorTaskID must match parentId");
|
|
22488
|
+
if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
|
|
22356
22489
|
}
|
|
22357
22490
|
return payload;
|
|
22358
22491
|
}
|
|
@@ -22361,50 +22494,50 @@ async function guardTaskPredecessor(http, parentId, id, data) {
|
|
|
22361
22494
|
let row = data;
|
|
22362
22495
|
if (id !== void 0) {
|
|
22363
22496
|
const target = parseIdentifier(id, "id");
|
|
22364
|
-
if (target === 0)
|
|
22497
|
+
if (target === 0) fail3("id must name a predecessor relationship");
|
|
22365
22498
|
row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
|
|
22366
22499
|
assertPredecessorBinding(row, parent, target);
|
|
22367
22500
|
}
|
|
22368
22501
|
const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
|
|
22369
22502
|
const successor = numeric(row?.successorTaskID, "successorTaskID");
|
|
22370
|
-
if (predecessor === successor)
|
|
22503
|
+
if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
|
|
22371
22504
|
const projects = [];
|
|
22372
22505
|
for (const taskId of [predecessor, successor]) {
|
|
22373
22506
|
const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
|
|
22374
|
-
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId))
|
|
22507
|
+
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail3("the returned task must match its requested id");
|
|
22375
22508
|
projects.push(numeric(task.projectID, "task.projectID"));
|
|
22376
22509
|
}
|
|
22377
|
-
if (projects[0] !== projects[1])
|
|
22510
|
+
if (projects[0] !== projects[1]) fail3("predecessor and successor tasks must belong to the same project");
|
|
22378
22511
|
}
|
|
22379
22512
|
|
|
22380
22513
|
// src/resources/special/taskNotes.ts
|
|
22381
22514
|
var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
|
|
22382
22515
|
function admitTaskNote(data, parentId, creating) {
|
|
22383
22516
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22384
|
-
const
|
|
22517
|
+
const fail4 = (message) => {
|
|
22385
22518
|
throw new AutotaskConfigError(`task_notes: ${message}`);
|
|
22386
22519
|
};
|
|
22387
|
-
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
22520
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) fail4("data must be a record");
|
|
22388
22521
|
const body = data;
|
|
22389
|
-
for (const key of Object.keys(body)) if (!WRITABLE.has(key))
|
|
22522
|
+
for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail4(`${key} is not a writable TaskNotes field`);
|
|
22390
22523
|
for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
|
|
22391
22524
|
const value = body[field];
|
|
22392
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > maximum))
|
|
22525
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail4(`${field} must be a string of at most ${maximum} characters`);
|
|
22393
22526
|
}
|
|
22394
|
-
if (creating && (typeof body.description !== "string" || body.description.trim() === ""))
|
|
22527
|
+
if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail4("description is required");
|
|
22395
22528
|
for (const field of ["noteType", "publish"]) {
|
|
22396
22529
|
const value = body[field];
|
|
22397
|
-
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value)))
|
|
22530
|
+
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail4(`${field} must be an integer from the current field metadata`);
|
|
22398
22531
|
}
|
|
22399
|
-
if (creating && body.taskID === void 0)
|
|
22532
|
+
if (creating && body.taskID === void 0) fail4("taskID is required in the create body and must match parentId");
|
|
22400
22533
|
for (const field of ["createdByContactID", "taskID"]) {
|
|
22401
22534
|
if (body[field] !== void 0) {
|
|
22402
|
-
if (typeof body[field] !== "number")
|
|
22535
|
+
if (typeof body[field] !== "number") fail4(`${field} must be a numeric identifier`);
|
|
22403
22536
|
const id = parseIdentifier(body[field], field);
|
|
22404
|
-
if (field === "taskID" && String(id) !== String(parent))
|
|
22537
|
+
if (field === "taskID" && String(id) !== String(parent)) fail4("taskID must match the parentId path argument");
|
|
22405
22538
|
}
|
|
22406
22539
|
}
|
|
22407
|
-
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId"))
|
|
22540
|
+
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail4("update must contain a writable field");
|
|
22408
22541
|
}
|
|
22409
22542
|
|
|
22410
22543
|
// src/operations/invoke/fieldSuggest.ts
|
|
@@ -22674,38 +22807,38 @@ function isBase64(value) {
|
|
|
22674
22807
|
}
|
|
22675
22808
|
function admitTaskAttachment(data, parentId) {
|
|
22676
22809
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22677
|
-
const
|
|
22810
|
+
const fail4 = (message) => {
|
|
22678
22811
|
throw new AutotaskConfigError(`task_attachments: ${message}`);
|
|
22679
22812
|
};
|
|
22680
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22813
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22681
22814
|
const body = data;
|
|
22682
|
-
for (const field of Object.keys(body)) if (!WRITABLE2.has(field))
|
|
22815
|
+
for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail4(`${field} is not a supported create field`);
|
|
22683
22816
|
for (const field of ["attachmentType", "fullPath", "title"]) {
|
|
22684
|
-
if (typeof body[field] !== "string" || body[field].trim() === "")
|
|
22817
|
+
if (typeof body[field] !== "string" || body[field].trim() === "") fail4(`${field} is required and must be a non-empty string`);
|
|
22685
22818
|
}
|
|
22686
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
22819
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
|
|
22687
22820
|
for (const field of ["data", "contentType"]) {
|
|
22688
|
-
if (body[field] !== void 0 && typeof body[field] !== "string")
|
|
22821
|
+
if (body[field] !== void 0 && typeof body[field] !== "string") fail4(`${field} must be a string`);
|
|
22689
22822
|
}
|
|
22690
22823
|
if (body.attachmentType === "FILE_ATTACHMENT") {
|
|
22691
|
-
if (typeof body.data !== "string" || body.data === "") return
|
|
22692
|
-
if (!isBase64(body.data))
|
|
22824
|
+
if (typeof body.data !== "string" || body.data === "") return fail4("FILE_ATTACHMENT requires non-empty base64 data");
|
|
22825
|
+
if (!isBase64(body.data)) fail4("FILE_ATTACHMENT data must be base64 encoded");
|
|
22693
22826
|
}
|
|
22694
22827
|
if (body.taskID !== void 0) {
|
|
22695
|
-
if (typeof body.taskID !== "number")
|
|
22696
|
-
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent))
|
|
22828
|
+
if (typeof body.taskID !== "number") fail4("taskID must be a numeric identifier");
|
|
22829
|
+
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail4("taskID must match the parentId path argument");
|
|
22697
22830
|
}
|
|
22698
22831
|
if (body.parentAttachmentID !== void 0) {
|
|
22699
|
-
if (typeof body.parentAttachmentID !== "number")
|
|
22832
|
+
if (typeof body.parentAttachmentID !== "number") fail4("parentAttachmentID must be a numeric identifier");
|
|
22700
22833
|
parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
|
|
22701
22834
|
}
|
|
22702
22835
|
}
|
|
22703
22836
|
function admitFileAttachment(resource, data, parentId) {
|
|
22704
22837
|
parseIdentifier(parentId, "parentId");
|
|
22705
|
-
const
|
|
22838
|
+
const fail4 = (message) => {
|
|
22706
22839
|
throw new AutotaskConfigError(`${resource}: ${message}`);
|
|
22707
22840
|
};
|
|
22708
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22841
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22709
22842
|
const body = data;
|
|
22710
22843
|
const reference2 = {
|
|
22711
22844
|
project_attachments: void 0,
|
|
@@ -22718,20 +22851,20 @@ function admitFileAttachment(resource, data, parentId) {
|
|
|
22718
22851
|
configuration_item_attachments: "parentAttachmentID",
|
|
22719
22852
|
configuration_item_note_attachments: void 0
|
|
22720
22853
|
}[resource];
|
|
22721
|
-
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2)
|
|
22722
|
-
if (body.attachmentType !== "FILE_ATTACHMENT")
|
|
22854
|
+
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail4(`${field} is not a supported create field`);
|
|
22855
|
+
if (body.attachmentType !== "FILE_ATTACHMENT") fail4("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
|
|
22723
22856
|
const maxLength = resource === "project_attachments" ? void 0 : 255;
|
|
22724
22857
|
for (const field of ["fullPath", "title"]) {
|
|
22725
22858
|
const value = body[field];
|
|
22726
22859
|
const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
|
|
22727
|
-
if (typeof value !== "string" || value.trim() === "") return
|
|
22728
|
-
if (maxLength !== void 0 && value.length > maxLength)
|
|
22860
|
+
if (typeof value !== "string" || value.trim() === "") return fail4(requirement);
|
|
22861
|
+
if (maxLength !== void 0 && value.length > maxLength) fail4(requirement);
|
|
22729
22862
|
}
|
|
22730
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
22731
|
-
if (typeof body.data !== "string" || !isBase64(body.data))
|
|
22863
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
|
|
22864
|
+
if (typeof body.data !== "string" || !isBase64(body.data)) fail4("FILE_ATTACHMENT requires nonempty base64 data");
|
|
22732
22865
|
if (reference2 !== void 0 && body[reference2] !== void 0) {
|
|
22733
|
-
if (typeof body[reference2] !== "number")
|
|
22734
|
-
if (parseIdentifier(body[reference2], reference2) === 0)
|
|
22866
|
+
if (typeof body[reference2] !== "number") fail4(`${reference2} must be a numeric identifier`);
|
|
22867
|
+
if (parseIdentifier(body[reference2], reference2) === 0) fail4(`${reference2} must be positive`);
|
|
22735
22868
|
}
|
|
22736
22869
|
}
|
|
22737
22870
|
function admitScopedAttachmentQuery(resource, params) {
|
|
@@ -23580,6 +23713,16 @@ var SIMPLE_RESOURCES = [
|
|
|
23580
23713
|
helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23581
23714
|
opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
|
|
23582
23715
|
},
|
|
23716
|
+
{
|
|
23717
|
+
key: "inventory_locations",
|
|
23718
|
+
accessor: "inventoryLocations",
|
|
23719
|
+
resourcePath: "/V1.0/InventoryLocations",
|
|
23720
|
+
deletable: false,
|
|
23721
|
+
udfCapable: false,
|
|
23722
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
23723
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23724
|
+
opForms: { get: "global", create: "global", update: "global" }
|
|
23725
|
+
},
|
|
23583
23726
|
{
|
|
23584
23727
|
key: "invoice_templates",
|
|
23585
23728
|
accessor: "invoiceTemplates",
|
|
@@ -24475,7 +24618,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24475
24618
|
if (["company_attachments", "company_note_attachments", "configuration_item_attachments", "configuration_item_note_attachments", "contract_note_attachments", "expense_report_attachments", "project_attachments", "project_note_attachments", "resource_attachments", "sales_order_attachments", "task_attachments", "task_note_attachments"].includes(config.key)) this.getUdfInfo = async () => {
|
|
24476
24619
|
throw new OperationNotSupportedError(config.key, "getUdfInfo");
|
|
24477
24620
|
};
|
|
24478
|
-
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles"].includes(config.key)) this.createIfNotExists = async () => {
|
|
24621
|
+
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
|
|
24479
24622
|
throw new OperationNotSupportedError(config.key, "createIfNotExists");
|
|
24480
24623
|
};
|
|
24481
24624
|
if (config.key === "knowledge_base_categories") {
|
|
@@ -24590,9 +24733,9 @@ var GenericResource = class extends BaseResource {
|
|
|
24590
24733
|
return this.createScopedRaw(parentId, data2, opts2);
|
|
24591
24734
|
}
|
|
24592
24735
|
if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
|
|
24593
|
-
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : a;
|
|
24736
|
+
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
|
|
24594
24737
|
const supplied = b;
|
|
24595
|
-
const opts = this.config.key
|
|
24738
|
+
const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
24596
24739
|
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
24597
24740
|
return this.createGlobal(data, opts);
|
|
24598
24741
|
}
|
|
@@ -24619,8 +24762,24 @@ var GenericResource = class extends BaseResource {
|
|
|
24619
24762
|
}
|
|
24620
24763
|
if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
|
|
24621
24764
|
const category = this.config.key === "knowledge_base_categories";
|
|
24622
|
-
const
|
|
24765
|
+
const location = this.config.key === "inventory_locations";
|
|
24766
|
+
const id = category || location ? parseIdentifier(a, "id") : a;
|
|
24623
24767
|
const supplied = c;
|
|
24768
|
+
if (location) {
|
|
24769
|
+
const body = admitInventoryLocation(b, false);
|
|
24770
|
+
const opts2 = snapshotMutationOptions(supplied);
|
|
24771
|
+
if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
|
|
24772
|
+
const checkCurrent = (current) => checkInventoryLocationCurrent(body, current);
|
|
24773
|
+
if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
|
|
24774
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
24775
|
+
try {
|
|
24776
|
+
checkCurrent(await this.getGlobal(id, true, opts2.maxRetries, checkedBaseUrl));
|
|
24777
|
+
} catch (error) {
|
|
24778
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
24779
|
+
throw error;
|
|
24780
|
+
}
|
|
24781
|
+
return this.updateGlobal(id, body, opts2, "PATCH", checkedBaseUrl);
|
|
24782
|
+
}
|
|
24624
24783
|
const opts = category ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
24625
24784
|
if (category && opts.raw === true) throw new AutotaskConfigError("knowledge_base_categories: raw update is unsupported; a fresh merge is required");
|
|
24626
24785
|
const data = category ? admitKnowledgeBaseCategory(b, false, opts.lastModifiedDate) : b;
|
|
@@ -26713,8 +26872,9 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
|
|
|
26713
26872
|
try {
|
|
26714
26873
|
const id = parseIdentifier(item.id, `${at}.id`);
|
|
26715
26874
|
const audit = isAuditLogResource(resourceKey);
|
|
26716
|
-
if ((audit ||
|
|
26717
|
-
|
|
26875
|
+
if ((audit || isExactRecordResource(resourceKey)) && !isAuditDecimalId(String(id))) {
|
|
26876
|
+
const label = audit ? "audit log" : resourceKey === "inventory_locations" ? "inventory location" : "Knowledge Base record";
|
|
26877
|
+
problems.push(`${at}.id: ${label} ID must be a non-negative signed 64-bit integer`);
|
|
26718
26878
|
}
|
|
26719
26879
|
} catch {
|
|
26720
26880
|
if (typeof item.id === "string") {
|
|
@@ -29344,16 +29504,16 @@ function latchingHttp(raw, spend) {
|
|
|
29344
29504
|
}
|
|
29345
29505
|
};
|
|
29346
29506
|
observeRecordReadFailures(http, latch);
|
|
29347
|
-
const
|
|
29507
|
+
const fail4 = (err) => {
|
|
29348
29508
|
latch(err);
|
|
29349
29509
|
throw err;
|
|
29350
29510
|
};
|
|
29351
29511
|
http.request = (o) => {
|
|
29352
29512
|
if (fatal) throw fatal;
|
|
29353
29513
|
try {
|
|
29354
|
-
return counted.request({ ...o, signal: o.signal ?? signal }).catch(
|
|
29514
|
+
return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail4);
|
|
29355
29515
|
} catch (err) {
|
|
29356
|
-
return
|
|
29516
|
+
return fail4(err);
|
|
29357
29517
|
}
|
|
29358
29518
|
};
|
|
29359
29519
|
return { http, fatal: () => fatal, signal };
|