@getbrevo/brevo 5.0.1 → 5.0.4

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.
Files changed (132) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/Client.d.ts +12 -0
  3. package/dist/cjs/Client.js +67 -0
  4. package/dist/cjs/api/resources/balance/client/Client.js +15 -6
  5. package/dist/cjs/api/resources/balance/client/requests/GetContactBalancesRequest.d.ts +2 -0
  6. package/dist/cjs/api/resources/balance/client/requests/GetLoyaltyBalanceProgramsPidActiveBalanceRequest.d.ts +2 -0
  7. package/dist/cjs/api/resources/balance/client/requests/GetLoyaltyBalanceProgramsPidTransactionHistoryRequest.d.ts +5 -1
  8. package/dist/cjs/api/resources/balance/client/requests/GetSubscriptionBalancesRequest.d.ts +2 -0
  9. package/dist/cjs/api/resources/balance/client/requests/PostLoyaltyBalanceProgramsPidBalanceDefinitionsRequest.d.ts +10 -1
  10. package/dist/cjs/api/resources/balance/client/requests/UpdateBalanceDefinitionRequest.d.ts +10 -1
  11. package/dist/cjs/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestStatus.d.ts +8 -0
  12. package/dist/cjs/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestStatus.js +11 -0
  13. package/dist/cjs/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestTransactionType.d.ts +5 -0
  14. package/dist/cjs/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestTransactionType.js +8 -0
  15. package/dist/cjs/api/resources/balance/types/index.d.ts +2 -0
  16. package/dist/cjs/api/resources/balance/types/index.js +2 -0
  17. package/dist/cjs/api/resources/contacts/client/Client.d.ts +2 -2
  18. package/dist/cjs/api/resources/contacts/client/Client.js +5 -2
  19. package/dist/cjs/api/resources/contacts/client/requests/CreateContactRequest.d.ts +1 -1
  20. package/dist/cjs/api/resources/contacts/client/requests/UpdateContactRequest.d.ts +1 -1
  21. package/dist/cjs/api/resources/ecommerce/client/Client.d.ts +2 -2
  22. package/dist/cjs/api/resources/ecommerce/client/Client.js +8 -2
  23. package/dist/cjs/api/resources/ecommerce/client/requests/CreateUpdateBatchProductsRequest.d.ts +5 -1
  24. package/dist/cjs/api/resources/ecommerce/client/requests/CreateUpdateProductRequest.d.ts +5 -1
  25. package/dist/cjs/api/resources/event/client/Client.d.ts +20 -1
  26. package/dist/cjs/api/resources/event/client/Client.js +69 -1
  27. package/dist/cjs/api/resources/event/client/requests/CreateEventRequest.d.ts +2 -2
  28. package/dist/cjs/api/resources/event/client/requests/GetEventsRequest.d.ts +20 -0
  29. package/dist/cjs/api/resources/event/client/requests/GetEventsRequest.js +3 -0
  30. package/dist/cjs/api/resources/event/client/requests/index.d.ts +1 -0
  31. package/dist/cjs/api/resources/event/types/CreateBatchEventsRequestItem.d.ts +2 -2
  32. package/dist/cjs/api/resources/process/types/GetProcessResponse.d.ts +3 -2
  33. package/dist/cjs/api/resources/process/types/GetProcessResponse.js +1 -0
  34. package/dist/cjs/api/resources/process/types/GetProcessesResponse.d.ts +3 -2
  35. package/dist/cjs/api/resources/process/types/GetProcessesResponse.js +1 -0
  36. package/dist/cjs/api/resources/program/client/Client.js +2 -1
  37. package/dist/cjs/api/resources/program/client/requests/GetParameterSubscriptionInfoRequest.d.ts +2 -0
  38. package/dist/cjs/api/resources/tier/client/requests/CreateTierGroupRequest.d.ts +11 -0
  39. package/dist/cjs/api/resources/tier/client/requests/UpdateTierGroupRequest.d.ts +11 -0
  40. package/dist/cjs/api/types/BatchAcceptedResponse.d.ts +9 -0
  41. package/dist/cjs/api/types/BatchAcceptedResponse.js +3 -0
  42. package/dist/cjs/api/types/GetEventsList.d.ts +32 -0
  43. package/dist/cjs/api/types/GetEventsList.js +3 -0
  44. package/dist/cjs/api/types/GetProductDetails.d.ts +4 -0
  45. package/dist/cjs/api/types/InternalServerErrorBody.d.ts +48 -0
  46. package/dist/cjs/api/types/InternalServerErrorBody.js +46 -0
  47. package/dist/cjs/api/types/index.d.ts +3 -0
  48. package/dist/cjs/api/types/index.js +3 -0
  49. package/dist/cjs/core/auth/BasicAuth.d.ts +2 -2
  50. package/dist/cjs/core/auth/BasicAuth.js +7 -1
  51. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
  52. package/dist/cjs/core/fetcher/Fetcher.d.ts +2 -0
  53. package/dist/cjs/core/fetcher/Fetcher.js +4 -0
  54. package/dist/cjs/core/fetcher/index.d.ts +2 -0
  55. package/dist/cjs/core/fetcher/index.js +3 -1
  56. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  57. package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
  58. package/dist/cjs/core/file/file.js +3 -2
  59. package/dist/cjs/errors/BrevoError.d.ts +3 -1
  60. package/dist/cjs/errors/BrevoError.js +4 -1
  61. package/dist/cjs/errors/BrevoTimeoutError.d.ts +4 -1
  62. package/dist/cjs/errors/BrevoTimeoutError.js +4 -1
  63. package/dist/cjs/errors/handleNonStatusCodeError.js +4 -1
  64. package/dist/cjs/version.d.ts +1 -1
  65. package/dist/cjs/version.js +1 -1
  66. package/dist/esm/BaseClient.mjs +2 -2
  67. package/dist/esm/Client.d.mts +12 -0
  68. package/dist/esm/Client.mjs +34 -0
  69. package/dist/esm/api/resources/balance/client/Client.mjs +15 -6
  70. package/dist/esm/api/resources/balance/client/requests/GetContactBalancesRequest.d.mts +2 -0
  71. package/dist/esm/api/resources/balance/client/requests/GetLoyaltyBalanceProgramsPidActiveBalanceRequest.d.mts +2 -0
  72. package/dist/esm/api/resources/balance/client/requests/GetLoyaltyBalanceProgramsPidTransactionHistoryRequest.d.mts +5 -1
  73. package/dist/esm/api/resources/balance/client/requests/GetSubscriptionBalancesRequest.d.mts +2 -0
  74. package/dist/esm/api/resources/balance/client/requests/PostLoyaltyBalanceProgramsPidBalanceDefinitionsRequest.d.mts +10 -1
  75. package/dist/esm/api/resources/balance/client/requests/UpdateBalanceDefinitionRequest.d.mts +10 -1
  76. package/dist/esm/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestStatus.d.mts +8 -0
  77. package/dist/esm/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestStatus.mjs +8 -0
  78. package/dist/esm/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestTransactionType.d.mts +5 -0
  79. package/dist/esm/api/resources/balance/types/GetLoyaltyBalanceProgramsPidTransactionHistoryRequestTransactionType.mjs +5 -0
  80. package/dist/esm/api/resources/balance/types/index.d.mts +2 -0
  81. package/dist/esm/api/resources/balance/types/index.mjs +2 -0
  82. package/dist/esm/api/resources/contacts/client/Client.d.mts +2 -2
  83. package/dist/esm/api/resources/contacts/client/Client.mjs +5 -2
  84. package/dist/esm/api/resources/contacts/client/requests/CreateContactRequest.d.mts +1 -1
  85. package/dist/esm/api/resources/contacts/client/requests/UpdateContactRequest.d.mts +1 -1
  86. package/dist/esm/api/resources/ecommerce/client/Client.d.mts +2 -2
  87. package/dist/esm/api/resources/ecommerce/client/Client.mjs +8 -2
  88. package/dist/esm/api/resources/ecommerce/client/requests/CreateUpdateBatchProductsRequest.d.mts +5 -1
  89. package/dist/esm/api/resources/ecommerce/client/requests/CreateUpdateProductRequest.d.mts +5 -1
  90. package/dist/esm/api/resources/event/client/Client.d.mts +20 -1
  91. package/dist/esm/api/resources/event/client/Client.mjs +69 -1
  92. package/dist/esm/api/resources/event/client/requests/CreateEventRequest.d.mts +2 -2
  93. package/dist/esm/api/resources/event/client/requests/GetEventsRequest.d.mts +20 -0
  94. package/dist/esm/api/resources/event/client/requests/GetEventsRequest.mjs +2 -0
  95. package/dist/esm/api/resources/event/client/requests/index.d.mts +1 -0
  96. package/dist/esm/api/resources/event/types/CreateBatchEventsRequestItem.d.mts +2 -2
  97. package/dist/esm/api/resources/process/types/GetProcessResponse.d.mts +3 -2
  98. package/dist/esm/api/resources/process/types/GetProcessResponse.mjs +1 -0
  99. package/dist/esm/api/resources/process/types/GetProcessesResponse.d.mts +3 -2
  100. package/dist/esm/api/resources/process/types/GetProcessesResponse.mjs +1 -0
  101. package/dist/esm/api/resources/program/client/Client.mjs +2 -1
  102. package/dist/esm/api/resources/program/client/requests/GetParameterSubscriptionInfoRequest.d.mts +2 -0
  103. package/dist/esm/api/resources/tier/client/requests/CreateTierGroupRequest.d.mts +11 -0
  104. package/dist/esm/api/resources/tier/client/requests/UpdateTierGroupRequest.d.mts +11 -0
  105. package/dist/esm/api/types/BatchAcceptedResponse.d.mts +9 -0
  106. package/dist/esm/api/types/BatchAcceptedResponse.mjs +2 -0
  107. package/dist/esm/api/types/GetEventsList.d.mts +32 -0
  108. package/dist/esm/api/types/GetEventsList.mjs +2 -0
  109. package/dist/esm/api/types/GetProductDetails.d.mts +4 -0
  110. package/dist/esm/api/types/InternalServerErrorBody.d.mts +48 -0
  111. package/dist/esm/api/types/InternalServerErrorBody.mjs +43 -0
  112. package/dist/esm/api/types/index.d.mts +3 -0
  113. package/dist/esm/api/types/index.mjs +3 -0
  114. package/dist/esm/core/auth/BasicAuth.d.mts +2 -2
  115. package/dist/esm/core/auth/BasicAuth.mjs +7 -1
  116. package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
  117. package/dist/esm/core/fetcher/Fetcher.d.mts +2 -0
  118. package/dist/esm/core/fetcher/Fetcher.mjs +4 -0
  119. package/dist/esm/core/fetcher/index.d.mts +2 -0
  120. package/dist/esm/core/fetcher/index.mjs +1 -0
  121. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  122. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
  123. package/dist/esm/core/file/file.mjs +3 -2
  124. package/dist/esm/errors/BrevoError.d.mts +3 -1
  125. package/dist/esm/errors/BrevoError.mjs +4 -1
  126. package/dist/esm/errors/BrevoTimeoutError.d.mts +4 -1
  127. package/dist/esm/errors/BrevoTimeoutError.mjs +4 -1
  128. package/dist/esm/errors/handleNonStatusCodeError.mjs +4 -1
  129. package/dist/esm/version.d.mts +1 -1
  130. package/dist/esm/version.mjs +1 -1
  131. package/package.json +7 -7
  132. package/reference.md +72 -5
@@ -14,6 +14,6 @@ export type BinaryResponse = {
14
14
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
15
15
  * Some versions of the Fetch API may not support this method.
16
16
  */
17
- bytes?(): ReturnType<Response["bytes"]>;
17
+ bytes?(): Promise<Uint8Array>;
18
18
  };
19
19
  export declare function getBinaryResponse(response: Response): BinaryResponse;
@@ -38,10 +38,12 @@ export declare namespace Fetcher {
38
38
  }
39
39
  interface TimeoutError {
40
40
  reason: "timeout";
41
+ cause?: unknown;
41
42
  }
42
43
  interface UnknownError {
43
44
  reason: "unknown";
44
45
  errorMessage: string;
46
+ cause?: unknown;
45
47
  }
46
48
  }
47
49
  export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
@@ -257,6 +257,7 @@ export function fetcherImpl(args) {
257
257
  error: {
258
258
  reason: "unknown",
259
259
  errorMessage: "The user aborted a request",
260
+ cause: error,
260
261
  },
261
262
  rawResponse: abortRawResponse,
262
263
  };
@@ -274,6 +275,7 @@ export function fetcherImpl(args) {
274
275
  ok: false,
275
276
  error: {
276
277
  reason: "timeout",
278
+ cause: error,
277
279
  },
278
280
  rawResponse: abortRawResponse,
279
281
  };
@@ -292,6 +294,7 @@ export function fetcherImpl(args) {
292
294
  error: {
293
295
  reason: "unknown",
294
296
  errorMessage: error.message,
297
+ cause: error,
295
298
  },
296
299
  rawResponse: unknownRawResponse,
297
300
  };
@@ -309,6 +312,7 @@ export function fetcherImpl(args) {
309
312
  error: {
310
313
  reason: "unknown",
311
314
  errorMessage: toJson(error),
315
+ cause: error,
312
316
  },
313
317
  rawResponse: unknownRawResponse,
314
318
  };
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.mjs";
6
6
  export { fetcher } from "./Fetcher.mjs";
7
7
  export { getHeader } from "./getHeader.mjs";
8
8
  export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
9
+ export type { PassthroughRequest } from "./makePassthroughRequest.mjs";
10
+ export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
9
11
  export type { RawResponse, WithRawResponse } from "./RawResponse.mjs";
10
12
  export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
11
13
  export { Supplier } from "./Supplier.mjs";
@@ -2,5 +2,6 @@ export { EndpointSupplier } from "./EndpointSupplier.mjs";
2
2
  export { fetcher } from "./Fetcher.mjs";
3
3
  export { getHeader } from "./getHeader.mjs";
4
4
  export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
5
+ export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
5
6
  export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
6
7
  export { Supplier } from "./Supplier.mjs";
@@ -0,0 +1,49 @@
1
+ import { type LogConfig, type Logger } from "../logging/logger.mjs";
2
+ import { Supplier } from "./Supplier.mjs";
3
+ export declare namespace PassthroughRequest {
4
+ /**
5
+ * Per-request options that can override the SDK client defaults.
6
+ */
7
+ interface RequestOptions {
8
+ /** Override the default timeout for this request (in seconds). */
9
+ timeoutInSeconds?: number;
10
+ /** Override the default number of retries for this request. */
11
+ maxRetries?: number;
12
+ /** Additional headers to include in this request. */
13
+ headers?: Record<string, string>;
14
+ /** Abort signal for this request. */
15
+ abortSignal?: AbortSignal;
16
+ }
17
+ /**
18
+ * SDK client configuration used by the passthrough fetch method.
19
+ */
20
+ interface ClientOptions {
21
+ /** The base URL or environment for the client. */
22
+ environment?: Supplier<string>;
23
+ /** Override the base URL. */
24
+ baseUrl?: Supplier<string>;
25
+ /** Default headers to include in requests. */
26
+ headers?: Record<string, unknown>;
27
+ /** Default maximum time to wait for a response in seconds. */
28
+ timeoutInSeconds?: number;
29
+ /** Default number of times to retry the request. Defaults to 2. */
30
+ maxRetries?: number;
31
+ /** A custom fetch function. */
32
+ fetch?: typeof fetch;
33
+ /** Logging configuration. */
34
+ logging?: LogConfig | Logger;
35
+ /** A function that returns auth headers. */
36
+ getAuthHeaders?: () => Promise<Record<string, string>>;
37
+ }
38
+ }
39
+ /**
40
+ * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
41
+ * while mimicking the standard `fetch` API.
42
+ *
43
+ * @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
44
+ * @param init - Standard RequestInit options (method, headers, body, signal, etc.)
45
+ * @param clientOptions - SDK client options (auth, default headers, logging, etc.)
46
+ * @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
47
+ * @returns A standard Response object.
48
+ */
49
+ export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;
@@ -0,0 +1,132 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { createLogger } from "../logging/logger.mjs";
11
+ import { join } from "../url/join.mjs";
12
+ import { EndpointSupplier } from "./EndpointSupplier.mjs";
13
+ import { getFetchFn } from "./getFetchFn.mjs";
14
+ import { makeRequest } from "./makeRequest.mjs";
15
+ import { requestWithRetries } from "./requestWithRetries.mjs";
16
+ import { Supplier } from "./Supplier.mjs";
17
+ /**
18
+ * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
19
+ * while mimicking the standard `fetch` API.
20
+ *
21
+ * @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
22
+ * @param init - Standard RequestInit options (method, headers, body, signal, etc.)
23
+ * @param clientOptions - SDK client options (auth, default headers, logging, etc.)
24
+ * @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
25
+ * @returns A standard Response object.
26
+ */
27
+ export function makePassthroughRequest(input, init, clientOptions, requestOptions) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ var _a, _b, _c, _d, _e, _f, _g;
30
+ const logger = createLogger(clientOptions.logging);
31
+ // Extract URL and default init properties from Request object if provided
32
+ let url;
33
+ let effectiveInit = init;
34
+ if (input instanceof Request) {
35
+ url = input.url;
36
+ // If no explicit init provided, extract properties from the Request object
37
+ if (init == null) {
38
+ effectiveInit = {
39
+ method: input.method,
40
+ headers: Object.fromEntries(input.headers.entries()),
41
+ body: input.body,
42
+ signal: input.signal,
43
+ credentials: input.credentials,
44
+ cache: input.cache,
45
+ redirect: input.redirect,
46
+ referrer: input.referrer,
47
+ integrity: input.integrity,
48
+ mode: input.mode,
49
+ };
50
+ }
51
+ }
52
+ else {
53
+ url = input instanceof URL ? input.toString() : input;
54
+ }
55
+ // Resolve the base URL
56
+ const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier.get(clientOptions.environment) : undefined);
57
+ // Determine the full URL
58
+ let fullUrl;
59
+ if (url.startsWith("http://") || url.startsWith("https://")) {
60
+ fullUrl = url;
61
+ }
62
+ else if (baseUrl != null) {
63
+ fullUrl = join(baseUrl, url);
64
+ }
65
+ else {
66
+ fullUrl = url;
67
+ }
68
+ // Merge headers: SDK default headers -> auth headers -> user-provided headers
69
+ const mergedHeaders = {};
70
+ // Apply SDK default headers (resolve suppliers)
71
+ if (clientOptions.headers != null) {
72
+ for (const [key, value] of Object.entries(clientOptions.headers)) {
73
+ const resolved = yield EndpointSupplier.get(value, { endpointMetadata: {} });
74
+ if (resolved != null) {
75
+ mergedHeaders[key.toLowerCase()] = `${resolved}`;
76
+ }
77
+ }
78
+ }
79
+ // Apply auth headers
80
+ if (clientOptions.getAuthHeaders != null) {
81
+ const authHeaders = yield clientOptions.getAuthHeaders();
82
+ for (const [key, value] of Object.entries(authHeaders)) {
83
+ mergedHeaders[key.toLowerCase()] = value;
84
+ }
85
+ }
86
+ // Apply user-provided headers from init
87
+ if ((effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.headers) != null) {
88
+ const initHeaders = effectiveInit.headers instanceof Headers
89
+ ? Object.fromEntries(effectiveInit.headers.entries())
90
+ : Array.isArray(effectiveInit.headers)
91
+ ? Object.fromEntries(effectiveInit.headers)
92
+ : effectiveInit.headers;
93
+ for (const [key, value] of Object.entries(initHeaders)) {
94
+ if (value != null) {
95
+ mergedHeaders[key.toLowerCase()] = value;
96
+ }
97
+ }
98
+ }
99
+ // Apply per-request option headers (highest priority)
100
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) != null) {
101
+ for (const [key, value] of Object.entries(requestOptions.headers)) {
102
+ mergedHeaders[key.toLowerCase()] = value;
103
+ }
104
+ }
105
+ const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
106
+ const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
107
+ const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
108
+ const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
109
+ const maxRetries = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _d !== void 0 ? _d : clientOptions.maxRetries;
110
+ const abortSignal = (_f = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal) !== null && _e !== void 0 ? _e : effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.signal) !== null && _f !== void 0 ? _f : undefined;
111
+ const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield getFetchFn());
112
+ if (logger.isDebug()) {
113
+ logger.debug("Making passthrough HTTP request", {
114
+ method,
115
+ url: fullUrl,
116
+ hasBody: body != null,
117
+ });
118
+ }
119
+ const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
120
+ return makeRequest(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === "include", undefined, // duplex
121
+ false);
122
+ }), maxRetries);
123
+ if (logger.isDebug()) {
124
+ logger.debug("Passthrough HTTP request completed", {
125
+ method,
126
+ url: fullUrl,
127
+ statusCode: response.status,
128
+ });
129
+ }
130
+ return response;
131
+ });
132
+ }
@@ -48,7 +48,7 @@ function getFileWithMetadata(file_1) {
48
48
  }
49
49
  if ("path" in file) {
50
50
  const fs = yield import("fs");
51
- if (!fs || !fs.createReadStream) {
51
+ if (!(fs === null || fs === void 0 ? void 0 : fs.createReadStream)) {
52
52
  throw new Error("File path uploads are not supported in this environment.");
53
53
  }
54
54
  const data = fs.createReadStream(file.path);
@@ -89,9 +89,10 @@ function isFileLike(value) {
89
89
  }
90
90
  function tryGetFileSizeFromPath(path) {
91
91
  return __awaiter(this, void 0, void 0, function* () {
92
+ var _a;
92
93
  try {
93
94
  const fs = yield import("fs");
94
- if (!fs || !fs.promises || !fs.promises.stat) {
95
+ if (!((_a = fs === null || fs === void 0 ? void 0 : fs.promises) === null || _a === void 0 ? void 0 : _a.stat)) {
95
96
  return undefined;
96
97
  }
97
98
  const fileStat = yield fs.promises.stat(path);
@@ -3,10 +3,12 @@ export declare class BrevoError extends Error {
3
3
  readonly statusCode?: number;
4
4
  readonly body?: unknown;
5
5
  readonly rawResponse?: core.RawResponse;
6
- constructor({ message, statusCode, body, rawResponse, }: {
6
+ readonly cause?: unknown;
7
+ constructor({ message, statusCode, body, rawResponse, cause, }: {
7
8
  message?: string;
8
9
  statusCode?: number;
9
10
  body?: unknown;
10
11
  rawResponse?: core.RawResponse;
12
+ cause?: unknown;
11
13
  });
12
14
  }
@@ -1,7 +1,7 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
2
  import { toJson } from "../core/json.mjs";
3
3
  export class BrevoError extends Error {
4
- constructor({ message, statusCode, body, rawResponse, }) {
4
+ constructor({ message, statusCode, body, rawResponse, cause, }) {
5
5
  super(buildMessage({ message, statusCode, body }));
6
6
  Object.setPrototypeOf(this, new.target.prototype);
7
7
  if (Error.captureStackTrace) {
@@ -11,6 +11,9 @@ export class BrevoError extends Error {
11
11
  this.statusCode = statusCode;
12
12
  this.body = body;
13
13
  this.rawResponse = rawResponse;
14
+ if (cause != null) {
15
+ this.cause = cause;
16
+ }
14
17
  }
15
18
  }
16
19
  function buildMessage({ message, statusCode, body, }) {
@@ -1,3 +1,6 @@
1
1
  export declare class BrevoTimeoutError extends Error {
2
- constructor(message: string);
2
+ readonly cause?: unknown;
3
+ constructor(message: string, opts?: {
4
+ cause?: unknown;
5
+ });
3
6
  }
@@ -1,11 +1,14 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
2
  export class BrevoTimeoutError extends Error {
3
- constructor(message) {
3
+ constructor(message, opts) {
4
4
  super(message);
5
5
  Object.setPrototypeOf(this, new.target.prototype);
6
6
  if (Error.captureStackTrace) {
7
7
  Error.captureStackTrace(this, this.constructor);
8
8
  }
9
9
  this.name = this.constructor.name;
10
+ if ((opts === null || opts === void 0 ? void 0 : opts.cause) != null) {
11
+ this.cause = opts.cause;
12
+ }
10
13
  }
11
14
  }
@@ -14,11 +14,14 @@ export function handleNonStatusCodeError(error, rawResponse, method, path) {
14
14
  rawResponse: rawResponse,
15
15
  });
16
16
  case "timeout":
17
- throw new errors.BrevoTimeoutError(`Timeout exceeded when calling ${method} ${path}.`);
17
+ throw new errors.BrevoTimeoutError(`Timeout exceeded when calling ${method} ${path}.`, {
18
+ cause: error.cause,
19
+ });
18
20
  case "unknown":
19
21
  throw new errors.BrevoError({
20
22
  message: error.errorMessage,
21
23
  rawResponse: rawResponse,
24
+ cause: error.cause,
22
25
  });
23
26
  default:
24
27
  throw new errors.BrevoError({
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "5.0.1";
1
+ export declare const SDK_VERSION = "5.0.4";
@@ -1 +1 @@
1
- export const SDK_VERSION = "5.0.1";
1
+ export const SDK_VERSION = "5.0.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getbrevo/brevo",
3
- "version": "5.0.1",
3
+ "version": "5.0.4",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -398,13 +398,13 @@
398
398
  },
399
399
  "dependencies": {},
400
400
  "devDependencies": {
401
- "webpack": "^5.97.1",
402
- "ts-loader": "^9.5.1",
403
- "vitest": "^3.2.4",
401
+ "webpack": "^5.105.4",
402
+ "ts-loader": "^9.5.4",
403
+ "vitest": "^4.1.1",
404
404
  "msw": "2.11.2",
405
405
  "@types/node": "^18.19.70",
406
- "typescript": "~5.7.2",
407
- "@biomejs/biome": "2.4.3"
406
+ "typescript": "~5.9.3",
407
+ "@biomejs/biome": "2.4.10"
408
408
  },
409
409
  "browser": {
410
410
  "fs": false,
@@ -413,7 +413,7 @@
413
413
  "stream": false,
414
414
  "crypto": false
415
415
  },
416
- "packageManager": "pnpm@10.20.0",
416
+ "packageManager": "pnpm@10.33.0",
417
417
  "engines": {
418
418
  "node": ">=18.0.0"
419
419
  },
package/reference.md CHANGED
@@ -4637,7 +4637,7 @@ await client.contacts.getContacts();
4637
4637
  </dl>
4638
4638
  </details>
4639
4639
 
4640
- <details><summary><code>client.contacts.<a href="/src/api/resources/contacts/client/Client.ts">createContact</a>({ ...params }) -> Brevo.CreateContactResponse</code></summary>
4640
+ <details><summary><code>client.contacts.<a href="/src/api/resources/contacts/client/Client.ts">createContact</a>({ ...params }) -> Brevo.CreateContactResponse | undefined</code></summary>
4641
4641
  <dl>
4642
4642
  <dd>
4643
4643
 
@@ -6108,7 +6108,7 @@ await client.contacts.getContactInfo({
6108
6108
  <dd>
6109
6109
 
6110
6110
  <Note>Follow this format when passing a "SMS" phone number as an attribute.
6111
- Accepted Number Formats 91xxxxxxxxxx +91xxxxxxxxxx 0091xxxxxxxxxx</Note>
6111
+ Accepted Number Formats 91xxxxxxxxxx +91xxxxxxxxxx 0091xxxxxxxxxx <br><br> If a blocklisted contact's email address is updated, it is going to remove that blocklisting from the contact and they will be resubscribed.</Note>
6112
6112
  There are 2 ways to update a contact <br><br> Option 1- https://api.brevo.com/v3/contacts/{identifier} <br><br> Option 2- https://api.brevo.com/v3/contacts/{identifier}?identifierType={} <br> <br> Option 1 only works if identifierType is email_id (for EMAIL) or contact_id (for ID of the contact),where you can directly pass the value of EMAIL and ID of the contact. <br><br> Option 2 works for all identifierType, use email_id for EMAIL attribute, contact_id for ID of the contact, ext_id for EXT_ID attribute, phone_id for SMS attribute, whatsapp_id for WHATSAPP attribute, landline_number_id for LANDLINE attribute
6113
6113
  </dd>
6114
6114
  </dl>
@@ -6915,7 +6915,7 @@ await client.ecommerce.getCategories();
6915
6915
  </dl>
6916
6916
  </details>
6917
6917
 
6918
- <details><summary><code>client.ecommerce.<a href="/src/api/resources/ecommerce/client/Client.ts">createUpdateCategory</a>({ ...params }) -> Brevo.CreateUpdateCategoryResponse</code></summary>
6918
+ <details><summary><code>client.ecommerce.<a href="/src/api/resources/ecommerce/client/Client.ts">createUpdateCategory</a>({ ...params }) -> Brevo.CreateUpdateCategoryResponse | undefined</code></summary>
6919
6919
  <dl>
6920
6920
  <dd>
6921
6921
 
@@ -7633,7 +7633,7 @@ await client.ecommerce.getProducts();
7633
7633
  </dl>
7634
7634
  </details>
7635
7635
 
7636
- <details><summary><code>client.ecommerce.<a href="/src/api/resources/ecommerce/client/Client.ts">createUpdateProduct</a>({ ...params }) -> Brevo.CreateUpdateProductResponse</code></summary>
7636
+ <details><summary><code>client.ecommerce.<a href="/src/api/resources/ecommerce/client/Client.ts">createUpdateProduct</a>({ ...params }) -> Brevo.CreateUpdateProductResponse | undefined</code></summary>
7637
7637
  <dl>
7638
7638
  <dd>
7639
7639
 
@@ -8258,6 +8258,73 @@ await client.payments.deletePaymentRequest({
8258
8258
  </details>
8259
8259
 
8260
8260
  ## Event
8261
+ <details><summary><code>client.event.<a href="/src/api/resources/event/client/Client.ts">getEvents</a>({ ...params }) -> Brevo.GetEventsList</code></summary>
8262
+ <dl>
8263
+ <dd>
8264
+
8265
+ #### 📝 Description
8266
+
8267
+ <dl>
8268
+ <dd>
8269
+
8270
+ <dl>
8271
+ <dd>
8272
+
8273
+ <Note>
8274
+ This endpoint currently only supports custom events.
8275
+ </Note>
8276
+
8277
+ Retrieve a list of events filtered by various criteria.
8278
+ </dd>
8279
+ </dl>
8280
+ </dd>
8281
+ </dl>
8282
+
8283
+ #### 🔌 Usage
8284
+
8285
+ <dl>
8286
+ <dd>
8287
+
8288
+ <dl>
8289
+ <dd>
8290
+
8291
+ ```typescript
8292
+ await client.event.getEvents();
8293
+
8294
+ ```
8295
+ </dd>
8296
+ </dl>
8297
+ </dd>
8298
+ </dl>
8299
+
8300
+ #### ⚙️ Parameters
8301
+
8302
+ <dl>
8303
+ <dd>
8304
+
8305
+ <dl>
8306
+ <dd>
8307
+
8308
+ **request:** `Brevo.GetEventsRequest`
8309
+
8310
+ </dd>
8311
+ </dl>
8312
+
8313
+ <dl>
8314
+ <dd>
8315
+
8316
+ **requestOptions:** `EventClient.RequestOptions`
8317
+
8318
+ </dd>
8319
+ </dl>
8320
+ </dd>
8321
+ </dl>
8322
+
8323
+
8324
+ </dd>
8325
+ </dl>
8326
+ </details>
8327
+
8261
8328
  <details><summary><code>client.event.<a href="/src/api/resources/event/client/Client.ts">createEvent</a>({ ...params }) -> void</code></summary>
8262
8329
  <dl>
8263
8330
  <dd>
@@ -8324,7 +8391,7 @@ await client.event.createEvent({
8324
8391
  </dl>
8325
8392
  </details>
8326
8393
 
8327
- <details><summary><code>client.event.<a href="/src/api/resources/event/client/Client.ts">createBatchEvents</a>({ ...params }) -> void</code></summary>
8394
+ <details><summary><code>client.event.<a href="/src/api/resources/event/client/Client.ts">createBatchEvents</a>({ ...params }) -> Brevo.BatchAcceptedResponse</code></summary>
8328
8395
  <dl>
8329
8396
  <dd>
8330
8397