node-autotask 0.9.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 +1354 -1263
- package/dist/capabilities.cjs +2 -3
- package/dist/capabilities.js +1 -2
- package/dist/{chunk-53MC2QRQ.cjs → chunk-25ZUKHS4.cjs} +135 -136
- package/dist/{chunk-BZPFDRAE.js → chunk-7L23FDQW.js} +1353 -1263
- package/dist/{chunk-UYJ5V262.js → chunk-CJONZQ7E.js} +32 -182
- package/dist/chunk-DMMMWO6A.js +0 -0
- package/dist/chunk-FLB2X6O5.cjs +1 -0
- package/dist/chunk-IDPB4N2Q.cjs +1 -0
- package/dist/{chunk-UDWV4VVD.js → chunk-LNRN45XS.js} +214 -20
- package/dist/{chunk-OYHKIYVR.cjs → chunk-QAX222R6.cjs} +422 -572
- package/dist/{chunk-QJU2N32V.js → chunk-SXHPUQMB.js} +2 -3
- package/dist/{chunk-LTKMTXUR.cjs → chunk-T5FLSJOD.cjs} +1353 -1263
- package/dist/chunk-UPQIUWOS.js +0 -0
- package/dist/{chunk-RWLPTU67.cjs → chunk-YKEX4SK7.cjs} +235 -41
- package/dist/{index-ZknpNhtc.d.ts → index-B_xToSpq.d.ts} +8 -8
- package/dist/{index-CfU1JDgS.d.cts → index-Dv_GSZaN.d.cts} +8 -8
- package/dist/{index-O2zzIMcQ.d.cts → index-cQ6CRexR.d.cts} +3 -1
- package/dist/{index-O2zzIMcQ.d.ts → index-cQ6CRexR.d.ts} +3 -1
- package/dist/index.cjs +21 -22
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -7
- package/dist/operations/index.cjs +284 -131
- package/dist/operations/index.d.cts +28 -5
- package/dist/operations/index.d.ts +28 -5
- package/dist/operations/index.js +160 -7
- package/dist/pool.cjs +36 -12
- package/dist/pool.d.cts +2 -2
- package/dist/pool.d.ts +2 -2
- package/dist/pool.js +31 -7
- 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 +12 -6
- package/package.json +1 -1
- package/dist/capabilities.cjs.map +0 -1
- package/dist/capabilities.js.map +0 -1
- package/dist/chunk-53MC2QRQ.cjs.map +0 -1
- package/dist/chunk-BZPFDRAE.js.map +0 -1
- package/dist/chunk-CXM35TEC.cjs +0 -1
- package/dist/chunk-CXM35TEC.cjs.map +0 -1
- package/dist/chunk-GIVD2CQ3.js +0 -1
- package/dist/chunk-GIVD2CQ3.js.map +0 -1
- package/dist/chunk-LTKMTXUR.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-OYHKIYVR.cjs.map +0 -1
- package/dist/chunk-QJU2N32V.js.map +0 -1
- package/dist/chunk-RWLPTU67.cjs.map +0 -1
- package/dist/chunk-UDWV4VVD.js.map +0 -1
- package/dist/chunk-UYJ5V262.js.map +0 -1
- 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
|
@@ -29,26 +29,27 @@
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var _chunkRWLPTU67cjs = require('../chunk-RWLPTU67.cjs');
|
|
33
32
|
|
|
33
|
+
var _chunkYKEX4SK7cjs = require('../chunk-YKEX4SK7.cjs');
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
var _chunkT5FLSJODcjs = require('../chunk-T5FLSJOD.cjs');
|
|
36
37
|
|
|
37
38
|
// src/operations/searchAcrossResources.ts
|
|
38
39
|
var DEFAULT_LIMIT = 25;
|
|
39
40
|
function resourceFor(client, key) {
|
|
40
|
-
return client[
|
|
41
|
+
return client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
41
42
|
}
|
|
42
43
|
async function searchAcrossResources(client, query, opts = {}) {
|
|
43
44
|
const text = query.trim();
|
|
44
45
|
if (text === "") {
|
|
45
|
-
throw new (0,
|
|
46
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("searchAcrossResources: query must be a non-empty string");
|
|
46
47
|
}
|
|
47
|
-
const keys = _nullishCoalesce(opts.resources, () => (
|
|
48
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkYKEX4SK7cjs.WORKFLOW_RESOURCES));
|
|
48
49
|
if (keys.length === 0) {
|
|
49
|
-
throw new (0,
|
|
50
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("searchAcrossResources: no resources requested");
|
|
50
51
|
}
|
|
51
|
-
const limit =
|
|
52
|
+
const limit = _chunkYKEX4SK7cjs.clampPageSize.call(void 0, _nullishCoalesce(opts.limit, () => ( DEFAULT_LIMIT)));
|
|
52
53
|
const results = [];
|
|
53
54
|
const skipped = [];
|
|
54
55
|
for (const key of keys) {
|
|
@@ -66,7 +67,7 @@ async function searchAcrossResources(client, query, opts = {}) {
|
|
|
66
67
|
|
|
67
68
|
// src/operations/resolveAny.ts
|
|
68
69
|
function resourceFor2(client, key) {
|
|
69
|
-
return client[
|
|
70
|
+
return client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
70
71
|
}
|
|
71
72
|
var FAULT_CATEGORIES = /* @__PURE__ */ new Set(["auth", "rate_limit", "server", "network", "timeout", "policy"]);
|
|
72
73
|
function missCost(identifier) {
|
|
@@ -75,13 +76,13 @@ function missCost(identifier) {
|
|
|
75
76
|
}
|
|
76
77
|
async function resolveAny(client, identifier, opts = {}) {
|
|
77
78
|
if (typeof identifier === "number") {
|
|
78
|
-
|
|
79
|
+
_chunkYKEX4SK7cjs.parseIdentifier.call(void 0, identifier, "identifier");
|
|
79
80
|
} else if (identifier.trim() === "") {
|
|
80
|
-
throw new (0,
|
|
81
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("resolveAny: identifier must be non-empty");
|
|
81
82
|
}
|
|
82
|
-
const keys = _nullishCoalesce(opts.resources, () => (
|
|
83
|
+
const keys = _nullishCoalesce(opts.resources, () => ( _chunkYKEX4SK7cjs.WORKFLOW_RESOURCES));
|
|
83
84
|
if (keys.length === 0) {
|
|
84
|
-
throw new (0,
|
|
85
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("resolveAny: no resources requested");
|
|
85
86
|
}
|
|
86
87
|
const results = [];
|
|
87
88
|
for (const key of keys) {
|
|
@@ -111,9 +112,9 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
111
112
|
} catch (err) {
|
|
112
113
|
let code;
|
|
113
114
|
let candidates = [];
|
|
114
|
-
if (err instanceof
|
|
115
|
+
if (err instanceof _chunkYKEX4SK7cjs.AutotaskConfigError) {
|
|
115
116
|
code = "CONFIG_ERROR";
|
|
116
|
-
} else if (
|
|
117
|
+
} else if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err)) {
|
|
117
118
|
if (FAULT_CATEGORIES.has(err.category)) throw err;
|
|
118
119
|
code = err.code;
|
|
119
120
|
if (code === "RESOLUTION_AMBIGUOUS" && err.resourceIds !== void 0) {
|
|
@@ -257,12 +258,71 @@ var MODEL_FIELD_SETS = {
|
|
|
257
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"],
|
|
258
259
|
"time_off_requests": ["id", "approvedDateTime", "approveRejectResourceID", "createdByResourceID", "createDateTime", "endTime", "hours", "impersonatorApproveRejectResourceID", "lastModifiedByResourceID", "lastModifiedDateTime", "lastApprovedLevel", "reason", "rejectReason", "requestDate", "resourceID", "startTime", "status", "timeOffRequestType", "soapParentPropertyId"]
|
|
259
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
|
+
};
|
|
260
320
|
|
|
261
321
|
// src/operations/fetchMany.ts
|
|
262
322
|
var FETCH_MANY_MAX_ITEMS = 20;
|
|
263
323
|
function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETCH_MANY_MAX_ITEMS = ${FETCH_MANY_MAX_ITEMS}`, validation) {
|
|
264
324
|
if (!Array.isArray(items)) {
|
|
265
|
-
throw new (0,
|
|
325
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
266
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})`,
|
|
267
327
|
{
|
|
268
328
|
suggestedAction: 'Pass args = [[{ resource: "tickets", id: 123 }, { resource: "projects", id: 456 }]] \u2014 the items array is the single positional argument.'
|
|
@@ -270,12 +330,12 @@ function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETC
|
|
|
270
330
|
);
|
|
271
331
|
}
|
|
272
332
|
if (items.length === 0) {
|
|
273
|
-
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)`, {
|
|
274
334
|
suggestedAction: "Pass at least one { resource, id } item \u2014 or use the resource's query op for a filtered read."
|
|
275
335
|
});
|
|
276
336
|
}
|
|
277
337
|
if (items.length > cap) {
|
|
278
|
-
throw new (0,
|
|
338
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
279
339
|
`${opName}: ${items.length} items over the ${cap}-item cap (${capRef}) \u2014 zero items were fetched (pre-request)`,
|
|
280
340
|
{
|
|
281
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).`
|
|
@@ -303,15 +363,15 @@ function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETC
|
|
|
303
363
|
);
|
|
304
364
|
continue;
|
|
305
365
|
}
|
|
306
|
-
const rel =
|
|
366
|
+
const rel = _chunkYKEX4SK7cjs.RELATIONSHIP_MAP[resourceKey];
|
|
307
367
|
if (rel !== void 0 && rel.parentScoped) {
|
|
308
368
|
problems.push(
|
|
309
|
-
`${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))`
|
|
310
370
|
);
|
|
311
371
|
continue;
|
|
312
372
|
}
|
|
313
373
|
try {
|
|
314
|
-
|
|
374
|
+
_chunkYKEX4SK7cjs.parseIdentifier.call(void 0, item.id, `${at}.id`);
|
|
315
375
|
} catch (e2) {
|
|
316
376
|
if (typeof item.id === "string") {
|
|
317
377
|
problems.push(
|
|
@@ -344,7 +404,7 @@ function validateFetchManyItems(items, cap, opName = "fetchMany", capRef = `FETC
|
|
|
344
404
|
}
|
|
345
405
|
}
|
|
346
406
|
if (problems.length > 0) {
|
|
347
|
-
throw new (0,
|
|
407
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
348
408
|
`${opName}: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
349
409
|
- ` + problems.join("\n- "),
|
|
350
410
|
{ suggestedAction: "Fix every item above and call again \u2014 validation covers the whole batch up-front (one round, zero wire)." }
|
|
@@ -361,11 +421,11 @@ function project(value, fields) {
|
|
|
361
421
|
async function fetchMany(client, items, opts = {}) {
|
|
362
422
|
if (opts.maxItems !== void 0) {
|
|
363
423
|
if (!Number.isInteger(opts.maxItems) || opts.maxItems < 1) {
|
|
364
|
-
throw new (0,
|
|
424
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: maxItems must be an integer >= 1 (got ${String(opts.maxItems)})`);
|
|
365
425
|
}
|
|
366
426
|
}
|
|
367
427
|
if (opts.liveFields !== void 0 && typeof opts.liveFields !== "boolean") {
|
|
368
|
-
throw new (0,
|
|
428
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: liveFields must be a boolean (got ${typeof opts.liveFields})`);
|
|
369
429
|
}
|
|
370
430
|
const cap = Math.min(FETCH_MANY_MAX_ITEMS, _nullishCoalesce(opts.maxItems, () => ( FETCH_MANY_MAX_ITEMS)));
|
|
371
431
|
if (opts.liveFields === true) {
|
|
@@ -374,9 +434,9 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
374
434
|
for (const item of items) {
|
|
375
435
|
const key = item.resource;
|
|
376
436
|
if (liveFieldSets.has(key)) continue;
|
|
377
|
-
const holder = client[
|
|
437
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
378
438
|
if (holder === void 0) {
|
|
379
|
-
throw new (0,
|
|
439
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: the client exposes no accessor for resource "${key}"`, {
|
|
380
440
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
381
441
|
});
|
|
382
442
|
}
|
|
@@ -388,7 +448,7 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
388
448
|
}
|
|
389
449
|
liveFieldSets.set(key, names.length > 0 ? names : null);
|
|
390
450
|
} catch (err) {
|
|
391
|
-
if (!
|
|
451
|
+
if (!_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) || err.code === "ABORTED") throw err;
|
|
392
452
|
liveFieldSets.set(key, null);
|
|
393
453
|
}
|
|
394
454
|
}
|
|
@@ -399,10 +459,10 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
399
459
|
const results = [];
|
|
400
460
|
for (const item of items) {
|
|
401
461
|
const key = item.resource;
|
|
402
|
-
const id =
|
|
403
|
-
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)];
|
|
404
464
|
if (holder === void 0) {
|
|
405
|
-
throw new (0,
|
|
465
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchMany: the client exposes no accessor for resource "${key}"`, {
|
|
406
466
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
407
467
|
});
|
|
408
468
|
}
|
|
@@ -410,9 +470,9 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
410
470
|
const value = await holder.get(id);
|
|
411
471
|
results.push({ resource: key, id, found: true, value: item.fields !== void 0 ? project(value, item.fields) : value });
|
|
412
472
|
} catch (err) {
|
|
413
|
-
if (err instanceof
|
|
473
|
+
if (err instanceof _chunkYKEX4SK7cjs.NotFoundError) {
|
|
414
474
|
results.push({ resource: key, id, found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
415
|
-
} else if (
|
|
475
|
+
} else if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
416
476
|
const e = { code: err.code, message: err.message };
|
|
417
477
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
418
478
|
results.push({ resource: key, id, found: false, value: null, error: e });
|
|
@@ -428,10 +488,64 @@ async function fetchMany(client, items, opts = {}) {
|
|
|
428
488
|
// src/operations/aggregate.ts
|
|
429
489
|
var AGGREGATE_TOP_MAX = 100;
|
|
430
490
|
var AGGREGATE_DEFAULT_TOP = 25;
|
|
431
|
-
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
|
+
}
|
|
432
546
|
var QUERY_RESOURCE_KEYS = (() => {
|
|
433
547
|
const s = /* @__PURE__ */ new Set();
|
|
434
|
-
for (const rec of
|
|
548
|
+
for (const rec of _chunkT5FLSJODcjs.CAPABILITIES) if (rec.operation === "query") s.add(rec.resource);
|
|
435
549
|
return s;
|
|
436
550
|
})();
|
|
437
551
|
var AGGREGATE_OPT_KEYS = ["groupBy", "sum", "top", "limit"];
|
|
@@ -466,14 +580,14 @@ function validateAggregate(operation, filter, opts) {
|
|
|
466
580
|
conditions = [];
|
|
467
581
|
} else {
|
|
468
582
|
try {
|
|
469
|
-
conditions =
|
|
583
|
+
conditions = _chunkYKEX4SK7cjs.buildFilter.call(void 0, conds).filter;
|
|
470
584
|
} catch (err) {
|
|
471
|
-
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)}`);
|
|
472
586
|
}
|
|
473
587
|
}
|
|
474
588
|
}
|
|
475
589
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
476
|
-
throw new (0,
|
|
590
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
477
591
|
`aggregate: opts must be the options object (got ${Array.isArray(opts) ? "an array" : typeof opts})`,
|
|
478
592
|
{ operation: "operations.aggregate" }
|
|
479
593
|
);
|
|
@@ -484,6 +598,7 @@ function validateAggregate(operation, filter, opts) {
|
|
|
484
598
|
}
|
|
485
599
|
}
|
|
486
600
|
const fieldSets = resourceKey !== void 0 ? MODEL_FIELD_SETS[resourceKey] : void 0;
|
|
601
|
+
const dateSets = resourceKey !== void 0 ? MODEL_DATE_FIELDS[resourceKey] : void 0;
|
|
487
602
|
const checkFields = (name, fields) => {
|
|
488
603
|
if (fields === void 0) return [];
|
|
489
604
|
if (!Array.isArray(fields) || fields.length === 0 || fields.some((f) => typeof f !== "string" || f.trim() === "")) {
|
|
@@ -500,7 +615,39 @@ function validateAggregate(operation, filter, opts) {
|
|
|
500
615
|
}
|
|
501
616
|
return out;
|
|
502
617
|
};
|
|
503
|
-
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
|
+
}
|
|
504
651
|
const sum = checkFields("sum", opts.sum);
|
|
505
652
|
let top = AGGREGATE_DEFAULT_TOP;
|
|
506
653
|
if (opts.top !== void 0) {
|
|
@@ -515,11 +662,11 @@ function validateAggregate(operation, filter, opts) {
|
|
|
515
662
|
if (!Number.isInteger(opts.limit)) {
|
|
516
663
|
problems.push(`limit must be an integer (got ${String(opts.limit)})`);
|
|
517
664
|
} else {
|
|
518
|
-
limit = Math.min(Math.max(opts.limit, 1),
|
|
665
|
+
limit = Math.min(Math.max(opts.limit, 1), _chunkYKEX4SK7cjs.BOUNDED_QUERY_MAX_LIMIT);
|
|
519
666
|
}
|
|
520
667
|
}
|
|
521
668
|
if (problems.length > 0) {
|
|
522
|
-
throw new (0,
|
|
669
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
523
670
|
`aggregate: ${problems.length} problem(s) found pre-request (zero wire was issued)
|
|
524
671
|
- ` + problems.join("\n- "),
|
|
525
672
|
{ operation: "operations.aggregate" }
|
|
@@ -529,9 +676,9 @@ function validateAggregate(operation, filter, opts) {
|
|
|
529
676
|
}
|
|
530
677
|
async function aggregate(client, operation, filter, opts = {}) {
|
|
531
678
|
const v = validateAggregate(operation, filter, opts);
|
|
532
|
-
const holder = client[
|
|
679
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, v.resourceKey)];
|
|
533
680
|
if (holder === void 0) {
|
|
534
|
-
throw new (0,
|
|
681
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`aggregate: the client exposes no accessor for resource "${v.resourceKey}"`, {
|
|
535
682
|
operation: "operations.aggregate",
|
|
536
683
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
537
684
|
});
|
|
@@ -550,9 +697,11 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
550
697
|
for (const item of res.items) {
|
|
551
698
|
const key = {};
|
|
552
699
|
const values = [];
|
|
553
|
-
for (const
|
|
554
|
-
|
|
555
|
-
|
|
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;
|
|
704
|
+
values.push(value);
|
|
556
705
|
}
|
|
557
706
|
const keyOrder = JSON.stringify(values);
|
|
558
707
|
let g = groups.get(keyOrder);
|
|
@@ -570,6 +719,8 @@ async function aggregate(client, operation, filter, opts = {}) {
|
|
|
570
719
|
const result = {
|
|
571
720
|
mode: v.groupBy.length > 0 ? "group" : "sum",
|
|
572
721
|
groups: top.map((g) => ({ key: g.key, count: g.count, ...g.sums !== void 0 ? { sums: g.sums } : {} })),
|
|
722
|
+
totalGroups: sorted.length,
|
|
723
|
+
groupsTruncated: sorted.length > top.length,
|
|
573
724
|
totalScanned: res.fetched,
|
|
574
725
|
hasMore: res.hasMore
|
|
575
726
|
};
|
|
@@ -591,7 +742,7 @@ function project2(value, fields) {
|
|
|
591
742
|
function resourcePathOf(key, holder) {
|
|
592
743
|
const path = _optionalChain([holder, 'optionalAccess', _5 => _5.resourcePath]);
|
|
593
744
|
if (typeof path !== "string" || path === "") {
|
|
594
|
-
throw new (0,
|
|
745
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchByIds: the client exposes no ${key} resource path (registry drift)`, {
|
|
595
746
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
596
747
|
});
|
|
597
748
|
}
|
|
@@ -600,7 +751,7 @@ function resourcePathOf(key, holder) {
|
|
|
600
751
|
async function fetchByIds(client, items, opts = {}) {
|
|
601
752
|
if (opts.maxItems !== void 0) {
|
|
602
753
|
if (!Number.isInteger(opts.maxItems) || opts.maxItems < 1) {
|
|
603
|
-
throw new (0,
|
|
754
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchByIds: maxItems must be an integer >= 1 (got ${String(opts.maxItems)})`);
|
|
604
755
|
}
|
|
605
756
|
}
|
|
606
757
|
const cap = Math.min(FETCH_BY_IDS_MAX_ITEMS, _nullishCoalesce(opts.maxItems, () => ( FETCH_BY_IDS_MAX_ITEMS)));
|
|
@@ -609,7 +760,7 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
609
760
|
const canonical = [];
|
|
610
761
|
for (let i = 0; i < items.length; i += 1) {
|
|
611
762
|
const item = items[i];
|
|
612
|
-
const id =
|
|
763
|
+
const id = _chunkYKEX4SK7cjs.parseIdentifier.call(void 0, item.id, `items[${i}].id`);
|
|
613
764
|
canonical[i] = id;
|
|
614
765
|
const g = _nullishCoalesce(groups.get(item.resource), () => ( { indices: [], fields: /* @__PURE__ */ new Set(), anyFields: false }));
|
|
615
766
|
g.indices.push(i);
|
|
@@ -621,9 +772,9 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
621
772
|
}
|
|
622
773
|
const byKey = /* @__PURE__ */ new Map();
|
|
623
774
|
for (const [key, group] of groups) {
|
|
624
|
-
const holder = client[
|
|
775
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, key)];
|
|
625
776
|
if (holder === void 0) {
|
|
626
|
-
throw new (0,
|
|
777
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`fetchByIds: the client exposes no accessor for resource "${key}"`, {
|
|
627
778
|
suggestedAction: "Rebuild the client from the SDK build that ships this registry (the resource set is pinned by the plan)."
|
|
628
779
|
});
|
|
629
780
|
}
|
|
@@ -643,13 +794,13 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
643
794
|
const chunk = unique.slice(c, c + FETCH_BY_IDS_CHUNK_SIZE);
|
|
644
795
|
const chunkKeys = new Set(chunk.map((id) => String(id)));
|
|
645
796
|
try {
|
|
646
|
-
const req =
|
|
797
|
+
const req = _chunkYKEX4SK7cjs.buildQueryRequest.call(void 0, client.http.baseUrl, resourcePath, {
|
|
647
798
|
filter: [{ field: "id", op: "in", value: chunk }],
|
|
648
799
|
maxRecords: FETCH_BY_IDS_CHUNK_SIZE,
|
|
649
800
|
includeFields
|
|
650
801
|
});
|
|
651
802
|
const res = await client.http.request({ ...req, operation: `${key}.fetchByIds` });
|
|
652
|
-
const { items: rows } =
|
|
803
|
+
const { items: rows } = _chunkYKEX4SK7cjs.unwrapItems.call(void 0, res, `${key}.fetchByIds`);
|
|
653
804
|
for (const row of rows) {
|
|
654
805
|
const k = String(row.id);
|
|
655
806
|
if (!chunkKeys.has(k)) continue;
|
|
@@ -657,7 +808,7 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
657
808
|
if (!byKey.has(q)) byKey.set(q, { found: true, value: row });
|
|
658
809
|
}
|
|
659
810
|
} catch (err) {
|
|
660
|
-
if (
|
|
811
|
+
if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
661
812
|
const e = { code: err.code, message: err.message };
|
|
662
813
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
663
814
|
for (const u of chunk) {
|
|
@@ -676,9 +827,9 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
676
827
|
const value = await holder.get(id);
|
|
677
828
|
byKey.set(k, { found: true, value });
|
|
678
829
|
} catch (err) {
|
|
679
|
-
if (err instanceof
|
|
830
|
+
if (err instanceof _chunkYKEX4SK7cjs.NotFoundError) {
|
|
680
831
|
byKey.set(k, { found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
681
|
-
} else if (
|
|
832
|
+
} else if (_chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) && err.code !== "ABORTED") {
|
|
682
833
|
const e = { code: err.code, message: err.message };
|
|
683
834
|
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
684
835
|
byKey.set(k, { found: false, value: null, error: e });
|
|
@@ -706,20 +857,20 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
706
857
|
async function relationshipMap(client, resourceKey) {
|
|
707
858
|
void client;
|
|
708
859
|
if (typeof resourceKey !== "string" || resourceKey.trim() === "") {
|
|
709
|
-
throw new (0,
|
|
860
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
710
861
|
`relationshipMap: resourceKey must be a non-empty plan resource key string (e.g. 'tickets'; got ${typeof resourceKey === "string" ? "a blank string" : typeof resourceKey})`,
|
|
711
862
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items, ticket_notes." }
|
|
712
863
|
);
|
|
713
864
|
}
|
|
714
865
|
const key = resourceKey.trim();
|
|
715
|
-
const entry =
|
|
866
|
+
const entry = _chunkYKEX4SK7cjs.RELATIONSHIP_MAP[key];
|
|
716
867
|
if (entry === void 0) {
|
|
717
|
-
throw new (0,
|
|
718
|
-
`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`,
|
|
719
870
|
{
|
|
720
871
|
code: "RESOURCE_UNKNOWN",
|
|
721
872
|
category: "validation",
|
|
722
|
-
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.`
|
|
723
874
|
}
|
|
724
875
|
);
|
|
725
876
|
}
|
|
@@ -736,24 +887,24 @@ var BLIND_SURFACE_KINDS = [
|
|
|
736
887
|
async function blindSurfaces(client, opts) {
|
|
737
888
|
void client;
|
|
738
889
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
739
|
-
throw new (0,
|
|
890
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("blindSurfaces: opts must be an object { resource?: string, kind?: BlindSurfaceKind }");
|
|
740
891
|
}
|
|
741
|
-
const inv =
|
|
892
|
+
const inv = _chunkYKEX4SK7cjs.BLIND_SURFACE_INVENTORY;
|
|
742
893
|
if (inv === null) {
|
|
743
|
-
throw new (0,
|
|
894
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("blindSurfaces: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
744
895
|
}
|
|
745
896
|
let surfaces = inv.surfaces;
|
|
746
897
|
if (_optionalChain([opts, 'optionalAccess', _6 => _6.resource]) !== void 0) {
|
|
747
898
|
const key = typeof opts.resource === "string" ? opts.resource.trim() : "";
|
|
748
899
|
if (key === "") {
|
|
749
|
-
throw new (0,
|
|
900
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
750
901
|
"blindSurfaces: opts.resource must be a non-empty plan resource key string (e.g. 'tickets')",
|
|
751
902
|
{ suggestedAction: "Pass the exact plan resource key (snake_case) from autotask_catalog \u2014 e.g. tickets, companies, configuration_items." }
|
|
752
903
|
);
|
|
753
904
|
}
|
|
754
905
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
755
|
-
throw new (0,
|
|
756
|
-
`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`,
|
|
757
908
|
{
|
|
758
909
|
code: "RESOURCE_UNKNOWN",
|
|
759
910
|
category: "validation",
|
|
@@ -765,7 +916,7 @@ async function blindSurfaces(client, opts) {
|
|
|
765
916
|
}
|
|
766
917
|
if (_optionalChain([opts, 'optionalAccess', _7 => _7.kind]) !== void 0) {
|
|
767
918
|
if (!BLIND_SURFACE_KINDS.includes(opts.kind)) {
|
|
768
|
-
throw new (0,
|
|
919
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
769
920
|
`blindSurfaces: unknown kind "${String(opts.kind)}" \u2014 the valid classes are: ${BLIND_SURFACE_KINDS.join(", ")}`,
|
|
770
921
|
{ suggestedAction: `Filter with one of: ${BLIND_SURFACE_KINDS.join(", ")} (or omit kind for the full 116-surface inventory).` }
|
|
771
922
|
);
|
|
@@ -778,51 +929,51 @@ async function blindSurfaces(client, opts) {
|
|
|
778
929
|
// src/operations/probeReachability.ts
|
|
779
930
|
async function probeReachability(client, opts) {
|
|
780
931
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
781
|
-
throw new (0,
|
|
932
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("probeReachability: opts must be an object { resources?: string[], limit?: 1|2, maxWireCalls?: number, confirmProbe?: true }");
|
|
782
933
|
}
|
|
783
|
-
const defs =
|
|
934
|
+
const defs = _chunkYKEX4SK7cjs.REACHABILITY_PROBE_DEFAULTS;
|
|
784
935
|
if (_optionalChain([opts, 'optionalAccess', _8 => _8.confirmProbe]) !== true) {
|
|
785
|
-
throw new (0,
|
|
936
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
786
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",
|
|
787
938
|
{ suggestedAction: `Re-call with { confirmProbe: true } (plus resources/limit/maxWireCalls as needed). For the ZERO-wire pinned inventory use operations.blindSurfaces.` }
|
|
788
939
|
);
|
|
789
940
|
}
|
|
790
941
|
const limit = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _9 => _9.limit]), () => ( defs.limitDefault));
|
|
791
942
|
if (!Number.isInteger(limit) || limit < 1 || limit > defs.limitMax) {
|
|
792
|
-
throw new (0,
|
|
943
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
793
944
|
`probeReachability: limit must be an integer 1..${defs.limitMax} (got ${String(limit)}) \u2014 the rows-per-surface bound for the discovery read`
|
|
794
945
|
);
|
|
795
946
|
}
|
|
796
947
|
const cap = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _10 => _10.maxWireCalls]), () => ( defs.defaultCap));
|
|
797
948
|
if (!Number.isInteger(cap) || cap < 1) {
|
|
798
|
-
throw new (0,
|
|
949
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(`probeReachability: maxWireCalls must be a positive integer (got ${String(cap)})`);
|
|
799
950
|
}
|
|
800
951
|
if (cap > defs.hardCap) {
|
|
801
|
-
throw new (0,
|
|
952
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
802
953
|
`probeReachability: maxWireCalls ${cap} exceeds the hard wire cap of ${defs.hardCap} \u2014 the sweep is refused above it (never capped silently)`,
|
|
803
954
|
{ suggestedAction: `Pass maxWireCalls \u2264 ${defs.hardCap} and a resources set no larger than the cap (the refused set is never truncated).` }
|
|
804
955
|
);
|
|
805
956
|
}
|
|
806
|
-
const inv =
|
|
957
|
+
const inv = _chunkYKEX4SK7cjs.BLIND_SURFACE_INVENTORY;
|
|
807
958
|
if (inv === null) {
|
|
808
|
-
throw new (0,
|
|
959
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("probeReachability: the reachability inventory is absent from the generated artifact \u2014 re-run the build");
|
|
809
960
|
}
|
|
810
961
|
let targets;
|
|
811
962
|
if (_optionalChain([opts, 'optionalAccess', _11 => _11.resources]) === void 0) {
|
|
812
963
|
targets = [...defs.defaultTargets];
|
|
813
964
|
} else {
|
|
814
965
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
815
|
-
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)");
|
|
816
967
|
}
|
|
817
968
|
const seen = /* @__PURE__ */ new Set();
|
|
818
969
|
for (const r of opts.resources) {
|
|
819
970
|
if (typeof r !== "string" || r.trim() === "") {
|
|
820
|
-
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})`);
|
|
821
972
|
}
|
|
822
973
|
const key = r.trim();
|
|
823
974
|
if (!inv.surfaces.some((row) => row.resource === key)) {
|
|
824
975
|
const surfaceCount = new Set(inv.surfaces.map((s) => s.resource)).size;
|
|
825
|
-
throw new (0,
|
|
976
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskError)(
|
|
826
977
|
`probeReachability: unknown resource "${key}" \u2014 the inventory has ${surfaceCount} surfaces`,
|
|
827
978
|
{
|
|
828
979
|
code: "RESOURCE_UNKNOWN",
|
|
@@ -836,7 +987,7 @@ async function probeReachability(client, opts) {
|
|
|
836
987
|
targets = [...seen];
|
|
837
988
|
}
|
|
838
989
|
if (targets.length > cap) {
|
|
839
|
-
throw new (0,
|
|
990
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
840
991
|
`probeReachability: ${targets.length} requested surface(s) exceed the wire cap of ${cap} \u2014 the sweep is refused above its cap (never truncated)`,
|
|
841
992
|
{ suggestedAction: `Raise maxWireCalls (\u2264 ${defs.hardCap}) to cover the set, or pass a smaller resources list.` }
|
|
842
993
|
);
|
|
@@ -846,7 +997,7 @@ async function probeReachability(client, opts) {
|
|
|
846
997
|
for (const resource of targets.sort()) {
|
|
847
998
|
const row = byResource.get(resource);
|
|
848
999
|
if (row === void 0) continue;
|
|
849
|
-
const holder = client[
|
|
1000
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, resource)];
|
|
850
1001
|
const probeFn = _optionalChain([holder, 'optionalAccess', _12 => _12.queryBounded]);
|
|
851
1002
|
if (typeof probeFn !== "function") {
|
|
852
1003
|
results.push({
|
|
@@ -865,7 +1016,7 @@ async function probeReachability(client, opts) {
|
|
|
865
1016
|
probe: { ok: true, wire: 1, error: null }
|
|
866
1017
|
});
|
|
867
1018
|
} catch (err) {
|
|
868
|
-
const code =
|
|
1019
|
+
const code = _chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) ? err.code : "NETWORK_ERROR";
|
|
869
1020
|
const message = err instanceof Error ? err.message : String(err);
|
|
870
1021
|
results.push({
|
|
871
1022
|
...row,
|
|
@@ -893,24 +1044,24 @@ var CREATE_BLOCKER_KINDS = [
|
|
|
893
1044
|
async function createGuidance(client, opts) {
|
|
894
1045
|
void client;
|
|
895
1046
|
if (opts !== void 0 && (typeof opts !== "object" || opts === null || Array.isArray(opts))) {
|
|
896
|
-
throw new (0,
|
|
1047
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
897
1048
|
"createGuidance: opts must be an object { resources?: string[], kind?: CreateBlockerKind }"
|
|
898
1049
|
);
|
|
899
1050
|
}
|
|
900
|
-
let rows =
|
|
1051
|
+
let rows = _chunkYKEX4SK7cjs.CREATE_GUIDANCE.rows;
|
|
901
1052
|
if (_optionalChain([opts, 'optionalAccess', _14 => _14.resources]) !== void 0) {
|
|
902
1053
|
if (!Array.isArray(opts.resources) || opts.resources.length === 0) {
|
|
903
|
-
throw new (0,
|
|
1054
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("createGuidance: opts.resources must be a non-empty string[] of plan resource keys");
|
|
904
1055
|
}
|
|
905
1056
|
const wanted = /* @__PURE__ */ new Set();
|
|
906
1057
|
for (const r of opts.resources) {
|
|
907
1058
|
if (typeof r !== "string" || r.trim() === "") {
|
|
908
|
-
throw new (0,
|
|
1059
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)("createGuidance: opts.resources must contain non-empty plan resource key strings");
|
|
909
1060
|
}
|
|
910
1061
|
const key = r.trim();
|
|
911
|
-
if (!
|
|
912
|
-
throw new (0,
|
|
913
|
-
`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`,
|
|
914
1065
|
{
|
|
915
1066
|
code: "RESOURCE_UNKNOWN",
|
|
916
1067
|
category: "validation",
|
|
@@ -924,18 +1075,18 @@ async function createGuidance(client, opts) {
|
|
|
924
1075
|
}
|
|
925
1076
|
if (_optionalChain([opts, 'optionalAccess', _15 => _15.kind]) !== void 0) {
|
|
926
1077
|
if (!CREATE_BLOCKER_KINDS.includes(opts.kind)) {
|
|
927
|
-
throw new (0,
|
|
1078
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
928
1079
|
`createGuidance: unknown kind "${String(opts.kind)}" \u2014 the valid kinds are: ${CREATE_BLOCKER_KINDS.join(", ")}`
|
|
929
1080
|
);
|
|
930
1081
|
}
|
|
931
1082
|
rows = rows.filter((row) => _optionalChain([row, 'access', _16 => _16.blocker, 'optionalAccess', _17 => _17.kind]) === opts.kind);
|
|
932
1083
|
}
|
|
933
1084
|
return {
|
|
934
|
-
zone:
|
|
935
|
-
label:
|
|
936
|
-
verifiedAt:
|
|
1085
|
+
zone: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.zone,
|
|
1086
|
+
label: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.label,
|
|
1087
|
+
verifiedAt: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.verifiedAt,
|
|
937
1088
|
rows,
|
|
938
|
-
counts:
|
|
1089
|
+
counts: _chunkYKEX4SK7cjs.CREATE_GUIDANCE.counts
|
|
939
1090
|
};
|
|
940
1091
|
}
|
|
941
1092
|
|
|
@@ -944,7 +1095,7 @@ var RECOVERY_CONFIRM = "operations.recovery";
|
|
|
944
1095
|
var RECOVERY_DEFAULT_LIMIT = 25;
|
|
945
1096
|
var RECOVERY_MAX_LIMIT = 100;
|
|
946
1097
|
function configError(message, operation, suggestedAction) {
|
|
947
|
-
throw new (0,
|
|
1098
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(message, { operation, suggestedAction });
|
|
948
1099
|
}
|
|
949
1100
|
function parseMatchId(record) {
|
|
950
1101
|
const raw = record.id;
|
|
@@ -961,7 +1112,7 @@ function parseMatchId(record) {
|
|
|
961
1112
|
}
|
|
962
1113
|
async function recovery(client, input, opts = {}) {
|
|
963
1114
|
const operation = RECOVERY_CONFIRM;
|
|
964
|
-
if (!
|
|
1115
|
+
if (!_chunkYKEX4SK7cjs.isRecord.call(void 0, input)) {
|
|
965
1116
|
configError(
|
|
966
1117
|
`recovery: input must be an object { resource, marker, ... } (got ${typeof input})`,
|
|
967
1118
|
operation,
|
|
@@ -992,10 +1143,10 @@ async function recovery(client, input, opts = {}) {
|
|
|
992
1143
|
"Pass action: 'delete' for the destructive path (dry-run-first; the apply requires the confirm string)."
|
|
993
1144
|
);
|
|
994
1145
|
}
|
|
995
|
-
const entry =
|
|
1146
|
+
const entry = _chunkYKEX4SK7cjs.RELATIONSHIP_MAP[resource];
|
|
996
1147
|
if (entry === void 0) {
|
|
997
|
-
throw new (0,
|
|
998
|
-
`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`,
|
|
999
1150
|
{
|
|
1000
1151
|
code: "RESOURCE_UNKNOWN",
|
|
1001
1152
|
category: "validation",
|
|
@@ -1004,7 +1155,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1004
1155
|
}
|
|
1005
1156
|
);
|
|
1006
1157
|
}
|
|
1007
|
-
const holder = client[
|
|
1158
|
+
const holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, resource)];
|
|
1008
1159
|
if (!holder || typeof holder.queryBounded !== "function") {
|
|
1009
1160
|
configError(
|
|
1010
1161
|
`recovery: ${resource} exposes no bounded query surface \u2014 the marker search cannot run`,
|
|
@@ -1012,7 +1163,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1012
1163
|
"Use a resource with a query surface, or address the record by id directly (get/fetchMany)."
|
|
1013
1164
|
);
|
|
1014
1165
|
}
|
|
1015
|
-
const field = input.field !== void 0 ? String(input.field) :
|
|
1166
|
+
const field = input.field !== void 0 ? String(input.field) : _chunkYKEX4SK7cjs.MARKER_FIELDS[resource];
|
|
1016
1167
|
if (typeof field !== "string" || field.trim() === "") {
|
|
1017
1168
|
configError(
|
|
1018
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`,
|
|
@@ -1048,7 +1199,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1048
1199
|
);
|
|
1049
1200
|
}
|
|
1050
1201
|
for (const c of input.filter) {
|
|
1051
|
-
if (!
|
|
1202
|
+
if (!_chunkYKEX4SK7cjs.isRecord.call(void 0, c) || typeof c.op !== "string" || c.op === "and" || c.op === "or") {
|
|
1052
1203
|
configError(
|
|
1053
1204
|
"recovery: input.filter accepts only plain leaf conditions ({ field, op, value }) \u2014 no grouping",
|
|
1054
1205
|
operation,
|
|
@@ -1069,7 +1220,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1069
1220
|
}
|
|
1070
1221
|
limit = input.limit;
|
|
1071
1222
|
}
|
|
1072
|
-
const boundaryNote =
|
|
1223
|
+
const boundaryNote = _chunkYKEX4SK7cjs.DELETE_BOUNDARY_NOTES[resource];
|
|
1073
1224
|
const boundary = {
|
|
1074
1225
|
available: boundaryNote === void 0,
|
|
1075
1226
|
reason: _nullishCoalesce(boundaryNote, () => ( null)),
|
|
@@ -1081,7 +1232,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1081
1232
|
};
|
|
1082
1233
|
const isDelete = action === "delete";
|
|
1083
1234
|
if (isDelete && boundaryNote !== void 0) {
|
|
1084
|
-
throw new (0,
|
|
1235
|
+
throw new (0, _chunkYKEX4SK7cjs.DeleteBoundaryError)(
|
|
1085
1236
|
`recovery: the vendor defines no DELETE for ${resource} \u2014 the delete cannot be issued through the API (zero wire was issued)`,
|
|
1086
1237
|
{
|
|
1087
1238
|
operation,
|
|
@@ -1093,7 +1244,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1093
1244
|
const dryRun = _optionalChain([opts, 'optionalAccess', _18 => _18.dryRun]) !== false;
|
|
1094
1245
|
const confirm = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _19 => _19.confirm]), () => ( input.confirm));
|
|
1095
1246
|
if (isDelete && !dryRun && confirm !== RECOVERY_CONFIRM) {
|
|
1096
|
-
throw new (0,
|
|
1247
|
+
throw new (0, _chunkYKEX4SK7cjs.ConfirmationRequiredError)(
|
|
1097
1248
|
`recovery: action 'delete' apply is destructive and requires its confirmation flag: pass confirm: "${RECOVERY_CONFIRM}"`,
|
|
1098
1249
|
{
|
|
1099
1250
|
operation: RECOVERY_CONFIRM,
|
|
@@ -1109,7 +1260,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1109
1260
|
const query = await holder.queryBounded({ filter: conditions, limit });
|
|
1110
1261
|
if (query.hasMore) {
|
|
1111
1262
|
const wire = isDelete ? "DELETE wire" : "mutating wire";
|
|
1112
|
-
throw new (0,
|
|
1263
|
+
throw new (0, _chunkYKEX4SK7cjs.RecoveryTruncatedError)(
|
|
1113
1264
|
`recovery: the marker search on ${resource} TRIPPED its match cap (${limit}) \u2014 more matches exist than were returned (zero ${wire} was issued)`,
|
|
1114
1265
|
{
|
|
1115
1266
|
operation,
|
|
@@ -1148,7 +1299,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1148
1299
|
return { ...base, simulated: true, dryRun: true };
|
|
1149
1300
|
}
|
|
1150
1301
|
if (unsafeId) {
|
|
1151
|
-
throw new (0,
|
|
1302
|
+
throw new (0, _chunkYKEX4SK7cjs.MarkerUnsafeIdError)(
|
|
1152
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)`,
|
|
1153
1304
|
{
|
|
1154
1305
|
operation,
|
|
@@ -1159,7 +1310,7 @@ async function recovery(client, input, opts = {}) {
|
|
|
1159
1310
|
}
|
|
1160
1311
|
const deleteMethod = holder.delete;
|
|
1161
1312
|
if (deleteMethod === void 0) {
|
|
1162
|
-
throw new (0,
|
|
1313
|
+
throw new (0, _chunkYKEX4SK7cjs.DeleteBoundaryError)(
|
|
1163
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`,
|
|
1164
1315
|
{
|
|
1165
1316
|
operation,
|
|
@@ -1188,14 +1339,14 @@ async function recovery(client, input, opts = {}) {
|
|
|
1188
1339
|
verify = "still-present";
|
|
1189
1340
|
}
|
|
1190
1341
|
} catch (err) {
|
|
1191
|
-
if (err instanceof
|
|
1342
|
+
if (err instanceof _chunkYKEX4SK7cjs.NotFoundError) verify = "not-found";
|
|
1192
1343
|
else {
|
|
1193
1344
|
verify = "error";
|
|
1194
|
-
code =
|
|
1345
|
+
code = _chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1195
1346
|
}
|
|
1196
1347
|
}
|
|
1197
1348
|
} catch (err) {
|
|
1198
|
-
code =
|
|
1349
|
+
code = _chunkYKEX4SK7cjs.isAutotaskError.call(void 0, err) ? err.code : "SERVER_ERROR";
|
|
1199
1350
|
}
|
|
1200
1351
|
deleted.push({ id, verified: verify === "not-found", code });
|
|
1201
1352
|
}
|
|
@@ -1203,13 +1354,13 @@ async function recovery(client, input, opts = {}) {
|
|
|
1203
1354
|
}
|
|
1204
1355
|
|
|
1205
1356
|
// src/operations/invoke.ts
|
|
1206
|
-
var RECORDS =
|
|
1357
|
+
var RECORDS = _chunkT5FLSJODcjs.CAPABILITIES;
|
|
1207
1358
|
var byId = new Map(RECORDS.map((r) => [r.id, r]));
|
|
1208
1359
|
function needsConfirmation(record) {
|
|
1209
1360
|
return record.effect === "destructive" || (_nullishCoalesce(record.flags, () => ( []))).includes("requiresApproval");
|
|
1210
1361
|
}
|
|
1211
1362
|
function refuse(message, operation, suggestedAction) {
|
|
1212
|
-
throw new (0,
|
|
1363
|
+
throw new (0, _chunkYKEX4SK7cjs.ConfirmationRequiredError)(message, { operation, suggestedAction });
|
|
1213
1364
|
}
|
|
1214
1365
|
var MODE_BY_EFFECT = {
|
|
1215
1366
|
read: "read",
|
|
@@ -1253,7 +1404,7 @@ function looseTypeOk(type, value) {
|
|
|
1253
1404
|
case "string[]":
|
|
1254
1405
|
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
1255
1406
|
case "object":
|
|
1256
|
-
return
|
|
1407
|
+
return _chunkYKEX4SK7cjs.isRecord.call(void 0, value);
|
|
1257
1408
|
default:
|
|
1258
1409
|
return true;
|
|
1259
1410
|
}
|
|
@@ -1270,7 +1421,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1270
1421
|
const schema = _nullishCoalesce(record.inputSchema, () => ( {}));
|
|
1271
1422
|
const names = Object.keys(schema);
|
|
1272
1423
|
if (args.length > names.length) {
|
|
1273
|
-
throw new (0,
|
|
1424
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1274
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)`,
|
|
1275
1426
|
{
|
|
1276
1427
|
operation,
|
|
@@ -1280,7 +1431,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1280
1431
|
}
|
|
1281
1432
|
const required = names.filter((n) => schema[n].required);
|
|
1282
1433
|
if (args.length < required.length) {
|
|
1283
|
-
throw new (0,
|
|
1434
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1284
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)}`,
|
|
1285
1436
|
{ operation }
|
|
1286
1437
|
);
|
|
@@ -1291,7 +1442,7 @@ function validateDispatchArgs(record, argsIn) {
|
|
|
1291
1442
|
const name = names[i];
|
|
1292
1443
|
const spec = schema[name];
|
|
1293
1444
|
if (!looseTypeOk(spec.type, value)) {
|
|
1294
|
-
throw new (0,
|
|
1445
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1295
1446
|
`invoke: "${operation}" arg ${i + 1} is declared ${name}: ${spec.type} \u2014 the value has the wrong type (pass a ${spec.type} value)`,
|
|
1296
1447
|
{ operation }
|
|
1297
1448
|
);
|
|
@@ -1343,11 +1494,11 @@ function validateParamsBag(record, args) {
|
|
|
1343
1494
|
const valid = PARAMS_BAG_KEYS[record.operation];
|
|
1344
1495
|
if (valid === void 0) return;
|
|
1345
1496
|
const bag = _optionalChain([args, 'optionalAccess', _20 => _20[0]]);
|
|
1346
|
-
if (bag === void 0 || bag === null || !
|
|
1497
|
+
if (bag === void 0 || bag === null || !_chunkYKEX4SK7cjs.isRecord.call(void 0, bag)) return;
|
|
1347
1498
|
const unknown = Object.keys(bag).filter((k) => !valid.includes(k));
|
|
1348
1499
|
if (unknown.length === 0) return;
|
|
1349
1500
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, valid)]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1350
|
-
throw new (0,
|
|
1501
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1351
1502
|
`invoke: "${record.id}" params bag has unknown key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the bag is closed (valid keys: ${valid.join(", ")})`,
|
|
1352
1503
|
{
|
|
1353
1504
|
operation: record.id,
|
|
@@ -1361,7 +1512,7 @@ function validateInvokeOptions(opts, operation) {
|
|
|
1361
1512
|
const unknown = Object.keys(opts).filter((k) => !INVOKE_OPTION_KEYS.includes(k));
|
|
1362
1513
|
if (unknown.length === 0) return;
|
|
1363
1514
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, ["dryRun", "confirm", "lastModifiedDate"])]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1364
|
-
throw new (0,
|
|
1515
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1365
1516
|
`invoke: "${operation}" has unknown option key(s) ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the options set is closed (valid: dryRun, confirm, lastModifiedDate)`,
|
|
1366
1517
|
{
|
|
1367
1518
|
operation,
|
|
@@ -1374,7 +1525,7 @@ function unknownKeysRefusal(raw, validKeys, subject, operation) {
|
|
|
1374
1525
|
const unknown = Object.keys(raw).filter((k) => !validKeys.includes(k));
|
|
1375
1526
|
if (unknown.length === 0) return null;
|
|
1376
1527
|
const suggestions = unknown.map((k) => [k, suggestForKey(k, [...validKeys])]).filter((pair) => pair[1] !== null).map(([k, s]) => `"${k}" \u2192 "${s}"`);
|
|
1377
|
-
return new (0,
|
|
1528
|
+
return new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1378
1529
|
`unknown ${subject} ${unknown.map((k) => `"${k}"`).join(", ")} \u2014 the ${subject} set is closed (valid keys: ${validKeys.join(", ")})`,
|
|
1379
1530
|
{
|
|
1380
1531
|
...operation !== void 0 ? { operation } : {},
|
|
@@ -1386,7 +1537,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1386
1537
|
const args = _nullishCoalesce(argsIn, () => ( []));
|
|
1387
1538
|
const record = byId.get(operation);
|
|
1388
1539
|
if (record === void 0) {
|
|
1389
|
-
throw new (0,
|
|
1540
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1390
1541
|
`invoke: unknown operation "${operation}" \u2014 it is not in the capability registry`,
|
|
1391
1542
|
{ operation, suggestedAction: "List the registry (the ./capabilities subpath) for the exact operation key." }
|
|
1392
1543
|
);
|
|
@@ -1394,17 +1545,17 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1394
1545
|
validateInvokeOptions(opts, operation);
|
|
1395
1546
|
const mode = opts.mode;
|
|
1396
1547
|
if (mode !== void 0 && MODE_BY_EFFECT[record.effect] !== mode) {
|
|
1397
|
-
throw new (0,
|
|
1548
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(crossModeRefusal(operation, record.effect, mode), { operation });
|
|
1398
1549
|
}
|
|
1399
1550
|
if (opts.dryRun !== void 0 && typeof opts.dryRun !== "boolean") {
|
|
1400
|
-
throw new (0,
|
|
1551
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1401
1552
|
`invoke: dryRun must be a boolean (got ${typeof opts.dryRun}) \u2014 "${operation}" was not issued`,
|
|
1402
1553
|
{ operation, suggestedAction: "Pass dryRun: true (simulate) or dryRun: false (apply) as a real boolean." }
|
|
1403
1554
|
);
|
|
1404
1555
|
}
|
|
1405
1556
|
const isWrite = record.effect !== "read";
|
|
1406
1557
|
if (!isWrite && opts.dryRun === true) {
|
|
1407
|
-
throw new (0,
|
|
1558
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1408
1559
|
`invoke: "${operation}" is a read \u2014 dryRun is not applicable (reads issue their request as-is)`,
|
|
1409
1560
|
{ operation }
|
|
1410
1561
|
);
|
|
@@ -1419,9 +1570,9 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1419
1570
|
validateDispatchArgs(record, args);
|
|
1420
1571
|
validateParamsBag(record, args);
|
|
1421
1572
|
const boundedQuery = record.kind === "primitive" && record.operation === "query";
|
|
1422
|
-
let holder = client[
|
|
1573
|
+
let holder = client[_chunkYKEX4SK7cjs.camelKey.call(void 0, record.resource)];
|
|
1423
1574
|
if (typeof holder === "function") {
|
|
1424
|
-
holder = _nullishCoalesce(client[`${
|
|
1575
|
+
holder = _nullishCoalesce(client[`${_chunkYKEX4SK7cjs.camelKey.call(void 0, record.resource)}Resource`], () => ( holder));
|
|
1425
1576
|
}
|
|
1426
1577
|
if (holder === void 0 && record.resource === "operations") {
|
|
1427
1578
|
holder = {
|
|
@@ -1442,7 +1593,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1442
1593
|
// reads ONLY (never an id-in query — the resources table can be blind
|
|
1443
1594
|
// to count/query while per-id reads work); blind-marked rows for ids
|
|
1444
1595
|
// the API user cannot resolve; the name cache (default-on).
|
|
1445
|
-
expandResourceNames: (ids, opts2) =>
|
|
1596
|
+
expandResourceNames: (ids, opts2) => _chunkYKEX4SK7cjs.expandResourceNames.call(void 0, client, ids, opts2),
|
|
1446
1597
|
relationshipMap: (resourceKey) => relationshipMap(client, resourceKey),
|
|
1447
1598
|
// Issue #11: the served blind-surface inventory (zero wire) + the
|
|
1448
1599
|
// bounded caller-opted reachability sweep (read-only, confirmProbe-
|
|
@@ -1455,7 +1606,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1455
1606
|
// entityInformation GETs (the op's own cap refuses over-cap fan-outs
|
|
1456
1607
|
// pre-request; per-resource failures are recorded on the row and
|
|
1457
1608
|
// never abort the call).
|
|
1458
|
-
fieldCatalog: (opts2) =>
|
|
1609
|
+
fieldCatalog: (opts2) => _chunkYKEX4SK7cjs.fieldCatalog.call(void 0, client, opts2),
|
|
1459
1610
|
// Issue #9: the one-call recovery/cleanup op — effect write in the
|
|
1460
1611
|
// registry (the governor's dry-run-first applies to it); the op's own
|
|
1461
1612
|
// confirm gate makes the destructive action deliberate (the governor
|
|
@@ -1464,7 +1615,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1464
1615
|
};
|
|
1465
1616
|
}
|
|
1466
1617
|
if (holder === void 0) {
|
|
1467
|
-
throw new (0,
|
|
1618
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1468
1619
|
`invoke: the client exposes no accessor for resource "${record.resource}"`,
|
|
1469
1620
|
{ operation }
|
|
1470
1621
|
);
|
|
@@ -1472,7 +1623,7 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
1472
1623
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
1473
1624
|
const method = holder[methodName];
|
|
1474
1625
|
if (typeof method !== "function") {
|
|
1475
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkYKEX4SK7cjs.AutotaskConfigError)(
|
|
1476
1627
|
`invoke: "${record.resource}.${methodName}" is not a callable method on the client`,
|
|
1477
1628
|
{ operation }
|
|
1478
1629
|
);
|
|
@@ -1573,5 +1724,7 @@ async function invokeDelete(client, operation, args = [], opts = {}) {
|
|
|
1573
1724
|
|
|
1574
1725
|
|
|
1575
1726
|
|
|
1576
|
-
|
|
1577
|
-
|
|
1727
|
+
|
|
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;
|