node-autotask 0.19.0 → 0.20.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/CHANGELOG.md +16 -0
- package/MCP_TOOL_CATALOG.json +6 -6
- package/MCP_TOOL_MANIFEST.md +127 -127
- package/N8N_MCP_MANIFEST.json +44 -9
- package/N8N_MCP_MANIFEST.md +8 -8
- package/capabilities.json +1938 -1826
- package/capabilities.schema.json +6 -0
- package/dist/capabilities.cjs +2 -2
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-NDK7WYWA.js → chunk-2T77J2ZM.js} +1937 -1825
- package/dist/{chunk-JM52ZU7T.cjs → chunk-FLYTKJKV.cjs} +1937 -1825
- package/dist/{chunk-LB2X4X4B.js → chunk-GA6UCX3Z.js} +207 -51
- package/dist/{chunk-4YKV7ORF.js → chunk-JEJUFXHX.js} +2 -2
- package/dist/{chunk-QDYSHAU6.cjs → chunk-L6V66V22.cjs} +215 -59
- package/dist/{chunk-TIM75K3G.cjs → chunk-RMLGOCGA.cjs} +135 -135
- package/dist/{chunk-D5RAQ4DE.js → chunk-XSYJB4IW.js} +3 -3
- package/dist/{chunk-7RDR5DSI.cjs → chunk-YH5CPRDN.cjs} +394 -394
- package/dist/{index-aZ3tCh1h.d.cts → index-AN-NjLi9.d.cts} +100 -9
- package/dist/{index-DLugNSr7.d.ts → index-CvLLsOCP.d.ts} +100 -9
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/operations/index.cjs +184 -136
- package/dist/operations/index.d.cts +2 -2
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +79 -31
- package/dist/pool.cjs +8 -8
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +4 -4
- package/dist/resources/index.d.cts +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +3 -3
- package/docs/API.md +78 -22
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CAPABILITIES
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2T77J2ZM.js";
|
|
4
4
|
|
|
5
5
|
// src/auth.ts
|
|
6
6
|
var AUTH_HEADERS = {
|
|
@@ -2074,6 +2074,88 @@ function refusedFilterShape(filter) {
|
|
|
2074
2074
|
// src/http.ts
|
|
2075
2075
|
import { AsyncLocalStorage } from "async_hooks";
|
|
2076
2076
|
|
|
2077
|
+
// src/latest-count-cache.ts
|
|
2078
|
+
var LATEST_COUNT_CACHE_TTL_MS = 3e4;
|
|
2079
|
+
var LATEST_COUNT_CACHE_MAX_ENTRIES = 4096;
|
|
2080
|
+
var LatestCountCache = class {
|
|
2081
|
+
/** The TTL in ms. */
|
|
2082
|
+
ttlMs;
|
|
2083
|
+
/** The entry bound (applies to STORED entries). */
|
|
2084
|
+
maxEntries;
|
|
2085
|
+
store = /* @__PURE__ */ new Map();
|
|
2086
|
+
/** The invalidation epoch (the `ReadCache` pattern — issue #139): bumped
|
|
2087
|
+
* by `clear()`; capture it before a wire read and pass it to `set` so a
|
|
2088
|
+
* probe in flight across a write cannot re-store its stale answer. */
|
|
2089
|
+
epochCounter = 0;
|
|
2090
|
+
constructor(ttlMs, maxEntries = LATEST_COUNT_CACHE_MAX_ENTRIES) {
|
|
2091
|
+
if (!Number.isInteger(ttlMs) || ttlMs <= 0) {
|
|
2092
|
+
throw new AutotaskConfigError(`latestCountCache.ttlMs must be a positive integer (got ${String(ttlMs)})`);
|
|
2093
|
+
}
|
|
2094
|
+
if (!Number.isInteger(maxEntries) || maxEntries <= 0) {
|
|
2095
|
+
throw new AutotaskConfigError(`latestCountCache.maxEntries must be a positive integer (got ${String(maxEntries)})`);
|
|
2096
|
+
}
|
|
2097
|
+
this.ttlMs = ttlMs;
|
|
2098
|
+
this.maxEntries = maxEntries;
|
|
2099
|
+
}
|
|
2100
|
+
/** The composite key: (resource plan key, canonical filter serialisation)
|
|
2101
|
+
* — the `\u0000` separator is unencodable in a filter value, so no two
|
|
2102
|
+
* (resource, conditions) pairs collide. */
|
|
2103
|
+
static key(resourceKey, conditions) {
|
|
2104
|
+
return `${resourceKey}\0${JSON.stringify(conditions ?? [])}`;
|
|
2105
|
+
}
|
|
2106
|
+
/** The live entry's count, or `undefined` (absent OR expired — an expired
|
|
2107
|
+
* entry is purged lazily on this read). */
|
|
2108
|
+
get(key) {
|
|
2109
|
+
const entry = this.store.get(key);
|
|
2110
|
+
if (entry === void 0) return void 0;
|
|
2111
|
+
if (entry.expiresAt <= Date.now()) {
|
|
2112
|
+
this.store.delete(key);
|
|
2113
|
+
return void 0;
|
|
2114
|
+
}
|
|
2115
|
+
return entry.value;
|
|
2116
|
+
}
|
|
2117
|
+
/** The invalidation epoch: bumped by `clear()`; capture it before a wire
|
|
2118
|
+
* read and pass it to `set` so a probe in flight across a write cannot
|
|
2119
|
+
* re-store its stale answer (issue #139, the `ReadCache` pattern). */
|
|
2120
|
+
get epoch() {
|
|
2121
|
+
return this.epochCounter;
|
|
2122
|
+
}
|
|
2123
|
+
/** Store a SUCCESSFUL plain-number count under `key`, live for `ttlMs`.
|
|
2124
|
+
* `epoch` is the invalidation epoch the caller captured BEFORE its wire
|
|
2125
|
+
* read: a probe that straddled a `clear()` (a write) is dropped, never
|
|
2126
|
+
* re-stored with its pre-write body (issue #139). Past the cap: purge
|
|
2127
|
+
* expired entries first, then evict the oldest-inserted (Map iteration
|
|
2128
|
+
* order = insertion order). */
|
|
2129
|
+
set(key, value, epoch = this.epochCounter) {
|
|
2130
|
+
if (epoch !== this.epochCounter) return;
|
|
2131
|
+
if (!Number.isFinite(value)) return;
|
|
2132
|
+
const entry = { value, expiresAt: Date.now() + this.ttlMs };
|
|
2133
|
+
if (!this.store.has(key) && this.store.size >= this.maxEntries) {
|
|
2134
|
+
for (const [k, e] of this.store) {
|
|
2135
|
+
if (e.expiresAt <= Date.now()) this.store.delete(k);
|
|
2136
|
+
}
|
|
2137
|
+
if (this.store.size >= this.maxEntries) {
|
|
2138
|
+
const oldest = this.store.keys().next();
|
|
2139
|
+
if (!oldest.done) this.store.delete(oldest.value);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
this.store.set(key, entry);
|
|
2143
|
+
}
|
|
2144
|
+
/** Drop one entry (absent = no-op). Issue #157: the stale-LOW recovery
|
|
2145
|
+
* deletes the cached total before its one fresh wire re-probe, so the
|
|
2146
|
+
* re-probe cannot be served by the entry it is meant to replace. */
|
|
2147
|
+
delete(key) {
|
|
2148
|
+
this.store.delete(key);
|
|
2149
|
+
}
|
|
2150
|
+
/** Clear every entry (a real write through the owning client — the
|
|
2151
|
+
* write-then-read re-fetch rule) and bump the invalidation epoch: a
|
|
2152
|
+
* `set` captured before this `clear` is discarded (issue #139). */
|
|
2153
|
+
clear() {
|
|
2154
|
+
this.epochCounter += 1;
|
|
2155
|
+
this.store.clear();
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2077
2159
|
// src/relationships.ts
|
|
2078
2160
|
var RELATIONSHIP_ZONE = {
|
|
2079
2161
|
"zone": "ww29",
|
|
@@ -8306,7 +8388,7 @@ var RELATIONSHIP_MAP = {
|
|
|
8306
8388
|
],
|
|
8307
8389
|
"naturalKeys": {
|
|
8308
8390
|
"hasSearch": true,
|
|
8309
|
-
"searchCovers": "title only (contains); ticketNumber lookups use resolve / findByTicketNumber",
|
|
8391
|
+
"searchCovers": "title only (contains \u2014 the vendor's contains match is looser than a literal substring (case/token matching): a search can return MORE hits than a local title-substring check (measured 2026-10-19: 25 vs 24); a per-field contains filter in tickets.query is the precise tool); ticketNumber lookups use resolve / findByTicketNumber",
|
|
8310
8392
|
"findBy": [
|
|
8311
8393
|
"findByTicketNumber"
|
|
8312
8394
|
]
|
|
@@ -10253,8 +10335,8 @@ var EMPTY_REASON_STAMPS = {
|
|
|
10253
10335
|
var POINTER_NOTES = {
|
|
10254
10336
|
"ticket_history.query": `W1 (ww29 (australia-nz) live 2026-10-04; vendor contract change live-verified 2026-10-06): the vendor requires ticket_history.query to be supplied with exactly ONE ticketID-equals filter \u2014 an unfiltered call 500s by contract (10-06 text: "When querying the TicketHistory entity you are required to supply one and only one ticketID equals filter"). WITH the filter the query WORKS (live 2026-10-06: rows returned, hasMore true \u2014 a single {op:'eq', field:'ticketID', value:<id>} condition; the filter vocabulary is eq/noteq/gt/gte/lt/lte/beginsWith/endsWith/contains/exist/notExist/in/notIn/and/or). tickets.timeline / tickets.fullContext remain the convenient composites; raw history rows come from the filtered query.`,
|
|
10255
10337
|
"time_entries.create": `W-A3 (ww29 (australia-nz) live 2026-10-04; drift re-verified 2026-10-06): the vendor now refuses ALL time-entry writes for this API-only user with "API-only user cannot be selected for this field" (10-04 text: "The specified AssignedResourceID and AssignedRoleID combination is not currently defined"). UNSATISFIABLE for an API-only integration user: the resources table is blind (0 rows) and the only selectable resource is the user's own API-only record, which the vendor refuses. createForResource \u2014 stage-11 PROVEN (8 live creates, 10-04) \u2014 is walled by the SAME drift (confirm-100 receipt 2026-10-06). Tenant evidence that valid pairs exist: postedWithin rows (resourceID 31131373 / 29869529 with roleID 29682834) \u2014 human resources the API user cannot select.`,
|
|
10256
|
-
"time_entries.getPosted":
|
|
10257
|
-
"time_entries.getUnposted":
|
|
10338
|
+
"time_entries.getPosted": "W-D3 (ww29 (australia-nz) live 2026-10-04, re-verified live 2026-10-15): this zone's TimeEntry entity exposes NO posted-state filter field \u2014 the vendor rejects postingStatus, postedDate and status with \"Unable to find X in the TimeEntry Entity\" (live field-existence oracle 2026-10-04: only dateWorked / resourceID / ticketID / taskID resolve as filter fields). Re-probed 2026-10-15 (ww29 re-probe campaign): time_entries.getPosted live 500, vendor body verbatim 'Unable to find postedDate in the TimeEntry Entity.' \u2014 a vendor endpoint defect on AU03, not a transient fault: posted cannot be filtered server-side on this zone \u2014 use time_entries.postedWithin (the dateWorked window, live-verified working \u2014 omit the `posted` narrowing on this zone: it sends postedDate, which the zone 500s) or read time_entries.query and derive posted-state from the fields your zone's entity exposes",
|
|
10339
|
+
"time_entries.getUnposted": "W-D3 (ww29 (australia-nz) live 2026-10-04, re-verified live 2026-10-15): this zone's TimeEntry entity exposes NO posted-state filter field \u2014 the vendor rejects postingStatus, postedDate and status with \"Unable to find X in the TimeEntry Entity\" (live field-existence oracle 2026-10-04: only dateWorked / resourceID / ticketID / taskID resolve as filter fields). Re-probed 2026-10-15 (ww29 re-probe campaign): time_entries.getUnposted live 500, vendor body verbatim 'Unable to find postedDate in the TimeEntry Entity.' \u2014 a vendor endpoint defect on AU03, not a transient fault: unposted cannot be filtered server-side on this zone \u2014 use time_entries.postedWithin (the dateWorked window, live-verified working \u2014 omit the `posted` narrowing on this zone: it sends postedDate, which the zone 500s) or read time_entries.query and derive posted-state from the fields your zone's entity exposes",
|
|
10258
10340
|
"authenticate.get": "W2: authenticate.get is DESIGNATOR-ONLY \u2014 it returns the designator identity, not a tenant data surface; a miss/empty here is not a data-empty signal (no emptyReason is attached by design \u2014 a false reason would be worse than none)"
|
|
10259
10341
|
};
|
|
10260
10342
|
var BLIND_SURFACE_INVENTORY = {
|
|
@@ -14888,6 +14970,11 @@ var HttpClient = class {
|
|
|
14888
14970
|
fieldCache;
|
|
14889
14971
|
/** Resource-name cache for `operations.expandResourceNames` (issue #80: the default instance when `resourceNameCache` is absent; undefined only when the user set `false` explicitly, issue #65). */
|
|
14890
14972
|
resourceNameCache;
|
|
14973
|
+
/** The `latest` walk's count-probe cache (issue #127: the short-TTL
|
|
14974
|
+
* per-client count cache — ALWAYS on, process-internal: no config
|
|
14975
|
+
* surface, no served keys; the plain `count` op and `operations.aggregate`
|
|
14976
|
+
* bypass it by construction and promise fresh totals). */
|
|
14977
|
+
latestCountCache;
|
|
14891
14978
|
/** Resolved update fallback gate (issue #34; OFF by default). */
|
|
14892
14979
|
update;
|
|
14893
14980
|
auth;
|
|
@@ -14953,6 +15040,7 @@ var HttpClient = class {
|
|
|
14953
15040
|
this.readCache = config.readCache;
|
|
14954
15041
|
this.fieldCache = config.fieldCache;
|
|
14955
15042
|
this.resourceNameCache = config.resourceNameCache;
|
|
15043
|
+
this.latestCountCache = new LatestCountCache(LATEST_COUNT_CACHE_TTL_MS);
|
|
14956
15044
|
this.update = config.update;
|
|
14957
15045
|
this.zone = config.zone;
|
|
14958
15046
|
this.reResolveZoneOn401 = config.reResolveZoneOn401;
|
|
@@ -15686,6 +15774,7 @@ var HttpClient = class {
|
|
|
15686
15774
|
clearTimeout(deadlineTimer);
|
|
15687
15775
|
if (!(method === "GET" || opts.idempotent === true)) {
|
|
15688
15776
|
this.readCache?.clear();
|
|
15777
|
+
this.latestCountCache.clear();
|
|
15689
15778
|
const nameOp = typeof opts.operation === "string" ? opts.operation : void 0;
|
|
15690
15779
|
const nameDot = nameOp !== void 0 ? nameOp.indexOf(".") : -1;
|
|
15691
15780
|
if (this.resourceNameCache !== void 0 && nameOp !== void 0 && nameDot > 0 && nameOp.slice(0, nameDot) === "resources") {
|
|
@@ -17345,17 +17434,56 @@ var BaseResource = class {
|
|
|
17345
17434
|
const bigB = typeof b === "number" ? BigInt(String(b)) : BigInt(b);
|
|
17346
17435
|
return bigA < bigB ? -1 : bigA > bigB ? 1 : 0;
|
|
17347
17436
|
}
|
|
17437
|
+
/** Issue #127: the `latest` walk's count probes through the per-client
|
|
17438
|
+
* short-TTL count cache (`LatestCountCache` — fixed 30 s TTL, the
|
|
17439
|
+
* memory guard; cleared on every real write through this client, the
|
|
17440
|
+
* write-then-read re-fetch rule). Only a SUCCESSFUL plain-number vendor
|
|
17441
|
+
* count answer is stored: the blind-surface / pinned-empty sentinels are
|
|
17442
|
+
* RECORDS and pass through un-stored (the plan-pinned stamps stay fresh
|
|
17443
|
+
* and re-derive on every call), and an error rejects before any store.
|
|
17444
|
+
* The key is (resource plan key, canonical filter serialisation — the
|
|
17445
|
+
* normalised conditions' JSON): the initial `count(F)` probe and every
|
|
17446
|
+
* `id gt T` threshold probe are separate entries, and a re-asked
|
|
17447
|
+
* "top N" within the TTL makes ZERO extra count calls (its probes all
|
|
17448
|
+
* hit — the bracket/search sequence is deterministic given the counts).
|
|
17449
|
+
* Issue #157: two corrections to the snapshot trade. (1) A total of 0 is
|
|
17450
|
+
* NEVER stored — a 0 is rare and cheap to re-probe, and a cached 0 fed
|
|
17451
|
+
* the false-empty branch (a repeat after an out-of-band insert returned
|
|
17452
|
+
* no rows without walking). (2) `fresh: true` DELETES the entry before
|
|
17453
|
+
* the wire read and re-stores the fresh answer — the ONE re-probe the
|
|
17454
|
+
* stale-LOW recovery in `latestWalk` is allowed. Counts are snapshots,
|
|
17455
|
+
* not contracts: the truncation guard covers the growth-of-total
|
|
17456
|
+
* direction; a stale-LOW total within the TTL is resolved by that one
|
|
17457
|
+
* fresh re-probe (never by the guard alone). The plain `count` op and
|
|
17458
|
+
* `operations.aggregate` call `countGlobal` directly and promise fresh
|
|
17459
|
+
* totals — this wrapper is used ONLY on the latest-walk probe path.
|
|
17460
|
+
*/
|
|
17461
|
+
async latestProbeCount(filter, opts = {}) {
|
|
17462
|
+
const cache = this.http.latestCountCache;
|
|
17463
|
+
const key = LatestCountCache.key(this.config.key, normalizedConditions(filter));
|
|
17464
|
+
if (opts.fresh === true) {
|
|
17465
|
+
cache.delete(key);
|
|
17466
|
+
} else {
|
|
17467
|
+
const hit = cache.get(key);
|
|
17468
|
+
if (hit !== void 0) return { value: hit, cached: true };
|
|
17469
|
+
}
|
|
17470
|
+
const epoch = cache.epoch;
|
|
17471
|
+
const res = await this.countGlobal({ filter });
|
|
17472
|
+
const value = res;
|
|
17473
|
+
if (typeof value === "number" && value !== 0) cache.set(key, value, epoch);
|
|
17474
|
+
return { value, cached: false };
|
|
17475
|
+
}
|
|
17348
17476
|
/** Issue #59: one `latest` threshold count probe — a ROWLESS
|
|
17349
17477
|
* `count(F ∧ id gt T)` call (the vendor caps — ≤500 OR-conditions,
|
|
17350
17478
|
* 8000 chars serialised — leave a single `gt` condition room on any
|
|
17351
|
-
* filter). The `BlindCountResult` sentinel (a record, not a number —
|
|
17479
|
+
* filter). Issue #127: it rides the per-client short-TTL count cache — the same (resource, conditions) probe within the 30 s window is reused (zero vendor calls); a sentinel answer is never cached. The `BlindCountResult` sentinel (a record, not a number —
|
|
17352
17480
|
* the declared `number` return is the documented under-type) unwraps to
|
|
17353
17481
|
* its `count` value (always 0): at or above the max matching id the
|
|
17354
17482
|
* count is 0, which is exactly the bracket-termination signal. */
|
|
17355
17483
|
async countAboveId(baseConds, t) {
|
|
17356
17484
|
const value = t <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(t) : t.toString();
|
|
17357
|
-
const
|
|
17358
|
-
return typeof
|
|
17485
|
+
const probed = await this.latestProbeCount([...baseConds, { op: "gt", field: "id", value }]);
|
|
17486
|
+
return typeof probed.value === "object" && probed.value !== null && "count" in probed.value ? probed.value.count : probed.value;
|
|
17359
17487
|
}
|
|
17360
17488
|
/**
|
|
17361
17489
|
* Issue #59: the `latest: N` mechanism — the N highest-`id` rows,
|
|
@@ -17373,8 +17501,11 @@ var BaseResource = class {
|
|
|
17373
17501
|
* 1 + ceil(C/500) <= 6, independent of table size. A truncated walk
|
|
17374
17502
|
* (the vendor's rows disagree with its own count) is
|
|
17375
17503
|
* LATEST_WINDOW_INCOMPLETE — the top-N of a truncated set is
|
|
17376
|
-
* unprovable
|
|
17377
|
-
*
|
|
17504
|
+
* unprovable — EXCEPT issue #157: when `C` came from the CACHE, the
|
|
17505
|
+
* total is re-probed ONCE fresh (the stale-LOW recovery: a larger
|
|
17506
|
+
* fresh total continues the walk against it; the refusal stands only
|
|
17507
|
+
* when the fresh probe confirms the cached value). Sort
|
|
17508
|
+
* id-descending; return the top N (a set of C < N returns itself).
|
|
17378
17509
|
* - `C > 2500` → THRESHOLD mode: find the smallest id threshold `T`
|
|
17379
17510
|
* with `count(F ∧ id gt T) <= N` by exponential bracketing
|
|
17380
17511
|
* (T = 1, 2, 4, …) + binary search — each probe ONE rowless count
|
|
@@ -17401,13 +17532,25 @@ var BaseResource = class {
|
|
|
17401
17532
|
* answer.
|
|
17402
17533
|
* `includeFields` always carries `id` (the P1 id-append,
|
|
17403
17534
|
* `buildQueryRequest`), which `latest` sorts on. Pure read; no mutation
|
|
17404
|
-
* paths involved.
|
|
17535
|
+
* paths involved. Issue #127: every count probe of this walk (the
|
|
17536
|
+
* initial `count(F)` + the `id gt T` threshold probes) rides the
|
|
17537
|
+
* per-client short-TTL count cache (30 s; a real write through this
|
|
17538
|
+
* client clears it) — a re-asked "top N" within the window reuses the
|
|
17539
|
+
* probes (zero extra vendor count calls); sentinel answers are never
|
|
17540
|
+
* cached (the plan-pinned stamps stay fresh), and a 0 total is never
|
|
17541
|
+
* cached either (issue #157: a 0 is cheap to re-probe and a cached 0
|
|
17542
|
+
* would shadow an out-of-band insert). The stale-LOW direction is closed
|
|
17543
|
+
* by the ONE fresh re-probe above; the stale-HIGH direction is safe by
|
|
17544
|
+
* construction (threshold mode re-probes fresh `id gt T` counts and
|
|
17545
|
+
* full-set mode ends when the cursor exhausts). The plain `count` op and
|
|
17546
|
+
* `operations.aggregate` bypass the cache by construction and promise
|
|
17547
|
+
* fresh totals.
|
|
17405
17548
|
*/
|
|
17406
17549
|
async latestWalk(params, limit, latest) {
|
|
17407
17550
|
const baseConds = normalizedConditions(params.filter) ?? [];
|
|
17408
|
-
const probe = await this.
|
|
17409
|
-
if (typeof probe === "object" && probe !== null) {
|
|
17410
|
-
const rec = probe;
|
|
17551
|
+
const probe = await this.latestProbeCount(params.filter);
|
|
17552
|
+
if (typeof probe.value === "object" && probe.value !== null) {
|
|
17553
|
+
const rec = probe.value;
|
|
17411
17554
|
if (rec.blindSurface !== void 0) {
|
|
17412
17555
|
return this.latestBlindWalk(params, limit, latest);
|
|
17413
17556
|
}
|
|
@@ -17415,47 +17558,60 @@ var BaseResource = class {
|
|
|
17415
17558
|
this.stampEmptyQueryResult(result, params);
|
|
17416
17559
|
return result;
|
|
17417
17560
|
}
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
|
|
17426
|
-
if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 })) {
|
|
17427
|
-
throw this.latestWindowIncompleteError(total);
|
|
17561
|
+
let total = probe.value;
|
|
17562
|
+
let cacheSourced = probe.cached;
|
|
17563
|
+
let reProbed = false;
|
|
17564
|
+
for (; ; ) {
|
|
17565
|
+
if (total === 0) {
|
|
17566
|
+
const result = { items: [], fetched: 0, hasMore: false, pagesWalked: 0 };
|
|
17567
|
+
this.stampEmptyQueryResult(result, params);
|
|
17568
|
+
return result;
|
|
17428
17569
|
}
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
-
|
|
17432
|
-
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17436
|
-
|
|
17437
|
-
|
|
17438
|
-
|
|
17439
|
-
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
|
|
17570
|
+
if (total <= BOUNDED_QUERY_MAX_LIMIT) {
|
|
17571
|
+
const { items: items2, pages: pages2, guard: guard2, sliced: sliced2, cursor: cursor2 } = await this.walkBounded(params, total);
|
|
17572
|
+
if (this.walkTruncated(total, { itemsLength: items2.length, guard: guard2, sliced: sliced2, cursor: cursor2 })) {
|
|
17573
|
+
if (cacheSourced && !reProbed) {
|
|
17574
|
+
reProbed = true;
|
|
17575
|
+
const fresh = await this.latestProbeCount(params.filter, { fresh: true });
|
|
17576
|
+
if (typeof fresh.value === "number" && fresh.value > total) {
|
|
17577
|
+
total = fresh.value;
|
|
17578
|
+
cacheSourced = false;
|
|
17579
|
+
continue;
|
|
17580
|
+
}
|
|
17581
|
+
}
|
|
17582
|
+
throw this.latestWindowIncompleteError(total);
|
|
17583
|
+
}
|
|
17584
|
+
return this.finishLatest(items2, latest, pages2);
|
|
17443
17585
|
}
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
|
|
17586
|
+
let probes = reProbed ? 2 : 1;
|
|
17587
|
+
const spend = () => {
|
|
17588
|
+
probes += 1;
|
|
17589
|
+
if (probes > LATEST_MAX_COUNT_PROBES) throw this.latestThresholdUnresolvedError();
|
|
17590
|
+
};
|
|
17591
|
+
let lo = 0n;
|
|
17592
|
+
let hi = 0n;
|
|
17593
|
+
for (let t = 1n; ; t = t << 1n) {
|
|
17594
|
+
spend();
|
|
17595
|
+
if (await this.countAboveId(baseConds, t) <= latest) {
|
|
17596
|
+
hi = t;
|
|
17597
|
+
break;
|
|
17598
|
+
}
|
|
17599
|
+
lo = t;
|
|
17600
|
+
}
|
|
17601
|
+
while (hi - lo > 1n) {
|
|
17602
|
+
const mid = lo + hi >> 1n;
|
|
17603
|
+
spend();
|
|
17604
|
+
if (await this.countAboveId(baseConds, mid) <= latest) hi = mid;
|
|
17605
|
+
else lo = mid;
|
|
17606
|
+
}
|
|
17607
|
+
const windowValue = hi <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(hi) : hi.toString();
|
|
17608
|
+
const window = [...baseConds, { op: "gte", field: "id", value: windowValue }];
|
|
17609
|
+
const { items, pages, guard, sliced, cursor } = await this.walkBounded({ ...params, filter: window }, latest + 1);
|
|
17610
|
+
if (this.walkTruncated(latest + 1, { itemsLength: items.length, guard, sliced, cursor })) {
|
|
17611
|
+
throw this.latestWindowIncompleteError(latest + 1);
|
|
17612
|
+
}
|
|
17613
|
+
return this.finishLatest(items, latest, pages);
|
|
17457
17614
|
}
|
|
17458
|
-
return this.finishLatest(items, latest, pages);
|
|
17459
17615
|
}
|
|
17460
17616
|
/** The shared `latest` completion: the (provably complete or
|
|
17461
17617
|
* stamp-scoped) set sorted id-descending, top N taken. `hasMore: false`
|
|
@@ -127,13 +127,13 @@ import {
|
|
|
127
127
|
VersionInformationResource,
|
|
128
128
|
VersionResource,
|
|
129
129
|
ZoneInformationResource
|
|
130
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-XSYJB4IW.js";
|
|
131
131
|
import {
|
|
132
132
|
AutotaskConfigError,
|
|
133
133
|
HttpClient,
|
|
134
134
|
resolveConfig,
|
|
135
135
|
runWithSignal
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-GA6UCX3Z.js";
|
|
137
137
|
|
|
138
138
|
// src/client.ts
|
|
139
139
|
var AutotaskClient = class {
|