@digisglobal/omnivox-sdk 0.5.0 → 0.6.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 CHANGED
@@ -24,14 +24,19 @@ __export(index_exports, {
24
24
  buildPageParams: () => buildPageParams,
25
25
  createAgentsModule: () => createAgentsModule,
26
26
  createApiKeyTokenProvider: () => createApiKeyTokenProvider,
27
+ createAttachmentsModule: () => createAttachmentsModule,
27
28
  createAuthMeModule: () => createAuthMeModule,
29
+ createCannedResponsesModule: () => createCannedResponsesModule,
28
30
  createChannelsModule: () => createChannelsModule,
29
31
  createContactsModule: () => createContactsModule,
30
32
  createConversationsModule: () => createConversationsModule,
31
33
  createMessagesModule: () => createMessagesModule,
32
34
  createOmnivoxClient: () => createOmnivoxClient,
33
35
  createSessionTokenProvider: () => createSessionTokenProvider,
36
+ createTemplatesModule: () => createTemplatesModule,
34
37
  createTenantsModule: () => createTenantsModule,
38
+ createWhatsAppBusinessAccountsModule: () => createWhatsAppBusinessAccountsModule,
39
+ createWsClient: () => createWsClient,
35
40
  iteratePages: () => iteratePages
36
41
  });
37
42
  module.exports = __toCommonJS(index_exports);
@@ -163,6 +168,9 @@ var getConversationsControllerListLobbyUrl = (params) => {
163
168
  var getConversationsControllerPickupLobbyEntryUrl = (entryId) => {
164
169
  return `/api/v1/conversations/lobby/${entryId}/pickup`;
165
170
  };
171
+ var getConversationsControllerGetWhatsAppRecoveryOptionsUrl = (id) => {
172
+ return `/api/v1/conversations/${id}/whatsapp-recovery-options`;
173
+ };
166
174
  var getConversationsControllerFindOneUrl = (id) => {
167
175
  return `/api/v1/conversations/${id}`;
168
176
  };
@@ -179,6 +187,9 @@ var getMessagesControllerListUrl = (params) => {
179
187
  const stringifiedParams = normalizedParams.toString();
180
188
  return stringifiedParams.length > 0 ? `/api/v1/messages?${stringifiedParams}` : `/api/v1/messages`;
181
189
  };
190
+ var getMessagesControllerSendTemplateUrl = () => {
191
+ return `/api/v1/messages/send-template`;
192
+ };
182
193
  var getMessagesControllerGetByIdUrl = (id, params) => {
183
194
  const normalizedParams = new URLSearchParams();
184
195
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -207,6 +218,12 @@ var getChannelsControllerUpdateUrl = (id, channelId) => {
207
218
  var getChannelsControllerVerifyUrl = (id, channelId) => {
208
219
  return `/api/v1/tenants/${id}/channels/${channelId}/verify`;
209
220
  };
221
+ var getWhatsAppBusinessAccountsControllerListUrl = (id) => {
222
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts`;
223
+ };
224
+ var getWhatsAppBusinessAccountsControllerFindOneUrl = (id, wabaRowId) => {
225
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaRowId}`;
226
+ };
210
227
  var getAgentsControllerCreateUrl = () => {
211
228
  return `/api/v1/agents`;
212
229
  };
@@ -223,6 +240,68 @@ var getAgentsControllerListUrl = (params) => {
223
240
  var getAgentsControllerFindOneUrl = (id) => {
224
241
  return `/api/v1/agents/${id}`;
225
242
  };
243
+ var getTemplatesControllerAuthorDraftUrl = (id, wabaId) => {
244
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates`;
245
+ };
246
+ var getTemplatesControllerImportApprovedUrl = (id, wabaId) => {
247
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/import`;
248
+ };
249
+ var getTemplatesControllerForkDraftUrl = (id, wabaId, templateId) => {
250
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}`;
251
+ };
252
+ var getTemplatesControllerGetHistoryUrl = (id, wabaId, templateId) => {
253
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}/history`;
254
+ };
255
+ var getTemplatesControllerSubmitUrl = (id, wabaId, templateId) => {
256
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}/submit`;
257
+ };
258
+ var getEmailTemplatesControllerCreateUrl = () => {
259
+ return `/api/v1/templates/email`;
260
+ };
261
+ var getEmailTemplatesControllerListUrl = (params) => {
262
+ const normalizedParams = new URLSearchParams();
263
+ Object.entries(params || {}).forEach(([key, value]) => {
264
+ if (value !== void 0) {
265
+ normalizedParams.append(key, value === null ? "null" : String(value));
266
+ }
267
+ });
268
+ const stringifiedParams = normalizedParams.toString();
269
+ return stringifiedParams.length > 0 ? `/api/v1/templates/email?${stringifiedParams}` : `/api/v1/templates/email`;
270
+ };
271
+ var getEmailTemplatesControllerGetByIdUrl = (id) => {
272
+ return `/api/v1/templates/email/${id}`;
273
+ };
274
+ var getEmailTemplatesControllerPatchUrl = (id) => {
275
+ return `/api/v1/templates/email/${id}`;
276
+ };
277
+ var getEmailTemplatesControllerDeleteUrl = (id) => {
278
+ return `/api/v1/templates/email/${id}`;
279
+ };
280
+ var getCannedResponsesControllerCreateUrl = () => {
281
+ return `/api/v1/canned-responses`;
282
+ };
283
+ var getCannedResponsesControllerListUrl = (params) => {
284
+ const normalizedParams = new URLSearchParams();
285
+ Object.entries(params || {}).forEach(([key, value]) => {
286
+ if (value !== void 0) {
287
+ normalizedParams.append(key, value === null ? "null" : String(value));
288
+ }
289
+ });
290
+ const stringifiedParams = normalizedParams.toString();
291
+ return stringifiedParams.length > 0 ? `/api/v1/canned-responses?${stringifiedParams}` : `/api/v1/canned-responses`;
292
+ };
293
+ var getCannedResponsesControllerPatchUrl = (id) => {
294
+ return `/api/v1/canned-responses/${id}`;
295
+ };
296
+ var getCannedResponsesControllerDeleteUrl = (id) => {
297
+ return `/api/v1/canned-responses/${id}`;
298
+ };
299
+ var getAttachmentsControllerUploadUrl = () => {
300
+ return `/api/v1/attachments`;
301
+ };
302
+ var getAttachmentsControllerGetDownloadUrlUrl = (id) => {
303
+ return `/api/v1/attachments/${id}/url`;
304
+ };
226
305
 
227
306
  // src/pagination/pagination.ts
228
307
  var MAX_PAGE_SIZE = 100;
@@ -623,6 +702,18 @@ function createConversationsModule(options) {
623
702
  const url = `${baseUrl}${path}`;
624
703
  const res = await fetch(url, buildInit("POST", input));
625
704
  return parseResponse(res);
705
+ },
706
+ /**
707
+ * List APPROVED + SENDABLE WhatsApp templates eligible to re-open an
708
+ * expired 24-hour customer-service window for the given conversation.
709
+ * Returns an empty array when the channel is not WhatsApp or has no linked WABA.
710
+ * Calls GET /api/v1/conversations/:id/whatsapp-recovery-options.
711
+ */
712
+ async whatsappRecoveryOptions(id) {
713
+ const path = getConversationsControllerGetWhatsAppRecoveryOptionsUrl(id);
714
+ const url = `${baseUrl}${path}`;
715
+ const res = await fetch(url, buildInit("GET"));
716
+ return parseResponse(res);
626
717
  }
627
718
  };
628
719
  }
@@ -689,6 +780,415 @@ function createMessagesModule(options) {
689
780
  const url = `${baseUrl}${path}`;
690
781
  const res = await fetch(url, buildInit("DELETE"));
691
782
  await parseResponse(res);
783
+ },
784
+ /**
785
+ * Send a template message in a conversation (WhatsApp or Email).
786
+ * Branches on the conversation channel type — WhatsApp uses positional
787
+ * `variables`; Email uses named `emailVariables`.
788
+ * Calls POST /api/v1/messages/send-template.
789
+ */
790
+ async sendTemplate(input) {
791
+ const path = getMessagesControllerSendTemplateUrl();
792
+ const url = `${baseUrl}${path}`;
793
+ const res = await fetch(url, buildInit("POST", input));
794
+ return parseResponse(res);
795
+ }
796
+ };
797
+ }
798
+
799
+ // src/templates/templates.ts
800
+ function createTemplatesModule(options) {
801
+ const baseUrl = options.baseUrl;
802
+ function buildInit(method, body) {
803
+ return {
804
+ method,
805
+ credentials: options.getCredentials(),
806
+ headers: {
807
+ "Content-Type": "application/json",
808
+ ...options.getHeaders()
809
+ },
810
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
811
+ };
812
+ }
813
+ return {
814
+ /**
815
+ * WhatsApp template submodule — WABA-scoped operations.
816
+ */
817
+ whatsapp: {
818
+ /**
819
+ * Author a new DRAFT template (version 1) under a WhatsApp Business Account.
820
+ * Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates.
821
+ */
822
+ async authorDraft(tenantId, wabaId, input) {
823
+ const path = getTemplatesControllerAuthorDraftUrl(tenantId, wabaId);
824
+ const url = `${baseUrl}${path}`;
825
+ const res = await fetch(url, buildInit("POST", input));
826
+ return parseResponse(res);
827
+ },
828
+ /**
829
+ * Import all APPROVED templates from the WABA into the system (immediately sendable).
830
+ * Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/import.
831
+ */
832
+ async importApproved(tenantId, wabaId) {
833
+ const path = getTemplatesControllerImportApprovedUrl(tenantId, wabaId);
834
+ const url = `${baseUrl}${path}`;
835
+ const res = await fetch(url, buildInit("POST"));
836
+ return parseResponse(res);
837
+ },
838
+ /**
839
+ * Fork a new DRAFT version from the latest version of a template (update).
840
+ * Calls PATCH /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId.
841
+ */
842
+ async update(tenantId, wabaId, templateId, input) {
843
+ const path = getTemplatesControllerForkDraftUrl(
844
+ tenantId,
845
+ wabaId,
846
+ templateId
847
+ );
848
+ const url = `${baseUrl}${path}`;
849
+ const res = await fetch(url, buildInit("PATCH", input));
850
+ return parseResponse(res);
851
+ },
852
+ /**
853
+ * List all versions and status events for a template in chronological order.
854
+ * Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId/history.
855
+ */
856
+ async history(tenantId, wabaId, templateId) {
857
+ const path = getTemplatesControllerGetHistoryUrl(
858
+ tenantId,
859
+ wabaId,
860
+ templateId
861
+ );
862
+ const url = `${baseUrl}${path}`;
863
+ const res = await fetch(url, buildInit("GET"));
864
+ return parseResponse(res);
865
+ },
866
+ /**
867
+ * Submit a DRAFT template version to Meta for review and approval (DRAFT → PENDING_APPROVAL).
868
+ * Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId/submit.
869
+ */
870
+ async submit(tenantId, wabaId, templateId) {
871
+ const path = getTemplatesControllerSubmitUrl(
872
+ tenantId,
873
+ wabaId,
874
+ templateId
875
+ );
876
+ const url = `${baseUrl}${path}`;
877
+ const res = await fetch(url, buildInit("POST"));
878
+ return parseResponse(res);
879
+ }
880
+ },
881
+ /**
882
+ * Email template submodule — tenant-scoped operations.
883
+ */
884
+ email: {
885
+ /**
886
+ * Create an Email template for the authenticated tenant.
887
+ * Calls POST /api/v1/templates/email.
888
+ */
889
+ async create(input) {
890
+ const path = getEmailTemplatesControllerCreateUrl();
891
+ const url = `${baseUrl}${path}`;
892
+ const res = await fetch(url, buildInit("POST", input));
893
+ return parseResponse(res);
894
+ },
895
+ /**
896
+ * List Email templates for the authenticated tenant (paginated).
897
+ * Calls GET /api/v1/templates/email.
898
+ */
899
+ async list(opts) {
900
+ const { page, pageSize } = buildPageParams(opts);
901
+ const path = getEmailTemplatesControllerListUrl({ page, pageSize });
902
+ const url = `${baseUrl}${path}`;
903
+ const res = await fetch(url, buildInit("GET"));
904
+ return parseResponse(res);
905
+ },
906
+ /**
907
+ * Get an Email template by id.
908
+ * Calls GET /api/v1/templates/email/:id.
909
+ */
910
+ async getById(id) {
911
+ const path = getEmailTemplatesControllerGetByIdUrl(id);
912
+ const url = `${baseUrl}${path}`;
913
+ const res = await fetch(url, buildInit("GET"));
914
+ return parseResponse(res);
915
+ },
916
+ /**
917
+ * Partially update an Email template — name, subject, htmlBody, textBody, and/or variableSchema; omitted fields unchanged.
918
+ * Calls PATCH /api/v1/templates/email/:id.
919
+ */
920
+ async patch(id, input) {
921
+ const path = getEmailTemplatesControllerPatchUrl(id);
922
+ const url = `${baseUrl}${path}`;
923
+ const res = await fetch(url, buildInit("PATCH", input));
924
+ return parseResponse(res);
925
+ },
926
+ /**
927
+ * Delete an Email template.
928
+ * Calls DELETE /api/v1/templates/email/:id.
929
+ */
930
+ async delete(id) {
931
+ const path = getEmailTemplatesControllerDeleteUrl(id);
932
+ const url = `${baseUrl}${path}`;
933
+ const res = await fetch(url, buildInit("DELETE"));
934
+ if (!res.ok) {
935
+ return parseResponse(res);
936
+ }
937
+ }
938
+ }
939
+ };
940
+ }
941
+
942
+ // src/canned-responses/canned-responses.ts
943
+ function createCannedResponsesModule(options) {
944
+ const baseUrl = options.baseUrl;
945
+ function buildInit(method, body) {
946
+ return {
947
+ method,
948
+ credentials: options.getCredentials(),
949
+ headers: {
950
+ "Content-Type": "application/json",
951
+ ...options.getHeaders()
952
+ },
953
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
954
+ };
955
+ }
956
+ return {
957
+ /**
958
+ * List canned responses (paginated, no search filter).
959
+ * pageSize is clamped to 100 per the API contract.
960
+ * Calls GET /api/v1/canned-responses.
961
+ */
962
+ async list(opts) {
963
+ const { page, pageSize } = buildPageParams(opts);
964
+ const path = getCannedResponsesControllerListUrl({ page, pageSize });
965
+ const url = `${baseUrl}${path}`;
966
+ const res = await fetch(url, buildInit("GET"));
967
+ return parseResponse(res);
968
+ },
969
+ /**
970
+ * Search canned responses by title substring or keyword prefix.
971
+ * pageSize is clamped to 100 per the API contract.
972
+ * Calls GET /api/v1/canned-responses?q=<term>.
973
+ */
974
+ async search(opts) {
975
+ const { page, pageSize } = buildPageParams(opts);
976
+ const path = getCannedResponsesControllerListUrl({
977
+ page,
978
+ pageSize,
979
+ q: opts.q
980
+ });
981
+ const url = `${baseUrl}${path}`;
982
+ const res = await fetch(url, buildInit("GET"));
983
+ return parseResponse(res);
984
+ },
985
+ /**
986
+ * Create a canned response.
987
+ * Calls POST /api/v1/canned-responses.
988
+ */
989
+ async create(input) {
990
+ const path = getCannedResponsesControllerCreateUrl();
991
+ const url = `${baseUrl}${path}`;
992
+ const res = await fetch(url, buildInit("POST", input));
993
+ return parseResponse(res);
994
+ },
995
+ /**
996
+ * Partially update a canned response — title, body, and/or keywords.
997
+ * Calls PATCH /api/v1/canned-responses/:id.
998
+ */
999
+ async update(id, input) {
1000
+ const path = getCannedResponsesControllerPatchUrl(id);
1001
+ const url = `${baseUrl}${path}`;
1002
+ const res = await fetch(url, buildInit("PATCH", input));
1003
+ return parseResponse(res);
1004
+ },
1005
+ /**
1006
+ * Delete a canned response by id.
1007
+ * Calls DELETE /api/v1/canned-responses/:id.
1008
+ */
1009
+ async delete(id) {
1010
+ const path = getCannedResponsesControllerDeleteUrl(id);
1011
+ const url = `${baseUrl}${path}`;
1012
+ const res = await fetch(url, buildInit("DELETE"));
1013
+ if (!res.ok) {
1014
+ return parseResponse(res);
1015
+ }
1016
+ }
1017
+ };
1018
+ }
1019
+
1020
+ // src/attachments/attachments.ts
1021
+ function createAttachmentsModule(options) {
1022
+ const baseUrl = options.baseUrl;
1023
+ return {
1024
+ /**
1025
+ * Upload a file as a draft attachment.
1026
+ *
1027
+ * Accepts a Blob or File (browser) or a Uint8Array wrapped in a Blob (Node 22+).
1028
+ * Content-Type is intentionally omitted from headers so that fetch (both
1029
+ * Node 22 built-in and browser) can set the multipart/form-data boundary.
1030
+ *
1031
+ * Calls POST /api/v1/attachments.
1032
+ */
1033
+ async upload(file, _opts) {
1034
+ const form = new FormData();
1035
+ const blob = file instanceof Uint8Array ? new Blob([file]) : file;
1036
+ form.append("file", blob);
1037
+ const path = getAttachmentsControllerUploadUrl();
1038
+ const url = `${baseUrl}${path}`;
1039
+ const res = await fetch(url, {
1040
+ method: "POST",
1041
+ credentials: options.getCredentials(),
1042
+ headers: {
1043
+ // No Content-Type — let fetch set multipart boundary.
1044
+ ...options.getHeaders()
1045
+ },
1046
+ body: form
1047
+ });
1048
+ return parseResponse(res);
1049
+ },
1050
+ /**
1051
+ * Get a short-lived presigned download URL for a stored attachment.
1052
+ * The URL is valid for ≤ 15 minutes (NF-09).
1053
+ *
1054
+ * Calls GET /api/v1/attachments/:id/url.
1055
+ */
1056
+ async url(id) {
1057
+ const path = getAttachmentsControllerGetDownloadUrlUrl(id);
1058
+ const fullUrl = `${baseUrl}${path}`;
1059
+ const res = await fetch(fullUrl, {
1060
+ method: "GET",
1061
+ credentials: options.getCredentials(),
1062
+ headers: {
1063
+ ...options.getHeaders()
1064
+ }
1065
+ });
1066
+ return parseResponse(res);
1067
+ }
1068
+ };
1069
+ }
1070
+
1071
+ // src/whatsapp-business-accounts/whatsapp-business-accounts.ts
1072
+ function createWhatsAppBusinessAccountsModule(options) {
1073
+ const baseUrl = options.baseUrl;
1074
+ function buildInit(method) {
1075
+ return {
1076
+ method,
1077
+ credentials: options.getCredentials(),
1078
+ headers: {
1079
+ "Content-Type": "application/json",
1080
+ ...options.getHeaders()
1081
+ }
1082
+ };
1083
+ }
1084
+ return {
1085
+ /**
1086
+ * List all WhatsApp Business Accounts for the tenant.
1087
+ * Returns a non-secret view — no secretRef is exposed.
1088
+ * Calls GET /api/v1/tenants/:id/whatsapp-business-accounts.
1089
+ *
1090
+ * @example
1091
+ * const wabas = await sdk.whatsappBusinessAccounts.list('ten_acmecorp')
1092
+ * // pick wabas[0].id as the wabaId for sdk.templates.whatsapp.*
1093
+ */
1094
+ async list(tenantId) {
1095
+ const path = getWhatsAppBusinessAccountsControllerListUrl(tenantId);
1096
+ const url = `${baseUrl}${path}`;
1097
+ const res = await fetch(url, buildInit("GET"));
1098
+ return parseResponse(res);
1099
+ },
1100
+ /**
1101
+ * Get a single WhatsApp Business Account by its row id.
1102
+ * Returns a non-secret view — no secretRef is exposed.
1103
+ * Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaRowId.
1104
+ *
1105
+ * @example
1106
+ * const waba = await sdk.whatsappBusinessAccounts.get('ten_acmecorp', 'waba_row_001')
1107
+ */
1108
+ async get(tenantId, wabaRowId) {
1109
+ const path = getWhatsAppBusinessAccountsControllerFindOneUrl(
1110
+ tenantId,
1111
+ wabaRowId
1112
+ );
1113
+ const url = `${baseUrl}${path}`;
1114
+ const res = await fetch(url, buildInit("GET"));
1115
+ return parseResponse(res);
1116
+ }
1117
+ };
1118
+ }
1119
+
1120
+ // src/ws/ws-client.ts
1121
+ var import_socket = require("socket.io-client");
1122
+ function createWsClient(options) {
1123
+ const handshakeAuth = options.auth === void 0 ? void 0 : "apiKey" in options.auth ? { apiKey: options.auth.apiKey } : { token: options.auth.token };
1124
+ const ioOptions = {
1125
+ reconnection: true,
1126
+ reconnectionAttempts: Infinity,
1127
+ reconnectionDelay: 1e3,
1128
+ reconnectionDelayMax: 3e4,
1129
+ randomizationFactor: 0.5,
1130
+ withCredentials: options.withCredentials ?? false
1131
+ };
1132
+ if (handshakeAuth !== void 0) {
1133
+ ioOptions.auth = handshakeAuth;
1134
+ }
1135
+ const socket = (0, import_socket.io)(`${options.baseUrl}/ws/chat`, ioOptions);
1136
+ let currentState = "connecting";
1137
+ const stateListeners = /* @__PURE__ */ new Set();
1138
+ function setState(next) {
1139
+ if (next === currentState) return;
1140
+ currentState = next;
1141
+ for (const listener of stateListeners) {
1142
+ listener(next);
1143
+ }
1144
+ }
1145
+ socket.on("connect", () => {
1146
+ setState("connected");
1147
+ });
1148
+ socket.on("disconnect", () => {
1149
+ setState("disconnected");
1150
+ });
1151
+ socket.on("reconnect_attempt", () => {
1152
+ setState("reconnecting");
1153
+ });
1154
+ socket.on("reconnect", () => {
1155
+ setState("connected");
1156
+ });
1157
+ return {
1158
+ get state() {
1159
+ return currentState;
1160
+ },
1161
+ onStateChange(listener) {
1162
+ stateListeners.add(listener);
1163
+ return () => {
1164
+ stateListeners.delete(listener);
1165
+ };
1166
+ },
1167
+ on(event, handler) {
1168
+ const rawHandler = handler;
1169
+ socket.on(event, rawHandler);
1170
+ return () => {
1171
+ ;
1172
+ socket.off(event, rawHandler);
1173
+ };
1174
+ },
1175
+ joinConversation(conversationId) {
1176
+ socket.emit("conversation:join", { conversationId });
1177
+ },
1178
+ leaveConversation(conversationId) {
1179
+ socket.emit("conversation:leave", { conversationId });
1180
+ },
1181
+ typingStart(conversationId) {
1182
+ socket.emit("typing:start", { conversationId });
1183
+ },
1184
+ typingStop(conversationId) {
1185
+ socket.emit("typing:stop", { conversationId });
1186
+ },
1187
+ markRead(conversationId, lastReadMessageId) {
1188
+ socket.emit("message:read", { conversationId, lastReadMessageId });
1189
+ },
1190
+ disconnect() {
1191
+ socket.disconnect();
692
1192
  }
693
1193
  };
694
1194
  }
@@ -707,7 +1207,35 @@ function createOmnivoxClient(options) {
707
1207
  channels: createChannelsModule(moduleOptions),
708
1208
  contacts: createContactsModule(moduleOptions),
709
1209
  conversations: createConversationsModule(moduleOptions),
710
- messages: createMessagesModule(moduleOptions)
1210
+ messages: createMessagesModule(moduleOptions),
1211
+ templates: createTemplatesModule(moduleOptions),
1212
+ cannedResponses: createCannedResponsesModule(moduleOptions),
1213
+ attachments: createAttachmentsModule(moduleOptions),
1214
+ whatsappBusinessAccounts: createWhatsAppBusinessAccountsModule(moduleOptions),
1215
+ /**
1216
+ * Creates a WebSocket client connected to the `/ws/chat` namespace.
1217
+ *
1218
+ * Call this factory once and reuse the returned client. Reconnection with
1219
+ * exponential backoff + jitter (cap 30 s) is fully automatic.
1220
+ *
1221
+ * For API-key or token auth, pass the credential explicitly:
1222
+ * @example
1223
+ * const ws = client.connect({ apiKey: 'ovx_live_abc' })
1224
+ * ws.on('message:new', (msg) => console.log(msg))
1225
+ * ws.joinConversation('conv_001')
1226
+ *
1227
+ * For session/cookie auth (Console), call with no argument — the token
1228
+ * provider's `getCredentials() === 'include'` signals cookie mode and
1229
+ * `withCredentials` is set automatically:
1230
+ * @example
1231
+ * const ws = client.connect()
1232
+ * ws.on('message:new', (msg) => console.log(msg))
1233
+ */
1234
+ connect: (auth) => createWsClient({
1235
+ baseUrl: options.baseUrl,
1236
+ ...auth !== void 0 ? { auth } : {},
1237
+ withCredentials: options.tokenProvider.getCredentials() === "include"
1238
+ })
711
1239
  };
712
1240
  }
713
1241
 
@@ -738,13 +1266,18 @@ function createSessionTokenProvider() {
738
1266
  buildPageParams,
739
1267
  createAgentsModule,
740
1268
  createApiKeyTokenProvider,
1269
+ createAttachmentsModule,
741
1270
  createAuthMeModule,
1271
+ createCannedResponsesModule,
742
1272
  createChannelsModule,
743
1273
  createContactsModule,
744
1274
  createConversationsModule,
745
1275
  createMessagesModule,
746
1276
  createOmnivoxClient,
747
1277
  createSessionTokenProvider,
1278
+ createTemplatesModule,
748
1279
  createTenantsModule,
1280
+ createWhatsAppBusinessAccountsModule,
1281
+ createWsClient,
749
1282
  iteratePages
750
1283
  });