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