node-autotask 0.91.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 +4 -0
- package/MCP_TOOL_CATALOG.json +152 -9
- package/README.md +1 -1
- package/capabilities.json +575 -28
- package/dist/capabilities-data.js +574 -27
- package/dist/capabilities.cjs +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-43ADHLZJ.js → chunk-2MC3LDZU.js} +3 -3
- package/dist/{chunk-YFC5VAKK.cjs → chunk-ATDGRAX2.cjs} +31 -30
- package/dist/{chunk-Y2KXGSWM.js → chunk-ELAU2MT5.js} +3 -2
- package/dist/{chunk-RXXITZH4.cjs → chunk-H24SV774.cjs} +377 -114
- package/dist/{chunk-5PUHGPKG.cjs → chunk-JPZ7M7QI.cjs} +200 -200
- package/dist/{chunk-2GP7W6QB.js → chunk-NQNAEA23.js} +372 -109
- package/dist/{chunk-KRYDLTY3.cjs → chunk-QXJQIZCT.cjs} +3 -3
- package/dist/{chunk-WAHRZDV4.js → chunk-XAOWO42G.js} +2 -2
- package/dist/{index-Dy92Xbpv.d.cts → index-B9y5IwT1.d.cts} +41 -1
- package/dist/{index-Dy92Xbpv.d.ts → index-B9y5IwT1.d.ts} +41 -1
- package/dist/{index-C3jXvpXZ.d.ts → index-U7Lepdm2.d.ts} +8 -5
- package/dist/{index-BfGOllfY.d.cts → index-lWek2NrV.d.cts} +8 -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 +3 -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,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQXJQIZCT_cjs = require('./chunk-QXJQIZCT.cjs');
|
|
4
4
|
var chunkCM5O672I_cjs = require('./chunk-CM5O672I.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
@@ -1588,6 +1588,11 @@ function countUdfConditions(conditions) {
|
|
|
1588
1588
|
}
|
|
1589
1589
|
return n;
|
|
1590
1590
|
}
|
|
1591
|
+
function assertSupportedUdfConditions(conditions, operation) {
|
|
1592
|
+
if (operation.startsWith("inventory_items.") && conditions !== void 0 && countUdfConditions(conditions) > 0) {
|
|
1593
|
+
throw new AutotaskConfigError("InventoryItems has no record UDFs. Filter on its documented fields.", { operation });
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1591
1596
|
function serializeFilter(filter) {
|
|
1592
1597
|
return JSON.stringify(filter);
|
|
1593
1598
|
}
|
|
@@ -10967,6 +10972,65 @@ var RELATIONSHIP_MAP = {
|
|
|
10967
10972
|
"deleteBoundary": null,
|
|
10968
10973
|
"markerField": null
|
|
10969
10974
|
},
|
|
10975
|
+
"inventory_items": {
|
|
10976
|
+
"resource": "inventory_items",
|
|
10977
|
+
"apiEntity": "InventoryItem",
|
|
10978
|
+
"kind": "entity",
|
|
10979
|
+
"path": "InventoryItems",
|
|
10980
|
+
"parentScoped": false,
|
|
10981
|
+
"tier": "extended",
|
|
10982
|
+
"workflowResource": false,
|
|
10983
|
+
"group": "A",
|
|
10984
|
+
"parent": null,
|
|
10985
|
+
"children": [],
|
|
10986
|
+
"naturalKeys": {
|
|
10987
|
+
"hasSearch": false,
|
|
10988
|
+
"searchCovers": null,
|
|
10989
|
+
"findBy": []
|
|
10990
|
+
},
|
|
10991
|
+
"blindSurfaces": null,
|
|
10992
|
+
"zoneFacts": {
|
|
10993
|
+
"createRequiredSet": [
|
|
10994
|
+
"inventoryLocationID",
|
|
10995
|
+
"productID",
|
|
10996
|
+
"quantityMinimum",
|
|
10997
|
+
"quantityMaximum",
|
|
10998
|
+
"quantityOnHand"
|
|
10999
|
+
],
|
|
11000
|
+
"createGuidance": {
|
|
11001
|
+
"createOp": "inventory_items.create",
|
|
11002
|
+
"parentScoped": false,
|
|
11003
|
+
"liveProvenPrefix": [],
|
|
11004
|
+
"unproven": true,
|
|
11005
|
+
"blocker": {
|
|
11006
|
+
"kind": "unknown",
|
|
11007
|
+
"message": "Inventory access, an active location, a visible product and a unique product-location pair are required.",
|
|
11008
|
+
"remedy": "Read product and location metadata, supply the required quantities and preview before apply.",
|
|
11009
|
+
"requires": {
|
|
11010
|
+
"allOf": [
|
|
11011
|
+
"inventoryLocationID",
|
|
11012
|
+
"productID",
|
|
11013
|
+
"quantityMinimum",
|
|
11014
|
+
"quantityMaximum",
|
|
11015
|
+
"quantityOnHand"
|
|
11016
|
+
]
|
|
11017
|
+
}
|
|
11018
|
+
},
|
|
11019
|
+
"vendorEvidence": [
|
|
11020
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryItemsEntity.htm"
|
|
11021
|
+
],
|
|
11022
|
+
"deleteBoundary": {
|
|
11023
|
+
"available": false,
|
|
11024
|
+
"note": "The specification defines no public DELETE for InventoryItems."
|
|
11025
|
+
}
|
|
11026
|
+
}
|
|
11027
|
+
},
|
|
11028
|
+
"deleteBoundary": {
|
|
11029
|
+
"note": "The specification defines no public DELETE for InventoryItems. A created item cannot be removed through that API.",
|
|
11030
|
+
"proof": "spec-derived"
|
|
11031
|
+
},
|
|
11032
|
+
"markerField": null
|
|
11033
|
+
},
|
|
10970
11034
|
"inventory_locations": {
|
|
10971
11035
|
"resource": "inventory_locations",
|
|
10972
11036
|
"apiEntity": "InventoryLocation",
|
|
@@ -11173,6 +11237,7 @@ var DELETE_BOUNDARY_NOTES = {
|
|
|
11173
11237
|
"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.",
|
|
11174
11238
|
"task_notes": "The vendor defines no DELETE for task_notes (spec-derived); a created task note cannot be removed through the public API.",
|
|
11175
11239
|
"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.",
|
|
11240
|
+
"inventory_items": "The specification defines no public DELETE for InventoryItems. A created item cannot be removed through that API.",
|
|
11176
11241
|
"inventory_locations": "The vendor defines no DELETE for inventory_locations (spec-derived); a created inventory location cannot be removed through the public API."
|
|
11177
11242
|
};
|
|
11178
11243
|
var RESPONSE_DRIFT_MARKERS = {
|
|
@@ -14100,6 +14165,34 @@ var CREATE_GUIDANCE = {
|
|
|
14100
14165
|
"note": null
|
|
14101
14166
|
}
|
|
14102
14167
|
},
|
|
14168
|
+
{
|
|
14169
|
+
"resource": "inventory_items",
|
|
14170
|
+
"createOp": "inventory_items.create",
|
|
14171
|
+
"parentScoped": false,
|
|
14172
|
+
"liveProvenPrefix": [],
|
|
14173
|
+
"unproven": true,
|
|
14174
|
+
"blocker": {
|
|
14175
|
+
"kind": "unknown",
|
|
14176
|
+
"message": "Inventory access, an active location, a visible product and a unique product-location pair are required.",
|
|
14177
|
+
"remedy": "Read product and location metadata, supply the required quantities and preview before apply.",
|
|
14178
|
+
"requires": {
|
|
14179
|
+
"allOf": [
|
|
14180
|
+
"inventoryLocationID",
|
|
14181
|
+
"productID",
|
|
14182
|
+
"quantityMinimum",
|
|
14183
|
+
"quantityMaximum",
|
|
14184
|
+
"quantityOnHand"
|
|
14185
|
+
]
|
|
14186
|
+
}
|
|
14187
|
+
},
|
|
14188
|
+
"vendorEvidence": [
|
|
14189
|
+
"https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/InventoryItemsEntity.htm"
|
|
14190
|
+
],
|
|
14191
|
+
"deleteBoundary": {
|
|
14192
|
+
"available": false,
|
|
14193
|
+
"note": "The specification defines no public DELETE for InventoryItems."
|
|
14194
|
+
}
|
|
14195
|
+
},
|
|
14103
14196
|
{
|
|
14104
14197
|
"resource": "inventory_locations",
|
|
14105
14198
|
"createOp": "inventory_locations.create",
|
|
@@ -15705,7 +15798,7 @@ var CREATE_GUIDANCE = {
|
|
|
15705
15798
|
}
|
|
15706
15799
|
],
|
|
15707
15800
|
"counts": {
|
|
15708
|
-
"total":
|
|
15801
|
+
"total": 118,
|
|
15709
15802
|
"byKind": {
|
|
15710
15803
|
"ok": 41,
|
|
15711
15804
|
"blind-reference": 16,
|
|
@@ -15715,7 +15808,7 @@ var CREATE_GUIDANCE = {
|
|
|
15715
15808
|
"resource-role-pair": 2,
|
|
15716
15809
|
"delete-absent": 0,
|
|
15717
15810
|
"non-mutable": 0,
|
|
15718
|
-
"unknown":
|
|
15811
|
+
"unknown": 42
|
|
15719
15812
|
}
|
|
15720
15813
|
}
|
|
15721
15814
|
};
|
|
@@ -16495,6 +16588,10 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
|
|
|
16495
16588
|
"referenceLink",
|
|
16496
16589
|
"title"
|
|
16497
16590
|
],
|
|
16591
|
+
"inventory_items": [
|
|
16592
|
+
"bin",
|
|
16593
|
+
"referenceNumber"
|
|
16594
|
+
],
|
|
16498
16595
|
"inventory_locations": [
|
|
16499
16596
|
"locationName"
|
|
16500
16597
|
],
|
|
@@ -16966,9 +17063,9 @@ function isKnowledgeBaseRootResource(resource) {
|
|
|
16966
17063
|
return resource === "knowledge_base_categories" || resource === "knowledge_base_articles";
|
|
16967
17064
|
}
|
|
16968
17065
|
function isExactRecordResource(resource) {
|
|
16969
|
-
return resource === "inventory_locations" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
|
|
17066
|
+
return resource === "inventory_locations" || resource === "inventory_items" || resource === "internal_locations" || resource === "shipping_types" || isKnowledgeBaseRootResource(resource);
|
|
16970
17067
|
}
|
|
16971
|
-
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
17068
|
+
var EXACT_RECORD_PATH = /^\/v1\.0\/(?:InventoryLocations|InventoryItems|InternalLocations|ShippingTypes|KnowledgeBaseArticles|KnowledgeBaseCategories(?:\/\d+\/KnowledgeBaseArticles)?)(?:\/(query(?:\/(?:next|previous|count))?|\d+))?\/?$/i;
|
|
16972
17069
|
function exactRecordResponseTarget(path, method, operation) {
|
|
16973
17070
|
const match = EXACT_RECORD_PATH.exec(path);
|
|
16974
17071
|
if (match === null) return void 0;
|
|
@@ -17140,7 +17237,7 @@ function attachEmptyReasonDetails(err) {
|
|
|
17140
17237
|
} : {
|
|
17141
17238
|
surface,
|
|
17142
17239
|
kind: "not-found",
|
|
17143
|
-
note: isDeletedAuditRead(surface) ? "No audit log entry at this ID was visible to this API user." : resource === "internal_locations" || resource === "shipping_types" ? "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)`,
|
|
17240
|
+
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)`,
|
|
17144
17241
|
authority: `${resource}.query`,
|
|
17145
17242
|
remedy: `query the ${resource} collection (a bounded queryBounded walk) or verify the id from the authority surface \u2014 do not retry the same get`
|
|
17146
17243
|
};
|
|
@@ -18529,13 +18626,13 @@ async function runBounded(fn, items, opts) {
|
|
|
18529
18626
|
const results = new Array(items.length);
|
|
18530
18627
|
let next = 0;
|
|
18531
18628
|
let failure;
|
|
18532
|
-
const
|
|
18629
|
+
const fail5 = (error, index) => {
|
|
18533
18630
|
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
18534
18631
|
};
|
|
18535
18632
|
const worker = async () => {
|
|
18536
18633
|
while (failure === void 0 && next < items.length) {
|
|
18537
18634
|
if (signal?.aborted) {
|
|
18538
|
-
|
|
18635
|
+
fail5(signal.reason, -1);
|
|
18539
18636
|
return;
|
|
18540
18637
|
}
|
|
18541
18638
|
const i = next++;
|
|
@@ -18545,7 +18642,7 @@ async function runBounded(fn, items, opts) {
|
|
|
18545
18642
|
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
18546
18643
|
} catch (error) {
|
|
18547
18644
|
if (settle) results[i] = { status: "rejected", reason: error };
|
|
18548
|
-
else
|
|
18645
|
+
else fail5(error, i);
|
|
18549
18646
|
}
|
|
18550
18647
|
}
|
|
18551
18648
|
};
|
|
@@ -18601,7 +18698,7 @@ async function capabilitySets() {
|
|
|
18601
18698
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
18602
18699
|
const udfCapable = /* @__PURE__ */ new Set();
|
|
18603
18700
|
const resources = /* @__PURE__ */ new Set();
|
|
18604
|
-
for (const rec of await
|
|
18701
|
+
for (const rec of await chunkQXJQIZCT_cjs.loadCapabilityRecords()) {
|
|
18605
18702
|
if (rec.resource === "operations") continue;
|
|
18606
18703
|
resources.add(rec.resource);
|
|
18607
18704
|
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
@@ -18612,7 +18709,7 @@ async function capabilitySets() {
|
|
|
18612
18709
|
var derivedIndexPromise = null;
|
|
18613
18710
|
function derivedIndexLoad() {
|
|
18614
18711
|
if (derivedIndexPromise === null) {
|
|
18615
|
-
derivedIndexPromise =
|
|
18712
|
+
derivedIndexPromise = chunkQXJQIZCT_cjs.loadCapabilityRecords().then((records) => {
|
|
18616
18713
|
const index = /* @__PURE__ */ new Map();
|
|
18617
18714
|
for (const rec of records) {
|
|
18618
18715
|
const declared = rec.metadata?.derivedFields;
|
|
@@ -20018,6 +20115,108 @@ function checkInventoryLocationCurrent(value, current, id) {
|
|
|
20018
20115
|
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");
|
|
20019
20116
|
}
|
|
20020
20117
|
|
|
20118
|
+
// src/resources/special/inventoryItems.ts
|
|
20119
|
+
var REFERENCES = ["inventoryLocationID", "productID"];
|
|
20120
|
+
var QUANTITIES = ["quantityMinimum", "quantityMaximum", "quantityOnHand"];
|
|
20121
|
+
var TEXT_FIELDS = ["bin", "referenceNumber"];
|
|
20122
|
+
var MUTATION_OPTIONS = ["dryRun", "lastModifiedDate", "maxRetries", "raw", "verifyPersisted"];
|
|
20123
|
+
function fail2(message) {
|
|
20124
|
+
throw new AutotaskConfigError(`inventory_items: ${message}`);
|
|
20125
|
+
}
|
|
20126
|
+
function own(record, field) {
|
|
20127
|
+
return Object.hasOwn(record, field) ? record[field] : void 0;
|
|
20128
|
+
}
|
|
20129
|
+
function int32(value, label, minimum = -2147483648) {
|
|
20130
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > 2147483647) {
|
|
20131
|
+
fail2(`${label} must be an integer between ${minimum} and 2147483647`);
|
|
20132
|
+
}
|
|
20133
|
+
return value;
|
|
20134
|
+
}
|
|
20135
|
+
function inventoryItemId(value) {
|
|
20136
|
+
const id = parseIdentifier(value, "inventory_items: id");
|
|
20137
|
+
if (!isAuditDecimalId(String(id))) fail2("id must fit a signed 64-bit integer");
|
|
20138
|
+
return id;
|
|
20139
|
+
}
|
|
20140
|
+
function admitInventoryItem(value, creating) {
|
|
20141
|
+
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail2("data must be a plain record");
|
|
20142
|
+
const body = { ...value };
|
|
20143
|
+
const writable = [...QUANTITIES, ...TEXT_FIELDS, ...creating ? REFERENCES : []];
|
|
20144
|
+
for (const field of Object.keys(body)) {
|
|
20145
|
+
if (!writable.some((name) => name === field)) fail2(`${field} is not a writable InventoryItems field on ${creating ? "create" : "update"}`);
|
|
20146
|
+
}
|
|
20147
|
+
if (!creating && Object.keys(body).length === 0) fail2("update must contain a writable field");
|
|
20148
|
+
if (creating) for (const field of REFERENCES) int32(own(body, field), field, 1);
|
|
20149
|
+
for (const field of QUANTITIES) {
|
|
20150
|
+
const nonnegative = field === "quantityMinimum" || creating && field === "quantityOnHand";
|
|
20151
|
+
if (creating || Object.hasOwn(body, field)) int32(own(body, field), field, nonnegative ? 0 : void 0);
|
|
20152
|
+
}
|
|
20153
|
+
for (const field of TEXT_FIELDS) {
|
|
20154
|
+
const text = own(body, field);
|
|
20155
|
+
if (Object.hasOwn(body, field) && (typeof text !== "string" || text.length > 50)) fail2(`${field} must be a string of at most 50 characters`);
|
|
20156
|
+
}
|
|
20157
|
+
assertQuantityRange(own(body, "quantityMinimum"), own(body, "quantityMaximum"));
|
|
20158
|
+
return body;
|
|
20159
|
+
}
|
|
20160
|
+
function snapshotInventoryItemOptions(value) {
|
|
20161
|
+
if (value !== void 0 && !isRecord2(value)) fail2("options must be an object");
|
|
20162
|
+
const options = value ?? {};
|
|
20163
|
+
for (const key of MUTATION_OPTIONS) {
|
|
20164
|
+
if (key in options && !Object.hasOwn(options, key)) fail2(`${key} must be an own option`);
|
|
20165
|
+
}
|
|
20166
|
+
const result = snapshotMutationOptions(Object.fromEntries(MUTATION_OPTIONS.map((key) => [key, own(options, key)])));
|
|
20167
|
+
if (result.lastModifiedDate !== void 0) fail2("no documented stale timestamp is available");
|
|
20168
|
+
if (result.raw !== void 0 && result.raw !== false) fail2("raw updates are unsupported");
|
|
20169
|
+
if (result.maxRetries !== void 0 && (!Number.isSafeInteger(result.maxRetries) || result.maxRetries < 0)) fail2("maxRetries must be a nonnegative safe integer");
|
|
20170
|
+
if (result.verifyPersisted !== void 0 && typeof result.verifyPersisted !== "boolean") fail2("verifyPersisted must be a boolean");
|
|
20171
|
+
return result;
|
|
20172
|
+
}
|
|
20173
|
+
function assertQuantityRange(minimum, maximum) {
|
|
20174
|
+
if (typeof minimum === "number" && typeof maximum === "number" && maximum < minimum) fail2("quantityMaximum must be at least quantityMinimum");
|
|
20175
|
+
}
|
|
20176
|
+
function exactItem(value, id, label) {
|
|
20177
|
+
if (!isRecord2(value)) fail2(`${label} must be a record`);
|
|
20178
|
+
const returned = own(value, "id");
|
|
20179
|
+
if (typeof returned !== "string" && (typeof returned !== "number" || !Number.isSafeInteger(returned))) fail2(`${label} requires its own exact id`);
|
|
20180
|
+
if (String(returned) !== String(id)) fail2(`${label} id must match the requested id`);
|
|
20181
|
+
return value;
|
|
20182
|
+
}
|
|
20183
|
+
async function productIsSerialized(http, id, checkedBaseUrl, maxRetries) {
|
|
20184
|
+
const operation = "products.get";
|
|
20185
|
+
const body = await http.request({ method: "GET", path: `/V1.0/Products/${id}`, operation, maxRetries, checkedBaseUrl });
|
|
20186
|
+
const product = exactItem(unwrapItem(body, id, operation, "product"), id, "product");
|
|
20187
|
+
const serialized = own(product, "isSerialized");
|
|
20188
|
+
if (typeof serialized !== "boolean") fail2("product requires a fresh boolean isSerialized fact");
|
|
20189
|
+
return serialized;
|
|
20190
|
+
}
|
|
20191
|
+
async function guardInventoryItemCreate(http, data, checkedBaseUrl, maxRetries) {
|
|
20192
|
+
const locationId = data.inventoryLocationID;
|
|
20193
|
+
const operation = "inventory_locations.get";
|
|
20194
|
+
const body = await http.request({ method: "GET", path: `/V1.0/InventoryLocations/${locationId}`, operation, maxRetries, checkedBaseUrl });
|
|
20195
|
+
const location = exactItem(unwrapItem(body, locationId, operation, "inventory_location"), locationId, "inventory location");
|
|
20196
|
+
if (own(location, "isActive") !== true) fail2("inventory location requires a fresh isActive value explicitly true");
|
|
20197
|
+
if (await productIsSerialized(http, data.productID, checkedBaseUrl, maxRetries) && data.quantityOnHand !== 0) {
|
|
20198
|
+
fail2("quantityOnHand must be zero when creating an item for a serialized product");
|
|
20199
|
+
}
|
|
20200
|
+
}
|
|
20201
|
+
async function checkInventoryItemCurrent(http, data, current, id, checkedBaseUrl, maxRetries) {
|
|
20202
|
+
const item = exactItem(current, id, "current record");
|
|
20203
|
+
const minimum = own(data, "quantityMinimum");
|
|
20204
|
+
const maximum = own(data, "quantityMaximum");
|
|
20205
|
+
if (minimum !== void 0 || maximum !== void 0) {
|
|
20206
|
+
assertQuantityRange(
|
|
20207
|
+
minimum ?? int32(own(item, "quantityMinimum"), "current quantityMinimum", 0),
|
|
20208
|
+
maximum ?? int32(own(item, "quantityMaximum"), "current quantityMaximum")
|
|
20209
|
+
);
|
|
20210
|
+
}
|
|
20211
|
+
const onHand = own(data, "quantityOnHand");
|
|
20212
|
+
if (typeof onHand !== "number") return;
|
|
20213
|
+
const picked = int32(own(item, "quantityPicked"), "current quantityPicked");
|
|
20214
|
+
const reserved = int32(own(item, "quantityReserved"), "current quantityReserved");
|
|
20215
|
+
if (onHand < picked + reserved) fail2("quantityOnHand must be at least quantityPicked plus quantityReserved");
|
|
20216
|
+
const productId = int32(own(item, "productID"), "current productID", 1);
|
|
20217
|
+
if (await productIsSerialized(http, productId, checkedBaseUrl, maxRetries)) fail2("quantityOnHand is read-only on update for a serialized product");
|
|
20218
|
+
}
|
|
20219
|
+
|
|
20021
20220
|
// src/resources/base/types.ts
|
|
20022
20221
|
var BOUNDED_QUERY_DEFAULT_LIMIT = 500;
|
|
20023
20222
|
var BOUNDED_QUERY_MAX_LIMIT = 2500;
|
|
@@ -20185,6 +20384,7 @@ var MODEL_FIELD_SETS = {
|
|
|
20185
20384
|
"holiday_sets": ["id", "holidaySetDescription", "holidaySetName"],
|
|
20186
20385
|
"holidays": ["id", "holidayDate", "holidayName", "holidaySetID", "soapParentPropertyId"],
|
|
20187
20386
|
"internal_locations": ["id", "additionalAddressInfo", "address1", "address2", "city", "country", "holidaySetId", "isDefault", "name", "postalCode", "state", "timeZone"],
|
|
20387
|
+
"inventory_items": ["id", "backOrderQuantity", "bin", "impersonatorCreatorResourceID", "inventoryLocationID", "productID", "quantityMaximum", "quantityMinimum", "quantityOnHand", "quantityOnOrder", "quantityPicked", "quantityReserved", "referenceNumber"],
|
|
20188
20388
|
"inventory_locations": ["id", "impersonatorCreatorResourceID", "isActive", "isDefault", "locationName", "resourceID"],
|
|
20189
20389
|
"inventory_products": ["id", "availableUnits", "backOrderQuantity", "bin", "createDateTime", "createdByResourceID", "inventoryLocationID", "onHandUnits", "pickedUnits", "productID", "quantityMaximum", "quantityMinimum", "referenceNumber", "reservedUnits", "unitsOnOrder"],
|
|
20190
20390
|
"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"],
|
|
@@ -20426,27 +20626,28 @@ function validateRelationLeaves(resourceKey, conditions, op) {
|
|
|
20426
20626
|
assertUndottedUdfField(c, op);
|
|
20427
20627
|
const field = c.field;
|
|
20428
20628
|
const [rel, sub, ...rest] = field.split(".");
|
|
20429
|
-
const
|
|
20629
|
+
const fail5 = (why) => {
|
|
20430
20630
|
throw new AutotaskConfigError(`${op}: relation filter "${field}" ${why} \u2014 the request was not issued`, {
|
|
20431
20631
|
operation: op,
|
|
20432
20632
|
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.`
|
|
20433
20633
|
});
|
|
20434
20634
|
};
|
|
20435
20635
|
if (selfPrefixes(resourceKey).includes(rel)) {
|
|
20436
|
-
if (rest.length > 0 || !sub)
|
|
20636
|
+
if (rest.length > 0 || !sub) fail5("is not <resource>.<field> (multi-hop relations are not supported)");
|
|
20437
20637
|
continue;
|
|
20438
20638
|
}
|
|
20439
|
-
if (rest.length > 0 || !sub)
|
|
20440
|
-
if (!valid.includes(rel))
|
|
20639
|
+
if (rest.length > 0 || !sub) fail5("is not <relation>.<field> (multi-hop relations are not supported)");
|
|
20640
|
+
if (!valid.includes(rel)) fail5(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
|
|
20441
20641
|
const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
|
|
20442
20642
|
if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
|
|
20443
|
-
|
|
20643
|
+
fail5(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
|
|
20444
20644
|
}
|
|
20445
20645
|
}
|
|
20446
20646
|
};
|
|
20447
20647
|
walk(conditions);
|
|
20448
20648
|
}
|
|
20449
20649
|
async function rewriteRelationFilters(http, resourceKey, conditions, op) {
|
|
20650
|
+
assertSupportedUdfConditions(conditions, op);
|
|
20450
20651
|
if (!hasRelationConditions(conditions)) return void 0;
|
|
20451
20652
|
const conds = conditions;
|
|
20452
20653
|
validateRelationLeaves(resourceKey, conds, op);
|
|
@@ -20799,11 +21000,13 @@ var QueryBase = class {
|
|
|
20799
21000
|
walkPageSize(params) {
|
|
20800
21001
|
return clampPageSize(params?.maxRecords ?? this.defaultPageSize);
|
|
20801
21002
|
}
|
|
21003
|
+
/** Capture mutable input for Knowledge Base and InventoryItems reads. */
|
|
20802
21004
|
snapshotKnowledgeBaseQuery(params) {
|
|
20803
|
-
|
|
21005
|
+
const knowledgeBase = isKnowledgeBaseRootResource(this.config.key);
|
|
21006
|
+
if ((knowledgeBase || this.config.key === "inventory_items") && isRecord2(params)) {
|
|
20804
21007
|
const captured = snapshotQueryBag(params, QUERY_BAG_KEYS);
|
|
20805
21008
|
const conditions = Array.isArray(captured.filter) ? captured.filter : captured.filter?.filter;
|
|
20806
|
-
if (conditions?.length === 0) delete captured.filter;
|
|
21009
|
+
if (knowledgeBase && conditions?.length === 0) delete captured.filter;
|
|
20807
21010
|
return captured;
|
|
20808
21011
|
}
|
|
20809
21012
|
return params;
|
|
@@ -20844,7 +21047,7 @@ var QueryBase = class {
|
|
|
20844
21047
|
}
|
|
20845
21048
|
/** Stream page objects (the resource `queryPages` surface; relation filters resolve first, #281). */
|
|
20846
21049
|
async *queryPageIter(params) {
|
|
20847
|
-
const walk = await this.relationWalkParams(params, `${this.config.key}.query`);
|
|
21050
|
+
const walk = await this.relationWalkParams(this.snapshotKnowledgeBaseQuery(params), `${this.config.key}.query`);
|
|
20848
21051
|
if (walk === void 0) return;
|
|
20849
21052
|
yield* paginate(this.pageFetcher(walk), { pageSize: this.walkPageSize(walk), continueOnEmpty: this.continueAcrossEmptyPage() });
|
|
20850
21053
|
}
|
|
@@ -21881,26 +22084,26 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21881
22084
|
|
|
21882
22085
|
// src/resources/special/knowledgeBaseCategories.ts
|
|
21883
22086
|
function admitKnowledgeBaseCategory(data, creating, staleToken) {
|
|
21884
|
-
const
|
|
22087
|
+
const fail5 = (message) => {
|
|
21885
22088
|
throw new AutotaskConfigError(`knowledge_base_categories: ${message}`);
|
|
21886
22089
|
};
|
|
21887
|
-
if (!creating && staleToken !== void 0)
|
|
21888
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22090
|
+
if (!creating && staleToken !== void 0) fail5("no documented stale timestamp is available");
|
|
22091
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
21889
22092
|
const body = { ...data };
|
|
21890
|
-
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field))
|
|
22093
|
+
for (const field of Object.keys(body)) if (!["name", "description", "parentCategoryID"].includes(field)) fail5(`${field} is not a writable KnowledgeBaseCategories field`);
|
|
21891
22094
|
for (const [field, max] of [["name", 50], ["description", 1e3]]) {
|
|
21892
22095
|
const value = body[field];
|
|
21893
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > max))
|
|
22096
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > max)) fail5(`${field} must be a string of at most ${max} characters`);
|
|
21894
22097
|
}
|
|
21895
|
-
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === ""))
|
|
21896
|
-
if (creating && body.parentCategoryID === void 0)
|
|
22098
|
+
if ((creating || body.name !== void 0) && (typeof body.name !== "string" || body.name.trim() === "")) fail5("name is required");
|
|
22099
|
+
if (creating && body.parentCategoryID === void 0) fail5("parentCategoryID is required; choose a documented visible category rather than guessing a root id");
|
|
21897
22100
|
const parent = body.parentCategoryID;
|
|
21898
22101
|
if (parent !== void 0) {
|
|
21899
|
-
if (typeof parent !== "number") return
|
|
22102
|
+
if (typeof parent !== "number") return fail5("parentCategoryID must be a numeric identifier");
|
|
21900
22103
|
parseIdentifier(parent, "parentCategoryID");
|
|
21901
|
-
if (parent > 2147483647)
|
|
22104
|
+
if (parent > 2147483647) fail5("parentCategoryID must fit a signed 32-bit integer");
|
|
21902
22105
|
}
|
|
21903
|
-
if (!creating && !Object.values(body).some((value) => value !== void 0))
|
|
22106
|
+
if (!creating && !Object.values(body).some((value) => value !== void 0)) fail5("update must contain a writable field");
|
|
21904
22107
|
return body;
|
|
21905
22108
|
}
|
|
21906
22109
|
function categoryReplacement(body) {
|
|
@@ -21914,45 +22117,45 @@ function categoryReplacement(body) {
|
|
|
21914
22117
|
}
|
|
21915
22118
|
|
|
21916
22119
|
// src/resources/special/knowledgeBaseArticles.ts
|
|
21917
|
-
function
|
|
22120
|
+
function fail3(detail) {
|
|
21918
22121
|
throw new AutotaskConfigError(`knowledge_base_articles: ${detail}`);
|
|
21919
22122
|
}
|
|
21920
22123
|
function reference(value, name) {
|
|
21921
|
-
if (typeof value !== "number")
|
|
22124
|
+
if (typeof value !== "number") fail3(`${name} must be a numeric identifier`);
|
|
21922
22125
|
parseIdentifier(value, name);
|
|
21923
|
-
if (value > 2147483647)
|
|
22126
|
+
if (value > 2147483647) fail3(`${name} must fit a signed 32-bit integer`);
|
|
21924
22127
|
return value;
|
|
21925
22128
|
}
|
|
21926
22129
|
function articleParent(value) {
|
|
21927
22130
|
const parent = parseIdentifier(value, "parentId");
|
|
21928
|
-
if (typeof parent !== "number" || parent > 2147483647)
|
|
21929
|
-
if (parent === 0)
|
|
22131
|
+
if (typeof parent !== "number" || parent > 2147483647) fail3("parentId must fit a signed 32-bit category identifier");
|
|
22132
|
+
if (parent === 0) fail3("parentId must name an article category");
|
|
21930
22133
|
return parent;
|
|
21931
22134
|
}
|
|
21932
22135
|
function admitArticle(data, parentId, creating) {
|
|
21933
22136
|
const parent = articleParent(parentId);
|
|
21934
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22137
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail3("data must be a plain record");
|
|
21935
22138
|
const body = { ...data };
|
|
21936
22139
|
const allowed = ["articleCategoryID", "publish", "title", "errorCodes", "keywords", "referenceLink", "isActive"];
|
|
21937
22140
|
for (const key of Object.keys(body)) {
|
|
21938
|
-
if (!allowed.includes(key))
|
|
22141
|
+
if (!allowed.includes(key)) fail3(`${key} is not a writable article root field`);
|
|
21939
22142
|
if (key !== "articleCategoryID" && body[key] === void 0) delete body[key];
|
|
21940
22143
|
}
|
|
21941
22144
|
for (const [field, max] of [["title", 200], ["errorCodes", 200], ["keywords", 300], ["referenceLink", 500]]) {
|
|
21942
|
-
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max))
|
|
21943
|
-
}
|
|
21944
|
-
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim()))
|
|
21945
|
-
if (!creating && Object.hasOwn(body, "articleCategoryID"))
|
|
21946
|
-
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent))
|
|
21947
|
-
if ((creating || Object.hasOwn(body, "publish")) && (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish) || body.publish < -2147483648 || body.publish > 2147483647))
|
|
21948
|
-
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean")
|
|
21949
|
-
if (!creating && !Object.keys(body).length)
|
|
22145
|
+
if (Object.hasOwn(body, field) && (typeof body[field] !== "string" || body[field].length > max)) fail3(`${field} must be a string of at most ${max} characters`);
|
|
22146
|
+
}
|
|
22147
|
+
if ((creating || Object.hasOwn(body, "title")) && (typeof body.title !== "string" || !body.title.trim())) fail3("title is required and cannot be blank");
|
|
22148
|
+
if (!creating && Object.hasOwn(body, "articleCategoryID")) fail3("articleCategoryID is read-only after creation");
|
|
22149
|
+
if (creating && String(reference(body.articleCategoryID, "articleCategoryID")) !== String(parent)) fail3("articleCategoryID must match parentId");
|
|
22150
|
+
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");
|
|
22151
|
+
if (Object.hasOwn(body, "isActive") && typeof body.isActive !== "boolean") fail3("isActive must be boolean");
|
|
22152
|
+
if (!creating && !Object.keys(body).length) fail3("update must contain a writable field");
|
|
21950
22153
|
return body;
|
|
21951
22154
|
}
|
|
21952
22155
|
async function guardArticle(http, parentId, id, maxRetries) {
|
|
21953
22156
|
const parent = articleParent(parentId);
|
|
21954
22157
|
const target = id === void 0 ? void 0 : parseIdentifier(id, "id");
|
|
21955
|
-
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target))))
|
|
22158
|
+
if (target !== void 0 && (target === 0 || !isAuditDecimalId(String(target)))) fail3("id must name an article within the signed 64-bit range");
|
|
21956
22159
|
unwrapItem(await http.request({ method: "GET", path: `/V1.0/KnowledgeBaseCategories/${parent}`, operation: "knowledge_base_categories.get", maxRetries }), parent, "knowledge_base_categories.get", "article_category");
|
|
21957
22160
|
if (target !== void 0) {
|
|
21958
22161
|
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");
|
|
@@ -21961,7 +22164,7 @@ async function guardArticle(http, parentId, id, maxRetries) {
|
|
|
21961
22164
|
}
|
|
21962
22165
|
function assertArticlePublish(data, fields) {
|
|
21963
22166
|
if (!Object.hasOwn(data, "publish")) return;
|
|
21964
|
-
const unavailable = () =>
|
|
22167
|
+
const unavailable = () => fail3("publish requires an unambiguous active value in current field metadata");
|
|
21965
22168
|
if (!Array.isArray(fields)) unavailable();
|
|
21966
22169
|
const rows = fields.filter((field) => isRecord2(field) && field.name === "publish");
|
|
21967
22170
|
if (rows.length !== 1 || rows[0].isPickList !== true || rows[0].isReadOnly !== false || !Array.isArray(rows[0].picklistValues)) unavailable();
|
|
@@ -21995,14 +22198,15 @@ var MutationBase = class extends MetaBase {
|
|
|
21995
22198
|
return body;
|
|
21996
22199
|
}
|
|
21997
22200
|
/** `POST /V1.0/<E>` → `{ id }` (issue #13: a drifted 2xx runs the bounded marker recovery where the plan pins a marker field). */
|
|
21998
|
-
async createGlobal(data, opts = {}) {
|
|
22201
|
+
async createGlobal(data, opts = {}, checkedBaseUrl) {
|
|
21999
22202
|
const body = this.normalizeMutationBody(data);
|
|
22000
22203
|
const res = await this.http.request({
|
|
22001
22204
|
method: "POST",
|
|
22002
22205
|
path: this.resourcePath,
|
|
22003
22206
|
body,
|
|
22004
22207
|
operation: `${this.config.key}.create`,
|
|
22005
|
-
maxRetries: opts.maxRetries
|
|
22208
|
+
maxRetries: opts.maxRetries,
|
|
22209
|
+
...checkedBaseUrl === void 0 ? {} : { checkedBaseUrl, maintenanceMaxWaitMs: 0 }
|
|
22006
22210
|
});
|
|
22007
22211
|
return this.unwrapCreateOperation(res, body, opts);
|
|
22008
22212
|
}
|
|
@@ -22174,11 +22378,12 @@ var MutationBase = class extends MetaBase {
|
|
|
22174
22378
|
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);
|
|
22175
22379
|
const submitted = data;
|
|
22176
22380
|
const persisted = stored;
|
|
22177
|
-
|
|
22178
|
-
|
|
22381
|
+
const inventory = this.config.key === "inventory_locations" || this.config.key === "inventory_items";
|
|
22382
|
+
if (inventory) {
|
|
22383
|
+
if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError(`${this.config.key}: persisted record requires its own id`);
|
|
22179
22384
|
validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
|
|
22180
22385
|
}
|
|
22181
|
-
const notPersisted =
|
|
22386
|
+
const notPersisted = inventory ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
22182
22387
|
return { ...result, notPersisted };
|
|
22183
22388
|
} catch (err) {
|
|
22184
22389
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
@@ -22565,7 +22770,7 @@ var MutationBase = class extends MetaBase {
|
|
|
22565
22770
|
const method = scopedUpdate || partialCollection !== void 0 ? "PATCH" : "PUT";
|
|
22566
22771
|
let current;
|
|
22567
22772
|
try {
|
|
22568
|
-
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));
|
|
22773
|
+
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));
|
|
22569
22774
|
} catch (err) {
|
|
22570
22775
|
if (err instanceof NotFoundError) {
|
|
22571
22776
|
const reasons = EMPTY_REASON_STAMPS[this.config.key];
|
|
@@ -22591,7 +22796,7 @@ var MutationBase = class extends MetaBase {
|
|
|
22591
22796
|
throw err;
|
|
22592
22797
|
}
|
|
22593
22798
|
checks.push({ name: "current-record-exists", ok: true });
|
|
22594
|
-
partialCollection
|
|
22799
|
+
if (partialCollection !== void 0) await partialCollection.checkCurrent(current);
|
|
22595
22800
|
if (this.staleObjectCheck(current, opts, operation)) {
|
|
22596
22801
|
checks.push({ name: "stale-check", ok: true });
|
|
22597
22802
|
}
|
|
@@ -22673,34 +22878,34 @@ var BaseResource = class extends MutationBase {
|
|
|
22673
22878
|
};
|
|
22674
22879
|
|
|
22675
22880
|
// src/resources/special/taskPredecessors.ts
|
|
22676
|
-
function
|
|
22881
|
+
function fail4(detail) {
|
|
22677
22882
|
throw new AutotaskConfigError(`task_predecessors: ${detail}`);
|
|
22678
22883
|
}
|
|
22679
22884
|
function numeric(value, field) {
|
|
22680
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)
|
|
22885
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) fail4(`${field} must be a positive numeric identifier`);
|
|
22681
22886
|
return value;
|
|
22682
22887
|
}
|
|
22683
22888
|
function predecessorParent(value) {
|
|
22684
22889
|
const parent = parseIdentifier(value, "parentId");
|
|
22685
|
-
if (parent === 0)
|
|
22890
|
+
if (parent === 0) fail4("parentId must name a successor task");
|
|
22686
22891
|
return parent;
|
|
22687
22892
|
}
|
|
22688
22893
|
function assertPredecessorBinding(value, parentId, id) {
|
|
22689
|
-
if (!isRecord2(value))
|
|
22690
|
-
if (String(parseIdentifier(value.id, "record.id")) !== String(parseIdentifier(id, "id")) || String(parseIdentifier(value.successorTaskID, "record.successorTaskID")) !== String(predecessorParent(parentId)))
|
|
22894
|
+
if (!isRecord2(value)) fail4("the returned record must establish id and successorTaskID parent");
|
|
22895
|
+
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");
|
|
22691
22896
|
}
|
|
22692
22897
|
function admitTaskPredecessor(data, parentId, creating) {
|
|
22693
22898
|
const parent = predecessorParent(parentId);
|
|
22694
|
-
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
22899
|
+
if (!isRecord2(data) || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail4("data must be a plain record");
|
|
22695
22900
|
const payload = { ...data };
|
|
22696
22901
|
const allowed = creating ? ["predecessorTaskID", "successorTaskID", "lagDays"] : ["lagDays"];
|
|
22697
|
-
if (Object.keys(payload).some((key) => !allowed.includes(key)))
|
|
22698
|
-
if ((!creating || payload.lagDays !== void 0) && (typeof payload.lagDays !== "number" || !Number.isInteger(payload.lagDays) || payload.lagDays < -2147483648 || payload.lagDays > 2147483647))
|
|
22902
|
+
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");
|
|
22903
|
+
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");
|
|
22699
22904
|
if (creating) {
|
|
22700
22905
|
const successor = numeric(payload.successorTaskID, "successorTaskID");
|
|
22701
22906
|
const predecessor = numeric(payload.predecessorTaskID, "predecessorTaskID");
|
|
22702
|
-
if (String(successor) !== String(parent))
|
|
22703
|
-
if (predecessor === successor)
|
|
22907
|
+
if (String(successor) !== String(parent)) fail4("successorTaskID must match parentId");
|
|
22908
|
+
if (predecessor === successor) fail4("predecessorTaskID and successorTaskID must be distinct");
|
|
22704
22909
|
}
|
|
22705
22910
|
return payload;
|
|
22706
22911
|
}
|
|
@@ -22709,50 +22914,50 @@ async function guardTaskPredecessor(http, parentId, id, data) {
|
|
|
22709
22914
|
let row = data;
|
|
22710
22915
|
if (id !== void 0) {
|
|
22711
22916
|
const target = parseIdentifier(id, "id");
|
|
22712
|
-
if (target === 0)
|
|
22917
|
+
if (target === 0) fail4("id must name a predecessor relationship");
|
|
22713
22918
|
row = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${parent}/Predecessors/${target}`, operation: "task_predecessors.get" }), target, "task_predecessors.get", "task_predecessor");
|
|
22714
22919
|
assertPredecessorBinding(row, parent, target);
|
|
22715
22920
|
}
|
|
22716
22921
|
const predecessor = numeric(row?.predecessorTaskID, "predecessorTaskID");
|
|
22717
22922
|
const successor = numeric(row?.successorTaskID, "successorTaskID");
|
|
22718
|
-
if (predecessor === successor)
|
|
22923
|
+
if (predecessor === successor) fail4("predecessorTaskID and successorTaskID must be distinct");
|
|
22719
22924
|
const projects = [];
|
|
22720
22925
|
for (const taskId of [predecessor, successor]) {
|
|
22721
22926
|
const task = unwrapItem(await http.request({ method: "GET", path: `/V1.0/Tasks/${taskId}`, operation: "tasks.get" }), taskId, "tasks.get", "task");
|
|
22722
|
-
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId))
|
|
22927
|
+
if (String(parseIdentifier(task.id, "task.id")) !== String(taskId)) fail4("the returned task must match its requested id");
|
|
22723
22928
|
projects.push(numeric(task.projectID, "task.projectID"));
|
|
22724
22929
|
}
|
|
22725
|
-
if (projects[0] !== projects[1])
|
|
22930
|
+
if (projects[0] !== projects[1]) fail4("predecessor and successor tasks must belong to the same project");
|
|
22726
22931
|
}
|
|
22727
22932
|
|
|
22728
22933
|
// src/resources/special/taskNotes.ts
|
|
22729
22934
|
var WRITABLE = /* @__PURE__ */ new Set(["id", "itemId", "createdByContactID", "description", "noteType", "publish", "taskID", "title"]);
|
|
22730
22935
|
function admitTaskNote(data, parentId, creating) {
|
|
22731
22936
|
const parent = parseIdentifier(parentId, "parentId");
|
|
22732
|
-
const
|
|
22937
|
+
const fail5 = (message) => {
|
|
22733
22938
|
throw new AutotaskConfigError(`task_notes: ${message}`);
|
|
22734
22939
|
};
|
|
22735
|
-
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
22940
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) fail5("data must be a record");
|
|
22736
22941
|
const body = data;
|
|
22737
|
-
for (const key of Object.keys(body)) if (!WRITABLE.has(key))
|
|
22942
|
+
for (const key of Object.keys(body)) if (!WRITABLE.has(key)) fail5(`${key} is not a writable TaskNotes field`);
|
|
22738
22943
|
for (const [field, maximum] of [["description", 3200], ["title", 250]]) {
|
|
22739
22944
|
const value = body[field];
|
|
22740
|
-
if (value !== void 0 && (typeof value !== "string" || value.length > maximum))
|
|
22945
|
+
if (value !== void 0 && (typeof value !== "string" || value.length > maximum)) fail5(`${field} must be a string of at most ${maximum} characters`);
|
|
22741
22946
|
}
|
|
22742
|
-
if (creating && (typeof body.description !== "string" || body.description.trim() === ""))
|
|
22947
|
+
if (creating && (typeof body.description !== "string" || body.description.trim() === "")) fail5("description is required");
|
|
22743
22948
|
for (const field of ["noteType", "publish"]) {
|
|
22744
22949
|
const value = body[field];
|
|
22745
|
-
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value)))
|
|
22950
|
+
if ((creating || value !== void 0) && (typeof value !== "number" || !Number.isSafeInteger(value))) fail5(`${field} must be an integer from the current field metadata`);
|
|
22746
22951
|
}
|
|
22747
|
-
if (creating && body.taskID === void 0)
|
|
22952
|
+
if (creating && body.taskID === void 0) fail5("taskID is required in the create body and must match parentId");
|
|
22748
22953
|
for (const field of ["createdByContactID", "taskID"]) {
|
|
22749
22954
|
if (body[field] !== void 0) {
|
|
22750
|
-
if (typeof body[field] !== "number")
|
|
22955
|
+
if (typeof body[field] !== "number") fail5(`${field} must be a numeric identifier`);
|
|
22751
22956
|
const id = parseIdentifier(body[field], field);
|
|
22752
|
-
if (field === "taskID" && String(id) !== String(parent))
|
|
22957
|
+
if (field === "taskID" && String(id) !== String(parent)) fail5("taskID must match the parentId path argument");
|
|
22753
22958
|
}
|
|
22754
22959
|
}
|
|
22755
|
-
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId"))
|
|
22960
|
+
if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail5("update must contain a writable field");
|
|
22756
22961
|
}
|
|
22757
22962
|
|
|
22758
22963
|
// src/operations/invoke/fieldSuggest.ts
|
|
@@ -22887,8 +23092,8 @@ function collectFilterFieldNames(conditions, resourceKey, operation = `${resourc
|
|
|
22887
23092
|
continue;
|
|
22888
23093
|
}
|
|
22889
23094
|
if (resourceKey !== void 0) {
|
|
22890
|
-
const
|
|
22891
|
-
if (
|
|
23095
|
+
const own2 = normalizeOwnField(resourceKey, cond.field);
|
|
23096
|
+
if (own2 !== cond.field) out.push(own2);
|
|
22892
23097
|
}
|
|
22893
23098
|
}
|
|
22894
23099
|
}
|
|
@@ -22980,6 +23185,7 @@ async function validateQueryFieldNames(record, holder, args) {
|
|
|
22980
23185
|
let filterNames;
|
|
22981
23186
|
if (bag["filter"] !== void 0) {
|
|
22982
23187
|
const conditions = normalizedConditions(bag["filter"]);
|
|
23188
|
+
assertSupportedUdfConditions(conditions, record.id);
|
|
22983
23189
|
filterNames = collectFilterFieldNames(conditions ?? [], record.resource, record.id);
|
|
22984
23190
|
}
|
|
22985
23191
|
if (fieldCheck === false) return;
|
|
@@ -23022,38 +23228,38 @@ function isBase64(value) {
|
|
|
23022
23228
|
}
|
|
23023
23229
|
function admitTaskAttachment(data, parentId) {
|
|
23024
23230
|
const parent = parseIdentifier(parentId, "parentId");
|
|
23025
|
-
const
|
|
23231
|
+
const fail5 = (message) => {
|
|
23026
23232
|
throw new AutotaskConfigError(`task_attachments: ${message}`);
|
|
23027
23233
|
};
|
|
23028
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23234
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
23029
23235
|
const body = data;
|
|
23030
|
-
for (const field of Object.keys(body)) if (!WRITABLE2.has(field))
|
|
23236
|
+
for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail5(`${field} is not a supported create field`);
|
|
23031
23237
|
for (const field of ["attachmentType", "fullPath", "title"]) {
|
|
23032
|
-
if (typeof body[field] !== "string" || body[field].trim() === "")
|
|
23238
|
+
if (typeof body[field] !== "string" || body[field].trim() === "") fail5(`${field} is required and must be a non-empty string`);
|
|
23033
23239
|
}
|
|
23034
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
23240
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail5("publish must be an integer from current field metadata");
|
|
23035
23241
|
for (const field of ["data", "contentType"]) {
|
|
23036
|
-
if (body[field] !== void 0 && typeof body[field] !== "string")
|
|
23242
|
+
if (body[field] !== void 0 && typeof body[field] !== "string") fail5(`${field} must be a string`);
|
|
23037
23243
|
}
|
|
23038
23244
|
if (body.attachmentType === "FILE_ATTACHMENT") {
|
|
23039
|
-
if (typeof body.data !== "string" || body.data === "") return
|
|
23040
|
-
if (!isBase64(body.data))
|
|
23245
|
+
if (typeof body.data !== "string" || body.data === "") return fail5("FILE_ATTACHMENT requires non-empty base64 data");
|
|
23246
|
+
if (!isBase64(body.data)) fail5("FILE_ATTACHMENT data must be base64 encoded");
|
|
23041
23247
|
}
|
|
23042
23248
|
if (body.taskID !== void 0) {
|
|
23043
|
-
if (typeof body.taskID !== "number")
|
|
23044
|
-
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent))
|
|
23249
|
+
if (typeof body.taskID !== "number") fail5("taskID must be a numeric identifier");
|
|
23250
|
+
if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail5("taskID must match the parentId path argument");
|
|
23045
23251
|
}
|
|
23046
23252
|
if (body.parentAttachmentID !== void 0) {
|
|
23047
|
-
if (typeof body.parentAttachmentID !== "number")
|
|
23253
|
+
if (typeof body.parentAttachmentID !== "number") fail5("parentAttachmentID must be a numeric identifier");
|
|
23048
23254
|
parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
|
|
23049
23255
|
}
|
|
23050
23256
|
}
|
|
23051
23257
|
function admitFileAttachment(resource, data, parentId) {
|
|
23052
23258
|
parseIdentifier(parentId, "parentId");
|
|
23053
|
-
const
|
|
23259
|
+
const fail5 = (message) => {
|
|
23054
23260
|
throw new AutotaskConfigError(`${resource}: ${message}`);
|
|
23055
23261
|
};
|
|
23056
|
-
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data)))
|
|
23262
|
+
if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail5("data must be a plain record");
|
|
23057
23263
|
const body = data;
|
|
23058
23264
|
const reference2 = {
|
|
23059
23265
|
project_attachments: void 0,
|
|
@@ -23066,20 +23272,20 @@ function admitFileAttachment(resource, data, parentId) {
|
|
|
23066
23272
|
configuration_item_attachments: "parentAttachmentID",
|
|
23067
23273
|
configuration_item_note_attachments: void 0
|
|
23068
23274
|
}[resource];
|
|
23069
|
-
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2)
|
|
23070
|
-
if (body.attachmentType !== "FILE_ATTACHMENT")
|
|
23275
|
+
for (const field of Object.keys(body)) if (!FILE_WRITABLE.has(field) && field !== reference2) fail5(`${field} is not a supported create field`);
|
|
23276
|
+
if (body.attachmentType !== "FILE_ATTACHMENT") fail5("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
|
|
23071
23277
|
const maxLength = resource === "project_attachments" ? void 0 : 255;
|
|
23072
23278
|
for (const field of ["fullPath", "title"]) {
|
|
23073
23279
|
const value = body[field];
|
|
23074
23280
|
const requirement = `${field} is required and must be a nonblank string${maxLength === void 0 ? "" : ` of at most ${maxLength} characters`}`;
|
|
23075
|
-
if (typeof value !== "string" || value.trim() === "") return
|
|
23076
|
-
if (maxLength !== void 0 && value.length > maxLength)
|
|
23281
|
+
if (typeof value !== "string" || value.trim() === "") return fail5(requirement);
|
|
23282
|
+
if (maxLength !== void 0 && value.length > maxLength) fail5(requirement);
|
|
23077
23283
|
}
|
|
23078
|
-
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish))
|
|
23079
|
-
if (typeof body.data !== "string" || !isBase64(body.data))
|
|
23284
|
+
if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail5("publish must be an integer from current field metadata");
|
|
23285
|
+
if (typeof body.data !== "string" || !isBase64(body.data)) fail5("FILE_ATTACHMENT requires nonempty base64 data");
|
|
23080
23286
|
if (reference2 !== void 0 && body[reference2] !== void 0) {
|
|
23081
|
-
if (typeof body[reference2] !== "number")
|
|
23082
|
-
if (parseIdentifier(body[reference2], reference2) === 0)
|
|
23287
|
+
if (typeof body[reference2] !== "number") fail5(`${reference2} must be a numeric identifier`);
|
|
23288
|
+
if (parseIdentifier(body[reference2], reference2) === 0) fail5(`${reference2} must be positive`);
|
|
23083
23289
|
}
|
|
23084
23290
|
}
|
|
23085
23291
|
function admitScopedAttachmentQuery(resource, params) {
|
|
@@ -23938,6 +24144,16 @@ var SIMPLE_RESOURCES = [
|
|
|
23938
24144
|
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
23939
24145
|
opForms: { get: "global" }
|
|
23940
24146
|
},
|
|
24147
|
+
{
|
|
24148
|
+
key: "inventory_items",
|
|
24149
|
+
accessor: "inventoryItems",
|
|
24150
|
+
resourcePath: "/V1.0/InventoryItems",
|
|
24151
|
+
deletable: false,
|
|
24152
|
+
udfCapable: false,
|
|
24153
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
24154
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
24155
|
+
opForms: { get: "global", create: "global", update: "global" }
|
|
24156
|
+
},
|
|
23941
24157
|
{
|
|
23942
24158
|
key: "inventory_locations",
|
|
23943
24159
|
accessor: "inventoryLocations",
|
|
@@ -24853,7 +25069,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24853
25069
|
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 () => {
|
|
24854
25070
|
throw new OperationNotSupportedError(config.key, "getUdfInfo");
|
|
24855
25071
|
};
|
|
24856
|
-
if (config.ops?.create === false || isScopedAttachmentResource(config.key) || ["company_attachments", "task_predecessors", "knowledge_base_articles", "inventory_locations"].includes(config.key)) this.createIfNotExists = async () => {
|
|
25072
|
+
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 () => {
|
|
24857
25073
|
throw new OperationNotSupportedError(config.key, "createIfNotExists");
|
|
24858
25074
|
};
|
|
24859
25075
|
if (config.key === "knowledge_base_categories") {
|
|
@@ -24968,6 +25184,20 @@ var GenericResource = class extends BaseResource {
|
|
|
24968
25184
|
return this.createScopedRaw(parentId, data2, opts2);
|
|
24969
25185
|
}
|
|
24970
25186
|
if (this.config.opForms?.create === "scoped") throw new OperationNotSupportedError(this.config.key, "create");
|
|
25187
|
+
if (this.config.key === "inventory_items") {
|
|
25188
|
+
const body = admitInventoryItem(a, true);
|
|
25189
|
+
const opts2 = snapshotInventoryItemOptions(b);
|
|
25190
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
25191
|
+
try {
|
|
25192
|
+
await guardInventoryItemCreate(this.http, body, checkedBaseUrl, opts2.maxRetries);
|
|
25193
|
+
} catch (error) {
|
|
25194
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
25195
|
+
throw error;
|
|
25196
|
+
}
|
|
25197
|
+
if (opts2.dryRun === true) return this.runCreateDryRun(body);
|
|
25198
|
+
const result = await this.createGlobal(body, opts2, checkedBaseUrl);
|
|
25199
|
+
return this.withPersistedCheck(result, body, opts2, result.id, void 0, checkedBaseUrl);
|
|
25200
|
+
}
|
|
24971
25201
|
const data = this.config.key === "knowledge_base_categories" ? admitKnowledgeBaseCategory(a, true) : this.config.key === "inventory_locations" ? admitInventoryLocation(a, true) : a;
|
|
24972
25202
|
const supplied = b;
|
|
24973
25203
|
const opts = ["knowledge_base_categories", "inventory_locations"].includes(this.config.key) ? snapshotMutationOptions(supplied) : supplied ?? {};
|
|
@@ -24996,6 +25226,21 @@ var GenericResource = class extends BaseResource {
|
|
|
24996
25226
|
return this.updateScopedRaw(parentId, id2, data2, opts2);
|
|
24997
25227
|
}
|
|
24998
25228
|
if (this.config.opForms?.update === "scoped") throw new OperationNotSupportedError(this.config.key, "update");
|
|
25229
|
+
if (this.config.key === "inventory_items") {
|
|
25230
|
+
const id2 = inventoryItemId(a);
|
|
25231
|
+
const body = admitInventoryItem(b, false);
|
|
25232
|
+
const opts2 = snapshotInventoryItemOptions(c);
|
|
25233
|
+
const checkedBaseUrl = this.http.baseUrl;
|
|
25234
|
+
const checkCurrent = (current) => checkInventoryItemCurrent(this.http, body, current, id2, checkedBaseUrl, opts2.maxRetries);
|
|
25235
|
+
if (opts2.dryRun === true) return this.runUpdateDryRun(id2, body, opts2, void 0, void 0, { checkCurrent, checkedBaseUrl });
|
|
25236
|
+
try {
|
|
25237
|
+
await checkCurrent(await this.getGlobal(id2, true, opts2.maxRetries, checkedBaseUrl));
|
|
25238
|
+
} catch (error) {
|
|
25239
|
+
if (error instanceof AutotaskError) Object.assign(error, { notSent: true });
|
|
25240
|
+
throw error;
|
|
25241
|
+
}
|
|
25242
|
+
return this.updateGlobal(id2, body, opts2, "PATCH", checkedBaseUrl);
|
|
25243
|
+
}
|
|
24999
25244
|
const category = this.config.key === "knowledge_base_categories";
|
|
25000
25245
|
const location = this.config.key === "inventory_locations";
|
|
25001
25246
|
const id = category || location ? parseIdentifier(a, "id") : a;
|
|
@@ -26707,7 +26952,7 @@ function dateBucketLabel(value, bucket) {
|
|
|
26707
26952
|
var queryResourceKeysPromise = null;
|
|
26708
26953
|
function queryResourceKeys() {
|
|
26709
26954
|
if (queryResourceKeysPromise === null) {
|
|
26710
|
-
queryResourceKeysPromise =
|
|
26955
|
+
queryResourceKeysPromise = chunkQXJQIZCT_cjs.loadCapabilityRecords().then((records) => {
|
|
26711
26956
|
const s = /* @__PURE__ */ new Set();
|
|
26712
26957
|
for (const rec of records) if (rec.operation === "query") s.add(rec.resource);
|
|
26713
26958
|
return s;
|
|
@@ -26829,7 +27074,7 @@ function parseTopAndLimit(opts, problems) {
|
|
|
26829
27074
|
return { top, limit };
|
|
26830
27075
|
}
|
|
26831
27076
|
async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
26832
|
-
const records = resourceKey === void 0 ? [] : await
|
|
27077
|
+
const records = resourceKey === void 0 ? [] : await chunkQXJQIZCT_cjs.loadCapabilityRecords();
|
|
26833
27078
|
const record = resourceKey === void 0 ? void 0 : records.find((r) => r.resource === resourceKey && r.operation === "query");
|
|
26834
27079
|
if (record === void 0) return void 0;
|
|
26835
27080
|
const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
|
|
@@ -26938,6 +27183,7 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
26938
27183
|
const labelled = !label || v.groupBy.length === 0 ? void 0 : await labelRows(client, v.resourceKey, top.map((g) => g.key));
|
|
26939
27184
|
const result = {
|
|
26940
27185
|
mode: v.groupBy.length > 0 ? "group" : "sum",
|
|
27186
|
+
...v.resourceKey === "inventory_items" ? { resource: v.resourceKey } : {},
|
|
26941
27187
|
groups: top.map((g, i) => ({ key: labelled?.rows[i] ?? g.key, count: g.count, ...g.sums !== void 0 ? { sums: g.sums } : {} })),
|
|
26942
27188
|
totalGroups: sorted.length,
|
|
26943
27189
|
groupsTruncated: sorted.length > top.length,
|
|
@@ -27324,7 +27570,7 @@ async function uiLink(client, input) {
|
|
|
27324
27570
|
var indexPromise = null;
|
|
27325
27571
|
function operationIndex() {
|
|
27326
27572
|
if (indexPromise === null) {
|
|
27327
|
-
indexPromise =
|
|
27573
|
+
indexPromise = chunkQXJQIZCT_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
|
|
27328
27574
|
}
|
|
27329
27575
|
return indexPromise;
|
|
27330
27576
|
}
|
|
@@ -27337,15 +27583,32 @@ async function sanitiseResult(client, result, operation) {
|
|
|
27337
27583
|
{ suggestedAction: "Pass the operation key the result came from \u2014 the registry id, not the resource key." }
|
|
27338
27584
|
);
|
|
27339
27585
|
}
|
|
27340
|
-
const
|
|
27586
|
+
const records = await operationIndex();
|
|
27587
|
+
const record = records.get(operation);
|
|
27341
27588
|
if (record === void 0) {
|
|
27342
27589
|
throw new AutotaskConfigError(
|
|
27343
27590
|
`sanitiseResult: unknown operation "${operation.slice(0, 60)}" \u2014 it is not in the capability registry`,
|
|
27344
27591
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
27345
27592
|
);
|
|
27346
27593
|
}
|
|
27347
|
-
const
|
|
27348
|
-
|
|
27594
|
+
const names = record.metadata.untrustedFields;
|
|
27595
|
+
const fields = Array.isArray(names) ? names : [];
|
|
27596
|
+
const inventoryAggregate = operation === "operations.aggregate" && result.resource === "inventory_items";
|
|
27597
|
+
const projected = chunkCM5O672I_cjs.deepMarkUntrusted(result, inventoryAggregate ? [...fields, "referenceNumber"] : fields);
|
|
27598
|
+
if (operation === "operations.searchAcrossResources") return wrapReferenceRows(projected, "matches");
|
|
27599
|
+
if (operation === "operations.fetchByIds") return wrapReferenceRows(projected, "value");
|
|
27600
|
+
if (operation === "operations.resolveAny") {
|
|
27601
|
+
const wrapped = wrapReferenceRows(projected, "value");
|
|
27602
|
+
return isRecord2(wrapped.contains) ? { ...wrapped, contains: wrapReferenceRows(wrapped.contains, "matches") } : wrapped;
|
|
27603
|
+
}
|
|
27604
|
+
return projected;
|
|
27605
|
+
}
|
|
27606
|
+
function wrapReferenceRows(result, field) {
|
|
27607
|
+
if (!Array.isArray(result.results)) return result;
|
|
27608
|
+
return { ...result, results: result.results.map((row) => {
|
|
27609
|
+
if (!isRecord2(row) || typeof row.resource !== "string" || !Object.hasOwn(row, field) || !row.resource.split("_").every(Boolean) || camelKey(row.resource) !== "inventoryItems") return row;
|
|
27610
|
+
return { ...row, [field]: chunkCM5O672I_cjs.deepMarkUntrusted(row[field], ["referenceNumber"]) };
|
|
27611
|
+
}) };
|
|
27349
27612
|
}
|
|
27350
27613
|
|
|
27351
27614
|
// src/resources/special/invoices.ts
|
|
@@ -28748,18 +29011,18 @@ async function fetchExpenses(ctx, join, entries) {
|
|
|
28748
29011
|
const gaps = [...task.gaps];
|
|
28749
29012
|
const timeTruncated = ctx.truncatedMonths["timeEntries"];
|
|
28750
29013
|
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`);
|
|
28751
|
-
const
|
|
29014
|
+
const own2 = [
|
|
28752
29015
|
...tasks.ids.length > 0 ? [{ field: "taskID", op: "in", value: tasks.ids }] : [],
|
|
28753
29016
|
...task.projectIds.length > 0 ? [{ field: "projectID", op: "in", value: task.projectIds }] : []
|
|
28754
29017
|
];
|
|
28755
29018
|
const orOf = (keys) => [keys.length === 1 ? keys[0] : { op: "or", items: keys }, ...ctx.windowOn("expenseDate")];
|
|
28756
|
-
const expCond = orOf([{ field: "ticketID", op: "exist" }, ...
|
|
29019
|
+
const expCond = orOf([{ field: "ticketID", op: "exist" }, ...own2]);
|
|
28757
29020
|
const shared = ctx.sharedExpenses;
|
|
28758
29021
|
let raw;
|
|
28759
|
-
if (shared &&
|
|
29022
|
+
if (shared && own2.length === 0) {
|
|
28760
29023
|
raw = { items: [], capped: false, hasMore: false };
|
|
28761
29024
|
} else {
|
|
28762
|
-
const read = await ctx.windowedPart("expenses", "expense_items", "/V1.0/ExpenseItems/query", shared ? orOf(
|
|
29025
|
+
const read = await ctx.windowedPart("expenses", "expense_items", "/V1.0/ExpenseItems/query", shared ? orOf(own2) : expCond, EXPENSE_FIELDS, "expenseDate", EXPENSE_PAGE);
|
|
28763
29026
|
raw = read.part;
|
|
28764
29027
|
raw.items = read.rows;
|
|
28765
29028
|
}
|
|
@@ -29660,16 +29923,16 @@ function latchingHttp(raw, spend) {
|
|
|
29660
29923
|
}
|
|
29661
29924
|
};
|
|
29662
29925
|
observeRecordReadFailures(http, latch);
|
|
29663
|
-
const
|
|
29926
|
+
const fail5 = (err) => {
|
|
29664
29927
|
latch(err);
|
|
29665
29928
|
throw err;
|
|
29666
29929
|
};
|
|
29667
29930
|
http.request = (o) => {
|
|
29668
29931
|
if (fatal) throw fatal;
|
|
29669
29932
|
try {
|
|
29670
|
-
return counted.request({ ...o, signal: o.signal ?? signal }).catch(
|
|
29933
|
+
return counted.request({ ...o, signal: o.signal ?? signal }).catch(fail5);
|
|
29671
29934
|
} catch (err) {
|
|
29672
|
-
return
|
|
29935
|
+
return fail5(err);
|
|
29673
29936
|
}
|
|
29674
29937
|
};
|
|
29675
29938
|
return { http, fatal: () => fatal, signal };
|