@digisglobal/omnivox-sdk 0.4.1 → 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.js CHANGED
@@ -125,6 +125,9 @@ var getConversationsControllerListLobbyUrl = (params) => {
125
125
  var getConversationsControllerPickupLobbyEntryUrl = (entryId) => {
126
126
  return `/api/v1/conversations/lobby/${entryId}/pickup`;
127
127
  };
128
+ var getConversationsControllerGetWhatsAppRecoveryOptionsUrl = (id) => {
129
+ return `/api/v1/conversations/${id}/whatsapp-recovery-options`;
130
+ };
128
131
  var getConversationsControllerFindOneUrl = (id) => {
129
132
  return `/api/v1/conversations/${id}`;
130
133
  };
@@ -141,6 +144,9 @@ var getMessagesControllerListUrl = (params) => {
141
144
  const stringifiedParams = normalizedParams.toString();
142
145
  return stringifiedParams.length > 0 ? `/api/v1/messages?${stringifiedParams}` : `/api/v1/messages`;
143
146
  };
147
+ var getMessagesControllerSendTemplateUrl = () => {
148
+ return `/api/v1/messages/send-template`;
149
+ };
144
150
  var getMessagesControllerGetByIdUrl = (id, params) => {
145
151
  const normalizedParams = new URLSearchParams();
146
152
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -169,6 +175,12 @@ var getChannelsControllerUpdateUrl = (id, channelId) => {
169
175
  var getChannelsControllerVerifyUrl = (id, channelId) => {
170
176
  return `/api/v1/tenants/${id}/channels/${channelId}/verify`;
171
177
  };
178
+ var getWhatsAppBusinessAccountsControllerListUrl = (id) => {
179
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts`;
180
+ };
181
+ var getWhatsAppBusinessAccountsControllerFindOneUrl = (id, wabaRowId) => {
182
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaRowId}`;
183
+ };
172
184
  var getAgentsControllerCreateUrl = () => {
173
185
  return `/api/v1/agents`;
174
186
  };
@@ -185,6 +197,68 @@ var getAgentsControllerListUrl = (params) => {
185
197
  var getAgentsControllerFindOneUrl = (id) => {
186
198
  return `/api/v1/agents/${id}`;
187
199
  };
200
+ var getTemplatesControllerAuthorDraftUrl = (id, wabaId) => {
201
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates`;
202
+ };
203
+ var getTemplatesControllerImportApprovedUrl = (id, wabaId) => {
204
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/import`;
205
+ };
206
+ var getTemplatesControllerForkDraftUrl = (id, wabaId, templateId) => {
207
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}`;
208
+ };
209
+ var getTemplatesControllerGetHistoryUrl = (id, wabaId, templateId) => {
210
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}/history`;
211
+ };
212
+ var getTemplatesControllerSubmitUrl = (id, wabaId, templateId) => {
213
+ return `/api/v1/tenants/${id}/whatsapp-business-accounts/${wabaId}/templates/${templateId}/submit`;
214
+ };
215
+ var getEmailTemplatesControllerCreateUrl = () => {
216
+ return `/api/v1/templates/email`;
217
+ };
218
+ var getEmailTemplatesControllerListUrl = (params) => {
219
+ const normalizedParams = new URLSearchParams();
220
+ Object.entries(params || {}).forEach(([key, value]) => {
221
+ if (value !== void 0) {
222
+ normalizedParams.append(key, value === null ? "null" : String(value));
223
+ }
224
+ });
225
+ const stringifiedParams = normalizedParams.toString();
226
+ return stringifiedParams.length > 0 ? `/api/v1/templates/email?${stringifiedParams}` : `/api/v1/templates/email`;
227
+ };
228
+ var getEmailTemplatesControllerGetByIdUrl = (id) => {
229
+ return `/api/v1/templates/email/${id}`;
230
+ };
231
+ var getEmailTemplatesControllerPatchUrl = (id) => {
232
+ return `/api/v1/templates/email/${id}`;
233
+ };
234
+ var getEmailTemplatesControllerDeleteUrl = (id) => {
235
+ return `/api/v1/templates/email/${id}`;
236
+ };
237
+ var getCannedResponsesControllerCreateUrl = () => {
238
+ return `/api/v1/canned-responses`;
239
+ };
240
+ var getCannedResponsesControllerListUrl = (params) => {
241
+ const normalizedParams = new URLSearchParams();
242
+ Object.entries(params || {}).forEach(([key, value]) => {
243
+ if (value !== void 0) {
244
+ normalizedParams.append(key, value === null ? "null" : String(value));
245
+ }
246
+ });
247
+ const stringifiedParams = normalizedParams.toString();
248
+ return stringifiedParams.length > 0 ? `/api/v1/canned-responses?${stringifiedParams}` : `/api/v1/canned-responses`;
249
+ };
250
+ var getCannedResponsesControllerPatchUrl = (id) => {
251
+ return `/api/v1/canned-responses/${id}`;
252
+ };
253
+ var getCannedResponsesControllerDeleteUrl = (id) => {
254
+ return `/api/v1/canned-responses/${id}`;
255
+ };
256
+ var getAttachmentsControllerUploadUrl = () => {
257
+ return `/api/v1/attachments`;
258
+ };
259
+ var getAttachmentsControllerGetDownloadUrlUrl = (id) => {
260
+ return `/api/v1/attachments/${id}/url`;
261
+ };
188
262
 
189
263
  // src/pagination/pagination.ts
190
264
  var MAX_PAGE_SIZE = 100;
@@ -585,6 +659,18 @@ function createConversationsModule(options) {
585
659
  const url = `${baseUrl}${path}`;
586
660
  const res = await fetch(url, buildInit("POST", input));
587
661
  return parseResponse(res);
662
+ },
663
+ /**
664
+ * List APPROVED + SENDABLE WhatsApp templates eligible to re-open an
665
+ * expired 24-hour customer-service window for the given conversation.
666
+ * Returns an empty array when the channel is not WhatsApp or has no linked WABA.
667
+ * Calls GET /api/v1/conversations/:id/whatsapp-recovery-options.
668
+ */
669
+ async whatsappRecoveryOptions(id) {
670
+ const path = getConversationsControllerGetWhatsAppRecoveryOptionsUrl(id);
671
+ const url = `${baseUrl}${path}`;
672
+ const res = await fetch(url, buildInit("GET"));
673
+ return parseResponse(res);
588
674
  }
589
675
  };
590
676
  }
@@ -651,6 +737,415 @@ function createMessagesModule(options) {
651
737
  const url = `${baseUrl}${path}`;
652
738
  const res = await fetch(url, buildInit("DELETE"));
653
739
  await parseResponse(res);
740
+ },
741
+ /**
742
+ * Send a template message in a conversation (WhatsApp or Email).
743
+ * Branches on the conversation channel type — WhatsApp uses positional
744
+ * `variables`; Email uses named `emailVariables`.
745
+ * Calls POST /api/v1/messages/send-template.
746
+ */
747
+ async sendTemplate(input) {
748
+ const path = getMessagesControllerSendTemplateUrl();
749
+ const url = `${baseUrl}${path}`;
750
+ const res = await fetch(url, buildInit("POST", input));
751
+ return parseResponse(res);
752
+ }
753
+ };
754
+ }
755
+
756
+ // src/templates/templates.ts
757
+ function createTemplatesModule(options) {
758
+ const baseUrl = options.baseUrl;
759
+ function buildInit(method, body) {
760
+ return {
761
+ method,
762
+ credentials: options.getCredentials(),
763
+ headers: {
764
+ "Content-Type": "application/json",
765
+ ...options.getHeaders()
766
+ },
767
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
768
+ };
769
+ }
770
+ return {
771
+ /**
772
+ * WhatsApp template submodule — WABA-scoped operations.
773
+ */
774
+ whatsapp: {
775
+ /**
776
+ * Author a new DRAFT template (version 1) under a WhatsApp Business Account.
777
+ * Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates.
778
+ */
779
+ async authorDraft(tenantId, wabaId, input) {
780
+ const path = getTemplatesControllerAuthorDraftUrl(tenantId, wabaId);
781
+ const url = `${baseUrl}${path}`;
782
+ const res = await fetch(url, buildInit("POST", input));
783
+ return parseResponse(res);
784
+ },
785
+ /**
786
+ * Import all APPROVED templates from the WABA into the system (immediately sendable).
787
+ * Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/import.
788
+ */
789
+ async importApproved(tenantId, wabaId) {
790
+ const path = getTemplatesControllerImportApprovedUrl(tenantId, wabaId);
791
+ const url = `${baseUrl}${path}`;
792
+ const res = await fetch(url, buildInit("POST"));
793
+ return parseResponse(res);
794
+ },
795
+ /**
796
+ * Fork a new DRAFT version from the latest version of a template (update).
797
+ * Calls PATCH /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId.
798
+ */
799
+ async update(tenantId, wabaId, templateId, input) {
800
+ const path = getTemplatesControllerForkDraftUrl(
801
+ tenantId,
802
+ wabaId,
803
+ templateId
804
+ );
805
+ const url = `${baseUrl}${path}`;
806
+ const res = await fetch(url, buildInit("PATCH", input));
807
+ return parseResponse(res);
808
+ },
809
+ /**
810
+ * List all versions and status events for a template in chronological order.
811
+ * Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId/history.
812
+ */
813
+ async history(tenantId, wabaId, templateId) {
814
+ const path = getTemplatesControllerGetHistoryUrl(
815
+ tenantId,
816
+ wabaId,
817
+ templateId
818
+ );
819
+ const url = `${baseUrl}${path}`;
820
+ const res = await fetch(url, buildInit("GET"));
821
+ return parseResponse(res);
822
+ },
823
+ /**
824
+ * Submit a DRAFT template version to Meta for review and approval (DRAFT → PENDING_APPROVAL).
825
+ * Calls POST /api/v1/tenants/:id/whatsapp-business-accounts/:wabaId/templates/:templateId/submit.
826
+ */
827
+ async submit(tenantId, wabaId, templateId) {
828
+ const path = getTemplatesControllerSubmitUrl(
829
+ tenantId,
830
+ wabaId,
831
+ templateId
832
+ );
833
+ const url = `${baseUrl}${path}`;
834
+ const res = await fetch(url, buildInit("POST"));
835
+ return parseResponse(res);
836
+ }
837
+ },
838
+ /**
839
+ * Email template submodule — tenant-scoped operations.
840
+ */
841
+ email: {
842
+ /**
843
+ * Create an Email template for the authenticated tenant.
844
+ * Calls POST /api/v1/templates/email.
845
+ */
846
+ async create(input) {
847
+ const path = getEmailTemplatesControllerCreateUrl();
848
+ const url = `${baseUrl}${path}`;
849
+ const res = await fetch(url, buildInit("POST", input));
850
+ return parseResponse(res);
851
+ },
852
+ /**
853
+ * List Email templates for the authenticated tenant (paginated).
854
+ * Calls GET /api/v1/templates/email.
855
+ */
856
+ async list(opts) {
857
+ const { page, pageSize } = buildPageParams(opts);
858
+ const path = getEmailTemplatesControllerListUrl({ page, pageSize });
859
+ const url = `${baseUrl}${path}`;
860
+ const res = await fetch(url, buildInit("GET"));
861
+ return parseResponse(res);
862
+ },
863
+ /**
864
+ * Get an Email template by id.
865
+ * Calls GET /api/v1/templates/email/:id.
866
+ */
867
+ async getById(id) {
868
+ const path = getEmailTemplatesControllerGetByIdUrl(id);
869
+ const url = `${baseUrl}${path}`;
870
+ const res = await fetch(url, buildInit("GET"));
871
+ return parseResponse(res);
872
+ },
873
+ /**
874
+ * Partially update an Email template — name, subject, htmlBody, textBody, and/or variableSchema; omitted fields unchanged.
875
+ * Calls PATCH /api/v1/templates/email/:id.
876
+ */
877
+ async patch(id, input) {
878
+ const path = getEmailTemplatesControllerPatchUrl(id);
879
+ const url = `${baseUrl}${path}`;
880
+ const res = await fetch(url, buildInit("PATCH", input));
881
+ return parseResponse(res);
882
+ },
883
+ /**
884
+ * Delete an Email template.
885
+ * Calls DELETE /api/v1/templates/email/:id.
886
+ */
887
+ async delete(id) {
888
+ const path = getEmailTemplatesControllerDeleteUrl(id);
889
+ const url = `${baseUrl}${path}`;
890
+ const res = await fetch(url, buildInit("DELETE"));
891
+ if (!res.ok) {
892
+ return parseResponse(res);
893
+ }
894
+ }
895
+ }
896
+ };
897
+ }
898
+
899
+ // src/canned-responses/canned-responses.ts
900
+ function createCannedResponsesModule(options) {
901
+ const baseUrl = options.baseUrl;
902
+ function buildInit(method, body) {
903
+ return {
904
+ method,
905
+ credentials: options.getCredentials(),
906
+ headers: {
907
+ "Content-Type": "application/json",
908
+ ...options.getHeaders()
909
+ },
910
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
911
+ };
912
+ }
913
+ return {
914
+ /**
915
+ * List canned responses (paginated, no search filter).
916
+ * pageSize is clamped to 100 per the API contract.
917
+ * Calls GET /api/v1/canned-responses.
918
+ */
919
+ async list(opts) {
920
+ const { page, pageSize } = buildPageParams(opts);
921
+ const path = getCannedResponsesControllerListUrl({ page, pageSize });
922
+ const url = `${baseUrl}${path}`;
923
+ const res = await fetch(url, buildInit("GET"));
924
+ return parseResponse(res);
925
+ },
926
+ /**
927
+ * Search canned responses by title substring or keyword prefix.
928
+ * pageSize is clamped to 100 per the API contract.
929
+ * Calls GET /api/v1/canned-responses?q=<term>.
930
+ */
931
+ async search(opts) {
932
+ const { page, pageSize } = buildPageParams(opts);
933
+ const path = getCannedResponsesControllerListUrl({
934
+ page,
935
+ pageSize,
936
+ q: opts.q
937
+ });
938
+ const url = `${baseUrl}${path}`;
939
+ const res = await fetch(url, buildInit("GET"));
940
+ return parseResponse(res);
941
+ },
942
+ /**
943
+ * Create a canned response.
944
+ * Calls POST /api/v1/canned-responses.
945
+ */
946
+ async create(input) {
947
+ const path = getCannedResponsesControllerCreateUrl();
948
+ const url = `${baseUrl}${path}`;
949
+ const res = await fetch(url, buildInit("POST", input));
950
+ return parseResponse(res);
951
+ },
952
+ /**
953
+ * Partially update a canned response — title, body, and/or keywords.
954
+ * Calls PATCH /api/v1/canned-responses/:id.
955
+ */
956
+ async update(id, input) {
957
+ const path = getCannedResponsesControllerPatchUrl(id);
958
+ const url = `${baseUrl}${path}`;
959
+ const res = await fetch(url, buildInit("PATCH", input));
960
+ return parseResponse(res);
961
+ },
962
+ /**
963
+ * Delete a canned response by id.
964
+ * Calls DELETE /api/v1/canned-responses/:id.
965
+ */
966
+ async delete(id) {
967
+ const path = getCannedResponsesControllerDeleteUrl(id);
968
+ const url = `${baseUrl}${path}`;
969
+ const res = await fetch(url, buildInit("DELETE"));
970
+ if (!res.ok) {
971
+ return parseResponse(res);
972
+ }
973
+ }
974
+ };
975
+ }
976
+
977
+ // src/attachments/attachments.ts
978
+ function createAttachmentsModule(options) {
979
+ const baseUrl = options.baseUrl;
980
+ return {
981
+ /**
982
+ * Upload a file as a draft attachment.
983
+ *
984
+ * Accepts a Blob or File (browser) or a Uint8Array wrapped in a Blob (Node 22+).
985
+ * Content-Type is intentionally omitted from headers so that fetch (both
986
+ * Node 22 built-in and browser) can set the multipart/form-data boundary.
987
+ *
988
+ * Calls POST /api/v1/attachments.
989
+ */
990
+ async upload(file, _opts) {
991
+ const form = new FormData();
992
+ const blob = file instanceof Uint8Array ? new Blob([file]) : file;
993
+ form.append("file", blob);
994
+ const path = getAttachmentsControllerUploadUrl();
995
+ const url = `${baseUrl}${path}`;
996
+ const res = await fetch(url, {
997
+ method: "POST",
998
+ credentials: options.getCredentials(),
999
+ headers: {
1000
+ // No Content-Type — let fetch set multipart boundary.
1001
+ ...options.getHeaders()
1002
+ },
1003
+ body: form
1004
+ });
1005
+ return parseResponse(res);
1006
+ },
1007
+ /**
1008
+ * Get a short-lived presigned download URL for a stored attachment.
1009
+ * The URL is valid for ≤ 15 minutes (NF-09).
1010
+ *
1011
+ * Calls GET /api/v1/attachments/:id/url.
1012
+ */
1013
+ async url(id) {
1014
+ const path = getAttachmentsControllerGetDownloadUrlUrl(id);
1015
+ const fullUrl = `${baseUrl}${path}`;
1016
+ const res = await fetch(fullUrl, {
1017
+ method: "GET",
1018
+ credentials: options.getCredentials(),
1019
+ headers: {
1020
+ ...options.getHeaders()
1021
+ }
1022
+ });
1023
+ return parseResponse(res);
1024
+ }
1025
+ };
1026
+ }
1027
+
1028
+ // src/whatsapp-business-accounts/whatsapp-business-accounts.ts
1029
+ function createWhatsAppBusinessAccountsModule(options) {
1030
+ const baseUrl = options.baseUrl;
1031
+ function buildInit(method) {
1032
+ return {
1033
+ method,
1034
+ credentials: options.getCredentials(),
1035
+ headers: {
1036
+ "Content-Type": "application/json",
1037
+ ...options.getHeaders()
1038
+ }
1039
+ };
1040
+ }
1041
+ return {
1042
+ /**
1043
+ * List all WhatsApp Business Accounts for the tenant.
1044
+ * Returns a non-secret view — no secretRef is exposed.
1045
+ * Calls GET /api/v1/tenants/:id/whatsapp-business-accounts.
1046
+ *
1047
+ * @example
1048
+ * const wabas = await sdk.whatsappBusinessAccounts.list('ten_acmecorp')
1049
+ * // pick wabas[0].id as the wabaId for sdk.templates.whatsapp.*
1050
+ */
1051
+ async list(tenantId) {
1052
+ const path = getWhatsAppBusinessAccountsControllerListUrl(tenantId);
1053
+ const url = `${baseUrl}${path}`;
1054
+ const res = await fetch(url, buildInit("GET"));
1055
+ return parseResponse(res);
1056
+ },
1057
+ /**
1058
+ * Get a single WhatsApp Business Account by its row id.
1059
+ * Returns a non-secret view — no secretRef is exposed.
1060
+ * Calls GET /api/v1/tenants/:id/whatsapp-business-accounts/:wabaRowId.
1061
+ *
1062
+ * @example
1063
+ * const waba = await sdk.whatsappBusinessAccounts.get('ten_acmecorp', 'waba_row_001')
1064
+ */
1065
+ async get(tenantId, wabaRowId) {
1066
+ const path = getWhatsAppBusinessAccountsControllerFindOneUrl(
1067
+ tenantId,
1068
+ wabaRowId
1069
+ );
1070
+ const url = `${baseUrl}${path}`;
1071
+ const res = await fetch(url, buildInit("GET"));
1072
+ return parseResponse(res);
1073
+ }
1074
+ };
1075
+ }
1076
+
1077
+ // src/ws/ws-client.ts
1078
+ import { io } from "socket.io-client";
1079
+ function createWsClient(options) {
1080
+ const handshakeAuth = options.auth === void 0 ? void 0 : "apiKey" in options.auth ? { apiKey: options.auth.apiKey } : { token: options.auth.token };
1081
+ const ioOptions = {
1082
+ reconnection: true,
1083
+ reconnectionAttempts: Infinity,
1084
+ reconnectionDelay: 1e3,
1085
+ reconnectionDelayMax: 3e4,
1086
+ randomizationFactor: 0.5,
1087
+ withCredentials: options.withCredentials ?? false
1088
+ };
1089
+ if (handshakeAuth !== void 0) {
1090
+ ioOptions.auth = handshakeAuth;
1091
+ }
1092
+ const socket = io(`${options.baseUrl}/ws/chat`, ioOptions);
1093
+ let currentState = "connecting";
1094
+ const stateListeners = /* @__PURE__ */ new Set();
1095
+ function setState(next) {
1096
+ if (next === currentState) return;
1097
+ currentState = next;
1098
+ for (const listener of stateListeners) {
1099
+ listener(next);
1100
+ }
1101
+ }
1102
+ socket.on("connect", () => {
1103
+ setState("connected");
1104
+ });
1105
+ socket.on("disconnect", () => {
1106
+ setState("disconnected");
1107
+ });
1108
+ socket.on("reconnect_attempt", () => {
1109
+ setState("reconnecting");
1110
+ });
1111
+ socket.on("reconnect", () => {
1112
+ setState("connected");
1113
+ });
1114
+ return {
1115
+ get state() {
1116
+ return currentState;
1117
+ },
1118
+ onStateChange(listener) {
1119
+ stateListeners.add(listener);
1120
+ return () => {
1121
+ stateListeners.delete(listener);
1122
+ };
1123
+ },
1124
+ on(event, handler) {
1125
+ const rawHandler = handler;
1126
+ socket.on(event, rawHandler);
1127
+ return () => {
1128
+ ;
1129
+ socket.off(event, rawHandler);
1130
+ };
1131
+ },
1132
+ joinConversation(conversationId) {
1133
+ socket.emit("conversation:join", { conversationId });
1134
+ },
1135
+ leaveConversation(conversationId) {
1136
+ socket.emit("conversation:leave", { conversationId });
1137
+ },
1138
+ typingStart(conversationId) {
1139
+ socket.emit("typing:start", { conversationId });
1140
+ },
1141
+ typingStop(conversationId) {
1142
+ socket.emit("typing:stop", { conversationId });
1143
+ },
1144
+ markRead(conversationId, lastReadMessageId) {
1145
+ socket.emit("message:read", { conversationId, lastReadMessageId });
1146
+ },
1147
+ disconnect() {
1148
+ socket.disconnect();
654
1149
  }
655
1150
  };
656
1151
  }
@@ -669,7 +1164,35 @@ function createOmnivoxClient(options) {
669
1164
  channels: createChannelsModule(moduleOptions),
670
1165
  contacts: createContactsModule(moduleOptions),
671
1166
  conversations: createConversationsModule(moduleOptions),
672
- messages: createMessagesModule(moduleOptions)
1167
+ messages: createMessagesModule(moduleOptions),
1168
+ templates: createTemplatesModule(moduleOptions),
1169
+ cannedResponses: createCannedResponsesModule(moduleOptions),
1170
+ attachments: createAttachmentsModule(moduleOptions),
1171
+ whatsappBusinessAccounts: createWhatsAppBusinessAccountsModule(moduleOptions),
1172
+ /**
1173
+ * Creates a WebSocket client connected to the `/ws/chat` namespace.
1174
+ *
1175
+ * Call this factory once and reuse the returned client. Reconnection with
1176
+ * exponential backoff + jitter (cap 30 s) is fully automatic.
1177
+ *
1178
+ * For API-key or token auth, pass the credential explicitly:
1179
+ * @example
1180
+ * const ws = client.connect({ apiKey: 'ovx_live_abc' })
1181
+ * ws.on('message:new', (msg) => console.log(msg))
1182
+ * ws.joinConversation('conv_001')
1183
+ *
1184
+ * For session/cookie auth (Console), call with no argument — the token
1185
+ * provider's `getCredentials() === 'include'` signals cookie mode and
1186
+ * `withCredentials` is set automatically:
1187
+ * @example
1188
+ * const ws = client.connect()
1189
+ * ws.on('message:new', (msg) => console.log(msg))
1190
+ */
1191
+ connect: (auth) => createWsClient({
1192
+ baseUrl: options.baseUrl,
1193
+ ...auth !== void 0 ? { auth } : {},
1194
+ withCredentials: options.tokenProvider.getCredentials() === "include"
1195
+ })
673
1196
  };
674
1197
  }
675
1198
 
@@ -699,13 +1222,18 @@ export {
699
1222
  buildPageParams,
700
1223
  createAgentsModule,
701
1224
  createApiKeyTokenProvider,
1225
+ createAttachmentsModule,
702
1226
  createAuthMeModule,
1227
+ createCannedResponsesModule,
703
1228
  createChannelsModule,
704
1229
  createContactsModule,
705
1230
  createConversationsModule,
706
1231
  createMessagesModule,
707
1232
  createOmnivoxClient,
708
1233
  createSessionTokenProvider,
1234
+ createTemplatesModule,
709
1235
  createTenantsModule,
1236
+ createWhatsAppBusinessAccountsModule,
1237
+ createWsClient,
710
1238
  iteratePages
711
1239
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digisglobal/omnivox-sdk",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^25.9.1",
27
+ "dependency-cruiser": "^17.4.0",
27
28
  "happy-dom": "^20.9.0",
28
29
  "orval": "^8.15.0",
29
30
  "tsup": "latest",
@@ -31,11 +32,15 @@
31
32
  "vitest": "latest",
32
33
  "@omnivox/tsconfig": "0.0.0"
33
34
  },
35
+ "dependencies": {
36
+ "socket.io-client": "^4.8.3"
37
+ },
34
38
  "scripts": {
35
39
  "codegen": "orval --config orval.config.ts && prettier --write src/_generated",
36
40
  "build": "tsup",
37
41
  "typecheck": "tsc --noEmit",
38
42
  "test": "vitest run",
39
- "lint": "eslint ."
43
+ "lint": "eslint .",
44
+ "depcruise": "depcruise src --config .dependency-cruiser.cjs"
40
45
  }
41
46
  }