node-autotask 0.90.0 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/MCP_TOOL_CATALOG.json +360 -9
- package/README.md +1 -1
- package/capabilities.json +2022 -655
- package/dist/capabilities-data.js +2021 -654
- package/dist/capabilities.cjs +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-K5X4BPQC.js → chunk-2MC3LDZU.js} +3 -3
- package/dist/{chunk-4CI27SCM.cjs → chunk-ATDGRAX2.cjs} +33 -30
- package/dist/{chunk-HU6OGAPI.js → chunk-ELAU2MT5.js} +5 -2
- package/dist/{chunk-OI6E5XQA.cjs → chunk-H24SV774.cjs} +473 -122
- package/dist/{chunk-D7MJC7HA.cjs → chunk-JPZ7M7QI.cjs} +200 -200
- package/dist/{chunk-CY6USWUY.js → chunk-NQNAEA23.js} +468 -117
- package/dist/{chunk-ZLMYYO7R.cjs → chunk-QXJQIZCT.cjs} +3 -3
- package/dist/{chunk-Q73VQSUP.js → chunk-XAOWO42G.js} +2 -2
- package/dist/{index-4jmitXBs.d.cts → index-B9y5IwT1.d.cts} +115 -1
- package/dist/{index-4jmitXBs.d.ts → index-B9y5IwT1.d.ts} +115 -1
- package/dist/{index-DWyJAad_.d.ts → index-U7Lepdm2.d.ts} +10 -5
- package/dist/{index-BEqbDuMk.d.cts → index-lWek2NrV.d.cts} +10 -5
- package/dist/index.cjs +85 -85
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/operations/index.cjs +51 -51
- package/dist/operations/index.d.cts +6 -4
- package/dist/operations/index.d.ts +6 -4
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +12 -12
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +27 -27
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/API.md +5 -2
- package/examples/mcp/manifest.ts +1 -1
- package/examples/mcp/tools-mode.ts +15 -6
- package/examples/mcp/tools-read.ts +8 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadCapabilityRecords } from './chunk-
|
|
1
|
+
import { loadCapabilityRecords } from './chunk-2MC3LDZU.js';
|
|
2
2
|
import { NoopLogger, REDACTED, deepMarkUntrusted, wrapUntrusted } from './chunk-X6VWD6WW.js';
|
|
3
3
|
import { randomUUID, createHash } from 'crypto';
|
|
4
4
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
@@ -251,6 +251,7 @@ var SECRET_RESPONSE_FIELDS = [
|
|
|
251
251
|
// IntegrationVendorInsightModel, IntegrationVendorWidgetModel
|
|
252
252
|
];
|
|
253
253
|
var PERSONAL_RESPONSE_FIELDS = [
|
|
254
|
+
"additionalAddressInfo",
|
|
254
255
|
"additionalAddressInformation",
|
|
255
256
|
"additionalBillToAddressInformation",
|
|
256
257
|
"additionalShipToAddressInformation",
|
|
@@ -1585,6 +1586,11 @@ function countUdfConditions(conditions) {
|
|
|
1585
1586
|
}
|
|
1586
1587
|
return n;
|
|
1587
1588
|
}
|
|
1589
|
+
function assertSupportedUdfConditions(conditions, operation) {
|
|
1590
|
+
if (operation.startsWith("inventory_items.") && conditions !== void 0 && countUdfConditions(conditions) > 0) {
|
|
1591
|
+
throw new AutotaskConfigError("InventoryItems has no record UDFs. Filter on its documented fields.", { operation });
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1588
1594
|
function serializeFilter(filter) {
|
|
1589
1595
|
return JSON.stringify(filter);
|
|
1590
1596
|
}
|
|
@@ -10964,6 +10970,65 @@ var RELATIONSHIP_MAP = {
|
|
|
10964
10970
|
"deleteBoundary": null,
|
|
10965
10971
|
"markerField": null
|
|
10966
10972
|
},
|
|
10973
|
+
"inventory_items": {
|
|
10974
|
+
"resource": "inventory_items",
|
|
10975
|
+
"apiEntity": "InventoryItem",
|
|
10976
|
+
"kind": "entity",
|
|
10977
|
+
"path": "InventoryItems",
|
|
10978
|
+
"parentScoped": false,
|
|
10979
|
+
"tier": "extended",
|
|
10980
|
+
"workflowResource": false,
|
|
10981
|
+
"group": "A",
|
|
10982
|
+
"parent": null,
|
|
10983
|
+
"children": [],
|
|
10984
|
+
"naturalKeys": {
|
|
10985
|
+
"hasSearch": false,
|
|
10986
|
+
"searchCovers": null,
|
|
10987
|
+
"findBy": []
|
|
10988
|
+
},
|
|
10989
|
+
"blindSurfaces": null,
|
|
10990
|
+
"zoneFacts": {
|
|
10991
|
+
"createRequiredSet": [
|
|
10992
|
+
"inventoryLocationID",
|
|
10993
|
+
"productID",
|
|
10994
|
+
"quantityMinimum",
|
|
10995
|
+
"quantityMaximum",
|
|
10996
|
+
"quantityOnHand"
|
|
10997
|
+
],
|
|
10998
|
+
"createGuidance": {
|
|
10999
|
+
"createOp": "inventory_items.create",
|
|
11000
|
+
"parentScoped": false,
|
|
11001
|
+
"liveProvenPrefix": [],
|
|
11002
|
+
"unproven": true,
|
|
11003
|
+
"blocker": {
|
|
11004
|
+
"kind": "unknown",
|
|
11005
|
+
"message": "Inventory access, an active location, a visible product and a unique product-location pair are required.",
|
|
11006
|
+
"remedy": "Read product and location metadata, supply the required quantities and preview before apply.",
|
|
11007
|
+
"requires": {
|
|
11008
|
+
"allOf": [
|
|
11009
|
+
"inventoryLocationID",
|
|
11010
|
+
"productID",
|
|
11011
|
+
"quantityMinimum",
|
|
11012
|
+
"quantityMaximum",
|
|
11013
|
+
"quantityOnHand"
|
|
11014
|
+
]
|
|
11015
|
+
}
|
|
11016
|
+
},
|
|
11017
|
+
"vendorEvidence": [
|
|
11018
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryItemsEntity.htm"
|
|
11019
|
+
],
|
|
11020
|
+
"deleteBoundary": {
|
|
11021
|
+
"available": false,
|
|
11022
|
+
"note": "The specification defines no public DELETE for InventoryItems."
|
|
11023
|
+
}
|
|
11024
|
+
}
|
|
11025
|
+
},
|
|
11026
|
+
"deleteBoundary": {
|
|
11027
|
+
"note": "The specification defines no public DELETE for InventoryItems. A created item cannot be removed through that API.",
|
|
11028
|
+
"proof": "spec-derived"
|
|
11029
|
+
},
|
|
11030
|
+
"markerField": null
|
|
11031
|
+
},
|
|
10967
11032
|
"inventory_locations": {
|
|
10968
11033
|
"resource": "inventory_locations",
|
|
10969
11034
|
"apiEntity": "InventoryLocation",
|
|
@@ -11016,6 +11081,48 @@ var RELATIONSHIP_MAP = {
|
|
|
11016
11081
|
"proof": "spec-derived"
|
|
11017
11082
|
},
|
|
11018
11083
|
"markerField": null
|
|
11084
|
+
},
|
|
11085
|
+
"internal_locations": {
|
|
11086
|
+
"resource": "internal_locations",
|
|
11087
|
+
"apiEntity": "InternalLocation",
|
|
11088
|
+
"kind": "entity",
|
|
11089
|
+
"path": "InternalLocations",
|
|
11090
|
+
"parentScoped": false,
|
|
11091
|
+
"tier": "extended",
|
|
11092
|
+
"workflowResource": false,
|
|
11093
|
+
"group": "B",
|
|
11094
|
+
"parent": null,
|
|
11095
|
+
"children": [],
|
|
11096
|
+
"naturalKeys": {
|
|
11097
|
+
"hasSearch": false,
|
|
11098
|
+
"searchCovers": null,
|
|
11099
|
+
"findBy": []
|
|
11100
|
+
},
|
|
11101
|
+
"blindSurfaces": null,
|
|
11102
|
+
"zoneFacts": null,
|
|
11103
|
+
"deleteBoundary": null,
|
|
11104
|
+
"markerField": null
|
|
11105
|
+
},
|
|
11106
|
+
"shipping_types": {
|
|
11107
|
+
"resource": "shipping_types",
|
|
11108
|
+
"apiEntity": "ShippingType",
|
|
11109
|
+
"kind": "entity",
|
|
11110
|
+
"path": "ShippingTypes",
|
|
11111
|
+
"parentScoped": false,
|
|
11112
|
+
"tier": "extended",
|
|
11113
|
+
"workflowResource": false,
|
|
11114
|
+
"group": "B",
|
|
11115
|
+
"parent": null,
|
|
11116
|
+
"children": [],
|
|
11117
|
+
"naturalKeys": {
|
|
11118
|
+
"hasSearch": false,
|
|
11119
|
+
"searchCovers": null,
|
|
11120
|
+
"findBy": []
|
|
11121
|
+
},
|
|
11122
|
+
"blindSurfaces": null,
|
|
11123
|
+
"zoneFacts": null,
|
|
11124
|
+
"deleteBoundary": null,
|
|
11125
|
+
"markerField": null
|
|
11019
11126
|
}
|
|
11020
11127
|
};
|
|
11021
11128
|
var BLIND_SURFACE_STAMPS = {
|
|
@@ -11128,6 +11235,7 @@ var DELETE_BOUNDARY_NOTES = {
|
|
|
11128
11235
|
"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.",
|
|
11129
11236
|
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
|
|
11130
11237
|
"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.",
|
|
11238
|
+
"inventory_items": "The specification defines no public DELETE for InventoryItems. A created item cannot be removed through that API.",
|
|
11131
11239
|
"inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
11132
11240
|
};
|
|
11133
11241
|
var RESPONSE_DRIFT_MARKERS = {
|
|
@@ -14055,6 +14163,34 @@ var CREATE_GUIDANCE = {
|
|
|
14055
14163
|
"note": null
|
|
14056
14164
|
}
|
|
14057
14165
|
},
|
|
14166
|
+
{
|
|
14167
|
+
"resource": "inventory_items",
|
|
14168
|
+
"createOp": "inventory_items.create",
|
|
14169
|
+
"parentScoped": false,
|
|
14170
|
+
"liveProvenPrefix": [],
|
|
14171
|
+
"unproven": true,
|
|
14172
|
+
"blocker": {
|
|
14173
|
+
"kind": "unknown",
|
|
14174
|
+
"message": "Inventory access, an active location, a visible product and a unique product-location pair are required.",
|
|
14175
|
+
"remedy": "Read product and location metadata, supply the required quantities and preview before apply.",
|
|
14176
|
+
"requires": {
|
|
14177
|
+
"allOf": [
|
|
14178
|
+
"inventoryLocationID",
|
|
14179
|
+
"productID",
|
|
14180
|
+
"quantityMinimum",
|
|
14181
|
+
"quantityMaximum",
|
|
14182
|
+
"quantityOnHand"
|
|
14183
|
+
]
|
|
14184
|
+
}
|
|
14185
|
+
},
|
|
14186
|
+
"vendorEvidence": [
|
|
14187
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryItemsEntity.htm"
|
|
14188
|
+
],
|
|
14189
|
+
"deleteBoundary": {
|
|
14190
|
+
"available": false,
|
|
14191
|
+
"note": "The specification defines no public DELETE for InventoryItems."
|
|
14192
|
+
}
|
|
14193
|
+
},
|
|
14058
14194
|
{
|
|
14059
14195
|
"resource": "inventory_locations",
|
|
14060
14196
|
"createOp": "inventory_locations.create",
|
|
@@ -15660,7 +15796,7 @@ var CREATE_GUIDANCE = {
|
|
|
15660
15796
|
}
|
|
15661
15797
|
],
|
|
15662
15798
|
"counts": {
|
|
15663
|
-
"total":
|
|
15799
|
+
"total": 118,
|
|
15664
15800
|
"byKind": {
|
|
15665
15801
|
"ok": 41,
|
|
15666
15802
|
"blind-reference": 16,
|
|
@@ -15670,7 +15806,7 @@ var CREATE_GUIDANCE = {
|
|
|
15670
15806
|
"resource-role-pair": 2,
|
|
15671
15807
|
"delete-absent": 0,
|
|
15672
15808
|
"non-mutable": 0,
|
|
15673
|
-
"unknown":
|
|
15809
|
+
"unknown": 42
|
|
15674
15810
|
}
|
|
15675
15811
|
}
|
|
15676
15812
|
};
|
|
@@ -16450,8 +16586,22 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
|
|
|
16450
16586
|
"referenceLink",
|
|
16451
16587
|
"title"
|
|
16452
16588
|
],
|
|
16589
|
+
"inventory_items": [
|
|
16590
|
+
"bin",
|
|
16591
|
+
"referenceNumber"
|
|
16592
|
+
],
|
|
16453
16593
|
"inventory_locations": [
|
|
16454
16594
|
"locationName"
|
|
16595
|
+
],
|
|
16596
|
+
"internal_locations": [
|
|
16597
|
+
"additionalAddressInfo",
|
|
16598
|
+
"country",
|
|
16599
|
+
"name",
|
|
16600
|
+
"timeZone"
|
|
16601
|
+
],
|
|
16602
|
+
"shipping_types": [
|
|
16603
|
+
"description",
|
|
16604
|
+
"name"
|
|
16455
16605
|
]
|
|
16456
16606
|
};
|
|
16457
16607
|
|
|
@@ -16911,9 +17061,9 @@ function isKnowledgeBaseRootResource(resource) {
|
|
|
16911
17061
|
return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
|
|
16912
17062
|
}
|
|
16913
17063
|
function isExactRecordResource(resource) {
|
|
16914
|
-
return resource === "inventory_locations" || isKnowledgeBaseRootResource(resource);
|
|
17064
|
+
return resource === "inventory_locations" || resource === "inventory_items" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
|
|
16915
17065
|
}
|
|
16916
|
-
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
17066
|
+
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|InventoryItems|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
16917
17067
|
function exactRecordResponseTarget(path, method, operation) {
|
|
16918
17068
|
const match = EXACT_RECORD_PATH.exec(path);
|
|
16919
17069
|
if (match === null) return void 0;
|
|
@@ -16935,6 +17085,9 @@ function receiptId(body) {
|
|
|
16935
17085
|
function isNonNegativeInt64(id) {
|
|
16936
17086
|
return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
|
|
16937
17087
|
}
|
|
17088
|
+
function isSignedInt64Token(token) {
|
|
17089
|
+
return token.startsWith("-") ? /^-[0-9]{1,19}$/.test(token) && BigInt(token) >= -9223372036854775808n : isAuditDecimalId(token);
|
|
17090
|
+
}
|
|
16938
17091
|
function validateExactRecordResponse(body, target, path, method, requestBody, operation) {
|
|
16939
17092
|
const invalid = (message) => {
|
|
16940
17093
|
throw new AutotaskError(message, { code: "INVALID_RESPONSE", category: "server", operation, suggestedAction: INVALID_SHAPE_ACTION });
|
|
@@ -16975,7 +17128,7 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16975
17128
|
return invalid("Expected an item envelope with a valid record ID");
|
|
16976
17129
|
}
|
|
16977
17130
|
const entity = parts.at(-2)?.toLowerCase();
|
|
16978
|
-
const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
|
|
17131
|
+
const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : entity === "knowledgebasecategories" ? "category" : "record";
|
|
16979
17132
|
if (String(id) !== expectedId) {
|
|
16980
17133
|
throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
|
|
16981
17134
|
}
|
|
@@ -16997,7 +17150,7 @@ function serializeExactRecordUpdate(body, operation) {
|
|
|
16997
17150
|
const { rawJSON } = JSON;
|
|
16998
17151
|
return JSON.stringify({ ...body, id: rawJSON(body.id) });
|
|
16999
17152
|
}
|
|
17000
|
-
function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
17153
|
+
function decodeResponseJson(text, auditTarget, recordTarget, path) {
|
|
17001
17154
|
const target = auditTarget ?? recordTarget;
|
|
17002
17155
|
if (target === void 0) return JSON.parse(text);
|
|
17003
17156
|
if (target === "query/count") {
|
|
@@ -17005,10 +17158,13 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
|
17005
17158
|
}
|
|
17006
17159
|
const idTokens = /* @__PURE__ */ new WeakMap();
|
|
17007
17160
|
const receiptTokens = /* @__PURE__ */ new WeakMap();
|
|
17161
|
+
const holidaySetTokens = /* @__PURE__ */ new WeakMap();
|
|
17162
|
+
const internalLocations = path !== void 0 && /^\/v1\.0\/InternalLocations\//i.test(path);
|
|
17008
17163
|
const body = JSON.parse(text, function(key, value, context) {
|
|
17009
17164
|
if (typeof value === "number" && context?.source !== void 0) {
|
|
17010
17165
|
if (key === "id") idTokens.set(this, context.source);
|
|
17011
17166
|
if (key === "itemId" && target === "mutation") receiptTokens.set(this, context.source);
|
|
17167
|
+
if (internalLocations && key === "holidaySetId") holidaySetTokens.set(this, context.source);
|
|
17012
17168
|
}
|
|
17013
17169
|
return value;
|
|
17014
17170
|
});
|
|
@@ -17016,6 +17172,10 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
|
17016
17172
|
if (Array.isArray(rows)) {
|
|
17017
17173
|
for (const row of rows) {
|
|
17018
17174
|
if (!isRecord2(row)) continue;
|
|
17175
|
+
const holidaySet = holidaySetTokens.get(row);
|
|
17176
|
+
if (holidaySet !== void 0 && !Number.isSafeInteger(row.holidaySetId) && isSignedInt64Token(holidaySet)) {
|
|
17177
|
+
row.holidaySetId = holidaySet;
|
|
17178
|
+
}
|
|
17019
17179
|
const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
|
|
17020
17180
|
const value = ownField(row, key);
|
|
17021
17181
|
if (typeof value !== "number") continue;
|
|
@@ -17075,7 +17235,7 @@ function attachEmptyReasonDetails(err) {
|
|
|
17075
17235
|
} : {
|
|
17076
17236
|
surface,
|
|
17077
17237
|
kind: "not-found",
|
|
17078
|
-
note: isDeletedAuditRead(surface) ? "No audit log entry at this ID was visible to this API user." : resource === "knowledge_base_articles" ? "No published article at this ID was visible to this API user." : `no ${resource} record exists at this id (a miss is the data, not an error condition)`,
|
|
17238
|
+
note: isDeletedAuditRead(surface) ? "No audit log entry at this ID was visible to this API user." : resource === "internal_locations" || resource === "shipping_types" || resource === "inventory_items" ? "No record at this ID was visible to this API user." : resource === "knowledge_base_articles" ? "No published article at this ID was visible to this API user." : `no ${resource} record exists at this id (a miss is the data, not an error condition)`,
|
|
17079
17239
|
authority: `${resource}.query`,
|
|
17080
17240
|
remedy: `query the ${resource} collection (a bounded queryBounded walk) or verify the id from the authority surface \u2014 do not retry the same get`
|
|
17081
17241
|
};
|
|
@@ -17641,7 +17801,7 @@ var HttpClient = class {
|
|
|
17641
17801
|
}
|
|
17642
17802
|
let parsed;
|
|
17643
17803
|
try {
|
|
17644
|
-
parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget);
|
|
17804
|
+
parsed = decodeResponseJson(text, s.auditTarget, s.recordTarget, decodeURIComponent(s.opts.path));
|
|
17645
17805
|
} catch {
|
|
17646
17806
|
return this.handleNonJson2xx(s, res, status, text);
|
|
17647
17807
|
}
|
|
@@ -17866,7 +18026,7 @@ var HttpClient = class {
|
|
|
17866
18026
|
if (queryRoute) {
|
|
17867
18027
|
const audit = auditTarget === "query" || auditTarget === "query/count";
|
|
17868
18028
|
const exactRecord = recordTarget === "query" || recordTarget === "query/count";
|
|
17869
|
-
const recordLabel = /^\/v1\.0\/InventoryLocations\//i.test(route) ? "inventory location" : "Knowledge Base record";
|
|
18029
|
+
const recordLabel = /^\/v1\.0\/InventoryLocations\//i.test(route) ? "inventory location" : /^\/v1\.0\/KnowledgeBase/i.test(route) ? "Knowledge Base record" : "record";
|
|
17870
18030
|
const exactIdLabel = audit ? "audit log" : exactRecord ? recordLabel : void 0;
|
|
17871
18031
|
assertQueryFilters(opts, requestUrl, bodyText, exactIdLabel);
|
|
17872
18032
|
}
|
|
@@ -18464,13 +18624,13 @@ async function runBounded(fn, items, opts) {
|
|
|
18464
18624
|
const results = new Array(items.length);
|
|
18465
18625
|
let next = 0;
|
|
18466
18626
|
let failure;
|
|
18467
|
-
const
|
|
18627
|
+
const fail5 = (error, index) => {
|
|
18468
18628
|
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
18469
18629
|
};
|
|
18470
18630
|
const worker = async () => {
|
|
18471
18631
|
while (failure === void 0 && next < items.length) {
|
|
18472
18632
|
if (signal?.aborted) {
|
|
18473
|
-
|
|
18633
|
+
fail5(signal.reason, -1);
|
|
18474
18634
|
return;
|
|
18475
18635
|
}
|
|
18476
18636
|
const i = next++;
|
|
@@ -18480,7 +18640,7 @@ async function runBounded(fn, items, opts) {
|
|
|
18480
18640
|
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
18481
18641
|
} catch (error) {
|
|
18482
18642
|
if (settle) results[i] = { status: "rejected", reason: error };
|
|
18483
|
-
else
|
|
18643
|
+
else fail5(error, i);
|
|
18484
18644
|
}
|
|
18485
18645
|
}
|
|
18486
18646
|
};
|
|
@@ -18934,7 +19094,7 @@ function truncateNoteChars(items, cap, fields) {
|
|
|
18934
19094
|
const copy = { ...item };
|
|
18935
19095
|
for (const field of fields) {
|
|
18936
19096
|
const v = copy[field];
|
|
18937
|
-
if (typeof v === "string" && v.length > cap) {
|
|
19097
|
+
if (typeof v === "string" && v !== REDACTED && v.length > cap) {
|
|
18938
19098
|
const end = cap > 0 && (v.charCodeAt(cap - 1) & 64512) === 55296 ? cap - 1 : cap;
|
|
18939
19099
|
copy[field] = v.slice(0, end) + noteCharsTruncationMarker(v.length - end);
|
|
18940
19100
|
truncated += 1;
|
|
@@ -19953,6 +20113,108 @@ function checkInventoryLocationCurrent(value, current, id) {
|
|
|
19953
20113
|
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");
|
|
19954
20114
|
}
|
|
19955
20115
|
|
|
20116
|
+
// src/resources/special/inventoryItems.ts
|
|
20117
|
+
var REFERENCES = ["inventoryLocationID", "productID"];
|
|
20118
|
+
var QUANTITIES = ["quantityMinimum", "quantityMaximum", "quantityOnHand"];
|
|
20119
|
+
var TEXT_FIELDS = ["bin", "referenceNumber"];
|
|
20120
|
+
var MUTATION_OPTIONS = ["dryRun", "lastModifiedDate", "maxRetries", "raw", "verifyPersisted"];
|
|
20121
|
+
function fail2(message) {
|
|
20122
|
+
throw new AutotaskConfigError(`inventory_items: ${message}`);
|
|
20123
|
+
}
|
|
20124
|
+
function own(record, field) {
|
|
20125
|
+
return Object.hasOwn(record, field) ? record[field] : void 0;
|
|
20126
|
+
}
|
|
20127
|
+
function int32(value, label, minimum = -2147483648) {
|
|
20128
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > 2147483647) {
|
|
20129
|
+
fail2(`${label} must be an integer between ${minimum} and 2147483647`);
|
|
20130
|
+
}
|
|
20131
|
+
return value;
|
|
20132
|
+
}
|
|
20133
|
+
function inventoryItemId(value) {
|
|
20134
|
+
const id = parseIdentifier(value, "inventory_items: id");
|
|
20135
|
+
if (!isAuditDecimalId(String(id))) fail2("id must fit a signed 64-bit integer");
|
|
20136
|
+
return id;
|
|
20137
|
+
}
|
|
20138
|
+
function admitInventoryItem(value, creating) {
|
|
20139
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail2("data must be a plain record");
|
|
20140
|
+
const body = { ...value };
|
|
20141
|
+
const writable = [...QUANTITIES, ...TEXT_FIELDS, ...creating ? REFERENCES : []];
|
|
20142
|
+
for (const field of Object.keys(body)) {
|
|
20143
|
+
if (!writable.some((name) => name === field)) fail2(`${field} is not a writable InventoryItems field on ${creating ? "create" : "update"}`);
|
|
20144
|
+
}
|
|
20145
|
+
if (!creating && Object.keys(body).length === 0) fail2("update must contain a writable field");
|
|
20146
|
+
if (creating) for (const field of REFERENCES) int32(own(body, field), field, 1);
|
|
20147
|
+
for (const field of QUANTITIES) {
|
|
20148
|
+
const nonnegative = field === "quantityMinimum" || creating && field === "quantityOnHand";
|
|
20149
|
+
if (creating || Object.hasOwn(body, field)) int32(own(body, field), field, nonnegative ? 0 : void 0);
|
|
20150
|
+
}
|
|
20151
|
+
for (const field of TEXT_FIELDS) {
|
|
20152
|
+
const text = own(body, field);
|
|
20153
|
+
if (Object.hasOwn(body, field) && (typeof text !== "string" || text.length > 50)) fail2(`${field} must be a string of at most 50 characters`);
|
|
20154
|
+
}
|
|
20155
|
+
assertQuantityRange(own(body, "quantityMinimum"), own(body, "quantityMaximum"));
|
|
20156
|
+
return body;
|
|
20157
|
+
}
|
|
20158
|
+
function snapshotInventoryItemOptions(value) {
|
|
20159
|
+
if (value !== void 0 && !isRecord2(value)) fail2("options must be an object");
|
|
20160
|
+
const options = value ?? {};
|
|
20161
|
+
for (const key of MUTATION_OPTIONS) {
|
|
20162
|
+
if (key in options && !Object.hasOwn(options, key)) fail2(`${key} must be an own option`);
|
|
20163
|
+
}
|
|
20164
|
+
const result = snapshotMutationOptions(Object.fromEntries(MUTATION_OPTIONS.map((key) => [key, own(options, key)])));
|
|
20165
|
+
if (result.lastModifiedDate !== void 0) fail2("no documented stale timestamp is available");
|
|
20166
|
+
if (result.raw !== void 0 && result.raw !== false) fail2("raw updates are unsupported");
|
|
20167
|
+
if (result.maxRetries !== void 0 && (!Number.isSafeInteger(result.maxRetries) || result.maxRetries < 0)) fail2("maxRetries must be a nonnegative safe integer");
|
|
20168
|
+
if (result.verifyPersisted !== void 0 && typeof result.verifyPersisted !== "boolean") fail2("verifyPersisted must be a boolean");
|
|
20169
|
+
return result;
|
|
20170
|
+
}
|
|
20171
|
+
function assertQuantityRange(minimum, maximum) {
|
|
20172
|
+
if (typeof minimum === "number" && typeof maximum === "number" && maximum < minimum) fail2("quantityMaximum must be at least quantityMinimum");
|
|
20173
|
+
}
|
|
20174
|
+
function exactItem(value, id, label) {
|
|
20175
|
+
if (!isRecord2(value)) fail2(`${label} must be a record`);
|
|
20176
|
+
const returned = own(value, "id");
|
|
20177
|
+
if (typeof returned !== "string" && (typeof returned !== "number" || !Number.isSafeInteger(returned))) fail2(`${label} requires its own exact id`);
|
|
20178
|
+
if (String(returned) !== String(id)) fail2(`${label} id must match the requested id`);
|
|
20179
|
+
return value;
|
|
20180
|
+
}
|
|
20181
|
+
async function productIsSerialized(http, id, checkedBaseUrl, maxRetries) {
|
|
20182
|
+
const operation = "products.get";
|
|
20183
|
+
const body = await http.request({ method: "GET", path: `/V1.0/Products/${id}`, operation, maxRetries, checkedBaseUrl });
|
|
20184
|
+
const product = exactItem(unwrapItem(body, id, operation, "product"), id, "product");
|
|
20185
|
+
const serialized = own(product, "isSerialized");
|
|
20186
|
+
if (typeof serialized !== "boolean") fail2("product requires a fresh boolean isSerialized fact");
|
|
20187
|
+
return serialized;
|
|
20188
|
+
}
|
|
20189
|
+
async function guardInventoryItemCreate(http, data, checkedBaseUrl, maxRetries) {
|
|
20190
|
+
const locationId = data.inventoryLocationID;
|
|
20191
|
+
const operation = "inventory_locations.get";
|
|
20192
|
+
const body = await http.request({ method: "GET", path: `/V1.0/InventoryLocations/${locationId}`, operation, maxRetries, checkedBaseUrl });
|
|
20193
|
+
const location = exactItem(unwrapItem(body, locationId, operation, "inventory_location"), locationId, "inventory location");
|
|
20194
|
+
if (own(location, "isActive") !== true) fail2("inventory location requires a fresh isActive value explicitly true");
|
|
20195
|
+
if (await productIsSerialized(http, data.productID, checkedBaseUrl, maxRetries) && data.quantityOnHand !== 0) {
|
|
20196
|
+
fail2("quantityOnHand must be zero when creating an item for a serialized product");
|
|
20197
|
+
}
|
|
20198
|
+
}
|
|
20199
|
+
async function checkInventoryItemCurrent(http, data, current, id, checkedBaseUrl, maxRetries) {
|
|
20200
|
+
const item = exactItem(current, id, "current record");
|
|
20201
|
+
const minimum = own(data, "quantityMinimum");
|
|
20202
|
+
const maximum = own(data, "quantityMaximum");
|
|
20203
|
+
if (minimum !== void 0 || maximum !== void 0) {
|
|
20204
|
+
assertQuantityRange(
|
|
20205
|
+
minimum ?? int32(own(item, "quantityMinimum"), "current quantityMinimum", 0),
|
|
20206
|
+
maximum ?? int32(own(item, "quantityMaximum"), "current quantityMaximum")
|
|
20207
|
+
);
|
|
20208
|
+
}
|
|
20209
|
+
const onHand = own(data, "quantityOnHand");
|
|
20210
|
+
if (typeof onHand !== "number") return;
|
|
20211
|
+
const picked = int32(own(item, "quantityPicked"), "current quantityPicked");
|
|
20212
|
+
const reserved = int32(own(item, "quantityReserved"), "current quantityReserved");
|
|
20213
|
+
if (onHand < picked + reserved) fail2("quantityOnHand must be at least quantityPicked plus quantityReserved");
|
|
20214
|
+
const productId = int32(own(item, "productID"), "current productID", 1);
|
|
20215
|
+
if (await productIsSerialized(http, productId, checkedBaseUrl, maxRetries)) fail2("quantityOnHand is read-only on update for a serialized product");
|
|
20216
|
+
}
|
|
20217
|
+
|
|
19956
20218
|
// src/resources/base/types.ts
|
|
19957
20219
|
var BOUNDED_QUERY_DEFAULT_LIMIT = 500;
|
|
19958
20220
|
var BOUNDED_QUERY_MAX_LIMIT = 2500;
|
|
@@ -20119,6 +20381,8 @@ var MODEL_FIELD_SETS = {
|
|
|
20119
20381
|
"expense_reports": ["id", "amountDue", "approvedDate", "approverID", "departmentNumber", "internalCurrencyCashAdvanceAmount", "internalCurrencyExpenseTotal", "name", "organizationalLevelAssociationID", "quickBooksReferenceNumber", "reimbursementCurrencyAmountDue", "reimbursementCurrencyCashAdvanceAmount", "reimbursementCurrencyID", "rejectionReason", "status", "submit", "submitDate", "submitterID", "weekEnding"],
|
|
20120
20382
|
"holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
|
|
20121
20383
|
"holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
|
|
20384
|
+
"internal_locations": ["id", "additionalAddressInfo", "address1", "address2", "city", "country", "holidaySetId", "isDefault", "name", "postalCode", "state", "timeZone"],
|
|
20385
|
+
"inventory_items": ["id", "backOrderQuantity", "bin", "impersonatorCreatorResourceID", "inventoryLocationID", "productID", "quantityMaximum", "quantityMinimum", "quantityOnHand", "quantityOnOrder", "quantityPicked", "quantityReserved", "referenceNumber"],
|
|
20122
20386
|
"inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
|
|
20123
20387
|
"inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
|
|
20124
20388
|
"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"],
|
|
@@ -20165,6 +20429,7 @@ var MODEL_FIELD_SETS = {
|
|
|
20165
20429
|
"service_calls": ["id", "cancelationNoticeHours", "canceledByResourceID", "canceledDateTime", "companyID", "companyLocationID", "createDateTime", "creatorResourceID", "description", "duration", "endDateTime", "impersonatorCreatorResourceID", "isComplete", "lastModifiedDateTime", "startDateTime", "status"],
|
|
20166
20430
|
"service_level_agreement_results": ["id", "firstResponseElapsedHours", "firstResponseInitiatingResourceID", "firstResponseResourceID", "isFirstResponseMet", "isResolutionMet", "isResolutionPlanMet", "resolutionElapsedHours", "resolutionPlanElapsedHours", "resolutionPlanResourceID", "resolutionResourceID", "serviceLevelAgreementName", "ticketID", "soapParentPropertyId"],
|
|
20167
20431
|
"services": ["id", "billingCodeID", "createDate", "creatorResourceID", "description", "invoiceDescription", "isActive", "lastModifiedDate", "markupRate", "name", "periodType", "serviceLevelAgreementID", "unitCost", "unitPrice", "updateResourceID", "vendorCompanyID", "manufacturerServiceProvider", "manufacturerServiceProviderProductNumber", "catalogNumberPartNumber", "sku", "internalID", "externalID", "url", "userDefinedFields"],
|
|
20432
|
+
"shipping_types": ["id", "billingCodeID", "description", "isActive", "name"],
|
|
20168
20433
|
"skills": ["id", "categoryID", "description", "isActive", "name"],
|
|
20169
20434
|
"subscription_periods": ["id", "periodCost", "periodDate", "periodPrice", "postedDate", "purchaseOrderNumber", "subscriptionID", "soapParentPropertyId"],
|
|
20170
20435
|
"subscriptions": ["id", "configurationItemID", "description", "effectiveDate", "expirationDate", "impersonatorCreatorResourceID", "materialCodeID", "organizationalLevelAssociationID", "periodCost", "periodPrice", "periodType", "purchaseOrderNumber", "status", "subscriptionName", "totalCost", "totalPrice", "vendorID", "userDefinedFields"],
|
|
@@ -20359,27 +20624,28 @@ function validateRelationLeaves(resourceKey, conditions, op) {
|
|
|
20359
20624
|
assertUndottedUdfField(c, op);
|
|
20360
20625
|
const field = c.field;
|
|
20361
20626
|
const [rel, sub, ...rest] = field.split(".");
|
|
20362
|
-
const
|
|
20627
|
+
const fail5 = (why) => {
|
|
20363
20628
|
throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
|
|
20364
20629
|
operation: op,
|
|
20365
20630
|
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.`
|
|
20366
20631
|
});
|
|
20367
20632
|
};
|
|
20368
20633
|
if (selfPrefixes(resourceKey).includes(rel)) {
|
|
20369
|
-
if (rest.length > 0 || !sub)
|
|
20634
|
+
if (rest.length > 0 || !sub) fail5("is not <resource>.<field> (multi-hop relations are not supported)");
|
|
20370
20635
|
continue;
|
|
20371
20636
|
}
|
|
20372
|
-
if (rest.length > 0 || !sub)
|
|
20373
|
-
if (!valid.includes(rel))
|
|
20637
|
+
if (rest.length > 0 || !sub) fail5("is not <relation>.<field> (multi-hop relations are not supported)");
|
|
20638
|
+
if (!valid.includes(rel)) fail5(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
|
|
20374
20639
|
const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
|
|
20375
20640
|
if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
|
|
20376
|
-
|
|
20641
|
+
fail5(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
|
|
20377
20642
|
}
|
|
20378
20643
|
}
|
|
20379
20644
|
};
|
|
20380
20645
|
walk(conditions);
|
|
20381
20646
|
}
|
|
20382
20647
|
async function rewriteRelationFilters(http, resourceKey, conditions, op) {
|
|
20648
|
+
assertSupportedUdfConditions(conditions, op);
|
|
20383
20649
|
if (!hasRelationConditions(conditions)) return void 0;
|
|
20384
20650
|
const conds = conditions;
|
|
20385
20651
|
validateRelationLeaves(resourceKey, conds, op);
|
|
@@ -20468,11 +20734,14 @@ var ROW_FK_TABLES = {
|
|
|
20468
20734
|
configurationItemCategoryID: "configurationItemCategory"
|
|
20469
20735
|
};
|
|
20470
20736
|
var isResourceFkField = (field) => field === "resourceID" || field.endsWith("ResourceID");
|
|
20737
|
+
function rowFkTable(resourceKey, field) {
|
|
20738
|
+
return resourceKey === "shipping_types" && field === "billingCodeID" ? void 0 : ROW_FK_TABLES[field];
|
|
20739
|
+
}
|
|
20471
20740
|
function rowNamePlan(rows, resourceKey, picklistFields = []) {
|
|
20472
20741
|
const builder = createNamePlan(picklistFields, resourceKey);
|
|
20473
20742
|
for (const row of rows) {
|
|
20474
20743
|
for (const [field, value] of Object.entries(row)) {
|
|
20475
|
-
const table =
|
|
20744
|
+
const table = rowFkTable(resourceKey, field);
|
|
20476
20745
|
if (table !== void 0) builder.addFk(table, value);
|
|
20477
20746
|
else if (isResourceFkField(field)) builder.addResource(value);
|
|
20478
20747
|
}
|
|
@@ -20510,7 +20779,7 @@ async function labelRows(client, resourceKey, rows) {
|
|
|
20510
20779
|
if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
20511
20780
|
}
|
|
20512
20781
|
}
|
|
20513
|
-
const labelled = (field) => picklistFields.includes(field) ||
|
|
20782
|
+
const labelled = (field) => picklistFields.includes(field) || rowFkTable(resourceKey, field) !== void 0 || isResourceFkField(field);
|
|
20514
20783
|
if (![...keys].some(labelled)) return { rows: [...rows] };
|
|
20515
20784
|
const plan = rowNamePlan(rows, resourceKey, picklistFields);
|
|
20516
20785
|
const names = plan.resourceIds.length === 0 && plan.recordFks.length === 0 && picklistFields.length === 0 ? void 0 : await resolveCompositeNames(client.http, plan);
|
|
@@ -20519,7 +20788,7 @@ async function labelRows(client, resourceKey, rows) {
|
|
|
20519
20788
|
for (const [field, value] of Object.entries(row)) {
|
|
20520
20789
|
const has2 = value !== null && value !== void 0 && names !== void 0;
|
|
20521
20790
|
if (picklistFields.includes(field)) r[`${field}Label`] = has2 ? names.labelFor(field, value) : null;
|
|
20522
|
-
const table =
|
|
20791
|
+
const table = rowFkTable(resourceKey, field);
|
|
20523
20792
|
const set = has2 && (table === "company" || value !== 0 && value !== "0");
|
|
20524
20793
|
if (table !== void 0) r[`${field}Name`] = set && isVendorId(value) ? untrustedName(names.recordName(table, value)) : null;
|
|
20525
20794
|
else if (isResourceFkField(field)) r[`${field}Name`] = set && isVendorId(value) ? untrustedName(names.resourceName(value)) : null;
|
|
@@ -20729,11 +20998,13 @@ var QueryBase = class {
|
|
|
20729
20998
|
walkPageSize(params) {
|
|
20730
20999
|
return clampPageSize(params?.maxRecords ?? this.defaultPageSize);
|
|
20731
21000
|
}
|
|
21001
|
+
/** Capture mutable input for Knowledge Base and InventoryItems reads. */
|
|
20732
21002
|
snapshotKnowledgeBaseQuery(params) {
|
|
20733
|
-
|
|
21003
|
+
const knowledgeBase = isKnowledgeBaseRootResource(this.config.key);
|
|
21004
|
+
if ((knowledgeBase || this.config.key === "inventory_items") && isRecord2(params)) {
|
|
20734
21005
|
const captured = snapshotQueryBag(params, QUERY_BAG_KEYS);
|
|
20735
21006
|
const conditions = Array.isArray(captured.filter) ? captured.filter : captured.filter?.filter;
|
|
20736
|
-
if (conditions?.length === 0) delete captured.filter;
|
|
21007
|
+
if (knowledgeBase && conditions?.length === 0) delete captured.filter;
|
|
20737
21008
|
return captured;
|
|
20738
21009
|
}
|
|
20739
21010
|
return params;
|
|
@@ -20774,7 +21045,7 @@ var QueryBase = class {
|
|
|
20774
21045
|
}
|
|
20775
21046
|
/** Stream page objects (the resource `queryPages` surface; relation filters resolve first, #281). */
|
|
20776
21047
|
async *queryPageIter(params) {
|
|
20777
|
-
const walk = await this.relationWalkParams(params, `${this.config.key}.query`);
|
|
21048
|
+
const walk = await this.relationWalkParams(this.snapshotKnowledgeBaseQuery(params), `${this.config.key}.query`);
|
|
20778
21049
|
if (walk === void 0) return;
|
|
20779
21050
|
yield* paginate(this.pageFetcher(walk), { pageSize: this.walkPageSize(walk), continueOnEmpty: this.continueAcrossEmptyPage() });
|
|
20780
21051
|
}
|
|
@@ -21811,26 +22082,26 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21811
22082
|
|
|
21812
22083
|
// src/resources/special/knowledgeBaseCategories.ts
|
|
21813
22084
|
function admitKnowledgeBaseCategory(data, creating, staleToken) {
|
|
21814
|
-
const
|
|
22085
|
+
const fail5 = (message) => {
|
|
21815
22086
|
throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
|
|
21816
22087
|
};
|
|
21817
|
-
if (!creating && staleToken !== void 0)
|
|
21818
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22088
|
+
if (!creating && staleToken !== void 0) fail5("no documented stale timestamp is available");
|
|
22089
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
21819
22090
|
const body = { ...data };
|
|
21820
|
-
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field))
|
|
22091
|
+
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail5(`${field} is not a writable KnowledgeBaseCategories field`);
|
|
21821
22092
|
for (const [field, max] of [["name", 50], ["description", 1e3]]) {
|
|
21822
22093
|
const value = body[field];
|
|
21823
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > max))
|
|
22094
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail5(`${field} must be a string of at most ${max} characters`);
|
|
21824
22095
|
}
|
|
21825
|
-
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === ""))
|
|
21826
|
-
if (creating && body.parentCategoryID === void 0)
|
|
22096
|
+
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail5("name is required");
|
|
22097
|
+
if (creating && body.parentCategoryID === void 0) fail5("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
|
|
21827
22098
|
const parent = body.parentCategoryID;
|
|
21828
22099
|
if (parent !== void 0) {
|
|
21829
|
-
if (typeof parent !== "number") return
|
|
22100
|
+
if (typeof parent !== "number") return fail5("parentCategoryID must be a numeric identifier");
|
|
21830
22101
|
parseIdentifier(parent, "parentCategoryID");
|
|
21831
|
-
if (parent > 2147483647)
|
|
22102
|
+
if (parent > 2147483647) fail5("parentCategoryID must fit a signed 32-bit integer");
|
|
21832
22103
|
}
|
|
21833
|
-
if (!creating && !Object.values(body).some((value) => value !== void 0))
|
|
22104
|
+
if (!creating && !Object.values(body).some((value) => value !== void 0)) fail5("update must contain a writable field");
|
|
21834
22105
|
return body;
|
|
21835
22106
|
}
|
|
21836
22107
|
function categoryReplacement(body) {
|
|
@@ -21844,45 +22115,45 @@ function categoryReplacement(body) {
|
|
|
21844
22115
|
}
|
|
21845
22116
|
|
|
21846
22117
|
// src/resources/special/knowledgeBaseArticles.ts
|
|
21847
|
-
function
|
|
22118
|
+
function fail3(detail) {
|
|
21848
22119
|
throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
|
|
21849
22120
|
}
|
|
21850
22121
|
function reference(value, name) {
|
|
21851
|
-
if (typeof value !== "number")
|
|
22122
|
+
if (typeof value !== "number") fail3(`${name} must be a numeric identifier`);
|
|
21852
22123
|
parseIdentifier(value, name);
|
|
21853
|
-
if (value > 2147483647)
|
|
22124
|
+
if (value > 2147483647) fail3(`${name} must fit a signed 32-bit integer`);
|
|
21854
22125
|
return value;
|
|
21855
22126
|
}
|
|
21856
22127
|
function articleParent(value) {
|
|
21857
22128
|
const parent = parseIdentifier(value, "parentId");
|
|
21858
|
-
if (typeof parent !== "number" || parent > 2147483647)
|
|
21859
|
-
if (parent === 0)
|
|
22129
|
+
if (typeof parent !== "number" || parent > 2147483647) fail3("parentId must fit a signed 32-bit category identifier");
|
|
22130
|
+
if (parent === 0) fail3("parentId must name an article category");
|
|
21860
22131
|
return parent;
|
|
21861
22132
|
}
|
|
21862
22133
|
function admitArticle(data, parentId, creating) {
|
|
21863
22134
|
const parent = articleParent(parentId);
|
|
21864
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22135
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
|
|
21865
22136
|
const body = { ...data };
|
|
21866
22137
|
const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
|
|
21867
22138
|
for (const key of Object.keys(body)) {
|
|
21868
|
-
if (!allowed.includes(key))
|
|
22139
|
+
if (!allowed.includes(key)) fail3(`${key} is not a writable article root field`);
|
|
21869
22140
|
if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
|
|
21870
22141
|
}
|
|
21871
22142
|
for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
|
|
21872
|
-
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max))
|
|
21873
|
-
}
|
|
21874
|
-
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim()))
|
|
21875
|
-
if (!creating && Object.hasOwn(body, "articleCategoryID"))
|
|
21876
|
-
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent))
|
|
21877
|
-
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647))
|
|
21878
|
-
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean")
|
|
21879
|
-
if (!creating && !Object.keys(body).length)
|
|
22143
|
+
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail3(`${field} must be a string of at most ${max} characters`);
|
|
22144
|
+
}
|
|
22145
|
+
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail3("title is required and cannot be blank");
|
|
22146
|
+
if (!creating && Object.hasOwn(body, "articleCategoryID")) fail3("articleCategoryID is read-only after creation");
|
|
22147
|
+
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail3("articleCategoryID must match parentId");
|
|
22148
|
+
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647)) fail3("publish must be an int32 from current field metadata");
|
|
22149
|
+
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail3("isActive must be boolean");
|
|
22150
|
+
if (!creating && !Object.keys(body).length) fail3("update must contain a writable field");
|
|
21880
22151
|
return body;
|
|
21881
22152
|
}
|
|
21882
22153
|
async function guardArticle(http, parentId, id, maxRetries) {
|
|
21883
22154
|
const parent = articleParent(parentId);
|
|
21884
22155
|
const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
|
|
21885
|
-
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target))))
|
|
22156
|
+
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail3("id must name an article within the signed 64-bit range");
|
|
21886
22157
|
unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
|
|
21887
22158
|
if (target !== void 0) {
|
|
21888
22159
|
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");
|
|
@@ -21891,7 +22162,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
|
|
|
21891
22162
|
}
|
|
21892
22163
|
function assertArticlePublish(data, fields) {
|
|
21893
22164
|
if (!Object.hasOwn(data, "publish")) return;
|
|
21894
|
-
const unavailable = () =>
|
|
22165
|
+
const unavailable = () => fail3("publish requires an unambiguous active value in current field metadata");
|
|
21895
22166
|
if (!Array.isArray(fields)) unavailable();
|
|
21896
22167
|
const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
|
|
21897
22168
|
if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
|
|
@@ -21925,14 +22196,15 @@ var MutationBase = class extends MetaBase {
|
|
|
21925
22196
|
return body;
|
|
21926
22197
|
}
|
|
21927
22198
|
/** `POST /V1.0/<E>` → `{ id }` (issue #13: a drifted 2xx runs the bounded marker recovery where the plan pins a marker field). */
|
|
21928
|
-
async createGlobal(data, opts = {}) {
|
|
22199
|
+
async createGlobal(data, opts = {}, checkedBaseUrl) {
|
|
21929
22200
|
const body = this.normalizeMutationBody(data);
|
|
21930
22201
|
const res = await this.http.request({
|
|
21931
22202
|
method: "POST",
|
|
21932
22203
|
path: this.resourcePath,
|
|
21933
22204
|
body,
|
|
21934
22205
|
operation: `${this.config.key}.create`,
|
|
21935
|
-
maxRetries: opts.maxRetries
|
|
22206
|
+
maxRetries: opts.maxRetries,
|
|
22207
|
+
...checkedBaseUrl === void 0 ? {} : { checkedBaseUrl, maintenanceMaxWaitMs: 0 }
|
|
21936
22208
|
});
|
|
21937
22209
|
return this.unwrapCreateOperation(res, body, opts);
|
|
21938
22210
|
}
|
|
@@ -22104,11 +22376,12 @@ var MutationBase = class extends MetaBase {
|
|
|
22104
22376
|
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);
|
|
22105
22377
|
const submitted = data;
|
|
22106
22378
|
const persisted = stored;
|
|
22107
|
-
|
|
22108
|
-
|
|
22379
|
+
const inventory = this.config.key === "inventory_locations" || this.config.key === "inventory_items";
|
|
22380
|
+
if (inventory) {
|
|
22381
|
+
if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError(`${this.config.key}: persisted record requires its own id`);
|
|
22109
22382
|
validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
|
|
22110
22383
|
}
|
|
22111
|
-
const notPersisted =
|
|
22384
|
+
const notPersisted = inventory ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
22112
22385
|
return { ...result, notPersisted };
|
|
22113
22386
|
} catch (err) {
|
|
22114
22387
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
@@ -22495,7 +22768,7 @@ var MutationBase = class extends MetaBase {
|
|
|
22495
22768
|
const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
|
|
22496
22769
|
let current;
|
|
22497
22770
|
try {
|
|
22498
|
-
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));
|
|
22771
|
+
current = currentRecord ?? (parentId === void 0 ? await this.getGlobal(id, true, this.config.key === "knowledge_base_categories" || partialCollection !== void 0 ? opts.maxRetries : void 0, partialCollection?.checkedBaseUrl) : this.config.attachmentGet ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true));
|
|
22499
22772
|
} catch (err) {
|
|
22500
22773
|
if (err instanceof NotFoundError) {
|
|
22501
22774
|
const reasons = EMPTY_REASON_STAMPS[this.config.key];
|
|
@@ -22521,7 +22794,7 @@ var MutationBase = class extends MetaBase {
|
|
|
22521
22794
|
throw err;
|
|
22522
22795
|
}
|
|
22523
22796
|
checks.push({ name: "current-record-exists", ok: true });
|
|
22524
|
-
partialCollection
|
|
22797
|
+
if (partialCollection !== void 0) await partialCollection.checkCurrent(current);
|
|
22525
22798
|
if (this.staleObjectCheck(current, opts, operation)) {
|
|
22526
22799
|
checks.push({ name: "stale-check", ok: true });
|
|
22527
22800
|
}
|
|
@@ -22603,34 +22876,34 @@ var BaseResource = class extends MutationBase {
|
|
|
22603
22876
|
};
|
|
22604
22877
|
|
|
22605
22878
|
// src/resources/special/taskPredecessors.ts
|
|
22606
|
-
function
|
|
22879
|
+
function fail4(detail) {
|
|
22607
22880
|
throw new AutotaskConfigError(`task_predecessors: ${detail}`);
|
|
22608
22881
|
}
|
|
22609
22882
|
function numeric(value, field) {
|
|
22610
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
22883
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail4(`${field} must be a positive numeric identifier`);
|
|
22611
22884
|
return value;
|
|
22612
22885
|
}
|
|
22613
22886
|
function predecessorParent(value) {
|
|
22614
22887
|
const parent = parseIdentifier(value, "parentId");
|
|
22615
|
-
if (parent === 0)
|
|
22888
|
+
if (parent === 0) fail4("parentId must name a successor task");
|
|
22616
22889
|
return parent;
|
|
22617
22890
|
}
|
|
22618
22891
|
function assertPredecessorBinding(value, parentId, id) {
|
|
22619
|
-
if (!isRecord2(value))
|
|
22620
|
-
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId)))
|
|
22892
|
+
if (!isRecord2(value)) fail4("the returned record must establish id and successorTaskID parent");
|
|
22893
|
+
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId))) fail4("the returned record must match id and successorTaskID parent");
|
|
22621
22894
|
}
|
|
22622
22895
|
function admitTaskPredecessor(data, parentId, creating) {
|
|
22623
22896
|
const parent = predecessorParent(parentId);
|
|
22624
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22897
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22625
22898
|
const payload = { ...data };
|
|
22626
22899
|
const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
|
|
22627
|
-
if (Object.keys(payload).some((key) => !allowed.includes(key)))
|
|
22628
|
-
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647))
|
|
22900
|
+
if (Object.keys(payload).some((key) => !allowed.includes(key))) fail4(creating ? "only predecessorTaskID, successorTaskID and lagDays are writable on create" : "only lagDays can be updated");
|
|
22901
|
+
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647)) fail4("lagDays must be an int32 integer");
|
|
22629
22902
|
if (creating) {
|
|
22630
22903
|
const successor = numeric(payload.successorTaskID, "successorTaskID");
|
|
22631
22904
|
const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
|
|
22632
|
-
if (String(successor) !== String(parent))
|
|
22633
|
-
if (predecessor === successor)
|
|
22905
|
+
if (String(successor) !== String(parent)) fail4("successorTaskID must match parentId");
|
|
22906
|
+
if (predecessor === successor) fail4("predecessorTaskID and successorTaskID must be distinct");
|
|
22634
22907
|
}
|
|
22635
22908
|
return payload;
|
|
22636
22909
|
}
|
|
@@ -22639,50 +22912,50 @@ async function guardTaskPredecessor(http, parentId, id, data) {
|
|
|
22639
22912
|
let row = data;
|
|
22640
22913
|
if (id !== void 0) {
|
|
22641
22914
|
const target = parseIdentifier(id, "id");
|
|
22642
|
-
if (target === 0)
|
|
22915
|
+
if (target === 0) fail4("id must name a predecessor relationship");
|
|
22643
22916
|
row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
|
|
22644
22917
|
assertPredecessorBinding(row, parent, target);
|
|
22645
22918
|
}
|
|
22646
22919
|
const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
|
|
22647
22920
|
const successor = numeric(row?.successorTaskID, "successorTaskID");
|
|
22648
|
-
if (predecessor === successor)
|
|
22921
|
+
if (predecessor === successor) fail4("predecessorTaskID and successorTaskID must be distinct");
|
|
22649
22922
|
const projects = [];
|
|
22650
22923
|
for (const taskId of [predecessor, successor]) {
|
|
22651
22924
|
const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
|
|
22652
|
-
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId))
|
|
22925
|
+
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail4("the returned task must match its requested id");
|
|
22653
22926
|
projects.push(numeric(task.projectID, "task.projectID"));
|
|
22654
22927
|
}
|
|
22655
|
-
if (projects[0] !== projects[1])
|
|
22928
|
+
if (projects[0] !== projects[1]) fail4("predecessor and successor tasks must belong to the same project");
|
|
22656
22929
|
}
|
|
22657
22930
|
|
|
22658
22931
|
// src/resources/special/taskNotes.ts
|
|
22659
22932
|
var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
|
|
22660
22933
|
function admitTaskNote(data, parentId, creating) {
|
|
22661
22934
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22662
|
-
const
|
|
22935
|
+
const fail5 = (message) => {
|
|
22663
22936
|
throw new AutotaskConfigError(`task_notes: ${message}`);
|
|
22664
22937
|
};
|
|
22665
|
-
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
22938
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) fail5("data must be a record");
|
|
22666
22939
|
const body = data;
|
|
22667
|
-
for (const key of Object.keys(body)) if (!WRITABLE.has(key))
|
|
22940
|
+
for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail5(`${key} is not a writable TaskNotes field`);
|
|
22668
22941
|
for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
|
|
22669
22942
|
const value = body[field];
|
|
22670
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > maximum))
|
|
22943
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail5(`${field} must be a string of at most ${maximum} characters`);
|
|
22671
22944
|
}
|
|
22672
|
-
if (creating && (typeof body.description !== "string" || body.description.trim() === ""))
|
|
22945
|
+
if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail5("description is required");
|
|
22673
22946
|
for (const field of ["noteType", "publish"]) {
|
|
22674
22947
|
const value = body[field];
|
|
22675
|
-
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value)))
|
|
22948
|
+
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail5(`${field} must be an integer from the current field metadata`);
|
|
22676
22949
|
}
|
|
22677
|
-
if (creating && body.taskID === void 0)
|
|
22950
|
+
if (creating && body.taskID === void 0) fail5("taskID is required in the create body and must match parentId");
|
|
22678
22951
|
for (const field of ["createdByContactID", "taskID"]) {
|
|
22679
22952
|
if (body[field] !== void 0) {
|
|
22680
|
-
if (typeof body[field] !== "number")
|
|
22953
|
+
if (typeof body[field] !== "number") fail5(`${field} must be a numeric identifier`);
|
|
22681
22954
|
const id = parseIdentifier(body[field], field);
|
|
22682
|
-
if (field === "taskID" && String(id) !== String(parent))
|
|
22955
|
+
if (field === "taskID" && String(id) !== String(parent)) fail5("taskID must match the parentId path argument");
|
|
22683
22956
|
}
|
|
22684
22957
|
}
|
|
22685
|
-
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId"))
|
|
22958
|
+
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail5("update must contain a writable field");
|
|
22686
22959
|
}
|
|
22687
22960
|
|
|
22688
22961
|
// src/operations/invoke/fieldSuggest.ts
|
|
@@ -22817,8 +23090,8 @@ function collectFilterFieldNames(conditions, resourceKey, operation = `${resourc
|
|
|
22817
23090
|
continue;
|
|
22818
23091
|
}
|
|
22819
23092
|
if (resourceKey !== void 0) {
|
|
22820
|
-
const
|
|
22821
|
-
if (
|
|
23093
|
+
const own2 = normalizeOwnField(resourceKey, cond.field);
|
|
23094
|
+
if (own2 !== cond.field) out.push(own2);
|
|
22822
23095
|
}
|
|
22823
23096
|
}
|
|
22824
23097
|
}
|
|
@@ -22910,6 +23183,7 @@ async function validateQueryFieldNames(record, holder, args) {
|
|
|
22910
23183
|
let filterNames;
|
|
22911
23184
|
if (bag["filter"] !== void 0) {
|
|
22912
23185
|
const conditions = normalizedConditions(bag["filter"]);
|
|
23186
|
+
assertSupportedUdfConditions(conditions, record.id);
|
|
22913
23187
|
filterNames = collectFilterFieldNames(conditions ?? [], record.resource, record.id);
|
|
22914
23188
|
}
|
|
22915
23189
|
if (fieldCheck === false) return;
|
|
@@ -22952,38 +23226,38 @@ function isBase64(value) {
|
|
|
22952
23226
|
}
|
|
22953
23227
|
function admitTaskAttachment(data, parentId) {
|
|
22954
23228
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22955
|
-
const
|
|
23229
|
+
const fail5 = (message) => {
|
|
22956
23230
|
throw new AutotaskConfigError(`task_attachments: ${message}`);
|
|
22957
23231
|
};
|
|
22958
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23232
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
22959
23233
|
const body = data;
|
|
22960
|
-
for (const field of Object.keys(body)) if (!WRITABLE2.has(field))
|
|
23234
|
+
for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail5(`${field} is not a supported create field`);
|
|
22961
23235
|
for (const field of ["attachmentType", "fullPath", "title"]) {
|
|
22962
|
-
if (typeof body[field] !== "string" || body[field].trim() === "")
|
|
23236
|
+
if (typeof body[field] !== "string" || body[field].trim() === "") fail5(`${field} is required and must be a non-empty string`);
|
|
22963
23237
|
}
|
|
22964
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
23238
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail5("publish must be an integer from current field metadata");
|
|
22965
23239
|
for (const field of ["data", "contentType"]) {
|
|
22966
|
-
if (body[field] !== void 0 && typeof body[field] !== "string")
|
|
23240
|
+
if (body[field] !== void 0 && typeof body[field] !== "string") fail5(`${field} must be a string`);
|
|
22967
23241
|
}
|
|
22968
23242
|
if (body.attachmentType === "FILE_ATTACHMENT") {
|
|
22969
|
-
if (typeof body.data !== "string" || body.data === "") return
|
|
22970
|
-
if (!isBase64(body.data))
|
|
23243
|
+
if (typeof body.data !== "string" || body.data === "") return fail5("FILE_ATTACHMENT requires non-empty base64 data");
|
|
23244
|
+
if (!isBase64(body.data)) fail5("FILE_ATTACHMENT data must be base64 encoded");
|
|
22971
23245
|
}
|
|
22972
23246
|
if (body.taskID !== void 0) {
|
|
22973
|
-
if (typeof body.taskID !== "number")
|
|
22974
|
-
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent))
|
|
23247
|
+
if (typeof body.taskID !== "number") fail5("taskID must be a numeric identifier");
|
|
23248
|
+
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail5("taskID must match the parentId path argument");
|
|
22975
23249
|
}
|
|
22976
23250
|
if (body.parentAttachmentID !== void 0) {
|
|
22977
|
-
if (typeof body.parentAttachmentID !== "number")
|
|
23251
|
+
if (typeof body.parentAttachmentID !== "number") fail5("parentAttachmentID must be a numeric identifier");
|
|
22978
23252
|
parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
|
|
22979
23253
|
}
|
|
22980
23254
|
}
|
|
22981
23255
|
function admitFileAttachment(resource, data, parentId) {
|
|
22982
23256
|
parseIdentifier(parentId, "parentId");
|
|
22983
|
-
const
|
|
23257
|
+
const fail5 = (message) => {
|
|
22984
23258
|
throw new AutotaskConfigError(`${resource}: ${message}`);
|
|
22985
23259
|
};
|
|
22986
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23260
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
22987
23261
|
const body = data;
|
|
22988
23262
|
const reference2 = {
|
|
22989
23263
|
project_attachments: void 0,
|
|
@@ -22996,20 +23270,20 @@ function admitFileAttachment(resource, data, parentId) {
|
|
|
22996
23270
|
configuration_item_attachments: "parentAttachmentID",
|
|
22997
23271
|
configuration_item_note_attachments: void 0
|
|
22998
23272
|
}[resource];
|
|
22999
|
-
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2)
|
|
23000
|
-
if (body.attachmentType !== "FILE_ATTACHMENT")
|
|
23273
|
+
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail5(`${field} is not a supported create field`);
|
|
23274
|
+
if (body.attachmentType !== "FILE_ATTACHMENT") fail5("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
|
|
23001
23275
|
const maxLength = resource === "project_attachments" ? void 0 : 255;
|
|
23002
23276
|
for (const field of ["fullPath", "title"]) {
|
|
23003
23277
|
const value = body[field];
|
|
23004
23278
|
const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
|
|
23005
|
-
if (typeof value !== "string" || value.trim() === "") return
|
|
23006
|
-
if (maxLength !== void 0 && value.length > maxLength)
|
|
23279
|
+
if (typeof value !== "string" || value.trim() === "") return fail5(requirement);
|
|
23280
|
+
if (maxLength !== void 0 && value.length > maxLength) fail5(requirement);
|
|
23007
23281
|
}
|
|
23008
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
23009
|
-
if (typeof body.data !== "string" || !isBase64(body.data))
|
|
23282
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail5("publish must be an integer from current field metadata");
|
|
23283
|
+
if (typeof body.data !== "string" || !isBase64(body.data)) fail5("FILE_ATTACHMENT requires nonempty base64 data");
|
|
23010
23284
|
if (reference2 !== void 0 && body[reference2] !== void 0) {
|
|
23011
|
-
if (typeof body[reference2] !== "number")
|
|
23012
|
-
if (parseIdentifier(body[reference2], reference2) === 0)
|
|
23285
|
+
if (typeof body[reference2] !== "number") fail5(`${reference2} must be a numeric identifier`);
|
|
23286
|
+
if (parseIdentifier(body[reference2], reference2) === 0) fail5(`${reference2} must be positive`);
|
|
23013
23287
|
}
|
|
23014
23288
|
}
|
|
23015
23289
|
function admitScopedAttachmentQuery(resource, params) {
|
|
@@ -23858,6 +24132,26 @@ var SIMPLE_RESOURCES = [
|
|
|
23858
24132
|
helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23859
24133
|
opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
|
|
23860
24134
|
},
|
|
24135
|
+
{
|
|
24136
|
+
key: "internal_locations",
|
|
24137
|
+
accessor: "internalLocations",
|
|
24138
|
+
resourcePath: "/V1.0/InternalLocations",
|
|
24139
|
+
deletable: false,
|
|
24140
|
+
udfCapable: false,
|
|
24141
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
24142
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
24143
|
+
opForms: { get: "global" }
|
|
24144
|
+
},
|
|
24145
|
+
{
|
|
24146
|
+
key: "inventory_items",
|
|
24147
|
+
accessor: "inventoryItems",
|
|
24148
|
+
resourcePath: "/V1.0/InventoryItems",
|
|
24149
|
+
deletable: false,
|
|
24150
|
+
udfCapable: false,
|
|
24151
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
24152
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
24153
|
+
opForms: { get: "global", create: "global", update: "global" }
|
|
24154
|
+
},
|
|
23861
24155
|
{
|
|
23862
24156
|
key: "inventory_locations",
|
|
23863
24157
|
accessor: "inventoryLocations",
|
|
@@ -24356,6 +24650,16 @@ var SIMPLE_RESOURCES = [
|
|
|
24356
24650
|
helpers: { search: true, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
24357
24651
|
opForms: { get: "global", create: "global", update: "global" }
|
|
24358
24652
|
},
|
|
24653
|
+
{
|
|
24654
|
+
key: "shipping_types",
|
|
24655
|
+
accessor: "shippingTypes",
|
|
24656
|
+
resourcePath: "/V1.0/ShippingTypes",
|
|
24657
|
+
deletable: false,
|
|
24658
|
+
udfCapable: false,
|
|
24659
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
24660
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
24661
|
+
opForms: { get: "global" }
|
|
24662
|
+
},
|
|
24359
24663
|
{
|
|
24360
24664
|
key: "skills",
|
|
24361
24665
|
accessor: "skills",
|
|
@@ -24763,7 +25067,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24763
25067
|
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 () => {
|
|
24764
25068
|
throw new OperationNotSupportedError(config.key, "getUdfInfo");
|
|
24765
25069
|
};
|
|
24766
|
-
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
|
|
25070
|
+
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations", "inventory_items"].includes(config.key)) this.createIfNotExists = async () => {
|
|
24767
25071
|
throw new OperationNotSupportedError(config.key, "createIfNotExists");
|
|
24768
25072
|
};
|
|
24769
25073
|
if (config.key === "knowledge_base_categories") {
|
|
@@ -24878,6 +25182,20 @@ var GenericResource = class extends BaseResource {
|
|
|
24878
25182
|
return this.createScopedRaw(parentId, data2, opts2);
|
|
24879
25183
|
}
|
|
24880
25184
|
if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
|
|
25185
|
+
if (this.config.key === "inventory_items") {
|
|
25186
|
+
const body = admitInventoryItem(a, true);
|
|
25187
|
+
const opts2 = snapshotInventoryItemOptions(b);
|
|
25188
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
25189
|
+
try {
|
|
25190
|
+
await guardInventoryItemCreate(this.http, body, checkedBaseUrl, opts2.maxRetries);
|
|
25191
|
+
} catch (error) {
|
|
25192
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
25193
|
+
throw error;
|
|
25194
|
+
}
|
|
25195
|
+
if (opts2.dryRun === true) return this.runCreateDryRun(body);
|
|
25196
|
+
const result = await this.createGlobal(body, opts2, checkedBaseUrl);
|
|
25197
|
+
return this.withPersistedCheck(result, body, opts2, result.id, void 0, checkedBaseUrl);
|
|
25198
|
+
}
|
|
24881
25199
|
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
|
|
24882
25200
|
const supplied = b;
|
|
24883
25201
|
const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
@@ -24906,6 +25224,21 @@ var GenericResource = class extends BaseResource {
|
|
|
24906
25224
|
return this.updateScopedRaw(parentId, id2, data2, opts2);
|
|
24907
25225
|
}
|
|
24908
25226
|
if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
|
|
25227
|
+
if (this.config.key === "inventory_items") {
|
|
25228
|
+
const id2 = inventoryItemId(a);
|
|
25229
|
+
const body = admitInventoryItem(b, false);
|
|
25230
|
+
const opts2 = snapshotInventoryItemOptions(c);
|
|
25231
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
25232
|
+
const checkCurrent = (current) => checkInventoryItemCurrent(this.http, body, current, id2, checkedBaseUrl, opts2.maxRetries);
|
|
25233
|
+
if (opts2.dryRun === true) return this.runUpdateDryRun(id2, body, opts2, void 0, void 0, { checkCurrent, checkedBaseUrl });
|
|
25234
|
+
try {
|
|
25235
|
+
await checkCurrent(await this.getGlobal(id2, true, opts2.maxRetries, checkedBaseUrl));
|
|
25236
|
+
} catch (error) {
|
|
25237
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
25238
|
+
throw error;
|
|
25239
|
+
}
|
|
25240
|
+
return this.updateGlobal(id2, body, opts2, "PATCH", checkedBaseUrl);
|
|
25241
|
+
}
|
|
24909
25242
|
const category = this.config.key === "knowledge_base_categories";
|
|
24910
25243
|
const location = this.config.key === "inventory_locations";
|
|
24911
25244
|
const id = category || location ? parseIdentifier(a, "id") : a;
|
|
@@ -26848,6 +27181,7 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
26848
27181
|
const labelled = !label || v.groupBy.length === 0 ? void 0 : await labelRows(client, v.resourceKey, top.map((g) => g.key));
|
|
26849
27182
|
const result = {
|
|
26850
27183
|
mode: v.groupBy.length > 0 ? "group" : "sum",
|
|
27184
|
+
...v.resourceKey === "inventory_items" ? { resource: v.resourceKey } : {},
|
|
26851
27185
|
groups: top.map((g, i) => ({ key: labelled?.rows[i] ?? g.key, count: g.count, ...g.sums !== void 0 ? { sums: g.sums } : {} })),
|
|
26852
27186
|
totalGroups: sorted.length,
|
|
26853
27187
|
groupsTruncated: sorted.length > top.length,
|
|
@@ -27247,15 +27581,32 @@ async function sanitiseResult(client, result, operation) {
|
|
|
27247
27581
|
{ suggestedAction: "Pass the operation key the result came from \u2014 the registry id, not the resource key." }
|
|
27248
27582
|
);
|
|
27249
27583
|
}
|
|
27250
|
-
const
|
|
27584
|
+
const records = await operationIndex();
|
|
27585
|
+
const record = records.get(operation);
|
|
27251
27586
|
if (record === void 0) {
|
|
27252
27587
|
throw new AutotaskConfigError(
|
|
27253
27588
|
`sanitiseResult: unknown operation "${operation.slice(0, 60)}" \u2014 it is not in the capability registry`,
|
|
27254
27589
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
27255
27590
|
);
|
|
27256
27591
|
}
|
|
27257
|
-
const
|
|
27258
|
-
|
|
27592
|
+
const names = record.metadata.untrustedFields;
|
|
27593
|
+
const fields = Array.isArray(names) ? names : [];
|
|
27594
|
+
const inventoryAggregate = operation === "operations.aggregate" && result.resource === "inventory_items";
|
|
27595
|
+
const projected = deepMarkUntrusted(result, inventoryAggregate ? [...fields, "referenceNumber"] : fields);
|
|
27596
|
+
if (operation === "operations.searchAcrossResources") return wrapReferenceRows(projected, "matches");
|
|
27597
|
+
if (operation === "operations.fetchByIds") return wrapReferenceRows(projected, "value");
|
|
27598
|
+
if (operation === "operations.resolveAny") {
|
|
27599
|
+
const wrapped = wrapReferenceRows(projected, "value");
|
|
27600
|
+
return isRecord2(wrapped.contains) ? { ...wrapped, contains: wrapReferenceRows(wrapped.contains, "matches") } : wrapped;
|
|
27601
|
+
}
|
|
27602
|
+
return projected;
|
|
27603
|
+
}
|
|
27604
|
+
function wrapReferenceRows(result, field) {
|
|
27605
|
+
if (!Array.isArray(result.results)) return result;
|
|
27606
|
+
return { ...result, results: result.results.map((row) => {
|
|
27607
|
+
if (!isRecord2(row) || typeof row.resource !== "string" || !Object.hasOwn(row, field) || !row.resource.split("_").every(Boolean) || camelKey(row.resource) !== "inventoryItems") return row;
|
|
27608
|
+
return { ...row, [field]: deepMarkUntrusted(row[field], ["referenceNumber"]) };
|
|
27609
|
+
}) };
|
|
27259
27610
|
}
|
|
27260
27611
|
|
|
27261
27612
|
// src/resources/special/invoices.ts
|
|
@@ -28658,18 +29009,18 @@ async function fetchExpenses(ctx, join, entries) {
|
|
|
28658
29009
|
const gaps = [...task.gaps];
|
|
28659
29010
|
const timeTruncated = ctx.truncatedMonths["timeEntries"];
|
|
28660
29011
|
if (timeTruncated !== void 0 && timeTruncated.length > 0) gaps.push(`time entries truncated in ${timeTruncated.join(", ")}, so a no-contract ticket or task their missing rows reference is not joined`);
|
|
28661
|
-
const
|
|
29012
|
+
const own2 = [
|
|
28662
29013
|
...tasks.ids.length > 0 ? [{ field: "taskID", op: "in", value: tasks.ids }] : [],
|
|
28663
29014
|
...task.projectIds.length > 0 ? [{ field: "projectID", op: "in", value: task.projectIds }] : []
|
|
28664
29015
|
];
|
|
28665
29016
|
const orOf = (keys) => [keys.length === 1 ? keys[0] : { op: "or", items: keys }, ...ctx.windowOn("expenseDate")];
|
|
28666
|
-
const expCond = orOf([{ field: "ticketID", op: "exist" }, ...
|
|
29017
|
+
const expCond = orOf([{ field: "ticketID", op: "exist" }, ...own2]);
|
|
28667
29018
|
const shared = ctx.sharedExpenses;
|
|
28668
29019
|
let raw;
|
|
28669
|
-
if (shared &&
|
|
29020
|
+
if (shared && own2.length === 0) {
|
|
28670
29021
|
raw = { items: [], capped: false, hasMore: false };
|
|
28671
29022
|
} else {
|
|
28672
|
-
const read = await ctx.windowedPart("expenses", "expense_items", "/V1.0/ExpenseItems/query", shared ? orOf(
|
|
29023
|
+
const read = await ctx.windowedPart("expenses", "expense_items", "/V1.0/ExpenseItems/query", shared ? orOf(own2) : expCond, EXPENSE_FIELDS, "expenseDate", EXPENSE_PAGE);
|
|
28673
29024
|
raw = read.part;
|
|
28674
29025
|
raw.items = read.rows;
|
|
28675
29026
|
}
|
|
@@ -29570,16 +29921,16 @@ function latchingHttp(raw, spend) {
|
|
|
29570
29921
|
}
|
|
29571
29922
|
};
|
|
29572
29923
|
observeRecordReadFailures(http, latch);
|
|
29573
|
-
const
|
|
29924
|
+
const fail5 = (err) => {
|
|
29574
29925
|
latch(err);
|
|
29575
29926
|
throw err;
|
|
29576
29927
|
};
|
|
29577
29928
|
http.request = (o) => {
|
|
29578
29929
|
if (fatal) throw fatal;
|
|
29579
29930
|
try {
|
|
29580
|
-
return counted.request({ ...o, signal: o.signal ?? signal }).catch(
|
|
29931
|
+
return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail5);
|
|
29581
29932
|
} catch (err) {
|
|
29582
|
-
return
|
|
29933
|
+
return fail5(err);
|
|
29583
29934
|
}
|
|
29584
29935
|
};
|
|
29585
29936
|
return { http, fatal: () => fatal, signal };
|