node-autotask 0.69.0 → 0.70.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 +25 -0
- package/MCP_TOOL_CATALOG.json +1 -1
- package/README.md +6 -0
- package/capabilities.json +4 -4
- package/dist/capabilities-data.js +3 -3
- package/dist/{chunk-QDBJCGQD.js → chunk-3RANR2RY.js} +965 -376
- package/dist/{chunk-24GRFW55.cjs → chunk-GVP2WW47.cjs} +175 -175
- package/dist/{chunk-AH6WAGPS.js → chunk-MN5VLBCI.js} +1 -1
- package/dist/{chunk-2BB7OASJ.js → chunk-TYUTIZWB.js} +2 -2
- package/dist/{chunk-DPRY3CUJ.cjs → chunk-YQX45JBG.cjs} +30 -30
- package/dist/{chunk-JLBSUZ5B.cjs → chunk-YRRTE2NF.cjs} +965 -375
- package/dist/{index-CxBU31jT.d.ts → index-By9Zw2Oc.d.ts} +11 -5
- package/dist/{index-WZ3A8nG6.d.cts → index-CGW80Uzc.d.cts} +11 -5
- package/dist/index.cjs +83 -83
- 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 +53 -49
- package/dist/operations/index.d.cts +22 -4
- package/dist/operations/index.d.ts +22 -4
- package/dist/operations/index.js +1 -1
- package/dist/pool.cjs +11 -11
- package/dist/pool.js +3 -3
- package/dist/resources/index.cjs +26 -26
- package/dist/resources/index.d.cts +1 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +2 -2
- package/docs/API.md +53 -0
- package/docs/N8N-ADAPTER.md +1 -1
- package/docs/performance-caching.md +92 -0
- package/docs/performance-reads.md +71 -0
- package/package.json +1 -1
|
@@ -618,6 +618,27 @@ function isKnownZone(zone) {
|
|
|
618
618
|
return typeof zone === "string" && ZONES.includes(zone);
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
+
// src/metadata-projection.ts
|
|
622
|
+
var METADATA_PROJECTION = /* @__PURE__ */ Symbol.for("node-autotask.metadata-projection.v1");
|
|
623
|
+
function projectMetadata(value, projector) {
|
|
624
|
+
return structuredClone(projector(value));
|
|
625
|
+
}
|
|
626
|
+
async function readMetadataProjection(holder, kind, projector, fallbackReader) {
|
|
627
|
+
const hook = holder !== null && (typeof holder === "object" || typeof holder === "function") ? holder[METADATA_PROJECTION] : void 0;
|
|
628
|
+
const owned = hook?.call(holder, kind, projector);
|
|
629
|
+
owned?.guard();
|
|
630
|
+
if (owned?.projected !== void 0) {
|
|
631
|
+
const value2 = await owned.projected;
|
|
632
|
+
owned.guard();
|
|
633
|
+
return value2;
|
|
634
|
+
}
|
|
635
|
+
const raw = await fallbackReader();
|
|
636
|
+
owned?.guard();
|
|
637
|
+
const value = projector(raw);
|
|
638
|
+
owned?.guard();
|
|
639
|
+
return value;
|
|
640
|
+
}
|
|
641
|
+
|
|
621
642
|
// src/cache.ts
|
|
622
643
|
var READ_CACHE_MAX_ENTRIES = 4096;
|
|
623
644
|
var REFERENCE_TTL_MS = 36e5;
|
|
@@ -630,6 +651,7 @@ function readTtlFor(key, ttlMs) {
|
|
|
630
651
|
const entity = key.split("\0")[0].split("/").at(-2);
|
|
631
652
|
return entity !== void 0 && REFERENCE_ENTITIES.includes(entity) ? Math.max(ttlMs, REFERENCE_TTL_MS) : ttlMs;
|
|
632
653
|
}
|
|
654
|
+
var MAX_ENTRY_PROJECTIONS = 8;
|
|
633
655
|
var TtlCache = class {
|
|
634
656
|
ttlMs;
|
|
635
657
|
maxEntries;
|
|
@@ -650,15 +672,38 @@ var TtlCache = class {
|
|
|
650
672
|
this.maxEntries = maxEntries;
|
|
651
673
|
this.ttlFor = options.ttlFor ?? (() => ttlMs);
|
|
652
674
|
}
|
|
653
|
-
|
|
654
|
-
get(key) {
|
|
675
|
+
liveEntry(key) {
|
|
655
676
|
const entry = this.store.get(key);
|
|
656
677
|
if (entry === void 0) return void 0;
|
|
657
678
|
if (entry.expiresAt <= Date.now()) {
|
|
658
679
|
this.store.delete(key);
|
|
659
680
|
return void 0;
|
|
660
681
|
}
|
|
661
|
-
return
|
|
682
|
+
return entry;
|
|
683
|
+
}
|
|
684
|
+
/** The live value (a copy), or `undefined` when absent or expired. */
|
|
685
|
+
get(key) {
|
|
686
|
+
const entry = this.liveEntry(key);
|
|
687
|
+
return entry === void 0 ? void 0 : structuredClone(entry.value);
|
|
688
|
+
}
|
|
689
|
+
projectEntry(key, entry, projector) {
|
|
690
|
+
if (entry.projections?.has(projector)) return structuredClone(entry.projections.get(projector));
|
|
691
|
+
const value = projectMetadata(structuredClone(entry.value), projector);
|
|
692
|
+
if (this.store.get(key) === entry && entry.expiresAt > Date.now()) {
|
|
693
|
+
const projections = entry.projections ??= /* @__PURE__ */ new Map();
|
|
694
|
+
if (projections.size >= MAX_ENTRY_PROJECTIONS) {
|
|
695
|
+
const oldest = projections.keys().next();
|
|
696
|
+
if (!oldest.done) projections.delete(oldest.value);
|
|
697
|
+
}
|
|
698
|
+
projections.set(projector, value);
|
|
699
|
+
return structuredClone(value);
|
|
700
|
+
}
|
|
701
|
+
return value;
|
|
702
|
+
}
|
|
703
|
+
/** Clone a live derived value without cloning the full metadata on each hit. @internal */
|
|
704
|
+
getProjected(key, projector) {
|
|
705
|
+
const entry = this.liveEntry(key);
|
|
706
|
+
return entry === void 0 ? void 0 : this.projectEntry(key, entry, projector);
|
|
662
707
|
}
|
|
663
708
|
/**
|
|
664
709
|
* Load one record once for concurrent callers. Each subscriber owns its
|
|
@@ -666,14 +711,26 @@ var TtlCache = class {
|
|
|
666
711
|
* its last subscriber leaves. A fresh load starts a new flight and prevents
|
|
667
712
|
* an older flight from replacing its result; invalidation detaches flights
|
|
668
713
|
* without changing the answer owed to their existing subscribers.
|
|
714
|
+
* `shouldStore` controls retention, never the result returned to subscribers.
|
|
669
715
|
* @internal
|
|
670
716
|
*/
|
|
671
|
-
|
|
717
|
+
load(key, loader, opts) {
|
|
718
|
+
return this.loadValue(key, loader, opts);
|
|
719
|
+
}
|
|
720
|
+
/** Projected and raw subscribers share the same raw flight and retention policy. @internal */
|
|
721
|
+
loadProjected(key, loader, projector, opts) {
|
|
722
|
+
return this.loadValue(key, loader, opts, projector);
|
|
723
|
+
}
|
|
724
|
+
async loadValue(key, loader, opts, projector) {
|
|
672
725
|
const { signal } = opts;
|
|
673
726
|
if (signal?.aborted) throw opts.abortError();
|
|
674
727
|
if (!opts.fresh) {
|
|
675
|
-
const
|
|
676
|
-
if (
|
|
728
|
+
const entry = this.liveEntry(key);
|
|
729
|
+
if (entry !== void 0 && entry.value !== void 0) {
|
|
730
|
+
const hit = projector === void 0 ? structuredClone(entry.value) : this.projectEntry(key, entry, projector);
|
|
731
|
+
if (signal?.aborted) throw opts.abortError();
|
|
732
|
+
return hit;
|
|
733
|
+
}
|
|
677
734
|
}
|
|
678
735
|
let flight = opts.fresh ? void 0 : this.loads.get(key);
|
|
679
736
|
let start;
|
|
@@ -691,7 +748,10 @@ var TtlCache = class {
|
|
|
691
748
|
}
|
|
692
749
|
};
|
|
693
750
|
}).then((value) => {
|
|
694
|
-
if (this.loads.get(key) === created && !controller.signal.aborted)
|
|
751
|
+
if (this.loads.get(key) === created && !controller.signal.aborted) {
|
|
752
|
+
const retain = opts.shouldStore?.(value) ?? true;
|
|
753
|
+
if (retain && this.loads.get(key) === created && !controller.signal.aborted) created.entry = this.storeValue(key, value, epoch);
|
|
754
|
+
}
|
|
695
755
|
return value;
|
|
696
756
|
});
|
|
697
757
|
const settled = () => {
|
|
@@ -725,7 +785,11 @@ var TtlCache = class {
|
|
|
725
785
|
(value) => {
|
|
726
786
|
if (leave()) {
|
|
727
787
|
try {
|
|
728
|
-
|
|
788
|
+
if (signal?.aborted) throw opts.abortError();
|
|
789
|
+
const entry = shared.entry;
|
|
790
|
+
const selected = projector === void 0 ? structuredClone(value) : entry !== void 0 && this.liveEntry(key) === entry ? this.projectEntry(key, entry, projector) : projectMetadata(structuredClone(value), projector);
|
|
791
|
+
if (signal?.aborted) throw opts.abortError();
|
|
792
|
+
resolve(selected);
|
|
729
793
|
} catch (error) {
|
|
730
794
|
reject(error);
|
|
731
795
|
}
|
|
@@ -742,14 +806,19 @@ var TtlCache = class {
|
|
|
742
806
|
/** Store `value` under `key`. `epoch` is the value the caller read BEFORE its
|
|
743
807
|
* wire request: a read that straddled a `clear()` (a write) is dropped. */
|
|
744
808
|
set(key, value, epoch = this.epochCounter) {
|
|
745
|
-
|
|
809
|
+
this.storeValue(key, value, epoch);
|
|
810
|
+
}
|
|
811
|
+
storeValue(key, value, epoch) {
|
|
812
|
+
if (epoch !== this.epochCounter) return void 0;
|
|
746
813
|
if (!this.store.has(key) && this.store.size >= this.maxEntries && this.purgeExpired() === 0) {
|
|
747
814
|
const oldest = this.store.keys().next();
|
|
748
815
|
if (!oldest.done) this.store.delete(oldest.value);
|
|
749
816
|
}
|
|
750
817
|
const now = Date.now();
|
|
751
818
|
this.store.delete(key);
|
|
752
|
-
|
|
819
|
+
const entry = { value: structuredClone(value), storedAt: now, expiresAt: now + this.ttlFor(key) };
|
|
820
|
+
this.store.set(key, entry);
|
|
821
|
+
return entry;
|
|
753
822
|
}
|
|
754
823
|
/** `{ hit, age }` without consuming or cloning the entry (age in ms since stored). */
|
|
755
824
|
peek(key) {
|
|
@@ -1531,8 +1600,8 @@ function buildFilter(conditions) {
|
|
|
1531
1600
|
if (list.length === 0) {
|
|
1532
1601
|
throw new AutotaskConfigError("buildFilter requires at least one condition");
|
|
1533
1602
|
}
|
|
1534
|
-
const
|
|
1535
|
-
const filter = { filter: [
|
|
1603
|
+
const root3 = list.length === 1 ? list[0] : { op: "and", items: list };
|
|
1604
|
+
const filter = { filter: [root3] };
|
|
1536
1605
|
validateFilter(filter);
|
|
1537
1606
|
return filter;
|
|
1538
1607
|
}
|
|
@@ -1733,6 +1802,12 @@ function isAbortLike(err) {
|
|
|
1733
1802
|
return typeof err === "object" && err !== null && "name" in err && err.name === "AbortError";
|
|
1734
1803
|
}
|
|
1735
1804
|
|
|
1805
|
+
// src/read-scope.ts
|
|
1806
|
+
var CAPTURE_READ_GUARD = /* @__PURE__ */ Symbol.for("node-autotask.capture-read-guard.v1");
|
|
1807
|
+
function captureReadGuard(http, operation) {
|
|
1808
|
+
return http[CAPTURE_READ_GUARD](operation);
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1736
1811
|
// src/auth.ts
|
|
1737
1812
|
var AUTH_HEADERS = {
|
|
1738
1813
|
integrationCode: "ApiIntegrationCode",
|
|
@@ -1852,6 +1927,10 @@ var Semaphore = class {
|
|
|
1852
1927
|
maxConcurrent;
|
|
1853
1928
|
inFlight = 0;
|
|
1854
1929
|
waitQueue = /* @__PURE__ */ new Set();
|
|
1930
|
+
/** Synchronous eligibility check; acquisition must follow without an await. @internal */
|
|
1931
|
+
canAcquire() {
|
|
1932
|
+
return this.inFlight < this.maxConcurrent && this.waitQueue.size === 0;
|
|
1933
|
+
}
|
|
1855
1934
|
acquire(signal) {
|
|
1856
1935
|
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
1857
1936
|
if (this.inFlight < this.maxConcurrent) {
|
|
@@ -14271,13 +14350,43 @@ function canonicalObjectKey(url) {
|
|
|
14271
14350
|
|
|
14272
14351
|
// src/http/object-threads.ts
|
|
14273
14352
|
var REGISTRY2 = /* @__PURE__ */ Symbol.for("node-autotask.object-thread-gates.v1");
|
|
14353
|
+
var NOTIFY = /* @__PURE__ */ Symbol.for("node-autotask.object-thread-notify.v1");
|
|
14274
14354
|
var OBJECT_THREAD_LIMIT = 3;
|
|
14275
14355
|
var state = globalThis;
|
|
14276
|
-
|
|
14277
|
-
|
|
14356
|
+
function unsupported() {
|
|
14357
|
+
return new AutotaskConfigError("Unsupported shared object-thread semaphore; refusing admission");
|
|
14358
|
+
}
|
|
14359
|
+
function available(semaphore) {
|
|
14360
|
+
const legacy = semaphore;
|
|
14361
|
+
if (!Number.isInteger(legacy.inFlight) || legacy.inFlight < 0 || legacy.inFlight > OBJECT_THREAD_LIMIT || legacy.maxConcurrent !== OBJECT_THREAD_LIMIT || !(legacy.waitQueue instanceof Set)) {
|
|
14362
|
+
throw unsupported();
|
|
14363
|
+
}
|
|
14364
|
+
return legacy.inFlight < OBJECT_THREAD_LIMIT && legacy.waitQueue.size === 0 && (typeof semaphore.canAcquire !== "function" || semaphore.canAcquire());
|
|
14365
|
+
}
|
|
14366
|
+
function observe(semaphore, notify) {
|
|
14367
|
+
let notifications = semaphore[NOTIFY];
|
|
14368
|
+
if (notifications === void 0) {
|
|
14369
|
+
notifications = { listeners: /* @__PURE__ */ new Map() };
|
|
14370
|
+
semaphore[NOTIFY] = notifications;
|
|
14371
|
+
const original = semaphore.release;
|
|
14372
|
+
const shared = notifications;
|
|
14373
|
+
semaphore.release = function() {
|
|
14374
|
+
original.call(this);
|
|
14375
|
+
for (const listener of shared.listeners.keys()) listener();
|
|
14376
|
+
};
|
|
14377
|
+
}
|
|
14378
|
+
const listeners = notifications.listeners;
|
|
14379
|
+
listeners.set(notify, (listeners.get(notify) ?? 0) + 1);
|
|
14380
|
+
return () => {
|
|
14381
|
+
const count = listeners.get(notify) ?? 0;
|
|
14382
|
+
if (count <= 1) listeners.delete(notify);
|
|
14383
|
+
else listeners.set(notify, count - 1);
|
|
14384
|
+
};
|
|
14385
|
+
}
|
|
14386
|
+
function retainObjectThread(url, trackingIdentifier) {
|
|
14278
14387
|
const target = new URL(url);
|
|
14279
14388
|
const object = canonicalObjectKey(target.pathname);
|
|
14280
|
-
if (object === void 0) return
|
|
14389
|
+
if (object === void 0) return void 0;
|
|
14281
14390
|
const key = crypto.createHash("sha256").update(JSON.stringify([target.origin, trackingIdentifier.trim().toLowerCase(), object])).digest("hex");
|
|
14282
14391
|
const registry2 = state[REGISTRY2] ??= /* @__PURE__ */ new Map();
|
|
14283
14392
|
let entry = registry2.get(key);
|
|
@@ -14286,25 +14395,261 @@ async function acquireObjectThread(url, trackingIdentifier, signal) {
|
|
|
14286
14395
|
registry2.set(key, entry);
|
|
14287
14396
|
}
|
|
14288
14397
|
const active = entry;
|
|
14398
|
+
if (!Number.isInteger(active.users) || active.users < 0 || typeof active.semaphore?.acquire !== "function" || typeof active.semaphore.release !== "function") {
|
|
14399
|
+
throw unsupported();
|
|
14400
|
+
}
|
|
14401
|
+
available(active.semaphore);
|
|
14289
14402
|
active.users += 1;
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14403
|
+
let left = false;
|
|
14404
|
+
return {
|
|
14405
|
+
identity: active,
|
|
14406
|
+
listen: (notify) => observe(active.semaphore, notify),
|
|
14407
|
+
available: () => available(active.semaphore),
|
|
14408
|
+
acquire: (signal) => active.semaphore.acquire(signal),
|
|
14409
|
+
release: () => active.semaphore.release(),
|
|
14410
|
+
leave: () => {
|
|
14411
|
+
if (left) return;
|
|
14412
|
+
left = true;
|
|
14413
|
+
active.users -= 1;
|
|
14414
|
+
if (active.users === 0 && registry2.get(key) === active) registry2.delete(key);
|
|
14415
|
+
}
|
|
14293
14416
|
};
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14417
|
+
}
|
|
14418
|
+
|
|
14419
|
+
// src/http/transport-admission.ts
|
|
14420
|
+
var KEY = /* @__PURE__ */ Symbol.for("node-autotask.transport-admission.v2");
|
|
14421
|
+
var root2 = globalThis;
|
|
14422
|
+
var coordinator = root2[KEY] ??= { ready: { rows: [], available: () => true }, dirty: /* @__PURE__ */ new Set(), objects: /* @__PURE__ */ new Map(), signals: /* @__PURE__ */ new WeakMap(), sequence: 0, draining: false, batching: 0 };
|
|
14423
|
+
function subscribe(signal, aborted) {
|
|
14424
|
+
let queue = coordinator.signals.get(signal);
|
|
14425
|
+
if (queue === void 0) {
|
|
14426
|
+
const callbacks = /* @__PURE__ */ new Set();
|
|
14427
|
+
queue = { callbacks, listener: () => {
|
|
14428
|
+
coordinator.signals.delete(signal);
|
|
14429
|
+
coordinator.batching += 1;
|
|
14430
|
+
try {
|
|
14431
|
+
for (const callback of callbacks) callback();
|
|
14432
|
+
} finally {
|
|
14433
|
+
coordinator.batching -= 1;
|
|
14434
|
+
drain();
|
|
14435
|
+
}
|
|
14436
|
+
} };
|
|
14437
|
+
coordinator.signals.set(signal, queue);
|
|
14438
|
+
signal.addEventListener("abort", queue.listener, { once: true });
|
|
14299
14439
|
}
|
|
14300
|
-
|
|
14440
|
+
const shared = queue;
|
|
14441
|
+
shared.callbacks.add(aborted);
|
|
14301
14442
|
return () => {
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14443
|
+
shared.callbacks.delete(aborted);
|
|
14444
|
+
if (shared.callbacks.size === 0) {
|
|
14445
|
+
coordinator.signals.delete(signal);
|
|
14446
|
+
signal.removeEventListener("abort", shared.listener);
|
|
14447
|
+
}
|
|
14306
14448
|
};
|
|
14307
14449
|
}
|
|
14450
|
+
function earlier(a, b) {
|
|
14451
|
+
return a.head.sequence < b.head.sequence;
|
|
14452
|
+
}
|
|
14453
|
+
function swap(heap, a, b) {
|
|
14454
|
+
const rows = heap.rows;
|
|
14455
|
+
[rows[a], rows[b]] = [rows[b], rows[a]];
|
|
14456
|
+
rows[a].index = a;
|
|
14457
|
+
rows[b].index = b;
|
|
14458
|
+
}
|
|
14459
|
+
function remove(pair) {
|
|
14460
|
+
const heap = pair.heap;
|
|
14461
|
+
if (heap === void 0) return;
|
|
14462
|
+
const index = pair.index;
|
|
14463
|
+
const last = heap.rows.pop();
|
|
14464
|
+
pair.heap = void 0;
|
|
14465
|
+
if (last === pair) return;
|
|
14466
|
+
heap.rows[index] = last;
|
|
14467
|
+
last.index = index;
|
|
14468
|
+
let current = index;
|
|
14469
|
+
while (current > 0) {
|
|
14470
|
+
const parent = Math.floor((current - 1) / 2);
|
|
14471
|
+
if (!earlier(heap.rows[current], heap.rows[parent])) break;
|
|
14472
|
+
swap(heap, current, parent);
|
|
14473
|
+
current = parent;
|
|
14474
|
+
}
|
|
14475
|
+
if (current !== index) return;
|
|
14476
|
+
for (; ; ) {
|
|
14477
|
+
const left = current * 2 + 1;
|
|
14478
|
+
const right = left + 1;
|
|
14479
|
+
if (left >= heap.rows.length) break;
|
|
14480
|
+
const child = right < heap.rows.length && earlier(heap.rows[right], heap.rows[left]) ? right : left;
|
|
14481
|
+
if (!earlier(heap.rows[child], heap.rows[current])) break;
|
|
14482
|
+
swap(heap, current, child);
|
|
14483
|
+
current = child;
|
|
14484
|
+
}
|
|
14485
|
+
}
|
|
14486
|
+
function insert(heap, pair) {
|
|
14487
|
+
pair.heap = heap;
|
|
14488
|
+
pair.index = heap.rows.length;
|
|
14489
|
+
heap.rows.push(pair);
|
|
14490
|
+
let current = pair.index;
|
|
14491
|
+
while (current > 0) {
|
|
14492
|
+
const parent = Math.floor((current - 1) / 2);
|
|
14493
|
+
if (!earlier(heap.rows[current], heap.rows[parent])) break;
|
|
14494
|
+
swap(heap, current, parent);
|
|
14495
|
+
current = parent;
|
|
14496
|
+
}
|
|
14497
|
+
}
|
|
14498
|
+
function reconsider(pair) {
|
|
14499
|
+
const origin = pair.origin;
|
|
14500
|
+
pair.origin = void 0;
|
|
14501
|
+
remove(pair);
|
|
14502
|
+
if (origin !== void 0) coordinator.dirty.add(origin);
|
|
14503
|
+
if (pair.head === void 0) return false;
|
|
14504
|
+
if (pair.client.active >= pair.client.maxConcurrent) insert(pair.client.waiting, pair);
|
|
14505
|
+
else if (pair.object !== void 0 && !pair.object.gate.available()) insert(pair.object.waiting, pair);
|
|
14506
|
+
else {
|
|
14507
|
+
insert(coordinator.ready, pair);
|
|
14508
|
+
return true;
|
|
14509
|
+
}
|
|
14510
|
+
return false;
|
|
14511
|
+
}
|
|
14512
|
+
function unlink(ticket) {
|
|
14513
|
+
const pair = ticket.pair;
|
|
14514
|
+
if (ticket.previous !== void 0) ticket.previous.next = ticket.next;
|
|
14515
|
+
else pair.head = ticket.next;
|
|
14516
|
+
if (ticket.next !== void 0) ticket.next.previous = ticket.previous;
|
|
14517
|
+
else pair.tail = ticket.previous;
|
|
14518
|
+
ticket.previous = void 0;
|
|
14519
|
+
ticket.next = void 0;
|
|
14520
|
+
if (pair.head === void 0) pair.client.pairs.delete(pair.object?.gate.identity);
|
|
14521
|
+
}
|
|
14522
|
+
function drain() {
|
|
14523
|
+
if (coordinator.draining || coordinator.batching > 0) return;
|
|
14524
|
+
coordinator.draining = true;
|
|
14525
|
+
try {
|
|
14526
|
+
for (; ; ) {
|
|
14527
|
+
for (const heap of coordinator.dirty) {
|
|
14528
|
+
coordinator.dirty.delete(heap);
|
|
14529
|
+
while (heap.rows.length > 0 && heap.available()) {
|
|
14530
|
+
const pair2 = heap.rows[0];
|
|
14531
|
+
if (reconsider(pair2)) {
|
|
14532
|
+
pair2.origin = heap;
|
|
14533
|
+
break;
|
|
14534
|
+
}
|
|
14535
|
+
}
|
|
14536
|
+
}
|
|
14537
|
+
const pair = coordinator.ready.rows[0];
|
|
14538
|
+
if (pair === void 0) break;
|
|
14539
|
+
remove(pair);
|
|
14540
|
+
if (pair.client.active >= pair.client.maxConcurrent || pair.object !== void 0 && !pair.object.gate.available()) {
|
|
14541
|
+
reconsider(pair);
|
|
14542
|
+
continue;
|
|
14543
|
+
}
|
|
14544
|
+
const origin = pair.origin;
|
|
14545
|
+
pair.origin = void 0;
|
|
14546
|
+
if (origin !== void 0) coordinator.dirty.add(origin);
|
|
14547
|
+
const ticket = pair.head;
|
|
14548
|
+
unlink(ticket);
|
|
14549
|
+
ticket.grant();
|
|
14550
|
+
if (pair.head !== void 0) reconsider(pair);
|
|
14551
|
+
}
|
|
14552
|
+
} finally {
|
|
14553
|
+
coordinator.draining = false;
|
|
14554
|
+
}
|
|
14555
|
+
}
|
|
14556
|
+
function wake(heap) {
|
|
14557
|
+
coordinator.dirty.add(heap);
|
|
14558
|
+
drain();
|
|
14559
|
+
}
|
|
14560
|
+
function admissionClient(maxConcurrent) {
|
|
14561
|
+
const client = { maxConcurrent, active: 0, pairs: /* @__PURE__ */ new Map(), waiting: { rows: [], available: () => client.active < client.maxConcurrent } };
|
|
14562
|
+
return client;
|
|
14563
|
+
}
|
|
14564
|
+
async function acquireTransport(client, url, trackingIdentifier, signal) {
|
|
14565
|
+
if (signal.aborted) throw signal.reason;
|
|
14566
|
+
const retained = retainObjectThread(url, trackingIdentifier);
|
|
14567
|
+
let object = retained === void 0 ? void 0 : coordinator.objects.get(retained.identity);
|
|
14568
|
+
if (retained !== void 0 && object === void 0) {
|
|
14569
|
+
object = { gate: retained, references: 0, stop: () => void 0, waiting: { rows: [], available: () => retained.available() } };
|
|
14570
|
+
const shared = object;
|
|
14571
|
+
shared.stop = retained.listen(() => wake(shared.waiting));
|
|
14572
|
+
coordinator.objects.set(retained.identity, shared);
|
|
14573
|
+
}
|
|
14574
|
+
if (object !== void 0) object.references += 1;
|
|
14575
|
+
const drop = () => {
|
|
14576
|
+
retained?.leave();
|
|
14577
|
+
if (object !== void 0 && --object.references === 0) {
|
|
14578
|
+
object.stop();
|
|
14579
|
+
coordinator.objects.delete(object.gate.identity);
|
|
14580
|
+
}
|
|
14581
|
+
};
|
|
14582
|
+
let pair = client.pairs.get(retained?.identity);
|
|
14583
|
+
if (pair === void 0) {
|
|
14584
|
+
pair = { client, object, index: -1 };
|
|
14585
|
+
client.pairs.set(retained?.identity, pair);
|
|
14586
|
+
}
|
|
14587
|
+
const queue = pair;
|
|
14588
|
+
return new Promise((resolve, reject) => {
|
|
14589
|
+
let released = false;
|
|
14590
|
+
let unsubscribe = () => void 0;
|
|
14591
|
+
const leave = () => {
|
|
14592
|
+
if (released) return;
|
|
14593
|
+
released = true;
|
|
14594
|
+
coordinator.batching += 1;
|
|
14595
|
+
client.active -= 1;
|
|
14596
|
+
coordinator.dirty.add(client.waiting);
|
|
14597
|
+
try {
|
|
14598
|
+
retained?.release();
|
|
14599
|
+
} finally {
|
|
14600
|
+
drop();
|
|
14601
|
+
coordinator.batching -= 1;
|
|
14602
|
+
drain();
|
|
14603
|
+
}
|
|
14604
|
+
};
|
|
14605
|
+
const aborted = () => {
|
|
14606
|
+
const front = queue.head === ticket;
|
|
14607
|
+
if (front) remove(queue);
|
|
14608
|
+
unlink(ticket);
|
|
14609
|
+
unsubscribe();
|
|
14610
|
+
drop();
|
|
14611
|
+
reject(signal.reason);
|
|
14612
|
+
if (front) reconsider(queue);
|
|
14613
|
+
drain();
|
|
14614
|
+
};
|
|
14615
|
+
const ticket = {
|
|
14616
|
+
sequence: coordinator.sequence++,
|
|
14617
|
+
pair: queue,
|
|
14618
|
+
grant: () => {
|
|
14619
|
+
unsubscribe();
|
|
14620
|
+
client.active += 1;
|
|
14621
|
+
let acquired;
|
|
14622
|
+
try {
|
|
14623
|
+
acquired = retained?.acquire(signal) ?? Promise.resolve();
|
|
14624
|
+
} catch (error) {
|
|
14625
|
+
client.active -= 1;
|
|
14626
|
+
drop();
|
|
14627
|
+
reject(error);
|
|
14628
|
+
wake(client.waiting);
|
|
14629
|
+
return;
|
|
14630
|
+
}
|
|
14631
|
+
void acquired.then(() => {
|
|
14632
|
+
if (signal.aborted) {
|
|
14633
|
+
leave();
|
|
14634
|
+
reject(signal.reason);
|
|
14635
|
+
} else resolve(leave);
|
|
14636
|
+
}, (error) => {
|
|
14637
|
+
client.active -= 1;
|
|
14638
|
+
drop();
|
|
14639
|
+
reject(error);
|
|
14640
|
+
wake(client.waiting);
|
|
14641
|
+
});
|
|
14642
|
+
}
|
|
14643
|
+
};
|
|
14644
|
+
ticket.previous = queue.tail;
|
|
14645
|
+
if (queue.tail !== void 0) queue.tail.next = ticket;
|
|
14646
|
+
else queue.head = ticket;
|
|
14647
|
+
queue.tail = ticket;
|
|
14648
|
+
unsubscribe = subscribe(signal, aborted);
|
|
14649
|
+
if (queue.head === ticket) reconsider(queue);
|
|
14650
|
+
drain();
|
|
14651
|
+
});
|
|
14652
|
+
}
|
|
14308
14653
|
|
|
14309
14654
|
// src/http/credentials.ts
|
|
14310
14655
|
var CREDENTIAL_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -14522,6 +14867,13 @@ async function discoverZoneBase(userName, maxResponseBytes, signal, ctx) {
|
|
|
14522
14867
|
var META_TRIO_VERBS = /* @__PURE__ */ new Set(["getEntityInfo", "getFieldInfo", "getUdfInfo"]);
|
|
14523
14868
|
var RETRY = { done: false };
|
|
14524
14869
|
var HttpClient = class {
|
|
14870
|
+
/** Retain this build's caller scope without sharing ambient storage. @internal */
|
|
14871
|
+
[CAPTURE_READ_GUARD](operation) {
|
|
14872
|
+
const signal = ambientCallerSignal();
|
|
14873
|
+
return () => {
|
|
14874
|
+
if (signal?.aborted) throw new AutotaskAbortError("Read aborted by the caller", { operation });
|
|
14875
|
+
};
|
|
14876
|
+
}
|
|
14525
14877
|
/**
|
|
14526
14878
|
* The LIVE base URL (issue #43): the construction-time value until a zone
|
|
14527
14879
|
* re-point happens, then the tenant's newly resolved zone base. Reads are
|
|
@@ -14559,8 +14911,8 @@ var HttpClient = class {
|
|
|
14559
14911
|
maxResponseBytes;
|
|
14560
14912
|
/** Local hourly budget (undefined when `rateLimit.perHour` is off). */
|
|
14561
14913
|
hourly;
|
|
14562
|
-
/**
|
|
14563
|
-
|
|
14914
|
+
/** Client identity for atomic local/object capacity admission. */
|
|
14915
|
+
admission;
|
|
14564
14916
|
/** Tenant 429 cooldown gate (issue #6; ON by default). */
|
|
14565
14917
|
cooldownEnabled;
|
|
14566
14918
|
cooldownMaxMs;
|
|
@@ -14623,7 +14975,7 @@ var HttpClient = class {
|
|
|
14623
14975
|
this.cooldownMaxMs = config.cooldown.maxMs;
|
|
14624
14976
|
this.cooldownDefaultMs = config.cooldown.defaultMs;
|
|
14625
14977
|
this.maxConcurrent = config.maxConcurrent;
|
|
14626
|
-
this.
|
|
14978
|
+
this.admission = admissionClient(config.maxConcurrent);
|
|
14627
14979
|
this.timeoutMs = config.timeoutMs;
|
|
14628
14980
|
this.logger = config.logger;
|
|
14629
14981
|
this.redactPersonalData = config.redactPersonalData;
|
|
@@ -14830,7 +15182,7 @@ var HttpClient = class {
|
|
|
14830
15182
|
}
|
|
14831
15183
|
// ---- the attempt --------------------------------------------------------
|
|
14832
15184
|
/**
|
|
14833
|
-
*
|
|
15185
|
+
* Acquire client/object capacity together, charge the attempt, fetch and read the body.
|
|
14834
15186
|
* `retry` when a network error is retriable (already waited); throws the
|
|
14835
15187
|
* typed error otherwise. The permit is released on every path.
|
|
14836
15188
|
*/
|
|
@@ -14838,24 +15190,22 @@ var HttpClient = class {
|
|
|
14838
15190
|
const { method, opts, ctx } = s;
|
|
14839
15191
|
let release;
|
|
14840
15192
|
for (; ; ) {
|
|
15193
|
+
let releaseThreads;
|
|
14841
15194
|
try {
|
|
14842
|
-
await this.
|
|
15195
|
+
releaseThreads = await acquireTransport(this.admission, s.url, this.auth.apiIntegrationCode, s.signal);
|
|
14843
15196
|
} catch (err) {
|
|
14844
15197
|
if (s.signal.aborted) throw this.interrupted(s);
|
|
14845
15198
|
throw err;
|
|
14846
15199
|
}
|
|
14847
|
-
let releaseObject = () => void 0;
|
|
14848
15200
|
let finishHourly = () => void 0;
|
|
14849
15201
|
let released = false;
|
|
14850
15202
|
const releaseCurrent = () => {
|
|
14851
15203
|
if (released) return;
|
|
14852
15204
|
released = true;
|
|
14853
15205
|
finishHourly();
|
|
14854
|
-
|
|
14855
|
-
this.semaphore.release();
|
|
15206
|
+
releaseThreads();
|
|
14856
15207
|
};
|
|
14857
15208
|
try {
|
|
14858
|
-
releaseObject = await acquireObjectThread(s.url, this.auth.apiIntegrationCode, s.signal);
|
|
14859
15209
|
if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
|
|
14860
15210
|
this.gate(s, false);
|
|
14861
15211
|
if (s.signal.aborted || Date.now() >= s.deadlineAt) throw this.interrupted(s);
|
|
@@ -15575,11 +15925,13 @@ var WORKFLOW_RESOURCES = [
|
|
|
15575
15925
|
"projects"
|
|
15576
15926
|
];
|
|
15577
15927
|
|
|
15578
|
-
// src/
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15928
|
+
// src/metadata-views.ts
|
|
15929
|
+
function liveFieldNamesView(rows) {
|
|
15930
|
+
if (!Array.isArray(rows)) return null;
|
|
15931
|
+
const names = [];
|
|
15932
|
+
for (const row of rows) if (typeof row.name === "string") names.push(row.name);
|
|
15933
|
+
return names.length === 0 ? null : { names, known: new Set(names) };
|
|
15934
|
+
}
|
|
15583
15935
|
function projectFieldRow(raw, labels = false, udf = false) {
|
|
15584
15936
|
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
15585
15937
|
const name = typeof r.name === "string" ? r.name : "";
|
|
@@ -15603,16 +15955,6 @@ function projectFieldRow(raw, labels = false, udf = false) {
|
|
|
15603
15955
|
...values !== void 0 ? { picklistValues: values } : {}
|
|
15604
15956
|
};
|
|
15605
15957
|
}
|
|
15606
|
-
function compactFieldRow(f, udf, keepValues) {
|
|
15607
|
-
return {
|
|
15608
|
-
name: f.name,
|
|
15609
|
-
type: f.type,
|
|
15610
|
-
isPickList: f.isPickList,
|
|
15611
|
-
isReference: f.referenceEntityType !== "",
|
|
15612
|
-
udf,
|
|
15613
|
-
...keepValues && f.picklistValues !== void 0 ? { picklistValues: f.picklistValues } : {}
|
|
15614
|
-
};
|
|
15615
|
-
}
|
|
15616
15958
|
function isObjectOrArrayType(type) {
|
|
15617
15959
|
const t = type.trim().toLowerCase();
|
|
15618
15960
|
return t === "object" || t === "array" || t === "collection" || t.endsWith("[]");
|
|
@@ -15621,7 +15963,151 @@ function exposesPicklistValues(raw) {
|
|
|
15621
15963
|
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
15622
15964
|
return Array.isArray(r.picklistValues) && r.picklistValues.length > 0;
|
|
15623
15965
|
}
|
|
15624
|
-
function
|
|
15966
|
+
function catalogList(raw, labels, udf) {
|
|
15967
|
+
return Array.isArray(raw) ? { rows: raw.map((row) => projectFieldRow(row, labels, udf)), exposesValues: raw.some(exposesPicklistValues) } : { rows: null, exposesValues: false };
|
|
15968
|
+
}
|
|
15969
|
+
var catalogFieldsView = (raw) => catalogList(raw, false, false);
|
|
15970
|
+
var catalogLabelledFieldsView = (raw) => catalogList(raw, true, false);
|
|
15971
|
+
var catalogUdfView = (raw) => catalogList(raw, false, true);
|
|
15972
|
+
var catalogLabelledUdfView = (raw) => catalogList(raw, true, true);
|
|
15973
|
+
function compactCatalogList(raw, keepValues, udf) {
|
|
15974
|
+
const view = catalogList(raw, keepValues, udf);
|
|
15975
|
+
if (view.rows === null) return { rows: null, exposesValues: view.exposesValues };
|
|
15976
|
+
const flags = {
|
|
15977
|
+
required: view.rows.filter((row) => row.isRequired).map((row) => row.name),
|
|
15978
|
+
readOnly: view.rows.filter((row) => row.isReadOnly).map((row) => row.name),
|
|
15979
|
+
queryable: view.rows.filter((row) => row.isQueryable).map((row) => row.name),
|
|
15980
|
+
picklistFields: view.rows.filter((row) => row.isPickList).map((row) => row.name)
|
|
15981
|
+
};
|
|
15982
|
+
return {
|
|
15983
|
+
rows: view.rows.map((row) => ({
|
|
15984
|
+
name: row.name,
|
|
15985
|
+
type: row.type,
|
|
15986
|
+
isPickList: row.isPickList,
|
|
15987
|
+
isReference: row.referenceEntityType !== "",
|
|
15988
|
+
udf,
|
|
15989
|
+
...keepValues && row.picklistValues !== void 0 ? { picklistValues: row.picklistValues } : {}
|
|
15990
|
+
})),
|
|
15991
|
+
flags,
|
|
15992
|
+
exposesValues: view.exposesValues
|
|
15993
|
+
};
|
|
15994
|
+
}
|
|
15995
|
+
var compactCatalogFieldsView = (raw) => compactCatalogList(raw, false, false);
|
|
15996
|
+
var compactCatalogLabelledFieldsView = (raw) => compactCatalogList(raw, true, false);
|
|
15997
|
+
var compactCatalogUdfView = (raw) => compactCatalogList(raw, false, true);
|
|
15998
|
+
var compactCatalogLabelledUdfView = (raw) => compactCatalogList(raw, true, true);
|
|
15999
|
+
function ticketStatusView(fields) {
|
|
16000
|
+
if (!Array.isArray(fields)) return [];
|
|
16001
|
+
const status = fields.find((f) => typeof f?.name === "string" && f.name.toLowerCase() === "status");
|
|
16002
|
+
if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
|
|
16003
|
+
const out = [];
|
|
16004
|
+
for (const v of status.picklistValues) {
|
|
16005
|
+
const id = Number(v?.value);
|
|
16006
|
+
if (!Number.isSafeInteger(id)) continue;
|
|
16007
|
+
out.push({ id, label: typeof v.label === "string" ? v.label : "" });
|
|
16008
|
+
}
|
|
16009
|
+
return out;
|
|
16010
|
+
}
|
|
16011
|
+
function primitiveData(descriptor2) {
|
|
16012
|
+
return descriptor2 !== void 0 && "value" in descriptor2 && (descriptor2.value === null || typeof descriptor2.value !== "object" && typeof descriptor2.value !== "function");
|
|
16013
|
+
}
|
|
16014
|
+
function picklistsView(raw) {
|
|
16015
|
+
if (!Array.isArray(raw)) return null;
|
|
16016
|
+
const fields = /* @__PURE__ */ new Map();
|
|
16017
|
+
for (const rawField of raw) {
|
|
16018
|
+
const field = projectFieldRow(rawField, true);
|
|
16019
|
+
if (fields.has(field.name)) continue;
|
|
16020
|
+
const values = field.picklistValues;
|
|
16021
|
+
if (values === void 0) {
|
|
16022
|
+
fields.set(field.name, void 0);
|
|
16023
|
+
continue;
|
|
16024
|
+
}
|
|
16025
|
+
const labels = /* @__PURE__ */ new Map();
|
|
16026
|
+
if (values.some((entry) => {
|
|
16027
|
+
if (entry === null || typeof entry !== "object" || Object.getPrototypeOf(entry) !== Object.prototype) return true;
|
|
16028
|
+
return !primitiveData(Object.getOwnPropertyDescriptor(entry, "value")) || !primitiveData(Object.getOwnPropertyDescriptor(entry, "label"));
|
|
16029
|
+
})) {
|
|
16030
|
+
fields.set(field.name, { labels, ordered: values });
|
|
16031
|
+
continue;
|
|
16032
|
+
}
|
|
16033
|
+
for (const value of values) {
|
|
16034
|
+
const key = String(value.value);
|
|
16035
|
+
if (!labels.has(key)) labels.set(key, typeof value.label === "string" ? value.label : null);
|
|
16036
|
+
}
|
|
16037
|
+
fields.set(field.name, { labels });
|
|
16038
|
+
}
|
|
16039
|
+
return fields;
|
|
16040
|
+
}
|
|
16041
|
+
function lookupPicklist(view, value) {
|
|
16042
|
+
if (view.ordered !== void 0) {
|
|
16043
|
+
const hit = view.ordered.find((entry) => String(entry.value) === String(value));
|
|
16044
|
+
return { found: hit !== void 0, label: typeof hit?.label === "string" ? hit.label : null };
|
|
16045
|
+
}
|
|
16046
|
+
const key = String(value);
|
|
16047
|
+
return { found: view.labels.has(key), label: view.labels.get(key) ?? null };
|
|
16048
|
+
}
|
|
16049
|
+
function ticketStatusFieldsView(fields) {
|
|
16050
|
+
if (!Array.isArray(fields)) return [];
|
|
16051
|
+
const status = fields.find((field) => typeof field?.name === "string" && field.name.toLowerCase() === "status");
|
|
16052
|
+
return status === void 0 ? [] : [status];
|
|
16053
|
+
}
|
|
16054
|
+
|
|
16055
|
+
// src/utils/bounded.ts
|
|
16056
|
+
async function runBounded(fn, items, opts) {
|
|
16057
|
+
const { concurrency, signal, settle } = opts;
|
|
16058
|
+
if (!Number.isInteger(concurrency) || concurrency <= 0) {
|
|
16059
|
+
throw new AutotaskConfigError("batch concurrency must be a positive integer");
|
|
16060
|
+
}
|
|
16061
|
+
const results = new Array(items.length);
|
|
16062
|
+
let next = 0;
|
|
16063
|
+
let failure;
|
|
16064
|
+
const fail = (error, index) => {
|
|
16065
|
+
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
16066
|
+
};
|
|
16067
|
+
const worker = async () => {
|
|
16068
|
+
while (failure === void 0 && next < items.length) {
|
|
16069
|
+
if (signal?.aborted) {
|
|
16070
|
+
fail(signal.reason, -1);
|
|
16071
|
+
return;
|
|
16072
|
+
}
|
|
16073
|
+
const i = next++;
|
|
16074
|
+
try {
|
|
16075
|
+
const item = items[i];
|
|
16076
|
+
const value = await (signal === void 0 ? fn(item) : runWithSignal(signal, () => fn(item)));
|
|
16077
|
+
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
16078
|
+
} catch (error) {
|
|
16079
|
+
if (settle) results[i] = { status: "rejected", reason: error };
|
|
16080
|
+
else fail(error, i);
|
|
16081
|
+
}
|
|
16082
|
+
}
|
|
16083
|
+
};
|
|
16084
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, worker));
|
|
16085
|
+
if (failure !== void 0) throw failure.error;
|
|
16086
|
+
return results;
|
|
16087
|
+
}
|
|
16088
|
+
async function mapReadTasks(http, items, fn) {
|
|
16089
|
+
const signal = ambientCallerSignal();
|
|
16090
|
+
const abort = () => new AutotaskAbortError("Read fan-out aborted by the caller");
|
|
16091
|
+
if (signal?.aborted) throw abort();
|
|
16092
|
+
try {
|
|
16093
|
+
const results = await runBounded(fn, items, { concurrency: http === void 0 ? DEFAULT_MAX_CONCURRENT : http.maxConcurrent, orderedErrors: true, ...signal === void 0 ? {} : { signal } });
|
|
16094
|
+
if (signal?.aborted) throw abort();
|
|
16095
|
+
return results;
|
|
16096
|
+
} catch (error) {
|
|
16097
|
+
if (signal?.aborted && !(error instanceof AutotaskAbortError)) throw abort();
|
|
16098
|
+
throw error;
|
|
16099
|
+
}
|
|
16100
|
+
}
|
|
16101
|
+
function readTasks(http, tasks) {
|
|
16102
|
+
return mapReadTasks(http, tasks, (task) => task());
|
|
16103
|
+
}
|
|
16104
|
+
|
|
16105
|
+
// src/operations/fieldCatalog.ts
|
|
16106
|
+
var MAX_FIELD_CATALOG_WIRE = 60;
|
|
16107
|
+
var FIELD_CATALOG_HONESTY_NOTE = "Live field metadata reports the SHAPE of a field (existence, requiredness, type, maxLength, read-only, queryable, picklist-ness) as FLAGS and NAMES: picklist-ness as a flag (isPickList) and picklist field names (picklistFields). With the opt-in `labels: true`, picklist rows carry the vendor's exposed picklist VALUES (labels next to each value); without it the op serves no VALUES. It cannot resolve a picklist VALUE the vendor does not expose to this API user (a vendor-withheld picklist value): retrying the catalog will not surface a withheld value; that gap is vendor-side, not a client defect.";
|
|
16108
|
+
var MIN_FIELD_CATALOG_MAX_BYTES = 4096;
|
|
16109
|
+
var FIELD_CATALOG_OPT_KEYS = ["resources", "include", "fresh", "fields", "labels", "compact", "maxBytes"];
|
|
16110
|
+
function applyFieldsFilter(projected, filter, row, flags) {
|
|
15625
16111
|
const kept = filter === void 0 ? projected : projected.filter((f) => filter.includes(f.name));
|
|
15626
16112
|
if (filter !== void 0) {
|
|
15627
16113
|
const present = new Set(projected.map((f) => f.name));
|
|
@@ -15629,10 +16115,19 @@ function applyFieldsFilter(projected, filter, row) {
|
|
|
15629
16115
|
row.projected = true;
|
|
15630
16116
|
}
|
|
15631
16117
|
row.fields = kept;
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
|
|
16118
|
+
if (flags !== void 0) {
|
|
16119
|
+
const present = new Set(kept.map((field) => field.name));
|
|
16120
|
+
row.required = flags.required.filter((name) => present.has(name));
|
|
16121
|
+
row.readOnly = flags.readOnly.filter((name) => present.has(name));
|
|
16122
|
+
row.queryable = flags.queryable.filter((name) => present.has(name));
|
|
16123
|
+
row.picklistFields = flags.picklistFields.filter((name) => present.has(name));
|
|
16124
|
+
} else {
|
|
16125
|
+
const full = kept;
|
|
16126
|
+
row.required = full.filter((field) => field.isRequired).map((field) => field.name);
|
|
16127
|
+
row.readOnly = full.filter((field) => field.isReadOnly).map((field) => field.name);
|
|
16128
|
+
row.queryable = full.filter((field) => field.isQueryable).map((field) => field.name);
|
|
16129
|
+
row.picklistFields = full.filter((field) => field.isPickList).map((field) => field.name);
|
|
16130
|
+
}
|
|
15636
16131
|
}
|
|
15637
16132
|
async function capabilitySets() {
|
|
15638
16133
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
@@ -15847,13 +16342,36 @@ function kindFetches(holder, resource) {
|
|
|
15847
16342
|
udf: () => holder?.getUdfInfo?.() ?? Promise.reject(new AutotaskError(`fieldCatalog: the client exposes no getUdfInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" }))
|
|
15848
16343
|
};
|
|
15849
16344
|
}
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
16345
|
+
function catalogProjector(kind, ctx) {
|
|
16346
|
+
if (ctx.compact) {
|
|
16347
|
+
const keepValues = ctx.labels && ctx.fieldsFilter !== void 0;
|
|
16348
|
+
if (kind === "fields") return keepValues ? compactCatalogLabelledFieldsView : compactCatalogFieldsView;
|
|
16349
|
+
if (kind === "udf") return keepValues ? compactCatalogLabelledUdfView : compactCatalogUdfView;
|
|
16350
|
+
}
|
|
16351
|
+
if (kind === "fields") return ctx.labels ? catalogLabelledFieldsView : catalogFieldsView;
|
|
16352
|
+
if (kind === "udf") return ctx.labels ? catalogLabelledUdfView : catalogUdfView;
|
|
16353
|
+
return void 0;
|
|
16354
|
+
}
|
|
16355
|
+
async function readKind(ctx, resource, kind, fetch2, holder, projector = catalogProjector(kind, ctx)) {
|
|
16356
|
+
const cache = ctx.client.http.fieldCache;
|
|
16357
|
+
const peek = cache !== void 0 && !ctx.fresh ? cache.peek(fieldKey(resource, kind)) : { hit: false, age: null };
|
|
16358
|
+
if (peek.hit && cache !== void 0) {
|
|
16359
|
+
const value = projector !== void 0 && typeof cache.getProjected === "function" ? cache.getProjected(fieldKey(resource, kind), projector) ?? projector(void 0) : projector === void 0 ? cache.get(fieldKey(resource, kind)) : projector(cache.get(fieldKey(resource, kind)));
|
|
16360
|
+
return { kind, peek, outcome: { status: "fulfilled", value } };
|
|
16361
|
+
}
|
|
16362
|
+
try {
|
|
16363
|
+
const value = projector === void 0 ? await fetch2() : await readMetadataProjection(holder, kind, projector, fetch2);
|
|
16364
|
+
return { kind, peek, outcome: { status: "fulfilled", value } };
|
|
16365
|
+
} catch (error) {
|
|
16366
|
+
if (!isAutotaskError(error) || error.code === "ABORTED") throw error;
|
|
16367
|
+
return { kind, peek, outcome: { status: "rejected", reason: error } };
|
|
16368
|
+
}
|
|
16369
|
+
}
|
|
16370
|
+
async function sweepResource(ctx, resource, tally, reads) {
|
|
16371
|
+
const { fieldsFilter } = ctx;
|
|
15853
16372
|
const fieldOp = ctx.fieldOps.get(resource);
|
|
15854
16373
|
if (fieldOp === void 0) return void 0;
|
|
15855
16374
|
const apiEntity = apiEntityFor(fieldOp);
|
|
15856
|
-
const holder = client[camelKey(resource)];
|
|
15857
16375
|
const row = {
|
|
15858
16376
|
resource,
|
|
15859
16377
|
apiEntity,
|
|
@@ -15869,54 +16387,34 @@ async function sweepResource(ctx, resource, tally) {
|
|
|
15869
16387
|
wire: 0,
|
|
15870
16388
|
error: null
|
|
15871
16389
|
};
|
|
15872
|
-
const fetches = kindFetches(holder, resource);
|
|
15873
|
-
if (fresh) cache?.invalidate(`${resource}:`);
|
|
15874
|
-
const projectList = (kind, list) => {
|
|
15875
|
-
const projected = list.map((f) => projectFieldRow(f, labels, kind === "udf"));
|
|
15876
|
-
if (kind === "fields") applyFieldsFilter(projected, fieldsFilter, row);
|
|
15877
|
-
else row.udf = projected;
|
|
15878
|
-
for (const f of list) if (exposesPicklistValues(f)) tally.anyPicklistValues = true;
|
|
15879
|
-
};
|
|
15880
16390
|
let allCached = true;
|
|
15881
16391
|
const ages = [];
|
|
15882
|
-
for (const kind of
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
if (peek.hit === true && cache !== void 0) {
|
|
15886
|
-
const value2 = cache.get(fieldKey(resource, kind));
|
|
15887
|
-
if (kind === "info") row.info = value2 ?? null;
|
|
15888
|
-
else projectList(kind, Array.isArray(value2) ? value2 : []);
|
|
15889
|
-
if (peek.age !== null) ages.push(peek.age);
|
|
15890
|
-
continue;
|
|
15891
|
-
}
|
|
15892
|
-
let value;
|
|
15893
|
-
try {
|
|
15894
|
-
value = await fetches[kind]();
|
|
15895
|
-
} catch (err) {
|
|
15896
|
-
if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
16392
|
+
for (const { kind, peek, outcome } of reads) {
|
|
16393
|
+
if (!peek.hit) {
|
|
16394
|
+
allCached = false;
|
|
15897
16395
|
tally.wireUsed += 1;
|
|
15898
16396
|
row.wire += 1;
|
|
15899
|
-
|
|
16397
|
+
} else if (peek.age !== null) ages.push(peek.age);
|
|
16398
|
+
if (outcome.status === "rejected") {
|
|
16399
|
+
const error = outcome.reason;
|
|
16400
|
+
if (row.error === null) row.error = { code: error.code, message: error.message };
|
|
15900
16401
|
continue;
|
|
15901
16402
|
}
|
|
15902
|
-
|
|
15903
|
-
row.wire += 1;
|
|
16403
|
+
const value = outcome.value;
|
|
15904
16404
|
if (kind === "info") {
|
|
15905
16405
|
row.info = value ?? null;
|
|
15906
16406
|
} else {
|
|
15907
|
-
|
|
16407
|
+
const view = value;
|
|
16408
|
+
if (view.rows === null) {
|
|
15908
16409
|
if (row.error === null) row.error = { code: "INVALID_RESPONSE", message: `fieldCatalog: the ${kind} response for ${resource} was not a list` };
|
|
15909
16410
|
continue;
|
|
15910
16411
|
}
|
|
15911
|
-
|
|
16412
|
+
if (kind === "fields") applyFieldsFilter(view.rows, fieldsFilter, row, view.flags);
|
|
16413
|
+
else row.udf = view.rows;
|
|
16414
|
+
if (view.exposesValues) tally.anyPicklistValues = true;
|
|
15912
16415
|
}
|
|
15913
16416
|
}
|
|
15914
16417
|
row.cache = allCached ? { hit: true, age: ages.length > 0 ? Math.max(...ages) : 0 } : { hit: false, age: null };
|
|
15915
|
-
if (ctx.compact) {
|
|
15916
|
-
const keepValues = labels && fieldsFilter !== void 0;
|
|
15917
|
-
if (row.fields !== void 0) row.fields = row.fields.map((f) => compactFieldRow(f, false, keepValues));
|
|
15918
|
-
if (Array.isArray(row.udf)) row.udf = row.udf.map((f) => compactFieldRow(f, true, keepValues));
|
|
15919
|
-
}
|
|
15920
16418
|
const declared = await derivedFieldsFor(resource);
|
|
15921
16419
|
if (declared.length > 0) {
|
|
15922
16420
|
const byField = new Map(declared.map((d) => [d.field, d]));
|
|
@@ -15932,7 +16430,7 @@ async function sweepResource(ctx, resource, tally) {
|
|
|
15932
16430
|
}
|
|
15933
16431
|
return row;
|
|
15934
16432
|
}
|
|
15935
|
-
async function
|
|
16433
|
+
async function prepareCatalog(client, opts) {
|
|
15936
16434
|
validateCatalogOptsShape(opts);
|
|
15937
16435
|
const { fieldOps, udfCapable, resources: allResources } = await capabilitySets();
|
|
15938
16436
|
const include = resolveInclude(opts);
|
|
@@ -15941,13 +16439,35 @@ async function fieldCatalog(client, opts) {
|
|
|
15941
16439
|
const labels = resolveLabels(opts);
|
|
15942
16440
|
const { compact, maxBytes } = resolveSizeOpts(opts);
|
|
15943
16441
|
assertWithinWireCap(targets.length, include.length);
|
|
16442
|
+
const ctx = { client, include, fieldsFilter, labels, compact, fresh: opts?.fresh === true, fieldOps, udfCapable };
|
|
16443
|
+
return { ctx, targets, compact, maxBytes };
|
|
16444
|
+
}
|
|
16445
|
+
async function fieldCatalogPicklists(client, resource, fields) {
|
|
16446
|
+
const { ctx } = await prepareCatalog(client, { resources: [resource], labels: true, fields: [...fields] });
|
|
16447
|
+
const holder = client[camelKey(resource)];
|
|
16448
|
+
const [read] = await mapReadTasks(client.http, [resource], () => readKind(ctx, resource, "fields", kindFetches(holder, resource).fields, holder, picklistsView));
|
|
16449
|
+
return read.outcome.status === "fulfilled" ? read.outcome.value : null;
|
|
16450
|
+
}
|
|
16451
|
+
async function fieldCatalog(client, opts) {
|
|
16452
|
+
const { ctx, targets, compact, maxBytes } = await prepareCatalog(client, opts);
|
|
16453
|
+
const { include, labels, fieldOps, udfCapable } = ctx;
|
|
15944
16454
|
const cache = client.http.fieldCache;
|
|
15945
16455
|
const zone = client.config.zone ?? "unknown";
|
|
15946
16456
|
const rows = [];
|
|
15947
16457
|
const tally = { wireUsed: 0, anyPicklistValues: false };
|
|
15948
|
-
const ctx = { client, include, fieldsFilter, labels, compact, fresh: opts?.fresh === true, fieldOps, udfCapable };
|
|
15949
16458
|
for (const resource of targets) {
|
|
15950
|
-
|
|
16459
|
+
apiEntityFor(fieldOps.get(resource));
|
|
16460
|
+
if (ctx.fresh) cache?.invalidate(`${resource}:`);
|
|
16461
|
+
}
|
|
16462
|
+
const tasks = targets.flatMap((resource) => {
|
|
16463
|
+
const holder = client[camelKey(resource)];
|
|
16464
|
+
const fetches = kindFetches(holder, resource);
|
|
16465
|
+
return include.map((kind) => ({ resource, kind, fetch: fetches[kind], holder }));
|
|
16466
|
+
});
|
|
16467
|
+
const reads = await mapReadTasks(client.http, tasks, ({ resource, kind, fetch: fetch2, holder }) => readKind(ctx, resource, kind, fetch2, holder));
|
|
16468
|
+
for (let index = 0; index < targets.length; index += 1) {
|
|
16469
|
+
const start = index * include.length;
|
|
16470
|
+
const row = await sweepResource(ctx, targets[index], tally, reads.slice(start, start + include.length));
|
|
15951
16471
|
if (row !== void 0) rows.push(row);
|
|
15952
16472
|
}
|
|
15953
16473
|
const result = {
|
|
@@ -16130,56 +16650,6 @@ function entityNameFromPath(resourcePath) {
|
|
|
16130
16650
|
return snake;
|
|
16131
16651
|
}
|
|
16132
16652
|
|
|
16133
|
-
// src/utils/bounded.ts
|
|
16134
|
-
async function runBounded(fn, items, opts) {
|
|
16135
|
-
const { concurrency, signal, settle } = opts;
|
|
16136
|
-
if (!Number.isInteger(concurrency) || concurrency <= 0) {
|
|
16137
|
-
throw new AutotaskConfigError("batch concurrency must be a positive integer");
|
|
16138
|
-
}
|
|
16139
|
-
const results = new Array(items.length);
|
|
16140
|
-
let next = 0;
|
|
16141
|
-
let failure;
|
|
16142
|
-
const fail = (error, index) => {
|
|
16143
|
-
if (failure === void 0 || opts.orderedErrors === true && index < failure.index) failure = { error, index };
|
|
16144
|
-
};
|
|
16145
|
-
const worker = async () => {
|
|
16146
|
-
while (failure === void 0 && next < items.length) {
|
|
16147
|
-
if (signal?.aborted) {
|
|
16148
|
-
fail(signal.reason, -1);
|
|
16149
|
-
return;
|
|
16150
|
-
}
|
|
16151
|
-
const i = next++;
|
|
16152
|
-
try {
|
|
16153
|
-
const item = items[i];
|
|
16154
|
-
const value = await (signal === void 0 ? fn(item) : runWithSignal(signal, () => fn(item)));
|
|
16155
|
-
results[i] = settle ? { status: "fulfilled", value } : value;
|
|
16156
|
-
} catch (error) {
|
|
16157
|
-
if (settle) results[i] = { status: "rejected", reason: error };
|
|
16158
|
-
else fail(error, i);
|
|
16159
|
-
}
|
|
16160
|
-
}
|
|
16161
|
-
};
|
|
16162
|
-
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, worker));
|
|
16163
|
-
if (failure !== void 0) throw failure.error;
|
|
16164
|
-
return results;
|
|
16165
|
-
}
|
|
16166
|
-
async function mapReadTasks(http, items, fn) {
|
|
16167
|
-
const signal = ambientCallerSignal();
|
|
16168
|
-
const abort = () => new AutotaskAbortError("Read fan-out aborted by the caller");
|
|
16169
|
-
if (signal?.aborted) throw abort();
|
|
16170
|
-
try {
|
|
16171
|
-
const results = await runBounded(fn, items, { concurrency: http.maxConcurrent, orderedErrors: true, ...signal === void 0 ? {} : { signal } });
|
|
16172
|
-
if (signal?.aborted) throw abort();
|
|
16173
|
-
return results;
|
|
16174
|
-
} catch (error) {
|
|
16175
|
-
if (signal?.aborted && !(error instanceof AutotaskAbortError)) throw abort();
|
|
16176
|
-
throw error;
|
|
16177
|
-
}
|
|
16178
|
-
}
|
|
16179
|
-
function readTasks(http, tasks) {
|
|
16180
|
-
return mapReadTasks(http, tasks, (task) => task());
|
|
16181
|
-
}
|
|
16182
|
-
|
|
16183
16653
|
// src/operations/nameSnapshot.ts
|
|
16184
16654
|
function nameRecordSnapshot(cache, path, id, operation) {
|
|
16185
16655
|
const body = cache?.get(path);
|
|
@@ -16596,19 +17066,12 @@ async function resolveCompositeNames(http, plan, opts = {}) {
|
|
|
16596
17066
|
};
|
|
16597
17067
|
});
|
|
16598
17068
|
}
|
|
16599
|
-
|
|
17069
|
+
let picklists = null;
|
|
16600
17070
|
if (plan.labelFields.length > 0) {
|
|
16601
17071
|
tasks.push(async () => {
|
|
16602
17072
|
try {
|
|
16603
17073
|
const labelResource = plan.labelResource ?? "tickets";
|
|
16604
|
-
|
|
16605
|
-
const row = catalog.rows.find((r) => r.resource === labelResource);
|
|
16606
|
-
if (row !== void 0 && row.error === null && row.fields !== void 0) {
|
|
16607
|
-
for (const f of plan.labelFields) {
|
|
16608
|
-
const frow = row.fields.find((x) => x.name === f);
|
|
16609
|
-
picklists[f] = frow?.picklistValues;
|
|
16610
|
-
}
|
|
16611
|
-
}
|
|
17074
|
+
picklists = await fieldCatalogPicklists(client, labelResource, plan.labelFields);
|
|
16612
17075
|
} catch (err) {
|
|
16613
17076
|
if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
16614
17077
|
}
|
|
@@ -16644,17 +17107,17 @@ async function resolveCompositeNames(http, plan, opts = {}) {
|
|
|
16644
17107
|
recordName: (table, id) => section.rows[`${table}:${id}`]?.name ?? null,
|
|
16645
17108
|
labelFor: (field, value) => {
|
|
16646
17109
|
if (value === null || value === void 0) return null;
|
|
16647
|
-
const values = picklists
|
|
17110
|
+
const values = picklists?.get(field);
|
|
16648
17111
|
if (values === void 0) {
|
|
16649
17112
|
section.reasons[field] = FIELD_CATALOG_HONESTY_NOTE;
|
|
16650
17113
|
return null;
|
|
16651
17114
|
}
|
|
16652
|
-
const hit = values
|
|
16653
|
-
if (hit
|
|
17115
|
+
const hit = lookupPicklist(values, value);
|
|
17116
|
+
if (!hit.found) {
|
|
16654
17117
|
if (String(value) !== "0") section.reasons[field] = PICKLIST_VALUE_NOT_SERVED_NOTE;
|
|
16655
17118
|
return null;
|
|
16656
17119
|
}
|
|
16657
|
-
return
|
|
17120
|
+
return hit.label;
|
|
16658
17121
|
}
|
|
16659
17122
|
};
|
|
16660
17123
|
}
|
|
@@ -16716,27 +17179,36 @@ function subscriberError(error, operation) {
|
|
|
16716
17179
|
};
|
|
16717
17180
|
return copyValue(error);
|
|
16718
17181
|
}
|
|
16719
|
-
function
|
|
16720
|
-
const cache = http.readCache;
|
|
16721
|
-
if (cache === void 0) return http.request({ method: "GET", path, operation });
|
|
17182
|
+
function cachedRead(http, cache, key, path, operation, request, fresh, shouldStore, projector) {
|
|
16722
17183
|
let ownsLoader = false;
|
|
16723
17184
|
const loader = (signal) => {
|
|
16724
17185
|
ownsLoader = true;
|
|
16725
|
-
return
|
|
17186
|
+
return request(signal);
|
|
16726
17187
|
};
|
|
16727
17188
|
const options = {
|
|
16728
17189
|
signal: ambientCallerSignal(),
|
|
16729
17190
|
fresh,
|
|
17191
|
+
shouldStore,
|
|
16730
17192
|
abortError: () => new AutotaskAbortError(`Request aborted: GET ${path}`, {
|
|
16731
17193
|
operation,
|
|
16732
17194
|
suggestedAction: "The caller aborted; re-issue the call if still needed."
|
|
16733
17195
|
})
|
|
16734
17196
|
};
|
|
16735
|
-
|
|
17197
|
+
const select = (value) => {
|
|
17198
|
+
if (options.signal?.aborted) throw options.abortError();
|
|
17199
|
+
const selected = projector === void 0 ? value : projectMetadata(value, projector);
|
|
17200
|
+
if (options.signal?.aborted) throw options.abortError();
|
|
17201
|
+
return selected;
|
|
17202
|
+
};
|
|
17203
|
+
if (cache === void 0) return request().then(select);
|
|
17204
|
+
const load = (fresh2) => projector !== void 0 && typeof cache.loadProjected === "function" ? cache.loadProjected(key, loader, projector, { ...options, fresh: fresh2 }) : cache.load(key, loader, { ...options, fresh: fresh2 }).then(select);
|
|
17205
|
+
return load(fresh).catch((error) => {
|
|
16736
17206
|
if (ownsLoader || !(error instanceof AutotaskError) || error.details?.budgetScope !== "client" || error.notSent !== true) throw error;
|
|
16737
17207
|
if (options.signal?.aborted) throw options.abortError();
|
|
16738
|
-
const
|
|
16739
|
-
|
|
17208
|
+
const projected = projector !== void 0 && typeof cache.getProjected === "function";
|
|
17209
|
+
const warm = projected ? cache.getProjected(key, projector) : cache.get(key);
|
|
17210
|
+
if (options.signal?.aborted) throw options.abortError();
|
|
17211
|
+
return warm !== void 0 ? projected ? warm : select(warm) : load(true);
|
|
16740
17212
|
}).catch((error) => {
|
|
16741
17213
|
if (!(error instanceof AutotaskError)) throw error;
|
|
16742
17214
|
const failure = subscriberError(error, operation);
|
|
@@ -16744,6 +17216,33 @@ function cachedRecordGet(http, path, operation, fresh = false) {
|
|
|
16744
17216
|
throw failure;
|
|
16745
17217
|
});
|
|
16746
17218
|
}
|
|
17219
|
+
function cachedRecordGet(http, path, operation, fresh = false) {
|
|
17220
|
+
return cachedRead(
|
|
17221
|
+
http,
|
|
17222
|
+
http.readCache,
|
|
17223
|
+
path,
|
|
17224
|
+
path,
|
|
17225
|
+
operation,
|
|
17226
|
+
(signal) => http.request({ method: "GET", path, operation, signal }),
|
|
17227
|
+
fresh
|
|
17228
|
+
);
|
|
17229
|
+
}
|
|
17230
|
+
function cachedMetadataGet(http, resource, kind, path, operation, unwrap, fresh = false, maxRetries, projector) {
|
|
17231
|
+
const cache = http.fieldCache;
|
|
17232
|
+
const request = (signal) => {
|
|
17233
|
+
return http.request({ method: "GET", path, operation, signal, maxRetries }).then(unwrap).catch((error) => {
|
|
17234
|
+
if (error instanceof AutotaskError && (error.code === "INVALID_RESPONSE" || error.details?.deterministic === true)) {
|
|
17235
|
+
cache?.invalidate(`${resource}:`);
|
|
17236
|
+
}
|
|
17237
|
+
throw error;
|
|
17238
|
+
});
|
|
17239
|
+
};
|
|
17240
|
+
return cachedRead(http, cache, fieldKey(resource, kind), path, operation, request, fresh, (value) => {
|
|
17241
|
+
if (value === null || value === void 0) return false;
|
|
17242
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
17243
|
+
return typeof value !== "object" || Object.keys(value).length > 0;
|
|
17244
|
+
}, projector);
|
|
17245
|
+
}
|
|
16747
17246
|
|
|
16748
17247
|
// src/field-sets.ts
|
|
16749
17248
|
var MODEL_FIELD_SETS = {
|
|
@@ -16956,6 +17455,19 @@ async function boundedPart(http, path, conditions, limit, operation, includeFiel
|
|
|
16956
17455
|
return { items, capped, hasMore: capped && pageDetails.nextPageUrl != null };
|
|
16957
17456
|
}
|
|
16958
17457
|
|
|
17458
|
+
// src/utils/model-fields.ts
|
|
17459
|
+
var lookups = /* @__PURE__ */ new Map();
|
|
17460
|
+
function modelFieldLookup(resourceKey) {
|
|
17461
|
+
if (!Object.hasOwn(MODEL_FIELD_SETS, resourceKey)) return void 0;
|
|
17462
|
+
let lookup = lookups.get(resourceKey);
|
|
17463
|
+
if (lookup === void 0) {
|
|
17464
|
+
const names = new Set(MODEL_FIELD_SETS[resourceKey]);
|
|
17465
|
+
lookup = (field) => names.has(field);
|
|
17466
|
+
lookups.set(resourceKey, lookup);
|
|
17467
|
+
}
|
|
17468
|
+
return lookup;
|
|
17469
|
+
}
|
|
17470
|
+
|
|
16959
17471
|
// src/resources/special/_shared/relation-filters.ts
|
|
16960
17472
|
var JOIN_SET_CAP = 300;
|
|
16961
17473
|
function capJoinSet(ids2, cap = JOIN_SET_CAP) {
|
|
@@ -16969,8 +17481,8 @@ var RELATION_TARGETS = {
|
|
|
16969
17481
|
project: { resource: "projects", path: "/V1.0/Projects/query" }
|
|
16970
17482
|
};
|
|
16971
17483
|
function relationsFor(resourceKey) {
|
|
16972
|
-
const
|
|
16973
|
-
return Object.keys(RELATION_TARGETS).filter((rel) =>
|
|
17484
|
+
const hasField = modelFieldLookup(resourceKey);
|
|
17485
|
+
return Object.keys(RELATION_TARGETS).filter((rel) => hasField?.(`${rel}ID`) === true);
|
|
16974
17486
|
}
|
|
16975
17487
|
function selfPrefixes(resourceKey) {
|
|
16976
17488
|
const rels = Object.keys(RELATION_TARGETS).filter((rel) => RELATION_TARGETS[rel].resource === resourceKey);
|
|
@@ -17015,7 +17527,7 @@ function validateRelationLeaves(resourceKey, conditions, op) {
|
|
|
17015
17527
|
if (rest.length > 0 || !sub) fail("is not <relation>.<field> (multi-hop relations are not supported)");
|
|
17016
17528
|
if (!valid.includes(rel)) fail(`names an unknown relation for ${resourceKey} (valid: ${valid.join(", ") || "none"})`);
|
|
17017
17529
|
const parentFields = MODEL_FIELD_SETS[RELATION_TARGETS[rel].resource];
|
|
17018
|
-
if (parentFields !== void 0 &&
|
|
17530
|
+
if (parentFields !== void 0 && modelFieldLookup(RELATION_TARGETS[rel].resource)?.(sub) !== true) {
|
|
17019
17531
|
fail(`names a field unknown on ${RELATION_TARGETS[rel].resource}`);
|
|
17020
17532
|
}
|
|
17021
17533
|
}
|
|
@@ -17026,36 +17538,52 @@ async function rewriteRelationFilters(http, resourceKey, conditions, op) {
|
|
|
17026
17538
|
if (!hasRelationConditions(conditions)) return void 0;
|
|
17027
17539
|
const conds = conditions;
|
|
17028
17540
|
validateRelationLeaves(resourceKey, conds, op);
|
|
17541
|
+
const parentReads = /* @__PURE__ */ new Map();
|
|
17029
17542
|
const parentIds = async (rel, leaves) => {
|
|
17030
17543
|
const target = RELATION_TARGETS[rel];
|
|
17031
17544
|
const parentConds = buildFilter(leaves.map((l) => ({ ...l, field: l.field.slice(rel.length + 1) }))).filter;
|
|
17032
|
-
const
|
|
17033
|
-
|
|
17034
|
-
|
|
17035
|
-
|
|
17036
|
-
|
|
17037
|
-
|
|
17545
|
+
const key = JSON.stringify([target.path, parentConds], (_key, value) => isRecord2(value) ? Object.fromEntries(Object.keys(value).sort().map((name) => [name, value[name]])) : value);
|
|
17546
|
+
let pending = parentReads.get(key);
|
|
17547
|
+
if (pending === void 0) {
|
|
17548
|
+
pending = (async () => {
|
|
17549
|
+
const res = await boundedPart(http, target.path, parentConds, JOIN_SET_CAP, op, ["id"]);
|
|
17550
|
+
if (res.hasMore) {
|
|
17551
|
+
throw new AutotaskConfigError(
|
|
17552
|
+
`${op}: the ${rel}.* conditions match more than ${JOIN_SET_CAP} ${target.resource} \u2014 the ${resourceKey} query was not issued (a partial ${rel} set would give partial results)`,
|
|
17553
|
+
{ operation: op, suggestedAction: `Narrow the ${rel}.* conditions (e.g. add a ${rel} date or status condition) or filter ${resourceKey} by ${rel}ID directly.` }
|
|
17554
|
+
);
|
|
17555
|
+
}
|
|
17556
|
+
return capJoinSet(res.items.map((r) => Number(r.id)).filter((n) => Number.isFinite(n) && n > 0)).ids;
|
|
17557
|
+
})();
|
|
17558
|
+
parentReads.set(key, pending);
|
|
17038
17559
|
}
|
|
17039
|
-
return
|
|
17560
|
+
return [...await pending];
|
|
17040
17561
|
};
|
|
17041
17562
|
const NEVER = null;
|
|
17563
|
+
const rewriteLeaf = async (c) => {
|
|
17564
|
+
const [rel, field] = c.field.split(".");
|
|
17565
|
+
if (selfPrefixes(resourceKey).includes(rel)) return { ...c, field };
|
|
17566
|
+
const ids2 = await parentIds(rel, [c]);
|
|
17567
|
+
return ids2.length === 0 ? void 0 : { field: `${rel}ID`, op: "in", value: ids2 };
|
|
17568
|
+
};
|
|
17042
17569
|
const rewrite = async (list, mode) => {
|
|
17570
|
+
if (mode === "or" && !list.some((c) => Array.isArray(c.items) && hasRelationConditions(c.items))) {
|
|
17571
|
+
const parts = await mapReadTasks(http, list, (c) => isRelationLeaf(c) ? rewriteLeaf(c) : Promise.resolve(c));
|
|
17572
|
+
const out2 = parts.filter((c) => c !== void 0);
|
|
17573
|
+
return out2.length === 0 ? NEVER : out2;
|
|
17574
|
+
}
|
|
17043
17575
|
const out = [];
|
|
17044
17576
|
const byRel = /* @__PURE__ */ new Map();
|
|
17045
17577
|
for (const c of list) {
|
|
17046
17578
|
if (isRelationLeaf(c)) {
|
|
17047
17579
|
const parts = c.field.split(".");
|
|
17048
|
-
if (parts.length === 2 && selfPrefixes(resourceKey).includes(parts[0])) {
|
|
17049
|
-
|
|
17580
|
+
if (mode === "or" || parts.length === 2 && selfPrefixes(resourceKey).includes(parts[0])) {
|
|
17581
|
+
const leaf = await rewriteLeaf(c);
|
|
17582
|
+
if (leaf !== void 0) out.push(leaf);
|
|
17050
17583
|
continue;
|
|
17051
17584
|
}
|
|
17052
17585
|
const rel = parts[0];
|
|
17053
|
-
|
|
17054
|
-
byRel.set(rel, [...byRel.get(rel) ?? [], c]);
|
|
17055
|
-
continue;
|
|
17056
|
-
}
|
|
17057
|
-
const ids2 = await parentIds(rel, [c]);
|
|
17058
|
-
if (ids2.length > 0) out.push({ field: `${rel}ID`, op: "in", value: ids2 });
|
|
17586
|
+
byRel.set(rel, [...byRel.get(rel) ?? [], c]);
|
|
17059
17587
|
continue;
|
|
17060
17588
|
}
|
|
17061
17589
|
if (isRecord2(c) && (c.op === "and" || c.op === "or") && Array.isArray(c.items) && hasRelationConditions(c.items)) {
|
|
@@ -17092,6 +17620,17 @@ var ROW_FK_TABLES = {
|
|
|
17092
17620
|
billingCodeID: "billingCode"
|
|
17093
17621
|
};
|
|
17094
17622
|
var isResourceFkField = (field) => field === "resourceID" || field.endsWith("ResourceID");
|
|
17623
|
+
function rowNamePlan(rows, resourceKey, picklistFields = []) {
|
|
17624
|
+
const builder = createNamePlan(picklistFields, resourceKey);
|
|
17625
|
+
for (const row of rows) {
|
|
17626
|
+
for (const [field, value] of Object.entries(row)) {
|
|
17627
|
+
const table = ROW_FK_TABLES[field];
|
|
17628
|
+
if (table !== void 0) builder.addFk(table, value);
|
|
17629
|
+
else if (isResourceFkField(field)) builder.addResource(value);
|
|
17630
|
+
}
|
|
17631
|
+
}
|
|
17632
|
+
return builder.plan();
|
|
17633
|
+
}
|
|
17095
17634
|
var LABEL_NAME_MAX_CHARS = 200;
|
|
17096
17635
|
function untrustedName(name) {
|
|
17097
17636
|
if (name === null) return null;
|
|
@@ -17110,8 +17649,8 @@ async function labelRows(client, resourceKey, rows) {
|
|
|
17110
17649
|
for (const row of rows) for (const k of Object.keys(row)) keys.add(k);
|
|
17111
17650
|
if (keys.size === 0) return { rows: [...rows] };
|
|
17112
17651
|
let picklistFields = [];
|
|
17113
|
-
const
|
|
17114
|
-
const candidates = [...keys].filter((f) => f !== "id" &&
|
|
17652
|
+
const modelHas = modelFieldLookup(resourceKey);
|
|
17653
|
+
const candidates = [...keys].filter((f) => f !== "id" && modelHas?.(f) === true && ROW_FK_TABLES[f] === void 0 && !isResourceFkField(f));
|
|
17115
17654
|
if (candidates.length > 0) {
|
|
17116
17655
|
try {
|
|
17117
17656
|
const catalog = await fieldCatalog(client, { resources: [resourceKey], labels: true });
|
|
@@ -17125,16 +17664,7 @@ async function labelRows(client, resourceKey, rows) {
|
|
|
17125
17664
|
}
|
|
17126
17665
|
const labelled = (field) => picklistFields.includes(field) || ROW_FK_TABLES[field] !== void 0 || isResourceFkField(field);
|
|
17127
17666
|
if (![...keys].some(labelled)) return { rows: [...rows] };
|
|
17128
|
-
const
|
|
17129
|
-
for (const row of rows) {
|
|
17130
|
-
for (const [field, value] of Object.entries(row)) {
|
|
17131
|
-
const table = ROW_FK_TABLES[field];
|
|
17132
|
-
if ((value === 0 || value === "0") && table !== "company") continue;
|
|
17133
|
-
if (table !== void 0) builder.addFk(table, value);
|
|
17134
|
-
else if (isResourceFkField(field)) builder.addResource(value);
|
|
17135
|
-
}
|
|
17136
|
-
}
|
|
17137
|
-
const plan = builder.plan();
|
|
17667
|
+
const plan = rowNamePlan(rows, resourceKey, picklistFields);
|
|
17138
17668
|
const names = plan.resourceIds.length === 0 && plan.recordFks.length === 0 && picklistFields.length === 0 ? void 0 : await resolveCompositeNames(client.http, plan);
|
|
17139
17669
|
const out = rows.map((row) => {
|
|
17140
17670
|
const r = { ...row };
|
|
@@ -17162,16 +17692,34 @@ async function labelFetchResults(client, result) {
|
|
|
17162
17692
|
if (r.found && r.value !== null) byResource2.set(r.resource, [...byResource2.get(r.resource) ?? [], i]);
|
|
17163
17693
|
});
|
|
17164
17694
|
const results = [...result.results];
|
|
17695
|
+
const groups = [...byResource2].map(([resource, indices]) => ({ resource, indices, rows: indices.map((i) => results[i].value) }));
|
|
17696
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17697
|
+
let dependent = false;
|
|
17698
|
+
for (const group of groups) {
|
|
17699
|
+
const plan = rowNamePlan(group.rows, group.resource);
|
|
17700
|
+
const targets = [...plan.resourceIds.map((id) => `resource:${String(id)}`), ...plan.recordFks.map((fk2) => `${fk2.table}:${String(fk2.id)}`)];
|
|
17701
|
+
for (const target of targets) {
|
|
17702
|
+
if (seen.has(target)) dependent = true;
|
|
17703
|
+
seen.add(target);
|
|
17704
|
+
}
|
|
17705
|
+
}
|
|
17706
|
+
const labelledGroups = /* @__PURE__ */ new Map();
|
|
17707
|
+
const labelled = await mapReadTasks(
|
|
17708
|
+
dependent ? { maxConcurrent: 1 } : client.http,
|
|
17709
|
+
groups,
|
|
17710
|
+
async (group) => ({ resource: group.resource, result: await labelRows(client, group.resource, group.rows) })
|
|
17711
|
+
);
|
|
17712
|
+
for (const group of labelled) labelledGroups.set(group.resource, group.result);
|
|
17165
17713
|
const notes = [];
|
|
17166
17714
|
const reasons = {};
|
|
17167
17715
|
for (const [resource, indices] of byResource2) {
|
|
17168
|
-
const
|
|
17716
|
+
const labelled2 = labelledGroups.get(resource);
|
|
17169
17717
|
indices.forEach((idx, j) => {
|
|
17170
|
-
results[idx] = { ...results[idx], value:
|
|
17718
|
+
results[idx] = { ...results[idx], value: labelled2.rows[j] };
|
|
17171
17719
|
});
|
|
17172
|
-
if (
|
|
17173
|
-
notes.push(
|
|
17174
|
-
for (const [field, why] of Object.entries(
|
|
17720
|
+
if (labelled2.names !== void 0) {
|
|
17721
|
+
notes.push(labelled2.names.note);
|
|
17722
|
+
for (const [field, why] of Object.entries(labelled2.names.reasons ?? {})) reasons[field] = why;
|
|
17175
17723
|
}
|
|
17176
17724
|
}
|
|
17177
17725
|
if (notes.length === 0) return { ...result, results };
|
|
@@ -17191,6 +17739,12 @@ function validateWalkBag(walk, prefix, details) {
|
|
|
17191
17739
|
return wr;
|
|
17192
17740
|
}
|
|
17193
17741
|
|
|
17742
|
+
// src/operations/query-pages.ts
|
|
17743
|
+
var PREPARE_BOUNDED_QUERY = /* @__PURE__ */ Symbol.for("node-autotask.prepare-bounded-query.v1");
|
|
17744
|
+
function assertPageReadActive(operation) {
|
|
17745
|
+
if (ambientCallerSignal()?.aborted) throw new AutotaskAbortError("Bounded query page consumption aborted by the caller", { operation });
|
|
17746
|
+
}
|
|
17747
|
+
|
|
17194
17748
|
// src/resources/base/query.ts
|
|
17195
17749
|
var QueryBase = class {
|
|
17196
17750
|
httpClient;
|
|
@@ -17365,6 +17919,22 @@ var QueryBase = class {
|
|
|
17365
17919
|
* Pure read; no mutation paths involved.
|
|
17366
17920
|
*/
|
|
17367
17921
|
async queryBounded(params) {
|
|
17922
|
+
return this.boundedQueryResult(params);
|
|
17923
|
+
}
|
|
17924
|
+
/** Internal governed consumer hook; all validation and paging stay shared. @internal */
|
|
17925
|
+
[PREPARE_BOUNDED_QUERY]() {
|
|
17926
|
+
const guard = captureReadGuard(this.http, `${this.config.key}.query`);
|
|
17927
|
+
return {
|
|
17928
|
+
guard,
|
|
17929
|
+
consume: async (params, consume) => {
|
|
17930
|
+
guard();
|
|
17931
|
+
const { items, ...summary } = await this.boundedQueryResult(params, consume);
|
|
17932
|
+
guard();
|
|
17933
|
+
return summary;
|
|
17934
|
+
}
|
|
17935
|
+
};
|
|
17936
|
+
}
|
|
17937
|
+
async boundedQueryResult(params, consume) {
|
|
17368
17938
|
if (Array.isArray(params)) {
|
|
17369
17939
|
throw new AutotaskConfigError(
|
|
17370
17940
|
"queryBounded: params must be an object { filter?, limit?, latest?, includeFields? } \u2014 a bare conditions array is not accepted (wrap it: { filter: [...] })"
|
|
@@ -17411,13 +17981,28 @@ var QueryBase = class {
|
|
|
17411
17981
|
if (latest !== void 0) {
|
|
17412
17982
|
return this.applyNoteChars(await this.latestWalk(walkParams, Math.max(limit, latest), latest), noteChars);
|
|
17413
17983
|
}
|
|
17414
|
-
|
|
17415
|
-
const
|
|
17416
|
-
|
|
17984
|
+
let truncatedFields = 0;
|
|
17985
|
+
const sink = consume === void 0 ? void 0 : async (rows, page) => {
|
|
17986
|
+
const projected = this.applyNoteChars({ items: rows, fetched: rows.length, hasMore: false, pagesWalked: 1 }, noteChars);
|
|
17987
|
+
truncatedFields += projected.noteCharsTruncated ?? 0;
|
|
17988
|
+
assertPageReadActive(`${this.config.key}.query`);
|
|
17989
|
+
try {
|
|
17990
|
+
await consume({ items: projected.items, page });
|
|
17991
|
+
} catch (error) {
|
|
17992
|
+
assertPageReadActive(`${this.config.key}.query`);
|
|
17993
|
+
throw error;
|
|
17994
|
+
}
|
|
17995
|
+
assertPageReadActive(`${this.config.key}.query`);
|
|
17996
|
+
};
|
|
17997
|
+
const { items, fetched, pages: pages2, guard, sliced, cursor, names } = await this.walkBounded(walkParams, cap, limit, labelPages, sink);
|
|
17998
|
+
const hasMore = maxRows === void 0 ? (fetched >= cap || guard) && (sliced > 0 || cursor !== null) : guard || sliced > 0 || cursor !== null;
|
|
17999
|
+
const result = { items, fetched, hasMore, pagesWalked: pages2 };
|
|
17417
18000
|
if (maxRows !== void 0) result.truncated = hasMore;
|
|
17418
18001
|
if (names !== void 0) result.names = names;
|
|
17419
18002
|
this.stampEmptyQueryResult(result, params);
|
|
17420
|
-
return this.applyNoteChars(result, noteChars);
|
|
18003
|
+
if (consume === void 0) return this.applyNoteChars(result, noteChars);
|
|
18004
|
+
if (truncatedFields > 0) result.noteCharsTruncated = truncatedFields;
|
|
18005
|
+
return result;
|
|
17421
18006
|
}
|
|
17422
18007
|
/** Issue #61 (slice A): the noteChars truncation at the SINGLE chokepoint
|
|
17423
18008
|
* of `queryBounded` — the normal walk and the `latest` paths both
|
|
@@ -17446,9 +18031,10 @@ var QueryBase = class {
|
|
|
17446
18031
|
* SOFT stop (never a throw). ONE per-walk closure (walks never share
|
|
17447
18032
|
* state).
|
|
17448
18033
|
* @internal */
|
|
17449
|
-
async walkBounded(p, limit, pageSizeBase, labelPages = false) {
|
|
18034
|
+
async walkBounded(p, limit, pageSizeBase, labelPages = false, consume) {
|
|
17450
18035
|
const state2 = { cursor: null };
|
|
17451
18036
|
const items = [];
|
|
18037
|
+
let fetched = 0;
|
|
17452
18038
|
let pages2 = 0;
|
|
17453
18039
|
let sliced = 0;
|
|
17454
18040
|
let guard = false;
|
|
@@ -17460,6 +18046,7 @@ var QueryBase = class {
|
|
|
17460
18046
|
guard = true;
|
|
17461
18047
|
break;
|
|
17462
18048
|
}
|
|
18049
|
+
if (consume !== void 0) assertPageReadActive(`${this.config.key}.query`);
|
|
17463
18050
|
const page = await this.fetchPage(p, pages2 + 1, pageSize, state2);
|
|
17464
18051
|
pages2 += 1;
|
|
17465
18052
|
if (labelPages && this.http.client !== void 0) {
|
|
@@ -17470,18 +18057,20 @@ var QueryBase = class {
|
|
|
17470
18057
|
Object.assign(nameReasons, labelled.names.reasons);
|
|
17471
18058
|
}
|
|
17472
18059
|
}
|
|
17473
|
-
const remaining = limit -
|
|
18060
|
+
const remaining = limit - fetched;
|
|
17474
18061
|
const take = page.items.slice(0, remaining);
|
|
17475
18062
|
sliced += Math.max(0, page.items.length - remaining);
|
|
17476
|
-
|
|
17477
|
-
if (
|
|
18063
|
+
fetched += take.length;
|
|
18064
|
+
if (consume === void 0) items.push(...take);
|
|
18065
|
+
else await consume(take, pages2);
|
|
18066
|
+
if (fetched >= limit) break;
|
|
17478
18067
|
if (!page.hasMore || page.items.length === 0) break;
|
|
17479
18068
|
}
|
|
17480
18069
|
const names = nameNotes.size === 0 ? void 0 : {
|
|
17481
18070
|
note: [...nameNotes].join("; "),
|
|
17482
18071
|
...Object.keys(nameReasons).length === 0 ? {} : { reasons: nameReasons }
|
|
17483
18072
|
};
|
|
17484
|
-
return { items, pages: pages2, guard, sliced, cursor: state2.cursor, ...names === void 0 ? {} : { names } };
|
|
18073
|
+
return { items, fetched, pages: pages2, guard, sliced, cursor: state2.cursor, ...names === void 0 ? {} : { names } };
|
|
17485
18074
|
}
|
|
17486
18075
|
/** A walk stop is TRUNCATED when the 1000-page guard fired, or the limit
|
|
17487
18076
|
* was met with a live next cursor (or a sliced final page): rows exist
|
|
@@ -17505,7 +18094,7 @@ var QueryBase = class {
|
|
|
17505
18094
|
* speculation).
|
|
17506
18095
|
* @internal */
|
|
17507
18096
|
stampEmptyQueryResult(result, params) {
|
|
17508
|
-
if (result.
|
|
18097
|
+
if (result.fetched !== 0) return;
|
|
17509
18098
|
result.blindSurface = blindStampFor(BLIND_SURFACE_STAMPS[this.config.key]?.query, params?.filter);
|
|
17510
18099
|
const pinnedReason = normalizedConditions(params?.filter) === void 0 ? EMPTY_REASON_STAMPS[this.config.key]?.query : void 0;
|
|
17511
18100
|
if (result.blindSurface !== void 0 || pinnedReason !== void 0) {
|
|
@@ -17741,7 +18330,7 @@ var QueryBase = class {
|
|
|
17741
18330
|
};
|
|
17742
18331
|
|
|
17743
18332
|
// src/resources/base/meta.ts
|
|
17744
|
-
var MetaBase = class extends QueryBase {
|
|
18333
|
+
var MetaBase = class _MetaBase extends QueryBase {
|
|
17745
18334
|
// ------------------------------------------------------------------
|
|
17746
18335
|
// Single-record reads
|
|
17747
18336
|
// ------------------------------------------------------------------
|
|
@@ -17761,8 +18350,8 @@ var MetaBase = class extends QueryBase {
|
|
|
17761
18350
|
return cachedRecordGet(this.http, path, operation, fresh);
|
|
17762
18351
|
}
|
|
17763
18352
|
/**
|
|
17764
|
-
* Entity-metadata read through the
|
|
17765
|
-
*
|
|
18353
|
+
* Entity-metadata read through the default-on field cache (issue #31;
|
|
18354
|
+
* with no fieldCache this is exactly one `http.request` — the
|
|
17766
18355
|
* bit-for-bit uncached trio path). One private helper beside `cachedGet`,
|
|
17767
18356
|
* for the same three reasons the read cache exists: a vendor drift
|
|
17768
18357
|
* (deterministic 500, INVALID_RESPONSE) must not be served stale, repeat
|
|
@@ -17770,7 +18359,9 @@ var MetaBase = class extends QueryBase {
|
|
|
17770
18359
|
* duplicate requests. The UNWRAPPED value is stored (never the raw
|
|
17771
18360
|
* envelope); an EMPTY or FAILED result is never cached (a failure
|
|
17772
18361
|
* rejects before any `set`; an empty is refused by the cache itself);
|
|
17773
|
-
* concurrent callers share
|
|
18362
|
+
* concurrent callers share one wire with independent cancellation and cloned
|
|
18363
|
+
* values; invalidation detaches older reads before they can repopulate
|
|
18364
|
+
* the cache. The drift signal
|
|
17774
18365
|
* (the INVALID_RESPONSE shape drift, the deterministic validation 500)
|
|
17775
18366
|
* invalidates THIS entity's entries so the next call refetches
|
|
17776
18367
|
* (transport-level signals are also invalidated in the transport's own
|
|
@@ -17779,29 +18370,7 @@ var MetaBase = class extends QueryBase {
|
|
|
17779
18370
|
* @internal
|
|
17780
18371
|
*/
|
|
17781
18372
|
async cachedMeta(kind, path, operation, unwrap, fresh = false) {
|
|
17782
|
-
|
|
17783
|
-
if (cache === void 0) {
|
|
17784
|
-
const res = await this.http.request({ method: "GET", path, operation });
|
|
17785
|
-
return unwrap(res);
|
|
17786
|
-
}
|
|
17787
|
-
const key = fieldKey(this.config.key, kind);
|
|
17788
|
-
if (!fresh) {
|
|
17789
|
-
const shared = cache.inflight(key);
|
|
17790
|
-
if (shared !== void 0) return shared;
|
|
17791
|
-
const hit = cache.get(key);
|
|
17792
|
-
if (hit !== void 0) return hit;
|
|
17793
|
-
}
|
|
17794
|
-
const work = this.http.request({ method: "GET", path, operation }).then((body) => {
|
|
17795
|
-
const value = unwrap(body);
|
|
17796
|
-
if (!isEmpty(value)) cache.set(key, value);
|
|
17797
|
-
return value;
|
|
17798
|
-
});
|
|
17799
|
-
work.catch((err) => {
|
|
17800
|
-
if (err instanceof AutotaskError && (err.code === "INVALID_RESPONSE" || err.details?.deterministic === true)) {
|
|
17801
|
-
cache.invalidate(`${this.config.key}:`);
|
|
17802
|
-
}
|
|
17803
|
-
});
|
|
17804
|
-
return cache.track(key, work);
|
|
18373
|
+
return cachedMetadataGet(this.http, this.config.key, kind, path, operation, unwrap, fresh);
|
|
17805
18374
|
}
|
|
17806
18375
|
/** `GET /V1.0/<E>/{id}` → `{ item }` unwrapped (`item: null` → NotFoundError). */
|
|
17807
18376
|
async getGlobal(id, fresh = false) {
|
|
@@ -17908,21 +18477,7 @@ var MetaBase = class extends QueryBase {
|
|
|
17908
18477
|
* entity's entries via the fieldCache's `invalidate` first — the trio
|
|
17909
18478
|
* keeps its no-arg surface (the registry/MCP arity pin). */
|
|
17910
18479
|
async getEntityInfo() {
|
|
17911
|
-
return await this.
|
|
17912
|
-
"info",
|
|
17913
|
-
`${this.resourcePath}/entityInformation`,
|
|
17914
|
-
`${this.config.key}.getEntityInfo`,
|
|
17915
|
-
(res) => {
|
|
17916
|
-
const body = isRecord2(res) ? res : void 0;
|
|
17917
|
-
if (body === void 0 || !isRecord2(body.info)) {
|
|
17918
|
-
throw new AutotaskError("Expected the entityInformation envelope { info }; got a different shape", {
|
|
17919
|
-
code: "INVALID_RESPONSE",
|
|
17920
|
-
category: "server"
|
|
17921
|
-
});
|
|
17922
|
-
}
|
|
17923
|
-
return body.info;
|
|
17924
|
-
}
|
|
17925
|
-
);
|
|
18480
|
+
return await this.metadataRead("info");
|
|
17926
18481
|
}
|
|
17927
18482
|
/** `GET /V1.0/<E>/entityInformation/fields` → `{ fields }` unwrapped.
|
|
17928
18483
|
* Goes through the field cache when it is present (issue #80:
|
|
@@ -17932,12 +18487,7 @@ var MetaBase = class extends QueryBase {
|
|
|
17932
18487
|
* entity's entries via the fieldCache's `invalidate` first — the trio
|
|
17933
18488
|
* keeps its no-arg surface (the registry/MCP arity pin). */
|
|
17934
18489
|
async getFieldInfo() {
|
|
17935
|
-
return await this.
|
|
17936
|
-
"fields",
|
|
17937
|
-
`${this.resourcePath}/entityInformation/fields`,
|
|
17938
|
-
`${this.config.key}.getFieldInfo`,
|
|
17939
|
-
(res) => this.unwrapFields(res, "FieldInformationResultModel")
|
|
17940
|
-
);
|
|
18490
|
+
return await this.metadataRead("fields");
|
|
17941
18491
|
}
|
|
17942
18492
|
/** `GET /V1.0/<E>/entityInformation/userDefinedFields` → `{ fields }` unwrapped.
|
|
17943
18493
|
* Goes through the field cache when it is present (issue #80:
|
|
@@ -17947,12 +18497,29 @@ var MetaBase = class extends QueryBase {
|
|
|
17947
18497
|
* entity's entries via the fieldCache's `invalidate` first — the trio
|
|
17948
18498
|
* keeps its no-arg surface (the registry/MCP arity pin). */
|
|
17949
18499
|
async getUdfInfo() {
|
|
17950
|
-
return await this.
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
);
|
|
18500
|
+
return await this.metadataRead("udf");
|
|
18501
|
+
}
|
|
18502
|
+
/** Capture the owning transport's context; overridden readers keep their original path. @internal */
|
|
18503
|
+
[METADATA_PROJECTION](kind, projector) {
|
|
18504
|
+
const reader = kind === "info" ? "getEntityInfo" : kind === "fields" ? "getFieldInfo" : "getUdfInfo";
|
|
18505
|
+
const guard = captureReadGuard(this.http, `${this.config.key}.${reader}`);
|
|
18506
|
+
guard();
|
|
18507
|
+
if (this[reader] !== _MetaBase.prototype[reader] || this.cachedMeta !== _MetaBase.prototype.cachedMeta) return { guard };
|
|
18508
|
+
return { guard, projected: this.metadataRead(kind, projector) };
|
|
18509
|
+
}
|
|
18510
|
+
metadataRead(kind, projector) {
|
|
18511
|
+
const suffix = kind === "info" ? "" : kind === "fields" ? "/fields" : "/userDefinedFields";
|
|
18512
|
+
const operation = kind === "info" ? "getEntityInfo" : kind === "fields" ? "getFieldInfo" : "getUdfInfo";
|
|
18513
|
+
const path = `${this.resourcePath}/entityInformation${suffix}`;
|
|
18514
|
+
const unwrap = (res) => {
|
|
18515
|
+
if (kind !== "info") return this.unwrapFields(res, kind === "fields" ? "FieldInformationResultModel" : "UserDefinedFieldInformationResultModel");
|
|
18516
|
+
const body = isRecord2(res) ? res : void 0;
|
|
18517
|
+
if (body === void 0 || !isRecord2(body.info)) {
|
|
18518
|
+
throw new AutotaskError("Expected the entityInformation envelope { info }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
18519
|
+
}
|
|
18520
|
+
return body.info;
|
|
18521
|
+
};
|
|
18522
|
+
return projector === void 0 ? this.cachedMeta(kind, path, `${this.config.key}.${operation}`, unwrap) : cachedMetadataGet(this.http, this.config.key, kind, path, `${this.config.key}.${operation}`, unwrap, false, void 0, projector);
|
|
17956
18523
|
}
|
|
17957
18524
|
/** @internal */
|
|
17958
18525
|
unwrapFields(body, envelopeName) {
|
|
@@ -18107,8 +18674,8 @@ var MetaBase = class extends QueryBase {
|
|
|
18107
18674
|
);
|
|
18108
18675
|
}
|
|
18109
18676
|
const leaf = fields.map((field) => ({ field, op: "eq", value }));
|
|
18110
|
-
const
|
|
18111
|
-
const items = await this.queryPage1([
|
|
18677
|
+
const root3 = leaf.length === 1 ? leaf[0] : { op: "or", items: leaf };
|
|
18678
|
+
const items = await this.queryPage1([root3], 2);
|
|
18112
18679
|
if (items.length === 1) {
|
|
18113
18680
|
return { value: items[0], resolutionCost: "server-filter", scanned: 0, scanTruncated: false };
|
|
18114
18681
|
}
|
|
@@ -18275,7 +18842,7 @@ var MetaBase = class extends QueryBase {
|
|
|
18275
18842
|
}
|
|
18276
18843
|
const limit = opts.limit === void 0 ? 25 : clampPageSize(opts.limit);
|
|
18277
18844
|
const leaf = fields.map((field) => ({ field, op: "contains", value: text }));
|
|
18278
|
-
const
|
|
18845
|
+
const root3 = leaf.length === 1 ? leaf[0] : { op: "or", items: leaf };
|
|
18279
18846
|
for (const key of Object.keys(opts)) {
|
|
18280
18847
|
if (key !== "limit" && key !== "companyID" && key !== "includeFields") {
|
|
18281
18848
|
throw new AutotaskConfigError(`search: unknown opts key "${key}" \u2014 the bag is closed: limit, companyID, includeFields`);
|
|
@@ -18289,7 +18856,7 @@ var MetaBase = class extends QueryBase {
|
|
|
18289
18856
|
}
|
|
18290
18857
|
const companyID = opts.companyID === void 0 ? void 0 : Number(opts.companyID);
|
|
18291
18858
|
const includeFields = opts.includeFields === void 0 ? void 0 : opts.includeFields.includes("id") ? opts.includeFields : ["id", ...opts.includeFields];
|
|
18292
|
-
const conditions = companyID === void 0 ? [
|
|
18859
|
+
const conditions = companyID === void 0 ? [root3] : [{ field: "companyID", op: "eq", value: companyID }, root3];
|
|
18293
18860
|
const rows = await this.queryEntity(`${this.resourcePath}/query`, conditions, {
|
|
18294
18861
|
maxRecords: limit,
|
|
18295
18862
|
...includeFields !== void 0 ? { includeFields } : {}
|
|
@@ -18320,11 +18887,6 @@ var MetaBase = class extends QueryBase {
|
|
|
18320
18887
|
return this.searchBase(value, { limit });
|
|
18321
18888
|
}
|
|
18322
18889
|
};
|
|
18323
|
-
function isEmpty(value) {
|
|
18324
|
-
if (value === null || value === void 0) return true;
|
|
18325
|
-
if (Array.isArray(value)) return value.length === 0;
|
|
18326
|
-
return typeof value === "object" && Object.keys(value).length === 0;
|
|
18327
|
-
}
|
|
18328
18890
|
|
|
18329
18891
|
// src/resources/base/mutations.ts
|
|
18330
18892
|
var MutationBase = class extends MetaBase {
|
|
@@ -20562,20 +21124,20 @@ var GenericResource = class extends BaseResource {
|
|
|
20562
21124
|
this.requireHelper("getContext");
|
|
20563
21125
|
const cfg = this.config;
|
|
20564
21126
|
const rootField = cfg.contextRootField ?? this.config.key;
|
|
20565
|
-
const
|
|
20566
|
-
const result = { [rootField]:
|
|
21127
|
+
const root3 = await this.fetchRecordRaw(this.config.resourcePath, id, cfg.contextRootFresh === true);
|
|
21128
|
+
const result = { [rootField]: root3 };
|
|
20567
21129
|
const parts = cfg.contextParts ?? [];
|
|
20568
|
-
const values = await mapReadTasks(this.http, parts, ([, idField, targetPath]) => this.contextFetch(targetPath,
|
|
21130
|
+
const values = await mapReadTasks(this.http, parts, ([, idField, targetPath]) => this.contextFetch(targetPath, root3[idField]));
|
|
20569
21131
|
for (const [i, [name]] of parts.entries()) result[name] = values[i];
|
|
20570
21132
|
if (opts.names === true) {
|
|
20571
21133
|
const builder = createNamePlan();
|
|
20572
21134
|
for (const sib of cfg.nameSiblings ?? []) {
|
|
20573
|
-
const fk2 =
|
|
21135
|
+
const fk2 = root3[sib.field];
|
|
20574
21136
|
if (sib.kind === "resource") builder.addResource(fk2);
|
|
20575
21137
|
else builder.addFk(sib.kind, fk2);
|
|
20576
21138
|
}
|
|
20577
21139
|
const names = await resolveCompositeNames(this.http, builder.plan(), { maxNameReads: opts.maxNameReads });
|
|
20578
|
-
const row = { ...
|
|
21140
|
+
const row = { ...root3 };
|
|
20579
21141
|
for (const sib of cfg.nameSiblings ?? []) {
|
|
20580
21142
|
addNameSibling(row, sib.field, (v) => sib.kind === "resource" ? names.resourceName(v) : names.recordName(sib.kind, v));
|
|
20581
21143
|
}
|
|
@@ -20774,13 +21336,7 @@ async function liveFieldNames(holder) {
|
|
|
20774
21336
|
const reader = holder.getFieldInfo;
|
|
20775
21337
|
if (typeof reader !== "function") return null;
|
|
20776
21338
|
try {
|
|
20777
|
-
|
|
20778
|
-
if (!Array.isArray(rows)) return null;
|
|
20779
|
-
const names = [];
|
|
20780
|
-
for (const row of rows) {
|
|
20781
|
-
if (typeof row.name === "string") names.push(row.name);
|
|
20782
|
-
}
|
|
20783
|
-
return names.length > 0 ? names : null;
|
|
21339
|
+
return await readMetadataProjection(holder, "fields", liveFieldNamesView, () => reader.call(holder));
|
|
20784
21340
|
} catch (err) {
|
|
20785
21341
|
if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
20786
21342
|
return null;
|
|
@@ -20855,12 +21411,14 @@ function readIncludeNames(record, includeFields) {
|
|
|
20855
21411
|
return names;
|
|
20856
21412
|
}
|
|
20857
21413
|
function resolveAuthority(record, live) {
|
|
20858
|
-
if (live !== null) return { known: live, authority: "the tenant's live entity field metadata" };
|
|
21414
|
+
if (live !== null) return { known: live.names, authority: "the tenant's live entity field metadata", hasField: (name) => live.known.has(name) };
|
|
20859
21415
|
const vendored = MODEL_FIELD_SETS[record.resource];
|
|
21416
|
+
const modelHas = modelFieldLookup(record.resource);
|
|
20860
21417
|
const liveOnlyExempt = Array.isArray(record.metadata?.liveOnlyFields) ? record.metadata.liveOnlyFields : [];
|
|
20861
|
-
if (vendored === void 0) return void 0;
|
|
21418
|
+
if (vendored === void 0 || modelHas === void 0) return void 0;
|
|
20862
21419
|
return {
|
|
20863
21420
|
known: [...vendored, ...liveOnlyExempt],
|
|
21421
|
+
hasField: (name) => modelHas(name) || liveOnlyExempt.includes(name),
|
|
20864
21422
|
authority: liveOnlyExempt.length > 0 ? "the vendored spec (src/field-sets.ts) + the plan-pinned live-only fields (exempt from the vendored refusal)" : "the vendored spec (src/field-sets.ts)"
|
|
20865
21423
|
};
|
|
20866
21424
|
}
|
|
@@ -20910,46 +21468,22 @@ async function findUnknownFieldNames(record, holder, lists) {
|
|
|
20910
21468
|
const resolved = resolveAuthority(record, await liveFieldNames(holder));
|
|
20911
21469
|
if (resolved === void 0) return void 0;
|
|
20912
21470
|
const unknown = {};
|
|
20913
|
-
for (const [key, names] of Object.entries(lists)) unknown[key] = [...new Set(names.filter((name) => !resolved.
|
|
20914
|
-
return {
|
|
21471
|
+
for (const [key, names] of Object.entries(lists)) unknown[key] = [...new Set(names.filter((name) => !resolved.hasField(name)))];
|
|
21472
|
+
return { known: resolved.known, authority: resolved.authority, unknown };
|
|
20915
21473
|
}
|
|
20916
21474
|
|
|
20917
21475
|
// src/resources/special/_shared/ticketStatus.ts
|
|
20918
21476
|
var ASSUMED_CLOSED_STATUS_ID = 5;
|
|
20919
21477
|
var CLOSED_STATUS_LABELS = ["complete", "completed", "closed", "cancelled", "canceled", "resolved"];
|
|
20920
21478
|
var OP = "tickets.statusSemantics";
|
|
20921
|
-
function picklistOf(fields) {
|
|
20922
|
-
if (!Array.isArray(fields)) return [];
|
|
20923
|
-
const status = fields.find((f) => typeof f?.name === "string" && f.name.toLowerCase() === "status");
|
|
20924
|
-
if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
|
|
20925
|
-
const out = [];
|
|
20926
|
-
for (const v of status.picklistValues) {
|
|
20927
|
-
const id = Number(v?.value);
|
|
20928
|
-
if (!Number.isSafeInteger(id)) continue;
|
|
20929
|
-
out.push({ id, label: typeof v.label === "string" ? v.label : "" });
|
|
20930
|
-
}
|
|
20931
|
-
return out;
|
|
20932
|
-
}
|
|
20933
21479
|
async function readFields(http, fresh) {
|
|
20934
|
-
|
|
20935
|
-
const key = fieldKey("tickets", "fields");
|
|
20936
|
-
if (!fresh && cache !== void 0) {
|
|
20937
|
-
const shared = cache.inflight(key);
|
|
20938
|
-
if (shared !== void 0) return await shared;
|
|
20939
|
-
const hit = cache.get(key);
|
|
20940
|
-
if (hit !== void 0) return hit;
|
|
20941
|
-
}
|
|
20942
|
-
const epoch = cache?.epoch;
|
|
20943
|
-
const work = (async () => {
|
|
20944
|
-
const res = await http.request({ method: "GET", path: "/V1.0/Tickets/entityInformation/fields", operation: OP, maxRetries: 0 });
|
|
21480
|
+
return cachedMetadataGet(http, "tickets", "fields", "/V1.0/Tickets/entityInformation/fields", OP, (res) => {
|
|
20945
21481
|
const fields = res?.fields;
|
|
20946
21482
|
if (!Array.isArray(fields)) {
|
|
20947
21483
|
throw new AutotaskError("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
20948
21484
|
}
|
|
20949
|
-
if (fields.length > 0) cache?.set(key, fields, epoch);
|
|
20950
21485
|
return fields;
|
|
20951
|
-
})
|
|
20952
|
-
return cache !== void 0 && !fresh ? cache.track(key, work) : work;
|
|
21486
|
+
}, fresh, 0, ticketStatusFieldsView);
|
|
20953
21487
|
}
|
|
20954
21488
|
function assumed(allowAssumed, operation) {
|
|
20955
21489
|
if (!allowAssumed) {
|
|
@@ -20986,7 +21520,7 @@ async function resolveTicketStatusSemantics(http, opts = {}, operation = OP) {
|
|
|
20986
21520
|
if (e instanceof AutotaskError && e.code === "ABORTED") throw e;
|
|
20987
21521
|
return assumed(allowAssumed, operation);
|
|
20988
21522
|
}
|
|
20989
|
-
const picklist =
|
|
21523
|
+
const picklist = ticketStatusView(fields);
|
|
20990
21524
|
const closedIds = picklist.filter((v) => CLOSED_STATUS_LABELS.includes(v.label.trim().toLowerCase())).map((v) => v.id);
|
|
20991
21525
|
if (closedIds.length === 0) return assumed(allowAssumed, operation);
|
|
20992
21526
|
const labels = picklist.filter((v) => closedIds.includes(v.id)).map((v) => `${v.id} ${v.label}`).join(", ");
|
|
@@ -21039,7 +21573,8 @@ function validateProjection(fields) {
|
|
|
21039
21573
|
const names = [...new Set(list)];
|
|
21040
21574
|
const entity = PART_ENTITY[part];
|
|
21041
21575
|
const known = MODEL_FIELD_SETS[entity] ?? [];
|
|
21042
|
-
const
|
|
21576
|
+
const hasField = modelFieldLookup(entity);
|
|
21577
|
+
const unknown = names.filter((n) => hasField?.(n) !== true);
|
|
21043
21578
|
if (unknown.length > 0) {
|
|
21044
21579
|
throw new AutotaskConfigError(
|
|
21045
21580
|
`fullProfile: fields.${part} has unknown field name(s) ${formatUnknownNameList(unknown)} against the vendored spec for ${entity} (${known.length} fields; operations.fieldCatalog resources: ["${entity}"] lists the live set) \u2014 no request was issued`
|
|
@@ -21310,7 +21845,7 @@ async function prepareCrmWrite(resource, input) {
|
|
|
21310
21845
|
if (input.intent === "create_company" && status !== "matched") {
|
|
21311
21846
|
const eff = effectiveRequiredFields(null, RELATIONSHIP_MAP.companies?.zoneFacts);
|
|
21312
21847
|
const research = (f) => ["companyType", "ownerResourceID", "countryID"].includes(f) ? "lookup" : "web_if_available_else_ask";
|
|
21313
|
-
const
|
|
21848
|
+
const lookups2 = {
|
|
21314
21849
|
companyType: { via: "operations.fieldCatalog", resource: "companies", field: "companyType", labels: true, note: "map the user wording to one returned label; never hardcode ids" },
|
|
21315
21850
|
ownerResourceID: { via: "resources.get / the staff resolver", note: "owners cannot be enumerated on a blind surface: take a known resource id and confirm it with resources.get" },
|
|
21316
21851
|
countryID: { via: "countries.query", note: "resolve the country name to an id; never guess" }
|
|
@@ -21321,7 +21856,7 @@ async function prepareCrmWrite(resource, input) {
|
|
|
21321
21856
|
];
|
|
21322
21857
|
for (const [f, source] of wanted) {
|
|
21323
21858
|
if (has(co[f]) || needsInput.some((n) => n.field === f)) continue;
|
|
21324
|
-
needsInput.push({ field: f, why: source === "policy" ? `CRM policy: a new company needs ${f} (the vendor auto-creates a "Primary Address" location from it)` : `the vendor requires ${f} to create a company`, source, ...
|
|
21859
|
+
needsInput.push({ field: f, why: source === "policy" ? `CRM policy: a new company needs ${f} (the vendor auto-creates a "Primary Address" location from it)` : `the vendor requires ${f} to create a company`, source, ...lookups2[f] ? { lookup: lookups2[f] } : {}, research: research(f) });
|
|
21325
21860
|
}
|
|
21326
21861
|
}
|
|
21327
21862
|
if (input.intent === "add_contact") {
|
|
@@ -21876,10 +22411,10 @@ var CompaniesResource = class extends GenericResource {
|
|
|
21876
22411
|
* fetch; no sub-lists; absent/dangling references come back null). */
|
|
21877
22412
|
async getContext(id) {
|
|
21878
22413
|
const company = await this.fetchRecordRaw("/V1.0/Companies", id);
|
|
21879
|
-
const
|
|
22414
|
+
const root3 = company;
|
|
21880
22415
|
const [ownerResource, parentCompany] = await readTasks(this.http, [
|
|
21881
|
-
() => this.contextFetch("/V1.0/Resources",
|
|
21882
|
-
() => this.contextFetch("/V1.0/Companies",
|
|
22416
|
+
() => this.contextFetch("/V1.0/Resources", root3["ownerResourceID"]),
|
|
22417
|
+
() => this.contextFetch("/V1.0/Companies", root3["parentCompanyID"])
|
|
21883
22418
|
]);
|
|
21884
22419
|
return { company, ownerResource, parentCompany };
|
|
21885
22420
|
}
|
|
@@ -22147,6 +22682,14 @@ var DEFAULT_LIMIT2 = 25;
|
|
|
22147
22682
|
function resourceFor(client, key) {
|
|
22148
22683
|
return client[camelKey(key)];
|
|
22149
22684
|
}
|
|
22685
|
+
function searchable(client, key) {
|
|
22686
|
+
const holder = resourceFor(client, key);
|
|
22687
|
+
return holder !== void 0 && typeof holder.search === "function" && (typeof holder.hasSearch !== "function" || holder.hasSearch()) ? holder : void 0;
|
|
22688
|
+
}
|
|
22689
|
+
async function searchRows(holder, text, limit) {
|
|
22690
|
+
const matches = await holder.search(text, { limit });
|
|
22691
|
+
return Array.isArray(matches) ? matches.filter((m) => typeof m === "object" && m !== null) : [];
|
|
22692
|
+
}
|
|
22150
22693
|
async function searchAcrossResources(client, query, opts = {}) {
|
|
22151
22694
|
const text = query.trim();
|
|
22152
22695
|
if (text === "") {
|
|
@@ -22163,12 +22706,23 @@ async function searchAcrossResources(client, query, opts = {}) {
|
|
|
22163
22706
|
}
|
|
22164
22707
|
const results = [];
|
|
22165
22708
|
const skipped = [];
|
|
22709
|
+
if (totalLimit === void 0) {
|
|
22710
|
+
const completed = await mapReadTasks(client.http, keys, async (key) => {
|
|
22711
|
+
const holder = searchable(client, key);
|
|
22712
|
+
return holder === void 0 ? void 0 : { resource: key, matches: await searchRows(holder, text, limit) };
|
|
22713
|
+
});
|
|
22714
|
+
completed.forEach((row, i) => {
|
|
22715
|
+
if (row === void 0) skipped.push(keys[i]);
|
|
22716
|
+
else results.push(row);
|
|
22717
|
+
});
|
|
22718
|
+
return { query: text, results, skipped };
|
|
22719
|
+
}
|
|
22166
22720
|
const notSearched = [];
|
|
22167
|
-
let remaining = totalLimit
|
|
22721
|
+
let remaining = totalLimit;
|
|
22168
22722
|
let hitQuota = false;
|
|
22169
22723
|
for (const key of keys) {
|
|
22170
|
-
const holder =
|
|
22171
|
-
if (holder === void 0
|
|
22724
|
+
const holder = searchable(client, key);
|
|
22725
|
+
if (holder === void 0) {
|
|
22172
22726
|
skipped.push(key);
|
|
22173
22727
|
continue;
|
|
22174
22728
|
}
|
|
@@ -22177,14 +22731,12 @@ async function searchAcrossResources(client, query, opts = {}) {
|
|
|
22177
22731
|
continue;
|
|
22178
22732
|
}
|
|
22179
22733
|
const ask = Math.min(limit, remaining);
|
|
22180
|
-
const
|
|
22181
|
-
|
|
22182
|
-
if (totalLimit !== void 0) rows.length = Math.min(rows.length, ask);
|
|
22734
|
+
const rows = await searchRows(holder, text, ask);
|
|
22735
|
+
rows.length = Math.min(rows.length, ask);
|
|
22183
22736
|
results.push({ resource: key, matches: rows });
|
|
22184
22737
|
remaining -= rows.length;
|
|
22185
22738
|
if (rows.length === ask) hitQuota = true;
|
|
22186
22739
|
}
|
|
22187
|
-
if (totalLimit === void 0) return { query: text, results, skipped };
|
|
22188
22740
|
return { query: text, results, skipped, notSearched, truncated: notSearched.length > 0 || hitQuota };
|
|
22189
22741
|
}
|
|
22190
22742
|
|
|
@@ -22216,11 +22768,10 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
22216
22768
|
}
|
|
22217
22769
|
const configuredCap = Math.min(client.config?.resolution?.maxScanRecords ?? 500, 500);
|
|
22218
22770
|
const limit = Math.min(opts.limit ?? configuredCap, configuredCap);
|
|
22219
|
-
const results =
|
|
22220
|
-
for (const key of keys) {
|
|
22771
|
+
const results = await mapReadTasks(client.http, keys, async (key) => {
|
|
22221
22772
|
const holder = resourceFor2(client, key);
|
|
22222
22773
|
if (holder === void 0 || typeof holder.resolveDetailed !== "function") {
|
|
22223
|
-
|
|
22774
|
+
return {
|
|
22224
22775
|
resource: key,
|
|
22225
22776
|
value: null,
|
|
22226
22777
|
resolutionCost: missCost(identifier),
|
|
@@ -22228,8 +22779,7 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
22228
22779
|
scanTruncated: false,
|
|
22229
22780
|
candidates: [],
|
|
22230
22781
|
error: "NO_RESOLVE"
|
|
22231
|
-
}
|
|
22232
|
-
continue;
|
|
22782
|
+
};
|
|
22233
22783
|
}
|
|
22234
22784
|
try {
|
|
22235
22785
|
const r = await holder.resolveDetailed(identifier);
|
|
@@ -22241,7 +22791,7 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
22241
22791
|
scanTruncated: r.scanTruncated,
|
|
22242
22792
|
candidates: (r.candidates ?? []).map((c) => c.id)
|
|
22243
22793
|
};
|
|
22244
|
-
|
|
22794
|
+
return outcome;
|
|
22245
22795
|
} catch (err) {
|
|
22246
22796
|
let code;
|
|
22247
22797
|
let candidates = [];
|
|
@@ -22256,7 +22806,7 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
22256
22806
|
} else {
|
|
22257
22807
|
throw err;
|
|
22258
22808
|
}
|
|
22259
|
-
|
|
22809
|
+
return {
|
|
22260
22810
|
resource: key,
|
|
22261
22811
|
value: null,
|
|
22262
22812
|
resolutionCost: missCost(identifier),
|
|
@@ -22264,9 +22814,9 @@ async function resolveAny(client, identifier, opts = {}) {
|
|
|
22264
22814
|
scanTruncated: code === "RESOLUTION_TRUNCATED",
|
|
22265
22815
|
candidates,
|
|
22266
22816
|
error: code
|
|
22267
|
-
}
|
|
22817
|
+
};
|
|
22268
22818
|
}
|
|
22269
|
-
}
|
|
22819
|
+
});
|
|
22270
22820
|
const cleanMiss = results.every((r) => r.value === null && r.candidates.length === 0 && !r.scanTruncated && (r.error === void 0 || r.error === "NOT_FOUND"));
|
|
22271
22821
|
if (match === "auto" && typeof identifier === "string" && !/^\d+$/.test(identifier.trim()) && cleanMiss) {
|
|
22272
22822
|
const contains = await searchAcrossResources(client, identifier, { resources: keys, limit });
|
|
@@ -22833,6 +23383,7 @@ var shortName = (operation) => operation.split(".").pop() ?? operation;
|
|
|
22833
23383
|
// src/operations/fetchByIds.ts
|
|
22834
23384
|
var FETCH_BY_IDS_MAX_ITEMS = 500;
|
|
22835
23385
|
var FETCH_BY_IDS_CHUNK_SIZE = 250;
|
|
23386
|
+
var itemKey = (resource, id) => `${resource}:${String(id)}`;
|
|
22836
23387
|
function project2(value, fields) {
|
|
22837
23388
|
const out = {};
|
|
22838
23389
|
for (const f of fields) {
|
|
@@ -22886,7 +23437,8 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
|
|
|
22886
23437
|
}
|
|
22887
23438
|
const resourceKey = item.resource;
|
|
22888
23439
|
const fields = MODEL_FIELD_SETS[resourceKey];
|
|
22889
|
-
|
|
23440
|
+
const hasField = modelFieldLookup(resourceKey);
|
|
23441
|
+
if (fields === void 0 || hasField === void 0) {
|
|
22890
23442
|
problems.push(
|
|
22891
23443
|
`${at}.resource: "${resourceKey}" is not a single-record GETtable resource (${Object.keys(MODEL_FIELD_SETS).length} known) \u2014 see autotask_catalog for the exact plan keys`
|
|
22892
23444
|
);
|
|
@@ -22921,7 +23473,7 @@ function validateFetchManyItems(items, cap, opName = "fetchByIds", capRef = `FET
|
|
|
22921
23473
|
continue;
|
|
22922
23474
|
}
|
|
22923
23475
|
for (const f of item.fields) {
|
|
22924
|
-
if (!
|
|
23476
|
+
if (!hasField(f)) {
|
|
22925
23477
|
problems.push(
|
|
22926
23478
|
`${at}.fields: "${f}" is not a field of ${resourceKey} \u2014 a hallucinated field is a shape error, not a silent projection-miss (exact vendor field names via operations.fieldCatalog)`
|
|
22927
23479
|
);
|
|
@@ -22961,7 +23513,7 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
22961
23513
|
groups.set(item.resource, g);
|
|
22962
23514
|
}
|
|
22963
23515
|
const byKey2 = /* @__PURE__ */ new Map();
|
|
22964
|
-
|
|
23516
|
+
const plans = [...groups].map(([key, group]) => {
|
|
22965
23517
|
const holder = client[camelKey(key)];
|
|
22966
23518
|
if (holder === void 0) {
|
|
22967
23519
|
throw new AutotaskConfigError(`fetchByIds: the client exposes no accessor for resource "${key}"`, {
|
|
@@ -22979,7 +23531,10 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
22979
23531
|
}
|
|
22980
23532
|
}
|
|
22981
23533
|
const includeFields = group.anyFields && group.indices.every((i) => items[i].fields !== void 0) ? [...group.fields] : void 0;
|
|
22982
|
-
const kOf = (id) =>
|
|
23534
|
+
const kOf = (id) => itemKey(key, id);
|
|
23535
|
+
return { key, holder, resourcePath, unique, includeFields, kOf };
|
|
23536
|
+
});
|
|
23537
|
+
await mapReadTasks(client.http, plans, async ({ key, resourcePath, unique, includeFields, kOf }) => {
|
|
22983
23538
|
const foundRows = await fetchIdChunks(client.http, resourcePath, unique, includeFields, `${key}.fetchByIds`, {
|
|
22984
23539
|
chunkSize: FETCH_BY_IDS_CHUNK_SIZE,
|
|
22985
23540
|
maxRecords: FETCH_BY_IDS_CHUNK_SIZE,
|
|
@@ -22998,30 +23553,30 @@ async function fetchByIds(client, items, opts = {}) {
|
|
|
22998
23553
|
const q = kOf(k);
|
|
22999
23554
|
if (!byKey2.has(q)) byKey2.set(q, { found: true, value: row });
|
|
23000
23555
|
}
|
|
23001
|
-
|
|
23002
|
-
|
|
23003
|
-
|
|
23004
|
-
|
|
23005
|
-
|
|
23006
|
-
|
|
23007
|
-
|
|
23008
|
-
|
|
23009
|
-
|
|
23010
|
-
|
|
23011
|
-
|
|
23012
|
-
|
|
23013
|
-
|
|
23014
|
-
|
|
23015
|
-
|
|
23016
|
-
|
|
23556
|
+
});
|
|
23557
|
+
const missing = plans.flatMap((plan) => plan.unique.filter((id) => !byKey2.has(plan.kOf(id))).map((id) => ({ plan, id })));
|
|
23558
|
+
await mapReadTasks(client.http, missing, async ({ plan: { holder, kOf }, id }) => {
|
|
23559
|
+
const k = kOf(id);
|
|
23560
|
+
try {
|
|
23561
|
+
const value = await holder.get(id);
|
|
23562
|
+
byKey2.set(k, { found: true, value });
|
|
23563
|
+
} catch (err) {
|
|
23564
|
+
if (err instanceof NotFoundError) {
|
|
23565
|
+
byKey2.set(k, { found: false, value: null, error: { code: "NOT_FOUND", message: err.message } });
|
|
23566
|
+
} else if (isAutotaskError(err) && err.code !== "ABORTED") {
|
|
23567
|
+
const e = { code: err.code, message: err.message };
|
|
23568
|
+
if (err.httpStatus !== void 0) e.httpStatus = err.httpStatus;
|
|
23569
|
+
byKey2.set(k, { found: false, value: null, error: e });
|
|
23570
|
+
} else {
|
|
23571
|
+
throw err;
|
|
23017
23572
|
}
|
|
23018
23573
|
}
|
|
23019
|
-
}
|
|
23574
|
+
});
|
|
23020
23575
|
const results = [];
|
|
23021
23576
|
for (let i = 0; i < items.length; i += 1) {
|
|
23022
23577
|
const item = items[i];
|
|
23023
23578
|
const id = canonical[i];
|
|
23024
|
-
const out = byKey2.get(
|
|
23579
|
+
const out = byKey2.get(itemKey(item.resource, id));
|
|
23025
23580
|
const value = out.found ? item.fields !== void 0 ? project2(out.value, item.fields) : out.value : null;
|
|
23026
23581
|
results.push(
|
|
23027
23582
|
out.found ? { resource: item.resource, id, found: true, value } : { resource: item.resource, id, found: false, value: null, error: out.error }
|
|
@@ -24363,17 +24918,17 @@ async function fetchCharges(ctx) {
|
|
|
24363
24918
|
const raw = await ctx.readPart("/V1.0/ContractCharges/query", chargesCond, ["id", "chargeType", "billableAmount", "extendedCost", "unitCost", "unitPrice", "unitQuantity", "datePurchased", "isBilled", "status", "contractServiceID"]);
|
|
24364
24919
|
return { charges: raw.items, chargesPart: stampPart("contract_charges", raw, chargesCond) };
|
|
24365
24920
|
}
|
|
24366
|
-
async function fetchBlocks(ctx,
|
|
24367
|
-
if (!
|
|
24921
|
+
async function fetchBlocks(ctx, root3) {
|
|
24922
|
+
if (!root3.isBlockHours) {
|
|
24368
24923
|
return skipPart(
|
|
24369
|
-
|
|
24924
|
+
root3.contractTypeKnown ? `skipped: not a Block Hours contract (contractType ${root3.contractType} "${root3.contractTypeLabel}") \u2014 included hours apply to hour blocks only (zero wire)` : `skipped: the contract type is unknown (contractType ${root3.contractType || "absent"}; label unresolved) \u2014 included hours are not evaluable (zero wire)`
|
|
24370
24925
|
);
|
|
24371
24926
|
}
|
|
24372
24927
|
const blocksCond = [{ field: "contractID", op: "eq", value: ctx.id }];
|
|
24373
24928
|
const raw = await ctx.readPart("/V1.0/ContractBlocks/query", blocksCond, ["id", "datePurchased", "startDate", "endDate", "hours", "hoursApproved", "status", "isPaid"]);
|
|
24374
24929
|
return stampPart("contract_blocks", raw, blocksCond);
|
|
24375
24930
|
}
|
|
24376
|
-
async function fetchContractState(ctx,
|
|
24931
|
+
async function fetchContractState(ctx, root3) {
|
|
24377
24932
|
const servicesCond = [{ field: "contractID", op: "eq", value: ctx.id }];
|
|
24378
24933
|
const unitsCond = [{ field: "contractID", op: "eq", value: ctx.id }, ...ctx.windowOn("startDate")];
|
|
24379
24934
|
const roleCostsCond = [{ field: "contractID", op: "eq", value: ctx.id }];
|
|
@@ -24384,7 +24939,7 @@ async function fetchContractState(ctx, root2) {
|
|
|
24384
24939
|
() => fetchCharges(ctx),
|
|
24385
24940
|
() => ctx.readPart("/V1.0/ContractRoleCosts/query", roleCostsCond, ["id", "rate", "resourceID", "roleID"]),
|
|
24386
24941
|
() => ctx.readPart("/V1.0/ContractRates/query", ratesCond, ["id", "roleID", "contractHourlyRate", "internalCurrencyContractHourlyRate"]),
|
|
24387
|
-
() => fetchBlocks(ctx,
|
|
24942
|
+
() => fetchBlocks(ctx, root3)
|
|
24388
24943
|
]);
|
|
24389
24944
|
return { servicesRaw, servicesCond, unitRows: units.rows, unitsPartRaw: units.part, chargesPart, charges, roleCostsRaw, roleCostsCond, ratesRaw, ratesCond, blocksPart };
|
|
24390
24945
|
}
|
|
@@ -24749,7 +25304,7 @@ async function fetchSubscriptionsJoin(ctx) {
|
|
|
24749
25304
|
|
|
24750
25305
|
// src/resources/special/contracts/profitability.data.ts
|
|
24751
25306
|
async function gather(ctx) {
|
|
24752
|
-
const
|
|
25307
|
+
const root3 = await fetchRoot(ctx);
|
|
24753
25308
|
const stages = Object.fromEntries(
|
|
24754
25309
|
["state", "billing", "time", "activity", "open", "res", "join", "subs"].map((name) => [name, forkFetchCtx(ctx)])
|
|
24755
25310
|
);
|
|
@@ -24760,7 +25315,7 @@ async function gather(ctx) {
|
|
|
24760
25315
|
let openRead;
|
|
24761
25316
|
const openTask = () => openRead ??= fetchOpenTickets(stages.open);
|
|
24762
25317
|
const tasks = {
|
|
24763
|
-
state: () => fetchContractState(stages.state,
|
|
25318
|
+
state: () => fetchContractState(stages.state, root3),
|
|
24764
25319
|
billing: () => fetchBilling(stages.billing),
|
|
24765
25320
|
time: timeTask,
|
|
24766
25321
|
activity: activityTask,
|
|
@@ -24779,7 +25334,7 @@ async function gather(ctx) {
|
|
|
24779
25334
|
const completed = await mapReadTasks(ctx.http, order, async (name) => [name, await tasks[name]()]);
|
|
24780
25335
|
const parts = Object.fromEntries(completed);
|
|
24781
25336
|
mergeFetchContexts(ctx, Object.values(stages));
|
|
24782
|
-
return { root:
|
|
25337
|
+
return { root: root3, ...parts };
|
|
24783
25338
|
}
|
|
24784
25339
|
function stampListParts(v, f) {
|
|
24785
25340
|
const { state: state2, activity, join } = f;
|
|
@@ -27527,25 +28082,46 @@ async function requireReadBack(record, operation, opts) {
|
|
|
27527
28082
|
}
|
|
27528
28083
|
var PRE_REQUEST_VALIDATORS = [
|
|
27529
28084
|
(c) => governPreRequest(c.record, c.operation, c.opts),
|
|
28085
|
+
(c) => {
|
|
28086
|
+
if (!c.streaming) return;
|
|
28087
|
+
if (!c.boundedQuery) throw new AutotaskConfigError("invokeReadPages: only primitive query reads support bounded page consumption", { operation: c.operation });
|
|
28088
|
+
const holder = c.holder;
|
|
28089
|
+
const prepare2 = holder[PREPARE_BOUNDED_QUERY];
|
|
28090
|
+
if (typeof prepare2 !== "function") {
|
|
28091
|
+
throw new AutotaskConfigError("invokeReadPages: the resource does not support governed bounded page consumption", { operation: c.operation });
|
|
28092
|
+
}
|
|
28093
|
+
const session = prepare2.call(holder);
|
|
28094
|
+
if (typeof session?.guard !== "function" || typeof session.consume !== "function") throw new AutotaskConfigError("invokeReadPages: the resource has no scoped page consumer", { operation: c.operation });
|
|
28095
|
+
c.pageSession = session;
|
|
28096
|
+
session.guard();
|
|
28097
|
+
},
|
|
27530
28098
|
(c) => requireReadBack(c.record, c.operation, c.opts),
|
|
27531
28099
|
(c) => validateDispatchArgs(c.record, c.args),
|
|
27532
28100
|
(c) => validateParamsBag(c.record, c.args),
|
|
27533
28101
|
(c) => validateFreshSpelling(c.record, c.args),
|
|
28102
|
+
(c) => {
|
|
28103
|
+
if (!c.streaming) return;
|
|
28104
|
+
const bag = c.args[0];
|
|
28105
|
+
if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
|
|
28106
|
+
throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
|
|
28107
|
+
}
|
|
28108
|
+
},
|
|
27534
28109
|
(c) => c.boundedQuery || c.countedQuery ? validateQueryFieldNames(c.record, c.holder, c.args) : Promise.resolve(void 0)
|
|
27535
28110
|
];
|
|
27536
28111
|
async function runPreRequestPass(ctx) {
|
|
27537
28112
|
for (const step of PRE_REQUEST_VALIDATORS) await step(ctx);
|
|
27538
28113
|
}
|
|
27539
|
-
async function
|
|
28114
|
+
async function prepareInvocation(client, operation, argsIn, opts, streaming = false) {
|
|
27540
28115
|
const record = await resolveRecord(operation);
|
|
27541
28116
|
const args = resolveDispatchArgs(record, argsIn);
|
|
27542
28117
|
const boundedQuery = record.kind === "primitive" && record.operation === "query";
|
|
27543
28118
|
const countedQuery = record.kind === "primitive" && record.operation === "count";
|
|
27544
28119
|
const holder = resolveHolder(client, record, operation);
|
|
27545
|
-
|
|
28120
|
+
const context = { record, operation, args, opts, client, holder, boundedQuery, countedQuery, streaming };
|
|
28121
|
+
await runPreRequestPass(context);
|
|
27546
28122
|
const labelQuery = boundedQuery && readNamesOpt(client, args[0]?.["names"], `invoke: "${record.id}" params bag`);
|
|
27547
28123
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
27548
|
-
const method = holder[methodName];
|
|
28124
|
+
const method = streaming ? context.pageSession?.consume : holder[methodName];
|
|
27549
28125
|
if (typeof method !== "function") {
|
|
27550
28126
|
throw new AutotaskConfigError(
|
|
27551
28127
|
`invoke: "${record.resource}.${methodName}" is not a callable method on the client`,
|
|
@@ -27561,6 +28137,10 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
27561
28137
|
if (boundedQuery && args[0]?.["acknowledgeUnscoped"] !== true) {
|
|
27562
28138
|
scopeNote = (await guardUnscopedQueryWalk(holder, record.id, args[0])).note;
|
|
27563
28139
|
}
|
|
28140
|
+
return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
|
|
28141
|
+
}
|
|
28142
|
+
async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
28143
|
+
const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
|
|
27564
28144
|
const result = await method.apply(holder, callArgs);
|
|
27565
28145
|
if (labelQuery && args[0]?.["walk"] === void 0 && Array.isArray(result?.items)) {
|
|
27566
28146
|
const bounded = result;
|
|
@@ -27576,6 +28156,15 @@ async function invoke(client, operation, args = [], opts = {}) {
|
|
|
27576
28156
|
async function invokeRead(client, operation, args = [], opts = {}) {
|
|
27577
28157
|
return invokeMode(client, operation, args, { ...opts, mode: "read" });
|
|
27578
28158
|
}
|
|
28159
|
+
async function invokeReadPages(client, operation, args, onPage, opts = {}) {
|
|
28160
|
+
if (typeof onPage !== "function") throw new AutotaskConfigError("invokeReadPages: onPage must be a function", { operation });
|
|
28161
|
+
const prepared = await prepareInvocation(client, operation, args, { ...opts, mode: "read" }, true);
|
|
28162
|
+
prepared.pageSession.guard();
|
|
28163
|
+
const consume = prepared.method;
|
|
28164
|
+
const result = await consume.call(prepared.holder, prepared.callArgs[0], onPage);
|
|
28165
|
+
prepared.pageSession.guard();
|
|
28166
|
+
return prepared.scopeNote === void 0 ? result : { ...result, scopeNote: prepared.scopeNote };
|
|
28167
|
+
}
|
|
27579
28168
|
async function invokeWrite(client, operation, args = [], opts = {}) {
|
|
27580
28169
|
return invokeMode(client, operation, args, { ...opts, mode: "write" });
|
|
27581
28170
|
}
|
|
@@ -27644,7 +28233,7 @@ async function fullProfile2(resource, id, opts = {}) {
|
|
|
27644
28233
|
const serviceLimit = compositePartLimit(opts.serviceLimit, "serviceLimit", OP12);
|
|
27645
28234
|
const billingRuleLimit = compositePartLimit(opts.billingRuleLimit, "billingRuleLimit", OP12);
|
|
27646
28235
|
const contractId = parseIdentifier(id, "id");
|
|
27647
|
-
const
|
|
28236
|
+
const root3 = await invokeRead(client, "contracts.get", [contractId]);
|
|
27648
28237
|
const [services, billingRules, charges, units] = await readTasks(resource.http, [
|
|
27649
28238
|
() => compositePart(client, "contract_services.query", [
|
|
27650
28239
|
{ filter: [{ field: "contractID", op: "eq", value: contractId }], limit: serviceLimit }
|
|
@@ -27660,7 +28249,7 @@ async function fullProfile2(resource, id, opts = {}) {
|
|
|
27660
28249
|
])
|
|
27661
28250
|
]);
|
|
27662
28251
|
return {
|
|
27663
|
-
root:
|
|
28252
|
+
root: root3,
|
|
27664
28253
|
parts: {
|
|
27665
28254
|
services,
|
|
27666
28255
|
billing_rules: billingRules,
|
|
@@ -27824,6 +28413,7 @@ exports.formatVendorDetail = formatVendorDetail;
|
|
|
27824
28413
|
exports.invoke = invoke;
|
|
27825
28414
|
exports.invokeDelete = invokeDelete;
|
|
27826
28415
|
exports.invokeRead = invokeRead;
|
|
28416
|
+
exports.invokeReadPages = invokeReadPages;
|
|
27827
28417
|
exports.invokeWrite = invokeWrite;
|
|
27828
28418
|
exports.isAutotaskError = isAutotaskError;
|
|
27829
28419
|
exports.isClosedStatus = isClosedStatus;
|