node-autotask 0.74.0 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/MCP_TOOL_CATALOG.json +265 -9
  3. package/README.md +1 -1
  4. package/capabilities.json +1219 -217
  5. package/dist/capabilities-data.js +1449 -447
  6. package/dist/capabilities.cjs +4 -4
  7. package/dist/capabilities.js +1 -1
  8. package/dist/{chunk-HJKY7LUL.js → chunk-3SFIKG2R.js} +575 -215
  9. package/dist/{chunk-DSQJTGXK.cjs → chunk-55BQEFBO.cjs} +32 -30
  10. package/dist/{chunk-ASL3BIW2.cjs → chunk-C4S3EKIK.cjs} +3 -3
  11. package/dist/{chunk-IWTTCBCS.js → chunk-ECSE6B3U.js} +3 -3
  12. package/dist/{chunk-IFE5FWS7.js → chunk-S7QPD6TR.js} +2 -2
  13. package/dist/{chunk-PGSDJS52.js → chunk-UFK7JYYC.js} +4 -2
  14. package/dist/{chunk-AMB54GOO.cjs → chunk-Y4BH5N6R.cjs} +580 -220
  15. package/dist/{chunk-QZY5LAOG.cjs → chunk-YRTOAPWD.cjs} +199 -199
  16. package/dist/{index-CH65Ftmy.d.cts → index-BbAzrm2i.d.cts} +95 -1
  17. package/dist/{index-CH65Ftmy.d.ts → index-BbAzrm2i.d.ts} +95 -1
  18. package/dist/{index-ColCzIyw.d.ts → index-CY7exGOe.d.ts} +7 -8
  19. package/dist/{index-CkBDlaSS.d.cts → index-MY7qYY5d.d.cts} +7 -8
  20. package/dist/index.cjs +84 -84
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +5 -5
  24. package/dist/operations/index.cjs +51 -51
  25. package/dist/operations/index.d.cts +4 -4
  26. package/dist/operations/index.d.ts +4 -4
  27. package/dist/operations/index.js +2 -2
  28. package/dist/pool.cjs +12 -12
  29. package/dist/pool.d.cts +1 -1
  30. package/dist/pool.d.ts +1 -1
  31. package/dist/pool.js +4 -4
  32. package/dist/resources/index.cjs +27 -27
  33. package/dist/resources/index.d.cts +2 -2
  34. package/dist/resources/index.d.ts +2 -2
  35. package/dist/resources/index.js +3 -3
  36. package/dist/types/index.d.cts +1 -1
  37. package/dist/types/index.d.ts +1 -1
  38. package/docs/API.md +4 -2
  39. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkASL3BIW2_cjs = require('./chunk-ASL3BIW2.cjs');
3
+ var chunkC4S3EKIK_cjs = require('./chunk-C4S3EKIK.cjs');
4
4
  var chunkBD4AUGCJ_cjs = require('./chunk-BD4AUGCJ.cjs');
5
5
  var crypto = require('crypto');
6
6
  var async_hooks = require('async_hooks');
@@ -6201,6 +6201,22 @@ var RELATIONSHIP_MAP = {
6201
6201
  "field": "projectID"
6202
6202
  },
6203
6203
  "children": [
6204
+ {
6205
+ "resource": "task_attachments",
6206
+ "apiEntity": "TaskAttachment",
6207
+ "parentField": "taskID",
6208
+ "parentSegment": "Attachments",
6209
+ "tier": "extended",
6210
+ "workflowResource": false,
6211
+ "specialOps": [],
6212
+ "searchCovers": null,
6213
+ "scopedOps": {
6214
+ "create": true,
6215
+ "query": true,
6216
+ "update": false,
6217
+ "delete": true
6218
+ }
6219
+ },
6204
6220
  {
6205
6221
  "resource": "task_notes",
6206
6222
  "apiEntity": "TaskNote",
@@ -9759,7 +9775,24 @@ var RELATIONSHIP_MAP = {
9759
9775
  "segment": "Notes",
9760
9776
  "field": "taskID"
9761
9777
  },
9762
- "children": [],
9778
+ "children": [
9779
+ {
9780
+ "resource": "task_note_attachments",
9781
+ "apiEntity": "TaskNoteAttachment",
9782
+ "parentField": "taskNoteID",
9783
+ "parentSegment": "Attachments",
9784
+ "tier": "extended",
9785
+ "workflowResource": false,
9786
+ "specialOps": [],
9787
+ "searchCovers": null,
9788
+ "scopedOps": {
9789
+ "create": true,
9790
+ "query": true,
9791
+ "update": false,
9792
+ "delete": true
9793
+ }
9794
+ }
9795
+ ],
9763
9796
  "naturalKeys": {
9764
9797
  "hasSearch": false,
9765
9798
  "searchCovers": null,
@@ -9835,6 +9868,127 @@ var RELATIONSHIP_MAP = {
9835
9868
  },
9836
9869
  "deleteBoundary": null,
9837
9870
  "markerField": null
9871
+ },
9872
+ "task_attachments": {
9873
+ "resource": "task_attachments",
9874
+ "apiEntity": "TaskAttachment",
9875
+ "kind": "entity",
9876
+ "path": "TaskAttachments",
9877
+ "parentScoped": true,
9878
+ "tier": "extended",
9879
+ "workflowResource": false,
9880
+ "group": "A",
9881
+ "parent": {
9882
+ "resource": "tasks",
9883
+ "segment": "Attachments",
9884
+ "field": "taskID"
9885
+ },
9886
+ "children": [],
9887
+ "naturalKeys": {
9888
+ "hasSearch": false,
9889
+ "searchCovers": null,
9890
+ "findBy": []
9891
+ },
9892
+ "blindSurfaces": null,
9893
+ "zoneFacts": {
9894
+ "createGuidance": {
9895
+ "createOp": "task_attachments.create",
9896
+ "parentScoped": true,
9897
+ "liveProvenPrefix": [],
9898
+ "unproven": true,
9899
+ "blocker": {
9900
+ "kind": "unknown",
9901
+ "message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
9902
+ "remedy": "Read current field and picklist metadata, supply the task parent id and required attachment fields, and preview before applying. Parent-query child inclusion prevents exact-parent deduplication."
9903
+ },
9904
+ "requiresByValue": [
9905
+ {
9906
+ "field": "attachmentType",
9907
+ "value": "FILE_ATTACHMENT",
9908
+ "requires": {
9909
+ "allOf": [
9910
+ "data"
9911
+ ]
9912
+ }
9913
+ }
9914
+ ],
9915
+ "vendorEvidence": [
9916
+ "Specification: POST /V1.0/Tasks/{parentId}/Attachments returns OperationResultModel. https://ww3.autotask.net/help/developerhelp/Content/APIs/REST/Entities/TaskAttachmentsEntity.htm requires data for FILE_ATTACHMENT; the common attachment guide requires base64 encoding. No live create was performed."
9917
+ ],
9918
+ "deleteBoundary": {
9919
+ "available": true,
9920
+ "note": null
9921
+ }
9922
+ }
9923
+ },
9924
+ "deleteBoundary": null,
9925
+ "markerField": null
9926
+ },
9927
+ "task_note_attachments": {
9928
+ "resource": "task_note_attachments",
9929
+ "apiEntity": "TaskNoteAttachment",
9930
+ "kind": "entity",
9931
+ "path": "TaskNoteAttachments",
9932
+ "parentScoped": true,
9933
+ "tier": "extended",
9934
+ "workflowResource": false,
9935
+ "group": "A",
9936
+ "parent": {
9937
+ "resource": "task_notes",
9938
+ "segment": "Attachments",
9939
+ "field": "taskNoteID"
9940
+ },
9941
+ "children": [],
9942
+ "naturalKeys": {
9943
+ "hasSearch": false,
9944
+ "searchCovers": null,
9945
+ "findBy": []
9946
+ },
9947
+ "blindSurfaces": null,
9948
+ "zoneFacts": {
9949
+ "createGuidance": {
9950
+ "createOp": "task_note_attachments.create",
9951
+ "parentScoped": true,
9952
+ "liveProvenPrefix": [],
9953
+ "unproven": true,
9954
+ "blocker": {
9955
+ "kind": "unknown",
9956
+ "message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
9957
+ "remedy": "Read the current field and picklist metadata, supply the named parent id, and preview the attachment before applying.",
9958
+ "requires": {
9959
+ "allOf": [
9960
+ "attachmentType",
9961
+ "fullPath",
9962
+ "title",
9963
+ "publish",
9964
+ "data"
9965
+ ]
9966
+ }
9967
+ },
9968
+ "requiresByValue": [
9969
+ {
9970
+ "field": "attachmentType",
9971
+ "value": "FILE_ATTACHMENT",
9972
+ "requires": {
9973
+ "allOf": [
9974
+ "data"
9975
+ ]
9976
+ }
9977
+ }
9978
+ ],
9979
+ "vendorEvidence": [
9980
+ "https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/TaskNoteAttachmentsEntity.htm",
9981
+ "https://www.autotask.net/help/developerhelp/content/apis/REST/API_Calls/REST_Attachments.htm",
9982
+ "Official entity URLs table repeats TaskNotes routes, while vendored TaskNoteAttachments controllers define the actual scoped attachment routes. No update, UDF metadata or data-download endpoint is implemented. Static contract only; no live create."
9983
+ ],
9984
+ "deleteBoundary": {
9985
+ "available": true,
9986
+ "note": null
9987
+ }
9988
+ }
9989
+ },
9990
+ "deleteBoundary": null,
9991
+ "markerField": null
9838
9992
  }
9839
9993
  };
9840
9994
  var BLIND_SURFACE_STAMPS = {
@@ -13392,6 +13546,77 @@ var CREATE_GUIDANCE = {
13392
13546
  "note": null
13393
13547
  }
13394
13548
  },
13549
+ {
13550
+ "resource": "task_attachments",
13551
+ "createOp": "task_attachments.create",
13552
+ "parentScoped": true,
13553
+ "liveProvenPrefix": [],
13554
+ "unproven": true,
13555
+ "blocker": {
13556
+ "kind": "unknown",
13557
+ "message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
13558
+ "remedy": "Read current field and picklist metadata, supply the task parent id and required attachment fields, and preview before applying. Parent-query child inclusion prevents exact-parent deduplication."
13559
+ },
13560
+ "vendorEvidence": [
13561
+ "Specification: POST /V1.0/Tasks/{parentId}/Attachments returns OperationResultModel. https://ww3.autotask.net/help/developerhelp/Content/APIs/REST/Entities/TaskAttachmentsEntity.htm requires data for FILE_ATTACHMENT; the common attachment guide requires base64 encoding. No live create was performed."
13562
+ ],
13563
+ "deleteBoundary": {
13564
+ "available": true,
13565
+ "note": null
13566
+ },
13567
+ "requiresByValue": [
13568
+ {
13569
+ "field": "attachmentType",
13570
+ "value": "FILE_ATTACHMENT",
13571
+ "requires": {
13572
+ "allOf": [
13573
+ "data"
13574
+ ]
13575
+ }
13576
+ }
13577
+ ]
13578
+ },
13579
+ {
13580
+ "resource": "task_note_attachments",
13581
+ "createOp": "task_note_attachments.create",
13582
+ "parentScoped": true,
13583
+ "liveProvenPrefix": [],
13584
+ "unproven": true,
13585
+ "blocker": {
13586
+ "kind": "unknown",
13587
+ "message": "Attachment creation is documented; valid input remains subject to API-user permissions and vendor validation.",
13588
+ "remedy": "Read the current field and picklist metadata, supply the named parent id, and preview the attachment before applying.",
13589
+ "requires": {
13590
+ "allOf": [
13591
+ "attachmentType",
13592
+ "fullPath",
13593
+ "title",
13594
+ "publish",
13595
+ "data"
13596
+ ]
13597
+ }
13598
+ },
13599
+ "vendorEvidence": [
13600
+ "https://www.autotask.net/help/developerhelp/Content/APIs/REST/Entities/TaskNoteAttachmentsEntity.htm",
13601
+ "https://www.autotask.net/help/developerhelp/content/apis/REST/API_Calls/REST_Attachments.htm",
13602
+ "Official entity URLs table repeats TaskNotes routes, while vendored TaskNoteAttachments controllers define the actual scoped attachment routes. No update, UDF metadata or data-download endpoint is implemented. Static contract only; no live create."
13603
+ ],
13604
+ "deleteBoundary": {
13605
+ "available": true,
13606
+ "note": null
13607
+ },
13608
+ "requiresByValue": [
13609
+ {
13610
+ "field": "attachmentType",
13611
+ "value": "FILE_ATTACHMENT",
13612
+ "requires": {
13613
+ "allOf": [
13614
+ "data"
13615
+ ]
13616
+ }
13617
+ }
13618
+ ]
13619
+ },
13395
13620
  {
13396
13621
  "resource": "task_notes",
13397
13622
  "createOp": "task_notes.create",
@@ -13985,7 +14210,7 @@ var CREATE_GUIDANCE = {
13985
14210
  }
13986
14211
  ],
13987
14212
  "counts": {
13988
- "total": 104,
14213
+ "total": 106,
13989
14214
  "byKind": {
13990
14215
  "ok": 41,
13991
14216
  "blind-reference": 16,
@@ -13995,7 +14220,7 @@ var CREATE_GUIDANCE = {
13995
14220
  "resource-role-pair": 2,
13996
14221
  "delete-absent": 0,
13997
14222
  "non-mutable": 0,
13998
- "unknown": 28
14223
+ "unknown": 30
13999
14224
  }
14000
14225
  }
14001
14226
  };
@@ -14725,6 +14950,12 @@ var UNTRUSTED_FIELDS_BY_RESOURCE = {
14725
14950
  "task_notes": [
14726
14951
  "description",
14727
14952
  "title"
14953
+ ],
14954
+ "task_attachments": [
14955
+ "title"
14956
+ ],
14957
+ "task_note_attachments": [
14958
+ "title"
14728
14959
  ]
14729
14960
  };
14730
14961
 
@@ -16599,7 +16830,7 @@ async function capabilitySets() {
16599
16830
  const fieldOps = /* @__PURE__ */ new Map();
16600
16831
  const udfCapable = /* @__PURE__ */ new Set();
16601
16832
  const resources = /* @__PURE__ */ new Set();
16602
- for (const rec of await chunkASL3BIW2_cjs.loadCapabilityRecords()) {
16833
+ for (const rec of await chunkC4S3EKIK_cjs.loadCapabilityRecords()) {
16603
16834
  if (rec.resource === "operations") continue;
16604
16835
  resources.add(rec.resource);
16605
16836
  if (rec.operation === "getFieldInfo") fieldOps.set(rec.resource, rec);
@@ -16610,7 +16841,7 @@ async function capabilitySets() {
16610
16841
  var derivedIndexPromise = null;
16611
16842
  function derivedIndexLoad() {
16612
16843
  if (derivedIndexPromise === null) {
16613
- derivedIndexPromise = chunkASL3BIW2_cjs.loadCapabilityRecords().then((records) => {
16844
+ derivedIndexPromise = chunkC4S3EKIK_cjs.loadCapabilityRecords().then((records) => {
16614
16845
  const index = /* @__PURE__ */ new Map();
16615
16846
  for (const rec of records) {
16616
16847
  const declared = rec.metadata?.derivedFields;
@@ -17819,6 +18050,8 @@ var MODEL_FIELD_SETS = {
17819
18050
  "tag_aliases": ["id", "alias", "tagID", "soapParentPropertyId"],
17820
18051
  "tag_groups": ["id", "displayColor", "isActive", "isSystem", "label"],
17821
18052
  "tags": ["id", "createDateTime", "isActive", "isExcludedFromAutomaticTagging", "isSystem", "label", "lastModifiedDateTime", "tagGroupID"],
18053
+ "task_attachments": ["id", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "contentType", "creatorType", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentAttachmentID", "parentID", "publish", "taskID", "taskNoteID", "timeEntryID", "title", "data", "isTaskAttachment", "parentType", "soapParentPropertyId"],
18054
+ "task_note_attachments": ["id", "isTaskAttachment", "attachDate", "attachedByContactID", "attachedByResourceID", "attachmentType", "contentType", "creatorType", "fileSize", "fullPath", "impersonatorCreatorResourceID", "opportunityID", "parentID", "publish", "taskID", "taskNoteID", "title", "data", "parentType", "soapParentPropertyId"],
17822
18055
  "task_notes": ["id", "createDateTime", "creatorResourceID", "createdByContactID", "description", "impersonatorCreatorResourceID", "impersonatorUpdaterResourceID", "lastActivityDate", "noteType", "publish", "taskID", "title", "soapParentPropertyId"],
17823
18056
  "task_predecessors": ["id", "lagDays", "predecessorTaskID", "successorTaskID", "soapParentPropertyId"],
17824
18057
  "task_secondary_resources": ["id", "resourceID", "roleID", "taskID", "soapParentPropertyId"],
@@ -17897,6 +18130,8 @@ var MODEL_DATE_FIELDS = {
17897
18130
  "subscriptions": ["effectiveDate", "expirationDate"],
17898
18131
  "survey_results": ["completeDate", "sendDate"],
17899
18132
  "tags": ["createDateTime", "lastModifiedDateTime"],
18133
+ "task_attachments": ["attachDate"],
18134
+ "task_note_attachments": ["attachDate"],
17900
18135
  "task_notes": ["createDateTime", "lastActivityDate"],
17901
18136
  "tasks": ["completedDateTime", "createDateTime", "endDateTime", "lastActivityDateTime", "startDateTime"],
17902
18137
  "ticket_attachments": ["attachDate"],
@@ -20108,73 +20343,294 @@ function admitTaskNote(data, parentId, creating) {
20108
20343
  if (!creating && !Object.keys(body).some((key) => key !== "id" && key !== "itemId")) fail2("update must contain a writable field");
20109
20344
  }
20110
20345
 
20111
- // src/resources/simple.ts
20112
- var isIdentifier = (v) => typeof v === "number" || typeof v === "string";
20113
- var SIMPLE_RESOURCES = [
20114
- {
20115
- key: "appointments",
20116
- accessor: "appointments",
20117
- resourcePath: "/V1.0/Appointments",
20118
- deletable: true,
20119
- udfCapable: false,
20120
- collectionUpdate: true,
20121
- ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20122
- helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20123
- opForms: { get: "global", create: "global", update: "global", delete: "global" }
20124
- },
20125
- {
20126
- key: "attachment_info",
20127
- accessor: "attachmentInfo",
20128
- resourcePath: "/V1.0/AttachmentInfo",
20129
- deletable: false,
20130
- udfCapable: false,
20131
- ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20132
- helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20133
- opForms: { get: "global" }
20134
- },
20135
- {
20136
- key: "billing_codes",
20137
- accessor: "billingCodes",
20138
- resourcePath: "/V1.0/BillingCodes",
20139
- deletable: false,
20140
- udfCapable: false,
20141
- searchFields: ["name"],
20142
- ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20143
- helpers: { search: true, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20144
- opForms: { get: "global" }
20145
- },
20146
- {
20147
- key: "billing_item_approval_levels",
20148
- accessor: "billingItemApprovalLevels",
20149
- resourcePath: "/V1.0/BillingItemApprovalLevels",
20150
- deletable: false,
20151
- udfCapable: false,
20152
- ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: false, getEntityInfo: false, getFieldInfo: false, getUdfInfo: false },
20153
- helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20154
- opForms: { get: "global", create: "global" }
20155
- },
20156
- {
20157
- key: "billing_items",
20158
- accessor: "billingItems",
20159
- resourcePath: "/V1.0/BillingItems",
20160
- deletable: false,
20161
- udfCapable: false,
20162
- collectionUpdate: true,
20163
- ops: { query: true, queryAll: false, count: true, get: true, create: false, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20164
- helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20165
- opForms: { get: "global", update: "global" }
20166
- },
20167
- {
20168
- key: "change_request_links",
20169
- accessor: "changeRequestLinks",
20170
- resourcePath: "/V1.0/ChangeRequestLinks",
20171
- deletable: true,
20172
- udfCapable: false,
20173
- ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20174
- helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20175
- opForms: { get: "global", create: "global", delete: "global" }
20176
- },
20177
- {
20346
+ // src/operations/invoke/fieldNames.ts
20347
+ async function liveFieldNames(holder) {
20348
+ if (holder === void 0) return null;
20349
+ const reader = holder.getFieldInfo;
20350
+ if (typeof reader !== "function") return null;
20351
+ try {
20352
+ return await readMetadataProjection(holder, "fields", liveFieldNamesView, () => reader.call(holder));
20353
+ } catch (err) {
20354
+ if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
20355
+ return null;
20356
+ }
20357
+ }
20358
+ var UNKNOWN_NAME_LIST_CAP = 20;
20359
+ var UNKNOWN_NAME_DISPLAY_CHARS = 40;
20360
+ var ENTITY_NAME_LIST_CAP = 20;
20361
+ function formatUnknownNameList(names, cap = UNKNOWN_NAME_LIST_CAP) {
20362
+ const listed = names.slice(0, cap).map((n) => `"${n.length > UNKNOWN_NAME_DISPLAY_CHARS ? `${n.slice(0, UNKNOWN_NAME_DISPLAY_CHARS)}\u2026` : n}"`).join(", ");
20363
+ const more = names.length > cap ? ` (and ${names.length - cap} more)` : "";
20364
+ return `${listed}${more}`;
20365
+ }
20366
+ function collectFilterFieldNames(conditions, resourceKey, operation = `${resourceKey ?? "resource"}.query`) {
20367
+ const out = [];
20368
+ const walk = (conds) => {
20369
+ for (const cond of conds) {
20370
+ if (!isRecord2(cond)) continue;
20371
+ if (cond.op === "and" || cond.op === "or") {
20372
+ if (Array.isArray(cond.items)) walk(cond.items);
20373
+ continue;
20374
+ }
20375
+ assertUndottedUdfField(cond, operation);
20376
+ if (cond.udf === true) continue;
20377
+ if (typeof cond.field === "string" && cond.field.length > 0) {
20378
+ if (!cond.field.includes(".")) {
20379
+ out.push(cond.field);
20380
+ continue;
20381
+ }
20382
+ if (resourceKey !== void 0) {
20383
+ const own = normalizeOwnField(resourceKey, cond.field);
20384
+ if (own !== cond.field) out.push(own);
20385
+ }
20386
+ }
20387
+ }
20388
+ };
20389
+ walk(conditions);
20390
+ return out;
20391
+ }
20392
+ function readFieldCheck(record, bag) {
20393
+ const fieldCheck = bag["fieldCheck"];
20394
+ if (fieldCheck !== void 0 && typeof fieldCheck !== "boolean") {
20395
+ throw new AutotaskConfigError(
20396
+ `invoke: "${record.id}" params bag fieldCheck must be a boolean (got ${typeof fieldCheck}) \u2014 the request was not issued`,
20397
+ { operation: record.id, suggestedAction: "Pass fieldCheck: true (default) or fieldCheck: false (disable the field-name checks \u2014 includeFields AND filter condition names)." }
20398
+ );
20399
+ }
20400
+ return fieldCheck;
20401
+ }
20402
+ function readIncludeNames(record, includeFields) {
20403
+ if (includeFields === void 0) return void 0;
20404
+ let shapeOk = Array.isArray(includeFields);
20405
+ const names = [];
20406
+ if (shapeOk) {
20407
+ for (const entry of includeFields) {
20408
+ if (typeof entry !== "string" || entry.length === 0) {
20409
+ shapeOk = false;
20410
+ break;
20411
+ }
20412
+ names.push(normalizeOwnField(record.resource, entry));
20413
+ }
20414
+ }
20415
+ if (!shapeOk) {
20416
+ throw new AutotaskConfigError(
20417
+ `invoke: "${record.id}" params bag includeFields must be an array of non-empty field-name strings \u2014 the request was not issued`,
20418
+ {
20419
+ operation: record.id,
20420
+ suggestedAction: 'Pass includeFields as an array of exact vendor field names, e.g. ["id", "title"]; the live set is in operations.fieldCatalog.'
20421
+ }
20422
+ );
20423
+ }
20424
+ return names;
20425
+ }
20426
+ function resolveAuthority(record, live) {
20427
+ if (live !== null) return { known: live.names, authority: "the tenant's live entity field metadata", hasField: (name) => live.known.has(name) };
20428
+ const vendored = MODEL_FIELD_SETS[record.resource];
20429
+ const modelHas = modelFieldLookup(record.resource);
20430
+ const liveOnlyExempt = Array.isArray(record.metadata?.liveOnlyFields) ? record.metadata.liveOnlyFields : [];
20431
+ if (vendored === void 0 || modelHas === void 0) return void 0;
20432
+ return {
20433
+ known: [...vendored, ...liveOnlyExempt],
20434
+ hasField: (name) => modelHas(name) || liveOnlyExempt.includes(name),
20435
+ 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)"
20436
+ };
20437
+ }
20438
+ function unknownNamesRefusal(record, authority, known, unknownInclude, unknownFilter) {
20439
+ const parts = [];
20440
+ if (unknownInclude.length > 0) parts.push(`includeFields has unknown field name(s) ${formatUnknownNameList(unknownInclude)}`);
20441
+ if (unknownFilter.length > 0) parts.push(`filter condition(s) carry unknown field name(s) ${formatUnknownNameList(unknownFilter)}`);
20442
+ const wireClause = record.operation === "count" ? "the count request was not issued" : "the query POST was not issued";
20443
+ const head = `invoke: "${record.id}" ${parts.join("; ")} against ${authority}`;
20444
+ const count = known.length > ENTITY_NAME_LIST_CAP ? `${known.length}, first ${ENTITY_NAME_LIST_CAP}` : `${known.length}`;
20445
+ const withList = `${head} \u2014 fields available on ${record.resource} (${count}): ${formatUnknownNameList(known, ENTITY_NAME_LIST_CAP)} \u2014 ${wireClause}`;
20446
+ const message = known.length === 0 ? `${head} \u2014 ${wireClause}` : withList.length <= 3e3 ? withList : `${head} \u2014 ${record.resource} has ${known.length} fields; use operations.fieldCatalog resources: ["${record.resource}"] for the full set \u2014 ${wireClause}`;
20447
+ return new AutotaskConfigError(
20448
+ message,
20449
+ {
20450
+ operation: record.id,
20451
+ suggestedAction: unknownNamesSuggestedAction(record, authority, unknownFilter.length > 0)
20452
+ }
20453
+ );
20454
+ }
20455
+ function unknownNamesSuggestedAction(record, authority, filterUnknown) {
20456
+ const vendor = `Use exact vendor field names (operations.fieldCatalog resources: ["${record.resource}"] lists the live set).`;
20457
+ if (filterUnknown && record.udfCapable) {
20458
+ return `${vendor} UDF names: filter with udf: true (max 1 per query); names + picklist ids via fieldCatalog resources: ["${record.resource}"], include: ["udf"], labels: true; fieldCheck: false = vendor names only (never UDF names). Authority: ${authority}.`;
20459
+ }
20460
+ return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
20461
+ }
20462
+ async function validateQueryFieldNames(record, holder, args) {
20463
+ const bag = args[0];
20464
+ if (!isRecord2(bag)) return;
20465
+ const fieldCheck = readFieldCheck(record, bag);
20466
+ const includeNames = readIncludeNames(record, bag["includeFields"]);
20467
+ let filterNames;
20468
+ if (bag["filter"] !== void 0) {
20469
+ const conditions = normalizedConditions(bag["filter"]);
20470
+ filterNames = collectFilterFieldNames(conditions ?? [], record.resource, record.id);
20471
+ }
20472
+ if (fieldCheck === false) return;
20473
+ const found = await findUnknownFieldNames(record, holder, { includeFields: includeNames ?? [], filter: filterNames ?? [] });
20474
+ if (found === void 0) return;
20475
+ const { known, authority, unknown } = found;
20476
+ if (unknown["includeFields"].length === 0 && unknown["filter"].length === 0) return;
20477
+ throw unknownNamesRefusal(record, authority, known, unknown["includeFields"], unknown["filter"]);
20478
+ }
20479
+ async function findUnknownFieldNames(record, holder, lists) {
20480
+ if (Object.values(lists).every((names) => names.length === 0)) return void 0;
20481
+ const resolved = resolveAuthority(record, await liveFieldNames(holder));
20482
+ if (resolved === void 0) return void 0;
20483
+ const unknown = {};
20484
+ for (const [key, names] of Object.entries(lists)) unknown[key] = [...new Set(names.filter((name) => !resolved.hasField(name)))];
20485
+ return { known: resolved.known, authority: resolved.authority, unknown };
20486
+ }
20487
+
20488
+ // src/resources/special/taskAttachments.ts
20489
+ var WRITABLE2 = /* @__PURE__ */ new Set(["attachmentType", "contentType", "data", "fullPath", "parentAttachmentID", "publish", "taskID", "title"]);
20490
+ var NOTE_WRITABLE = /* @__PURE__ */ new Set(["attachmentType", "data", "fullPath", "publish", "title", "attachedByContactID"]);
20491
+ var NON_QUERYABLE = /* @__PURE__ */ new Set(["creatortype", "data", "filesize"]);
20492
+ function isBase64(value) {
20493
+ return value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(value);
20494
+ }
20495
+ function admitTaskAttachment(data, parentId) {
20496
+ const parent = parseIdentifier(parentId, "parentId");
20497
+ const fail2 = (message) => {
20498
+ throw new AutotaskConfigError(`task_attachments: ${message}`);
20499
+ };
20500
+ if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
20501
+ const body = data;
20502
+ for (const field of Object.keys(body)) if (!WRITABLE2.has(field)) fail2(`${field} is not a supported create field`);
20503
+ for (const field of ["attachmentType", "fullPath", "title"]) {
20504
+ if (typeof body[field] !== "string" || body[field].trim() === "") fail2(`${field} is required and must be a non-empty string`);
20505
+ }
20506
+ if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail2("publish must be an integer from current field metadata");
20507
+ for (const field of ["data", "contentType"]) {
20508
+ if (body[field] !== void 0 && typeof body[field] !== "string") fail2(`${field} must be a string`);
20509
+ }
20510
+ if (body.attachmentType === "FILE_ATTACHMENT") {
20511
+ if (typeof body.data !== "string" || body.data === "") return fail2("FILE_ATTACHMENT requires non-empty base64 data");
20512
+ if (!isBase64(body.data)) fail2("FILE_ATTACHMENT data must be base64 encoded");
20513
+ }
20514
+ if (body.taskID !== void 0) {
20515
+ if (typeof body.taskID !== "number") fail2("taskID must be a numeric identifier");
20516
+ if (String(parseIdentifier(body.taskID, "taskID")) !== String(parent)) fail2("taskID must match the parentId path argument");
20517
+ }
20518
+ if (body.parentAttachmentID !== void 0) {
20519
+ if (typeof body.parentAttachmentID !== "number") fail2("parentAttachmentID must be a numeric identifier");
20520
+ parseIdentifier(body.parentAttachmentID, "parentAttachmentID");
20521
+ }
20522
+ }
20523
+ function admitTaskNoteAttachment(data, parentId) {
20524
+ parseIdentifier(parentId, "parentId");
20525
+ const fail2 = (message) => {
20526
+ throw new AutotaskConfigError(`task_note_attachments: ${message}`);
20527
+ };
20528
+ if (data === null || typeof data !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(data))) fail2("data must be a plain record");
20529
+ const body = data;
20530
+ for (const field of Object.keys(body)) if (!NOTE_WRITABLE.has(field)) fail2(`${field} is not a supported create field`);
20531
+ if (body.attachmentType !== "FILE_ATTACHMENT") fail2("attachmentType must explicitly be FILE_ATTACHMENT; other attachment types are unsupported");
20532
+ for (const field of ["fullPath", "title"]) {
20533
+ if (typeof body[field] !== "string" || body[field].trim() === "" || body[field].length > 255) fail2(`${field} is required and must be a nonblank string of at most 255 characters`);
20534
+ }
20535
+ if (typeof body.publish !== "number" || !Number.isSafeInteger(body.publish)) fail2("publish must be an integer from current field metadata");
20536
+ if (typeof body.data !== "string" || !isBase64(body.data)) fail2("FILE_ATTACHMENT requires nonempty base64 data");
20537
+ if (body.attachedByContactID !== void 0) {
20538
+ if (typeof body.attachedByContactID !== "number") fail2("attachedByContactID must be a numeric identifier");
20539
+ if (parseIdentifier(body.attachedByContactID, "attachedByContactID") === 0) fail2("attachedByContactID must be positive");
20540
+ }
20541
+ }
20542
+ function admitTaskAttachmentQuery(resource, params) {
20543
+ const fields = collectFilterFieldNames(normalizedConditions(params?.filter) ?? [], resource);
20544
+ for (const field of fields) {
20545
+ if (NON_QUERYABLE.has(field.toLowerCase())) throw new AutotaskConfigError(`${resource}: ${field} is not queryable`);
20546
+ }
20547
+ }
20548
+ function assertTaskAttachmentIdentity(resource, model, parentId, id) {
20549
+ const matches = (value, expected) => {
20550
+ try {
20551
+ return parseIdentifier(value) === parseIdentifier(expected);
20552
+ } catch {
20553
+ return false;
20554
+ }
20555
+ };
20556
+ const parentField = resource === "task_attachments" ? "taskID" : "taskNoteID";
20557
+ if (!isRecord2(model) || !matches(model.id, id) || model[parentField] != null && !matches(model[parentField], parentId)) {
20558
+ const parentName = resource === "task_attachments" ? "task" : "task note";
20559
+ throw new AutotaskError(`Returned attachment identifiers contradict the requested ${parentName} or attachment`, {
20560
+ code: "INVALID_RESPONSE",
20561
+ category: "server",
20562
+ operation: `${resource}.get`
20563
+ });
20564
+ }
20565
+ }
20566
+
20567
+ // src/resources/simple.ts
20568
+ var isIdentifier = (v) => typeof v === "number" || typeof v === "string";
20569
+ var SIMPLE_RESOURCES = [
20570
+ {
20571
+ key: "appointments",
20572
+ accessor: "appointments",
20573
+ resourcePath: "/V1.0/Appointments",
20574
+ deletable: true,
20575
+ udfCapable: false,
20576
+ collectionUpdate: true,
20577
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: true, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20578
+ helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20579
+ opForms: { get: "global", create: "global", update: "global", delete: "global" }
20580
+ },
20581
+ {
20582
+ key: "attachment_info",
20583
+ accessor: "attachmentInfo",
20584
+ resourcePath: "/V1.0/AttachmentInfo",
20585
+ deletable: false,
20586
+ udfCapable: false,
20587
+ ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20588
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20589
+ opForms: { get: "global" }
20590
+ },
20591
+ {
20592
+ key: "billing_codes",
20593
+ accessor: "billingCodes",
20594
+ resourcePath: "/V1.0/BillingCodes",
20595
+ deletable: false,
20596
+ udfCapable: false,
20597
+ searchFields: ["name"],
20598
+ ops: { query: true, queryAll: false, count: true, get: true, create: false, update: false, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20599
+ helpers: { search: true, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20600
+ opForms: { get: "global" }
20601
+ },
20602
+ {
20603
+ key: "billing_item_approval_levels",
20604
+ accessor: "billingItemApprovalLevels",
20605
+ resourcePath: "/V1.0/BillingItemApprovalLevels",
20606
+ deletable: false,
20607
+ udfCapable: false,
20608
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: false, getEntityInfo: false, getFieldInfo: false, getUdfInfo: false },
20609
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20610
+ opForms: { get: "global", create: "global" }
20611
+ },
20612
+ {
20613
+ key: "billing_items",
20614
+ accessor: "billingItems",
20615
+ resourcePath: "/V1.0/BillingItems",
20616
+ deletable: false,
20617
+ udfCapable: false,
20618
+ collectionUpdate: true,
20619
+ ops: { query: true, queryAll: false, count: true, get: true, create: false, update: true, delete: false, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20620
+ helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20621
+ opForms: { get: "global", update: "global" }
20622
+ },
20623
+ {
20624
+ key: "change_request_links",
20625
+ accessor: "changeRequestLinks",
20626
+ resourcePath: "/V1.0/ChangeRequestLinks",
20627
+ deletable: true,
20628
+ udfCapable: false,
20629
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: true },
20630
+ helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
20631
+ opForms: { get: "global", create: "global", delete: "global" }
20632
+ },
20633
+ {
20178
20634
  key: "checklist_libraries",
20179
20635
  accessor: "checklistLibraries",
20180
20636
  resourcePath: "/V1.0/ChecklistLibraries",
@@ -21339,6 +21795,34 @@ var SIMPLE_RESOURCES = [
21339
21795
  helpers: { search: false, resolve: true, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
21340
21796
  opForms: { get: "global", create: "global", update: "global", delete: "global" }
21341
21797
  },
21798
+ {
21799
+ key: "task_attachments",
21800
+ accessor: "taskAttachments",
21801
+ resourcePath: "/V1.0/TaskAttachments",
21802
+ parentScopedPath: "/V1.0/Tasks/{parentId}/Attachments",
21803
+ parentPath: "/V1.0/Tasks",
21804
+ parentField: "taskID",
21805
+ deletable: true,
21806
+ udfCapable: false,
21807
+ attachmentGet: true,
21808
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: false, download: false },
21809
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
21810
+ opForms: { get: "scoped", create: "scoped", delete: "scoped" }
21811
+ },
21812
+ {
21813
+ key: "task_note_attachments",
21814
+ accessor: "taskNoteAttachments",
21815
+ resourcePath: "/V1.0/TaskNoteAttachments",
21816
+ parentScopedPath: "/V1.0/TaskNotes/{parentId}/Attachments",
21817
+ parentPath: "/V1.0/TaskNotes",
21818
+ parentField: "taskNoteID",
21819
+ deletable: true,
21820
+ udfCapable: false,
21821
+ attachmentGet: true,
21822
+ ops: { query: true, queryAll: false, count: true, get: true, create: true, update: false, delete: true, getEntityInfo: true, getFieldInfo: true, getUdfInfo: false, download: false },
21823
+ helpers: { search: false, resolve: false, getContext: false, createIfNotExists: false, attachToDocument: false, findBy: [] },
21824
+ opForms: { get: "scoped", create: "scoped", delete: "scoped" }
21825
+ },
21342
21826
  {
21343
21827
  key: "task_notes",
21344
21828
  accessor: "taskNotes",
@@ -21627,10 +22111,10 @@ var SIMPLE_RESOURCES = [
21627
22111
  var GenericResource = class extends BaseResource {
21628
22112
  constructor(http, config, pageSize) {
21629
22113
  super(http, config, pageSize);
21630
- if (["company_attachments", "company_note_attachments"].includes(config.key)) this.getUdfInfo = async () => {
22114
+ if (["company_attachments", "company_note_attachments", "task_attachments", "task_note_attachments"].includes(config.key)) this.getUdfInfo = async () => {
21631
22115
  throw new OperationNotSupportedError(config.key, "getUdfInfo");
21632
22116
  };
21633
- if (config.ops?.create === false || config.key === "company_attachments" || config.key === "task_predecessors") this.createIfNotExists = async () => {
22117
+ if (config.ops?.create === false || ["company_attachments", "task_attachments", "task_note_attachments", "task_predecessors"].includes(config.key)) this.createIfNotExists = async () => {
21634
22118
  throw new OperationNotSupportedError(config.key, "createIfNotExists");
21635
22119
  };
21636
22120
  if (config.key === "task_notes") {
@@ -21660,6 +22144,22 @@ var GenericResource = class extends BaseResource {
21660
22144
  const f = this.config.helpers;
21661
22145
  if (f && !f.findBy.includes(field)) throw new OperationNotSupportedError(this.config.key, method);
21662
22146
  }
22147
+ async getScopedModel(parentId, id, fresh = false) {
22148
+ const model = await super.getScopedModel(parentId, id, fresh);
22149
+ const key = this.config.key;
22150
+ if (key === "task_attachments" || key === "task_note_attachments") assertTaskAttachmentIdentity(key, model, parentId, id);
22151
+ return model;
22152
+ }
22153
+ async fetchPage(params, page, pageSize, state2) {
22154
+ const key = this.config.key;
22155
+ if (key === "task_attachments" || key === "task_note_attachments") admitTaskAttachmentQuery(key, params);
22156
+ return super.fetchPage(params, page, pageSize, state2);
22157
+ }
22158
+ async countGlobal(params) {
22159
+ const key = this.config.key;
22160
+ if (key === "task_attachments" || key === "task_note_attachments") admitTaskAttachmentQuery(key, params);
22161
+ return super.countGlobal(params);
22162
+ }
21663
22163
  /** Query records with the G3 filter surface (server-side JSON filter). */
21664
22164
  query(params) {
21665
22165
  this.requireOp("query");
@@ -21699,6 +22199,8 @@ var GenericResource = class extends BaseResource {
21699
22199
  const data2 = this.config.key === "task_predecessors" ? admitTaskPredecessor(b, parentId, true) : b;
21700
22200
  const opts2 = this.config.key === "task_predecessors" ? { ...c } : c ?? {};
21701
22201
  if (this.config.key === "task_notes") admitTaskNote(data2, parentId, true);
22202
+ if (this.config.key === "task_attachments") admitTaskAttachment(data2, parentId);
22203
+ if (this.config.key === "task_note_attachments") admitTaskNoteAttachment(data2, parentId);
21702
22204
  if (this.config.key === "task_predecessors") await guardTaskPredecessor(this.http, parentId, void 0, data2);
21703
22205
  if (opts2.dryRun === true) return this.runCreateDryRun(data2, parentId);
21704
22206
  return this.createScopedRaw(parentId, data2, opts2);
@@ -21983,148 +22485,6 @@ async function searchFuzzy(resource, query, opts = {}) {
21983
22485
  return { items, tier: state2.state === "warm" && validIndex ? "index+live" : "live", truncated: live.length >= 500 || ranked.length > limit, pieces, index: validIndex ? state2 : index.state() };
21984
22486
  }
21985
22487
 
21986
- // src/operations/invoke/fieldNames.ts
21987
- async function liveFieldNames(holder) {
21988
- if (holder === void 0) return null;
21989
- const reader = holder.getFieldInfo;
21990
- if (typeof reader !== "function") return null;
21991
- try {
21992
- return await readMetadataProjection(holder, "fields", liveFieldNamesView, () => reader.call(holder));
21993
- } catch (err) {
21994
- if (!isAutotaskError(err) || err.code === "ABORTED") throw err;
21995
- return null;
21996
- }
21997
- }
21998
- var UNKNOWN_NAME_LIST_CAP = 20;
21999
- var UNKNOWN_NAME_DISPLAY_CHARS = 40;
22000
- var ENTITY_NAME_LIST_CAP = 20;
22001
- function formatUnknownNameList(names, cap = UNKNOWN_NAME_LIST_CAP) {
22002
- const listed = names.slice(0, cap).map((n) => `"${n.length > UNKNOWN_NAME_DISPLAY_CHARS ? `${n.slice(0, UNKNOWN_NAME_DISPLAY_CHARS)}\u2026` : n}"`).join(", ");
22003
- const more = names.length > cap ? ` (and ${names.length - cap} more)` : "";
22004
- return `${listed}${more}`;
22005
- }
22006
- function collectFilterFieldNames(conditions, resourceKey, operation = `${resourceKey ?? "resource"}.query`) {
22007
- const out = [];
22008
- const walk = (conds) => {
22009
- for (const cond of conds) {
22010
- if (!isRecord2(cond)) continue;
22011
- if (cond.op === "and" || cond.op === "or") {
22012
- if (Array.isArray(cond.items)) walk(cond.items);
22013
- continue;
22014
- }
22015
- assertUndottedUdfField(cond, operation);
22016
- if (cond.udf === true) continue;
22017
- if (typeof cond.field === "string" && cond.field.length > 0) {
22018
- if (!cond.field.includes(".")) {
22019
- out.push(cond.field);
22020
- continue;
22021
- }
22022
- if (resourceKey !== void 0) {
22023
- const own = normalizeOwnField(resourceKey, cond.field);
22024
- if (own !== cond.field) out.push(own);
22025
- }
22026
- }
22027
- }
22028
- };
22029
- walk(conditions);
22030
- return out;
22031
- }
22032
- function readFieldCheck(record, bag) {
22033
- const fieldCheck = bag["fieldCheck"];
22034
- if (fieldCheck !== void 0 && typeof fieldCheck !== "boolean") {
22035
- throw new AutotaskConfigError(
22036
- `invoke: "${record.id}" params bag fieldCheck must be a boolean (got ${typeof fieldCheck}) \u2014 the request was not issued`,
22037
- { operation: record.id, suggestedAction: "Pass fieldCheck: true (default) or fieldCheck: false (disable the field-name checks \u2014 includeFields AND filter condition names)." }
22038
- );
22039
- }
22040
- return fieldCheck;
22041
- }
22042
- function readIncludeNames(record, includeFields) {
22043
- if (includeFields === void 0) return void 0;
22044
- let shapeOk = Array.isArray(includeFields);
22045
- const names = [];
22046
- if (shapeOk) {
22047
- for (const entry of includeFields) {
22048
- if (typeof entry !== "string" || entry.length === 0) {
22049
- shapeOk = false;
22050
- break;
22051
- }
22052
- names.push(normalizeOwnField(record.resource, entry));
22053
- }
22054
- }
22055
- if (!shapeOk) {
22056
- throw new AutotaskConfigError(
22057
- `invoke: "${record.id}" params bag includeFields must be an array of non-empty field-name strings \u2014 the request was not issued`,
22058
- {
22059
- operation: record.id,
22060
- suggestedAction: 'Pass includeFields as an array of exact vendor field names, e.g. ["id", "title"]; the live set is in operations.fieldCatalog.'
22061
- }
22062
- );
22063
- }
22064
- return names;
22065
- }
22066
- function resolveAuthority(record, live) {
22067
- if (live !== null) return { known: live.names, authority: "the tenant's live entity field metadata", hasField: (name) => live.known.has(name) };
22068
- const vendored = MODEL_FIELD_SETS[record.resource];
22069
- const modelHas = modelFieldLookup(record.resource);
22070
- const liveOnlyExempt = Array.isArray(record.metadata?.liveOnlyFields) ? record.metadata.liveOnlyFields : [];
22071
- if (vendored === void 0 || modelHas === void 0) return void 0;
22072
- return {
22073
- known: [...vendored, ...liveOnlyExempt],
22074
- hasField: (name) => modelHas(name) || liveOnlyExempt.includes(name),
22075
- 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)"
22076
- };
22077
- }
22078
- function unknownNamesRefusal(record, authority, known, unknownInclude, unknownFilter) {
22079
- const parts = [];
22080
- if (unknownInclude.length > 0) parts.push(`includeFields has unknown field name(s) ${formatUnknownNameList(unknownInclude)}`);
22081
- if (unknownFilter.length > 0) parts.push(`filter condition(s) carry unknown field name(s) ${formatUnknownNameList(unknownFilter)}`);
22082
- const wireClause = record.operation === "count" ? "the count request was not issued" : "the query POST was not issued";
22083
- const head = `invoke: "${record.id}" ${parts.join("; ")} against ${authority}`;
22084
- const count = known.length > ENTITY_NAME_LIST_CAP ? `${known.length}, first ${ENTITY_NAME_LIST_CAP}` : `${known.length}`;
22085
- const withList = `${head} \u2014 fields available on ${record.resource} (${count}): ${formatUnknownNameList(known, ENTITY_NAME_LIST_CAP)} \u2014 ${wireClause}`;
22086
- const message = known.length === 0 ? `${head} \u2014 ${wireClause}` : withList.length <= 3e3 ? withList : `${head} \u2014 ${record.resource} has ${known.length} fields; use operations.fieldCatalog resources: ["${record.resource}"] for the full set \u2014 ${wireClause}`;
22087
- return new AutotaskConfigError(
22088
- message,
22089
- {
22090
- operation: record.id,
22091
- suggestedAction: unknownNamesSuggestedAction(record, authority, unknownFilter.length > 0)
22092
- }
22093
- );
22094
- }
22095
- function unknownNamesSuggestedAction(record, authority, filterUnknown) {
22096
- const vendor = `Use exact vendor field names (operations.fieldCatalog resources: ["${record.resource}"] lists the live set).`;
22097
- if (filterUnknown && record.udfCapable) {
22098
- return `${vendor} UDF names: filter with udf: true (max 1 per query); names + picklist ids via fieldCatalog resources: ["${record.resource}"], include: ["udf"], labels: true; fieldCheck: false = vendor names only (never UDF names). Authority: ${authority}.`;
22099
- }
22100
- return `${vendor} Pass fieldCheck: false to disable this name check. The authority here was ${authority}.`;
22101
- }
22102
- async function validateQueryFieldNames(record, holder, args) {
22103
- const bag = args[0];
22104
- if (!isRecord2(bag)) return;
22105
- const fieldCheck = readFieldCheck(record, bag);
22106
- const includeNames = readIncludeNames(record, bag["includeFields"]);
22107
- let filterNames;
22108
- if (bag["filter"] !== void 0) {
22109
- const conditions = normalizedConditions(bag["filter"]);
22110
- filterNames = collectFilterFieldNames(conditions ?? [], record.resource, record.id);
22111
- }
22112
- if (fieldCheck === false) return;
22113
- const found = await findUnknownFieldNames(record, holder, { includeFields: includeNames ?? [], filter: filterNames ?? [] });
22114
- if (found === void 0) return;
22115
- const { known, authority, unknown } = found;
22116
- if (unknown["includeFields"].length === 0 && unknown["filter"].length === 0) return;
22117
- throw unknownNamesRefusal(record, authority, known, unknown["includeFields"], unknown["filter"]);
22118
- }
22119
- async function findUnknownFieldNames(record, holder, lists) {
22120
- if (Object.values(lists).every((names) => names.length === 0)) return void 0;
22121
- const resolved = resolveAuthority(record, await liveFieldNames(holder));
22122
- if (resolved === void 0) return void 0;
22123
- const unknown = {};
22124
- for (const [key, names] of Object.entries(lists)) unknown[key] = [...new Set(names.filter((name) => !resolved.hasField(name)))];
22125
- return { known: resolved.known, authority: resolved.authority, unknown };
22126
- }
22127
-
22128
22488
  // src/resources/special/_shared/ticketStatus.ts
22129
22489
  var ASSUMED_CLOSED_STATUS_ID = 5;
22130
22490
  var CLOSED_STATUS_LABELS = ["complete", "completed", "closed", "cancelled", "canceled", "resolved"];
@@ -23631,7 +23991,7 @@ function dateBucketLabel(value, bucket) {
23631
23991
  var queryResourceKeysPromise = null;
23632
23992
  function queryResourceKeys() {
23633
23993
  if (queryResourceKeysPromise === null) {
23634
- queryResourceKeysPromise = chunkASL3BIW2_cjs.loadCapabilityRecords().then((records) => {
23994
+ queryResourceKeysPromise = chunkC4S3EKIK_cjs.loadCapabilityRecords().then((records) => {
23635
23995
  const s = /* @__PURE__ */ new Set();
23636
23996
  for (const rec of records) if (rec.operation === "query") s.add(rec.resource);
23637
23997
  return s;
@@ -23753,7 +24113,7 @@ function parseTopAndLimit(opts, problems) {
23753
24113
  return { top, limit };
23754
24114
  }
23755
24115
  async function checkFieldNames(resourceKey, conditions, opts, problems) {
23756
- const records = resourceKey === void 0 ? [] : await chunkASL3BIW2_cjs.loadCapabilityRecords();
24116
+ const records = resourceKey === void 0 ? [] : await chunkC4S3EKIK_cjs.loadCapabilityRecords();
23757
24117
  const record = resourceKey === void 0 ? void 0 : records.find((r) => r.resource === resourceKey && r.operation === "query");
23758
24118
  if (record === void 0) return void 0;
23759
24119
  const strings = (v) => Array.isArray(v) ? v.filter((f) => typeof f === "string" && f.trim() !== "") : [];
@@ -24398,7 +24758,7 @@ async function uiLink(client, input) {
24398
24758
  var indexPromise = null;
24399
24759
  function operationIndex() {
24400
24760
  if (indexPromise === null) {
24401
- indexPromise = chunkASL3BIW2_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
24761
+ indexPromise = chunkC4S3EKIK_cjs.loadCapabilityRecords().then((records) => new Map(records.map((r) => [r.id, r])));
24402
24762
  }
24403
24763
  return indexPromise;
24404
24764
  }