@digisglobal/omnivox-sdk 0.8.0 → 0.10.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/dist/index.cjs +201 -3
- package/dist/index.d.cts +317 -12
- package/dist/index.d.ts +317 -12
- package/dist/index.js +198 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,13 +25,16 @@ __export(index_exports, {
|
|
|
25
25
|
createAgentsModule: () => createAgentsModule,
|
|
26
26
|
createApiKeyTokenProvider: () => createApiKeyTokenProvider,
|
|
27
27
|
createAttachmentsModule: () => createAttachmentsModule,
|
|
28
|
+
createAuditModule: () => createAuditModule,
|
|
28
29
|
createAuthMeModule: () => createAuthMeModule,
|
|
29
30
|
createCannedResponsesModule: () => createCannedResponsesModule,
|
|
30
31
|
createChannelsModule: () => createChannelsModule,
|
|
31
32
|
createContactsModule: () => createContactsModule,
|
|
32
33
|
createConversationsModule: () => createConversationsModule,
|
|
34
|
+
createDashboardModule: () => createDashboardModule,
|
|
33
35
|
createMessagesModule: () => createMessagesModule,
|
|
34
36
|
createOmnivoxClient: () => createOmnivoxClient,
|
|
37
|
+
createParticipantsModule: () => createParticipantsModule,
|
|
35
38
|
createSessionTokenProvider: () => createSessionTokenProvider,
|
|
36
39
|
createTemplatesModule: () => createTemplatesModule,
|
|
37
40
|
createTenantsModule: () => createTenantsModule,
|
|
@@ -160,6 +163,15 @@ var getConversationsControllerUpdateStatusUrl = (id) => {
|
|
|
160
163
|
var getConversationsControllerAssignUrl = (id) => {
|
|
161
164
|
return `/api/v1/conversations/${id}/assign`;
|
|
162
165
|
};
|
|
166
|
+
var getConversationsControllerAddParticipantUrl = (id) => {
|
|
167
|
+
return `/api/v1/conversations/${id}/participants`;
|
|
168
|
+
};
|
|
169
|
+
var getConversationsControllerListParticipantsUrl = (id) => {
|
|
170
|
+
return `/api/v1/conversations/${id}/participants`;
|
|
171
|
+
};
|
|
172
|
+
var getConversationsControllerRemoveParticipantUrl = (id, agentId) => {
|
|
173
|
+
return `/api/v1/conversations/${id}/participants/${agentId}`;
|
|
174
|
+
};
|
|
163
175
|
var getConversationsControllerListLobbyUrl = (params) => {
|
|
164
176
|
const normalizedParams = new URLSearchParams();
|
|
165
177
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
@@ -320,12 +332,38 @@ var getCannedResponsesControllerPatchUrl = (id) => {
|
|
|
320
332
|
var getCannedResponsesControllerDeleteUrl = (id) => {
|
|
321
333
|
return `/api/v1/canned-responses/${id}`;
|
|
322
334
|
};
|
|
335
|
+
var getCannedResponsesControllerDuplicateUrl = (id) => {
|
|
336
|
+
return `/api/v1/canned-responses/${id}/duplicate`;
|
|
337
|
+
};
|
|
323
338
|
var getAttachmentsControllerUploadUrl = () => {
|
|
324
339
|
return `/api/v1/attachments`;
|
|
325
340
|
};
|
|
326
341
|
var getAttachmentsControllerGetDownloadUrlUrl = (id) => {
|
|
327
342
|
return `/api/v1/attachments/${id}/url`;
|
|
328
343
|
};
|
|
344
|
+
var getDashboardControllerGetStatsUrl = () => {
|
|
345
|
+
return `/api/v1/dashboard/stats`;
|
|
346
|
+
};
|
|
347
|
+
var getDashboardControllerGetRecentActivityUrl = (params) => {
|
|
348
|
+
const normalizedParams = new URLSearchParams();
|
|
349
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
350
|
+
if (value !== void 0) {
|
|
351
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
const stringifiedParams = normalizedParams.toString();
|
|
355
|
+
return stringifiedParams.length > 0 ? `/api/v1/dashboard/recent-activity?${stringifiedParams}` : `/api/v1/dashboard/recent-activity`;
|
|
356
|
+
};
|
|
357
|
+
var getAuditLogControllerListUrl = (params) => {
|
|
358
|
+
const normalizedParams = new URLSearchParams();
|
|
359
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
360
|
+
if (value !== void 0) {
|
|
361
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
const stringifiedParams = normalizedParams.toString();
|
|
365
|
+
return stringifiedParams.length > 0 ? `/api/v1/audit-log?${stringifiedParams}` : `/api/v1/audit-log`;
|
|
366
|
+
};
|
|
329
367
|
|
|
330
368
|
// src/pagination/pagination.ts
|
|
331
369
|
var MAX_PAGE_SIZE = 100;
|
|
@@ -742,6 +780,60 @@ function createConversationsModule(options) {
|
|
|
742
780
|
};
|
|
743
781
|
}
|
|
744
782
|
|
|
783
|
+
// src/conversations/participants.ts
|
|
784
|
+
function createParticipantsModule(options) {
|
|
785
|
+
const baseUrl = options.baseUrl;
|
|
786
|
+
function buildInit(method, body) {
|
|
787
|
+
return {
|
|
788
|
+
method,
|
|
789
|
+
credentials: options.getCredentials(),
|
|
790
|
+
headers: {
|
|
791
|
+
"Content-Type": "application/json",
|
|
792
|
+
...options.getHeaders()
|
|
793
|
+
},
|
|
794
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
/**
|
|
799
|
+
* Add (or re-add) an agent as a conversation participant with a role.
|
|
800
|
+
* Idempotent per active membership — re-adding an active participant
|
|
801
|
+
* updates its role; a second OWNER co-owns (no demotion of other owners).
|
|
802
|
+
* Calls POST /api/v1/conversations/:id/participants.
|
|
803
|
+
*/
|
|
804
|
+
async add(conversationId, input) {
|
|
805
|
+
const path = getConversationsControllerAddParticipantUrl(conversationId);
|
|
806
|
+
const url = `${baseUrl}${path}`;
|
|
807
|
+
const res = await fetch(url, buildInit("POST", input));
|
|
808
|
+
return parseEnvelopedResponse(res);
|
|
809
|
+
},
|
|
810
|
+
/**
|
|
811
|
+
* End an active membership for an agent. Idempotent — removing a
|
|
812
|
+
* non-participant is a no-op ({ removed: 0 }).
|
|
813
|
+
* Calls DELETE /api/v1/conversations/:id/participants/:agentId.
|
|
814
|
+
*/
|
|
815
|
+
async remove(conversationId, agentId) {
|
|
816
|
+
const path = getConversationsControllerRemoveParticipantUrl(
|
|
817
|
+
conversationId,
|
|
818
|
+
agentId
|
|
819
|
+
);
|
|
820
|
+
const url = `${baseUrl}${path}`;
|
|
821
|
+
const res = await fetch(url, buildInit("DELETE"));
|
|
822
|
+
return parseEnvelopedResponse(res);
|
|
823
|
+
},
|
|
824
|
+
/**
|
|
825
|
+
* List the ACTIVE (leftAt IS NULL) participants of a conversation.
|
|
826
|
+
* Calls GET /api/v1/conversations/:id/participants.
|
|
827
|
+
*/
|
|
828
|
+
async list(conversationId) {
|
|
829
|
+
const path = getConversationsControllerListParticipantsUrl(conversationId);
|
|
830
|
+
const url = `${baseUrl}${path}`;
|
|
831
|
+
const res = await fetch(url, buildInit("GET"));
|
|
832
|
+
return parseEnvelopedResponse(res);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
|
|
745
837
|
// src/messages/messages.ts
|
|
746
838
|
function createMessagesModule(options) {
|
|
747
839
|
const baseUrl = options.baseUrl;
|
|
@@ -1025,7 +1117,12 @@ function createCannedResponsesModule(options) {
|
|
|
1025
1117
|
*/
|
|
1026
1118
|
async list(opts) {
|
|
1027
1119
|
const { page, pageSize } = buildPageParams(opts);
|
|
1028
|
-
const path = getCannedResponsesControllerListUrl({
|
|
1120
|
+
const path = getCannedResponsesControllerListUrl({
|
|
1121
|
+
page,
|
|
1122
|
+
pageSize,
|
|
1123
|
+
...opts.category ? { category: opts.category } : {},
|
|
1124
|
+
...opts.channel ? { channel: opts.channel } : {}
|
|
1125
|
+
});
|
|
1029
1126
|
const url = `${baseUrl}${path}`;
|
|
1030
1127
|
const res = await fetch(url, buildInit("GET"));
|
|
1031
1128
|
return parseResponse(res);
|
|
@@ -1040,7 +1137,9 @@ function createCannedResponsesModule(options) {
|
|
|
1040
1137
|
const path = getCannedResponsesControllerListUrl({
|
|
1041
1138
|
page,
|
|
1042
1139
|
pageSize,
|
|
1043
|
-
q: opts.q
|
|
1140
|
+
q: opts.q,
|
|
1141
|
+
...opts.category ? { category: opts.category } : {},
|
|
1142
|
+
...opts.channel ? { channel: opts.channel } : {}
|
|
1044
1143
|
});
|
|
1045
1144
|
const url = `${baseUrl}${path}`;
|
|
1046
1145
|
const res = await fetch(url, buildInit("GET"));
|
|
@@ -1057,7 +1156,7 @@ function createCannedResponsesModule(options) {
|
|
|
1057
1156
|
return parseEnvelopedResponse(res);
|
|
1058
1157
|
},
|
|
1059
1158
|
/**
|
|
1060
|
-
* Partially update a canned response — title,
|
|
1159
|
+
* Partially update a canned response — title, shortcut, category, channel, and/or body.
|
|
1061
1160
|
* Calls PATCH /api/v1/canned-responses/:id.
|
|
1062
1161
|
*/
|
|
1063
1162
|
async update(id, input) {
|
|
@@ -1077,6 +1176,16 @@ function createCannedResponsesModule(options) {
|
|
|
1077
1176
|
if (!res.ok) {
|
|
1078
1177
|
return parseResponse(res);
|
|
1079
1178
|
}
|
|
1179
|
+
},
|
|
1180
|
+
/**
|
|
1181
|
+
* Duplicate a canned response. The server generates a unique title and
|
|
1182
|
+
* shortcut. Calls POST /api/v1/canned-responses/:id/duplicate.
|
|
1183
|
+
*/
|
|
1184
|
+
async duplicate(id) {
|
|
1185
|
+
const path = getCannedResponsesControllerDuplicateUrl(id);
|
|
1186
|
+
const url = `${baseUrl}${path}`;
|
|
1187
|
+
const res = await fetch(url, buildInit("POST"));
|
|
1188
|
+
return parseEnvelopedResponse(res);
|
|
1080
1189
|
}
|
|
1081
1190
|
};
|
|
1082
1191
|
}
|
|
@@ -1220,6 +1329,89 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1220
1329
|
};
|
|
1221
1330
|
}
|
|
1222
1331
|
|
|
1332
|
+
// src/dashboard/dashboard.ts
|
|
1333
|
+
function createDashboardModule(options) {
|
|
1334
|
+
const baseUrl = options.baseUrl;
|
|
1335
|
+
function buildInit() {
|
|
1336
|
+
return {
|
|
1337
|
+
method: "GET",
|
|
1338
|
+
credentials: options.getCredentials(),
|
|
1339
|
+
headers: {
|
|
1340
|
+
"Content-Type": "application/json",
|
|
1341
|
+
...options.getHeaders()
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
return {
|
|
1346
|
+
/**
|
|
1347
|
+
* Fetch the tenant dashboard KPIs.
|
|
1348
|
+
* Calls GET /api/v1/dashboard/stats.
|
|
1349
|
+
*/
|
|
1350
|
+
async stats() {
|
|
1351
|
+
const path = getDashboardControllerGetStatsUrl();
|
|
1352
|
+
const url = `${baseUrl}${path}`;
|
|
1353
|
+
const res = await fetch(url, buildInit());
|
|
1354
|
+
return parseEnvelopedResponse(res);
|
|
1355
|
+
},
|
|
1356
|
+
/**
|
|
1357
|
+
* List the tenant's recent conversation/message activity feed
|
|
1358
|
+
* (newest first, paginated). pageSize is clamped to 100 per the API
|
|
1359
|
+
* contract. Calls GET /api/v1/dashboard/recent-activity.
|
|
1360
|
+
*/
|
|
1361
|
+
async recentActivity(opts = { page: 1, pageSize: 25 }) {
|
|
1362
|
+
const { page, pageSize } = buildPageParams(opts);
|
|
1363
|
+
const path = getDashboardControllerGetRecentActivityUrl({
|
|
1364
|
+
page,
|
|
1365
|
+
pageSize
|
|
1366
|
+
});
|
|
1367
|
+
const url = `${baseUrl}${path}`;
|
|
1368
|
+
const res = await fetch(url, buildInit());
|
|
1369
|
+
return parseResponse(res);
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// src/audit/audit.ts
|
|
1375
|
+
function createAuditModule(options) {
|
|
1376
|
+
const baseUrl = options.baseUrl;
|
|
1377
|
+
function buildInit() {
|
|
1378
|
+
return {
|
|
1379
|
+
method: "GET",
|
|
1380
|
+
credentials: options.getCredentials(),
|
|
1381
|
+
headers: {
|
|
1382
|
+
"Content-Type": "application/json",
|
|
1383
|
+
...options.getHeaders()
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
return {
|
|
1388
|
+
/**
|
|
1389
|
+
* List the tenant audit trail (newest first, paginated).
|
|
1390
|
+
* pageSize is clamped to 100 per the API contract.
|
|
1391
|
+
* Calls GET /api/v1/audit-log.
|
|
1392
|
+
*/
|
|
1393
|
+
async list(opts = {}) {
|
|
1394
|
+
const { page, pageSize } = buildPageParams({
|
|
1395
|
+
page: opts.page ?? 1,
|
|
1396
|
+
pageSize: opts.pageSize ?? 25
|
|
1397
|
+
});
|
|
1398
|
+
const params = {
|
|
1399
|
+
...opts.resourceType !== void 0 ? { resourceType: opts.resourceType } : {},
|
|
1400
|
+
...opts.resourceId !== void 0 ? { resourceId: opts.resourceId } : {},
|
|
1401
|
+
...opts.actorId !== void 0 ? { actorId: opts.actorId } : {},
|
|
1402
|
+
...opts.from !== void 0 ? { from: opts.from } : {},
|
|
1403
|
+
...opts.to !== void 0 ? { to: opts.to } : {},
|
|
1404
|
+
page,
|
|
1405
|
+
pageSize
|
|
1406
|
+
};
|
|
1407
|
+
const path = getAuditLogControllerListUrl(params);
|
|
1408
|
+
const url = `${baseUrl}${path}`;
|
|
1409
|
+
const res = await fetch(url, buildInit());
|
|
1410
|
+
return parseResponse(res);
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1223
1415
|
// src/ws/ws-client.ts
|
|
1224
1416
|
var import_socket = require("socket.io-client");
|
|
1225
1417
|
function createWsClient(options) {
|
|
@@ -1310,11 +1502,14 @@ function createOmnivoxClient(options) {
|
|
|
1310
1502
|
channels: createChannelsModule(moduleOptions),
|
|
1311
1503
|
contacts: createContactsModule(moduleOptions),
|
|
1312
1504
|
conversations: createConversationsModule(moduleOptions),
|
|
1505
|
+
participants: createParticipantsModule(moduleOptions),
|
|
1313
1506
|
messages: createMessagesModule(moduleOptions),
|
|
1314
1507
|
templates: createTemplatesModule(moduleOptions),
|
|
1315
1508
|
cannedResponses: createCannedResponsesModule(moduleOptions),
|
|
1316
1509
|
attachments: createAttachmentsModule(moduleOptions),
|
|
1317
1510
|
whatsappBusinessAccounts: createWhatsAppBusinessAccountsModule(moduleOptions),
|
|
1511
|
+
dashboard: createDashboardModule(moduleOptions),
|
|
1512
|
+
audit: createAuditModule(moduleOptions),
|
|
1318
1513
|
/**
|
|
1319
1514
|
* Creates a WebSocket client connected to the `/ws/chat` namespace.
|
|
1320
1515
|
*
|
|
@@ -1370,13 +1565,16 @@ function createSessionTokenProvider() {
|
|
|
1370
1565
|
createAgentsModule,
|
|
1371
1566
|
createApiKeyTokenProvider,
|
|
1372
1567
|
createAttachmentsModule,
|
|
1568
|
+
createAuditModule,
|
|
1373
1569
|
createAuthMeModule,
|
|
1374
1570
|
createCannedResponsesModule,
|
|
1375
1571
|
createChannelsModule,
|
|
1376
1572
|
createContactsModule,
|
|
1377
1573
|
createConversationsModule,
|
|
1574
|
+
createDashboardModule,
|
|
1378
1575
|
createMessagesModule,
|
|
1379
1576
|
createOmnivoxClient,
|
|
1577
|
+
createParticipantsModule,
|
|
1380
1578
|
createSessionTokenProvider,
|
|
1381
1579
|
createTemplatesModule,
|
|
1382
1580
|
createTenantsModule,
|