node-autotask 0.8.3 → 0.10.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/ARCHITECTURE.md +13 -10
- package/MCP_TOOL_CATALOG.json +733 -251
- package/MCP_TOOL_MANIFEST.md +162 -133
- package/MCP_TOOL_OVERRIDES.json +2 -2
- package/N8N_MCP_MANIFEST.json +88 -25
- package/N8N_MCP_MANIFEST.md +26 -24
- package/README.md +12 -4
- package/capabilities.json +12503 -9316
- package/dist/capabilities.cjs +2 -3
- package/dist/capabilities.js +1 -2
- package/dist/{chunk-4WJCXIY2.js → chunk-3VB6N44U.js} +1141 -2977
- package/dist/{chunk-32AKZMY4.js → chunk-6KFP5HV3.js} +12502 -9316
- package/dist/chunk-DMMMWO6A.js +0 -0
- package/dist/chunk-FLB2X6O5.cjs +1 -0
- package/dist/{chunk-GYI4ZQID.js → chunk-HWC2WPX2.js} +4781 -89
- package/dist/chunk-IDPB4N2Q.cjs +1 -0
- package/dist/{chunk-F6YSQRZV.js → chunk-NVJ2PTN3.js} +7 -7
- package/dist/{chunk-5UGSQLLO.cjs → chunk-QUM74WLQ.cjs} +136 -136
- package/dist/{chunk-LAKEIYET.cjs → chunk-S7VMY5KN.cjs} +1468 -3304
- package/dist/chunk-UPQIUWOS.js +0 -0
- package/dist/{chunk-KNTUX3RR.cjs → chunk-WTVD2JZN.cjs} +12502 -9316
- package/dist/{chunk-V3XPLTIR.cjs → chunk-WTVLHMZA.cjs} +4784 -92
- package/dist/{index-B6JeThrY.d.ts → index-BOyh7S65.d.cts} +870 -79
- package/dist/{index-B0I2bGtx.d.cts → index-DGgMD8aq.d.ts} +870 -79
- package/dist/{index-DOCRp_83.d.cts → index-cQ6CRexR.d.cts} +158 -90
- package/dist/{index-DOCRp_83.d.ts → index-cQ6CRexR.d.ts} +158 -90
- package/dist/index.cjs +37 -22
- package/dist/index.d.cts +46 -5
- package/dist/index.d.ts +46 -5
- package/dist/index.js +48 -33
- package/dist/operations/index.cjs +480 -359
- package/dist/operations/index.d.cts +195 -16
- package/dist/operations/index.d.ts +195 -16
- package/dist/operations/index.js +370 -249
- package/dist/pool.cjs +36 -12
- package/dist/pool.d.cts +2 -3
- package/dist/pool.d.ts +2 -3
- package/dist/pool.js +33 -9
- package/dist/resources/index.cjs +5 -6
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +4 -5
- package/dist/types/index.cjs +1 -2
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -2
- package/dist/untrusted.cjs +0 -1
- package/dist/untrusted.js +0 -1
- package/docs/API.md +693 -48
- package/docs/N8N-ADAPTER.md +4 -4
- package/examples/basic.ts +1 -1
- package/package.json +5 -3
- package/dist/capabilities.cjs.map +0 -1
- package/dist/capabilities.js.map +0 -1
- package/dist/chunk-32AKZMY4.js.map +0 -1
- package/dist/chunk-4WJCXIY2.js.map +0 -1
- package/dist/chunk-5UGSQLLO.cjs.map +0 -1
- package/dist/chunk-CXM35TEC.cjs +0 -1
- package/dist/chunk-CXM35TEC.cjs.map +0 -1
- package/dist/chunk-F6YSQRZV.js.map +0 -1
- package/dist/chunk-GIVD2CQ3.js +0 -1
- package/dist/chunk-GIVD2CQ3.js.map +0 -1
- package/dist/chunk-GYI4ZQID.js.map +0 -1
- package/dist/chunk-KNTUX3RR.cjs.map +0 -1
- package/dist/chunk-LAKEIYET.cjs.map +0 -1
- package/dist/chunk-MHBMSBTA.js +0 -1
- package/dist/chunk-MHBMSBTA.js.map +0 -1
- package/dist/chunk-NZUFSSIZ.cjs +0 -1
- package/dist/chunk-NZUFSSIZ.cjs.map +0 -1
- package/dist/chunk-V3XPLTIR.cjs.map +0 -1
- package/dist/client-DHmr0Oyx.d.ts +0 -203
- package/dist/client-Q6NoqinP.d.cts +0 -203
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/operations/index.cjs.map +0 -1
- package/dist/operations/index.js.map +0 -1
- package/dist/pool.cjs.map +0 -1
- package/dist/pool.js.map +0 -1
- package/dist/resources/index.cjs.map +0 -1
- package/dist/resources/index.js.map +0 -1
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/untrusted.cjs.map +0 -1
- package/dist/untrusted.js.map +0 -1
|
@@ -19,35 +19,37 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var _chunkV3XPLTIRcjs = require('../chunk-V3XPLTIR.cjs');
|
|
23
22
|
|
|
24
23
|
|
|
25
|
-
var _chunkKNTUX3RRcjs = require('../chunk-KNTUX3RR.cjs');
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunkWTVLHMZAcjs = require('../chunk-WTVLHMZA.cjs');
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var _chunkWTVD2JZNcjs = require('../chunk-WTVD2JZN.cjs');
|
|
35
37
|
|
|
36
38
|
// src/operations/searchAcrossResources.ts
|
|
37
39
|
var DEFAULT_LIMIT = 25;
|
|
38
40
|
function resourceFor(client, key) {
|
|
39
|
-
return client[
|
|
41
|
+
return client[_chunkWTVLHMZAcjs.camelKey.call(void 0, key)];
|
|
40
42
|
}
|
|
41
43
|
async function searchAcrossResources(client, query, opts = {}) {
|
|
42
44
|
const text = query.trim();
|
|
43
45
|
if (text === "") {
|
|
44
|
-
throw new (0,
|
|
46
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("searchAcrossResources: query must be a non-empty string");
|
|
45
47
|
}
|
|
46
|
-
const keys = _nullishCoalesce(opts.resources, () => ( WORKFLOW_RESOURCES));
|
|
48
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkWTVLHMZAcjs.WORKFLOW_RESOURCES));
|
|
47
49
|
if (keys.length === 0) {
|
|
48
|
-
throw new (0,
|
|
50
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("searchAcrossResources: no resources requested");
|
|
49
51
|
}
|
|
50
|
-
const limit =
|
|
52
|
+
const limit = _chunkWTVLHMZAcjs.clampPageSize.call(void 0, _nullishCoalesce(opts.limit, () => ( DEFAULT_LIMIT)));
|
|
51
53
|
const results = [];
|
|
52
54
|
const skipped = [];
|
|
53
55
|
for (const key of keys) {
|
|
@@ -65,7 +67,7 @@ async function searchAcrossResources(client, query, opts = {}) {
|
|
|
65
67
|
|
|
66
68
|
// src/operations/resolveAny.ts
|
|
67
69
|
function resourceFor2(client, key) {
|
|
68
|
-
return client[
|
|
70
|
+
return client[_chunkWTVLHMZAcjs.camelKey.call(void 0, key)];
|
|
69
71
|
}
|
|
70
72
|
var FAULT_CATEGORIES = /* @__PURE__ */ new Set(["auth", "rate_limit", "server", "network", "timeout", "policy"]);
|
|
71
73
|
function missCost(identifier) {
|
|
@@ -74,13 +76,13 @@ function missCost(identifier) {
|
|
|
74
76
|
}
|
|
75
77
|
async function resolveAny(client, identifier, opts = {}) {
|
|
76
78
|
if (typeof identifier === "number") {
|
|
77
|
-
|
|
79
|
+
_chunkWTVLHMZAcjs.parseIdentifier.call(void 0, identifier, "identifier");
|
|
78
80
|
} else if (identifier.trim() === "") {
|
|
79
|
-
throw new (0,
|
|
81
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("resolveAny: identifier must be non-empty");
|
|
80
82
|
}
|
|
81
|
-
const keys = _nullishCoalesce(opts.resources, () => ( WORKFLOW_RESOURCES));
|
|
83
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkWTVLHMZAcjs.WORKFLOW_RESOURCES));
|
|
82
84
|
if (keys.length === 0) {
|
|
83
|
-
throw new (0,
|
|
85
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("resolveAny: no resources requested");
|
|
84
86
|
}
|
|
85
87
|
const results = [];
|
|
86
88
|
for (const key of keys) {
|
|
@@ -110,9 +112,9 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
110
112
|
} catch (err) {
|
|
111
113
|
let code;
|
|
112
114
|
let candidates = [];
|
|
113
|
-
if (err instanceof
|
|
115
|
+
if (err instanceof _chunkWTVLHMZAcjs.AutotaskConfigError) {
|
|
114
116
|
code = "CONFIG_ERROR";
|
|
115
|
-
} else if (
|
|
117
|
+
} else if (_chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err)) {
|
|
116
118
|
if (FAULT_CATEGORIES.has(err.category)) throw err;
|
|
117
119
|
code = err.code;
|
|
118
120
|
if (code === "RESOLUTION_AMBIGUOUS" && err.resourceIds !== void 0) {
|
|
@@ -259,23 +261,23 @@ var MODEL_FIELD_SETS = {
|
|
|
259
261
|
|
|
260
262
|
// src/operations/fetchMany.ts
|
|
261
263
|
var FETCH_MANY_MAX_ITEMS = 20;
|
|
262
|
-
function validateFetchManyItems(items, cap) {
|
|
264
|
+
function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETCH_MANY_MAX_ITEMS = ${FETCH_MANY_MAX_ITEMS}`, validation) {
|
|
263
265
|
if (!Array.isArray(items)) {
|
|
264
|
-
throw new (0,
|
|
265
|
-
|
|
266
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
267
|
+
`${opName}: items must be the items ARRAY \u2014 one positional arg, [{ resource: string, id: number, fields?: string[] }] (got ${Array.isArray(items) ? "an array" : typeof items})`,
|
|
266
268
|
{
|
|
267
269
|
suggestedAction: 'Pass args = [[{ resource: "tickets", id: 123 }, { resource: "projects", id: 456 }]] \u2014 the items array is the single positional argument.'
|
|
268
270
|
}
|
|
269
271
|
);
|
|
270
272
|
}
|
|
271
273
|
if (items.length === 0) {
|
|
272
|
-
throw new (0,
|
|
274
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`${opName}: items must not be empty (a zero-item batch is a shape error, not a no-op)`, {
|
|
273
275
|
suggestedAction: "Pass at least one { resource, id } item \u2014 or use the resource's query op for a filtered read."
|
|
274
276
|
});
|
|
275
277
|
}
|
|
276
278
|
if (items.length > cap) {
|
|
277
|
-
throw new (0,
|
|
278
|
-
|
|
279
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
280
|
+
`${opName}: ${items.length} items over the ${cap}-item cap (${capRef}) \u2014 zero items were fetched (pre-request)`,
|
|
279
281
|
{
|
|
280
282
|
suggestedAction: `Split the batch into groups of <= ${cap} items \u2014 or, for more than ${cap} records / a filtered set, use the resource's bounded query op (<resource>.query).`
|
|
281
283
|
}
|
|
@@ -302,15 +304,15 @@ function validateFetchManyItems(items, cap) {
|
|
|
302
304
|
);
|
|
303
305
|
continue;
|
|
304
306
|
}
|
|
305
|
-
const rel =
|
|
307
|
+
const rel = _chunkWTVLHMZAcjs.RELATIONSHIP_MAP[resourceKey];
|
|
306
308
|
if (rel !== void 0 && rel.parentScoped) {
|
|
307
309
|
problems.push(
|
|
308
|
-
`${at}.resource: "${resourceKey}" is a parent-scoped child \u2014 its get needs (parentId, id); fetchMany takes single numeric ids of TOP-LEVEL records (scoped reads: client.${
|
|
310
|
+
`${at}.resource: "${resourceKey}" is a parent-scoped child \u2014 its get needs (parentId, id); fetchMany takes single numeric ids of TOP-LEVEL records (scoped reads: client.${_chunkWTVLHMZAcjs.camelKey.call(void 0, resourceKey)}.get(parentId, id))`
|
|
309
311
|
);
|
|
310
312
|
continue;
|
|
311
313
|
}
|
|
312
314
|
try {
|
|
313
|
-
|
|
315
|
+
_chunkWTVLHMZAcjs.parseIdentifier.call(void 0, item.id, `${at}.id`);
|
|
314
316
|
} catch (e2) {
|
|
315
317
|
if (typeof item.id === "string") {
|
|
316
318
|
problems.push(
|
|
@@ -327,21 +329,24 @@ function validateFetchManyItems(items, cap) {
|
|
|
327
329
|
}
|
|
328
330
|
if (item.fields !== void 0) {
|
|
329
331
|
if (!Array.isArray(item.fields) || item.fields.some((f) => typeof f !== "string")) {
|
|
330
|
-
problems.push(`${at}.fields: must be an array of exact vendor field names (discover them via
|
|
332
|
+
problems.push(`${at}.fields: must be an array of exact vendor field names (discover them via operations.fieldCatalog)`);
|
|
331
333
|
continue;
|
|
332
334
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
if (_optionalChain([validation, 'optionalAccess', _ => _.fieldCheck]) !== false) {
|
|
336
|
+
const authoritative = _nullishCoalesce(_optionalChain([validation, 'optionalAccess', _2 => _2.fieldSetsByResource, 'optionalAccess', _3 => _3.get, 'call', _4 => _4(resourceKey)]), () => ( fields));
|
|
337
|
+
for (const f of item.fields) {
|
|
338
|
+
if (!authoritative.includes(f)) {
|
|
339
|
+
problems.push(
|
|
340
|
+
`${at}.fields: "${f}" is not a field of ${resourceKey} \u2014 a hallucinated field is a shape error, not a silent projection-miss (exact vendor field names via operations.fieldCatalog)`
|
|
341
|
+
);
|
|
342
|
+
}
|
|
338
343
|
}
|
|
339
344
|
}
|
|
340
345
|
}
|
|
341
346
|
}
|
|
342
347
|
if (problems.length > 0) {
|
|
343
|
-
throw new (0,
|
|
344
|
-
|
|
348
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
349
|
+
`${opName}: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
345
350
|
- ` + problems.join("\n- "),
|
|
346
351
|
{ suggestedAction: "Fix every item above and call again \u2014 validation covers the whole batch up-front (one round, zero wire)." }
|
|
347
352
|
);
|
|
@@ -357,18 +362,48 @@ function project(value, fields) {
|
|
|
357
362
|
async function fetchMany(client, items, opts = {}) {
|
|
358
363
|
if (opts.maxItems !== void 0) {
|
|
359
364
|
if (!Number.isInteger(opts.maxItems) || opts.maxItems < 1) {
|
|
360
|
-
throw new (0,
|
|
365
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchMany: maxItems must be an integer >= 1 (got ${String(opts.maxItems)})`);
|
|
361
366
|
}
|
|
362
367
|
}
|
|
368
|
+
if (opts.liveFields !== void 0 && typeof opts.liveFields !== "boolean") {
|
|
369
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchMany: liveFields must be a boolean (got ${typeof opts.liveFields})`);
|
|
370
|
+
}
|
|
363
371
|
const cap = Math.min(FETCH_MANY_MAX_ITEMS, _nullishCoalesce(opts.maxItems, () => ( FETCH_MANY_MAX_ITEMS)));
|
|
364
|
-
|
|
372
|
+
if (opts.liveFields === true) {
|
|
373
|
+
validateFetchManyItems(items, cap, void 0, void 0, { fieldCheck: false });
|
|
374
|
+
const liveFieldSets = /* @__PURE__ */ new Map();
|
|
375
|
+
for (const item of items) {
|
|
376
|
+
const key = item.resource;
|
|
377
|
+
if (liveFieldSets.has(key)) continue;
|
|
378
|
+
const holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, key)];
|
|
379
|
+
if (holder === void 0) {
|
|
380
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchMany: the client exposes no accessor for resource "${key}"`, {
|
|
381
|
+
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
const rows = await holder.getFieldInfo();
|
|
386
|
+
const names = [];
|
|
387
|
+
for (const row of rows) {
|
|
388
|
+
if (typeof row.name === "string") names.push(row.name);
|
|
389
|
+
}
|
|
390
|
+
liveFieldSets.set(key, names.length > 0 ? names : null);
|
|
391
|
+
} catch (err) {
|
|
392
|
+
if (!_chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
393
|
+
liveFieldSets.set(key, null);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
validateFetchManyItems(items, cap, void 0, void 0, { fieldSetsByResource: liveFieldSets });
|
|
397
|
+
} else {
|
|
398
|
+
validateFetchManyItems(items, cap);
|
|
399
|
+
}
|
|
365
400
|
const results = [];
|
|
366
401
|
for (const item of items) {
|
|
367
402
|
const key = item.resource;
|
|
368
|
-
const id =
|
|
369
|
-
const holder = client[
|
|
403
|
+
const id = _chunkWTVLHMZAcjs.parseIdentifier.call(void 0, item.id, `items[${results.length}].id`);
|
|
404
|
+
const holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, key)];
|
|
370
405
|
if (holder === void 0) {
|
|
371
|
-
throw new (0,
|
|
406
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchMany: the client exposes no accessor for resource "${key}"`, {
|
|
372
407
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
373
408
|
});
|
|
374
409
|
}
|
|
@@ -376,9 +411,9 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
376
411
|
const value = await holder.get(id);
|
|
377
412
|
results.push({ resource: key, id, found: true, value: item.fields !== void 0 ? project(value, item.fields) : value });
|
|
378
413
|
} catch (err) {
|
|
379
|
-
if (err instanceof
|
|
414
|
+
if (err instanceof _chunkWTVLHMZAcjs.NotFoundError) {
|
|
380
415
|
results.push({ resource: key, id, found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
381
|
-
} else if (
|
|
416
|
+
} else if (_chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
382
417
|
const e = { code: err.code, message: err.message };
|
|
383
418
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
384
419
|
results.push({ resource: key, id, found: false, value: null, error: e });
|
|
@@ -391,24 +426,304 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
391
426
|
return { results, ok, failed: results.length - ok };
|
|
392
427
|
}
|
|
393
428
|
|
|
429
|
+
// src/operations/aggregate.ts
|
|
430
|
+
var AGGREGATE_TOP_MAX = 100;
|
|
431
|
+
var AGGREGATE_DEFAULT_TOP = 25;
|
|
432
|
+
var AGGREGATE_DEFAULT_LIMIT = _chunkWTVLHMZAcjs.BOUNDED_QUERY_MAX_LIMIT;
|
|
433
|
+
var QUERY_RESOURCE_KEYS = (() => {
|
|
434
|
+
const s = /* @__PURE__ */ new Set();
|
|
435
|
+
for (const rec of _chunkWTVD2JZNcjs.CAPABILITIES) if (rec.operation === "query") s.add(rec.resource);
|
|
436
|
+
return s;
|
|
437
|
+
})();
|
|
438
|
+
var AGGREGATE_OPT_KEYS = ["groupBy", "sum", "top", "limit"];
|
|
439
|
+
var OP_RE = /^([a-z0-9_]+)\.query$/;
|
|
440
|
+
function num(v) {
|
|
441
|
+
return typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
442
|
+
}
|
|
443
|
+
function validateAggregate(operation, filter, opts) {
|
|
444
|
+
const problems = [];
|
|
445
|
+
let resourceKey;
|
|
446
|
+
if (typeof operation !== "string" || !OP_RE.test(operation)) {
|
|
447
|
+
problems.push(
|
|
448
|
+
`operation must be exactly "<planResourceKey>.query" (the resource's bounded query op \u2014 e.g. "billing_items.query"); a special op, a ".count" row, or any other verb is not an aggregate surface \u2014 see autotask_catalog for the exact plan keys`
|
|
449
|
+
);
|
|
450
|
+
} else {
|
|
451
|
+
const key = OP_RE.exec(operation)[1];
|
|
452
|
+
resourceKey = key;
|
|
453
|
+
if (!QUERY_RESOURCE_KEYS.has(key)) {
|
|
454
|
+
problems.push(
|
|
455
|
+
`operation "${operation}": "${key}" has no query row in the capability registry (116 query surfaces) \u2014 see autotask_catalog for the exact plan keys`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
let conditions = [];
|
|
460
|
+
if (filter === void 0 || filter === null) {
|
|
461
|
+
conditions = [];
|
|
462
|
+
} else {
|
|
463
|
+
const conds = Array.isArray(filter) ? filter : filter.filter;
|
|
464
|
+
if (!Array.isArray(conds)) {
|
|
465
|
+
problems.push("filter must be the query-bag filter (a conditions array, or { filter: [...] })");
|
|
466
|
+
} else if (conds.length === 0) {
|
|
467
|
+
conditions = [];
|
|
468
|
+
} else {
|
|
469
|
+
try {
|
|
470
|
+
conditions = _chunkWTVLHMZAcjs.buildFilter.call(void 0, conds).filter;
|
|
471
|
+
} catch (err) {
|
|
472
|
+
problems.push(err instanceof _chunkWTVLHMZAcjs.AutotaskConfigError ? err.message : `filter must be the query-bag filter (13 operators; caps 500 OR-conditions / 1 UDF / 8000 chars); ${String(err)}`);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
477
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
478
|
+
`aggregate: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
479
|
+
{ operation: "operations.aggregate" }
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
483
|
+
if (!AGGREGATE_OPT_KEYS.includes(key)) {
|
|
484
|
+
problems.push(`unknown opts key "${key}" \u2014 the bag is closed: ${AGGREGATE_OPT_KEYS.join(", ")}`);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const fieldSets = resourceKey !== void 0 ? MODEL_FIELD_SETS[resourceKey] : void 0;
|
|
488
|
+
const checkFields = (name, fields) => {
|
|
489
|
+
if (fields === void 0) return [];
|
|
490
|
+
if (!Array.isArray(fields) || fields.length === 0 || fields.some((f) => typeof f !== "string" || f.trim() === "")) {
|
|
491
|
+
problems.push(`${name} must be a non-empty array of exact vendor field names (discover them via operations.fieldCatalog)`);
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
494
|
+
const out = [];
|
|
495
|
+
for (const f of fields) {
|
|
496
|
+
if (fieldSets === void 0 || !fieldSets.includes(f)) {
|
|
497
|
+
problems.push(`${name}: "${f}" is not a field of ${resourceKey} \u2014 a hallucinated field is a shape error, not a silent fold-miss (exact vendor field names via operations.fieldCatalog)`);
|
|
498
|
+
} else {
|
|
499
|
+
out.push(f);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return out;
|
|
503
|
+
};
|
|
504
|
+
const groupBy = checkFields("groupBy", opts.groupBy);
|
|
505
|
+
const sum = checkFields("sum", opts.sum);
|
|
506
|
+
let top = AGGREGATE_DEFAULT_TOP;
|
|
507
|
+
if (opts.top !== void 0) {
|
|
508
|
+
if (!Number.isInteger(opts.top)) {
|
|
509
|
+
problems.push(`top must be an integer (got ${String(opts.top)})`);
|
|
510
|
+
} else {
|
|
511
|
+
top = Math.min(Math.max(opts.top, 1), AGGREGATE_TOP_MAX);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
let limit = AGGREGATE_DEFAULT_LIMIT;
|
|
515
|
+
if (opts.limit !== void 0) {
|
|
516
|
+
if (!Number.isInteger(opts.limit)) {
|
|
517
|
+
problems.push(`limit must be an integer (got ${String(opts.limit)})`);
|
|
518
|
+
} else {
|
|
519
|
+
limit = Math.min(Math.max(opts.limit, 1), _chunkWTVLHMZAcjs.BOUNDED_QUERY_MAX_LIMIT);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (problems.length > 0) {
|
|
523
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
524
|
+
`aggregate: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
525
|
+
- ` + problems.join("\n- "),
|
|
526
|
+
{ operation: "operations.aggregate" }
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
return { resourceKey, conditions, groupBy, sum, top, limit };
|
|
530
|
+
}
|
|
531
|
+
async function aggregate(client, operation, filter, opts = {}) {
|
|
532
|
+
const v = validateAggregate(operation, filter, opts);
|
|
533
|
+
const holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, v.resourceKey)];
|
|
534
|
+
if (holder === void 0) {
|
|
535
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`aggregate: the client exposes no accessor for resource "${v.resourceKey}"`, {
|
|
536
|
+
operation: "operations.aggregate",
|
|
537
|
+
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
const wireFilter = v.conditions.length === 0 ? void 0 : v.conditions;
|
|
541
|
+
if (v.groupBy.length === 0 && v.sum.length === 0) {
|
|
542
|
+
const raw = await holder.count({ filter: wireFilter });
|
|
543
|
+
const sentinel = typeof raw === "object" && raw !== null && "count" in raw ? raw : { count: raw };
|
|
544
|
+
const result2 = { mode: "count", count: sentinel.count, blind: sentinel.blindSurface !== void 0 };
|
|
545
|
+
if (sentinel.blindSurface !== void 0) result2.blindSurface = sentinel.blindSurface;
|
|
546
|
+
if (sentinel.emptyReason !== void 0) result2.emptyReason = sentinel.emptyReason;
|
|
547
|
+
return result2;
|
|
548
|
+
}
|
|
549
|
+
const res = await holder.queryBounded({ filter: wireFilter, limit: v.limit });
|
|
550
|
+
const groups = /* @__PURE__ */ new Map();
|
|
551
|
+
for (const item of res.items) {
|
|
552
|
+
const key = {};
|
|
553
|
+
const values = [];
|
|
554
|
+
for (const f of v.groupBy) {
|
|
555
|
+
const value = item[f] === void 0 ? null : item[f];
|
|
556
|
+
key[f] = value;
|
|
557
|
+
values.push(value);
|
|
558
|
+
}
|
|
559
|
+
const keyOrder = JSON.stringify(values);
|
|
560
|
+
let g = groups.get(keyOrder);
|
|
561
|
+
if (g === void 0) {
|
|
562
|
+
g = { key, keyOrder, count: 0, ...v.sum.length > 0 ? { sums: {} } : {} };
|
|
563
|
+
groups.set(keyOrder, g);
|
|
564
|
+
}
|
|
565
|
+
g.count += 1;
|
|
566
|
+
if (g.sums !== void 0) {
|
|
567
|
+
for (const f of v.sum) g.sums[f] = (_nullishCoalesce(g.sums[f], () => ( 0))) + num(item[f]);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const sorted = [...groups.values()].sort((a, b) => b.count - a.count || (a.keyOrder < b.keyOrder ? -1 : a.keyOrder > b.keyOrder ? 1 : 0));
|
|
571
|
+
const top = sorted.slice(0, v.top);
|
|
572
|
+
const result = {
|
|
573
|
+
mode: v.groupBy.length > 0 ? "group" : "sum",
|
|
574
|
+
groups: top.map((g) => ({ key: g.key, count: g.count, ...g.sums !== void 0 ? { sums: g.sums } : {} })),
|
|
575
|
+
totalGroups: sorted.length,
|
|
576
|
+
groupsTruncated: sorted.length > top.length,
|
|
577
|
+
totalScanned: res.fetched,
|
|
578
|
+
hasMore: res.hasMore
|
|
579
|
+
};
|
|
580
|
+
if (res.blindSurface !== void 0) result.blindSurface = res.blindSurface;
|
|
581
|
+
if (res.emptyReason !== void 0) result.emptyReason = res.emptyReason;
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/operations/fetchByIds.ts
|
|
586
|
+
var FETCH_BY_IDS_MAX_ITEMS = 500;
|
|
587
|
+
var FETCH_BY_IDS_CHUNK_SIZE = 250;
|
|
588
|
+
function project2(value, fields) {
|
|
589
|
+
const out = {};
|
|
590
|
+
for (const f of fields) {
|
|
591
|
+
if (f in value) out[f] = value[f];
|
|
592
|
+
}
|
|
593
|
+
return out;
|
|
594
|
+
}
|
|
595
|
+
function resourcePathOf(key, holder) {
|
|
596
|
+
const path = _optionalChain([holder, 'optionalAccess', _5 => _5.resourcePath]);
|
|
597
|
+
if (typeof path !== "string" || path === "") {
|
|
598
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchByIds: the client exposes no ${key} resource path (registry drift)`, {
|
|
599
|
+
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
return path;
|
|
603
|
+
}
|
|
604
|
+
async function fetchByIds(client, items, opts = {}) {
|
|
605
|
+
if (opts.maxItems !== void 0) {
|
|
606
|
+
if (!Number.isInteger(opts.maxItems) || opts.maxItems < 1) {
|
|
607
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchByIds: maxItems must be an integer >= 1 (got ${String(opts.maxItems)})`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const cap = Math.min(FETCH_BY_IDS_MAX_ITEMS, _nullishCoalesce(opts.maxItems, () => ( FETCH_BY_IDS_MAX_ITEMS)));
|
|
611
|
+
validateFetchManyItems(items, cap, "fetchByIds", `FETCH_BY_IDS_MAX_ITEMS = ${FETCH_BY_IDS_MAX_ITEMS}`);
|
|
612
|
+
const groups = /* @__PURE__ */ new Map();
|
|
613
|
+
const canonical = [];
|
|
614
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
615
|
+
const item = items[i];
|
|
616
|
+
const id = _chunkWTVLHMZAcjs.parseIdentifier.call(void 0, item.id, `items[${i}].id`);
|
|
617
|
+
canonical[i] = id;
|
|
618
|
+
const g = _nullishCoalesce(groups.get(item.resource), () => ( { indices: [], fields: /* @__PURE__ */ new Set(), anyFields: false }));
|
|
619
|
+
g.indices.push(i);
|
|
620
|
+
if (item.fields !== void 0) {
|
|
621
|
+
g.anyFields = true;
|
|
622
|
+
for (const f of item.fields) g.fields.add(f);
|
|
623
|
+
}
|
|
624
|
+
groups.set(item.resource, g);
|
|
625
|
+
}
|
|
626
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
627
|
+
for (const [key, group] of groups) {
|
|
628
|
+
const holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, key)];
|
|
629
|
+
if (holder === void 0) {
|
|
630
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`fetchByIds: the client exposes no accessor for resource "${key}"`, {
|
|
631
|
+
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
const resourcePath = resourcePathOf(key, holder);
|
|
635
|
+
const unique = [];
|
|
636
|
+
const seen = /* @__PURE__ */ new Set();
|
|
637
|
+
for (const i of group.indices) {
|
|
638
|
+
const k = String(canonical[i]);
|
|
639
|
+
if (!seen.has(k)) {
|
|
640
|
+
seen.add(k);
|
|
641
|
+
unique.push(canonical[i]);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
const includeFields = group.anyFields && group.indices.every((i) => items[i].fields !== void 0) ? [...group.fields] : void 0;
|
|
645
|
+
const kOf = (id) => `${key}:${String(id)}`;
|
|
646
|
+
for (let c = 0; c < unique.length; c += FETCH_BY_IDS_CHUNK_SIZE) {
|
|
647
|
+
const chunk = unique.slice(c, c + FETCH_BY_IDS_CHUNK_SIZE);
|
|
648
|
+
const chunkKeys = new Set(chunk.map((id) => String(id)));
|
|
649
|
+
try {
|
|
650
|
+
const req = _chunkWTVLHMZAcjs.buildQueryRequest.call(void 0, client.http.baseUrl, resourcePath, {
|
|
651
|
+
filter: [{ field: "id", op: "in", value: chunk }],
|
|
652
|
+
maxRecords: FETCH_BY_IDS_CHUNK_SIZE,
|
|
653
|
+
includeFields
|
|
654
|
+
});
|
|
655
|
+
const res = await client.http.request({ ...req, operation: `${key}.fetchByIds` });
|
|
656
|
+
const { items: rows } = _chunkWTVLHMZAcjs.unwrapItems.call(void 0, res, `${key}.fetchByIds`);
|
|
657
|
+
for (const row of rows) {
|
|
658
|
+
const k = String(row.id);
|
|
659
|
+
if (!chunkKeys.has(k)) continue;
|
|
660
|
+
const q = kOf(k);
|
|
661
|
+
if (!byKey.has(q)) byKey.set(q, { found: true, value: row });
|
|
662
|
+
}
|
|
663
|
+
} catch (err) {
|
|
664
|
+
if (_chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
665
|
+
const e = { code: err.code, message: err.message };
|
|
666
|
+
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
667
|
+
for (const u of chunk) {
|
|
668
|
+
const q = kOf(u);
|
|
669
|
+
if (!byKey.has(q)) byKey.set(q, { found: false, value: null, error: e });
|
|
670
|
+
}
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
throw err;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
for (const id of unique) {
|
|
677
|
+
const k = kOf(id);
|
|
678
|
+
if (byKey.has(k)) continue;
|
|
679
|
+
try {
|
|
680
|
+
const value = await holder.get(id);
|
|
681
|
+
byKey.set(k, { found: true, value });
|
|
682
|
+
} catch (err) {
|
|
683
|
+
if (err instanceof _chunkWTVLHMZAcjs.NotFoundError) {
|
|
684
|
+
byKey.set(k, { found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
685
|
+
} else if (_chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
686
|
+
const e = { code: err.code, message: err.message };
|
|
687
|
+
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
688
|
+
byKey.set(k, { found: false, value: null, error: e });
|
|
689
|
+
} else {
|
|
690
|
+
throw err;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
const results = [];
|
|
696
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
697
|
+
const item = items[i];
|
|
698
|
+
const id = canonical[i];
|
|
699
|
+
const out = byKey.get(`${item.resource}:${String(id)}`);
|
|
700
|
+
const value = out.found ? item.fields !== void 0 ? project2(out.value, item.fields) : out.value : null;
|
|
701
|
+
results.push(
|
|
702
|
+
out.found ? { resource: item.resource, id, found: true, value } : { resource: item.resource, id, found: false, value: null, error: out.error }
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
const ok = results.filter((r) => r.found).length;
|
|
706
|
+
return { results, ok, failed: results.length - ok };
|
|
707
|
+
}
|
|
708
|
+
|
|
394
709
|
// src/operations/relationshipMap.ts
|
|
395
710
|
async function relationshipMap(client, resourceKey) {
|
|
396
711
|
void client;
|
|
397
712
|
if (typeof resourceKey !== "string" || resourceKey.trim() === "") {
|
|
398
|
-
throw new (0,
|
|
713
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
399
714
|
`relationshipMap: resourceKey must be a non-empty plan resource key string (e.g. 'tickets'; got ${typeof resourceKey === "string" ? "a blank string" : typeof resourceKey})`,
|
|
400
715
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items, ticket_notes." }
|
|
401
716
|
);
|
|
402
717
|
}
|
|
403
718
|
const key = resourceKey.trim();
|
|
404
|
-
const entry =
|
|
719
|
+
const entry = _chunkWTVLHMZAcjs.RELATIONSHIP_MAP[key];
|
|
405
720
|
if (entry === void 0) {
|
|
406
|
-
throw new (0,
|
|
407
|
-
`relationshipMap: unknown resource "${key}" \u2014 the plan has ${Object.keys(
|
|
721
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskError)(
|
|
722
|
+
`relationshipMap: unknown resource "${key}" \u2014 the plan has ${Object.keys(_chunkWTVLHMZAcjs.RELATIONSHIP_MAP).length} resources`,
|
|
408
723
|
{
|
|
409
724
|
code: "RESOURCE_UNKNOWN",
|
|
410
725
|
category: "validation",
|
|
411
|
-
suggestedAction: `Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items). Zone facts served are ${
|
|
726
|
+
suggestedAction: `Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items). Zone facts served are ${_chunkWTVLHMZAcjs.RELATIONSHIP_ZONE.label} (${_chunkWTVLHMZAcjs.RELATIONSHIP_ZONE.zone})-verified.`
|
|
412
727
|
}
|
|
413
728
|
);
|
|
414
729
|
}
|
|
@@ -425,24 +740,24 @@ var BLIND_SURFACE_KINDS = [
|
|
|
425
740
|
async function blindSurfaces(client, opts) {
|
|
426
741
|
void client;
|
|
427
742
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
428
|
-
throw new (0,
|
|
743
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("blindSurfaces: opts must be an object { resource?: string, kind?: BlindSurfaceKind }");
|
|
429
744
|
}
|
|
430
|
-
const inv =
|
|
745
|
+
const inv = _chunkWTVLHMZAcjs.BLIND_SURFACE_INVENTORY;
|
|
431
746
|
if (inv === null) {
|
|
432
|
-
throw new (0,
|
|
747
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("blindSurfaces: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
433
748
|
}
|
|
434
749
|
let surfaces = inv.surfaces;
|
|
435
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
750
|
+
if (_optionalChain([opts, 'optionalAccess', _6 => _6.resource]) !== void 0) {
|
|
436
751
|
const key = typeof opts.resource === "string" ? opts.resource.trim() : "";
|
|
437
752
|
if (key === "") {
|
|
438
|
-
throw new (0,
|
|
753
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
439
754
|
"blindSurfaces: opts.resource must be a non-empty plan resource key string (e.g. 'tickets')",
|
|
440
755
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items." }
|
|
441
756
|
);
|
|
442
757
|
}
|
|
443
758
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
444
|
-
throw new (0,
|
|
445
|
-
`blindSurfaces: unknown resource "${key}" \u2014 the plan has ${Object.keys(
|
|
759
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskError)(
|
|
760
|
+
`blindSurfaces: unknown resource "${key}" \u2014 the plan has ${Object.keys(_chunkWTVLHMZAcjs.RELATIONSHIP_MAP).length} resources`,
|
|
446
761
|
{
|
|
447
762
|
code: "RESOURCE_UNKNOWN",
|
|
448
763
|
category: "validation",
|
|
@@ -452,9 +767,9 @@ async function blindSurfaces(client, opts) {
|
|
|
452
767
|
}
|
|
453
768
|
surfaces = surfaces.filter((row) => row.resource === key);
|
|
454
769
|
}
|
|
455
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
770
|
+
if (_optionalChain([opts, 'optionalAccess', _7 => _7.kind]) !== void 0) {
|
|
456
771
|
if (!BLIND_SURFACE_KINDS.includes(opts.kind)) {
|
|
457
|
-
throw new (0,
|
|
772
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
458
773
|
`blindSurfaces: unknown kind "${String(opts.kind)}" \u2014 the valid classes are: ${BLIND_SURFACE_KINDS.join(", ")}`,
|
|
459
774
|
{ suggestedAction: `Filter with one of: ${BLIND_SURFACE_KINDS.join(", ")} (or omit kind for the full 116-surface inventory).` }
|
|
460
775
|
);
|
|
@@ -467,51 +782,51 @@ async function blindSurfaces(client, opts) {
|
|
|
467
782
|
// src/operations/probeReachability.ts
|
|
468
783
|
async function probeReachability(client, opts) {
|
|
469
784
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
470
|
-
throw new (0,
|
|
785
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("probeReachability: opts must be an object { resources?: string[], limit?: 1|2, maxWireCalls?: number, confirmProbe?: true }");
|
|
471
786
|
}
|
|
472
|
-
const defs =
|
|
473
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
474
|
-
throw new (0,
|
|
787
|
+
const defs = _chunkWTVLHMZAcjs.REACHABILITY_PROBE_DEFAULTS;
|
|
788
|
+
if (_optionalChain([opts, 'optionalAccess', _8 => _8.confirmProbe]) !== true) {
|
|
789
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
475
790
|
"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",
|
|
476
791
|
{ suggestedAction: `Re-call with { confirmProbe: true } (plus resources/limit/maxWireCalls as needed). For the ZERO-wire pinned inventory use operations.blindSurfaces.` }
|
|
477
792
|
);
|
|
478
793
|
}
|
|
479
|
-
const limit = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
794
|
+
const limit = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _9 => _9.limit]), () => ( defs.limitDefault));
|
|
480
795
|
if (!Number.isInteger(limit) || limit < 1 || limit > defs.limitMax) {
|
|
481
|
-
throw new (0,
|
|
796
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
482
797
|
`probeReachability: limit must be an integer 1..${defs.limitMax} (got ${String(limit)}) \u2014 the rows-per-surface bound for the discovery read`
|
|
483
798
|
);
|
|
484
799
|
}
|
|
485
|
-
const cap = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
800
|
+
const cap = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _10 => _10.maxWireCalls]), () => ( defs.defaultCap));
|
|
486
801
|
if (!Number.isInteger(cap) || cap < 1) {
|
|
487
|
-
throw new (0,
|
|
802
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`probeReachability: maxWireCalls must be a positive integer (got ${String(cap)})`);
|
|
488
803
|
}
|
|
489
804
|
if (cap > defs.hardCap) {
|
|
490
|
-
throw new (0,
|
|
805
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
491
806
|
`probeReachability: maxWireCalls ${cap} exceeds the hard wire cap of ${defs.hardCap} \u2014 the sweep is refused above it (never capped silently)`,
|
|
492
807
|
{ suggestedAction: `Pass maxWireCalls \u2264 ${defs.hardCap} and a resources set no larger than the cap (the refused set is never truncated).` }
|
|
493
808
|
);
|
|
494
809
|
}
|
|
495
|
-
const inv =
|
|
810
|
+
const inv = _chunkWTVLHMZAcjs.BLIND_SURFACE_INVENTORY;
|
|
496
811
|
if (inv === null) {
|
|
497
|
-
throw new (0,
|
|
812
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("probeReachability: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
498
813
|
}
|
|
499
814
|
let targets;
|
|
500
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
815
|
+
if (_optionalChain([opts, 'optionalAccess', _11 => _11.resources]) === void 0) {
|
|
501
816
|
targets = [...defs.defaultTargets];
|
|
502
817
|
} else {
|
|
503
818
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
504
|
-
throw new (0,
|
|
819
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("probeReachability: opts.resources must be a non-empty string[] of plan resource keys (or omit it for the default non-data-full set)");
|
|
505
820
|
}
|
|
506
821
|
const seen = /* @__PURE__ */ new Set();
|
|
507
822
|
for (const r of opts.resources) {
|
|
508
823
|
if (typeof r !== "string" || r.trim() === "") {
|
|
509
|
-
throw new (0,
|
|
824
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(`probeReachability: opts.resources must contain non-empty plan resource key strings (got ${typeof r === "string" && r.trim() === "" ? "a blank string" : typeof r})`);
|
|
510
825
|
}
|
|
511
826
|
const key = r.trim();
|
|
512
827
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
513
828
|
const surfaceCount = new Set(inv.surfaces.map((s) => s.resource)).size;
|
|
514
|
-
throw new (0,
|
|
829
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskError)(
|
|
515
830
|
`probeReachability: unknown resource "${key}" \u2014 the inventory has ${surfaceCount} surfaces`,
|
|
516
831
|
{
|
|
517
832
|
code: "RESOURCE_UNKNOWN",
|
|
@@ -525,7 +840,7 @@ async function probeReachability(client, opts) {
|
|
|
525
840
|
targets = [...seen];
|
|
526
841
|
}
|
|
527
842
|
if (targets.length > cap) {
|
|
528
|
-
throw new (0,
|
|
843
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
529
844
|
`probeReachability: ${targets.length} requested surface(s) exceed the wire cap of ${cap} \u2014 the sweep is refused above its cap (never truncated)`,
|
|
530
845
|
{ suggestedAction: `Raise maxWireCalls (\u2264 ${defs.hardCap}) to cover the set, or pass a smaller resources list.` }
|
|
531
846
|
);
|
|
@@ -535,8 +850,8 @@ async function probeReachability(client, opts) {
|
|
|
535
850
|
for (const resource of targets.sort()) {
|
|
536
851
|
const row = byResource.get(resource);
|
|
537
852
|
if (row === void 0) continue;
|
|
538
|
-
const holder = client[
|
|
539
|
-
const probeFn = _optionalChain([holder, 'optionalAccess',
|
|
853
|
+
const holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, resource)];
|
|
854
|
+
const probeFn = _optionalChain([holder, 'optionalAccess', _12 => _12.queryBounded]);
|
|
540
855
|
if (typeof probeFn !== "function") {
|
|
541
856
|
results.push({
|
|
542
857
|
...row,
|
|
@@ -547,14 +862,14 @@ async function probeReachability(client, opts) {
|
|
|
547
862
|
}
|
|
548
863
|
try {
|
|
549
864
|
const res = await probeFn.call(holder, { limit });
|
|
550
|
-
const items = Array.isArray(_optionalChain([res, 'optionalAccess',
|
|
865
|
+
const items = Array.isArray(_optionalChain([res, 'optionalAccess', _13 => _13.items])) ? res.items : [];
|
|
551
866
|
results.push({
|
|
552
867
|
...row,
|
|
553
868
|
unfilteredRows: items.length,
|
|
554
869
|
probe: { ok: true, wire: 1, error: null }
|
|
555
870
|
});
|
|
556
871
|
} catch (err) {
|
|
557
|
-
const code =
|
|
872
|
+
const code = _chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) ? err.code : "NETWORK_ERROR";
|
|
558
873
|
const message = err instanceof Error ? err.message : String(err);
|
|
559
874
|
results.push({
|
|
560
875
|
...row,
|
|
@@ -582,24 +897,24 @@ var CREATE_BLOCKER_KINDS = [
|
|
|
582
897
|
async function createGuidance(client, opts) {
|
|
583
898
|
void client;
|
|
584
899
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
585
|
-
throw new (0,
|
|
900
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
586
901
|
"createGuidance: opts must be an object { resources?: string[], kind?: CreateBlockerKind }"
|
|
587
902
|
);
|
|
588
903
|
}
|
|
589
|
-
let rows =
|
|
590
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
904
|
+
let rows = _chunkWTVLHMZAcjs.CREATE_GUIDANCE.rows;
|
|
905
|
+
if (_optionalChain([opts, 'optionalAccess', _14 => _14.resources]) !== void 0) {
|
|
591
906
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
592
|
-
throw new (0,
|
|
907
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("createGuidance: opts.resources must be a non-empty string[] of plan resource keys");
|
|
593
908
|
}
|
|
594
909
|
const wanted = /* @__PURE__ */ new Set();
|
|
595
910
|
for (const r of opts.resources) {
|
|
596
911
|
if (typeof r !== "string" || r.trim() === "") {
|
|
597
|
-
throw new (0,
|
|
912
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)("createGuidance: opts.resources must contain non-empty plan resource key strings");
|
|
598
913
|
}
|
|
599
914
|
const key = r.trim();
|
|
600
|
-
if (!
|
|
601
|
-
throw new (0,
|
|
602
|
-
`createGuidance: unknown resource "${key}" \u2014 the catalog has ${
|
|
915
|
+
if (!_chunkWTVLHMZAcjs.CREATE_GUIDANCE.rows.some((row) => row.resource === key)) {
|
|
916
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskError)(
|
|
917
|
+
`createGuidance: unknown resource "${key}" \u2014 the catalog has ${_chunkWTVLHMZAcjs.CREATE_GUIDANCE.rows.length} create entities`,
|
|
603
918
|
{
|
|
604
919
|
code: "RESOURCE_UNKNOWN",
|
|
605
920
|
category: "validation",
|
|
@@ -611,243 +926,20 @@ async function createGuidance(client, opts) {
|
|
|
611
926
|
}
|
|
612
927
|
rows = rows.filter((row) => wanted.has(row.resource));
|
|
613
928
|
}
|
|
614
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
929
|
+
if (_optionalChain([opts, 'optionalAccess', _15 => _15.kind]) !== void 0) {
|
|
615
930
|
if (!CREATE_BLOCKER_KINDS.includes(opts.kind)) {
|
|
616
|
-
throw new (0,
|
|
931
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
617
932
|
`createGuidance: unknown kind "${String(opts.kind)}" \u2014 the valid kinds are: ${CREATE_BLOCKER_KINDS.join(", ")}`
|
|
618
933
|
);
|
|
619
934
|
}
|
|
620
|
-
rows = rows.filter((row) => _optionalChain([row, 'access',
|
|
935
|
+
rows = rows.filter((row) => _optionalChain([row, 'access', _16 => _16.blocker, 'optionalAccess', _17 => _17.kind]) === opts.kind);
|
|
621
936
|
}
|
|
622
937
|
return {
|
|
623
|
-
zone:
|
|
624
|
-
label:
|
|
625
|
-
verifiedAt:
|
|
938
|
+
zone: _chunkWTVLHMZAcjs.CREATE_GUIDANCE.zone,
|
|
939
|
+
label: _chunkWTVLHMZAcjs.CREATE_GUIDANCE.label,
|
|
940
|
+
verifiedAt: _chunkWTVLHMZAcjs.CREATE_GUIDANCE.verifiedAt,
|
|
626
941
|
rows,
|
|
627
|
-
counts:
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// src/operations/fieldCatalog.ts
|
|
632
|
-
var MAX_FIELD_CATALOG_WIRE = 60;
|
|
633
|
-
var FIELD_CATALOG_HONESTY_NOTE = "Live field metadata reports the SHAPE of a field (existence, requiredness, type, maxLength, read-only, queryable, picklist-ness) and serves picklist VALUES where the vendor exposes them. It cannot resolve a picklist VALUE the vendor does not expose to this API user (the W-A4 wall \u2014 e.g. the attachments Type picklist): retrying the catalog will not surface a withheld value; that gap is vendor-side, not a client defect.";
|
|
634
|
-
var FIELD_CATALOG_OPT_KEYS = ["resources", "include", "fresh"];
|
|
635
|
-
function projectFieldRow(raw) {
|
|
636
|
-
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
637
|
-
const name = typeof r.name === "string" ? r.name : "";
|
|
638
|
-
const type = typeof r.dataType === "string" ? r.dataType : typeof r.type === "string" ? r.type : "";
|
|
639
|
-
return {
|
|
640
|
-
name,
|
|
641
|
-
...typeof r.label === "string" && r.label !== "" ? { label: r.label } : {},
|
|
642
|
-
type,
|
|
643
|
-
isRequired: r.isRequired === true,
|
|
644
|
-
isReadOnly: r.isReadOnly === true,
|
|
645
|
-
isQueryable: r.isQueryable === true,
|
|
646
|
-
isPickList: r.isPickList === true,
|
|
647
|
-
maxLength: typeof r.length === "number" ? r.length : null,
|
|
648
|
-
referenceEntityType: typeof r.referenceEntityType === "string" ? r.referenceEntityType : ""
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
function exposesPicklistValues(raw) {
|
|
652
|
-
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
653
|
-
return Array.isArray(r.picklistValues) && r.picklistValues.length > 0;
|
|
654
|
-
}
|
|
655
|
-
function capabilitySets() {
|
|
656
|
-
const fieldOps = /* @__PURE__ */ new Map();
|
|
657
|
-
const udfOps = /* @__PURE__ */ new Map();
|
|
658
|
-
const resources = /* @__PURE__ */ new Set();
|
|
659
|
-
for (const rec of _chunkKNTUX3RRcjs.CAPABILITIES) {
|
|
660
|
-
if (rec.resource === "operations") continue;
|
|
661
|
-
resources.add(rec.resource);
|
|
662
|
-
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
663
|
-
if (rec.operation === "getUdfInfo") udfOps.set(rec.resource, rec);
|
|
664
|
-
}
|
|
665
|
-
return { fieldOps, udfOps, resources };
|
|
666
|
-
}
|
|
667
|
-
function apiEntityFor(rec) {
|
|
668
|
-
const m = /^GET \/V1\.0\/([^/]+)\/entityInformation\/fields$/.exec(_nullishCoalesce(rec.endpoint, () => ( "")));
|
|
669
|
-
if (m === null) {
|
|
670
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
671
|
-
`fieldCatalog: the plan's getFieldInfo endpoint for "${rec.resource}" has no /V1.0/<Entity>/entityInformation/fields shape (${rec.endpoint}) \u2014 plan defect`,
|
|
672
|
-
{ operation: "operations.fieldCatalog" }
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
return m[1];
|
|
676
|
-
}
|
|
677
|
-
async function fieldCatalog(client, opts) {
|
|
678
|
-
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
679
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
680
|
-
"fieldCatalog: opts must be an object { resources?: string[], include?: (info|fields|udf)[], fresh?: boolean }"
|
|
681
|
-
);
|
|
682
|
-
}
|
|
683
|
-
for (const key of Object.keys(_nullishCoalesce(opts, () => ( {})))) {
|
|
684
|
-
if (!FIELD_CATALOG_OPT_KEYS.includes(key)) {
|
|
685
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
686
|
-
`fieldCatalog: unknown opts key "${key}" \u2014 the bag is closed: ${FIELD_CATALOG_OPT_KEYS.join(", ")}`,
|
|
687
|
-
{ suggestedAction: "Drop the unknown key (autotask_describe(operations.fieldCatalog) shows the exact bag)." }
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
const { fieldOps, udfOps, resources: allResources } = capabilitySets();
|
|
692
|
-
const includeRaw = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _13 => _13.include]), () => ( ["fields"]));
|
|
693
|
-
if (!Array.isArray(includeRaw) || includeRaw.length === 0) {
|
|
694
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)("fieldCatalog: opts.include must be a non-empty array of (info|fields|udf)");
|
|
695
|
-
}
|
|
696
|
-
const include = [];
|
|
697
|
-
for (const kind of includeRaw) {
|
|
698
|
-
if (typeof kind !== "string" || !_chunkV3XPLTIRcjs.FIELD_CACHE_KINDS.includes(kind)) {
|
|
699
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
700
|
-
`fieldCatalog: unknown include kind "${String(kind)}" \u2014 the valid kinds are: ${_chunkV3XPLTIRcjs.FIELD_CACHE_KINDS.join(", ")}`,
|
|
701
|
-
{ suggestedAction: `Filter with one or more of: ${_chunkV3XPLTIRcjs.FIELD_CACHE_KINDS.join(", ")} (default ['fields']).` }
|
|
702
|
-
);
|
|
703
|
-
}
|
|
704
|
-
if (!include.includes(kind)) include.push(kind);
|
|
705
|
-
}
|
|
706
|
-
const resourcesRaw = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _14 => _14.resources]), () => ( WORKFLOW_RESOURCES));
|
|
707
|
-
if (!Array.isArray(resourcesRaw) || resourcesRaw.length === 0) {
|
|
708
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)("fieldCatalog: opts.resources must be a non-empty array of plan resource keys");
|
|
709
|
-
}
|
|
710
|
-
const targets = [];
|
|
711
|
-
for (const r of resourcesRaw) {
|
|
712
|
-
if (typeof r !== "string" || r.trim() === "") {
|
|
713
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
714
|
-
`fieldCatalog: opts.resources must contain non-empty plan resource key strings (got ${typeof r === "string" && r.trim() === "" ? "a blank string" : typeof r})`
|
|
715
|
-
);
|
|
716
|
-
}
|
|
717
|
-
const key = r.trim();
|
|
718
|
-
const fieldOp = fieldOps.get(key);
|
|
719
|
-
if (fieldOp === void 0) {
|
|
720
|
-
if (allResources.has(key)) {
|
|
721
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
722
|
-
`fieldCatalog: resource "${key}" has no field catalog \u2014 the vendor defines the entityInformation trio for the ${fieldOps.size} plan entity resources only`,
|
|
723
|
-
{ suggestedAction: `Pass one of the ${fieldOps.size} field-capable plan keys (list them with autotask_catalog).` }
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskError)(
|
|
727
|
-
`fieldCatalog: unknown resource "${key}" \u2014 the plan has ${fieldOps.size} field-capable resources`,
|
|
728
|
-
{
|
|
729
|
-
code: "RESOURCE_UNKNOWN",
|
|
730
|
-
category: "validation",
|
|
731
|
-
suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items)."
|
|
732
|
-
}
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
if (!targets.includes(key)) targets.push(key);
|
|
736
|
-
}
|
|
737
|
-
const cost = targets.length * include.length;
|
|
738
|
-
if (cost > MAX_FIELD_CATALOG_WIRE) {
|
|
739
|
-
throw new (0, _chunkV3XPLTIRcjs.AutotaskConfigError)(
|
|
740
|
-
`fieldCatalog: ${targets.length} resource(s) \xD7 ${include.length} kind(s) = ${cost} metadata reads exceed the wire cap of ${MAX_FIELD_CATALOG_WIRE} \u2014 the call is refused above its cap (never truncated)`,
|
|
741
|
-
{ suggestedAction: `Pass a smaller resources list or a narrower include set so the product stays \u2264 ${MAX_FIELD_CATALOG_WIRE}.` }
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
const cache = client.http.fieldCache;
|
|
745
|
-
const fresh = _optionalChain([opts, 'optionalAccess', _15 => _15.fresh]) === true;
|
|
746
|
-
const zone = _nullishCoalesce(client.config.zone, () => ( "unknown"));
|
|
747
|
-
const rows = [];
|
|
748
|
-
let wireUsed = 0;
|
|
749
|
-
let anyPicklistValues = false;
|
|
750
|
-
for (const resource of targets) {
|
|
751
|
-
const fieldOp = fieldOps.get(resource);
|
|
752
|
-
if (fieldOp === void 0) continue;
|
|
753
|
-
const apiEntity = apiEntityFor(fieldOp);
|
|
754
|
-
const holder = client[_chunkV3XPLTIRcjs.camelKey.call(void 0, resource)];
|
|
755
|
-
const row = {
|
|
756
|
-
resource,
|
|
757
|
-
apiEntity,
|
|
758
|
-
udfCapable: udfOps.has(resource),
|
|
759
|
-
required: [],
|
|
760
|
-
readOnly: [],
|
|
761
|
-
queryable: [],
|
|
762
|
-
picklistFields: [],
|
|
763
|
-
cache: { hit: false, age: null },
|
|
764
|
-
wire: 0,
|
|
765
|
-
error: null
|
|
766
|
-
};
|
|
767
|
-
const fetches = {
|
|
768
|
-
info: () => _nullishCoalesce(_optionalChain([holder, 'optionalAccess', _16 => _16.getEntityInfo, 'optionalCall', _17 => _17()]), () => ( Promise.reject(new (0, _chunkV3XPLTIRcjs.AutotaskError)(`fieldCatalog: the client exposes no getEntityInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" })))),
|
|
769
|
-
fields: () => _nullishCoalesce(_optionalChain([holder, 'optionalAccess', _18 => _18.getFieldInfo, 'optionalCall', _19 => _19()]), () => ( Promise.reject(new (0, _chunkV3XPLTIRcjs.AutotaskError)(`fieldCatalog: the client exposes no getFieldInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" })))),
|
|
770
|
-
udf: () => _nullishCoalesce(_optionalChain([holder, 'optionalAccess', _20 => _20.getUdfInfo, 'optionalCall', _21 => _21()]), () => ( Promise.reject(new (0, _chunkV3XPLTIRcjs.AutotaskError)(`fieldCatalog: the client exposes no getUdfInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" }))))
|
|
771
|
-
};
|
|
772
|
-
if (fresh) _optionalChain([cache, 'optionalAccess', _22 => _22.invalidate, 'call', _23 => _23(resource)]);
|
|
773
|
-
let allCached = true;
|
|
774
|
-
const ages = [];
|
|
775
|
-
for (const kind of include) {
|
|
776
|
-
const peek = cache !== void 0 && !fresh ? cache.peek(resource, kind) : { hit: false, age: null };
|
|
777
|
-
if (peek.hit !== true) allCached = false;
|
|
778
|
-
if (peek.hit === true && cache !== void 0) {
|
|
779
|
-
const value2 = cache.get(resource, kind);
|
|
780
|
-
if (kind === "info") row.info = _nullishCoalesce(value2, () => ( null));
|
|
781
|
-
else {
|
|
782
|
-
const list = Array.isArray(value2) ? value2 : [];
|
|
783
|
-
const projected = list.map((f) => projectFieldRow(f));
|
|
784
|
-
if (kind === "fields") row.fields = projected;
|
|
785
|
-
else row.udf = projected;
|
|
786
|
-
for (const f of list) if (exposesPicklistValues(f)) anyPicklistValues = true;
|
|
787
|
-
if (kind === "fields") {
|
|
788
|
-
row.required = projected.filter((f) => f.isRequired).map((f) => f.name);
|
|
789
|
-
row.readOnly = projected.filter((f) => f.isReadOnly).map((f) => f.name);
|
|
790
|
-
row.queryable = projected.filter((f) => f.isQueryable).map((f) => f.name);
|
|
791
|
-
row.picklistFields = projected.filter((f) => f.isPickList).map((f) => f.name);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (peek.age !== null) ages.push(peek.age);
|
|
795
|
-
continue;
|
|
796
|
-
}
|
|
797
|
-
let value;
|
|
798
|
-
try {
|
|
799
|
-
value = await fetches[kind]();
|
|
800
|
-
} catch (err) {
|
|
801
|
-
wireUsed += 1;
|
|
802
|
-
row.wire += 1;
|
|
803
|
-
if (row.error === null) {
|
|
804
|
-
const code = _chunkV3XPLTIRcjs.isAutotaskError.call(void 0, err) ? err.code : "NETWORK_ERROR";
|
|
805
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
806
|
-
row.error = { code, message };
|
|
807
|
-
}
|
|
808
|
-
continue;
|
|
809
|
-
}
|
|
810
|
-
wireUsed += 1;
|
|
811
|
-
row.wire += 1;
|
|
812
|
-
if (kind === "info") {
|
|
813
|
-
row.info = _nullishCoalesce(value, () => ( null));
|
|
814
|
-
} else {
|
|
815
|
-
const list = Array.isArray(value) ? value : [];
|
|
816
|
-
const projected = list.map((f) => projectFieldRow(f));
|
|
817
|
-
if (kind === "fields") row.fields = projected;
|
|
818
|
-
else row.udf = projected;
|
|
819
|
-
for (const f of list) if (exposesPicklistValues(f)) anyPicklistValues = true;
|
|
820
|
-
if (kind === "fields") {
|
|
821
|
-
row.required = projected.filter((f) => f.isRequired).map((f) => f.name);
|
|
822
|
-
row.readOnly = projected.filter((f) => f.isReadOnly).map((f) => f.name);
|
|
823
|
-
row.queryable = projected.filter((f) => f.isQueryable).map((f) => f.name);
|
|
824
|
-
row.picklistFields = projected.filter((f) => f.isPickList).map((f) => f.name);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
row.cache = allCached ? { hit: true, age: ages.length > 0 ? Math.max(...ages) : 0 } : { hit: false, age: null };
|
|
829
|
-
rows.push(row);
|
|
830
|
-
}
|
|
831
|
-
return {
|
|
832
|
-
zone,
|
|
833
|
-
label: zone,
|
|
834
|
-
cached: cache !== void 0,
|
|
835
|
-
ttlMs: _nullishCoalesce(_optionalChain([cache, 'optionalAccess', _24 => _24.ttlMs]), () => ( null)),
|
|
836
|
-
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
837
|
-
rows,
|
|
838
|
-
wireUsed,
|
|
839
|
-
cap: MAX_FIELD_CATALOG_WIRE,
|
|
840
|
-
truncated: false,
|
|
841
|
-
counts: {
|
|
842
|
-
resources: targets.length,
|
|
843
|
-
fieldCapableResources: fieldOps.size,
|
|
844
|
-
udfCapableResources: udfOps.size,
|
|
845
|
-
cached: rows.filter((r) => r.cache.hit === true).length
|
|
846
|
-
},
|
|
847
|
-
honesty: {
|
|
848
|
-
picklistValues: anyPicklistValues ? "partial" : "unexposed",
|
|
849
|
-
note: FIELD_CATALOG_HONESTY_NOTE
|
|
850
|
-
}
|
|
942
|
+
counts: _chunkWTVLHMZAcjs.CREATE_GUIDANCE.counts
|
|
851
943
|
};
|
|
852
944
|
}
|
|
853
945
|
|
|
@@ -856,7 +948,7 @@ var RECOVERY_CONFIRM = "operations.recovery";
|
|
|
856
948
|
var RECOVERY_DEFAULT_LIMIT = 25;
|
|
857
949
|
var RECOVERY_MAX_LIMIT = 100;
|
|
858
950
|
function configError(message, operation, suggestedAction) {
|
|
859
|
-
throw new (0,
|
|
951
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(message, { operation, suggestedAction });
|
|
860
952
|
}
|
|
861
953
|
function parseMatchId(record) {
|
|
862
954
|
const raw = record.id;
|
|
@@ -873,7 +965,7 @@ function parseMatchId(record) {
|
|
|
873
965
|
}
|
|
874
966
|
async function recovery(client, input, opts = {}) {
|
|
875
967
|
const operation = RECOVERY_CONFIRM;
|
|
876
|
-
if (!
|
|
968
|
+
if (!_chunkWTVLHMZAcjs.isRecord.call(void 0, input)) {
|
|
877
969
|
configError(
|
|
878
970
|
`recovery: input must be an object { resource, marker, ... } (got ${typeof input})`,
|
|
879
971
|
operation,
|
|
@@ -904,10 +996,10 @@ async function recovery(client, input, opts = {}) {
|
|
|
904
996
|
"Pass action: 'delete' for the destructive path (dry-run-first; the apply requires the confirm string)."
|
|
905
997
|
);
|
|
906
998
|
}
|
|
907
|
-
const entry =
|
|
999
|
+
const entry = _chunkWTVLHMZAcjs.RELATIONSHIP_MAP[resource];
|
|
908
1000
|
if (entry === void 0) {
|
|
909
|
-
throw new (0,
|
|
910
|
-
`recovery: unknown resource "${resource}" \u2014 the plan has ${Object.keys(
|
|
1001
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskError)(
|
|
1002
|
+
`recovery: unknown resource "${resource}" \u2014 the plan has ${Object.keys(_chunkWTVLHMZAcjs.RELATIONSHIP_MAP).length} resources`,
|
|
911
1003
|
{
|
|
912
1004
|
code: "RESOURCE_UNKNOWN",
|
|
913
1005
|
category: "validation",
|
|
@@ -916,7 +1008,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
916
1008
|
}
|
|
917
1009
|
);
|
|
918
1010
|
}
|
|
919
|
-
const holder = client[
|
|
1011
|
+
const holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, resource)];
|
|
920
1012
|
if (!holder || typeof holder.queryBounded !== "function") {
|
|
921
1013
|
configError(
|
|
922
1014
|
`recovery: ${resource} exposes no bounded query surface \u2014 the marker search cannot run`,
|
|
@@ -924,7 +1016,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
924
1016
|
"Use a resource with a query surface, or address the record by id directly (get/fetchMany)."
|
|
925
1017
|
);
|
|
926
1018
|
}
|
|
927
|
-
const field = input.field !== void 0 ? String(input.field) :
|
|
1019
|
+
const field = input.field !== void 0 ? String(input.field) : _chunkWTVLHMZAcjs.MARKER_FIELDS[resource];
|
|
928
1020
|
if (typeof field !== "string" || field.trim() === "") {
|
|
929
1021
|
configError(
|
|
930
1022
|
`recovery: ${resource} has no plan markerField and no input.field was passed \u2014 the marker search needs a name-like field to filter on`,
|
|
@@ -960,7 +1052,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
960
1052
|
);
|
|
961
1053
|
}
|
|
962
1054
|
for (const c of input.filter) {
|
|
963
|
-
if (!
|
|
1055
|
+
if (!_chunkWTVLHMZAcjs.isRecord.call(void 0, c) || typeof c.op !== "string" || c.op === "and" || c.op === "or") {
|
|
964
1056
|
configError(
|
|
965
1057
|
"recovery: input.filter accepts only plain leaf conditions ({ field, op, value }) \u2014 no grouping",
|
|
966
1058
|
operation,
|
|
@@ -981,7 +1073,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
981
1073
|
}
|
|
982
1074
|
limit = input.limit;
|
|
983
1075
|
}
|
|
984
|
-
const boundaryNote =
|
|
1076
|
+
const boundaryNote = _chunkWTVLHMZAcjs.DELETE_BOUNDARY_NOTES[resource];
|
|
985
1077
|
const boundary = {
|
|
986
1078
|
available: boundaryNote === void 0,
|
|
987
1079
|
reason: _nullishCoalesce(boundaryNote, () => ( null)),
|
|
@@ -993,7 +1085,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
993
1085
|
};
|
|
994
1086
|
const isDelete = action === "delete";
|
|
995
1087
|
if (isDelete && boundaryNote !== void 0) {
|
|
996
|
-
throw new (0,
|
|
1088
|
+
throw new (0, _chunkWTVLHMZAcjs.DeleteBoundaryError)(
|
|
997
1089
|
`recovery: the vendor defines no DELETE for ${resource} \u2014 the delete cannot be issued through the API (zero wire was issued)`,
|
|
998
1090
|
{
|
|
999
1091
|
operation,
|
|
@@ -1002,10 +1094,10 @@ async function recovery(client, input, opts = {}) {
|
|
|
1002
1094
|
}
|
|
1003
1095
|
);
|
|
1004
1096
|
}
|
|
1005
|
-
const dryRun = _optionalChain([opts, 'optionalAccess',
|
|
1006
|
-
const confirm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
1097
|
+
const dryRun = _optionalChain([opts, 'optionalAccess', _18 => _18.dryRun]) !== false;
|
|
1098
|
+
const confirm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _19 => _19.confirm]), () => ( input.confirm));
|
|
1007
1099
|
if (isDelete && !dryRun && confirm !== RECOVERY_CONFIRM) {
|
|
1008
|
-
throw new (0,
|
|
1100
|
+
throw new (0, _chunkWTVLHMZAcjs.ConfirmationRequiredError)(
|
|
1009
1101
|
`recovery: action 'delete' apply is destructive and requires its confirmation flag: pass confirm: "${RECOVERY_CONFIRM}"`,
|
|
1010
1102
|
{
|
|
1011
1103
|
operation: RECOVERY_CONFIRM,
|
|
@@ -1021,7 +1113,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1021
1113
|
const query = await holder.queryBounded({ filter: conditions, limit });
|
|
1022
1114
|
if (query.hasMore) {
|
|
1023
1115
|
const wire = isDelete ? "DELETE wire" : "mutating wire";
|
|
1024
|
-
throw new (0,
|
|
1116
|
+
throw new (0, _chunkWTVLHMZAcjs.RecoveryTruncatedError)(
|
|
1025
1117
|
`recovery: the marker search on ${resource} TRIPPED its match cap (${limit}) \u2014 more matches exist than were returned (zero ${wire} was issued)`,
|
|
1026
1118
|
{
|
|
1027
1119
|
operation,
|
|
@@ -1060,7 +1152,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1060
1152
|
return { ...base, simulated: true, dryRun: true };
|
|
1061
1153
|
}
|
|
1062
1154
|
if (unsafeId) {
|
|
1063
|
-
throw new (0,
|
|
1155
|
+
throw new (0, _chunkWTVLHMZAcjs.MarkerUnsafeIdError)(
|
|
1064
1156
|
`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)`,
|
|
1065
1157
|
{
|
|
1066
1158
|
operation,
|
|
@@ -1071,7 +1163,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1071
1163
|
}
|
|
1072
1164
|
const deleteMethod = holder.delete;
|
|
1073
1165
|
if (deleteMethod === void 0) {
|
|
1074
|
-
throw new (0,
|
|
1166
|
+
throw new (0, _chunkWTVLHMZAcjs.DeleteBoundaryError)(
|
|
1075
1167
|
`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`,
|
|
1076
1168
|
{
|
|
1077
1169
|
operation,
|
|
@@ -1100,14 +1192,14 @@ async function recovery(client, input, opts = {}) {
|
|
|
1100
1192
|
verify = "still-present";
|
|
1101
1193
|
}
|
|
1102
1194
|
} catch (err) {
|
|
1103
|
-
if (err instanceof
|
|
1195
|
+
if (err instanceof _chunkWTVLHMZAcjs.NotFoundError) verify = "not-found";
|
|
1104
1196
|
else {
|
|
1105
1197
|
verify = "error";
|
|
1106
|
-
code =
|
|
1198
|
+
code = _chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1107
1199
|
}
|
|
1108
1200
|
}
|
|
1109
1201
|
} catch (err) {
|
|
1110
|
-
code =
|
|
1202
|
+
code = _chunkWTVLHMZAcjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1111
1203
|
}
|
|
1112
1204
|
deleted.push({ id, verified: verify === "not-found", code });
|
|
1113
1205
|
}
|
|
@@ -1115,13 +1207,13 @@ async function recovery(client, input, opts = {}) {
|
|
|
1115
1207
|
}
|
|
1116
1208
|
|
|
1117
1209
|
// src/operations/invoke.ts
|
|
1118
|
-
var RECORDS =
|
|
1210
|
+
var RECORDS = _chunkWTVD2JZNcjs.CAPABILITIES;
|
|
1119
1211
|
var byId = new Map(RECORDS.map((r) => [r.id, r]));
|
|
1120
1212
|
function needsConfirmation(record) {
|
|
1121
1213
|
return record.effect === "destructive" || (_nullishCoalesce(record.flags, () => ( []))).includes("requiresApproval");
|
|
1122
1214
|
}
|
|
1123
1215
|
function refuse(message, operation, suggestedAction) {
|
|
1124
|
-
throw new (0,
|
|
1216
|
+
throw new (0, _chunkWTVLHMZAcjs.ConfirmationRequiredError)(message, { operation, suggestedAction });
|
|
1125
1217
|
}
|
|
1126
1218
|
var MODE_BY_EFFECT = {
|
|
1127
1219
|
read: "read",
|
|
@@ -1165,7 +1257,7 @@ function looseTypeOk(type, value) {
|
|
|
1165
1257
|
case "string[]":
|
|
1166
1258
|
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
1167
1259
|
case "object":
|
|
1168
|
-
return
|
|
1260
|
+
return _chunkWTVLHMZAcjs.isRecord.call(void 0, value);
|
|
1169
1261
|
default:
|
|
1170
1262
|
return true;
|
|
1171
1263
|
}
|
|
@@ -1182,7 +1274,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1182
1274
|
const schema = _nullishCoalesce(record.inputSchema, () => ( {}));
|
|
1183
1275
|
const names = Object.keys(schema);
|
|
1184
1276
|
if (args.length > names.length) {
|
|
1185
|
-
throw new (0,
|
|
1277
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1186
1278
|
`invoke: "${operation}" declares ${names.length} positional arg(s) (${declaredArgList(record)}) but ${args.length} were passed \u2014 extra args are refused, not dropped (v0.2.0 silently dropped them)`,
|
|
1187
1279
|
{
|
|
1188
1280
|
operation,
|
|
@@ -1192,7 +1284,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1192
1284
|
}
|
|
1193
1285
|
const required = names.filter((n) => schema[n].required);
|
|
1194
1286
|
if (args.length < required.length) {
|
|
1195
|
-
throw new (0,
|
|
1287
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1196
1288
|
`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)}`,
|
|
1197
1289
|
{ operation }
|
|
1198
1290
|
);
|
|
@@ -1203,7 +1295,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1203
1295
|
const name = names[i];
|
|
1204
1296
|
const spec = schema[name];
|
|
1205
1297
|
if (!looseTypeOk(spec.type, value)) {
|
|
1206
|
-
throw new (0,
|
|
1298
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1207
1299
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
1208
1300
|
{ operation }
|
|
1209
1301
|
);
|
|
@@ -1211,12 +1303,14 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1211
1303
|
}
|
|
1212
1304
|
}
|
|
1213
1305
|
var PARAMS_BAG_KEYS = {
|
|
1214
|
-
query: ["filter", "limit", "includeFields", "via"],
|
|
1306
|
+
query: ["filter", "limit", "includeFields", "via", "latest", "noteChars", "fieldsPreset"],
|
|
1215
1307
|
queryAll: ["filter", "maxRecords", "includeFields", "maxTotalRecords", "via"],
|
|
1216
1308
|
count: ["filter"]
|
|
1217
1309
|
};
|
|
1218
1310
|
var BAG_KEY_SYNONYMS = {
|
|
1219
1311
|
filters: "filter",
|
|
1312
|
+
last: "latest",
|
|
1313
|
+
// issue #59: the expected typo class (honoured only on `query`)
|
|
1220
1314
|
lmit: "limit",
|
|
1221
1315
|
page: "limit",
|
|
1222
1316
|
pageSize: "limit",
|
|
@@ -1252,12 +1346,12 @@ function validateParamsBag(record, args) {
|
|
|
1252
1346
|
if (record.inputSchemaStrict !== true) return;
|
|
1253
1347
|
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
1254
1348
|
if (valid === void 0) return;
|
|
1255
|
-
const bag = _optionalChain([args, 'optionalAccess',
|
|
1256
|
-
if (bag === void 0 || bag === null || !
|
|
1349
|
+
const bag = _optionalChain([args, 'optionalAccess', _20 => _20[0]]);
|
|
1350
|
+
if (bag === void 0 || bag === null || !_chunkWTVLHMZAcjs.isRecord.call(void 0, bag)) return;
|
|
1257
1351
|
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
1258
1352
|
if (unknown.length === 0) return;
|
|
1259
1353
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1260
|
-
throw new (0,
|
|
1354
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1261
1355
|
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
1262
1356
|
{
|
|
1263
1357
|
operation: record.id,
|
|
@@ -1271,7 +1365,7 @@ function validateInvokeOptions(opts, operation) {
|
|
|
1271
1365
|
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
1272
1366
|
if (unknown.length === 0) return;
|
|
1273
1367
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, ["dryRun", "confirm", "lastModifiedDate"])]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1274
|
-
throw new (0,
|
|
1368
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1275
1369
|
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate)`,
|
|
1276
1370
|
{
|
|
1277
1371
|
operation,
|
|
@@ -1284,7 +1378,7 @@ function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
|
1284
1378
|
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
1285
1379
|
if (unknown.length === 0) return null;
|
|
1286
1380
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, [...validKeys])]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1287
|
-
return new (0,
|
|
1381
|
+
return new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1288
1382
|
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
1289
1383
|
{
|
|
1290
1384
|
...operation !== void 0 ? { operation } : {},
|
|
@@ -1296,7 +1390,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1296
1390
|
const args = _nullishCoalesce(argsIn, () => ( []));
|
|
1297
1391
|
const record = byId.get(operation);
|
|
1298
1392
|
if (record === void 0) {
|
|
1299
|
-
throw new (0,
|
|
1393
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1300
1394
|
`invoke: unknown operation "${operation}" \u2014 it is not in the capability registry`,
|
|
1301
1395
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
1302
1396
|
);
|
|
@@ -1304,17 +1398,17 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1304
1398
|
validateInvokeOptions(opts, operation);
|
|
1305
1399
|
const mode = opts.mode;
|
|
1306
1400
|
if (mode !== void 0 && MODE_BY_EFFECT[record.effect] !== mode) {
|
|
1307
|
-
throw new (0,
|
|
1401
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(crossModeRefusal(operation, record.effect, mode), { operation });
|
|
1308
1402
|
}
|
|
1309
1403
|
if (opts.dryRun !== void 0 && typeof opts.dryRun !== "boolean") {
|
|
1310
|
-
throw new (0,
|
|
1404
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1311
1405
|
`invoke: dryRun must be a boolean (got ${typeof opts.dryRun}) \u2014 "${operation}" was not issued`,
|
|
1312
1406
|
{ operation, suggestedAction: "Pass dryRun: true (simulate) or dryRun: false (apply) as a real boolean." }
|
|
1313
1407
|
);
|
|
1314
1408
|
}
|
|
1315
1409
|
const isWrite = record.effect !== "read";
|
|
1316
1410
|
if (!isWrite && opts.dryRun === true) {
|
|
1317
|
-
throw new (0,
|
|
1411
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1318
1412
|
`invoke: "${operation}" is a read \u2014 dryRun is not applicable (reads issue their request as-is)`,
|
|
1319
1413
|
{ operation }
|
|
1320
1414
|
);
|
|
@@ -1329,12 +1423,30 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1329
1423
|
validateDispatchArgs(record, args);
|
|
1330
1424
|
validateParamsBag(record, args);
|
|
1331
1425
|
const boundedQuery = record.kind === "primitive" && record.operation === "query";
|
|
1332
|
-
let holder = client[
|
|
1426
|
+
let holder = client[_chunkWTVLHMZAcjs.camelKey.call(void 0, record.resource)];
|
|
1427
|
+
if (typeof holder === "function") {
|
|
1428
|
+
holder = _nullishCoalesce(client[`${_chunkWTVLHMZAcjs.camelKey.call(void 0, record.resource)}Resource`], () => ( holder));
|
|
1429
|
+
}
|
|
1333
1430
|
if (holder === void 0 && record.resource === "operations") {
|
|
1334
1431
|
holder = {
|
|
1335
1432
|
resolveAny: (identifier, opts2) => resolveAny(client, identifier, opts2),
|
|
1336
1433
|
searchAcrossResources: (query, opts2) => searchAcrossResources(client, query, opts2),
|
|
1337
1434
|
fetchMany: (items, opts2) => fetchMany(client, items, opts2),
|
|
1435
|
+
// Issue #62: the generic aggregate + the cheap count — the
|
|
1436
|
+
// groupBy/sum-absent mode is ONE vendor /query/count (the S12-C blind
|
|
1437
|
+
// sentinel rides through); the group/sum modes walk the named
|
|
1438
|
+
// <resource>.query op via the house bounded walk and fold client-side
|
|
1439
|
+
// (truncation honesty: hasMore/totalScanned — no silent partial sums).
|
|
1440
|
+
aggregate: (operation2, filter, opts2) => aggregate(client, operation2, filter, opts2),
|
|
1441
|
+
// Issue #59 PR-B: the bulk fetch by ids — query-first chunked `id in`
|
|
1442
|
+
// reads + the per-id `get` fallback (blind-surface-safe; per-item
|
|
1443
|
+
// typed outcomes reuse the fetchMany shapes).
|
|
1444
|
+
fetchByIds: (items, opts2) => fetchByIds(client, items, opts2),
|
|
1445
|
+
// Issue #65: opt-in resource name expansion — per-id resources.get
|
|
1446
|
+
// reads ONLY (never an id-in query — the resources table can be blind
|
|
1447
|
+
// to count/query while per-id reads work); blind-marked rows for ids
|
|
1448
|
+
// the API user cannot resolve; the name cache (default-on).
|
|
1449
|
+
expandResourceNames: (ids, opts2) => _chunkWTVLHMZAcjs.expandResourceNames.call(void 0, client, ids, opts2),
|
|
1338
1450
|
relationshipMap: (resourceKey) => relationshipMap(client, resourceKey),
|
|
1339
1451
|
// Issue #11: the served blind-surface inventory (zero wire) + the
|
|
1340
1452
|
// bounded caller-opted reachability sweep (read-only, confirmProbe-
|
|
@@ -1347,7 +1459,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1347
1459
|
// entityInformation GETs (the op's own cap refuses over-cap fan-outs
|
|
1348
1460
|
// pre-request; per-resource failures are recorded on the row and
|
|
1349
1461
|
// never abort the call).
|
|
1350
|
-
fieldCatalog: (opts2) => fieldCatalog(client, opts2),
|
|
1462
|
+
fieldCatalog: (opts2) => _chunkWTVLHMZAcjs.fieldCatalog.call(void 0, client, opts2),
|
|
1351
1463
|
// Issue #9: the one-call recovery/cleanup op — effect write in the
|
|
1352
1464
|
// registry (the governor's dry-run-first applies to it); the op's own
|
|
1353
1465
|
// confirm gate makes the destructive action deliberate (the governor
|
|
@@ -1356,7 +1468,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1356
1468
|
};
|
|
1357
1469
|
}
|
|
1358
1470
|
if (holder === void 0) {
|
|
1359
|
-
throw new (0,
|
|
1471
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1360
1472
|
`invoke: the client exposes no accessor for resource "${record.resource}"`,
|
|
1361
1473
|
{ operation }
|
|
1362
1474
|
);
|
|
@@ -1364,7 +1476,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1364
1476
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
1365
1477
|
const method = holder[methodName];
|
|
1366
1478
|
if (typeof method !== "function") {
|
|
1367
|
-
throw new (0,
|
|
1479
|
+
throw new (0, _chunkWTVLHMZAcjs.AutotaskConfigError)(
|
|
1368
1480
|
`invoke: "${record.resource}.${methodName}" is not a callable method on the client`,
|
|
1369
1481
|
{ operation }
|
|
1370
1482
|
);
|
|
@@ -1456,5 +1568,14 @@ async function invokeDelete(client, operation, args = [], opts = {}) {
|
|
|
1456
1568
|
|
|
1457
1569
|
|
|
1458
1570
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1571
|
+
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
|
|
1581
|
+
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 = _chunkWTVLHMZAcjs.EXPAND_RESOURCE_NAMES_MAX_IDS; exports.FETCH_BY_IDS_CHUNK_SIZE = FETCH_BY_IDS_CHUNK_SIZE; exports.FETCH_BY_IDS_MAX_ITEMS = FETCH_BY_IDS_MAX_ITEMS; exports.FETCH_MANY_MAX_ITEMS = FETCH_MANY_MAX_ITEMS; exports.FIELD_CACHE_KINDS = _chunkWTVLHMZAcjs.FIELD_CACHE_KINDS; exports.FIELD_CATALOG_HONESTY_NOTE = _chunkWTVLHMZAcjs.FIELD_CATALOG_HONESTY_NOTE; exports.INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS; exports.MAX_FIELD_CATALOG_WIRE = _chunkWTVLHMZAcjs.MAX_FIELD_CATALOG_WIRE; exports.PARAMS_BAG_KEYS = PARAMS_BAG_KEYS; exports.PICKLIST_VALUE_NOT_SERVED_NOTE = _chunkWTVLHMZAcjs.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.WORKFLOW_RESOURCES = _chunkWTVLHMZAcjs.WORKFLOW_RESOURCES; exports.aggregate = aggregate; exports.blindSurfaces = blindSurfaces; exports.createGuidance = createGuidance; exports.expandResourceNames = _chunkWTVLHMZAcjs.expandResourceNames; exports.fetchByIds = fetchByIds; exports.fetchMany = fetchMany; exports.fieldCatalog = _chunkWTVLHMZAcjs.fieldCatalog; 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.searchAcrossResources = searchAcrossResources; exports.unknownKeysRefusal = unknownKeysRefusal; exports.validateDispatchArgs = validateDispatchArgs; exports.validateFetchManyItems = validateFetchManyItems; exports.validateInvokeOptions = validateInvokeOptions; exports.validateParamsBag = validateParamsBag;
|