@digisglobal/omnivox-sdk 0.6.0 → 0.7.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
@@ -69,6 +69,11 @@ async function parseResponse(res) {
69
69
  }
70
70
  return text ? JSON.parse(text) : void 0;
71
71
  }
72
+ async function parseEnvelopedResponse(res) {
73
+ if (NO_BODY_STATUSES.includes(res.status)) return void 0;
74
+ const envelope = await parseResponse(res);
75
+ return envelope.data;
76
+ }
72
77
 
73
78
  // src/auth/auth-me.ts
74
79
  function createAuthMeModule(options) {
@@ -823,7 +828,7 @@ function createTemplatesModule(options) {
823
828
  const path = getTemplatesControllerAuthorDraftUrl(tenantId, wabaId);
824
829
  const url = `${baseUrl}${path}`;
825
830
  const res = await fetch(url, buildInit("POST", input));
826
- return parseResponse(res);
831
+ return parseEnvelopedResponse(res);
827
832
  },
828
833
  /**
829
834
  * Import all APPROVED templates from the WABA into the system (immediately sendable).
@@ -833,7 +838,7 @@ function createTemplatesModule(options) {
833
838
  const path = getTemplatesControllerImportApprovedUrl(tenantId, wabaId);
834
839
  const url = `${baseUrl}${path}`;
835
840
  const res = await fetch(url, buildInit("POST"));
836
- return parseResponse(res);
841
+ return parseEnvelopedResponse(res);
837
842
  },
838
843
  /**
839
844
  * Fork a new DRAFT version from the latest version of a template (update).
@@ -847,7 +852,7 @@ function createTemplatesModule(options) {
847
852
  );
848
853
  const url = `${baseUrl}${path}`;
849
854
  const res = await fetch(url, buildInit("PATCH", input));
850
- return parseResponse(res);
855
+ return parseEnvelopedResponse(res);
851
856
  },
852
857
  /**
853
858
  * List all versions and status events for a template in chronological order.
@@ -861,7 +866,7 @@ function createTemplatesModule(options) {
861
866
  );
862
867
  const url = `${baseUrl}${path}`;
863
868
  const res = await fetch(url, buildInit("GET"));
864
- return parseResponse(res);
869
+ return parseEnvelopedResponse(res);
865
870
  },
866
871
  /**
867
872
  * Submit a DRAFT template version to Meta for review and approval (DRAFT → PENDING_APPROVAL).
@@ -875,7 +880,7 @@ function createTemplatesModule(options) {
875
880
  );
876
881
  const url = `${baseUrl}${path}`;
877
882
  const res = await fetch(url, buildInit("POST"));
878
- return parseResponse(res);
883
+ return parseEnvelopedResponse(res);
879
884
  }
880
885
  },
881
886
  /**
@@ -890,7 +895,7 @@ function createTemplatesModule(options) {
890
895
  const path = getEmailTemplatesControllerCreateUrl();
891
896
  const url = `${baseUrl}${path}`;
892
897
  const res = await fetch(url, buildInit("POST", input));
893
- return parseResponse(res);
898
+ return parseEnvelopedResponse(res);
894
899
  },
895
900
  /**
896
901
  * List Email templates for the authenticated tenant (paginated).
@@ -911,7 +916,7 @@ function createTemplatesModule(options) {
911
916
  const path = getEmailTemplatesControllerGetByIdUrl(id);
912
917
  const url = `${baseUrl}${path}`;
913
918
  const res = await fetch(url, buildInit("GET"));
914
- return parseResponse(res);
919
+ return parseEnvelopedResponse(res);
915
920
  },
916
921
  /**
917
922
  * Partially update an Email template — name, subject, htmlBody, textBody, and/or variableSchema; omitted fields unchanged.
@@ -921,7 +926,7 @@ function createTemplatesModule(options) {
921
926
  const path = getEmailTemplatesControllerPatchUrl(id);
922
927
  const url = `${baseUrl}${path}`;
923
928
  const res = await fetch(url, buildInit("PATCH", input));
924
- return parseResponse(res);
929
+ return parseEnvelopedResponse(res);
925
930
  },
926
931
  /**
927
932
  * Delete an Email template.
@@ -1095,7 +1100,7 @@ function createWhatsAppBusinessAccountsModule(options) {
1095
1100
  const path = getWhatsAppBusinessAccountsControllerListUrl(tenantId);
1096
1101
  const url = `${baseUrl}${path}`;
1097
1102
  const res = await fetch(url, buildInit("GET"));
1098
- return parseResponse(res);
1103
+ return parseEnvelopedResponse(res);
1099
1104
  },
1100
1105
  /**
1101
1106
  * Get a single WhatsApp Business Account by its row id.
@@ -1112,7 +1117,7 @@ function createWhatsAppBusinessAccountsModule(options) {
1112
1117
  );
1113
1118
  const url = `${baseUrl}${path}`;
1114
1119
  const res = await fetch(url, buildInit("GET"));
1115
- return parseResponse(res);
1120
+ return parseEnvelopedResponse(res);
1116
1121
  }
1117
1122
  };
1118
1123
  }
package/dist/index.d.cts CHANGED
@@ -580,49 +580,95 @@ interface ContactsModuleOptions extends TokenProvider {
580
580
  /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
581
581
  baseUrl: string;
582
582
  }
583
- /** Identity shape for creating a contact. */
583
+ /** Channel discriminator for a contact identity (wire enum). */
584
+ type ContactChannel = 'WHATSAPP' | 'EMAIL';
585
+ /**
586
+ * Identity shape for creating / adding a contact identity (request body).
587
+ * Matches the API Zod contract: `{ channelType, rawIdentifier }`.
588
+ */
584
589
  interface ContactIdentityInput {
585
- channel: string;
590
+ channelType: ContactChannel;
591
+ rawIdentifier: string;
592
+ }
593
+ /** Custom-field value on a create/patch request — referenced by field NAME. */
594
+ interface ContactFieldValueInput {
595
+ fieldName: string;
586
596
  value: string;
587
- [key: string]: unknown;
588
597
  }
589
598
  /** Input for creating a contact. */
590
599
  interface CreateContactInput {
591
600
  displayName: string;
592
- identities: ContactIdentityInput[];
593
- [key: string]: unknown;
601
+ /** Single identity (the API accepts `identity` or `identities[]`). */
602
+ identity?: ContactIdentityInput;
603
+ identities?: ContactIdentityInput[];
604
+ /** Tag NAMES from the catalog (unknown names → 422). Full set on create. */
605
+ tags?: string[];
606
+ /** Field values by NAME (unknown names → 422). */
607
+ fieldValues?: ContactFieldValueInput[];
594
608
  }
595
- /** Input for patching a contact. */
609
+ /**
610
+ * Input for patching a contact. The PATCH endpoint is strict — only these
611
+ * keys are accepted. `tags`/`fieldValues`, when present, are full-replacement.
612
+ */
596
613
  interface PatchContactInput {
597
614
  displayName?: string;
598
615
  isActive?: boolean;
599
- [key: string]: unknown;
616
+ tags?: string[];
617
+ fieldValues?: ContactFieldValueInput[];
600
618
  }
601
619
  /** Input for adding an identity to a contact. */
602
- interface AddIdentityInput {
603
- channel: string;
604
- value: string;
605
- [key: string]: unknown;
606
- }
607
- /** Contact identity resource shape. */
620
+ type AddIdentityInput = ContactIdentityInput;
621
+ /** Contact identity resource shape (response). */
608
622
  interface ContactIdentity {
609
623
  id: string;
610
- channel: string;
624
+ channelType: ContactChannel;
625
+ rawIdentifier: string;
626
+ normalizedIdentifier?: string;
627
+ }
628
+ /** A tag reference from the tenant catalog (response). */
629
+ interface ContactTag {
630
+ id: string;
631
+ name: string;
632
+ }
633
+ /** A custom-field definition from the catalog (response). */
634
+ interface ContactFieldDefinition {
635
+ id: string;
636
+ name: string;
637
+ type: string;
638
+ }
639
+ /**
640
+ * A custom-field value on contact detail (response). `fieldName` is a future
641
+ * enrichment (DEP-13) — until it lands, join `fieldId` against `metadata().fields`.
642
+ */
643
+ interface ContactFieldValue {
644
+ fieldId: string;
611
645
  value: string;
612
- [key: string]: unknown;
646
+ fieldName?: string;
613
647
  }
614
- /** Contact resource shape returned by the API. */
648
+ /** A conversation summary embedded on contact detail (response). */
649
+ interface ContactConversationSummary {
650
+ id: string;
651
+ contactIdentityId: string;
652
+ status: string;
653
+ lastInboundAt: string | null;
654
+ createdAt: string;
655
+ updatedAt: string;
656
+ }
657
+ /** Contact resource shape returned by the API (list + detail). */
615
658
  interface ContactItem {
616
659
  id: string;
617
660
  displayName: string;
661
+ isActive?: boolean;
662
+ createdAt?: string;
618
663
  identities?: ContactIdentity[];
619
- [key: string]: unknown;
664
+ tags?: ContactTag[];
665
+ fieldValues?: ContactFieldValue[];
666
+ conversations?: ContactConversationSummary[];
620
667
  }
621
668
  /** Contacts metadata (tag catalog and custom-field definitions). */
622
669
  interface ContactsMetadata {
623
- tags: unknown[];
624
- customFields: unknown[];
625
- [key: string]: unknown;
670
+ tags: ContactTag[];
671
+ fields: ContactFieldDefinition[];
626
672
  }
627
673
  /** Paginated list response. */
628
674
  interface PagedList$2<T> {
@@ -1588,4 +1634,4 @@ declare function createWhatsAppBusinessAccountsModule(options: WhatsAppBusinessA
1588
1634
  /** Return type of createWhatsAppBusinessAccountsModule. */
1589
1635
  type WhatsAppBusinessAccountsModule = ReturnType<typeof createWhatsAppBusinessAccountsModule>;
1590
1636
 
1591
- export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantPayload, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateItem, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
1637
+ export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactChannel, type ContactConversationSummary, type ContactFieldDefinition, type ContactFieldValue, type ContactFieldValueInput, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactTag, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantPayload, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateItem, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
package/dist/index.d.ts CHANGED
@@ -580,49 +580,95 @@ interface ContactsModuleOptions extends TokenProvider {
580
580
  /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
581
581
  baseUrl: string;
582
582
  }
583
- /** Identity shape for creating a contact. */
583
+ /** Channel discriminator for a contact identity (wire enum). */
584
+ type ContactChannel = 'WHATSAPP' | 'EMAIL';
585
+ /**
586
+ * Identity shape for creating / adding a contact identity (request body).
587
+ * Matches the API Zod contract: `{ channelType, rawIdentifier }`.
588
+ */
584
589
  interface ContactIdentityInput {
585
- channel: string;
590
+ channelType: ContactChannel;
591
+ rawIdentifier: string;
592
+ }
593
+ /** Custom-field value on a create/patch request — referenced by field NAME. */
594
+ interface ContactFieldValueInput {
595
+ fieldName: string;
586
596
  value: string;
587
- [key: string]: unknown;
588
597
  }
589
598
  /** Input for creating a contact. */
590
599
  interface CreateContactInput {
591
600
  displayName: string;
592
- identities: ContactIdentityInput[];
593
- [key: string]: unknown;
601
+ /** Single identity (the API accepts `identity` or `identities[]`). */
602
+ identity?: ContactIdentityInput;
603
+ identities?: ContactIdentityInput[];
604
+ /** Tag NAMES from the catalog (unknown names → 422). Full set on create. */
605
+ tags?: string[];
606
+ /** Field values by NAME (unknown names → 422). */
607
+ fieldValues?: ContactFieldValueInput[];
594
608
  }
595
- /** Input for patching a contact. */
609
+ /**
610
+ * Input for patching a contact. The PATCH endpoint is strict — only these
611
+ * keys are accepted. `tags`/`fieldValues`, when present, are full-replacement.
612
+ */
596
613
  interface PatchContactInput {
597
614
  displayName?: string;
598
615
  isActive?: boolean;
599
- [key: string]: unknown;
616
+ tags?: string[];
617
+ fieldValues?: ContactFieldValueInput[];
600
618
  }
601
619
  /** Input for adding an identity to a contact. */
602
- interface AddIdentityInput {
603
- channel: string;
604
- value: string;
605
- [key: string]: unknown;
606
- }
607
- /** Contact identity resource shape. */
620
+ type AddIdentityInput = ContactIdentityInput;
621
+ /** Contact identity resource shape (response). */
608
622
  interface ContactIdentity {
609
623
  id: string;
610
- channel: string;
624
+ channelType: ContactChannel;
625
+ rawIdentifier: string;
626
+ normalizedIdentifier?: string;
627
+ }
628
+ /** A tag reference from the tenant catalog (response). */
629
+ interface ContactTag {
630
+ id: string;
631
+ name: string;
632
+ }
633
+ /** A custom-field definition from the catalog (response). */
634
+ interface ContactFieldDefinition {
635
+ id: string;
636
+ name: string;
637
+ type: string;
638
+ }
639
+ /**
640
+ * A custom-field value on contact detail (response). `fieldName` is a future
641
+ * enrichment (DEP-13) — until it lands, join `fieldId` against `metadata().fields`.
642
+ */
643
+ interface ContactFieldValue {
644
+ fieldId: string;
611
645
  value: string;
612
- [key: string]: unknown;
646
+ fieldName?: string;
613
647
  }
614
- /** Contact resource shape returned by the API. */
648
+ /** A conversation summary embedded on contact detail (response). */
649
+ interface ContactConversationSummary {
650
+ id: string;
651
+ contactIdentityId: string;
652
+ status: string;
653
+ lastInboundAt: string | null;
654
+ createdAt: string;
655
+ updatedAt: string;
656
+ }
657
+ /** Contact resource shape returned by the API (list + detail). */
615
658
  interface ContactItem {
616
659
  id: string;
617
660
  displayName: string;
661
+ isActive?: boolean;
662
+ createdAt?: string;
618
663
  identities?: ContactIdentity[];
619
- [key: string]: unknown;
664
+ tags?: ContactTag[];
665
+ fieldValues?: ContactFieldValue[];
666
+ conversations?: ContactConversationSummary[];
620
667
  }
621
668
  /** Contacts metadata (tag catalog and custom-field definitions). */
622
669
  interface ContactsMetadata {
623
- tags: unknown[];
624
- customFields: unknown[];
625
- [key: string]: unknown;
670
+ tags: ContactTag[];
671
+ fields: ContactFieldDefinition[];
626
672
  }
627
673
  /** Paginated list response. */
628
674
  interface PagedList$2<T> {
@@ -1588,4 +1634,4 @@ declare function createWhatsAppBusinessAccountsModule(options: WhatsAppBusinessA
1588
1634
  /** Return type of createWhatsAppBusinessAccountsModule. */
1589
1635
  type WhatsAppBusinessAccountsModule = ReturnType<typeof createWhatsAppBusinessAccountsModule>;
1590
1636
 
1591
- export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantPayload, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateItem, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
1637
+ export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactChannel, type ContactConversationSummary, type ContactFieldDefinition, type ContactFieldValue, type ContactFieldValueInput, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactTag, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantPayload, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateItem, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
package/dist/index.js CHANGED
@@ -26,6 +26,11 @@ async function parseResponse(res) {
26
26
  }
27
27
  return text ? JSON.parse(text) : void 0;
28
28
  }
29
+ async function parseEnvelopedResponse(res) {
30
+ if (NO_BODY_STATUSES.includes(res.status)) return void 0;
31
+ const envelope = await parseResponse(res);
32
+ return envelope.data;
33
+ }
29
34
 
30
35
  // src/auth/auth-me.ts
31
36
  function createAuthMeModule(options) {
@@ -780,7 +785,7 @@ function createTemplatesModule(options) {
780
785
  const path = getTemplatesControllerAuthorDraftUrl(tenantId, wabaId);
781
786
  const url = `${baseUrl}${path}`;
782
787
  const res = await fetch(url, buildInit("POST", input));
783
- return parseResponse(res);
788
+ return parseEnvelopedResponse(res);
784
789
  },
785
790
  /**
786
791
  * Import all APPROVED templates from the WABA into the system (immediately sendable).
@@ -790,7 +795,7 @@ function createTemplatesModule(options) {
790
795
  const path = getTemplatesControllerImportApprovedUrl(tenantId, wabaId);
791
796
  const url = `${baseUrl}${path}`;
792
797
  const res = await fetch(url, buildInit("POST"));
793
- return parseResponse(res);
798
+ return parseEnvelopedResponse(res);
794
799
  },
795
800
  /**
796
801
  * Fork a new DRAFT version from the latest version of a template (update).
@@ -804,7 +809,7 @@ function createTemplatesModule(options) {
804
809
  );
805
810
  const url = `${baseUrl}${path}`;
806
811
  const res = await fetch(url, buildInit("PATCH", input));
807
- return parseResponse(res);
812
+ return parseEnvelopedResponse(res);
808
813
  },
809
814
  /**
810
815
  * List all versions and status events for a template in chronological order.
@@ -818,7 +823,7 @@ function createTemplatesModule(options) {
818
823
  );
819
824
  const url = `${baseUrl}${path}`;
820
825
  const res = await fetch(url, buildInit("GET"));
821
- return parseResponse(res);
826
+ return parseEnvelopedResponse(res);
822
827
  },
823
828
  /**
824
829
  * Submit a DRAFT template version to Meta for review and approval (DRAFT → PENDING_APPROVAL).
@@ -832,7 +837,7 @@ function createTemplatesModule(options) {
832
837
  );
833
838
  const url = `${baseUrl}${path}`;
834
839
  const res = await fetch(url, buildInit("POST"));
835
- return parseResponse(res);
840
+ return parseEnvelopedResponse(res);
836
841
  }
837
842
  },
838
843
  /**
@@ -847,7 +852,7 @@ function createTemplatesModule(options) {
847
852
  const path = getEmailTemplatesControllerCreateUrl();
848
853
  const url = `${baseUrl}${path}`;
849
854
  const res = await fetch(url, buildInit("POST", input));
850
- return parseResponse(res);
855
+ return parseEnvelopedResponse(res);
851
856
  },
852
857
  /**
853
858
  * List Email templates for the authenticated tenant (paginated).
@@ -868,7 +873,7 @@ function createTemplatesModule(options) {
868
873
  const path = getEmailTemplatesControllerGetByIdUrl(id);
869
874
  const url = `${baseUrl}${path}`;
870
875
  const res = await fetch(url, buildInit("GET"));
871
- return parseResponse(res);
876
+ return parseEnvelopedResponse(res);
872
877
  },
873
878
  /**
874
879
  * Partially update an Email template — name, subject, htmlBody, textBody, and/or variableSchema; omitted fields unchanged.
@@ -878,7 +883,7 @@ function createTemplatesModule(options) {
878
883
  const path = getEmailTemplatesControllerPatchUrl(id);
879
884
  const url = `${baseUrl}${path}`;
880
885
  const res = await fetch(url, buildInit("PATCH", input));
881
- return parseResponse(res);
886
+ return parseEnvelopedResponse(res);
882
887
  },
883
888
  /**
884
889
  * Delete an Email template.
@@ -1052,7 +1057,7 @@ function createWhatsAppBusinessAccountsModule(options) {
1052
1057
  const path = getWhatsAppBusinessAccountsControllerListUrl(tenantId);
1053
1058
  const url = `${baseUrl}${path}`;
1054
1059
  const res = await fetch(url, buildInit("GET"));
1055
- return parseResponse(res);
1060
+ return parseEnvelopedResponse(res);
1056
1061
  },
1057
1062
  /**
1058
1063
  * Get a single WhatsApp Business Account by its row id.
@@ -1069,7 +1074,7 @@ function createWhatsAppBusinessAccountsModule(options) {
1069
1074
  );
1070
1075
  const url = `${baseUrl}${path}`;
1071
1076
  const res = await fetch(url, buildInit("GET"));
1072
- return parseResponse(res);
1077
+ return parseEnvelopedResponse(res);
1073
1078
  }
1074
1079
  };
1075
1080
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digisglobal/omnivox-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {