node-autotask 0.42.0 → 0.43.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 +10 -0
- package/MCP_TOOL_CATALOG.json +1 -1
- package/MCP_TOOL_MANIFEST.md +2 -2
- package/N8N_MCP_MANIFEST.json +2 -2
- package/N8N_MCP_MANIFEST.md +3 -3
- package/capabilities.json +14 -14
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-ZR24JGW2.js → chunk-4EFXIE53.js} +2 -2
- package/dist/{chunk-VEOSOIU4.cjs → chunk-5BDUMDAQ.cjs} +13 -13
- package/dist/{chunk-WP33PQVM.js → chunk-JY2BWYXY.js} +13 -13
- package/dist/{chunk-TTPHVFPJ.js → chunk-KTEDPS4X.js} +3 -3
- package/dist/{chunk-AETFO6BO.js → chunk-Q23JULNN.js} +1 -1
- package/dist/{chunk-MYL34QU5.cjs → chunk-SK3GYRNA.cjs} +143 -143
- package/dist/{chunk-HD5BRA3Z.cjs → chunk-TH7B5H4P.cjs} +286 -286
- package/dist/{chunk-SEFJJY4J.cjs → chunk-VFLAMMIJ.cjs} +3 -3
- package/dist/index.cjs +22 -22
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +185 -185
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +8 -8
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.js +3 -3
- package/package.json +8 -2
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var
|
|
73
|
+
var _chunkVFLAMMIJcjs = require('../chunk-VFLAMMIJ.cjs');
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
var
|
|
76
|
+
var _chunk5BDUMDAQcjs = require('../chunk-5BDUMDAQ.cjs');
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
var _chunkMJTKK3QGcjs = require('../chunk-MJTKK3QG.cjs');
|
|
@@ -81,21 +81,21 @@ var _chunkMJTKK3QGcjs = require('../chunk-MJTKK3QG.cjs');
|
|
|
81
81
|
// src/operations/searchAcrossResources.ts
|
|
82
82
|
var DEFAULT_LIMIT = 25;
|
|
83
83
|
function resourceFor(client, key) {
|
|
84
|
-
return client[
|
|
84
|
+
return client[_chunkVFLAMMIJcjs.camelKey.call(void 0, key)];
|
|
85
85
|
}
|
|
86
86
|
async function searchAcrossResources(client, query, opts = {}) {
|
|
87
87
|
const text = query.trim();
|
|
88
88
|
if (text === "") {
|
|
89
|
-
throw new (0,
|
|
89
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("searchAcrossResources: query must be a non-empty string");
|
|
90
90
|
}
|
|
91
|
-
const keys = _nullishCoalesce(opts.resources, () => (
|
|
91
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkVFLAMMIJcjs.WORKFLOW_RESOURCES));
|
|
92
92
|
if (keys.length === 0) {
|
|
93
|
-
throw new (0,
|
|
93
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("searchAcrossResources: no resources requested");
|
|
94
94
|
}
|
|
95
|
-
const limit =
|
|
95
|
+
const limit = _chunkVFLAMMIJcjs.clampPageSize.call(void 0, _nullishCoalesce(opts.limit, () => ( DEFAULT_LIMIT)));
|
|
96
96
|
const totalLimit = opts.totalLimit;
|
|
97
97
|
if (totalLimit !== void 0 && !(Number.isInteger(totalLimit) && totalLimit >= 1)) {
|
|
98
|
-
throw new (0,
|
|
98
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("searchAcrossResources: totalLimit must be a positive integer");
|
|
99
99
|
}
|
|
100
100
|
const results = [];
|
|
101
101
|
const skipped = [];
|
|
@@ -126,7 +126,7 @@ async function searchAcrossResources(client, query, opts = {}) {
|
|
|
126
126
|
|
|
127
127
|
// src/operations/resolveAny.ts
|
|
128
128
|
function resourceFor2(client, key) {
|
|
129
|
-
return client[
|
|
129
|
+
return client[_chunkVFLAMMIJcjs.camelKey.call(void 0, key)];
|
|
130
130
|
}
|
|
131
131
|
var FAULT_CATEGORIES = /* @__PURE__ */ new Set(["auth", "rate_limit", "server", "network", "timeout", "policy"]);
|
|
132
132
|
function missCost(identifier) {
|
|
@@ -135,17 +135,17 @@ function missCost(identifier) {
|
|
|
135
135
|
}
|
|
136
136
|
async function resolveAny(client, identifier, opts = {}) {
|
|
137
137
|
if (typeof identifier === "number") {
|
|
138
|
-
|
|
138
|
+
_chunkVFLAMMIJcjs.parseIdentifier.call(void 0, identifier, "identifier");
|
|
139
139
|
} else if (identifier.trim() === "") {
|
|
140
|
-
throw new (0,
|
|
140
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("resolveAny: identifier must be non-empty");
|
|
141
141
|
}
|
|
142
|
-
const keys = _nullishCoalesce(opts.resources, () => (
|
|
142
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkVFLAMMIJcjs.WORKFLOW_RESOURCES));
|
|
143
143
|
if (keys.length === 0) {
|
|
144
|
-
throw new (0,
|
|
144
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("resolveAny: no resources requested");
|
|
145
145
|
}
|
|
146
146
|
const match = _nullishCoalesce(opts.match, () => ( "exact"));
|
|
147
147
|
if (match !== "exact" && match !== "auto") {
|
|
148
|
-
throw new (0,
|
|
148
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`resolveAny: match must be 'exact' or 'auto' (got ${JSON.stringify(match)})`);
|
|
149
149
|
}
|
|
150
150
|
const results = [];
|
|
151
151
|
for (const key of keys) {
|
|
@@ -192,9 +192,9 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
192
192
|
} catch (err) {
|
|
193
193
|
let code;
|
|
194
194
|
let candidates = [];
|
|
195
|
-
if (err instanceof
|
|
195
|
+
if (err instanceof _chunkVFLAMMIJcjs.AutotaskConfigError) {
|
|
196
196
|
code = "CONFIG_ERROR";
|
|
197
|
-
} else if (
|
|
197
|
+
} else if (_chunkVFLAMMIJcjs.isAutotaskError.call(void 0, err)) {
|
|
198
198
|
if (FAULT_CATEGORIES.has(err.category)) throw err;
|
|
199
199
|
code = err.code;
|
|
200
200
|
if (code === "RESOLUTION_AMBIGUOUS" && err.resourceIds !== void 0) {
|
|
@@ -221,7 +221,7 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
221
221
|
// src/operations/aggregate.ts
|
|
222
222
|
var AGGREGATE_TOP_MAX = 100;
|
|
223
223
|
var AGGREGATE_DEFAULT_TOP = 25;
|
|
224
|
-
var AGGREGATE_DEFAULT_LIMIT =
|
|
224
|
+
var AGGREGATE_DEFAULT_LIMIT = _chunkVFLAMMIJcjs.BOUNDED_QUERY_MAX_LIMIT;
|
|
225
225
|
var AGGREGATE_DATE_BUCKETS = ["month", "week", "year"];
|
|
226
226
|
var DATE_ONLY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
227
227
|
var DATETIME_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,9})?(Z|[+-]\d{2}:?\d{2})?$/;
|
|
@@ -278,7 +278,7 @@ function dateBucketLabel(value, bucket) {
|
|
|
278
278
|
}
|
|
279
279
|
var QUERY_RESOURCE_KEYS = (() => {
|
|
280
280
|
const s = /* @__PURE__ */ new Set();
|
|
281
|
-
for (const rec of
|
|
281
|
+
for (const rec of _chunk5BDUMDAQcjs.CAPABILITIES) if (rec.operation === "query") s.add(rec.resource);
|
|
282
282
|
return s;
|
|
283
283
|
})();
|
|
284
284
|
var AGGREGATE_OPT_KEYS = ["groupBy", "sum", "top", "limit", "names", "acknowledgeUnscoped"];
|
|
@@ -314,15 +314,15 @@ function parseFilterConditions(filter, problems) {
|
|
|
314
314
|
return [];
|
|
315
315
|
}
|
|
316
316
|
try {
|
|
317
|
-
return
|
|
317
|
+
return _chunkVFLAMMIJcjs.buildFilter.call(void 0, conds).filter;
|
|
318
318
|
} catch (err) {
|
|
319
|
-
problems.push(err instanceof
|
|
319
|
+
problems.push(err instanceof _chunkVFLAMMIJcjs.AutotaskConfigError ? err.message : `filter must be the query-bag filter (13 operators; caps 500 OR-conditions / 1 UDF / 8000 chars); ${String(err)}`);
|
|
320
320
|
return [];
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
function checkOptsBag(opts, problems) {
|
|
324
324
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
325
|
-
throw new (0,
|
|
325
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
326
326
|
`aggregate: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
327
327
|
{ operation: "operations.aggregate" }
|
|
328
328
|
);
|
|
@@ -389,18 +389,18 @@ function parseTopAndLimit(opts, problems) {
|
|
|
389
389
|
if (!Number.isInteger(opts.limit)) {
|
|
390
390
|
problems.push(`limit must be an integer (got ${String(opts.limit)})`);
|
|
391
391
|
} else {
|
|
392
|
-
limit = Math.min(Math.max(opts.limit, 1),
|
|
392
|
+
limit = Math.min(Math.max(opts.limit, 1), _chunkVFLAMMIJcjs.BOUNDED_QUERY_MAX_LIMIT);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
return { top, limit };
|
|
396
396
|
}
|
|
397
397
|
async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
398
|
-
const record = resourceKey === void 0 ? void 0 :
|
|
398
|
+
const record = resourceKey === void 0 ? void 0 : _chunk5BDUMDAQcjs.CAPABILITIES.find((r) => r.resource === resourceKey && r.operation === "query");
|
|
399
399
|
if (record === void 0) return void 0;
|
|
400
400
|
const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
|
|
401
401
|
const groupBy = strings(opts.groupBy);
|
|
402
|
-
const found = await
|
|
403
|
-
filter:
|
|
402
|
+
const found = await _chunkVFLAMMIJcjs.findUnknownFieldNames.call(void 0, record, void 0, {
|
|
403
|
+
filter: _chunkVFLAMMIJcjs.collectFilterFieldNames.call(void 0, conditions, resourceKey),
|
|
404
404
|
groupBy: groupBy.map((f) => f.split("@")[0]),
|
|
405
405
|
sum: strings(opts.sum)
|
|
406
406
|
});
|
|
@@ -424,21 +424,21 @@ async function validateAggregate(operation, filter, opts) {
|
|
|
424
424
|
checkOptsBag(opts, problems);
|
|
425
425
|
const oracles = {
|
|
426
426
|
resourceKey,
|
|
427
|
-
dateSets: resourceKey !== void 0 ?
|
|
427
|
+
dateSets: resourceKey !== void 0 ? _chunkVFLAMMIJcjs.MODEL_DATE_FIELDS[resourceKey] : void 0
|
|
428
428
|
};
|
|
429
429
|
const known = await checkFieldNames(resourceKey, conditions, opts, problems);
|
|
430
430
|
const groupBy = parseGroupBy(opts, oracles, known, problems);
|
|
431
431
|
const sum = checkSumFields("sum", opts.sum, problems);
|
|
432
432
|
const { top, limit } = parseTopAndLimit(opts, problems);
|
|
433
433
|
if (problems.length > 0) {
|
|
434
|
-
throw new (0,
|
|
434
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
435
435
|
`aggregate: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
436
436
|
- ` + problems.join("\n- "),
|
|
437
437
|
{ operation: "operations.aggregate" }
|
|
438
438
|
);
|
|
439
439
|
}
|
|
440
440
|
if ((groupBy.length > 0 || sum.length > 0) && conditions.length === 0 && opts.acknowledgeUnscoped !== true) {
|
|
441
|
-
throw new (0,
|
|
441
|
+
throw new (0, _chunkVFLAMMIJcjs.ScopeRequiredError)(operation, { threshold: _chunkVFLAMMIJcjs.UNSCOPED_WALK_THRESHOLD }, "empty-filter");
|
|
442
442
|
}
|
|
443
443
|
return { resourceKey, conditions, groupBy, sum, top, limit };
|
|
444
444
|
}
|
|
@@ -468,9 +468,9 @@ function foldGroups(items, v) {
|
|
|
468
468
|
}
|
|
469
469
|
async function aggregate(client, operation, filter, opts = {}) {
|
|
470
470
|
const v = await validateAggregate(operation, filter, opts);
|
|
471
|
-
const holder = client[
|
|
471
|
+
const holder = client[_chunkVFLAMMIJcjs.camelKey.call(void 0, v.resourceKey)];
|
|
472
472
|
if (holder === void 0) {
|
|
473
|
-
throw new (0,
|
|
473
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`aggregate: the client exposes no accessor for resource "${v.resourceKey}"`, {
|
|
474
474
|
operation: "operations.aggregate",
|
|
475
475
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
476
476
|
});
|
|
@@ -487,8 +487,8 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
487
487
|
const res = await holder.queryBounded({ filter: wireFilter, limit: v.limit });
|
|
488
488
|
const sorted = foldGroups(res.items, v);
|
|
489
489
|
const top = sorted.slice(0, v.top);
|
|
490
|
-
const label =
|
|
491
|
-
const labelled = !label || v.groupBy.length === 0 ? void 0 : await
|
|
490
|
+
const label = _chunkVFLAMMIJcjs.readNamesOpt.call(void 0, client, opts.names, "aggregate");
|
|
491
|
+
const labelled = !label || v.groupBy.length === 0 ? void 0 : await _chunkVFLAMMIJcjs.labelRows.call(void 0, client, v.resourceKey, top.map((g) => g.key));
|
|
492
492
|
const result = {
|
|
493
493
|
mode: v.groupBy.length > 0 ? "group" : "sum",
|
|
494
494
|
groups: top.map((g, i) => ({ key: _nullishCoalesce(_optionalChain([labelled, 'optionalAccess', _4 => _4.rows, 'access', _5 => _5[i]]), () => ( g.key)), count: g.count, ...g.sums !== void 0 ? { sums: g.sums } : {} })),
|
|
@@ -521,10 +521,10 @@ var DEFAULT_CONTRACT_TYPE_RE = /^\s*(recurring|fixed)\b/i;
|
|
|
521
521
|
var CONTRACTS_PATH = "/V1.0/Contracts";
|
|
522
522
|
var COMPANIES_PATH = "/V1.0/Companies";
|
|
523
523
|
var BILLING_ITEMS_PATH = "/V1.0/BillingItems";
|
|
524
|
-
var LINE_TYPE_FIELDS = ["billingItemType", "timeEntryID", "expenseItemID", ...
|
|
525
|
-
var isLabour = (line) =>
|
|
524
|
+
var LINE_TYPE_FIELDS = ["billingItemType", "timeEntryID", "expenseItemID", ..._chunkVFLAMMIJcjs.CHARGE_LINE_FKS, ..._chunkVFLAMMIJcjs.SERVICE_LINE_FKS];
|
|
525
|
+
var isLabour = (line) => _chunkVFLAMMIJcjs.billingLineType.call(void 0, line) === "labour";
|
|
526
526
|
function picklistKey(c, dim, path, field, raw, missing) {
|
|
527
|
-
const id =
|
|
527
|
+
const id = _chunkVFLAMMIJcjs.num.call(void 0, raw);
|
|
528
528
|
if (id === 0) return { id: null, label: missing };
|
|
529
529
|
const label = _optionalChain([c, 'access', _7 => _7.labels, 'access', _8 => _8[path], 'optionalAccess', _9 => _9.get, 'call', _10 => _10(field), 'optionalAccess', _11 => _11.get, 'call', _12 => _12(id)]);
|
|
530
530
|
if (label === void 0) {
|
|
@@ -547,7 +547,7 @@ var DIMENSIONS = {
|
|
|
547
547
|
},
|
|
548
548
|
company: {
|
|
549
549
|
joins: { companies: ["companyName"] },
|
|
550
|
-
key: (c) => ({ id:
|
|
550
|
+
key: (c) => ({ id: _chunkVFLAMMIJcjs.num.call(void 0, c.line["companyID"]), name: String(_nullishCoalesce(_optionalChain([c, 'access', _15 => _15.company, 'optionalAccess', _16 => _16["companyName"]]), () => ( ""))) })
|
|
551
551
|
},
|
|
552
552
|
month: {
|
|
553
553
|
key: (c) => ({ id: c.invoice.month })
|
|
@@ -555,11 +555,11 @@ var DIMENSIONS = {
|
|
|
555
555
|
billingItemKind: {
|
|
556
556
|
lineFields: LINE_TYPE_FIELDS,
|
|
557
557
|
picklist: BILLING_ITEMS_PATH,
|
|
558
|
-
key: (c) =>
|
|
558
|
+
key: (c) => _chunkVFLAMMIJcjs.num.call(void 0, c.line["billingItemType"]) === 0 ? { id: _chunkVFLAMMIJcjs.billingLineType.call(void 0, c.line), label: _chunkVFLAMMIJcjs.billingLineType.call(void 0, c.line) } : picklistKey(c, "billingItemKind", BILLING_ITEMS_PATH, "billingItemType", c.line["billingItemType"], "other")
|
|
559
559
|
},
|
|
560
560
|
contract: {
|
|
561
561
|
joins: { contracts: ["contractName"] },
|
|
562
|
-
key: (c) => ({ id:
|
|
562
|
+
key: (c) => ({ id: _chunkVFLAMMIJcjs.num.call(void 0, c.line["contractID"]), name: String(_nullishCoalesce(c.contract["contractName"], () => ( ""))) })
|
|
563
563
|
},
|
|
564
564
|
// Per line (no contract-pointer fallback): association → level2 (the Line of Business, `name`) + level1 (the division).
|
|
565
565
|
lineOfBusiness: {
|
|
@@ -567,11 +567,11 @@ var DIMENSIONS = {
|
|
|
567
567
|
joins: { organizationalLevelAssociations: [], organizationalLevel1s: [], organizationalLevel2s: [] },
|
|
568
568
|
unresolved: "unresolvedAssociations",
|
|
569
569
|
key: (c) => {
|
|
570
|
-
const id =
|
|
570
|
+
const id = _chunkVFLAMMIJcjs.num.call(void 0, c.line["organizationalLevelAssociationID"]);
|
|
571
571
|
if (id === 0) return { id: null, label: "no LOB assigned" };
|
|
572
572
|
const a = c.joined.organizationalLevelAssociations.get(id);
|
|
573
|
-
const l1 = c.joined.organizationalLevel1s.get(
|
|
574
|
-
const l2 = c.joined.organizationalLevel2s.get(
|
|
573
|
+
const l1 = c.joined.organizationalLevel1s.get(_chunkVFLAMMIJcjs.num.call(void 0, _optionalChain([a, 'optionalAccess', _17 => _17["organizationalLevel1ID"]])));
|
|
574
|
+
const l2 = c.joined.organizationalLevel2s.get(_chunkVFLAMMIJcjs.num.call(void 0, _optionalChain([a, 'optionalAccess', _18 => _18["organizationalLevel2ID"]])));
|
|
575
575
|
if (l1 === void 0 || l2 === void 0) return "unresolvedAssociations";
|
|
576
576
|
return { id, name: String(_nullishCoalesce(l2["name"], () => ( ""))), division: String(_nullishCoalesce(l1["name"], () => ( ""))) };
|
|
577
577
|
}
|
|
@@ -582,9 +582,9 @@ var DIMENSIONS = {
|
|
|
582
582
|
joins: { timeEntries: [], resources: [] },
|
|
583
583
|
unresolved: "unresolvedTimeEntries",
|
|
584
584
|
key: (c) => {
|
|
585
|
-
const te =
|
|
585
|
+
const te = _chunkVFLAMMIJcjs.num.call(void 0, c.line["timeEntryID"]);
|
|
586
586
|
if (!isLabour(c.line) || te === 0) return { id: null, label: "n/a" };
|
|
587
|
-
const id =
|
|
587
|
+
const id = _chunkVFLAMMIJcjs.num.call(void 0, _optionalChain([c, 'access', _19 => _19.joined, 'access', _20 => _20.timeEntries, 'access', _21 => _21.get, 'call', _22 => _22(te), 'optionalAccess', _23 => _23["resourceID"]]));
|
|
588
588
|
const r = c.joined.resources.get(id);
|
|
589
589
|
if (r === void 0) return "unresolvedTimeEntries";
|
|
590
590
|
return { id, name: `${String(_nullishCoalesce(r["firstName"], () => ( "")))} ${String(_nullishCoalesce(r["lastName"], () => ( "")))}`.trim() };
|
|
@@ -595,58 +595,58 @@ var DIMENSIONS = {
|
|
|
595
595
|
joins: { billingCodes: [] },
|
|
596
596
|
unresolved: "unresolvedBillingCodes",
|
|
597
597
|
key: (c) => {
|
|
598
|
-
const id =
|
|
598
|
+
const id = _chunkVFLAMMIJcjs.num.call(void 0, c.line["billingCodeID"]);
|
|
599
599
|
if (id === 0) return { id: null, label: "none" };
|
|
600
600
|
const b = c.joined.billingCodes.get(id);
|
|
601
601
|
return b === void 0 ? "unresolvedBillingCodes" : { id, name: String(_nullishCoalesce(b["name"], () => ( ""))) };
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
};
|
|
605
|
-
var fk = (rows, field) => [...rows].map((r) =>
|
|
605
|
+
var fk = (rows, field) => [...rows].map((r) => _chunkVFLAMMIJcjs.num.call(void 0, r[field]));
|
|
606
606
|
var ONE_CHUNK = (idChunks) => Math.min(1, idChunks);
|
|
607
607
|
var JOINS = {
|
|
608
608
|
contracts: {
|
|
609
|
-
make: (http) => new (0,
|
|
609
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.ContractsResource)(http, PAGE),
|
|
610
610
|
fields: ["id", "contractType", "contractCategory"],
|
|
611
611
|
ids: (lines) => fk(lines, "contractID")
|
|
612
612
|
},
|
|
613
613
|
companies: {
|
|
614
|
-
make: (http) => new (0,
|
|
614
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.CompaniesResource)(http, PAGE),
|
|
615
615
|
fields: ["id"],
|
|
616
616
|
ids: (lines) => fk(lines, "companyID")
|
|
617
617
|
},
|
|
618
618
|
organizationalLevelAssociations: {
|
|
619
|
-
make: (http) => new (0,
|
|
619
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.OrganizationalLevelAssociationsResource)(http, PAGE),
|
|
620
620
|
fields: ["id", "organizationalLevel1ID", "organizationalLevel2ID"],
|
|
621
621
|
ids: (lines) => fk(lines, "organizationalLevelAssociationID")
|
|
622
622
|
},
|
|
623
623
|
organizationalLevel1s: {
|
|
624
|
-
make: (http) => new (0,
|
|
624
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.OrganizationalLevel1sResource)(http, PAGE),
|
|
625
625
|
fields: ["id", "name"],
|
|
626
626
|
ids: (_, j) => fk(j["organizationalLevelAssociations"].values(), "organizationalLevel1ID"),
|
|
627
627
|
chunks: ONE_CHUNK
|
|
628
628
|
},
|
|
629
629
|
organizationalLevel2s: {
|
|
630
|
-
make: (http) => new (0,
|
|
630
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.OrganizationalLevel2sResource)(http, PAGE),
|
|
631
631
|
fields: ["id", "name"],
|
|
632
632
|
ids: (_, j) => fk(j["organizationalLevelAssociations"].values(), "organizationalLevel2ID"),
|
|
633
633
|
chunks: ONE_CHUNK
|
|
634
634
|
},
|
|
635
635
|
timeEntries: {
|
|
636
|
-
make: (http) => new (0,
|
|
636
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.TimeEntriesResource)(http, PAGE),
|
|
637
637
|
fields: ["id", "resourceID"],
|
|
638
638
|
ids: (lines) => fk(lines.filter(isLabour), "timeEntryID"),
|
|
639
639
|
// One time entry per labour line: the line count is the upper bound (labour share unknown pre-walk).
|
|
640
640
|
chunks: (_, lines) => pages(lines)
|
|
641
641
|
},
|
|
642
642
|
resources: {
|
|
643
|
-
make: (http, client) => new (0,
|
|
643
|
+
make: (http, client) => new (0, _chunkVFLAMMIJcjs.ResourcesResource)(http, client.config, PAGE),
|
|
644
644
|
fields: ["id", "firstName", "lastName"],
|
|
645
645
|
ids: (_, j) => fk(j["timeEntries"].values(), "resourceID"),
|
|
646
646
|
chunks: ONE_CHUNK
|
|
647
647
|
},
|
|
648
648
|
billingCodes: {
|
|
649
|
-
make: (http) => new (0,
|
|
649
|
+
make: (http) => new (0, _chunkVFLAMMIJcjs.BillingCodesResource)(http, PAGE),
|
|
650
650
|
fields: ["id", "name"],
|
|
651
651
|
ids: (lines) => fk(lines, "billingCodeID")
|
|
652
652
|
}
|
|
@@ -681,7 +681,7 @@ function checkInt(name, v, def, max, problems) {
|
|
|
681
681
|
}
|
|
682
682
|
function validate(opts) {
|
|
683
683
|
if (typeof opts !== "object" || opts === null || Array.isArray(opts)) {
|
|
684
|
-
throw new (0,
|
|
684
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("revenueRollup: opts must be the options object { <scope>, dateFrom, dateTo, ... } (zero wire was issued)", { operation: OP });
|
|
685
685
|
}
|
|
686
686
|
const o = opts;
|
|
687
687
|
const problems = [];
|
|
@@ -698,12 +698,12 @@ function validate(opts) {
|
|
|
698
698
|
if (scopeKind === "tenantWide" && o.tenantWide !== true) problems.push("tenantWide must be exactly true");
|
|
699
699
|
}
|
|
700
700
|
const { dateFrom, dateTo } = o;
|
|
701
|
-
if (!
|
|
701
|
+
if (!_chunkVFLAMMIJcjs.isDateYMD.call(void 0, dateFrom) || !_chunkVFLAMMIJcjs.isDateYMD.call(void 0, dateTo)) {
|
|
702
702
|
problems.push("dateFrom and dateTo are both required as YYYY-MM-DD (the window is inclusive, whole UTC days)");
|
|
703
703
|
} else if (dateFrom > dateTo) {
|
|
704
704
|
problems.push(`dateFrom ${dateFrom} is after dateTo ${dateTo}`);
|
|
705
|
-
} else if (
|
|
706
|
-
problems.push(`the window spans ${
|
|
705
|
+
} else if (_chunkVFLAMMIJcjs.monthsInWindow.call(void 0, dateFrom, dateTo) > _chunkVFLAMMIJcjs.PROFITABILITY_MAX_WINDOW_MONTHS) {
|
|
706
|
+
problems.push(`the window spans ${_chunkVFLAMMIJcjs.monthsInWindow.call(void 0, dateFrom, dateTo)} months; the cap is ${_chunkVFLAMMIJcjs.PROFITABILITY_MAX_WINDOW_MONTHS}`);
|
|
707
707
|
}
|
|
708
708
|
let groupBy = [...DEFAULT_GROUP_BY];
|
|
709
709
|
if (o.groupBy !== void 0) {
|
|
@@ -730,7 +730,7 @@ function validate(opts) {
|
|
|
730
730
|
};
|
|
731
731
|
if (o.includeNonChargeable !== void 0 && typeof o.includeNonChargeable !== "boolean") problems.push("includeNonChargeable must be a boolean");
|
|
732
732
|
if (problems.length > 0) {
|
|
733
|
-
throw new (0,
|
|
733
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`revenueRollup: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
734
734
|
- ${problems.join("\n- ")}`, { operation: OP });
|
|
735
735
|
}
|
|
736
736
|
return v;
|
|
@@ -748,7 +748,7 @@ function resolveSelector(name, sel, values) {
|
|
|
748
748
|
}
|
|
749
749
|
function unmatched(name, what, values) {
|
|
750
750
|
const live = [...values].map(([id, l]) => `${id} ${l}`).join("; ") || "(the picklist serves no values)";
|
|
751
|
-
return new (0,
|
|
751
|
+
return new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`revenueRollup: ${name}: ${what}. Live values (id label): ${live}`, {
|
|
752
752
|
operation: OP,
|
|
753
753
|
suggestedAction: `Pass ${name} as ids or exact labels from the live list.`
|
|
754
754
|
});
|
|
@@ -759,10 +759,10 @@ var chunk = (a) => {
|
|
|
759
759
|
for (let i = 0; i < a.length; i += PAGE) out.push(a.slice(i, i + PAGE));
|
|
760
760
|
return out;
|
|
761
761
|
};
|
|
762
|
-
var byId = (rows) => [...new Map(rows.map((r) => [
|
|
763
|
-
var cents = (v) => Math.round(
|
|
764
|
-
var revC = (line) => cents(
|
|
765
|
-
var extC = (line) => cents(
|
|
762
|
+
var byId = (rows) => [...new Map(rows.map((r) => [_chunkVFLAMMIJcjs.num.call(void 0, r["id"]), r])).values()];
|
|
763
|
+
var cents = (v) => Math.round(_chunkVFLAMMIJcjs.num.call(void 0, v) * 100);
|
|
764
|
+
var revC = (line) => cents(_chunkVFLAMMIJcjs.internalAmount.call(void 0, line, "internalCurrencyTotalAmount", "totalAmount"));
|
|
765
|
+
var extC = (line) => cents(_chunkVFLAMMIJcjs.internalAmount.call(void 0, line, "internalCurrencyExtendedPrice", "extendedPrice"));
|
|
766
766
|
var INTERNAL_FIELDS = ["internalCurrencyTotalAmount", "internalCurrencyExtendedPrice"];
|
|
767
767
|
var lacksInternal = (line) => INTERNAL_FIELDS.some((k) => !Number.isFinite(line[k]));
|
|
768
768
|
var money = (c) => c / 100;
|
|
@@ -773,7 +773,7 @@ async function collect(res, filter, includeFields) {
|
|
|
773
773
|
return out;
|
|
774
774
|
}
|
|
775
775
|
function blindCount() {
|
|
776
|
-
return new (0,
|
|
776
|
+
return new (0, _chunkVFLAMMIJcjs.AutotaskError)("revenueRollup: a gate count came back blind (unknown, not zero); the roll-up cannot be sized", {
|
|
777
777
|
code: "INVALID_RESPONSE",
|
|
778
778
|
category: "server",
|
|
779
779
|
operation: OP,
|
|
@@ -783,7 +783,7 @@ function blindCount() {
|
|
|
783
783
|
}
|
|
784
784
|
function countMismatch(what, streamed, counted, rows) {
|
|
785
785
|
const rowNote = rows !== void 0 && rows !== streamed ? ` (${rows} rows)` : "";
|
|
786
|
-
return new (0,
|
|
786
|
+
return new (0, _chunkVFLAMMIJcjs.AutotaskError)(`revenueRollup: the ${what} stream returned ${streamed} distinct ids${rowNote} but the gate count was ${counted} (the data changed mid-walk or a page dropped rows); the fold was discarded`, {
|
|
787
787
|
code: "INVALID_RESPONSE",
|
|
788
788
|
category: "server",
|
|
789
789
|
operation: OP,
|
|
@@ -792,7 +792,7 @@ function countMismatch(what, streamed, counted, rows) {
|
|
|
792
792
|
});
|
|
793
793
|
}
|
|
794
794
|
function budgetError(message, details, suggestedAction) {
|
|
795
|
-
return new (0,
|
|
795
|
+
return new (0, _chunkVFLAMMIJcjs.AutotaskError)(message, { code: "BUDGET_EXCEEDED", category: "policy", operation: OP, details, suggestedAction });
|
|
796
796
|
}
|
|
797
797
|
function lastMonthsFrom(dateTo, months) {
|
|
798
798
|
return new Date(Date.UTC(Number(dateTo.slice(0, 4)), Number(dateTo.slice(5, 7)) - months, 1)).toISOString().slice(0, 10);
|
|
@@ -825,7 +825,7 @@ async function revenueRollup(client, opts) {
|
|
|
825
825
|
const groupDims = v.groupBy.map((d) => DIMENSIONS[d]);
|
|
826
826
|
const paths = [.../* @__PURE__ */ new Set([CONTRACTS_PATH, ...groupDims.flatMap((d) => d.picklist ? [d.picklist] : [])])];
|
|
827
827
|
const labels = {};
|
|
828
|
-
for (const p of paths) labels[p] = await
|
|
828
|
+
for (const p of paths) labels[p] = await _chunkVFLAMMIJcjs.readPicklists.call(void 0, http, p, OP);
|
|
829
829
|
const contractLabels = labels[CONTRACTS_PATH];
|
|
830
830
|
const typeValues = _nullishCoalesce(contractLabels.get("contractType"), () => ( /* @__PURE__ */ new Map()));
|
|
831
831
|
const inTypes = v.contractTypes ? resolveSelector("contractTypes", v.contractTypes, typeValues) : new Map([...typeValues].filter(([, l]) => DEFAULT_CONTRACT_TYPE_RE.test(l)));
|
|
@@ -834,23 +834,23 @@ async function revenueRollup(client, opts) {
|
|
|
834
834
|
let scopeIds = v.scopeIds;
|
|
835
835
|
if (v.scopeKind === "ownerResourceID") {
|
|
836
836
|
const owned = /* @__PURE__ */ new Set();
|
|
837
|
-
for await (const c of new (0,
|
|
838
|
-
const id =
|
|
837
|
+
for await (const c of new (0, _chunkVFLAMMIJcjs.CompaniesResource)(http, PAGE).query({ filter: [{ field: "ownerResourceID", op: "eq", value: v.ownerResourceID }], includeFields: ["id"], maxRecords: PAGE, names: false })) {
|
|
838
|
+
const id = _chunkVFLAMMIJcjs.num.call(void 0, c.id);
|
|
839
839
|
if (id > 0) owned.add(id);
|
|
840
840
|
if (owned.size > SCOPE_IDS_MAX) break;
|
|
841
841
|
}
|
|
842
842
|
scopeIds = [...owned].sort((a, b) => a - b);
|
|
843
843
|
if (scopeIds.length === 0 || scopeIds.length > SCOPE_IDS_MAX) {
|
|
844
|
-
throw new (0,
|
|
844
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
845
845
|
`revenueRollup: ownerResourceID ${v.ownerResourceID} resolves to ${scopeIds.length > SCOPE_IDS_MAX ? `more than ${SCOPE_IDS_MAX}` : 0} companies (companies.query; 1..${SCOPE_IDS_MAX} supported)`,
|
|
846
846
|
{ operation: OP, suggestedAction: "Pass companyIDs explicitly, or tenantWide: true." }
|
|
847
847
|
);
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
850
|
const scopeCond = scopeIds === void 0 ? [] : [{ field: v.scopeKind === "contractIDs" ? "contractID" : "companyID", op: "in", value: scopeIds }];
|
|
851
|
-
const invoices = new (0,
|
|
852
|
-
const billingItems = new (0,
|
|
853
|
-
const windowOn = (field) => [{ field, op: "gte", value: v.dateFrom }, { field, op: "lt", value:
|
|
851
|
+
const invoices = new (0, _chunkVFLAMMIJcjs.InvoicesResource)(http, PAGE);
|
|
852
|
+
const billingItems = new (0, _chunkVFLAMMIJcjs.BillingItemsResource)(http, PAGE);
|
|
853
|
+
const windowOn = (field) => [{ field, op: "gte", value: v.dateFrom }, { field, op: "lt", value: _chunkVFLAMMIJcjs.dayAfter.call(void 0, v.dateTo) }];
|
|
854
854
|
const invoiceFilter = (voided2) => [...windowOn("invoiceDateTime"), { field: "isVoided", op: "eq", value: voided2 }];
|
|
855
855
|
const withVoided = v.scopeKind !== "contractIDs";
|
|
856
856
|
const voidedFilter = [...invoiceFilter(true), ...scopeIds !== void 0 && withVoided ? [{ field: "companyID", op: "in", value: scopeIds }] : []];
|
|
@@ -874,7 +874,7 @@ async function revenueRollup(client, opts) {
|
|
|
874
874
|
const invoiceRows = await collect(invoices, invoiceFilter(false), ["id", "invoiceTotal", "invoiceDateTime", "companyID"]);
|
|
875
875
|
const invoiceById = /* @__PURE__ */ new Map();
|
|
876
876
|
for (const r of invoiceRows) {
|
|
877
|
-
invoiceById.set(
|
|
877
|
+
invoiceById.set(_chunkVFLAMMIJcjs.num.call(void 0, r["id"]), { total: cents(r["invoiceTotal"]), month: String(_nullishCoalesce(r["invoiceDateTime"], () => ( ""))).slice(0, 7), companyID: _chunkVFLAMMIJcjs.num.call(void 0, r["companyID"]) });
|
|
878
878
|
}
|
|
879
879
|
if (invoiceById.size !== nInvoices) throw countMismatch("invoice", invoiceById.size, nInvoices, invoiceRows.length);
|
|
880
880
|
const voided = withVoided ? byId(await collect(invoices, voidedFilter, ["id", "invoiceTotal"])) : void 0;
|
|
@@ -888,13 +888,13 @@ async function revenueRollup(client, opts) {
|
|
|
888
888
|
if (rows.length !== n) throw countMismatch("line", rows.length, n);
|
|
889
889
|
return rows;
|
|
890
890
|
}, chunk(ids), { concurrency: CONCURRENCY })).flat();
|
|
891
|
-
const orphan = lines.find((l) => !invoiceById.has(
|
|
891
|
+
const orphan = lines.find((l) => !invoiceById.has(_chunkVFLAMMIJcjs.num.call(void 0, l["invoiceID"])));
|
|
892
892
|
if (orphan !== void 0) {
|
|
893
|
-
throw new (0,
|
|
893
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskError)(`revenueRollup: billing line ${_chunkVFLAMMIJcjs.num.call(void 0, orphan["id"])} belongs to invoice ${_chunkVFLAMMIJcjs.num.call(void 0, orphan["invoiceID"])}, which is not among the ${invoiceById.size} streamed invoices; the fold was discarded`, {
|
|
894
894
|
code: "INVALID_RESPONSE",
|
|
895
895
|
category: "server",
|
|
896
896
|
operation: OP,
|
|
897
|
-
details: { reason: "orphan_line", lineID:
|
|
897
|
+
details: { reason: "orphan_line", lineID: _chunkVFLAMMIJcjs.num.call(void 0, orphan["id"]), invoiceID: _chunkVFLAMMIJcjs.num.call(void 0, orphan["invoiceID"]) },
|
|
898
898
|
suggestedAction: "Retry the call."
|
|
899
899
|
});
|
|
900
900
|
}
|
|
@@ -908,12 +908,12 @@ async function revenueRollup(client, opts) {
|
|
|
908
908
|
const fields = [.../* @__PURE__ */ new Set([...spec.fields, ...groupDims.flatMap((d) => _nullishCoalesce(_optionalChain([d, 'access', _26 => _26.joins, 'optionalAccess', _27 => _27[j]]), () => ( [])))])];
|
|
909
909
|
const want = [...new Set(spec.ids(all, joined))].filter((id) => id > 0).sort((a, b) => a - b);
|
|
910
910
|
const rows = await client.batch((c) => collect(res, [{ field: "id", op: "in", value: c }], fields), chunk(want), { concurrency: CONCURRENCY });
|
|
911
|
-
for (const r of rows.flat()) joined[j].set(
|
|
911
|
+
for (const r of rows.flat()) joined[j].set(_chunkVFLAMMIJcjs.num.call(void 0, r["id"]), r);
|
|
912
912
|
}
|
|
913
913
|
return fold(v, { invoiceById, voided, lines, uninvoiced, joined, labels, inTypes, inCategories, scopeIds, calls, estimate });
|
|
914
914
|
}
|
|
915
915
|
function refusal(v, estimate, fixed, scopeIds, joinCount) {
|
|
916
|
-
const months =
|
|
916
|
+
const months = _chunkVFLAMMIJcjs.monthsInWindow.call(void 0, v.dateFrom, v.dateTo);
|
|
917
917
|
const variable = estimate - fixed;
|
|
918
918
|
const fitMonths = Math.floor((v.budget - fixed) * months / variable);
|
|
919
919
|
const suggestions = [];
|
|
@@ -1009,15 +1009,15 @@ function fold(v, f) {
|
|
|
1009
1009
|
const zeroTotal = amt();
|
|
1010
1010
|
const zeroIds = /* @__PURE__ */ new Set();
|
|
1011
1011
|
const locate = (line, invoice) => {
|
|
1012
|
-
const contractID =
|
|
1012
|
+
const contractID = _chunkVFLAMMIJcjs.num.call(void 0, line["contractID"]);
|
|
1013
1013
|
if (contractID === 0) return { bucket: uncontracted, unresolved: false };
|
|
1014
1014
|
const contract = f.joined.contracts.get(contractID);
|
|
1015
1015
|
if (contract === void 0) return { bucket: unresolvedContracts, unresolved: true };
|
|
1016
|
-
const type =
|
|
1016
|
+
const type = _chunkVFLAMMIJcjs.num.call(void 0, contract["contractType"]);
|
|
1017
1017
|
if (!f.inTypes.has(type)) return { bucket: slot(otherTypes, typeLabel(type)), unresolved: false };
|
|
1018
|
-
const cat =
|
|
1018
|
+
const cat = _chunkVFLAMMIJcjs.num.call(void 0, contract["contractCategory"]);
|
|
1019
1019
|
if (f.inCategories !== void 0 && !f.inCategories.has(cat)) return { bucket: slot(otherCats, cat === 0 ? "uncategorised" : catLabel(cat)), unresolved: false };
|
|
1020
|
-
const company = f.joined.companies.get(
|
|
1020
|
+
const company = f.joined.companies.get(_chunkVFLAMMIJcjs.num.call(void 0, line["companyID"]));
|
|
1021
1021
|
if (needCompany && company === void 0) return { bucket: unresolvedCompanies, unresolved: true };
|
|
1022
1022
|
const ctx = { line, invoice, contract, company, joined: f.joined, labels: f.labels, unlabelled };
|
|
1023
1023
|
const keys = {};
|
|
@@ -1037,7 +1037,7 @@ function fold(v, f) {
|
|
|
1037
1037
|
return { cell };
|
|
1038
1038
|
};
|
|
1039
1039
|
for (const line of f.lines) {
|
|
1040
|
-
const invoiceID =
|
|
1040
|
+
const invoiceID = _chunkVFLAMMIJcjs.num.call(void 0, line["invoiceID"]);
|
|
1041
1041
|
const invoice = f.invoiceById.get(invoiceID);
|
|
1042
1042
|
lineTotals.set(invoiceID, (_nullishCoalesce(lineTotals.get(invoiceID), () => ( 0))) + cents(line["totalAmount"]));
|
|
1043
1043
|
const c = revC(line);
|
|
@@ -1058,9 +1058,9 @@ function fold(v, f) {
|
|
|
1058
1058
|
cell.creditLines += 1;
|
|
1059
1059
|
}
|
|
1060
1060
|
cell.included += extC(line) - c;
|
|
1061
|
-
cell.contracts.add(
|
|
1061
|
+
cell.contracts.add(_chunkVFLAMMIJcjs.num.call(void 0, line["contractID"]));
|
|
1062
1062
|
cell.items += 1;
|
|
1063
|
-
allContracts.add(
|
|
1063
|
+
allContracts.add(_chunkVFLAMMIJcjs.num.call(void 0, line["contractID"]));
|
|
1064
1064
|
if (byLob && cell.keys.lineOfBusiness.id === null) add(noPointer, c);
|
|
1065
1065
|
const k = v.nonChargeable ? ncClass(line) : void 0;
|
|
1066
1066
|
if (k) ncAdd(cell.nc, k, line);
|
|
@@ -1068,7 +1068,7 @@ function fold(v, f) {
|
|
|
1068
1068
|
for (const line of f.uninvoiced) {
|
|
1069
1069
|
const k = ncClass(line);
|
|
1070
1070
|
if (!k) continue;
|
|
1071
|
-
const at = locate(line, { total: 0, month: String(_nullishCoalesce(line["itemDate"], () => ( ""))).slice(0, 7), companyID:
|
|
1071
|
+
const at = locate(line, { total: 0, month: String(_nullishCoalesce(line["itemDate"], () => ( ""))).slice(0, 7), companyID: _chunkVFLAMMIJcjs.num.call(void 0, line["companyID"]) });
|
|
1072
1072
|
if ("cell" in at) ncAdd(at.cell.nc, k, line);
|
|
1073
1073
|
else if (at.unresolved) add(unresolvedNc, extC(line));
|
|
1074
1074
|
}
|
|
@@ -1178,20 +1178,20 @@ function slot(m, k) {
|
|
|
1178
1178
|
async function relationshipMap(client, resourceKey) {
|
|
1179
1179
|
void client;
|
|
1180
1180
|
if (typeof resourceKey !== "string" || resourceKey.trim() === "") {
|
|
1181
|
-
throw new (0,
|
|
1181
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1182
1182
|
`relationshipMap: resourceKey must be a non-empty plan resource key string (e.g. 'tickets'; got ${typeof resourceKey === "string" ? "a blank string" : typeof resourceKey})`,
|
|
1183
1183
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items, ticket_notes." }
|
|
1184
1184
|
);
|
|
1185
1185
|
}
|
|
1186
1186
|
const key = resourceKey.trim();
|
|
1187
|
-
const entry =
|
|
1187
|
+
const entry = _chunkVFLAMMIJcjs.RELATIONSHIP_MAP[key];
|
|
1188
1188
|
if (entry === void 0) {
|
|
1189
|
-
throw new (0,
|
|
1190
|
-
`relationshipMap: unknown resource "${key}" \u2014 the plan has ${Object.keys(
|
|
1189
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskError)(
|
|
1190
|
+
`relationshipMap: unknown resource "${key}" \u2014 the plan has ${Object.keys(_chunkVFLAMMIJcjs.RELATIONSHIP_MAP).length} resources`,
|
|
1191
1191
|
{
|
|
1192
1192
|
code: "RESOURCE_UNKNOWN",
|
|
1193
1193
|
category: "validation",
|
|
1194
|
-
suggestedAction: `Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items). Zone facts served are ${
|
|
1194
|
+
suggestedAction: `Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items). Zone facts served are ${_chunkVFLAMMIJcjs.RELATIONSHIP_ZONE.label} (${_chunkVFLAMMIJcjs.RELATIONSHIP_ZONE.zone})-verified.`
|
|
1195
1195
|
}
|
|
1196
1196
|
);
|
|
1197
1197
|
}
|
|
@@ -1208,24 +1208,24 @@ var BLIND_SURFACE_KINDS = [
|
|
|
1208
1208
|
async function blindSurfaces(client, opts) {
|
|
1209
1209
|
void client;
|
|
1210
1210
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1211
|
-
throw new (0,
|
|
1211
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("blindSurfaces: opts must be an object { resource?: string, kind?: BlindSurfaceKind }");
|
|
1212
1212
|
}
|
|
1213
|
-
const inv =
|
|
1213
|
+
const inv = _chunkVFLAMMIJcjs.BLIND_SURFACE_INVENTORY;
|
|
1214
1214
|
if (inv === null) {
|
|
1215
|
-
throw new (0,
|
|
1215
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("blindSurfaces: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
1216
1216
|
}
|
|
1217
1217
|
let surfaces = inv.surfaces;
|
|
1218
1218
|
if (_optionalChain([opts, 'optionalAccess', _33 => _33.resource]) !== void 0) {
|
|
1219
1219
|
const key = typeof opts.resource === "string" ? opts.resource.trim() : "";
|
|
1220
1220
|
if (key === "") {
|
|
1221
|
-
throw new (0,
|
|
1221
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1222
1222
|
"blindSurfaces: opts.resource must be a non-empty plan resource key string (e.g. 'tickets')",
|
|
1223
1223
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items." }
|
|
1224
1224
|
);
|
|
1225
1225
|
}
|
|
1226
1226
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
1227
|
-
throw new (0,
|
|
1228
|
-
`blindSurfaces: unknown resource "${key}" \u2014 the plan has ${Object.keys(
|
|
1227
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskError)(
|
|
1228
|
+
`blindSurfaces: unknown resource "${key}" \u2014 the plan has ${Object.keys(_chunkVFLAMMIJcjs.RELATIONSHIP_MAP).length} resources`,
|
|
1229
1229
|
{
|
|
1230
1230
|
code: "RESOURCE_UNKNOWN",
|
|
1231
1231
|
category: "validation",
|
|
@@ -1237,7 +1237,7 @@ async function blindSurfaces(client, opts) {
|
|
|
1237
1237
|
}
|
|
1238
1238
|
if (_optionalChain([opts, 'optionalAccess', _34 => _34.kind]) !== void 0) {
|
|
1239
1239
|
if (!BLIND_SURFACE_KINDS.includes(opts.kind)) {
|
|
1240
|
-
throw new (0,
|
|
1240
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1241
1241
|
`blindSurfaces: unknown kind "${String(opts.kind)}" \u2014 the valid classes are: ${BLIND_SURFACE_KINDS.join(", ")}`,
|
|
1242
1242
|
{ suggestedAction: `Filter with one of: ${BLIND_SURFACE_KINDS.join(", ")} (or omit kind for the full 116-surface inventory).` }
|
|
1243
1243
|
);
|
|
@@ -1250,51 +1250,51 @@ async function blindSurfaces(client, opts) {
|
|
|
1250
1250
|
// src/operations/probeReachability.ts
|
|
1251
1251
|
async function probeReachability(client, opts) {
|
|
1252
1252
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1253
|
-
throw new (0,
|
|
1253
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("probeReachability: opts must be an object { resources?: string[], limit?: 1|2, maxWireCalls?: number, confirmProbe?: true }");
|
|
1254
1254
|
}
|
|
1255
|
-
const defs =
|
|
1255
|
+
const defs = _chunkVFLAMMIJcjs.REACHABILITY_PROBE_DEFAULTS;
|
|
1256
1256
|
if (_optionalChain([opts, 'optionalAccess', _35 => _35.confirmProbe]) !== true) {
|
|
1257
|
-
throw new (0,
|
|
1257
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1258
1258
|
"probeReachability: confirmProbe: true is required \u2014 the op deliberately fans out read wire across the tenant (one bounded query per surface); pass confirmProbe: true to run it",
|
|
1259
1259
|
{ suggestedAction: `Re-call with { confirmProbe: true } (plus resources/limit/maxWireCalls as needed). For the ZERO-wire pinned inventory use operations.blindSurfaces.` }
|
|
1260
1260
|
);
|
|
1261
1261
|
}
|
|
1262
1262
|
const limit = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _36 => _36.limit]), () => ( defs.limitDefault));
|
|
1263
1263
|
if (!Number.isInteger(limit) || limit < 1 || limit > defs.limitMax) {
|
|
1264
|
-
throw new (0,
|
|
1264
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1265
1265
|
`probeReachability: limit must be an integer 1..${defs.limitMax} (got ${String(limit)}) \u2014 the rows-per-surface bound for the discovery read`
|
|
1266
1266
|
);
|
|
1267
1267
|
}
|
|
1268
1268
|
const cap = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _37 => _37.maxWireCalls]), () => ( defs.defaultCap));
|
|
1269
1269
|
if (!Number.isInteger(cap) || cap < 1) {
|
|
1270
|
-
throw new (0,
|
|
1270
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`probeReachability: maxWireCalls must be a positive integer (got ${String(cap)})`);
|
|
1271
1271
|
}
|
|
1272
1272
|
if (cap > defs.hardCap) {
|
|
1273
|
-
throw new (0,
|
|
1273
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1274
1274
|
`probeReachability: maxWireCalls ${cap} exceeds the hard wire cap of ${defs.hardCap} \u2014 the sweep is refused above it (never capped silently)`,
|
|
1275
1275
|
{ suggestedAction: `Pass maxWireCalls \u2264 ${defs.hardCap} and a resources set no larger than the cap (the refused set is never truncated).` }
|
|
1276
1276
|
);
|
|
1277
1277
|
}
|
|
1278
|
-
const inv =
|
|
1278
|
+
const inv = _chunkVFLAMMIJcjs.BLIND_SURFACE_INVENTORY;
|
|
1279
1279
|
if (inv === null) {
|
|
1280
|
-
throw new (0,
|
|
1280
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("probeReachability: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
1281
1281
|
}
|
|
1282
1282
|
let targets;
|
|
1283
1283
|
if (_optionalChain([opts, 'optionalAccess', _38 => _38.resources]) === void 0) {
|
|
1284
1284
|
targets = [...defs.defaultTargets];
|
|
1285
1285
|
} else {
|
|
1286
1286
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
1287
|
-
throw new (0,
|
|
1287
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("probeReachability: opts.resources must be a non-empty string[] of plan resource keys (or omit it for the default non-data-full set)");
|
|
1288
1288
|
}
|
|
1289
1289
|
const seen = /* @__PURE__ */ new Set();
|
|
1290
1290
|
for (const r of opts.resources) {
|
|
1291
1291
|
if (typeof r !== "string" || r.trim() === "") {
|
|
1292
|
-
throw new (0,
|
|
1292
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`probeReachability: opts.resources must contain non-empty plan resource key strings (got ${typeof r === "string" && r.trim() === "" ? "a blank string" : typeof r})`);
|
|
1293
1293
|
}
|
|
1294
1294
|
const key = r.trim();
|
|
1295
1295
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
1296
1296
|
const surfaceCount = new Set(inv.surfaces.map((s) => s.resource)).size;
|
|
1297
|
-
throw new (0,
|
|
1297
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskError)(
|
|
1298
1298
|
`probeReachability: unknown resource "${key}" \u2014 the inventory has ${surfaceCount} surfaces`,
|
|
1299
1299
|
{
|
|
1300
1300
|
code: "RESOURCE_UNKNOWN",
|
|
@@ -1308,7 +1308,7 @@ async function probeReachability(client, opts) {
|
|
|
1308
1308
|
targets = [...seen];
|
|
1309
1309
|
}
|
|
1310
1310
|
if (targets.length > cap) {
|
|
1311
|
-
throw new (0,
|
|
1311
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1312
1312
|
`probeReachability: ${targets.length} requested surface(s) exceed the wire cap of ${cap} \u2014 the sweep is refused above its cap (never truncated)`,
|
|
1313
1313
|
{ suggestedAction: `Raise maxWireCalls (\u2264 ${defs.hardCap}) to cover the set, or pass a smaller resources list.` }
|
|
1314
1314
|
);
|
|
@@ -1318,7 +1318,7 @@ async function probeReachability(client, opts) {
|
|
|
1318
1318
|
for (const resource of targets.sort()) {
|
|
1319
1319
|
const row = byResource.get(resource);
|
|
1320
1320
|
if (row === void 0) continue;
|
|
1321
|
-
const holder = client[
|
|
1321
|
+
const holder = client[_chunkVFLAMMIJcjs.camelKey.call(void 0, resource)];
|
|
1322
1322
|
const probeFn = _optionalChain([holder, 'optionalAccess', _39 => _39.queryBounded]);
|
|
1323
1323
|
if (typeof probeFn !== "function") {
|
|
1324
1324
|
results.push({
|
|
@@ -1337,7 +1337,7 @@ async function probeReachability(client, opts) {
|
|
|
1337
1337
|
probe: { ok: true, wire: 1, error: null }
|
|
1338
1338
|
});
|
|
1339
1339
|
} catch (err) {
|
|
1340
|
-
const code =
|
|
1340
|
+
const code = _chunkVFLAMMIJcjs.isAutotaskError.call(void 0, err) ? err.code : "NETWORK_ERROR";
|
|
1341
1341
|
const message = err instanceof Error ? err.message : String(err);
|
|
1342
1342
|
results.push({
|
|
1343
1343
|
...row,
|
|
@@ -1365,30 +1365,30 @@ var CREATE_BLOCKER_KINDS = [
|
|
|
1365
1365
|
async function createGuidance(client, opts) {
|
|
1366
1366
|
void client;
|
|
1367
1367
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
1368
|
-
throw new (0,
|
|
1368
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1369
1369
|
"createGuidance: opts must be an object { resources?: string[], kind?: CreateBlockerKind }"
|
|
1370
1370
|
);
|
|
1371
1371
|
}
|
|
1372
|
-
let servedRows =
|
|
1372
|
+
let servedRows = _chunkVFLAMMIJcjs.CREATE_GUIDANCE.rows.map((row) => ({
|
|
1373
1373
|
...row,
|
|
1374
1374
|
// Issue #219 N4: one precedence rule, stated on every row (live-proven >
|
|
1375
1375
|
// zone > spec). The spec set is not available here (it is a LIVE read) —
|
|
1376
1376
|
// the helper is handed the plan's two shapes and names the source.
|
|
1377
|
-
requiredFields:
|
|
1377
|
+
requiredFields: _chunkVFLAMMIJcjs.effectiveRequiredFields.call(void 0, void 0, _nullishCoalesce(_optionalChain([_chunkVFLAMMIJcjs.RELATIONSHIP_MAP, 'access', _41 => _41[row.resource], 'optionalAccess', _42 => _42.zoneFacts]), () => ( null)))
|
|
1378
1378
|
}));
|
|
1379
1379
|
if (_optionalChain([opts, 'optionalAccess', _43 => _43.resources]) !== void 0) {
|
|
1380
1380
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
1381
|
-
throw new (0,
|
|
1381
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("createGuidance: opts.resources must be a non-empty string[] of plan resource keys");
|
|
1382
1382
|
}
|
|
1383
1383
|
const wanted = /* @__PURE__ */ new Set();
|
|
1384
1384
|
for (const r of opts.resources) {
|
|
1385
1385
|
if (typeof r !== "string" || r.trim() === "") {
|
|
1386
|
-
throw new (0,
|
|
1386
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)("createGuidance: opts.resources must contain non-empty plan resource key strings");
|
|
1387
1387
|
}
|
|
1388
1388
|
const key = r.trim();
|
|
1389
|
-
if (!
|
|
1390
|
-
throw new (0,
|
|
1391
|
-
`createGuidance: unknown resource "${key}" \u2014 the catalog has ${
|
|
1389
|
+
if (!_chunkVFLAMMIJcjs.CREATE_GUIDANCE.rows.some((row) => row.resource === key)) {
|
|
1390
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskError)(
|
|
1391
|
+
`createGuidance: unknown resource "${key}" \u2014 the catalog has ${_chunkVFLAMMIJcjs.CREATE_GUIDANCE.rows.length} create entities`,
|
|
1392
1392
|
{
|
|
1393
1393
|
code: "RESOURCE_UNKNOWN",
|
|
1394
1394
|
category: "validation",
|
|
@@ -1402,36 +1402,36 @@ async function createGuidance(client, opts) {
|
|
|
1402
1402
|
}
|
|
1403
1403
|
if (_optionalChain([opts, 'optionalAccess', _44 => _44.kind]) !== void 0) {
|
|
1404
1404
|
if (!CREATE_BLOCKER_KINDS.includes(opts.kind)) {
|
|
1405
|
-
throw new (0,
|
|
1405
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1406
1406
|
`createGuidance: unknown kind "${String(opts.kind)}" \u2014 the valid kinds are: ${CREATE_BLOCKER_KINDS.join(", ")}`
|
|
1407
1407
|
);
|
|
1408
1408
|
}
|
|
1409
1409
|
servedRows = servedRows.filter((row) => _optionalChain([row, 'access', _45 => _45.blocker, 'optionalAccess', _46 => _46.kind]) === opts.kind);
|
|
1410
1410
|
}
|
|
1411
1411
|
return {
|
|
1412
|
-
zone:
|
|
1413
|
-
label:
|
|
1414
|
-
verifiedAt:
|
|
1412
|
+
zone: _chunkVFLAMMIJcjs.CREATE_GUIDANCE.zone,
|
|
1413
|
+
label: _chunkVFLAMMIJcjs.CREATE_GUIDANCE.label,
|
|
1414
|
+
verifiedAt: _chunkVFLAMMIJcjs.CREATE_GUIDANCE.verifiedAt,
|
|
1415
1415
|
rows: servedRows,
|
|
1416
|
-
counts:
|
|
1416
|
+
counts: _chunkVFLAMMIJcjs.CREATE_GUIDANCE.counts
|
|
1417
1417
|
};
|
|
1418
1418
|
}
|
|
1419
1419
|
|
|
1420
1420
|
// src/operations/registryIndex.ts
|
|
1421
|
-
var OPERATION_BY_ID = new Map(
|
|
1421
|
+
var OPERATION_BY_ID = new Map(_chunk5BDUMDAQcjs.CAPABILITIES.map((r) => [r.id, r]));
|
|
1422
1422
|
|
|
1423
1423
|
// src/operations/sanitiseResult.ts
|
|
1424
1424
|
async function sanitiseResult(client, result, operation) {
|
|
1425
1425
|
void client;
|
|
1426
1426
|
if (typeof operation !== "string" || operation === "") {
|
|
1427
|
-
throw new (0,
|
|
1427
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1428
1428
|
'sanitiseResult: operation must be a non-empty registry operation key (e.g. "tickets.query")',
|
|
1429
1429
|
{ suggestedAction: "Pass the operation key the result came from \u2014 the registry id, not the resource key." }
|
|
1430
1430
|
);
|
|
1431
1431
|
}
|
|
1432
1432
|
const record = OPERATION_BY_ID.get(operation);
|
|
1433
1433
|
if (record === void 0) {
|
|
1434
|
-
throw new (0,
|
|
1434
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1435
1435
|
`sanitiseResult: unknown operation "${operation.slice(0, 60)}" \u2014 it is not in the capability registry`,
|
|
1436
1436
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
1437
1437
|
);
|
|
@@ -1446,7 +1446,7 @@ var RECOVERY_CONFIRM = "operations.recovery";
|
|
|
1446
1446
|
var RECOVERY_DEFAULT_LIMIT = 25;
|
|
1447
1447
|
var RECOVERY_MAX_LIMIT = 100;
|
|
1448
1448
|
function configError(message, operation, suggestedAction) {
|
|
1449
|
-
throw new (0,
|
|
1449
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(message, { operation, suggestedAction });
|
|
1450
1450
|
}
|
|
1451
1451
|
function parseMatchId(record) {
|
|
1452
1452
|
const raw = record.id;
|
|
@@ -1462,7 +1462,7 @@ function parseMatchId(record) {
|
|
|
1462
1462
|
return { id: null, unsafe: true };
|
|
1463
1463
|
}
|
|
1464
1464
|
function validateRecoveryInput(input, operation) {
|
|
1465
|
-
if (!
|
|
1465
|
+
if (!_chunkVFLAMMIJcjs.isRecord.call(void 0, input)) {
|
|
1466
1466
|
configError(
|
|
1467
1467
|
`recovery: input must be an object { resource, marker, ... } (got ${typeof input})`,
|
|
1468
1468
|
operation,
|
|
@@ -1496,10 +1496,10 @@ function validateRecoveryInput(input, operation) {
|
|
|
1496
1496
|
return { resource, marker, action };
|
|
1497
1497
|
}
|
|
1498
1498
|
function resolveRecoveryTarget(client, resource, operation) {
|
|
1499
|
-
const entry =
|
|
1499
|
+
const entry = _chunkVFLAMMIJcjs.RELATIONSHIP_MAP[resource];
|
|
1500
1500
|
if (entry === void 0) {
|
|
1501
|
-
throw new (0,
|
|
1502
|
-
`recovery: unknown resource "${resource}" \u2014 the plan has ${Object.keys(
|
|
1501
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskError)(
|
|
1502
|
+
`recovery: unknown resource "${resource}" \u2014 the plan has ${Object.keys(_chunkVFLAMMIJcjs.RELATIONSHIP_MAP).length} resources`,
|
|
1503
1503
|
{
|
|
1504
1504
|
code: "RESOURCE_UNKNOWN",
|
|
1505
1505
|
category: "validation",
|
|
@@ -1508,7 +1508,7 @@ function resolveRecoveryTarget(client, resource, operation) {
|
|
|
1508
1508
|
}
|
|
1509
1509
|
);
|
|
1510
1510
|
}
|
|
1511
|
-
const holder = client[
|
|
1511
|
+
const holder = client[_chunkVFLAMMIJcjs.camelKey.call(void 0, resource)];
|
|
1512
1512
|
if (!holder || typeof holder.queryBounded !== "function") {
|
|
1513
1513
|
configError(
|
|
1514
1514
|
`recovery: ${resource} exposes no bounded query surface \u2014 the marker search cannot run`,
|
|
@@ -1519,7 +1519,7 @@ function resolveRecoveryTarget(client, resource, operation) {
|
|
|
1519
1519
|
return { entry, holder };
|
|
1520
1520
|
}
|
|
1521
1521
|
function resolveMarkerField(input, resource, operation) {
|
|
1522
|
-
const field = input.field !== void 0 ? String(input.field) :
|
|
1522
|
+
const field = input.field !== void 0 ? String(input.field) : _chunkVFLAMMIJcjs.MARKER_FIELDS[resource];
|
|
1523
1523
|
if (typeof field !== "string" || field.trim() === "") {
|
|
1524
1524
|
configError(
|
|
1525
1525
|
`recovery: ${resource} has no plan markerField and no input.field was passed \u2014 the marker search needs a name-like field to filter on`,
|
|
@@ -1558,7 +1558,7 @@ function resolveExtraFilter(input, operation) {
|
|
|
1558
1558
|
);
|
|
1559
1559
|
}
|
|
1560
1560
|
for (const c of input.filter) {
|
|
1561
|
-
if (!
|
|
1561
|
+
if (!_chunkVFLAMMIJcjs.isRecord.call(void 0, c) || typeof c.op !== "string" || c.op === "and" || c.op === "or") {
|
|
1562
1562
|
configError(
|
|
1563
1563
|
"recovery: input.filter accepts only plain leaf conditions ({ field, op, value }) \u2014 no grouping",
|
|
1564
1564
|
operation,
|
|
@@ -1583,7 +1583,7 @@ function resolveLimit(input, operation) {
|
|
|
1583
1583
|
async function applyRecoveryDeletes(holder, matches, parentId, resource, operation) {
|
|
1584
1584
|
const deleteMethod = holder.delete;
|
|
1585
1585
|
if (deleteMethod === void 0) {
|
|
1586
|
-
throw new (0,
|
|
1586
|
+
throw new (0, _chunkVFLAMMIJcjs.DeleteBoundaryError)(
|
|
1587
1587
|
`recovery: ${resource} has no delete method on the client \u2014 the boundary is marked available in the plan but the typed delete surface is missing`,
|
|
1588
1588
|
{
|
|
1589
1589
|
operation,
|
|
@@ -1612,14 +1612,14 @@ async function applyRecoveryDeletes(holder, matches, parentId, resource, operati
|
|
|
1612
1612
|
verify = "still-present";
|
|
1613
1613
|
}
|
|
1614
1614
|
} catch (err) {
|
|
1615
|
-
if (err instanceof
|
|
1615
|
+
if (err instanceof _chunkVFLAMMIJcjs.NotFoundError) verify = "not-found";
|
|
1616
1616
|
else {
|
|
1617
1617
|
verify = "error";
|
|
1618
|
-
code =
|
|
1618
|
+
code = _chunkVFLAMMIJcjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1619
1619
|
}
|
|
1620
1620
|
}
|
|
1621
1621
|
} catch (err) {
|
|
1622
|
-
code =
|
|
1622
|
+
code = _chunkVFLAMMIJcjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1623
1623
|
}
|
|
1624
1624
|
deleted.push({ id, verified: verify === "not-found", code });
|
|
1625
1625
|
}
|
|
@@ -1647,7 +1647,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1647
1647
|
const parentId = resolveParentId(input, entry, resource, operation);
|
|
1648
1648
|
const extra = resolveExtraFilter(input, operation);
|
|
1649
1649
|
const limit = resolveLimit(input, operation);
|
|
1650
|
-
const boundaryNote =
|
|
1650
|
+
const boundaryNote = _chunkVFLAMMIJcjs.DELETE_BOUNDARY_NOTES[resource];
|
|
1651
1651
|
const boundary = {
|
|
1652
1652
|
available: boundaryNote === void 0,
|
|
1653
1653
|
reason: _nullishCoalesce(boundaryNote, () => ( null)),
|
|
@@ -1659,7 +1659,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1659
1659
|
};
|
|
1660
1660
|
const isDelete = action === "delete";
|
|
1661
1661
|
if (isDelete && boundaryNote !== void 0) {
|
|
1662
|
-
throw new (0,
|
|
1662
|
+
throw new (0, _chunkVFLAMMIJcjs.DeleteBoundaryError)(
|
|
1663
1663
|
`recovery: the vendor defines no DELETE for ${resource} \u2014 the delete cannot be issued through the API (zero wire was issued)`,
|
|
1664
1664
|
{
|
|
1665
1665
|
operation,
|
|
@@ -1671,7 +1671,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1671
1671
|
const dryRun = _optionalChain([opts, 'optionalAccess', _49 => _49.dryRun]) !== false;
|
|
1672
1672
|
const confirm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _50 => _50.confirm]), () => ( input.confirm));
|
|
1673
1673
|
if (isDelete && !dryRun && confirm !== RECOVERY_CONFIRM) {
|
|
1674
|
-
throw new (0,
|
|
1674
|
+
throw new (0, _chunkVFLAMMIJcjs.ConfirmationRequiredError)(
|
|
1675
1675
|
`recovery: action 'delete' apply is destructive and requires its confirmation flag: pass confirm: "${RECOVERY_CONFIRM}"`,
|
|
1676
1676
|
{
|
|
1677
1677
|
operation: RECOVERY_CONFIRM,
|
|
@@ -1687,7 +1687,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1687
1687
|
const query = await holder.queryBounded({ filter: conditions, limit });
|
|
1688
1688
|
if (query.hasMore) {
|
|
1689
1689
|
const wire = isDelete ? "DELETE wire" : "mutating wire";
|
|
1690
|
-
throw new (0,
|
|
1690
|
+
throw new (0, _chunkVFLAMMIJcjs.RecoveryTruncatedError)(
|
|
1691
1691
|
`recovery: the marker search on ${resource} TRIPPED its match cap (${limit}) \u2014 more matches exist than were returned (zero ${wire} was issued)`,
|
|
1692
1692
|
{
|
|
1693
1693
|
operation,
|
|
@@ -1716,7 +1716,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1716
1716
|
return { ...base, simulated: true, dryRun: true };
|
|
1717
1717
|
}
|
|
1718
1718
|
if (unsafeId) {
|
|
1719
|
-
throw new (0,
|
|
1719
|
+
throw new (0, _chunkVFLAMMIJcjs.MarkerUnsafeIdError)(
|
|
1720
1720
|
`recovery: ${unsafeIds.length} of ${matches.length} match(es) on ${resource} have ids beyond Number.MAX_SAFE_INTEGER \u2014 they CANNOT be addressed through the SDK's typed delete surface (zero DELETE wire was issued)`,
|
|
1721
1721
|
{
|
|
1722
1722
|
operation,
|
|
@@ -1734,7 +1734,7 @@ function needsConfirmation(record) {
|
|
|
1734
1734
|
return record.effect === "destructive" || (_nullishCoalesce(record.flags, () => ( []))).includes("requiresApproval");
|
|
1735
1735
|
}
|
|
1736
1736
|
function refuse(message, operation, suggestedAction) {
|
|
1737
|
-
throw new (0,
|
|
1737
|
+
throw new (0, _chunkVFLAMMIJcjs.ConfirmationRequiredError)(message, { operation, suggestedAction });
|
|
1738
1738
|
}
|
|
1739
1739
|
var MODE_BY_EFFECT = {
|
|
1740
1740
|
read: "read",
|
|
@@ -1780,7 +1780,7 @@ function looseTypeOk(type, value) {
|
|
|
1780
1780
|
case "string[]":
|
|
1781
1781
|
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
1782
1782
|
case "object":
|
|
1783
|
-
return
|
|
1783
|
+
return _chunkVFLAMMIJcjs.isRecord.call(void 0, value);
|
|
1784
1784
|
default:
|
|
1785
1785
|
return true;
|
|
1786
1786
|
}
|
|
@@ -1794,12 +1794,12 @@ function declaredArgList(record) {
|
|
|
1794
1794
|
function resolveDispatchArgs(record, argsIn) {
|
|
1795
1795
|
const operation = record.id;
|
|
1796
1796
|
const bad = (message) => {
|
|
1797
|
-
throw new (0,
|
|
1797
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`invoke: "${operation}" ${message}`, { operation });
|
|
1798
1798
|
};
|
|
1799
1799
|
if (argsIn === void 0 || argsIn === null) return [];
|
|
1800
1800
|
if (Array.isArray(argsIn)) return argsIn;
|
|
1801
1801
|
const byName = argsIn;
|
|
1802
|
-
if (!
|
|
1802
|
+
if (!_chunkVFLAMMIJcjs.isRecord.call(void 0, byName) || ![Object.prototype, null].includes(Object.getPrototypeOf(byName))) {
|
|
1803
1803
|
return bad(`args must be a positional array or a plain object of named inputs (declared: ${declaredArgList(record)})`);
|
|
1804
1804
|
}
|
|
1805
1805
|
const schema = _nullishCoalesce(record.inputSchema, () => ( {}));
|
|
@@ -1820,7 +1820,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1820
1820
|
const bagName = names.find((n) => schema[n].properties);
|
|
1821
1821
|
const surplus = args[names.length];
|
|
1822
1822
|
const bagHint = bagName && surplus !== null && typeof surplus === "object" && !Array.isArray(surplus) ? ` \u2014 options go inside the single ${bagName} object` : "";
|
|
1823
|
-
throw new (0,
|
|
1823
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1824
1824
|
`invoke: "${operation}" declares ${names.length} positional arg(s) (${declaredArgList(record)}) but ${args.length} were passed \u2014 extra args are refused${bagHint}`,
|
|
1825
1825
|
{
|
|
1826
1826
|
operation,
|
|
@@ -1830,7 +1830,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1830
1830
|
}
|
|
1831
1831
|
const required = names.filter((n) => schema[n].required);
|
|
1832
1832
|
if (args.length < required.length) {
|
|
1833
|
-
throw new (0,
|
|
1833
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1834
1834
|
`invoke: "${operation}" requires ${required.length} positional arg(s) (${required.map((n) => `${n}: ${schema[n].type}`).join(", ")}) but only ${args.length} were passed \u2014 declared args: ${declaredArgList(record)}`,
|
|
1835
1835
|
{ operation }
|
|
1836
1836
|
);
|
|
@@ -1841,7 +1841,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1841
1841
|
const name = names[i];
|
|
1842
1842
|
const spec = schema[name];
|
|
1843
1843
|
if (!looseTypeOk(spec.type, value)) {
|
|
1844
|
-
throw new (0,
|
|
1844
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1845
1845
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
1846
1846
|
{ operation }
|
|
1847
1847
|
);
|
|
@@ -1849,8 +1849,8 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
1851
|
function foldFlattenedOpts(record, toolArgs) {
|
|
1852
|
-
if (!
|
|
1853
|
-
throw new (0,
|
|
1852
|
+
if (!_chunkVFLAMMIJcjs.isRecord.call(void 0, toolArgs)) {
|
|
1853
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(`invoke: "${record.id}" tool args must be a plain object of named inputs`, { operation: record.id });
|
|
1854
1854
|
}
|
|
1855
1855
|
const bagKeys = (_nullishCoalesce(_optionalChain([record, 'access', _51 => _51.inputSchema, 'optionalAccess', _52 => _52.opts, 'optionalAccess', _53 => _53.properties]), () => ( []))).map((p) => p.name);
|
|
1856
1856
|
const flat = Object.keys(toolArgs).filter((k) => bagKeys.includes(k) && toolArgs[k] !== void 0 && toolArgs[k] !== null);
|
|
@@ -1859,7 +1859,7 @@ function foldFlattenedOpts(record, toolArgs) {
|
|
|
1859
1859
|
if (folded.opts === null) delete folded.opts;
|
|
1860
1860
|
if (flat.length === 0) return folded;
|
|
1861
1861
|
if (folded.opts !== void 0) {
|
|
1862
|
-
throw new (0,
|
|
1862
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1863
1863
|
`invoke: "${record.id}" was given both opts and flattened option(s) ${flat.map((k) => `"${k}"`).join(", ")} \u2014 pass one form`,
|
|
1864
1864
|
{ operation: record.id }
|
|
1865
1865
|
);
|
|
@@ -1926,11 +1926,11 @@ function validateParamsBag(record, args) {
|
|
|
1926
1926
|
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
1927
1927
|
if (valid === void 0) return;
|
|
1928
1928
|
const bag = _optionalChain([args, 'optionalAccess', _54 => _54[0]]);
|
|
1929
|
-
if (bag === void 0 || bag === null || !
|
|
1929
|
+
if (bag === void 0 || bag === null || !_chunkVFLAMMIJcjs.isRecord.call(void 0, bag)) return;
|
|
1930
1930
|
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
1931
1931
|
if (unknown.length === 0) return;
|
|
1932
1932
|
const suggestions = keySuggestions(unknown, valid);
|
|
1933
|
-
throw new (0,
|
|
1933
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1934
1934
|
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
1935
1935
|
{
|
|
1936
1936
|
operation: record.id,
|
|
@@ -1944,7 +1944,7 @@ function validateInvokeOptions(opts, operation) {
|
|
|
1944
1944
|
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
1945
1945
|
if (unknown.length === 0) return;
|
|
1946
1946
|
const suggestions = keySuggestions(unknown, ["dryRun", "confirm", "lastModifiedDate", "maxRetries", "fresh"]);
|
|
1947
|
-
throw new (0,
|
|
1947
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1948
1948
|
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate, maxRetries, fresh; "mode" is internal to the mode wrappers)`,
|
|
1949
1949
|
{
|
|
1950
1950
|
operation,
|
|
@@ -1957,7 +1957,7 @@ function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
|
1957
1957
|
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
1958
1958
|
if (unknown.length === 0) return null;
|
|
1959
1959
|
const suggestions = keySuggestions(unknown, [...validKeys]);
|
|
1960
|
-
return new (0,
|
|
1960
|
+
return new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
1961
1961
|
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
1962
1962
|
{
|
|
1963
1963
|
...operation !== void 0 ? { operation } : {},
|
|
@@ -1993,13 +1993,13 @@ async function guardUnscopedQueryWalk(holder, operation, bag) {
|
|
|
1993
1993
|
const latest = _optionalChain([bag, 'optionalAccess', _57 => _57["latest"]]);
|
|
1994
1994
|
const walk = typeof _optionalChain([bag, 'optionalAccess', _58 => _58["walk"]]) === "object" && _optionalChain([bag, 'optionalAccess', _59 => _59["walk"]]) !== null ? _optionalChain([bag, 'optionalAccess', _60 => _60["walk"]]) : void 0;
|
|
1995
1995
|
const maxRows = typeof _optionalChain([walk, 'optionalAccess', _61 => _61.maxRows]) === "number" ? walk.maxRows : void 0;
|
|
1996
|
-
const effectiveLimit = typeof limit === "number" ? limit :
|
|
1996
|
+
const effectiveLimit = typeof limit === "number" ? limit : _chunkVFLAMMIJcjs.BOUNDED_QUERY_DEFAULT_LIMIT;
|
|
1997
1997
|
let walked = typeof latest === "number" ? Math.max(effectiveLimit, latest) : effectiveLimit;
|
|
1998
1998
|
if (maxRows !== void 0) walked = Math.min(walked, maxRows);
|
|
1999
|
-
if (walked <=
|
|
1999
|
+
if (walked <= _chunkVFLAMMIJcjs.UNSCOPED_WALK_THRESHOLD || hasIdScope(filter)) return {};
|
|
2000
2000
|
let conditions;
|
|
2001
2001
|
try {
|
|
2002
|
-
conditions =
|
|
2002
|
+
conditions = _chunkVFLAMMIJcjs.normalizedConditions.call(void 0, filter);
|
|
2003
2003
|
} catch (e) {
|
|
2004
2004
|
return {};
|
|
2005
2005
|
}
|
|
@@ -2020,7 +2020,7 @@ async function guardUnscopedQueryWalk(holder, operation, bag) {
|
|
|
2020
2020
|
if (count === void 0) {
|
|
2021
2021
|
return { note: "scope check skipped: the pre-flight count was unreadable; this unscoped walk was not guarded." };
|
|
2022
2022
|
}
|
|
2023
|
-
if (count >
|
|
2023
|
+
if (count > _chunkVFLAMMIJcjs.UNSCOPED_WALK_THRESHOLD) throw new (0, _chunkVFLAMMIJcjs.ScopeRequiredError)(operation, { threshold: _chunkVFLAMMIJcjs.UNSCOPED_WALK_THRESHOLD, count });
|
|
2024
2024
|
return {};
|
|
2025
2025
|
}
|
|
2026
2026
|
|
|
@@ -2040,7 +2040,7 @@ function bufferResult(buf) {
|
|
|
2040
2040
|
function resolveRecord(operation) {
|
|
2041
2041
|
const record = OPERATION_BY_ID.get(operation);
|
|
2042
2042
|
if (record === void 0) {
|
|
2043
|
-
throw new (0,
|
|
2043
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2044
2044
|
`invoke: unknown operation "${operation}" \u2014 it is not in the capability registry`,
|
|
2045
2045
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
2046
2046
|
);
|
|
@@ -2051,30 +2051,30 @@ function governPreRequest(record, operation, opts) {
|
|
|
2051
2051
|
validateInvokeOptions(opts, operation);
|
|
2052
2052
|
const mode = opts.mode;
|
|
2053
2053
|
if (mode !== void 0 && MODE_BY_EFFECT[record.effect] !== mode) {
|
|
2054
|
-
throw new (0,
|
|
2054
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(crossModeRefusal(operation, record.effect, mode), { operation });
|
|
2055
2055
|
}
|
|
2056
2056
|
if (opts.dryRun !== void 0 && typeof opts.dryRun !== "boolean") {
|
|
2057
|
-
throw new (0,
|
|
2057
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2058
2058
|
`invoke: dryRun must be a boolean (got ${typeof opts.dryRun}) \u2014 "${operation}" was not issued`,
|
|
2059
2059
|
{ operation, suggestedAction: "Pass dryRun: true (simulate) or dryRun: false (apply) as a real boolean." }
|
|
2060
2060
|
);
|
|
2061
2061
|
}
|
|
2062
2062
|
if (opts.fresh !== void 0) {
|
|
2063
2063
|
if (typeof opts.fresh !== "boolean") {
|
|
2064
|
-
throw new (0,
|
|
2064
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2065
2065
|
`invoke: fresh must be a boolean (got ${typeof opts.fresh}) \u2014 "${operation}" was not issued`,
|
|
2066
2066
|
{ operation, suggestedAction: "Pass fresh: true (bypass the read cache) or omit it." }
|
|
2067
2067
|
);
|
|
2068
2068
|
}
|
|
2069
2069
|
if (record.effect !== "read" || record.kind !== "primitive" || record.operation !== "get" || !("opts" in (_nullishCoalesce(record.inputSchema, () => ( {}))))) {
|
|
2070
|
-
throw new (0,
|
|
2070
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2071
2071
|
`invoke: fresh applies only to a single-record "<resource>.get" read \u2014 "${operation}" was not issued`,
|
|
2072
2072
|
{ operation, suggestedAction: "Drop the fresh option (only <resource>.get consults the read cache per call)." }
|
|
2073
2073
|
);
|
|
2074
2074
|
}
|
|
2075
2075
|
}
|
|
2076
2076
|
if (record.effect === "read" && opts.dryRun === true) {
|
|
2077
|
-
throw new (0,
|
|
2077
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2078
2078
|
`invoke: "${operation}" is a read \u2014 dryRun is not applicable (reads issue their request as-is)`,
|
|
2079
2079
|
{ operation }
|
|
2080
2080
|
);
|
|
@@ -2091,7 +2091,7 @@ function operationsHolder(client) {
|
|
|
2091
2091
|
return {
|
|
2092
2092
|
resolveAny: (identifier, opts) => resolveAny(client, identifier, opts),
|
|
2093
2093
|
searchAcrossResources: (query, opts) => searchAcrossResources(client, query, opts),
|
|
2094
|
-
fetchMany: (items, opts) =>
|
|
2094
|
+
fetchMany: (items, opts) => _chunkVFLAMMIJcjs.fetchMany.call(void 0, client, items, opts),
|
|
2095
2095
|
// Issue #62: the generic aggregate + the cheap count — the
|
|
2096
2096
|
// groupBy/sum-absent mode is ONE vendor /query/count (the S12-C blind
|
|
2097
2097
|
// sentinel rides through); the group/sum modes walk the named
|
|
@@ -2103,12 +2103,12 @@ function operationsHolder(client) {
|
|
|
2103
2103
|
// Issue #59 PR-B: the bulk fetch by ids — query-first chunked `id in`
|
|
2104
2104
|
// reads + the per-id `get` fallback (blind-surface-safe; per-item
|
|
2105
2105
|
// typed outcomes reuse the fetchMany shapes).
|
|
2106
|
-
fetchByIds: (items, opts) =>
|
|
2106
|
+
fetchByIds: (items, opts) => _chunkVFLAMMIJcjs.fetchByIds.call(void 0, client, items, opts),
|
|
2107
2107
|
// Issue #65: opt-in resource name expansion — per-id resources.get
|
|
2108
2108
|
// reads ONLY (never an id-in query — the resources table can be blind
|
|
2109
2109
|
// to count/query while per-id reads work); blind-marked rows for ids
|
|
2110
2110
|
// the API user cannot resolve; the read cache (default-on).
|
|
2111
|
-
expandResourceNames: (ids, opts) =>
|
|
2111
|
+
expandResourceNames: (ids, opts) => _chunkVFLAMMIJcjs.expandResourceNames.call(void 0, client, ids, opts),
|
|
2112
2112
|
relationshipMap: (resourceKey) => relationshipMap(client, resourceKey),
|
|
2113
2113
|
// Issue #11: the served blind-surface inventory (zero wire) + the
|
|
2114
2114
|
// bounded caller-opted reachability sweep (read-only, confirmProbe-
|
|
@@ -2118,7 +2118,7 @@ function operationsHolder(client) {
|
|
|
2118
2118
|
// Issue #12: the served zone-fact create-guidance catalog (zero wire).
|
|
2119
2119
|
createGuidance: (opts) => createGuidance(client, opts),
|
|
2120
2120
|
// Issue #202: ExecuteCommand deep links — pure, zero wire.
|
|
2121
|
-
uiLink: (input) =>
|
|
2121
|
+
uiLink: (input) => _chunkVFLAMMIJcjs.uiLink.call(void 0, client, input),
|
|
2122
2122
|
// Issue #287 (D8): the projection-layer untrusted-content helper — pure,
|
|
2123
2123
|
// zero wire (the registry record's metadata.untrustedFields + the deep
|
|
2124
2124
|
// walker from src/untrusted.ts; an unknown operation refuses).
|
|
@@ -2127,7 +2127,7 @@ function operationsHolder(client) {
|
|
|
2127
2127
|
// entityInformation GETs (the op's own cap refuses over-cap fan-outs
|
|
2128
2128
|
// pre-request; per-resource failures are recorded on the row and
|
|
2129
2129
|
// never abort the call).
|
|
2130
|
-
fieldCatalog: (opts) =>
|
|
2130
|
+
fieldCatalog: (opts) => _chunkVFLAMMIJcjs.fieldCatalog.call(void 0, client, opts),
|
|
2131
2131
|
// Issue #9: the one-call recovery/cleanup op — effect write in the
|
|
2132
2132
|
// registry (the governor's dry-run-first applies to it); the op's own
|
|
2133
2133
|
// confirm gate makes the destructive action deliberate (the governor
|
|
@@ -2137,15 +2137,15 @@ function operationsHolder(client) {
|
|
|
2137
2137
|
}
|
|
2138
2138
|
function resolveHolder(client, record, operation) {
|
|
2139
2139
|
const clientBag = client;
|
|
2140
|
-
let holder = clientBag[
|
|
2140
|
+
let holder = clientBag[_chunkVFLAMMIJcjs.camelKey.call(void 0, record.resource)];
|
|
2141
2141
|
if (typeof holder === "function") {
|
|
2142
|
-
holder = _nullishCoalesce(clientBag[`${
|
|
2142
|
+
holder = _nullishCoalesce(clientBag[`${_chunkVFLAMMIJcjs.camelKey.call(void 0, record.resource)}Resource`], () => ( holder));
|
|
2143
2143
|
}
|
|
2144
2144
|
if (holder === void 0 && record.resource === "operations") {
|
|
2145
2145
|
holder = operationsHolder(client);
|
|
2146
2146
|
}
|
|
2147
2147
|
if (holder === void 0) {
|
|
2148
|
-
throw new (0,
|
|
2148
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2149
2149
|
`invoke: the client exposes no accessor for resource "${record.resource}"`,
|
|
2150
2150
|
{ operation }
|
|
2151
2151
|
);
|
|
@@ -2200,7 +2200,7 @@ function validateFreshSpelling(record, args) {
|
|
|
2200
2200
|
const at = Object.keys(_nullishCoalesce(record.inputSchema, () => ( {}))).indexOf("opts");
|
|
2201
2201
|
const bag = at < 0 ? void 0 : args[at];
|
|
2202
2202
|
if (bag === void 0 || bag === null) return;
|
|
2203
|
-
throw new (0,
|
|
2203
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2204
2204
|
`invoke: "${record.id}" takes no positional options bag \u2014 the fresh spelling is the fresh invoke option (pass { fresh: true } in the invoke options, not as a method argument)`,
|
|
2205
2205
|
{
|
|
2206
2206
|
operation: record.id,
|
|
@@ -2213,7 +2213,7 @@ var PRE_REQUEST_VALIDATORS = [
|
|
|
2213
2213
|
(c) => validateDispatchArgs(c.record, c.args),
|
|
2214
2214
|
(c) => validateParamsBag(c.record, c.args),
|
|
2215
2215
|
(c) => validateFreshSpelling(c.record, c.args),
|
|
2216
|
-
(c) => c.boundedQuery || c.countedQuery ?
|
|
2216
|
+
(c) => c.boundedQuery || c.countedQuery ? _chunkVFLAMMIJcjs.validateQueryFieldNames.call(void 0, c.record, c.holder, c.args) : Promise.resolve(void 0)
|
|
2217
2217
|
];
|
|
2218
2218
|
async function runPreRequestPass(ctx) {
|
|
2219
2219
|
for (const step of PRE_REQUEST_VALIDATORS) await step(ctx);
|
|
@@ -2225,11 +2225,11 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
2225
2225
|
const countedQuery = record.kind === "primitive" && record.operation === "count";
|
|
2226
2226
|
const holder = resolveHolder(client, record, operation);
|
|
2227
2227
|
await runPreRequestPass({ record, operation, args, opts, client, holder, boundedQuery, countedQuery });
|
|
2228
|
-
const labelQuery = boundedQuery &&
|
|
2228
|
+
const labelQuery = boundedQuery && _chunkVFLAMMIJcjs.readNamesOpt.call(void 0, client, _optionalChain([args, 'access', _63 => _63[0], 'optionalAccess', _64 => _64["names"]]), `invoke: "${record.id}" params bag`);
|
|
2229
2229
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
2230
2230
|
const method = holder[methodName];
|
|
2231
2231
|
if (typeof method !== "function") {
|
|
2232
|
-
throw new (0,
|
|
2232
|
+
throw new (0, _chunkVFLAMMIJcjs.AutotaskConfigError)(
|
|
2233
2233
|
`invoke: "${record.resource}.${methodName}" is not a callable method on the client`,
|
|
2234
2234
|
{ operation }
|
|
2235
2235
|
);
|
|
@@ -2238,7 +2238,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
2238
2238
|
const mutationOpts = buildMutationOpts(opts, isWrite);
|
|
2239
2239
|
const callArgs = buildCallArgs(record, args, mutationOpts, isWrite);
|
|
2240
2240
|
if (opts.fresh === true) appendFresh(record, callArgs);
|
|
2241
|
-
if (boundedQuery)
|
|
2241
|
+
if (boundedQuery) _chunkVFLAMMIJcjs.validateWalkBag.call(void 0, _optionalChain([args, 'access', _65 => _65[0], 'optionalAccess', _66 => _66["walk"]]), `invoke: "${record.id}"`, { operation: record.id });
|
|
2242
2242
|
let scopeNote;
|
|
2243
2243
|
if (boundedQuery && _optionalChain([args, 'access', _67 => _67[0], 'optionalAccess', _68 => _68["acknowledgeUnscoped"]]) !== true) {
|
|
2244
2244
|
scopeNote = (await guardUnscopedQueryWalk(holder, record.id, args[0])).note;
|
|
@@ -2246,7 +2246,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
2246
2246
|
const result = await method.apply(holder, callArgs);
|
|
2247
2247
|
if (labelQuery && Array.isArray(_optionalChain([result, 'optionalAccess', _69 => _69.items]))) {
|
|
2248
2248
|
const bounded = result;
|
|
2249
|
-
const labelled = await
|
|
2249
|
+
const labelled = await _chunkVFLAMMIJcjs.labelRows.call(void 0, client, record.resource, bounded.items);
|
|
2250
2250
|
return { ...bounded, items: labelled.rows, ...labelled.names !== void 0 ? { names: labelled.names } : {}, ...scopeNote !== void 0 ? { scopeNote } : {} };
|
|
2251
2251
|
}
|
|
2252
2252
|
const finished = Buffer.isBuffer(result) ? bufferResult(result) : result;
|
|
@@ -2316,4 +2316,4 @@ async function invokeDelete(client, operation, args = [], opts = {}) {
|
|
|
2316
2316
|
|
|
2317
2317
|
|
|
2318
2318
|
|
|
2319
|
-
exports.AGGREGATE_DATE_BUCKETS = AGGREGATE_DATE_BUCKETS; exports.AGGREGATE_DEFAULT_LIMIT = AGGREGATE_DEFAULT_LIMIT; exports.AGGREGATE_DEFAULT_TOP = AGGREGATE_DEFAULT_TOP; exports.AGGREGATE_TOP_MAX = AGGREGATE_TOP_MAX; exports.BLIND_SURFACE_KINDS = BLIND_SURFACE_KINDS; exports.CREATE_BLOCKER_KINDS = CREATE_BLOCKER_KINDS; exports.EXPAND_RESOURCE_NAMES_MAX_IDS =
|
|
2319
|
+
exports.AGGREGATE_DATE_BUCKETS = AGGREGATE_DATE_BUCKETS; exports.AGGREGATE_DEFAULT_LIMIT = AGGREGATE_DEFAULT_LIMIT; exports.AGGREGATE_DEFAULT_TOP = AGGREGATE_DEFAULT_TOP; exports.AGGREGATE_TOP_MAX = AGGREGATE_TOP_MAX; exports.BLIND_SURFACE_KINDS = BLIND_SURFACE_KINDS; exports.CREATE_BLOCKER_KINDS = CREATE_BLOCKER_KINDS; exports.EXPAND_RESOURCE_NAMES_MAX_IDS = _chunkVFLAMMIJcjs.EXPAND_RESOURCE_NAMES_MAX_IDS; exports.FETCH_BY_IDS_CHUNK_SIZE = _chunkVFLAMMIJcjs.FETCH_BY_IDS_CHUNK_SIZE; exports.FETCH_BY_IDS_MAX_ITEMS = _chunkVFLAMMIJcjs.FETCH_BY_IDS_MAX_ITEMS; exports.FETCH_MANY_MAX_ITEMS = _chunkVFLAMMIJcjs.FETCH_MANY_MAX_ITEMS; exports.FIELD_CACHE_KINDS = _chunkVFLAMMIJcjs.FIELD_CACHE_KINDS; exports.FIELD_CATALOG_HONESTY_NOTE = _chunkVFLAMMIJcjs.FIELD_CATALOG_HONESTY_NOTE; exports.INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS; exports.MAX_FIELD_CATALOG_WIRE = _chunkVFLAMMIJcjs.MAX_FIELD_CATALOG_WIRE; exports.MIN_FIELD_CATALOG_MAX_BYTES = _chunkVFLAMMIJcjs.MIN_FIELD_CATALOG_MAX_BYTES; exports.PARAMS_BAG_KEYS = PARAMS_BAG_KEYS; exports.PICKLIST_VALUE_NOT_SERVED_NOTE = _chunkVFLAMMIJcjs.PICKLIST_VALUE_NOT_SERVED_NOTE; exports.RECOVERY_CONFIRM = RECOVERY_CONFIRM; exports.RECOVERY_DEFAULT_LIMIT = RECOVERY_DEFAULT_LIMIT; exports.RECOVERY_MAX_LIMIT = RECOVERY_MAX_LIMIT; exports.UI_LINK_ENTITIES = _chunkVFLAMMIJcjs.UI_LINK_ENTITIES; exports.WORKFLOW_RESOURCES = _chunkVFLAMMIJcjs.WORKFLOW_RESOURCES; exports.aggregate = aggregate; exports.blindSurfaces = blindSurfaces; exports.buildUiLink = _chunkVFLAMMIJcjs.buildUiLink; exports.createGuidance = createGuidance; exports.dateBucketLabel = dateBucketLabel; exports.effectiveRequiredFields = _chunkVFLAMMIJcjs.effectiveRequiredFields; exports.expandResourceNames = _chunkVFLAMMIJcjs.expandResourceNames; exports.fetchByIds = _chunkVFLAMMIJcjs.fetchByIds; exports.fetchMany = _chunkVFLAMMIJcjs.fetchMany; exports.fieldCatalog = _chunkVFLAMMIJcjs.fieldCatalog; exports.foldFlattenedOpts = foldFlattenedOpts; exports.invoke = invoke; exports.invokeDelete = invokeDelete; exports.invokeRead = invokeRead; exports.invokeWrite = invokeWrite; exports.needsConfirmation = needsConfirmation; exports.probeReachability = probeReachability; exports.recovery = recovery; exports.relationshipMap = relationshipMap; exports.resolveAny = resolveAny; exports.revenueRollup = revenueRollup; exports.sanitiseResult = sanitiseResult; exports.searchAcrossResources = searchAcrossResources; exports.uiLink = _chunkVFLAMMIJcjs.uiLink; exports.unknownKeysRefusal = unknownKeysRefusal; exports.validateDispatchArgs = validateDispatchArgs; exports.validateFetchManyItems = _chunkVFLAMMIJcjs.validateFetchManyItems; exports.validateInvokeOptions = validateInvokeOptions; exports.validateParamsBag = validateParamsBag;
|