node-autotask 0.10.0 → 0.11.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/MCP_TOOL_CATALOG.json +3 -3
- package/MCP_TOOL_MANIFEST.md +5 -5
- package/N8N_MCP_MANIFEST.json +2 -2
- package/N8N_MCP_MANIFEST.md +3 -3
- package/capabilities.json +1327 -1236
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-QUM74WLQ.cjs → chunk-25ZUKHS4.cjs} +135 -135
- package/dist/{chunk-6KFP5HV3.js → chunk-7L23FDQW.js} +1326 -1235
- package/dist/{chunk-3VB6N44U.js → chunk-CJONZQ7E.js} +2 -2
- package/dist/{chunk-HWC2WPX2.js → chunk-LNRN45XS.js} +1 -1
- package/dist/{chunk-S7VMY5KN.cjs → chunk-QAX222R6.cjs} +365 -365
- package/dist/{chunk-NVJ2PTN3.js → chunk-SXHPUQMB.js} +2 -2
- package/dist/{chunk-WTVD2JZN.cjs → chunk-T5FLSJOD.cjs} +1326 -1235
- package/dist/{chunk-WTVLHMZA.cjs → chunk-YKEX4SK7.cjs} +2 -2
- package/dist/{index-DGgMD8aq.d.ts → index-B_xToSpq.d.ts} +1 -1
- package/dist/{index-BOyh7S65.d.cts → index-Dv_GSZaN.d.cts} +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +279 -130
- package/dist/operations/index.d.cts +22 -4
- package/dist/operations/index.d.ts +22 -4
- package/dist/operations/index.js +155 -6
- package/dist/pool.cjs +8 -8
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +3 -3
- package/package.json +1 -1
|
@@ -30,26 +30,26 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _chunkYKEX4SK7cjs = require('../chunk-YKEX4SK7.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkT5FLSJODcjs = require('../chunk-T5FLSJOD.cjs');
|
|
37
37
|
|
|
38
38
|
// src/operations/searchAcrossResources.ts
|
|
39
39
|
var DEFAULT_LIMIT = 25;
|
|
40
40
|
function resourceFor(client, key) {
|
|
41
|
-
return client[
|
|
41
|
+
return client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
42
42
|
}
|
|
43
43
|
async function searchAcrossResources(client, query, opts = {}) {
|
|
44
44
|
const text = query.trim();
|
|
45
45
|
if (text === "") {
|
|
46
|
-
throw new (0,
|
|
46
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("searchAcrossResources: query must be a non-empty string");
|
|
47
47
|
}
|
|
48
|
-
const keys = _nullishCoalesce(opts.resources, () => (
|
|
48
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkYKEX4SK7cjs.WORKFLOW_RESOURCES));
|
|
49
49
|
if (keys.length === 0) {
|
|
50
|
-
throw new (0,
|
|
50
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("searchAcrossResources: no resources requested");
|
|
51
51
|
}
|
|
52
|
-
const limit =
|
|
52
|
+
const limit = _chunkYKEX4SK7cjs.clampPageSize.call(void 0, _nullishCoalesce(opts.limit, () => ( DEFAULT_LIMIT)));
|
|
53
53
|
const results = [];
|
|
54
54
|
const skipped = [];
|
|
55
55
|
for (const key of keys) {
|
|
@@ -67,7 +67,7 @@ async function searchAcrossResources(client, query, opts = {}) {
|
|
|
67
67
|
|
|
68
68
|
// src/operations/resolveAny.ts
|
|
69
69
|
function resourceFor2(client, key) {
|
|
70
|
-
return client[
|
|
70
|
+
return client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
71
71
|
}
|
|
72
72
|
var FAULT_CATEGORIES = /* @__PURE__ */ new Set(["auth", "rate_limit", "server", "network", "timeout", "policy"]);
|
|
73
73
|
function missCost(identifier) {
|
|
@@ -76,13 +76,13 @@ function missCost(identifier) {
|
|
|
76
76
|
}
|
|
77
77
|
async function resolveAny(client, identifier, opts = {}) {
|
|
78
78
|
if (typeof identifier === "number") {
|
|
79
|
-
|
|
79
|
+
_chunkYKEX4SK7cjs.parseIdentifier.call(void 0, identifier, "identifier");
|
|
80
80
|
} else if (identifier.trim() === "") {
|
|
81
|
-
throw new (0,
|
|
81
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("resolveAny: identifier must be non-empty");
|
|
82
82
|
}
|
|
83
|
-
const keys = _nullishCoalesce(opts.resources, () => (
|
|
83
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkYKEX4SK7cjs.WORKFLOW_RESOURCES));
|
|
84
84
|
if (keys.length === 0) {
|
|
85
|
-
throw new (0,
|
|
85
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("resolveAny: no resources requested");
|
|
86
86
|
}
|
|
87
87
|
const results = [];
|
|
88
88
|
for (const key of keys) {
|
|
@@ -112,9 +112,9 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
112
112
|
} catch (err) {
|
|
113
113
|
let code;
|
|
114
114
|
let candidates = [];
|
|
115
|
-
if (err instanceof
|
|
115
|
+
if (err instanceof _chunkYKEX4SK7cjs.AutotaskConfigError) {
|
|
116
116
|
code = "CONFIG_ERROR";
|
|
117
|
-
} else if (
|
|
117
|
+
} else if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err)) {
|
|
118
118
|
if (FAULT_CATEGORIES.has(err.category)) throw err;
|
|
119
119
|
code = err.code;
|
|
120
120
|
if (code === "RESOLUTION_AMBIGUOUS" && err.resourceIds !== void 0) {
|
|
@@ -258,12 +258,71 @@ var MODEL_FIELD_SETS = {
|
|
|
258
258
|
"time_entry_attachments": ["id", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "contentType", "creatorType", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentID", "publish", "taskID", "ticketID", "timeEntryID", "title", "data", "parentType", "soapParentPropertyId", "isTaskAttachment"],
|
|
259
259
|
"time_off_requests": ["id", "approvedDateTime", "approveRejectResourceID", "createdByResourceID", "createDateTime", "endTime", "hours", "impersonatorApproveRejectResourceID", "lastModifiedByResourceID", "lastModifiedDateTime", "lastApprovedLevel", "reason", "rejectReason", "requestDate", "resourceID", "startTime", "status", "timeOffRequestType", "soapParentPropertyId"]
|
|
260
260
|
};
|
|
261
|
+
var MODEL_DATE_FIELDS = {
|
|
262
|
+
"appointments": ["createDateTime", "endDateTime", "startDateTime", "updateDateTime"],
|
|
263
|
+
"billing_items": ["itemDate", "postedDate", "postedOnTime", "webServiceDate"],
|
|
264
|
+
"companies": ["createDate", "lastActivityDate", "lastTrackedModifiedDateTime"],
|
|
265
|
+
"company_notes": ["completedDateTime", "createDateTime", "endDateTime", "lastModifiedDate", "startDateTime"],
|
|
266
|
+
"configuration_item_billing_product_associations": ["effectiveDate", "expirationDate"],
|
|
267
|
+
"configuration_item_dns_records": ["createDateTime"],
|
|
268
|
+
"configuration_item_notes": ["createDateTime", "lastActivityDate"],
|
|
269
|
+
"configuration_items": ["createDate", "dattoLastCheckInDateTime", "domainRegistrationDateTime", "domainLastUpdatedDateTime", "domainExpirationDateTime", "installDate", "lastModifiedTime", "sslValidFromDateTime", "sslValidUntilDateTime", "warrantyExpirationDate"],
|
|
270
|
+
"contacts": ["bulkEmailOptOutTime", "createDate", "lastActivityDate", "lastModifiedDate", "solicitationOptOutTime"],
|
|
271
|
+
"contract_billing_rules": ["endDate", "startDate"],
|
|
272
|
+
"contract_blocks": ["datePurchased", "endDate", "startDate"],
|
|
273
|
+
"contract_charges": ["createDate", "datePurchased", "statusLastModifiedDate"],
|
|
274
|
+
"contract_milestones": ["createDate", "dateDue"],
|
|
275
|
+
"contract_notes": ["createDateTime", "lastActivityDate"],
|
|
276
|
+
"contract_retainers": ["datePurchased", "endDate", "startDate"],
|
|
277
|
+
"contract_service_bundle_units": ["approveAndPostDate", "endDate", "startDate"],
|
|
278
|
+
"contract_service_units": ["approveAndPostDate", "endDate", "startDate"],
|
|
279
|
+
"contract_ticket_purchases": ["datePurchased", "endDate", "startDate"],
|
|
280
|
+
"contracts": ["endDate", "lastModifiedDateTime", "startDate"],
|
|
281
|
+
"expense_item_attachments": ["attachDate"],
|
|
282
|
+
"expense_items": ["expenseDate"],
|
|
283
|
+
"expense_reports": ["approvedDate", "submitDate", "weekEnding"],
|
|
284
|
+
"holidays": ["holidayDate"],
|
|
285
|
+
"inventory_products": ["createDateTime"],
|
|
286
|
+
"invoices": ["createDateTime", "dueDate", "fromDate", "invoiceDateTime", "paidDate", "toDate", "voidedDate", "webServiceDate"],
|
|
287
|
+
"notification_history": ["notificationSentTime"],
|
|
288
|
+
"opportunities": ["closedDate", "createDate", "lastActivity", "lostDate", "projectedCloseDate", "promisedFulfillmentDate", "startDate", "throughDate"],
|
|
289
|
+
"opportunity_attachments": ["attachDate"],
|
|
290
|
+
"phases": ["createDate", "dueDate", "lastActivityDateTime", "startDate"],
|
|
291
|
+
"products": ["createdTime"],
|
|
292
|
+
"project_charges": ["createDate", "datePurchased", "statusLastModifiedDate"],
|
|
293
|
+
"project_notes": ["createDateTime", "lastActivityDate"],
|
|
294
|
+
"projects": ["completedDateTime", "createDateTime", "endDateTime", "lastActivityDateTime", "startDateTime", "statusDateTime"],
|
|
295
|
+
"purchase_order_item_receiving": ["receiveDate"],
|
|
296
|
+
"purchase_order_items": ["estimatedArrivalDate"],
|
|
297
|
+
"purchase_orders": ["cancelDateTime", "createDateTime", "latestEstimatedArrivalDate", "shippingDate", "submitDateTime"],
|
|
298
|
+
"quote_templates": ["createDate", "lastActivityDate"],
|
|
299
|
+
"quotes": ["approvalStatusChangedDate", "createDate", "effectiveDate", "expirationDate", "extApprovalResponseDate", "lastActivityDate", "lastPublishedDateTime"],
|
|
300
|
+
"resources": ["hireDate"],
|
|
301
|
+
"service_calls": ["canceledDateTime", "createDateTime", "endDateTime", "lastModifiedDateTime", "startDateTime"],
|
|
302
|
+
"services": ["createDate", "lastModifiedDate"],
|
|
303
|
+
"subscription_periods": ["periodDate", "postedDate"],
|
|
304
|
+
"subscriptions": ["effectiveDate", "expirationDate"],
|
|
305
|
+
"survey_results": ["completeDate", "sendDate"],
|
|
306
|
+
"tags": ["createDateTime", "lastModifiedDateTime"],
|
|
307
|
+
"tasks": ["completedDateTime", "createDateTime", "endDateTime", "lastActivityDateTime", "startDateTime"],
|
|
308
|
+
"ticket_attachments": ["attachDate"],
|
|
309
|
+
"ticket_change_request_approvals": ["approveRejectDateTime"],
|
|
310
|
+
"ticket_charges": ["createDate", "datePurchased", "statusLastModifiedDate"],
|
|
311
|
+
"ticket_checklist_items": ["completedDateTime"],
|
|
312
|
+
"ticket_history": ["date"],
|
|
313
|
+
"ticket_note_attachments": ["attachDate"],
|
|
314
|
+
"ticket_notes": ["createDateTime", "lastActivityDate"],
|
|
315
|
+
"tickets": ["completedDate", "createDate", "dueDateTime", "firstResponseDateTime", "firstResponseDueDateTime", "lastActivityDate", "lastCustomerNotificationDateTime", "lastCustomerVisibleActivityDateTime", "lastTrackedModificationDateTime", "resolutionPlanDateTime", "resolutionPlanDueDateTime", "resolvedDateTime", "resolvedDueDateTime"],
|
|
316
|
+
"time_entries": ["billingApprovalDateTime", "createDateTime", "dateWorked", "endDateTime", "lastModifiedDateTime", "startDateTime"],
|
|
317
|
+
"time_entry_attachments": ["attachDate"],
|
|
318
|
+
"time_off_requests": ["approvedDateTime", "createDateTime", "endTime", "lastModifiedDateTime", "requestDate", "startTime"]
|
|
319
|
+
};
|
|
261
320
|
|
|
262
321
|
// src/operations/fetchMany.ts
|
|
263
322
|
var FETCH_MANY_MAX_ITEMS = 20;
|
|
264
323
|
function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETCH_MANY_MAX_ITEMS = ${FETCH_MANY_MAX_ITEMS}`, validation) {
|
|
265
324
|
if (!Array.isArray(items)) {
|
|
266
|
-
throw new (0,
|
|
325
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
267
326
|
`${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})`,
|
|
268
327
|
{
|
|
269
328
|
suggestedAction: 'Pass args = [[{ resource: "tickets", id: 123 }, { resource: "projects", id: 456 }]] \u2014 the items array is the single positional argument.'
|
|
@@ -271,12 +330,12 @@ function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETC
|
|
|
271
330
|
);
|
|
272
331
|
}
|
|
273
332
|
if (items.length === 0) {
|
|
274
|
-
throw new (0,
|
|
333
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`${opName}: items must not be empty (a zero-item batch is a shape error, not a no-op)`, {
|
|
275
334
|
suggestedAction: "Pass at least one { resource, id } item \u2014 or use the resource's query op for a filtered read."
|
|
276
335
|
});
|
|
277
336
|
}
|
|
278
337
|
if (items.length > cap) {
|
|
279
|
-
throw new (0,
|
|
338
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
280
339
|
`${opName}: ${items.length} items over the ${cap}-item cap (${capRef}) \u2014 zero items were fetched (pre-request)`,
|
|
281
340
|
{
|
|
282
341
|
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).`
|
|
@@ -304,15 +363,15 @@ function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETC
|
|
|
304
363
|
);
|
|
305
364
|
continue;
|
|
306
365
|
}
|
|
307
|
-
const rel =
|
|
366
|
+
const rel = _chunkYKEX4SK7cjs.RELATIONSHIP_MAP[resourceKey];
|
|
308
367
|
if (rel !== void 0 && rel.parentScoped) {
|
|
309
368
|
problems.push(
|
|
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.${
|
|
369
|
+
`${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.${_chunkYKEX4SK7cjs.camelKey.call(void 0, resourceKey)}.get(parentId, id))`
|
|
311
370
|
);
|
|
312
371
|
continue;
|
|
313
372
|
}
|
|
314
373
|
try {
|
|
315
|
-
|
|
374
|
+
_chunkYKEX4SK7cjs.parseIdentifier.call(void 0, item.id, `${at}.id`);
|
|
316
375
|
} catch (e2) {
|
|
317
376
|
if (typeof item.id === "string") {
|
|
318
377
|
problems.push(
|
|
@@ -345,7 +404,7 @@ function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETC
|
|
|
345
404
|
}
|
|
346
405
|
}
|
|
347
406
|
if (problems.length > 0) {
|
|
348
|
-
throw new (0,
|
|
407
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
349
408
|
`${opName}: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
350
409
|
- ` + problems.join("\n- "),
|
|
351
410
|
{ suggestedAction: "Fix every item above and call again \u2014 validation covers the whole batch up-front (one round, zero wire)." }
|
|
@@ -362,11 +421,11 @@ function project(value, fields) {
|
|
|
362
421
|
async function fetchMany(client, items, opts = {}) {
|
|
363
422
|
if (opts.maxItems !== void 0) {
|
|
364
423
|
if (!Number.isInteger(opts.maxItems) || opts.maxItems < 1) {
|
|
365
|
-
throw new (0,
|
|
424
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: maxItems must be an integer >= 1 (got ${String(opts.maxItems)})`);
|
|
366
425
|
}
|
|
367
426
|
}
|
|
368
427
|
if (opts.liveFields !== void 0 && typeof opts.liveFields !== "boolean") {
|
|
369
|
-
throw new (0,
|
|
428
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: liveFields must be a boolean (got ${typeof opts.liveFields})`);
|
|
370
429
|
}
|
|
371
430
|
const cap = Math.min(FETCH_MANY_MAX_ITEMS, _nullishCoalesce(opts.maxItems, () => ( FETCH_MANY_MAX_ITEMS)));
|
|
372
431
|
if (opts.liveFields === true) {
|
|
@@ -375,9 +434,9 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
375
434
|
for (const item of items) {
|
|
376
435
|
const key = item.resource;
|
|
377
436
|
if (liveFieldSets.has(key)) continue;
|
|
378
|
-
const holder = client[
|
|
437
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
379
438
|
if (holder === void 0) {
|
|
380
|
-
throw new (0,
|
|
439
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: the client exposes no accessor for resource "${key}"`, {
|
|
381
440
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
382
441
|
});
|
|
383
442
|
}
|
|
@@ -389,7 +448,7 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
389
448
|
}
|
|
390
449
|
liveFieldSets.set(key, names.length > 0 ? names : null);
|
|
391
450
|
} catch (err) {
|
|
392
|
-
if (!
|
|
451
|
+
if (!_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
393
452
|
liveFieldSets.set(key, null);
|
|
394
453
|
}
|
|
395
454
|
}
|
|
@@ -400,10 +459,10 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
400
459
|
const results = [];
|
|
401
460
|
for (const item of items) {
|
|
402
461
|
const key = item.resource;
|
|
403
|
-
const id =
|
|
404
|
-
const holder = client[
|
|
462
|
+
const id = _chunkYKEX4SK7cjs.parseIdentifier.call(void 0, item.id, `items[${results.length}].id`);
|
|
463
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
405
464
|
if (holder === void 0) {
|
|
406
|
-
throw new (0,
|
|
465
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: the client exposes no accessor for resource "${key}"`, {
|
|
407
466
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
408
467
|
});
|
|
409
468
|
}
|
|
@@ -411,9 +470,9 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
411
470
|
const value = await holder.get(id);
|
|
412
471
|
results.push({ resource: key, id, found: true, value: item.fields !== void 0 ? project(value, item.fields) : value });
|
|
413
472
|
} catch (err) {
|
|
414
|
-
if (err instanceof
|
|
473
|
+
if (err instanceof _chunkYKEX4SK7cjs.NotFoundError) {
|
|
415
474
|
results.push({ resource: key, id, found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
416
|
-
} else if (
|
|
475
|
+
} else if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
417
476
|
const e = { code: err.code, message: err.message };
|
|
418
477
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
419
478
|
results.push({ resource: key, id, found: false, value: null, error: e });
|
|
@@ -429,10 +488,64 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
429
488
|
// src/operations/aggregate.ts
|
|
430
489
|
var AGGREGATE_TOP_MAX = 100;
|
|
431
490
|
var AGGREGATE_DEFAULT_TOP = 25;
|
|
432
|
-
var AGGREGATE_DEFAULT_LIMIT =
|
|
491
|
+
var AGGREGATE_DEFAULT_LIMIT = _chunkYKEX4SK7cjs.BOUNDED_QUERY_MAX_LIMIT;
|
|
492
|
+
var AGGREGATE_DATE_BUCKETS = ["month", "week", "year"];
|
|
493
|
+
var DATE_ONLY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
494
|
+
var DATETIME_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,9})?(Z|[+-]\d{2}:?\d{2})?$/;
|
|
495
|
+
function parseDateInstant(v) {
|
|
496
|
+
if (typeof v !== "string") return null;
|
|
497
|
+
let m = v.match(DATE_ONLY_RE);
|
|
498
|
+
if (m) {
|
|
499
|
+
return _nullishCoalesce(validUtc(Number(m[1]), Number(m[2]), Number(m[3])), () => ( null));
|
|
500
|
+
}
|
|
501
|
+
m = v.match(DATETIME_RE);
|
|
502
|
+
if (m) {
|
|
503
|
+
const t = validUtc(Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4]), Number(m[5]), Number(m[6]));
|
|
504
|
+
if (t === null) return null;
|
|
505
|
+
const zone = m[8];
|
|
506
|
+
if (zone === void 0 || zone === "Z") return t;
|
|
507
|
+
const sign = zone[0] === "-" ? -1 : 1;
|
|
508
|
+
const hh = Number(zone.slice(1, 3));
|
|
509
|
+
const mm = Number(zone.slice(zone.length - 2));
|
|
510
|
+
return t - sign * (hh * 60 + mm) * 6e4;
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
function validUtc(y, mo, d, h = 0, mi = 0, s = 0) {
|
|
515
|
+
const dt = new Date(Date.UTC(y, mo - 1, d, h, mi, s));
|
|
516
|
+
if (y >= 0 && y < 100) dt.setUTCFullYear(y);
|
|
517
|
+
if (dt.getUTCFullYear() !== y || dt.getUTCMonth() !== mo - 1 || dt.getUTCDate() !== d || dt.getUTCHours() !== h || dt.getUTCMinutes() !== mi || dt.getUTCSeconds() !== s) {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
return dt.getTime();
|
|
521
|
+
}
|
|
522
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
523
|
+
function isoWeekLabel(ms) {
|
|
524
|
+
const d = new Date(ms);
|
|
525
|
+
const dow = d.getUTCDay() || 7;
|
|
526
|
+
const S = d.getUTCFullYear() < 200 ? 100 : 0;
|
|
527
|
+
const thu = new Date(Date.UTC(d.getUTCFullYear() + S, d.getUTCMonth(), d.getUTCDate() + (4 - dow)));
|
|
528
|
+
const isoYear = thu.getUTCFullYear() - S;
|
|
529
|
+
const week = Math.ceil(((thu.getTime() - Date.UTC(thu.getUTCFullYear(), 0, 1)) / 864e5 + 1) / 7);
|
|
530
|
+
return `${isoYear}-W${pad2(week)}`;
|
|
531
|
+
}
|
|
532
|
+
function dateBucketLabel(value, bucket) {
|
|
533
|
+
if (value === null || value === void 0) return null;
|
|
534
|
+
const t = parseDateInstant(value);
|
|
535
|
+
if (t === null) return value;
|
|
536
|
+
const d = new Date(t);
|
|
537
|
+
switch (bucket) {
|
|
538
|
+
case "month":
|
|
539
|
+
return `${d.getUTCFullYear()}-${pad2(d.getUTCMonth() + 1)}`;
|
|
540
|
+
case "year":
|
|
541
|
+
return `${d.getUTCFullYear()}`;
|
|
542
|
+
case "week":
|
|
543
|
+
return isoWeekLabel(t);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
433
546
|
var QUERY_RESOURCE_KEYS = (() => {
|
|
434
547
|
const s = /* @__PURE__ */ new Set();
|
|
435
|
-
for (const rec of
|
|
548
|
+
for (const rec of _chunkT5FLSJODcjs.CAPABILITIES) if (rec.operation === "query") s.add(rec.resource);
|
|
436
549
|
return s;
|
|
437
550
|
})();
|
|
438
551
|
var AGGREGATE_OPT_KEYS = ["groupBy", "sum", "top", "limit"];
|
|
@@ -467,14 +580,14 @@ function validateAggregate(operation, filter, opts) {
|
|
|
467
580
|
conditions = [];
|
|
468
581
|
} else {
|
|
469
582
|
try {
|
|
470
|
-
conditions =
|
|
583
|
+
conditions = _chunkYKEX4SK7cjs.buildFilter.call(void 0, conds).filter;
|
|
471
584
|
} catch (err) {
|
|
472
|
-
problems.push(err instanceof
|
|
585
|
+
problems.push(err instanceof _chunkYKEX4SK7cjs.AutotaskConfigError ? err.message : `filter must be the query-bag filter (13 operators; caps 500 OR-conditions / 1 UDF / 8000 chars); ${String(err)}`);
|
|
473
586
|
}
|
|
474
587
|
}
|
|
475
588
|
}
|
|
476
589
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
477
|
-
throw new (0,
|
|
590
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
478
591
|
`aggregate: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
479
592
|
{ operation: "operations.aggregate" }
|
|
480
593
|
);
|
|
@@ -485,6 +598,7 @@ function validateAggregate(operation, filter, opts) {
|
|
|
485
598
|
}
|
|
486
599
|
}
|
|
487
600
|
const fieldSets = resourceKey !== void 0 ? MODEL_FIELD_SETS[resourceKey] : void 0;
|
|
601
|
+
const dateSets = resourceKey !== void 0 ? MODEL_DATE_FIELDS[resourceKey] : void 0;
|
|
488
602
|
const checkFields = (name, fields) => {
|
|
489
603
|
if (fields === void 0) return [];
|
|
490
604
|
if (!Array.isArray(fields) || fields.length === 0 || fields.some((f) => typeof f !== "string" || f.trim() === "")) {
|
|
@@ -501,7 +615,39 @@ function validateAggregate(operation, filter, opts) {
|
|
|
501
615
|
}
|
|
502
616
|
return out;
|
|
503
617
|
};
|
|
504
|
-
const groupBy =
|
|
618
|
+
const groupBy = [];
|
|
619
|
+
if (opts.groupBy !== void 0) {
|
|
620
|
+
if (!Array.isArray(opts.groupBy) || opts.groupBy.length === 0 || opts.groupBy.some((f) => typeof f !== "string" || f.trim() === "")) {
|
|
621
|
+
problems.push("groupBy must be a non-empty array of exact vendor field names (a date-typed field may carry the closed bucket suffix @month | @week | @year \u2014 discover them via operations.fieldCatalog)");
|
|
622
|
+
} else {
|
|
623
|
+
for (const f of opts.groupBy) {
|
|
624
|
+
const at = f.indexOf("@");
|
|
625
|
+
if (at === -1) {
|
|
626
|
+
if (fieldSets === void 0 || !fieldSets.includes(f)) {
|
|
627
|
+
problems.push(`groupBy: "${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)`);
|
|
628
|
+
} else {
|
|
629
|
+
groupBy.push({ name: f, base: f });
|
|
630
|
+
}
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
const base = f.slice(0, at);
|
|
634
|
+
const suffix = f.slice(at + 1);
|
|
635
|
+
if (!AGGREGATE_DATE_BUCKETS.includes(suffix)) {
|
|
636
|
+
problems.push(`groupBy: "${f}": unknown bucket suffix "${suffix}" \u2014 the closed set is month | week | year (the suffix applies to date-typed fields only)`);
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
if (fieldSets === void 0 || !fieldSets.includes(base)) {
|
|
640
|
+
problems.push(`groupBy: "${f}": "${base}" 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)`);
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
if (dateSets === void 0 || !dateSets.includes(base)) {
|
|
644
|
+
problems.push(`groupBy: "${f}": "${base}" is not a date field of ${resourceKey} (the @month/@week/@year bucket suffix applies to date-typed fields of the resource's vendored model \u2014 exact vendor field names via operations.fieldCatalog)`);
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
groupBy.push({ name: f, base, bucket: suffix });
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
505
651
|
const sum = checkFields("sum", opts.sum);
|
|
506
652
|
let top = AGGREGATE_DEFAULT_TOP;
|
|
507
653
|
if (opts.top !== void 0) {
|
|
@@ -516,11 +662,11 @@ function validateAggregate(operation, filter, opts) {
|
|
|
516
662
|
if (!Number.isInteger(opts.limit)) {
|
|
517
663
|
problems.push(`limit must be an integer (got ${String(opts.limit)})`);
|
|
518
664
|
} else {
|
|
519
|
-
limit = Math.min(Math.max(opts.limit, 1),
|
|
665
|
+
limit = Math.min(Math.max(opts.limit, 1), _chunkYKEX4SK7cjs.BOUNDED_QUERY_MAX_LIMIT);
|
|
520
666
|
}
|
|
521
667
|
}
|
|
522
668
|
if (problems.length > 0) {
|
|
523
|
-
throw new (0,
|
|
669
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
524
670
|
`aggregate: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
525
671
|
- ` + problems.join("\n- "),
|
|
526
672
|
{ operation: "operations.aggregate" }
|
|
@@ -530,9 +676,9 @@ function validateAggregate(operation, filter, opts) {
|
|
|
530
676
|
}
|
|
531
677
|
async function aggregate(client, operation, filter, opts = {}) {
|
|
532
678
|
const v = validateAggregate(operation, filter, opts);
|
|
533
|
-
const holder = client[
|
|
679
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, v.resourceKey)];
|
|
534
680
|
if (holder === void 0) {
|
|
535
|
-
throw new (0,
|
|
681
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`aggregate: the client exposes no accessor for resource "${v.resourceKey}"`, {
|
|
536
682
|
operation: "operations.aggregate",
|
|
537
683
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
538
684
|
});
|
|
@@ -551,9 +697,10 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
551
697
|
for (const item of res.items) {
|
|
552
698
|
const key = {};
|
|
553
699
|
const values = [];
|
|
554
|
-
for (const
|
|
555
|
-
const
|
|
556
|
-
|
|
700
|
+
for (const spec of v.groupBy) {
|
|
701
|
+
const raw = item[spec.base] === void 0 ? null : item[spec.base];
|
|
702
|
+
const value = spec.bucket === void 0 ? raw : dateBucketLabel(raw, spec.bucket);
|
|
703
|
+
key[spec.name] = value;
|
|
557
704
|
values.push(value);
|
|
558
705
|
}
|
|
559
706
|
const keyOrder = JSON.stringify(values);
|
|
@@ -595,7 +742,7 @@ function project2(value, fields) {
|
|
|
595
742
|
function resourcePathOf(key, holder) {
|
|
596
743
|
const path = _optionalChain([holder, 'optionalAccess', _5 => _5.resourcePath]);
|
|
597
744
|
if (typeof path !== "string" || path === "") {
|
|
598
|
-
throw new (0,
|
|
745
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchByIds: the client exposes no ${key} resource path (registry drift)`, {
|
|
599
746
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
600
747
|
});
|
|
601
748
|
}
|
|
@@ -604,7 +751,7 @@ function resourcePathOf(key, holder) {
|
|
|
604
751
|
async function fetchByIds(client, items, opts = {}) {
|
|
605
752
|
if (opts.maxItems !== void 0) {
|
|
606
753
|
if (!Number.isInteger(opts.maxItems) || opts.maxItems < 1) {
|
|
607
|
-
throw new (0,
|
|
754
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchByIds: maxItems must be an integer >= 1 (got ${String(opts.maxItems)})`);
|
|
608
755
|
}
|
|
609
756
|
}
|
|
610
757
|
const cap = Math.min(FETCH_BY_IDS_MAX_ITEMS, _nullishCoalesce(opts.maxItems, () => ( FETCH_BY_IDS_MAX_ITEMS)));
|
|
@@ -613,7 +760,7 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
613
760
|
const canonical = [];
|
|
614
761
|
for (let i = 0; i < items.length; i += 1) {
|
|
615
762
|
const item = items[i];
|
|
616
|
-
const id =
|
|
763
|
+
const id = _chunkYKEX4SK7cjs.parseIdentifier.call(void 0, item.id, `items[${i}].id`);
|
|
617
764
|
canonical[i] = id;
|
|
618
765
|
const g = _nullishCoalesce(groups.get(item.resource), () => ( { indices: [], fields: /* @__PURE__ */ new Set(), anyFields: false }));
|
|
619
766
|
g.indices.push(i);
|
|
@@ -625,9 +772,9 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
625
772
|
}
|
|
626
773
|
const byKey = /* @__PURE__ */ new Map();
|
|
627
774
|
for (const [key, group] of groups) {
|
|
628
|
-
const holder = client[
|
|
775
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
629
776
|
if (holder === void 0) {
|
|
630
|
-
throw new (0,
|
|
777
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchByIds: the client exposes no accessor for resource "${key}"`, {
|
|
631
778
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
632
779
|
});
|
|
633
780
|
}
|
|
@@ -647,13 +794,13 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
647
794
|
const chunk = unique.slice(c, c + FETCH_BY_IDS_CHUNK_SIZE);
|
|
648
795
|
const chunkKeys = new Set(chunk.map((id) => String(id)));
|
|
649
796
|
try {
|
|
650
|
-
const req =
|
|
797
|
+
const req = _chunkYKEX4SK7cjs.buildQueryRequest.call(void 0, client.http.baseUrl, resourcePath, {
|
|
651
798
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
652
799
|
maxRecords: FETCH_BY_IDS_CHUNK_SIZE,
|
|
653
800
|
includeFields
|
|
654
801
|
});
|
|
655
802
|
const res = await client.http.request({ ...req, operation: `${key}.fetchByIds` });
|
|
656
|
-
const { items: rows } =
|
|
803
|
+
const { items: rows } = _chunkYKEX4SK7cjs.unwrapItems.call(void 0, res, `${key}.fetchByIds`);
|
|
657
804
|
for (const row of rows) {
|
|
658
805
|
const k = String(row.id);
|
|
659
806
|
if (!chunkKeys.has(k)) continue;
|
|
@@ -661,7 +808,7 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
661
808
|
if (!byKey.has(q)) byKey.set(q, { found: true, value: row });
|
|
662
809
|
}
|
|
663
810
|
} catch (err) {
|
|
664
|
-
if (
|
|
811
|
+
if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
665
812
|
const e = { code: err.code, message: err.message };
|
|
666
813
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
667
814
|
for (const u of chunk) {
|
|
@@ -680,9 +827,9 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
680
827
|
const value = await holder.get(id);
|
|
681
828
|
byKey.set(k, { found: true, value });
|
|
682
829
|
} catch (err) {
|
|
683
|
-
if (err instanceof
|
|
830
|
+
if (err instanceof _chunkYKEX4SK7cjs.NotFoundError) {
|
|
684
831
|
byKey.set(k, { found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
685
|
-
} else if (
|
|
832
|
+
} else if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
686
833
|
const e = { code: err.code, message: err.message };
|
|
687
834
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
688
835
|
byKey.set(k, { found: false, value: null, error: e });
|
|
@@ -710,20 +857,20 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
710
857
|
async function relationshipMap(client, resourceKey) {
|
|
711
858
|
void client;
|
|
712
859
|
if (typeof resourceKey !== "string" || resourceKey.trim() === "") {
|
|
713
|
-
throw new (0,
|
|
860
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
714
861
|
`relationshipMap: resourceKey must be a non-empty plan resource key string (e.g. 'tickets'; got ${typeof resourceKey === "string" ? "a blank string" : typeof resourceKey})`,
|
|
715
862
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items, ticket_notes." }
|
|
716
863
|
);
|
|
717
864
|
}
|
|
718
865
|
const key = resourceKey.trim();
|
|
719
|
-
const entry =
|
|
866
|
+
const entry = _chunkYKEX4SK7cjs.RELATIONSHIP_MAP[key];
|
|
720
867
|
if (entry === void 0) {
|
|
721
|
-
throw new (0,
|
|
722
|
-
`relationshipMap: unknown resource "${key}" \u2014 the plan has ${Object.keys(
|
|
868
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskError)(
|
|
869
|
+
`relationshipMap: unknown resource "${key}" \u2014 the plan has ${Object.keys(_chunkYKEX4SK7cjs.RELATIONSHIP_MAP).length} resources`,
|
|
723
870
|
{
|
|
724
871
|
code: "RESOURCE_UNKNOWN",
|
|
725
872
|
category: "validation",
|
|
726
|
-
suggestedAction: `Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items). Zone facts served are ${
|
|
873
|
+
suggestedAction: `Pass the exact plan resource key (snake_case) from autotask_catalog (e.g. tickets, companies, configuration_items). Zone facts served are ${_chunkYKEX4SK7cjs.RELATIONSHIP_ZONE.label} (${_chunkYKEX4SK7cjs.RELATIONSHIP_ZONE.zone})-verified.`
|
|
727
874
|
}
|
|
728
875
|
);
|
|
729
876
|
}
|
|
@@ -740,24 +887,24 @@ var BLIND_SURFACE_KINDS = [
|
|
|
740
887
|
async function blindSurfaces(client, opts) {
|
|
741
888
|
void client;
|
|
742
889
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
743
|
-
throw new (0,
|
|
890
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("blindSurfaces: opts must be an object { resource?: string, kind?: BlindSurfaceKind }");
|
|
744
891
|
}
|
|
745
|
-
const inv =
|
|
892
|
+
const inv = _chunkYKEX4SK7cjs.BLIND_SURFACE_INVENTORY;
|
|
746
893
|
if (inv === null) {
|
|
747
|
-
throw new (0,
|
|
894
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("blindSurfaces: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
748
895
|
}
|
|
749
896
|
let surfaces = inv.surfaces;
|
|
750
897
|
if (_optionalChain([opts, 'optionalAccess', _6 => _6.resource]) !== void 0) {
|
|
751
898
|
const key = typeof opts.resource === "string" ? opts.resource.trim() : "";
|
|
752
899
|
if (key === "") {
|
|
753
|
-
throw new (0,
|
|
900
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
754
901
|
"blindSurfaces: opts.resource must be a non-empty plan resource key string (e.g. 'tickets')",
|
|
755
902
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items." }
|
|
756
903
|
);
|
|
757
904
|
}
|
|
758
905
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
759
|
-
throw new (0,
|
|
760
|
-
`blindSurfaces: unknown resource "${key}" \u2014 the plan has ${Object.keys(
|
|
906
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskError)(
|
|
907
|
+
`blindSurfaces: unknown resource "${key}" \u2014 the plan has ${Object.keys(_chunkYKEX4SK7cjs.RELATIONSHIP_MAP).length} resources`,
|
|
761
908
|
{
|
|
762
909
|
code: "RESOURCE_UNKNOWN",
|
|
763
910
|
category: "validation",
|
|
@@ -769,7 +916,7 @@ async function blindSurfaces(client, opts) {
|
|
|
769
916
|
}
|
|
770
917
|
if (_optionalChain([opts, 'optionalAccess', _7 => _7.kind]) !== void 0) {
|
|
771
918
|
if (!BLIND_SURFACE_KINDS.includes(opts.kind)) {
|
|
772
|
-
throw new (0,
|
|
919
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
773
920
|
`blindSurfaces: unknown kind "${String(opts.kind)}" \u2014 the valid classes are: ${BLIND_SURFACE_KINDS.join(", ")}`,
|
|
774
921
|
{ suggestedAction: `Filter with one of: ${BLIND_SURFACE_KINDS.join(", ")} (or omit kind for the full 116-surface inventory).` }
|
|
775
922
|
);
|
|
@@ -782,51 +929,51 @@ async function blindSurfaces(client, opts) {
|
|
|
782
929
|
// src/operations/probeReachability.ts
|
|
783
930
|
async function probeReachability(client, opts) {
|
|
784
931
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
785
|
-
throw new (0,
|
|
932
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("probeReachability: opts must be an object { resources?: string[], limit?: 1|2, maxWireCalls?: number, confirmProbe?: true }");
|
|
786
933
|
}
|
|
787
|
-
const defs =
|
|
934
|
+
const defs = _chunkYKEX4SK7cjs.REACHABILITY_PROBE_DEFAULTS;
|
|
788
935
|
if (_optionalChain([opts, 'optionalAccess', _8 => _8.confirmProbe]) !== true) {
|
|
789
|
-
throw new (0,
|
|
936
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
790
937
|
"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",
|
|
791
938
|
{ suggestedAction: `Re-call with { confirmProbe: true } (plus resources/limit/maxWireCalls as needed). For the ZERO-wire pinned inventory use operations.blindSurfaces.` }
|
|
792
939
|
);
|
|
793
940
|
}
|
|
794
941
|
const limit = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _9 => _9.limit]), () => ( defs.limitDefault));
|
|
795
942
|
if (!Number.isInteger(limit) || limit < 1 || limit > defs.limitMax) {
|
|
796
|
-
throw new (0,
|
|
943
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
797
944
|
`probeReachability: limit must be an integer 1..${defs.limitMax} (got ${String(limit)}) \u2014 the rows-per-surface bound for the discovery read`
|
|
798
945
|
);
|
|
799
946
|
}
|
|
800
947
|
const cap = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _10 => _10.maxWireCalls]), () => ( defs.defaultCap));
|
|
801
948
|
if (!Number.isInteger(cap) || cap < 1) {
|
|
802
|
-
throw new (0,
|
|
949
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`probeReachability: maxWireCalls must be a positive integer (got ${String(cap)})`);
|
|
803
950
|
}
|
|
804
951
|
if (cap > defs.hardCap) {
|
|
805
|
-
throw new (0,
|
|
952
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
806
953
|
`probeReachability: maxWireCalls ${cap} exceeds the hard wire cap of ${defs.hardCap} \u2014 the sweep is refused above it (never capped silently)`,
|
|
807
954
|
{ suggestedAction: `Pass maxWireCalls \u2264 ${defs.hardCap} and a resources set no larger than the cap (the refused set is never truncated).` }
|
|
808
955
|
);
|
|
809
956
|
}
|
|
810
|
-
const inv =
|
|
957
|
+
const inv = _chunkYKEX4SK7cjs.BLIND_SURFACE_INVENTORY;
|
|
811
958
|
if (inv === null) {
|
|
812
|
-
throw new (0,
|
|
959
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("probeReachability: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
813
960
|
}
|
|
814
961
|
let targets;
|
|
815
962
|
if (_optionalChain([opts, 'optionalAccess', _11 => _11.resources]) === void 0) {
|
|
816
963
|
targets = [...defs.defaultTargets];
|
|
817
964
|
} else {
|
|
818
965
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
819
|
-
throw new (0,
|
|
966
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("probeReachability: opts.resources must be a non-empty string[] of plan resource keys (or omit it for the default non-data-full set)");
|
|
820
967
|
}
|
|
821
968
|
const seen = /* @__PURE__ */ new Set();
|
|
822
969
|
for (const r of opts.resources) {
|
|
823
970
|
if (typeof r !== "string" || r.trim() === "") {
|
|
824
|
-
throw new (0,
|
|
971
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`probeReachability: opts.resources must contain non-empty plan resource key strings (got ${typeof r === "string" && r.trim() === "" ? "a blank string" : typeof r})`);
|
|
825
972
|
}
|
|
826
973
|
const key = r.trim();
|
|
827
974
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
828
975
|
const surfaceCount = new Set(inv.surfaces.map((s) => s.resource)).size;
|
|
829
|
-
throw new (0,
|
|
976
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskError)(
|
|
830
977
|
`probeReachability: unknown resource "${key}" \u2014 the inventory has ${surfaceCount} surfaces`,
|
|
831
978
|
{
|
|
832
979
|
code: "RESOURCE_UNKNOWN",
|
|
@@ -840,7 +987,7 @@ async function probeReachability(client, opts) {
|
|
|
840
987
|
targets = [...seen];
|
|
841
988
|
}
|
|
842
989
|
if (targets.length > cap) {
|
|
843
|
-
throw new (0,
|
|
990
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
844
991
|
`probeReachability: ${targets.length} requested surface(s) exceed the wire cap of ${cap} \u2014 the sweep is refused above its cap (never truncated)`,
|
|
845
992
|
{ suggestedAction: `Raise maxWireCalls (\u2264 ${defs.hardCap}) to cover the set, or pass a smaller resources list.` }
|
|
846
993
|
);
|
|
@@ -850,7 +997,7 @@ async function probeReachability(client, opts) {
|
|
|
850
997
|
for (const resource of targets.sort()) {
|
|
851
998
|
const row = byResource.get(resource);
|
|
852
999
|
if (row === void 0) continue;
|
|
853
|
-
const holder = client[
|
|
1000
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, resource)];
|
|
854
1001
|
const probeFn = _optionalChain([holder, 'optionalAccess', _12 => _12.queryBounded]);
|
|
855
1002
|
if (typeof probeFn !== "function") {
|
|
856
1003
|
results.push({
|
|
@@ -869,7 +1016,7 @@ async function probeReachability(client, opts) {
|
|
|
869
1016
|
probe: { ok: true, wire: 1, error: null }
|
|
870
1017
|
});
|
|
871
1018
|
} catch (err) {
|
|
872
|
-
const code =
|
|
1019
|
+
const code = _chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) ? err.code : "NETWORK_ERROR";
|
|
873
1020
|
const message = err instanceof Error ? err.message : String(err);
|
|
874
1021
|
results.push({
|
|
875
1022
|
...row,
|
|
@@ -897,24 +1044,24 @@ var CREATE_BLOCKER_KINDS = [
|
|
|
897
1044
|
async function createGuidance(client, opts) {
|
|
898
1045
|
void client;
|
|
899
1046
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
900
|
-
throw new (0,
|
|
1047
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
901
1048
|
"createGuidance: opts must be an object { resources?: string[], kind?: CreateBlockerKind }"
|
|
902
1049
|
);
|
|
903
1050
|
}
|
|
904
|
-
let rows =
|
|
1051
|
+
let rows = _chunkYKEX4SK7cjs.CREATE_GUIDANCE.rows;
|
|
905
1052
|
if (_optionalChain([opts, 'optionalAccess', _14 => _14.resources]) !== void 0) {
|
|
906
1053
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
907
|
-
throw new (0,
|
|
1054
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("createGuidance: opts.resources must be a non-empty string[] of plan resource keys");
|
|
908
1055
|
}
|
|
909
1056
|
const wanted = /* @__PURE__ */ new Set();
|
|
910
1057
|
for (const r of opts.resources) {
|
|
911
1058
|
if (typeof r !== "string" || r.trim() === "") {
|
|
912
|
-
throw new (0,
|
|
1059
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("createGuidance: opts.resources must contain non-empty plan resource key strings");
|
|
913
1060
|
}
|
|
914
1061
|
const key = r.trim();
|
|
915
|
-
if (!
|
|
916
|
-
throw new (0,
|
|
917
|
-
`createGuidance: unknown resource "${key}" \u2014 the catalog has ${
|
|
1062
|
+
if (!_chunkYKEX4SK7cjs.CREATE_GUIDANCE.rows.some((row) => row.resource === key)) {
|
|
1063
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskError)(
|
|
1064
|
+
`createGuidance: unknown resource "${key}" \u2014 the catalog has ${_chunkYKEX4SK7cjs.CREATE_GUIDANCE.rows.length} create entities`,
|
|
918
1065
|
{
|
|
919
1066
|
code: "RESOURCE_UNKNOWN",
|
|
920
1067
|
category: "validation",
|
|
@@ -928,18 +1075,18 @@ async function createGuidance(client, opts) {
|
|
|
928
1075
|
}
|
|
929
1076
|
if (_optionalChain([opts, 'optionalAccess', _15 => _15.kind]) !== void 0) {
|
|
930
1077
|
if (!CREATE_BLOCKER_KINDS.includes(opts.kind)) {
|
|
931
|
-
throw new (0,
|
|
1078
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
932
1079
|
`createGuidance: unknown kind "${String(opts.kind)}" \u2014 the valid kinds are: ${CREATE_BLOCKER_KINDS.join(", ")}`
|
|
933
1080
|
);
|
|
934
1081
|
}
|
|
935
1082
|
rows = rows.filter((row) => _optionalChain([row, 'access', _16 => _16.blocker, 'optionalAccess', _17 => _17.kind]) === opts.kind);
|
|
936
1083
|
}
|
|
937
1084
|
return {
|
|
938
|
-
zone:
|
|
939
|
-
label:
|
|
940
|
-
verifiedAt:
|
|
1085
|
+
zone: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.zone,
|
|
1086
|
+
label: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.label,
|
|
1087
|
+
verifiedAt: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.verifiedAt,
|
|
941
1088
|
rows,
|
|
942
|
-
counts:
|
|
1089
|
+
counts: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.counts
|
|
943
1090
|
};
|
|
944
1091
|
}
|
|
945
1092
|
|
|
@@ -948,7 +1095,7 @@ var RECOVERY_CONFIRM = "operations.recovery";
|
|
|
948
1095
|
var RECOVERY_DEFAULT_LIMIT = 25;
|
|
949
1096
|
var RECOVERY_MAX_LIMIT = 100;
|
|
950
1097
|
function configError(message, operation, suggestedAction) {
|
|
951
|
-
throw new (0,
|
|
1098
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(message, { operation, suggestedAction });
|
|
952
1099
|
}
|
|
953
1100
|
function parseMatchId(record) {
|
|
954
1101
|
const raw = record.id;
|
|
@@ -965,7 +1112,7 @@ function parseMatchId(record) {
|
|
|
965
1112
|
}
|
|
966
1113
|
async function recovery(client, input, opts = {}) {
|
|
967
1114
|
const operation = RECOVERY_CONFIRM;
|
|
968
|
-
if (!
|
|
1115
|
+
if (!_chunkYKEX4SK7cjs.isRecord.call(void 0, input)) {
|
|
969
1116
|
configError(
|
|
970
1117
|
`recovery: input must be an object { resource, marker, ... } (got ${typeof input})`,
|
|
971
1118
|
operation,
|
|
@@ -996,10 +1143,10 @@ async function recovery(client, input, opts = {}) {
|
|
|
996
1143
|
"Pass action: 'delete' for the destructive path (dry-run-first; the apply requires the confirm string)."
|
|
997
1144
|
);
|
|
998
1145
|
}
|
|
999
|
-
const entry =
|
|
1146
|
+
const entry = _chunkYKEX4SK7cjs.RELATIONSHIP_MAP[resource];
|
|
1000
1147
|
if (entry === void 0) {
|
|
1001
|
-
throw new (0,
|
|
1002
|
-
`recovery: unknown resource "${resource}" \u2014 the plan has ${Object.keys(
|
|
1148
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskError)(
|
|
1149
|
+
`recovery: unknown resource "${resource}" \u2014 the plan has ${Object.keys(_chunkYKEX4SK7cjs.RELATIONSHIP_MAP).length} resources`,
|
|
1003
1150
|
{
|
|
1004
1151
|
code: "RESOURCE_UNKNOWN",
|
|
1005
1152
|
category: "validation",
|
|
@@ -1008,7 +1155,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1008
1155
|
}
|
|
1009
1156
|
);
|
|
1010
1157
|
}
|
|
1011
|
-
const holder = client[
|
|
1158
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, resource)];
|
|
1012
1159
|
if (!holder || typeof holder.queryBounded !== "function") {
|
|
1013
1160
|
configError(
|
|
1014
1161
|
`recovery: ${resource} exposes no bounded query surface \u2014 the marker search cannot run`,
|
|
@@ -1016,7 +1163,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1016
1163
|
"Use a resource with a query surface, or address the record by id directly (get/fetchMany)."
|
|
1017
1164
|
);
|
|
1018
1165
|
}
|
|
1019
|
-
const field = input.field !== void 0 ? String(input.field) :
|
|
1166
|
+
const field = input.field !== void 0 ? String(input.field) : _chunkYKEX4SK7cjs.MARKER_FIELDS[resource];
|
|
1020
1167
|
if (typeof field !== "string" || field.trim() === "") {
|
|
1021
1168
|
configError(
|
|
1022
1169
|
`recovery: ${resource} has no plan markerField and no input.field was passed \u2014 the marker search needs a name-like field to filter on`,
|
|
@@ -1052,7 +1199,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1052
1199
|
);
|
|
1053
1200
|
}
|
|
1054
1201
|
for (const c of input.filter) {
|
|
1055
|
-
if (!
|
|
1202
|
+
if (!_chunkYKEX4SK7cjs.isRecord.call(void 0, c) || typeof c.op !== "string" || c.op === "and" || c.op === "or") {
|
|
1056
1203
|
configError(
|
|
1057
1204
|
"recovery: input.filter accepts only plain leaf conditions ({ field, op, value }) \u2014 no grouping",
|
|
1058
1205
|
operation,
|
|
@@ -1073,7 +1220,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1073
1220
|
}
|
|
1074
1221
|
limit = input.limit;
|
|
1075
1222
|
}
|
|
1076
|
-
const boundaryNote =
|
|
1223
|
+
const boundaryNote = _chunkYKEX4SK7cjs.DELETE_BOUNDARY_NOTES[resource];
|
|
1077
1224
|
const boundary = {
|
|
1078
1225
|
available: boundaryNote === void 0,
|
|
1079
1226
|
reason: _nullishCoalesce(boundaryNote, () => ( null)),
|
|
@@ -1085,7 +1232,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1085
1232
|
};
|
|
1086
1233
|
const isDelete = action === "delete";
|
|
1087
1234
|
if (isDelete && boundaryNote !== void 0) {
|
|
1088
|
-
throw new (0,
|
|
1235
|
+
throw new (0, _chunkYKEX4SK7cjs.DeleteBoundaryError)(
|
|
1089
1236
|
`recovery: the vendor defines no DELETE for ${resource} \u2014 the delete cannot be issued through the API (zero wire was issued)`,
|
|
1090
1237
|
{
|
|
1091
1238
|
operation,
|
|
@@ -1097,7 +1244,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1097
1244
|
const dryRun = _optionalChain([opts, 'optionalAccess', _18 => _18.dryRun]) !== false;
|
|
1098
1245
|
const confirm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _19 => _19.confirm]), () => ( input.confirm));
|
|
1099
1246
|
if (isDelete && !dryRun && confirm !== RECOVERY_CONFIRM) {
|
|
1100
|
-
throw new (0,
|
|
1247
|
+
throw new (0, _chunkYKEX4SK7cjs.ConfirmationRequiredError)(
|
|
1101
1248
|
`recovery: action 'delete' apply is destructive and requires its confirmation flag: pass confirm: "${RECOVERY_CONFIRM}"`,
|
|
1102
1249
|
{
|
|
1103
1250
|
operation: RECOVERY_CONFIRM,
|
|
@@ -1113,7 +1260,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1113
1260
|
const query = await holder.queryBounded({ filter: conditions, limit });
|
|
1114
1261
|
if (query.hasMore) {
|
|
1115
1262
|
const wire = isDelete ? "DELETE wire" : "mutating wire";
|
|
1116
|
-
throw new (0,
|
|
1263
|
+
throw new (0, _chunkYKEX4SK7cjs.RecoveryTruncatedError)(
|
|
1117
1264
|
`recovery: the marker search on ${resource} TRIPPED its match cap (${limit}) \u2014 more matches exist than were returned (zero ${wire} was issued)`,
|
|
1118
1265
|
{
|
|
1119
1266
|
operation,
|
|
@@ -1152,7 +1299,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1152
1299
|
return { ...base, simulated: true, dryRun: true };
|
|
1153
1300
|
}
|
|
1154
1301
|
if (unsafeId) {
|
|
1155
|
-
throw new (0,
|
|
1302
|
+
throw new (0, _chunkYKEX4SK7cjs.MarkerUnsafeIdError)(
|
|
1156
1303
|
`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)`,
|
|
1157
1304
|
{
|
|
1158
1305
|
operation,
|
|
@@ -1163,7 +1310,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1163
1310
|
}
|
|
1164
1311
|
const deleteMethod = holder.delete;
|
|
1165
1312
|
if (deleteMethod === void 0) {
|
|
1166
|
-
throw new (0,
|
|
1313
|
+
throw new (0, _chunkYKEX4SK7cjs.DeleteBoundaryError)(
|
|
1167
1314
|
`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`,
|
|
1168
1315
|
{
|
|
1169
1316
|
operation,
|
|
@@ -1192,14 +1339,14 @@ async function recovery(client, input, opts = {}) {
|
|
|
1192
1339
|
verify = "still-present";
|
|
1193
1340
|
}
|
|
1194
1341
|
} catch (err) {
|
|
1195
|
-
if (err instanceof
|
|
1342
|
+
if (err instanceof _chunkYKEX4SK7cjs.NotFoundError) verify = "not-found";
|
|
1196
1343
|
else {
|
|
1197
1344
|
verify = "error";
|
|
1198
|
-
code =
|
|
1345
|
+
code = _chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1199
1346
|
}
|
|
1200
1347
|
}
|
|
1201
1348
|
} catch (err) {
|
|
1202
|
-
code =
|
|
1349
|
+
code = _chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1203
1350
|
}
|
|
1204
1351
|
deleted.push({ id, verified: verify === "not-found", code });
|
|
1205
1352
|
}
|
|
@@ -1207,13 +1354,13 @@ async function recovery(client, input, opts = {}) {
|
|
|
1207
1354
|
}
|
|
1208
1355
|
|
|
1209
1356
|
// src/operations/invoke.ts
|
|
1210
|
-
var RECORDS =
|
|
1357
|
+
var RECORDS = _chunkT5FLSJODcjs.CAPABILITIES;
|
|
1211
1358
|
var byId = new Map(RECORDS.map((r) => [r.id, r]));
|
|
1212
1359
|
function needsConfirmation(record) {
|
|
1213
1360
|
return record.effect === "destructive" || (_nullishCoalesce(record.flags, () => ( []))).includes("requiresApproval");
|
|
1214
1361
|
}
|
|
1215
1362
|
function refuse(message, operation, suggestedAction) {
|
|
1216
|
-
throw new (0,
|
|
1363
|
+
throw new (0, _chunkYKEX4SK7cjs.ConfirmationRequiredError)(message, { operation, suggestedAction });
|
|
1217
1364
|
}
|
|
1218
1365
|
var MODE_BY_EFFECT = {
|
|
1219
1366
|
read: "read",
|
|
@@ -1257,7 +1404,7 @@ function looseTypeOk(type, value) {
|
|
|
1257
1404
|
case "string[]":
|
|
1258
1405
|
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
1259
1406
|
case "object":
|
|
1260
|
-
return
|
|
1407
|
+
return _chunkYKEX4SK7cjs.isRecord.call(void 0, value);
|
|
1261
1408
|
default:
|
|
1262
1409
|
return true;
|
|
1263
1410
|
}
|
|
@@ -1274,7 +1421,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1274
1421
|
const schema = _nullishCoalesce(record.inputSchema, () => ( {}));
|
|
1275
1422
|
const names = Object.keys(schema);
|
|
1276
1423
|
if (args.length > names.length) {
|
|
1277
|
-
throw new (0,
|
|
1424
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1278
1425
|
`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)`,
|
|
1279
1426
|
{
|
|
1280
1427
|
operation,
|
|
@@ -1284,7 +1431,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1284
1431
|
}
|
|
1285
1432
|
const required = names.filter((n) => schema[n].required);
|
|
1286
1433
|
if (args.length < required.length) {
|
|
1287
|
-
throw new (0,
|
|
1434
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1288
1435
|
`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)}`,
|
|
1289
1436
|
{ operation }
|
|
1290
1437
|
);
|
|
@@ -1295,7 +1442,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1295
1442
|
const name = names[i];
|
|
1296
1443
|
const spec = schema[name];
|
|
1297
1444
|
if (!looseTypeOk(spec.type, value)) {
|
|
1298
|
-
throw new (0,
|
|
1445
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1299
1446
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
1300
1447
|
{ operation }
|
|
1301
1448
|
);
|
|
@@ -1347,11 +1494,11 @@ function validateParamsBag(record, args) {
|
|
|
1347
1494
|
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
1348
1495
|
if (valid === void 0) return;
|
|
1349
1496
|
const bag = _optionalChain([args, 'optionalAccess', _20 => _20[0]]);
|
|
1350
|
-
if (bag === void 0 || bag === null || !
|
|
1497
|
+
if (bag === void 0 || bag === null || !_chunkYKEX4SK7cjs.isRecord.call(void 0, bag)) return;
|
|
1351
1498
|
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
1352
1499
|
if (unknown.length === 0) return;
|
|
1353
1500
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1354
|
-
throw new (0,
|
|
1501
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1355
1502
|
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
1356
1503
|
{
|
|
1357
1504
|
operation: record.id,
|
|
@@ -1365,7 +1512,7 @@ function validateInvokeOptions(opts, operation) {
|
|
|
1365
1512
|
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
1366
1513
|
if (unknown.length === 0) return;
|
|
1367
1514
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, ["dryRun", "confirm", "lastModifiedDate"])]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1368
|
-
throw new (0,
|
|
1515
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1369
1516
|
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate)`,
|
|
1370
1517
|
{
|
|
1371
1518
|
operation,
|
|
@@ -1378,7 +1525,7 @@ function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
|
1378
1525
|
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
1379
1526
|
if (unknown.length === 0) return null;
|
|
1380
1527
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, [...validKeys])]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1381
|
-
return new (0,
|
|
1528
|
+
return new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1382
1529
|
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
1383
1530
|
{
|
|
1384
1531
|
...operation !== void 0 ? { operation } : {},
|
|
@@ -1390,7 +1537,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1390
1537
|
const args = _nullishCoalesce(argsIn, () => ( []));
|
|
1391
1538
|
const record = byId.get(operation);
|
|
1392
1539
|
if (record === void 0) {
|
|
1393
|
-
throw new (0,
|
|
1540
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1394
1541
|
`invoke: unknown operation "${operation}" \u2014 it is not in the capability registry`,
|
|
1395
1542
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
1396
1543
|
);
|
|
@@ -1398,17 +1545,17 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1398
1545
|
validateInvokeOptions(opts, operation);
|
|
1399
1546
|
const mode = opts.mode;
|
|
1400
1547
|
if (mode !== void 0 && MODE_BY_EFFECT[record.effect] !== mode) {
|
|
1401
|
-
throw new (0,
|
|
1548
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(crossModeRefusal(operation, record.effect, mode), { operation });
|
|
1402
1549
|
}
|
|
1403
1550
|
if (opts.dryRun !== void 0 && typeof opts.dryRun !== "boolean") {
|
|
1404
|
-
throw new (0,
|
|
1551
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1405
1552
|
`invoke: dryRun must be a boolean (got ${typeof opts.dryRun}) \u2014 "${operation}" was not issued`,
|
|
1406
1553
|
{ operation, suggestedAction: "Pass dryRun: true (simulate) or dryRun: false (apply) as a real boolean." }
|
|
1407
1554
|
);
|
|
1408
1555
|
}
|
|
1409
1556
|
const isWrite = record.effect !== "read";
|
|
1410
1557
|
if (!isWrite && opts.dryRun === true) {
|
|
1411
|
-
throw new (0,
|
|
1558
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1412
1559
|
`invoke: "${operation}" is a read \u2014 dryRun is not applicable (reads issue their request as-is)`,
|
|
1413
1560
|
{ operation }
|
|
1414
1561
|
);
|
|
@@ -1423,9 +1570,9 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1423
1570
|
validateDispatchArgs(record, args);
|
|
1424
1571
|
validateParamsBag(record, args);
|
|
1425
1572
|
const boundedQuery = record.kind === "primitive" && record.operation === "query";
|
|
1426
|
-
let holder = client[
|
|
1573
|
+
let holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, record.resource)];
|
|
1427
1574
|
if (typeof holder === "function") {
|
|
1428
|
-
holder = _nullishCoalesce(client[`${
|
|
1575
|
+
holder = _nullishCoalesce(client[`${_chunkYKEX4SK7cjs.camelKey.call(void 0, record.resource)}Resource`], () => ( holder));
|
|
1429
1576
|
}
|
|
1430
1577
|
if (holder === void 0 && record.resource === "operations") {
|
|
1431
1578
|
holder = {
|
|
@@ -1446,7 +1593,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1446
1593
|
// reads ONLY (never an id-in query — the resources table can be blind
|
|
1447
1594
|
// to count/query while per-id reads work); blind-marked rows for ids
|
|
1448
1595
|
// the API user cannot resolve; the name cache (default-on).
|
|
1449
|
-
expandResourceNames: (ids, opts2) =>
|
|
1596
|
+
expandResourceNames: (ids, opts2) => _chunkYKEX4SK7cjs.expandResourceNames.call(void 0, client, ids, opts2),
|
|
1450
1597
|
relationshipMap: (resourceKey) => relationshipMap(client, resourceKey),
|
|
1451
1598
|
// Issue #11: the served blind-surface inventory (zero wire) + the
|
|
1452
1599
|
// bounded caller-opted reachability sweep (read-only, confirmProbe-
|
|
@@ -1459,7 +1606,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1459
1606
|
// entityInformation GETs (the op's own cap refuses over-cap fan-outs
|
|
1460
1607
|
// pre-request; per-resource failures are recorded on the row and
|
|
1461
1608
|
// never abort the call).
|
|
1462
|
-
fieldCatalog: (opts2) =>
|
|
1609
|
+
fieldCatalog: (opts2) => _chunkYKEX4SK7cjs.fieldCatalog.call(void 0, client, opts2),
|
|
1463
1610
|
// Issue #9: the one-call recovery/cleanup op — effect write in the
|
|
1464
1611
|
// registry (the governor's dry-run-first applies to it); the op's own
|
|
1465
1612
|
// confirm gate makes the destructive action deliberate (the governor
|
|
@@ -1468,7 +1615,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1468
1615
|
};
|
|
1469
1616
|
}
|
|
1470
1617
|
if (holder === void 0) {
|
|
1471
|
-
throw new (0,
|
|
1618
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1472
1619
|
`invoke: the client exposes no accessor for resource "${record.resource}"`,
|
|
1473
1620
|
{ operation }
|
|
1474
1621
|
);
|
|
@@ -1476,7 +1623,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1476
1623
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
1477
1624
|
const method = holder[methodName];
|
|
1478
1625
|
if (typeof method !== "function") {
|
|
1479
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1480
1627
|
`invoke: "${record.resource}.${methodName}" is not a callable method on the client`,
|
|
1481
1628
|
{ operation }
|
|
1482
1629
|
);
|
|
@@ -1578,4 +1725,6 @@ async function invokeDelete(client, operation, args = [], opts = {}) {
|
|
|
1578
1725
|
|
|
1579
1726
|
|
|
1580
1727
|
|
|
1581
|
-
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
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 = _chunkYKEX4SK7cjs.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 = _chunkYKEX4SK7cjs.FIELD_CACHE_KINDS; exports.FIELD_CATALOG_HONESTY_NOTE = _chunkYKEX4SK7cjs.FIELD_CATALOG_HONESTY_NOTE; exports.INVOKE_OPTION_KEYS = INVOKE_OPTION_KEYS; exports.MAX_FIELD_CATALOG_WIRE = _chunkYKEX4SK7cjs.MAX_FIELD_CATALOG_WIRE; exports.PARAMS_BAG_KEYS = PARAMS_BAG_KEYS; exports.PICKLIST_VALUE_NOT_SERVED_NOTE = _chunkYKEX4SK7cjs.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 = _chunkYKEX4SK7cjs.WORKFLOW_RESOURCES; exports.aggregate = aggregate; exports.blindSurfaces = blindSurfaces; exports.createGuidance = createGuidance; exports.dateBucketLabel = dateBucketLabel; exports.expandResourceNames = _chunkYKEX4SK7cjs.expandResourceNames; exports.fetchByIds = fetchByIds; exports.fetchMany = fetchMany; exports.fieldCatalog = _chunkYKEX4SK7cjs.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;
|