node-autotask 0.88.0 → 0.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/{chunk-QKRHKLVY.js → chunk-33UVHMFN.js} +1 -1
- package/dist/{chunk-ESKQAINP.cjs → chunk-DSHWQMF2.cjs} +30 -30
- package/dist/{chunk-AB326MJO.cjs → chunk-JHDT4O7N.cjs} +198 -198
- package/dist/{chunk-LGOJ2HBH.js → chunk-JVVE4XEN.js} +2 -2
- package/dist/{chunk-K72PPAAD.js → chunk-KM7ITBOT.js} +238 -161
- package/dist/{chunk-GEFUSYH5.cjs → chunk-YTOBU3Z6.cjs} +238 -161
- package/dist/{index-D0KHVqoO.d.cts → index-4jmitXBs.d.cts} +1 -1
- package/dist/{index-D0KHVqoO.d.ts → index-4jmitXBs.d.ts} +1 -1
- package/dist/{index-BFgZJsqx.d.ts → index-GSA44LRd.d.ts} +1 -1
- package/dist/{index-DsA1-2GA.d.cts → index-XDIy_GvD.d.cts} +1 -1
- package/dist/index.cjs +84 -84
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +50 -50
- package/dist/operations/index.d.cts +4 -4
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +1 -1
- package/dist/pool.cjs +11 -11
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +3 -3
- package/dist/resources/index.cjs +26 -26
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +2 -2
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -325,12 +325,10 @@ function redactResponseBody(value, policy) {
|
|
|
325
325
|
return value.map((entry) => redactResponseBody(entry, policy));
|
|
326
326
|
}
|
|
327
327
|
if (!isPlainRecord(value)) return value;
|
|
328
|
-
|
|
329
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
328
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => {
|
|
330
329
|
const pinned = SECRET_SET.has(key) || personal && OPTIONAL_SET.has(key);
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
return out;
|
|
330
|
+
return [key, pinned ? chunkCM5O672I_cjs.REDACTED : redactResponseBody(entry, policy)];
|
|
331
|
+
}));
|
|
334
332
|
}
|
|
335
333
|
|
|
336
334
|
// src/errors/from-status.ts
|
|
@@ -1452,8 +1450,14 @@ function isAuditDecimalId(id) {
|
|
|
1452
1450
|
function isRecord2(value) {
|
|
1453
1451
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1454
1452
|
}
|
|
1455
|
-
function snapshotFields(record, keys) {
|
|
1456
|
-
const captured = { ...record }
|
|
1453
|
+
function snapshotFields(record, keys, fixed) {
|
|
1454
|
+
const captured = fixed === void 0 ? { ...record } : {
|
|
1455
|
+
...Object.fromEntries(Reflect.ownKeys(record).flatMap((key) => {
|
|
1456
|
+
if (Object.hasOwn(fixed, key) || !Object.prototype.propertyIsEnumerable.call(record, key)) return [];
|
|
1457
|
+
return [[key, Reflect.get(record, key)]];
|
|
1458
|
+
})),
|
|
1459
|
+
...fixed
|
|
1460
|
+
};
|
|
1457
1461
|
for (const key of keys) {
|
|
1458
1462
|
if (Object.hasOwn(captured, key)) continue;
|
|
1459
1463
|
const value = Reflect.get(record, key);
|
|
@@ -1673,9 +1677,20 @@ function snapshotQueryFilter(filter) {
|
|
|
1673
1677
|
throw invalidFilterShape(filter);
|
|
1674
1678
|
}
|
|
1675
1679
|
function snapshotQueryBag(bag, keys) {
|
|
1676
|
-
|
|
1680
|
+
let fixed;
|
|
1681
|
+
if (keys.includes("acknowledgeUnscoped")) {
|
|
1682
|
+
const acknowledgment = Object.getOwnPropertyDescriptor(bag, "acknowledgeUnscoped");
|
|
1683
|
+
const direct = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") ? acknowledgment.value : void 0;
|
|
1684
|
+
const filter = Reflect.get(bag, "filter");
|
|
1685
|
+
const capturedFilter = filter === void 0 ? void 0 : snapshotQueryFilter(filter);
|
|
1686
|
+
fixed = {
|
|
1687
|
+
filter: capturedFilter,
|
|
1688
|
+
acknowledgeUnscoped: direct === true ? Reflect.get(bag, "acknowledgeUnscoped") === true : direct
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
const snapshot = snapshotFields(bag, keys, fixed);
|
|
1677
1692
|
const captured = snapshot;
|
|
1678
|
-
if (captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
|
|
1693
|
+
if (fixed === void 0 && captured.filter !== void 0) captured.filter = snapshotQueryFilter(captured.filter);
|
|
1679
1694
|
if (Array.isArray(captured.includeFields)) {
|
|
1680
1695
|
const fields = captured.includeFields;
|
|
1681
1696
|
captured.includeFields = Array.from({ length: fields.length }, (_, i) => fields[i]);
|
|
@@ -16900,6 +16915,13 @@ function exactRecordResponseTarget(path, method, operation) {
|
|
|
16900
16915
|
}
|
|
16901
16916
|
return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
|
|
16902
16917
|
}
|
|
16918
|
+
function ownField(value, key) {
|
|
16919
|
+
return isRecord2(value) && Object.hasOwn(value, key) ? value[key] : void 0;
|
|
16920
|
+
}
|
|
16921
|
+
function receiptId(body) {
|
|
16922
|
+
const itemId = ownField(body, "itemId");
|
|
16923
|
+
return itemId === void 0 ? ownField(body, "id") : itemId;
|
|
16924
|
+
}
|
|
16903
16925
|
function isNonNegativeInt64(id) {
|
|
16904
16926
|
return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
|
|
16905
16927
|
}
|
|
@@ -16912,14 +16934,14 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16912
16934
|
return;
|
|
16913
16935
|
}
|
|
16914
16936
|
if (target === "query") {
|
|
16915
|
-
|
|
16937
|
+
const items = ownField(body, "items");
|
|
16938
|
+
const paging = ownField(body, "pageDetails");
|
|
16939
|
+
if (!Array.isArray(items) || !isRecord2(paging)) {
|
|
16916
16940
|
return invalid("Expected a query page with paging details");
|
|
16917
16941
|
}
|
|
16918
|
-
if (!
|
|
16919
|
-
if (
|
|
16920
|
-
|
|
16921
|
-
}
|
|
16922
|
-
const cursor = body.pageDetails.nextPageUrl;
|
|
16942
|
+
if (!items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
|
|
16943
|
+
if (ownField(paging, "count") !== items.length) invalid("The page record count did not match its rows");
|
|
16944
|
+
const cursor = ownField(paging, "nextPageUrl");
|
|
16923
16945
|
if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
|
|
16924
16946
|
invalid("Expected a valid query cursor or an explicit end of results");
|
|
16925
16947
|
}
|
|
@@ -16928,26 +16950,27 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16928
16950
|
const parts = path.replace(/\/$/, "").split("/");
|
|
16929
16951
|
const expectedId = parts.at(-1);
|
|
16930
16952
|
if (target === "mutation") {
|
|
16931
|
-
const
|
|
16932
|
-
if (!isNonNegativeInt64(
|
|
16933
|
-
const expected = method === "DELETE" ? expectedId :
|
|
16934
|
-
if (expected !== void 0 && String(
|
|
16953
|
+
const id2 = receiptId(body);
|
|
16954
|
+
if (!isNonNegativeInt64(id2)) invalid("Expected a valid mutation receipt");
|
|
16955
|
+
const expected = method === "DELETE" ? expectedId : ownField(requestBody, "id");
|
|
16956
|
+
if (expected !== void 0 && String(id2) !== String(expected)) {
|
|
16935
16957
|
invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
|
|
16936
16958
|
}
|
|
16937
16959
|
return;
|
|
16938
16960
|
}
|
|
16939
|
-
const item =
|
|
16961
|
+
const item = ownField(body, "item");
|
|
16940
16962
|
if (item === null) return;
|
|
16941
|
-
|
|
16963
|
+
const id = ownField(item, "id");
|
|
16964
|
+
if (!isNonNegativeInt64(id)) {
|
|
16942
16965
|
return invalid("Expected an item envelope with a valid record ID");
|
|
16943
16966
|
}
|
|
16944
16967
|
const entity = parts.at(-2)?.toLowerCase();
|
|
16945
16968
|
const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
|
|
16946
|
-
if (String(
|
|
16969
|
+
if (String(id) !== expectedId) {
|
|
16947
16970
|
throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
|
|
16948
16971
|
}
|
|
16949
16972
|
if (parts.length === 6) {
|
|
16950
|
-
const parent = item
|
|
16973
|
+
const parent = ownField(item, "articleCategoryID");
|
|
16951
16974
|
if (typeof parent !== "number" || !Number.isInteger(parent) || parent <= 0 || parent > 2147483647) {
|
|
16952
16975
|
invalid("Expected a valid category ID in the Knowledge Base article response");
|
|
16953
16976
|
}
|
|
@@ -16957,7 +16980,7 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16957
16980
|
}
|
|
16958
16981
|
}
|
|
16959
16982
|
function serializeExactRecordUpdate(body, operation) {
|
|
16960
|
-
if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
|
|
16983
|
+
if (!isRecord2(body) || !Object.hasOwn(body, "id") || typeof body.id !== "string") return JSON.stringify(body);
|
|
16961
16984
|
if (!isAuditDecimalId(body.id)) {
|
|
16962
16985
|
throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
|
|
16963
16986
|
}
|
|
@@ -16979,12 +17002,12 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
|
16979
17002
|
}
|
|
16980
17003
|
return value;
|
|
16981
17004
|
});
|
|
16982
|
-
const rows =
|
|
17005
|
+
const rows = target === "query" ? ownField(body, "items") : [target === "mutation" ? body : ownField(body, "item")];
|
|
16983
17006
|
if (Array.isArray(rows)) {
|
|
16984
17007
|
for (const row of rows) {
|
|
16985
17008
|
if (!isRecord2(row)) continue;
|
|
16986
|
-
const key = target === "mutation" && row
|
|
16987
|
-
const value = row
|
|
17009
|
+
const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
|
|
17010
|
+
const value = ownField(row, key);
|
|
16988
17011
|
if (typeof value !== "number") continue;
|
|
16989
17012
|
const token = (key === "id" ? idTokens : receiptTokens).get(row);
|
|
16990
17013
|
if (token === void 0 || !isAuditDecimalId(token)) row[key] = null;
|
|
@@ -16994,8 +17017,7 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
|
16994
17017
|
return body;
|
|
16995
17018
|
}
|
|
16996
17019
|
function hasExactRecordId(item) {
|
|
16997
|
-
|
|
16998
|
-
return isNonNegativeInt64(item.id);
|
|
17020
|
+
return isNonNegativeInt64(ownField(item, "id"));
|
|
16999
17021
|
}
|
|
17000
17022
|
function isAuditPage(body) {
|
|
17001
17023
|
if (!Array.isArray(body.items) || !isRecord2(body.pageDetails)) return false;
|
|
@@ -17064,7 +17086,7 @@ function unwrapItems(body, operation) {
|
|
|
17064
17086
|
return { items: body.items, pageDetails: body.pageDetails };
|
|
17065
17087
|
}
|
|
17066
17088
|
function unwrapItem(body, id, operation, entity) {
|
|
17067
|
-
if (!isRecord2(body) || !("item"
|
|
17089
|
+
if (!isRecord2(body) || !Object.hasOwn(body, "item")) {
|
|
17068
17090
|
throw new AutotaskError("Expected the item envelope { item }; got a different shape", {
|
|
17069
17091
|
code: "INVALID_RESPONSE",
|
|
17070
17092
|
category: "server",
|
|
@@ -17090,7 +17112,7 @@ function unwrapItem(body, id, operation, entity) {
|
|
|
17090
17112
|
return item;
|
|
17091
17113
|
}
|
|
17092
17114
|
function unwrapQueryCount(body, operation) {
|
|
17093
|
-
const count =
|
|
17115
|
+
const count = ownField(body, "queryCount");
|
|
17094
17116
|
if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > 2147483647) {
|
|
17095
17117
|
const err = new AutotaskError("Expected the count envelope { queryCount: non-negative int32 }", {
|
|
17096
17118
|
code: "INVALID_RESPONSE",
|
|
@@ -17104,7 +17126,7 @@ function unwrapQueryCount(body, operation) {
|
|
|
17104
17126
|
return count;
|
|
17105
17127
|
}
|
|
17106
17128
|
function unwrapOperation(body, operation) {
|
|
17107
|
-
const value =
|
|
17129
|
+
const value = receiptId(body);
|
|
17108
17130
|
const idValue = toIdentifierId(value);
|
|
17109
17131
|
if (idValue === void 0) {
|
|
17110
17132
|
const err = new AutotaskError(
|
|
@@ -18959,7 +18981,7 @@ function computeFieldDiff(current, data) {
|
|
|
18959
18981
|
const out = [];
|
|
18960
18982
|
for (const [field, to] of Object.entries(data)) {
|
|
18961
18983
|
if (field === "id" || to === void 0) continue;
|
|
18962
|
-
const from = current[field];
|
|
18984
|
+
const from = Object.hasOwn(current, field) ? current[field] : void 0;
|
|
18963
18985
|
if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
|
|
18964
18986
|
out.push({ field, from: from === void 0 ? null : from, to });
|
|
18965
18987
|
}
|
|
@@ -19797,6 +19819,109 @@ function notPersistedFields(sent, stored) {
|
|
|
19797
19819
|
return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== chunkCM5O672I_cjs.REDACTED && !same(value, stored[key])).map(([key]) => key);
|
|
19798
19820
|
}
|
|
19799
19821
|
|
|
19822
|
+
// src/operations/invoke/inputSets.ts
|
|
19823
|
+
var PARAMS_BAG_KEYS = {
|
|
19824
|
+
query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
|
|
19825
|
+
// No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
|
|
19826
|
+
// called directly), so this entry never fires. It is KEPT so that a future
|
|
19827
|
+
// `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
|
|
19828
|
+
// cannot silently open the bag (the keys are the vendor `QueryParams` set
|
|
19829
|
+
// the raw method accepts).
|
|
19830
|
+
queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
|
|
19831
|
+
// issue #145: the count bag carries the fieldCheck opt-out — the #140
|
|
19832
|
+
// refusal's advised remedy (before, the closed bag refused the very key it
|
|
19833
|
+
// advised, and the remedy looped into a second CONFIG_ERROR).
|
|
19834
|
+
count: ["filter", "fieldCheck"]
|
|
19835
|
+
};
|
|
19836
|
+
var BAG_KEY_SYNONYMS = {
|
|
19837
|
+
filters: "filter",
|
|
19838
|
+
last: "latest",
|
|
19839
|
+
// issue #59: the expected typo class (honoured only on `query`)
|
|
19840
|
+
lmit: "limit",
|
|
19841
|
+
page: "limit",
|
|
19842
|
+
pageSize: "limit",
|
|
19843
|
+
cursor: "limit",
|
|
19844
|
+
maxrecords: "maxRecords",
|
|
19845
|
+
fieldsPreset: "includeFields"
|
|
19846
|
+
// issue #287: the preset was removed — the refusal points at the explicit includeFields
|
|
19847
|
+
};
|
|
19848
|
+
function levenshtein(a, b) {
|
|
19849
|
+
if (a === b) return 0;
|
|
19850
|
+
const prev = new Array(b.length + 1);
|
|
19851
|
+
const cur = new Array(b.length + 1);
|
|
19852
|
+
for (let j = 0; j <= b.length; j += 1) prev[j] = j;
|
|
19853
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
19854
|
+
cur[0] = i;
|
|
19855
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
19856
|
+
cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
19857
|
+
}
|
|
19858
|
+
for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
|
|
19859
|
+
}
|
|
19860
|
+
return prev[b.length] ?? 0;
|
|
19861
|
+
}
|
|
19862
|
+
function suggestForKey(key, valid) {
|
|
19863
|
+
const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
|
|
19864
|
+
if (synonym !== void 0 && valid.includes(synonym)) return synonym;
|
|
19865
|
+
let best = null;
|
|
19866
|
+
for (const v of valid) {
|
|
19867
|
+
const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
|
|
19868
|
+
if (best === null || dist < best.dist) best = { key: v, dist };
|
|
19869
|
+
}
|
|
19870
|
+
if (best !== null && best.dist <= 3) return best.key;
|
|
19871
|
+
return null;
|
|
19872
|
+
}
|
|
19873
|
+
function keySuggestions(unknown, valid) {
|
|
19874
|
+
return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
19875
|
+
}
|
|
19876
|
+
function ownQueryBag(args) {
|
|
19877
|
+
const bag = args != null && Object.hasOwn(args, 0) ? args[0] : void 0;
|
|
19878
|
+
return isRecord2(bag) ? bag : void 0;
|
|
19879
|
+
}
|
|
19880
|
+
function validateParamsBag(record, args) {
|
|
19881
|
+
if (record.inputSchemaStrict !== true) return;
|
|
19882
|
+
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
19883
|
+
if (valid === void 0) return;
|
|
19884
|
+
const bag = ownQueryBag(args);
|
|
19885
|
+
if (bag === void 0) return;
|
|
19886
|
+
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
19887
|
+
if (unknown.length === 0) return;
|
|
19888
|
+
const suggestions = keySuggestions(unknown, valid);
|
|
19889
|
+
throw new AutotaskConfigError(
|
|
19890
|
+
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
19891
|
+
{
|
|
19892
|
+
operation: record.id,
|
|
19893
|
+
suggestedAction: suggestions.length > 0 ? `Fix the key name (${suggestions.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).` : `Pass only the valid keys (${valid.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).`
|
|
19894
|
+
}
|
|
19895
|
+
);
|
|
19896
|
+
}
|
|
19897
|
+
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
|
|
19898
|
+
function validateInvokeOptions(opts, operation) {
|
|
19899
|
+
if (opts === void 0 || opts === null) return;
|
|
19900
|
+
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
19901
|
+
if (unknown.length === 0) return;
|
|
19902
|
+
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
|
|
19903
|
+
throw new AutotaskConfigError(
|
|
19904
|
+
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
|
|
19905
|
+
{
|
|
19906
|
+
operation,
|
|
19907
|
+
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
|
|
19908
|
+
}
|
|
19909
|
+
);
|
|
19910
|
+
}
|
|
19911
|
+
function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
19912
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
19913
|
+
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
19914
|
+
if (unknown.length === 0) return null;
|
|
19915
|
+
const suggestions = keySuggestions(unknown, [...validKeys]);
|
|
19916
|
+
return new AutotaskConfigError(
|
|
19917
|
+
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
19918
|
+
{
|
|
19919
|
+
...operation !== void 0 ? { operation } : {},
|
|
19920
|
+
suggestedAction: suggestions.length > 0 ? operation === void 0 ? `Fix the ${subject} name (${suggestions.join(", ")}); the tool's full contract is in the tool's inputSchema, served by the MCP client's list_tools.` : `Fix the ${subject} name (${suggestions.join(", ")}); the full contract is in the tool's inputSchema (autotask_describe).` : `Pass only the valid keys (${validKeys.join(", ")}).`
|
|
19921
|
+
}
|
|
19922
|
+
);
|
|
19923
|
+
}
|
|
19924
|
+
|
|
19800
19925
|
// src/resources/special/inventoryLocations.ts
|
|
19801
19926
|
var fail = (message) => {
|
|
19802
19927
|
throw new AutotaskConfigError(`inventory_locations: ${message}`);
|
|
@@ -19805,13 +19930,17 @@ function admitInventoryLocation(value, creating) {
|
|
|
19805
19930
|
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
19806
19931
|
const body = { ...value };
|
|
19807
19932
|
for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
if (
|
|
19933
|
+
const hasName = Object.hasOwn(body, "locationName");
|
|
19934
|
+
const hasActive = Object.hasOwn(body, "isActive");
|
|
19935
|
+
if (creating && !hasName || hasName && (typeof body.locationName !== "string" || body.locationName.trim() === "" || body.locationName.length > 50)) fail("locationName is required and must be a nonblank string of at most 50 characters");
|
|
19936
|
+
if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
|
|
19937
|
+
if (!creating && !hasName && !hasActive) fail("update must contain locationName or isActive");
|
|
19811
19938
|
return body;
|
|
19812
19939
|
}
|
|
19813
|
-
function checkInventoryLocationCurrent(value, current) {
|
|
19814
|
-
if (
|
|
19940
|
+
function checkInventoryLocationCurrent(value, current, id) {
|
|
19941
|
+
if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail("current record requires its own id");
|
|
19942
|
+
if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail("current record id must match the requested id");
|
|
19943
|
+
if (Object.hasOwn(value, "isActive") && value.isActive === false && (!Object.hasOwn(current, "isDefault") || current.isDefault !== false)) fail("inactivation requires a fresh current isDefault value explicitly false; default or unknown locations cannot be inactivated");
|
|
19815
19944
|
}
|
|
19816
19945
|
|
|
19817
19946
|
// src/resources/base/types.ts
|
|
@@ -21225,8 +21354,8 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21225
21354
|
if (Object.keys(body).length === 0) {
|
|
21226
21355
|
throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
|
|
21227
21356
|
}
|
|
21228
|
-
if ("item"
|
|
21229
|
-
if (Array.isArray(body.items)) {
|
|
21357
|
+
if (Object.hasOwn(body, "item")) return unwrapItem(body, id, void 0, entity);
|
|
21358
|
+
if (Object.hasOwn(body, "items") && Array.isArray(body.items)) {
|
|
21230
21359
|
const first = body.items[0];
|
|
21231
21360
|
if (first === null || first === void 0) {
|
|
21232
21361
|
throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
|
|
@@ -21776,7 +21905,7 @@ var MutationBase = class extends MetaBase {
|
|
|
21776
21905
|
/** Normalise a mutation body: `id` OR `itemId` → `id`; UDF map → UDF array (UDF-capable only). */
|
|
21777
21906
|
normalizeMutationBody(data) {
|
|
21778
21907
|
const body = { ...data };
|
|
21779
|
-
if (body.itemId !== void 0 && body.id === void 0) {
|
|
21908
|
+
if (Object.hasOwn(body, "itemId") && body.itemId !== void 0 && (!Object.hasOwn(body, "id") || body.id === void 0)) {
|
|
21780
21909
|
body.id = body.itemId;
|
|
21781
21910
|
delete body.itemId;
|
|
21782
21911
|
}
|
|
@@ -21965,7 +22094,11 @@ var MutationBase = class extends MetaBase {
|
|
|
21965
22094
|
const stored = parentId === void 0 ? await this.getGlobal(id, true, maxRetries, checkedBaseUrl) : this.config.attachmentGet === true ? await this.getScopedModel(parentId, id, true) : await this.getScopedRaw(parentId, id, true, maxRetries);
|
|
21966
22095
|
const submitted = data;
|
|
21967
22096
|
const persisted = stored;
|
|
21968
|
-
|
|
22097
|
+
if (this.config.key === "inventory_locations") {
|
|
22098
|
+
if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError("inventory_locations: persisted record requires its own id");
|
|
22099
|
+
validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
|
|
22100
|
+
}
|
|
22101
|
+
const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
21969
22102
|
return { ...result, notPersisted };
|
|
21970
22103
|
} catch (err) {
|
|
21971
22104
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
@@ -22760,8 +22893,8 @@ function unknownNamesSuggestedAction(record, authority, filterUnknown) {
|
|
|
22760
22893
|
return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
|
|
22761
22894
|
}
|
|
22762
22895
|
async function validateQueryFieldNames(record, holder, args) {
|
|
22763
|
-
const bag = args
|
|
22764
|
-
if (
|
|
22896
|
+
const bag = ownQueryBag(args);
|
|
22897
|
+
if (bag === void 0) return;
|
|
22765
22898
|
const fieldCheck = readFieldCheck(record, bag);
|
|
22766
22899
|
const includeNames = readIncludeNames(record, bag["includeFields"]);
|
|
22767
22900
|
let filterNames;
|
|
@@ -24771,7 +24904,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24771
24904
|
const body = admitInventoryLocation(b, false);
|
|
24772
24905
|
const opts2 = snapshotMutationOptions(supplied);
|
|
24773
24906
|
if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
|
|
24774
|
-
const checkCurrent = (current) => checkInventoryLocationCurrent(body, current);
|
|
24907
|
+
const checkCurrent = (current) => checkInventoryLocationCurrent(body, current, id);
|
|
24775
24908
|
if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
|
|
24776
24909
|
const checkedBaseUrl = this.http.baseUrl;
|
|
24777
24910
|
try {
|
|
@@ -26086,7 +26219,11 @@ function resolveDispatchArgs(record, argsIn) {
|
|
|
26086
26219
|
const names = Object.keys(schema);
|
|
26087
26220
|
const unknown = Object.keys(byName).filter((k) => !names.includes(k));
|
|
26088
26221
|
if (unknown.length > 0) bad(`has no input named ${unknown.slice(0, 10).map((k) => `"${k}"`).join(", ")}${unknown.length > 10 ? ` (and ${unknown.length - 10} more)` : ""} (declared: ${declaredArgList(record)})`);
|
|
26089
|
-
const values = names.map((
|
|
26222
|
+
const values = names.map((name) => {
|
|
26223
|
+
if (Object.hasOwn(byName, name)) return byName[name];
|
|
26224
|
+
if (!schema[name].required && name in byName) bad(`named input "${name}" must be supplied directly`);
|
|
26225
|
+
return void 0;
|
|
26226
|
+
});
|
|
26090
26227
|
const missing = names.filter((n, i) => schema[n].required && values[i] === void 0);
|
|
26091
26228
|
if (missing.length > 0) bad(`requires named input ${missing.map((k) => `"${k}"`).join(", ")} (declared: ${declaredArgList(record)})`);
|
|
26092
26229
|
const last = values.findLastIndex((value) => value !== void 0);
|
|
@@ -26118,12 +26255,26 @@ function captureDispatchArgs(record, argsIn) {
|
|
|
26118
26255
|
);
|
|
26119
26256
|
}
|
|
26120
26257
|
const captured = [];
|
|
26258
|
+
const isWrite = record.effect !== "read";
|
|
26121
26259
|
for (let i = 0; i < length; i += 1) {
|
|
26122
|
-
const value = args[i];
|
|
26123
|
-
captured.push(value);
|
|
26124
|
-
if (value === void 0) continue;
|
|
26125
26260
|
const name = names[i];
|
|
26126
26261
|
const spec = schema[name];
|
|
26262
|
+
const supplied = Object.hasOwn(args, i);
|
|
26263
|
+
const value = supplied ? args[i] : void 0;
|
|
26264
|
+
if (!supplied && !spec.required && i in args) {
|
|
26265
|
+
throw new AutotaskConfigError(
|
|
26266
|
+
`invoke: "${operation}" positional input ${i + 1} (${name}) must be supplied directly`,
|
|
26267
|
+
{ operation }
|
|
26268
|
+
);
|
|
26269
|
+
}
|
|
26270
|
+
if (spec.required && (!supplied || isWrite && value === void 0)) {
|
|
26271
|
+
throw new AutotaskConfigError(
|
|
26272
|
+
`invoke: "${operation}" requires positional input ${i + 1} (${name}: ${spec.type})`,
|
|
26273
|
+
{ operation }
|
|
26274
|
+
);
|
|
26275
|
+
}
|
|
26276
|
+
captured.push(value);
|
|
26277
|
+
if (value === void 0) continue;
|
|
26127
26278
|
if (!looseTypeOk(spec.type, value)) {
|
|
26128
26279
|
throw new AutotaskConfigError(
|
|
26129
26280
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
@@ -26155,105 +26306,6 @@ function foldFlattenedOpts(record, toolArgs) {
|
|
|
26155
26306
|
return { ...folded, opts: Object.fromEntries(flat.map((k) => [k, toolArgs[k]])) };
|
|
26156
26307
|
}
|
|
26157
26308
|
|
|
26158
|
-
// src/operations/invoke/inputSets.ts
|
|
26159
|
-
var PARAMS_BAG_KEYS = {
|
|
26160
|
-
query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
|
|
26161
|
-
// No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
|
|
26162
|
-
// called directly), so this entry never fires. It is KEPT so that a future
|
|
26163
|
-
// `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
|
|
26164
|
-
// cannot silently open the bag (the keys are the vendor `QueryParams` set
|
|
26165
|
-
// the raw method accepts).
|
|
26166
|
-
queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
|
|
26167
|
-
// issue #145: the count bag carries the fieldCheck opt-out — the #140
|
|
26168
|
-
// refusal's advised remedy (before, the closed bag refused the very key it
|
|
26169
|
-
// advised, and the remedy looped into a second CONFIG_ERROR).
|
|
26170
|
-
count: ["filter", "fieldCheck"]
|
|
26171
|
-
};
|
|
26172
|
-
var BAG_KEY_SYNONYMS = {
|
|
26173
|
-
filters: "filter",
|
|
26174
|
-
last: "latest",
|
|
26175
|
-
// issue #59: the expected typo class (honoured only on `query`)
|
|
26176
|
-
lmit: "limit",
|
|
26177
|
-
page: "limit",
|
|
26178
|
-
pageSize: "limit",
|
|
26179
|
-
cursor: "limit",
|
|
26180
|
-
maxrecords: "maxRecords",
|
|
26181
|
-
fieldsPreset: "includeFields"
|
|
26182
|
-
// issue #287: the preset was removed — the refusal points at the explicit includeFields
|
|
26183
|
-
};
|
|
26184
|
-
function levenshtein(a, b) {
|
|
26185
|
-
if (a === b) return 0;
|
|
26186
|
-
const prev = new Array(b.length + 1);
|
|
26187
|
-
const cur = new Array(b.length + 1);
|
|
26188
|
-
for (let j = 0; j <= b.length; j += 1) prev[j] = j;
|
|
26189
|
-
for (let i = 1; i <= a.length; i += 1) {
|
|
26190
|
-
cur[0] = i;
|
|
26191
|
-
for (let j = 1; j <= b.length; j += 1) {
|
|
26192
|
-
cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
26193
|
-
}
|
|
26194
|
-
for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
|
|
26195
|
-
}
|
|
26196
|
-
return prev[b.length] ?? 0;
|
|
26197
|
-
}
|
|
26198
|
-
function suggestForKey(key, valid) {
|
|
26199
|
-
const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
|
|
26200
|
-
if (synonym !== void 0 && valid.includes(synonym)) return synonym;
|
|
26201
|
-
let best = null;
|
|
26202
|
-
for (const v of valid) {
|
|
26203
|
-
const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
|
|
26204
|
-
if (best === null || dist < best.dist) best = { key: v, dist };
|
|
26205
|
-
}
|
|
26206
|
-
if (best !== null && best.dist <= 3) return best.key;
|
|
26207
|
-
return null;
|
|
26208
|
-
}
|
|
26209
|
-
function keySuggestions(unknown, valid) {
|
|
26210
|
-
return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
26211
|
-
}
|
|
26212
|
-
function validateParamsBag(record, args) {
|
|
26213
|
-
if (record.inputSchemaStrict !== true) return;
|
|
26214
|
-
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
26215
|
-
if (valid === void 0) return;
|
|
26216
|
-
const bag = args?.[0];
|
|
26217
|
-
if (bag === void 0 || bag === null || !isRecord2(bag)) return;
|
|
26218
|
-
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
26219
|
-
if (unknown.length === 0) return;
|
|
26220
|
-
const suggestions = keySuggestions(unknown, valid);
|
|
26221
|
-
throw new AutotaskConfigError(
|
|
26222
|
-
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
26223
|
-
{
|
|
26224
|
-
operation: record.id,
|
|
26225
|
-
suggestedAction: suggestions.length > 0 ? `Fix the key name (${suggestions.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).` : `Pass only the valid keys (${valid.join(", ")}); the full bag contract is in the operation's inputSchema (autotask_describe).`
|
|
26226
|
-
}
|
|
26227
|
-
);
|
|
26228
|
-
}
|
|
26229
|
-
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
|
|
26230
|
-
function validateInvokeOptions(opts, operation) {
|
|
26231
|
-
if (opts === void 0 || opts === null) return;
|
|
26232
|
-
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
26233
|
-
if (unknown.length === 0) return;
|
|
26234
|
-
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
|
|
26235
|
-
throw new AutotaskConfigError(
|
|
26236
|
-
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh, verifyPersisted; "mode" is internal to the mode wrappers)`,
|
|
26237
|
-
{
|
|
26238
|
-
operation,
|
|
26239
|
-
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
|
|
26240
|
-
}
|
|
26241
|
-
);
|
|
26242
|
-
}
|
|
26243
|
-
function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
26244
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
26245
|
-
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
26246
|
-
if (unknown.length === 0) return null;
|
|
26247
|
-
const suggestions = keySuggestions(unknown, [...validKeys]);
|
|
26248
|
-
return new AutotaskConfigError(
|
|
26249
|
-
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
26250
|
-
{
|
|
26251
|
-
...operation !== void 0 ? { operation } : {},
|
|
26252
|
-
suggestedAction: suggestions.length > 0 ? operation === void 0 ? `Fix the ${subject} name (${suggestions.join(", ")}); the tool's full contract is in the tool's inputSchema, served by the MCP client's list_tools.` : `Fix the ${subject} name (${suggestions.join(", ")}); the full contract is in the tool's inputSchema (autotask_describe).` : `Pass only the valid keys (${validKeys.join(", ")}).`
|
|
26253
|
-
}
|
|
26254
|
-
);
|
|
26255
|
-
}
|
|
26256
|
-
|
|
26257
26309
|
// src/operations/searchAcrossResources.ts
|
|
26258
26310
|
var DEFAULT_LIMIT2 = 25;
|
|
26259
26311
|
function resourceFor(client, key) {
|
|
@@ -26615,7 +26667,7 @@ function checkOptsBag(opts, problems) {
|
|
|
26615
26667
|
}
|
|
26616
26668
|
}
|
|
26617
26669
|
if (opts?.names !== void 0 && typeof opts.names !== "boolean") problems.push(`names must be a boolean (got ${typeof opts.names})`);
|
|
26618
|
-
if (opts
|
|
26670
|
+
if (opts !== void 0 && Object.hasOwn(opts, "acknowledgeUnscoped") && opts.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
|
|
26619
26671
|
problems.push(`acknowledgeUnscoped must be a boolean (got ${typeof opts.acknowledgeUnscoped})`);
|
|
26620
26672
|
}
|
|
26621
26673
|
}
|
|
@@ -26702,8 +26754,10 @@ async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
|
26702
26754
|
}
|
|
26703
26755
|
async function validateAggregate(operation, filter, opts) {
|
|
26704
26756
|
const problems = [];
|
|
26757
|
+
const acknowledgment = opts !== null && typeof opts === "object" ? Object.getOwnPropertyDescriptor(opts, "acknowledgeUnscoped") : void 0;
|
|
26705
26758
|
const resourceKey = await parseOperationKey(operation, problems);
|
|
26706
26759
|
const conditions = parseFilterConditions(filter, problems);
|
|
26760
|
+
const acknowledged = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") && acknowledgment.value === true && opts.acknowledgeUnscoped === true;
|
|
26707
26761
|
checkOptsBag(opts, problems);
|
|
26708
26762
|
if (resourceKey !== void 0) {
|
|
26709
26763
|
opts = {
|
|
@@ -26730,7 +26784,7 @@ async function validateAggregate(operation, filter, opts) {
|
|
|
26730
26784
|
{ operation: "operations.aggregate" }
|
|
26731
26785
|
);
|
|
26732
26786
|
}
|
|
26733
|
-
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 &&
|
|
26787
|
+
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && !acknowledged) {
|
|
26734
26788
|
throw new ScopeRequiredError(operation, { threshold: UNSCOPED_WALK_THRESHOLD }, "empty-filter");
|
|
26735
26789
|
}
|
|
26736
26790
|
return { resourceKey, conditions, groupBy, sum, top, limit };
|
|
@@ -31315,8 +31369,25 @@ function bufferResult(buf) {
|
|
|
31315
31369
|
}
|
|
31316
31370
|
var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
|
|
31317
31371
|
function snapshotInvokeOptions(options, mode) {
|
|
31318
|
-
|
|
31319
|
-
|
|
31372
|
+
if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
|
|
31373
|
+
const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
|
|
31374
|
+
const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
|
|
31375
|
+
let confirmation;
|
|
31376
|
+
for (let owner = options; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
|
|
31377
|
+
confirmation = Object.getOwnPropertyDescriptor(owner, "confirm");
|
|
31378
|
+
if (confirmation !== void 0) break;
|
|
31379
|
+
}
|
|
31380
|
+
let confirm;
|
|
31381
|
+
if (confirmation !== void 0) {
|
|
31382
|
+
const visible = options.confirm;
|
|
31383
|
+
if (Object.hasOwn(confirmation, "value") && confirmation.value === visible || Object.hasOwn(confirmation, "get") && typeof confirmation.get === "function") confirm = visible;
|
|
31384
|
+
}
|
|
31385
|
+
const dryRun = options.dryRun;
|
|
31386
|
+
const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
|
|
31387
|
+
dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
|
|
31388
|
+
confirm
|
|
31389
|
+
});
|
|
31390
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
|
|
31320
31391
|
}
|
|
31321
31392
|
async function resolveRecord(operation) {
|
|
31322
31393
|
const record = (await operationIndex()).get(operation);
|
|
@@ -31530,15 +31601,19 @@ var PRE_REQUEST_VALIDATORS = [
|
|
|
31530
31601
|
(c) => requireReadBack(c.record, c.operation, c.opts),
|
|
31531
31602
|
(c) => {
|
|
31532
31603
|
c.args = captureDispatchArgs(c.record, c.args);
|
|
31533
|
-
|
|
31534
|
-
|
|
31535
|
-
|
|
31604
|
+
if (!c.boundedQuery && !c.countedQuery) return;
|
|
31605
|
+
const bag = ownQueryBag(c.args);
|
|
31606
|
+
if (bag === void 0) return;
|
|
31607
|
+
if (c.boundedQuery && "acknowledgeUnscoped" in bag && !Object.hasOwn(bag, "acknowledgeUnscoped")) {
|
|
31608
|
+
throw new AutotaskConfigError(`invoke: "${c.operation}" params bag key "acknowledgeUnscoped" must be supplied directly`, { operation: c.operation });
|
|
31609
|
+
}
|
|
31610
|
+
c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...c.args.slice(1)];
|
|
31536
31611
|
},
|
|
31537
31612
|
(c) => validateParamsBag(c.record, c.args),
|
|
31538
31613
|
(c) => validateFreshSpelling(c.record, c.args),
|
|
31539
31614
|
(c) => {
|
|
31540
31615
|
if (!c.streaming) return;
|
|
31541
|
-
const bag = c.args
|
|
31616
|
+
const bag = ownQueryBag(c.args);
|
|
31542
31617
|
if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
|
|
31543
31618
|
throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
|
|
31544
31619
|
}
|
|
@@ -31557,7 +31632,8 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
|
|
|
31557
31632
|
const context = { record, operation, args: resolvedArgs, opts, client, holder, boundedQuery, countedQuery, streaming };
|
|
31558
31633
|
await runPreRequestPass(context);
|
|
31559
31634
|
const { args } = context;
|
|
31560
|
-
const
|
|
31635
|
+
const queryParams = boundedQuery ? ownQueryBag(args) : void 0;
|
|
31636
|
+
const labelQuery = boundedQuery && readNamesOpt(client, queryParams?.["names"], `invoke: "${record.id}" params bag`);
|
|
31561
31637
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
31562
31638
|
const method = streaming ? context.pageSession?.consume : holder[methodName];
|
|
31563
31639
|
if (typeof method !== "function") {
|
|
@@ -31570,17 +31646,18 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
|
|
|
31570
31646
|
const mutationOpts = buildMutationOpts(opts, isWrite);
|
|
31571
31647
|
const callArgs = buildCallArgs(record, args, mutationOpts, isWrite);
|
|
31572
31648
|
if (opts.fresh === true) appendFresh(record, callArgs);
|
|
31573
|
-
if (boundedQuery) validateWalkBag(args[0]?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
|
|
31574
31649
|
let scopeNote;
|
|
31575
|
-
if (boundedQuery
|
|
31576
|
-
|
|
31650
|
+
if (boundedQuery) {
|
|
31651
|
+
validateWalkBag(queryParams?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
|
|
31652
|
+
const acknowledged = queryParams !== void 0 && Object.hasOwn(queryParams, "acknowledgeUnscoped") && queryParams.acknowledgeUnscoped === true;
|
|
31653
|
+
if (!acknowledged) scopeNote = (await guardUnscopedQueryWalk(holder, record.id, queryParams)).note;
|
|
31577
31654
|
}
|
|
31578
31655
|
return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
|
|
31579
31656
|
}
|
|
31580
31657
|
async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
31581
31658
|
const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
|
|
31582
31659
|
const result = await method.apply(holder, callArgs);
|
|
31583
|
-
if (labelQuery && args
|
|
31660
|
+
if (labelQuery && ownQueryBag(args)?.["walk"] === void 0 && Array.isArray(result?.items)) {
|
|
31584
31661
|
const bounded = result;
|
|
31585
31662
|
const labelled = await labelRows(client, record.resource, bounded.items);
|
|
31586
31663
|
return { ...bounded, items: labelled.rows, ...labelled.names !== void 0 ? { names: labelled.names } : {}, ...scopeNote !== void 0 ? { scopeNote } : {} };
|
|
@@ -4523,7 +4523,7 @@ interface InventoryLocationCreate {
|
|
|
4523
4523
|
isActive: boolean;
|
|
4524
4524
|
locationName: string;
|
|
4525
4525
|
}
|
|
4526
|
-
/**
|
|
4526
|
+
/** Partial collection PATCH input; the separate record id is injected into the request body. */
|
|
4527
4527
|
type InventoryLocationUpdate = Partial<InventoryLocationCreate>;
|
|
4528
4528
|
/** Compact helper shape for InventoryLocation (resolve/search/getContext): structural alias of the
|
|
4529
4529
|
* full record — the registry outputSchema names the fields the MCP projection keeps.
|