node-autotask 0.88.0 → 0.89.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 +11 -0
- package/README.md +3 -4
- package/dist/{chunk-LGOJ2HBH.js → chunk-2PWAWWWM.js} +2 -2
- package/dist/{chunk-QKRHKLVY.js → chunk-4EIN7AZJ.js} +2 -2
- package/dist/{chunk-AB326MJO.cjs → chunk-4MPQ5CDB.cjs} +199 -199
- package/dist/{chunk-ESKQAINP.cjs → chunk-BRU7TZOD.cjs} +30 -30
- package/dist/{chunk-K72PPAAD.js → chunk-OVIYLMGB.js} +246 -170
- package/dist/{chunk-GEFUSYH5.cjs → chunk-YAXEPESA.cjs} +246 -170
- 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-DsA1-2GA.d.cts → index-CoTtEn8U.d.cts} +6 -11
- package/dist/{index-BFgZJsqx.d.ts → index-Wh6bLfv_.d.ts} +6 -11
- package/dist/index.cjs +84 -84
- package/dist/index.d.cts +8 -11
- package/dist/index.d.ts +8 -11
- 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/docs/API.md +17 -29
- 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
|
|
@@ -402,7 +400,7 @@ function suggestedActionForStatus(status) {
|
|
|
402
400
|
return status >= 500 ? "The SDK already retried per its policy. A repeated 500 on one entity while others work usually means the API user lacks permission on that entity \u2014 ask the Autotask admin to grant it; otherwise retry once more at most." : void 0;
|
|
403
401
|
}
|
|
404
402
|
}
|
|
405
|
-
function errorFromStatus(status, body, url, operation, redactPersonalData =
|
|
403
|
+
function errorFromStatus(status, body, url, operation, redactPersonalData = false, credential, includeVendorDetails = true) {
|
|
406
404
|
const safeBody = redactResponseBody(body, { redactPersonalData });
|
|
407
405
|
const exposedBody = includeVendorDetails ? safeBody : void 0;
|
|
408
406
|
let detail = formatVendorDetail(exposedBody);
|
|
@@ -1397,7 +1395,7 @@ function resolveConfig(config) {
|
|
|
1397
1395
|
const rateLimit = resolveRateLimit(config, agent);
|
|
1398
1396
|
const cooldown = resolveCooldown(config);
|
|
1399
1397
|
const resolution = resolveResolution(config, agent);
|
|
1400
|
-
const redactPersonalData = config.redactPersonalData ??
|
|
1398
|
+
const redactPersonalData = config.redactPersonalData ?? false;
|
|
1401
1399
|
const caches = resolveCaches(config);
|
|
1402
1400
|
const update = { putFallback: config.update?.putFallback === true };
|
|
1403
1401
|
const reResolveZoneOn401 = config.reResolveZoneOn401 === true;
|
|
@@ -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]);
|
|
@@ -1970,9 +1985,8 @@ function isJsonMediaType(header) {
|
|
|
1970
1985
|
const mediaType = header.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
1971
1986
|
return mediaType.startsWith("application/json") || mediaType.endsWith("+json");
|
|
1972
1987
|
}
|
|
1973
|
-
function bodySnippet(text
|
|
1974
|
-
|
|
1975
|
-
return redactResponseBody(bytes, { redactPersonalData });
|
|
1988
|
+
function bodySnippet(text) {
|
|
1989
|
+
return Buffer.from(text, "utf8").subarray(0, 256).toString("utf8");
|
|
1976
1990
|
}
|
|
1977
1991
|
|
|
1978
1992
|
// src/http/limits.ts
|
|
@@ -16898,6 +16912,13 @@ function exactRecordResponseTarget(path, method, operation) {
|
|
|
16898
16912
|
}
|
|
16899
16913
|
return method === "GET" ? suffix === void 0 ? void 0 : "item" : "mutation";
|
|
16900
16914
|
}
|
|
16915
|
+
function ownField(value, key) {
|
|
16916
|
+
return isRecord2(value) && Object.hasOwn(value, key) ? value[key] : void 0;
|
|
16917
|
+
}
|
|
16918
|
+
function receiptId(body) {
|
|
16919
|
+
const itemId = ownField(body, "itemId");
|
|
16920
|
+
return itemId === void 0 ? ownField(body, "id") : itemId;
|
|
16921
|
+
}
|
|
16901
16922
|
function isNonNegativeInt64(id) {
|
|
16902
16923
|
return typeof id === "number" ? Number.isSafeInteger(id) && id >= 0 : typeof id === "string" && isAuditDecimalId(id);
|
|
16903
16924
|
}
|
|
@@ -16910,14 +16931,14 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16910
16931
|
return;
|
|
16911
16932
|
}
|
|
16912
16933
|
if (target === "query") {
|
|
16913
|
-
|
|
16934
|
+
const items = ownField(body, "items");
|
|
16935
|
+
const paging = ownField(body, "pageDetails");
|
|
16936
|
+
if (!Array.isArray(items) || !isRecord2(paging)) {
|
|
16914
16937
|
return invalid("Expected a query page with paging details");
|
|
16915
16938
|
}
|
|
16916
|
-
if (!
|
|
16917
|
-
if (
|
|
16918
|
-
|
|
16919
|
-
}
|
|
16920
|
-
const cursor = body.pageDetails.nextPageUrl;
|
|
16939
|
+
if (!items.every(hasExactRecordId)) invalid("Expected valid record IDs in the query response");
|
|
16940
|
+
if (ownField(paging, "count") !== items.length) invalid("The page record count did not match its rows");
|
|
16941
|
+
const cursor = ownField(paging, "nextPageUrl");
|
|
16921
16942
|
if (cursor !== null && (typeof cursor !== "string" || cursor.trim() === "")) {
|
|
16922
16943
|
invalid("Expected a valid query cursor or an explicit end of results");
|
|
16923
16944
|
}
|
|
@@ -16926,26 +16947,27 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16926
16947
|
const parts = path.replace(/\/$/, "").split("/");
|
|
16927
16948
|
const expectedId = parts.at(-1);
|
|
16928
16949
|
if (target === "mutation") {
|
|
16929
|
-
const
|
|
16930
|
-
if (!isNonNegativeInt64(
|
|
16931
|
-
const expected = method === "DELETE" ? expectedId :
|
|
16932
|
-
if (expected !== void 0 && String(
|
|
16950
|
+
const id2 = receiptId(body);
|
|
16951
|
+
if (!isNonNegativeInt64(id2)) invalid("Expected a valid mutation receipt");
|
|
16952
|
+
const expected = method === "DELETE" ? expectedId : ownField(requestBody, "id");
|
|
16953
|
+
if (expected !== void 0 && String(id2) !== String(expected)) {
|
|
16933
16954
|
invalid("The mutation response identified a different record. Re-read the requested record before retrying.");
|
|
16934
16955
|
}
|
|
16935
16956
|
return;
|
|
16936
16957
|
}
|
|
16937
|
-
const item =
|
|
16958
|
+
const item = ownField(body, "item");
|
|
16938
16959
|
if (item === null) return;
|
|
16939
|
-
|
|
16960
|
+
const id = ownField(item, "id");
|
|
16961
|
+
if (!isNonNegativeInt64(id)) {
|
|
16940
16962
|
return invalid("Expected an item envelope with a valid record ID");
|
|
16941
16963
|
}
|
|
16942
16964
|
const entity = parts.at(-2)?.toLowerCase();
|
|
16943
16965
|
const resource = entity === "inventorylocations" ? "inventory location" : entity === "knowledgebasearticles" ? "article" : "category";
|
|
16944
|
-
if (String(
|
|
16966
|
+
if (String(id) !== expectedId) {
|
|
16945
16967
|
throw new AutotaskConfigError(`returned ${resource} id must match the requested id`, { operation });
|
|
16946
16968
|
}
|
|
16947
16969
|
if (parts.length === 6) {
|
|
16948
|
-
const parent = item
|
|
16970
|
+
const parent = ownField(item, "articleCategoryID");
|
|
16949
16971
|
if (typeof parent !== "number" || !Number.isInteger(parent) || parent <= 0 || parent > 2147483647) {
|
|
16950
16972
|
invalid("Expected a valid category ID in the Knowledge Base article response");
|
|
16951
16973
|
}
|
|
@@ -16955,7 +16977,7 @@ function validateExactRecordResponse(body, target, path, method, requestBody, op
|
|
|
16955
16977
|
}
|
|
16956
16978
|
}
|
|
16957
16979
|
function serializeExactRecordUpdate(body, operation) {
|
|
16958
|
-
if (!isRecord2(body) || typeof body.id !== "string") return JSON.stringify(body);
|
|
16980
|
+
if (!isRecord2(body) || !Object.hasOwn(body, "id") || typeof body.id !== "string") return JSON.stringify(body);
|
|
16959
16981
|
if (!isAuditDecimalId(body.id)) {
|
|
16960
16982
|
throw new AutotaskConfigError("Update id must be a non-negative signed 64-bit integer.", { operation });
|
|
16961
16983
|
}
|
|
@@ -16977,12 +16999,12 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
|
16977
16999
|
}
|
|
16978
17000
|
return value;
|
|
16979
17001
|
});
|
|
16980
|
-
const rows =
|
|
17002
|
+
const rows = target === "query" ? ownField(body, "items") : [target === "mutation" ? body : ownField(body, "item")];
|
|
16981
17003
|
if (Array.isArray(rows)) {
|
|
16982
17004
|
for (const row of rows) {
|
|
16983
17005
|
if (!isRecord2(row)) continue;
|
|
16984
|
-
const key = target === "mutation" && row
|
|
16985
|
-
const value = row
|
|
17006
|
+
const key = target === "mutation" && ownField(row, "itemId") !== void 0 ? "itemId" : "id";
|
|
17007
|
+
const value = ownField(row, key);
|
|
16986
17008
|
if (typeof value !== "number") continue;
|
|
16987
17009
|
const token = (key === "id" ? idTokens : receiptTokens).get(row);
|
|
16988
17010
|
if (token === void 0 || !isAuditDecimalId(token)) row[key] = null;
|
|
@@ -16992,8 +17014,7 @@ function decodeResponseJson(text, auditTarget, recordTarget) {
|
|
|
16992
17014
|
return body;
|
|
16993
17015
|
}
|
|
16994
17016
|
function hasExactRecordId(item) {
|
|
16995
|
-
|
|
16996
|
-
return isNonNegativeInt64(item.id);
|
|
17017
|
+
return isNonNegativeInt64(ownField(item, "id"));
|
|
16997
17018
|
}
|
|
16998
17019
|
function isAuditPage(body) {
|
|
16999
17020
|
if (!Array.isArray(body.items) || !isRecord2(body.pageDetails)) return false;
|
|
@@ -17062,7 +17083,7 @@ function unwrapItems(body, operation) {
|
|
|
17062
17083
|
return { items: body.items, pageDetails: body.pageDetails };
|
|
17063
17084
|
}
|
|
17064
17085
|
function unwrapItem(body, id, operation, entity) {
|
|
17065
|
-
if (!isRecord2(body) || !("item"
|
|
17086
|
+
if (!isRecord2(body) || !Object.hasOwn(body, "item")) {
|
|
17066
17087
|
throw new AutotaskError("Expected the item envelope { item }; got a different shape", {
|
|
17067
17088
|
code: "INVALID_RESPONSE",
|
|
17068
17089
|
category: "server",
|
|
@@ -17088,7 +17109,7 @@ function unwrapItem(body, id, operation, entity) {
|
|
|
17088
17109
|
return item;
|
|
17089
17110
|
}
|
|
17090
17111
|
function unwrapQueryCount(body, operation) {
|
|
17091
|
-
const count =
|
|
17112
|
+
const count = ownField(body, "queryCount");
|
|
17092
17113
|
if (typeof count !== "number" || !Number.isInteger(count) || count < 0 || count > 2147483647) {
|
|
17093
17114
|
const err = new AutotaskError("Expected the count envelope { queryCount: non-negative int32 }", {
|
|
17094
17115
|
code: "INVALID_RESPONSE",
|
|
@@ -17102,7 +17123,7 @@ function unwrapQueryCount(body, operation) {
|
|
|
17102
17123
|
return count;
|
|
17103
17124
|
}
|
|
17104
17125
|
function unwrapOperation(body, operation) {
|
|
17105
|
-
const value =
|
|
17126
|
+
const value = receiptId(body);
|
|
17106
17127
|
const idValue = toIdentifierId(value);
|
|
17107
17128
|
if (idValue === void 0) {
|
|
17108
17129
|
const err = new AutotaskError(
|
|
@@ -17453,7 +17474,7 @@ var HttpClient = class {
|
|
|
17453
17474
|
since,
|
|
17454
17475
|
retryAfterMs: s.maintenancePollMs,
|
|
17455
17476
|
httpStatus: status,
|
|
17456
|
-
...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text
|
|
17477
|
+
...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text) },
|
|
17457
17478
|
maintenanceDetected: true
|
|
17458
17479
|
},
|
|
17459
17480
|
suggestedAction: unknownWrite ? `A maintenance-shaped page answered ${method} ${opts.path} (HTTP ${status}); it was NOT waited out or re-sent \u2014 a non-2xx edge page can arrive after the request was forwarded, so verify the record before re-issuing (only a GET or an explicitly idempotent-flagged call waits this window out).` : `The Autotask zone is in its maintenance window (since ${since}); retry after the window (windows usually last 30-90 min).`
|
|
@@ -17631,7 +17652,7 @@ var HttpClient = class {
|
|
|
17631
17652
|
httpStatus: status,
|
|
17632
17653
|
details: {
|
|
17633
17654
|
httpStatus: status,
|
|
17634
|
-
...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text
|
|
17655
|
+
...s.getQuery ? {} : { contentType, bodySnippet: bodySnippet(text) }
|
|
17635
17656
|
},
|
|
17636
17657
|
// The content-type is host-sourced (a host-supplied
|
|
17637
17658
|
// baseUrl can serve arbitrary HTML) — capped, never prose;
|
|
@@ -17682,7 +17703,7 @@ var HttpClient = class {
|
|
|
17682
17703
|
nonJsonBody = text;
|
|
17683
17704
|
}
|
|
17684
17705
|
}
|
|
17685
|
-
const nonJsonSnippet = nonJsonBody === void 0 || s.getQuery ? void 0 : bodySnippet(nonJsonBody
|
|
17706
|
+
const nonJsonSnippet = nonJsonBody === void 0 || s.getQuery ? void 0 : bodySnippet(nonJsonBody);
|
|
17686
17707
|
const nonJsonIsMaintenance = s.maintenancePage;
|
|
17687
17708
|
const nonJsonIsHtmlCandidate = nonJsonBody !== void 0 && isHtmlLike(res.headers.get("Content-Type"), nonJsonBody);
|
|
17688
17709
|
if (nonJsonIsMaintenance) {
|
|
@@ -18925,7 +18946,7 @@ function attachUpdateTargetMissReason(err, key) {
|
|
|
18925
18946
|
if (pinned === void 0) return;
|
|
18926
18947
|
err.details = { ...err.details ?? {}, emptyReason: pinned };
|
|
18927
18948
|
}
|
|
18928
|
-
function buildDryRunResult(spec, policy
|
|
18949
|
+
function buildDryRunResult(spec, policy) {
|
|
18929
18950
|
if (spec.operation === "") {
|
|
18930
18951
|
throw new AutotaskConfigError("dry-run: the operation name is required");
|
|
18931
18952
|
}
|
|
@@ -18957,7 +18978,7 @@ function computeFieldDiff(current, data) {
|
|
|
18957
18978
|
const out = [];
|
|
18958
18979
|
for (const [field, to] of Object.entries(data)) {
|
|
18959
18980
|
if (field === "id" || to === void 0) continue;
|
|
18960
|
-
const from = current[field];
|
|
18981
|
+
const from = Object.hasOwn(current, field) ? current[field] : void 0;
|
|
18961
18982
|
if (from !== void 0 && JSON.stringify(from) === JSON.stringify(to)) continue;
|
|
18962
18983
|
out.push({ field, from: from === void 0 ? null : from, to });
|
|
18963
18984
|
}
|
|
@@ -19795,6 +19816,109 @@ function notPersistedFields(sent, stored) {
|
|
|
19795
19816
|
return Object.entries(sent).filter(([key, value]) => (value === null || typeof value !== "object") && stored[key] !== REDACTED && !same(value, stored[key])).map(([key]) => key);
|
|
19796
19817
|
}
|
|
19797
19818
|
|
|
19819
|
+
// src/operations/invoke/inputSets.ts
|
|
19820
|
+
var PARAMS_BAG_KEYS = {
|
|
19821
|
+
query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldCheck", "names", "acknowledgeUnscoped", "walk"],
|
|
19822
|
+
// No registry row DECLARES `queryAll` today (a plan decision: the raw walk is
|
|
19823
|
+
// called directly), so this entry never fires. It is KEPT so that a future
|
|
19824
|
+
// `queryAll` row — which `invoke` WOULD dispatch via holder[operation] —
|
|
19825
|
+
// cannot silently open the bag (the keys are the vendor `QueryParams` set
|
|
19826
|
+
// the raw method accepts).
|
|
19827
|
+
queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
|
|
19828
|
+
// issue #145: the count bag carries the fieldCheck opt-out — the #140
|
|
19829
|
+
// refusal's advised remedy (before, the closed bag refused the very key it
|
|
19830
|
+
// advised, and the remedy looped into a second CONFIG_ERROR).
|
|
19831
|
+
count: ["filter", "fieldCheck"]
|
|
19832
|
+
};
|
|
19833
|
+
var BAG_KEY_SYNONYMS = {
|
|
19834
|
+
filters: "filter",
|
|
19835
|
+
last: "latest",
|
|
19836
|
+
// issue #59: the expected typo class (honoured only on `query`)
|
|
19837
|
+
lmit: "limit",
|
|
19838
|
+
page: "limit",
|
|
19839
|
+
pageSize: "limit",
|
|
19840
|
+
cursor: "limit",
|
|
19841
|
+
maxrecords: "maxRecords",
|
|
19842
|
+
fieldsPreset: "includeFields"
|
|
19843
|
+
// issue #287: the preset was removed — the refusal points at the explicit includeFields
|
|
19844
|
+
};
|
|
19845
|
+
function levenshtein(a, b) {
|
|
19846
|
+
if (a === b) return 0;
|
|
19847
|
+
const prev = new Array(b.length + 1);
|
|
19848
|
+
const cur = new Array(b.length + 1);
|
|
19849
|
+
for (let j = 0; j <= b.length; j += 1) prev[j] = j;
|
|
19850
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
19851
|
+
cur[0] = i;
|
|
19852
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
19853
|
+
cur[j] = Math.min((prev[j] ?? 0) + 1, (cur[j - 1] ?? 0) + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
19854
|
+
}
|
|
19855
|
+
for (let j = 0; j <= b.length; j += 1) prev[j] = cur[j];
|
|
19856
|
+
}
|
|
19857
|
+
return prev[b.length] ?? 0;
|
|
19858
|
+
}
|
|
19859
|
+
function suggestForKey(key, valid) {
|
|
19860
|
+
const synonym = BAG_KEY_SYNONYMS[key.toLowerCase()];
|
|
19861
|
+
if (synonym !== void 0 && valid.includes(synonym)) return synonym;
|
|
19862
|
+
let best = null;
|
|
19863
|
+
for (const v of valid) {
|
|
19864
|
+
const dist = levenshtein(key.toLowerCase(), v.toLowerCase());
|
|
19865
|
+
if (best === null || dist < best.dist) best = { key: v, dist };
|
|
19866
|
+
}
|
|
19867
|
+
if (best !== null && best.dist <= 3) return best.key;
|
|
19868
|
+
return null;
|
|
19869
|
+
}
|
|
19870
|
+
function keySuggestions(unknown, valid) {
|
|
19871
|
+
return unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
19872
|
+
}
|
|
19873
|
+
function ownQueryBag(args) {
|
|
19874
|
+
const bag = args != null && Object.hasOwn(args, 0) ? args[0] : void 0;
|
|
19875
|
+
return isRecord2(bag) ? bag : void 0;
|
|
19876
|
+
}
|
|
19877
|
+
function validateParamsBag(record, args) {
|
|
19878
|
+
if (record.inputSchemaStrict !== true) return;
|
|
19879
|
+
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
19880
|
+
if (valid === void 0) return;
|
|
19881
|
+
const bag = ownQueryBag(args);
|
|
19882
|
+
if (bag === void 0) return;
|
|
19883
|
+
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
19884
|
+
if (unknown.length === 0) return;
|
|
19885
|
+
const suggestions = keySuggestions(unknown, valid);
|
|
19886
|
+
throw new AutotaskConfigError(
|
|
19887
|
+
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
19888
|
+
{
|
|
19889
|
+
operation: record.id,
|
|
19890
|
+
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).`
|
|
19891
|
+
}
|
|
19892
|
+
);
|
|
19893
|
+
}
|
|
19894
|
+
var INVOKE_OPTION_KEYS = ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted", "mode"];
|
|
19895
|
+
function validateInvokeOptions(opts, operation) {
|
|
19896
|
+
if (opts === void 0 || opts === null) return;
|
|
19897
|
+
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
19898
|
+
if (unknown.length === 0) return;
|
|
19899
|
+
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh", "verifyPersisted"]);
|
|
19900
|
+
throw new AutotaskConfigError(
|
|
19901
|
+
`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)`,
|
|
19902
|
+
{
|
|
19903
|
+
operation,
|
|
19904
|
+
suggestedAction: suggestions.length > 0 ? `Fix the option name (${suggestions.join(", ")}).` : `Pass only dryRun / confirm / lastModifiedDate / maxRetries / fresh / verifyPersisted.`
|
|
19905
|
+
}
|
|
19906
|
+
);
|
|
19907
|
+
}
|
|
19908
|
+
function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
19909
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
|
|
19910
|
+
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
19911
|
+
if (unknown.length === 0) return null;
|
|
19912
|
+
const suggestions = keySuggestions(unknown, [...validKeys]);
|
|
19913
|
+
return new AutotaskConfigError(
|
|
19914
|
+
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
19915
|
+
{
|
|
19916
|
+
...operation !== void 0 ? { operation } : {},
|
|
19917
|
+
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(", ")}).`
|
|
19918
|
+
}
|
|
19919
|
+
);
|
|
19920
|
+
}
|
|
19921
|
+
|
|
19798
19922
|
// src/resources/special/inventoryLocations.ts
|
|
19799
19923
|
var fail = (message) => {
|
|
19800
19924
|
throw new AutotaskConfigError(`inventory_locations: ${message}`);
|
|
@@ -19803,13 +19927,17 @@ function admitInventoryLocation(value, creating) {
|
|
|
19803
19927
|
if (!isRecord2(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail("data must be a plain record");
|
|
19804
19928
|
const body = { ...value };
|
|
19805
19929
|
for (const field of Object.keys(body)) if (!["locationName", "isActive"].includes(field)) fail(`${field} is not a writable InventoryLocations field`);
|
|
19806
|
-
|
|
19807
|
-
|
|
19808
|
-
if (
|
|
19930
|
+
const hasName = Object.hasOwn(body, "locationName");
|
|
19931
|
+
const hasActive = Object.hasOwn(body, "isActive");
|
|
19932
|
+
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");
|
|
19933
|
+
if (creating && !hasActive || hasActive && typeof body.isActive !== "boolean") fail("isActive must be a boolean");
|
|
19934
|
+
if (!creating && !hasName && !hasActive) fail("update must contain locationName or isActive");
|
|
19809
19935
|
return body;
|
|
19810
19936
|
}
|
|
19811
|
-
function checkInventoryLocationCurrent(value, current) {
|
|
19812
|
-
if (
|
|
19937
|
+
function checkInventoryLocationCurrent(value, current, id) {
|
|
19938
|
+
if (!isRecord2(current) || !Object.hasOwn(current, "id")) fail("current record requires its own id");
|
|
19939
|
+
if (parseIdentifier(current.id, "inventory_locations: current id") !== id) fail("current record id must match the requested id");
|
|
19940
|
+
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
19941
|
}
|
|
19814
19942
|
|
|
19815
19943
|
// src/resources/base/types.ts
|
|
@@ -21223,8 +21351,8 @@ var MetaBase = class _MetaBase extends QueryBase {
|
|
|
21223
21351
|
if (Object.keys(body).length === 0) {
|
|
21224
21352
|
throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
|
|
21225
21353
|
}
|
|
21226
|
-
if ("item"
|
|
21227
|
-
if (Array.isArray(body.items)) {
|
|
21354
|
+
if (Object.hasOwn(body, "item")) return unwrapItem(body, id, void 0, entity);
|
|
21355
|
+
if (Object.hasOwn(body, "items") && Array.isArray(body.items)) {
|
|
21228
21356
|
const first = body.items[0];
|
|
21229
21357
|
if (first === null || first === void 0) {
|
|
21230
21358
|
throw new NotFoundError(`The record with ID ${id} was not found`, { httpStatus: 200, resourceIds: [id], details: { idRefs: [{ entity, id }] } });
|
|
@@ -21774,7 +21902,7 @@ var MutationBase = class extends MetaBase {
|
|
|
21774
21902
|
/** Normalise a mutation body: `id` OR `itemId` → `id`; UDF map → UDF array (UDF-capable only). */
|
|
21775
21903
|
normalizeMutationBody(data) {
|
|
21776
21904
|
const body = { ...data };
|
|
21777
|
-
if (body.itemId !== void 0 && body.id === void 0) {
|
|
21905
|
+
if (Object.hasOwn(body, "itemId") && body.itemId !== void 0 && (!Object.hasOwn(body, "id") || body.id === void 0)) {
|
|
21778
21906
|
body.id = body.itemId;
|
|
21779
21907
|
delete body.itemId;
|
|
21780
21908
|
}
|
|
@@ -21963,7 +22091,11 @@ var MutationBase = class extends MetaBase {
|
|
|
21963
22091
|
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
22092
|
const submitted = data;
|
|
21965
22093
|
const persisted = stored;
|
|
21966
|
-
|
|
22094
|
+
if (this.config.key === "inventory_locations") {
|
|
22095
|
+
if (!Object.hasOwn(persisted, "id")) throw new AutotaskConfigError("inventory_locations: persisted record requires its own id");
|
|
22096
|
+
validateExactRecordResponse({ item: persisted }, "item", `${this.resourcePath}/${parseIdentifier(id, "id")}`, "GET", void 0, `${this.config.key}.get`);
|
|
22097
|
+
}
|
|
22098
|
+
const notPersisted = this.config.key === "inventory_locations" ? Object.keys(submitted).filter((field) => !Object.hasOwn(persisted, field) || submitted[field] !== persisted[field]) : notPersistedFields(submitted, persisted);
|
|
21967
22099
|
return { ...result, notPersisted };
|
|
21968
22100
|
} catch (err) {
|
|
21969
22101
|
return { ...result, persistedCheckFailed: err instanceof AutotaskError ? err.code : `UNKNOWN (${err instanceof Error ? err.name : typeof err})` };
|
|
@@ -22758,8 +22890,8 @@ function unknownNamesSuggestedAction(record, authority, filterUnknown) {
|
|
|
22758
22890
|
return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
|
|
22759
22891
|
}
|
|
22760
22892
|
async function validateQueryFieldNames(record, holder, args) {
|
|
22761
|
-
const bag = args
|
|
22762
|
-
if (
|
|
22893
|
+
const bag = ownQueryBag(args);
|
|
22894
|
+
if (bag === void 0) return;
|
|
22763
22895
|
const fieldCheck = readFieldCheck(record, bag);
|
|
22764
22896
|
const includeNames = readIncludeNames(record, bag["includeFields"]);
|
|
22765
22897
|
let filterNames;
|
|
@@ -24769,7 +24901,7 @@ var GenericResource = class extends BaseResource {
|
|
|
24769
24901
|
const body = admitInventoryLocation(b, false);
|
|
24770
24902
|
const opts2 = snapshotMutationOptions(supplied);
|
|
24771
24903
|
if (opts2.lastModifiedDate !== void 0) throw new AutotaskConfigError("inventory_locations: no documented stale timestamp is available");
|
|
24772
|
-
const checkCurrent = (current) => checkInventoryLocationCurrent(body, current);
|
|
24904
|
+
const checkCurrent = (current) => checkInventoryLocationCurrent(body, current, id);
|
|
24773
24905
|
if (opts2.dryRun === true) return this.runUpdateDryRun(id, body, opts2, void 0, void 0, { checkCurrent });
|
|
24774
24906
|
const checkedBaseUrl = this.http.baseUrl;
|
|
24775
24907
|
try {
|
|
@@ -26084,7 +26216,11 @@ function resolveDispatchArgs(record, argsIn) {
|
|
|
26084
26216
|
const names = Object.keys(schema);
|
|
26085
26217
|
const unknown = Object.keys(byName).filter((k) => !names.includes(k));
|
|
26086
26218
|
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((
|
|
26219
|
+
const values = names.map((name) => {
|
|
26220
|
+
if (Object.hasOwn(byName, name)) return byName[name];
|
|
26221
|
+
if (!schema[name].required && name in byName) bad(`named input "${name}" must be supplied directly`);
|
|
26222
|
+
return void 0;
|
|
26223
|
+
});
|
|
26088
26224
|
const missing = names.filter((n, i) => schema[n].required && values[i] === void 0);
|
|
26089
26225
|
if (missing.length > 0) bad(`requires named input ${missing.map((k) => `"${k}"`).join(", ")} (declared: ${declaredArgList(record)})`);
|
|
26090
26226
|
const last = values.findLastIndex((value) => value !== void 0);
|
|
@@ -26116,12 +26252,26 @@ function captureDispatchArgs(record, argsIn) {
|
|
|
26116
26252
|
);
|
|
26117
26253
|
}
|
|
26118
26254
|
const captured = [];
|
|
26255
|
+
const isWrite = record.effect !== "read";
|
|
26119
26256
|
for (let i = 0; i < length; i += 1) {
|
|
26120
|
-
const value = args[i];
|
|
26121
|
-
captured.push(value);
|
|
26122
|
-
if (value === void 0) continue;
|
|
26123
26257
|
const name = names[i];
|
|
26124
26258
|
const spec = schema[name];
|
|
26259
|
+
const supplied = Object.hasOwn(args, i);
|
|
26260
|
+
const value = supplied ? args[i] : void 0;
|
|
26261
|
+
if (!supplied && !spec.required && i in args) {
|
|
26262
|
+
throw new AutotaskConfigError(
|
|
26263
|
+
`invoke: "${operation}" positional input ${i + 1} (${name}) must be supplied directly`,
|
|
26264
|
+
{ operation }
|
|
26265
|
+
);
|
|
26266
|
+
}
|
|
26267
|
+
if (spec.required && (!supplied || isWrite && value === void 0)) {
|
|
26268
|
+
throw new AutotaskConfigError(
|
|
26269
|
+
`invoke: "${operation}" requires positional input ${i + 1} (${name}: ${spec.type})`,
|
|
26270
|
+
{ operation }
|
|
26271
|
+
);
|
|
26272
|
+
}
|
|
26273
|
+
captured.push(value);
|
|
26274
|
+
if (value === void 0) continue;
|
|
26125
26275
|
if (!looseTypeOk(spec.type, value)) {
|
|
26126
26276
|
throw new AutotaskConfigError(
|
|
26127
26277
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
@@ -26153,105 +26303,6 @@ function foldFlattenedOpts(record, toolArgs) {
|
|
|
26153
26303
|
return { ...folded, opts: Object.fromEntries(flat.map((k) => [k, toolArgs[k]])) };
|
|
26154
26304
|
}
|
|
26155
26305
|
|
|
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
26306
|
// src/operations/searchAcrossResources.ts
|
|
26256
26307
|
var DEFAULT_LIMIT2 = 25;
|
|
26257
26308
|
function resourceFor(client, key) {
|
|
@@ -26613,7 +26664,7 @@ function checkOptsBag(opts, problems) {
|
|
|
26613
26664
|
}
|
|
26614
26665
|
}
|
|
26615
26666
|
if (opts?.names !== void 0 && typeof opts.names !== "boolean") problems.push(`names must be a boolean (got ${typeof opts.names})`);
|
|
26616
|
-
if (opts
|
|
26667
|
+
if (opts !== void 0 && Object.hasOwn(opts, "acknowledgeUnscoped") && opts.acknowledgeUnscoped !== void 0 && typeof opts.acknowledgeUnscoped !== "boolean") {
|
|
26617
26668
|
problems.push(`acknowledgeUnscoped must be a boolean (got ${typeof opts.acknowledgeUnscoped})`);
|
|
26618
26669
|
}
|
|
26619
26670
|
}
|
|
@@ -26700,8 +26751,10 @@ async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
|
26700
26751
|
}
|
|
26701
26752
|
async function validateAggregate(operation, filter, opts) {
|
|
26702
26753
|
const problems = [];
|
|
26754
|
+
const acknowledgment = opts !== null && typeof opts === "object" ? Object.getOwnPropertyDescriptor(opts, "acknowledgeUnscoped") : void 0;
|
|
26703
26755
|
const resourceKey = await parseOperationKey(operation, problems);
|
|
26704
26756
|
const conditions = parseFilterConditions(filter, problems);
|
|
26757
|
+
const acknowledged = acknowledgment !== void 0 && Object.hasOwn(acknowledgment, "value") && acknowledgment.value === true && opts.acknowledgeUnscoped === true;
|
|
26705
26758
|
checkOptsBag(opts, problems);
|
|
26706
26759
|
if (resourceKey !== void 0) {
|
|
26707
26760
|
opts = {
|
|
@@ -26728,7 +26781,7 @@ async function validateAggregate(operation, filter, opts) {
|
|
|
26728
26781
|
{ operation: "operations.aggregate" }
|
|
26729
26782
|
);
|
|
26730
26783
|
}
|
|
26731
|
-
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 &&
|
|
26784
|
+
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && !acknowledged) {
|
|
26732
26785
|
throw new ScopeRequiredError(operation, { threshold: UNSCOPED_WALK_THRESHOLD }, "empty-filter");
|
|
26733
26786
|
}
|
|
26734
26787
|
return { resourceKey, conditions, groupBy, sum, top, limit };
|
|
@@ -31313,8 +31366,25 @@ function bufferResult(buf) {
|
|
|
31313
31366
|
}
|
|
31314
31367
|
var PUBLIC_INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS.filter((key) => key !== "mode");
|
|
31315
31368
|
function snapshotInvokeOptions(options, mode) {
|
|
31316
|
-
|
|
31317
|
-
|
|
31369
|
+
if (!isRecord2(options)) throw new AutotaskConfigError("invoke: options must be an object");
|
|
31370
|
+
const applyFlag = Object.getOwnPropertyDescriptor(options, "dryRun");
|
|
31371
|
+
const applyRequested = applyFlag !== void 0 && Object.hasOwn(applyFlag, "value") && applyFlag.value === false;
|
|
31372
|
+
let confirmation;
|
|
31373
|
+
for (let owner = options; owner !== null && owner !== Object.prototype; owner = Object.getPrototypeOf(owner)) {
|
|
31374
|
+
confirmation = Object.getOwnPropertyDescriptor(owner, "confirm");
|
|
31375
|
+
if (confirmation !== void 0) break;
|
|
31376
|
+
}
|
|
31377
|
+
let confirm;
|
|
31378
|
+
if (confirmation !== void 0) {
|
|
31379
|
+
const visible = options.confirm;
|
|
31380
|
+
if (Object.hasOwn(confirmation, "value") && confirmation.value === visible || Object.hasOwn(confirmation, "get") && typeof confirmation.get === "function") confirm = visible;
|
|
31381
|
+
}
|
|
31382
|
+
const dryRun = options.dryRun;
|
|
31383
|
+
const captured = snapshotFields(options, PUBLIC_INVOKE_OPTION_KEYS, {
|
|
31384
|
+
dryRun: applyRequested || dryRun !== false ? dryRun : void 0,
|
|
31385
|
+
confirm
|
|
31386
|
+
});
|
|
31387
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), captured, { mode });
|
|
31318
31388
|
}
|
|
31319
31389
|
async function resolveRecord(operation) {
|
|
31320
31390
|
const record = (await operationIndex()).get(operation);
|
|
@@ -31528,15 +31598,19 @@ var PRE_REQUEST_VALIDATORS = [
|
|
|
31528
31598
|
(c) => requireReadBack(c.record, c.operation, c.opts),
|
|
31529
31599
|
(c) => {
|
|
31530
31600
|
c.args = captureDispatchArgs(c.record, c.args);
|
|
31531
|
-
|
|
31532
|
-
|
|
31533
|
-
|
|
31601
|
+
if (!c.boundedQuery && !c.countedQuery) return;
|
|
31602
|
+
const bag = ownQueryBag(c.args);
|
|
31603
|
+
if (bag === void 0) return;
|
|
31604
|
+
if (c.boundedQuery && "acknowledgeUnscoped" in bag && !Object.hasOwn(bag, "acknowledgeUnscoped")) {
|
|
31605
|
+
throw new AutotaskConfigError(`invoke: "${c.operation}" params bag key "acknowledgeUnscoped" must be supplied directly`, { operation: c.operation });
|
|
31606
|
+
}
|
|
31607
|
+
c.args = [snapshotQueryBag(bag, PARAMS_BAG_KEYS[c.record.operation] ?? []), ...c.args.slice(1)];
|
|
31534
31608
|
},
|
|
31535
31609
|
(c) => validateParamsBag(c.record, c.args),
|
|
31536
31610
|
(c) => validateFreshSpelling(c.record, c.args),
|
|
31537
31611
|
(c) => {
|
|
31538
31612
|
if (!c.streaming) return;
|
|
31539
|
-
const bag = c.args
|
|
31613
|
+
const bag = ownQueryBag(c.args);
|
|
31540
31614
|
if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
|
|
31541
31615
|
throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
|
|
31542
31616
|
}
|
|
@@ -31555,7 +31629,8 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
|
|
|
31555
31629
|
const context = { record, operation, args: resolvedArgs, opts, client, holder, boundedQuery, countedQuery, streaming };
|
|
31556
31630
|
await runPreRequestPass(context);
|
|
31557
31631
|
const { args } = context;
|
|
31558
|
-
const
|
|
31632
|
+
const queryParams = boundedQuery ? ownQueryBag(args) : void 0;
|
|
31633
|
+
const labelQuery = boundedQuery && readNamesOpt(client, queryParams?.["names"], `invoke: "${record.id}" params bag`);
|
|
31559
31634
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
31560
31635
|
const method = streaming ? context.pageSession?.consume : holder[methodName];
|
|
31561
31636
|
if (typeof method !== "function") {
|
|
@@ -31568,17 +31643,18 @@ async function prepareInvocation(client, operation, argsIn, opts, streaming = fa
|
|
|
31568
31643
|
const mutationOpts = buildMutationOpts(opts, isWrite);
|
|
31569
31644
|
const callArgs = buildCallArgs(record, args, mutationOpts, isWrite);
|
|
31570
31645
|
if (opts.fresh === true) appendFresh(record, callArgs);
|
|
31571
|
-
if (boundedQuery) validateWalkBag(args[0]?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
|
|
31572
31646
|
let scopeNote;
|
|
31573
|
-
if (boundedQuery
|
|
31574
|
-
|
|
31647
|
+
if (boundedQuery) {
|
|
31648
|
+
validateWalkBag(queryParams?.["walk"], `invoke: "${record.id}"`, { operation: record.id });
|
|
31649
|
+
const acknowledged = queryParams !== void 0 && Object.hasOwn(queryParams, "acknowledgeUnscoped") && queryParams.acknowledgeUnscoped === true;
|
|
31650
|
+
if (!acknowledged) scopeNote = (await guardUnscopedQueryWalk(holder, record.id, queryParams)).note;
|
|
31575
31651
|
}
|
|
31576
31652
|
return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
|
|
31577
31653
|
}
|
|
31578
31654
|
async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
31579
31655
|
const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
|
|
31580
31656
|
const result = await method.apply(holder, callArgs);
|
|
31581
|
-
if (labelQuery && args
|
|
31657
|
+
if (labelQuery && ownQueryBag(args)?.["walk"] === void 0 && Array.isArray(result?.items)) {
|
|
31582
31658
|
const bounded = result;
|
|
31583
31659
|
const labelled = await labelRows(client, record.resource, bounded.items);
|
|
31584
31660
|
return { ...bounded, items: labelled.rows, ...labelled.names !== void 0 ? { names: labelled.names } : {}, ...scopeNote !== void 0 ? { scopeNote } : {} };
|