@zyphr-dev/node-sdk 0.1.25 → 0.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyphr-dev/node-sdk",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Official Zyphr SDK for Node.js, React, and React Native",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -194,6 +194,9 @@ src/models/PaginationMeta.ts
194
194
  src/models/PasswordRequirements.ts
195
195
  src/models/PasswordRequirementsResponse.ts
196
196
  src/models/PasswordRequirementsResponseData.ts
197
+ src/models/PayloadTooLargeError.ts
198
+ src/models/PayloadTooLargeErrorError.ts
199
+ src/models/PayloadTooLargeErrorErrorDetails.ts
197
200
  src/models/PhoneAuthAvailabilityResponse.ts
198
201
  src/models/PhoneAuthAvailabilityResponseData.ts
199
202
  src/models/PhoneLoginVerifyRequest.ts
package/src/errors.ts CHANGED
@@ -82,6 +82,35 @@ export class ZyphrNotFoundError extends ZyphrError {
82
82
  }
83
83
  }
84
84
 
85
+ /**
86
+ * Thrown when the API returns a 413 payload-too-large error because the
87
+ * request body exceeds the maximum allowed size (currently 10 MB).
88
+ *
89
+ * Use `limitBytes` to read the server-side cap and `receivedBytes` to read
90
+ * the size of the rejected payload, both surfaced from `details` so callers
91
+ * don't have to reach into the untyped error body.
92
+ *
93
+ * @see https://zyphr.dev/resources/api-limits
94
+ */
95
+ export class ZyphrPayloadTooLargeError extends ZyphrError {
96
+ constructor(message: string, details?: Record<string, unknown>, requestId?: string) {
97
+ super({ message, status: 413, code: 'payload_too_large', details, requestId });
98
+ this.name = 'ZyphrPayloadTooLargeError';
99
+ }
100
+
101
+ /** Maximum allowed request body size in bytes (server-enforced). */
102
+ get limitBytes(): number | undefined {
103
+ const value = this.details?.limit_bytes;
104
+ return typeof value === 'number' ? value : undefined;
105
+ }
106
+
107
+ /** Size of the rejected request body in bytes, as measured by the server. */
108
+ get receivedBytes(): number | undefined {
109
+ const value = this.details?.received_bytes;
110
+ return typeof value === 'number' ? value : undefined;
111
+ }
112
+ }
113
+
85
114
  /**
86
115
  * Thrown when a Zyphr webhook signature fails verification.
87
116
  *
@@ -129,6 +158,8 @@ export async function parseErrorResponse(response: Response): Promise<ZyphrError
129
158
  return new ZyphrAuthenticationError(message);
130
159
  case 404:
131
160
  return new ZyphrNotFoundError(message);
161
+ case 413:
162
+ return new ZyphrPayloadTooLargeError(message, details, requestId);
132
163
  case 429: {
133
164
  const retryAfterHeader = response.headers.get('Retry-After');
134
165
  const retryAfter = retryAfterHeader ? parseInt(retryAfterHeader, 10) : undefined;
@@ -28,6 +28,7 @@ import type {
28
28
  AuthEmailType,
29
29
  BulkUpsertAuthEmailTemplatesRequest,
30
30
  BulkUpsertAuthEmailTemplatesResponse,
31
+ PayloadTooLargeError,
31
32
  UpsertAuthEmailTemplateRequest,
32
33
  } from '../models/index';
33
34
  import {
@@ -57,6 +58,8 @@ import {
57
58
  BulkUpsertAuthEmailTemplatesRequestToJSON,
58
59
  BulkUpsertAuthEmailTemplatesResponseFromJSON,
59
60
  BulkUpsertAuthEmailTemplatesResponseToJSON,
61
+ PayloadTooLargeErrorFromJSON,
62
+ PayloadTooLargeErrorToJSON,
60
63
  UpsertAuthEmailTemplateRequestFromJSON,
61
64
  UpsertAuthEmailTemplateRequestToJSON,
62
65
  } from '../models/index';
@@ -20,6 +20,7 @@ import type {
20
20
  EmailListResponse,
21
21
  EmailResponse,
22
22
  EmailTrackingResponse,
23
+ PayloadTooLargeError,
23
24
  SendBatchEmailRequest,
24
25
  SendBatchEmailResponse,
25
26
  SendEmailRequest,
@@ -36,6 +37,8 @@ import {
36
37
  EmailResponseToJSON,
37
38
  EmailTrackingResponseFromJSON,
38
39
  EmailTrackingResponseToJSON,
40
+ PayloadTooLargeErrorFromJSON,
41
+ PayloadTooLargeErrorToJSON,
39
42
  SendBatchEmailRequestFromJSON,
40
43
  SendBatchEmailRequestToJSON,
41
44
  SendBatchEmailResponseFromJSON,
@@ -24,6 +24,7 @@ import type {
24
24
  MarkAllReadResponse,
25
25
  MarkAllSubscriberNotificationsReadRequest,
26
26
  MarkInboxReadRequest,
27
+ PayloadTooLargeError,
27
28
  SendBatchInAppRequest,
28
29
  SendBatchInAppResponse,
29
30
  SendInAppRequest,
@@ -50,6 +51,8 @@ import {
50
51
  MarkAllSubscriberNotificationsReadRequestToJSON,
51
52
  MarkInboxReadRequestFromJSON,
52
53
  MarkInboxReadRequestToJSON,
54
+ PayloadTooLargeErrorFromJSON,
55
+ PayloadTooLargeErrorToJSON,
53
56
  SendBatchInAppRequestFromJSON,
54
57
  SendBatchInAppRequestToJSON,
55
58
  SendBatchInAppResponseFromJSON,
@@ -17,6 +17,7 @@ import * as runtime from '../runtime';
17
17
  import type {
18
18
  ApiError,
19
19
  DevicePushTopicListResponse,
20
+ PayloadTooLargeError,
20
21
  PushDetailResponse,
21
22
  PushListResponse,
22
23
  PushStatsResponse,
@@ -34,6 +35,8 @@ import {
34
35
  ApiErrorToJSON,
35
36
  DevicePushTopicListResponseFromJSON,
36
37
  DevicePushTopicListResponseToJSON,
38
+ PayloadTooLargeErrorFromJSON,
39
+ PayloadTooLargeErrorToJSON,
37
40
  PushDetailResponseFromJSON,
38
41
  PushDetailResponseToJSON,
39
42
  PushListResponseFromJSON,
@@ -16,6 +16,7 @@
16
16
  import * as runtime from '../runtime';
17
17
  import type {
18
18
  ApiError,
19
+ PayloadTooLargeError,
19
20
  SendBatchSmsRequest,
20
21
  SendBatchSmsResponse,
21
22
  SendSmsRequest,
@@ -32,6 +33,8 @@ import type {
32
33
  import {
33
34
  ApiErrorFromJSON,
34
35
  ApiErrorToJSON,
36
+ PayloadTooLargeErrorFromJSON,
37
+ PayloadTooLargeErrorToJSON,
35
38
  SendBatchSmsRequestFromJSON,
36
39
  SendBatchSmsRequestToJSON,
37
40
  SendBatchSmsResponseFromJSON,
@@ -18,6 +18,7 @@ import type {
18
18
  ApiError,
19
19
  CreateTemplateRequest,
20
20
  DeleteResult,
21
+ PayloadTooLargeError,
21
22
  RenderTemplateRequest,
22
23
  TemplateListResponse,
23
24
  TemplateRenderResponse,
@@ -31,6 +32,8 @@ import {
31
32
  CreateTemplateRequestToJSON,
32
33
  DeleteResultFromJSON,
33
34
  DeleteResultToJSON,
35
+ PayloadTooLargeErrorFromJSON,
36
+ PayloadTooLargeErrorToJSON,
34
37
  RenderTemplateRequestFromJSON,
35
38
  RenderTemplateRequestToJSON,
36
39
  TemplateListResponseFromJSON,
@@ -0,0 +1,89 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Zyphr API
5
+ * Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ * Contact: support@zyphr.dev
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ import type { PayloadTooLargeErrorError } from './PayloadTooLargeErrorError';
17
+ import {
18
+ PayloadTooLargeErrorErrorFromJSON,
19
+ PayloadTooLargeErrorErrorFromJSONTyped,
20
+ PayloadTooLargeErrorErrorToJSON,
21
+ PayloadTooLargeErrorErrorToJSONTyped,
22
+ } from './PayloadTooLargeErrorError';
23
+ import type { RequestMeta } from './RequestMeta';
24
+ import {
25
+ RequestMetaFromJSON,
26
+ RequestMetaFromJSONTyped,
27
+ RequestMetaToJSON,
28
+ RequestMetaToJSONTyped,
29
+ } from './RequestMeta';
30
+
31
+ /**
32
+ *
33
+ * @export
34
+ * @interface PayloadTooLargeError
35
+ */
36
+ export interface PayloadTooLargeError {
37
+ /**
38
+ *
39
+ * @type {PayloadTooLargeErrorError}
40
+ * @memberof PayloadTooLargeError
41
+ */
42
+ error: PayloadTooLargeErrorError;
43
+ /**
44
+ *
45
+ * @type {RequestMeta}
46
+ * @memberof PayloadTooLargeError
47
+ */
48
+ meta?: RequestMeta;
49
+ }
50
+
51
+ /**
52
+ * Check if a given object implements the PayloadTooLargeError interface.
53
+ */
54
+ export function instanceOfPayloadTooLargeError(value: object): value is PayloadTooLargeError {
55
+ if (!('error' in value) || value['error'] === undefined) return false;
56
+ return true;
57
+ }
58
+
59
+ export function PayloadTooLargeErrorFromJSON(json: any): PayloadTooLargeError {
60
+ return PayloadTooLargeErrorFromJSONTyped(json, false);
61
+ }
62
+
63
+ export function PayloadTooLargeErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): PayloadTooLargeError {
64
+ if (json == null) {
65
+ return json;
66
+ }
67
+ return {
68
+
69
+ 'error': PayloadTooLargeErrorErrorFromJSON(json['error']),
70
+ 'meta': json['meta'] == null ? undefined : RequestMetaFromJSON(json['meta']),
71
+ };
72
+ }
73
+
74
+ export function PayloadTooLargeErrorToJSON(json: any): PayloadTooLargeError {
75
+ return PayloadTooLargeErrorToJSONTyped(json, false);
76
+ }
77
+
78
+ export function PayloadTooLargeErrorToJSONTyped(value?: PayloadTooLargeError | null, ignoreDiscriminator: boolean = false): any {
79
+ if (value == null) {
80
+ return value;
81
+ }
82
+
83
+ return {
84
+
85
+ 'error': PayloadTooLargeErrorErrorToJSON(value['error']),
86
+ 'meta': RequestMetaToJSON(value['meta']),
87
+ };
88
+ }
89
+
@@ -0,0 +1,101 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Zyphr API
5
+ * Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ * Contact: support@zyphr.dev
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ import type { PayloadTooLargeErrorErrorDetails } from './PayloadTooLargeErrorErrorDetails';
17
+ import {
18
+ PayloadTooLargeErrorErrorDetailsFromJSON,
19
+ PayloadTooLargeErrorErrorDetailsFromJSONTyped,
20
+ PayloadTooLargeErrorErrorDetailsToJSON,
21
+ PayloadTooLargeErrorErrorDetailsToJSONTyped,
22
+ } from './PayloadTooLargeErrorErrorDetails';
23
+
24
+ /**
25
+ *
26
+ * @export
27
+ * @interface PayloadTooLargeErrorError
28
+ */
29
+ export interface PayloadTooLargeErrorError {
30
+ /**
31
+ *
32
+ * @type {string}
33
+ * @memberof PayloadTooLargeErrorError
34
+ */
35
+ code: PayloadTooLargeErrorErrorCodeEnum;
36
+ /**
37
+ *
38
+ * @type {string}
39
+ * @memberof PayloadTooLargeErrorError
40
+ */
41
+ message: string;
42
+ /**
43
+ *
44
+ * @type {PayloadTooLargeErrorErrorDetails}
45
+ * @memberof PayloadTooLargeErrorError
46
+ */
47
+ details?: PayloadTooLargeErrorErrorDetails;
48
+ }
49
+
50
+
51
+ /**
52
+ * @export
53
+ */
54
+ export const PayloadTooLargeErrorErrorCodeEnum = {
55
+ PAYLOAD_TOO_LARGE: 'payload_too_large'
56
+ } as const;
57
+ export type PayloadTooLargeErrorErrorCodeEnum = typeof PayloadTooLargeErrorErrorCodeEnum[keyof typeof PayloadTooLargeErrorErrorCodeEnum];
58
+
59
+
60
+ /**
61
+ * Check if a given object implements the PayloadTooLargeErrorError interface.
62
+ */
63
+ export function instanceOfPayloadTooLargeErrorError(value: object): value is PayloadTooLargeErrorError {
64
+ if (!('code' in value) || value['code'] === undefined) return false;
65
+ if (!('message' in value) || value['message'] === undefined) return false;
66
+ return true;
67
+ }
68
+
69
+ export function PayloadTooLargeErrorErrorFromJSON(json: any): PayloadTooLargeErrorError {
70
+ return PayloadTooLargeErrorErrorFromJSONTyped(json, false);
71
+ }
72
+
73
+ export function PayloadTooLargeErrorErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): PayloadTooLargeErrorError {
74
+ if (json == null) {
75
+ return json;
76
+ }
77
+ return {
78
+
79
+ 'code': json['code'],
80
+ 'message': json['message'],
81
+ 'details': json['details'] == null ? undefined : PayloadTooLargeErrorErrorDetailsFromJSON(json['details']),
82
+ };
83
+ }
84
+
85
+ export function PayloadTooLargeErrorErrorToJSON(json: any): PayloadTooLargeErrorError {
86
+ return PayloadTooLargeErrorErrorToJSONTyped(json, false);
87
+ }
88
+
89
+ export function PayloadTooLargeErrorErrorToJSONTyped(value?: PayloadTooLargeErrorError | null, ignoreDiscriminator: boolean = false): any {
90
+ if (value == null) {
91
+ return value;
92
+ }
93
+
94
+ return {
95
+
96
+ 'code': value['code'],
97
+ 'message': value['message'],
98
+ 'details': PayloadTooLargeErrorErrorDetailsToJSON(value['details']),
99
+ };
100
+ }
101
+
@@ -0,0 +1,73 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Zyphr API
5
+ * Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
6
+ *
7
+ * The version of the OpenAPI document: 1.0.0
8
+ * Contact: support@zyphr.dev
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ /**
17
+ *
18
+ * @export
19
+ * @interface PayloadTooLargeErrorErrorDetails
20
+ */
21
+ export interface PayloadTooLargeErrorErrorDetails {
22
+ /**
23
+ * Maximum allowed request body size in bytes.
24
+ * @type {number}
25
+ * @memberof PayloadTooLargeErrorErrorDetails
26
+ */
27
+ limitBytes?: number;
28
+ /**
29
+ * Size of the rejected request body in bytes.
30
+ * @type {number}
31
+ * @memberof PayloadTooLargeErrorErrorDetails
32
+ */
33
+ receivedBytes?: number;
34
+ }
35
+
36
+ /**
37
+ * Check if a given object implements the PayloadTooLargeErrorErrorDetails interface.
38
+ */
39
+ export function instanceOfPayloadTooLargeErrorErrorDetails(value: object): value is PayloadTooLargeErrorErrorDetails {
40
+ return true;
41
+ }
42
+
43
+ export function PayloadTooLargeErrorErrorDetailsFromJSON(json: any): PayloadTooLargeErrorErrorDetails {
44
+ return PayloadTooLargeErrorErrorDetailsFromJSONTyped(json, false);
45
+ }
46
+
47
+ export function PayloadTooLargeErrorErrorDetailsFromJSONTyped(json: any, ignoreDiscriminator: boolean): PayloadTooLargeErrorErrorDetails {
48
+ if (json == null) {
49
+ return json;
50
+ }
51
+ return {
52
+
53
+ 'limitBytes': json['limit_bytes'] == null ? undefined : json['limit_bytes'],
54
+ 'receivedBytes': json['received_bytes'] == null ? undefined : json['received_bytes'],
55
+ };
56
+ }
57
+
58
+ export function PayloadTooLargeErrorErrorDetailsToJSON(json: any): PayloadTooLargeErrorErrorDetails {
59
+ return PayloadTooLargeErrorErrorDetailsToJSONTyped(json, false);
60
+ }
61
+
62
+ export function PayloadTooLargeErrorErrorDetailsToJSONTyped(value?: PayloadTooLargeErrorErrorDetails | null, ignoreDiscriminator: boolean = false): any {
63
+ if (value == null) {
64
+ return value;
65
+ }
66
+
67
+ return {
68
+
69
+ 'limit_bytes': value['limitBytes'],
70
+ 'received_bytes': value['receivedBytes'],
71
+ };
72
+ }
73
+
@@ -160,6 +160,9 @@ export * from './PaginationMeta';
160
160
  export * from './PasswordRequirements';
161
161
  export * from './PasswordRequirementsResponse';
162
162
  export * from './PasswordRequirementsResponseData';
163
+ export * from './PayloadTooLargeError';
164
+ export * from './PayloadTooLargeErrorError';
165
+ export * from './PayloadTooLargeErrorErrorDetails';
163
166
  export * from './PhoneAuthAvailabilityResponse';
164
167
  export * from './PhoneAuthAvailabilityResponseData';
165
168
  export * from './PhoneLoginVerifyRequest';