@unboundcx/sdk 4.13.6 → 4.13.7
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/package.json +1 -1
- package/services/chat.js +244 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.7",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
package/services/chat.js
CHANGED
|
@@ -1016,15 +1016,16 @@ export class ChatService {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
1018
|
/**
|
|
1019
|
-
* Admin: list moderation
|
|
1019
|
+
* Admin: list moderation dispositions (permanent per-message
|
|
1020
|
+
* hide/disposition history — one row per message).
|
|
1020
1021
|
* @param {Object} [params]
|
|
1021
1022
|
* @param {'open'|'closed'|'all'} [params.status]
|
|
1022
1023
|
* @param {string} [params.authorId]
|
|
1023
|
-
* @param {string} [params.nextId] Pagination cursor (
|
|
1024
|
+
* @param {string} [params.nextId] Pagination cursor (disposition id)
|
|
1024
1025
|
* @param {number} [params.limit]
|
|
1025
1026
|
* @returns {Promise<Object>} `{results, hasMore, nextId}`
|
|
1026
1027
|
*/
|
|
1027
|
-
async
|
|
1028
|
+
async adminListDispositions({ status, authorId, nextId, limit } = {}) {
|
|
1028
1029
|
this.sdk.validateParams(
|
|
1029
1030
|
{ status, authorId, nextId, limit },
|
|
1030
1031
|
{
|
|
@@ -1039,12 +1040,90 @@ export class ChatService {
|
|
|
1039
1040
|
if (authorId !== undefined) query.authorId = authorId;
|
|
1040
1041
|
if (nextId !== undefined) query.nextId = nextId;
|
|
1041
1042
|
if (limit !== undefined) query.limit = limit;
|
|
1043
|
+
return internalRequest(this.sdk, "/chat/admin/dispositions", "GET", {
|
|
1044
|
+
query,
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Admin: get one moderation disposition — hydrated with its message
|
|
1050
|
+
* (content per the usual rules) and reports.
|
|
1051
|
+
* @param {string} id
|
|
1052
|
+
* @returns {Promise<Object>}
|
|
1053
|
+
*/
|
|
1054
|
+
async adminGetDisposition(id) {
|
|
1055
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1056
|
+
return internalRequest(this.sdk, `/chat/admin/dispositions/${id}`, "GET");
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Admin: list chat cases (multi-message investigations — distinct from
|
|
1061
|
+
* the per-message disposition ledger above).
|
|
1062
|
+
* @param {Object} [params]
|
|
1063
|
+
* @param {'open'|'in_review'|'closed'|'all'} [params.status]
|
|
1064
|
+
* @param {string} [params.category]
|
|
1065
|
+
* @param {string} [params.ownerId]
|
|
1066
|
+
* @param {string} [params.q] Substring match on title
|
|
1067
|
+
* @param {string} [params.nextId] Pagination cursor (case id)
|
|
1068
|
+
* @param {number} [params.limit]
|
|
1069
|
+
* @returns {Promise<Object>} `{results, hasMore, nextId}` — each result
|
|
1070
|
+
* includes `itemCount`, `noteCount`, `lastActivityAt`
|
|
1071
|
+
*/
|
|
1072
|
+
async adminListCases({ status, category, ownerId, q, nextId, limit } = {}) {
|
|
1073
|
+
this.sdk.validateParams(
|
|
1074
|
+
{ status, category, ownerId, q, nextId, limit },
|
|
1075
|
+
{
|
|
1076
|
+
status: { type: "string", required: false },
|
|
1077
|
+
category: { type: "string", required: false },
|
|
1078
|
+
ownerId: { type: "string", required: false },
|
|
1079
|
+
q: { type: "string", required: false },
|
|
1080
|
+
nextId: { type: "string", required: false },
|
|
1081
|
+
limit: { type: "number", required: false },
|
|
1082
|
+
},
|
|
1083
|
+
);
|
|
1084
|
+
const query = {};
|
|
1085
|
+
if (status !== undefined) query.status = status;
|
|
1086
|
+
if (category !== undefined) query.category = category;
|
|
1087
|
+
if (ownerId !== undefined) query.ownerId = ownerId;
|
|
1088
|
+
if (q !== undefined) query.q = q;
|
|
1089
|
+
if (nextId !== undefined) query.nextId = nextId;
|
|
1090
|
+
if (limit !== undefined) query.limit = limit;
|
|
1042
1091
|
return internalRequest(this.sdk, "/chat/admin/cases", "GET", { query });
|
|
1043
1092
|
}
|
|
1044
1093
|
|
|
1045
1094
|
/**
|
|
1046
|
-
* Admin:
|
|
1047
|
-
*
|
|
1095
|
+
* Admin: create a chat case, optionally seeding it with messages
|
|
1096
|
+
* (report ids on those messages are auto-attached to the created item).
|
|
1097
|
+
* @param {Object} params
|
|
1098
|
+
* @param {string} params.title
|
|
1099
|
+
* @param {string} [params.category]
|
|
1100
|
+
* @param {string} [params.description]
|
|
1101
|
+
* @param {string} [params.ownerId]
|
|
1102
|
+
* @param {string[]} [params.messageIds]
|
|
1103
|
+
* @returns {Promise<Object>} the case, plus `items`/`notes`
|
|
1104
|
+
*/
|
|
1105
|
+
async adminCreateCase({ title, category, description, ownerId, messageIds }) {
|
|
1106
|
+
this.sdk.validateParams(
|
|
1107
|
+
{ title, category, description, ownerId, messageIds },
|
|
1108
|
+
{
|
|
1109
|
+
title: { type: "string", required: true },
|
|
1110
|
+
category: { type: "string", required: false },
|
|
1111
|
+
description: { type: "string", required: false },
|
|
1112
|
+
ownerId: { type: "string", required: false },
|
|
1113
|
+
messageIds: { type: "array", required: false },
|
|
1114
|
+
},
|
|
1115
|
+
);
|
|
1116
|
+
const body = { title };
|
|
1117
|
+
if (category !== undefined) body.category = category;
|
|
1118
|
+
if (description !== undefined) body.description = description;
|
|
1119
|
+
if (ownerId !== undefined) body.ownerId = ownerId;
|
|
1120
|
+
if (messageIds !== undefined) body.messageIds = messageIds;
|
|
1121
|
+
return internalRequest(this.sdk, "/chat/admin/cases", "POST", { body });
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Admin: get one chat case — hydrated with its items (each with
|
|
1126
|
+
* message/channel/reports/disposition) and its note trail.
|
|
1048
1127
|
* @param {string} id
|
|
1049
1128
|
* @returns {Promise<Object>}
|
|
1050
1129
|
*/
|
|
@@ -1053,6 +1132,166 @@ export class ChatService {
|
|
|
1053
1132
|
return internalRequest(this.sdk, `/chat/admin/cases/${id}`, "GET");
|
|
1054
1133
|
}
|
|
1055
1134
|
|
|
1135
|
+
/**
|
|
1136
|
+
* Admin: update a chat case's fields. `status` may only move between
|
|
1137
|
+
* 'open' and 'in_review' here — use adminCloseCase/adminReopenCase to
|
|
1138
|
+
* close or reopen.
|
|
1139
|
+
* @param {string} id
|
|
1140
|
+
* @param {Object} params
|
|
1141
|
+
* @param {string} [params.title]
|
|
1142
|
+
* @param {string} [params.category]
|
|
1143
|
+
* @param {string} [params.description]
|
|
1144
|
+
* @param {string} [params.ownerId]
|
|
1145
|
+
* @param {'open'|'in_review'} [params.status]
|
|
1146
|
+
* @returns {Promise<Object>}
|
|
1147
|
+
*/
|
|
1148
|
+
async adminUpdateCase(id, { title, category, description, ownerId, status } = {}) {
|
|
1149
|
+
this.sdk.validateParams(
|
|
1150
|
+
{ id, title, category, description, ownerId, status },
|
|
1151
|
+
{
|
|
1152
|
+
id: { type: "string", required: true },
|
|
1153
|
+
title: { type: "string", required: false },
|
|
1154
|
+
category: { type: "string", required: false },
|
|
1155
|
+
description: { type: "string", required: false },
|
|
1156
|
+
ownerId: { type: "string", required: false },
|
|
1157
|
+
status: { type: "string", required: false },
|
|
1158
|
+
},
|
|
1159
|
+
);
|
|
1160
|
+
const body = {};
|
|
1161
|
+
if (title !== undefined) body.title = title;
|
|
1162
|
+
if (category !== undefined) body.category = category;
|
|
1163
|
+
if (description !== undefined) body.description = description;
|
|
1164
|
+
if (ownerId !== undefined) body.ownerId = ownerId;
|
|
1165
|
+
if (status !== undefined) body.status = status;
|
|
1166
|
+
return internalRequest(this.sdk, `/chat/admin/cases/${id}`, "PATCH", {
|
|
1167
|
+
body,
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Admin: attach messages to a case (reportIds auto-filled from each
|
|
1173
|
+
* message's open reports). Messages already on the case are skipped.
|
|
1174
|
+
* @param {string} id
|
|
1175
|
+
* @param {Object} params
|
|
1176
|
+
* @param {string[]} params.messageIds
|
|
1177
|
+
* @returns {Promise<Object>}
|
|
1178
|
+
*/
|
|
1179
|
+
async adminAddCaseItems(id, { messageIds }) {
|
|
1180
|
+
this.sdk.validateParams(
|
|
1181
|
+
{ id, messageIds },
|
|
1182
|
+
{
|
|
1183
|
+
id: { type: "string", required: true },
|
|
1184
|
+
messageIds: { type: "array", required: true },
|
|
1185
|
+
},
|
|
1186
|
+
);
|
|
1187
|
+
return internalRequest(this.sdk, `/chat/admin/cases/${id}/items`, "POST", {
|
|
1188
|
+
body: { messageIds },
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* Admin: remove one message from a case.
|
|
1194
|
+
* @param {string} id
|
|
1195
|
+
* @param {string} messageId
|
|
1196
|
+
* @returns {Promise<Object>}
|
|
1197
|
+
*/
|
|
1198
|
+
async adminRemoveCaseItem(id, messageId) {
|
|
1199
|
+
this.sdk.validateParams(
|
|
1200
|
+
{ id, messageId },
|
|
1201
|
+
{
|
|
1202
|
+
id: { type: "string", required: true },
|
|
1203
|
+
messageId: { type: "string", required: true },
|
|
1204
|
+
},
|
|
1205
|
+
);
|
|
1206
|
+
return internalRequest(
|
|
1207
|
+
this.sdk,
|
|
1208
|
+
`/chat/admin/cases/${id}/items/${messageId}`,
|
|
1209
|
+
"DELETE",
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Admin: add a note to a case.
|
|
1215
|
+
* @param {string} id
|
|
1216
|
+
* @param {Object} params
|
|
1217
|
+
* @param {string} params.body
|
|
1218
|
+
* @returns {Promise<Object>}
|
|
1219
|
+
*/
|
|
1220
|
+
async adminAddCaseNote(id, { body }) {
|
|
1221
|
+
this.sdk.validateParams(
|
|
1222
|
+
{ id, body },
|
|
1223
|
+
{
|
|
1224
|
+
id: { type: "string", required: true },
|
|
1225
|
+
body: { type: "string", required: true },
|
|
1226
|
+
},
|
|
1227
|
+
);
|
|
1228
|
+
return internalRequest(this.sdk, `/chat/admin/cases/${id}/notes`, "POST", {
|
|
1229
|
+
body: { body },
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Admin: close a case with a required outcome and note. Appends a
|
|
1235
|
+
* system note to the case.
|
|
1236
|
+
* @param {string} id
|
|
1237
|
+
* @param {Object} params
|
|
1238
|
+
* @param {'no_action'|'warned'|'escalated_hr'|'content_removed'|'other'} params.outcome
|
|
1239
|
+
* @param {string} params.note
|
|
1240
|
+
* @returns {Promise<Object>}
|
|
1241
|
+
*/
|
|
1242
|
+
async adminCloseCase(id, { outcome, note }) {
|
|
1243
|
+
this.sdk.validateParams(
|
|
1244
|
+
{ id, outcome, note },
|
|
1245
|
+
{
|
|
1246
|
+
id: { type: "string", required: true },
|
|
1247
|
+
outcome: { type: "string", required: true },
|
|
1248
|
+
note: { type: "string", required: true },
|
|
1249
|
+
},
|
|
1250
|
+
);
|
|
1251
|
+
return internalRequest(this.sdk, `/chat/admin/cases/${id}/close`, "POST", {
|
|
1252
|
+
body: { outcome, note },
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Admin: reopen a closed case with a required reason. Clears
|
|
1258
|
+
* outcome/closedAt/closedBy/closeNote and appends a system note.
|
|
1259
|
+
* @param {string} id
|
|
1260
|
+
* @param {Object} params
|
|
1261
|
+
* @param {string} params.reason
|
|
1262
|
+
* @returns {Promise<Object>}
|
|
1263
|
+
*/
|
|
1264
|
+
async adminReopenCase(id, { reason }) {
|
|
1265
|
+
this.sdk.validateParams(
|
|
1266
|
+
{ id, reason },
|
|
1267
|
+
{
|
|
1268
|
+
id: { type: "string", required: true },
|
|
1269
|
+
reason: { type: "string", required: true },
|
|
1270
|
+
},
|
|
1271
|
+
);
|
|
1272
|
+
return internalRequest(this.sdk, `/chat/admin/cases/${id}/reopen`, "POST", {
|
|
1273
|
+
body: { reason },
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Admin: list the chat cases a message is linked to (for a report/
|
|
1279
|
+
* flagged-message "Add to case" affordance).
|
|
1280
|
+
* @param {string} messageId
|
|
1281
|
+
* @returns {Promise<Object>} `{results}`
|
|
1282
|
+
*/
|
|
1283
|
+
async adminListMessageCases(messageId) {
|
|
1284
|
+
this.sdk.validateParams(
|
|
1285
|
+
{ messageId },
|
|
1286
|
+
{ messageId: { type: "string", required: true } },
|
|
1287
|
+
);
|
|
1288
|
+
return internalRequest(
|
|
1289
|
+
this.sdk,
|
|
1290
|
+
`/chat/admin/messages/${messageId}/cases`,
|
|
1291
|
+
"GET",
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1056
1295
|
/**
|
|
1057
1296
|
* Admin: audit log of review actions.
|
|
1058
1297
|
* @returns {Promise<Object>}
|