node-autotask 0.87.0 → 0.88.1
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 +9 -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-G57Q7OAC.js → chunk-33UVHMFN.js} +2 -2
- package/dist/{chunk-BD4AUGCJ.cjs → chunk-CM5O672I.cjs} +5 -4
- package/dist/{chunk-HUA4WB4N.cjs → chunk-DSHWQMF2.cjs} +31 -30
- package/dist/{chunk-RU4ECNQN.cjs → chunk-JHDT4O7N.cjs} +200 -200
- package/dist/{chunk-NXSQXXNK.js → chunk-JVVE4XEN.js} +3 -2
- package/dist/{chunk-GAFG7RHG.js → chunk-KM7ITBOT.js} +541 -304
- package/dist/{chunk-YVNGUGG6.cjs → chunk-SHJ7EOBW.cjs} +3 -3
- package/dist/{chunk-7NKB4UXV.js → chunk-X6VWD6WW.js} +5 -4
- package/dist/{chunk-CUZJJCI5.cjs → chunk-YTOBU3Z6.cjs} +553 -316
- package/dist/{chunk-EXNDYJPG.js → chunk-ZADTVF6M.js} +3 -3
- package/dist/{index-Cxfr_DOD.d.cts → index-4jmitXBs.d.cts} +29 -1
- package/dist/{index-Cxfr_DOD.d.ts → index-4jmitXBs.d.ts} +29 -1
- package/dist/{index-CsL5gGJo.d.ts → index-GSA44LRd.d.ts} +13 -7
- package/dist/{index-DGiua9uK.d.cts → index-XDIy_GvD.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,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkSHJ7EOBW_cjs = require('./chunk-SHJ7EOBW.cjs');
|
|
4
|
+
var chunkCM5O672I_cjs = require('./chunk-CM5O672I.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
7
7
|
|
|
@@ -325,12 +325,10 @@ function redactResponseBody(value, policy) {
|
|
|
325
325
|
return value.map((entry) => redactResponseBody(entry, policy));
|
|
326
326
|
}
|
|
327
327
|
if (!isPlainRecord(value)) return value;
|
|
328
|
-
|
|
329
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
328
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => {
|
|
330
329
|
const pinned = SECRET_SET.has(key) || personal && OPTIONAL_SET.has(key);
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
return out;
|
|
330
|
+
return [key, pinned ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry, policy)];
|
|
331
|
+
}));
|
|
334
332
|
}
|
|
335
333
|
|
|
336
334
|
// src/errors/from-status.ts
|
|
@@ -1412,7 +1410,7 @@ function resolveConfig(config) {
|
|
|
1412
1410
|
}
|
|
1413
1411
|
labels = config.labels;
|
|
1414
1412
|
}
|
|
1415
|
-
const logger = config.logger ??
|
|
1413
|
+
const logger = config.logger ?? chunkCM5O672I_cjs.NoopLogger;
|
|
1416
1414
|
if (credentials.baseUrl.startsWith("http:")) {
|
|
1417
1415
|
const host = new URL(credentials.baseUrl).host;
|
|
1418
1416
|
logger.warn?.(
|
|
@@ -1452,8 +1450,14 @@ function isAuditDecimalId(id) {
|
|
|
1452
1450
|
function isRecord2(value) {
|
|
1453
1451
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1454
1452
|
}
|
|
1455
|
-
function snapshotFields(record, keys) {
|
|
1456
|
-
const captured = { ...record }
|
|
1453
|
+
function snapshotFields(record, keys, fixed) {
|
|
1454
|
+
const captured = fixed === void 0 ? { ...record } : {
|
|
1455
|
+
...Object.fromEntries(Reflect.ownKeys(record).flatMap((key) => {
|
|
1456
|
+
if (Object.hasOwn(fixed, key) || !Object.prototype.propertyIsEnumerable.call(record, key)) return [];
|
|
1457
|
+
return [[key, Reflect.get(record, key)]];
|
|
1458
|
+
})),
|
|
1459
|
+
...fixed
|
|
1460
|
+
};
|
|
1457
1461
|
for (const key of keys) {
|
|
1458
1462
|
if (Object.hasOwn(captured, key)) continue;
|
|
1459
1463
|
const value = Reflect.get(record, key);
|
|
@@ -1492,7 +1496,7 @@ function redactAuditBody(value) {
|
|
|
1492
1496
|
if (!isRecord2(value)) return value;
|
|
1493
1497
|
const out = {};
|
|
1494
1498
|
for (const [key, entry] of Object.entries(value)) {
|
|
1495
|
-
out[key] = CREDENTIAL_KEY_RE.test(key) ?
|
|
1499
|
+
out[key] = CREDENTIAL_KEY_RE.test(key) ? chunkCM5O672I_cjs.REDACTED : redactAuditBody(entry);
|
|
1496
1500
|
}
|
|
1497
1501
|
return out;
|
|
1498
1502
|
}
|
|
@@ -1673,9 +1677,20 @@ function snapshotQueryFilter(filter) {
|
|
|
1673
1677
|
throw invalidFilterShape(filter);
|
|
1674
1678
|
}
|
|
1675
1679
|
function snapshotQueryBag(bag, keys) {
|
|
1676
|
-
|
|
1680
|
+
let fixed;
|
|
1681
|
+
if (keys.includes("acknowledgeUnscoped")) {
|
|
1682
|
+
const acknowledgment = Object.getOwnPropertyDescriptor(bag, "acknowledgeUnscoped");
|
|
1683
|
+
const direct = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") ? acknowledgment.value : void 0;
|
|
1684
|
+
const filter = Reflect.get(bag, "filter");
|
|
1685
|
+
const capturedFilter = filter === void 0 ? void 0 : snapshotQueryFilter(filter);
|
|
1686
|
+
fixed = {
|
|
1687
|
+
filter: capturedFilter,
|
|
1688
|
+
acknowledgeUnscoped: direct === true ? Reflect.get(bag, "acknowledgeUnscoped") === true : direct
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
const snapshot = snapshotFields(bag, keys, fixed);
|
|
1677
1692
|
const captured = snapshot;
|
|
1678
|
-
if (captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
|
|
1693
|
+
if (fixed === void 0 && captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
|
|
1679
1694
|
if (Array.isArray(captured.includeFields)) {
|
|
1680
1695
|
const fields = captured.includeFields;
|
|
1681
1696
|
captured.includeFields = Array.from({ length: fields.length }, (_, i) => fields[i]);
|
|
@@ -10938,6 +10953,59 @@ var RELATIONSHIP_MAP = {
|
|
|
10938
10953
|
},
|
|
10939
10954
|
"deleteBoundary": null,
|
|
10940
10955
|
"markerField": null
|
|
10956
|
+
},
|
|
10957
|
+
"inventory_locations": {
|
|
10958
|
+
"resource": "inventory_locations",
|
|
10959
|
+
"apiEntity": "InventoryLocation",
|
|
10960
|
+
"kind": "entity",
|
|
10961
|
+
"path": "InventoryLocations",
|
|
10962
|
+
"parentScoped": false,
|
|
10963
|
+
"tier": "extended",
|
|
10964
|
+
"workflowResource": false,
|
|
10965
|
+
"group": "A",
|
|
10966
|
+
"parent": null,
|
|
10967
|
+
"children": [],
|
|
10968
|
+
"naturalKeys": {
|
|
10969
|
+
"hasSearch": false,
|
|
10970
|
+
"searchCovers": null,
|
|
10971
|
+
"findBy": []
|
|
10972
|
+
},
|
|
10973
|
+
"blindSurfaces": null,
|
|
10974
|
+
"zoneFacts": {
|
|
10975
|
+
"createRequiredSet": [
|
|
10976
|
+
"locationName",
|
|
10977
|
+
"isActive"
|
|
10978
|
+
],
|
|
10979
|
+
"createGuidance": {
|
|
10980
|
+
"createOp": "inventory_locations.create",
|
|
10981
|
+
"parentScoped": false,
|
|
10982
|
+
"liveProvenPrefix": [],
|
|
10983
|
+
"unproven": true,
|
|
10984
|
+
"blocker": {
|
|
10985
|
+
"kind": "unknown",
|
|
10986
|
+
"message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
|
|
10987
|
+
"remedy": "Read current metadata, supply locationName and isActive, and preview first.",
|
|
10988
|
+
"requires": {
|
|
10989
|
+
"allOf": [
|
|
10990
|
+
"locationName",
|
|
10991
|
+
"isActive"
|
|
10992
|
+
]
|
|
10993
|
+
}
|
|
10994
|
+
},
|
|
10995
|
+
"vendorEvidence": [
|
|
10996
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
|
|
10997
|
+
],
|
|
10998
|
+
"deleteBoundary": {
|
|
10999
|
+
"available": false,
|
|
11000
|
+
"note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
11001
|
+
}
|
|
11002
|
+
}
|
|
11003
|
+
},
|
|
11004
|
+
"deleteBoundary": {
|
|
11005
|
+
"note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API.",
|
|
11006
|
+
"proof": "spec-derived"
|
|
11007
|
+
},
|
|
11008
|
+
"markerField": null
|
|
10941
11009
|
}
|
|
10942
11010
|
};
|
|
10943
11011
|
var BLIND_SURFACE_STAMPS = {
|
|
@@ -11049,7 +11117,8 @@ var DELETE_BOUNDARY_NOTES = {
|
|
|
11049
11117
|
"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.",
|
|
11050
11118
|
"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.",
|
|
11051
11119
|
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
|
|
11052
|
-
"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."
|
|
11120
|
+
"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.",
|
|
11121
|
+
"inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
11053
11122
|
};
|
|
11054
11123
|
var RESPONSE_DRIFT_MARKERS = {
|
|
11055
11124
|
"ticket_checklist_libraries": {
|
|
@@ -12485,6 +12554,15 @@ var EMPTY_REASON_STAMPS = {
|
|
|
12485
12554
|
"authority": null,
|
|
12486
12555
|
"remedy": "verify the created record by id (ticket_checklist_libraries.get) \u2014 the create may have succeeded despite the drifted envelope"
|
|
12487
12556
|
}
|
|
12557
|
+
},
|
|
12558
|
+
"inventory_locations": {
|
|
12559
|
+
"get": {
|
|
12560
|
+
"surface": "inventory_locations.get",
|
|
12561
|
+
"kind": "tenant-empty-for-user",
|
|
12562
|
+
"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.",
|
|
12563
|
+
"authority": "inventory_locations.get",
|
|
12564
|
+
"remedy": "Verify the ID and check View permission, Inventory access and Inventory Manage Locations with an authorized user."
|
|
12565
|
+
}
|
|
12488
12566
|
}
|
|
12489
12567
|
};
|
|
12490
12568
|
var POINTER_NOTES = {
|
|
@@ -13967,6 +14045,31 @@ var CREATE_GUIDANCE = {
|
|
|
13967
14045
|
"note": null
|
|
13968
14046
|
}
|
|
13969
14047
|
},
|
|
14048
|
+
{
|
|
14049
|
+
"resource": "inventory_locations",
|
|
14050
|
+
"createOp": "inventory_locations.create",
|
|
14051
|
+
"parentScoped": false,
|
|
14052
|
+
"liveProvenPrefix": [],
|
|
14053
|
+
"unproven": true,
|
|
14054
|
+
"blocker": {
|
|
14055
|
+
"kind": "unknown",
|
|
14056
|
+
"message": "Inventory location creation requires Inventory permissions and a unique locationName; not live verified.",
|
|
14057
|
+
"remedy": "Read current metadata, supply locationName and isActive, and preview first.",
|
|
14058
|
+
"requires": {
|
|
14059
|
+
"allOf": [
|
|
14060
|
+
"locationName",
|
|
14061
|
+
"isActive"
|
|
14062
|
+
]
|
|
14063
|
+
}
|
|
14064
|
+
},
|
|
14065
|
+
"vendorEvidence": [
|
|
14066
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryLocationsEntity.htm"
|
|
14067
|
+
],
|
|
14068
|
+
"deleteBoundary": {
|
|
14069
|
+
"available": false,
|
|
14070
|
+
"note": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
14071
|
+
}
|
|
14072
|
+
},
|
|
13970
14073
|
{
|
|
13971
14074
|
"resource": "inventory_products",
|
|
13972
14075
|
"createOp": "inventory_products.create",
|
|
@@ -15547,7 +15650,7 @@ var CREATE_GUIDANCE = {
|
|
|
15547
15650
|
}
|
|
15548
15651
|
],
|
|
15549
15652
|
"counts": {
|
|
15550
|
-
"total":
|
|
15653
|
+
"total": 117,
|
|
15551
15654
|
"byKind": {
|
|
15552
15655
|
"ok": 41,
|
|
15553
15656
|
"blind-reference": 16,
|
|
@@ -15557,7 +15660,7 @@ var CREATE_GUIDANCE = {
|
|
|
15557
15660
|
"resource-role-pair": 2,
|
|
15558
15661
|
"delete-absent": 0,
|
|
15559
15662
|
"non-mutable": 0,
|
|
15560
|
-
"unknown":
|
|
15663
|
+
"unknown": 41
|
|
15561
15664
|
}
|
|
15562
15665
|
}
|
|
15563
15666
|
};
|
|
@@ -16336,6 +16439,9 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
|
|
|
16336
16439
|
"keywords",
|
|
16337
16440
|
"referenceLink",
|
|
16338
16441
|
"title"
|
|
16442
|
+
],
|
|
16443
|
+
"inventory_locations": [
|
|
16444
|
+
"locationName"
|
|
16339
16445
|
]
|
|
16340
16446
|
};
|
|
16341
16447
|
|
|
@@ -16794,22 +16900,32 @@ function auditReadTarget(path, operation) {
|
|
|
16794
16900
|
function isKnowledgeBaseRootResource(resource) {
|
|
16795
16901
|
return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
|
|
16796
16902
|
}
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
|
|
16903
|
+
function isExactRecordResource(resource) {
|
|
16904
|
+
return resource === "inventory_locations" || isKnowledgeBaseRootResource(resource);
|
|
16905
|
+
}
|
|
16906
|
+
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
16907
|
+
function exactRecordResponseTarget(path, method, operation) {
|
|
16908
|
+
const match = EXACT_RECORD_PATH.exec(path);
|
|
16800
16909
|
if (match === null) return void 0;
|
|
16801
16910
|
const suffix = match[1]?.toLowerCase();
|
|
16802
16911
|
if (suffix === "query/count") return suffix;
|
|
16803
16912
|
if (suffix?.startsWith("query")) return "query";
|
|
16804
16913
|
if (suffix !== void 0 && !isAuditDecimalId(suffix)) {
|
|
16805
|
-
throw new AutotaskConfigError("
|
|
16914
|
+
throw new AutotaskConfigError("Record ID must be a non-negative signed 64-bit integer.", { operation });
|
|
16806
16915
|
}
|
|
16807
16916
|
return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
|
|
16808
16917
|
}
|
|
16918
|
+
function ownField(value, key) {
|
|
16919
|
+
return isRecord2(value) && Object.hasOwn(value, key) ? value[key] : void 0;
|
|
16920
|
+
}
|
|
16921
|
+
function receiptId(body) {
|
|
16922
|
+
const itemId = ownField(body, "itemId");
|
|
16923
|
+
return itemId === void 0 ? ownField(body, "id") : itemId;
|
|
16924
|
+
}
|
|
16809
16925
|
function isNonNegativeInt64(id) {
|
|
16810
16926
|
return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
|
|
16811
16927
|
}
|
|
16812
|
-
function
|
|
16928
|
+
function validateExactRecordResponse(body, target, path, method, requestBody, operation) {
|
|
16813
16929
|
const invalid = (message) => {
|
|
16814
16930
|
throw new AutotaskError(message, { code: "INVALID_RESPONSE", category: "server", operation, suggestedAction: INVALID_SHAPE_ACTION });
|
|
16815
16931
|
};
|
|
@@ -16818,41 +16934,43 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
|
|
|
16818
16934
|
return;
|
|
16819
16935
|
}
|
|
16820
16936
|
if (target === "query") {
|
|
16821
|
-
|
|
16822
|
-
|
|
16823
|
-
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
const cursor =
|
|
16937
|
+
const items = ownField(body, "items");
|
|
16938
|
+
const paging = ownField(body, "pageDetails");
|
|
16939
|
+
if (!Array.isArray(items) || !isRecord2(paging)) {
|
|
16940
|
+
return invalid("Expected a query page with paging details");
|
|
16941
|
+
}
|
|
16942
|
+
if (!items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
|
|
16943
|
+
if (ownField(paging, "count") !== items.length) invalid("The page record count did not match its rows");
|
|
16944
|
+
const cursor = ownField(paging, "nextPageUrl");
|
|
16829
16945
|
if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
|
|
16830
|
-
invalid("Expected a valid
|
|
16946
|
+
invalid("Expected a valid query cursor or an explicit end of results");
|
|
16831
16947
|
}
|
|
16832
16948
|
return;
|
|
16833
16949
|
}
|
|
16834
16950
|
const parts = path.replace(/\/$/, "").split("/");
|
|
16835
16951
|
const expectedId = parts.at(-1);
|
|
16836
16952
|
if (target === "mutation") {
|
|
16837
|
-
const
|
|
16838
|
-
if (!isNonNegativeInt64(
|
|
16839
|
-
const expected = method === "DELETE" ? expectedId :
|
|
16840
|
-
if (expected !== void 0 && String(
|
|
16953
|
+
const id2 = receiptId(body);
|
|
16954
|
+
if (!isNonNegativeInt64(id2)) invalid("Expected a valid mutation receipt");
|
|
16955
|
+
const expected = method === "DELETE" ? expectedId : ownField(requestBody, "id");
|
|
16956
|
+
if (expected !== void 0 && String(id2) !== String(expected)) {
|
|
16841
16957
|
invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
|
|
16842
16958
|
}
|
|
16843
16959
|
return;
|
|
16844
16960
|
}
|
|
16845
|
-
const item =
|
|
16961
|
+
const item = ownField(body, "item");
|
|
16846
16962
|
if (item === null) return;
|
|
16847
|
-
|
|
16848
|
-
|
|
16963
|
+
const id = ownField(item, "id");
|
|
16964
|
+
if (!isNonNegativeInt64(id)) {
|
|
16965
|
+
return invalid("Expected an item envelope with a valid record ID");
|
|
16849
16966
|
}
|
|
16850
|
-
const
|
|
16851
|
-
|
|
16967
|
+
const entity = parts.at(-2)?.toLowerCase();
|
|
16968
|
+
const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
|
|
16969
|
+
if (String(id) !== expectedId) {
|
|
16852
16970
|
throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
|
|
16853
16971
|
}
|
|
16854
16972
|
if (parts.length === 6) {
|
|
16855
|
-
const parent = item
|
|
16973
|
+
const parent = ownField(item, "articleCategoryID");
|
|
16856
16974
|
if (typeof parent !== "number" || !Number.isInteger(parent) || parent <= 0 || parent > 2147483647) {
|
|
16857
16975
|
invalid("Expected a valid category ID in the Knowledge Base article response");
|
|
16858
16976
|
}
|
|
@@ -16861,16 +16979,16 @@ function validateKnowledgeBaseResponse(body, target, path, method, requestBody,
|
|
|
16861
16979
|
}
|
|
16862
16980
|
}
|
|
16863
16981
|
}
|
|
16864
|
-
function
|
|
16865
|
-
if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
|
|
16982
|
+
function serializeExactRecordUpdate(body, operation) {
|
|
16983
|
+
if (!isRecord2(body) || !Object.hasOwn(body, "id") || typeof body.id !== "string") return JSON.stringify(body);
|
|
16866
16984
|
if (!isAuditDecimalId(body.id)) {
|
|
16867
|
-
throw new AutotaskConfigError("
|
|
16985
|
+
throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
|
|
16868
16986
|
}
|
|
16869
16987
|
const { rawJSON } = JSON;
|
|
16870
16988
|
return JSON.stringify({ ...body, id: rawJSON(body.id) });
|
|
16871
16989
|
}
|
|
16872
|
-
function decodeResponseJson(text, auditTarget,
|
|
16873
|
-
const target = auditTarget ??
|
|
16990
|
+
function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
16991
|
+
const target = auditTarget ?? recordTarget;
|
|
16874
16992
|
if (target === void 0) return JSON.parse(text);
|
|
16875
16993
|
if (target === "query/count") {
|
|
16876
16994
|
return JSON.parse(text, (key, value, context) => key === "queryCount" && typeof value === "number" && !isAuditDecimalId(context?.source ?? "") ? null : value);
|
|
@@ -16884,12 +17002,12 @@ function decodeResponseJson(text, auditTarget, knowledgeBaseTarget) {
|
|
|
16884
17002
|
}
|
|
16885
17003
|
return value;
|
|
16886
17004
|
});
|
|
16887
|
-
const rows =
|
|
17005
|
+
const rows = target === "query" ? ownField(body, "items") : [target === "mutation" ? body : ownField(body, "item")];
|
|
16888
17006
|
if (Array.isArray(rows)) {
|
|
16889
17007
|
for (const row of rows) {
|
|
16890
17008
|
if (!isRecord2(row)) continue;
|
|
16891
|
-
const key = target === "mutation" && row
|
|
16892
|
-
const value = row
|
|
17009
|
+
const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
|
|
17010
|
+
const value = ownField(row, key);
|
|
16893
17011
|
if (typeof value !== "number") continue;
|
|
16894
17012
|
const token = (key === "id" ? idTokens : receiptTokens).get(row);
|
|
16895
17013
|
if (token === void 0 || !isAuditDecimalId(token)) row[key] = null;
|
|
@@ -16899,8 +17017,7 @@ function decodeResponseJson(text, auditTarget, knowledgeBaseTarget) {
|
|
|
16899
17017
|
return body;
|
|
16900
17018
|
}
|
|
16901
17019
|
function hasExactRecordId(item) {
|
|
16902
|
-
|
|
16903
|
-
return isNonNegativeInt64(item.id);
|
|
17020
|
+
return isNonNegativeInt64(ownField(item, "id"));
|
|
16904
17021
|
}
|
|
16905
17022
|
function isAuditPage(body) {
|
|
16906
17023
|
if (!Array.isArray(body.items) || !isRecord2(body.pageDetails)) return false;
|
|
@@ -16930,9 +17047,9 @@ function attachEmptyReasonDetails(err) {
|
|
|
16930
17047
|
const resource = err.operation.slice(0, dot);
|
|
16931
17048
|
const op = err.operation.slice(dot + 1);
|
|
16932
17049
|
const surface = err.operation;
|
|
16933
|
-
const stamp = EMPTY_REASON_STAMPS[resource]?.[op];
|
|
16934
|
-
const pointer = POINTER_NOTES[surface];
|
|
16935
17050
|
const isGetMiss = err instanceof NotFoundError && op === "get";
|
|
17051
|
+
const stamp = op !== "get" || isGetMiss ? EMPTY_REASON_STAMPS[resource]?.[op] : void 0;
|
|
17052
|
+
const pointer = POINTER_NOTES[surface];
|
|
16936
17053
|
if (stamp === void 0 && pointer === void 0 && !isGetMiss) return;
|
|
16937
17054
|
err.details = { ...err.details ?? {} };
|
|
16938
17055
|
if (stamp !== void 0) {
|
|
@@ -16969,7 +17086,7 @@ function unwrapItems(body, operation) {
|
|
|
16969
17086
|
return { items: body.items, pageDetails: body.pageDetails };
|
|
16970
17087
|
}
|
|
16971
17088
|
function unwrapItem(body, id, operation, entity) {
|
|
16972
|
-
if (!isRecord2(body) || !("item"
|
|
17089
|
+
if (!isRecord2(body) || !Object.hasOwn(body, "item")) {
|
|
16973
17090
|
throw new AutotaskError("Expected the item envelope { item }; got a different shape", {
|
|
16974
17091
|
code: "INVALID_RESPONSE",
|
|
16975
17092
|
category: "server",
|
|
@@ -16995,7 +17112,7 @@ function unwrapItem(body, id, operation, entity) {
|
|
|
16995
17112
|
return item;
|
|
16996
17113
|
}
|
|
16997
17114
|
function unwrapQueryCount(body, operation) {
|
|
16998
|
-
const count =
|
|
17115
|
+
const count = ownField(body, "queryCount");
|
|
16999
17116
|
if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > 2147483647) {
|
|
17000
17117
|
const err = new AutotaskError("Expected the count envelope { queryCount: non-negative int32 }", {
|
|
17001
17118
|
code: "INVALID_RESPONSE",
|
|
@@ -17009,7 +17126,7 @@ function unwrapQueryCount(body, operation) {
|
|
|
17009
17126
|
return count;
|
|
17010
17127
|
}
|
|
17011
17128
|
function unwrapOperation(body, operation) {
|
|
17012
|
-
const value =
|
|
17129
|
+
const value = receiptId(body);
|
|
17013
17130
|
const idValue = toIdentifierId(value);
|
|
17014
17131
|
if (idValue === void 0) {
|
|
17015
17132
|
const err = new AutotaskError(
|
|
@@ -17044,7 +17161,7 @@ function normalizeZoneBase(raw) {
|
|
|
17044
17161
|
return `${url.origin}${url.pathname.replace(/\/+$/, "")}`;
|
|
17045
17162
|
}
|
|
17046
17163
|
function canReResolveZone(reResolveZoneOn401, zone, opts) {
|
|
17047
|
-
if (!reResolveZoneOn401) return false;
|
|
17164
|
+
if (!reResolveZoneOn401 || opts.checkedBaseUrl !== void 0) return false;
|
|
17048
17165
|
if (zone === void 0 || zone === "other") return false;
|
|
17049
17166
|
if (!opts.path.startsWith("/") || /^https?:\/\//i.test(opts.path)) return false;
|
|
17050
17167
|
return true;
|
|
@@ -17437,6 +17554,7 @@ var HttpClient = class {
|
|
|
17437
17554
|
if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
|
|
17438
17555
|
this.gate(s, false);
|
|
17439
17556
|
if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
|
|
17557
|
+
this.assertCheckedBase(opts);
|
|
17440
17558
|
const admission = admitHourlyAttempt(s.url, this.hourly, Date.now());
|
|
17441
17559
|
if (!admission.admitted) {
|
|
17442
17560
|
releaseCurrent();
|
|
@@ -17513,13 +17631,13 @@ var HttpClient = class {
|
|
|
17513
17631
|
}
|
|
17514
17632
|
let parsed;
|
|
17515
17633
|
try {
|
|
17516
|
-
parsed = decodeResponseJson(text, s.auditTarget, s.
|
|
17634
|
+
parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget);
|
|
17517
17635
|
} catch {
|
|
17518
17636
|
return this.handleNonJson2xx(s, res, status, text);
|
|
17519
17637
|
}
|
|
17520
17638
|
validateAuditResponse(parsed, s.auditTarget, opts.operation);
|
|
17521
|
-
if (s.
|
|
17522
|
-
|
|
17639
|
+
if (s.recordTarget !== void 0) {
|
|
17640
|
+
validateExactRecordResponse(parsed, s.recordTarget, decodeURIComponent(opts.path), method, opts.body, opts.operation);
|
|
17523
17641
|
}
|
|
17524
17642
|
return {
|
|
17525
17643
|
done: true,
|
|
@@ -17706,6 +17824,13 @@ var HttpClient = class {
|
|
|
17706
17824
|
this.readCache?.clear();
|
|
17707
17825
|
if (/\/V1\.0\/Companies(?:\/[^/]+)?(?:\?|$)/i.test(opts.path)) invalidateCompanyIndex(this);
|
|
17708
17826
|
}
|
|
17827
|
+
assertCheckedBase(opts) {
|
|
17828
|
+
const baseUrl = this.baseUrl;
|
|
17829
|
+
if (opts.checkedBaseUrl !== void 0 && opts.checkedBaseUrl !== baseUrl) {
|
|
17830
|
+
throw new AutotaskConfigError("The Autotask zone changed after preflight. Preview or check the target again.", { operation: opts.operation });
|
|
17831
|
+
}
|
|
17832
|
+
return baseUrl;
|
|
17833
|
+
}
|
|
17709
17834
|
/**
|
|
17710
17835
|
* One request: build URL/headers, apply the whole-call deadline, retry
|
|
17711
17836
|
* idempotent methods on 429/5xx, map failures to the typed errors.
|
|
@@ -17713,8 +17838,9 @@ var HttpClient = class {
|
|
|
17713
17838
|
*/
|
|
17714
17839
|
async request(opts) {
|
|
17715
17840
|
const method = opts.method;
|
|
17716
|
-
const
|
|
17717
|
-
const
|
|
17841
|
+
const baseUrl = this.assertCheckedBase(opts);
|
|
17842
|
+
const url = buildUrl(baseUrl, opts.path, opts.query);
|
|
17843
|
+
const wirePath = url.slice(baseUrl.length);
|
|
17718
17844
|
const path = wirePath.split("?", 1)[0];
|
|
17719
17845
|
const route = decodeURIComponent(path);
|
|
17720
17846
|
const auditTarget = auditReadTarget(route, opts.operation);
|
|
@@ -17724,13 +17850,14 @@ var HttpClient = class {
|
|
|
17724
17850
|
const queryRoute = /\/query(?:\/|$)/i.test(route);
|
|
17725
17851
|
const getQuery = method === "GET" && queryRoute && requestUrl.search !== "";
|
|
17726
17852
|
if (getQuery) assertGetQueryUrlLength(url);
|
|
17727
|
-
const
|
|
17728
|
-
const
|
|
17729
|
-
const bodyText =
|
|
17853
|
+
const recordTarget = exactRecordResponseTarget(route, method, opts.operation);
|
|
17854
|
+
const exactRecordUpdate = recordTarget === "mutation" && (method === "PUT" || method === "PATCH");
|
|
17855
|
+
const bodyText = exactRecordUpdate && opts.body !== void 0 ? serializeExactRecordUpdate(opts.body, opts.operation) : opts.body === void 0 ? void 0 : JSON.stringify(opts.body);
|
|
17730
17856
|
if (queryRoute) {
|
|
17731
17857
|
const audit = auditTarget === "query" || auditTarget === "query/count";
|
|
17732
|
-
const
|
|
17733
|
-
const
|
|
17858
|
+
const exactRecord = recordTarget === "query" || recordTarget === "query/count";
|
|
17859
|
+
const recordLabel = /^\/v1\.0\/InventoryLocations\//i.test(route) ? "inventory location" : "Knowledge Base record";
|
|
17860
|
+
const exactIdLabel = audit ? "audit log" : exactRecord ? recordLabel : void 0;
|
|
17734
17861
|
assertQueryFilters(opts, requestUrl, bodyText, exactIdLabel);
|
|
17735
17862
|
}
|
|
17736
17863
|
opts = { ...opts, path };
|
|
@@ -17746,7 +17873,7 @@ var HttpClient = class {
|
|
|
17746
17873
|
getQuery,
|
|
17747
17874
|
method,
|
|
17748
17875
|
auditTarget,
|
|
17749
|
-
|
|
17876
|
+
recordTarget,
|
|
17750
17877
|
url,
|
|
17751
17878
|
headers,
|
|
17752
17879
|
bodyText,
|
|
@@ -18327,13 +18454,13 @@ async function runBounded(fn, items, opts) {
|
|
|
18327
18454
|
const results = new Array(items.length);
|
|
18328
18455
|
let next = 0;
|
|
18329
18456
|
let failure;
|
|
18330
|
-
const
|
|
18457
|
+
const fail4 = (error, index) => {
|
|
18331
18458
|
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
18332
18459
|
};
|
|
18333
18460
|
const worker = async () => {
|
|
18334
18461
|
while (failure === void 0 && next < items.length) {
|
|
18335
18462
|
if (signal?.aborted) {
|
|
18336
|
-
|
|
18463
|
+
fail4(signal.reason, -1);
|
|
18337
18464
|
return;
|
|
18338
18465
|
}
|
|
18339
18466
|
const i = next++;
|
|
@@ -18343,7 +18470,7 @@ async function runBounded(fn, items, opts) {
|
|
|
18343
18470
|
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
18344
18471
|
} catch (error) {
|
|
18345
18472
|
if (settle) results[i] = { status: "rejected", reason: error };
|
|
18346
|
-
else
|
|
18473
|
+
else fail4(error, i);
|
|
18347
18474
|
}
|
|
18348
18475
|
}
|
|
18349
18476
|
};
|
|
@@ -18399,7 +18526,7 @@ async function capabilitySets() {
|
|
|
18399
18526
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
18400
18527
|
const udfCapable = /* @__PURE__ */ new Set();
|
|
18401
18528
|
const resources = /* @__PURE__ */ new Set();
|
|
18402
|
-
for (const rec of await
|
|
18529
|
+
for (const rec of await chunkSHJ7EOBW_cjs.loadCapabilityRecords()) {
|
|
18403
18530
|
if (rec.resource === "operations") continue;
|
|
18404
18531
|
resources.add(rec.resource);
|
|
18405
18532
|
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
@@ -18410,7 +18537,7 @@ async function capabilitySets() {
|
|
|
18410
18537
|
var derivedIndexPromise = null;
|
|
18411
18538
|
function derivedIndexLoad() {
|
|
18412
18539
|
if (derivedIndexPromise === null) {
|
|
18413
|
-
derivedIndexPromise =
|
|
18540
|
+
derivedIndexPromise = chunkSHJ7EOBW_cjs.loadCapabilityRecords().then((records) => {
|
|
18414
18541
|
const index = /* @__PURE__ */ new Map();
|
|
18415
18542
|
for (const rec of records) {
|
|
18416
18543
|
const declared = rec.metadata?.derivedFields;
|
|
@@ -18831,7 +18958,7 @@ function buildDryRunResult(spec, policy = { redactPersonalData: true }) {
|
|
|
18831
18958
|
const diffPart = spec.diff !== void 0 ? {
|
|
18832
18959
|
diff: spec.diff.map((entry) => {
|
|
18833
18960
|
if (entry.to === void 0) return entry;
|
|
18834
|
-
const to = isRedactedFieldName(entry.field, policy) ?
|
|
18961
|
+
const to = isRedactedFieldName(entry.field, policy) ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry.to, policy);
|
|
18835
18962
|
return { ...entry, to };
|
|
18836
18963
|
})
|
|
18837
18964
|
} : {};
|
|
@@ -18854,7 +18981,7 @@ function computeFieldDiff(current, data) {
|
|
|
18854
18981
|
const out = [];
|
|
18855
18982
|
for (const [field, to] of Object.entries(data)) {
|
|
18856
18983
|
if (field === "id" || to === void 0) continue;
|
|
18857
|
-
const from = current[field];
|
|
18984
|
+
const from = Object.hasOwn(current, field) ? current[field] : void 0;
|
|
18858
18985
|
if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
|
|
18859
18986
|
out.push({ field, from: from === void 0 ? null : from, to });
|
|
18860
18987
|
}
|
|
@@ -19689,7 +19816,131 @@ function same(sent, stored) {
|
|
|
19689
19816
|
return String(sent) === String(stored);
|
|
19690
19817
|
}
|
|
19691
19818
|
function notPersistedFields(sent, stored) {
|
|
19692
|
-
return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !==
|
|
19819
|
+
return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== chunkCM5O672I_cjs.REDACTED && !same(value, stored[key])).map(([key]) => key);
|
|
19820
|
+
}
|
|
19821
|
+
|
|
19822
|
+
// src/operations/invoke/inputSets.ts
|
|
19823
|
+
var PARAMS_BAG_KEYS = {
|
|
19824
|
+
query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
|
|
19825
|
+
// No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
|
|
19826
|
+
// called directly), so this entry never fires. It is KEPT so that a future
|
|
19827
|
+
// `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
|
|
19828
|
+
// cannot silently open the bag (the keys are the vendor `QueryParams` set
|
|
19829
|
+
// the raw method accepts).
|
|
19830
|
+
queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
|
|
19831
|
+
// issue #145: the count bag carries the fieldCheck opt-out — the #140
|
|
19832
|
+
// refusal's advised remedy (before, the closed bag refused the very key it
|
|
19833
|
+
// advised, and the remedy looped into a second CONFIG_ERROR).
|
|
19834
|
+
count: ["filter", "fieldCheck"]
|
|
19835
|
+
};
|
|
19836
|
+
var BAG_KEY_SYNONYMS = {
|
|
19837
|
+
filters: "filter",
|
|
19838
|
+
last: "latest",
|
|
19839
|
+
// issue #59: the expected typo class (honoured only on `query`)
|
|
19840
|
+
lmit: "limit",
|
|
19841
|
+
page: "limit",
|
|
19842
|
+
pageSize: "limit",
|
|
19843
|
+
cursor: "limit",
|
|
19844
|
+
maxrecords: "maxRecords",
|
|
19845
|
+
fieldsPreset: "includeFields"
|
|
19846
|
+
// issue #287: the preset was removed — the refusal points at the explicit includeFields
|
|
19847
|
+
};
|
|
19848
|
+
function levenshtein(a, b) {
|
|
19849
|
+
if (a === b) return 0;
|
|
19850
|
+
const prev = new Array(b.length + 1);
|
|
19851
|
+
const cur = new Array(b.length + 1);
|
|
19852
|
+
for (let j = 0; j <= b.length; j += 1) prev[j] = j;
|
|
19853
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
19854
|
+
cur[0] = i;
|
|
19855
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
19856
|
+
cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
19857
|
+
}
|
|
19858
|
+
for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
|
|
19859
|
+
}
|
|
19860
|
+
return prev[b.length] ?? 0;
|
|
19861
|
+
}
|
|
19862
|
+
function suggestForKey(key, valid) {
|
|
19863
|
+
const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
|
|
19864
|
+
if (synonym !== void 0 && valid.includes(synonym)) return synonym;
|
|
19865
|
+
let best = null;
|
|
19866
|
+
for (const v of valid) {
|
|
19867
|
+
const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
|
|
19868
|
+
if (best === null || dist < best.dist) best = { key: v, dist };
|
|
19869
|
+
}
|
|
19870
|
+
if (best !== null && best.dist <= 3) return best.key;
|
|
19871
|
+
return null;
|
|
19872
|
+
}
|
|
19873
|
+
function keySuggestions(unknown, valid) {
|
|
19874
|
+
return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
19875
|
+
}
|
|
19876
|
+
function ownQueryBag(args) {
|
|
19877
|
+
const bag = args != null && Object.hasOwn(args, 0) ? args[0] : void 0;
|
|
19878
|
+
return isRecord2(bag) ? bag : void 0;
|
|
19879
|
+
}
|
|
19880
|
+
function validateParamsBag(record, args) {
|
|
19881
|
+
if (record.inputSchemaStrict !== true) return;
|
|
19882
|
+
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
19883
|
+
if (valid === void 0) return;
|
|
19884
|
+
const bag = ownQueryBag(args);
|
|
19885
|
+
if (bag === void 0) return;
|
|
19886
|
+
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
19887
|
+
if (unknown.length === 0) return;
|
|
19888
|
+
const suggestions = keySuggestions(unknown, valid);
|
|
19889
|
+
throw new AutotaskConfigError(
|
|
19890
|
+
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
19891
|
+
{
|
|
19892
|
+
operation: record.id,
|
|
19893
|
+
suggestedAction: suggestions.length > 0 ? `Fix the key name (${suggestions.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).` : `Pass only the valid keys (${valid.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).`
|
|
19894
|
+
}
|
|
19895
|
+
);
|
|
19896
|
+
}
|
|
19897
|
+
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
|
|
19898
|
+
function validateInvokeOptions(opts, operation) {
|
|
19899
|
+
if (opts === void 0 || opts === null) return;
|
|
19900
|
+
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
19901
|
+
if (unknown.length === 0) return;
|
|
19902
|
+
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
|
|
19903
|
+
throw new AutotaskConfigError(
|
|
19904
|
+
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
|
|
19905
|
+
{
|
|
19906
|
+
operation,
|
|
19907
|
+
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
|
|
19908
|
+
}
|
|
19909
|
+
);
|
|
19910
|
+
}
|
|
19911
|
+
function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
19912
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
19913
|
+
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
19914
|
+
if (unknown.length === 0) return null;
|
|
19915
|
+
const suggestions = keySuggestions(unknown, [...validKeys]);
|
|
19916
|
+
return new AutotaskConfigError(
|
|
19917
|
+
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
19918
|
+
{
|
|
19919
|
+
...operation !== void 0 ? { operation } : {},
|
|
19920
|
+
suggestedAction: suggestions.length > 0 ? operation === void 0 ? `Fix the ${subject} name (${suggestions.join(", ")}); the tool's full contract is in the tool's inputSchema, served by the MCP client's list_tools.` : `Fix the ${subject} name (${suggestions.join(", ")}); the full contract is in the tool's inputSchema (autotask_describe).` : `Pass only the valid keys (${validKeys.join(", ")}).`
|
|
19921
|
+
}
|
|
19922
|
+
);
|
|
19923
|
+
}
|
|
19924
|
+
|
|
19925
|
+
// src/resources/special/inventoryLocations.ts
|
|
19926
|
+
var fail = (message) => {
|
|
19927
|
+
throw new AutotaskConfigError(`inventory_locations: ${message}`);
|
|
19928
|
+
};
|
|
19929
|
+
function admitInventoryLocation(value, creating) {
|
|
19930
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
19931
|
+
const body = { ...value };
|
|
19932
|
+
for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
|
|
19933
|
+
const hasName = Object.hasOwn(body, "locationName");
|
|
19934
|
+
const hasActive = Object.hasOwn(body, "isActive");
|
|
19935
|
+
if (creating && !hasName || hasName && (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");
|
|
19936
|
+
if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
|
|
19937
|
+
if (!creating && !hasName && !hasActive) fail("update must contain locationName or isActive");
|
|
19938
|
+
return body;
|
|
19939
|
+
}
|
|
19940
|
+
function checkInventoryLocationCurrent(value, current, id) {
|
|
19941
|
+
if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail("current record requires its own id");
|
|
19942
|
+
if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail("current record id must match the requested id");
|
|
19943
|
+
if (Object.hasOwn(value, "isActive") && value.isActive === false && (!Object.hasOwn(current, "isDefault") || current.isDefault !== false)) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
|
|
19693
19944
|
}
|
|
19694
19945
|
|
|
19695
19946
|
// src/resources/base/types.ts
|
|
@@ -19858,6 +20109,7 @@ var MODEL_FIELD_SETS = {
|
|
|
19858
20109
|
"expense_reports": ["id", "amountDue", "approvedDate", "approverID", "departmentNumber", "internalCurrencyCashAdvanceAmount", "internalCurrencyExpenseTotal", "name", "organizationalLevelAssociationID", "quickBooksReferenceNumber", "reimbursementCurrencyAmountDue", "reimbursementCurrencyCashAdvanceAmount", "reimbursementCurrencyID", "rejectionReason", "status", "submit", "submitDate", "submitterID", "weekEnding"],
|
|
19859
20110
|
"holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
|
|
19860
20111
|
"holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
|
|
20112
|
+
"inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
|
|
19861
20113
|
"inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
|
|
19862
20114
|
"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"],
|
|
19863
20115
|
"invoices": ["id", "batchID", "comments", "companyID", "createDateTime", "creatorResourceID", "dueDate", "fromDate", "invoiceDateTime", "invoiceEditorTemplateID", "invoiceNumber", "invoiceTotal", "isVoided", "orderNumber", "paidDate", "paymentTerm", "taxGroup", "taxRegionName", "toDate", "totalTaxValue", "voidedByResourceID", "voidedDate", "webServiceDate"],
|
|
@@ -20097,21 +20349,21 @@ function validateRelationLeaves(resourceKey, conditions, op) {
|
|
|
20097
20349
|
assertUndottedUdfField(c, op);
|
|
20098
20350
|
const field = c.field;
|
|
20099
20351
|
const [rel, sub, ...rest] = field.split(".");
|
|
20100
|
-
const
|
|
20352
|
+
const fail4 = (why) => {
|
|
20101
20353
|
throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
|
|
20102
20354
|
operation: op,
|
|
20103
20355
|
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.`
|
|
20104
20356
|
});
|
|
20105
20357
|
};
|
|
20106
20358
|
if (selfPrefixes(resourceKey).includes(rel)) {
|
|
20107
|
-
if (rest.length > 0 || !sub)
|
|
20359
|
+
if (rest.length > 0 || !sub) fail4("is not <resource>.<field> (multi-hop relations are not supported)");
|
|
20108
20360
|
continue;
|
|
20109
20361
|
}
|
|
20110
|
-
if (rest.length > 0 || !sub)
|
|
20111
|
-
if (!valid.includes(rel))
|
|
20362
|
+
if (rest.length > 0 || !sub) fail4("is not <relation>.<field> (multi-hop relations are not supported)");
|
|
20363
|
+
if (!valid.includes(rel)) fail4(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
|
|
20112
20364
|
const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
|
|
20113
20365
|
if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
|
|
20114
|
-
|
|
20366
|
+
fail4(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
|
|
20115
20367
|
}
|
|
20116
20368
|
}
|
|
20117
20369
|
};
|
|
@@ -20221,7 +20473,7 @@ var LABEL_NAME_MAX_CHARS = 200;
|
|
|
20221
20473
|
function untrustedName(name) {
|
|
20222
20474
|
if (name === null) return null;
|
|
20223
20475
|
const [[capped]] = truncateNoteChars([{ v: name }], LABEL_NAME_MAX_CHARS, ["v"]);
|
|
20224
|
-
return
|
|
20476
|
+
return chunkCM5O672I_cjs.wrapUntrusted(capped.v) ?? capped.v;
|
|
20225
20477
|
}
|
|
20226
20478
|
function readNamesOpt(client, value, where) {
|
|
20227
20479
|
if (value === void 0) return client?.config?.labels ?? false;
|
|
@@ -20439,7 +20691,7 @@ var QueryBase = class {
|
|
|
20439
20691
|
}
|
|
20440
20692
|
continueAcrossEmptyPage() {
|
|
20441
20693
|
const { key } = this.config;
|
|
20442
|
-
return isAuditLogResource(key) ||
|
|
20694
|
+
return isAuditLogResource(key) || isExactRecordResource(key);
|
|
20443
20695
|
}
|
|
20444
20696
|
/** @internal */
|
|
20445
20697
|
readPage(body, page, pageSize, state2) {
|
|
@@ -20836,7 +21088,7 @@ var QueryBase = class {
|
|
|
20836
21088
|
}
|
|
20837
21089
|
if (total <= BOUNDED_QUERY_MAX_LIMIT) {
|
|
20838
21090
|
const { items: items2, pages: pages3, guard: guard2, sliced: sliced2, cursor: cursor2 } = await this.walkBounded(params, total);
|
|
20839
|
-
if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.
|
|
21091
|
+
if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 }) || !this.hasCompleteExactRecordWindow(items2, total)) {
|
|
20840
21092
|
throw this.latestWindowIncompleteError(total);
|
|
20841
21093
|
}
|
|
20842
21094
|
return this.finishLatest(items2, latest, pages3);
|
|
@@ -20845,11 +21097,11 @@ var QueryBase = class {
|
|
|
20845
21097
|
probes += 1;
|
|
20846
21098
|
if (probes > LATEST_MAX_COUNT_PROBES) throw this.latestThresholdUnresolvedError();
|
|
20847
21099
|
};
|
|
20848
|
-
const
|
|
20849
|
-
let lo =
|
|
21100
|
+
const exactRecord = isExactRecordResource(this.config.key);
|
|
21101
|
+
let lo = exactRecord ? -1n : 0n;
|
|
20850
21102
|
let hi;
|
|
20851
21103
|
let aboveThreshold = 0;
|
|
20852
|
-
if (isAuditLogResource(this.config.key) ||
|
|
21104
|
+
if (isAuditLogResource(this.config.key) || exactRecord) {
|
|
20853
21105
|
hi = BigInt(MAX_AUDIT_ID);
|
|
20854
21106
|
} else {
|
|
20855
21107
|
for (let t = 1n; ; t = t << 1n) {
|
|
@@ -20870,17 +21122,17 @@ var QueryBase = class {
|
|
|
20870
21122
|
aboveThreshold = above;
|
|
20871
21123
|
} else lo = mid;
|
|
20872
21124
|
}
|
|
20873
|
-
if (
|
|
21125
|
+
if (exactRecord && aboveThreshold !== latest) throw this.latestWindowIncompleteError(latest + 1);
|
|
20874
21126
|
const windowValue = hi <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(hi) : hi.toString();
|
|
20875
21127
|
const window = [...baseConds, { op: "gte", field: "id", value: windowValue }];
|
|
20876
21128
|
const { items, pages: pages2, guard, sliced, cursor } = await this.walkBounded({ ...params, filter: window }, latest + 1);
|
|
20877
|
-
if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.
|
|
21129
|
+
if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor }) || !this.hasCompleteExactRecordWindow(items, latest + 1, hi)) {
|
|
20878
21130
|
throw this.latestWindowIncompleteError(latest + 1);
|
|
20879
21131
|
}
|
|
20880
21132
|
return this.finishLatest(items, latest, pages2);
|
|
20881
21133
|
}
|
|
20882
|
-
|
|
20883
|
-
if (!
|
|
21134
|
+
hasCompleteExactRecordWindow(items, expected, minimum) {
|
|
21135
|
+
if (!isExactRecordResource(this.config.key)) return true;
|
|
20884
21136
|
if (items.length !== expected) return false;
|
|
20885
21137
|
const ids2 = items.map((item) => String(item.id));
|
|
20886
21138
|
if (new Set(ids2).size !== expected) return false;
|
|
@@ -21027,10 +21279,12 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21027
21279
|
return cachedMetadataGet(this.http, this.config.key, kind, path, operation, unwrap, fresh, maxRetries);
|
|
21028
21280
|
}
|
|
21029
21281
|
/** `GET /V1.0/<E>/{id}` → `{ item }` unwrapped (`item: null` → NotFoundError). */
|
|
21030
|
-
async getGlobal(id, fresh = false, maxRetries) {
|
|
21282
|
+
async getGlobal(id, fresh = false, maxRetries, checkedBaseUrl) {
|
|
21031
21283
|
const numeric2 = parseIdentifier(id, "id");
|
|
21032
|
-
const
|
|
21033
|
-
|
|
21284
|
+
const path = `${this.resourcePath}/${numeric2}`;
|
|
21285
|
+
const operation = `${this.config.key}.get`;
|
|
21286
|
+
const res = checkedBaseUrl === void 0 ? await this.cachedGet(path, operation, fresh, maxRetries) : await this.http.request({ method: "GET", path, operation, maxRetries, checkedBaseUrl });
|
|
21287
|
+
return unwrapItem(res, numeric2, operation, this.entityName);
|
|
21034
21288
|
}
|
|
21035
21289
|
/**
|
|
21036
21290
|
* V2 merge read: a FRESH single-record GET that skips response redaction
|
|
@@ -21100,8 +21354,8 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21100
21354
|
if (Object.keys(body).length === 0) {
|
|
21101
21355
|
throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
|
|
21102
21356
|
}
|
|
21103
|
-
if ("item"
|
|
21104
|
-
if (Array.isArray(body.items)) {
|
|
21357
|
+
if (Object.hasOwn(body, "item")) return unwrapItem(body, id, void 0, entity);
|
|
21358
|
+
if (Object.hasOwn(body, "items") && Array.isArray(body.items)) {
|
|
21105
21359
|
const first = body.items[0];
|
|
21106
21360
|
if (first === null || first === void 0) {
|
|
21107
21361
|
throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
|
|
@@ -21547,26 +21801,26 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21547
21801
|
|
|
21548
21802
|
// src/resources/special/knowledgeBaseCategories.ts
|
|
21549
21803
|
function admitKnowledgeBaseCategory(data, creating, staleToken) {
|
|
21550
|
-
const
|
|
21804
|
+
const fail4 = (message) => {
|
|
21551
21805
|
throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
|
|
21552
21806
|
};
|
|
21553
|
-
if (!creating && staleToken !== void 0)
|
|
21554
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
21807
|
+
if (!creating && staleToken !== void 0) fail4("no documented stale timestamp is available");
|
|
21808
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
21555
21809
|
const body = { ...data };
|
|
21556
|
-
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field))
|
|
21810
|
+
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail4(`${field} is not a writable KnowledgeBaseCategories field`);
|
|
21557
21811
|
for (const [field, max] of [["name", 50], ["description", 1e3]]) {
|
|
21558
21812
|
const value = body[field];
|
|
21559
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > max))
|
|
21813
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail4(`${field} must be a string of at most ${max} characters`);
|
|
21560
21814
|
}
|
|
21561
|
-
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === ""))
|
|
21562
|
-
if (creating && body.parentCategoryID === void 0)
|
|
21815
|
+
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail4("name is required");
|
|
21816
|
+
if (creating && body.parentCategoryID === void 0) fail4("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
|
|
21563
21817
|
const parent = body.parentCategoryID;
|
|
21564
21818
|
if (parent !== void 0) {
|
|
21565
|
-
if (typeof parent !== "number") return
|
|
21819
|
+
if (typeof parent !== "number") return fail4("parentCategoryID must be a numeric identifier");
|
|
21566
21820
|
parseIdentifier(parent, "parentCategoryID");
|
|
21567
|
-
if (parent > 2147483647)
|
|
21821
|
+
if (parent > 2147483647) fail4("parentCategoryID must fit a signed 32-bit integer");
|
|
21568
21822
|
}
|
|
21569
|
-
if (!creating && !Object.values(body).some((value) => value !== void 0))
|
|
21823
|
+
if (!creating && !Object.values(body).some((value) => value !== void 0)) fail4("update must contain a writable field");
|
|
21570
21824
|
return body;
|
|
21571
21825
|
}
|
|
21572
21826
|
function categoryReplacement(body) {
|
|
@@ -21580,45 +21834,45 @@ function categoryReplacement(body) {
|
|
|
21580
21834
|
}
|
|
21581
21835
|
|
|
21582
21836
|
// src/resources/special/knowledgeBaseArticles.ts
|
|
21583
|
-
function
|
|
21837
|
+
function fail2(detail) {
|
|
21584
21838
|
throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
|
|
21585
21839
|
}
|
|
21586
21840
|
function reference(value, name) {
|
|
21587
|
-
if (typeof value !== "number")
|
|
21841
|
+
if (typeof value !== "number") fail2(`${name} must be a numeric identifier`);
|
|
21588
21842
|
parseIdentifier(value, name);
|
|
21589
|
-
if (value > 2147483647)
|
|
21843
|
+
if (value > 2147483647) fail2(`${name} must fit a signed 32-bit integer`);
|
|
21590
21844
|
return value;
|
|
21591
21845
|
}
|
|
21592
21846
|
function articleParent(value) {
|
|
21593
21847
|
const parent = parseIdentifier(value, "parentId");
|
|
21594
|
-
if (typeof parent !== "number" || parent > 2147483647)
|
|
21595
|
-
if (parent === 0)
|
|
21848
|
+
if (typeof parent !== "number" || parent > 2147483647) fail2("parentId must fit a signed 32-bit category identifier");
|
|
21849
|
+
if (parent === 0) fail2("parentId must name an article category");
|
|
21596
21850
|
return parent;
|
|
21597
21851
|
}
|
|
21598
21852
|
function admitArticle(data, parentId, creating) {
|
|
21599
21853
|
const parent = articleParent(parentId);
|
|
21600
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
21854
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
|
|
21601
21855
|
const body = { ...data };
|
|
21602
21856
|
const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
|
|
21603
21857
|
for (const key of Object.keys(body)) {
|
|
21604
|
-
if (!allowed.includes(key))
|
|
21858
|
+
if (!allowed.includes(key)) fail2(`${key} is not a writable article root field`);
|
|
21605
21859
|
if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
|
|
21606
21860
|
}
|
|
21607
21861
|
for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
|
|
21608
|
-
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max))
|
|
21609
|
-
}
|
|
21610
|
-
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim()))
|
|
21611
|
-
if (!creating && Object.hasOwn(body, "articleCategoryID"))
|
|
21612
|
-
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent))
|
|
21613
|
-
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647))
|
|
21614
|
-
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean")
|
|
21615
|
-
if (!creating && !Object.keys(body).length)
|
|
21862
|
+
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail2(`${field} must be a string of at most ${max} characters`);
|
|
21863
|
+
}
|
|
21864
|
+
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail2("title is required and cannot be blank");
|
|
21865
|
+
if (!creating && Object.hasOwn(body, "articleCategoryID")) fail2("articleCategoryID is read-only after creation");
|
|
21866
|
+
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail2("articleCategoryID must match parentId");
|
|
21867
|
+
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");
|
|
21868
|
+
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail2("isActive must be boolean");
|
|
21869
|
+
if (!creating && !Object.keys(body).length) fail2("update must contain a writable field");
|
|
21616
21870
|
return body;
|
|
21617
21871
|
}
|
|
21618
21872
|
async function guardArticle(http, parentId, id, maxRetries) {
|
|
21619
21873
|
const parent = articleParent(parentId);
|
|
21620
21874
|
const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
|
|
21621
|
-
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target))))
|
|
21875
|
+
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail2("id must name an article within the signed 64-bit range");
|
|
21622
21876
|
unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
|
|
21623
21877
|
if (target !== void 0) {
|
|
21624
21878
|
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");
|
|
@@ -21627,7 +21881,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
|
|
|
21627
21881
|
}
|
|
21628
21882
|
function assertArticlePublish(data, fields) {
|
|
21629
21883
|
if (!Object.hasOwn(data, "publish")) return;
|
|
21630
|
-
const unavailable = () =>
|
|
21884
|
+
const unavailable = () => fail2("publish requires an unambiguous active value in current field metadata");
|
|
21631
21885
|
if (!Array.isArray(fields)) unavailable();
|
|
21632
21886
|
const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
|
|
21633
21887
|
if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
|
|
@@ -21651,7 +21905,7 @@ var MutationBase = class extends MetaBase {
|
|
|
21651
21905
|
/** Normalise a mutation body: `id` OR `itemId` → `id`; UDF map → UDF array (UDF-capable only). */
|
|
21652
21906
|
normalizeMutationBody(data) {
|
|
21653
21907
|
const body = { ...data };
|
|
21654
|
-
if (body.itemId !== void 0 && body.id === void 0) {
|
|
21908
|
+
if (Object.hasOwn(body, "itemId") && body.itemId !== void 0 && (!Object.hasOwn(body, "id") || body.id === void 0)) {
|
|
21655
21909
|
body.id = body.itemId;
|
|
21656
21910
|
delete body.itemId;
|
|
21657
21911
|
}
|
|
@@ -21833,23 +22087,31 @@ var MutationBase = class extends MetaBase {
|
|
|
21833
22087
|
* write already happened, so a failed read-back is reported on the result
|
|
21834
22088
|
* (`persistedCheckFailed`: the error code, or `UNKNOWN (<error name>)`), never thrown.
|
|
21835
22089
|
*/
|
|
21836
|
-
async withPersistedCheck(result, data, opts, id, parentId) {
|
|
22090
|
+
async withPersistedCheck(result, data, opts, id, parentId, checkedBaseUrl) {
|
|
21837
22091
|
if (opts.verifyPersisted !== true) return result;
|
|
21838
|
-
const maxRetries =
|
|
22092
|
+
const maxRetries = isExactRecordResource(this.config.key) ? opts.maxRetries : void 0;
|
|
21839
22093
|
try {
|
|
21840
|
-
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);
|
|
21841
|
-
|
|
22094
|
+
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);
|
|
22095
|
+
const submitted = data;
|
|
22096
|
+
const persisted = stored;
|
|
22097
|
+
if (this.config.key === "inventory_locations") {
|
|
22098
|
+
if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError("inventory_locations: persisted record requires its own id");
|
|
22099
|
+
validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
|
|
22100
|
+
}
|
|
22101
|
+
const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
22102
|
+
return { ...result, notPersisted };
|
|
21842
22103
|
} catch (err) {
|
|
21843
22104
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
21844
22105
|
}
|
|
21845
22106
|
}
|
|
21846
|
-
async updateGlobal(id, data, opts = {}, method = "PUT") {
|
|
22107
|
+
async updateGlobal(id, data, opts = {}, method = "PUT", checkedBaseUrl) {
|
|
21847
22108
|
const numeric2 = parseIdentifier(id, "id");
|
|
21848
22109
|
const operation = `${this.config.key}.update`;
|
|
21849
22110
|
let body = this.normalizeMutationBody(data);
|
|
21850
|
-
const
|
|
22111
|
+
const partialCollection = checkedBaseUrl !== void 0;
|
|
22112
|
+
const collectionUpdate = partialCollection || this.config.collectionUpdate === true;
|
|
21851
22113
|
if (collectionUpdate) {
|
|
21852
|
-
if (opts.raw !== true) {
|
|
22114
|
+
if (!partialCollection && opts.raw !== true) {
|
|
21853
22115
|
let current;
|
|
21854
22116
|
try {
|
|
21855
22117
|
current = await this.getGlobalUnredacted(numeric2, { maxRetries: opts.maxRetries });
|
|
@@ -21873,7 +22135,9 @@ var MutationBase = class extends MetaBase {
|
|
|
21873
22135
|
path: collectionUpdate ? this.resourcePath : `${this.resourcePath}/${numeric2}`,
|
|
21874
22136
|
body,
|
|
21875
22137
|
operation,
|
|
21876
|
-
maxRetries: opts.maxRetries
|
|
22138
|
+
maxRetries: opts.maxRetries,
|
|
22139
|
+
// The preflight facts must be checked again before any later PATCH.
|
|
22140
|
+
...partialCollection ? { maintenanceMaxWaitMs: 0, checkedBaseUrl } : {}
|
|
21877
22141
|
});
|
|
21878
22142
|
} catch (err) {
|
|
21879
22143
|
if (method === "PATCH" || !this.putFallbackEligible(err)) throw err;
|
|
@@ -21900,7 +22164,7 @@ var MutationBase = class extends MetaBase {
|
|
|
21900
22164
|
}
|
|
21901
22165
|
return this.withPersistedCheck(unwrapOperation(retry, operation), data, opts, numeric2);
|
|
21902
22166
|
}
|
|
21903
|
-
return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2);
|
|
22167
|
+
return this.withPersistedCheck(unwrapOperation(res, operation), data, opts, numeric2, void 0, checkedBaseUrl);
|
|
21904
22168
|
}
|
|
21905
22169
|
/** `DELETE /V1.0/<E>/{id}` → `{ id }` (OperationResultModel). A blank 2xx
|
|
21906
22170
|
* (204 / empty body) is a valid vendor delete answer — synthesize the
|
|
@@ -22210,21 +22474,22 @@ var MutationBase = class extends MetaBase {
|
|
|
22210
22474
|
* check (mismatch throws STALE_OBJECT) and the best-effort `diff`. NO
|
|
22211
22475
|
* mutating request is issued.
|
|
22212
22476
|
*/
|
|
22213
|
-
async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord) {
|
|
22477
|
+
async runUpdateDryRun(id, data, opts = {}, parentId, currentRecord, partialCollection) {
|
|
22214
22478
|
const operation = `${this.config.key}.update`;
|
|
22215
22479
|
const checks = [];
|
|
22216
22480
|
const warnings = [];
|
|
22217
22481
|
checks.push({ name: "input-validation", ok: isRecord2(data) && Object.keys(data).length > 0 });
|
|
22218
22482
|
const scopedUpdate = parentId !== void 0 && this.config.parentScopedPath !== void 0;
|
|
22219
|
-
const collectionUpdate = scopedUpdate || this.config.collectionUpdate === true;
|
|
22483
|
+
const collectionUpdate = scopedUpdate || partialCollection !== void 0 || this.config.collectionUpdate === true;
|
|
22220
22484
|
const path = scopedUpdate ? this.scopedCollectionPath(parentId) : collectionUpdate ? this.resourcePath : `${this.resourcePath}/${id}`;
|
|
22221
|
-
const method = scopedUpdate ? "PATCH" : "PUT";
|
|
22485
|
+
const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
|
|
22222
22486
|
let current;
|
|
22223
22487
|
try {
|
|
22224
|
-
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));
|
|
22488
|
+
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));
|
|
22225
22489
|
} catch (err) {
|
|
22226
22490
|
if (err instanceof NotFoundError) {
|
|
22227
|
-
const
|
|
22491
|
+
const reasons = EMPTY_REASON_STAMPS[this.config.key];
|
|
22492
|
+
const updateReason = reasons?.update ?? (partialCollection === void 0 ? void 0 : reasons?.get);
|
|
22228
22493
|
checks.push({
|
|
22229
22494
|
name: "current-record-exists",
|
|
22230
22495
|
ok: false,
|
|
@@ -22239,18 +22504,19 @@ var MutationBase = class extends MetaBase {
|
|
|
22239
22504
|
checks,
|
|
22240
22505
|
impact: { affected: 1, scope: "single-record", reversible: true },
|
|
22241
22506
|
warnings,
|
|
22242
|
-
data,
|
|
22507
|
+
data: partialCollection === void 0 ? data : { ...data, id },
|
|
22243
22508
|
...updateReason !== void 0 ? { emptyReason: updateReason } : {}
|
|
22244
22509
|
}, { redactPersonalData: this.http.redactPersonalData });
|
|
22245
22510
|
}
|
|
22246
22511
|
throw err;
|
|
22247
22512
|
}
|
|
22248
22513
|
checks.push({ name: "current-record-exists", ok: true });
|
|
22514
|
+
partialCollection?.checkCurrent(current);
|
|
22249
22515
|
if (this.staleObjectCheck(current, opts, operation)) {
|
|
22250
22516
|
checks.push({ name: "stale-check", ok: true });
|
|
22251
22517
|
}
|
|
22252
22518
|
let envelopeData = data;
|
|
22253
|
-
if (this.config.key === "knowledge_base_articles") {
|
|
22519
|
+
if (partialCollection !== void 0 || this.config.key === "knowledge_base_articles") {
|
|
22254
22520
|
envelopeData = { ...this.normalizeMutationBody(data), id };
|
|
22255
22521
|
} else if (parentId === void 0 && this.config.collectionUpdate === true && opts.raw !== true) {
|
|
22256
22522
|
const merged = mergePartialBody(current, this.normalizeMutationBody(data));
|
|
@@ -22327,34 +22593,34 @@ var BaseResource = class extends MutationBase {
|
|
|
22327
22593
|
};
|
|
22328
22594
|
|
|
22329
22595
|
// src/resources/special/taskPredecessors.ts
|
|
22330
|
-
function
|
|
22596
|
+
function fail3(detail) {
|
|
22331
22597
|
throw new AutotaskConfigError(`task_predecessors: ${detail}`);
|
|
22332
22598
|
}
|
|
22333
22599
|
function numeric(value, field) {
|
|
22334
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
22600
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail3(`${field} must be a positive numeric identifier`);
|
|
22335
22601
|
return value;
|
|
22336
22602
|
}
|
|
22337
22603
|
function predecessorParent(value) {
|
|
22338
22604
|
const parent = parseIdentifier(value, "parentId");
|
|
22339
|
-
if (parent === 0)
|
|
22605
|
+
if (parent === 0) fail3("parentId must name a successor task");
|
|
22340
22606
|
return parent;
|
|
22341
22607
|
}
|
|
22342
22608
|
function assertPredecessorBinding(value, parentId, id) {
|
|
22343
|
-
if (!isRecord2(value))
|
|
22344
|
-
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId)))
|
|
22609
|
+
if (!isRecord2(value)) fail3("the returned record must establish id and successorTaskID parent");
|
|
22610
|
+
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");
|
|
22345
22611
|
}
|
|
22346
22612
|
function admitTaskPredecessor(data, parentId, creating) {
|
|
22347
22613
|
const parent = predecessorParent(parentId);
|
|
22348
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22614
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
|
|
22349
22615
|
const payload = { ...data };
|
|
22350
22616
|
const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
|
|
22351
|
-
if (Object.keys(payload).some((key) => !allowed.includes(key)))
|
|
22352
|
-
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647))
|
|
22617
|
+
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");
|
|
22618
|
+
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");
|
|
22353
22619
|
if (creating) {
|
|
22354
22620
|
const successor = numeric(payload.successorTaskID, "successorTaskID");
|
|
22355
22621
|
const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
|
|
22356
|
-
if (String(successor) !== String(parent))
|
|
22357
|
-
if (predecessor === successor)
|
|
22622
|
+
if (String(successor) !== String(parent)) fail3("successorTaskID must match parentId");
|
|
22623
|
+
if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
|
|
22358
22624
|
}
|
|
22359
22625
|
return payload;
|
|
22360
22626
|
}
|
|
@@ -22363,50 +22629,50 @@ async function guardTaskPredecessor(http, parentId, id, data) {
|
|
|
22363
22629
|
let row = data;
|
|
22364
22630
|
if (id !== void 0) {
|
|
22365
22631
|
const target = parseIdentifier(id, "id");
|
|
22366
|
-
if (target === 0)
|
|
22632
|
+
if (target === 0) fail3("id must name a predecessor relationship");
|
|
22367
22633
|
row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
|
|
22368
22634
|
assertPredecessorBinding(row, parent, target);
|
|
22369
22635
|
}
|
|
22370
22636
|
const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
|
|
22371
22637
|
const successor = numeric(row?.successorTaskID, "successorTaskID");
|
|
22372
|
-
if (predecessor === successor)
|
|
22638
|
+
if (predecessor === successor) fail3("predecessorTaskID and successorTaskID must be distinct");
|
|
22373
22639
|
const projects = [];
|
|
22374
22640
|
for (const taskId of [predecessor, successor]) {
|
|
22375
22641
|
const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
|
|
22376
|
-
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId))
|
|
22642
|
+
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail3("the returned task must match its requested id");
|
|
22377
22643
|
projects.push(numeric(task.projectID, "task.projectID"));
|
|
22378
22644
|
}
|
|
22379
|
-
if (projects[0] !== projects[1])
|
|
22645
|
+
if (projects[0] !== projects[1]) fail3("predecessor and successor tasks must belong to the same project");
|
|
22380
22646
|
}
|
|
22381
22647
|
|
|
22382
22648
|
// src/resources/special/taskNotes.ts
|
|
22383
22649
|
var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
|
|
22384
22650
|
function admitTaskNote(data, parentId, creating) {
|
|
22385
22651
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22386
|
-
const
|
|
22652
|
+
const fail4 = (message) => {
|
|
22387
22653
|
throw new AutotaskConfigError(`task_notes: ${message}`);
|
|
22388
22654
|
};
|
|
22389
|
-
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
22655
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) fail4("data must be a record");
|
|
22390
22656
|
const body = data;
|
|
22391
|
-
for (const key of Object.keys(body)) if (!WRITABLE.has(key))
|
|
22657
|
+
for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail4(`${key} is not a writable TaskNotes field`);
|
|
22392
22658
|
for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
|
|
22393
22659
|
const value = body[field];
|
|
22394
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > maximum))
|
|
22660
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail4(`${field} must be a string of at most ${maximum} characters`);
|
|
22395
22661
|
}
|
|
22396
|
-
if (creating && (typeof body.description !== "string" || body.description.trim() === ""))
|
|
22662
|
+
if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail4("description is required");
|
|
22397
22663
|
for (const field of ["noteType", "publish"]) {
|
|
22398
22664
|
const value = body[field];
|
|
22399
|
-
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value)))
|
|
22665
|
+
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail4(`${field} must be an integer from the current field metadata`);
|
|
22400
22666
|
}
|
|
22401
|
-
if (creating && body.taskID === void 0)
|
|
22667
|
+
if (creating && body.taskID === void 0) fail4("taskID is required in the create body and must match parentId");
|
|
22402
22668
|
for (const field of ["createdByContactID", "taskID"]) {
|
|
22403
22669
|
if (body[field] !== void 0) {
|
|
22404
|
-
if (typeof body[field] !== "number")
|
|
22670
|
+
if (typeof body[field] !== "number") fail4(`${field} must be a numeric identifier`);
|
|
22405
22671
|
const id = parseIdentifier(body[field], field);
|
|
22406
|
-
if (field === "taskID" && String(id) !== String(parent))
|
|
22672
|
+
if (field === "taskID" && String(id) !== String(parent)) fail4("taskID must match the parentId path argument");
|
|
22407
22673
|
}
|
|
22408
22674
|
}
|
|
22409
|
-
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId"))
|
|
22675
|
+
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail4("update must contain a writable field");
|
|
22410
22676
|
}
|
|
22411
22677
|
|
|
22412
22678
|
// src/operations/invoke/fieldSuggest.ts
|
|
@@ -22627,8 +22893,8 @@ function unknownNamesSuggestedAction(record, authority, filterUnknown) {
|
|
|
22627
22893
|
return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
|
|
22628
22894
|
}
|
|
22629
22895
|
async function validateQueryFieldNames(record, holder, args) {
|
|
22630
|
-
const bag = args
|
|
22631
|
-
if (
|
|
22896
|
+
const bag = ownQueryBag(args);
|
|
22897
|
+
if (bag === void 0) return;
|
|
22632
22898
|
const fieldCheck = readFieldCheck(record, bag);
|
|
22633
22899
|
const includeNames = readIncludeNames(record, bag["includeFields"]);
|
|
22634
22900
|
let filterNames;
|
|
@@ -22676,38 +22942,38 @@ function isBase64(value) {
|
|
|
22676
22942
|
}
|
|
22677
22943
|
function admitTaskAttachment(data, parentId) {
|
|
22678
22944
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22679
|
-
const
|
|
22945
|
+
const fail4 = (message) => {
|
|
22680
22946
|
throw new AutotaskConfigError(`task_attachments: ${message}`);
|
|
22681
22947
|
};
|
|
22682
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22948
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22683
22949
|
const body = data;
|
|
22684
|
-
for (const field of Object.keys(body)) if (!WRITABLE2.has(field))
|
|
22950
|
+
for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail4(`${field} is not a supported create field`);
|
|
22685
22951
|
for (const field of ["attachmentType", "fullPath", "title"]) {
|
|
22686
|
-
if (typeof body[field] !== "string" || body[field].trim() === "")
|
|
22952
|
+
if (typeof body[field] !== "string" || body[field].trim() === "") fail4(`${field} is required and must be a non-empty string`);
|
|
22687
22953
|
}
|
|
22688
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
22954
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
|
|
22689
22955
|
for (const field of ["data", "contentType"]) {
|
|
22690
|
-
if (body[field] !== void 0 && typeof body[field] !== "string")
|
|
22956
|
+
if (body[field] !== void 0 && typeof body[field] !== "string") fail4(`${field} must be a string`);
|
|
22691
22957
|
}
|
|
22692
22958
|
if (body.attachmentType === "FILE_ATTACHMENT") {
|
|
22693
|
-
if (typeof body.data !== "string" || body.data === "") return
|
|
22694
|
-
if (!isBase64(body.data))
|
|
22959
|
+
if (typeof body.data !== "string" || body.data === "") return fail4("FILE_ATTACHMENT requires non-empty base64 data");
|
|
22960
|
+
if (!isBase64(body.data)) fail4("FILE_ATTACHMENT data must be base64 encoded");
|
|
22695
22961
|
}
|
|
22696
22962
|
if (body.taskID !== void 0) {
|
|
22697
|
-
if (typeof body.taskID !== "number")
|
|
22698
|
-
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent))
|
|
22963
|
+
if (typeof body.taskID !== "number") fail4("taskID must be a numeric identifier");
|
|
22964
|
+
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail4("taskID must match the parentId path argument");
|
|
22699
22965
|
}
|
|
22700
22966
|
if (body.parentAttachmentID !== void 0) {
|
|
22701
|
-
if (typeof body.parentAttachmentID !== "number")
|
|
22967
|
+
if (typeof body.parentAttachmentID !== "number") fail4("parentAttachmentID must be a numeric identifier");
|
|
22702
22968
|
parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
|
|
22703
22969
|
}
|
|
22704
22970
|
}
|
|
22705
22971
|
function admitFileAttachment(resource, data, parentId) {
|
|
22706
22972
|
parseIdentifier(parentId, "parentId");
|
|
22707
|
-
const
|
|
22973
|
+
const fail4 = (message) => {
|
|
22708
22974
|
throw new AutotaskConfigError(`${resource}: ${message}`);
|
|
22709
22975
|
};
|
|
22710
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22976
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22711
22977
|
const body = data;
|
|
22712
22978
|
const reference2 = {
|
|
22713
22979
|
project_attachments: void 0,
|
|
@@ -22720,20 +22986,20 @@ function admitFileAttachment(resource, data, parentId) {
|
|
|
22720
22986
|
configuration_item_attachments: "parentAttachmentID",
|
|
22721
22987
|
configuration_item_note_attachments: void 0
|
|
22722
22988
|
}[resource];
|
|
22723
|
-
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2)
|
|
22724
|
-
if (body.attachmentType !== "FILE_ATTACHMENT")
|
|
22989
|
+
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail4(`${field} is not a supported create field`);
|
|
22990
|
+
if (body.attachmentType !== "FILE_ATTACHMENT") fail4("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
|
|
22725
22991
|
const maxLength = resource === "project_attachments" ? void 0 : 255;
|
|
22726
22992
|
for (const field of ["fullPath", "title"]) {
|
|
22727
22993
|
const value = body[field];
|
|
22728
22994
|
const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
|
|
22729
|
-
if (typeof value !== "string" || value.trim() === "") return
|
|
22730
|
-
if (maxLength !== void 0 && value.length > maxLength)
|
|
22995
|
+
if (typeof value !== "string" || value.trim() === "") return fail4(requirement);
|
|
22996
|
+
if (maxLength !== void 0 && value.length > maxLength) fail4(requirement);
|
|
22731
22997
|
}
|
|
22732
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
22733
|
-
if (typeof body.data !== "string" || !isBase64(body.data))
|
|
22998
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail4("publish must be an integer from current field metadata");
|
|
22999
|
+
if (typeof body.data !== "string" || !isBase64(body.data)) fail4("FILE_ATTACHMENT requires nonempty base64 data");
|
|
22734
23000
|
if (reference2 !== void 0 && body[reference2] !== void 0) {
|
|
22735
|
-
if (typeof body[reference2] !== "number")
|
|
22736
|
-
if (parseIdentifier(body[reference2], reference2) === 0)
|
|
23001
|
+
if (typeof body[reference2] !== "number") fail4(`${reference2} must be a numeric identifier`);
|
|
23002
|
+
if (parseIdentifier(body[reference2], reference2) === 0) fail4(`${reference2} must be positive`);
|
|
22737
23003
|
}
|
|
22738
23004
|
}
|
|
22739
23005
|
function admitScopedAttachmentQuery(resource, params) {
|
|
@@ -23582,6 +23848,16 @@ var SIMPLE_RESOURCES = [
|
|
|
23582
23848
|
helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23583
23849
|
opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
|
|
23584
23850
|
},
|
|
23851
|
+
{
|
|
23852
|
+
key: "inventory_locations",
|
|
23853
|
+
accessor: "inventoryLocations",
|
|
23854
|
+
resourcePath: "/V1.0/InventoryLocations",
|
|
23855
|
+
deletable: false,
|
|
23856
|
+
udfCapable: false,
|
|
23857
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
23858
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23859
|
+
opForms: { get: "global", create: "global", update: "global" }
|
|
23860
|
+
},
|
|
23585
23861
|
{
|
|
23586
23862
|
key: "invoice_templates",
|
|
23587
23863
|
accessor: "invoiceTemplates",
|
|
@@ -24477,7 +24753,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24477
24753
|
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 () => {
|
|
24478
24754
|
throw new OperationNotSupportedError(config.key, "getUdfInfo");
|
|
24479
24755
|
};
|
|
24480
|
-
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles"].includes(config.key)) this.createIfNotExists = async () => {
|
|
24756
|
+
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
|
|
24481
24757
|
throw new OperationNotSupportedError(config.key, "createIfNotExists");
|
|
24482
24758
|
};
|
|
24483
24759
|
if (config.key === "knowledge_base_categories") {
|
|
@@ -24592,9 +24868,9 @@ var GenericResource = class extends BaseResource {
|
|
|
24592
24868
|
return this.createScopedRaw(parentId, data2, opts2);
|
|
24593
24869
|
}
|
|
24594
24870
|
if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
|
|
24595
|
-
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : a;
|
|
24871
|
+
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
|
|
24596
24872
|
const supplied = b;
|
|
24597
|
-
const opts = this.config.key
|
|
24873
|
+
const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
24598
24874
|
if (opts.dryRun === true) return this.runCreateDryRun(data);
|
|
24599
24875
|
return this.createGlobal(data, opts);
|
|
24600
24876
|
}
|
|
@@ -24621,8 +24897,24 @@ var GenericResource = class extends BaseResource {
|
|
|
24621
24897
|
}
|
|
24622
24898
|
if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
|
|
24623
24899
|
const category = this.config.key === "knowledge_base_categories";
|
|
24624
|
-
const
|
|
24900
|
+
const location = this.config.key === "inventory_locations";
|
|
24901
|
+
const id = category || location ? parseIdentifier(a, "id") : a;
|
|
24625
24902
|
const supplied = c;
|
|
24903
|
+
if (location) {
|
|
24904
|
+
const body = admitInventoryLocation(b, false);
|
|
24905
|
+
const opts2 = snapshotMutationOptions(supplied);
|
|
24906
|
+
if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
|
|
24907
|
+
const checkCurrent = (current) => checkInventoryLocationCurrent(body, current, id);
|
|
24908
|
+
if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
|
|
24909
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
24910
|
+
try {
|
|
24911
|
+
checkCurrent(await this.getGlobal(id, true, opts2.maxRetries, checkedBaseUrl));
|
|
24912
|
+
} catch (error) {
|
|
24913
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
24914
|
+
throw error;
|
|
24915
|
+
}
|
|
24916
|
+
return this.updateGlobal(id, body, opts2, "PATCH", checkedBaseUrl);
|
|
24917
|
+
}
|
|
24626
24918
|
const opts = category ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
24627
24919
|
if (category && opts.raw === true) throw new AutotaskConfigError("knowledge_base_categories: raw update is unsupported; a fresh merge is required");
|
|
24628
24920
|
const data = category ? admitKnowledgeBaseCategory(b, false, opts.lastModifiedDate) : b;
|
|
@@ -25927,7 +26219,11 @@ function resolveDispatchArgs(record, argsIn) {
|
|
|
25927
26219
|
const names = Object.keys(schema);
|
|
25928
26220
|
const unknown = Object.keys(byName).filter((k) => !names.includes(k));
|
|
25929
26221
|
if (unknown.length > 0) bad(`has no input named ${unknown.slice(0, 10).map((k) => `"${k}"`).join(", ")}${unknown.length > 10 ? ` (and ${unknown.length - 10} more)` : ""} (declared: ${declaredArgList(record)})`);
|
|
25930
|
-
const values = names.map((
|
|
26222
|
+
const values = names.map((name) => {
|
|
26223
|
+
if (Object.hasOwn(byName, name)) return byName[name];
|
|
26224
|
+
if (!schema[name].required && name in byName) bad(`named input "${name}" must be supplied directly`);
|
|
26225
|
+
return void 0;
|
|
26226
|
+
});
|
|
25931
26227
|
const missing = names.filter((n, i) => schema[n].required && values[i] === void 0);
|
|
25932
26228
|
if (missing.length > 0) bad(`requires named input ${missing.map((k) => `"${k}"`).join(", ")} (declared: ${declaredArgList(record)})`);
|
|
25933
26229
|
const last = values.findLastIndex((value) => value !== void 0);
|
|
@@ -25959,12 +26255,26 @@ function captureDispatchArgs(record, argsIn) {
|
|
|
25959
26255
|
);
|
|
25960
26256
|
}
|
|
25961
26257
|
const captured = [];
|
|
26258
|
+
const isWrite = record.effect !== "read";
|
|
25962
26259
|
for (let i = 0; i < length; i += 1) {
|
|
25963
|
-
const value = args[i];
|
|
25964
|
-
captured.push(value);
|
|
25965
|
-
if (value === void 0) continue;
|
|
25966
26260
|
const name = names[i];
|
|
25967
26261
|
const spec = schema[name];
|
|
26262
|
+
const supplied = Object.hasOwn(args, i);
|
|
26263
|
+
const value = supplied ? args[i] : void 0;
|
|
26264
|
+
if (!supplied && !spec.required && i in args) {
|
|
26265
|
+
throw new AutotaskConfigError(
|
|
26266
|
+
`invoke: "${operation}" positional input ${i + 1} (${name}) must be supplied directly`,
|
|
26267
|
+
{ operation }
|
|
26268
|
+
);
|
|
26269
|
+
}
|
|
26270
|
+
if (spec.required && (!supplied || isWrite && value === void 0)) {
|
|
26271
|
+
throw new AutotaskConfigError(
|
|
26272
|
+
`invoke: "${operation}" requires positional input ${i + 1} (${name}: ${spec.type})`,
|
|
26273
|
+
{ operation }
|
|
26274
|
+
);
|
|
26275
|
+
}
|
|
26276
|
+
captured.push(value);
|
|
26277
|
+
if (value === void 0) continue;
|
|
25968
26278
|
if (!looseTypeOk(spec.type, value)) {
|
|
25969
26279
|
throw new AutotaskConfigError(
|
|
25970
26280
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
@@ -25996,105 +26306,6 @@ function foldFlattenedOpts(record, toolArgs) {
|
|
|
25996
26306
|
return { ...folded, opts: Object.fromEntries(flat.map((k) => [k, toolArgs[k]])) };
|
|
25997
26307
|
}
|
|
25998
26308
|
|
|
25999
|
-
// src/operations/invoke/inputSets.ts
|
|
26000
|
-
var PARAMS_BAG_KEYS = {
|
|
26001
|
-
query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
|
|
26002
|
-
// No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
|
|
26003
|
-
// called directly), so this entry never fires. It is KEPT so that a future
|
|
26004
|
-
// `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
|
|
26005
|
-
// cannot silently open the bag (the keys are the vendor `QueryParams` set
|
|
26006
|
-
// the raw method accepts).
|
|
26007
|
-
queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
|
|
26008
|
-
// issue #145: the count bag carries the fieldCheck opt-out — the #140
|
|
26009
|
-
// refusal's advised remedy (before, the closed bag refused the very key it
|
|
26010
|
-
// advised, and the remedy looped into a second CONFIG_ERROR).
|
|
26011
|
-
count: ["filter", "fieldCheck"]
|
|
26012
|
-
};
|
|
26013
|
-
var BAG_KEY_SYNONYMS = {
|
|
26014
|
-
filters: "filter",
|
|
26015
|
-
last: "latest",
|
|
26016
|
-
// issue #59: the expected typo class (honoured only on `query`)
|
|
26017
|
-
lmit: "limit",
|
|
26018
|
-
page: "limit",
|
|
26019
|
-
pageSize: "limit",
|
|
26020
|
-
cursor: "limit",
|
|
26021
|
-
maxrecords: "maxRecords",
|
|
26022
|
-
fieldsPreset: "includeFields"
|
|
26023
|
-
// issue #287: the preset was removed — the refusal points at the explicit includeFields
|
|
26024
|
-
};
|
|
26025
|
-
function levenshtein(a, b) {
|
|
26026
|
-
if (a === b) return 0;
|
|
26027
|
-
const prev = new Array(b.length + 1);
|
|
26028
|
-
const cur = new Array(b.length + 1);
|
|
26029
|
-
for (let j = 0; j <= b.length; j += 1) prev[j] = j;
|
|
26030
|
-
for (let i = 1; i <= a.length; i += 1) {
|
|
26031
|
-
cur[0] = i;
|
|
26032
|
-
for (let j = 1; j <= b.length; j += 1) {
|
|
26033
|
-
cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
26034
|
-
}
|
|
26035
|
-
for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
|
|
26036
|
-
}
|
|
26037
|
-
return prev[b.length] ?? 0;
|
|
26038
|
-
}
|
|
26039
|
-
function suggestForKey(key, valid) {
|
|
26040
|
-
const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
|
|
26041
|
-
if (synonym !== void 0 && valid.includes(synonym)) return synonym;
|
|
26042
|
-
let best = null;
|
|
26043
|
-
for (const v of valid) {
|
|
26044
|
-
const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
|
|
26045
|
-
if (best === null || dist < best.dist) best = { key: v, dist };
|
|
26046
|
-
}
|
|
26047
|
-
if (best !== null && best.dist <= 3) return best.key;
|
|
26048
|
-
return null;
|
|
26049
|
-
}
|
|
26050
|
-
function keySuggestions(unknown, valid) {
|
|
26051
|
-
return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
26052
|
-
}
|
|
26053
|
-
function validateParamsBag(record, args) {
|
|
26054
|
-
if (record.inputSchemaStrict !== true) return;
|
|
26055
|
-
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
26056
|
-
if (valid === void 0) return;
|
|
26057
|
-
const bag = args?.[0];
|
|
26058
|
-
if (bag === void 0 || bag === null || !isRecord2(bag)) return;
|
|
26059
|
-
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
26060
|
-
if (unknown.length === 0) return;
|
|
26061
|
-
const suggestions = keySuggestions(unknown, valid);
|
|
26062
|
-
throw new AutotaskConfigError(
|
|
26063
|
-
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
26064
|
-
{
|
|
26065
|
-
operation: record.id,
|
|
26066
|
-
suggestedAction: suggestions.length > 0 ? `Fix the key name (${suggestions.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).` : `Pass only the valid keys (${valid.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).`
|
|
26067
|
-
}
|
|
26068
|
-
);
|
|
26069
|
-
}
|
|
26070
|
-
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
|
|
26071
|
-
function validateInvokeOptions(opts, operation) {
|
|
26072
|
-
if (opts === void 0 || opts === null) return;
|
|
26073
|
-
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
26074
|
-
if (unknown.length === 0) return;
|
|
26075
|
-
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
|
|
26076
|
-
throw new AutotaskConfigError(
|
|
26077
|
-
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
|
|
26078
|
-
{
|
|
26079
|
-
operation,
|
|
26080
|
-
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
|
|
26081
|
-
}
|
|
26082
|
-
);
|
|
26083
|
-
}
|
|
26084
|
-
function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
26085
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
26086
|
-
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
26087
|
-
if (unknown.length === 0) return null;
|
|
26088
|
-
const suggestions = keySuggestions(unknown, [...validKeys]);
|
|
26089
|
-
return new AutotaskConfigError(
|
|
26090
|
-
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
26091
|
-
{
|
|
26092
|
-
...operation !== void 0 ? { operation } : {},
|
|
26093
|
-
suggestedAction: suggestions.length > 0 ? operation === void 0 ? `Fix the ${subject} name (${suggestions.join(", ")}); the tool's full contract is in the tool's inputSchema, served by the MCP client's list_tools.` : `Fix the ${subject} name (${suggestions.join(", ")}); the full contract is in the tool's inputSchema (autotask_describe).` : `Pass only the valid keys (${validKeys.join(", ")}).`
|
|
26094
|
-
}
|
|
26095
|
-
);
|
|
26096
|
-
}
|
|
26097
|
-
|
|
26098
26309
|
// src/operations/searchAcrossResources.ts
|
|
26099
26310
|
var DEFAULT_LIMIT2 = 25;
|
|
26100
26311
|
function resourceFor(client, key) {
|
|
@@ -26396,7 +26607,7 @@ function dateBucketLabel(value, bucket) {
|
|
|
26396
26607
|
var queryResourceKeysPromise = null;
|
|
26397
26608
|
function queryResourceKeys() {
|
|
26398
26609
|
if (queryResourceKeysPromise === null) {
|
|
26399
|
-
queryResourceKeysPromise =
|
|
26610
|
+
queryResourceKeysPromise = chunkSHJ7EOBW_cjs.loadCapabilityRecords().then((records) => {
|
|
26400
26611
|
const s = /* @__PURE__ */ new Set();
|
|
26401
26612
|
for (const rec of records) if (rec.operation === "query") s.add(rec.resource);
|
|
26402
26613
|
return s;
|
|
@@ -26456,7 +26667,7 @@ function checkOptsBag(opts, problems) {
|
|
|
26456
26667
|
}
|
|
26457
26668
|
}
|
|
26458
26669
|
if (opts?.names !== void 0 && typeof opts.names !== "boolean") problems.push(`names must be a boolean (got ${typeof opts.names})`);
|
|
26459
|
-
if (opts
|
|
26670
|
+
if (opts !== void 0 && Object.hasOwn(opts, "acknowledgeUnscoped") && opts.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
|
|
26460
26671
|
problems.push(`acknowledgeUnscoped must be a boolean (got ${typeof opts.acknowledgeUnscoped})`);
|
|
26461
26672
|
}
|
|
26462
26673
|
}
|
|
@@ -26518,7 +26729,7 @@ function parseTopAndLimit(opts, problems) {
|
|
|
26518
26729
|
return { top, limit };
|
|
26519
26730
|
}
|
|
26520
26731
|
async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
26521
|
-
const records = resourceKey === void 0 ? [] : await
|
|
26732
|
+
const records = resourceKey === void 0 ? [] : await chunkSHJ7EOBW_cjs.loadCapabilityRecords();
|
|
26522
26733
|
const record = resourceKey === void 0 ? void 0 : records.find((r) => r.resource === resourceKey && r.operation === "query");
|
|
26523
26734
|
if (record === void 0) return void 0;
|
|
26524
26735
|
const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
|
|
@@ -26543,8 +26754,10 @@ async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
|
26543
26754
|
}
|
|
26544
26755
|
async function validateAggregate(operation, filter, opts) {
|
|
26545
26756
|
const problems = [];
|
|
26757
|
+
const acknowledgment = opts !== null && typeof opts === "object" ? Object.getOwnPropertyDescriptor(opts, "acknowledgeUnscoped") : void 0;
|
|
26546
26758
|
const resourceKey = await parseOperationKey(operation, problems);
|
|
26547
26759
|
const conditions = parseFilterConditions(filter, problems);
|
|
26760
|
+
const acknowledged = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") && acknowledgment.value === true && opts.acknowledgeUnscoped === true;
|
|
26548
26761
|
checkOptsBag(opts, problems);
|
|
26549
26762
|
if (resourceKey !== void 0) {
|
|
26550
26763
|
opts = {
|
|
@@ -26571,7 +26784,7 @@ async function validateAggregate(operation, filter, opts) {
|
|
|
26571
26784
|
{ operation: "operations.aggregate" }
|
|
26572
26785
|
);
|
|
26573
26786
|
}
|
|
26574
|
-
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 &&
|
|
26787
|
+
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && !acknowledged) {
|
|
26575
26788
|
throw new ScopeRequiredError(operation, { threshold: UNSCOPED_WALK_THRESHOLD }, "empty-filter");
|
|
26576
26789
|
}
|
|
26577
26790
|
return { resourceKey, conditions, groupBy, sum, top, limit };
|
|
@@ -26715,8 +26928,9 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
|
|
|
26715
26928
|
try {
|
|
26716
26929
|
const id = parseIdentifier(item.id, `${at}.id`);
|
|
26717
26930
|
const audit = isAuditLogResource(resourceKey);
|
|
26718
|
-
if ((audit ||
|
|
26719
|
-
|
|
26931
|
+
if ((audit || isExactRecordResource(resourceKey)) && !isAuditDecimalId(String(id))) {
|
|
26932
|
+
const label = audit ? "audit log" : resourceKey === "inventory_locations" ? "inventory location" : "Knowledge Base record";
|
|
26933
|
+
problems.push(`${at}.id: ${label} ID must be a non-negative signed 64-bit integer`);
|
|
26720
26934
|
}
|
|
26721
26935
|
} catch {
|
|
26722
26936
|
if (typeof item.id === "string") {
|
|
@@ -27010,7 +27224,7 @@ async function uiLink(client, input) {
|
|
|
27010
27224
|
var indexPromise = null;
|
|
27011
27225
|
function operationIndex() {
|
|
27012
27226
|
if (indexPromise === null) {
|
|
27013
|
-
indexPromise =
|
|
27227
|
+
indexPromise = chunkSHJ7EOBW_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
|
|
27014
27228
|
}
|
|
27015
27229
|
return indexPromise;
|
|
27016
27230
|
}
|
|
@@ -27031,7 +27245,7 @@ async function sanitiseResult(client, result, operation) {
|
|
|
27031
27245
|
);
|
|
27032
27246
|
}
|
|
27033
27247
|
const fields = record.metadata?.untrustedFields;
|
|
27034
|
-
return
|
|
27248
|
+
return chunkCM5O672I_cjs.deepMarkUntrusted(result, Array.isArray(fields) ? fields : []);
|
|
27035
27249
|
}
|
|
27036
27250
|
|
|
27037
27251
|
// src/resources/special/invoices.ts
|
|
@@ -29082,7 +29296,7 @@ function buildMiscoding(fc, crossTimeEntries, unresolvedRefs) {
|
|
|
29082
29296
|
return [...miscoding.values()].sort((a, b) => a.entryId - b.entryId).slice(0, fc.v.limit);
|
|
29083
29297
|
}
|
|
29084
29298
|
function vendorLabel(value, fallback) {
|
|
29085
|
-
return typeof value === "string" && value !== "" ?
|
|
29299
|
+
return typeof value === "string" && value !== "" ? chunkCM5O672I_cjs.wrapUntrusted(value) ?? value : fallback;
|
|
29086
29300
|
}
|
|
29087
29301
|
function openTicketItems(fc) {
|
|
29088
29302
|
const { openStatusSet } = fc.f.open;
|
|
@@ -29346,16 +29560,16 @@ function latchingHttp(raw, spend) {
|
|
|
29346
29560
|
}
|
|
29347
29561
|
};
|
|
29348
29562
|
observeRecordReadFailures(http, latch);
|
|
29349
|
-
const
|
|
29563
|
+
const fail4 = (err) => {
|
|
29350
29564
|
latch(err);
|
|
29351
29565
|
throw err;
|
|
29352
29566
|
};
|
|
29353
29567
|
http.request = (o) => {
|
|
29354
29568
|
if (fatal) throw fatal;
|
|
29355
29569
|
try {
|
|
29356
|
-
return counted.request({ ...o, signal: o.signal ?? signal }).catch(
|
|
29570
|
+
return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail4);
|
|
29357
29571
|
} catch (err) {
|
|
29358
|
-
return
|
|
29572
|
+
return fail4(err);
|
|
29359
29573
|
}
|
|
29360
29574
|
};
|
|
29361
29575
|
return { http, fatal: () => fatal, signal };
|
|
@@ -31155,8 +31369,25 @@ function bufferResult(buf) {
|
|
|
31155
31369
|
}
|
|
31156
31370
|
var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
|
|
31157
31371
|
function snapshotInvokeOptions(options, mode) {
|
|
31158
|
-
|
|
31159
|
-
|
|
31372
|
+
if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
|
|
31373
|
+
const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
|
|
31374
|
+
const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
|
|
31375
|
+
let confirmation;
|
|
31376
|
+
for (let owner = options; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
|
|
31377
|
+
confirmation = Object.getOwnPropertyDescriptor(owner, "confirm");
|
|
31378
|
+
if (confirmation !== void 0) break;
|
|
31379
|
+
}
|
|
31380
|
+
let confirm;
|
|
31381
|
+
if (confirmation !== void 0) {
|
|
31382
|
+
const visible = options.confirm;
|
|
31383
|
+
if (Object.hasOwn(confirmation, "value") && confirmation.value === visible || Object.hasOwn(confirmation, "get") && typeof confirmation.get === "function") confirm = visible;
|
|
31384
|
+
}
|
|
31385
|
+
const dryRun = options.dryRun;
|
|
31386
|
+
const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
|
|
31387
|
+
dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
|
|
31388
|
+
confirm
|
|
31389
|
+
});
|
|
31390
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
|
|
31160
31391
|
}
|
|
31161
31392
|
async function resolveRecord(operation) {
|
|
31162
31393
|
const record = (await operationIndex()).get(operation);
|
|
@@ -31370,15 +31601,19 @@ var PRE_REQUEST_VALIDATORS = [
|
|
|
31370
31601
|
(c) => requireReadBack(c.record, c.operation, c.opts),
|
|
31371
31602
|
(c) => {
|
|
31372
31603
|
c.args = captureDispatchArgs(c.record, c.args);
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
|
|
31604
|
+
if (!c.boundedQuery && !c.countedQuery) return;
|
|
31605
|
+
const bag = ownQueryBag(c.args);
|
|
31606
|
+
if (bag === void 0) return;
|
|
31607
|
+
if (c.boundedQuery && "acknowledgeUnscoped" in bag && !Object.hasOwn(bag, "acknowledgeUnscoped")) {
|
|
31608
|
+
throw new AutotaskConfigError(`invoke: "${c.operation}" params bag key "acknowledgeUnscoped" must be supplied directly`, { operation: c.operation });
|
|
31609
|
+
}
|
|
31610
|
+
c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...c.args.slice(1)];
|
|
31376
31611
|
},
|
|
31377
31612
|
(c) => validateParamsBag(c.record, c.args),
|
|
31378
31613
|
(c) => validateFreshSpelling(c.record, c.args),
|
|
31379
31614
|
(c) => {
|
|
31380
31615
|
if (!c.streaming) return;
|
|
31381
|
-
const bag = c.args
|
|
31616
|
+
const bag = ownQueryBag(c.args);
|
|
31382
31617
|
if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
|
|
31383
31618
|
throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
|
|
31384
31619
|
}
|
|
@@ -31397,7 +31632,8 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
|
|
|
31397
31632
|
const context = { record, operation, args: resolvedArgs, opts, client, holder, boundedQuery, countedQuery, streaming };
|
|
31398
31633
|
await runPreRequestPass(context);
|
|
31399
31634
|
const { args } = context;
|
|
31400
|
-
const
|
|
31635
|
+
const queryParams = boundedQuery ? ownQueryBag(args) : void 0;
|
|
31636
|
+
const labelQuery = boundedQuery && readNamesOpt(client, queryParams?.["names"], `invoke: "${record.id}" params bag`);
|
|
31401
31637
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
31402
31638
|
const method = streaming ? context.pageSession?.consume : holder[methodName];
|
|
31403
31639
|
if (typeof method !== "function") {
|
|
@@ -31410,17 +31646,18 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
|
|
|
31410
31646
|
const mutationOpts = buildMutationOpts(opts, isWrite);
|
|
31411
31647
|
const callArgs = buildCallArgs(record, args, mutationOpts, isWrite);
|
|
31412
31648
|
if (opts.fresh === true) appendFresh(record, callArgs);
|
|
31413
|
-
if (boundedQuery) validateWalkBag(args[0]?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
|
|
31414
31649
|
let scopeNote;
|
|
31415
|
-
if (boundedQuery
|
|
31416
|
-
|
|
31650
|
+
if (boundedQuery) {
|
|
31651
|
+
validateWalkBag(queryParams?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
|
|
31652
|
+
const acknowledged = queryParams !== void 0 && Object.hasOwn(queryParams, "acknowledgeUnscoped") && queryParams.acknowledgeUnscoped === true;
|
|
31653
|
+
if (!acknowledged) scopeNote = (await guardUnscopedQueryWalk(holder, record.id, queryParams)).note;
|
|
31417
31654
|
}
|
|
31418
31655
|
return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
|
|
31419
31656
|
}
|
|
31420
31657
|
async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
31421
31658
|
const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
|
|
31422
31659
|
const result = await method.apply(holder, callArgs);
|
|
31423
|
-
if (labelQuery && args
|
|
31660
|
+
if (labelQuery && ownQueryBag(args)?.["walk"] === void 0 && Array.isArray(result?.items)) {
|
|
31424
31661
|
const bounded = result;
|
|
31425
31662
|
const labelled = await labelRows(client, record.resource, bounded.items);
|
|
31426
31663
|
return { ...bounded, items: labelled.rows, ...labelled.names !== void 0 ? { names: labelled.names } : {}, ...scopeNote !== void 0 ? { scopeNote } : {} };
|