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