@zyphr-dev/node-sdk 0.1.37 → 0.1.39
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 +39 -0
- package/dist/index.cjs +762 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +720 -59
- package/dist/index.d.ts +720 -59
- package/dist/index.js +726 -47
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
- package/src/.openapi-generator/FILES +7 -0
- package/src/clientAuth.ts +182 -0
- package/src/errors.ts +29 -16
- package/src/index.ts +4 -1
- package/src/src/apis/AuthOAuthApi.ts +27 -24
- package/src/src/apis/AuthRegistrationApi.ts +134 -4
- package/src/src/apis/AuthUserDirectoryApi.ts +596 -0
- package/src/src/apis/AuthUserProfileApi.ts +0 -62
- package/src/src/apis/index.ts +1 -0
- package/src/src/models/InviteEndUserRequest.ts +110 -0
- package/src/src/models/OAuthProviderName.ts +56 -0
- package/src/src/models/SetEndUserClaimsRequest.ts +65 -0
- package/src/src/models/SignInAnonymouslyRequest.ts +16 -0
- package/src/src/models/SignInWithGameCenterRequest.ts +111 -0
- package/src/src/models/SignInWithGooglePlayGamesRequest.ts +66 -0
- package/src/src/models/UpdateEndUserByApplicationRequest.ts +97 -0
- package/src/src/models/index.ts +6 -0
package/README.md
CHANGED
|
@@ -535,6 +535,45 @@ All error classes extend `ZyphrError`, which extends `Error`:
|
|
|
535
535
|
| `limitBytes` | `number \| undefined` | Server-enforced body cap (`ZyphrPayloadTooLargeError` only) |
|
|
536
536
|
| `receivedBytes` | `number \| undefined` | Size of the rejected body (`ZyphrPayloadTooLargeError` only) |
|
|
537
537
|
|
|
538
|
+
### Branch on `error.code`, not `error.message`
|
|
539
|
+
|
|
540
|
+
`error.code` carries the API's stable, machine-readable code — branch on it
|
|
541
|
+
instead of matching `message` text (which is display copy and may change).
|
|
542
|
+
The code is the exact value from the API response body (e.g. `account_frozen`,
|
|
543
|
+
`account_throttled`, `otp_invalid`, `email_not_found`), not a generic
|
|
544
|
+
per-status placeholder:
|
|
545
|
+
|
|
546
|
+
> **Behavior change (≥ 0.1.30):** `error.code` now reflects the API's actual
|
|
547
|
+
> machine-readable code for every status. Previously the SDK overwrote it with a
|
|
548
|
+
> generic per-status placeholder (`authentication_error`, `rate_limit_exceeded`,
|
|
549
|
+
> `validation_error`, …). If you were matching those generic strings, switch to
|
|
550
|
+
> `instanceof` for the error *class* and use `error.code` for the specific
|
|
551
|
+
> condition. `error.status` and the error classes are unchanged.
|
|
552
|
+
|
|
553
|
+
```ts
|
|
554
|
+
try {
|
|
555
|
+
await zyphr.emails.sendEmail({ /* ... */ });
|
|
556
|
+
} catch (error) {
|
|
557
|
+
if (error instanceof ZyphrError) {
|
|
558
|
+
switch (error.code) {
|
|
559
|
+
case 'account_frozen': // 403 — sending paused for reputation; see the dashboard
|
|
560
|
+
case 'account_throttled': // 429 — sending throttled; back off and retry
|
|
561
|
+
// ...handle the account's sending state
|
|
562
|
+
break;
|
|
563
|
+
case 'otp_invalid': // 400 — wrong/expired OTP
|
|
564
|
+
case 'email_not_found': // 404 — no account for this email (registration fallback)
|
|
565
|
+
// ...
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
The full catalog of codes per endpoint is at
|
|
573
|
+
[zyphr.dev/docs/resources/error-codes](https://zyphr.dev/docs/resources/error-codes).
|
|
574
|
+
Reading `error.code` also flows through the Zyphr MCP server, so agents get the
|
|
575
|
+
same actionable code.
|
|
576
|
+
|
|
538
577
|
## Bundle
|
|
539
578
|
|
|
540
579
|
Dual-format build — works with both ESM and CommonJS:
|