mailchannels-sdk 0.7.7 → 0.7.8

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![MailChannels Node.js SDK](/docs/public/images/presentation.png)
1
+ ![MailChannels Node.js SDK](./docs/public/images/presentation.png)
2
2
 
3
3
  # MailChannels Node.js SDK
4
4
 
@@ -809,6 +809,37 @@ interface WebhooksBatch {
809
809
  webhook: string;
810
810
  }
811
811
  type WebhooksBatchesResponse = DataResponse<WebhooksBatch[]>;
812
+ interface WebhooksResendBatch {
813
+ /**
814
+ * Unique identifier for the webhook batch.
815
+ */
816
+ batchId: number;
817
+ /**
818
+ * Customer handle associated with the webhook batch.
819
+ */
820
+ customerHandle: string;
821
+ /**
822
+ * Webhook URL to which events in the batch were posted.
823
+ */
824
+ webhook: string;
825
+ /**
826
+ * Timestamp of when the webhook batch was created.
827
+ */
828
+ createdAt: string;
829
+ /**
830
+ * Number of events in the webhook batch.
831
+ */
832
+ eventCount: number;
833
+ /**
834
+ * Duration of the webhook batch in milliseconds. `null` indicates that no response was returned from the webhook endpoint.
835
+ */
836
+ duration: number | null;
837
+ /**
838
+ * HTTP status code returned by the webhook endpoint. `null` indicates that no response was returned from the webhook endpoint.
839
+ */
840
+ statusCode: number | null;
841
+ }
842
+ type WebhooksResendBatchResponse = DataResponse<WebhooksResendBatch>;
812
843
  declare class Webhooks {
813
844
  protected mailchannels: MailChannelsClient;
814
845
  constructor(mailchannels: MailChannelsClient);
@@ -889,6 +920,16 @@ declare class Webhooks {
889
920
  * ```
890
921
  */
891
922
  batches(options?: WebhooksBatchesOptions): Promise<WebhooksBatchesResponse>;
923
+ /**
924
+ * Synchronously resends the webhook batch with the provided `batchId` for the customer. The result is returned in the response.
925
+ * @param batchId - The ID of the batch to resend.
926
+ * @example
927
+ * ```ts
928
+ * const mailchannels = new MailChannels('your-api-key')
929
+ * const { data, error } = await mailchannels.webhooks.resendBatch(123)
930
+ * ```
931
+ */
932
+ resendBatch(batchId: number): Promise<WebhooksResendBatchResponse>;
892
933
  }
893
934
  interface SubAccountsAccount {
894
935
  /**
@@ -2148,4 +2189,4 @@ declare class MailChannels extends MailChannelsClient {
2148
2189
  readonly service: Service;
2149
2190
  constructor(key: string, options?: MailChannelsClientOptions);
2150
2191
  }
2151
- export { DataResponse, Domains, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, Emails, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAsyncResponse, EmailsSendAttachment, EmailsSendDkim, EmailsSendOptions, EmailsSendPersonalization, EmailsSendRecipient, EmailsSendRecipientInput, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ErrorResponse, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, Lists, MailChannels, MailChannelsClient, type MailChannelsClientOptions, Metrics, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Service, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccounts, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, Suppressions, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, Users, UsersCreateOptions, UsersCreateResponse, WebhookEvent, WebhookEventClick, WebhookEventComplained, WebhookEventDelivered, WebhookEventDropped, WebhookEventHardBounced, WebhookEventOpen, WebhookEventProcessed, WebhookEventSoftBounced, WebhookEventTest, WebhookEventType, WebhookEventUnsubscribed, WebhookEvents, Webhooks, WebhooksBatch, WebhooksBatchResponseStatus, WebhooksBatchStatus, WebhooksBatchesOptions, WebhooksBatchesResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse, WebhooksVerifyOptions };
2192
+ export { DataResponse, Domains, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, Emails, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAsyncResponse, EmailsSendAttachment, EmailsSendDkim, EmailsSendOptions, EmailsSendPersonalization, EmailsSendRecipient, EmailsSendRecipientInput, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ErrorResponse, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, Lists, MailChannels, MailChannelsClient, type MailChannelsClientOptions, Metrics, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Service, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccounts, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, Suppressions, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, Users, UsersCreateOptions, UsersCreateResponse, WebhookEvent, WebhookEventClick, WebhookEventComplained, WebhookEventDelivered, WebhookEventDropped, WebhookEventHardBounced, WebhookEventOpen, WebhookEventProcessed, WebhookEventSoftBounced, WebhookEventTest, WebhookEventType, WebhookEventUnsubscribed, WebhookEvents, Webhooks, WebhooksBatch, WebhooksBatchResponseStatus, WebhooksBatchStatus, WebhooksBatchesOptions, WebhooksBatchesResponse, WebhooksListResponse, WebhooksResendBatch, WebhooksResendBatchResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse, WebhooksVerifyOptions };
@@ -842,6 +842,34 @@ var Webhooks = class Webhooks {
842
842
  error: null
843
843
  };
844
844
  }
845
+ async resendBatch(batchId) {
846
+ let error = null;
847
+ const response = await this.mailchannels.post(`/tx/v1/webhook-batch/${batchId}/resend`, { onResponseError: async ({ response }) => {
848
+ error = getStatusError(response, {
849
+ [ErrorCode.BadRequest]: "Bad Request. The batch ID is invalid.",
850
+ [ErrorCode.NotFound]: `The batch '${batchId}' is not found for the customer.`
851
+ });
852
+ } }).catch((e) => {
853
+ error ||= getResultError(e, "Failed to resend webhook batch.");
854
+ return null;
855
+ });
856
+ if (!response) return {
857
+ data: null,
858
+ error
859
+ };
860
+ return {
861
+ data: clean({
862
+ batchId: response.batch_id,
863
+ customerHandle: response.customer_handle,
864
+ webhook: response.webhook,
865
+ createdAt: response.created_at,
866
+ eventCount: response.event_count,
867
+ duration: response.duration_in_ms,
868
+ statusCode: response.status_code
869
+ }),
870
+ error: null
871
+ };
872
+ }
845
873
  };
846
874
  var SubAccounts = class SubAccounts {
847
875
  static COMPANY_PATTERN = /^.{3,128}$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailchannels-sdk",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "Node.js SDK to integrate MailChannels API into your JavaScript or TypeScript server-side applications.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,8 +39,8 @@
39
39
  "devDependencies": {
40
40
  "@stylistic/eslint-plugin": "^5.10.0",
41
41
  "@types/markdown-it": "^14.1.2",
42
- "@types/node": "^25.5.2",
43
- "@vitest/coverage-v8": "^4.1.3",
42
+ "@types/node": "^25.6.0",
43
+ "@vitest/coverage-v8": "^4.1.4",
44
44
  "changelogen": "^0.6.2",
45
45
  "jiti": "^2.6.1",
46
46
  "obuild": "^0.4.33",
@@ -50,7 +50,7 @@
50
50
  "vitepress": "^2.0.0-alpha.17",
51
51
  "vitepress-plugin-group-icons": "^1.7.3",
52
52
  "vitepress-plugin-llms": "^1.12.0",
53
- "vitest": "^4.1.3"
53
+ "vitest": "^4.1.4"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "obuild",