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