@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.js CHANGED
@@ -117,6 +117,15 @@ var getConversationsControllerUpdateStatusUrl = (id) => {
117
117
  var getConversationsControllerAssignUrl = (id) => {
118
118
  return `/api/v1/conversations/${id}/assign`;
119
119
  };
120
+ var getConversationsControllerAddParticipantUrl = (id) => {
121
+ return `/api/v1/conversations/${id}/participants`;
122
+ };
123
+ var getConversationsControllerListParticipantsUrl = (id) => {
124
+ return `/api/v1/conversations/${id}/participants`;
125
+ };
126
+ var getConversationsControllerRemoveParticipantUrl = (id, agentId) => {
127
+ return `/api/v1/conversations/${id}/participants/${agentId}`;
128
+ };
120
129
  var getConversationsControllerListLobbyUrl = (params) => {
121
130
  const normalizedParams = new URLSearchParams();
122
131
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -277,12 +286,38 @@ var getCannedResponsesControllerPatchUrl = (id) => {
277
286
  var getCannedResponsesControllerDeleteUrl = (id) => {
278
287
  return `/api/v1/canned-responses/${id}`;
279
288
  };
289
+ var getCannedResponsesControllerDuplicateUrl = (id) => {
290
+ return `/api/v1/canned-responses/${id}/duplicate`;
291
+ };
280
292
  var getAttachmentsControllerUploadUrl = () => {
281
293
  return `/api/v1/attachments`;
282
294
  };
283
295
  var getAttachmentsControllerGetDownloadUrlUrl = (id) => {
284
296
  return `/api/v1/attachments/${id}/url`;
285
297
  };
298
+ var getDashboardControllerGetStatsUrl = () => {
299
+ return `/api/v1/dashboard/stats`;
300
+ };
301
+ var getDashboardControllerGetRecentActivityUrl = (params) => {
302
+ const normalizedParams = new URLSearchParams();
303
+ Object.entries(params || {}).forEach(([key, value]) => {
304
+ if (value !== void 0) {
305
+ normalizedParams.append(key, value === null ? "null" : String(value));
306
+ }
307
+ });
308
+ const stringifiedParams = normalizedParams.toString();
309
+ return stringifiedParams.length > 0 ? `/api/v1/dashboard/recent-activity?${stringifiedParams}` : `/api/v1/dashboard/recent-activity`;
310
+ };
311
+ var getAuditLogControllerListUrl = (params) => {
312
+ const normalizedParams = new URLSearchParams();
313
+ Object.entries(params || {}).forEach(([key, value]) => {
314
+ if (value !== void 0) {
315
+ normalizedParams.append(key, value === null ? "null" : String(value));
316
+ }
317
+ });
318
+ const stringifiedParams = normalizedParams.toString();
319
+ return stringifiedParams.length > 0 ? `/api/v1/audit-log?${stringifiedParams}` : `/api/v1/audit-log`;
320
+ };
286
321
 
287
322
  // src/pagination/pagination.ts
288
323
  var MAX_PAGE_SIZE = 100;
@@ -699,6 +734,60 @@ function createConversationsModule(options) {
699
734
  };
700
735
  }
701
736
 
737
+ // src/conversations/participants.ts
738
+ function createParticipantsModule(options) {
739
+ const baseUrl = options.baseUrl;
740
+ function buildInit(method, body) {
741
+ return {
742
+ method,
743
+ credentials: options.getCredentials(),
744
+ headers: {
745
+ "Content-Type": "application/json",
746
+ ...options.getHeaders()
747
+ },
748
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
749
+ };
750
+ }
751
+ return {
752
+ /**
753
+ * Add (or re-add) an agent as a conversation participant with a role.
754
+ * Idempotent per active membership — re-adding an active participant
755
+ * updates its role; a second OWNER co-owns (no demotion of other owners).
756
+ * Calls POST /api/v1/conversations/:id/participants.
757
+ */
758
+ async add(conversationId, input) {
759
+ const path = getConversationsControllerAddParticipantUrl(conversationId);
760
+ const url = `${baseUrl}${path}`;
761
+ const res = await fetch(url, buildInit("POST", input));
762
+ return parseEnvelopedResponse(res);
763
+ },
764
+ /**
765
+ * End an active membership for an agent. Idempotent — removing a
766
+ * non-participant is a no-op ({ removed: 0 }).
767
+ * Calls DELETE /api/v1/conversations/:id/participants/:agentId.
768
+ */
769
+ async remove(conversationId, agentId) {
770
+ const path = getConversationsControllerRemoveParticipantUrl(
771
+ conversationId,
772
+ agentId
773
+ );
774
+ const url = `${baseUrl}${path}`;
775
+ const res = await fetch(url, buildInit("DELETE"));
776
+ return parseEnvelopedResponse(res);
777
+ },
778
+ /**
779
+ * List the ACTIVE (leftAt IS NULL) participants of a conversation.
780
+ * Calls GET /api/v1/conversations/:id/participants.
781
+ */
782
+ async list(conversationId) {
783
+ const path = getConversationsControllerListParticipantsUrl(conversationId);
784
+ const url = `${baseUrl}${path}`;
785
+ const res = await fetch(url, buildInit("GET"));
786
+ return parseEnvelopedResponse(res);
787
+ }
788
+ };
789
+ }
790
+
702
791
  // src/messages/messages.ts
703
792
  function createMessagesModule(options) {
704
793
  const baseUrl = options.baseUrl;
@@ -982,7 +1071,12 @@ function createCannedResponsesModule(options) {
982
1071
  */
983
1072
  async list(opts) {
984
1073
  const { page, pageSize } = buildPageParams(opts);
985
- const path = getCannedResponsesControllerListUrl({ page, pageSize });
1074
+ const path = getCannedResponsesControllerListUrl({
1075
+ page,
1076
+ pageSize,
1077
+ ...opts.category ? { category: opts.category } : {},
1078
+ ...opts.channel ? { channel: opts.channel } : {}
1079
+ });
986
1080
  const url = `${baseUrl}${path}`;
987
1081
  const res = await fetch(url, buildInit("GET"));
988
1082
  return parseResponse(res);
@@ -997,7 +1091,9 @@ function createCannedResponsesModule(options) {
997
1091
  const path = getCannedResponsesControllerListUrl({
998
1092
  page,
999
1093
  pageSize,
1000
- q: opts.q
1094
+ q: opts.q,
1095
+ ...opts.category ? { category: opts.category } : {},
1096
+ ...opts.channel ? { channel: opts.channel } : {}
1001
1097
  });
1002
1098
  const url = `${baseUrl}${path}`;
1003
1099
  const res = await fetch(url, buildInit("GET"));
@@ -1014,7 +1110,7 @@ function createCannedResponsesModule(options) {
1014
1110
  return parseEnvelopedResponse(res);
1015
1111
  },
1016
1112
  /**
1017
- * Partially update a canned response — title, body, and/or keywords.
1113
+ * Partially update a canned response — title, shortcut, category, channel, and/or body.
1018
1114
  * Calls PATCH /api/v1/canned-responses/:id.
1019
1115
  */
1020
1116
  async update(id, input) {
@@ -1034,6 +1130,16 @@ function createCannedResponsesModule(options) {
1034
1130
  if (!res.ok) {
1035
1131
  return parseResponse(res);
1036
1132
  }
1133
+ },
1134
+ /**
1135
+ * Duplicate a canned response. The server generates a unique title and
1136
+ * shortcut. Calls POST /api/v1/canned-responses/:id/duplicate.
1137
+ */
1138
+ async duplicate(id) {
1139
+ const path = getCannedResponsesControllerDuplicateUrl(id);
1140
+ const url = `${baseUrl}${path}`;
1141
+ const res = await fetch(url, buildInit("POST"));
1142
+ return parseEnvelopedResponse(res);
1037
1143
  }
1038
1144
  };
1039
1145
  }
@@ -1177,6 +1283,89 @@ function createWhatsAppBusinessAccountsModule(options) {
1177
1283
  };
1178
1284
  }
1179
1285
 
1286
+ // src/dashboard/dashboard.ts
1287
+ function createDashboardModule(options) {
1288
+ const baseUrl = options.baseUrl;
1289
+ function buildInit() {
1290
+ return {
1291
+ method: "GET",
1292
+ credentials: options.getCredentials(),
1293
+ headers: {
1294
+ "Content-Type": "application/json",
1295
+ ...options.getHeaders()
1296
+ }
1297
+ };
1298
+ }
1299
+ return {
1300
+ /**
1301
+ * Fetch the tenant dashboard KPIs.
1302
+ * Calls GET /api/v1/dashboard/stats.
1303
+ */
1304
+ async stats() {
1305
+ const path = getDashboardControllerGetStatsUrl();
1306
+ const url = `${baseUrl}${path}`;
1307
+ const res = await fetch(url, buildInit());
1308
+ return parseEnvelopedResponse(res);
1309
+ },
1310
+ /**
1311
+ * List the tenant's recent conversation/message activity feed
1312
+ * (newest first, paginated). pageSize is clamped to 100 per the API
1313
+ * contract. Calls GET /api/v1/dashboard/recent-activity.
1314
+ */
1315
+ async recentActivity(opts = { page: 1, pageSize: 25 }) {
1316
+ const { page, pageSize } = buildPageParams(opts);
1317
+ const path = getDashboardControllerGetRecentActivityUrl({
1318
+ page,
1319
+ pageSize
1320
+ });
1321
+ const url = `${baseUrl}${path}`;
1322
+ const res = await fetch(url, buildInit());
1323
+ return parseResponse(res);
1324
+ }
1325
+ };
1326
+ }
1327
+
1328
+ // src/audit/audit.ts
1329
+ function createAuditModule(options) {
1330
+ const baseUrl = options.baseUrl;
1331
+ function buildInit() {
1332
+ return {
1333
+ method: "GET",
1334
+ credentials: options.getCredentials(),
1335
+ headers: {
1336
+ "Content-Type": "application/json",
1337
+ ...options.getHeaders()
1338
+ }
1339
+ };
1340
+ }
1341
+ return {
1342
+ /**
1343
+ * List the tenant audit trail (newest first, paginated).
1344
+ * pageSize is clamped to 100 per the API contract.
1345
+ * Calls GET /api/v1/audit-log.
1346
+ */
1347
+ async list(opts = {}) {
1348
+ const { page, pageSize } = buildPageParams({
1349
+ page: opts.page ?? 1,
1350
+ pageSize: opts.pageSize ?? 25
1351
+ });
1352
+ const params = {
1353
+ ...opts.resourceType !== void 0 ? { resourceType: opts.resourceType } : {},
1354
+ ...opts.resourceId !== void 0 ? { resourceId: opts.resourceId } : {},
1355
+ ...opts.actorId !== void 0 ? { actorId: opts.actorId } : {},
1356
+ ...opts.from !== void 0 ? { from: opts.from } : {},
1357
+ ...opts.to !== void 0 ? { to: opts.to } : {},
1358
+ page,
1359
+ pageSize
1360
+ };
1361
+ const path = getAuditLogControllerListUrl(params);
1362
+ const url = `${baseUrl}${path}`;
1363
+ const res = await fetch(url, buildInit());
1364
+ return parseResponse(res);
1365
+ }
1366
+ };
1367
+ }
1368
+
1180
1369
  // src/ws/ws-client.ts
1181
1370
  import { io } from "socket.io-client";
1182
1371
  function createWsClient(options) {
@@ -1267,11 +1456,14 @@ function createOmnivoxClient(options) {
1267
1456
  channels: createChannelsModule(moduleOptions),
1268
1457
  contacts: createContactsModule(moduleOptions),
1269
1458
  conversations: createConversationsModule(moduleOptions),
1459
+ participants: createParticipantsModule(moduleOptions),
1270
1460
  messages: createMessagesModule(moduleOptions),
1271
1461
  templates: createTemplatesModule(moduleOptions),
1272
1462
  cannedResponses: createCannedResponsesModule(moduleOptions),
1273
1463
  attachments: createAttachmentsModule(moduleOptions),
1274
1464
  whatsappBusinessAccounts: createWhatsAppBusinessAccountsModule(moduleOptions),
1465
+ dashboard: createDashboardModule(moduleOptions),
1466
+ audit: createAuditModule(moduleOptions),
1275
1467
  /**
1276
1468
  * Creates a WebSocket client connected to the `/ws/chat` namespace.
1277
1469
  *
@@ -1326,13 +1518,16 @@ export {
1326
1518
  createAgentsModule,
1327
1519
  createApiKeyTokenProvider,
1328
1520
  createAttachmentsModule,
1521
+ createAuditModule,
1329
1522
  createAuthMeModule,
1330
1523
  createCannedResponsesModule,
1331
1524
  createChannelsModule,
1332
1525
  createContactsModule,
1333
1526
  createConversationsModule,
1527
+ createDashboardModule,
1334
1528
  createMessagesModule,
1335
1529
  createOmnivoxClient,
1530
+ createParticipantsModule,
1336
1531
  createSessionTokenProvider,
1337
1532
  createTemplatesModule,
1338
1533
  createTenantsModule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digisglobal/omnivox-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {