node-autotask 0.28.0 → 0.30.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/MCP_TOOL_CATALOG.json +46 -8
  3. package/MCP_TOOL_MANIFEST.md +13 -11
  4. package/N8N_MCP_MANIFEST.json +34 -5
  5. package/N8N_MCP_MANIFEST.md +8 -7
  6. package/README.md +1 -2
  7. package/capabilities.json +1642 -1319
  8. package/dist/capabilities.cjs +2 -2
  9. package/dist/capabilities.js +1 -1
  10. package/dist/{chunk-O2D7KDDD.js → chunk-2ETR5GSO.js} +2 -2
  11. package/dist/{chunk-ZEGMVEF3.cjs → chunk-EDVSWL32.cjs} +1641 -1318
  12. package/dist/{chunk-GUY2KK7U.cjs → chunk-L4TDVUJM.cjs} +143 -143
  13. package/dist/{chunk-D5IVS6GY.cjs → chunk-LLIB4JGK.cjs} +140 -6
  14. package/dist/{chunk-SYX6EWMT.js → chunk-P4PC32RJ.js} +192 -70
  15. package/dist/{chunk-IRVZGW5K.js → chunk-QQPCJT2L.js} +136 -2
  16. package/dist/{chunk-WYKGD5UD.cjs → chunk-RS7QMPRO.cjs} +622 -500
  17. package/dist/{chunk-6EQSXYRW.js → chunk-TZC4ZAA6.js} +1641 -1318
  18. package/dist/{index-CORcZUNm.d.cts → index-B9VNv-EP.d.cts} +52 -2
  19. package/dist/{index-DQ9NgraW.d.cts → index-CJ36PwRG.d.cts} +110 -82
  20. package/dist/{index-DQ9NgraW.d.ts → index-CJ36PwRG.d.ts} +110 -82
  21. package/dist/{index-DXuV04zM.d.ts → index-DkpaFqyu.d.ts} +52 -2
  22. package/dist/index.cjs +22 -22
  23. package/dist/index.d.cts +4 -4
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +4 -4
  26. package/dist/operations/index.cjs +112 -112
  27. package/dist/operations/index.d.cts +4 -4
  28. package/dist/operations/index.d.ts +4 -4
  29. package/dist/operations/index.js +2 -2
  30. package/dist/pool.cjs +9 -9
  31. package/dist/pool.d.cts +2 -2
  32. package/dist/pool.d.ts +2 -2
  33. package/dist/pool.js +4 -4
  34. package/dist/resources/index.cjs +4 -4
  35. package/dist/resources/index.d.cts +2 -2
  36. package/dist/resources/index.d.ts +2 -2
  37. package/dist/resources/index.js +3 -3
  38. package/dist/types/index.d.cts +1 -1
  39. package/dist/types/index.d.ts +1 -1
  40. package/docs/API.md +1 -2
  41. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CAPABILITIES
3
- } from "./chunk-6EQSXYRW.js";
3
+ } from "./chunk-TZC4ZAA6.js";
4
4
 
5
5
  // src/auth.ts
6
6
  var AUTH_HEADERS = {
@@ -17390,8 +17390,18 @@ function createNamePlan(labelFields = []) {
17390
17390
  const resSeen = /* @__PURE__ */ new Set();
17391
17391
  const recordFks = [];
17392
17392
  const fkSeen = /* @__PURE__ */ new Set();
17393
+ let lineOfBusinessId;
17394
+ let lineOfBusinessSource;
17395
+ let lineOfBusinessContractId;
17393
17396
  return {
17394
- plan: () => ({ resourceIds, recordFks, labelFields }),
17397
+ plan: () => ({
17398
+ resourceIds,
17399
+ recordFks,
17400
+ labelFields,
17401
+ ...lineOfBusinessId !== void 0 ? { lineOfBusinessId } : {},
17402
+ ...lineOfBusinessSource !== void 0 ? { lineOfBusinessSource } : {},
17403
+ ...lineOfBusinessContractId !== void 0 ? { lineOfBusinessContractId } : {}
17404
+ }),
17395
17405
  addResource: (value) => {
17396
17406
  if (!isVendorId(value)) return;
17397
17407
  const k = String(value);
@@ -17407,6 +17417,18 @@ function createNamePlan(labelFields = []) {
17407
17417
  fkSeen.add(k);
17408
17418
  recordFks.push({ table, id: value });
17409
17419
  }
17420
+ },
17421
+ addLineOfBusinessFromContract: (value) => {
17422
+ if (!isVendorId(value)) return;
17423
+ lineOfBusinessContractId = value;
17424
+ },
17425
+ addLineOfBusiness: (value, origin) => {
17426
+ if (!isVendorId(value)) return;
17427
+ lineOfBusinessId = value;
17428
+ if (origin !== void 0) {
17429
+ lineOfBusinessSource = origin.source;
17430
+ if (origin.contractId !== void 0) lineOfBusinessContractId = origin.contractId;
17431
+ }
17410
17432
  }
17411
17433
  };
17412
17434
  }
@@ -17438,6 +17460,82 @@ function faultRow(err) {
17438
17460
  const e = err;
17439
17461
  return e.httpStatus !== void 0 ? { code: e.code, message: e.message, httpStatus: e.httpStatus } : { code: e.code, message: e.message };
17440
17462
  }
17463
+ function vendorId(value) {
17464
+ if (typeof value === "number") return Number.isSafeInteger(value) && value >= 1 ? value : void 0;
17465
+ if (typeof value === "string" && /^[0-9]+$/.test(value.trim())) {
17466
+ const n = Number(value.trim());
17467
+ return Number.isSafeInteger(n) && n >= 1 ? n : void 0;
17468
+ }
17469
+ return void 0;
17470
+ }
17471
+ async function resolveLineOfBusinessChain(http, associationId, options) {
17472
+ const operation = options.operation ?? "compositeNames";
17473
+ const degrade = options.onError === "degrade";
17474
+ const get = (path) => {
17475
+ const res = http.request({ method: "GET", path, operation }).then((body) => {
17476
+ const b = body;
17477
+ if (b === null || !("item" in b) || b.item === null || b.item === void 0) return null;
17478
+ return b.item;
17479
+ });
17480
+ if (!degrade) {
17481
+ return res.catch((e) => {
17482
+ if (e instanceof NotFoundError) return null;
17483
+ throw e;
17484
+ });
17485
+ }
17486
+ return res.catch((e) => {
17487
+ if (e instanceof NotFoundError || isAutotaskError(e) && e.code !== "ABORTED") return null;
17488
+ throw e;
17489
+ });
17490
+ };
17491
+ let remaining = options.budget;
17492
+ if (remaining < 1) {
17493
+ return {
17494
+ lineOfBusiness: { association: null, organizationalLevel2: null, organizationalLevel1: null, markers: { association: "capped", organizationalLevel2: "capped", organizationalLevel1: "capped" } },
17495
+ used: 0,
17496
+ truncated: true
17497
+ };
17498
+ }
17499
+ remaining -= 1;
17500
+ const association = await get(`/V1.0/OrganizationalLevelAssociations/${associationId}`);
17501
+ const associationMarker = association === null ? "unresolved" : "ok";
17502
+ if (association === null) {
17503
+ return {
17504
+ lineOfBusiness: { association: null, organizationalLevel2: null, organizationalLevel1: null, markers: { association: associationMarker, organizationalLevel2: "missing", organizationalLevel1: "missing" } },
17505
+ used: 1,
17506
+ truncated: false
17507
+ };
17508
+ }
17509
+ const l2Id = vendorId(association.organizationalLevel2ID);
17510
+ const l1Id = vendorId(association.organizationalLevel1ID);
17511
+ let l2Marker = l2Id !== void 0 ? "unresolved" : "missing";
17512
+ let l1Marker = l1Id !== void 0 ? "unresolved" : "missing";
17513
+ const need = (l2Id !== void 0 ? 1 : 0) + (l1Id !== void 0 ? 1 : 0);
17514
+ let l2 = null;
17515
+ let l1 = null;
17516
+ let used = 1;
17517
+ let truncated = false;
17518
+ if (need > 0 && remaining < need) {
17519
+ truncated = true;
17520
+ if (l2Id !== void 0) l2Marker = "capped";
17521
+ if (l1Id !== void 0) l1Marker = "capped";
17522
+ } else {
17523
+ used += need;
17524
+ const [r2, r1] = await Promise.all([
17525
+ l2Id !== void 0 ? get(`/V1.0/OrganizationalLevel2s/${l2Id}`) : Promise.resolve(null),
17526
+ l1Id !== void 0 ? get(`/V1.0/OrganizationalLevel1s/${l1Id}`) : Promise.resolve(null)
17527
+ ]);
17528
+ l2 = r2;
17529
+ l1 = r1;
17530
+ if (l2Id !== void 0) l2Marker = l2 === null ? "unresolved" : "ok";
17531
+ if (l1Id !== void 0) l1Marker = l1 === null ? "unresolved" : "ok";
17532
+ }
17533
+ return {
17534
+ lineOfBusiness: { association, organizationalLevel2: l2, organizationalLevel1: l1, markers: { association: associationMarker, organizationalLevel2: l2Marker, organizationalLevel1: l1Marker } },
17535
+ used,
17536
+ truncated
17537
+ };
17538
+ }
17441
17539
  async function resolveCompositeNames(http, plan, opts = {}) {
17442
17540
  if (opts.maxNameReads !== void 0 && (!Number.isInteger(opts.maxNameReads) || opts.maxNameReads < 1)) {
17443
17541
  throw new AutotaskConfigError(`composite names: maxNameReads must be an integer >= 1 (got ${String(opts.maxNameReads)})`);
@@ -17451,6 +17549,8 @@ async function resolveCompositeNames(http, plan, opts = {}) {
17451
17549
  const nameCache = http.resourceNameCache;
17452
17550
  const section = { truncated: false, rows: {}, reasons: {} };
17453
17551
  let remaining = budget;
17552
+ let contractLobPointer;
17553
+ let contractLobUnread;
17454
17554
  const coldResource = [];
17455
17555
  for (const id of plan.resourceIds) {
17456
17556
  if (nameCache !== void 0 && nameCache.get(id) !== void 0) continue;
@@ -17494,18 +17594,27 @@ async function resolveCompositeNames(http, plan, opts = {}) {
17494
17594
  if (remaining < 1) {
17495
17595
  section.rows[key] = { name: null, blind: false, capped: true };
17496
17596
  section.truncated = true;
17597
+ if (fk.table === "contract" && plan.lineOfBusinessContractId !== void 0 && String(fk.id) === String(plan.lineOfBusinessContractId)) {
17598
+ contractLobUnread = "capped";
17599
+ }
17497
17600
  continue;
17498
17601
  }
17499
17602
  remaining -= 1;
17500
17603
  }
17501
17604
  try {
17502
17605
  const record = await holders[fk.table].get(fk.id);
17606
+ if (fk.table === "contract" && plan.lineOfBusinessId === void 0 && plan.lineOfBusinessContractId !== void 0 && String(fk.id) === String(plan.lineOfBusinessContractId)) {
17607
+ contractLobPointer = vendorId(record["organizationalLevelAssociationID"]);
17608
+ }
17503
17609
  section.rows[key] = { name: fkName(record, fk.table), blind: false, capped: false };
17504
17610
  } catch (err) {
17505
17611
  if (err instanceof NotFoundError) {
17506
17612
  section.rows[key] = { name: null, blind: true, capped: false };
17507
17613
  } else if (isAutotaskError(err) && err.code !== "ABORTED") {
17508
17614
  section.rows[key] = { name: null, blind: false, capped: false, error: faultRow(err) };
17615
+ if (fk.table === "contract" && plan.lineOfBusinessContractId !== void 0 && String(fk.id) === String(plan.lineOfBusinessContractId)) {
17616
+ contractLobUnread = "unresolved";
17617
+ }
17509
17618
  } else {
17510
17619
  throw err;
17511
17620
  }
@@ -17531,8 +17640,31 @@ async function resolveCompositeNames(http, plan, opts = {}) {
17531
17640
  }
17532
17641
  if (!usable) for (const f of plan.labelFields) section.reasons[f] = FIELD_CATALOG_HONESTY_NOTE;
17533
17642
  }
17643
+ let lineOfBusiness = null;
17644
+ const lobId = plan.lineOfBusinessId ?? contractLobPointer;
17645
+ if (lobId !== void 0) {
17646
+ const chain = await resolveLineOfBusinessChain(http, lobId, { budget: remaining, onError: "degrade" });
17647
+ remaining -= chain.used;
17648
+ if (chain.truncated) section.truncated = true;
17649
+ const fromContract = plan.lineOfBusinessId === void 0;
17650
+ lineOfBusiness = {
17651
+ ...chain.lineOfBusiness,
17652
+ ...fromContract ? { source: "contract", contractId: plan.lineOfBusinessContractId } : plan.lineOfBusinessSource !== void 0 ? { source: plan.lineOfBusinessSource } : {},
17653
+ ...!fromContract && plan.lineOfBusinessContractId !== void 0 ? { contractId: plan.lineOfBusinessContractId } : {}
17654
+ };
17655
+ } else if (contractLobUnread !== void 0 && plan.lineOfBusinessContractId !== void 0) {
17656
+ lineOfBusiness = {
17657
+ source: "contract",
17658
+ contractId: plan.lineOfBusinessContractId,
17659
+ association: null,
17660
+ organizationalLevel2: null,
17661
+ organizationalLevel1: null,
17662
+ markers: { association: contractLobUnread, organizationalLevel2: "missing", organizationalLevel1: "missing" }
17663
+ };
17664
+ }
17534
17665
  return {
17535
17666
  section,
17667
+ lineOfBusiness,
17536
17668
  resourceName: (id) => section.rows[`resource:${id}`]?.name ?? null,
17537
17669
  recordName: (table, id) => section.rows[`${table}:${id}`]?.name ?? null,
17538
17670
  labelFor: (field, value) => {
@@ -20297,6 +20429,8 @@ export {
20297
20429
  createNamePlan,
20298
20430
  addNameSibling,
20299
20431
  addLabelSibling,
20432
+ vendorId,
20433
+ resolveLineOfBusinessChain,
20300
20434
  resolveCompositeNames,
20301
20435
  FETCH_MANY_MAX_ITEMS,
20302
20436
  validateFetchManyItems,