node-autotask 0.39.4 → 0.41.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 (44) hide show
  1. package/ARCHITECTURE.md +6 -2
  2. package/CHANGELOG.md +33 -0
  3. package/MCP_TOOL_CATALOG.json +10 -32
  4. package/MCP_TOOL_MANIFEST.md +12 -13
  5. package/N8N_MCP_MANIFEST.json +5 -44
  6. package/N8N_MCP_MANIFEST.md +7 -8
  7. package/README.md +29 -37
  8. package/capabilities.json +1346 -1535
  9. package/dist/base-CVx2VMSj.d.cts +103 -0
  10. package/dist/base-CVx2VMSj.d.ts +103 -0
  11. package/dist/capabilities.cjs +2 -2
  12. package/dist/capabilities.js +1 -1
  13. package/dist/{chunk-SGKGNJEI.cjs → chunk-DKAD7MOV.cjs} +771 -1835
  14. package/dist/{chunk-DJCRQLQE.cjs → chunk-DXEBPK55.cjs} +287 -292
  15. package/dist/{chunk-GHRB46YN.js → chunk-LR6FDJI3.js} +614 -1678
  16. package/dist/{chunk-VR6RYXTD.cjs → chunk-MJ6J74F3.cjs} +1345 -1534
  17. package/dist/{chunk-JBQ55HYG.js → chunk-P5655PGY.js} +2 -2
  18. package/dist/{chunk-DBLXPY4B.js → chunk-TCND5PFF.js} +4 -9
  19. package/dist/{chunk-H4S4KSXX.cjs → chunk-YAHFPOQF.cjs} +143 -143
  20. package/dist/{chunk-GDSCYY2G.js → chunk-ZVSSAULC.js} +1345 -1534
  21. package/dist/{index-DkZVRMeW.d.ts → index-CqO1HNHl.d.cts} +125 -851
  22. package/dist/{index-DkZVRMeW.d.cts → index-CqO1HNHl.d.ts} +125 -851
  23. package/dist/index.cjs +23 -51
  24. package/dist/index.d.cts +103 -102
  25. package/dist/index.d.ts +103 -102
  26. package/dist/index.js +19 -47
  27. package/dist/operations/index.cjs +178 -178
  28. package/dist/operations/index.d.cts +5 -4
  29. package/dist/operations/index.d.ts +5 -4
  30. package/dist/operations/index.js +3 -3
  31. package/dist/pool.cjs +17 -60
  32. package/dist/pool.d.cts +5 -13
  33. package/dist/pool.d.ts +5 -13
  34. package/dist/pool.js +13 -56
  35. package/dist/resources/index.cjs +4 -4
  36. package/dist/resources/index.d.cts +1 -1
  37. package/dist/resources/index.d.ts +1 -1
  38. package/dist/resources/index.js +3 -3
  39. package/dist/types/index.d.cts +1 -1
  40. package/dist/types/index.d.ts +1 -1
  41. package/docs/API.md +138 -340
  42. package/docs/N8N-ADAPTER.md +7 -7
  43. package/examples/mcp-server-http.ts +18 -18
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -4,8 +4,8 @@ Fully-typed TypeScript SDK for the Autotask (Datto) PSA REST API. Zero runtime
4
4
  dependencies. Built for building MCP servers and integrations.
5
5
 
6
6
  The SDK is also the **deterministic execution layer for agents** (ARCHITECTURE
7
- section 19): a generated capability registry (1281 operations across the 121-entity
8
- MVP set), a mechanical MCP substrate (registry → manifest → overrides → core tier +
7
+ section 19): a generated capability registry (one record per operation, across the entity
8
+ registry in `capabilities.json`), a mechanical MCP substrate (registry → manifest → overrides → core tier +
9
9
  catalog meta-tool), and a write governor (dry-run-first, destructive
10
10
  confirmation). The SDK boundary also redacts response field values — the
11
11
  secret fields (`password`, `secretKey`, `secret`) always, personal and
@@ -219,29 +219,23 @@ The reference MCP servers (`examples/mcp-server.ts`,
219
219
  (0 disables retries). Unset = the profile's value; an invalid value stops
220
220
  startup with an `AutotaskConfigError` naming the variable.
221
221
 
222
- ## Optional per-host circuit breaker (issue #26)
223
-
224
- `circuitBreaker: { enabled: true }` opts into the circuit breaker at the
225
- transport (OFF by default — nothing changes unless opted in). It counts
226
- SERVICE-FAILURE outcomes per HOST (the lowercased host of the base URL — a
227
- zone outage hits every tenant on that zone) and, once 5 counted failures
228
- land inside a 10-second window, refuses further calls for that host
229
- LOCALLY — zero upstream calls, no hourly-limiter stamp — as a
230
- `CircuitBreakerError` (`code: 'CIRCUIT_BREAKER_OPEN'`, `notSent: true`,
231
- `retryAfter` = the remaining open seconds; `retryable: true` — the open
232
- period is bounded and advertised, so retry the SAME call after the wait;
233
- the deliberate divergence from the #6 cooldown refusal's `retryable:
234
- false`). After 30 seconds open, up to `halfOpenProbes` probes go
235
- upstream; 2 probe successes close the circuit, a probe failure re-arms it.
236
- The default predicate counts `NETWORK_ERROR`, `TIMEOUT`, a vendor 429, a
237
- 5xx except the deterministic field-validation 500, and
238
- `UNEXPECTED_CONTENT_TYPE` — never a caller's cancellation, a 4xx, or a
239
- local refusal. On a shared host (one host, many credential tuples) one
240
- tenant's outage opens the circuit for the others — the documented
241
- consequence of the host-only key. `thresholdInformation.get()` bypasses
242
- the refusal (its outcome is still recorded); a custom `CircuitBreakerStore`
243
- and failure predicate are injectable (details:
244
- [`docs/API.md`](./docs/API.md) section 3.2.2).
222
+ ## Maintenance gate (issue #285)
223
+
224
+ Autotask takes each zone down for a weekly maintenance window, during which the
225
+ edge serves an HTML maintenance page. The first call that sees that page opens a
226
+ process-wide gate for the zone (always on). While it is open, every other call on
227
+ the zone fails at once with `MaintenanceError` (`code: 'MAINTENANCE'`,
228
+ `notSent: true`, `retryAfter` = seconds to the next probe, `details.since`), with
229
+ zero upstream calls. One call per `maintenancePollMs` (default 30 s) goes upstream
230
+ as the probe, and the first non-maintenance response closes the gate. The call
231
+ that saw the page waits the window out for up to `maintenanceMaxWaitMs` (default
232
+ 1 h); `maintenanceMaxWaitMs: 0` fails fast instead (the gate still opens). A
233
+ call that receives the page and does not wait it out throws the same
234
+ `MaintenanceError` (with `httpStatus` set, no `notSent`), so consumers map one
235
+ code. Only the
236
+ page's text is recognised: a non-matching HTML page (for example a wrong
237
+ `baseUrl`) never opens the gate. Details: [`docs/API.md`](./docs/API.md)
238
+ section 3.2.2.
245
239
 
246
240
  ## Subpaths
247
241
 
@@ -265,7 +259,7 @@ import { markUntrusted, stripUntrustedDeep } from 'node-autotask/untrusted';
265
259
  // tuple (multi-tenant gateways: one client per tenant — limiter state and
266
260
  // read cache persist across a tenant's requests, never across tenants)
267
261
  import { createClientPool } from 'node-autotask/pool';
268
- // createClientPool({ maxSize = 128, idleTtlMs?, factory? })
262
+ // createClientPool({ maxSize = 128, sharedReadCache? })
269
263
  // -> { get(config), delete(config), clear(), size }
270
264
 
271
265
  // Errors (the class → code → status hierarchy)
@@ -284,9 +278,8 @@ The SDK ships the mechanical substrate, not a server (no MCP imports, no zod):
284
278
  `staleCheck` hash-pins). Generated from `capabilities.plan.json` (the single source
285
279
  of truth) — never hand-edited.
286
280
  2. **Manifest** — [`MCP_TOOL_MANIFEST.md`](./MCP_TOOL_MANIFEST.md): the mechanical
287
- projection (`npm run mcp:project`) — 804 entity-first tool names
288
- (`autotask_<entity>_<verb>`; the five META tools bring the full surface to
289
- 809), descriptions = registry purpose + a mechanical
281
+ projection (`npm run mcp:project`) — entity-first tool names
282
+ (`autotask_<entity>_<verb>`, plus the five META tools), descriptions = registry purpose + a mechanical
290
283
  bounds/flags sentence, `dry_run` affordance on mutating tools, `confirm` on
291
284
  destructive ones; the plan-derived `untrustedFields` read tools additionally
292
285
  carry the untrusted-content sentence + the field list as the `x-untrusted`
@@ -352,7 +345,7 @@ The SDK ships the mechanical substrate, not a server (no MCP imports, no zod):
352
345
  whose MCP annotation is `readOnlyHint !== true` — today exactly **267
353
346
  tools**: the 265 dedicated write/delete tools (209 `effect=write` + 56
354
347
  `effect=destructive`, every one of them has a dedicated tool) +
355
- `autotask_write` + `autotask_delete`. The remaining **635 tools** (the 622 dedicated read tools + the 10 core read tools + `autotask_read` +
348
+ `autotask_write` + `autotask_delete`. The remaining **634 tools** (the 621 dedicated read tools + the 10 core read tools + `autotask_read` +
356
349
  `autotask_catalog` + `autotask_describe`) all carry `readOnlyHint: true`
357
350
  and are safe ungated: every op they can route is `effect=read` (zero
358
351
  mutating requests — pinned by the test inventory). Refined class for the
@@ -448,7 +441,8 @@ The SDK ships the mechanical substrate, not a server (no MCP imports, no zod):
448
441
  that the MCP servers wrap as untrusted host text; a maintenance notice is waited
449
442
  out for up to `maintenanceMaxWaitMs` (default 1 h; `MAINTENANCE_WINDOW_MAX_MS`
450
443
  = 4 h, the observed ceiling) for reads and writes; the same wait recognises the
451
- page at ANY status — `2xx`/`4xx`/`5xx`, issue #114 — but a `4xx`/`5xx` page is
444
+ page at ANY status — `2xx`/`4xx`/`5xx`, issue #114 — and the page opens the
445
+ zone's maintenance gate (see "Maintenance gate" above) — but a `4xx`/`5xx` page is
452
446
  waited out only for calls safe to re-send (a `GET` or an explicitly
453
447
  `idempotent`-flagged call): an unflagged mutation makes ONE send and says the
454
448
  write may have taken effect (`details.maintenanceDetected`); a non-matching
@@ -512,7 +506,7 @@ Semantics, pinned by `test/resources/collection-update-merge.test.ts` (mock fetc
512
506
 
513
507
  [`docs/N8N-ADAPTER.md`](./docs/N8N-ADAPTER.md) proves the thin-importer thesis: how
514
508
  `n8n-nodes-autotask` v2.29.4 keeps zero Autotask knowledge after the port — the
515
- generated 121-row operation mapping (node dir → node ops → SDK methods), the global-op
509
+ generated operation mapping (node dir → node ops → SDK methods), the global-op
516
510
  mapping (searchFilter/tool/aiHelper/apiThreshold), the swagger-gap table (87
517
511
  node-parity paths the vendored swagger lacks, all UNVERIFIED-live this run), and the
518
512
  5-line rewrite recipe.
@@ -531,7 +525,7 @@ node-parity paths the vendored swagger lacks, all UNVERIFIED-live this run), and
531
525
  | `npm run capabilities:check` | `scripts/check-capabilities.mjs` — the batch gate (missing/incomplete/stale records → exit 1) |
532
526
  | `npm run public-surface` | `scripts/public-surface.mjs` — capture (`--write`) / verify the public API surface baseline; default mode fails on unannounced removals, **and** checks the BUILT surface: every tsup entry has a matching `exports` key (and vice versa), every declared target was emitted and loads (ESM+CJS), and no runtime dependency leaks into `dist` |
533
527
  | `npm run live-smoke` | `scripts/live-smoke.mjs` — read-only live smoke: 5 vendor probes (5-6 wire calls worst case: 4 GET + 1 bounded query that may walk a 2nd, empty page) + a zero-network shape guard; `--dry` prints the plan with no calls (DRY-RUN-ONLY verdict, exit 0); live via `AUTOTASK_*` env — missing/partial credentials hard-fail exit 2 |
534
- | `npm run live-coverage` | `scripts/live-coverage.mjs` — the live coverage sweep over all 1281 registry ops (`--dry`: full call plan, no calls; live: bounded reads for real, mutations `dryRun: true` only — zero mutating requests, every governor-gated row (the 54 delete dry-runs included) routed through invoke with `confirm`; budget <= 1227 plan-honest / <= 1382 wire-honest worst case) |
528
+ | `npm run live-coverage` | `scripts/live-coverage.mjs` — the live coverage sweep over all registry ops (`--dry`: full call plan, no calls; live: bounded reads for real, mutations `dryRun: true` only — zero mutating requests, every governor-gated row (the 54 delete dry-runs included) routed through invoke with `confirm`; budget <= 1227 plan-honest / <= 1382 wire-honest worst case) |
535
529
  | `npm run mcp:project` | `scripts/project-mcp-tools.mjs` — mechanical MCP projection → `MCP_TOOL_MANIFEST.md` (`:check` verifies) |
536
530
  | `npm run n8n:project` / `n8n:project:check` | `scripts/project-n8n-mcp.mjs` — the n8n consumer projection from the SAME registry → `N8N_MCP_MANIFEST.json`/`.md` (`--check` rebuilds and diffs; the gate is wired into `verify`) |
537
531
  | `npm run catalog:build` / `catalog:check` | `scripts/build-tool-catalog.mjs` — the catalog meta-tool row data → `MCP_TOOL_CATALOG.json` + mechanical CORE profile (`--check` verifies drift) |
@@ -573,8 +567,7 @@ without credentials; a green exit is never a false pass.
573
567
 
574
568
  ## Testing
575
569
 
576
- Strict TDD against mocked HTTP (no live calls in CI): 2685 tests / 215 files on
577
- this build. Every registry record pins the plan + source + test file hashes
570
+ Strict TDD against mocked HTTP (no live calls in CI): see `npm test` for the current suite. Every registry record pins the plan + source + test file hashes
578
571
  (`staleCheck`), and `capabilities:check` re-derives them at the gate. Coverage
579
572
  thresholds: 90/90/80/90 (lines/functions/branches/statements). The public API
580
573
  surface baseline (`test/__fixtures__/public-surface.json`) proves "additive only":
@@ -602,8 +595,7 @@ suites are the release gate, the live scripts are the ground-truth check.
602
595
  env rename to the official Autotask terms, the swagger-required
603
596
  `zoneInformation` `user` param, and the always-sent query `filter` (node
604
597
  parity) — all live-verified against AU03/ww29.
605
- - **v0.1.0** — the node's 121-entity MVP set: 128 resources
606
- (121 entities + 7 integration endpoints), 1167 registry operations, the agent
598
+ - **v0.1.0** — the node's MVP entity set and integration endpoints, the agent
607
599
  execution layer (helper floor, bounded scans, mutation safety), the MCP substrate
608
600
  (registry → manifest → overrides → core tier + catalog), and the docs surface.
609
601
  - **Full 3003-operation spec** — the vendored swagger's complete op set (3003