node-autotask 0.69.1 → 0.71.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 +30 -0
- package/MCP_TOOL_CATALOG.json +369 -9
- package/README.md +7 -1
- package/capabilities.json +1697 -392
- package/dist/capabilities-data.js +1696 -391
- package/dist/capabilities.cjs +4 -4
- package/dist/capabilities.js +1 -1
- package/dist/{chunk-WFVLF7EW.cjs → chunk-4DSLRDIF.cjs} +33 -30
- package/dist/{chunk-FK37JXSJ.js → chunk-4OR3XBIP.js} +699 -168
- package/dist/{chunk-MMGO3SFL.js → chunk-5COLIVBE.js} +2 -2
- package/dist/{chunk-KAZE4WC7.cjs → chunk-JLCHKCEB.cjs} +3 -3
- package/dist/{chunk-SCFB5MF3.js → chunk-LKJA57CH.js} +3 -3
- package/dist/{chunk-EWXRFHPP.cjs → chunk-QJ327YI6.cjs} +177 -177
- package/dist/{chunk-CLHDTYWO.cjs → chunk-QQFF7X67.cjs} +704 -172
- package/dist/{chunk-64BMSXWT.js → chunk-YKQ2KNQO.js} +5 -2
- package/dist/{index-BT_0tTPS.d.cts → index-CAXT5ZKT.d.cts} +14 -4
- package/dist/{index-COQEG55Q.d.cts → index-CM_SRgtH.d.cts} +209 -1
- package/dist/{index-COQEG55Q.d.ts → index-CM_SRgtH.d.ts} +209 -1
- package/dist/{index-Coe7LFLY.d.ts → index-lGpxr4gY.d.ts} +14 -4
- package/dist/index.cjs +84 -84
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/operations/index.cjs +54 -50
- package/dist/operations/index.d.cts +25 -7
- package/dist/operations/index.d.ts +25 -7
- package/dist/operations/index.js +2 -2
- package/dist/pool.cjs +12 -12
- package/dist/pool.d.cts +1 -1
- package/dist/pool.d.ts +1 -1
- package/dist/pool.js +4 -4
- package/dist/resources/index.cjs +27 -27
- package/dist/resources/index.d.cts +2 -2
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/docs/API.md +108 -2
- package/docs/N8N-ADAPTER.md +1 -1
- package/docs/RELEASING.md +11 -3
- package/docs/performance-caching.md +92 -0
- package/docs/performance-reads.md +9 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJLCHKCEB_cjs = require('./chunk-JLCHKCEB.cjs');
|
|
4
4
|
var chunkBD4AUGCJ_cjs = require('./chunk-BD4AUGCJ.cjs');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var async_hooks = require('async_hooks');
|
|
@@ -618,6 +618,27 @@ function isKnownZone(zone) {
|
|
|
618
618
|
return typeof zone === "string" && ZONES.includes(zone);
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
+
// src/metadata-projection.ts
|
|
622
|
+
var METADATA_PROJECTION = /* @__PURE__ */ Symbol.for("node-autotask.metadata-projection.v1");
|
|
623
|
+
function projectMetadata(value, projector) {
|
|
624
|
+
return structuredClone(projector(value));
|
|
625
|
+
}
|
|
626
|
+
async function readMetadataProjection(holder, kind, projector, fallbackReader) {
|
|
627
|
+
const hook = holder !== null && (typeof holder === "object" || typeof holder === "function") ? holder[METADATA_PROJECTION] : void 0;
|
|
628
|
+
const owned = hook?.call(holder, kind, projector);
|
|
629
|
+
owned?.guard();
|
|
630
|
+
if (owned?.projected !== void 0) {
|
|
631
|
+
const value2 = await owned.projected;
|
|
632
|
+
owned.guard();
|
|
633
|
+
return value2;
|
|
634
|
+
}
|
|
635
|
+
const raw = await fallbackReader();
|
|
636
|
+
owned?.guard();
|
|
637
|
+
const value = projector(raw);
|
|
638
|
+
owned?.guard();
|
|
639
|
+
return value;
|
|
640
|
+
}
|
|
641
|
+
|
|
621
642
|
// src/cache.ts
|
|
622
643
|
var READ_CACHE_MAX_ENTRIES = 4096;
|
|
623
644
|
var REFERENCE_TTL_MS = 36e5;
|
|
@@ -630,6 +651,7 @@ function readTtlFor(key, ttlMs) {
|
|
|
630
651
|
const entity = key.split("\0")[0].split("/").at(-2);
|
|
631
652
|
return entity !== void 0 && REFERENCE_ENTITIES.includes(entity) ? Math.max(ttlMs, REFERENCE_TTL_MS) : ttlMs;
|
|
632
653
|
}
|
|
654
|
+
var MAX_ENTRY_PROJECTIONS = 8;
|
|
633
655
|
var TtlCache = class {
|
|
634
656
|
ttlMs;
|
|
635
657
|
maxEntries;
|
|
@@ -650,15 +672,38 @@ var TtlCache = class {
|
|
|
650
672
|
this.maxEntries = maxEntries;
|
|
651
673
|
this.ttlFor = options.ttlFor ?? (() => ttlMs);
|
|
652
674
|
}
|
|
653
|
-
|
|
654
|
-
get(key) {
|
|
675
|
+
liveEntry(key) {
|
|
655
676
|
const entry = this.store.get(key);
|
|
656
677
|
if (entry === void 0) return void 0;
|
|
657
678
|
if (entry.expiresAt <= Date.now()) {
|
|
658
679
|
this.store.delete(key);
|
|
659
680
|
return void 0;
|
|
660
681
|
}
|
|
661
|
-
return
|
|
682
|
+
return entry;
|
|
683
|
+
}
|
|
684
|
+
/** The live value (a copy), or `undefined` when absent or expired. */
|
|
685
|
+
get(key) {
|
|
686
|
+
const entry = this.liveEntry(key);
|
|
687
|
+
return entry === void 0 ? void 0 : structuredClone(entry.value);
|
|
688
|
+
}
|
|
689
|
+
projectEntry(key, entry, projector) {
|
|
690
|
+
if (entry.projections?.has(projector)) return structuredClone(entry.projections.get(projector));
|
|
691
|
+
const value = projectMetadata(structuredClone(entry.value), projector);
|
|
692
|
+
if (this.store.get(key) === entry && entry.expiresAt > Date.now()) {
|
|
693
|
+
const projections = entry.projections ??= /* @__PURE__ */ new Map();
|
|
694
|
+
if (projections.size >= MAX_ENTRY_PROJECTIONS) {
|
|
695
|
+
const oldest = projections.keys().next();
|
|
696
|
+
if (!oldest.done) projections.delete(oldest.value);
|
|
697
|
+
}
|
|
698
|
+
projections.set(projector, value);
|
|
699
|
+
return structuredClone(value);
|
|
700
|
+
}
|
|
701
|
+
return value;
|
|
702
|
+
}
|
|
703
|
+
/** Clone a live derived value without cloning the full metadata on each hit. @internal */
|
|
704
|
+
getProjected(key, projector) {
|
|
705
|
+
const entry = this.liveEntry(key);
|
|
706
|
+
return entry === void 0 ? void 0 : this.projectEntry(key, entry, projector);
|
|
662
707
|
}
|
|
663
708
|
/**
|
|
664
709
|
* Load one record once for concurrent callers. Each subscriber owns its
|
|
@@ -669,12 +714,23 @@ var TtlCache = class {
|
|
|
669
714
|
* `shouldStore` controls retention, never the result returned to subscribers.
|
|
670
715
|
* @internal
|
|
671
716
|
*/
|
|
672
|
-
|
|
717
|
+
load(key, loader, opts) {
|
|
718
|
+
return this.loadValue(key, loader, opts);
|
|
719
|
+
}
|
|
720
|
+
/** Projected and raw subscribers share the same raw flight and retention policy. @internal */
|
|
721
|
+
loadProjected(key, loader, projector, opts) {
|
|
722
|
+
return this.loadValue(key, loader, opts, projector);
|
|
723
|
+
}
|
|
724
|
+
async loadValue(key, loader, opts, projector) {
|
|
673
725
|
const { signal } = opts;
|
|
674
726
|
if (signal?.aborted) throw opts.abortError();
|
|
675
727
|
if (!opts.fresh) {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
728
|
+
const entry = this.liveEntry(key);
|
|
729
|
+
if (entry !== void 0 && entry.value !== void 0) {
|
|
730
|
+
const hit = projector === void 0 ? structuredClone(entry.value) : this.projectEntry(key, entry, projector);
|
|
731
|
+
if (signal?.aborted) throw opts.abortError();
|
|
732
|
+
return hit;
|
|
733
|
+
}
|
|
678
734
|
}
|
|
679
735
|
let flight = opts.fresh ? void 0 : this.loads.get(key);
|
|
680
736
|
let start;
|
|
@@ -692,7 +748,10 @@ var TtlCache = class {
|
|
|
692
748
|
}
|
|
693
749
|
};
|
|
694
750
|
}).then((value) => {
|
|
695
|
-
if (this.loads.get(key) === created && !controller.signal.aborted
|
|
751
|
+
if (this.loads.get(key) === created && !controller.signal.aborted) {
|
|
752
|
+
const retain = opts.shouldStore?.(value) ?? true;
|
|
753
|
+
if (retain && this.loads.get(key) === created && !controller.signal.aborted) created.entry = this.storeValue(key, value, epoch);
|
|
754
|
+
}
|
|
696
755
|
return value;
|
|
697
756
|
});
|
|
698
757
|
const settled = () => {
|
|
@@ -726,7 +785,11 @@ var TtlCache = class {
|
|
|
726
785
|
(value) => {
|
|
727
786
|
if (leave()) {
|
|
728
787
|
try {
|
|
729
|
-
|
|
788
|
+
if (signal?.aborted) throw opts.abortError();
|
|
789
|
+
const entry = shared.entry;
|
|
790
|
+
const selected = projector === void 0 ? structuredClone(value) : entry !== void 0 && this.liveEntry(key) === entry ? this.projectEntry(key, entry, projector) : projectMetadata(structuredClone(value), projector);
|
|
791
|
+
if (signal?.aborted) throw opts.abortError();
|
|
792
|
+
resolve(selected);
|
|
730
793
|
} catch (error) {
|
|
731
794
|
reject(error);
|
|
732
795
|
}
|
|
@@ -743,14 +806,19 @@ var TtlCache = class {
|
|
|
743
806
|
/** Store `value` under `key`. `epoch` is the value the caller read BEFORE its
|
|
744
807
|
* wire request: a read that straddled a `clear()` (a write) is dropped. */
|
|
745
808
|
set(key, value, epoch = this.epochCounter) {
|
|
746
|
-
|
|
809
|
+
this.storeValue(key, value, epoch);
|
|
810
|
+
}
|
|
811
|
+
storeValue(key, value, epoch) {
|
|
812
|
+
if (epoch !== this.epochCounter) return void 0;
|
|
747
813
|
if (!this.store.has(key) && this.store.size >= this.maxEntries && this.purgeExpired() === 0) {
|
|
748
814
|
const oldest = this.store.keys().next();
|
|
749
815
|
if (!oldest.done) this.store.delete(oldest.value);
|
|
750
816
|
}
|
|
751
817
|
const now = Date.now();
|
|
752
818
|
this.store.delete(key);
|
|
753
|
-
|
|
819
|
+
const entry = { value: structuredClone(value), storedAt: now, expiresAt: now + this.ttlFor(key) };
|
|
820
|
+
this.store.set(key, entry);
|
|
821
|
+
return entry;
|
|
754
822
|
}
|
|
755
823
|
/** `{ hit, age }` without consuming or cloning the entry (age in ms since stored). */
|
|
756
824
|
peek(key) {
|
|
@@ -1734,6 +1802,12 @@ function isAbortLike(err) {
|
|
|
1734
1802
|
return typeof err === "object" && err !== null && "name" in err && err.name === "AbortError";
|
|
1735
1803
|
}
|
|
1736
1804
|
|
|
1805
|
+
// src/read-scope.ts
|
|
1806
|
+
var CAPTURE_READ_GUARD = /* @__PURE__ */ Symbol.for("node-autotask.capture-read-guard.v1");
|
|
1807
|
+
function captureReadGuard(http, operation) {
|
|
1808
|
+
return http[CAPTURE_READ_GUARD](operation);
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1737
1811
|
// src/auth.ts
|
|
1738
1812
|
var AUTH_HEADERS = {
|
|
1739
1813
|
integrationCode: "ApiIntegrationCode",
|
|
@@ -2323,6 +2397,22 @@ var RELATIONSHIP_MAP = {
|
|
|
2323
2397
|
"delete": true
|
|
2324
2398
|
}
|
|
2325
2399
|
},
|
|
2400
|
+
{
|
|
2401
|
+
"resource": "company_attachments",
|
|
2402
|
+
"apiEntity": "CompanyAttachment",
|
|
2403
|
+
"parentField": "companyID",
|
|
2404
|
+
"parentSegment": "Attachments",
|
|
2405
|
+
"tier": "extended",
|
|
2406
|
+
"workflowResource": false,
|
|
2407
|
+
"specialOps": [],
|
|
2408
|
+
"searchCovers": null,
|
|
2409
|
+
"scopedOps": {
|
|
2410
|
+
"create": true,
|
|
2411
|
+
"query": true,
|
|
2412
|
+
"update": false,
|
|
2413
|
+
"delete": true
|
|
2414
|
+
}
|
|
2415
|
+
},
|
|
2326
2416
|
{
|
|
2327
2417
|
"resource": "company_locations",
|
|
2328
2418
|
"apiEntity": "CompanyLocation",
|
|
@@ -2604,7 +2694,24 @@ var RELATIONSHIP_MAP = {
|
|
|
2604
2694
|
"segment": "Notes",
|
|
2605
2695
|
"field": "companyID"
|
|
2606
2696
|
},
|
|
2607
|
-
"children": [
|
|
2697
|
+
"children": [
|
|
2698
|
+
{
|
|
2699
|
+
"resource": "company_note_attachments",
|
|
2700
|
+
"apiEntity": "CompanyNoteAttachment",
|
|
2701
|
+
"parentField": "companyNoteID",
|
|
2702
|
+
"parentSegment": "Attachments",
|
|
2703
|
+
"tier": "extended",
|
|
2704
|
+
"workflowResource": false,
|
|
2705
|
+
"specialOps": [],
|
|
2706
|
+
"searchCovers": null,
|
|
2707
|
+
"scopedOps": {
|
|
2708
|
+
"create": true,
|
|
2709
|
+
"query": true,
|
|
2710
|
+
"update": false,
|
|
2711
|
+
"delete": true
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
],
|
|
2608
2715
|
"naturalKeys": {
|
|
2609
2716
|
"hasSearch": true,
|
|
2610
2717
|
"searchCovers": "name only (contains)",
|
|
@@ -2891,7 +2998,7 @@ var RELATIONSHIP_MAP = {
|
|
|
2891
2998
|
"parent": {
|
|
2892
2999
|
"resource": "configuration_items",
|
|
2893
3000
|
"segment": "DnsRecords",
|
|
2894
|
-
"field": "
|
|
3001
|
+
"field": "installedProductID"
|
|
2895
3002
|
},
|
|
2896
3003
|
"children": [],
|
|
2897
3004
|
"naturalKeys": {
|
|
@@ -3161,7 +3268,7 @@ var RELATIONSHIP_MAP = {
|
|
|
3161
3268
|
{
|
|
3162
3269
|
"resource": "configuration_item_dns_records",
|
|
3163
3270
|
"apiEntity": "ConfigurationItemDnsRecord",
|
|
3164
|
-
"parentField": "
|
|
3271
|
+
"parentField": "installedProductID",
|
|
3165
3272
|
"parentSegment": "DnsRecords",
|
|
3166
3273
|
"tier": "extended",
|
|
3167
3274
|
"workflowResource": false,
|
|
@@ -9428,6 +9535,137 @@ var RELATIONSHIP_MAP = {
|
|
|
9428
9535
|
"zoneFacts": null,
|
|
9429
9536
|
"deleteBoundary": null,
|
|
9430
9537
|
"markerField": null
|
|
9538
|
+
},
|
|
9539
|
+
"attachment_info": {
|
|
9540
|
+
"resource": "attachment_info",
|
|
9541
|
+
"apiEntity": "AttachmentInfo",
|
|
9542
|
+
"kind": "entity",
|
|
9543
|
+
"path": "AttachmentInfo",
|
|
9544
|
+
"parentScoped": false,
|
|
9545
|
+
"tier": "extended",
|
|
9546
|
+
"workflowResource": false,
|
|
9547
|
+
"group": "A",
|
|
9548
|
+
"parent": null,
|
|
9549
|
+
"children": [],
|
|
9550
|
+
"naturalKeys": {
|
|
9551
|
+
"hasSearch": false,
|
|
9552
|
+
"searchCovers": null,
|
|
9553
|
+
"findBy": []
|
|
9554
|
+
},
|
|
9555
|
+
"blindSurfaces": null,
|
|
9556
|
+
"zoneFacts": null,
|
|
9557
|
+
"deleteBoundary": null,
|
|
9558
|
+
"markerField": null
|
|
9559
|
+
},
|
|
9560
|
+
"company_attachments": {
|
|
9561
|
+
"resource": "company_attachments",
|
|
9562
|
+
"apiEntity": "CompanyAttachment",
|
|
9563
|
+
"kind": "entity",
|
|
9564
|
+
"path": "CompanyAttachments",
|
|
9565
|
+
"parentScoped": true,
|
|
9566
|
+
"tier": "extended",
|
|
9567
|
+
"workflowResource": false,
|
|
9568
|
+
"group": "A",
|
|
9569
|
+
"parent": {
|
|
9570
|
+
"resource": "companies",
|
|
9571
|
+
"segment": "Attachments",
|
|
9572
|
+
"field": "companyID"
|
|
9573
|
+
},
|
|
9574
|
+
"children": [],
|
|
9575
|
+
"naturalKeys": {
|
|
9576
|
+
"hasSearch": false,
|
|
9577
|
+
"searchCovers": null,
|
|
9578
|
+
"findBy": []
|
|
9579
|
+
},
|
|
9580
|
+
"blindSurfaces": null,
|
|
9581
|
+
"zoneFacts": {
|
|
9582
|
+
"createGuidance": {
|
|
9583
|
+
"createOp": "company_attachments.create",
|
|
9584
|
+
"parentScoped": true,
|
|
9585
|
+
"liveProvenPrefix": [],
|
|
9586
|
+
"unproven": true,
|
|
9587
|
+
"blocker": {
|
|
9588
|
+
"kind": "unknown",
|
|
9589
|
+
"message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
|
|
9590
|
+
"remedy": "Read the current field and picklist metadata, supply the named parent id, and preview the attachment before applying."
|
|
9591
|
+
},
|
|
9592
|
+
"requiresByValue": [
|
|
9593
|
+
{
|
|
9594
|
+
"field": "attachmentType",
|
|
9595
|
+
"value": "FILE_ATTACHMENT",
|
|
9596
|
+
"requires": {
|
|
9597
|
+
"allOf": [
|
|
9598
|
+
"data"
|
|
9599
|
+
]
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
],
|
|
9603
|
+
"vendorEvidence": [
|
|
9604
|
+
"Specification: POST /V1.0/Companies/{parentId}/Attachments returns OperationResultModel. Official attachment guidance requires base64 data for FILE_ATTACHMENT. No live create was performed."
|
|
9605
|
+
],
|
|
9606
|
+
"deleteBoundary": {
|
|
9607
|
+
"available": true,
|
|
9608
|
+
"note": null
|
|
9609
|
+
}
|
|
9610
|
+
}
|
|
9611
|
+
},
|
|
9612
|
+
"deleteBoundary": null,
|
|
9613
|
+
"markerField": null
|
|
9614
|
+
},
|
|
9615
|
+
"company_note_attachments": {
|
|
9616
|
+
"resource": "company_note_attachments",
|
|
9617
|
+
"apiEntity": "CompanyNoteAttachment",
|
|
9618
|
+
"kind": "entity",
|
|
9619
|
+
"path": "CompanyNoteAttachments",
|
|
9620
|
+
"parentScoped": true,
|
|
9621
|
+
"tier": "extended",
|
|
9622
|
+
"workflowResource": false,
|
|
9623
|
+
"group": "A",
|
|
9624
|
+
"parent": {
|
|
9625
|
+
"resource": "company_notes",
|
|
9626
|
+
"segment": "Attachments",
|
|
9627
|
+
"field": "companyNoteID"
|
|
9628
|
+
},
|
|
9629
|
+
"children": [],
|
|
9630
|
+
"naturalKeys": {
|
|
9631
|
+
"hasSearch": false,
|
|
9632
|
+
"searchCovers": null,
|
|
9633
|
+
"findBy": []
|
|
9634
|
+
},
|
|
9635
|
+
"blindSurfaces": null,
|
|
9636
|
+
"zoneFacts": {
|
|
9637
|
+
"createGuidance": {
|
|
9638
|
+
"createOp": "company_note_attachments.create",
|
|
9639
|
+
"parentScoped": true,
|
|
9640
|
+
"liveProvenPrefix": [],
|
|
9641
|
+
"unproven": true,
|
|
9642
|
+
"blocker": {
|
|
9643
|
+
"kind": "unknown",
|
|
9644
|
+
"message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
|
|
9645
|
+
"remedy": "Read the current field and picklist metadata, supply the named parent id, and preview the attachment before applying."
|
|
9646
|
+
},
|
|
9647
|
+
"requiresByValue": [
|
|
9648
|
+
{
|
|
9649
|
+
"field": "attachmentType",
|
|
9650
|
+
"value": "FILE_ATTACHMENT",
|
|
9651
|
+
"requires": {
|
|
9652
|
+
"allOf": [
|
|
9653
|
+
"data"
|
|
9654
|
+
]
|
|
9655
|
+
}
|
|
9656
|
+
}
|
|
9657
|
+
],
|
|
9658
|
+
"vendorEvidence": [
|
|
9659
|
+
"Specification: POST /V1.0/CompanyNotes/{parentId}/Attachments returns OperationResultModel. Official attachment guidance requires base64 data for FILE_ATTACHMENT. No live create was performed."
|
|
9660
|
+
],
|
|
9661
|
+
"deleteBoundary": {
|
|
9662
|
+
"available": true,
|
|
9663
|
+
"note": null
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
},
|
|
9667
|
+
"deleteBoundary": null,
|
|
9668
|
+
"markerField": null
|
|
9431
9669
|
}
|
|
9432
9670
|
};
|
|
9433
9671
|
var BLIND_SURFACE_STAMPS = {
|
|
@@ -11135,6 +11373,36 @@ var CREATE_GUIDANCE = {
|
|
|
11135
11373
|
"note": null
|
|
11136
11374
|
}
|
|
11137
11375
|
},
|
|
11376
|
+
{
|
|
11377
|
+
"resource": "company_attachments",
|
|
11378
|
+
"createOp": "company_attachments.create",
|
|
11379
|
+
"parentScoped": true,
|
|
11380
|
+
"liveProvenPrefix": [],
|
|
11381
|
+
"unproven": true,
|
|
11382
|
+
"blocker": {
|
|
11383
|
+
"kind": "unknown",
|
|
11384
|
+
"message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
|
|
11385
|
+
"remedy": "Read the current field and picklist metadata, supply the named parent id, and preview the attachment before applying."
|
|
11386
|
+
},
|
|
11387
|
+
"vendorEvidence": [
|
|
11388
|
+
"Specification: POST /V1.0/Companies/{parentId}/Attachments returns OperationResultModel. Official attachment guidance requires base64 data for FILE_ATTACHMENT. No live create was performed."
|
|
11389
|
+
],
|
|
11390
|
+
"deleteBoundary": {
|
|
11391
|
+
"available": true,
|
|
11392
|
+
"note": null
|
|
11393
|
+
},
|
|
11394
|
+
"requiresByValue": [
|
|
11395
|
+
{
|
|
11396
|
+
"field": "attachmentType",
|
|
11397
|
+
"value": "FILE_ATTACHMENT",
|
|
11398
|
+
"requires": {
|
|
11399
|
+
"allOf": [
|
|
11400
|
+
"data"
|
|
11401
|
+
]
|
|
11402
|
+
}
|
|
11403
|
+
}
|
|
11404
|
+
]
|
|
11405
|
+
},
|
|
11138
11406
|
{
|
|
11139
11407
|
"resource": "company_locations",
|
|
11140
11408
|
"createOp": "company_locations.create",
|
|
@@ -11152,6 +11420,36 @@ var CREATE_GUIDANCE = {
|
|
|
11152
11420
|
"note": null
|
|
11153
11421
|
}
|
|
11154
11422
|
},
|
|
11423
|
+
{
|
|
11424
|
+
"resource": "company_note_attachments",
|
|
11425
|
+
"createOp": "company_note_attachments.create",
|
|
11426
|
+
"parentScoped": true,
|
|
11427
|
+
"liveProvenPrefix": [],
|
|
11428
|
+
"unproven": true,
|
|
11429
|
+
"blocker": {
|
|
11430
|
+
"kind": "unknown",
|
|
11431
|
+
"message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
|
|
11432
|
+
"remedy": "Read the current field and picklist metadata, supply the named parent id, and preview the attachment before applying."
|
|
11433
|
+
},
|
|
11434
|
+
"vendorEvidence": [
|
|
11435
|
+
"Specification: POST /V1.0/CompanyNotes/{parentId}/Attachments returns OperationResultModel. Official attachment guidance requires base64 data for FILE_ATTACHMENT. No live create was performed."
|
|
11436
|
+
],
|
|
11437
|
+
"deleteBoundary": {
|
|
11438
|
+
"available": true,
|
|
11439
|
+
"note": null
|
|
11440
|
+
},
|
|
11441
|
+
"requiresByValue": [
|
|
11442
|
+
{
|
|
11443
|
+
"field": "attachmentType",
|
|
11444
|
+
"value": "FILE_ATTACHMENT",
|
|
11445
|
+
"requires": {
|
|
11446
|
+
"allOf": [
|
|
11447
|
+
"data"
|
|
11448
|
+
]
|
|
11449
|
+
}
|
|
11450
|
+
}
|
|
11451
|
+
]
|
|
11452
|
+
},
|
|
11155
11453
|
{
|
|
11156
11454
|
"resource": "company_notes",
|
|
11157
11455
|
"createOp": "company_notes.create",
|
|
@@ -13458,7 +13756,7 @@ var CREATE_GUIDANCE = {
|
|
|
13458
13756
|
}
|
|
13459
13757
|
],
|
|
13460
13758
|
"counts": {
|
|
13461
|
-
"total":
|
|
13759
|
+
"total": 101,
|
|
13462
13760
|
"byKind": {
|
|
13463
13761
|
"ok": 41,
|
|
13464
13762
|
"blind-reference": 16,
|
|
@@ -13468,7 +13766,7 @@ var CREATE_GUIDANCE = {
|
|
|
13468
13766
|
"resource-role-pair": 2,
|
|
13469
13767
|
"delete-absent": 0,
|
|
13470
13768
|
"non-mutable": 0,
|
|
13471
|
-
"unknown":
|
|
13769
|
+
"unknown": 25
|
|
13472
13770
|
}
|
|
13473
13771
|
}
|
|
13474
13772
|
};
|
|
@@ -14185,6 +14483,15 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
|
|
|
14185
14483
|
"user_defined_field_list_items": [
|
|
14186
14484
|
"valueForDisplay",
|
|
14187
14485
|
"valueForExport"
|
|
14486
|
+
],
|
|
14487
|
+
"attachment_info": [
|
|
14488
|
+
"title"
|
|
14489
|
+
],
|
|
14490
|
+
"company_attachments": [
|
|
14491
|
+
"title"
|
|
14492
|
+
],
|
|
14493
|
+
"company_note_attachments": [
|
|
14494
|
+
"title"
|
|
14188
14495
|
]
|
|
14189
14496
|
};
|
|
14190
14497
|
|
|
@@ -14793,6 +15100,13 @@ async function discoverZoneBase(userName, maxResponseBytes, signal, ctx) {
|
|
|
14793
15100
|
var META_TRIO_VERBS = /* @__PURE__ */ new Set(["getEntityInfo", "getFieldInfo", "getUdfInfo"]);
|
|
14794
15101
|
var RETRY = { done: false };
|
|
14795
15102
|
var HttpClient = class {
|
|
15103
|
+
/** Retain this build's caller scope without sharing ambient storage. @internal */
|
|
15104
|
+
[CAPTURE_READ_GUARD](operation) {
|
|
15105
|
+
const signal = ambientCallerSignal();
|
|
15106
|
+
return () => {
|
|
15107
|
+
if (signal?.aborted) throw new AutotaskAbortError("Read aborted by the caller", { operation });
|
|
15108
|
+
};
|
|
15109
|
+
}
|
|
14796
15110
|
/**
|
|
14797
15111
|
* The LIVE base URL (issue #43): the construction-time value until a zone
|
|
14798
15112
|
* re-point happens, then the tenant's newly resolved zone base. Reads are
|
|
@@ -15844,6 +16158,133 @@ var WORKFLOW_RESOURCES = [
|
|
|
15844
16158
|
"projects"
|
|
15845
16159
|
];
|
|
15846
16160
|
|
|
16161
|
+
// src/metadata-views.ts
|
|
16162
|
+
function liveFieldNamesView(rows) {
|
|
16163
|
+
if (!Array.isArray(rows)) return null;
|
|
16164
|
+
const names = [];
|
|
16165
|
+
for (const row of rows) if (typeof row.name === "string") names.push(row.name);
|
|
16166
|
+
return names.length === 0 ? null : { names, known: new Set(names) };
|
|
16167
|
+
}
|
|
16168
|
+
function projectFieldRow(raw, labels = false, udf = false) {
|
|
16169
|
+
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
16170
|
+
const name = typeof r.name === "string" ? r.name : "";
|
|
16171
|
+
const type = typeof r.dataType === "string" ? r.dataType : typeof r.type === "string" ? r.type : "";
|
|
16172
|
+
const values = labels && r.isPickList === true && Array.isArray(r.picklistValues) && r.picklistValues.length > 0 ? r.picklistValues : void 0;
|
|
16173
|
+
const referenceEntityType = typeof r.referenceEntityType === "string" ? r.referenceEntityType : "";
|
|
16174
|
+
return {
|
|
16175
|
+
name,
|
|
16176
|
+
...typeof r.label === "string" && r.label !== "" ? { label: r.label } : {},
|
|
16177
|
+
type,
|
|
16178
|
+
isRequired: r.isRequired === true,
|
|
16179
|
+
isReadOnly: r.isReadOnly === true,
|
|
16180
|
+
// Issue #219 N7: a UDF row never serves the vendor's isQueryable (it is
|
|
16181
|
+
// true for UDFs while a plain filter on a UDF name is refused); it serves
|
|
16182
|
+
// the marker the filter actually needs.
|
|
16183
|
+
...udf ? { filterable: "udf-marker" } : { isQueryable: r.isQueryable === true },
|
|
16184
|
+
isPickList: r.isPickList === true,
|
|
16185
|
+
...isObjectOrArrayType(type) ? { writeShape: "replace-all" } : {},
|
|
16186
|
+
maxLength: typeof r.length === "number" ? r.length : null,
|
|
16187
|
+
referenceEntityType,
|
|
16188
|
+
...values !== void 0 ? { picklistValues: values } : {}
|
|
16189
|
+
};
|
|
16190
|
+
}
|
|
16191
|
+
function isObjectOrArrayType(type) {
|
|
16192
|
+
const t = type.trim().toLowerCase();
|
|
16193
|
+
return t === "object" || t === "array" || t === "collection" || t.endsWith("[]");
|
|
16194
|
+
}
|
|
16195
|
+
function exposesPicklistValues(raw) {
|
|
16196
|
+
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
16197
|
+
return Array.isArray(r.picklistValues) && r.picklistValues.length > 0;
|
|
16198
|
+
}
|
|
16199
|
+
function catalogList(raw, labels, udf) {
|
|
16200
|
+
return Array.isArray(raw) ? { rows: raw.map((row) => projectFieldRow(row, labels, udf)), exposesValues: raw.some(exposesPicklistValues) } : { rows: null, exposesValues: false };
|
|
16201
|
+
}
|
|
16202
|
+
var catalogFieldsView = (raw) => catalogList(raw, false, false);
|
|
16203
|
+
var catalogLabelledFieldsView = (raw) => catalogList(raw, true, false);
|
|
16204
|
+
var catalogUdfView = (raw) => catalogList(raw, false, true);
|
|
16205
|
+
var catalogLabelledUdfView = (raw) => catalogList(raw, true, true);
|
|
16206
|
+
function compactCatalogList(raw, keepValues, udf) {
|
|
16207
|
+
const view = catalogList(raw, keepValues, udf);
|
|
16208
|
+
if (view.rows === null) return { rows: null, exposesValues: view.exposesValues };
|
|
16209
|
+
const flags = {
|
|
16210
|
+
required: view.rows.filter((row) => row.isRequired).map((row) => row.name),
|
|
16211
|
+
readOnly: view.rows.filter((row) => row.isReadOnly).map((row) => row.name),
|
|
16212
|
+
queryable: view.rows.filter((row) => row.isQueryable).map((row) => row.name),
|
|
16213
|
+
picklistFields: view.rows.filter((row) => row.isPickList).map((row) => row.name)
|
|
16214
|
+
};
|
|
16215
|
+
return {
|
|
16216
|
+
rows: view.rows.map((row) => ({
|
|
16217
|
+
name: row.name,
|
|
16218
|
+
type: row.type,
|
|
16219
|
+
isPickList: row.isPickList,
|
|
16220
|
+
isReference: row.referenceEntityType !== "",
|
|
16221
|
+
udf,
|
|
16222
|
+
...keepValues && row.picklistValues !== void 0 ? { picklistValues: row.picklistValues } : {}
|
|
16223
|
+
})),
|
|
16224
|
+
flags,
|
|
16225
|
+
exposesValues: view.exposesValues
|
|
16226
|
+
};
|
|
16227
|
+
}
|
|
16228
|
+
var compactCatalogFieldsView = (raw) => compactCatalogList(raw, false, false);
|
|
16229
|
+
var compactCatalogLabelledFieldsView = (raw) => compactCatalogList(raw, true, false);
|
|
16230
|
+
var compactCatalogUdfView = (raw) => compactCatalogList(raw, false, true);
|
|
16231
|
+
var compactCatalogLabelledUdfView = (raw) => compactCatalogList(raw, true, true);
|
|
16232
|
+
function ticketStatusView(fields) {
|
|
16233
|
+
if (!Array.isArray(fields)) return [];
|
|
16234
|
+
const status = fields.find((f) => typeof f?.name === "string" && f.name.toLowerCase() === "status");
|
|
16235
|
+
if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
|
|
16236
|
+
const out = [];
|
|
16237
|
+
for (const v of status.picklistValues) {
|
|
16238
|
+
const id = Number(v?.value);
|
|
16239
|
+
if (!Number.isSafeInteger(id)) continue;
|
|
16240
|
+
out.push({ id, label: typeof v.label === "string" ? v.label : "" });
|
|
16241
|
+
}
|
|
16242
|
+
return out;
|
|
16243
|
+
}
|
|
16244
|
+
function primitiveData(descriptor2) {
|
|
16245
|
+
return descriptor2 !== void 0 && "value" in descriptor2 && (descriptor2.value === null || typeof descriptor2.value !== "object" && typeof descriptor2.value !== "function");
|
|
16246
|
+
}
|
|
16247
|
+
function picklistsView(raw) {
|
|
16248
|
+
if (!Array.isArray(raw)) return null;
|
|
16249
|
+
const fields = /* @__PURE__ */ new Map();
|
|
16250
|
+
for (const rawField of raw) {
|
|
16251
|
+
const field = projectFieldRow(rawField, true);
|
|
16252
|
+
if (fields.has(field.name)) continue;
|
|
16253
|
+
const values = field.picklistValues;
|
|
16254
|
+
if (values === void 0) {
|
|
16255
|
+
fields.set(field.name, void 0);
|
|
16256
|
+
continue;
|
|
16257
|
+
}
|
|
16258
|
+
const labels = /* @__PURE__ */ new Map();
|
|
16259
|
+
if (values.some((entry) => {
|
|
16260
|
+
if (entry === null || typeof entry !== "object" || Object.getPrototypeOf(entry) !== Object.prototype) return true;
|
|
16261
|
+
return !primitiveData(Object.getOwnPropertyDescriptor(entry, "value")) || !primitiveData(Object.getOwnPropertyDescriptor(entry, "label"));
|
|
16262
|
+
})) {
|
|
16263
|
+
fields.set(field.name, { labels, ordered: values });
|
|
16264
|
+
continue;
|
|
16265
|
+
}
|
|
16266
|
+
for (const value of values) {
|
|
16267
|
+
const key = String(value.value);
|
|
16268
|
+
if (!labels.has(key)) labels.set(key, typeof value.label === "string" ? value.label : null);
|
|
16269
|
+
}
|
|
16270
|
+
fields.set(field.name, { labels });
|
|
16271
|
+
}
|
|
16272
|
+
return fields;
|
|
16273
|
+
}
|
|
16274
|
+
function lookupPicklist(view, value) {
|
|
16275
|
+
if (view.ordered !== void 0) {
|
|
16276
|
+
const hit = view.ordered.find((entry) => String(entry.value) === String(value));
|
|
16277
|
+
return { found: hit !== void 0, label: typeof hit?.label === "string" ? hit.label : null };
|
|
16278
|
+
}
|
|
16279
|
+
const key = String(value);
|
|
16280
|
+
return { found: view.labels.has(key), label: view.labels.get(key) ?? null };
|
|
16281
|
+
}
|
|
16282
|
+
function ticketStatusFieldsView(fields) {
|
|
16283
|
+
if (!Array.isArray(fields)) return [];
|
|
16284
|
+
const status = fields.find((field) => typeof field?.name === "string" && field.name.toLowerCase() === "status");
|
|
16285
|
+
return status === void 0 ? [] : [status];
|
|
16286
|
+
}
|
|
16287
|
+
|
|
15847
16288
|
// src/utils/bounded.ts
|
|
15848
16289
|
async function runBounded(fn, items, opts) {
|
|
15849
16290
|
const { concurrency, signal, settle } = opts;
|
|
@@ -15899,48 +16340,7 @@ var MAX_FIELD_CATALOG_WIRE = 60;
|
|
|
15899
16340
|
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.";
|
|
15900
16341
|
var MIN_FIELD_CATALOG_MAX_BYTES = 4096;
|
|
15901
16342
|
var FIELD_CATALOG_OPT_KEYS = ["resources", "include", "fresh", "fields", "labels", "compact", "maxBytes"];
|
|
15902
|
-
function
|
|
15903
|
-
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
15904
|
-
const name = typeof r.name === "string" ? r.name : "";
|
|
15905
|
-
const type = typeof r.dataType === "string" ? r.dataType : typeof r.type === "string" ? r.type : "";
|
|
15906
|
-
const values = labels && r.isPickList === true && Array.isArray(r.picklistValues) && r.picklistValues.length > 0 ? r.picklistValues : void 0;
|
|
15907
|
-
const referenceEntityType = typeof r.referenceEntityType === "string" ? r.referenceEntityType : "";
|
|
15908
|
-
return {
|
|
15909
|
-
name,
|
|
15910
|
-
...typeof r.label === "string" && r.label !== "" ? { label: r.label } : {},
|
|
15911
|
-
type,
|
|
15912
|
-
isRequired: r.isRequired === true,
|
|
15913
|
-
isReadOnly: r.isReadOnly === true,
|
|
15914
|
-
// Issue #219 N7: a UDF row never serves the vendor's isQueryable (it is
|
|
15915
|
-
// true for UDFs while a plain filter on a UDF name is refused); it serves
|
|
15916
|
-
// the marker the filter actually needs.
|
|
15917
|
-
...udf ? { filterable: "udf-marker" } : { isQueryable: r.isQueryable === true },
|
|
15918
|
-
isPickList: r.isPickList === true,
|
|
15919
|
-
...isObjectOrArrayType(type) ? { writeShape: "replace-all" } : {},
|
|
15920
|
-
maxLength: typeof r.length === "number" ? r.length : null,
|
|
15921
|
-
referenceEntityType,
|
|
15922
|
-
...values !== void 0 ? { picklistValues: values } : {}
|
|
15923
|
-
};
|
|
15924
|
-
}
|
|
15925
|
-
function compactFieldRow(f, udf, keepValues) {
|
|
15926
|
-
return {
|
|
15927
|
-
name: f.name,
|
|
15928
|
-
type: f.type,
|
|
15929
|
-
isPickList: f.isPickList,
|
|
15930
|
-
isReference: f.referenceEntityType !== "",
|
|
15931
|
-
udf,
|
|
15932
|
-
...keepValues && f.picklistValues !== void 0 ? { picklistValues: f.picklistValues } : {}
|
|
15933
|
-
};
|
|
15934
|
-
}
|
|
15935
|
-
function isObjectOrArrayType(type) {
|
|
15936
|
-
const t = type.trim().toLowerCase();
|
|
15937
|
-
return t === "object" || t === "array" || t === "collection" || t.endsWith("[]");
|
|
15938
|
-
}
|
|
15939
|
-
function exposesPicklistValues(raw) {
|
|
15940
|
-
const r = typeof raw === "object" && raw !== null ? raw : {};
|
|
15941
|
-
return Array.isArray(r.picklistValues) && r.picklistValues.length > 0;
|
|
15942
|
-
}
|
|
15943
|
-
function applyFieldsFilter(projected, filter, row) {
|
|
16343
|
+
function applyFieldsFilter(projected, filter, row, flags) {
|
|
15944
16344
|
const kept = filter === void 0 ? projected : projected.filter((f) => filter.includes(f.name));
|
|
15945
16345
|
if (filter !== void 0) {
|
|
15946
16346
|
const present = new Set(projected.map((f) => f.name));
|
|
@@ -15948,16 +16348,25 @@ function applyFieldsFilter(projected, filter, row) {
|
|
|
15948
16348
|
row.projected = true;
|
|
15949
16349
|
}
|
|
15950
16350
|
row.fields = kept;
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
16351
|
+
if (flags !== void 0) {
|
|
16352
|
+
const present = new Set(kept.map((field) => field.name));
|
|
16353
|
+
row.required = flags.required.filter((name) => present.has(name));
|
|
16354
|
+
row.readOnly = flags.readOnly.filter((name) => present.has(name));
|
|
16355
|
+
row.queryable = flags.queryable.filter((name) => present.has(name));
|
|
16356
|
+
row.picklistFields = flags.picklistFields.filter((name) => present.has(name));
|
|
16357
|
+
} else {
|
|
16358
|
+
const full = kept;
|
|
16359
|
+
row.required = full.filter((field) => field.isRequired).map((field) => field.name);
|
|
16360
|
+
row.readOnly = full.filter((field) => field.isReadOnly).map((field) => field.name);
|
|
16361
|
+
row.queryable = full.filter((field) => field.isQueryable).map((field) => field.name);
|
|
16362
|
+
row.picklistFields = full.filter((field) => field.isPickList).map((field) => field.name);
|
|
16363
|
+
}
|
|
15955
16364
|
}
|
|
15956
16365
|
async function capabilitySets() {
|
|
15957
16366
|
const fieldOps = /* @__PURE__ */ new Map();
|
|
15958
16367
|
const udfCapable = /* @__PURE__ */ new Set();
|
|
15959
16368
|
const resources = /* @__PURE__ */ new Set();
|
|
15960
|
-
for (const rec of await
|
|
16369
|
+
for (const rec of await chunkJLCHKCEB_cjs.loadCapabilityRecords()) {
|
|
15961
16370
|
if (rec.resource === "operations") continue;
|
|
15962
16371
|
resources.add(rec.resource);
|
|
15963
16372
|
if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
|
|
@@ -15968,7 +16377,7 @@ async function capabilitySets() {
|
|
|
15968
16377
|
var derivedIndexPromise = null;
|
|
15969
16378
|
function derivedIndexLoad() {
|
|
15970
16379
|
if (derivedIndexPromise === null) {
|
|
15971
|
-
derivedIndexPromise =
|
|
16380
|
+
derivedIndexPromise = chunkJLCHKCEB_cjs.loadCapabilityRecords().then((records) => {
|
|
15972
16381
|
const index = /* @__PURE__ */ new Map();
|
|
15973
16382
|
for (const rec of records) {
|
|
15974
16383
|
const declared = rec.metadata?.derivedFields;
|
|
@@ -16166,14 +16575,25 @@ function kindFetches(holder, resource) {
|
|
|
16166
16575
|
udf: () => holder?.getUdfInfo?.() ?? Promise.reject(new AutotaskError(`fieldCatalog: the client exposes no getUdfInfo read for "${resource}"`, { code: "INVALID_RESPONSE", category: "server" }))
|
|
16167
16576
|
};
|
|
16168
16577
|
}
|
|
16169
|
-
|
|
16578
|
+
function catalogProjector(kind, ctx) {
|
|
16579
|
+
if (ctx.compact) {
|
|
16580
|
+
const keepValues = ctx.labels && ctx.fieldsFilter !== void 0;
|
|
16581
|
+
if (kind === "fields") return keepValues ? compactCatalogLabelledFieldsView : compactCatalogFieldsView;
|
|
16582
|
+
if (kind === "udf") return keepValues ? compactCatalogLabelledUdfView : compactCatalogUdfView;
|
|
16583
|
+
}
|
|
16584
|
+
if (kind === "fields") return ctx.labels ? catalogLabelledFieldsView : catalogFieldsView;
|
|
16585
|
+
if (kind === "udf") return ctx.labels ? catalogLabelledUdfView : catalogUdfView;
|
|
16586
|
+
return void 0;
|
|
16587
|
+
}
|
|
16588
|
+
async function readKind(ctx, resource, kind, fetch2, holder, projector = catalogProjector(kind, ctx)) {
|
|
16170
16589
|
const cache = ctx.client.http.fieldCache;
|
|
16171
16590
|
const peek = cache !== void 0 && !ctx.fresh ? cache.peek(fieldKey(resource, kind)) : { hit: false, age: null };
|
|
16172
16591
|
if (peek.hit && cache !== void 0) {
|
|
16173
|
-
|
|
16592
|
+
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)));
|
|
16593
|
+
return { kind, peek, outcome: { status: "fulfilled", value } };
|
|
16174
16594
|
}
|
|
16175
16595
|
try {
|
|
16176
|
-
const value = await fetch2();
|
|
16596
|
+
const value = projector === void 0 ? await fetch2() : await readMetadataProjection(holder, kind, projector, fetch2);
|
|
16177
16597
|
return { kind, peek, outcome: { status: "fulfilled", value } };
|
|
16178
16598
|
} catch (error) {
|
|
16179
16599
|
if (!isAutotaskError(error) || error.code === "ABORTED") throw error;
|
|
@@ -16181,7 +16601,7 @@ async function readKind(ctx, resource, kind, fetch2) {
|
|
|
16181
16601
|
}
|
|
16182
16602
|
}
|
|
16183
16603
|
async function sweepResource(ctx, resource, tally, reads) {
|
|
16184
|
-
const { fieldsFilter
|
|
16604
|
+
const { fieldsFilter } = ctx;
|
|
16185
16605
|
const fieldOp = ctx.fieldOps.get(resource);
|
|
16186
16606
|
if (fieldOp === void 0) return void 0;
|
|
16187
16607
|
const apiEntity = apiEntityFor(fieldOp);
|
|
@@ -16200,12 +16620,6 @@ async function sweepResource(ctx, resource, tally, reads) {
|
|
|
16200
16620
|
wire: 0,
|
|
16201
16621
|
error: null
|
|
16202
16622
|
};
|
|
16203
|
-
const projectList = (kind, list) => {
|
|
16204
|
-
const projected = list.map((f) => projectFieldRow(f, labels, kind === "udf"));
|
|
16205
|
-
if (kind === "fields") applyFieldsFilter(projected, fieldsFilter, row);
|
|
16206
|
-
else row.udf = projected;
|
|
16207
|
-
for (const f of list) if (exposesPicklistValues(f)) tally.anyPicklistValues = true;
|
|
16208
|
-
};
|
|
16209
16623
|
let allCached = true;
|
|
16210
16624
|
const ages = [];
|
|
16211
16625
|
for (const { kind, peek, outcome } of reads) {
|
|
@@ -16223,19 +16637,17 @@ async function sweepResource(ctx, resource, tally, reads) {
|
|
|
16223
16637
|
if (kind === "info") {
|
|
16224
16638
|
row.info = value ?? null;
|
|
16225
16639
|
} else {
|
|
16226
|
-
|
|
16640
|
+
const view = value;
|
|
16641
|
+
if (view.rows === null) {
|
|
16227
16642
|
if (row.error === null) row.error = { code: "INVALID_RESPONSE", message: `fieldCatalog: the ${kind} response for ${resource} was not a list` };
|
|
16228
16643
|
continue;
|
|
16229
16644
|
}
|
|
16230
|
-
|
|
16645
|
+
if (kind === "fields") applyFieldsFilter(view.rows, fieldsFilter, row, view.flags);
|
|
16646
|
+
else row.udf = view.rows;
|
|
16647
|
+
if (view.exposesValues) tally.anyPicklistValues = true;
|
|
16231
16648
|
}
|
|
16232
16649
|
}
|
|
16233
16650
|
row.cache = allCached ? { hit: true, age: ages.length > 0 ? Math.max(...ages) : 0 } : { hit: false, age: null };
|
|
16234
|
-
if (ctx.compact) {
|
|
16235
|
-
const keepValues = labels && fieldsFilter !== void 0;
|
|
16236
|
-
if (row.fields !== void 0) row.fields = row.fields.map((f) => compactFieldRow(f, false, keepValues));
|
|
16237
|
-
if (Array.isArray(row.udf)) row.udf = row.udf.map((f) => compactFieldRow(f, true, keepValues));
|
|
16238
|
-
}
|
|
16239
16651
|
const declared = await derivedFieldsFor(resource);
|
|
16240
16652
|
if (declared.length > 0) {
|
|
16241
16653
|
const byField = new Map(declared.map((d) => [d.field, d]));
|
|
@@ -16251,7 +16663,7 @@ async function sweepResource(ctx, resource, tally, reads) {
|
|
|
16251
16663
|
}
|
|
16252
16664
|
return row;
|
|
16253
16665
|
}
|
|
16254
|
-
async function
|
|
16666
|
+
async function prepareCatalog(client, opts) {
|
|
16255
16667
|
validateCatalogOptsShape(opts);
|
|
16256
16668
|
const { fieldOps, udfCapable, resources: allResources } = await capabilitySets();
|
|
16257
16669
|
const include = resolveInclude(opts);
|
|
@@ -16260,11 +16672,22 @@ async function fieldCatalog(client, opts) {
|
|
|
16260
16672
|
const labels = resolveLabels(opts);
|
|
16261
16673
|
const { compact, maxBytes } = resolveSizeOpts(opts);
|
|
16262
16674
|
assertWithinWireCap(targets.length, include.length);
|
|
16675
|
+
const ctx = { client, include, fieldsFilter, labels, compact, fresh: opts?.fresh === true, fieldOps, udfCapable };
|
|
16676
|
+
return { ctx, targets, compact, maxBytes };
|
|
16677
|
+
}
|
|
16678
|
+
async function fieldCatalogPicklists(client, resource, fields) {
|
|
16679
|
+
const { ctx } = await prepareCatalog(client, { resources: [resource], labels: true, fields: [...fields] });
|
|
16680
|
+
const holder = client[camelKey(resource)];
|
|
16681
|
+
const [read] = await mapReadTasks(client.http, [resource], () => readKind(ctx, resource, "fields", kindFetches(holder, resource).fields, holder, picklistsView));
|
|
16682
|
+
return read.outcome.status === "fulfilled" ? read.outcome.value : null;
|
|
16683
|
+
}
|
|
16684
|
+
async function fieldCatalog(client, opts) {
|
|
16685
|
+
const { ctx, targets, compact, maxBytes } = await prepareCatalog(client, opts);
|
|
16686
|
+
const { include, labels, fieldOps, udfCapable } = ctx;
|
|
16263
16687
|
const cache = client.http.fieldCache;
|
|
16264
16688
|
const zone = client.config.zone ?? "unknown";
|
|
16265
16689
|
const rows = [];
|
|
16266
16690
|
const tally = { wireUsed: 0, anyPicklistValues: false };
|
|
16267
|
-
const ctx = { client, fieldsFilter, labels, compact, fresh: opts?.fresh === true, fieldOps, udfCapable };
|
|
16268
16691
|
for (const resource of targets) {
|
|
16269
16692
|
apiEntityFor(fieldOps.get(resource));
|
|
16270
16693
|
if (ctx.fresh) cache?.invalidate(`${resource}:`);
|
|
@@ -16272,9 +16695,9 @@ async function fieldCatalog(client, opts) {
|
|
|
16272
16695
|
const tasks = targets.flatMap((resource) => {
|
|
16273
16696
|
const holder = client[camelKey(resource)];
|
|
16274
16697
|
const fetches = kindFetches(holder, resource);
|
|
16275
|
-
return include.map((kind) => ({ resource, kind, fetch: fetches[kind] }));
|
|
16698
|
+
return include.map((kind) => ({ resource, kind, fetch: fetches[kind], holder }));
|
|
16276
16699
|
});
|
|
16277
|
-
const reads = await mapReadTasks(client.http, tasks, ({ resource, kind, fetch: fetch2 }) => readKind(ctx, resource, kind, fetch2));
|
|
16700
|
+
const reads = await mapReadTasks(client.http, tasks, ({ resource, kind, fetch: fetch2, holder }) => readKind(ctx, resource, kind, fetch2, holder));
|
|
16278
16701
|
for (let index = 0; index < targets.length; index += 1) {
|
|
16279
16702
|
const start = index * include.length;
|
|
16280
16703
|
const row = await sweepResource(ctx, targets[index], tally, reads.slice(start, start + include.length));
|
|
@@ -16876,19 +17299,12 @@ async function resolveCompositeNames(http, plan, opts = {}) {
|
|
|
16876
17299
|
};
|
|
16877
17300
|
});
|
|
16878
17301
|
}
|
|
16879
|
-
|
|
17302
|
+
let picklists = null;
|
|
16880
17303
|
if (plan.labelFields.length > 0) {
|
|
16881
17304
|
tasks.push(async () => {
|
|
16882
17305
|
try {
|
|
16883
17306
|
const labelResource = plan.labelResource ?? "tickets";
|
|
16884
|
-
|
|
16885
|
-
const row = catalog.rows.find((r) => r.resource === labelResource);
|
|
16886
|
-
if (row !== void 0 && row.error === null && row.fields !== void 0) {
|
|
16887
|
-
for (const f of plan.labelFields) {
|
|
16888
|
-
const frow = row.fields.find((x) => x.name === f);
|
|
16889
|
-
picklists[f] = frow?.picklistValues;
|
|
16890
|
-
}
|
|
16891
|
-
}
|
|
17307
|
+
picklists = await fieldCatalogPicklists(client, labelResource, plan.labelFields);
|
|
16892
17308
|
} catch (err) {
|
|
16893
17309
|
if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
16894
17310
|
}
|
|
@@ -16924,17 +17340,17 @@ async function resolveCompositeNames(http, plan, opts = {}) {
|
|
|
16924
17340
|
recordName: (table, id) => section.rows[`${table}:${id}`]?.name ?? null,
|
|
16925
17341
|
labelFor: (field, value) => {
|
|
16926
17342
|
if (value === null || value === void 0) return null;
|
|
16927
|
-
const values = picklists
|
|
17343
|
+
const values = picklists?.get(field);
|
|
16928
17344
|
if (values === void 0) {
|
|
16929
17345
|
section.reasons[field] = FIELD_CATALOG_HONESTY_NOTE;
|
|
16930
17346
|
return null;
|
|
16931
17347
|
}
|
|
16932
|
-
const hit = values
|
|
16933
|
-
if (hit
|
|
17348
|
+
const hit = lookupPicklist(values, value);
|
|
17349
|
+
if (!hit.found) {
|
|
16934
17350
|
if (String(value) !== "0") section.reasons[field] = PICKLIST_VALUE_NOT_SERVED_NOTE;
|
|
16935
17351
|
return null;
|
|
16936
17352
|
}
|
|
16937
|
-
return
|
|
17353
|
+
return hit.label;
|
|
16938
17354
|
}
|
|
16939
17355
|
};
|
|
16940
17356
|
}
|
|
@@ -16996,8 +17412,7 @@ function subscriberError(error, operation) {
|
|
|
16996
17412
|
};
|
|
16997
17413
|
return copyValue(error);
|
|
16998
17414
|
}
|
|
16999
|
-
function cachedRead(http, cache, key, path, operation, request, fresh, shouldStore) {
|
|
17000
|
-
if (cache === void 0) return request();
|
|
17415
|
+
function cachedRead(http, cache, key, path, operation, request, fresh, shouldStore, projector) {
|
|
17001
17416
|
let ownsLoader = false;
|
|
17002
17417
|
const loader = (signal) => {
|
|
17003
17418
|
ownsLoader = true;
|
|
@@ -17012,11 +17427,21 @@ function cachedRead(http, cache, key, path, operation, request, fresh, shouldSto
|
|
|
17012
17427
|
suggestedAction: "The caller aborted; re-issue the call if still needed."
|
|
17013
17428
|
})
|
|
17014
17429
|
};
|
|
17015
|
-
|
|
17430
|
+
const select = (value) => {
|
|
17431
|
+
if (options.signal?.aborted) throw options.abortError();
|
|
17432
|
+
const selected = projector === void 0 ? value : projectMetadata(value, projector);
|
|
17433
|
+
if (options.signal?.aborted) throw options.abortError();
|
|
17434
|
+
return selected;
|
|
17435
|
+
};
|
|
17436
|
+
if (cache === void 0) return request().then(select);
|
|
17437
|
+
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);
|
|
17438
|
+
return load(fresh).catch((error) => {
|
|
17016
17439
|
if (ownsLoader || !(error instanceof AutotaskError) || error.details?.budgetScope !== "client" || error.notSent !== true) throw error;
|
|
17017
17440
|
if (options.signal?.aborted) throw options.abortError();
|
|
17018
|
-
const
|
|
17019
|
-
|
|
17441
|
+
const projected = projector !== void 0 && typeof cache.getProjected === "function";
|
|
17442
|
+
const warm = projected ? cache.getProjected(key, projector) : cache.get(key);
|
|
17443
|
+
if (options.signal?.aborted) throw options.abortError();
|
|
17444
|
+
return warm !== void 0 ? projected ? warm : select(warm) : load(true);
|
|
17020
17445
|
}).catch((error) => {
|
|
17021
17446
|
if (!(error instanceof AutotaskError)) throw error;
|
|
17022
17447
|
const failure = subscriberError(error, operation);
|
|
@@ -17035,7 +17460,7 @@ function cachedRecordGet(http, path, operation, fresh = false) {
|
|
|
17035
17460
|
fresh
|
|
17036
17461
|
);
|
|
17037
17462
|
}
|
|
17038
|
-
function cachedMetadataGet(http, resource, kind, path, operation, unwrap, fresh = false, maxRetries) {
|
|
17463
|
+
function cachedMetadataGet(http, resource, kind, path, operation, unwrap, fresh = false, maxRetries, projector) {
|
|
17039
17464
|
const cache = http.fieldCache;
|
|
17040
17465
|
const request = (signal) => {
|
|
17041
17466
|
return http.request({ method: "GET", path, operation, signal, maxRetries }).then(unwrap).catch((error) => {
|
|
@@ -17049,12 +17474,13 @@ function cachedMetadataGet(http, resource, kind, path, operation, unwrap, fresh
|
|
|
17049
17474
|
if (value === null || value === void 0) return false;
|
|
17050
17475
|
if (Array.isArray(value)) return value.length > 0;
|
|
17051
17476
|
return typeof value !== "object" || Object.keys(value).length > 0;
|
|
17052
|
-
});
|
|
17477
|
+
}, projector);
|
|
17053
17478
|
}
|
|
17054
17479
|
|
|
17055
17480
|
// src/field-sets.ts
|
|
17056
17481
|
var MODEL_FIELD_SETS = {
|
|
17057
17482
|
"appointments": ["id", "createDateTime", "creatorResourceID", "description", "endDateTime", "resourceID", "startDateTime", "title", "updateDateTime"],
|
|
17483
|
+
"attachment_info": ["id", "articleID", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "companyID", "companyNoteID", "configurationItemID", "configurationItemNoteID", "contentType", "contractID", "contractNoteID", "creatorType", "documentID", "expenseItemID", "expenseReportID", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentAttachmentID", "parentID", "parentType", "projectID", "projectNoteID", "publish", "resourceID", "salesOrderID", "taskID", "taskNoteID", "ticketID", "ticketNoteID", "timeEntryID", "title", "soapParentPropertyId"],
|
|
17058
17484
|
"billing_codes": ["id", "afterHoursWorkType", "billingCodeType", "department", "description", "externalNumber", "generalLedgerAccount", "isActive", "isExcludedFromNewContracts", "markupRate", "name", "taxCategoryID", "unitCost", "unitPrice", "useType"],
|
|
17059
17485
|
"billing_item_approval_levels": ["id", "approvalDateTime", "approvalLevel", "approvalResourceID", "timeEntryID"],
|
|
17060
17486
|
"billing_items": ["id", "accountManagerWhenApprovedID", "billingCodeID", "billingItemType", "companyID", "configurationItemID", "contractBlockID", "contractChargeID", "contractID", "contractServiceAdjustmentID", "contractServiceBundleAdjustmentID", "contractServiceBundleID", "contractServiceBundlePeriodID", "contractServiceID", "contractServicePeriodID", "description", "expenseItemID", "extendedPrice", "internalCurrencyExtendedPrice", "internalCurrencyRate", "internalCurrencyTaxDollars", "internalCurrencyTotalAmount", "invoiceID", "itemApproverID", "itemDate", "itemName", "lineItemFullDescription", "lineItemGroupDescription", "milestoneID", "nonBillable", "organizationalLevelAssociationID", "ourCost", "postedDate", "postedOnTime", "projectChargeID", "projectID", "purchaseOrderNumber", "quantity", "rate", "roleID", "serviceBundleID", "serviceID", "sortOrderID", "subType", "taskID", "taxDollars", "ticketChargeID", "ticketID", "timeEntryID", "totalAmount", "vendorID", "webServiceDate"],
|
|
@@ -17064,7 +17490,9 @@ var MODEL_FIELD_SETS = {
|
|
|
17064
17490
|
"classification_icons": ["id", "description", "isActive", "isSystem", "name", "relativeUrl"],
|
|
17065
17491
|
"companies": ["id", "additionalAddressInformation", "address1", "address2", "alternatePhone1", "alternatePhone2", "apiVendorID", "assetValue", "billToCompanyLocationID", "billToAdditionalAddressInformation", "billingAddress1", "billingAddress2", "billToAddressToUse", "billToAttention", "billToCity", "billToCountryID", "billToState", "billToZipCode", "city", "classification", "companyCategoryID", "companyName", "companyNumber", "companyType", "competitorID", "countryID", "createDate", "createdByResourceID", "currencyID", "fax", "impersonatorCreatorResourceID", "invoiceEmailMessageID", "invoiceMethod", "invoiceNonContractItemsToParentCompany", "invoiceTemplateID", "isActive", "isClientPortalActive", "isEnabledForComanaged", "isSample", "isTaskFireActive", "isTaxExempt", "lastActivityDate", "lastTrackedModifiedDateTime", "marketSegmentID", "ownerResourceID", "parentCompanyID", "phone", "postalCode", "purchaseOrderTemplateID", "quoteEmailMessageID", "quoteTemplateID", "sicCode", "state", "stockMarket", "stockSymbol", "surveyCompanyRating", "taxID", "taxRegionID", "territoryID", "webAddress", "userDefinedFields"],
|
|
17066
17492
|
"company_alerts": ["id", "alertText", "alertTypeID", "companyID", "soapParentPropertyId"],
|
|
17493
|
+
"company_attachments": ["id", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "companyID", "companyNoteID", "contentType", "creatorType", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentAttachmentID", "parentID", "publish", "salesOrderID", "title", "data", "parentType", "soapParentPropertyId", "isTaskAttachment"],
|
|
17067
17494
|
"company_locations": ["id", "address1", "address2", "alternatePhone1", "alternatePhone2", "city", "companyID", "countryID", "description", "fax", "isActive", "isPrimary", "isTaxExempt", "overrideCompanyTaxSettings", "name", "phone", "postalCode", "roundtripDistance", "state", "taxRegionID", "soapParentPropertyId"],
|
|
17495
|
+
"company_note_attachments": ["id", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "companyID", "companyNoteID", "contentType", "creatorType", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentID", "publish", "salesOrderID", "title", "data", "parentType", "soapParentPropertyId", "isTaskAttachment"],
|
|
17068
17496
|
"company_notes": ["id", "actionType", "assignedResourceID", "companyID", "completedDateTime", "contactID", "createDateTime", "endDateTime", "impersonatorCreatorResourceID", "impersonatorUpdaterResourceID", "lastModifiedDate", "name", "note", "opportunityID", "startDateTime", "soapParentPropertyId"],
|
|
17069
17497
|
"company_site_configurations": ["id", "companyID", "locationName", "soapParentPropertyId", "userDefinedFields"],
|
|
17070
17498
|
"company_webhooks": ["id", "deactivationUrl", "isActive", "isReady", "isSubscribedToCreateEvents", "isSubscribedToDeleteEvents", "isSubscribedToUpdateEvents", "name", "notificationEmailAddress", "ownerResourceID", "secretKey", "sendThresholdExceededNotification", "webhookGUID", "webhookUrl"],
|
|
@@ -17184,9 +17612,12 @@ var MODEL_FIELD_SETS = {
|
|
|
17184
17612
|
};
|
|
17185
17613
|
var MODEL_DATE_FIELDS = {
|
|
17186
17614
|
"appointments": ["createDateTime", "endDateTime", "startDateTime", "updateDateTime"],
|
|
17615
|
+
"attachment_info": ["attachDate"],
|
|
17187
17616
|
"billing_item_approval_levels": ["approvalDateTime"],
|
|
17188
17617
|
"billing_items": ["itemDate", "postedDate", "postedOnTime", "webServiceDate"],
|
|
17189
17618
|
"companies": ["createDate", "lastActivityDate", "lastTrackedModifiedDateTime"],
|
|
17619
|
+
"company_attachments": ["attachDate"],
|
|
17620
|
+
"company_note_attachments": ["attachDate"],
|
|
17190
17621
|
"company_notes": ["completedDateTime", "createDateTime", "endDateTime", "lastModifiedDate", "startDateTime"],
|
|
17191
17622
|
"configuration_item_billing_product_associations": ["effectiveDate", "expirationDate"],
|
|
17192
17623
|
"configuration_item_dns_records": ["createDateTime"],
|
|
@@ -17547,6 +17978,12 @@ function validateWalkBag(walk, prefix, details) {
|
|
|
17547
17978
|
return wr;
|
|
17548
17979
|
}
|
|
17549
17980
|
|
|
17981
|
+
// src/operations/query-pages.ts
|
|
17982
|
+
var PREPARE_BOUNDED_QUERY = /* @__PURE__ */ Symbol.for("node-autotask.prepare-bounded-query.v1");
|
|
17983
|
+
function assertPageReadActive(operation) {
|
|
17984
|
+
if (ambientCallerSignal()?.aborted) throw new AutotaskAbortError("Bounded query page consumption aborted by the caller", { operation });
|
|
17985
|
+
}
|
|
17986
|
+
|
|
17550
17987
|
// src/resources/base/query.ts
|
|
17551
17988
|
var QueryBase = class {
|
|
17552
17989
|
httpClient;
|
|
@@ -17721,6 +18158,22 @@ var QueryBase = class {
|
|
|
17721
18158
|
* Pure read; no mutation paths involved.
|
|
17722
18159
|
*/
|
|
17723
18160
|
async queryBounded(params) {
|
|
18161
|
+
return this.boundedQueryResult(params);
|
|
18162
|
+
}
|
|
18163
|
+
/** Internal governed consumer hook; all validation and paging stay shared. @internal */
|
|
18164
|
+
[PREPARE_BOUNDED_QUERY]() {
|
|
18165
|
+
const guard = captureReadGuard(this.http, `${this.config.key}.query`);
|
|
18166
|
+
return {
|
|
18167
|
+
guard,
|
|
18168
|
+
consume: async (params, consume) => {
|
|
18169
|
+
guard();
|
|
18170
|
+
const { items, ...summary } = await this.boundedQueryResult(params, consume);
|
|
18171
|
+
guard();
|
|
18172
|
+
return summary;
|
|
18173
|
+
}
|
|
18174
|
+
};
|
|
18175
|
+
}
|
|
18176
|
+
async boundedQueryResult(params, consume) {
|
|
17724
18177
|
if (Array.isArray(params)) {
|
|
17725
18178
|
throw new AutotaskConfigError(
|
|
17726
18179
|
"queryBounded: params must be an object { filter?, limit?, latest?, includeFields? } \u2014 a bare conditions array is not accepted (wrap it: { filter: [...] })"
|
|
@@ -17767,13 +18220,28 @@ var QueryBase = class {
|
|
|
17767
18220
|
if (latest !== void 0) {
|
|
17768
18221
|
return this.applyNoteChars(await this.latestWalk(walkParams, Math.max(limit, latest), latest), noteChars);
|
|
17769
18222
|
}
|
|
17770
|
-
|
|
17771
|
-
const
|
|
17772
|
-
|
|
18223
|
+
let truncatedFields = 0;
|
|
18224
|
+
const sink = consume === void 0 ? void 0 : async (rows, page) => {
|
|
18225
|
+
const projected = this.applyNoteChars({ items: rows, fetched: rows.length, hasMore: false, pagesWalked: 1 }, noteChars);
|
|
18226
|
+
truncatedFields += projected.noteCharsTruncated ?? 0;
|
|
18227
|
+
assertPageReadActive(`${this.config.key}.query`);
|
|
18228
|
+
try {
|
|
18229
|
+
await consume({ items: projected.items, page });
|
|
18230
|
+
} catch (error) {
|
|
18231
|
+
assertPageReadActive(`${this.config.key}.query`);
|
|
18232
|
+
throw error;
|
|
18233
|
+
}
|
|
18234
|
+
assertPageReadActive(`${this.config.key}.query`);
|
|
18235
|
+
};
|
|
18236
|
+
const { items, fetched, pages: pages2, guard, sliced, cursor, names } = await this.walkBounded(walkParams, cap, limit, labelPages, sink);
|
|
18237
|
+
const hasMore = maxRows === void 0 ? (fetched >= cap || guard) && (sliced > 0 || cursor !== null) : guard || sliced > 0 || cursor !== null;
|
|
18238
|
+
const result = { items, fetched, hasMore, pagesWalked: pages2 };
|
|
17773
18239
|
if (maxRows !== void 0) result.truncated = hasMore;
|
|
17774
18240
|
if (names !== void 0) result.names = names;
|
|
17775
18241
|
this.stampEmptyQueryResult(result, params);
|
|
17776
|
-
return this.applyNoteChars(result, noteChars);
|
|
18242
|
+
if (consume === void 0) return this.applyNoteChars(result, noteChars);
|
|
18243
|
+
if (truncatedFields > 0) result.noteCharsTruncated = truncatedFields;
|
|
18244
|
+
return result;
|
|
17777
18245
|
}
|
|
17778
18246
|
/** Issue #61 (slice A): the noteChars truncation at the SINGLE chokepoint
|
|
17779
18247
|
* of `queryBounded` — the normal walk and the `latest` paths both
|
|
@@ -17802,9 +18270,10 @@ var QueryBase = class {
|
|
|
17802
18270
|
* SOFT stop (never a throw). ONE per-walk closure (walks never share
|
|
17803
18271
|
* state).
|
|
17804
18272
|
* @internal */
|
|
17805
|
-
async walkBounded(p, limit, pageSizeBase, labelPages = false) {
|
|
18273
|
+
async walkBounded(p, limit, pageSizeBase, labelPages = false, consume) {
|
|
17806
18274
|
const state2 = { cursor: null };
|
|
17807
18275
|
const items = [];
|
|
18276
|
+
let fetched = 0;
|
|
17808
18277
|
let pages2 = 0;
|
|
17809
18278
|
let sliced = 0;
|
|
17810
18279
|
let guard = false;
|
|
@@ -17816,6 +18285,7 @@ var QueryBase = class {
|
|
|
17816
18285
|
guard = true;
|
|
17817
18286
|
break;
|
|
17818
18287
|
}
|
|
18288
|
+
if (consume !== void 0) assertPageReadActive(`${this.config.key}.query`);
|
|
17819
18289
|
const page = await this.fetchPage(p, pages2 + 1, pageSize, state2);
|
|
17820
18290
|
pages2 += 1;
|
|
17821
18291
|
if (labelPages && this.http.client !== void 0) {
|
|
@@ -17826,18 +18296,20 @@ var QueryBase = class {
|
|
|
17826
18296
|
Object.assign(nameReasons, labelled.names.reasons);
|
|
17827
18297
|
}
|
|
17828
18298
|
}
|
|
17829
|
-
const remaining = limit -
|
|
18299
|
+
const remaining = limit - fetched;
|
|
17830
18300
|
const take = page.items.slice(0, remaining);
|
|
17831
18301
|
sliced += Math.max(0, page.items.length - remaining);
|
|
17832
|
-
|
|
17833
|
-
if (
|
|
18302
|
+
fetched += take.length;
|
|
18303
|
+
if (consume === void 0) items.push(...take);
|
|
18304
|
+
else await consume(take, pages2);
|
|
18305
|
+
if (fetched >= limit) break;
|
|
17834
18306
|
if (!page.hasMore || page.items.length === 0) break;
|
|
17835
18307
|
}
|
|
17836
18308
|
const names = nameNotes.size === 0 ? void 0 : {
|
|
17837
18309
|
note: [...nameNotes].join("; "),
|
|
17838
18310
|
...Object.keys(nameReasons).length === 0 ? {} : { reasons: nameReasons }
|
|
17839
18311
|
};
|
|
17840
|
-
return { items, pages: pages2, guard, sliced, cursor: state2.cursor, ...names === void 0 ? {} : { names } };
|
|
18312
|
+
return { items, fetched, pages: pages2, guard, sliced, cursor: state2.cursor, ...names === void 0 ? {} : { names } };
|
|
17841
18313
|
}
|
|
17842
18314
|
/** A walk stop is TRUNCATED when the 1000-page guard fired, or the limit
|
|
17843
18315
|
* was met with a live next cursor (or a sliced final page): rows exist
|
|
@@ -17861,7 +18333,7 @@ var QueryBase = class {
|
|
|
17861
18333
|
* speculation).
|
|
17862
18334
|
* @internal */
|
|
17863
18335
|
stampEmptyQueryResult(result, params) {
|
|
17864
|
-
if (result.
|
|
18336
|
+
if (result.fetched !== 0) return;
|
|
17865
18337
|
result.blindSurface = blindStampFor(BLIND_SURFACE_STAMPS[this.config.key]?.query, params?.filter);
|
|
17866
18338
|
const pinnedReason = normalizedConditions(params?.filter) === void 0 ? EMPTY_REASON_STAMPS[this.config.key]?.query : void 0;
|
|
17867
18339
|
if (result.blindSurface !== void 0 || pinnedReason !== void 0) {
|
|
@@ -18097,7 +18569,7 @@ var QueryBase = class {
|
|
|
18097
18569
|
};
|
|
18098
18570
|
|
|
18099
18571
|
// src/resources/base/meta.ts
|
|
18100
|
-
var MetaBase = class extends QueryBase {
|
|
18572
|
+
var MetaBase = class _MetaBase extends QueryBase {
|
|
18101
18573
|
// ------------------------------------------------------------------
|
|
18102
18574
|
// Single-record reads
|
|
18103
18575
|
// ------------------------------------------------------------------
|
|
@@ -18244,21 +18716,7 @@ var MetaBase = class extends QueryBase {
|
|
|
18244
18716
|
* entity's entries via the fieldCache's `invalidate` first — the trio
|
|
18245
18717
|
* keeps its no-arg surface (the registry/MCP arity pin). */
|
|
18246
18718
|
async getEntityInfo() {
|
|
18247
|
-
return await this.
|
|
18248
|
-
"info",
|
|
18249
|
-
`${this.resourcePath}/entityInformation`,
|
|
18250
|
-
`${this.config.key}.getEntityInfo`,
|
|
18251
|
-
(res) => {
|
|
18252
|
-
const body = isRecord2(res) ? res : void 0;
|
|
18253
|
-
if (body === void 0 || !isRecord2(body.info)) {
|
|
18254
|
-
throw new AutotaskError("Expected the entityInformation envelope { info }; got a different shape", {
|
|
18255
|
-
code: "INVALID_RESPONSE",
|
|
18256
|
-
category: "server"
|
|
18257
|
-
});
|
|
18258
|
-
}
|
|
18259
|
-
return body.info;
|
|
18260
|
-
}
|
|
18261
|
-
);
|
|
18719
|
+
return await this.metadataRead("info");
|
|
18262
18720
|
}
|
|
18263
18721
|
/** `GET /V1.0/<E>/entityInformation/fields` → `{ fields }` unwrapped.
|
|
18264
18722
|
* Goes through the field cache when it is present (issue #80:
|
|
@@ -18268,12 +18726,7 @@ var MetaBase = class extends QueryBase {
|
|
|
18268
18726
|
* entity's entries via the fieldCache's `invalidate` first — the trio
|
|
18269
18727
|
* keeps its no-arg surface (the registry/MCP arity pin). */
|
|
18270
18728
|
async getFieldInfo() {
|
|
18271
|
-
return await this.
|
|
18272
|
-
"fields",
|
|
18273
|
-
`${this.resourcePath}/entityInformation/fields`,
|
|
18274
|
-
`${this.config.key}.getFieldInfo`,
|
|
18275
|
-
(res) => this.unwrapFields(res, "FieldInformationResultModel")
|
|
18276
|
-
);
|
|
18729
|
+
return await this.metadataRead("fields");
|
|
18277
18730
|
}
|
|
18278
18731
|
/** `GET /V1.0/<E>/entityInformation/userDefinedFields` → `{ fields }` unwrapped.
|
|
18279
18732
|
* Goes through the field cache when it is present (issue #80:
|
|
@@ -18283,12 +18736,29 @@ var MetaBase = class extends QueryBase {
|
|
|
18283
18736
|
* entity's entries via the fieldCache's `invalidate` first — the trio
|
|
18284
18737
|
* keeps its no-arg surface (the registry/MCP arity pin). */
|
|
18285
18738
|
async getUdfInfo() {
|
|
18286
|
-
return await this.
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
);
|
|
18739
|
+
return await this.metadataRead("udf");
|
|
18740
|
+
}
|
|
18741
|
+
/** Capture the owning transport's context; overridden readers keep their original path. @internal */
|
|
18742
|
+
[METADATA_PROJECTION](kind, projector) {
|
|
18743
|
+
const reader = kind === "info" ? "getEntityInfo" : kind === "fields" ? "getFieldInfo" : "getUdfInfo";
|
|
18744
|
+
const guard = captureReadGuard(this.http, `${this.config.key}.${reader}`);
|
|
18745
|
+
guard();
|
|
18746
|
+
if (this[reader] !== _MetaBase.prototype[reader] || this.cachedMeta !== _MetaBase.prototype.cachedMeta) return { guard };
|
|
18747
|
+
return { guard, projected: this.metadataRead(kind, projector) };
|
|
18748
|
+
}
|
|
18749
|
+
metadataRead(kind, projector) {
|
|
18750
|
+
const suffix = kind === "info" ? "" : kind === "fields" ? "/fields" : "/userDefinedFields";
|
|
18751
|
+
const operation = kind === "info" ? "getEntityInfo" : kind === "fields" ? "getFieldInfo" : "getUdfInfo";
|
|
18752
|
+
const path = `${this.resourcePath}/entityInformation${suffix}`;
|
|
18753
|
+
const unwrap = (res) => {
|
|
18754
|
+
if (kind !== "info") return this.unwrapFields(res, kind === "fields" ? "FieldInformationResultModel" : "UserDefinedFieldInformationResultModel");
|
|
18755
|
+
const body = isRecord2(res) ? res : void 0;
|
|
18756
|
+
if (body === void 0 || !isRecord2(body.info)) {
|
|
18757
|
+
throw new AutotaskError("Expected the entityInformation envelope { info }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
18758
|
+
}
|
|
18759
|
+
return body.info;
|
|
18760
|
+
};
|
|
18761
|
+
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);
|
|
18292
18762
|
}
|
|
18293
18763
|
/** @internal */
|
|
18294
18764
|
unwrapFields(body, envelopeName) {
|
|
@@ -19330,6 +19800,16 @@ var SIMPLE_RESOURCES = [
|
|
|
19330
19800
|
helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
19331
19801
|
opForms: { get: "global", create: "global", update: "global", delete: "global" }
|
|
19332
19802
|
},
|
|
19803
|
+
{
|
|
19804
|
+
key: "attachment_info",
|
|
19805
|
+
accessor: "attachmentInfo",
|
|
19806
|
+
resourcePath: "/V1.0/AttachmentInfo",
|
|
19807
|
+
deletable: false,
|
|
19808
|
+
udfCapable: false,
|
|
19809
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
19810
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
19811
|
+
opForms: { get: "global" }
|
|
19812
|
+
},
|
|
19333
19813
|
{
|
|
19334
19814
|
key: "billing_codes",
|
|
19335
19815
|
accessor: "billingCodes",
|
|
@@ -19421,6 +19901,20 @@ var SIMPLE_RESOURCES = [
|
|
|
19421
19901
|
helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
19422
19902
|
opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
|
|
19423
19903
|
},
|
|
19904
|
+
{
|
|
19905
|
+
key: "company_attachments",
|
|
19906
|
+
accessor: "companyAttachments",
|
|
19907
|
+
resourcePath: "/V1.0/CompanyAttachments",
|
|
19908
|
+
parentScopedPath: "/V1.0/Companies/{parentId}/Attachments",
|
|
19909
|
+
parentPath: "/V1.0/Companies",
|
|
19910
|
+
parentField: "companyID",
|
|
19911
|
+
deletable: true,
|
|
19912
|
+
udfCapable: false,
|
|
19913
|
+
attachmentGet: true,
|
|
19914
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: false, download: false },
|
|
19915
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
19916
|
+
opForms: { get: "scoped", create: "scoped", delete: "scoped" }
|
|
19917
|
+
},
|
|
19424
19918
|
{
|
|
19425
19919
|
key: "company_locations",
|
|
19426
19920
|
accessor: "companyLocations",
|
|
@@ -19435,6 +19929,20 @@ var SIMPLE_RESOURCES = [
|
|
|
19435
19929
|
helpers: { search: true, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
19436
19930
|
opForms: { get: "scoped", create: "scoped", update: "scoped", delete: "scoped" }
|
|
19437
19931
|
},
|
|
19932
|
+
{
|
|
19933
|
+
key: "company_note_attachments",
|
|
19934
|
+
accessor: "companyNoteAttachments",
|
|
19935
|
+
resourcePath: "/V1.0/CompanyNoteAttachments",
|
|
19936
|
+
parentScopedPath: "/V1.0/CompanyNotes/{parentId}/Attachments",
|
|
19937
|
+
parentPath: "/V1.0/CompanyNotes",
|
|
19938
|
+
parentField: "companyNoteID",
|
|
19939
|
+
deletable: true,
|
|
19940
|
+
udfCapable: false,
|
|
19941
|
+
attachmentGet: true,
|
|
19942
|
+
ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: false, download: false },
|
|
19943
|
+
helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
|
|
19944
|
+
opForms: { get: "scoped", create: "scoped", delete: "scoped" }
|
|
19945
|
+
},
|
|
19438
19946
|
{
|
|
19439
19947
|
key: "company_notes",
|
|
19440
19948
|
accessor: "companyNotes",
|
|
@@ -19521,7 +20029,7 @@ var SIMPLE_RESOURCES = [
|
|
|
19521
20029
|
resourcePath: "/V1.0/ConfigurationItemDnsRecords",
|
|
19522
20030
|
parentScopedPath: "/V1.0/ConfigurationItems/{parentId}/DnsRecords",
|
|
19523
20031
|
parentPath: "/V1.0/ConfigurationItems",
|
|
19524
|
-
parentField: "
|
|
20032
|
+
parentField: "installedProductID",
|
|
19525
20033
|
deletable: true,
|
|
19526
20034
|
udfCapable: false,
|
|
19527
20035
|
ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
|
|
@@ -20771,6 +21279,12 @@ var SIMPLE_RESOURCES = [
|
|
|
20771
21279
|
var GenericResource = class extends BaseResource {
|
|
20772
21280
|
constructor(http, config, pageSize) {
|
|
20773
21281
|
super(http, config, pageSize);
|
|
21282
|
+
if (["company_attachments", "company_note_attachments"].includes(config.key)) this.getUdfInfo = async () => {
|
|
21283
|
+
throw new OperationNotSupportedError(config.key, "getUdfInfo");
|
|
21284
|
+
};
|
|
21285
|
+
if (config.ops?.create === false || config.key === "company_attachments") this.createIfNotExists = async () => {
|
|
21286
|
+
throw new OperationNotSupportedError(config.key, "createIfNotExists");
|
|
21287
|
+
};
|
|
20774
21288
|
}
|
|
20775
21289
|
/** #293 QA F2: the superset exposes every generic method, but a row whose ops/helpers
|
|
20776
21290
|
* flags mark an op absent (the plain entities) refuses it client-side, pre-wire — the
|
|
@@ -20959,6 +21473,7 @@ var GenericResource = class extends BaseResource {
|
|
|
20959
21473
|
}
|
|
20960
21474
|
/** Download the attachment bytes (GET .../{id}/data; node-proven path, quirk #9) → Buffer. */
|
|
20961
21475
|
async download(parentId, id) {
|
|
21476
|
+
this.requireOp("download");
|
|
20962
21477
|
if (this.config.attachmentGet !== true) throw new OperationNotSupportedError(this.config.key, "download");
|
|
20963
21478
|
return this.downloadScoped(parentId, id);
|
|
20964
21479
|
}
|
|
@@ -21105,13 +21620,7 @@ async function liveFieldNames(holder) {
|
|
|
21105
21620
|
const reader = holder.getFieldInfo;
|
|
21106
21621
|
if (typeof reader !== "function") return null;
|
|
21107
21622
|
try {
|
|
21108
|
-
|
|
21109
|
-
if (!Array.isArray(rows)) return null;
|
|
21110
|
-
const names = [];
|
|
21111
|
-
for (const row of rows) {
|
|
21112
|
-
if (typeof row.name === "string") names.push(row.name);
|
|
21113
|
-
}
|
|
21114
|
-
return names.length > 0 ? names : null;
|
|
21623
|
+
return await readMetadataProjection(holder, "fields", liveFieldNamesView, () => reader.call(holder));
|
|
21115
21624
|
} catch (err) {
|
|
21116
21625
|
if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
|
|
21117
21626
|
return null;
|
|
@@ -21186,7 +21695,7 @@ function readIncludeNames(record, includeFields) {
|
|
|
21186
21695
|
return names;
|
|
21187
21696
|
}
|
|
21188
21697
|
function resolveAuthority(record, live) {
|
|
21189
|
-
if (live !== null) return { known: live, authority: "the tenant's live entity field metadata", hasField: (name) => live.
|
|
21698
|
+
if (live !== null) return { known: live.names, authority: "the tenant's live entity field metadata", hasField: (name) => live.known.has(name) };
|
|
21190
21699
|
const vendored = MODEL_FIELD_SETS[record.resource];
|
|
21191
21700
|
const modelHas = modelFieldLookup(record.resource);
|
|
21192
21701
|
const liveOnlyExempt = Array.isArray(record.metadata?.liveOnlyFields) ? record.metadata.liveOnlyFields : [];
|
|
@@ -21251,18 +21760,6 @@ async function findUnknownFieldNames(record, holder, lists) {
|
|
|
21251
21760
|
var ASSUMED_CLOSED_STATUS_ID = 5;
|
|
21252
21761
|
var CLOSED_STATUS_LABELS = ["complete", "completed", "closed", "cancelled", "canceled", "resolved"];
|
|
21253
21762
|
var OP = "tickets.statusSemantics";
|
|
21254
|
-
function picklistOf(fields) {
|
|
21255
|
-
if (!Array.isArray(fields)) return [];
|
|
21256
|
-
const status = fields.find((f) => typeof f?.name === "string" && f.name.toLowerCase() === "status");
|
|
21257
|
-
if (status === void 0 || status.isPickList !== true || !Array.isArray(status.picklistValues)) return [];
|
|
21258
|
-
const out = [];
|
|
21259
|
-
for (const v of status.picklistValues) {
|
|
21260
|
-
const id = Number(v?.value);
|
|
21261
|
-
if (!Number.isSafeInteger(id)) continue;
|
|
21262
|
-
out.push({ id, label: typeof v.label === "string" ? v.label : "" });
|
|
21263
|
-
}
|
|
21264
|
-
return out;
|
|
21265
|
-
}
|
|
21266
21763
|
async function readFields(http, fresh) {
|
|
21267
21764
|
return cachedMetadataGet(http, "tickets", "fields", "/V1.0/Tickets/entityInformation/fields", OP, (res) => {
|
|
21268
21765
|
const fields = res?.fields;
|
|
@@ -21270,7 +21767,7 @@ async function readFields(http, fresh) {
|
|
|
21270
21767
|
throw new AutotaskError("Expected the FieldInformationResultModel envelope { fields: [] }; got a different shape", { code: "INVALID_RESPONSE", category: "server" });
|
|
21271
21768
|
}
|
|
21272
21769
|
return fields;
|
|
21273
|
-
}, fresh, 0);
|
|
21770
|
+
}, fresh, 0, ticketStatusFieldsView);
|
|
21274
21771
|
}
|
|
21275
21772
|
function assumed(allowAssumed, operation) {
|
|
21276
21773
|
if (!allowAssumed) {
|
|
@@ -21307,7 +21804,7 @@ async function resolveTicketStatusSemantics(http, opts = {}, operation = OP) {
|
|
|
21307
21804
|
if (e instanceof AutotaskError && e.code === "ABORTED") throw e;
|
|
21308
21805
|
return assumed(allowAssumed, operation);
|
|
21309
21806
|
}
|
|
21310
|
-
const picklist =
|
|
21807
|
+
const picklist = ticketStatusView(fields);
|
|
21311
21808
|
const closedIds = picklist.filter((v) => CLOSED_STATUS_LABELS.includes(v.label.trim().toLowerCase())).map((v) => v.id);
|
|
21312
21809
|
if (closedIds.length === 0) return assumed(allowAssumed, operation);
|
|
21313
21810
|
const labels = picklist.filter((v) => closedIds.includes(v.id)).map((v) => `${v.id} ${v.label}`).join(", ");
|
|
@@ -22765,7 +23262,7 @@ function dateBucketLabel(value, bucket) {
|
|
|
22765
23262
|
var queryResourceKeysPromise = null;
|
|
22766
23263
|
function queryResourceKeys() {
|
|
22767
23264
|
if (queryResourceKeysPromise === null) {
|
|
22768
|
-
queryResourceKeysPromise =
|
|
23265
|
+
queryResourceKeysPromise = chunkJLCHKCEB_cjs.loadCapabilityRecords().then((records) => {
|
|
22769
23266
|
const s = /* @__PURE__ */ new Set();
|
|
22770
23267
|
for (const rec of records) if (rec.operation === "query") s.add(rec.resource);
|
|
22771
23268
|
return s;
|
|
@@ -22887,7 +23384,7 @@ function parseTopAndLimit(opts, problems) {
|
|
|
22887
23384
|
return { top, limit };
|
|
22888
23385
|
}
|
|
22889
23386
|
async function checkFieldNames(resourceKey, conditions, opts, problems) {
|
|
22890
|
-
const records = resourceKey === void 0 ? [] : await
|
|
23387
|
+
const records = resourceKey === void 0 ? [] : await chunkJLCHKCEB_cjs.loadCapabilityRecords();
|
|
22891
23388
|
const record = resourceKey === void 0 ? void 0 : records.find((r) => r.resource === resourceKey && r.operation === "query");
|
|
22892
23389
|
if (record === void 0) return void 0;
|
|
22893
23390
|
const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
|
|
@@ -23532,7 +24029,7 @@ async function uiLink(client, input) {
|
|
|
23532
24029
|
var indexPromise = null;
|
|
23533
24030
|
function operationIndex() {
|
|
23534
24031
|
if (indexPromise === null) {
|
|
23535
|
-
indexPromise =
|
|
24032
|
+
indexPromise = chunkJLCHKCEB_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
|
|
23536
24033
|
}
|
|
23537
24034
|
return indexPromise;
|
|
23538
24035
|
}
|
|
@@ -27869,25 +28366,46 @@ async function requireReadBack(record, operation, opts) {
|
|
|
27869
28366
|
}
|
|
27870
28367
|
var PRE_REQUEST_VALIDATORS = [
|
|
27871
28368
|
(c) => governPreRequest(c.record, c.operation, c.opts),
|
|
28369
|
+
(c) => {
|
|
28370
|
+
if (!c.streaming) return;
|
|
28371
|
+
if (!c.boundedQuery) throw new AutotaskConfigError("invokeReadPages: only primitive query reads support bounded page consumption", { operation: c.operation });
|
|
28372
|
+
const holder = c.holder;
|
|
28373
|
+
const prepare2 = holder[PREPARE_BOUNDED_QUERY];
|
|
28374
|
+
if (typeof prepare2 !== "function") {
|
|
28375
|
+
throw new AutotaskConfigError("invokeReadPages: the resource does not support governed bounded page consumption", { operation: c.operation });
|
|
28376
|
+
}
|
|
28377
|
+
const session = prepare2.call(holder);
|
|
28378
|
+
if (typeof session?.guard !== "function" || typeof session.consume !== "function") throw new AutotaskConfigError("invokeReadPages: the resource has no scoped page consumer", { operation: c.operation });
|
|
28379
|
+
c.pageSession = session;
|
|
28380
|
+
session.guard();
|
|
28381
|
+
},
|
|
27872
28382
|
(c) => requireReadBack(c.record, c.operation, c.opts),
|
|
27873
28383
|
(c) => validateDispatchArgs(c.record, c.args),
|
|
27874
28384
|
(c) => validateParamsBag(c.record, c.args),
|
|
27875
28385
|
(c) => validateFreshSpelling(c.record, c.args),
|
|
28386
|
+
(c) => {
|
|
28387
|
+
if (!c.streaming) return;
|
|
28388
|
+
const bag = c.args[0];
|
|
28389
|
+
if (bag?.["walk"] === void 0 || bag?.["latest"] !== void 0) {
|
|
28390
|
+
throw new AutotaskConfigError("invokeReadPages: an explicit walk.maxRows query without latest is required", { operation: c.operation });
|
|
28391
|
+
}
|
|
28392
|
+
},
|
|
27876
28393
|
(c) => c.boundedQuery || c.countedQuery ? validateQueryFieldNames(c.record, c.holder, c.args) : Promise.resolve(void 0)
|
|
27877
28394
|
];
|
|
27878
28395
|
async function runPreRequestPass(ctx) {
|
|
27879
28396
|
for (const step of PRE_REQUEST_VALIDATORS) await step(ctx);
|
|
27880
28397
|
}
|
|
27881
|
-
async function
|
|
28398
|
+
async function prepareInvocation(client, operation, argsIn, opts, streaming = false) {
|
|
27882
28399
|
const record = await resolveRecord(operation);
|
|
27883
28400
|
const args = resolveDispatchArgs(record, argsIn);
|
|
27884
28401
|
const boundedQuery = record.kind === "primitive" && record.operation === "query";
|
|
27885
28402
|
const countedQuery = record.kind === "primitive" && record.operation === "count";
|
|
27886
28403
|
const holder = resolveHolder(client, record, operation);
|
|
27887
|
-
|
|
28404
|
+
const context = { record, operation, args, opts, client, holder, boundedQuery, countedQuery, streaming };
|
|
28405
|
+
await runPreRequestPass(context);
|
|
27888
28406
|
const labelQuery = boundedQuery && readNamesOpt(client, args[0]?.["names"], `invoke: "${record.id}" params bag`);
|
|
27889
28407
|
const methodName = boundedQuery ? "queryBounded" : record.operation;
|
|
27890
|
-
const method = holder[methodName];
|
|
28408
|
+
const method = streaming ? context.pageSession?.consume : holder[methodName];
|
|
27891
28409
|
if (typeof method !== "function") {
|
|
27892
28410
|
throw new AutotaskConfigError(
|
|
27893
28411
|
`invoke: "${record.resource}.${methodName}" is not a callable method on the client`,
|
|
@@ -27903,6 +28421,10 @@ async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
|
27903
28421
|
if (boundedQuery && args[0]?.["acknowledgeUnscoped"] !== true) {
|
|
27904
28422
|
scopeNote = (await guardUnscopedQueryWalk(holder, record.id, args[0])).note;
|
|
27905
28423
|
}
|
|
28424
|
+
return { record, args, holder, method, callArgs, labelQuery, scopeNote, pageSession: context.pageSession };
|
|
28425
|
+
}
|
|
28426
|
+
async function invokeMode(client, operation, argsIn = [], opts = {}) {
|
|
28427
|
+
const { record, args, holder, method, callArgs, labelQuery, scopeNote } = await prepareInvocation(client, operation, argsIn, opts);
|
|
27906
28428
|
const result = await method.apply(holder, callArgs);
|
|
27907
28429
|
if (labelQuery && args[0]?.["walk"] === void 0 && Array.isArray(result?.items)) {
|
|
27908
28430
|
const bounded = result;
|
|
@@ -27918,6 +28440,15 @@ async function invoke(client, operation, args = [], opts = {}) {
|
|
|
27918
28440
|
async function invokeRead(client, operation, args = [], opts = {}) {
|
|
27919
28441
|
return invokeMode(client, operation, args, { ...opts, mode: "read" });
|
|
27920
28442
|
}
|
|
28443
|
+
async function invokeReadPages(client, operation, args, onPage, opts = {}) {
|
|
28444
|
+
if (typeof onPage !== "function") throw new AutotaskConfigError("invokeReadPages: onPage must be a function", { operation });
|
|
28445
|
+
const prepared = await prepareInvocation(client, operation, args, { ...opts, mode: "read" }, true);
|
|
28446
|
+
prepared.pageSession.guard();
|
|
28447
|
+
const consume = prepared.method;
|
|
28448
|
+
const result = await consume.call(prepared.holder, prepared.callArgs[0], onPage);
|
|
28449
|
+
prepared.pageSession.guard();
|
|
28450
|
+
return prepared.scopeNote === void 0 ? result : { ...result, scopeNote: prepared.scopeNote };
|
|
28451
|
+
}
|
|
27921
28452
|
async function invokeWrite(client, operation, args = [], opts = {}) {
|
|
27922
28453
|
return invokeMode(client, operation, args, { ...opts, mode: "write" });
|
|
27923
28454
|
}
|
|
@@ -28166,6 +28697,7 @@ exports.formatVendorDetail = formatVendorDetail;
|
|
|
28166
28697
|
exports.invoke = invoke;
|
|
28167
28698
|
exports.invokeDelete = invokeDelete;
|
|
28168
28699
|
exports.invokeRead = invokeRead;
|
|
28700
|
+
exports.invokeReadPages = invokeReadPages;
|
|
28169
28701
|
exports.invokeWrite = invokeWrite;
|
|
28170
28702
|
exports.isAutotaskError = isAutotaskError;
|
|
28171
28703
|
exports.isClosedStatus = isClosedStatus;
|